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
p03006
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <utility> #include <vector> #define ll long long #define MP make_pair #define PII pair<int, int> #define PLL pair<ll, ll> #define PLI pair<ll, int> #define PIL pair<int, ll> #define F first #define S second #define SHN 1e9 #define LSHN 1e18 using namespace std; int n; PII a[55]; bool visit[55]; int res = 1e9; void dfs(int cur, int x, int y) { visit[cur] = 1; for (int i = 0; i < n; i++) { if (visit[i]) continue; if (a[i].F - a[cur].F == x && a[i].S - a[cur].S == y) { dfs(i, x, y); return; } } } int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i].F >> a[i].S; if (n == 1) { cout << "1"; return 0; } sort(a, a + n); for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { fill(visit, visit + n, 0); int x = a[j].F - a[i].F; int y = a[j].S - a[i].S; int t = 0; for (int k = 0; k < n; k++) { if (visit[k]) continue; dfs(k, x, y); t++; } res = min(res, t); } } cout << res; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <utility> #include <vector> #define ll long long #define MP make_pair #define PII pair<int, int> #define PLL pair<ll, ll> #define PLI pair<ll, int> #define PIL pair<int, ll> #define F first #define S second #define SHN 1e9 #define LSHN 1e18 using namespace std; int n; PII a[55]; bool visit[55]; int res = 1e9; void dfs(int cur, int x, int y) { visit[cur] = 1; for (int i = 0; i < n; i++) { if (visit[i]) continue; if (a[i].F - a[cur].F == x && a[i].S - a[cur].S == y) { dfs(i, x, y); return; } } } int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i].F >> a[i].S; if (n == 1) { cout << "1"; return 0; } sort(a, a + n); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { fill(visit, visit + n, 0); int x = a[j].F - a[i].F; int y = a[j].S - a[i].S; int t = 0; for (int k = 0; k < n; k++) { if (visit[k]) continue; dfs(k, x, y); t++; } res = min(res, t); } } cout << res; return 0; }
[ "identifier.replace.add", "literal.replace.remove", "control_flow.loop.for.initializer.change", "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
820,497
820,498
u152424169
cpp
p03006
#include <bits/stdc++.h> using namespace std; using LL = long long; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } // std::vector Declaration template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } // std::vector Initialization template <typename T> void fill_all(T &arr, const T &v) { arr = v; } template <typename T, typename U> void fill_all(T &arr, const U &v) { for (auto &i : arr) fill_all(i, v); } // std::vector Debug template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "["; bool a = 1; for (auto e : v) { os << (a ? "" : " "); os << e; a = 0; } os << "]"; return os; } // std::pair Debug template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << " " << p.second << ")"; return os; } // std::set Debug template <typename T> ostream &operator<<(ostream &os, const set<T> &st) { os << "{"; bool a = 1; for (auto e : st) { os << (a ? "" : " "); os << e; a = 0; } os << "}"; return os; } // std::multiset Debug template <typename T> ostream &operator<<(ostream &os, const multiset<T> &st) { os << "{"; bool a = 1; for (auto e : st) { os << (a ? "" : " "); os << e; a = 0; } os << "}"; return os; } // std::map Debug template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp) { os << "{"; bool a = 1; for (auto e : mp) { os << (a ? "" : " "); os << e.first << ":" << e.second; a = 0; } os << "}"; return os; } // std::tuple Debug template <int N, class Tuple> void out(ostream &os, const Tuple &t) {} template <int N, class Tuple, class H, class... Ts> void out(ostream &os, const Tuple &t) { if (N) os << " "; os << get<N>(t); out<N + 1, Tuple, Ts...>(os, t); } template <class... Ts> ostream &operator<<(ostream &os, const tuple<Ts...> &t) { os << "("; out<0, tuple<Ts...>, Ts...>(os, t); os << ")"; return os; } // Debug #define DUMP(x) cout << #x << " = " << (x) << endl struct edge { int to, cost; }; ostream &operator<<(ostream &os, const edge &e) { os << "(" << e.to << ", " << e.cost << ")"; return os; } const LL LINF = 1LL << 60; const int IINF = 1 << 30; const LL MOD = 1e9 + 7; int main() { int N; cin >> N; vector<LL> x(N), y(N); for (int i = 0; i < N; ++i) { cin >> x[i] >> y[i]; } map<pair<LL, LL>, int> cnt; for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { if (i == j) continue; ++cnt[make_pair(x[i] - x[j], y[i] - y[j])]; } } DUMP(cnt); int ans = N; for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { if (i == j) continue; chmin(ans, N - cnt[make_pair(x[i] - x[j], y[i] - y[j])]); } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using LL = long long; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } // std::vector Declaration template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } // std::vector Initialization template <typename T> void fill_all(T &arr, const T &v) { arr = v; } template <typename T, typename U> void fill_all(T &arr, const U &v) { for (auto &i : arr) fill_all(i, v); } // std::vector Debug template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "["; bool a = 1; for (auto e : v) { os << (a ? "" : " "); os << e; a = 0; } os << "]"; return os; } // std::pair Debug template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << " " << p.second << ")"; return os; } // std::set Debug template <typename T> ostream &operator<<(ostream &os, const set<T> &st) { os << "{"; bool a = 1; for (auto e : st) { os << (a ? "" : " "); os << e; a = 0; } os << "}"; return os; } // std::multiset Debug template <typename T> ostream &operator<<(ostream &os, const multiset<T> &st) { os << "{"; bool a = 1; for (auto e : st) { os << (a ? "" : " "); os << e; a = 0; } os << "}"; return os; } // std::map Debug template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp) { os << "{"; bool a = 1; for (auto e : mp) { os << (a ? "" : " "); os << e.first << ":" << e.second; a = 0; } os << "}"; return os; } // std::tuple Debug template <int N, class Tuple> void out(ostream &os, const Tuple &t) {} template <int N, class Tuple, class H, class... Ts> void out(ostream &os, const Tuple &t) { if (N) os << " "; os << get<N>(t); out<N + 1, Tuple, Ts...>(os, t); } template <class... Ts> ostream &operator<<(ostream &os, const tuple<Ts...> &t) { os << "("; out<0, tuple<Ts...>, Ts...>(os, t); os << ")"; return os; } // Debug #define DUMP(x) cerr << #x << " = " << (x) << endl struct edge { int to, cost; }; ostream &operator<<(ostream &os, const edge &e) { os << "(" << e.to << ", " << e.cost << ")"; return os; } const LL LINF = 1LL << 60; const int IINF = 1 << 30; const LL MOD = 1e9 + 7; int main() { int N; cin >> N; vector<LL> x(N), y(N); for (int i = 0; i < N; ++i) { cin >> x[i] >> y[i]; } map<pair<LL, LL>, int> cnt; for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { if (i == j) continue; ++cnt[make_pair(x[i] - x[j], y[i] - y[j])]; } } int ans = N; for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { if (i == j) continue; chmin(ans, N - cnt[make_pair(x[i] - x[j], y[i] - y[j])]); } } cout << ans << endl; return 0; }
[ "preprocessor.define.value.change", "call.remove" ]
820,502
820,503
u960524878
cpp
p03006
#include "bits/stdc++.h" using namespace std; typedef long long ll; //#define int long long template <class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; } template <class T> 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 T> void printv(vector<T> v) { for (T t : v) { cout << t << " "; } cout << '\n'; } #define REP(i, n) for (int i = 0; i < (n); ++i) #define RREP(i, n) for (int i = (n); i >= 0; --i) #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 ALL(v) (v).begin(), (v).end() #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; typedef vector<int> vi; typedef vector<string> vs; typedef vector<vi> vvi; typedef pair<int, int> pii; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<pii> p; REP(i, N) { int x, y; cin >> x >> y; pii t = {x, y}; p.emplace_back(t); } int ans = N + 1; map<pii, int> m; REP(i, N) { int nx = p[i].first; int ny = p[i].second; REP(j, N) { if (i == j) continue; pii t = {abs(nx - p[j].first), abs(ny - p[j].second)}; m[t]++; } int max_num = 0; for (auto x : m) { max_num = max(max_num, x.second); // cout << i << ": "<< x.second << ": " << x.first.first << "," << // x.first.second << endl; } ans = min(ans, N - max_num + 2); } cout << ans << endl; return 0; }
#include "bits/stdc++.h" using namespace std; typedef long long ll; //#define int long long template <class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; } template <class T> 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 T> void printv(vector<T> v) { for (T t : v) { cout << t << " "; } cout << '\n'; } #define REP(i, n) for (int i = 0; i < (n); ++i) #define RREP(i, n) for (int i = (n); i >= 0; --i) #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 ALL(v) (v).begin(), (v).end() #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; typedef vector<int> vi; typedef vector<string> vs; typedef vector<vi> vvi; typedef pair<int, int> pii; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<pii> p; REP(i, N) { int x, y; cin >> x >> y; pii t = {x, y}; p.emplace_back(t); } int ans = N + 1; map<pii, int> m; REP(i, N) { int nx = p[i].first; int ny = p[i].second; REP(j, N) { if (i == j) continue; pii t = {(nx - p[j].first), (ny - p[j].second)}; m[t]++; } int max_num = 0; for (auto x : m) { max_num = max(max_num, x.second); // cout << i << ": "<< x.second << ": " << x.first.first << "," << // x.first.second << endl; } ans = min(ans, N - max_num); } cout << ans << endl; return 0; }
[ "expression.operation.binary.remove" ]
820,529
820,530
u299377613
cpp
p03006
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <regex> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <valarray> #include <vector> using namespace std; using ll = long long; const int INF = 1e9; const ll MOD = 1e9 + 7; int main() { int n; cin >> n; vector<pair<int, int>> v(n); for (auto &e : v) cin >> e.first >> e.second; sort(v.begin(), v.end()); map<pair<int, int>, int> mp; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (i == j) continue; mp[make_pair(v[i].first - v[j].first, v[i].second - v[j].second)]++; } } int cnt = 0; int p = 0, q = 0; for (auto e : mp) { if (cnt < e.second) { cnt = e.second; p = e.first.first, q = e.first.second; } } cout << cnt << endl; return 0; }
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <regex> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <valarray> #include <vector> using namespace std; using ll = long long; const int INF = 1e9; const ll MOD = 1e9 + 7; int main() { int n; cin >> n; vector<pair<int, int>> v(n); for (auto &e : v) cin >> e.first >> e.second; sort(v.begin(), v.end()); map<pair<int, int>, int> mp; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (i == j) continue; mp[make_pair(v[i].first - v[j].first, v[i].second - v[j].second)]++; } } int cnt = 0; int p = 0, q = 0; for (auto e : mp) { if (cnt < e.second) { cnt = e.second; p = e.first.first, q = e.first.second; } } cout << n - cnt << endl; return 0; }
[ "expression.operation.binary.add" ]
820,555
820,556
u054652697
cpp
p03006
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <stdio.h> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #define rep(i, a, n) for (ll i = (a); i < (n); ++i) #define urep(i, a, n) for (ll i = (a); i >= (n); --i) #define all(x) (x).begin(), (x).end() #define INF 1e18 const int mod = 1e9 + 7; typedef long long ll; using namespace std; ll dx[4] = {1, -1, 0, 0}; ll dy[4] = {0, 0, 1, -1}; ll N, M, X, Y, A, B, C, D, Q, K, R, W, H, P, L, G; ll ans; string S, T; ll y[101010]; ll a[101010]; ll k[101010]; ll b[101010]; ll d[101010]; ll t[101010]; ll p[101010]; ll n[101010]; ll l[101010]; ll r[101010]; ll v[101010]; ll s[101010]; ll x[101010]; ll gcd(ll a, ll b) { if (b == 0) return a; else return gcd(b, a % b); } struct Edge { ll to, cost; Edge(ll to, ll cost) : to(to), cost(cost) {} }; typedef vector<vector<Edge>> AdjList; AdjList graph; vector<ll> dist; struct UnionFind { vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 vector<ll> size; UnionFind(ll N) : par(N), size(N) { //最初は全てが根であるとして初期化 for (ll i = 0; i < N; i++) par[i] = i; for (ll i = 0; i < N; i++) size[i] = 1; } ll root(ll x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (par[x] == x) return x; return par[x] = root(par[x]); } ll GetSize(ll x) { return size[root(x)]; } void unite(ll x, ll y) { // xとyの木を併合 ll rx = root(x); // xの根をrx ll ry = root(y); // yの根をry if (rx == ry) return; // xとyの根が同じ(=同じ木にある)時はそのまま par[rx] = ry; // xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける size[ry] += size[rx]; } bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す ll rx = root(x); ll ry = root(y); return rx == ry; } }; int main() { cin >> N; pair<ll, ll> pos[1010]; rep(i, 0, N) { cin >> pos[i].first >> pos[i].second; } sort(pos, pos + N); map<pair<ll, ll>, ll> cost; rep(i, 0, N) { rep(j, i + 1, N) { cost[make_pair(pos[i].first - pos[j].first, pos[i].first - pos[j].second)]++; } } ans = 0; for (auto itr = cost.begin(); itr != cost.end(); ++itr) { ans = max(ans, itr->second); } cout << ans << endl; return 0; }
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <stdio.h> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #define rep(i, a, n) for (ll i = (a); i < (n); ++i) #define urep(i, a, n) for (ll i = (a); i >= (n); --i) #define all(x) (x).begin(), (x).end() #define INF 1e18 const int mod = 1e9 + 7; typedef long long ll; using namespace std; ll dx[4] = {1, -1, 0, 0}; ll dy[4] = {0, 0, 1, -1}; ll N, M, X, Y, A, B, C, D, Q, K, R, W, H, P, L, G; ll ans; string S, T; ll y[101010]; ll a[101010]; ll k[101010]; ll b[101010]; ll d[101010]; ll t[101010]; ll p[101010]; ll n[101010]; ll l[101010]; ll r[101010]; ll v[101010]; ll s[101010]; ll x[101010]; ll gcd(ll a, ll b) { if (b == 0) return a; else return gcd(b, a % b); } struct Edge { ll to, cost; Edge(ll to, ll cost) : to(to), cost(cost) {} }; typedef vector<vector<Edge>> AdjList; AdjList graph; vector<ll> dist; struct UnionFind { vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 vector<ll> size; UnionFind(ll N) : par(N), size(N) { //最初は全てが根であるとして初期化 for (ll i = 0; i < N; i++) par[i] = i; for (ll i = 0; i < N; i++) size[i] = 1; } ll root(ll x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (par[x] == x) return x; return par[x] = root(par[x]); } ll GetSize(ll x) { return size[root(x)]; } void unite(ll x, ll y) { // xとyの木を併合 ll rx = root(x); // xの根をrx ll ry = root(y); // yの根をry if (rx == ry) return; // xとyの根が同じ(=同じ木にある)時はそのまま par[rx] = ry; // xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける size[ry] += size[rx]; } bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す ll rx = root(x); ll ry = root(y); return rx == ry; } }; int main() { cin >> N; pair<ll, ll> pos[1010]; rep(i, 0, N) { cin >> pos[i].first >> pos[i].second; } sort(pos, pos + N); map<pair<ll, ll>, ll> cost; rep(i, 0, N) { rep(j, i + 1, N) { cost[make_pair(pos[i].first - pos[j].first, pos[i].second - pos[j].second)]++; } } ans = 0; for (auto itr = cost.begin(); itr != cost.end(); ++itr) { ans = max(ans, itr->second); // cerr<< itr->first.first <<" " << itr->first.second<<" // "<<itr->second<<endl; } cout << N - ans << endl; return 0; }
[ "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
820,611
820,612
u406225550
cpp
p03006
#include <bits/stdc++.h> using namespace std; using LL = long long; #define FOR(i, l, r) for (int i = (l); i <= (r); ++i) #define REP(i, n) FOR(i, 0, (n)-1) #ifdef DEBUG template <class A, class B> ostream &operator<<(ostream &out, const pair<A, B> &p) { return out << '(' << p.first << ", " << p.second << ')'; } template <class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) { out << '{'; for (auto it = x.begin(); it != x.end(); ++it) out << *it << (it == --x.end() ? "" : ", "); return out << '}'; } void dump() {} template <class T, class... Args> void dump(T &&x, Args... args) { cerr << x << "; "; dump(args...); } const int seed = 1; struct Nl { ~Nl() { cerr << '\n'; } }; #define debug(x...) cerr << (#x != "" ? #x ": " : ""), dump(x), Nl(), cerr #else const int seed = chrono::system_clock::now().time_since_epoch().count(); #define debug(...) 0 && cerr #endif mt19937_64 rng(seed); int rd(int l, int r) { return uniform_int_distribution<int>(l, r)(rng); } template <class T> int size(T a) { return a.size(); } struct FindUnion { vector<int> rep; bool sameSet(int a, int b) { return find(a) == find(b); } int size(int x) { return -rep[find(x)]; } int find(int x) { return rep[x] < 0 ? x : rep[x] = find(rep[x]); } bool join(int a, int b) { a = find(a), b = find(b); if (a == b) return false; if (-rep[a] < -rep[b]) swap(a, b); rep[a] += rep[b]; rep[b] = a; return true; } FindUnion(int n) : rep(n, -1) {} }; #define ST first #define ND second LL absolute(LL a) { if (a < 0) return -a; return a; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<pair<LL, LL>> pts(n); for (auto &p : pts) cin >> p.ST >> p.ND; auto get = [&](LL a, LL b) { if (a == 0 || b == 0) return n; FindUnion s(n); int ret = n; REP(i, n) REP(j, n) if (pts[i].ST - pts[j].ST == a && pts[i].ND - pts[j].ND == b) ret -= s.join(i, j); return ret; }; int ans = n; REP(i, n) REP(j, n) ans = min(ans, get(pts[i].ST - pts[j].ST, pts[i].ND - pts[j].ND)); cout << ans << "\n"; }
#include <bits/stdc++.h> using namespace std; using LL = long long; #define FOR(i, l, r) for (int i = (l); i <= (r); ++i) #define REP(i, n) FOR(i, 0, (n)-1) #ifdef DEBUG template <class A, class B> ostream &operator<<(ostream &out, const pair<A, B> &p) { return out << '(' << p.first << ", " << p.second << ')'; } template <class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) { out << '{'; for (auto it = x.begin(); it != x.end(); ++it) out << *it << (it == --x.end() ? "" : ", "); return out << '}'; } void dump() {} template <class T, class... Args> void dump(T &&x, Args... args) { cerr << x << "; "; dump(args...); } const int seed = 1; struct Nl { ~Nl() { cerr << '\n'; } }; #define debug(x...) cerr << (#x != "" ? #x ": " : ""), dump(x), Nl(), cerr #else const int seed = chrono::system_clock::now().time_since_epoch().count(); #define debug(...) 0 && cerr #endif mt19937_64 rng(seed); int rd(int l, int r) { return uniform_int_distribution<int>(l, r)(rng); } template <class T> int size(T a) { return a.size(); } struct FindUnion { vector<int> rep; bool sameSet(int a, int b) { return find(a) == find(b); } int size(int x) { return -rep[find(x)]; } int find(int x) { return rep[x] < 0 ? x : rep[x] = find(rep[x]); } bool join(int a, int b) { a = find(a), b = find(b); if (a == b) return false; if (-rep[a] < -rep[b]) swap(a, b); rep[a] += rep[b]; rep[b] = a; return true; } FindUnion(int n) : rep(n, -1) {} }; #define ST first #define ND second LL absolute(LL a) { if (a < 0) return -a; return a; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<pair<LL, LL>> pts(n); for (auto &p : pts) cin >> p.ST >> p.ND; auto get = [&](LL a, LL b) { if (a == 0 && b == 0) return n; FindUnion s(n); int ret = n; REP(i, n) REP(j, n) if (pts[i].ST - pts[j].ST == a && pts[i].ND - pts[j].ND == b) ret -= s.join(i, j); return ret; }; int ans = n; REP(i, n) REP(j, n) ans = min(ans, get(pts[i].ST - pts[j].ST, pts[i].ND - pts[j].ND)); cout << ans << "\n"; }
[ "misc.opposites", "control_flow.branch.if.condition.change" ]
820,617
820,618
u765393825
cpp
p03006
#include <bits/stdc++.h> #define ll long long #define pii pair<int, int> #define pll pair<long long, long long> #define pbb pair<bool, bool> #define plll pair<long long, pair<long long, long long>> #define sefi second.first #define sese second.second #define fi first #define se second #define ld long double #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) x.size() #define cont continue //#define int long long const long long md = 1e9 + 9; const int Inf = 1e9; const ll Inf64 = 1e18; const ll MaxN = 1e5 + 10; const ll MaxM = 11; const ld eps = 1e-15; const ll dx[4] = {0, 1, 0, -1}; const ll dy[4] = {1, 0, -1, 0}; const ll ddx[4] = {1, 1, -1, -1}; const ll ddy[4] = {1, -1, 1, -1}; using namespace std; ll gcd(ll a, ll b) { while (a) { b %= a; swap(a, b); } return b; } ll gcdex(ll a, ll mod = md) { ll g = mod, r = a, x = 0, y = 1; while (r != 0) { ll q = g / r; g %= r; swap(g, r); x -= q * y; swap(x, y); } return x < 0 ? x + mod : x; } ll binpow(ll a, ll n) { ll res = 1; while (n) { if (n & 1) { res *= a; res %= md; } a *= a; a %= md; n >>= 1; } return res % md; } // / /// //// // /////// signed main() { ios_base::sync_with_stdio(0); // ifstream cin("penalty.in"); // ofstream cout("penalty.out"); cin.tie(0); cout.tie(0); cerr.tie(0); // // // cout << fixed,cout.precision(10); // // ll N; cin >> N; vector<pll> Mt(N); map<pll, ll> Mp; for (int i = 0; i < N; i++) { cin >> Mt[i].fi >> Mt[i].se; Mp[Mt[i]] = i + 1; } sort(all(Mt)); set<pll> St; ll Ans = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < i; j++) { pll a = mp(Mt[i].first - Mt[j].first, Mt[i].first - Mt[j].first); ll t = 0; for (int k = 0; k < N; k++) { if (Mp[{Mt[k].first - a.first, Mt[k].second - a.second}] != 0) t++; } Ans = max(Ans, t); } } cout << N - Ans; /// /////////////// cerr << '\n' << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << '\n'; return 0; } /* */
#include <bits/stdc++.h> #define ll long long #define pii pair<int, int> #define pll pair<long long, long long> #define pbb pair<bool, bool> #define plll pair<long long, pair<long long, long long>> #define sefi second.first #define sese second.second #define fi first #define se second #define ld long double #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) x.size() #define cont continue //#define int long long const long long md = 1e9 + 9; const int Inf = 1e9; const ll Inf64 = 1e18; const ll MaxN = 1e5 + 10; const ll MaxM = 11; const ld eps = 1e-15; const ll dx[4] = {0, 1, 0, -1}; const ll dy[4] = {1, 0, -1, 0}; const ll ddx[4] = {1, 1, -1, -1}; const ll ddy[4] = {1, -1, 1, -1}; using namespace std; ll gcd(ll a, ll b) { while (a) { b %= a; swap(a, b); } return b; } ll gcdex(ll a, ll mod = md) { ll g = mod, r = a, x = 0, y = 1; while (r != 0) { ll q = g / r; g %= r; swap(g, r); x -= q * y; swap(x, y); } return x < 0 ? x + mod : x; } ll binpow(ll a, ll n) { ll res = 1; while (n) { if (n & 1) { res *= a; res %= md; } a *= a; a %= md; n >>= 1; } return res % md; } // / /// //// // /////// signed main() { ios_base::sync_with_stdio(0); // ifstream cin("penalty.in"); // ofstream cout("penalty.out"); cin.tie(0); cout.tie(0); cerr.tie(0); // // // cout << fixed,cout.precision(10); // // ll N; cin >> N; vector<pll> Mt(N); map<pll, ll> Mp; for (int i = 0; i < N; i++) { cin >> Mt[i].fi >> Mt[i].se; Mp[Mt[i]] = i + 1; } sort(all(Mt)); set<pll> St; ll Ans = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < i; j++) { pll a = mp(Mt[i].first - Mt[j].first, Mt[i].second - Mt[j].second); ll t = 0; for (int k = 0; k < N; k++) { if (Mp[{Mt[k].first - a.first, Mt[k].second - a.second}] != 0) t++; } Ans = max(Ans, t); } } cout << N - Ans; /// /////////////// cerr << '\n' << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << '\n'; return 0; } /* */
[ "call.arguments.change", "expression.operation.binary.change" ]
820,635
820,636
u088907534
cpp
p03006
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) using namespace std; #define int long long typedef pair<int, int> P; typedef pair<int, P> P2; #define F first #define S second int dy[] = {-1, 0, 1, 0}; int dx[] = {0, 1, 0, -1}; signed main() { int n; cin >> n; int x[n], y[n]; r(i, n) cin >> x[i] >> y[i]; int ans = 0; map<P, int> M; r(i, n) { r(j, n) { if (i < j) { M[P(abs(x[j] - x[i]), abs(y[j] - y[i]))]++; ans = max(ans, M[P(abs(x[j] - x[i]), abs(y[j] - y[i]))]); } } } cout << n - ans << endl; }
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) using namespace std; #define int long long typedef pair<int, int> P; typedef pair<int, P> P2; #define F first #define S second int dy[] = {-1, 0, 1, 0}; int dx[] = {0, 1, 0, -1}; signed main() { int n; cin >> n; int x[n], y[n]; r(i, n) cin >> x[i] >> y[i]; int ans = 0; map<P, int> M; r(i, n) { r(j, n) { if (i != j) { M[P((x[j] - x[i]), (y[j] - y[i]))]++; ans = max(ans, M[P((x[j] - x[i]), (y[j] - y[i]))]); } } } cout << n - ans << endl; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "call.arguments.change" ]
820,639
820,640
u777468981
cpp
p03001
#include <bits/stdc++.h> using namespace std; int main() { int w, h, x, y; cin >> w >> h >> x >> y; double area; int num = 0; area = (w * h) / 2; cout << setprecision(6) << area; if (x == (w / 2) && y == (h / 2)) { num = 1; cout << " " << num << endl; } else { cout << " " << num << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { double w, h, x, y; cin >> w >> h >> x >> y; double area; int num = 0; area = (w * h) / 2; cout << setprecision(6) << area; if (x == (w / 2) && y == (h / 2)) { num = 1; cout << " " << num << endl; } else { cout << " " << num << endl; } return 0; }
[ "variable_declaration.type.primitive.change" ]
820,657
820,658
u745852541
cpp
p03001
// include #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; // conversion inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // math template <class T> inline T sqr(T x) { return x * x; } // typedef typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; // container util #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) #define EACH(i, c) \ for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) // repetition #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) // constant const double EPS = 1e-10; const double PI = acos(-1.0); // clear memory #define CLR(a) memset((a), 0, sizeof(a)) // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; int main() { LL W, H, x, y; cin >> W >> H >> x >> y; printf("%.10Lf %d\n", (long double)(W) * (long double)(H), 2 * x == W && 2 * y == H); }
// include #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; // conversion inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // math template <class T> inline T sqr(T x) { return x * x; } // typedef typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; // container util #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) #define EACH(i, c) \ for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) // repetition #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) // constant const double EPS = 1e-10; const double PI = acos(-1.0); // clear memory #define CLR(a) memset((a), 0, sizeof(a)) // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; int main() { LL W, H, x, y; cin >> W >> H >> x >> y; printf("%.10Lf %d\n", (long double)(W) * (long double)(H) / 2.0, 2 * x == W && 2 * y == H); }
[ "expression.operation.binary.add" ]
820,663
820,664
u946378574
cpp
p03001
#include <iostream> using namespace std; int main() { int w, h, x, y; cin >> w >> h >> x >> y; double ans1 = (double)w * (double)h / 2.0; if (x + x == w && y + y == h) { printf("%.10f, %d\n", ans1, 1); } else { printf("%.10f, %d\n", ans1, 0); } return 0; }
#include <iostream> using namespace std; int main() { int w, h, x, y; cin >> w >> h >> x >> y; double ans1 = (double)w * (double)h / 2.0; if (x + x == w && y + y == h) { printf("%.10f %d\n", ans1, 1); } else { printf("%.10f %d\n", ans1, 0); } return 0; }
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
820,669
820,670
u902619368
cpp
p03001
#include <iostream> using namespace std; int main() { int w, h, x, y; cin >> w >> h >> x >> y; long long ans1 = (double)w * (double)h / 2.0; if (x + x == w && y + y == h) { printf("%.10f, %d\n", ans1, 1); } else { printf("%.10f, %d\n", ans1, 0); } return 0; }
#include <iostream> using namespace std; int main() { int w, h, x, y; cin >> w >> h >> x >> y; double ans1 = (double)w * (double)h / 2.0; if (x + x == w && y + y == h) { printf("%.10f %d\n", ans1, 1); } else { printf("%.10f %d\n", ans1, 0); } return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.narrow.change", "literal.string.change", "call.arguments.change", "io.output.change" ]
820,671
820,670
u902619368
cpp
p03001
#include <bits/stdc++.h> #include <iomanip> using namespace std; using ll = long long; #define FOR(i, N) for (auto i = 0; i < N; ++i) #define ALL(x) x.begin(), x.end() /* clang-format off */ template <class T> inline void chmin(T& a, const T& b) { if (b < a) a = b; } template <class T> inline void chmax(T& a, const T& b) { if (b > a) a = b; } /* clang-format on */ int main() { ll W, H; cin >> W >> H; ll x, y; cin >> x >> y; cout << fixed; double ans = H * W / 2; ll mult = 0; if (x * 2 == W && y * 2 == H) { mult = 1; } cout << setprecision(10) << ans << " " << mult << endl; return 0; }
#include <bits/stdc++.h> #include <iomanip> using namespace std; using ll = long long; #define FOR(i, N) for (auto i = 0; i < N; ++i) #define ALL(x) x.begin(), x.end() /* clang-format off */ template <class T> inline void chmin(T& a, const T& b) { if (b < a) a = b; } template <class T> inline void chmax(T& a, const T& b) { if (b > a) a = b; } /* clang-format on */ int main() { ll W, H; cin >> W >> H; ll x, y; cin >> x >> y; cout << fixed; double ans = double(H) * W / 2; ll mult = 0; if (x * 2 == W && y * 2 == H) { mult = 1; } cout << setprecision(10) << ans << " " << mult << endl; return 0; }
[ "call.add", "call.arguments.change" ]
820,672
820,673
u572144347
cpp
p03001
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define repp(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define repm(i, a, b) for (int i = (int)a; i > (int)b; --i) using ll = long long; static const ll mod = 1e9 + 7; static const ll INF = 1LL << 50; using namespace std; int main() { ll h, w, x, y; cin >> w >> h >> x >> y; bool judge; long double ans; if (h % 2 == 0 && w % 2 == 0) { ans = h * w / 2; if (w == 2 * x && h == 2 * y) judge = true; } else { judge = false; ans = h * w; ans /= 2; } cout << ans << " " << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define repp(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define repm(i, a, b) for (int i = (int)a; i > (int)b; --i) using ll = long long; static const ll mod = 1e9 + 7; static const ll INF = 1LL << 50; using namespace std; int main() { ll h, w, x, y; cin >> w >> h >> x >> y; bool judge; long double ans; if (h % 2 == 0 && w % 2 == 0) { ans = h * w / 2; if (w == 2 * x && h == 2 * y) judge = true; } else { judge = false; ans = h * w; ans /= 2; } cout << ans << " " << judge << endl; return 0; }
[ "io.output.change" ]
820,683
820,684
u698883164
cpp
p03001
#include <bits/stdc++.h> using namespace std; int main() { int W, H, x, y; cin >> W >> H >> x >> y; double ans = W * H / 2; int zo; if (x == W / 2 && y == H / 2) zo = 1; else zo = 0; cout << ans << " " << zo << endl; }
#include <bits/stdc++.h> using namespace std; int main() { double W, H, x, y; cin >> W >> H >> x >> y; double ans = W * H / 2; int zo; if (x == W / 2 && y == H / 2) zo = 1; else zo = 0; cout << ans << " " << zo << endl; }
[ "variable_declaration.type.primitive.change" ]
820,691
820,692
u099277178
cpp
p03001
#include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(false); \ cin.tie(0); #define FOR(i, s, n) for (int i = s; i < n; i++) #define REP(n) FOR(i, 0, n) #define ALL(n) (n).begin(), (n).end() #define RALL(n) (n).rbegin(), (n).rend() using INT64 = long long; using UINT64 = unsigned long long; #define MOD 1000000007 int main(void) { IOS double w, h, x, y; cin >> w >> h >> x >> y; int ans = (x * 2 == x && y * 2 == h) ? 1 : 0; cout << w * h / 2 << " " << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(false); \ cin.tie(0); #define FOR(i, s, n) for (int i = s; i < n; i++) #define REP(n) FOR(i, 0, n) #define ALL(n) (n).begin(), (n).end() #define RALL(n) (n).rbegin(), (n).rend() using INT64 = long long; using UINT64 = unsigned long long; #define MOD 1000000007 int main(void) { IOS double w, h, x, y; cin >> w >> h >> x >> y; int ans = (x * 2 == w && y * 2 == h) ? 1 : 0; cout << w * h / 2 << " " << ans << endl; return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
820,700
820,701
u330661451
cpp
p03001
#include <bits/stdc++.h> using namespace std; int main(void) { // Your code here! long long a, b, c, d; double u; cin >> a >> b >> c >> d; u = a * b / 2; printf("%.10lf", u); cout << " "; if (c == a / 2 && d == b / 2) cout << 1 << endl; else cout << 0 << endl; }
#include <bits/stdc++.h> using namespace std; int main(void) { // Your code here! double a, b, c, d; double u; cin >> a >> b >> c >> d; u = a * b / 2; printf("%.10lf", u); cout << " "; if (c == a / 2 && d == b / 2) cout << 1 << endl; else cout << 0 << endl; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.narrow.change" ]
820,702
820,703
u112775098
cpp
p03001
#include <bits/stdc++.h> #define ALL(v) v.begin(), v.end() #define MOD 1000000007 #define INF 1000000011 #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) using namespace std; typedef long long ll; int main() { ll w, h, x, y; cin >> w >> h >> x >> y; long double m = w * h / 2.0; cout << fixed; cout << setprecision(12) << m << " "; if (x == w / 2 && y == h / 2) { cout << 1 << endl; } else { cout << 0 << endl; } }
#include <bits/stdc++.h> #define ALL(v) v.begin(), v.end() #define MOD 1000000007 #define INF 1000000011 #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) using namespace std; typedef long long ll; int main() { long double w, h, x, y; cin >> w >> h >> x >> y; long double m = w * h / 2.0; cout << fixed; cout << setprecision(11) << m << " "; if (x == w / 2 && y == h / 2) { cout << 1 << endl; } else { cout << 0 << endl; } }
[ "variable_declaration.type.widen.change", "literal.number.change", "io.output.change" ]
820,726
820,727
u233626335
cpp
p03001
#include <bits/stdc++.h> #define ALL(v) v.begin(), v.end() #define MOD 1000000007 #define INF 1000000011 #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) using namespace std; typedef long long ll; int main() { ll w, h, x, y; cin >> w >> h >> x >> y; long double m = w * h / 2.0; cout << fixed; cout << setprecision(10) << m << " "; if (x == w / 2 && y == h / 2) { cout << 1 << endl; } else { cout << 0 << endl; } }
#include <bits/stdc++.h> #define ALL(v) v.begin(), v.end() #define MOD 1000000007 #define INF 1000000011 #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) using namespace std; typedef long long ll; int main() { long double w, h, x, y; cin >> w >> h >> x >> y; long double m = w * h / 2.0; cout << fixed; cout << setprecision(11) << m << " "; if (x == w / 2 && y == h / 2) { cout << 1 << endl; } else { cout << 0 << endl; } }
[ "variable_declaration.type.widen.change", "literal.number.change", "io.output.change" ]
820,728
820,727
u233626335
cpp
p03001
#include <algorithm> #include <climits> #include <cmath> #include <iostream> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { long double w, h, x, y, a, b; cin >> w >> h >> x >> y; cout << w * h / 2 << " "; if (x == w / 2 && y == h / 2) cout << 0 << endl; else cout << 1 << endl; return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <iostream> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { long double w, h, x, y, a, b; cin >> w >> h >> x >> y; cout << w * h / 2 << " "; if (x == w / 2 && y == h / 2) cout << 1 << 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" ]
820,738
820,739
u582817680
cpp
p03001
#include <algorithm> #include <climits> #include <cmath> #include <iostream> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { long double w, h, x, y, a, b; cin >> w >> h >> x >> y; cout << w * h / 2 << " "; if (x == w / 2 && y == y / 2) cout << 0 << endl; else cout << 1 << endl; return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <iostream> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { long double w, h, x, y, a, b; cin >> w >> h >> x >> y; cout << w * h / 2 << " "; if (x == w / 2 && y == h / 2) cout << 1 << endl; else cout << 0 << endl; return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change", "control_flow.branch.else.remove", "control_flow.branch.else_if.replace.remove", "control_flow.branch.if.replace.add" ]
820,740
820,739
u582817680
cpp
p03001
#include <bits/stdc++.h> using namespace std; int main() { int W, H, x, y; double ans1; bool ans2; cin >> W >> H >> x >> y; ans1 = W * H / 2.0; ans2 = W / 2 == x && H / 2 == y; cout << ans1 << " " << ans2 << endl; }
#include <bits/stdc++.h> using namespace std; int main() { double W, H, x, y, ans1; bool ans2; cin >> W >> H >> x >> y; ans1 = W * H / 2.0; ans2 = (W / 2 == x && H / 2 == y); cout << ans1 << " " << ans2 << endl; }
[ "variable_declaration.type.primitive.change" ]
820,746
820,747
u074306398
cpp
p03001
#include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; int main() { double w, h, x, y, xk, yk, ansx, ansy, ans; cin >> w >> h >> x >> y; cout << double(w) * double(h) / 2 << " "; if (w == x + x || h == y + y) { cout << 1; } else { cout << 0; } return 0; }
#include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; int main() { double w, h, x, y, xk, yk, ansx, ansy, ans; cin >> w >> h >> x >> y; cout << double(w) * double(h) / 2 << " "; if (w == x + x && h == y + y) { cout << 1; } else { cout << 0; } return 0; }
[ "misc.opposites", "control_flow.branch.if.condition.change" ]
820,750
820,751
u125051909
cpp
p03001
#include <algorithm> #include <cstdlib> #include <iostream> #include <queue> #include <stdio.h> #include <string> #include <utility> #include <vector> using namespace std; 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; } int main() { long long w, h, x, y; cin >> w >> h >> x >> y; printf("%lf ", double(x) * double(y) * 0.5); if (w == 2 * x && h == 2 * y) cout << 1 << endl; else cout << 0 << endl; return 0; }
#include <algorithm> #include <cstdlib> #include <iostream> #include <queue> #include <stdio.h> #include <string> #include <utility> #include <vector> using namespace std; 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; } int main() { long long w, h, x, y; cin >> w >> h >> x >> y; printf("%lf ", double(w) * double(h) * 0.5); if (w == 2 * x && h == 2 * y) cout << 1 << endl; else cout << 0 << endl; return 0; }
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
820,755
820,756
u342005896
cpp
p03001
#include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #define M_PI 3.14159265358979323846 using namespace std; // conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } inline int readInt() { int x; scanf("%d", &x); return x; } // typedef //------------------------------------------ typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef pair<int, PII> TIII; typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) #define SQ(a) ((a) * (a)) #define EACH(i, c) \ for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) // repetition //------------------------------------------ #define FOR(i, s, n) for (int i = s; i < (int)n; ++i) #define REP(i, n) FOR(i, 0, n) #define MOD 1000000007 #define rep(i, a, b) for (int i = a; i < (b); ++i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() struct Edge { int to, cost; Edge(int to, int cost) : to(to), cost(cost) {} }; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<vector<Edge>> AdjList; AdjList graph; const int INF = 100000000; LL N, M; LL arr[100010] = {0}; int S[2010]; int T[2010]; LL dp[2010][2010]; int main() { cout << fixed << setprecision(15); LL W, H, x, y; cin >> W >> H >> x >> y; cout << W * H * 0.5 << " " << (x + x == W && y * y == H) << endl; return 0; }
#include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #define M_PI 3.14159265358979323846 using namespace std; // conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } inline int readInt() { int x; scanf("%d", &x); return x; } // typedef //------------------------------------------ typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef pair<int, PII> TIII; typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) #define SQ(a) ((a) * (a)) #define EACH(i, c) \ for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) // repetition //------------------------------------------ #define FOR(i, s, n) for (int i = s; i < (int)n; ++i) #define REP(i, n) FOR(i, 0, n) #define MOD 1000000007 #define rep(i, a, b) for (int i = a; i < (b); ++i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() struct Edge { int to, cost; Edge(int to, int cost) : to(to), cost(cost) {} }; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<vector<Edge>> AdjList; AdjList graph; const int INF = 100000000; LL N, M; LL arr[100010] = {0}; int S[2010]; int T[2010]; LL dp[2010][2010]; int main() { cout << fixed << setprecision(15); LL W, H, x, y; cin >> W >> H >> x >> y; cout << W * H * 0.5 << " " << (x + x == W && y + y == H) << endl; return 0; }
[ "expression.operator.arithmetic.change", "io.output.change" ]
820,759
820,760
u181719868
cpp
p03001
#include <iostream> #include <vector> using namespace std; int main(void) { long W = 0, H = 0, x = 0, y = 0; cin >> W >> H >> x >> y; cout << double(W) * double(H) << " "; if (2 * x == W && 2 * y == H) { cout << 1 << endl; } else { cout << 0 << endl; } return 0; }
#include <iostream> #include <vector> using namespace std; int main(void) { long W = 0, H = 0, x = 0, y = 0; cin >> W >> H >> x >> y; cout << double(W) * double(H) / 2 << " "; if (2 * x == W && 2 * y == H) { cout << 1 << endl; } else { cout << 0 << endl; } return 0; }
[ "expression.operation.binary.add" ]
820,761
820,762
u607754357
cpp
p03001
#include <bits/stdc++.h> #include <cmath> #include <iostream> #include <numeric> #include <string> using namespace std; typedef long long ll; int main() { int a, b, x, y; cin >> a >> b >> x >> y; cout << double(a) * double(b) / 2 << (x + x == a && y + y == b) << endl; }
#include <bits/stdc++.h> #include <cmath> #include <iostream> #include <numeric> #include <string> using namespace std; typedef long long ll; int main() { int a, b, x, y; cin >> a >> b >> x >> y; cout << double(a) * double(b) / 2 << ' ' << (x + x == a && y + y == b) << endl; }
[ "io.output.change" ]
820,789
820,790
u661461084
cpp
p03001
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) const long long MOD = 1000000007LL; const string alpha = "abcdefghijklmnopqrstuvwxyz"; int main() { long double w, h, x, y; cin >> w >> h >> x >> y; cout << setprecision(30) << w * h / 2 << " "; if (2 * x == w || 2 * y == h) { if (w * y == h * x) { cout << 1 << endl; } else { cout << 0 << endl; } } else { if (x == 0 || x == w || y == 0 || y == h) { cout << 0 << endl; } else { cout << 1 << endl; } } }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) const long long MOD = 1000000007LL; const string alpha = "abcdefghijklmnopqrstuvwxyz"; int main() { long double w, h, x, y; cin >> w >> h >> x >> y; cout << setprecision(30) << w * h / 2 << " "; if (2 * x == w || 2 * y == h) { if (w * y == h * x) { cout << 1 << endl; } else { cout << 0 << endl; } } else { if (x == 0 || x == w || y == 0 || y == h) { cout << 0 << endl; } else { cout << 0 << endl; } } }
[ "literal.number.change", "io.output.change" ]
820,821
820,822
u467826805
cpp
p03001
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) const long long MOD = 1000000007LL; const string alpha = "abcdefghijklmnopqrstuvwxyz"; int main() { long double w, h, x, y; cin >> w >> h >> x >> y; cout << setprecision(20) << w * h / 2 << " "; if (2 * x == w || 2 * y == h) { if (w * y == h * x) { cout << 1 << endl; } else { cout << 0 << endl; } } else { if (x == 0 || x == w || y == 0 || y == h) { cout << 0 << endl; } else { cout << 1 << endl; } } }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) const long long MOD = 1000000007LL; const string alpha = "abcdefghijklmnopqrstuvwxyz"; int main() { long double w, h, x, y; cin >> w >> h >> x >> y; cout << setprecision(30) << w * h / 2 << " "; if (2 * x == w || 2 * y == h) { if (w * y == h * x) { cout << 1 << endl; } else { cout << 0 << endl; } } else { if (x == 0 || x == w || y == 0 || y == h) { cout << 0 << endl; } else { cout << 0 << endl; } } }
[ "literal.number.change", "io.output.change" ]
820,823
820,822
u467826805
cpp
p03001
#include <bits/stdc++.h> using namespace std; // repetition #define FOR(i, a, b) for (ll i = (a); i < (b); ++i) #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) // container util #define all(x) (x).begin(), (x).end() // typedef typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<ll> VLL; typedef vector<VLL> VVLL; typedef vector<string> VS; typedef pair<int, int> PII; typedef pair<ll, ll> PLL; // const value // const ll MOD = 1e9 + 7; // const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1}; // const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1}; // conversion inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } inline ll toLL(string s) { ll v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } int main() { ios::sync_with_stdio(false); cin.tie(0); double w, h, x, y; cin >> w >> h; cin >> x >> y; if ((int)h % 2 == y && (int)w % 2 == 0) { if (h / 2 == y && w / 2 == x) { printf("%0.9lf 1", h * w / 2.0); return 0; } } printf("%0.9lf 0", h * w / 2.0); return 0; }
#include <bits/stdc++.h> using namespace std; // repetition #define FOR(i, a, b) for (ll i = (a); i < (b); ++i) #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) // container util #define all(x) (x).begin(), (x).end() // typedef typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<ll> VLL; typedef vector<VLL> VVLL; typedef vector<string> VS; typedef pair<int, int> PII; typedef pair<ll, ll> PLL; // const value // const ll MOD = 1e9 + 7; // const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1}; // const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1}; // conversion inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } inline ll toLL(string s) { ll v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } int main() { ios::sync_with_stdio(false); cin.tie(0); double w, h, x, y; cin >> w >> h; cin >> x >> y; if ((int)h % 2 == 0 && (int)w % 2 == 0) { if (h / 2 == y && w / 2 == x) { printf("%0.10lf 1\n", h * w / 2.0); return 0; } } printf("%0.10lf 0\n", h * w / 2.0); return 0; }
[ "identifier.replace.remove", "literal.replace.add", "control_flow.branch.if.condition.change", "literal.string.change", "call.arguments.change", "io.output.change", "io.output.newline.add" ]
820,831
820,832
u336011173
cpp
p03001
#include <algorithm> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string.h> #include <string> #include <vector> using namespace std; #define ll long long #define INF 1e9 #define MOD 1e9 + 7 #define rep(i, n) for (int i = 0; i < n; i++) #define loop(i, a, n) for (int i = a; i < n; i++) #define all(in) in.begin(), in.end() int main() { int W, H, x, y; cin >> W >> H >> x >> y; double ans = 0; double num = 0; ans = (double)(W * H) / 2; if (x == W / 2 && y == H / 2) num = 1; cout << ans << " " << num << endl; return 0; }
#include <algorithm> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string.h> #include <string> #include <vector> using namespace std; #define ll long long #define INF 1e9 #define MOD 1e9 + 7 #define rep(i, n) for (int i = 0; i < n; i++) #define loop(i, a, n) for (int i = a; i < n; i++) #define all(in) in.begin(), in.end() int main() { double W, H, x, y; cin >> W >> H >> x >> y; double ans = 0; double num = 0; ans = W * H / 2; if (x == W / 2 && y == H / 2) num = 1; cout << ans << " " << num << endl; return 0; }
[ "variable_declaration.type.primitive.change" ]
820,836
820,837
u270170852
cpp
p03001
#include <iostream> using namespace std; int main() { int w, h, x, y; double area; while (cin >> w >> h >> x >> y) { area = w * h / 2.00; cout << area << " "; if (x == w / 2 && y == h / 2) cout << 1; else cout << 0; } return 0; }
#include <iostream> using namespace std; int main() { double w, h, x, y; double area; while (cin >> w >> h >> x >> y) { area = w * h / 2.00; cout << area << " "; if (x == w / 2 && y == h / 2) cout << 1; else cout << 0; } return 0; }
[ "variable_declaration.type.primitive.change" ]
820,840
820,841
u734308503
cpp
p03001
#include <bits/stdc++.h> using namespace std; inline int_fast64_t read() { int_fast64_t x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return x * f; } inline string read_s() { string s = ""; char c = getchar(); while (c < '!' || c > '~') { c = getchar(); } while (c >= '!' && c <= '~') { s += c; c = getchar(); } return s; } void Main() { double ans1; int ans2; int W = read(), H = read(), x = read(), y = read(); ans1 = (W * H) / 2; ans2 = (x * 2 == W && y * 2 == H) ? 1 : 0; printf("%lf %d\n", ans1, ans2); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }
#include <bits/stdc++.h> using namespace std; inline int_fast64_t read() { int_fast64_t x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return x * f; } inline string read_s() { string s = ""; char c = getchar(); while (c < '!' || c > '~') { c = getchar(); } while (c >= '!' && c <= '~') { s += c; c = getchar(); } return s; } void Main() { double ans1; int ans2; double W = read(), H = read(), x = read(), y = read(); ans1 = W * H / 2; ans2 = (x * 2 == W && y * 2 == H) ? 1 : 0; printf("%lf %d\n", ans1, ans2); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }
[ "variable_declaration.type.primitive.change" ]
820,846
820,845
u572532976
cpp
p03001
#include <bits/stdc++.h> #define mod 1000000007 using namespace std; int main(void) { double W, H, x, y; cin >> W >> H >> x >> y; if (x * 2 == W || y * 2 == H) { printf("%.10f %d", W * H / 2, 1); } else printf("%.10f %d", W * H / 2, 0); return 0; }
#include <bits/stdc++.h> #define mod 1000000007 using namespace std; int main(void) { double W, H, x, y; cin >> W >> H >> x >> y; if (x * 2 == W && y * 2 == H) { printf("%.10f %d", W * H / 2, 1); } else printf("%.10f %d", W * H / 2, 0); return 0; }
[ "misc.opposites", "control_flow.branch.if.condition.change" ]
820,849
820,850
u895536055
cpp
p03001
#include <iostream> using namespace std; int main() { int w, h, x, y; cin >> w >> h >> x >> y; cout << (double)w * (double)h / 2 << (2 * x == w && 2 * y == h) << endl; }
#include <iostream> using namespace std; int main() { int w, h, x, y; cin >> w >> h >> x >> y; cout << (double)w * (double)h / 2 << ' ' << (2 * x == w && 2 * y == h) << endl; }
[ "io.output.change" ]
820,855
820,856
u911828387
cpp
p03001
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; // repetition #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) for (int i = 0; i < (int)(n); i++) // container util #define all(x) (x).begin(), (x).end() // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; // typedef typedef long long lint; typedef unsigned long long ull; typedef complex<long double> Complex; typedef pair<int, int> P; typedef tuple<int, int, int> TP; typedef vector<int> vec; typedef vector<vec> mat; // constant const int MOD = (int)1e9 + 7; const int INF = (int)1e18; const int dx[] = {0, 1, 0, -1}; const int dy[] = {1, 0, -1, 0}; const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1}; const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1}; // conversion inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // 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; } // int main() { ios::sync_with_stdio(false); cin.tie(0); lint w, h, x, y; cin >> w >> h >> x >> y; double ans1 = w * h; printf("%.6f ", (double)(w * h) / 2); if (w % 2 == 0 && h % 2 == 0) { if (x == w / 2 || y == h / 2) { printf("1\n"); } else { printf("0\n"); } } else { printf("0\n"); } return 0; }
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; // repetition #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) for (int i = 0; i < (int)(n); i++) // container util #define all(x) (x).begin(), (x).end() // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; // typedef typedef long long lint; typedef unsigned long long ull; typedef complex<long double> Complex; typedef pair<int, int> P; typedef tuple<int, int, int> TP; typedef vector<int> vec; typedef vector<vec> mat; // constant const int MOD = (int)1e9 + 7; const int INF = (int)1e18; const int dx[] = {0, 1, 0, -1}; const int dy[] = {1, 0, -1, 0}; const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1}; const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1}; // conversion inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // 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; } // int main() { ios::sync_with_stdio(false); cin.tie(0); lint w, h, x, y; cin >> w >> h >> x >> y; double ans1 = w * h; printf("%.6f ", (double)(w * h) / 2); if (w % 2 == 0 && h % 2 == 0) { if (x == w / 2 && y == h / 2) { printf("1\n"); } else { printf("0\n"); } } else { printf("0\n"); } return 0; }
[ "misc.opposites", "control_flow.branch.if.condition.change" ]
820,862
820,863
u764228018
cpp
p03001
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; // repetition #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) for (int i = 0; i < (int)(n); i++) // container util #define all(x) (x).begin(), (x).end() // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; // typedef typedef long long lint; typedef unsigned long long ull; typedef complex<long double> Complex; typedef pair<int, int> P; typedef tuple<int, int, int> TP; typedef vector<int> vec; typedef vector<vec> mat; // constant const int MOD = (int)1e9 + 7; const int INF = (int)1e18; const int dx[] = {0, 1, 0, -1}; const int dy[] = {1, 0, -1, 0}; const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1}; const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1}; // conversion inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // 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; } // int main() { ios::sync_with_stdio(false); cin.tie(0); lint w, h, x, y; cin >> w >> h >> x >> y; double ans1 = w * h; printf("%.9f ", (double)(w * h) / 2); if (w % 2 == 0 && h % 2 == 0) { if (x == w / 2 || y == h / 2) { printf("1\n"); } else { printf("0\n"); } } else { printf("0\n"); } return 0; }
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; // repetition #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) for (int i = 0; i < (int)(n); i++) // container util #define all(x) (x).begin(), (x).end() // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; // typedef typedef long long lint; typedef unsigned long long ull; typedef complex<long double> Complex; typedef pair<int, int> P; typedef tuple<int, int, int> TP; typedef vector<int> vec; typedef vector<vec> mat; // constant const int MOD = (int)1e9 + 7; const int INF = (int)1e18; const int dx[] = {0, 1, 0, -1}; const int dy[] = {1, 0, -1, 0}; const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1}; const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1}; // conversion inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // 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; } // int main() { ios::sync_with_stdio(false); cin.tie(0); lint w, h, x, y; cin >> w >> h >> x >> y; double ans1 = w * h; printf("%.6f ", (double)(w * h) / 2); if (w % 2 == 0 && h % 2 == 0) { if (x == w / 2 && y == h / 2) { printf("1\n"); } else { printf("0\n"); } } else { printf("0\n"); } return 0; }
[ "literal.string.change", "call.arguments.change", "io.output.change", "misc.opposites", "control_flow.branch.if.condition.change" ]
820,864
820,863
u764228018
cpp
p03001
#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; int main() { int a, b, x, y; scanf("%d%d%d%d", &a, &b, &x, &y); printf("%lf%d\n", double(a) * double(b) / 2, x + x == a && y + y == b); 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; int main() { int a, b, x, y; scanf("%d%d%d%d", &a, &b, &x, &y); printf("%lf %d\n", double(a) * double(b) / 2, x + x == a && y + y == b); return 0; }
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
820,874
820,875
u915020369
cpp
p03001
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 2e5 + 10; int a[maxn]; int main() { ll x, y, z, w; cin >> x >> y >> z >> w; printf("%.6f ", (ll)x * y / 2.0); if (z == x / 2 && w == y / 2) cout << 1 << endl; else cout << 0 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 2e5 + 10; int a[maxn]; int main() { double x, y, z, w; cin >> x >> y >> z >> w; printf("%.6f ", (double)(x * y) / 2); if (z == x / 2 && w == y / 2) cout << 1 << endl; else cout << 0 << endl; return 0; }
[ "variable_declaration.type.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change", "literal.number.change" ]
820,891
820,892
u914135866
cpp
p03001
#include <bits/stdc++.h> 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 count(ll i, ll j, vector<string> &m) { return 0; } int main(int argc, const char *argv[]) { ios_base::sync_with_stdio(false); cin.tie(0); ll w, h, x, y; cin >> w >> h >> x >> y; double ans; ans = w * h / 2; cout << fixed << setprecision(10) << ans; if (w - x == x && h - y == y) cout << " 1"; else cout << " 0"; cout << endl; return 0; }
#include <bits/stdc++.h> 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 count(ll i, ll j, vector<string> &m) { return 0; } int main(int argc, const char *argv[]) { ios_base::sync_with_stdio(false); cin.tie(0); ll w, h, x, y; cin >> w >> h >> x >> y; double ans; ans = w * h / 2.0; cout << fixed << setprecision(10) << ans; if (w - x == x && h - y == y) cout << " 1"; else cout << " 0"; cout << endl; return 0; }
[ "literal.number.change", "assignment.value.change", "expression.operation.binary.change" ]
820,904
820,905
u712259491
cpp
p03001
#include <bits/stdc++.h> 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 count(ll i, ll j, vector<string> &m) { return 0; } int main(int argc, const char *argv[]) { ios_base::sync_with_stdio(false); cin.tie(0); ll w, h, x, y; cin >> w >> h >> x >> y; double ans; ans = w * h / 2; cout << fixed << setprecision(6) << ans; if (w - x == x && h - y == y) cout << " 1"; else cout << " 0"; cout << endl; return 0; }
#include <bits/stdc++.h> 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 count(ll i, ll j, vector<string> &m) { return 0; } int main(int argc, const char *argv[]) { ios_base::sync_with_stdio(false); cin.tie(0); ll w, h, x, y; cin >> w >> h >> x >> y; double ans; ans = w * h / 2.0; cout << fixed << setprecision(10) << ans; if (w - x == x && h - y == y) cout << " 1"; else cout << " 0"; cout << endl; return 0; }
[ "literal.number.change", "assignment.value.change", "expression.operation.binary.change", "io.output.change" ]
820,906
820,905
u712259491
cpp
p03006
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, from, to) for (int i = from; i < (to); ++i) #define mp(x, y) make_pair(x, y) #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() using ll = long long; using vin = vector<int>; using vll = vector<ll>; using P = pair<int, int>; const int inf = 1e9 + 7; const ll INF = 1e18; template <typename T> void chmin(T &a, T b) { a = min(a, b); } template <typename T> void chmax(T &a, T b) { a = max(a, b); } int main() { int n; cin >> n; vector<P> ab(n); rep(i, 0, n) { int a; int b; cin >> a >> b; ab[i] = mp(a, b); } /////// sort(all(ab)); map<P, int> cnt; rep(i, 0, n - 1) { rep(j, i + 1, n) { int x = abs(ab[i].first - ab[j].first); int y = abs(ab[i].second - ab[j].second); cnt[mp(x, y)]++; } } int ma = 0; for (auto v : cnt) { chmax(ma, v.second); } cout << n - ma << endl; }
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG #define rep(i, from, to) for (int i = from; i < (to); ++i) #define mp(x, y) make_pair(x, y) #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() using ll = long long; using vin = vector<int>; using vll = vector<ll>; using P = pair<int, int>; const int inf = 1e9 + 7; const ll INF = 1e18; template <typename T> void chmin(T &a, T b) { a = min(a, b); } template <typename T> void chmax(T &a, T b) { a = max(a, b); } int main() { int n; cin >> n; vector<P> ab(n); rep(i, 0, n) { int a; int b; cin >> a >> b; ab[i] = mp(a, b); } /////// sort(all(ab)); map<P, int> cnt; rep(i, 0, n - 1) { rep(j, i + 1, n) { int x = (ab[i].first - ab[j].first); int y = (ab[i].second - ab[j].second); cnt[mp(x, y)]++; } } int ma = 0; for (auto v : cnt) { chmax(ma, v.second); } cout << n - ma << endl; }
[]
820,954
820,955
u531461815
cpp
p03006
#include <limits.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <algorithm> #include <cassert> #include <cfloat> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <stack> #include <string> #include <unordered_map> #include <vector> using namespace std; #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) #define rep(i, n) for (ll i = 0; i < (n); ++i) #define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i) #define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i) #define Sort(v) sort(v.begin(), v.end()) #define rSort(v) sort(v.rbegin(), v.rend()) #define Reverse(v) reverse(v.begin(), v.end()) #define Lower_bound(v, x) \ distance(v.begin(), lower_bound(v.begin(), v.end(), x)) #define Upper_bound(v, x) \ distance(v.begin(), upper_bound(v.begin(), v.end(), x)) using ll = long long; using ull = unsigned long long; using P = pair<ll, ll>; using T = tuple<ll, ll, ll>; using vll = vector<ll>; using vP = vector<P>; using vT = vector<T>; using vvll = vector<vector<ll>>; using vvP = vector<vector<P>>; using dqll = deque<ll>; ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0}; ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0}; /* Macros reg. ends here */ const ll INF = 1LL << 50; int main() { // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << fixed << setprecision(15); ll n; cin >> n; vll xs(n), ys(n); rep(i, n) { cin >> xs[i] >> ys[i]; } map<P, ll> mp; rep(i, n) rep(j, n - 1) { if (i == j) continue; else mp[P(xs[i] - xs[j], ys[i] - ys[j])]++; } ll ans = 0; for (auto &x : mp) chmax(ans, x.second); cout << ans << endl; return 0; }
#include <limits.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <algorithm> #include <cassert> #include <cfloat> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <stack> #include <string> #include <unordered_map> #include <vector> using namespace std; #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) #define rep(i, n) for (ll i = 0; i < (n); ++i) #define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i) #define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i) #define Sort(v) sort(v.begin(), v.end()) #define rSort(v) sort(v.rbegin(), v.rend()) #define Reverse(v) reverse(v.begin(), v.end()) #define Lower_bound(v, x) \ distance(v.begin(), lower_bound(v.begin(), v.end(), x)) #define Upper_bound(v, x) \ distance(v.begin(), upper_bound(v.begin(), v.end(), x)) using ll = long long; using ull = unsigned long long; using P = pair<ll, ll>; using T = tuple<ll, ll, ll>; using vll = vector<ll>; using vP = vector<P>; using vT = vector<T>; using vvll = vector<vector<ll>>; using vvP = vector<vector<P>>; using dqll = deque<ll>; ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0}; ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0}; /* Macros reg. ends here */ const ll INF = 1LL << 50; int main() { // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << fixed << setprecision(15); ll n; cin >> n; vll xs(n), ys(n); rep(i, n) { cin >> xs[i] >> ys[i]; } map<P, ll> mp; rep(i, n) rep(j, n) { if (i == j) continue; else mp[P(xs[i] - xs[j], ys[i] - ys[j])]++; } ll ans = 0; for (auto &x : mp) chmax(ans, x.second); cout << n - ans << endl; return 0; }
[ "expression.operation.binary.remove" ]
820,956
820,957
u714724786
cpp
p03006
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> P; typedef pair<ll, ll> Pll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repn(i, n) for (int i = 0; i <= (int)(n); i++) #define srep(i, l, n) for (int i = l; i < (int)(n); i++) #define srepn(i, l, n) for (int i = l; i <= (int)(n); i++) #define pb push_back template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } const int MOD = 1000000007; const int INF = 1e9; #define PI 3.14159265369; int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; int ddx[8] = {1, 1, 1, -1, -1, -1, 0, 0}; int ddy[8] = {0, 1, -1, 0, 1, -1, 1, -1}; int main() { int n; cin >> n; vector<P> ball(n); rep(i, n) cin >> ball[i].first >> ball[i].second; sort(ball.begin(), ball.end()); map<P, int> mp; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { int a = ball[j].first - ball[i].first; int b = ball[j].second - ball[j].second; mp[P(a, b)]++; } } int mx = 0; for (auto e : mp) { chmax(mx, e.second); } int ans = n - mx; cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> P; typedef pair<ll, ll> Pll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repn(i, n) for (int i = 0; i <= (int)(n); i++) #define srep(i, l, n) for (int i = l; i < (int)(n); i++) #define srepn(i, l, n) for (int i = l; i <= (int)(n); i++) #define pb push_back template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } const int MOD = 1000000007; const int INF = 1e9; #define PI 3.14159265369; int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; int ddx[8] = {1, 1, 1, -1, -1, -1, 0, 0}; int ddy[8] = {0, 1, -1, 0, 1, -1, 1, -1}; int main() { int n; cin >> n; vector<P> ball(n); rep(i, n) cin >> ball[i].first >> ball[i].second; sort(ball.begin(), ball.end()); map<P, int> mp; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { int a = ball[j].first - ball[i].first; int b = ball[j].second - ball[i].second; mp[P(a, b)]++; } } int mx = 0; for (auto e : mp) { chmax(mx, e.second); } int ans = n - mx; cout << ans << endl; }
[ "identifier.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
820,979
820,980
u279033107
cpp
p03006
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < n; ++i) #define repR(i, n) for (ll i = n; i >= 0; ++i) #define FDS(i, n) for (ll i = 0; i < n; ++i) #define FDSR(i, n) for (ll i = n; i >= 0; ++i) #define FOR(i, m, n) for (ll i = m; i < n; ++i) #define FORR(i, m, n) for (ll i = m; i >= n; --i) #define VSORT(v) sort(v.begin(), v.end()); #define VREV(v) reverse(v.begin(), v.end()); #define INF 999999999 #define itn ll #define ednl endl using namespace std; typedef long long ll; template <typename Typell> Typell G_C_D(Typell a, Typell b) { if (a < 0) a = -a; if (b < 0) b = -b; while (b != 0) { a %= b; if (a == 0) return b; b %= a; } return a; } template <typename Typell> Typell G_C_D(const std::vector<Typell> &list) { Typell a = list[0]; for (size_t i = 1; i < list.size(); ++i) { a = G_C_D(a, list[i]); } return a; } template <typename Typell> Typell L_C_M(Typell a, Typell b) { if (a == 0 && b == 0) return 0; return a / G_C_D(a, b) * b; } template <typename Typell> Typell L_C_M(const std::vector<Typell> &list) { Typell a = list[0]; for (size_t i = 1; i < list.size(); ++i) { a = L_C_M(a, list[i]); } return a; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<ll> A(N); vector<ll> B(N); FDS(i, N) { cin >> A[i] >> B[i]; } vector<pair<ll, ll>> sa; FDS(i, N) FDS(j, N) { if (i == j) continue; sa.push_back(make_pair(A[j] - A[i], B[j] - B[i])); } int ans = N; FDS(i, sa.size()) { ll x = sa[i].first, y = sa[i].second; int c = 0; FDS(k, N - 1) { if (sa[k].first == x && sa[k].second == y) { c++; } } ans = min(ans, N - c); } cout << ans << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < n; ++i) #define repR(i, n) for (ll i = n; i >= 0; ++i) #define FDS(i, n) for (ll i = 0; i < n; ++i) #define FDSR(i, n) for (ll i = n; i >= 0; ++i) #define FOR(i, m, n) for (ll i = m; i < n; ++i) #define FORR(i, m, n) for (ll i = m; i >= n; --i) #define VSORT(v) sort(v.begin(), v.end()); #define VREV(v) reverse(v.begin(), v.end()); #define INF 999999999 #define itn ll #define ednl endl using namespace std; typedef long long ll; template <typename Typell> Typell G_C_D(Typell a, Typell b) { if (a < 0) a = -a; if (b < 0) b = -b; while (b != 0) { a %= b; if (a == 0) return b; b %= a; } return a; } template <typename Typell> Typell G_C_D(const std::vector<Typell> &list) { Typell a = list[0]; for (size_t i = 1; i < list.size(); ++i) { a = G_C_D(a, list[i]); } return a; } template <typename Typell> Typell L_C_M(Typell a, Typell b) { if (a == 0 && b == 0) return 0; return a / G_C_D(a, b) * b; } template <typename Typell> Typell L_C_M(const std::vector<Typell> &list) { Typell a = list[0]; for (size_t i = 1; i < list.size(); ++i) { a = L_C_M(a, list[i]); } return a; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<ll> A(N); vector<ll> B(N); FDS(i, N) { cin >> A[i] >> B[i]; } vector<pair<ll, ll>> sa; FDS(i, N) FDS(j, N) { if (i == j) continue; sa.push_back(make_pair(A[j] - A[i], B[j] - B[i])); } int ans = N; FDS(i, sa.size()) { ll x = sa[i].first, y = sa[i].second; int c = 0; FDS(k, sa.size()) { if (sa[k].first == x && sa[k].second == y) { c++; } } ans = min(ans, N - c); } cout << ans << endl; }
[ "call.add" ]
820,981
820,982
u168579419
cpp
p03006
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int64_t MOD = 1000000007; int main() { int N; cin >> N; vector<int64_t> A(N); vector<int64_t> B(N); vector<pair<int64_t, int64_t>> dif; vector<int64_t> same; rep(i, N) cin >> A.at(i) >> B.at(i); if (N == 1 || N == 2) cout << 1; else { for (int i = 0; i < N - 1; i++) { for (int j = i + 1; j < N; j++) { int64_t a = A.at(i), b = A.at(j), c = B.at(i), d = B.at(j); dif.push_back(make_pair(a - b, c - d)); } } int T = dif.size(), count = 0; for (int i = 0; i < T - 1; i++) { count = 0; for (int j = i + 1; j < T; j++) { int64_t a = dif.at(i).first, b = dif.at(i).second, c = dif.at(j).first, d = dif.at(j).second; if (a == c && b == d) count++; if (a == -1 * c && b == -1 * d) count++; } same.push_back(count); } sort(same.begin(), same.end()); reverse(same.begin(), same.end()); cout << same.at(0); } }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int64_t MOD = 1000000007; int main() { int N; cin >> N; vector<int64_t> A(N); vector<int64_t> B(N); vector<pair<int64_t, int64_t>> dif; vector<int64_t> same; rep(i, N) cin >> A.at(i) >> B.at(i); if (N == 1 || N == 2) cout << 1; else { for (int i = 0; i < N - 1; i++) { for (int j = i + 1; j < N; j++) { int64_t a = A.at(i), b = A.at(j), c = B.at(i), d = B.at(j); dif.push_back(make_pair(a - b, c - d)); } } int T = dif.size(), count = 0; for (int i = 0; i < T - 1; i++) { count = 0; for (int j = i + 1; j < T; j++) { int64_t a = dif.at(i).first, b = dif.at(i).second, c = dif.at(j).first, d = dif.at(j).second; if (a == c && b == d) count++; if (a == -1 * c && b == -1 * d) count++; } same.push_back(count); } sort(same.begin(), same.end()); reverse(same.begin(), same.end()); cout << N - 1 - same.at(0); } }
[ "expression.operation.binary.add" ]
820,985
820,986
u153686508
cpp
p03006
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n; vector<pair<long long, long long>> a; for (int i = 0; i < n; i++) { cin >> x >> y; a.push_back({x, y}); } sort(a.begin(), a.end()); int ans = n; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { int dx = a[i].first - a[j].first; int dy = a[i].second - a[j].second; map<pair<long long, long long>, bool> mp; int cnt = 0; for (int k = 0; k < n; k++) { int px = a[k].first + dx; int py = a[k].second + dy; if (mp[{px, py}] == false || dx == 0 || dy == 0) { cnt++; } mp[a[k]] = true; } ans = min(ans, cnt); } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n; vector<pair<long long, long long>> a; for (int i = 0; i < n; i++) { cin >> x >> y; a.push_back({x, y}); } sort(a.begin(), a.end()); int ans = n; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { int dx = a[i].first - a[j].first; int dy = a[i].second - a[j].second; map<pair<long long, long long>, bool> mp; int cnt = 0; for (int k = 0; k < n; k++) { int px = a[k].first + dx; int py = a[k].second + dy; if (mp[{px, py}] == false || (dx == 0 && dy == 0)) { cnt++; } mp[a[k]] = true; } ans = min(ans, cnt); } } cout << ans; return 0; }
[ "control_flow.branch.if.condition.change", "misc.opposites" ]
821,007
821,008
u192159607
cpp
p03006
#include "bits/stdc++.h" using namespace std; using ll = long long int; #define rep(i, a, b) for (int i = a; i < b; i++) #define rrep(i, a, b) for (int i = a; i >= b; i--) #define fore(i, a) for (auto &i : a) #define all(x) (x).begin(), (x).end() #define pi 3.14159265358979323846 template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } ll cnt_rep = 0; ll powmod(ll N, ll P, ll M) { cnt_rep++; if (P == 0) return 1; if (P % 2 == 0) { ll t = powmod(N, P / 2, M); return t * t % M; } return (N * powmod(N, P - 1, M)) % M; } ll gcd(ll a, ll b) { ll resi, g, l; if (a > b) { g = a; l = b; } else if (b > a) { g = b; l = a; } else { return a; } resi = g % l; if (resi != 0) { return gcd(l, resi); } else { return l; } } template <typename T> void remove(std::vector<T> &vector, unsigned int index) { vector.erase(vector.begin() + index); } int ans = 0; int N, M, Q; template <typename T> void showall(vector<T> v) { rep(i, 0, v.size()) { cout << v[i] << " "; } cout << endl; } template <typename T> ll com(T n, T m, T mod) { ll a = 1, b = 1, ans; if (n == m || m == 0) { ans = 1; } else { for (ll i = 0; i < m; i++) { a *= n - i; a %= mod; b *= i + 1; b %= mod; } ans = (a * powmod(b, mod - 2, mod)) % mod; } return ans; } int main() { ll N; cin >> N; vector<ll> x(N), y(N); rep(i, 0, N) { ll xi, yi; cin >> xi >> yi; x[i] = xi; y[i] = yi; } map<pair<ll, ll>, ll> cnt; rep(i, 0, N) { rep(j, i + 1, N) { if (i == j) continue; ll x_diff = abs(x[i] - x[j]); ll y_diff = abs(y[i] - y[j]); cnt[make_pair(x_diff, y_diff)]++; } } ll max = 0; for (auto i = cnt.begin(); i != cnt.end(); i++) { if (max < (i->second)) max = (i->second); } cout << N - max << endl; }
#include "bits/stdc++.h" using namespace std; using ll = long long int; #define rep(i, a, b) for (int i = a; i < b; i++) #define rrep(i, a, b) for (int i = a; i >= b; i--) #define fore(i, a) for (auto &i : a) #define all(x) (x).begin(), (x).end() #define pi 3.14159265358979323846 template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } ll cnt_rep = 0; ll powmod(ll N, ll P, ll M) { cnt_rep++; if (P == 0) return 1; if (P % 2 == 0) { ll t = powmod(N, P / 2, M); return t * t % M; } return (N * powmod(N, P - 1, M)) % M; } ll gcd(ll a, ll b) { ll resi, g, l; if (a > b) { g = a; l = b; } else if (b > a) { g = b; l = a; } else { return a; } resi = g % l; if (resi != 0) { return gcd(l, resi); } else { return l; } } template <typename T> void remove(std::vector<T> &vector, unsigned int index) { vector.erase(vector.begin() + index); } int ans = 0; int N, M, Q; template <typename T> void showall(vector<T> v) { rep(i, 0, v.size()) { cout << v[i] << " "; } cout << endl; } template <typename T> ll com(T n, T m, T mod) { ll a = 1, b = 1, ans; if (n == m || m == 0) { ans = 1; } else { for (ll i = 0; i < m; i++) { a *= n - i; a %= mod; b *= i + 1; b %= mod; } ans = (a * powmod(b, mod - 2, mod)) % mod; } return ans; } int main() { ll N; cin >> N; vector<ll> x(N), y(N); rep(i, 0, N) { ll xi, yi; cin >> xi >> yi; x[i] = xi; y[i] = yi; } map<pair<ll, ll>, ll> cnt; rep(i, 0, N) { rep(j, 0, N) { if (i == j) continue; ll x_diff = (x[i] - x[j]); ll y_diff = (y[i] - y[j]); cnt[make_pair(x_diff, y_diff)]++; } } ll max = 0; for (auto i = cnt.begin(); i != cnt.end(); i++) { if (max < (i->second)) max = (i->second); } cout << N - max << endl; }
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
821,011
821,012
u434910428
cpp
p03006
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> P; typedef pair<int, int> Pi; #define rep(i, n) for (ll i = 0; i < n; i++) #define FOR(i, a, b) for (ll i = a; i < b; i++) #define fi first #define se second #define endl "\n" template <typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <typename T> ostream &operator<<(ostream &s, const complex<T> &d) { return s << "(" << d.real() << ", " << d.imag() << ")"; } template <typename T1, typename T2> ostream &operator<<(ostream &s, const pair<T1, T2> &d) { return s << "(" << d.first << ", " << d.second << ")"; } template <typename T> ostream &operator<<(ostream &s, const vector<T> &d) { int len = d.size(); rep(i, len) { s << d[i]; if (i < len - 1) s << " "; } return s; } template <typename T> ostream &operator<<(ostream &s, const vector<vector<T>> &d) { int len = d.size(); rep(i, len) { s << d[i] << endl; } return s; } template <typename T> ostream &operator<<(ostream &s, const set<T> &v) { s << "{ "; for (auto itr = v.begin(); itr != v.end(); ++itr) { if (itr != v.begin()) { s << ", "; } s << (*itr); } s << " }"; return s; } template <typename T> ostream &operator<<(ostream &s, const multiset<T> &v) { s << "{ "; for (auto itr = v.begin(); itr != v.end(); ++itr) { if (itr != v.begin()) { s << ", "; } s << (*itr); } s << " }"; return s; } template <typename T1, typename T2> ostream &operator<<(ostream &s, const map<T1, T2> &m) { s << "{" << endl; for (auto itr = m.begin(); itr != m.end(); ++itr) { s << " " << (*itr).first << " : " << (*itr).second << endl; } s << "}" << endl; return s; } const ll mod = 1e9 + 7; const ll inf = 1e17; const int INF = 1e9; const double EPS = 1e-10; const double PI = acos(-1); int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<P> g(n); rep(i, n) cin >> g[i].fi >> g[i].se; if (n == 1) { cout << 0 << endl; return 0; } map<P, int> mp; rep(i, n) rep(j, n) { if (i == j) continue; ll p = g[j].fi - g[i].fi, q = g[j].se - g[j].se; mp[P(p, q)]++; } int cnt = 0; for (auto itr : mp) chmax(cnt, itr.se); cout << n - cnt << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> P; typedef pair<int, int> Pi; #define rep(i, n) for (ll i = 0; i < n; i++) #define FOR(i, a, b) for (ll i = a; i < b; i++) #define fi first #define se second #define endl "\n" template <typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <typename T> ostream &operator<<(ostream &s, const complex<T> &d) { return s << "(" << d.real() << ", " << d.imag() << ")"; } template <typename T1, typename T2> ostream &operator<<(ostream &s, const pair<T1, T2> &d) { return s << "(" << d.first << ", " << d.second << ")"; } template <typename T> ostream &operator<<(ostream &s, const vector<T> &d) { int len = d.size(); rep(i, len) { s << d[i]; if (i < len - 1) s << " "; } return s; } template <typename T> ostream &operator<<(ostream &s, const vector<vector<T>> &d) { int len = d.size(); rep(i, len) { s << d[i] << endl; } return s; } template <typename T> ostream &operator<<(ostream &s, const set<T> &v) { s << "{ "; for (auto itr = v.begin(); itr != v.end(); ++itr) { if (itr != v.begin()) { s << ", "; } s << (*itr); } s << " }"; return s; } template <typename T> ostream &operator<<(ostream &s, const multiset<T> &v) { s << "{ "; for (auto itr = v.begin(); itr != v.end(); ++itr) { if (itr != v.begin()) { s << ", "; } s << (*itr); } s << " }"; return s; } template <typename T1, typename T2> ostream &operator<<(ostream &s, const map<T1, T2> &m) { s << "{" << endl; for (auto itr = m.begin(); itr != m.end(); ++itr) { s << " " << (*itr).first << " : " << (*itr).second << endl; } s << "}" << endl; return s; } const ll mod = 1e9 + 7; const ll inf = 1e17; const int INF = 1e9; const double EPS = 1e-10; const double PI = acos(-1); int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<P> g(n); rep(i, n) cin >> g[i].fi >> g[i].se; if (n == 1) { cout << 1 << endl; return 0; } map<P, int> mp; rep(i, n) rep(j, n) { if (i == j) continue; ll p = g[j].fi - g[i].fi, q = g[j].se - g[i].se; mp[P(p, q)]++; } int cnt = 0; for (auto itr : mp) chmax(cnt, itr.se); cout << n - cnt << endl; }
[ "literal.number.change", "io.output.change", "identifier.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
821,025
821,024
u340010271
cpp
p03006
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<double, double> pdd; const ull mod = 1e9 + 7; #define REP(i, n) for (int i = 0; i < (int)n; ++i) // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; template <class S, class T> ostream &operator<<(ostream &os, const pair<S, T> v) { os << "(" << v.first << ", " << v.second << ")"; return os; } template <class T> ostream &operator<<(ostream &os, const vector<T> v) { for (int i = 0; i < v.size(); i++) { if (i > 0) { os << " "; } os << v[i]; } return os; } template <class T> ostream &operator<<(ostream &os, const vector<vector<T>> v) { for (int i = 0; i < v.size(); i++) { if (i > 0) { os << endl; } os << v[i]; } return os; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; vector<ll> x(N), y(N); REP(i, N) cin >> x[i] >> y[i]; multiset<pll> st; REP(i, N) REP(j, N) { if (i >= j) continue; st.insert({x[j] - x[i], y[j] - y[i]}); } ll ma = 0; REP(i, N) REP(j, N) { ll p = x[i] - x[j]; ll q = y[i] - y[j]; ll tmp = 0; tmp += st.count({p, q}); tmp += st.count({-p, -q}); ma = max(tmp, tmp); } cout << N - ma << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<double, double> pdd; const ull mod = 1e9 + 7; #define REP(i, n) for (int i = 0; i < (int)n; ++i) // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; template <class S, class T> ostream &operator<<(ostream &os, const pair<S, T> v) { os << "(" << v.first << ", " << v.second << ")"; return os; } template <class T> ostream &operator<<(ostream &os, const vector<T> v) { for (int i = 0; i < v.size(); i++) { if (i > 0) { os << " "; } os << v[i]; } return os; } template <class T> ostream &operator<<(ostream &os, const vector<vector<T>> v) { for (int i = 0; i < v.size(); i++) { if (i > 0) { os << endl; } os << v[i]; } return os; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; vector<ll> x(N), y(N); REP(i, N) cin >> x[i] >> y[i]; multiset<pll> st; REP(i, N) REP(j, N) { if (i >= j) continue; st.insert({x[j] - x[i], y[j] - y[i]}); } ll ma = 0; REP(i, N) REP(j, N) { ll p = x[i] - x[j]; ll q = y[i] - y[j]; ll tmp = 0; tmp += st.count({p, q}); tmp += st.count({-p, -q}); ma = max(tmp, ma); } cout << N - ma << endl; return 0; }
[ "assignment.value.change", "identifier.change", "call.arguments.change" ]
821,028
821,029
u895971408
cpp
p03006
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) using P = pair<int, int>; using ll = long long; static const int INF = 1000000000; static const ll MOD = 1000000007; ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { int n; cin >> n; vector<P> point(n); rep(i, n) { int x, y; cin >> x >> y; point[i] = P(x, y); } map<P, int> mp; for (int i = 0; i < n; ++i) { for (int j = i; j < n; ++j) { int p = point[i].first - point[j].first; int q = point[i].second - point[j].second; mp[P(p, q)]++; mp[P(-p, -q)]++; } } int mx = 0; for (auto it_point : mp) { mx = max(mx, it_point.second); } cout << n - mx << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) using P = pair<int, int>; using ll = long long; static const int INF = 1000000000; static const ll MOD = 1000000007; ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { int n; cin >> n; vector<P> point(n); rep(i, n) { int x, y; cin >> x >> y; point[i] = P(x, y); } map<P, int> mp; for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { int p = point[i].first - point[j].first; int q = point[i].second - point[j].second; mp[P(p, q)]++; mp[P(-p, -q)]++; } } int mx = 0; for (auto it_point : mp) { mx = max(mx, it_point.second); } cout << n - mx << endl; return 0; }
[ "control_flow.loop.for.initializer.change" ]
821,032
821,033
u741815956
cpp
p03006
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <bitset> #include <climits> #include <float.h> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <time.h> #include <utility> #include <vector> using namespace std; typedef pair<int, int> p; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } vector<long long> divisor(long long n) { vector<long long> ret; for (long long i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } struct LazySegmentTree { private: int n; vector<int> node, lazy; vector<bool> lazyFlag; public: LazySegmentTree(vector<int> v) { int sz = (int)v.size(); n = 1; while (n < sz) n *= 2; node.resize(2 * n - 1); lazy.resize(2 * n - 1, INT_MAX); lazyFlag.resize(2 * n - 1, false); for (int i = 0; i < sz; i++) node[i + n - 1] = v[i]; for (int i = n - 2; i >= 0; i--) node[i] = min(node[i * 2 + 1], node[i * 2 + 2]); } void lazyEvaluate(int k, int l, int r) { if (lazyFlag[k]) { node[k] = lazy[k]; if (r - l > 1) { lazy[k * 2 + 1] = lazy[k * 2 + 2] = lazy[k]; lazyFlag[k * 2 + 1] = lazyFlag[k * 2 + 2] = true; } lazyFlag[k] = false; } } void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) { if (r < 0) r = n; lazyEvaluate(k, l, r); if (b <= l || r <= a) return; if (a <= l && r <= b) { lazy[k] = x; lazyFlag[k] = true; lazyEvaluate(k, l, r); } else { update(a, b, x, 2 * k + 1, l, (l + r) / 2); update(a, b, x, 2 * k + 2, (l + r) / 2, r); node[k] = min(node[2 * k + 1], node[2 * k + 2]); } } int find(int a, int b, int k = 0, int l = 0, int r = -1) { if (r < 0) r = n; lazyEvaluate(k, l, r); if (b <= l || r <= a) return INT_MAX; if (a <= l && r <= b) return node[k]; int vl = find(a, b, 2 * k + 1, l, (l + r) / 2); int vr = find(a, b, 2 * k + 2, (l + r) / 2, r); return min(vl, vr); } }; long long mod = 1000000007; signed main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(16); int n; cin >> n; p point[53]; for (int i = 0; i < n; i++) { cin >> point[i].first >> point[i].second; } int ans = INT_MAX; if (n == 1) { cout << 1; return 0; } sort(point, point + n); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { int P = abs(point[j].first - point[i].first); int Q = abs(point[j].second - point[i].second); int used[53] = {0}; int cnt = 0; for (int x = 0; x < n; x++) { if (used[x] == 0) { cnt += 1; int nextx = point[x].first; int nexty = point[x].second; int judge = 1; while (judge) { judge = 0; for (int y = 0; y < n; y++) { if (point[y].first == nextx && point[y].second == nexty) { used[y] = 1; nextx += P; nexty += Q; judge = 1; break; } } } } } ans = min(ans, cnt); } } cout << ans; }
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <bitset> #include <climits> #include <float.h> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <time.h> #include <utility> #include <vector> using namespace std; typedef pair<int, int> p; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } vector<long long> divisor(long long n) { vector<long long> ret; for (long long i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } struct LazySegmentTree { private: int n; vector<int> node, lazy; vector<bool> lazyFlag; public: LazySegmentTree(vector<int> v) { int sz = (int)v.size(); n = 1; while (n < sz) n *= 2; node.resize(2 * n - 1); lazy.resize(2 * n - 1, INT_MAX); lazyFlag.resize(2 * n - 1, false); for (int i = 0; i < sz; i++) node[i + n - 1] = v[i]; for (int i = n - 2; i >= 0; i--) node[i] = min(node[i * 2 + 1], node[i * 2 + 2]); } void lazyEvaluate(int k, int l, int r) { if (lazyFlag[k]) { node[k] = lazy[k]; if (r - l > 1) { lazy[k * 2 + 1] = lazy[k * 2 + 2] = lazy[k]; lazyFlag[k * 2 + 1] = lazyFlag[k * 2 + 2] = true; } lazyFlag[k] = false; } } void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) { if (r < 0) r = n; lazyEvaluate(k, l, r); if (b <= l || r <= a) return; if (a <= l && r <= b) { lazy[k] = x; lazyFlag[k] = true; lazyEvaluate(k, l, r); } else { update(a, b, x, 2 * k + 1, l, (l + r) / 2); update(a, b, x, 2 * k + 2, (l + r) / 2, r); node[k] = min(node[2 * k + 1], node[2 * k + 2]); } } int find(int a, int b, int k = 0, int l = 0, int r = -1) { if (r < 0) r = n; lazyEvaluate(k, l, r); if (b <= l || r <= a) return INT_MAX; if (a <= l && r <= b) return node[k]; int vl = find(a, b, 2 * k + 1, l, (l + r) / 2); int vr = find(a, b, 2 * k + 2, (l + r) / 2, r); return min(vl, vr); } }; long long mod = 1000000007; signed main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(16); int n; cin >> n; p point[53]; for (int i = 0; i < n; i++) { cin >> point[i].first >> point[i].second; } int ans = INT_MAX; if (n == 1) { cout << 1; return 0; } sort(point, point + n); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { int P = (point[j].first - point[i].first); int Q = (point[j].second - point[i].second); int used[53] = {0}; int cnt = 0; for (int x = 0; x < n; x++) { if (used[x] == 0) { cnt += 1; int nextx = point[x].first; int nexty = point[x].second; int judge = 1; while (judge) { judge = 0; for (int y = 0; y < n; y++) { if (point[y].first == nextx && point[y].second == nexty) { used[y] = 1; nextx += P; nexty += Q; judge = 1; break; } } } } } ans = min(ans, cnt); } } cout << ans; }
[]
821,072
821,073
u313288017
cpp
p03006
#pragma GCC optimize(3, "Ofast", "inline") #include <bits/stdc++.h> #define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define ms(a, b) memset(a, b, sizeof(a)) #define msn(a, n, b) \ for (int i = 0; i <= n; i++) \ a[i] = b #define lson l, mid, rt << 1 #define rson mid + 1, r, rt << 1 | 1 #define fi first #define se second using namespace std; mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count()); typedef long long ll; typedef long double ld; typedef pair<ll, ll> P; const int mod = 1e9 + 7; const int seed = 233; const double PI = acos(-1.0); const double eps = 1e-7; const int inf = 0x3f3f3f3f; const int max_n = 100005; namespace { inline int Add(int x, int y) { return (x += y) >= mod ? x - mod : x; } inline int Sub(int x, int y) { return (x -= y) < 0 ? x + mod : x; } inline int Mul(int x, int y) { return 1ll * x * y % mod; } inline int Pow(int x, int y = mod - 2) { int res = 1; while (y) { if (y & 1) res = 1ll * res * x % mod; x = 1ll * x * x % mod; y >>= 1; } return res; } } // namespace /**********************head************************/ P p[55]; int n; int cal(ll dx, ll dy) { set<P> s; for (int i = 1; i <= n; i++) s.insert(p[i]); int res = 0; while (!s.empty()) { P tp = *s.begin(); ll x = tp.fi, y = tp.se; while (s.find(P(x, y)) != s.end()) { s.erase(P(x, y)); x += dx, y += dy; } res++; } return res; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%lld%lld", &p[i].fi, &p[i].se); ll dx = 0, dy = 0; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { dx = __gcd(dx, abs(p[i].fi - p[j].fi)); dy = __gcd(dy, abs(p[i].se - p[j].se)); } } int ans = cal(dx, dy); ans = min(ans, cal(dx, -dy)); ans = min(ans, cal(-dx, dy)); ans = min(ans, cal(-dx, -dy)); ans = min(ans, cal(0, dy)); ans = min(ans, cal(dx, 0)); printf("%d\n", ans); return 0; }
#pragma GCC optimize(3, "Ofast", "inline") #include <bits/stdc++.h> #define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define ms(a, b) memset(a, b, sizeof(a)) #define msn(a, n, b) \ for (int i = 0; i <= n; i++) \ a[i] = b #define lson l, mid, rt << 1 #define rson mid + 1, r, rt << 1 | 1 #define fi first #define se second using namespace std; mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count()); typedef long long ll; typedef long double ld; typedef pair<int, int> P; const int mod = 1e9 + 7; const int seed = 233; const double PI = acos(-1.0); const double eps = 1e-7; const int inf = 0x3f3f3f3f; const int max_n = 100005; namespace { inline int Add(int x, int y) { return (x += y) >= mod ? x - mod : x; } inline int Sub(int x, int y) { return (x -= y) < 0 ? x + mod : x; } inline int Mul(int x, int y) { return 1ll * x * y % mod; } inline int Pow(int x, int y = mod - 2) { int res = 1; while (y) { if (y & 1) res = 1ll * res * x % mod; x = 1ll * x * x % mod; y >>= 1; } return res; } } // namespace /**********************head************************/ P p[55]; int n; int cal(ll dx, ll dy) { set<P> s; for (int i = 1; i <= n; i++) s.insert(p[i]); int res = 0; while (!s.empty()) { P tp = *s.begin(); ll x = tp.fi, y = tp.se; while (s.find(P(x, y)) != s.end()) { s.erase(P(x, y)); x += dx, y += dy; } res++; } return res; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%lld%lld", &p[i].fi, &p[i].se); map<P, int> mp; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (j == i) continue; int dx = p[i].fi - p[j].fi, dy = p[i].se - p[j].se; mp[P(dx, dy)]++; } } int ans = 0; for (auto x : mp) ans = max(ans, x.second); printf("%d\n", n - ans); return 0; }
[]
821,088
821,089
u019233781
cpp
p03006
#pragma GCC optimize(3, "Ofast", "inline") #include <bits/stdc++.h> #define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define ms(a, b) memset(a, b, sizeof(a)) #define msn(a, n, b) \ for (int i = 0; i <= n; i++) \ a[i] = b #define lson l, mid, rt << 1 #define rson mid + 1, r, rt << 1 | 1 #define fi first #define se second using namespace std; mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count()); typedef long long ll; typedef long double ld; typedef pair<ll, ll> P; const int mod = 1e9 + 7; const int seed = 233; const double PI = acos(-1.0); const double eps = 1e-7; const int inf = 0x3f3f3f3f; const int max_n = 100005; namespace { inline int Add(int x, int y) { return (x += y) >= mod ? x - mod : x; } inline int Sub(int x, int y) { return (x -= y) < 0 ? x + mod : x; } inline int Mul(int x, int y) { return 1ll * x * y % mod; } inline int Pow(int x, int y = mod - 2) { int res = 1; while (y) { if (y & 1) res = 1ll * res * x % mod; x = 1ll * x * x % mod; y >>= 1; } return res; } } // namespace /**********************head************************/ P p[55]; int n; int cal(ll dx, ll dy) { set<P> s; for (int i = 1; i <= n; i++) s.insert(p[i]); int res = 0; while (!s.empty()) { P tp = *s.begin(); ll x = tp.fi, y = tp.se; while (s.find(P(x, y)) != s.end()) { s.erase(P(x, y)); x += dx, y += dy; } res++; } return res; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%lld%lld", &p[i].fi, &p[i].se); ll dx = 0, dy = 0; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { dx = __gcd(dx, abs(p[i].fi - p[j].fi)); dy = __gcd(dy, abs(p[i].se - p[j].se)); } } int ans = cal(dx, dy); ans = min(ans, cal(0, dy)); ans = min(ans, cal(dx, 0)); printf("%d\n", ans); return 0; }
#pragma GCC optimize(3, "Ofast", "inline") #include <bits/stdc++.h> #define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define ms(a, b) memset(a, b, sizeof(a)) #define msn(a, n, b) \ for (int i = 0; i <= n; i++) \ a[i] = b #define lson l, mid, rt << 1 #define rson mid + 1, r, rt << 1 | 1 #define fi first #define se second using namespace std; mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count()); typedef long long ll; typedef long double ld; typedef pair<int, int> P; const int mod = 1e9 + 7; const int seed = 233; const double PI = acos(-1.0); const double eps = 1e-7; const int inf = 0x3f3f3f3f; const int max_n = 100005; namespace { inline int Add(int x, int y) { return (x += y) >= mod ? x - mod : x; } inline int Sub(int x, int y) { return (x -= y) < 0 ? x + mod : x; } inline int Mul(int x, int y) { return 1ll * x * y % mod; } inline int Pow(int x, int y = mod - 2) { int res = 1; while (y) { if (y & 1) res = 1ll * res * x % mod; x = 1ll * x * x % mod; y >>= 1; } return res; } } // namespace /**********************head************************/ P p[55]; int n; int cal(ll dx, ll dy) { set<P> s; for (int i = 1; i <= n; i++) s.insert(p[i]); int res = 0; while (!s.empty()) { P tp = *s.begin(); ll x = tp.fi, y = tp.se; while (s.find(P(x, y)) != s.end()) { s.erase(P(x, y)); x += dx, y += dy; } res++; } return res; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%lld%lld", &p[i].fi, &p[i].se); map<P, int> mp; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (j == i) continue; int dx = p[i].fi - p[j].fi, dy = p[i].se - p[j].se; mp[P(dx, dy)]++; } } int ans = 0; for (auto x : mp) ans = max(ans, x.second); printf("%d\n", n - ans); return 0; }
[]
821,090
821,089
u019233781
cpp
p03006
#include <bits/stdc++.h> using namespace std; #define rep2(x, fr, to) for (int(x) = (fr); (x) < (to); (x)++) #define rep(x, to) for (int(x) = 0; (x) < (to); (x)++) #define repr(x, fr, to) for (int(x) = (fr); (x) >= (to); (x)--) #define all(c) (c).begin(), (c).end() #define sz(v) (int)(v).size() typedef int64_t ll; typedef vector<int> VI; typedef pair<int, int> pii; const int MD = 1e9 + 7; typedef vector<ll> VL; void dbg() { cerr << "\n"; } template <typename T, typename... T2> void dbg(const T &fst, const T2 &...rst) { cerr << fst << ": "; dbg(rst...); } int main() { cin.tie(0); ios_base::sync_with_stdio(false); int n; cin >> n; vector<VI> x(n, VI(2)); rep(i, n) cin >> x[i][0] >> x[i][1]; sort(all(x)); map<pii, int> mp; rep(i, n) rep2(j, i + 1, n) { mp[pii(abs(x[j][0] - x[i][0]), abs(x[j][1] - x[i][1]))]++; } // for(auto x :mp) printf("%d:%d:%d, ",x.first.first,x.first.second,x.second); // puts(""); int mx = 0; for (auto x : mp) mx = max(mx, x.second); cout << n - mx << "\n"; }
#include <bits/stdc++.h> using namespace std; #define rep2(x, fr, to) for (int(x) = (fr); (x) < (to); (x)++) #define rep(x, to) for (int(x) = 0; (x) < (to); (x)++) #define repr(x, fr, to) for (int(x) = (fr); (x) >= (to); (x)--) #define all(c) (c).begin(), (c).end() #define sz(v) (int)(v).size() typedef int64_t ll; typedef vector<int> VI; typedef pair<int, int> pii; const int MD = 1e9 + 7; typedef vector<ll> VL; void dbg() { cerr << "\n"; } template <typename T, typename... T2> void dbg(const T &fst, const T2 &...rst) { cerr << fst << ": "; dbg(rst...); } int main() { cin.tie(0); ios_base::sync_with_stdio(false); int n; cin >> n; vector<VI> x(n, VI(2)); rep(i, n) cin >> x[i][0] >> x[i][1]; sort(all(x)); map<pii, int> mp; rep(i, n) rep2(j, i + 1, n) { mp[pii(x[j][0] - x[i][0], x[j][1] - x[i][1])]++; } // for(auto x :mp) printf("%d:%d:%d, ",x.first.first,x.first.second,x.second); // puts(""); int mx = 0; for (auto x : mp) mx = max(mx, x.second); cout << n - mx << "\n"; }
[ "call.arguments.change", "call.remove" ]
821,111
821,112
u714564133
cpp
p03006
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back main() { // freopen("input.txt","r",stdin);freopen("output.txt","w",stdout); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; vector<pair<int, int>> v(n); for (int i = 0; i < n; i++) cin >> v[i].first >> v[i].second; sort(v.begin(), v.end()); map<pair<int, int>, int> m; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { m[{abs(v[j].first - v[i].first), abs(v[j].second - v[i].second)}]++; } } int k = 0; for (auto i : m) k = max(k, i.second); cout << n - k; }
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back main() { // freopen("input.txt","r",stdin);freopen("output.txt","w",stdout); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; vector<pair<int, int>> v(n); for (int i = 0; i < n; i++) cin >> v[i].first >> v[i].second; sort(v.begin(), v.end()); map<pair<int, int>, int> m; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) m[{(v[j].first - v[i].first), (v[j].second - v[i].second)}]++; } int k = 0; for (auto i : m) k = max(k, i.second); cout << n - k; }
[]
821,130
821,131
u862953056
cpp
p03007
// {{{ by unolight #pragma region #include <bits/stdc++.h> #include <unistd.h> #pragma GCC diagnostic ignored "-Wunused-result" #pragma GCC diagnostic ignored "-Wunused-function" #define SZ(x) ((int)(x).size()) #define ALL(x) begin(x), end(x) #define RALL(x) rbegin(x), rend(x) #define REP(i, n) for (int i = 0; i < int(n); i++) #define REP1(i, a, b) for (int i = (a); i <= int(b); i++) #define MP make_pair #define PB push_back using namespace std; typedef int64_t LL; typedef pair<int, int> PII; typedef vector<int> VI; namespace { namespace unolight { // Read Input template <class T> void _R(T &x) { cin >> x; } void _R(int &x) { scanf("%d", &x); } void _R(int64_t &x) { scanf("%" PRId64, &x); } void _R(double &x) { scanf("%lf", &x); } void _R(char &x) { scanf(" %c", &x); } void _R(char *x) { scanf("%s", x); } void R() {} template <class T, class... U> void R(T &head, U &...tail) { _R(head); R(tail...); } // Write Output template <class T> void _W(const T &x) { cout << x; } void _W(const int &x) { printf("%d", x); } void _W(const int64_t &x) { printf("%" PRId64, x); } void _W(const double &x) { printf("%.16f\n", x); } void _W(const char &x) { putchar(x); } void _W(const char *x) { printf("%s", x); } template <class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); } void W() {} template <class T, class... U> void W(const T &head, const U &...tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); } #ifdef UNOLIGHT #include "dump.hpp" #else #define dump(...) #endif template <class T> inline bool chmax(T &a, const T &b) { return b > a ? a = b, true : false; } template <class T> inline bool chmin(T &a, const T &b) { return b < a ? a = b, true : false; } template <class T> using MaxHeap = priority_queue<T>; template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>; template <class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); } #pragma endregion // }}} void main() { int n; R(n); VI a(n); REP(i, n) R(a[i]); // 1+ n-1 -, 2+ n-2-,...,(n-1)+ 1- sort(ALL(a)); int m = lower_bound(ALL(a), 0) - a.begin(); chmin(m, n - 2); chmax(m, 1); int sum = a[0]; vector<PII> ans; for (int i = m; i < n - 1; i++) { ans.emplace_back(sum, a[i]); sum -= a[i]; } ans.emplace_back(a[n - 1], sum); sum -= a[n - 1]; sum *= -1; for (int i = 1; i < m; i++) { ans.emplace_back(sum, a[i]); sum -= a[i]; } W(sum); for (auto [a, b] : ans) W(a, b); } } // namespace unolight } // namespace int main() { unolight::main(); return 0; } // }}}
// {{{ by unolight #pragma region #include <bits/stdc++.h> #include <unistd.h> #pragma GCC diagnostic ignored "-Wunused-result" #pragma GCC diagnostic ignored "-Wunused-function" #define SZ(x) ((int)(x).size()) #define ALL(x) begin(x), end(x) #define RALL(x) rbegin(x), rend(x) #define REP(i, n) for (int i = 0; i < int(n); i++) #define REP1(i, a, b) for (int i = (a); i <= int(b); i++) #define MP make_pair #define PB push_back using namespace std; typedef int64_t LL; typedef pair<int, int> PII; typedef vector<int> VI; namespace { namespace unolight { // Read Input template <class T> void _R(T &x) { cin >> x; } void _R(int &x) { scanf("%d", &x); } void _R(int64_t &x) { scanf("%" PRId64, &x); } void _R(double &x) { scanf("%lf", &x); } void _R(char &x) { scanf(" %c", &x); } void _R(char *x) { scanf("%s", x); } void R() {} template <class T, class... U> void R(T &head, U &...tail) { _R(head); R(tail...); } // Write Output template <class T> void _W(const T &x) { cout << x; } void _W(const int &x) { printf("%d", x); } void _W(const int64_t &x) { printf("%" PRId64, x); } void _W(const double &x) { printf("%.16f\n", x); } void _W(const char &x) { putchar(x); } void _W(const char *x) { printf("%s", x); } template <class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); } void W() {} template <class T, class... U> void W(const T &head, const U &...tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); } #ifdef UNOLIGHT #include "dump.hpp" #else #define dump(...) #endif template <class T> inline bool chmax(T &a, const T &b) { return b > a ? a = b, true : false; } template <class T> inline bool chmin(T &a, const T &b) { return b < a ? a = b, true : false; } template <class T> using MaxHeap = priority_queue<T>; template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>; template <class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); } #pragma endregion // }}} void main() { int n; R(n); VI a(n); REP(i, n) R(a[i]); // 1+ n-1 -, 2+ n-2-,...,(n-1)+ 1- sort(ALL(a)); int m = lower_bound(ALL(a), 0) - a.begin(); chmin(m, n - 1); chmax(m, 1); int sum = a[0]; vector<PII> ans; for (int i = m; i < n - 1; i++) { ans.emplace_back(sum, a[i]); sum -= a[i]; } ans.emplace_back(a[n - 1], sum); sum -= a[n - 1]; sum *= -1; for (int i = 1; i < m; i++) { ans.emplace_back(sum, a[i]); sum -= a[i]; } W(sum); for (auto [a, b] : ans) W(a, b); } } // namespace unolight } // namespace int main() { unolight::main(); return 0; } // }}}
[ "literal.number.change", "call.arguments.change", "expression.operation.binary.change" ]
821,144
821,145
u385825353
cpp
p03007
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; typedef long long ll; int main() { int n, k = 0, i = 0; cin >> n; vector<ll> a(n), x(n - 1), y(n - 1); for (int i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end()); while (k + 1 < n && a[k + 1] < 0) k++; ll ans = 0, p = a[n - 1], m = a[0]; for (int j = 1; j <= k; j++) { x[i] = p; y[i] = a[j]; p -= a[j]; i++; } for (int j = k + 1; j < n - 1; j++) { y[i] = m; x[i] = a[j]; m -= a[j]; i++; } x[i] = p; y[i] = m; cout << p - m << endl; for (int j = 0; j < n - 1; j++) cout << x[j] << " " << y[j] << endl; return 0; }
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; typedef long long ll; int main() { int n, k = 0, i = 0; cin >> n; vector<ll> a(n), x(n - 1), y(n - 1); for (int i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end()); while (k + 1 < n - 1 && a[k + 1] < 0) k++; ll ans = 0, p = a[n - 1], m = a[0]; for (int j = 1; j <= k; j++) { x[i] = p; y[i] = a[j]; p -= a[j]; i++; } for (int j = k + 1; j < n - 1; j++) { x[i] = m; y[i] = a[j]; m -= a[j]; i++; } x[i] = p; y[i] = m; cout << p - m << endl; for (int j = 0; j < n - 1; j++) cout << x[j] << " " << y[j] << endl; return 0; }
[ "control_flow.loop.condition.change", "assignment.variable.change", "identifier.change" ]
821,148
821,147
u110383054
cpp
p03007
#include <bits/stdc++.h> using namespace std; const int maxn = 100100; int n; long long a[maxn]; int main() { cin >> n; for (int i = 1; i <= n; i++) scanf("%lld", a + i); sort(a + 1, a + n + 1, greater<long long>()); int st = n; for (int i = 2; i <= n; i++) if (a[i] < 0) st = i; long long ans = 0; for (int i = 1; i < st; i++) ans += a[i]; for (int i = st; i <= n; i++) ans -= a[i]; cout << ans << endl; for (int i = 2; i < st; i++) cout << a[st] << ' ' << a[i] << endl, a[st] -= a[i]; for (int i = st; i <= n; i++) cout << a[1] << ' ' << a[i] << endl, a[1] -= a[i]; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 100100; int n; long long a[maxn]; int main() { cin >> n; for (int i = 1; i <= n; i++) scanf("%lld", a + i); sort(a + 1, a + n + 1, greater<long long>()); int st = n; for (int i = 2; i <= n; i++) if (a[i] < 0) { st = i; break; } long long ans = 0; for (int i = 1; i < st; i++) ans += a[i]; for (int i = st; i <= n; i++) ans -= a[i]; cout << ans << endl; for (int i = 2; i < st; i++) cout << a[st] << ' ' << a[i] << endl, a[st] -= a[i]; for (int i = st; i <= n; i++) cout << a[1] << ' ' << a[i] << endl, a[1] -= a[i]; return 0; }
[ "control_flow.break.add" ]
821,152
821,153
u177525366
cpp
p03007
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> P; int INF = 1e16 + 7; int mod = 998244353; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; signed main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } sort(A.begin(), A.end()); vector<P> ans; for (int i = 1; i < N - 1; i++) { if (A[i] < 0) { ans.push_back({A[N - 1], A[i]}); A[N - 1] += A[i]; } else { ans.push_back({A[0], A[i]}); A[0] -= A[i]; } } cout << A[N - 1] - A[0] << endl; ans.push_back({A[N - 1], A[0]}); for (int i = 0; i < N - 1; i++) { cout << ans[i].first << " " << ans[i].second << endl; } }
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> P; int INF = 1e16 + 7; int mod = 998244353; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; signed main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } sort(A.begin(), A.end()); vector<P> ans; for (int i = 1; i < N - 1; i++) { if (A[i] < 0) { ans.push_back({A[N - 1], A[i]}); A[N - 1] -= A[i]; } else { ans.push_back({A[0], A[i]}); A[0] -= A[i]; } } cout << A[N - 1] - A[0] << endl; ans.push_back({A[N - 1], A[0]}); for (int i = 0; i < N - 1; i++) { cout << ans[i].first << " " << ans[i].second << endl; } }
[ "expression.operator.change" ]
821,171
821,172
u237390401
cpp
p03007
#include <algorithm> #include <bitset> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define req(i, n) for (int i = 1; i <= n; i++) #define rrep(i, n) for (ll i = n - 1; i >= 0; i--) #define ALL(obj) begin(obj), end(obj) #define RALL(a) rbegin(a), rend(a) typedef long long int ll; typedef long double ld; const ll INF = 1e18; template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); } const int MOD = 1e9 + 7; int main(void) { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; sort(ALL(a)); int ans = a[0], sum = a[n - 1]; sum = sum - ans; req(i, n - 2) sum += abs(a[i]); cout << sum << endl; sum = a[n - 1]; req(i, n - 2) { if (a[0] < 0) cout << sum << " " << a[i] << endl, a[i], sum -= a[i]; else cout << ans << " " << a[i] << endl, ans -= a[i]; } cout << sum << " " << ans << endl; }
#include <algorithm> #include <bitset> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define req(i, n) for (int i = 1; i <= n; i++) #define rrep(i, n) for (ll i = n - 1; i >= 0; i--) #define ALL(obj) begin(obj), end(obj) #define RALL(a) rbegin(a), rend(a) typedef long long int ll; typedef long double ld; const ll INF = 1e18; template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); } const int MOD = 1e9 + 7; int main(void) { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; sort(ALL(a)); int ans = a[0], sum = a[n - 1]; sum = sum - ans; req(i, n - 2) sum += abs(a[i]); cout << sum << endl; sum = a[n - 1]; req(i, n - 2) { if (a[i] < 0) cout << sum << " " << a[i] << endl, sum -= a[i]; else cout << ans << " " << a[i] << endl, ans -= a[i]; } cout << sum << " " << ans << endl; }
[ "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
821,179
821,180
u670898337
cpp
p03007
#include <algorithm> #include <bitset> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define req(i, n) for (int i = 1; i <= n; i++) #define rrep(i, n) for (ll i = n - 1; i >= 0; i--) #define ALL(obj) begin(obj), end(obj) #define RALL(a) rbegin(a), rend(a) typedef long long int ll; typedef long double ld; const ll INF = 1e18; template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); } const int MOD = 1e9 + 7; int main(void) { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; sort(ALL(a)); int ans = a[0], sum = a[n - 1]; sum = sum - ans; req(i, n - 2) sum += abs(a[i]); cout << sum << endl; sum = a[n - 1]; req(i, n - 2) { if (a[0] < 0) cout << sum << " " << endl, a[i], sum -= a[i]; else cout << ans << " " << a[i] << endl, ans -= a[i]; } cout << sum << " " << ans << endl; }
#include <algorithm> #include <bitset> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define req(i, n) for (int i = 1; i <= n; i++) #define rrep(i, n) for (ll i = n - 1; i >= 0; i--) #define ALL(obj) begin(obj), end(obj) #define RALL(a) rbegin(a), rend(a) typedef long long int ll; typedef long double ld; const ll INF = 1e18; template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); } const int MOD = 1e9 + 7; int main(void) { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; sort(ALL(a)); int ans = a[0], sum = a[n - 1]; sum = sum - ans; req(i, n - 2) sum += abs(a[i]); cout << sum << endl; sum = a[n - 1]; req(i, n - 2) { if (a[i] < 0) cout << sum << " " << a[i] << endl, sum -= a[i]; else cout << ans << " " << a[i] << endl, ans -= a[i]; } cout << sum << " " << ans << endl; }
[ "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "io.output.newline.add" ]
821,181
821,180
u670898337
cpp
p03007
#include <bits/stdc++.h> #include <random> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef double ld; #define int ll typedef vector<char> vc; typedef vector<vc> vvc; typedef vector<vvc> vvvc; typedef pair<int, int> pii; typedef pair<pii, pii> piii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<pii> vpi; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef vector<short> vs; typedef vector<vs> vvs; typedef vector<vvs> vvvs; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<vvl> vvvl; typedef vector<ld> vld; typedef vector<vld> vvld; typedef vector<vvld> vvvld; typedef vector<string> vst; typedef vector<vst> vvst; typedef pair<ld, ld> pld; #define inmin(a, b) a = min(a, (b)) #define inmax(a, b) a = max(a, (b)) #define ALL(a) a.begin(), a.end() #define RALL(a) a.rbegin(), a.rend() #define sqr(x) ((x) * (x)) #define fori(i, n) for (int i = 0; i < int(n); ++i) #define SZ(a) ((int)((a).size())) #define triple(T) tuple<T, T, T> #define quad(T) tuple<T, T, T, T> #define watch(x) cerr << (#x) << " = " << (x) << endl; #ifdef RUS_HOME #define cerr cout #else #define cerr \ if (false) \ cerr #endif const double PI = 2 * acos(0.0); #define rand shittttty_shit mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count()); const string DIGITS = "0123456789"; const string ALPH = "abcdefghijklmnopqrstuvwxyz"; template <class T0, class T1> inline ostream &operator<<(ostream &out, pair<T0, T1> &a) { return out << "{" << a.first << ", " << a.second << "}"; } template <class T0, class T1> inline istream &operator>>(istream &in, pair<T0, T1> &a) { return in >> a.first >> a.second; } template <class T0, class T1, class T2> inline ostream &operator<<(ostream &out, tuple<T0, T1, T2> &a) { return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}"; } template <class T0, class T1, class T2, class T3> inline ostream &operator<<(ostream &out, tuple<T0, T1, T2, T3> &a) { return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " << get<3>(a) << "}"; } template <class T> inline ostream &operator<<(ostream &out, vector<T> &a) { out << "["; fori(i, a.size()) out << a[i] << vector<string>{", ", "] "}[i + 1 == a.size()]; return out; } void smain(); signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef RUS_HOME freopen("input", "r", stdin); clock_t start = clock(); #endif cout << setprecision(12) << fixed; smain(); #ifdef RUS_HOME cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float(clock() - start) / CLOCKS_PER_SEC << endl; #endif return 0; } const int MOD = 998244353, N = 1e5 + 100, oo = 1e15; void smain() { int n; cin >> n; vi a(n); int cnt = 0; multiset<int> s, t; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] > 0) s.insert(a[i]); else if (a[i] < 0) t.insert(a[i]); else cnt++; } if (n == 2) { sort(ALL(a)); cout << a[1] - a[0] << "\n" << a[1] << " " << a[0]; return; } vpi ans; if (SZ(s) == 0) { if (cnt) { cnt--; s.insert(0); } else { auto it = t.end(); it--; int u = *it; t.erase(it); it = t.end(); it--; int v = *it; t.erase(it); s.insert({u - v}); ans.push_back({u, v}); } return; } if (SZ(t) == 0) { if (cnt) { cnt--; t.insert(0); } else { auto it = s.begin(); int u = *it; s.erase(it); it = s.begin(); int v = *it; s.erase(it); t.insert({u - v}); ans.push_back({u, v}); } } for (int i = 0; i < cnt; i++) { s.insert(0); } while (SZ(s) > 1) { auto it = t.begin(); int u = *it; t.erase(it); it = s.begin(); int v = *it; s.erase(it); t.insert(u - v); ans.push_back({u, v}); } while (SZ(t) > 1) { auto it = t.end(); it--; int u = *it; t.erase(it); it = s.end(); it--; int v = *it; s.erase(it); s.insert(v - u); ans.push_back({v, u}); } auto it = s.begin(); int u = *it; it = t.begin(); int v = *it; ans.push_back({u, v}); cout << u - v << "\n"; for (auto p : ans) { cout << p.first << " " << p.second << "\n"; } }
#include <bits/stdc++.h> #include <random> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef double ld; #define int ll typedef vector<char> vc; typedef vector<vc> vvc; typedef vector<vvc> vvvc; typedef pair<int, int> pii; typedef pair<pii, pii> piii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<pii> vpi; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef vector<short> vs; typedef vector<vs> vvs; typedef vector<vvs> vvvs; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<vvl> vvvl; typedef vector<ld> vld; typedef vector<vld> vvld; typedef vector<vvld> vvvld; typedef vector<string> vst; typedef vector<vst> vvst; typedef pair<ld, ld> pld; #define inmin(a, b) a = min(a, (b)) #define inmax(a, b) a = max(a, (b)) #define ALL(a) a.begin(), a.end() #define RALL(a) a.rbegin(), a.rend() #define sqr(x) ((x) * (x)) #define fori(i, n) for (int i = 0; i < int(n); ++i) #define SZ(a) ((int)((a).size())) #define triple(T) tuple<T, T, T> #define quad(T) tuple<T, T, T, T> #define watch(x) cerr << (#x) << " = " << (x) << endl; #ifdef RUS_HOME #define cerr cout #else #define cerr \ if (false) \ cerr #endif const double PI = 2 * acos(0.0); #define rand shittttty_shit mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count()); const string DIGITS = "0123456789"; const string ALPH = "abcdefghijklmnopqrstuvwxyz"; template <class T0, class T1> inline ostream &operator<<(ostream &out, pair<T0, T1> &a) { return out << "{" << a.first << ", " << a.second << "}"; } template <class T0, class T1> inline istream &operator>>(istream &in, pair<T0, T1> &a) { return in >> a.first >> a.second; } template <class T0, class T1, class T2> inline ostream &operator<<(ostream &out, tuple<T0, T1, T2> &a) { return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}"; } template <class T0, class T1, class T2, class T3> inline ostream &operator<<(ostream &out, tuple<T0, T1, T2, T3> &a) { return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " << get<3>(a) << "}"; } template <class T> inline ostream &operator<<(ostream &out, vector<T> &a) { out << "["; fori(i, a.size()) out << a[i] << vector<string>{", ", "] "}[i + 1 == a.size()]; return out; } void smain(); signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef RUS_HOME freopen("input", "r", stdin); clock_t start = clock(); #endif cout << setprecision(12) << fixed; smain(); #ifdef RUS_HOME cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float(clock() - start) / CLOCKS_PER_SEC << endl; #endif return 0; } const int MOD = 998244353, N = 1e5 + 100, oo = 1e15; void smain() { int n; cin >> n; vi a(n); int cnt = 0; multiset<int> s, t; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] > 0) s.insert(a[i]); else if (a[i] < 0) t.insert(a[i]); else cnt++; } if (n == 2) { sort(ALL(a)); cout << a[1] - a[0] << "\n" << a[1] << " " << a[0]; return; } vpi ans; if (SZ(s) == 0) { if (cnt) { cnt--; s.insert(0); } else { auto it = t.end(); it--; int u = *it; t.erase(it); it = t.end(); it--; int v = *it; t.erase(it); s.insert({u - v}); ans.push_back({u, v}); } } if (SZ(t) == 0) { if (cnt) { cnt--; t.insert(0); } else { auto it = s.begin(); int u = *it; s.erase(it); it = s.begin(); int v = *it; s.erase(it); t.insert({u - v}); ans.push_back({u, v}); } } for (int i = 0; i < cnt; i++) { s.insert(0); } while (SZ(s) > 1) { auto it = t.begin(); int u = *it; t.erase(it); it = s.begin(); int v = *it; s.erase(it); t.insert(u - v); ans.push_back({u, v}); } while (SZ(t) > 1) { auto it = t.end(); it--; int u = *it; t.erase(it); it = s.end(); it--; int v = *it; s.erase(it); s.insert(v - u); ans.push_back({v, u}); } auto it = s.begin(); int u = *it; it = t.begin(); int v = *it; ans.push_back({u, v}); cout << u - v << "\n"; for (auto p : ans) { cout << p.first << " " << p.second << "\n"; } }
[]
821,205
821,206
u844213925
cpp
p03007
#include <bits/stdc++.h> #include <random> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef double ld; #define int ll typedef vector<char> vc; typedef vector<vc> vvc; typedef vector<vvc> vvvc; typedef pair<int, int> pii; typedef pair<pii, pii> piii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<pii> vpi; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef vector<short> vs; typedef vector<vs> vvs; typedef vector<vvs> vvvs; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<vvl> vvvl; typedef vector<ld> vld; typedef vector<vld> vvld; typedef vector<vvld> vvvld; typedef vector<string> vst; typedef vector<vst> vvst; typedef pair<ld, ld> pld; #define inmin(a, b) a = min(a, (b)) #define inmax(a, b) a = max(a, (b)) #define ALL(a) a.begin(), a.end() #define RALL(a) a.rbegin(), a.rend() #define sqr(x) ((x) * (x)) #define fori(i, n) for (int i = 0; i < int(n); ++i) #define SZ(a) ((int)((a).size())) #define triple(T) tuple<T, T, T> #define quad(T) tuple<T, T, T, T> #define watch(x) cerr << (#x) << " = " << (x) << endl; #ifdef RUS_HOME #define cerr cout #else #define cerr \ if (false) \ cerr #endif const double PI = 2 * acos(0.0); #define rand shittttty_shit mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count()); const string DIGITS = "0123456789"; const string ALPH = "abcdefghijklmnopqrstuvwxyz"; template <class T0, class T1> inline ostream &operator<<(ostream &out, pair<T0, T1> &a) { return out << "{" << a.first << ", " << a.second << "}"; } template <class T0, class T1> inline istream &operator>>(istream &in, pair<T0, T1> &a) { return in >> a.first >> a.second; } template <class T0, class T1, class T2> inline ostream &operator<<(ostream &out, tuple<T0, T1, T2> &a) { return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}"; } template <class T0, class T1, class T2, class T3> inline ostream &operator<<(ostream &out, tuple<T0, T1, T2, T3> &a) { return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " << get<3>(a) << "}"; } template <class T> inline ostream &operator<<(ostream &out, vector<T> &a) { out << "["; fori(i, a.size()) out << a[i] << vector<string>{", ", "] "}[i + 1 == a.size()]; return out; } void smain(); signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef RUS_HOME freopen("input", "r", stdin); clock_t start = clock(); #endif cout << setprecision(12) << fixed; smain(); #ifdef RUS_HOME cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float(clock() - start) / CLOCKS_PER_SEC << endl; #endif return 0; } const int MOD = 998244353, N = 1e5 + 100, oo = 1e15; void smain() { int n; cin >> n; vi a(n); int cnt = 0; multiset<int> s, t; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] > 0) s.insert(a[i]); else if (a[i] < 0) t.insert(a[i]); else cnt++; } if (n == 2) { sort(ALL(a)); cout << a[1] - a[0] << "\n" << a[1] << " " << a[0]; return; } vpi ans; if (SZ(s) == 0) { if (cnt) { cnt--; s.insert(0); } else { auto it = t.end(); it--; int u = *it; t.erase(it); it = t.end(); it--; int v = *it; t.erase(it); s.insert({u - v}); ans.push_back({u, v}); } return; } if (SZ(t) == 0) { if (cnt) { cnt--; t.insert(0); } else { auto it = s.begin(); int u = *it; s.erase(it); it = s.begin(); int v = *it; s.erase(it); t.insert({u - v}); ans.push_back({u, v}); } } for (int i = 0; i < cnt; i++) { s.insert(0); } while (SZ(s) > 1) { auto it = t.begin(); int u = *it; t.erase(it); it = s.begin(); int v = *it; s.erase(v); t.insert(u - v); ans.push_back({u, v}); } while (SZ(t) > 1) { auto it = t.end(); it--; int u = *it; t.erase(it); it = s.end(); it--; int v = *it; s.erase(v); s.insert(v - u); ans.push_back({v, u}); } auto it = s.begin(); int u = *it; it = t.begin(); int v = *it; ans.push_back({u, v}); cout << u - v << "\n"; for (auto p : ans) { cout << p.first << " " << p.second << "\n"; } }
#include <bits/stdc++.h> #include <random> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef double ld; #define int ll typedef vector<char> vc; typedef vector<vc> vvc; typedef vector<vvc> vvvc; typedef pair<int, int> pii; typedef pair<pii, pii> piii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<pii> vpi; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef vector<short> vs; typedef vector<vs> vvs; typedef vector<vvs> vvvs; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<vvl> vvvl; typedef vector<ld> vld; typedef vector<vld> vvld; typedef vector<vvld> vvvld; typedef vector<string> vst; typedef vector<vst> vvst; typedef pair<ld, ld> pld; #define inmin(a, b) a = min(a, (b)) #define inmax(a, b) a = max(a, (b)) #define ALL(a) a.begin(), a.end() #define RALL(a) a.rbegin(), a.rend() #define sqr(x) ((x) * (x)) #define fori(i, n) for (int i = 0; i < int(n); ++i) #define SZ(a) ((int)((a).size())) #define triple(T) tuple<T, T, T> #define quad(T) tuple<T, T, T, T> #define watch(x) cerr << (#x) << " = " << (x) << endl; #ifdef RUS_HOME #define cerr cout #else #define cerr \ if (false) \ cerr #endif const double PI = 2 * acos(0.0); #define rand shittttty_shit mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count()); const string DIGITS = "0123456789"; const string ALPH = "abcdefghijklmnopqrstuvwxyz"; template <class T0, class T1> inline ostream &operator<<(ostream &out, pair<T0, T1> &a) { return out << "{" << a.first << ", " << a.second << "}"; } template <class T0, class T1> inline istream &operator>>(istream &in, pair<T0, T1> &a) { return in >> a.first >> a.second; } template <class T0, class T1, class T2> inline ostream &operator<<(ostream &out, tuple<T0, T1, T2> &a) { return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}"; } template <class T0, class T1, class T2, class T3> inline ostream &operator<<(ostream &out, tuple<T0, T1, T2, T3> &a) { return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " << get<3>(a) << "}"; } template <class T> inline ostream &operator<<(ostream &out, vector<T> &a) { out << "["; fori(i, a.size()) out << a[i] << vector<string>{", ", "] "}[i + 1 == a.size()]; return out; } void smain(); signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef RUS_HOME freopen("input", "r", stdin); clock_t start = clock(); #endif cout << setprecision(12) << fixed; smain(); #ifdef RUS_HOME cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float(clock() - start) / CLOCKS_PER_SEC << endl; #endif return 0; } const int MOD = 998244353, N = 1e5 + 100, oo = 1e15; void smain() { int n; cin >> n; vi a(n); int cnt = 0; multiset<int> s, t; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] > 0) s.insert(a[i]); else if (a[i] < 0) t.insert(a[i]); else cnt++; } if (n == 2) { sort(ALL(a)); cout << a[1] - a[0] << "\n" << a[1] << " " << a[0]; return; } vpi ans; if (SZ(s) == 0) { if (cnt) { cnt--; s.insert(0); } else { auto it = t.end(); it--; int u = *it; t.erase(it); it = t.end(); it--; int v = *it; t.erase(it); s.insert({u - v}); ans.push_back({u, v}); } } if (SZ(t) == 0) { if (cnt) { cnt--; t.insert(0); } else { auto it = s.begin(); int u = *it; s.erase(it); it = s.begin(); int v = *it; s.erase(it); t.insert({u - v}); ans.push_back({u, v}); } } for (int i = 0; i < cnt; i++) { s.insert(0); } while (SZ(s) > 1) { auto it = t.begin(); int u = *it; t.erase(it); it = s.begin(); int v = *it; s.erase(it); t.insert(u - v); ans.push_back({u, v}); } while (SZ(t) > 1) { auto it = t.end(); it--; int u = *it; t.erase(it); it = s.end(); it--; int v = *it; s.erase(it); s.insert(v - u); ans.push_back({v, u}); } auto it = s.begin(); int u = *it; it = t.begin(); int v = *it; ans.push_back({u, v}); cout << u - v << "\n"; for (auto p : ans) { cout << p.first << " " << p.second << "\n"; } }
[ "identifier.change", "call.arguments.change" ]
821,207
821,206
u844213925
cpp
p03007
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) #define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++) #define repr(i, n) for (ll i = n; i >= 0; i--) #define pb push_back #define COUT(x) cout << (x) << "\n" #define COUTF(x) cout << setprecision(15) << (x) << "\n" #define ENDL cout << "\n" #define DF(x) x.erase(x.begin()) #define ALL(x) x.begin(), x.end() #define SZ(x) (ll) x.size() #define SORT(x) sort(ALL(x)) #define REVERSE(x) reverse(ALL(x)) #define ANS cout << ans << "\n" #define init() \ cin.tie(0); \ ios::sync_with_stdio(false) #define LINE cerr << "[debug] line: " << __LINE__ << "\n"; #define debug(x) cerr << "[debug] " << #x << ": " << x << "\n"; #define debugV(v) \ cerr << "[debugV] " << #v << ":"; \ rep(i, v.size()) cerr << " " << v[i]; \ cerr << "\n"; using namespace std; using ll = long long; using ld = long double; using vll = vector<ll>; using vvll = vector<vector<ll>>; using mll = map<ll, ll>; using qll = queue<ll>; using P = pair<ll, ll>; constexpr ll INF = 0x3f3f3f3f3f3f3f3f; constexpr ld PI = 3.141592653589793238462643383279; ll get_digit(ll x) { return to_string(x).size(); } ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } vector<P> factorize(ll n) { vector<P> result; for (ll i = 2; i * i <= n; ++i) { if (n % i == 0) { result.pb({i, 0}); while (n % i == 0) { n /= i; result.back().second++; } } } if (n != 1) { result.pb({n, 1}); } return result; } vll divisor(ll n) { vll ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } SORT(ret); return (ret); } const int mod = 1000000007; struct mint { ll x; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream &operator>>(istream &is, const mint &a) { return is >> a.x; } ostream &operator<<(ostream &os, const mint &a) { return os << a.x; } struct combination { vector<mint> fact, ifact; combination(ll n) : fact(n + 1), ifact(n + 1) { assert(n < mod); fact[0] = 1; for (ll i = 1; i <= n; ++i) { fact[i] = fact[i - 1] * i; } ifact[n] = fact[n].inv(); for (ll i = n; i >= 1; --i) { ifact[i - 1] = ifact[i] * i; } } mint operator()(ll n, ll k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } }; signed main() { init(); ll N; cin >> N; vll A(N); rep(i, N) cin >> A[i]; SORT(A); qll p; qll m; ll sum = 0; rep(i, N) { if (i == 0) { sum -= A[i]; m.push(A[i]); continue; } if (i == N - 1) { sum += A[i]; p.push(A[i]); continue; } if (A[i] > 0) { sum += A[i]; p.push(A[i]); continue; } else { sum -= A[i]; m.push(A[i]); continue; } } COUT(sum); while (p.size() != 1) { ll a = p.front(); p.pop(); ll b = m.front(); m.pop(); cout << b << " " << a << endl; m.push(b - a); } ll f = p.front(); while (!m.empty()) { ll b = m.front(); m.pop(); cout << f << " " << b << endl; } return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) #define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++) #define repr(i, n) for (ll i = n; i >= 0; i--) #define pb push_back #define COUT(x) cout << (x) << "\n" #define COUTF(x) cout << setprecision(15) << (x) << "\n" #define ENDL cout << "\n" #define DF(x) x.erase(x.begin()) #define ALL(x) x.begin(), x.end() #define SZ(x) (ll) x.size() #define SORT(x) sort(ALL(x)) #define REVERSE(x) reverse(ALL(x)) #define ANS cout << ans << "\n" #define init() \ cin.tie(0); \ ios::sync_with_stdio(false) #define LINE cerr << "[debug] line: " << __LINE__ << "\n"; #define debug(x) cerr << "[debug] " << #x << ": " << x << "\n"; #define debugV(v) \ cerr << "[debugV] " << #v << ":"; \ rep(i, v.size()) cerr << " " << v[i]; \ cerr << "\n"; using namespace std; using ll = long long; using ld = long double; using vll = vector<ll>; using vvll = vector<vector<ll>>; using mll = map<ll, ll>; using qll = queue<ll>; using P = pair<ll, ll>; constexpr ll INF = 0x3f3f3f3f3f3f3f3f; constexpr ld PI = 3.141592653589793238462643383279; ll get_digit(ll x) { return to_string(x).size(); } ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } vector<P> factorize(ll n) { vector<P> result; for (ll i = 2; i * i <= n; ++i) { if (n % i == 0) { result.pb({i, 0}); while (n % i == 0) { n /= i; result.back().second++; } } } if (n != 1) { result.pb({n, 1}); } return result; } vll divisor(ll n) { vll ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } SORT(ret); return (ret); } const int mod = 1000000007; struct mint { ll x; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream &operator>>(istream &is, const mint &a) { return is >> a.x; } ostream &operator<<(ostream &os, const mint &a) { return os << a.x; } struct combination { vector<mint> fact, ifact; combination(ll n) : fact(n + 1), ifact(n + 1) { assert(n < mod); fact[0] = 1; for (ll i = 1; i <= n; ++i) { fact[i] = fact[i - 1] * i; } ifact[n] = fact[n].inv(); for (ll i = n; i >= 1; --i) { ifact[i - 1] = ifact[i] * i; } } mint operator()(ll n, ll k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } }; signed main() { init(); ll N; cin >> N; vll A(N); rep(i, N) cin >> A[i]; SORT(A); qll p; qll m; ll sum = 0; rep(i, N) { if (i == 0) { sum -= A[i]; m.push(A[i]); continue; } if (i == N - 1) { sum += A[i]; p.push(A[i]); continue; } if (A[i] > 0) { sum += A[i]; p.push(A[i]); continue; } else { sum -= A[i]; m.push(A[i]); continue; } } COUT(sum); while (p.size() != 1) { ll a = p.front(); p.pop(); ll b = m.front(); m.pop(); cout << b << " " << a << endl; m.push(b - a); } ll f = p.front(); while (!m.empty()) { ll b = m.front(); m.pop(); cout << f << " " << b << endl; f = f - b; } return 0; }
[ "assignment.add" ]
821,210
821,211
u297738015
cpp
p03007
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい // for文のマクロ #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define big 1000000007 #define all(a) sort((a).begin(), (a).end()) //ソートのマクロ #define Re(a) reverse((a).begin(), (a).end()) #define YN(a) \ if (a) { \ cout << "Yes" << endl; \ } else \ cout << "No" << endl; //条件によってYes、Noを出力する #define ld long double int main() { int n; cin >> n; int64_t sum = 0; vector<int64_t> a(n); rep(i, n) { cin >> a[i]; sum += a[i]; } all(a); if (n == 2) { cout << a[1] - a[0] << endl; cout << a[1] << " " << a[0] << endl; return 0; } // a1+a2+a3+.....+anの中から「1個以上n-1個未満」マイナスにする if (a[0] > 0) { // 1個目だけ-にする int64_t ans = sum - 2 * a[0]; cout << ans << endl; int halfway = a[0]; rep(i, n - 1) { if (i == n - 2) { cout << a[i + 1] << " " << halfway << endl; } else { cout << halfway << " " << a[i + 1] << endl; halfway -= a[i + 1]; } } } else if (a[n - 1] < 0) { // a[n-1]以外全部マイナスにする int64_t ans = -sum + 2 * a[n - 1]; cout << ans << endl; int halfway = a[n - 1]; rep(i, n - 1) { cout << halfway << " " << a[i] << endl; halfway -= a[i]; } } else { //正の数なら+に、負の数ならマイナスにする int64_t ans = 0; rep(i, n) { ans += abs(a[i]); } cout << ans << endl; int halfway = a[0]; rep(i, n) { if (a[i] > 0 && i != n - 1) { cout << halfway << " " << a[i] << endl; halfway -= a[i]; } } int plushalf = a[n - 1]; rep(i, n) { if (i != 0 && a[i] <= 0) { cout << plushalf << " " << a[i] << endl; plushalf -= a[i]; } } cout << plushalf << " " << halfway << endl; } }
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい // for文のマクロ #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define big 1000000007 #define all(a) sort((a).begin(), (a).end()) //ソートのマクロ #define Re(a) reverse((a).begin(), (a).end()) #define YN(a) \ if (a) { \ cout << "Yes" << endl; \ } else \ cout << "No" << endl; //条件によってYes、Noを出力する #define ld long double int main() { int n; cin >> n; int64_t sum = 0; vector<int64_t> a(n); rep(i, n) { cin >> a[i]; sum += a[i]; } all(a); if (n == 2) { cout << a[1] - a[0] << endl; cout << a[1] << " " << a[0] << endl; return 0; } // a1+a2+a3+.....+anの中から「1個以上n-1個未満」マイナスにする if (a[0] > 0) { // 1個目だけ-にする int64_t ans = sum - 2 * a[0]; cout << ans << endl; int halfway = a[0]; rep(i, n - 1) { if (i == n - 2) { cout << a[i + 1] << " " << halfway << endl; } else { cout << halfway << " " << a[i + 1] << endl; halfway -= a[i + 1]; } } } else if (a[n - 1] <= 0) { // a[n-1]以外全部マイナスにする int64_t ans = -sum + 2 * a[n - 1]; cout << ans << endl; int halfway = a[n - 1]; rep(i, n - 1) { cout << halfway << " " << a[i] << endl; halfway -= a[i]; } } else { //正の数なら+に、負の数ならマイナスにする int64_t ans = 0; rep(i, n) { ans += abs(a[i]); } cout << ans << endl; int halfway = a[0]; rep(i, n) { if (a[i] > 0 && i != n - 1) { cout << halfway << " " << a[i] << endl; halfway -= a[i]; } } int plushalf = a[n - 1]; rep(i, n) { if (i != 0 && a[i] <= 0) { cout << plushalf << " " << a[i] << endl; plushalf -= a[i]; } } cout << plushalf << " " << halfway << endl; } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
821,212
821,213
u348231925
cpp
p03007
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい // for文のマクロ #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define big 1000000007 #define all(a) sort((a).begin(), (a).end()) //ソートのマクロ #define Re(a) reverse((a).begin(), (a).end()) #define YN(a) \ if (a) { \ cout << "Yes" << endl; \ } else \ cout << "No" << endl; //条件によってYes、Noを出力する #define ld long double int main() { int n; cin >> n; int64_t sum = 0; vector<int64_t> a(n); rep(i, n) { cin >> a[i]; sum += a[i]; } all(a); if (n == 2) { cout << a[1] - a[0] << endl; cout << a[1] << " " << a[0] << endl; return 0; } // a1+a2+a3+.....+anの中から「1個以上n-1個未満」マイナスにする if (a[0] > 0) { // 1個目だけ-にする int64_t ans = sum - 2 * a[0]; cout << ans << endl; int halfway = a[0]; rep(i, n - 1) { if (i == n - 2) { cout << a[i + 1] << " " << halfway << endl; } else { cout << halfway << " " << a[i + 1] << endl; halfway -= a[i + 1]; } } } else if (a[n - 1] < 0) { // a[n-1]以外全部マイナスにする int64_t ans = -sum + 2 * a[n - 1]; cout << ans << endl; int halfway = a[n - 1]; rep(i, n - 1) { cout << halfway << " " << a[i] << endl; halfway -= a[i]; } } else { //正の数なら+に、負の数ならマイナスにする int64_t ans = 0; rep(i, n) { ans += abs(a[i]); } cout << ans << endl; int halfway = a[0]; rep(i, n) { if (a[i] >= 0 && i != n - 1) { cout << halfway << " " << a[i] << endl; halfway -= a[i]; } } int plushalf = a[n - 1]; rep(i, n) { if (i != 0 && a[i] <= 0) { cout << plushalf << " " << a[i] << endl; plushalf -= a[i]; } } cout << plushalf << " " << halfway << endl; } }
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい // for文のマクロ #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define big 1000000007 #define all(a) sort((a).begin(), (a).end()) //ソートのマクロ #define Re(a) reverse((a).begin(), (a).end()) #define YN(a) \ if (a) { \ cout << "Yes" << endl; \ } else \ cout << "No" << endl; //条件によってYes、Noを出力する #define ld long double int main() { int n; cin >> n; int64_t sum = 0; vector<int64_t> a(n); rep(i, n) { cin >> a[i]; sum += a[i]; } all(a); if (n == 2) { cout << a[1] - a[0] << endl; cout << a[1] << " " << a[0] << endl; return 0; } // a1+a2+a3+.....+anの中から「1個以上n-1個未満」マイナスにする if (a[0] > 0) { // 1個目だけ-にする int64_t ans = sum - 2 * a[0]; cout << ans << endl; int halfway = a[0]; rep(i, n - 1) { if (i == n - 2) { cout << a[i + 1] << " " << halfway << endl; } else { cout << halfway << " " << a[i + 1] << endl; halfway -= a[i + 1]; } } } else if (a[n - 1] <= 0) { // a[n-1]以外全部マイナスにする int64_t ans = -sum + 2 * a[n - 1]; cout << ans << endl; int halfway = a[n - 1]; rep(i, n - 1) { cout << halfway << " " << a[i] << endl; halfway -= a[i]; } } else { //正の数なら+に、負の数ならマイナスにする int64_t ans = 0; rep(i, n) { ans += abs(a[i]); } cout << ans << endl; int halfway = a[0]; rep(i, n) { if (a[i] > 0 && i != n - 1) { cout << halfway << " " << a[i] << endl; halfway -= a[i]; } } int plushalf = a[n - 1]; rep(i, n) { if (i != 0 && a[i] <= 0) { cout << plushalf << " " << a[i] << endl; plushalf -= a[i]; } } cout << plushalf << " " << halfway << endl; } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
821,214
821,213
u348231925
cpp
p03007
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい // for文のマクロ #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define big 1000000007 #define all(a) sort((a).begin(), (a).end()) //ソートのマクロ #define Re(a) reverse((a).begin(), (a).end()) #define YN(a) \ if (a) { \ cout << "Yes" << endl; \ } else \ cout << "No" << endl; //条件によってYes、Noを出力する #define ld long double int main() { int n; cin >> n; int64_t sum = 0; vector<int64_t> a(n); rep(i, n) { cin >> a[i]; sum += a[i]; } all(a); if (n == 2) { cout << a[1] - a[0] << endl; cout << a[1] << " " << a[0] << endl; return 0; } // a1+a2+a3+.....+anの中から「1個以上n-1個未満」マイナスにする if (a[0] > 0) { // 1個目だけ-にする int64_t ans = sum - 2 * a[0]; cout << ans << endl; int halfway = a[0]; rep(i, n - 1) { if (i == n - 2) { cout << a[i + 1] << " " << halfway << endl; } else { cout << halfway << " " << a[i + 1] << endl; halfway -= a[i + 1]; } } } else if (a[n - 1] < 0) { // a[n-1]以外全部マイナスにする int64_t ans = -sum + 2 * a[n - 1]; cout << ans << endl; int halfway = a[n - 1]; rep(i, n - 1) { cout << halfway << " " << a[i] << endl; halfway -= a[i]; } } else { //正の数なら+に、負の数ならマイナスにする int64_t ans = 0; rep(i, n) { ans += abs(a[i]); } cout << ans << endl; int halfway = a[0]; rep(i, n) { if (a[i] >= 0 && i != n - 1) { cout << halfway << " " << a[i] << endl; halfway -= a[i]; } } int plushalf = a[n - 1]; rep(i, n) { if (i != 0 && a[i] <= 0) { cout << plushalf << " " << a[i] << endl; plushalf -= a[i]; } } cout << plushalf << " " << halfway << endl; } }
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい // for文のマクロ #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define big 1000000007 #define all(a) sort((a).begin(), (a).end()) //ソートのマクロ #define Re(a) reverse((a).begin(), (a).end()) #define YN(a) \ if (a) { \ cout << "Yes" << endl; \ } else \ cout << "No" << endl; //条件によってYes、Noを出力する #define ld long double int main() { int n; cin >> n; int64_t sum = 0; vector<int64_t> a(n); rep(i, n) { cin >> a[i]; sum += a[i]; } all(a); if (n == 2) { cout << a[1] - a[0] << endl; cout << a[1] << " " << a[0] << endl; return 0; } // a1+a2+a3+.....+anの中から「1個以上n-1個未満」マイナスにする if (a[0] > 0) { // 1個目だけ-にする int64_t ans = sum - 2 * a[0]; cout << ans << endl; int halfway = a[0]; rep(i, n - 1) { if (i == n - 2) { cout << a[i + 1] << " " << halfway << endl; } else { cout << halfway << " " << a[i + 1] << endl; halfway -= a[i + 1]; } } } else if (a[n - 1] <= 0) { // a[n-1]以外全部マイナスにする int64_t ans = -sum + 2 * a[n - 1]; cout << ans << endl; int halfway = a[n - 1]; rep(i, n - 1) { cout << halfway << " " << a[i] << endl; halfway -= a[i]; } } else { //正の数なら+に、負の数ならマイナスにする int64_t ans = 0; rep(i, n) { ans += abs(a[i]); } cout << ans << endl; int halfway = a[0]; rep(i, n) { if (a[i] > 0 && i != n - 1) { cout << halfway << " " << a[i] << endl; halfway -= a[i]; } } int plushalf = a[n - 1]; rep(i, n) { if (i != 0 && a[i] <= 0) { cout << plushalf << " " << a[i] << endl; plushalf -= a[i]; } } cout << plushalf << " " << halfway << endl; } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
821,215
821,213
u348231925
cpp
p03007
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define REP(a, b) for (int a = 0; a < (b); ++a) #define REP1(i, n) for (int i = 1; i <= (n); ++i) #define debug(x) cerr << #x << ": " << x << '\n' #define all(x) (x).begin(), (x).end() #define YES() printf("YES\n") #define NO() printf("NO\n") #define isYES(x) printf("%s\n", (x) ? "YES" : "NO") #define Yes() printf("Yes\n") #define No() printf("No\n") #define isYes(x) printf("%s\n", (x) ? "Yes" : "No") #define isPossible(x) printf("%s\n", (x) ? "Possible" : "Impossible") #define SZ(x) ((int)(x).size()) #define pb push_back #define mp make_pair // #define INF (1<<29) const long long INF = 1LL << 60; #define Sp(p) cout << setprecision(25) << fixed << p << endl #define vi vector<int> #define vl vector<ll> #define vii vector<vector<int>> #define vll vector<vector<ll>> #define vs vector<string> #define pii pair<int, int> #define pis pair<int, string> #define psi pair<string, int> #define pll pair<ll, ll> #define pie 3.14159265358979323846 using namespace std; typedef pair<int, int> P; typedef pair<ll, ll> LP; typedef pair<int, P> PP; typedef pair<ll, LP> LPP; template <class T = int> T in() { T x; cin >> x; return (x); } template <class T> void print(T &x) { cout << x << '\n'; } const int MOD = (int)1e9 + 7; // const int mod =(int)998244353; const int mod = (int)1e9 + 7; const int MAX = 510000; ll fac[MAX], finv[MAX], inv[MAX]; void COMint() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll gcd(ll a, ll b) { if (a < 0) a = -a; if (b < 0) b = -b; if (b == 0) return a; if (a > b) { swap(a, b); } return gcd(a, b % a); } ll lcm(ll a, ll b) { if (a < 0) a = -a; if (b < 0) b = -b; ll g; g = gcd(a, b); return b / g * a; } bool compare_by_b(pair<int, int> a, pair<int, int> b) { if (a.second != b.second) { return a.second < b.second; } else { return a.first < b.first; } } bool compare_by_a(pair<int, int> a, pair<int, int> b) { if (a.first != b.first) { return a.first < b.first; } else { return a.second < b.second; } } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } ll RS(ll N, ll P, ll m) { if (P == 0) { return 1; } else { if (P % 2 == 0) { ll t = RS(N, P / 2, m); return t * t % m; } else { return N * RS(N, P - 1, m) % m; } } } int main() { ios::sync_with_stdio(false); int N; cin >> N; vector<int> A; int cnt_m = 0; int cnt_p = 0; REP(i, N) { int a = in(); if (a <= 0) cnt_m++; if (a > 0) cnt_p++; A.pb(a); } sort(all(A)); if (N == 2) { cout << A[1] - A[0] << endl; cout << A[1] << " " << A[0] << endl; return 0; } if (cnt_m == 0) { int m = 0; m = (-1) * A[0]; REP1(i, N - 1) { m += A[i]; } cout << m << endl; int temp = A[0]; REP(i, N - 2) { cout << temp << " " << A[i + 1] << endl; temp = temp - A[i + 1]; } cout << A[N - 1] << " " << temp << endl; return 0; } if (cnt_p == 0) { int m = 0; m = A[N - 1]; REP(i, N - 1) { m -= A[i]; } cout << m << endl; int temp = A[N - 1]; REP(i, N - 1) { cout << temp << " " << A[i] << endl; temp -= A[i]; } return 0; } vector<int> p; vector<int> m; vector<pair<int, int>> ans; REP(i, N) { if (A[i] < 0) { m.pb(A[i]); } else { p.pb(A[i]); } } int temp = m[m.size() - 1]; m.pop_back(); int p_max = p[p.size() - 1]; p.pop_back(); for (auto i : p) { ans.emplace_back(temp, i); temp -= i; } ans.emplace_back(p_max, temp); temp = p_max - temp; for (auto i : m) { ans.emplace_back(temp, i); temp -= i; } cout << temp << endl; REP(i, N - 1) { cout << ans[i].first << " " << ans[i].second << endl; } return 0; }
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define REP(a, b) for (int a = 0; a < (b); ++a) #define REP1(i, n) for (int i = 1; i <= (n); ++i) #define debug(x) cerr << #x << ": " << x << '\n' #define all(x) (x).begin(), (x).end() #define YES() printf("YES\n") #define NO() printf("NO\n") #define isYES(x) printf("%s\n", (x) ? "YES" : "NO") #define Yes() printf("Yes\n") #define No() printf("No\n") #define isYes(x) printf("%s\n", (x) ? "Yes" : "No") #define isPossible(x) printf("%s\n", (x) ? "Possible" : "Impossible") #define SZ(x) ((int)(x).size()) #define pb push_back #define mp make_pair // #define INF (1<<29) const long long INF = 1LL << 60; #define Sp(p) cout << setprecision(25) << fixed << p << endl #define vi vector<int> #define vl vector<ll> #define vii vector<vector<int>> #define vll vector<vector<ll>> #define vs vector<string> #define pii pair<int, int> #define pis pair<int, string> #define psi pair<string, int> #define pll pair<ll, ll> #define pie 3.14159265358979323846 using namespace std; typedef pair<int, int> P; typedef pair<ll, ll> LP; typedef pair<int, P> PP; typedef pair<ll, LP> LPP; template <class T = int> T in() { T x; cin >> x; return (x); } template <class T> void print(T &x) { cout << x << '\n'; } const int MOD = (int)1e9 + 7; // const int mod =(int)998244353; const int mod = (int)1e9 + 7; const int MAX = 510000; ll fac[MAX], finv[MAX], inv[MAX]; void COMint() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll gcd(ll a, ll b) { if (a < 0) a = -a; if (b < 0) b = -b; if (b == 0) return a; if (a > b) { swap(a, b); } return gcd(a, b % a); } ll lcm(ll a, ll b) { if (a < 0) a = -a; if (b < 0) b = -b; ll g; g = gcd(a, b); return b / g * a; } bool compare_by_b(pair<int, int> a, pair<int, int> b) { if (a.second != b.second) { return a.second < b.second; } else { return a.first < b.first; } } bool compare_by_a(pair<int, int> a, pair<int, int> b) { if (a.first != b.first) { return a.first < b.first; } else { return a.second < b.second; } } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } ll RS(ll N, ll P, ll m) { if (P == 0) { return 1; } else { if (P % 2 == 0) { ll t = RS(N, P / 2, m); return t * t % m; } else { return N * RS(N, P - 1, m) % m; } } } int main() { ios::sync_with_stdio(false); int N; cin >> N; vector<int> A; int cnt_m = 0; int cnt_p = 0; REP(i, N) { int a = in(); if (a < 0) cnt_m++; if (a >= 0) cnt_p++; A.pb(a); } sort(all(A)); if (N == 2) { cout << A[1] - A[0] << endl; cout << A[1] << " " << A[0] << endl; return 0; } if (cnt_m == 0) { int m = 0; m = (-1) * A[0]; REP1(i, N - 1) { m += A[i]; } cout << m << endl; int temp = A[0]; REP(i, N - 2) { cout << temp << " " << A[i + 1] << endl; temp = temp - A[i + 1]; } cout << A[N - 1] << " " << temp << endl; return 0; } if (cnt_p == 0) { int m = 0; m = A[N - 1]; REP(i, N - 1) { m -= A[i]; } cout << m << endl; int temp = A[N - 1]; REP(i, N - 1) { cout << temp << " " << A[i] << endl; temp -= A[i]; } return 0; } vector<int> p; vector<int> m; vector<pair<int, int>> ans; REP(i, N) { if (A[i] < 0) { m.pb(A[i]); } else { p.pb(A[i]); } } int temp = m[m.size() - 1]; m.pop_back(); int p_max = p[p.size() - 1]; p.pop_back(); for (auto i : p) { ans.emplace_back(temp, i); temp -= i; } ans.emplace_back(p_max, temp); temp = p_max - temp; for (auto i : m) { ans.emplace_back(temp, i); temp -= i; } cout << temp << endl; REP(i, N - 1) { cout << ans[i].first << " " << ans[i].second << endl; } return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
821,227
821,228
u311671153
cpp
p03007
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> X(N, 0); vector<pair<int, int>> P; for (int i = 0; i < N; i++) { cin >> X[i]; } sort(X.begin(), X.end()); for (int i = 1; i < N - 1; i++) { if (X[i] > 0) { P.emplace_back(X[0], X[i]); X[0] -= X[i]; } else { P.emplace_back(X[N - 1], X[i]); X[N - 1] += X[i]; } } /*cout<<X[0]-X[N-1]<<endl; for(int i=0;i<N-2;i++){ cout<<setprecision(20)<<P[i].first<<" "<<P[i].second<<endl; }*/ P.push_back({X[N - 1], X[0]}); cout << X[N - 1] - X[0] << endl; for (auto &e : P) { cout << e.first << " " << e.second << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> X(N, 0); vector<pair<int, int>> P; for (int i = 0; i < N; i++) { cin >> X[i]; } sort(X.begin(), X.end()); for (int i = 1; i < N - 1; i++) { if (X[i] > 0) { P.emplace_back(X[0], X[i]); X[0] -= X[i]; } else { P.emplace_back(X[N - 1], X[i]); X[N - 1] -= X[i]; } } /*cout<<X[0]-X[N-1]<<endl; for(int i=0;i<N-2;i++){ cout<<setprecision(20)<<P[i].first<<" "<<P[i].second<<endl; }*/ P.emplace_back(X[N - 1], X[0]); cout << X[N - 1] - X[0] << endl; for (auto &e : P) { cout << e.first << " " << e.second << endl; } return 0; }
[ "expression.operator.change", "call.function.change", "call.arguments.change" ]
821,229
821,230
u469315559
cpp
p03007
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <functional> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <bitset> #include <deque> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> using namespace std; typedef long long ll; #define rep(i, a, b) for (auto i = a; i < b; i++) #define all(_x) _x.begin(), _x.end() #define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>()) #define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n)) #define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end()); #define vvec vector<vector<ll>> ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); } ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; } #define INF 1 << 30 const int mod = 1000000007; ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } } return a; } ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } } return a; } ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; } return a; } ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; } vector<int> ans, f; set<int> k; vector<vector<int>> G; void dfs(int v) { ans.push_back(v); for (auto n : G[v]) { if (f[n] == 0) { f[n] = 1; k.insert(n); } } if (k.size()) { int nv = *k.begin(); k.erase(*k.begin()); dfs(nv); } } int main() { int n; cin >> n; vector<int> a(n), b(n); rep(i, 0, n) cin >> a[i]; sort(all(a)); rep(i, 0, n) b[i] = a[i]; int k; auto it = lower_bound(all(a), 0); if (it == a.end()) { it = a.end() - 1; } k = it - a.begin(); if (k == 0) k++; rep(i, k, n - 1) { b[0] -= b[i]; } rep(i, 1, k) { b[n - 1] -= b[i]; } printf("%d\n", a[n - 1] - a[0]); rep(i, k, n - 1) { printf("%d %d\n", a[0], a[i]); a[0] -= a[i]; } rep(i, 1, k) { printf("%d %d\n", a[n - 1], a[i]); a[n - 1] -= a[i]; } printf("%d %d\n", a[n - 1], a[0]); return 0; }
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <functional> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <bitset> #include <deque> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> using namespace std; typedef long long ll; #define rep(i, a, b) for (auto i = a; i < b; i++) #define all(_x) _x.begin(), _x.end() #define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>()) #define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n)) #define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end()); #define vvec vector<vector<ll>> ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); } ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; } #define INF 1 << 30 const int mod = 1000000007; ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } } return a; } ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } } return a; } ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; } return a; } ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; } vector<int> ans, f; set<int> k; vector<vector<int>> G; void dfs(int v) { ans.push_back(v); for (auto n : G[v]) { if (f[n] == 0) { f[n] = 1; k.insert(n); } } if (k.size()) { int nv = *k.begin(); k.erase(*k.begin()); dfs(nv); } } int main() { int n; cin >> n; vector<int> a(n), b(n); rep(i, 0, n) cin >> a[i]; sort(all(a)); rep(i, 0, n) b[i] = a[i]; int k; auto it = lower_bound(all(a), 0); if (it == a.end()) { it = a.end() - 1; } k = it - a.begin(); if (k == 0) k++; rep(i, k, n - 1) { b[0] -= b[i]; } rep(i, 1, k) { b[n - 1] -= b[i]; } printf("%d\n", b[n - 1] - b[0]); rep(i, k, n - 1) { printf("%d %d\n", a[0], a[i]); a[0] -= a[i]; } rep(i, 1, k) { printf("%d %d\n", a[n - 1], a[i]); a[n - 1] -= a[i]; } printf("%d %d\n", a[n - 1], a[0]); return 0; }
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
821,233
821,234
u128572736
cpp
p03007
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <functional> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <bitset> #include <deque> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> using namespace std; typedef long long ll; #define rep(i, a, b) for (auto i = a; i < b; i++) #define all(_x) _x.begin(), _x.end() #define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>()) #define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n)) #define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end()); #define vvec vector<vector<ll>> ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); } ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; } #define INF 1 << 30 const int mod = 1000000007; ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } } return a; } ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } } return a; } ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; } return a; } ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; } vector<int> ans, f; set<int> k; vector<vector<int>> G; void dfs(int v) { ans.push_back(v); for (auto n : G[v]) { if (f[n] == 0) { f[n] = 1; k.insert(n); } } if (k.size()) { int nv = *k.begin(); k.erase(*k.begin()); dfs(nv); } } int main() { int n; cin >> n; vector<int> a(n), b(n); rep(i, 0, n) cin >> a[i]; sort(all(a)); rep(i, 0, n) b[i] = a[i]; int k; auto it = lower_bound(all(a), 0); if (it == a.end()) { it = a.end() - 1; } k = it - a.begin(); if (k == 0) k++; rep(i, k, n - 1) { a[0] -= a[i]; } rep(i, 1, k) { a[n - 1] -= a[i]; } printf("%d\n", a[n - 1] - a[0]); rep(i, k, n - 1) { printf("%d %d\n", a[0], a[i]); a[0] -= a[i]; } rep(i, 1, k) { printf("%d %d\n", a[n - 1], a[i]); a[n - 1] -= a[i]; } printf("%d %d\n", a[n - 1], a[0]); return 0; }
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <functional> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <bitset> #include <deque> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> using namespace std; typedef long long ll; #define rep(i, a, b) for (auto i = a; i < b; i++) #define all(_x) _x.begin(), _x.end() #define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>()) #define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n)) #define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end()); #define vvec vector<vector<ll>> ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); } ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; } #define INF 1 << 30 const int mod = 1000000007; ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } } return a; } ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } } return a; } ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; } return a; } ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; } vector<int> ans, f; set<int> k; vector<vector<int>> G; void dfs(int v) { ans.push_back(v); for (auto n : G[v]) { if (f[n] == 0) { f[n] = 1; k.insert(n); } } if (k.size()) { int nv = *k.begin(); k.erase(*k.begin()); dfs(nv); } } int main() { int n; cin >> n; vector<int> a(n), b(n); rep(i, 0, n) cin >> a[i]; sort(all(a)); rep(i, 0, n) b[i] = a[i]; int k; auto it = lower_bound(all(a), 0); if (it == a.end()) { it = a.end() - 1; } k = it - a.begin(); if (k == 0) k++; rep(i, k, n - 1) { b[0] -= b[i]; } rep(i, 1, k) { b[n - 1] -= b[i]; } printf("%d\n", b[n - 1] - b[0]); rep(i, k, n - 1) { printf("%d %d\n", a[0], a[i]); a[0] -= a[i]; } rep(i, 1, k) { printf("%d %d\n", a[n - 1], a[i]); a[n - 1] -= a[i]; } printf("%d %d\n", a[n - 1], a[0]); return 0; }
[ "assignment.variable.change", "identifier.change", "assignment.value.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
821,235
821,234
u128572736
cpp
p03007
#include <algorithm> #include <cmath> #include <deque> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdio.h> #include <vector> using namespace std; #define double long double #define int long long #define rep(s, i, n) for (int i = s; i < n; i++) #define c(n) cout << n << endl; #define ic(n) \ int n; \ cin >> n; #define sc(s) \ string s; \ cin >> s; #define dc(d) \ double d; \ cin >> d; #define mod 1000000007 #define inf 1000000000000000007 #define f first #define s second #define mini(c, a, b) *min_element(c + a, c + b) #define maxi(c, a, b) *max_element(c + a, c + b) #define pi 3.141592653589793238462643383279 #define e_ 2.718281828459045235360287471352 #define P pair<int, int> #define upp(a, n, x) upper_bound(a, a + n, x) - a; #define low(a, n, x) lower_bound(a, a + n, x) - a; #define UF UnionFind // printf("%.12Lf\n",); int keta(int x) { rep(0, i, 30) { if (x < 10) { return i + 1; } x = x / 10; } } int gcd(int x, int y) { if (x == 0 || y == 0) return x + y; int aa = x, bb = y; rep(0, i, 1000) { aa = aa % bb; if (aa == 0) { return bb; } bb = bb % aa; if (bb == 0) { return aa; } } } int lcm(int x, int y) { int aa = x, bb = y; rep(0, i, 1000) { aa = aa % bb; if (aa == 0) { return x / bb * y; } bb = bb % aa; if (bb == 0) { return x / aa * y; } } } int integer(double d) { return long(d); } int distance(double a, double b, double c, double d) { return sqrt((b - a) * (b - a) + (c - d) * (c - d)); } bool p(int x) { if (x == 1) return false; rep(2, i, sqrt(x) + 1) { if (x % i == 0 && x != i) { return false; } } return true; } int max(int a, int b) { if (a >= b) return a; else return b; } string maxst(string s, string t) { int n = s.size(); int m = t.size(); if (n > m) return s; else if (n < m) return t; else { rep(0, i, n) { if (s[i] > t[i]) return s; if (s[i] < t[i]) return t; } return s; } } int min(int a, int b) { if (a >= b) return b; else return a; } int n2[41]; int nis[41]; int nia[41]; int mody[41]; int nn; int com(int n, int y) { int ni = 1; for (int i = 0; i < 41; i++) { n2[i] = ni; ni *= 2; } int bunsi = 1, bunbo = 1; rep(0, i, y) bunsi = (bunsi * (n - i)) % mod; rep(0, i, y) bunbo = (bunbo * (i + 1)) % mod; mody[0] = bunbo; rep(1, i, 41) { bunbo = (bunbo * bunbo) % mod; mody[i] = bunbo; } rep(0, i, 41) nis[i] = 0; nn = mod - 2; for (int i = 40; i >= 0; i -= 1) { if (nn > n2[i]) { nis[i]++; nn -= n2[i]; } } nis[0]++; rep(0, i, 41) { if (nis[i] == 1) { bunsi = (bunsi * mody[i]) % mod; } } return bunsi; } int newcom(int n, int y) { int bunsi = 1, bunbo = 1; rep(0, i, y) { bunsi = (bunsi * (n - i)); bunbo = (bunbo * (i + 1)); int k = gcd(bunsi, bunbo); bunsi /= k; bunbo /= k; } return bunsi / bunbo; } int gyakugen(int n, int y) { int ni = 1; for (int i = 0; i < 41; i++) { n2[i] = ni; ni *= 2; } mody[0] = y; rep(1, i, 41) { y = (y * y) % mod; mody[i] = y; } rep(0, i, 41) nis[i] = 0; nn = mod - 2; for (int i = 40; i >= 0; i -= 1) { if (nn > n2[i]) { nis[i]++; nn -= n2[i]; } } nis[0]++; rep(0, i, 41) { if (nis[i] == 1) { n = (n * mody[i]) % mod; } } return n; } int yakuwa(int n) { int sum = 0; rep(1, i, sqrt(n + 1)) { if (n % i == 0) sum += i + n / i; if (i * i == n) sum -= i; } return sum; } int poow(int y, int n) { if (n == 0) return 1; n -= 1; int ni = 1; for (int i = 0; i < 41; i++) { n2[i] = ni; ni *= 2; } int yy = y; mody[0] = yy; rep(1, i, 41) { yy = (yy * yy) % mod; mody[i] = yy; } rep(0, i, 41) nis[i] = 0; nn = n; for (int i = 40; i >= 0; i -= 1) { if (nn >= n2[i]) { nis[i]++; nn -= n2[i]; } } rep(0, i, 41) { if (nis[i] == 1) { y = (y * mody[i]) % mod; } } return y; } int minpow(int x, int y) { int sum = 1; rep(0, i, y) sum *= x; return sum; } int ketawa(int x, int sinsuu) { int sum = 0; rep(0, i, 100) sum += (x % poow(sinsuu, i + 1)) / (poow(sinsuu, i)); return sum; } int sankaku(int a) { if (a % 2 == 0) return a / 2 * (a + 1); else return (a + 1) / 2 * a; } int sames(int a[1111111], int n) { int ans = 0; rep(0, i, n) { if (a[i] == a[i + 1]) { int j = i; while (a[j + 1] == a[i] && j <= n - 2) j++; ans += sankaku(j - i); i = j; } } return ans; } using Graph = vector<vector<int>>; int oya[114514]; int depth[114514]; void dfs(const Graph &G, int v, int p, int d) { depth[v] = d; oya[v] = p; for (auto nv : G[v]) { if (nv == p) continue; // nv が親 p だったらダメ dfs(G, nv, v, d + 1); // d を 1 増やして子ノードへ } } /*int H=10,W=10; char field[10][10]; char memo[10][10]; void dfs(int h, int w) { memo[h][w] = 'x'; // 八方向を探索 for (int dh = -1; dh <= 1; ++dh) { for (int dw = -1; dw <= 1; ++dw) { if(abs(0-dh)+abs(0-dw)==2)continue; int nh = h + dh, nw = w + dw; // 場外アウトしたり、0 だったりはスルー if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue; if (memo[nh][nw] == 'x') continue; // 再帰的に探索 dfs(nh, nw); } } }*/ int XOR(int a, int b) { if (a == 0 || b == 0) { return a + b; } int ni = 1; rep(0, i, 41) { n2[i] = ni; ni *= 2; } rep(0, i, 41) nis[i] = 0; for (int i = 40; i >= 0; i -= 1) { if (a >= n2[i]) { nis[i]++; a -= n2[i]; } if (b >= n2[i]) { nis[i]++; b -= n2[i]; } } int sum = 0; rep(0, i, 41) sum += (nis[i] % 2 * n2[i]); return sum; } // int ma[1024577][21]; // for(int bit=0;bit<(1<<n);bit++)rep(0,i,n)if(bit&(1<<i))ma[bit][i]=1; struct UnionFind { vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化 for (int i = 0; i < N; i++) par[i] = i; } int root(int x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (par[x] == x) return x; return par[x] = root(par[x]); } void unite(int x, int y) { // xとyの木を併合 int rx = root(x); // xの根をrx int ry = root(y); // yの根をry if (rx == ry) return; // xとyの根が同じ(=同じ木にある)時はそのまま par[rx] = ry; // xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける } bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す int rx = root(x); int ry = root(y); return rx == ry; } }; int a[114514]; P ans[114514]; signed main() { ic(n) rep(0, i, n) cin >> a[i]; sort(a, a + n); int ma = 0; if (a[0] <= 0 && a[n - 1] >= 0) { int k = 0; rep(0, i, n - 1) { if (a[i] <= 0 && a[i + 1] >= 0) { k = i + 1; } } int t = a[n - 1]; rep(1, i, k) { ans[i - 1].f = t; ans[i - 1].s = a[i]; t += a[i]; } int s = a[0]; rep(k, i, n - 1) { ans[i - 1].f = s; ans[i - 1].s = a[i]; s -= a[i]; } ans[n - 2].f = t; ans[n - 2].s = s; ma = t - s; } else if (a[0] > 0) { ans[0].f = a[0]; ans[0].s = a[1]; int t = a[0] - a[1]; rep(1, i, n - 2) { ans[i].f = t; ans[i].s = a[i + 1]; t -= a[i + 1]; } ans[n - 2].f = a[n - 1]; ans[n - 2].s = t; ma = a[n - 1] - t; } else { ans[0].f = a[n - 1]; ans[0].s = a[n - 2]; int t = a[n - 1] - a[n - 2]; rep(1, i, n - 1) { ans[i].f = t; ans[i].s = a[i - 1]; t -= a[i - 1]; } ma = t; } c(ma) rep(0, i, n - 1) { cout << ans[i].f << " " << ans[i].s << endl; } }
#include <algorithm> #include <cmath> #include <deque> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdio.h> #include <vector> using namespace std; #define double long double #define int long long #define rep(s, i, n) for (int i = s; i < n; i++) #define c(n) cout << n << endl; #define ic(n) \ int n; \ cin >> n; #define sc(s) \ string s; \ cin >> s; #define dc(d) \ double d; \ cin >> d; #define mod 1000000007 #define inf 1000000000000000007 #define f first #define s second #define mini(c, a, b) *min_element(c + a, c + b) #define maxi(c, a, b) *max_element(c + a, c + b) #define pi 3.141592653589793238462643383279 #define e_ 2.718281828459045235360287471352 #define P pair<int, int> #define upp(a, n, x) upper_bound(a, a + n, x) - a; #define low(a, n, x) lower_bound(a, a + n, x) - a; #define UF UnionFind // printf("%.12Lf\n",); int keta(int x) { rep(0, i, 30) { if (x < 10) { return i + 1; } x = x / 10; } } int gcd(int x, int y) { if (x == 0 || y == 0) return x + y; int aa = x, bb = y; rep(0, i, 1000) { aa = aa % bb; if (aa == 0) { return bb; } bb = bb % aa; if (bb == 0) { return aa; } } } int lcm(int x, int y) { int aa = x, bb = y; rep(0, i, 1000) { aa = aa % bb; if (aa == 0) { return x / bb * y; } bb = bb % aa; if (bb == 0) { return x / aa * y; } } } int integer(double d) { return long(d); } int distance(double a, double b, double c, double d) { return sqrt((b - a) * (b - a) + (c - d) * (c - d)); } bool p(int x) { if (x == 1) return false; rep(2, i, sqrt(x) + 1) { if (x % i == 0 && x != i) { return false; } } return true; } int max(int a, int b) { if (a >= b) return a; else return b; } string maxst(string s, string t) { int n = s.size(); int m = t.size(); if (n > m) return s; else if (n < m) return t; else { rep(0, i, n) { if (s[i] > t[i]) return s; if (s[i] < t[i]) return t; } return s; } } int min(int a, int b) { if (a >= b) return b; else return a; } int n2[41]; int nis[41]; int nia[41]; int mody[41]; int nn; int com(int n, int y) { int ni = 1; for (int i = 0; i < 41; i++) { n2[i] = ni; ni *= 2; } int bunsi = 1, bunbo = 1; rep(0, i, y) bunsi = (bunsi * (n - i)) % mod; rep(0, i, y) bunbo = (bunbo * (i + 1)) % mod; mody[0] = bunbo; rep(1, i, 41) { bunbo = (bunbo * bunbo) % mod; mody[i] = bunbo; } rep(0, i, 41) nis[i] = 0; nn = mod - 2; for (int i = 40; i >= 0; i -= 1) { if (nn > n2[i]) { nis[i]++; nn -= n2[i]; } } nis[0]++; rep(0, i, 41) { if (nis[i] == 1) { bunsi = (bunsi * mody[i]) % mod; } } return bunsi; } int newcom(int n, int y) { int bunsi = 1, bunbo = 1; rep(0, i, y) { bunsi = (bunsi * (n - i)); bunbo = (bunbo * (i + 1)); int k = gcd(bunsi, bunbo); bunsi /= k; bunbo /= k; } return bunsi / bunbo; } int gyakugen(int n, int y) { int ni = 1; for (int i = 0; i < 41; i++) { n2[i] = ni; ni *= 2; } mody[0] = y; rep(1, i, 41) { y = (y * y) % mod; mody[i] = y; } rep(0, i, 41) nis[i] = 0; nn = mod - 2; for (int i = 40; i >= 0; i -= 1) { if (nn > n2[i]) { nis[i]++; nn -= n2[i]; } } nis[0]++; rep(0, i, 41) { if (nis[i] == 1) { n = (n * mody[i]) % mod; } } return n; } int yakuwa(int n) { int sum = 0; rep(1, i, sqrt(n + 1)) { if (n % i == 0) sum += i + n / i; if (i * i == n) sum -= i; } return sum; } int poow(int y, int n) { if (n == 0) return 1; n -= 1; int ni = 1; for (int i = 0; i < 41; i++) { n2[i] = ni; ni *= 2; } int yy = y; mody[0] = yy; rep(1, i, 41) { yy = (yy * yy) % mod; mody[i] = yy; } rep(0, i, 41) nis[i] = 0; nn = n; for (int i = 40; i >= 0; i -= 1) { if (nn >= n2[i]) { nis[i]++; nn -= n2[i]; } } rep(0, i, 41) { if (nis[i] == 1) { y = (y * mody[i]) % mod; } } return y; } int minpow(int x, int y) { int sum = 1; rep(0, i, y) sum *= x; return sum; } int ketawa(int x, int sinsuu) { int sum = 0; rep(0, i, 100) sum += (x % poow(sinsuu, i + 1)) / (poow(sinsuu, i)); return sum; } int sankaku(int a) { if (a % 2 == 0) return a / 2 * (a + 1); else return (a + 1) / 2 * a; } int sames(int a[1111111], int n) { int ans = 0; rep(0, i, n) { if (a[i] == a[i + 1]) { int j = i; while (a[j + 1] == a[i] && j <= n - 2) j++; ans += sankaku(j - i); i = j; } } return ans; } using Graph = vector<vector<int>>; int oya[114514]; int depth[114514]; void dfs(const Graph &G, int v, int p, int d) { depth[v] = d; oya[v] = p; for (auto nv : G[v]) { if (nv == p) continue; // nv が親 p だったらダメ dfs(G, nv, v, d + 1); // d を 1 増やして子ノードへ } } /*int H=10,W=10; char field[10][10]; char memo[10][10]; void dfs(int h, int w) { memo[h][w] = 'x'; // 八方向を探索 for (int dh = -1; dh <= 1; ++dh) { for (int dw = -1; dw <= 1; ++dw) { if(abs(0-dh)+abs(0-dw)==2)continue; int nh = h + dh, nw = w + dw; // 場外アウトしたり、0 だったりはスルー if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue; if (memo[nh][nw] == 'x') continue; // 再帰的に探索 dfs(nh, nw); } } }*/ int XOR(int a, int b) { if (a == 0 || b == 0) { return a + b; } int ni = 1; rep(0, i, 41) { n2[i] = ni; ni *= 2; } rep(0, i, 41) nis[i] = 0; for (int i = 40; i >= 0; i -= 1) { if (a >= n2[i]) { nis[i]++; a -= n2[i]; } if (b >= n2[i]) { nis[i]++; b -= n2[i]; } } int sum = 0; rep(0, i, 41) sum += (nis[i] % 2 * n2[i]); return sum; } // int ma[1024577][21]; // for(int bit=0;bit<(1<<n);bit++)rep(0,i,n)if(bit&(1<<i))ma[bit][i]=1; struct UnionFind { vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化 for (int i = 0; i < N; i++) par[i] = i; } int root(int x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (par[x] == x) return x; return par[x] = root(par[x]); } void unite(int x, int y) { // xとyの木を併合 int rx = root(x); // xの根をrx int ry = root(y); // yの根をry if (rx == ry) return; // xとyの根が同じ(=同じ木にある)時はそのまま par[rx] = ry; // xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける } bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す int rx = root(x); int ry = root(y); return rx == ry; } }; int a[114514]; P ans[114514]; signed main() { ic(n) rep(0, i, n) cin >> a[i]; sort(a, a + n); int ma = 0; if (a[0] <= 0 && a[n - 1] >= 0) { int k = 0; rep(0, i, n - 1) { if (a[i] <= 0 && a[i + 1] >= 0) { k = i + 1; } } int t = a[n - 1]; rep(1, i, k) { ans[i - 1].f = t; ans[i - 1].s = a[i]; t -= a[i]; } int s = a[0]; rep(k, i, n - 1) { ans[i - 1].f = s; ans[i - 1].s = a[i]; s -= a[i]; } ans[n - 2].f = t; ans[n - 2].s = s; ma = t - s; } else if (a[0] > 0) { ans[0].f = a[0]; ans[0].s = a[1]; int t = a[0] - a[1]; rep(1, i, n - 2) { ans[i].f = t; ans[i].s = a[i + 1]; t -= a[i + 1]; } ans[n - 2].f = a[n - 1]; ans[n - 2].s = t; ma = a[n - 1] - t; } else { ans[0].f = a[n - 1]; ans[0].s = a[n - 2]; int t = a[n - 1] - a[n - 2]; rep(1, i, n - 1) { ans[i].f = t; ans[i].s = a[i - 1]; t -= a[i - 1]; } ma = t; } c(ma) rep(0, i, n - 1) { cout << ans[i].f << " " << ans[i].s << endl; } }
[ "expression.operator.change" ]
821,236
821,237
u942393279
cpp
p03007
#define _GLIBCXX_DEBUG #define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using pss = pair<string, string>; using pcc = pair<char, char>; using pbb = pair<bool, bool>; using pil = pair<int, ll>; using pli = pair<ll, int>; using ti3 = tuple<int, int, int>; using tl3 = tuple<ll, ll, ll>; using td3 = tuple<double, double, double>; using ts3 = tuple<string, string, string>; using tc3 = tuple<char, char, char>; using tb3 = tuple<bool, bool, bool>; using ti4 = tuple<int, int, int, int>; using tl4 = tuple<ll, ll, ll, ll>; using td4 = tuple<double, double, double, double>; using ts4 = tuple<string, string, string, string>; using tc4 = tuple<char, char, char, char>; using tb4 = tuple<bool, bool, bool, bool>; using vi = vector<int>; using vl = vector<ll>; using vd = vector<double>; using vs = vector<string>; using vc = vector<char>; using vb = vector<bool>; using vvi = vector<vi>; using vvl = vector<vl>; using vvd = vector<vd>; using vvs = vector<vs>; using vvc = vector<vc>; using vvb = vector<vb>; using vvvi = vector<vvi>; using vvvl = vector<vvl>; using vvvd = vector<vvd>; using vvvs = vector<vvs>; using vvvc = vector<vvc>; using vvvb = vector<vvb>; using vpii = vector<pii>; using vpll = vector<pll>; using vpdd = vector<pdd>; using vpss = vector<pss>; using vpcc = vector<pcc>; using vpbb = vector<pbb>; using vpil = vector<pil>; using vpli = vector<pli>; using vti3 = vector<ti3>; using vtl3 = vector<tl3>; using vtd3 = vector<td3>; using vts3 = vector<ts3>; using vtc3 = vector<tc3>; using vtb3 = vector<tb3>; using vti4 = vector<ti4>; using vtl4 = vector<tl4>; using vtd4 = vector<td4>; using vts4 = vector<ts4>; using vtc4 = vector<tc4>; using vtb4 = vector<tb4>; using mii = map<int, int>; using mll = map<ll, ll>; using msi = map<string, int>; using mci = map<char, int>; using mil = map<int, ll>; using mli = map<ll, int>; using si = set<int>; using sl = set<ll>; using sd = set<double>; using ss = set<string>; using sc = set<char>; using sb = set<bool>; using spii = set<pii>; using spll = set<pll>; using spdd = set<pdd>; using spss = set<pss>; using spcc = set<pcc>; using spbb = set<pbb>; using spil = set<pil>; using spli = set<pli>; using sti3 = set<ti3>; using stl3 = set<tl3>; using std3 = set<td3>; using sts3 = set<ts3>; using stc3 = set<tc3>; using stb3 = set<tb3>; #define rep0(TMS) for (int CNT = 0; CNT < (int)(TMS); CNT++) #define rep(CNT, GOAL) for (int CNT = 0; CNT < (int)(GOAL); CNT++) #define rep2(CNT, START, GOAL) \ for (int CNT = (int)(START); CNT < (int)(GOAL); CNT++) #define rep3(CNT, START, GOAL) \ for (int CNT = (int)(START); CNT > (int)(GOAL); CNT--) #define all(CONT) begin(CONT), end(CONT) #define fr1(CONT) next(begin(CONT)), end(CONT) #define itrep(ITR, CONT) for (auto ITR = begin(CONT); ITR != end(CONT); ITR++) #define itrep1(ITR, CONT) \ for (auto ITR = next(begin(CONT)); ITR != end(CONT); ITR++) #define maxel(CONT) *max_element(all(CONT)) #define minel(CONT) *min_element(all(CONT)) template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <typename T> T sum(const vector<T> &VEC) { return accumulate(all(VEC), 0.0); } template <typename T> vector<T> acm(const vector<T> &VEC) { vector<T> RES(VEC.size() + 1); rep(CNT, VEC.size()) RES[CNT + 1] = RES[CNT] + VEC[CNT]; return RES; } template <typename T> void fil(vector<T> &VEC, const int NUM, const T &VAL) { VEC.assign(NUM, VAL); } template <typename T> void fil(vector<T> &VEC, const int NUM) { VEC.assign(NUM, 0.0); } template <typename T> void fil(vector<vector<T>> &VV, const int RNUM, const int CNUM, const T &VAL) { fil(VV, RNUM, vector<T>()); rep(CNT, RNUM) fil(VV[CNT], CNUM, VAL); } template <typename T> void fil(vector<vector<T>> &VV, const int RNUM, const int CNUM) { fil(VV, RNUM, vector<T>()); rep(CNT, RNUM) fil(VV[CNT], CNUM); } template <typename T> void fil(vector<vector<T>> &VV, const int RNUM) { fil(VV, RNUM, vector<T>()); } void prec(const int &DIG) { cerr << fixed << setprecision(DIG); cout << fixed << setprecision(DIG); } template <typename T> void COUT(const T &ELEM) { cout << ELEM; } template <typename T> void pout(const T &ELEM) { COUT(ELEM); cout << " "; } template <typename T, typename... Ts> void pout(const T &FIRST, const Ts &...REST) { pout(FIRST); pout(REST...); } template <typename T> void print(T ELEM) { COUT(ELEM); cout << "\n"; } template <typename T, typename... Ts> void print(const T &FIRST, const Ts &...REST) { print(FIRST); print(REST...); } void CERR() { cerr << "\n"; } template <typename T> void CERR(const T &ELEM) { cerr << ELEM; } template <typename T, typename... Ts> void CERR(const T &FIRST, const Ts &...REST) { CERR(FIRST); cerr << ", "; CERR(REST...); } template <typename T1, typename T2> void CERR(const pair<T1, T2> &PAIR) { cerr << "("; CERR(PAIR.first); cerr << ", "; CERR(PAIR.second); cerr << ")"; } template <typename T1, typename T2, typename T3> void CERR(const tuple<T1, T2, T3> &TUP3) { cerr << "("; CERR(get<0>(TUP3)); cerr << ", "; CERR(get<1>(TUP3)); cerr << ", "; CERR(get<2>(TUP3)); cerr << ")"; } template <typename T1, typename T2, typename T3, typename T4> void CERR(const tuple<T1, T2, T3, T4> &TUP4) { cerr << "("; CERR(get<0>(TUP4)); cerr << ", "; CERR(get<1>(TUP4)); cerr << ", "; CERR(get<2>(TUP4)); cerr << ", "; CERR(get<3>(TUP4)); cerr << ")"; } template <typename T> void CERR(const vector<T> &VEC) { cerr << "{ "; itrep(ITR, VEC) { CERR(*ITR); cerr << ", "; } cerr << "}"; } template <typename T> void CERR1(const vector<T> &VEC) { cerr << "{ "; itrep1(ITR, VEC) { CERR(*ITR); cerr << ", "; } cerr << "}"; } template <typename T> void CERR(const set<T> &SET) { cerr << "{ "; itrep(ITR, SET) { CERR(*ITR); cerr << ", "; } cerr << "}"; } template <typename T1, typename T2> void CERR(const map<T1, T2> &MAP) { cerr << "{ "; itrep(ITR, MAP) { CERR(*ITR); cerr << ", "; } cerr << "}"; } #define db(OBJ) \ cerr << #OBJ << ": "; \ CERR(OBJ); \ cerr << ", " #define dbl(OBJ) \ cerr << #OBJ << ": "; \ CERR(OBJ); \ cerr << "\n" #define db1(OBJ) \ cerr << #OBJ << ": "; \ CERR1(OBJ); \ cerr << "\n" #define dbs(...) \ cerr << "(" << #__VA_ARGS__ << "): ("; \ CERR(__VA_ARGS__); \ cerr << ")\n" #define dbvv(VV) \ cerr << #VV << ": {\n"; \ rep(CNT, VV.size()) { \ cerr << #VV << "[" << CNT << "]: "; \ CERR(VV[CNT]); \ cerr << ",\n"; \ } \ cerr << "}\n" #define db01(VV) \ cerr << #VV << ": {\n"; \ rep(CNT, VV.size()) { \ cerr << #VV << "[" << CNT << "]: "; \ CERR1(VV[CNT]); \ cerr << ",\n"; \ } \ cerr << "}\n" #define db10(VV) \ cerr << #VV << ": {\n"; \ rep2(CNT, 1, VV.size()) { \ cerr << #VV << "[" << CNT << "]: "; \ CERR(VV[CNT]); \ cerr << ",\n"; \ } \ cerr << "}\n" #define db11(VV) \ cerr << #VV << ": {\n"; \ rep2(CNT, 1, VV.size()) { \ cerr << #VV << "[" << CNT << "]: "; \ CERR1(VV[CNT]); \ cerr << ",\n"; \ } \ cerr << "}\n" #define YN(FLG) cout << (FLG ? "YES" : "NO") << "\n" #define Yn(FLG) cout << (FLG ? "Yes" : "No") << "\n" #define yn(FLG) cout << (FLG ? "yes" : "no") << "\n" #define pcase(NUM) \ cout << "Case #" << NUM << ":" \ << " " #define pcasel(NUM) \ cout << "Case #" << NUM << ":" \ << "\n" // const ll INF = 1'000'000'000'000'000'007; const int INF = 1'000'000'007; const ll MOD = 1'000'000'007; // 998'244'353; // 1個以上N-1個以下のAの要素を-1倍し,合計を最大化することを考える。 // これは,Aの要素の単純な合計Sから,Aの要素を小さい方から1個以上N-1個の範囲で選び,その合計をできるだけ小さくしたときのTの2倍を減じたもの。 // Aの要素を昇順にソートしてよい。 void print(int x, int y) { cout << x << " " << y << endl; } int main() { int N; cin >> N; vi A(N); rep(i, N) cin >> A[i]; sort(all(A)); int M = -A[0] + A[N - 1]; rep2(i, 1, N - 1) { if (A[i] < 0) M -= A[i]; else M += A[i]; } cout << M << endl; int x1 = A[0], x2 = A[N - 1]; // x1:- x2:+. 最後にx2からx1を引く。 // 途中でx1から引かれているものは最後に+になり,x2から引かれているものは最後まで-のまま。 // したがって,Aiが負であればx2から引き,非負であればx1から引く。 rep2(i, 1, N - 1) { if (A[i] < 0) { print(x1, A[i]); x1 -= A[i]; } else { print(x2, A[i]); x2 -= A[i]; } } print(x2, x1); }
#define _GLIBCXX_DEBUG #define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using pss = pair<string, string>; using pcc = pair<char, char>; using pbb = pair<bool, bool>; using pil = pair<int, ll>; using pli = pair<ll, int>; using ti3 = tuple<int, int, int>; using tl3 = tuple<ll, ll, ll>; using td3 = tuple<double, double, double>; using ts3 = tuple<string, string, string>; using tc3 = tuple<char, char, char>; using tb3 = tuple<bool, bool, bool>; using ti4 = tuple<int, int, int, int>; using tl4 = tuple<ll, ll, ll, ll>; using td4 = tuple<double, double, double, double>; using ts4 = tuple<string, string, string, string>; using tc4 = tuple<char, char, char, char>; using tb4 = tuple<bool, bool, bool, bool>; using vi = vector<int>; using vl = vector<ll>; using vd = vector<double>; using vs = vector<string>; using vc = vector<char>; using vb = vector<bool>; using vvi = vector<vi>; using vvl = vector<vl>; using vvd = vector<vd>; using vvs = vector<vs>; using vvc = vector<vc>; using vvb = vector<vb>; using vvvi = vector<vvi>; using vvvl = vector<vvl>; using vvvd = vector<vvd>; using vvvs = vector<vvs>; using vvvc = vector<vvc>; using vvvb = vector<vvb>; using vpii = vector<pii>; using vpll = vector<pll>; using vpdd = vector<pdd>; using vpss = vector<pss>; using vpcc = vector<pcc>; using vpbb = vector<pbb>; using vpil = vector<pil>; using vpli = vector<pli>; using vti3 = vector<ti3>; using vtl3 = vector<tl3>; using vtd3 = vector<td3>; using vts3 = vector<ts3>; using vtc3 = vector<tc3>; using vtb3 = vector<tb3>; using vti4 = vector<ti4>; using vtl4 = vector<tl4>; using vtd4 = vector<td4>; using vts4 = vector<ts4>; using vtc4 = vector<tc4>; using vtb4 = vector<tb4>; using mii = map<int, int>; using mll = map<ll, ll>; using msi = map<string, int>; using mci = map<char, int>; using mil = map<int, ll>; using mli = map<ll, int>; using si = set<int>; using sl = set<ll>; using sd = set<double>; using ss = set<string>; using sc = set<char>; using sb = set<bool>; using spii = set<pii>; using spll = set<pll>; using spdd = set<pdd>; using spss = set<pss>; using spcc = set<pcc>; using spbb = set<pbb>; using spil = set<pil>; using spli = set<pli>; using sti3 = set<ti3>; using stl3 = set<tl3>; using std3 = set<td3>; using sts3 = set<ts3>; using stc3 = set<tc3>; using stb3 = set<tb3>; #define rep0(TMS) for (int CNT = 0; CNT < (int)(TMS); CNT++) #define rep(CNT, GOAL) for (int CNT = 0; CNT < (int)(GOAL); CNT++) #define rep2(CNT, START, GOAL) \ for (int CNT = (int)(START); CNT < (int)(GOAL); CNT++) #define rep3(CNT, START, GOAL) \ for (int CNT = (int)(START); CNT > (int)(GOAL); CNT--) #define all(CONT) begin(CONT), end(CONT) #define fr1(CONT) next(begin(CONT)), end(CONT) #define itrep(ITR, CONT) for (auto ITR = begin(CONT); ITR != end(CONT); ITR++) #define itrep1(ITR, CONT) \ for (auto ITR = next(begin(CONT)); ITR != end(CONT); ITR++) #define maxel(CONT) *max_element(all(CONT)) #define minel(CONT) *min_element(all(CONT)) template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <typename T> T sum(const vector<T> &VEC) { return accumulate(all(VEC), 0.0); } template <typename T> vector<T> acm(const vector<T> &VEC) { vector<T> RES(VEC.size() + 1); rep(CNT, VEC.size()) RES[CNT + 1] = RES[CNT] + VEC[CNT]; return RES; } template <typename T> void fil(vector<T> &VEC, const int NUM, const T &VAL) { VEC.assign(NUM, VAL); } template <typename T> void fil(vector<T> &VEC, const int NUM) { VEC.assign(NUM, 0.0); } template <typename T> void fil(vector<vector<T>> &VV, const int RNUM, const int CNUM, const T &VAL) { fil(VV, RNUM, vector<T>()); rep(CNT, RNUM) fil(VV[CNT], CNUM, VAL); } template <typename T> void fil(vector<vector<T>> &VV, const int RNUM, const int CNUM) { fil(VV, RNUM, vector<T>()); rep(CNT, RNUM) fil(VV[CNT], CNUM); } template <typename T> void fil(vector<vector<T>> &VV, const int RNUM) { fil(VV, RNUM, vector<T>()); } void prec(const int &DIG) { cerr << fixed << setprecision(DIG); cout << fixed << setprecision(DIG); } template <typename T> void COUT(const T &ELEM) { cout << ELEM; } template <typename T> void pout(const T &ELEM) { COUT(ELEM); cout << " "; } template <typename T, typename... Ts> void pout(const T &FIRST, const Ts &...REST) { pout(FIRST); pout(REST...); } template <typename T> void print(T ELEM) { COUT(ELEM); cout << "\n"; } template <typename T, typename... Ts> void print(const T &FIRST, const Ts &...REST) { print(FIRST); print(REST...); } void CERR() { cerr << "\n"; } template <typename T> void CERR(const T &ELEM) { cerr << ELEM; } template <typename T, typename... Ts> void CERR(const T &FIRST, const Ts &...REST) { CERR(FIRST); cerr << ", "; CERR(REST...); } template <typename T1, typename T2> void CERR(const pair<T1, T2> &PAIR) { cerr << "("; CERR(PAIR.first); cerr << ", "; CERR(PAIR.second); cerr << ")"; } template <typename T1, typename T2, typename T3> void CERR(const tuple<T1, T2, T3> &TUP3) { cerr << "("; CERR(get<0>(TUP3)); cerr << ", "; CERR(get<1>(TUP3)); cerr << ", "; CERR(get<2>(TUP3)); cerr << ")"; } template <typename T1, typename T2, typename T3, typename T4> void CERR(const tuple<T1, T2, T3, T4> &TUP4) { cerr << "("; CERR(get<0>(TUP4)); cerr << ", "; CERR(get<1>(TUP4)); cerr << ", "; CERR(get<2>(TUP4)); cerr << ", "; CERR(get<3>(TUP4)); cerr << ")"; } template <typename T> void CERR(const vector<T> &VEC) { cerr << "{ "; itrep(ITR, VEC) { CERR(*ITR); cerr << ", "; } cerr << "}"; } template <typename T> void CERR1(const vector<T> &VEC) { cerr << "{ "; itrep1(ITR, VEC) { CERR(*ITR); cerr << ", "; } cerr << "}"; } template <typename T> void CERR(const set<T> &SET) { cerr << "{ "; itrep(ITR, SET) { CERR(*ITR); cerr << ", "; } cerr << "}"; } template <typename T1, typename T2> void CERR(const map<T1, T2> &MAP) { cerr << "{ "; itrep(ITR, MAP) { CERR(*ITR); cerr << ", "; } cerr << "}"; } #define db(OBJ) \ cerr << #OBJ << ": "; \ CERR(OBJ); \ cerr << ", " #define dbl(OBJ) \ cerr << #OBJ << ": "; \ CERR(OBJ); \ cerr << "\n" #define db1(OBJ) \ cerr << #OBJ << ": "; \ CERR1(OBJ); \ cerr << "\n" #define dbs(...) \ cerr << "(" << #__VA_ARGS__ << "): ("; \ CERR(__VA_ARGS__); \ cerr << ")\n" #define dbvv(VV) \ cerr << #VV << ": {\n"; \ rep(CNT, VV.size()) { \ cerr << #VV << "[" << CNT << "]: "; \ CERR(VV[CNT]); \ cerr << ",\n"; \ } \ cerr << "}\n" #define db01(VV) \ cerr << #VV << ": {\n"; \ rep(CNT, VV.size()) { \ cerr << #VV << "[" << CNT << "]: "; \ CERR1(VV[CNT]); \ cerr << ",\n"; \ } \ cerr << "}\n" #define db10(VV) \ cerr << #VV << ": {\n"; \ rep2(CNT, 1, VV.size()) { \ cerr << #VV << "[" << CNT << "]: "; \ CERR(VV[CNT]); \ cerr << ",\n"; \ } \ cerr << "}\n" #define db11(VV) \ cerr << #VV << ": {\n"; \ rep2(CNT, 1, VV.size()) { \ cerr << #VV << "[" << CNT << "]: "; \ CERR1(VV[CNT]); \ cerr << ",\n"; \ } \ cerr << "}\n" #define YN(FLG) cout << (FLG ? "YES" : "NO") << "\n" #define Yn(FLG) cout << (FLG ? "Yes" : "No") << "\n" #define yn(FLG) cout << (FLG ? "yes" : "no") << "\n" #define pcase(NUM) \ cout << "Case #" << NUM << ":" \ << " " #define pcasel(NUM) \ cout << "Case #" << NUM << ":" \ << "\n" // const ll INF = 1'000'000'000'000'000'007; const int INF = 1'000'000'007; const ll MOD = 1'000'000'007; // 998'244'353; // 1個以上N-1個以下のAの要素を-1倍し,合計を最大化することを考える。 // これは,Aの要素の単純な合計Sから,Aの要素を小さい方から1個以上N-1個の範囲で選び,その合計をできるだけ小さくしたときのTの2倍を減じたもの。 // Aの要素を昇順にソートしてよい。 void print(int x, int y) { cout << x << " " << y << endl; } int main() { int N; cin >> N; vi A(N); rep(i, N) cin >> A[i]; sort(all(A)); int M = -A[0] + A[N - 1]; rep2(i, 1, N - 1) { if (A[i] < 0) M -= A[i]; else M += A[i]; } cout << M << endl; int x1 = A[0], x2 = A[N - 1]; // x1:- x2:+. 最後にx2からx1を引く。 // 途中でx1から引かれているものは最後に+になり,x2から引かれているものは最後まで-のまま。 // したがって,Aiが負であればx2から引き,非負であればx1から引く。 rep2(i, 1, N - 1) { if (A[i] >= 0) { print(x1, A[i]); x1 -= A[i]; } else { print(x2, A[i]); x2 -= A[i]; } } print(x2, x1); }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
821,248
821,249
u042802884
cpp
p03007
#include <bits/stdc++.h> using namespace std; #define repl(i, l, r) for (ll i = (l); i < (r); i++) #define rep(i, n) repl(i, 0, n) #define fi first #define se second #define all(x) (x).begin(), (x).end() #define CST(x) cout << fixed << setprecision(x) using ll = long long; const ll MOD = 1000000007; const int inf = 1e9 + 10; const ll INF = 4e18 + 10; const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0}; const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0}; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); int n; cin >> n; int a[n], sum = 0; rep(i, n) { cin >> a[i]; sum += a[i]; } sort(a, a + n); if (a[0] >= 0) { cout << sum - a[0] * 2 << endl; rep(i, n - 2) { cout << a[0] << " " << a[i + 1] << endl; a[0] -= a[i + 1]; } cout << a[n - 1] << " " << a[0] << endl; } else if (a[n - 1] <= 0) { reverse(a, a + n); cout << -sum + a[0] * 2 << endl; rep(i, n - 1) { cout << a[0] << " " << a[i + 1] << endl; a[0] -= a[i + 1]; } } else { sum = 0; rep(i, n) sum += abs(a[i]); cout << sum << endl; int p = upper_bound(a, a + n, 0) - a; for (int i = 1; i < p; i++) { cout << a[p] << " " << a[i] << endl; a[p] += a[i]; } for (int i = p; i < n - 1; i++) { cout << a[0] << " " << a[i] << endl; a[0] -= a[i]; } cout << a[n - 1] << " " << a[0] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; #define repl(i, l, r) for (ll i = (l); i < (r); i++) #define rep(i, n) repl(i, 0, n) #define fi first #define se second #define all(x) (x).begin(), (x).end() #define CST(x) cout << fixed << setprecision(x) using ll = long long; const ll MOD = 1000000007; const int inf = 1e9 + 10; const ll INF = 4e18 + 10; const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0}; const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0}; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); int n; cin >> n; int a[n], sum = 0; rep(i, n) { cin >> a[i]; sum += a[i]; } sort(a, a + n); if (a[0] >= 0) { cout << sum - a[0] * 2 << endl; rep(i, n - 2) { cout << a[0] << " " << a[i + 1] << endl; a[0] -= a[i + 1]; } cout << a[n - 1] << " " << a[0] << endl; } else if (a[n - 1] <= 0) { reverse(a, a + n); cout << -sum + a[0] * 2 << endl; rep(i, n - 1) { cout << a[0] << " " << a[i + 1] << endl; a[0] -= a[i + 1]; } } else { sum = 0; rep(i, n) sum += abs(a[i]); cout << sum << endl; int p = upper_bound(a, a + n, 0) - a; for (int i = 1; i < p; i++) { cout << a[p] << " " << a[i] << endl; a[p] -= a[i]; } for (int i = p; i < n - 1; i++) { cout << a[0] << " " << a[i] << endl; a[0] -= a[i]; } cout << a[n - 1] << " " << a[0] << endl; } return 0; }
[ "expression.operator.change" ]
821,252
821,253
u936602931
cpp
p03007
#include <bits/stdc++.h> using namespace std; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } using ll = long long; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; const int INF = 1 << 30; const ll mod = 1000000007LL; int main() { ll N; cin >> N; vector<ll> v(N); for (ll i = 0; i < N; i++) cin >> v[i]; sort(v.begin(), v.end()); if (v[N - 1] >= 0 && v[0] <= 0) { ll ans = 0; for (auto x : v) ans += abs(x); cout << ans << endl; ll t = v[N - 1]; ll i = 0; while (v[i + 1] <= 0) { cout << t << " " << v[i] << endl; t -= v[i]; i++; } ll j = N - 2; ll s = v[i]; while (v[j] > 0) { cout << s << " " << v[j] << endl; s -= v[j]; j--; } cout << t << " " << s << endl; } if (v[0] > 0) { ll ans = 0; for (ll i = 0; i < N; i++) { if (i == 0) ans -= v[i]; else ans += v[i]; } cout << ans << endl; ll t = v[0]; for (ll i = 1; i < N - 1; i++) { cout << t << " " << v[i] << endl; t -= v[i]; } cout << v[N - 1] << " " << t << endl; } if (v[N - 1] < 0) { ll ans = 0LL; for (ll i = 0; i < N; i++) { if (i == N - 1) ans -= v[i]; else ans += v[i]; } cout << abs(ans) << endl; ll t = v[N - 1]; for (int i = 0; i < N - 1; i++) { cout << t << " " << v[i] << endl; t -= v[i]; } } }
#include <bits/stdc++.h> using namespace std; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } using ll = long long; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; const int INF = 1 << 30; const ll mod = 1000000007LL; int main() { ll N; cin >> N; vector<ll> v(N); for (ll i = 0; i < N; i++) cin >> v[i]; sort(v.begin(), v.end()); if (v[N - 1] > 0 && v[0] < 0) { ll ans = 0; for (auto x : v) ans += abs(x); cout << ans << endl; ll t = v[N - 1]; ll i = 0; while (v[i + 1] <= 0) { cout << t << " " << v[i] << endl; t -= v[i]; i++; } ll j = N - 2; ll s = v[i]; while (v[j] > 0) { cout << s << " " << v[j] << endl; s -= v[j]; j--; } cout << t << " " << s << endl; } if (v[0] >= 0) { ll ans = 0; for (ll i = 0; i < N; i++) { if (i == 0) ans -= v[i]; else ans += v[i]; } cout << ans << endl; ll t = v[0]; for (ll i = 1; i < N - 1; i++) { cout << t << " " << v[i] << endl; t -= v[i]; } cout << v[N - 1] << " " << t << endl; } else if (v[N - 1] <= 0) { ll ans = 0LL; for (ll i = 0; i < N; i++) { if (i == N - 1) ans -= v[i]; else ans += v[i]; } cout << abs(ans) << endl; ll t = v[N - 1]; for (int i = 0; i < N - 1; i++) { cout << t << " " << v[i] << endl; t -= v[i]; } } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "control_flow.branch.else_if.replace.add", "control_flow.branch.if.replace.remove" ]
821,256
821,257
u787139585
cpp
p03007
#include <bits/stdc++.h> #define int long long typedef long long ll; using namespace std; const ll MAXN = 200000; ll N, ans = 0, tmp = 0; vector<ll> A; signed main() { cin >> N; for (int i = 0; i < N; i++) { ll num; cin >> num; A.push_back(num); } sort(A.begin(), A.end()); ll lv = A.back(); ll mv = A[0]; for (int i = 1; i < A.size() - 1; i++) { if (A[i] >= 0) { // cout << mv << " " << A[i] << endl; mv -= A[i]; } else { // cout << lv << " " << A[i] << endl; lv += A[i]; } } // cout << lv << " " << mv << endl; cout << lv - mv << endl; lv = A.back(); mv = A[0]; for (int i = 1; i < A.size() - 1; i++) { if (A[i] >= 0) { cout << mv << " " << A[i] << endl; mv -= A[i]; } else { cout << lv << " " << A[i] << endl; lv += A[i]; } } cout << lv << " " << mv << endl; // cout << lv-mv << endl; return 0; }
#include <bits/stdc++.h> #define int long long typedef long long ll; using namespace std; const ll MAXN = 200000; ll N, ans = 0, tmp = 0; vector<ll> A; signed main() { cin >> N; for (int i = 0; i < N; i++) { ll num; cin >> num; A.push_back(num); } sort(A.begin(), A.end()); ll lv = A.back(); ll mv = A[0]; for (int i = 1; i < A.size() - 1; i++) { if (A[i] >= 0) { // cout << mv << " " << A[i] << endl; mv -= A[i]; } else { // cout << lv << " " << A[i] << endl; lv -= A[i]; } } // cout << lv << " " << mv << endl; cout << lv - mv << endl; lv = A.back(); mv = A[0]; for (int i = 1; i < A.size() - 1; i++) { if (A[i] >= 0) { cout << mv << " " << A[i] << endl; mv -= A[i]; } else { cout << lv << " " << A[i] << endl; lv -= A[i]; } } cout << lv << " " << mv << endl; // cout << lv-mv << endl; return 0; }
[ "expression.operator.change" ]
821,266
821,267
u132452589
cpp
p03007
#include <bits/stdc++.h> #define int long long #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; constexpr int MOD = 1000000007; constexpr int INF = numeric_limits<int>::max() / 2; typedef pair<int, int> P; using Graph = vector<vector<int>>; signed main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N; cin >> N; vector<int> A(N); rep(i, N) cin >> A[i]; sort(A.begin(), A.end()); int num = A[0]; int ans = 0; if (A[0] <= 0 && A[N - 1] >= 0) { rep(i, N) { ans += abs(A[i]); } cout << ans << endl; for (int i = N - 2; i >= 0; i--) { if (A[i] >= 0) { cout << A[0] << ' ' << A[i] << endl; A[0] -= A[i]; } else { num = i; break; } } for (int i = 0; i <= num; i++) { cout << A[N - 1] << ' ' << A[i] << endl; A[N - 1] -= A[i]; } } else if (A[0] >= 0) { for (int i = 1; i < N; i++) { ans += A[i]; } cout << ans - A[0] << endl; for (int i = 0; i < N - 2; i++) { cout << A[i] << ' ' << A[i + 1] << endl; A[i + 1] = A[i] - A[i + 1]; } cout << A[N - 1] << ' ' << A[N - 2] << endl; } else { for (int i = 0; i < N - 1; i++) { ans -= A[i]; } cout << ans + A[N - 1] << endl; for (int i = N - 1; i > 0; i--) { cout << A[i] << ' ' << A[i - 1] << endl; A[i - 1] = A[i] - A[i - 1]; } } }
#include <bits/stdc++.h> #define int long long #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; constexpr int MOD = 1000000007; constexpr int INF = numeric_limits<int>::max() / 2; typedef pair<int, int> P; using Graph = vector<vector<int>>; signed main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N; cin >> N; vector<int> A(N); rep(i, N) cin >> A[i]; sort(A.begin(), A.end()); int num = A[0]; int ans = 0; if (A[0] <= 0 && A[N - 1] >= 0) { rep(i, N) { ans += abs(A[i]); } cout << ans << endl; for (int i = N - 2; i >= 0; i--) { if (A[i] > 0) { cout << A[0] << ' ' << A[i] << endl; A[0] -= A[i]; } else { num = i; break; } } for (int i = 0; i <= num; i++) { cout << A[N - 1] << ' ' << A[i] << endl; A[N - 1] -= A[i]; } } else if (A[0] >= 0) { for (int i = 1; i < N; i++) { ans += A[i]; } cout << ans - A[0] << endl; for (int i = 0; i < N - 2; i++) { cout << A[i] << ' ' << A[i + 1] << endl; A[i + 1] = A[i] - A[i + 1]; } cout << A[N - 1] << ' ' << A[N - 2] << endl; } else { for (int i = 0; i < N - 1; i++) { ans -= A[i]; } cout << ans + A[N - 1] << endl; for (int i = N - 1; i > 0; i--) { cout << A[i] << ' ' << A[i - 1] << endl; A[i - 1] = A[i] - A[i - 1]; } } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
821,268
821,269
u415916075
cpp
p03007
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> i_i; typedef pair<ll, ll> l_l; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) #define int ll // const ll mod = 1000000007; int n, t; vector<int> a; int p, ng; int sum; int ans; signed main() { cin >> n; for (int i = 0; i < n; i++) { cin >> t; a.push_back(t); if (t > 0) p += t; else if (t < 0) ng += t; } if (p == 0) { sort(a.begin(), a.end(), greater<int>()); cout << -ng + 2 * a.front() << endl; sum = a.front(); for (int i = 1; i < n; i++) { cout << sum << " " << a[i]; sum -= a[i]; } } else if (ng == 0) { sort(a.begin(), a.end()); cout << p - 2 * a.front() << endl; sum = a.front(); for (int i = 1; i < n - 1; i++) { cout << sum << " " << a[i] << endl; sum -= a[i]; } cout << a[n - 1] << " " << sum << endl; } else { cout << p - ng << endl; sort(a.begin(), a.end()); sum = a.back(); a.pop_back(); for (int i = n - 2; i >= 0; i--) { if (a[i] > 0) { cout << a[0] << " " << a[i] << endl; a[0] -= a[i]; a.pop_back(); } else break; } for (auto &it : a) { cout << sum << " " << it << endl; sum -= it; } } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> i_i; typedef pair<ll, ll> l_l; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) #define int ll // const ll mod = 1000000007; int n, t; vector<int> a; int p, ng; int sum; int ans; signed main() { cin >> n; for (int i = 0; i < n; i++) { cin >> t; a.push_back(t); if (t > 0) p += t; else if (t < 0) ng += t; } if (p == 0) { sort(a.begin(), a.end(), greater<int>()); cout << -ng + 2 * a.front() << endl; sum = a.front(); for (int i = 1; i < n; i++) { cout << sum << " " << a[i] << endl; sum -= a[i]; } } else if (ng == 0) { sort(a.begin(), a.end()); cout << p - 2 * a.front() << endl; sum = a.front(); for (int i = 1; i < n - 1; i++) { cout << sum << " " << a[i] << endl; sum -= a[i]; } cout << a[n - 1] << " " << sum << endl; } else { cout << p - ng << endl; sort(a.begin(), a.end()); sum = a.back(); a.pop_back(); for (int i = n - 2; i >= 0; i--) { if (a[i] > 0) { cout << a[0] << " " << a[i] << endl; a[0] -= a[i]; a.pop_back(); } else break; } for (auto &it : a) { cout << sum << " " << it << endl; sum -= it; } } }
[ "io.output.newline.add" ]
821,307
821,308
u324219643
cpp
p03007
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; int main() { int i, j = 0, k = 0, n; cin >> n; int x[n - 1], y[n - 1], a[n], b[n]; for (i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); for (i = 0; i < n - 2; i++) { if (a[j] <= 0) { x[i] = a[n - 1]; y[i] = a[j]; a[n - 1] -= y[i]; j++; } else if (a[n - k - 1] > 0) { x[i] = a[0]; y[i] = a[n - k - 1]; a[0] -= y[i]; k++; } } cout << a[n - 1] - a[0] << endl; for (i = 0; i < n - 2; i++) { cout << x[i] << " " << y[i] << endl; } cout << a[n - 1] << " " << a[0] << endl; return 0; }
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; int main() { int i, j = 1, k = 1, n; cin >> n; int x[n - 1], y[n - 1], a[n], b[n]; for (i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); for (i = 0; i < n - 2; i++) { if (a[j] <= 0) { x[i] = a[n - 1]; y[i] = a[j]; a[n - 1] -= y[i]; j++; } else if (a[n - k - 1] > 0) { x[i] = a[0]; y[i] = a[n - k - 1]; a[0] -= y[i]; k++; } } cout << a[n - 1] - a[0] << endl; for (i = 0; i < n - 2; i++) { cout << x[i] << " " << y[i] << endl; } cout << a[n - 1] << " " << a[0] << endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change" ]
821,318
821,319
u105801182
cpp
p03007
#include <bits/stdc++.h> #define LLI long long int #define FOR(v, a, b) for (LLI v = (a); v < (b); ++v) #define FORE(v, a, b) for (LLI v = (a); v <= (b); ++v) #define REP(v, n) FOR(v, 0, n) #define REPE(v, n) FORE(v, 0, n) #define REV(v, a, b) for (LLI v = (a); v >= (b); --v) #define ALL(x) (x).begin(), (x).end() #define RALL(x) (x).rbegin(), (x).rend() #define ITR(it, c) for (auto it = (c).begin(); it != (c).end(); ++it) #define RITR(it, c) for (auto it = (c).rbegin(); it != (c).rend(); ++it) #define EXIST(c, x) ((c).find(x) != (c).end()) #define fst first #define snd second #define popcount __builtin_popcount #define UNIQ(v) v.erase(unique(ALL(v)), v.end()) #define bit(i) (1LL << i) #define sz(v) ((LLI)(v).size()) #ifdef DEBUG #include <misc/C++/Debug.cpp> #else #define dump(...) ((void)0) #endif #define gcd __gcd using namespace std; template <class T> constexpr T lcm(T m, T n) { return m / gcd(m, n) * n; } template <typename I> void join(ostream &ost, I s, I t, string d = " ") { for (auto i = s; i != t; ++i) { if (i != s) ost << d; ost << *i; } ost << endl; } template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &a : v) is >> a; return is; } template <typename T, typename U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; } template <typename T, typename U> bool chmin(T &a, const U &b) { return (a > b ? a = b, true : false); } template <typename T, typename U> bool chmax(T &a, const U &b) { return (a < b ? a = b, true : false); } template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v) { fill((U *)a, (U *)(a + N), v); } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; while (cin >> N) { vector<LLI> A(N); cin >> A; sort(ALL(A)); vector<LLI> b(N); REP(i, N) b[i] = abs(A[i]); LLI ans = 0; vector<pair<int, int>> ans_op; if (A[0] > 0) { // all positive LLI x = A.front(); FOR(i, 1, N - 1) { ans_op.push_back({x, A[i]}); x -= A[i]; } ans_op.push_back({A.back(), x}); ans = accumulate(ALL(A), 0LL) - 2 * A[0]; } else if (A.back() < 0) { // all negative reverse(ALL(b)); reverse(ALL(A)); LLI x = A.front(); FOR(i, 1, N) { ans_op.push_back({x, A[i]}); x -= A[i]; } ans = accumulate(b.begin() + 1, b.end(), 0LL) - b[0]; } else { ans = accumulate(ALL(b), 0LL); LLI x = A.front(), y = A.back(); FOR(i, 1, N) { if (A[i] >= 0) break; ans_op.push_back({y, A[i]}); y -= A[i]; } REV(i, N - 2, 1) { if (A[i] < 0) break; ans_op.push_back({A[i], x}); x -= A[i]; } ans_op.push_back({y, x}); } cout << ans << endl; for (auto &p : ans_op) { cout << p.fst << " " << p.snd << endl; } } return 0; }
#include <bits/stdc++.h> #define LLI long long int #define FOR(v, a, b) for (LLI v = (a); v < (b); ++v) #define FORE(v, a, b) for (LLI v = (a); v <= (b); ++v) #define REP(v, n) FOR(v, 0, n) #define REPE(v, n) FORE(v, 0, n) #define REV(v, a, b) for (LLI v = (a); v >= (b); --v) #define ALL(x) (x).begin(), (x).end() #define RALL(x) (x).rbegin(), (x).rend() #define ITR(it, c) for (auto it = (c).begin(); it != (c).end(); ++it) #define RITR(it, c) for (auto it = (c).rbegin(); it != (c).rend(); ++it) #define EXIST(c, x) ((c).find(x) != (c).end()) #define fst first #define snd second #define popcount __builtin_popcount #define UNIQ(v) v.erase(unique(ALL(v)), v.end()) #define bit(i) (1LL << i) #define sz(v) ((LLI)(v).size()) #ifdef DEBUG #include <misc/C++/Debug.cpp> #else #define dump(...) ((void)0) #endif #define gcd __gcd using namespace std; template <class T> constexpr T lcm(T m, T n) { return m / gcd(m, n) * n; } template <typename I> void join(ostream &ost, I s, I t, string d = " ") { for (auto i = s; i != t; ++i) { if (i != s) ost << d; ost << *i; } ost << endl; } template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &a : v) is >> a; return is; } template <typename T, typename U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; } template <typename T, typename U> bool chmin(T &a, const U &b) { return (a > b ? a = b, true : false); } template <typename T, typename U> bool chmax(T &a, const U &b) { return (a < b ? a = b, true : false); } template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v) { fill((U *)a, (U *)(a + N), v); } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; while (cin >> N) { vector<LLI> A(N); cin >> A; sort(ALL(A)); vector<LLI> b(N); REP(i, N) b[i] = abs(A[i]); LLI ans = 0; vector<pair<int, int>> ans_op; if (A[0] >= 0) { // all positive LLI x = A.front(); FOR(i, 1, N - 1) { ans_op.push_back({x, A[i]}); x -= A[i]; } ans_op.push_back({A.back(), x}); ans = accumulate(ALL(A), 0LL) - 2 * A[0]; } else if (A.back() < 0) { // all negative reverse(ALL(b)); reverse(ALL(A)); LLI x = A.front(); FOR(i, 1, N) { ans_op.push_back({x, A[i]}); x -= A[i]; } ans = accumulate(b.begin() + 1, b.end(), 0LL) - b[0]; } else { ans = accumulate(ALL(b), 0LL); LLI x = A.front(), y = A.back(); FOR(i, 1, N) { if (A[i] >= 0) break; ans_op.push_back({y, A[i]}); y -= A[i]; } REV(i, N - 2, 1) { if (A[i] < 0) break; ans_op.push_back({x, A[i]}); x -= A[i]; } ans_op.push_back({y, x}); } cout << ans << endl; for (auto &p : ans_op) { cout << p.fst << " " << p.snd << endl; } } return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
821,337
821,338
u543167400
cpp
p03007
#include <bits/stdc++.h> using namespace std; #define int long long int #define ff first #define ss second #define N 100005 int32_t main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int a[n]; int sum = 0; vector<int> pos, neg; pos.push_back(0); for (int i = 0; i < n; ++i) { cin >> a[i]; sum += abs(a[i]); if (a[i] >= 0) pos.push_back(a[i]); else neg.push_back(a[i]); } sort(pos.begin(), pos.end()); sort(neg.begin(), neg.end(), greater<int>()); int ans; if (neg.size() > 0) { pos[0] = neg[0]; neg.erase(neg.begin()); if (pos.size() > 1) ans = sum; else ans = sum + 2 * pos[0]; } else { pos.erase(pos.begin()); ans = sum - 2 * pos[0]; } int n1 = pos.size(); cout << ans << "\n"; int in = 0; int last; last = pos[0]; for (int i = 0; i < n1 - 2; ++i) { cout << last << " " << pos[i + 1] << "\n"; last = last - pos[i + 1]; } if (n1 != 1) { cout << pos[n1 - 1] << " " << last << '\n'; last = pos[n - 1] - last; } int n2 = neg.size(); for (int i = 0; i < n2; ++i) { cout << last << " " << neg[i] << "\n"; last = last - neg[i]; } return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long int #define ff first #define ss second #define N 100005 int32_t main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int a[n]; int sum = 0; vector<int> pos, neg; pos.push_back(0); for (int i = 0; i < n; ++i) { cin >> a[i]; sum += abs(a[i]); if (a[i] >= 0) pos.push_back(a[i]); else neg.push_back(a[i]); } sort(pos.begin(), pos.end()); sort(neg.begin(), neg.end(), greater<int>()); int ans; if (neg.size() > 0) { pos[0] = neg[0]; neg.erase(neg.begin()); if (pos.size() > 1) ans = sum; else ans = sum + 2 * pos[0]; } else { pos.erase(pos.begin()); ans = sum - 2 * pos[0]; } int n1 = pos.size(); cout << ans << "\n"; int in = 0; int last; last = pos[0]; for (int i = 0; i < n1 - 2; ++i) { cout << last << " " << pos[i + 1] << "\n"; last = last - pos[i + 1]; } if (n1 != 1) { cout << pos[n1 - 1] << " " << last << '\n'; last = pos[n1 - 1] - last; } int n2 = neg.size(); for (int i = 0; i < n2; ++i) { cout << last << " " << neg[i] << "\n"; last = last - neg[i]; } return 0; }
[ "assignment.value.change", "identifier.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
821,359
821,360
u060049558
cpp
p03007
/* ASEEN AAN PINDAN AALE JATT!!! */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> //#include <boost/functional/hash.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef long long int lli; lli M = 1000000007; lli INF = 1e17; #define sqr(x) (x) * (x) #define bip(n) __builtin_popcount(n) // no of ones bit in binary!! #define bictz(n) __builtin_ctz(n) // no of trailing zeroes in binary!! #define biclz(n) __builtin_clz(n) // no of leading zeroes in binary!! #define bffs(n) __builtin_ffs(n) // index of first one bit!! typedef pair<lli, lli> ll; #define mem1(a, x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x) #define mem2(a, x) fill(&a[0][0], &a[0][0] + sizeof(a) / sizeof(a[0][0]), x) #define mem3(a, x) \ fill(&a[0][0][0], &a[0][0][0] + sizeof(a) / sizeof(a[0][0][0]), x) #define fi1 ifstream fin("input.txt") #define of1 ofstream fout("output.txt") typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> ost; lli n, q, z, x, y, k, m; const double pi1 = 3.14159265358979323846; // unordered_map<pair<ll,lli>,lli> mp; lli me(lli a, lli b, lli M) { if (b == 0) return 1; else if (b % 2 == 0) return me((a * a) % M, b / 2, M); else return (a % M * me((a * a) % M, (b - 1) / 2, M) % M) % M; } lli mI(lli a, lli m) { return me(a, m - 2, m); } // lli tot=0; vector<lli> pf(string s) { int n = (int)s.length(); vector<lli> pi(n); for (int i = 1; i < n; i++) { int j = pi[i - 1]; while (j > 0 && s[i] != s[j]) j = pi[j - 1]; if (s[i] == s[j]) j++; pi[i] = j; } return pi; } // map<ll,lli> dp; // set<lli> s[100005]; int main() { ios_base::sync_with_stdio(0); cin >> n; ll a[n + 1]; lli s = 0; lli ff = 0; lli f = 0; lli b[n + 1]; for (int i = 1; i <= n; i++) { cin >> a[i].first; b[i] = a[i].first; a[i].second = i; if (a[i].first > 0) ff = 1; if (a[i].first < 0) f = 1; } sort(a + 1, a + n + 1); vector<ll> v; if (f && ff) { lli s = 0; for (int i = 1; i <= n; i++) { if (a[i].first > 0 && i < n) { v.push_back({a[1].first, a[i].first}); a[1].first -= a[i].first; } } for (int i = 1; i <= n; i++) { if (a[i].first < 0 && i < n) { v.push_back({a[n].first, a[i].first}); a[n].first -= a[i].first; } } s += a[n].first; cout << s << endl; for (auto &i : v) cout << i.first << " " << i.second << endl; } else if (f) { lli s = 0; for (int i = 1; i < n; i++) { if (a[i].first < 0) { v.push_back({a[n].first, a[i].first}); a[n].first -= a[i].first; } } s = a[n].first; cout << s << endl; for (auto &i : v) cout << i.first << " " << i.second << endl; } else { lli s = 0; for (int i = 2; i < n; i++) { if (a[i].first > 0) { v.push_back({a[1].first, a[i].first}); a[1].first -= a[i].first; } } v.push_back({a[n].first, a[1].first}); a[n].first -= a[1].first; s = a[n].first; cout << s << endl; for (auto &i : v) cout << i.first << " " << i.second << endl; } }
/* ASEEN AAN PINDAN AALE JATT!!! */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> //#include <boost/functional/hash.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef long long int lli; lli M = 1000000007; lli INF = 1e17; #define sqr(x) (x) * (x) #define bip(n) __builtin_popcount(n) // no of ones bit in binary!! #define bictz(n) __builtin_ctz(n) // no of trailing zeroes in binary!! #define biclz(n) __builtin_clz(n) // no of leading zeroes in binary!! #define bffs(n) __builtin_ffs(n) // index of first one bit!! typedef pair<lli, lli> ll; #define mem1(a, x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x) #define mem2(a, x) fill(&a[0][0], &a[0][0] + sizeof(a) / sizeof(a[0][0]), x) #define mem3(a, x) \ fill(&a[0][0][0], &a[0][0][0] + sizeof(a) / sizeof(a[0][0][0]), x) #define fi1 ifstream fin("input.txt") #define of1 ofstream fout("output.txt") typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> ost; lli n, q, z, x, y, k, m; const double pi1 = 3.14159265358979323846; // unordered_map<pair<ll,lli>,lli> mp; lli me(lli a, lli b, lli M) { if (b == 0) return 1; else if (b % 2 == 0) return me((a * a) % M, b / 2, M); else return (a % M * me((a * a) % M, (b - 1) / 2, M) % M) % M; } lli mI(lli a, lli m) { return me(a, m - 2, m); } // lli tot=0; vector<lli> pf(string s) { int n = (int)s.length(); vector<lli> pi(n); for (int i = 1; i < n; i++) { int j = pi[i - 1]; while (j > 0 && s[i] != s[j]) j = pi[j - 1]; if (s[i] == s[j]) j++; pi[i] = j; } return pi; } // map<ll,lli> dp; // set<lli> s[100005]; int main() { ios_base::sync_with_stdio(0); cin >> n; ll a[n + 1]; lli s = 0; lli ff = 0; lli f = 0; lli b[n + 1]; for (int i = 1; i <= n; i++) { cin >> a[i].first; b[i] = a[i].first; a[i].second = i; if (a[i].first > 0) ff = 1; if (a[i].first < 0) f = 1; } sort(a + 1, a + n + 1); vector<ll> v; if (f && ff) { lli s = 0; for (int i = 1; i <= n; i++) { if (a[i].first >= 0 && i < n) { v.push_back({a[1].first, a[i].first}); a[1].first -= a[i].first; } } for (int i = 1; i <= n; i++) { if (a[i].first < 0 && i < n) { v.push_back({a[n].first, a[i].first}); a[n].first -= a[i].first; } } s += a[n].first; cout << s << endl; for (auto &i : v) cout << i.first << " " << i.second << endl; } else if (f) { lli s = 0; for (int i = 1; i < n; i++) { if (a[i].first <= 0) { v.push_back({a[n].first, a[i].first}); a[n].first -= a[i].first; } } s = a[n].first; cout << s << endl; for (auto &i : v) cout << i.first << " " << i.second << endl; } else { lli s = 0; for (int i = 2; i < n; i++) { if (a[i].first >= 0) { v.push_back({a[1].first, a[i].first}); a[1].first -= a[i].first; } } v.push_back({a[n].first, a[1].first}); a[n].first -= a[1].first; s = a[n].first; cout << s << endl; for (auto &i : v) cout << i.first << " " << i.second << endl; } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
821,411
821,412
u345883076
cpp
p03007
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define MOD 1000003 #define REP(i, n) for (ll(i) = 0; (i) < (n); (i)++) #define FOR(i, c) \ for (decltype((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define ll long long #define ull unsigned long long #define all(hoge) (hoge).begin(), (hoge).end() const long long INF = 1LL << 60; typedef vector<ll> Array; typedef vector<Array> Matrix; //グラフ関連 struct Edge { //グラフ ll to, cap, rev; Edge(ll _to, ll _cap, ll _rev) { to = _to; cap = _cap; rev = _rev; } }; typedef vector<Edge> Edges; typedef vector<Edges> Graph; void add_edge(Graph &G, ll from, ll to, ll cap) { //最大フロー求める Ford-fulkerson G[from].push_back(Edge(to, cap, (ll)G[to].size())); G[to].push_back( Edge(from, cap, (ll)G[from].size() - 1)); //最小カットの場合逆辺は0にする } ll max_flow_dfs(Graph &G, ll v, ll t, ll f, vector<bool> &used) { if (v == t) return f; used[v] = true; for (int i = 0; i < G[v].size(); ++i) { Edge &e = G[v][i]; if (!used[e.to] && e.cap > 0) { ll d = max_flow_dfs(G, e.to, t, min(f, e.cap), used); if (d > 0) { e.cap -= d; G[e.to][e.rev].cap += d; return d; } } } return 0; } ll max_flow(Graph &G, ll s, ll t) { ll flow = 0; for (;;) { vector<bool> used(G.size()); REP(i, used.size()) used[i] = false; ll f = max_flow_dfs(G, s, t, INF, used); if (f == 0) { return flow; } flow += f; } } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } class UnionFind { vector<int> data; int num; public: UnionFind(int size) : data(size, -1), num(size) {} bool unionSet(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; num--; } return x != y; } bool findSet(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 numSet() { return num; } }; // nCr,nPr,modの逆元 class Combination { public: Array fact; // n! Array inv; // n!の逆元 ll mod; // modの逆元 ll mod_inv(ll x) { ll n = mod - 2; ll res = 1LL; while (n > 0) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } ll nCr(ll n, ll r) { return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod; } ll nPr(ll n, ll r) { return (fact[n] * inv[n - r]) % mod; } Combination(ll n, ll _mod) { mod = _mod; fact.resize(n + 1); fact[0] = 1; REP(i, n) { fact[i + 1] = (fact[i] * (i + 1LL)) % mod; } inv.resize(n + 1); REP(i, n + 1) { inv[i] = mod_inv(fact[i]); } } }; bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) { //降順second if (a.second != b.second) { return a.second > b.second; } else { return a.first > b.first; } } bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) { //降順first if (a.first != b.first) { return a.first > b.first; } else { return a.second > b.second; } } //約数 void divisor(ll n, vector<ll> &ret) { for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end()); } //最大公約数 ll gcd(ll m, ll n) { if (n == 0) return m; return gcd(n, m % n); } // gcd //最小公倍数 ll lcm(ll m, ll n) { return m / gcd(m, n) * n; } //繰り返し自乗法 ll pow2(ll x, ll n) { // x^n 計算量O(logn) ll ans = 1ll; while (n > 0) { if ((n & 1) == 1) { ans = ans * x % MOD; } x = x * x % MOD; //一周する度にx, x^2, x^4, x^8となる n >>= 1; //桁をずらす n = n >> 1 } return ans; } class MedSet { public: multiset<ll> left, right; ll med; //中央値または中央値の左側 MedSet() {} MedSet(ll _med) {} void insert(ll a) { if (left.size() == 0) { med = a; left.insert(med); } else { if (a < med) { left.insert(a); if (left.size() > right.size() + 1) { // left->right right.insert(*(--left.end())); left.erase(--left.end()); } med = *(--left.end()); } else { right.insert(a); if (right.size() > left.size()) { // right->left left.insert(*(right.begin())); right.erase(right.begin()); } med = *(--left.end()); } } } }; // input ll N, M, L, K, A, B, C, D, Q; string S; int main() { cin >> N; vector<ll> a(N, 0); vector<ll> ap, an; REP(i, N) { cin >> a[i]; if (a[i] >= 0) { ap.push_back(a[i]); } else { an.push_back(a[i]); } } sort(all(ap)); sort(all(an), greater<ll>()); if (an.size() == 0) { ll ans = -2 * ap[0]; for (auto i : ap) { ans += i; } cout << ans << endl; ll n = N - 2; ll sum = ap[0]; while (n > 0) { cout << sum << " " << ap[n] << endl; sum -= ap[n]; n--; } cout << ap[N - 1] << " " << sum << endl; sum = ap[N - 1] - sum; } else if (ap.size() == 0) { ll ans = 2 * an[0]; for (auto i : an) { ans -= i; } cout << ans << endl; ll n = 1; ll sum = an[0]; while (n < N) { cout << sum << " " << an[n] << endl; sum -= an[n]; n++; } } else { ll ans = 0; for (auto i : ap) { ans += i; } for (auto i : an) { ans -= i; } cout << ans << endl; ll sum = an[0]; ll n = 0; while (n < ap.size() - 1) { cout << sum << " " << ap[n] << endl; sum -= ap[n]; n++; } cout << ap[ap.size() - 1] << " " << sum << endl; sum = ap[ap.size() - 1] - sum; n = an.size() - 1; while (n < 0) { cout << sum << " " << an[n] << endl; sum -= an[n]; n--; } } return 0; }
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define MOD 1000003 #define REP(i, n) for (ll(i) = 0; (i) < (n); (i)++) #define FOR(i, c) \ for (decltype((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define ll long long #define ull unsigned long long #define all(hoge) (hoge).begin(), (hoge).end() const long long INF = 1LL << 60; typedef vector<ll> Array; typedef vector<Array> Matrix; //グラフ関連 struct Edge { //グラフ ll to, cap, rev; Edge(ll _to, ll _cap, ll _rev) { to = _to; cap = _cap; rev = _rev; } }; typedef vector<Edge> Edges; typedef vector<Edges> Graph; void add_edge(Graph &G, ll from, ll to, ll cap) { //最大フロー求める Ford-fulkerson G[from].push_back(Edge(to, cap, (ll)G[to].size())); G[to].push_back( Edge(from, cap, (ll)G[from].size() - 1)); //最小カットの場合逆辺は0にする } ll max_flow_dfs(Graph &G, ll v, ll t, ll f, vector<bool> &used) { if (v == t) return f; used[v] = true; for (int i = 0; i < G[v].size(); ++i) { Edge &e = G[v][i]; if (!used[e.to] && e.cap > 0) { ll d = max_flow_dfs(G, e.to, t, min(f, e.cap), used); if (d > 0) { e.cap -= d; G[e.to][e.rev].cap += d; return d; } } } return 0; } ll max_flow(Graph &G, ll s, ll t) { ll flow = 0; for (;;) { vector<bool> used(G.size()); REP(i, used.size()) used[i] = false; ll f = max_flow_dfs(G, s, t, INF, used); if (f == 0) { return flow; } flow += f; } } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } class UnionFind { vector<int> data; int num; public: UnionFind(int size) : data(size, -1), num(size) {} bool unionSet(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; num--; } return x != y; } bool findSet(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 numSet() { return num; } }; // nCr,nPr,modの逆元 class Combination { public: Array fact; // n! Array inv; // n!の逆元 ll mod; // modの逆元 ll mod_inv(ll x) { ll n = mod - 2; ll res = 1LL; while (n > 0) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } ll nCr(ll n, ll r) { return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod; } ll nPr(ll n, ll r) { return (fact[n] * inv[n - r]) % mod; } Combination(ll n, ll _mod) { mod = _mod; fact.resize(n + 1); fact[0] = 1; REP(i, n) { fact[i + 1] = (fact[i] * (i + 1LL)) % mod; } inv.resize(n + 1); REP(i, n + 1) { inv[i] = mod_inv(fact[i]); } } }; bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) { //降順second if (a.second != b.second) { return a.second > b.second; } else { return a.first > b.first; } } bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) { //降順first if (a.first != b.first) { return a.first > b.first; } else { return a.second > b.second; } } //約数 void divisor(ll n, vector<ll> &ret) { for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end()); } //最大公約数 ll gcd(ll m, ll n) { if (n == 0) return m; return gcd(n, m % n); } // gcd //最小公倍数 ll lcm(ll m, ll n) { return m / gcd(m, n) * n; } //繰り返し自乗法 ll pow2(ll x, ll n) { // x^n 計算量O(logn) ll ans = 1ll; while (n > 0) { if ((n & 1) == 1) { ans = ans * x % MOD; } x = x * x % MOD; //一周する度にx, x^2, x^4, x^8となる n >>= 1; //桁をずらす n = n >> 1 } return ans; } class MedSet { public: multiset<ll> left, right; ll med; //中央値または中央値の左側 MedSet() {} MedSet(ll _med) {} void insert(ll a) { if (left.size() == 0) { med = a; left.insert(med); } else { if (a < med) { left.insert(a); if (left.size() > right.size() + 1) { // left->right right.insert(*(--left.end())); left.erase(--left.end()); } med = *(--left.end()); } else { right.insert(a); if (right.size() > left.size()) { // right->left left.insert(*(right.begin())); right.erase(right.begin()); } med = *(--left.end()); } } } }; // input ll N, M, L, K, A, B, C, D, Q; string S; int main() { cin >> N; vector<ll> a(N, 0); vector<ll> ap, an; REP(i, N) { cin >> a[i]; if (a[i] >= 0) { ap.push_back(a[i]); } else { an.push_back(a[i]); } } sort(all(ap)); sort(all(an), greater<ll>()); if (an.size() == 0) { ll ans = -2 * ap[0]; for (auto i : ap) { ans += i; } cout << ans << endl; ll n = N - 2; ll sum = ap[0]; while (n > 0) { cout << sum << " " << ap[n] << endl; sum -= ap[n]; n--; } cout << ap[N - 1] << " " << sum << endl; sum = ap[N - 1] - sum; } else if (ap.size() == 0) { ll ans = 2 * an[0]; for (auto i : an) { ans -= i; } cout << ans << endl; ll n = 1; ll sum = an[0]; while (n < N) { cout << sum << " " << an[n] << endl; sum -= an[n]; n++; } } else { ll ans = 0; for (auto i : ap) { ans += i; } for (auto i : an) { ans -= i; } cout << ans << endl; ll sum = an[0]; ll n = 0; while (n < ap.size() - 1) { cout << sum << " " << ap[n] << endl; sum -= ap[n]; n++; } cout << ap[ap.size() - 1] << " " << sum << endl; sum = ap[ap.size() - 1] - sum; n = an.size() - 1; while (n > 0) { cout << sum << " " << an[n] << endl; sum -= an[n]; n--; } } return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.loop.condition.change" ]
821,413
821,414
u712993629
cpp
p03007
#include <algorithm> #include <iostream> #include <queue> #include <set> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; vector<long long> da(n); for (int i = 0; i < n; i++) { cin >> da[i]; } sort(da.begin(), da.end()); if (da[0] > 0) { long long ans = -da[0]; for (int i = 1; i < n; i++) { ans += da[i]; } cout << ans << endl; for (int i = 1; i < n - 1; i++) { cout << da[0] << ' ' << da[i] << endl; da[0] -= da[i]; } cout << da[n - 1] << ' ' << da[0] << endl; } else if (da[n - 1] < 0) { long long ans = da[n - 1]; for (int i = 0; i < n - 1; i++) { ans -= da[i]; } cout << ans << endl; for (int i = 0; i < n - 1; i++) { cout << da[n - 1] << ' ' << da[i] << endl; da[n - 1] -= da[i]; } } else if (da[n - 2] < 0) { long long ans = 0; for (int i = 0; i < n; i++) { ans += abs(da[i]); } cout << ans << endl; for (int i = 0; i < n - 1; i++) { cout << da[n - 1] << ' ' << da[i] << endl; da[n - 1] -= da[i]; } } else { long long ans = 0; for (int i = 0; i < n; i++) { ans += abs(da[i]); } cout << ans << endl; long long num = 0; while (da[num] < 0) { num++; } long long jio = num; num -= 1; while (num > 0) { cout << da[jio] << ' ' << da[num] << endl; da[jio] -= da[num]; num--; } while (jio < n - 1) { cout << da[0] << ' ' << da[jio] << endl; da[0] -= da[jio]; jio++; } cout << da[n - 1] << ' ' << da[0] << endl; return 0; } }
#include <algorithm> #include <iostream> #include <queue> #include <set> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; vector<long long> da(n); for (int i = 0; i < n; i++) { cin >> da[i]; } sort(da.begin(), da.end()); if (da[0] >= 0) { long long ans = -da[0]; for (int i = 1; i < n; i++) { ans += da[i]; } cout << ans << endl; for (int i = 1; i < n - 1; i++) { cout << da[0] << ' ' << da[i] << endl; da[0] -= da[i]; } cout << da[n - 1] << ' ' << da[0] << endl; } else if (da[n - 1] < 0) { long long ans = da[n - 1]; for (int i = 0; i < n - 1; i++) { ans -= da[i]; } cout << ans << endl; for (int i = 0; i < n - 1; i++) { cout << da[n - 1] << ' ' << da[i] << endl; da[n - 1] -= da[i]; } } else if (da[n - 2] <= 0) { long long ans = 0; for (int i = 0; i < n; i++) { ans += abs(da[i]); } cout << ans << endl; for (int i = 0; i < n - 1; i++) { cout << da[n - 1] << ' ' << da[i] << endl; da[n - 1] -= da[i]; } } else { long long ans = 0; for (int i = 0; i < n; i++) { ans += abs(da[i]); } cout << ans << endl; long long num = 0; while (da[num] < 0) { num++; } long long jio = num; num -= 1; while (num > 0) { cout << da[jio] << ' ' << da[num] << endl; da[jio] -= da[num]; num--; } while (jio < n - 1) { cout << da[0] << ' ' << da[jio] << endl; da[0] -= da[jio]; jio++; } cout << da[n - 1] << ' ' << da[0] << endl; return 0; } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
821,415
821,416
u057079894
cpp
p03007
#include <bits/stdc++.h> using namespace std; #define N 300005 int n; long long a[N], x[N]; int main() { #ifdef whyqx freopen("work.in", "r", stdin); freopen("work.out", "w", stdout); #endif cin >> n; for (int i = 1; i <= n; ++i) scanf("%lld", a + i); sort(a + 1, a + n + 1); if (a[1] > 0) { long long ans = 0; for (int i = 2; i <= n; ++i) ans += a[i]; ans -= a[1]; cout << ans << endl; for (int i = 2; i < n; ++i) { printf("%lld %lld\n", a[1], a[i]); a[1] -= a[i]; } printf("%lld %lld\n", a[n], a[1]); } else if (a[n] < 0) { long long ans = 0; for (int i = 1; i < n; ++i) { ans -= a[i]; } ans += a[n]; cout << ans << endl; for (int i = 1; i < n; ++i) { printf("%lld %lld\n", a[n], a[i]); a[n] -= a[i]; } } else { long long ans = 0; for (int i = 1; i <= n; ++i) { ans += a[i] < 0 ? -a[i] : a[i]; } cout << ans << endl; int now = 1; while (a[now] < 0) ++now; for (int i = now; i < n; ++i) { printf("%lld %lld\n", a[1], a[i]); a[1] -= a[i]; } for (int i = 1; i < now; ++i) { printf("%lld %lld\n", a[n], a[i]); a[n] -= a[i]; } } return 0; }
#include <bits/stdc++.h> using namespace std; #define N 300005 int n; long long a[N], x[N]; int main() { #ifdef whyqx freopen("work.in", "r", stdin); freopen("work.out", "w", stdout); #endif cin >> n; for (int i = 1; i <= n; ++i) scanf("%lld", a + i); sort(a + 1, a + n + 1); if (a[1] >= 0) { long long ans = 0; for (int i = 2; i <= n; ++i) ans += a[i]; ans -= a[1]; cout << ans << endl; for (int i = 2; i < n; ++i) { printf("%lld %lld\n", a[1], a[i]); a[1] -= a[i]; } printf("%lld %lld\n", a[n], a[1]); } else if (a[n] <= 0) { long long ans = 0; for (int i = 1; i < n; ++i) { ans -= a[i]; } ans += a[n]; cout << ans << endl; for (int i = 1; i < n; ++i) { printf("%lld %lld\n", a[n], a[i]); a[n] -= a[i]; } } else { long long ans = 0; for (int i = 1; i <= n; ++i) { ans += a[i] < 0 ? -a[i] : a[i]; } cout << ans << endl; int now = 1; while (a[now] < 0) ++now; for (int i = now; i < n; ++i) { printf("%lld %lld\n", a[1], a[i]); a[1] -= a[i]; } for (int i = 1; i < now; ++i) { printf("%lld %lld\n", a[n], a[i]); a[n] -= a[i]; } } return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
821,417
821,418
u071613271
cpp
p03007
#define _CRT_SECURE_NO_WARNINGS #define MATH_PI 3.14159265358979323846264338327950288419716939 #define DIVIDER9 1000000007 #define lli long long int #include <fstream> #include <iostream> #include <math.h> #include <string.h> using namespace std; #ifdef _WIN32 #pragma warning(disable : 4101) signed wait() { char wait_dummy[256]; scanf("%c", &wait_dummy); return 0; } template <typename... Args> void dout(const char *format, Args const &...args) { printf(format, args...); } #define MAX_CHARBUF 65536 #define DATAFILE "data.dat" class csLocalInput { int FileOpen(); public: FILE *fp; csLocalInput(); }; csLocalInput::csLocalInput() { FileOpen(); } int csLocalInput::FileOpen() { fp = fopen(DATAFILE, "rt"); return 1; } csLocalInput local_in; #define DEBUG 1 #else inline signed wait() { return 0; } inline void dout(const char *arg, ...) {} #endif template <typename T> inline void SWAP(T &a, T &b) { T t = a; a = b; b = t; } inline void CSWAP(char *&a, char *&b) { char *t = a; a = b; b = t; } #define CLIP(ptr, min, max) \ { \ if ((min) <= (max)) { \ if (ptr < (min)) { \ ptr = (min); \ } \ if (ptr > (max)) { \ ptr = (max); \ } \ } \ } #define Sin(deg) sin((deg)*MATH_PI / 180.0) #define Cos(deg) cos((deg)*MATH_PI / 180.0) #define Tan(deg) tan((deg)*MATH_PI / 180.0) #define Rad(deg) ((deg)*MATH_PI / 180.0) #define rep(param, num) for (int param = 0; param < num; ++param) #define fi(num) for (int i = 0; i < num; ++i) #define fj(num) for (int j = 0; j < num; ++j) #define fk(num) for (int k = 0; k < num; ++k) #define fl(num) for (int l = 0; l < num; ++l) #define fn(num) for (int n = 0; n < num; ++n) #define ffr(param, num) for (int param = num - 1; param >= 0; --param) #define fir(num) for (int i = num - 1; i >= 0; --i) #define fjr(num) for (int j = num - 1; j >= 0; --j) #define fkr(num) for (int k = num - 1; k >= 0; --k) #define flr(num) for (int l = num - 1; l >= 0; --l) #define fnr(num) for (int n = num - 1; n >= 0; --n) #define gi(p) \ int p; \ ud_gi(p) #define gi2(p1, p2) \ int p1, p2; \ ud_gi2(p1, p2) #define gi3(p1, p2, p3) \ int p1, p2, p3; \ ud_gi3(p1, p2, p3) #define gi4(p1, p2, p3, p4) \ int p1, p2, p3, p4; \ ud_gi4(p1, p2, p3, p4) #define glli(p) \ lli p; \ ud_glli(p) #define glli2(p1, p2) \ lli p1, p2; \ ud_glli2(p1, p2) #define glli3(p1, p2, p3) \ lli p1, p2, p3; \ ud_glli3(p1, p2, p3) #define glli4(p1, p2, p3, p4) \ lli p1, p2, p3, p4; \ ud_glli4(p1, p2, p3, p4) #define gf(p) \ double p; \ ud_gf(p); #define gf2(p1, p2) \ double p1, p2; \ ud_gf2(p1, p2); #define gf3(p1, p2, p3) \ double p1, p2, p3; \ ud_gf3(p1, p2, p3); #define gf4(p1, p2, p3, p4) \ double p1, p2, p3, p4; \ ud_gf4(p1, p2, p3, p4); #define ud_gi(p) Scanf("%d", p) #define ud_gi2(p1, p2) Scanf2("%d %d", p1, p2) #define ud_gi3(p1, p2, p3) Scanf3("%d %d %d", p1, p2, p3) #define ud_gi4(p1, p2, p3, p4) Scanf4("%d %d %d %d", p1, p2, p3, p4) #define ud_glli(p) Scanf("%lld", p) #define ud_glli2(p1, p2) Scanf2("%lld %lld", p1, p2) #define ud_glli3(p1, p2, p3) Scanf3("%lld %lld %lld", p1, p2, p3) #define ud_glli4(p1, p2, p3, p4) Scanf4("%lld %lld %lld %lld", p1, p2, p3, p4) #define ud_gf(p) Scanf("%f", p) #define ud_gf2(p1, p2) Scanf2("%f %f", p1, p2) #define ud_gf3(p1, p2, p3) Scanf3("%f %f %f", p1, p2, p3) #define ud_gf4(p1, p2, p3, p4) Scanf4("%f %f %f %f", p1, p2, p3, p4) #ifdef DEBUG #define gc(buf) fscanf(local_in.fp, "%s", buf) #define Scanf(expr, p) fscanf(local_in.fp, expr, &p) #define Scanf2(expr, p1, p2) fscanf(local_in.fp, expr, &p1, &p2) #define Scanf3(expr, p1, p2, p3) fscanf(local_in.fp, expr, &p1, &p2, &p3) #define Scanf4(expr, p1, p2, p3, p4) \ fscanf(local_in.fp, expr, &p1, &p2, &p3, &p4) #else #define gc(buf) Scanf("%s", buf) #define Scanf(expr, p) scanf(expr, &p) #define Scanf2(expr, p1, p2) scanf(expr, &p1, &p2) #define Scanf3(expr, p1, p2, p3) scanf(expr, &p1, &p2, &p3) #define Scanf4(expr, p1, p2, p3, p4) scanf(expr, &p1, &p2, &p3, &p4) #endif #define ans(p) cout << p << endl; void CombSort(int N, lli *ar, int order_ascending = 1) { int h = int(N / 1.3); int flag; int i; while (true) { flag = 0; for (i = 0; i + h < N; ++i) { if ((order_ascending && ar[i] > ar[i + h]) || (!order_ascending && ar[i] < ar[i + h])) { swap<lli>(ar[i], ar[i + h]); flag = 1; } } if (h == 1 && !flag) break; if (h == 9 || h == 10) h = 11; if (h > 1) h = int(h / 1.3); } } int EuclideanAlgorithm(int N, int *ar) { fn(N - 1) { while (true) { if (ar[n] % ar[n + 1] == 0 || ar[n + 1] % ar[n] == 0) { ar[n + 1] = ar[n] < ar[n + 1] ? ar[n] : ar[n + 1]; break; } if (ar[n] > ar[n + 1]) { ar[n] %= ar[n + 1]; } else { ar[n + 1] %= ar[n]; } } } return ar[N - 1]; } #include <algorithm> #include <vector> struct UnionFind { vector<int> par; UnionFind(int N) : par(N) { for (int i = 0; i < N; i++) par[i] = i; } int root(int x) { if (par[x] == x) return x; return par[x] = root(par[x]); } void unite(int x, int y) { int rx = root(x); int ry = root(y); if (rx == ry) return; par[rx] = ry; } bool same(int x, int y) { int rx = root(x); int ry = root(y); return rx == ry; } }; void Replace(char *c, int len, char before, char after) { fi(len) { if (c[i] == before) c[i] = after; } } void Replace(char *c, char before, char after) { int len = strlen(c); Replace(c, len, before, after); } class csNode { public: csNode() {} }; char s[200010]; int nP, nM; lli P[100010] = {0}, M[100010] = {0}; lli history[100010][2] = {0}; signed main() { lli op; gi(n); nP = nM = 0; int num = 0; lli sum = 0; fi(n) { ud_glli(op); if (op > 0) { P[nP++] = op; } if (op < 0) { M[nM++] = op; } num++; sum += abs(op); } if (num == 2) { if (nP == 2) { op = P[1] - P[0]; ans(op); sprintf(s, "%lld %lld", P[1], P[0]); ans(s); } if (nP == 1) { op = P[0] - M[0]; ans(op); sprintf(s, "%lld %lld", P[0], M[0]); ans(s); } if (nP == 0) { op = M[0] - M[1]; ans(op); sprintf(s, "%lld %lld", M[0], M[1]); ans(s); } return wait(); } int pp1 = 0, pp2 = 1; int pm = 0, ph = 0; if (nP > 1) CombSort(nP, P, 1); if (nM > 1) CombSort(nM, M, 0); if (nP == 0) { sum -= abs(M[0]) * 2; history[ph][0] = M[0]; history[ph][1] = M[1]; op = M[0] - M[1]; P[0] = op; nP++; M[0] = 0; M[1] = 0; fi(nM - 2) { M[i] = M[i + 2]; M[i + 2] = 0; } nM -= 2; ph++; num--; } if (nM == 0) { sum -= abs(P[0]) * 2; history[ph][0] = P[0]; history[ph][1] = P[1]; op = P[0] - P[1]; M[0] = op; nM++; P[0] = 0; P[1] = 0; fi(nP - 2) { P[i] = P[i + 2]; P[i + 2] = 0; } nP -= 2; ph++; num--; } nP = nP; if (nP >= nM + 2) { } int pp = 0; pm = 0; while (true) { if (nP <= nM - 1) { history[ph][0] = P[pp]; history[ph][1] = M[pm]; op = P[pp] - M[pm]; P[pp] = op; M[pm] = 0; pm++; nM--; } else { history[ph][1] = P[pp]; history[ph][0] = M[pm]; op = -(P[pp] - M[pm]); P[pp] = 0; M[pm] = op; pp++; nP--; } ph++; num--; if (num == 1) break; } ans(sum); lli mn, mx; fi(ph) { if (i < ph - 1) { sprintf(s, "%lld %lld", history[i][0], history[i][1]); } else { mn = min(history[i][0], history[i][1]); mx = max(history[i][0], history[i][1]); sprintf(s, "%lld %lld", mx, mn); } ans(s); } return wait(); }
#define _CRT_SECURE_NO_WARNINGS #define MATH_PI 3.14159265358979323846264338327950288419716939 #define DIVIDER9 1000000007 #define lli long long int #include <fstream> #include <iostream> #include <math.h> #include <string.h> using namespace std; #ifdef _WIN32 #pragma warning(disable : 4101) signed wait() { char wait_dummy[256]; scanf("%c", &wait_dummy); return 0; } template <typename... Args> void dout(const char *format, Args const &...args) { printf(format, args...); } #define MAX_CHARBUF 65536 #define DATAFILE "data.dat" class csLocalInput { int FileOpen(); public: FILE *fp; csLocalInput(); }; csLocalInput::csLocalInput() { FileOpen(); } int csLocalInput::FileOpen() { fp = fopen(DATAFILE, "rt"); return 1; } csLocalInput local_in; #define DEBUG 1 #else inline signed wait() { return 0; } inline void dout(const char *arg, ...) {} #endif template <typename T> inline void SWAP(T &a, T &b) { T t = a; a = b; b = t; } inline void CSWAP(char *&a, char *&b) { char *t = a; a = b; b = t; } #define CLIP(ptr, min, max) \ { \ if ((min) <= (max)) { \ if (ptr < (min)) { \ ptr = (min); \ } \ if (ptr > (max)) { \ ptr = (max); \ } \ } \ } #define Sin(deg) sin((deg)*MATH_PI / 180.0) #define Cos(deg) cos((deg)*MATH_PI / 180.0) #define Tan(deg) tan((deg)*MATH_PI / 180.0) #define Rad(deg) ((deg)*MATH_PI / 180.0) #define rep(param, num) for (int param = 0; param < num; ++param) #define fi(num) for (int i = 0; i < num; ++i) #define fj(num) for (int j = 0; j < num; ++j) #define fk(num) for (int k = 0; k < num; ++k) #define fl(num) for (int l = 0; l < num; ++l) #define fn(num) for (int n = 0; n < num; ++n) #define ffr(param, num) for (int param = num - 1; param >= 0; --param) #define fir(num) for (int i = num - 1; i >= 0; --i) #define fjr(num) for (int j = num - 1; j >= 0; --j) #define fkr(num) for (int k = num - 1; k >= 0; --k) #define flr(num) for (int l = num - 1; l >= 0; --l) #define fnr(num) for (int n = num - 1; n >= 0; --n) #define gi(p) \ int p; \ ud_gi(p) #define gi2(p1, p2) \ int p1, p2; \ ud_gi2(p1, p2) #define gi3(p1, p2, p3) \ int p1, p2, p3; \ ud_gi3(p1, p2, p3) #define gi4(p1, p2, p3, p4) \ int p1, p2, p3, p4; \ ud_gi4(p1, p2, p3, p4) #define glli(p) \ lli p; \ ud_glli(p) #define glli2(p1, p2) \ lli p1, p2; \ ud_glli2(p1, p2) #define glli3(p1, p2, p3) \ lli p1, p2, p3; \ ud_glli3(p1, p2, p3) #define glli4(p1, p2, p3, p4) \ lli p1, p2, p3, p4; \ ud_glli4(p1, p2, p3, p4) #define gf(p) \ double p; \ ud_gf(p); #define gf2(p1, p2) \ double p1, p2; \ ud_gf2(p1, p2); #define gf3(p1, p2, p3) \ double p1, p2, p3; \ ud_gf3(p1, p2, p3); #define gf4(p1, p2, p3, p4) \ double p1, p2, p3, p4; \ ud_gf4(p1, p2, p3, p4); #define ud_gi(p) Scanf("%d", p) #define ud_gi2(p1, p2) Scanf2("%d %d", p1, p2) #define ud_gi3(p1, p2, p3) Scanf3("%d %d %d", p1, p2, p3) #define ud_gi4(p1, p2, p3, p4) Scanf4("%d %d %d %d", p1, p2, p3, p4) #define ud_glli(p) Scanf("%lld", p) #define ud_glli2(p1, p2) Scanf2("%lld %lld", p1, p2) #define ud_glli3(p1, p2, p3) Scanf3("%lld %lld %lld", p1, p2, p3) #define ud_glli4(p1, p2, p3, p4) Scanf4("%lld %lld %lld %lld", p1, p2, p3, p4) #define ud_gf(p) Scanf("%f", p) #define ud_gf2(p1, p2) Scanf2("%f %f", p1, p2) #define ud_gf3(p1, p2, p3) Scanf3("%f %f %f", p1, p2, p3) #define ud_gf4(p1, p2, p3, p4) Scanf4("%f %f %f %f", p1, p2, p3, p4) #ifdef DEBUG #define gc(buf) fscanf(local_in.fp, "%s", buf) #define Scanf(expr, p) fscanf(local_in.fp, expr, &p) #define Scanf2(expr, p1, p2) fscanf(local_in.fp, expr, &p1, &p2) #define Scanf3(expr, p1, p2, p3) fscanf(local_in.fp, expr, &p1, &p2, &p3) #define Scanf4(expr, p1, p2, p3, p4) \ fscanf(local_in.fp, expr, &p1, &p2, &p3, &p4) #else #define gc(buf) Scanf("%s", buf) #define Scanf(expr, p) scanf(expr, &p) #define Scanf2(expr, p1, p2) scanf(expr, &p1, &p2) #define Scanf3(expr, p1, p2, p3) scanf(expr, &p1, &p2, &p3) #define Scanf4(expr, p1, p2, p3, p4) scanf(expr, &p1, &p2, &p3, &p4) #endif #define ans(p) cout << p << endl; void CombSort(int N, lli *ar, int order_ascending = 1) { int h = int(N / 1.3); int flag; int i; while (true) { flag = 0; for (i = 0; i + h < N; ++i) { if ((order_ascending && ar[i] > ar[i + h]) || (!order_ascending && ar[i] < ar[i + h])) { swap<lli>(ar[i], ar[i + h]); flag = 1; } } if (h == 1 && !flag) break; if (h == 9 || h == 10) h = 11; if (h > 1) h = int(h / 1.3); } } int EuclideanAlgorithm(int N, int *ar) { fn(N - 1) { while (true) { if (ar[n] % ar[n + 1] == 0 || ar[n + 1] % ar[n] == 0) { ar[n + 1] = ar[n] < ar[n + 1] ? ar[n] : ar[n + 1]; break; } if (ar[n] > ar[n + 1]) { ar[n] %= ar[n + 1]; } else { ar[n + 1] %= ar[n]; } } } return ar[N - 1]; } #include <algorithm> #include <vector> struct UnionFind { vector<int> par; UnionFind(int N) : par(N) { for (int i = 0; i < N; i++) par[i] = i; } int root(int x) { if (par[x] == x) return x; return par[x] = root(par[x]); } void unite(int x, int y) { int rx = root(x); int ry = root(y); if (rx == ry) return; par[rx] = ry; } bool same(int x, int y) { int rx = root(x); int ry = root(y); return rx == ry; } }; void Replace(char *c, int len, char before, char after) { fi(len) { if (c[i] == before) c[i] = after; } } void Replace(char *c, char before, char after) { int len = strlen(c); Replace(c, len, before, after); } class csNode { public: csNode() {} }; char s[200010]; int nP, nM; lli P[100010] = {0}, M[100010] = {0}; lli history[100010][2] = {0}; signed main() { lli op; gi(n); nP = nM = 0; int num = 0; lli sum = 0; fi(n) { ud_glli(op); if (op >= 0) { P[nP++] = op; } if (op < 0) { M[nM++] = op; } num++; sum += abs(op); } if (num == 2) { if (nP == 2) { op = P[1] - P[0]; ans(op); sprintf(s, "%lld %lld", P[1], P[0]); ans(s); } if (nP == 1) { op = P[0] - M[0]; ans(op); sprintf(s, "%lld %lld", P[0], M[0]); ans(s); } if (nP == 0) { op = M[0] - M[1]; ans(op); sprintf(s, "%lld %lld", M[0], M[1]); ans(s); } return wait(); } int pp1 = 0, pp2 = 1; int pm = 0, ph = 0; if (nP > 1) CombSort(nP, P, 1); if (nM > 1) CombSort(nM, M, 0); if (nP == 0) { sum -= abs(M[0]) * 2; history[ph][0] = M[0]; history[ph][1] = M[1]; op = M[0] - M[1]; P[0] = op; nP++; M[0] = 0; M[1] = 0; fi(nM - 2) { M[i] = M[i + 2]; M[i + 2] = 0; } nM -= 2; ph++; num--; } if (nM == 0) { sum -= abs(P[0]) * 2; history[ph][0] = P[0]; history[ph][1] = P[1]; op = P[0] - P[1]; M[0] = op; nM++; P[0] = 0; P[1] = 0; fi(nP - 2) { P[i] = P[i + 2]; P[i + 2] = 0; } nP -= 2; ph++; num--; } nP = nP; if (nP >= nM + 2) { } int pp = 0; pm = 0; while (true) { if (nP <= nM - 1) { history[ph][0] = P[pp]; history[ph][1] = M[pm]; op = P[pp] - M[pm]; P[pp] = op; M[pm] = 0; pm++; nM--; } else { history[ph][1] = P[pp]; history[ph][0] = M[pm]; op = -(P[pp] - M[pm]); P[pp] = 0; M[pm] = op; pp++; nP--; } ph++; num--; if (num == 1) break; } ans(sum); lli mn, mx; fi(ph) { if (i < ph - 1) { sprintf(s, "%lld %lld", history[i][0], history[i][1]); } else { mn = min(history[i][0], history[i][1]); mx = max(history[i][0], history[i][1]); sprintf(s, "%lld %lld", mx, mn); } ans(s); } return wait(); }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
821,432
821,433
u575781793
cpp
p03007
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ull, ull> pullull; typedef pair<ll, int> plli; typedef pair<int, pii> pipii; typedef vector<vector<int>> mati; typedef vector<vector<double>> matd; typedef vector<ll> vll; typedef vector<vector<ll>> vvll; typedef vector<vector<vector<ll>>> vvvll; typedef vector<bool> vb; typedef vector<vector<bool>> vvb; typedef vector<vector<vector<bool>>> vvvb; typedef vector<pll> vpll; #define FOR(i, x, y) for (ll i = (ll)x; i < (ll)y; ++i) #define REP(i, y) FOR(i, 0, y) #define RFOR(i, x, y) for (ll i = (ll)x; i >= (ll)y; --i) #define RREP(i, x) RFOR(i, x, 0) #define ALL(a) a.begin(), a.end() #define pb push_back inline void IN(void) { return; } template <typename First, typename... Rest> void IN(First &first, Rest &...rest) { cin >> first; IN(rest...); return; } inline void OUT(void) { cout << "\n"; return; } template <typename First, typename... Rest> void OUT(First first, Rest... rest) { cout << first << " "; OUT(rest...); return; } template <typename T> void vec_print(vector<T> VEC) { REP(i, VEC.size()) { cout << VEC[i] << " "; } cout << "\n"; }; template <typename T> void mat_print(vector<vector<T>> MAT){ REP(i, MAT.size()){REP(j, MAT[i].size()){cout << MAT[i][j] << " "; } cout << "\n"; } } ; template <typename CLASS1, typename CLASS2> class HOGE { public: CLASS1 key; CLASS2 value; HOGE(void) { return; }; HOGE(CLASS1 key, CLASS2 value) { this->key = key; this->value = value; }; ~HOGE(void) { return; }; void print(void) { cout << "key : " << key << ", value : " << value << "\n"; return; }; bool operator==(const HOGE &obj) { return (this->value == obj.value); }; bool operator<(const HOGE &obj) { return (this->value < obj.value); }; bool operator>(const HOGE &obj) { return (this->value > obj.value); }; }; template <typename CLASS1, typename CLASS2> bool operator==(const HOGE<CLASS1, CLASS2> &hoge1, const HOGE<CLASS1, CLASS2> &hoge2) { return hoge1.value == hoge2.value; }; template <typename CLASS1, typename CLASS2> bool operator<(const HOGE<CLASS1, CLASS2> &hoge1, const HOGE<CLASS1, CLASS2> &hoge2) { return hoge1.value < hoge2.value; }; template <typename CLASS1, typename CLASS2> bool operator>(const HOGE<CLASS1, CLASS2> &hoge1, const HOGE<CLASS1, CLASS2> &hoge2) { return hoge1.value > hoge2.value; }; constexpr int INF = (1 << 30); constexpr ll INFLL = 1LL << 62; constexpr long double EPS = 1e-12; constexpr ll MOD = (ll)((1E+9) + 7); ll N; vll A; vll ans; /* ll search_max(ll start, ll end){ if(end<start) return 0; if(end==start) return A[start]; if(end-1==start){ ans.pb(A[end]); ans.pb(A[start]); return A[end]-A[start]; } if(end-2==start){ if(A[start+1]>0){ ans.pb(A[start]); ans.pb(A[start+1]); A[start] -= A[start+1]; ans.pb(A[end]); ans.pb(A[start]); return A[end] - A[start]; }else{ ans.pb(A[end]); ans.pb(A[start]); A[end] -= A[start]; ans.pb(A[end]); ans.pb(A[start+1]); return A[end] - A[start+1]; } } if(A[0]>=0){ ll start_buf = start+1; while(start_buf<end){ ans.pb(A[start]); ans.pb(A[start_buf]); A[start] -= A[start_buf]; start_buf++; } ans.pb(A[end]); ans.pb(A[start]); return A[end]-A[start]; }else if(A[end-2]>=0){ ans.pb(A[start]); ans.pb(A[end-1]); ll tmp2 = A[start] - A[end-1]; if(start+1<=end-2){ ll tmp = search_max(start+1, end-2); ans.pb(tmp2); ans.pb(tmp); tmp2 -= tmp; } ans.pb(A[end]); ans.pb(tmp2); return A[end] - tmp2; }else if(A[end-1]>0){ ans.pb(A[end-2]); ans.pb(A[end-1]); A[end-2] -= A[end-1]; while(start+1<end){ ans.pb(A[end]); ans.pb(A[start]); A[end] -= A[start]; start++; } return A[end]; }else{ while(start<end){ ans.pb(A[end]); ans.pb(A[start]); A[end] -= A[start]; start++; } return A[end]; } } */ ll search_max(ll start, ll end) { ll end_buf = end - 1; while (A[end_buf] > 0) { ans.pb(A[start]); ans.pb(A[end_buf]); A[start] -= A[end_buf]; end_buf--; if (start == end_buf) break; } ans.pb(A[end]); ans.pb(A[start]); A[end] -= A[start]; start++; while (start < end_buf) { ans.pb(A[end]); ans.pb(A[start]); A[end] -= A[start]; start++; } return A[end]; } int main() { cin.tie(0); // cut the cin and cout (default, std::flush is performed after // std::cin) ios::sync_with_stdio( false); // cut the iostream and stdio (DON'T endl; BUT "\n";) IN(N); A.resize(N); REP(i, N) IN(A[i]); sort(ALL(A)); OUT(search_max(0, N - 1)); for (int i = 0; i < ans.size(); i += 2) { OUT(ans[i], ans[i + 1]); } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ull, ull> pullull; typedef pair<ll, int> plli; typedef pair<int, pii> pipii; typedef vector<vector<int>> mati; typedef vector<vector<double>> matd; typedef vector<ll> vll; typedef vector<vector<ll>> vvll; typedef vector<vector<vector<ll>>> vvvll; typedef vector<bool> vb; typedef vector<vector<bool>> vvb; typedef vector<vector<vector<bool>>> vvvb; typedef vector<pll> vpll; #define FOR(i, x, y) for (ll i = (ll)x; i < (ll)y; ++i) #define REP(i, y) FOR(i, 0, y) #define RFOR(i, x, y) for (ll i = (ll)x; i >= (ll)y; --i) #define RREP(i, x) RFOR(i, x, 0) #define ALL(a) a.begin(), a.end() #define pb push_back inline void IN(void) { return; } template <typename First, typename... Rest> void IN(First &first, Rest &...rest) { cin >> first; IN(rest...); return; } inline void OUT(void) { cout << "\n"; return; } template <typename First, typename... Rest> void OUT(First first, Rest... rest) { cout << first << " "; OUT(rest...); return; } template <typename T> void vec_print(vector<T> VEC) { REP(i, VEC.size()) { cout << VEC[i] << " "; } cout << "\n"; }; template <typename T> void mat_print(vector<vector<T>> MAT){ REP(i, MAT.size()){REP(j, MAT[i].size()){cout << MAT[i][j] << " "; } cout << "\n"; } } ; template <typename CLASS1, typename CLASS2> class HOGE { public: CLASS1 key; CLASS2 value; HOGE(void) { return; }; HOGE(CLASS1 key, CLASS2 value) { this->key = key; this->value = value; }; ~HOGE(void) { return; }; void print(void) { cout << "key : " << key << ", value : " << value << "\n"; return; }; bool operator==(const HOGE &obj) { return (this->value == obj.value); }; bool operator<(const HOGE &obj) { return (this->value < obj.value); }; bool operator>(const HOGE &obj) { return (this->value > obj.value); }; }; template <typename CLASS1, typename CLASS2> bool operator==(const HOGE<CLASS1, CLASS2> &hoge1, const HOGE<CLASS1, CLASS2> &hoge2) { return hoge1.value == hoge2.value; }; template <typename CLASS1, typename CLASS2> bool operator<(const HOGE<CLASS1, CLASS2> &hoge1, const HOGE<CLASS1, CLASS2> &hoge2) { return hoge1.value < hoge2.value; }; template <typename CLASS1, typename CLASS2> bool operator>(const HOGE<CLASS1, CLASS2> &hoge1, const HOGE<CLASS1, CLASS2> &hoge2) { return hoge1.value > hoge2.value; }; constexpr int INF = (1 << 30); constexpr ll INFLL = 1LL << 62; constexpr long double EPS = 1e-12; constexpr ll MOD = (ll)((1E+9) + 7); ll N; vll A; vll ans; ll search_max(ll start, ll end) { ll end_buf = end - 1; while (A[end_buf] > 0) { ans.pb(A[start]); ans.pb(A[end_buf]); A[start] -= A[end_buf]; end_buf--; if (start == end_buf) break; } end_buf++; ans.pb(A[end]); ans.pb(A[start]); A[end] -= A[start]; start++; while (start < end_buf) { ans.pb(A[end]); ans.pb(A[start]); A[end] -= A[start]; start++; } return A[end]; } int main() { cin.tie(0); // cut the cin and cout (default, std::flush is performed after // std::cin) ios::sync_with_stdio( false); // cut the iostream and stdio (DON'T endl; BUT "\n";) IN(N); A.resize(N); REP(i, N) IN(A[i]); sort(ALL(A)); OUT(search_max(0, N - 1)); for (int i = 0; i < ans.size(); i += 2) { OUT(ans[i], ans[i + 1]); } return 0; }
[ "expression.unary.arithmetic.add" ]
821,446
821,447
u355335354
cpp
p03007
#include <bits/stdc++.h> #define rep(i, a, b) for (ll i = ll(a); i < ll(b); i++) #define irep(i, a, b) for (ll i = ll(a); i >= ll(b); i--) 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; } #define pb push_back #define mp make_pair #define F .first #define S .second using ll = long long; using ld = long double; const ll INF = 1LL << 60; const ll mod = 1e9 + 7; using namespace std; ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; } ll a[110000]; vector<ll> ap, am; vector<ll> x, y; int main() { ll n, t, a1, a2, cnt = 0; cin >> n; rep(i, 0, n) cin >> a[i]; sort(a, a + n); rep(i, 0, n - 1) { if (a[i] < 0) am.pb(a[i]); else ap.pb(a[i]); } if (am.empty()) { a2 = ap[0]; cnt++; } else if (ap.empty()) { a1 = am[am.size() - 1]; a2 = am[0]; cnt++; } else a2 = am[0]; a1 = a[n - 1]; while (cnt < ap.size()) { x.pb(a2), y.pb(ap[cnt]); a2 -= ap[cnt]; cnt++; } x.pb(a1), y.pb(a2); a1 -= a2; cnt = 1; while (cnt <= am.size()) { x.pb(a1), y.pb(am[cnt]); a1 -= am[cnt]; cnt++; } cout << a1 << endl; rep(i, 0, x.size()) cout << x[i] << " " << y[i] << endl; }
#include <bits/stdc++.h> #define rep(i, a, b) for (ll i = ll(a); i < ll(b); i++) #define irep(i, a, b) for (ll i = ll(a); i >= ll(b); i--) 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; } #define pb push_back #define mp make_pair #define F .first #define S .second using ll = long long; using ld = long double; const ll INF = 1LL << 60; const ll mod = 1e9 + 7; using namespace std; ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; } ll a[110000]; vector<ll> ap, am; vector<ll> x, y; int main() { ll n, t, a1, a2, cnt = 0; cin >> n; rep(i, 0, n) cin >> a[i]; sort(a, a + n); rep(i, 0, n - 1) { if (a[i] < 0) am.pb(a[i]); else ap.pb(a[i]); } if (am.empty()) { a2 = ap[0]; cnt++; } else if (ap.empty()) { a1 = am[am.size() - 1]; a2 = am[0]; cnt++; } else a2 = am[0]; a1 = a[n - 1]; while (cnt < ap.size()) { x.pb(a2), y.pb(ap[cnt]); a2 -= ap[cnt]; cnt++; } x.pb(a1), y.pb(a2); a1 -= a2; cnt = 1; while (cnt < am.size()) { x.pb(a1), y.pb(am[cnt]); a1 -= am[cnt]; cnt++; } cout << a1 << endl; rep(i, 0, x.size()) cout << x[i] << " " << y[i] << endl; }
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
821,453
821,454
u499009346
cpp
p03007
#include <algorithm> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> using namespace std; // マクロ&定数&関数 ================================================ typedef unsigned int uint; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<int> vint; typedef vector<ll> vll; typedef vector<double> vdouble; typedef vector<bool> vbool; typedef vector<string> vstring; typedef vector<pair<int, int>> vpint; typedef vector<pair<ll, ll>> vpll; typedef vector<pair<double, double>> vpdouble; typedef vector<vector<int>> vvint; typedef vector<vector<ll>> vvll; typedef vector<vpint> vvpint; typedef vector<vpll> vvpll; typedef vector<vector<double>> vvdouble; typedef vector<vector<string>> vvstring; typedef vector<vector<bool>> vvbool; typedef vector<vector<vector<ll>>> vvvll; const int INF = 1e9 + 1; const ll LLINF = 1e17 + 1; const int DX[9] = {0, 0, 1, -1, 1, 1, -1, -1, 0}; // 4;4近傍 const int DY[9] = {1, -1, 0, 0, 1, -1, 1, -1, 0}; // 8:8近傍 9:(0,0)を含む const ll MOD = 1e9 + 7; // 10^9 + 7 const ll MAX = 1e9; const double PI = 3.14159265358979323846264338327950288; //--------------------------------------------------------------- // オーバーフローチェック //--------------------------------------------------------------- bool is_overflow(ll a, ll b) { return ((a * b) / b != a); } //--------------------------------------------------------------- // 約数列挙 //--------------------------------------------------------------- vll divisor(ll n) { vll ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } //--------------------------------------------------------------- // N以下のすべての素数を列挙する(エラトステネスの篩) //--------------------------------------------------------------- vbool searchSosuu(ll N) { vbool sosuu; // ←これをグローバル変数にして1度だけ実行する for (ll i = 0; i < N; i++) { sosuu.emplace_back(true); } sosuu[0] = false; sosuu[1] = false; for (ll i = 2; i < N; i++) { if (sosuu[i]) { for (ll j = 2; i * j < N; j++) { sosuu[i * j] = false; } } } return sosuu; } //--------------------------------------------------------------- // 素因数分解 O(√N) //--------------------------------------------------------------- vpll div_prime(ll n) { vpll prime_factor; for (ll i = 2; i * i <= n; i++) { ll count = 0; while (n % i == 0) { count++; n /= i; } if (count) { pair<ll, ll> temp = {i, count}; prime_factor.emplace_back(temp); } } if (n != 1) { pair<ll, ll> temp = {n, 1}; prime_factor.emplace_back(temp); } return prime_factor; } //--------------------------------------------------------------- // 素数判定 //--------------------------------------------------------------- bool is_sosuu(ll N) { if (N < 2) { return false; } else if (N == 2) { return true; } else if (N % 2 == 0) { return false; } for (ll i = 3; i <= sqrt(N); i += 2) { if (N % i == 0) { return false; } } return true; } //--------------------------------------------------------------- // 最大公約数(ユークリッドの互除法) //--------------------------------------------------------------- ll gcd(ll a, ll b) { if (a < b) { ll tmp = a; a = b; b = tmp; } ll r = a % b; while (r != 0) { a = b; b = r; r = a % b; } return b; } //--------------------------------------------------------------- // 最小公倍数 //--------------------------------------------------------------- ll lcm(ll a, ll b) { ll temp = gcd(a, b); return temp * (a / temp) * (b / temp); } //--------------------------------------------------------------- // 階乗 //--------------------------------------------------------------- ll factorial(ll n) { if (n <= 1) { return 1; } return (n * (factorial(n - 1))) % MOD; } //--------------------------------------------------------------- // 高速コンビネーション計算(前処理:O(N) 計算:O(1)) //--------------------------------------------------------------- // テーブルを作る前処理 ll comb_const = 200005; vll fac(comb_const), finv(comb_const), inv(comb_const); bool COMineted = false; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < comb_const; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } COMineted = true; } // 二項係数計算 ll COM(ll n, ll k) { if (COMineted == false) COMinit(); if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } //--------------------------------------------------------------- // 繰り返し2乗法 base^sisuu //--------------------------------------------------------------- ll RepeatSquaring(ll base, ll sisuu) { if (sisuu < 0) { cout << "RepeatSquaring: 指数が負です!" << endl; return 0; } if (sisuu == 0) return 1; if (sisuu % 2 == 0) { ll t = RepeatSquaring(base, sisuu / 2) % MOD; return (t * t) % MOD; } return base * RepeatSquaring(base, sisuu - 1) % MOD; } //--------------------------------------------------------------- // 高速単発コンビネーション計算(O(logN)) //--------------------------------------------------------------- ll fast_com(ll a, ll b) { ll bunshi = 1; ll bunbo = 1; for (ll i = 1; i <= b; i++) { bunbo *= i; bunbo %= MOD; bunshi *= (a - i + 1); bunshi %= MOD; } ll ret = bunshi * RepeatSquaring(bunbo, MOD - 2); ret %= MOD; while (ret < 0) { ret += MOD; } return ret; } //--------------------------------------------------------------- // 2直線の交差判定(直線(x1, y1)->(x2, y2) と 直線(X1, Y1)->(X2, Y2)) //--------------------------------------------------------------- bool is_cross(ll x1, ll y1, ll x2, ll y2, ll X1, ll Y1, ll X2, ll Y2) { ll dx_ai = X1 - x1; ll dy_ai = Y1 - y1; ll dx_bi = X1 - x2; ll dy_bi = Y1 - y2; ll dx_ai2 = X2 - x1; ll dy_ai2 = Y2 - y1; ll dx_bi2 = X2 - x2; ll dy_bi2 = Y2 - y2; ll si = dx_ai * dy_bi - dy_ai * dx_bi; ll si2 = dx_ai2 * dy_bi2 - dy_ai2 * dx_bi2; ll si3 = dx_ai * dy_ai2 - dy_ai * dx_ai2; ll si4 = dx_bi * dy_bi2 - dy_bi * dx_bi2; return (si * si2 < 0 && si3 * si4 < 0); } //--------------------------------------------------------------- // 最長増加部分列の長さ(O(NlogN)) //--------------------------------------------------------------- ll LSI(vll vec, ll size) { vll lsi(size + 1); // 長さjを作った時の右端の最小値 for (ll i = 0; i <= size; i++) { lsi[i] = LLINF; } lsi[0] = 0; lsi[1] = vec[0]; for (ll i = 1; i < size; i++) { // 初めてvec[i]の方が小さくなるところを探す auto Iter = lower_bound(lsi.begin(), lsi.end(), vec[i]); ll idx = Iter - lsi.begin(); if (idx > 0 && lsi[idx - 1] < vec[i]) // 条件文の前半怪しい { lsi[idx] = vec[i]; } } for (ll i = size; i >= 0; i--) { if (lsi[i] < LLINF) { return i; } } } //--------------------------------------------------------------- // 木の根からの深さ //--------------------------------------------------------------- vll tree_depth(vvll edge, ll start_node, ll n_node) { vll dist(n_node, LLINF); dist[start_node] = 0; stack<pll> S; S.push({start_node, 0}); while (!S.empty()) { ll node = S.top().first; ll d = S.top().second; dist[node] = d; S.pop(); for (int i = 0; i < edge[node].size(); i++) { if (dist[edge[node][i]] == LLINF) { S.push({edge[node][i], d + 1}); } } } return dist; } //--------------------------------------------------------------- // ワーシャルフロイド法(O(N^3)) 任意の2点間の最短距離 //--------------------------------------------------------------- vvll warshall_floyd(ll n, vvll d) { for (int k = 0; k < n; k++) { // 経由する頂点 for (int i = 0; i < n; i++) { // 始点 for (int j = 0; j < n; j++) { // 終点 d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } return d; } //--------------------------------------------------------------- // Union Find //--------------------------------------------------------------- /* UnionFind uf(要素の個数); for(int i = 0;i < 関係の個数; i++) { uf.merge(A[i], B[i]); } nを含む集合の大きさ = uf.size(n) nを含む集合の代表者 = uf.root(n) 集合の個数 = uf.n_group */ class UnionFind { public: vector<ll> par; // 各元の親を表す配列 vector<ll> siz; // 素集合のサイズを表す配列(1 で初期化) ll n_group; //集合の数 // Constructor UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) { for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身 n_group = sz_; } 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; n_group--; return true; } bool issame(ll x, ll y) { // 連結判定 return root(x) == root(y); } ll size(ll x) { // 素集合のサイズ return siz[root(x)]; } }; //======================================================================== int main() { ////================================== cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(30); ////================================== ll N; cin >> N; vll A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } ll sum = 0; for (int i = 0; i < N; i++) { sum += A[i]; } priority_queue<ll, vll, greater<ll>> plus; priority_queue<ll> minus; for (int i = 0; i < N; i++) { if (A[i] > 0) { plus.push(A[i]); } else { minus.push(A[i]); } } if (minus.size() == 0) { // 1つだけマイナスで残って、残りはプラス // 最も小さいものをマイナスにする ll m = plus.top(); plus.pop(); cout << sum - 2 * m << endl; while (plus.size() > 1) { ll p = plus.top(); plus.pop(); cout << m << " " << p << endl; m -= p; } cout << plus.top() << " " << m << endl; } else if (minus.size() == N) { // 1つだけマイナスで残って、残りはプラス // 最も大きいものをマイナスにする ll m = minus.top(); minus.pop(); cout << -sum + 2 * m; while (!minus.empty()) { ll p = minus.top(); minus.pop(); cout << m << " " << p << endl; m -= p; } } else { // すべて非負にできるはず sum = 0; for (int i = 0; i < N; i++) { sum += abs(A[i]); } cout << sum << endl; // ひとつだけ0以下を残しておく // プラス - マイナス while (minus.size() > 1) { ll m = minus.top(); minus.pop(); ll p = plus.top(); plus.pop(); cout << p << " " << m << endl; plus.push(p - m); } // ひとつだけプラスを残しておく ll m = minus.top(); while (plus.size() > 1) { ll p = plus.top(); plus.pop(); cout << m << " " << p << endl; m -= p; } cout << plus.top() << " " << m << endl; } }
#include <algorithm> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> using namespace std; // マクロ&定数&関数 ================================================ typedef unsigned int uint; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<int> vint; typedef vector<ll> vll; typedef vector<double> vdouble; typedef vector<bool> vbool; typedef vector<string> vstring; typedef vector<pair<int, int>> vpint; typedef vector<pair<ll, ll>> vpll; typedef vector<pair<double, double>> vpdouble; typedef vector<vector<int>> vvint; typedef vector<vector<ll>> vvll; typedef vector<vpint> vvpint; typedef vector<vpll> vvpll; typedef vector<vector<double>> vvdouble; typedef vector<vector<string>> vvstring; typedef vector<vector<bool>> vvbool; typedef vector<vector<vector<ll>>> vvvll; const int INF = 1e9 + 1; const ll LLINF = 1e17 + 1; const int DX[9] = {0, 0, 1, -1, 1, 1, -1, -1, 0}; // 4;4近傍 const int DY[9] = {1, -1, 0, 0, 1, -1, 1, -1, 0}; // 8:8近傍 9:(0,0)を含む const ll MOD = 1e9 + 7; // 10^9 + 7 const ll MAX = 1e9; const double PI = 3.14159265358979323846264338327950288; //--------------------------------------------------------------- // オーバーフローチェック //--------------------------------------------------------------- bool is_overflow(ll a, ll b) { return ((a * b) / b != a); } //--------------------------------------------------------------- // 約数列挙 //--------------------------------------------------------------- vll divisor(ll n) { vll ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } //--------------------------------------------------------------- // N以下のすべての素数を列挙する(エラトステネスの篩) //--------------------------------------------------------------- vbool searchSosuu(ll N) { vbool sosuu; // ←これをグローバル変数にして1度だけ実行する for (ll i = 0; i < N; i++) { sosuu.emplace_back(true); } sosuu[0] = false; sosuu[1] = false; for (ll i = 2; i < N; i++) { if (sosuu[i]) { for (ll j = 2; i * j < N; j++) { sosuu[i * j] = false; } } } return sosuu; } //--------------------------------------------------------------- // 素因数分解 O(√N) //--------------------------------------------------------------- vpll div_prime(ll n) { vpll prime_factor; for (ll i = 2; i * i <= n; i++) { ll count = 0; while (n % i == 0) { count++; n /= i; } if (count) { pair<ll, ll> temp = {i, count}; prime_factor.emplace_back(temp); } } if (n != 1) { pair<ll, ll> temp = {n, 1}; prime_factor.emplace_back(temp); } return prime_factor; } //--------------------------------------------------------------- // 素数判定 //--------------------------------------------------------------- bool is_sosuu(ll N) { if (N < 2) { return false; } else if (N == 2) { return true; } else if (N % 2 == 0) { return false; } for (ll i = 3; i <= sqrt(N); i += 2) { if (N % i == 0) { return false; } } return true; } //--------------------------------------------------------------- // 最大公約数(ユークリッドの互除法) //--------------------------------------------------------------- ll gcd(ll a, ll b) { if (a < b) { ll tmp = a; a = b; b = tmp; } ll r = a % b; while (r != 0) { a = b; b = r; r = a % b; } return b; } //--------------------------------------------------------------- // 最小公倍数 //--------------------------------------------------------------- ll lcm(ll a, ll b) { ll temp = gcd(a, b); return temp * (a / temp) * (b / temp); } //--------------------------------------------------------------- // 階乗 //--------------------------------------------------------------- ll factorial(ll n) { if (n <= 1) { return 1; } return (n * (factorial(n - 1))) % MOD; } //--------------------------------------------------------------- // 高速コンビネーション計算(前処理:O(N) 計算:O(1)) //--------------------------------------------------------------- // テーブルを作る前処理 ll comb_const = 200005; vll fac(comb_const), finv(comb_const), inv(comb_const); bool COMineted = false; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < comb_const; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } COMineted = true; } // 二項係数計算 ll COM(ll n, ll k) { if (COMineted == false) COMinit(); if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } //--------------------------------------------------------------- // 繰り返し2乗法 base^sisuu //--------------------------------------------------------------- ll RepeatSquaring(ll base, ll sisuu) { if (sisuu < 0) { cout << "RepeatSquaring: 指数が負です!" << endl; return 0; } if (sisuu == 0) return 1; if (sisuu % 2 == 0) { ll t = RepeatSquaring(base, sisuu / 2) % MOD; return (t * t) % MOD; } return base * RepeatSquaring(base, sisuu - 1) % MOD; } //--------------------------------------------------------------- // 高速単発コンビネーション計算(O(logN)) //--------------------------------------------------------------- ll fast_com(ll a, ll b) { ll bunshi = 1; ll bunbo = 1; for (ll i = 1; i <= b; i++) { bunbo *= i; bunbo %= MOD; bunshi *= (a - i + 1); bunshi %= MOD; } ll ret = bunshi * RepeatSquaring(bunbo, MOD - 2); ret %= MOD; while (ret < 0) { ret += MOD; } return ret; } //--------------------------------------------------------------- // 2直線の交差判定(直線(x1, y1)->(x2, y2) と 直線(X1, Y1)->(X2, Y2)) //--------------------------------------------------------------- bool is_cross(ll x1, ll y1, ll x2, ll y2, ll X1, ll Y1, ll X2, ll Y2) { ll dx_ai = X1 - x1; ll dy_ai = Y1 - y1; ll dx_bi = X1 - x2; ll dy_bi = Y1 - y2; ll dx_ai2 = X2 - x1; ll dy_ai2 = Y2 - y1; ll dx_bi2 = X2 - x2; ll dy_bi2 = Y2 - y2; ll si = dx_ai * dy_bi - dy_ai * dx_bi; ll si2 = dx_ai2 * dy_bi2 - dy_ai2 * dx_bi2; ll si3 = dx_ai * dy_ai2 - dy_ai * dx_ai2; ll si4 = dx_bi * dy_bi2 - dy_bi * dx_bi2; return (si * si2 < 0 && si3 * si4 < 0); } //--------------------------------------------------------------- // 最長増加部分列の長さ(O(NlogN)) //--------------------------------------------------------------- ll LSI(vll vec, ll size) { vll lsi(size + 1); // 長さjを作った時の右端の最小値 for (ll i = 0; i <= size; i++) { lsi[i] = LLINF; } lsi[0] = 0; lsi[1] = vec[0]; for (ll i = 1; i < size; i++) { // 初めてvec[i]の方が小さくなるところを探す auto Iter = lower_bound(lsi.begin(), lsi.end(), vec[i]); ll idx = Iter - lsi.begin(); if (idx > 0 && lsi[idx - 1] < vec[i]) // 条件文の前半怪しい { lsi[idx] = vec[i]; } } for (ll i = size; i >= 0; i--) { if (lsi[i] < LLINF) { return i; } } } //--------------------------------------------------------------- // 木の根からの深さ //--------------------------------------------------------------- vll tree_depth(vvll edge, ll start_node, ll n_node) { vll dist(n_node, LLINF); dist[start_node] = 0; stack<pll> S; S.push({start_node, 0}); while (!S.empty()) { ll node = S.top().first; ll d = S.top().second; dist[node] = d; S.pop(); for (int i = 0; i < edge[node].size(); i++) { if (dist[edge[node][i]] == LLINF) { S.push({edge[node][i], d + 1}); } } } return dist; } //--------------------------------------------------------------- // ワーシャルフロイド法(O(N^3)) 任意の2点間の最短距離 //--------------------------------------------------------------- vvll warshall_floyd(ll n, vvll d) { for (int k = 0; k < n; k++) { // 経由する頂点 for (int i = 0; i < n; i++) { // 始点 for (int j = 0; j < n; j++) { // 終点 d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } return d; } //--------------------------------------------------------------- // Union Find //--------------------------------------------------------------- /* UnionFind uf(要素の個数); for(int i = 0;i < 関係の個数; i++) { uf.merge(A[i], B[i]); } nを含む集合の大きさ = uf.size(n) nを含む集合の代表者 = uf.root(n) 集合の個数 = uf.n_group */ class UnionFind { public: vector<ll> par; // 各元の親を表す配列 vector<ll> siz; // 素集合のサイズを表す配列(1 で初期化) ll n_group; //集合の数 // Constructor UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) { for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身 n_group = sz_; } 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; n_group--; return true; } bool issame(ll x, ll y) { // 連結判定 return root(x) == root(y); } ll size(ll x) { // 素集合のサイズ return siz[root(x)]; } }; //======================================================================== int main() { ////================================== cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(30); ////================================== ll N; cin >> N; vll A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } ll sum = 0; for (int i = 0; i < N; i++) { sum += A[i]; } priority_queue<ll, vll, greater<ll>> plus; priority_queue<ll> minus; for (int i = 0; i < N; i++) { if (A[i] > 0) { plus.push(A[i]); } else { minus.push(A[i]); } } if (minus.size() == 0) { // 1つだけマイナスで残って、残りはプラス // 最も小さいものをマイナスにする ll m = plus.top(); plus.pop(); cout << sum - 2 * m << endl; while (plus.size() > 1) { ll p = plus.top(); plus.pop(); cout << m << " " << p << endl; m -= p; } cout << plus.top() << " " << m << endl; } else if (minus.size() == N) { // 1つだけマイナスで残って、残りはプラス // 最も大きいものをマイナスにする ll m = minus.top(); minus.pop(); cout << -sum + 2 * m << endl; while (!minus.empty()) { ll p = minus.top(); minus.pop(); cout << m << " " << p << endl; m -= p; } } else { // すべて非負にできるはず sum = 0; for (int i = 0; i < N; i++) { sum += abs(A[i]); } cout << sum << endl; // ひとつだけ0以下を残しておく // プラス - マイナス while (minus.size() > 1) { ll m = minus.top(); minus.pop(); ll p = plus.top(); plus.pop(); cout << p << " " << m << endl; plus.push(p - m); } // ひとつだけプラスを残しておく ll m = minus.top(); while (plus.size() > 1) { ll p = plus.top(); plus.pop(); cout << m << " " << p << endl; m -= p; } cout << plus.top() << " " << m << endl; } }
[ "io.output.newline.add" ]
821,458
821,459
u433195318
cpp
p03007
#include <bits/stdc++.h> using namespace std; using lint = long long; signed main() { lint N, sum = 0; cin >> N; vector<lint> a(N); for (lint i = 0; i < N; i++) cin >> a[i], sum += abs(a[i]); sort(a.begin(), a.end()); if (a[0] > 0) sum -= a[0] * 2; if (a.back() < 0) sum += a.back() * 2; lint x = a[0]; cout << sum << endl; for (lint i = 1; i < N - 1; i++) { if (a[i] > 0) { cout << x << " " << a[i] << endl; x -= a[i]; } } cout << a.back() << " " << x << endl; x = a.back() - x; for (lint i = 1; i < N - 1; i++) { if (a[i] < 0) { cout << x << " " << a[i] << endl; x -= a[i]; } } }
#include <bits/stdc++.h> using namespace std; using lint = long long; signed main() { lint N, sum = 0; cin >> N; vector<lint> a(N); for (lint i = 0; i < N; i++) { cin >> a[i]; sum += abs(a[i]); }; sort(a.begin(), a.end()); if (a[0] > 0) sum -= a[0] * 2; if (a.back() < 0) sum += a.back() * 2; lint x = a[0]; cout << sum << endl; for (lint i = 1; i < N - 1; i++) { if (a[i] >= 0) { cout << x << " " << a[i] << endl; x -= a[i]; } } cout << a.back() << " " << x << endl; x = a.back() - x; for (lint i = 1; i < N - 1; i++) { if (a[i] < 0) { cout << x << " " << a[i] << endl; x -= a[i]; } } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
821,466
821,467
u265359795
cpp
p03007
#include <bits/stdc++.h> using namespace std; #define ll long long #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++) #define rep(i, n) REP(i, 0, n) #define RREP(i, m, n) for (int i = (int)(m); i >= (int)(n); i--) #define rrep(i, n) RREP(i, n - 1, 0) #define REPL(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++) #define repl(i, n) REPL(i, 0, n) #define all(v) v.begin(), v.end() const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; int main() { int N; cin >> N; vector<ll> A(N); int Nmin = 0; ll summin = 0; rep(i, N) { cin >> A[i]; if (A[i] < 0) { Nmin++; summin += A[i]; } } sort(all(A)); if (Nmin == N) summin -= A[--Nmin]; else if (Nmin == 0) summin += A[Nmin++]; cout << accumulate(all(A), 0LL) - 2 * summin << endl; rep(i, N - Nmin - 1) { cout << A[0] << ' ' << A[N - 2 - i] << endl; A[0] -= A[N - 1 - i]; } rep(i, Nmin) { cout << A[N - 1] << ' ' << A[i] << endl; A[N - 1] -= A[i]; } return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++) #define rep(i, n) REP(i, 0, n) #define RREP(i, m, n) for (int i = (int)(m); i >= (int)(n); i--) #define rrep(i, n) RREP(i, n - 1, 0) #define REPL(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++) #define repl(i, n) REPL(i, 0, n) #define all(v) v.begin(), v.end() const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; int main() { int N; cin >> N; vector<ll> A(N); int Nmin = 0; ll summin = 0; rep(i, N) { cin >> A[i]; if (A[i] < 0) { Nmin++; summin += A[i]; } } sort(all(A)); if (Nmin == N) summin -= A[--Nmin]; else if (Nmin == 0) summin += A[Nmin++]; cout << accumulate(all(A), 0LL) - 2 * summin << endl; rep(i, N - Nmin - 1) { cout << A[0] << ' ' << A[N - 2 - i] << endl; A[0] -= A[N - 2 - i]; } rep(i, Nmin) { cout << A[N - 1] << ' ' << A[i] << endl; A[N - 1] -= A[i]; } return 0; }
[ "literal.number.change", "assignment.value.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
821,470
821,471
u137747137
cpp
p03007
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, m, n) for (int i = m; i < (int)(n); i++) typedef long long ll; typedef pair<ll, ll> pint; int main() { ll n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; vector<pint> ans(n - 1); ll res; sort(a.begin(), a.end()); if (n == 2) { cout << a[1] - a[0] << endl; cout << a[1] << " " << a[0] << endl; } else { int jud = lower_bound(a.begin(), a.end(), 0) - a.begin(); // cout<<jud<<endl; if (jud == 0) { res = a[0] - a[1]; ans[0] = {a[0], a[1]}; int cnt = 1; if (3 < n) { REP(i, 2, n - 1) { ans[cnt] = {res, a[i]}; res -= a[i]; cnt++; } } ans[n - 2] = {a[n - 1], res}; res = a[n - 1] - res; } else if (jud == n) { res = a[n - 1] - a[0]; ans[0] = {a[n - 1], a[0]}; int cnt = 1; REP(i, 1, n - 1) { ans[cnt] = {res, a[i]}; res -= a[i]; cnt++; } } else if (0 < jud < n) { if (jud < n - 1) { res = a[0] - a[jud]; ans[0] = {a[0], a[jud]}; int cnt = 1; REP(i, jud + 1, n - 1) { ans[cnt] = {res, a[i]}; res -= a[i]; cnt++; } ans[cnt] = {a[n - 1], res}; res = a[n - 1] - res; cnt++; for (int i = jud - 1; 0 < i; i--) { ans[cnt] = {res, a[i]}; res -= a[i]; cnt++; } } else { res = a[jud] - a[0]; ans[0] = {a[jud], a[0]}; int cnt = 1; for (int i = jud - 1; 0 < i; i--) { ans[cnt] = {res, a[i]}; res -= a[i]; cnt++; } } cout << res << endl; rep(i, n - 1) { cout << ans[i].first << " " << ans[i].second << endl; } } } }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, m, n) for (int i = m; i < (int)(n); i++) typedef long long ll; typedef pair<ll, ll> pint; int main() { ll n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; vector<pint> ans(n - 1); ll res; sort(a.begin(), a.end()); if (n == 2) { cout << a[1] - a[0] << endl; cout << a[1] << " " << a[0] << endl; } else { int jud = lower_bound(a.begin(), a.end(), 0) - a.begin(); // cout<<jud<<endl; if (jud == 0) { res = a[0] - a[1]; ans[0] = {a[0], a[1]}; int cnt = 1; if (3 < n) { REP(i, 2, n - 1) { ans[cnt] = {res, a[i]}; res -= a[i]; cnt++; } } ans[n - 2] = {a[n - 1], res}; res = a[n - 1] - res; } else if (jud == n) { res = a[n - 1] - a[0]; ans[0] = {a[n - 1], a[0]}; int cnt = 1; REP(i, 1, n - 1) { ans[cnt] = {res, a[i]}; res -= a[i]; cnt++; } } else if (0 < jud < n) { if (jud < n - 1) { res = a[0] - a[jud]; ans[0] = {a[0], a[jud]}; int cnt = 1; REP(i, jud + 1, n - 1) { ans[cnt] = {res, a[i]}; res -= a[i]; cnt++; } ans[cnt] = {a[n - 1], res}; res = a[n - 1] - res; cnt++; for (int i = jud - 1; 0 < i; i--) { ans[cnt] = {res, a[i]}; res -= a[i]; cnt++; } } else { res = a[jud] - a[0]; ans[0] = {a[jud], a[0]}; int cnt = 1; for (int i = jud - 1; 0 < i; i--) { ans[cnt] = {res, a[i]}; res -= a[i]; cnt++; } } } cout << res << endl; rep(i, n - 1) { cout << ans[i].first << " " << ans[i].second << endl; } } }
[]
821,478
821,479
u466331465
cpp
p03007
#include <algorithm> #include <cmath> #include <iostream> using namespace std; int A[100010]; int main(void) { int N; cin >> N; for (int i = 0; i < N; ++i) cin >> A[i]; sort(A, A + N); int ans = A[N - 1] - A[0]; for (int i = 1; i < N - 1; ++i) ans += abs(A[i]); cout << ans << endl; for (int i = N - 2; i >= 0; --i) { if (A[i] > 0) { cout << A[0] << ' ' << A[i] << endl; A[0] -= A[i]; } else { cout << A[N - 1] << ' ' << A[i]; A[N - 1] -= A[i]; } } return 0; }
#include <algorithm> #include <cmath> #include <iostream> using namespace std; int A[100010]; int main(void) { int N; cin >> N; for (int i = 0; i < N; ++i) cin >> A[i]; sort(A, A + N); int ans = A[N - 1] - A[0]; for (int i = 1; i < N - 1; ++i) ans += abs(A[i]); cout << ans << endl; for (int i = N - 2; i >= 0; --i) { if (A[i] > 0) { cout << A[0] << ' ' << A[i] << endl; A[0] -= A[i]; } else { cout << A[N - 1] << ' ' << A[i] << endl; A[N - 1] -= A[i]; } } return 0; }
[ "io.output.newline.add" ]
821,480
821,481
u297367372
cpp
p03007
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define INF 1LL << 62 #define inf 1000000007 vector<ll> a; vector<ll> pl, mi; int main() { ll n; cin >> n; for (ll i = 0; i < n; i++) { ll x; cin >> x; a.push_back(x); } sort(a.begin(), a.end()); ll ans = 0; ans = a[n - 1] - a[0]; for (ll i = 1; i < n - 1; i++) { ans += abs(a[i]); } cout << ans << endl; for (ll i = 1; i < n - 1; i++) { if (a[i] > 0) { pl.push_back(a[i]); } else { mi.push_back(a[i]); } } ll sum = a[0]; while (pl.size() != 0) { cout << sum << " "; ll now = pl.back(); pl.pop_back(); cout << now << endl; sum -= now; } cout << a[n - 1] << " " << sum << endl; sum = a[n - 1] - sum; while (mi.size() != 0) { ll now = mi.back(); mi.pop_back(); cout << sum << " " << now << endl; sum -= now; } cout << sum; // your code goes here return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define INF 1LL << 62 #define inf 1000000007 vector<ll> a; vector<ll> pl, mi; int main() { ll n; cin >> n; for (ll i = 0; i < n; i++) { ll x; cin >> x; a.push_back(x); } sort(a.begin(), a.end()); ll ans = 0; ans = a[n - 1] - a[0]; for (ll i = 1; i < n - 1; i++) { ans += abs(a[i]); } cout << ans << endl; for (ll i = 1; i < n - 1; i++) { if (a[i] > 0) { pl.push_back(a[i]); } else { mi.push_back(a[i]); } } ll sum = a[0]; while (pl.size() != 0) { cout << sum << " "; ll now = pl.back(); pl.pop_back(); cout << now << endl; sum -= now; } cout << a[n - 1] << " " << sum << endl; sum = a[n - 1] - sum; while (mi.size() != 0) { ll now = mi.back(); mi.pop_back(); cout << sum << " " << now << endl; sum -= now; } // cout << sum; // your code goes here return 0; }
[]
821,484
821,485
u166378830
cpp
p03007
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define mkp(a, b) make_pair(a, b) int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); vector<pair<int, int>> ans; int total = 0; if (a[0] > 0) { int cur = a[0]; for (int i = 1; i < n - 1; i++) { ans.push_back(mkp(cur, a[i])); cur = cur - a[i]; } ans.push_back(mkp(a[n - 1], cur)); total = a[n - 1] - cur; } else if (a[n - 1] < 0) { int cur = a[n - 1]; for (int i = n - 2; i >= 0; i--) { ans.push_back(mkp(cur, a[i])); cur = cur - a[i]; } total = cur; } else { int index = -1; int cur = a[0]; for (int i = n - 2; i >= 1; i--) { if (a[i] < 0) { index = i; break; } ans.push_back(mkp(cur, a[i])); cur = cur - a[i]; } ans.push_back(mkp(a[n - 1], cur)); cur = a[n - 1] - cur; for (int i = index; i >= 1; i--) { ans.push_back(mkp(cur, a[i])); cur = cur - a[i]; total = cur; } } cout << total << endl; for (auto c : ans) { cout << c.first << " " << c.second << endl; } return 0; }
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define mkp(a, b) make_pair(a, b) int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); vector<pair<int, int>> ans; int total = 0; if (a[0] > 0) { int cur = a[0]; for (int i = 1; i < n - 1; i++) { ans.push_back(mkp(cur, a[i])); cur = cur - a[i]; } ans.push_back(mkp(a[n - 1], cur)); total = a[n - 1] - cur; } else if (a[n - 1] < 0) { int cur = a[n - 1]; for (int i = n - 2; i >= 0; i--) { ans.push_back(mkp(cur, a[i])); cur = cur - a[i]; } total = cur; } else { int index = -1; int cur = a[0]; for (int i = n - 2; i >= 1; i--) { if (a[i] < 0) { index = i; break; } ans.push_back(mkp(cur, a[i])); cur = cur - a[i]; } ans.push_back(mkp(a[n - 1], cur)); cur = a[n - 1] - cur; for (int i = index; i >= 1; i--) { ans.push_back(mkp(cur, a[i])); cur = cur - a[i]; } total = cur; } cout << total << endl; for (auto c : ans) { cout << c.first << " " << c.second << endl; } return 0; }
[]
821,487
821,488
u389009751
cpp
p03007
#include <bits/stdc++.h> #define endl '\n'; #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("Ofast") constexpr ll INF = 1e18; constexpr int inf = 1e9; constexpr double INFD = 1e100; constexpr ll mod = 1000000007; constexpr ll mod2 = 998244353; const double PI = 3.1415926535897932384626433832795028841971; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; 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; } // ios::sync_with_stdio(false); // cin.tie(nullptr); // --------------------------------------------------------------------------- int main() { int N; cin >> N; vector<ll> A(N); ll sum = 0; rep(i, N) { cin >> A[i]; sum += abs(A[i]); } sort(A.begin(), A.end()); if (A[N - 1] < 0) { cout << sum + A[N - 1] * 2 << endl; ll now = A[N - 1]; rep(i, N - 1) { cout << now << " " << A[i] << endl; now -= A[i]; } } else if (A[0] > 0) { cout << sum - A[0] * 2 << endl; ll now = A[0]; for (int i = 1; i < N - 1; i++) { cout << now << " " << A[i] << endl; now -= A[i]; } cout << A[N - 1] << " " << now << endl; } else { cout << sum << endl; int pos = lower_bound(A.begin(), A.end(), 0) - A.begin(); for (int i = pos; i < N - 1; i++) { cout << A[0] << " " << A[i] << endl; A[0] -= A[i]; } for (int i = 0; i < pos; i++) { cout << A[N - 1] << " " << A[i] << endl; A[N - 1] -= A[i]; } } return 0; }
#include <bits/stdc++.h> #define endl '\n'; #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("Ofast") constexpr ll INF = 1e18; constexpr int inf = 1e9; constexpr double INFD = 1e100; constexpr ll mod = 1000000007; constexpr ll mod2 = 998244353; const double PI = 3.1415926535897932384626433832795028841971; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; 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; } // ios::sync_with_stdio(false); // cin.tie(nullptr); // --------------------------------------------------------------------------- int main() { int N; cin >> N; vector<ll> A(N); ll sum = 0; rep(i, N) { cin >> A[i]; sum += abs(A[i]); } sort(A.begin(), A.end()); if (A[N - 1] <= 0) { cout << sum + A[N - 1] * 2 << endl; ll now = A[N - 1]; rep(i, N - 1) { cout << now << " " << A[i] << endl; now -= A[i]; } } else if (A[0] >= 0) { cout << sum - A[0] * 2 << endl; ll now = A[0]; for (int i = 1; i < N - 1; i++) { cout << now << " " << A[i] << endl; now -= A[i]; } cout << A[N - 1] << " " << now << endl; } else { cout << sum << endl; int pos = lower_bound(A.begin(), A.end(), 0) - A.begin(); for (int i = pos; i < N - 1; i++) { cout << A[0] << " " << A[i] << endl; A[0] -= A[i]; } for (int i = 0; i < pos; i++) { cout << A[N - 1] << " " << A[i] << endl; A[N - 1] -= A[i]; } } return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
821,489
821,490
u550014122
cpp
p03007
#include <algorithm> #include <array> #include <atomic> #include <bitset> #include <cassert> #include <ccomplex> #include <cctype> #include <cerrno> #include <cfenv> #include <cfloat> #include <chrono> #include <cinttypes> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <codecvt> #include <complex> #include <condition_variable> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstdbool> #include <cstddef> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctgmath> #include <ctime> #include <cwchar> #include <cwctype> #include <deque> #include <exception> #include <forward_list> #include <fstream> #include <functional> #include <future> #include <initializer_list> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <mutex> #include <new> #include <numeric> #include <ostream> #include <queue> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <system_error> #include <thread> #include <tuple> #include <type_traits> #include <typeindex> #include <typeinfo> #include <unordered_map> #include <unordered_set> #include <utility> #include <valarray> #include <vector> #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rrep(i, n) for (ll i = n - 1; i > 0; i--) #define all(x) (x).begin(), (x).end() #pragma GCC optimize("Ofast") using namespace std; typedef int64_t ll; typedef long double ld; const ll INF = (1LL << 60); const ld pi = acosl((ld)1); const ll mod = 1000000007; const int dx[4] = {0, 1, 0, -1}; const int dy[4] = {1, 0, -1, 0}; const int ddx[8] = {1, 0, -1, -1, -1, 0, 1, 1}; const int ddy[8] = {1, 1, 1, 0, -1, -1, -1, 0}; bool solve() { ll n; cin >> n; vector<ll> A(n); rep(i, n) { cin >> A[i]; } sort(all(A), greater<ll>()); //1つ目は+。その後負の値が出てきたら vector<pair<ll, ll>> v; for (int i = 1; i < n - 1; i++) { if (A[i] <= 0) { v.push_back(make_pair(A[0], A[i])); A[0] += A[i]; } } for (int i = 1; i < n - 1; i++) { if (A[i] > 0) { v.push_back(make_pair(A[n - 1], A[i])); A[n - 1] -= A[i]; } } v.push_back(make_pair(A[0], A[n - 1])); cout << A[0] - A[n - 1] << endl; for (auto &&i : v) cout << i.first << " " << i.second << endl; return false; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed; cout << setprecision(30); return solve(); }
#include <algorithm> #include <array> #include <atomic> #include <bitset> #include <cassert> #include <ccomplex> #include <cctype> #include <cerrno> #include <cfenv> #include <cfloat> #include <chrono> #include <cinttypes> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <codecvt> #include <complex> #include <condition_variable> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstdbool> #include <cstddef> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctgmath> #include <ctime> #include <cwchar> #include <cwctype> #include <deque> #include <exception> #include <forward_list> #include <fstream> #include <functional> #include <future> #include <initializer_list> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <mutex> #include <new> #include <numeric> #include <ostream> #include <queue> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <system_error> #include <thread> #include <tuple> #include <type_traits> #include <typeindex> #include <typeinfo> #include <unordered_map> #include <unordered_set> #include <utility> #include <valarray> #include <vector> #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rrep(i, n) for (ll i = n - 1; i > 0; i--) #define all(x) (x).begin(), (x).end() #pragma GCC optimize("Ofast") using namespace std; typedef int64_t ll; typedef long double ld; const ll INF = (1LL << 60); const ld pi = acosl((ld)1); const ll mod = 1000000007; const int dx[4] = {0, 1, 0, -1}; const int dy[4] = {1, 0, -1, 0}; const int ddx[8] = {1, 0, -1, -1, -1, 0, 1, 1}; const int ddy[8] = {1, 1, 1, 0, -1, -1, -1, 0}; bool solve() { ll n; cin >> n; vector<ll> A(n); rep(i, n) { cin >> A[i]; } sort(all(A), greater<ll>()); //1つ目は+。その後負の値が出てきたら vector<pair<ll, ll>> v; for (int i = 1; i < n - 1; i++) { if (A[i] <= 0) { v.push_back(make_pair(A[0], A[i])); A[0] -= A[i]; } } for (int i = 1; i < n - 1; i++) { if (A[i] > 0) { v.push_back(make_pair(A[n - 1], A[i])); A[n - 1] -= A[i]; } } v.push_back(make_pair(A[0], A[n - 1])); cout << A[0] - A[n - 1] << endl; for (auto &&i : v) cout << i.first << " " << i.second << endl; return false; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed; cout << setprecision(30); return solve(); }
[ "expression.operator.change" ]
821,495
821,496
u644568158
cpp
p03007
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> p; const ll INF = (1 << 28); const ll dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0}; const ll Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl #define REP(i, n) for (ll i = 0; i < n; i++) #define REPR(i, n) for (ll i = n; i >= 0; i--) #define FOR(i, m, n) for (ll i = m; i < n; i++) #define INF 2e9 #define ALL(v) v.begin(), v.end() ll n; ll a[100000]; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; for (ll i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); ll sum = 0; for (ll i = 0; i < n; i++) { sum += abs(a[i]); } if (a[0] >= 0) { sum -= 2 * a[0]; } if (a[n - 1] < 0) { sum += 2 * a[n - 1]; } cout << sum << "\n"; bool plus = false; ll temp = a[0]; ll im; for (ll i = 1; i < n - 1; i++) { if (a[i] > 0) { cout << temp << " " << a[i] << "\n"; temp -= a[i]; } } ll temp1 = a[n - 1]; cout << temp1 << " " << temp << "\n"; temp1 -= temp; for (ll i = 1; i < n - 1; i++) { if (a[i] <= 0) { cout << temp << " " << a[i] << "\n"; temp1 -= a[i]; } } }
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> p; const ll INF = (1 << 28); const ll dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0}; const ll Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl #define REP(i, n) for (ll i = 0; i < n; i++) #define REPR(i, n) for (ll i = n; i >= 0; i--) #define FOR(i, m, n) for (ll i = m; i < n; i++) #define INF 2e9 #define ALL(v) v.begin(), v.end() ll n; ll a[100000]; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; for (ll i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); ll sum = 0; for (ll i = 0; i < n; i++) { sum += abs(a[i]); } if (a[0] >= 0) { sum -= 2 * a[0]; } if (a[n - 1] < 0) { sum += 2 * a[n - 1]; } cout << sum << "\n"; bool plus = false; ll temp = a[0]; ll im; for (ll i = 1; i < n - 1; i++) { if (a[i] > 0) { cout << temp << " " << a[i] << "\n"; temp -= a[i]; } } ll temp1 = a[n - 1]; cout << temp1 << " " << temp << "\n"; temp1 -= temp; for (ll i = 1; i < n - 1; i++) { if (a[i] <= 0) { cout << temp1 << " " << a[i] << "\n"; temp1 -= a[i]; } } }
[ "identifier.change", "io.output.change" ]
821,497
821,498
u155416173
cpp
p03007
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> p; const ll INF = (1 << 28); const ll dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0}; const ll Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl #define REP(i, n) for (ll i = 0; i < n; i++) #define REPR(i, n) for (ll i = n; i >= 0; i--) #define FOR(i, m, n) for (ll i = m; i < n; i++) #define INF 2e9 #define ALL(v) v.begin(), v.end() ll n; ll a[100000]; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; for (ll i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); ll sum = 0; for (ll i = 0; i < n; i++) { sum += abs(a[i]); } if (a[0] >= 0) { sum -= 2 * a[0]; } if (a[n - 1] < 0) { sum += 2 * a[n - 1]; } cout << sum << "\n"; bool plus = false; ll temp = a[0]; ll im; for (ll i = 1; i < n - 1; i++) { if (a[i] >= 0) { cout << temp << " " << a[i] << "\n"; temp -= a[i]; } } ll temp1 = a[n - 1]; cout << temp1 << " " << temp << "\n"; temp1 -= temp; for (ll i = 1; i < n - 1; i++) { if (a[i] < 0) { cout << temp << " " << a[i] << "\n"; temp1 -= a[i]; } } }
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> p; const ll INF = (1 << 28); const ll dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0}; const ll Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl #define REP(i, n) for (ll i = 0; i < n; i++) #define REPR(i, n) for (ll i = n; i >= 0; i--) #define FOR(i, m, n) for (ll i = m; i < n; i++) #define INF 2e9 #define ALL(v) v.begin(), v.end() ll n; ll a[100000]; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; for (ll i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); ll sum = 0; for (ll i = 0; i < n; i++) { sum += abs(a[i]); } if (a[0] >= 0) { sum -= 2 * a[0]; } if (a[n - 1] < 0) { sum += 2 * a[n - 1]; } cout << sum << "\n"; bool plus = false; ll temp = a[0]; ll im; for (ll i = 1; i < n - 1; i++) { if (a[i] > 0) { cout << temp << " " << a[i] << "\n"; temp -= a[i]; } } ll temp1 = a[n - 1]; cout << temp1 << " " << temp << "\n"; temp1 -= temp; for (ll i = 1; i < n - 1; i++) { if (a[i] <= 0) { cout << temp1 << " " << a[i] << "\n"; temp1 -= a[i]; } } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "identifier.change", "io.output.change" ]
821,499
821,498
u155416173
cpp