output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <bits/stdc++.h> using namespace std; int main() { long long i, n, sum = 1; cin >> n; for (i = 1; i < n; i++) sum = sum + (12 * i); cout << sum; return 0; }
### Prompt Create a solution in cpp for the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long i, n, sum = 1; cin >> n; for (i = 1; i < n; i++) sum = sum + (12 * i); cout << sum; return 0; } ```
#include <bits/stdc++.h> using namespace std; int n; long long s, x; int main() { srand(time(NULL)); cin >> n; n--; s = 1; x = 12; while (n) { s += x; x += 12; n--; } cout << s << endl; return 0; }
### Prompt Please create a solution in Cpp to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int n; long long s, x; int main() { srand(time(NULL)); cin >> n; n--; s = 1; x = 12; while (n) { s += x; x += 12; n--; } cout << s << endl; return 0; } ```
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; { long long int n, i; cin >> n; n = 6 * n * (n - 1) + 1; cout << n; cout << '\n'; } return 0; }
### Prompt Construct a cpp code solution to the problem outlined: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; { long long int n, i; cin >> n; n = 6 * n * (n - 1) + 1; cout << n; cout << '\n'; } return 0; } ```
#include <bits/stdc++.h> int main(void) { int n; scanf("%d", &n); printf("%d\n", (6 * n * (n - 1) + 1)); return 0; }
### Prompt Construct a cpp code solution to the problem outlined: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> int main(void) { int n; scanf("%d", &n); printf("%d\n", (6 * n * (n - 1) + 1)); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << (n * 6) * (n - 1) + 1; }
### Prompt Please formulate a cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << (n * 6) * (n - 1) + 1; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 1) { cout << 1; exit(0); } if (n == 2) { cout << 13; exit(0); } int d = 24; int ops = 12; int ans = 13; for (int i = 0; i < n - 2; i++) { ans += d; d += ops; } cout << ans; }
### Prompt Generate a cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 1) { cout << 1; exit(0); } if (n == 2) { cout << 13; exit(0); } int d = 24; int ops = 12; int ans = 13; for (int i = 0; i < n - 2; i++) { ans += d; d += ops; } cout << ans; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long f = 0, ans = 1; for (int i = 2; i <= n; ++i) { f += 12; ans += f; } cout << ans << endl; return 0; }
### Prompt Generate a Cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long f = 0, ans = 1; for (int i = 2; i <= n; ++i) { f += 12; ans += f; } cout << ans << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << (6 * n * (n - 1)) + 1 << endl; return 0; }
### Prompt Please formulate a cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << (6 * n * (n - 1)) + 1 << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; const long long N = 1e6; long long t; long long a; void solve() { cin >> a; long long ans = 1; for (int i = 1; i <= a - 1; i++) { ans = ans + i * 12; } cout << ans << endl; } int main() { ios::sync_with_stdio(0), cin.tie(0); solve(); return 0; }
### Prompt Please create a solution in Cpp to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; const long long N = 1e6; long long t; long long a; void solve() { cin >> a; long long ans = 1; for (int i = 1; i <= a - 1; i++) { ans = ans + i * 12; } cout << ans << endl; } int main() { ios::sync_with_stdio(0), cin.tie(0); solve(); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; cout << (((3 * n) - 2) * ((2 * n) - 1)) + n - 1; return 0; }
### Prompt Please create a solution in cpp to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; cout << (((3 * n) - 2) * ((2 * n) - 1)) + n - 1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << (6 * n * (n - 1) + 1) << "\n"; return 0; }
### Prompt Please provide a CPP coded solution to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << (6 * n * (n - 1) + 1) << "\n"; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n, sum, i; cin >> n; cout << (12 * ((n * (n + 1)) / 2 - n)) + 1; return 0; }
### Prompt Create a solution in CPP for the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n, sum, i; cin >> n; cout << (12 * ((n * (n + 1)) / 2 - n)) + 1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << 6 * n * (n - 1) + 1; return 0; }
### Prompt Generate a Cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << 6 * n * (n - 1) + 1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long a, Output, i, k, j; while (cin >> a) { i = 0; j = 0; Output = 1; for (k = 1; k <= a; k++) { i++; Output += j; j = 12 * i; } cout << Output << endl; } return 0; }
### Prompt Your challenge is to write a CPP solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long a, Output, i, k, j; while (cin >> a) { i = 0; j = 0; Output = 1; for (k = 1; k <= a; k++) { i++; Output += j; j = 12 * i; } cout << Output << endl; } return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n, sn; 1 <= n <= 18257; 1 <= sn <= 2000000000; cin >> n; if (n == 1) cout << 1; if (n != 1) cout << 6 * n * (n - 1) + 1; return 0; }
### Prompt Create a solution in cpp for the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n, sn; 1 <= n <= 18257; 1 <= sn <= 2000000000; cin >> n; if (n == 1) cout << 1; if (n != 1) cout << 6 * n * (n - 1) + 1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int res = 1; for (int i = 1; i < n; ++i) { res += i * 12; } cout << res; }
### Prompt Create a solution in Cpp for the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int res = 1; for (int i = 1; i < n; ++i) { res += i * 12; } cout << res; } ```
#include <bits/stdc++.h> using namespace std; int f(int n) { if (n == 1) return 1; return (n * 2 - 1) * 6 - 6 + f(n - 1); } int main() { int n; cin >> n; cout << f(n) << endl; return 0; }
### Prompt In Cpp, your task is to solve the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int f(int n) { if (n == 1) return 1; return (n * 2 - 1) * 6 - 6 + f(n - 1); } int main() { int n; cin >> n; cout << f(n) << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; void timo() { ios::sync_with_stdio(0); ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); } int main() { timo(); long long n, ans = 1, arr[18258]; arr[0] = 1, arr[1] = 12; cin >> n; for (int i = 1; i < n; i++) { if (i > 1) arr[i] = arr[i - 1] + 12; ans += arr[i]; } cout << ans << endl; return 0; }
### Prompt Your challenge is to write a Cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; void timo() { ios::sync_with_stdio(0); ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); } int main() { timo(); long long n, ans = 1, arr[18258]; arr[0] = 1, arr[1] = 12; cin >> n; for (int i = 1; i < n; i++) { if (i > 1) arr[i] = arr[i - 1] + 12; ans += arr[i]; } cout << ans << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; const double PI = 2 * asin(1.0); const int INF = 1000000000; const double EPS = 1e-10; inline int cmp(double x, double y = 0, double tol = EPS) { return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1; } inline long long gcd(long long n1, long long n2) { return n2 == 0 ? abs(n1) : gcd(n2, n1 % n2); } inline long long lcm(long long n1, long long n2) { return n1 == 0 || n2 == 0 ? 0 : abs(n1 * (n2 / gcd(n1, n2))); } map<int, int> mapi; bool comp(pair<int, int> p1, pair<int, int> p2) { return p1.second > p2.second; } class mycomparison { bool reverse; public: mycomparison(const bool& revparam = false) { reverse = revparam; } bool operator()(const pair<int, int>& lhs, const pair<int, int>& rhs) const { if (reverse) return (lhs.second < rhs.second); else return (lhs.second > rhs.second); } }; int main() { int n; cin >> n; cout << (6 * n * (n - 1) + 1) << endl; }
### Prompt Your task is to create a cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; const double PI = 2 * asin(1.0); const int INF = 1000000000; const double EPS = 1e-10; inline int cmp(double x, double y = 0, double tol = EPS) { return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1; } inline long long gcd(long long n1, long long n2) { return n2 == 0 ? abs(n1) : gcd(n2, n1 % n2); } inline long long lcm(long long n1, long long n2) { return n1 == 0 || n2 == 0 ? 0 : abs(n1 * (n2 / gcd(n1, n2))); } map<int, int> mapi; bool comp(pair<int, int> p1, pair<int, int> p2) { return p1.second > p2.second; } class mycomparison { bool reverse; public: mycomparison(const bool& revparam = false) { reverse = revparam; } bool operator()(const pair<int, int>& lhs, const pair<int, int>& rhs) const { if (reverse) return (lhs.second < rhs.second); else return (lhs.second > rhs.second); } }; int main() { int n; cin >> n; cout << (6 * n * (n - 1) + 1) << endl; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << 6 * n * (n - 1) + 1; return 0; }
### Prompt Your challenge is to write a cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << 6 * n * (n - 1) + 1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int x; cin >> x; cout << 1 + x * (x - 1) * 6 << "\n"; }
### Prompt In Cpp, your task is to solve the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int x; cin >> x; cout << 1 + x * (x - 1) * 6 << "\n"; } ```
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const int inf = (int)1e9; int main() { int a; cin >> a; --a; long long int res = (24 + 12 * (a - 1)) / 2 * a; res++; cout << res; return 0; }
### Prompt Please formulate a Cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const int inf = (int)1e9; int main() { int a; cin >> a; --a; long long int res = (24 + 12 * (a - 1)) / 2 * a; res++; cout << res; return 0; } ```
#include <bits/stdc++.h> using namespace std; int n; int main() { scanf("%d", &n); printf("%lld", (long long)6 * (n - 1) * n + 1); return 0; }
### Prompt Construct a CPP code solution to the problem outlined: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int n; int main() { scanf("%d", &n); printf("%lld", (long long)6 * (n - 1) * n + 1); return 0; } ```
#include <bits/stdc++.h> using namespace std; const long long int inf = 1LL << 62; const long long int nlyinf = 1LL << 60; template <class P, class Q> ostream &operator<<(ostream &out, const pair<P, Q> &p); template <class T> ostream &operator<<(ostream &out, const vector<T> &V); template <> ostream &operator<<<long long int>(ostream &out, const vector<long long int> &V); void print(const vector<long long int> &V, long long int n); template <class T> ostream &operator<<(ostream &out, const set<T> &S); template <class T> ostream &operator<<(ostream &out, const unordered_set<T> &S); template <class P, class Q> ostream &operator<<(ostream &out, const map<P, Q> &S); template <class P, class Q> ostream &operator<<(ostream &out, const unordered_map<P, Q> &S); template <class P, class Q> ostream &operator<<(ostream &out, const pair<P, Q> &p) { cout << "[" << p.first << "," << p.second << "]"; return out; } template <class T> ostream &operator<<(ostream &out, const vector<T> &V) { for (long long int i = 0; i < V.size(); i++) { cout << V[i] << " "; } return out; } template <> ostream &operator<<<long long int>(ostream &out, const vector<long long int> &V) { for (long long int i = 0; i < V.size(); i++) { if (V[i] >= nlyinf) { cout << "inf "; } else { cout << V[i] << " "; } } return out; } template <class T> void print(const vector<T> &V, long long int n, bool newline = false) { for (long long int i = 0; i < n; i++) { cout << V[i]; if (newline) { cout << '\n'; } else { cout << " "; } } } void print(const vector<long long int> &V, long long int n) { for (long long int i = 0; i < n; i++) { if (V[i] >= nlyinf) { cout << "inf"; } else { cout << V[i]; } cout << " "; } } template <class T> ostream &operator<<(ostream &out, const set<T> &S) { cout << "{"; for (typename set<T>::const_iterator it = S.begin(); it != S.end(); ++it) { cout << (*it); if (next(it, 1) != S.end()) cout << ","; } cout << "}"; return out; } template <class T> ostream &operator<<(ostream &out, const unordered_set<T> &S) { cout << "{"; for (typename unordered_set<T>::const_iterator it = S.begin(); it != S.end(); ++it) { cout << (*it); if (next(it, 1) != S.end()) cout << ","; } cout << "}"; return out; } template <class P, class Q> ostream &operator<<(ostream &out, const map<P, Q> &S) { cout << "{"; for (typename map<P, Q>::const_iterator it = S.begin(); it != S.end(); ++it) { cout << (*it); if (next(it, 1) != S.end()) cout << ","; } cout << "}"; return out; } template <class P, class Q> ostream &operator<<(ostream &out, const unordered_map<P, Q> &S) { cout << "{"; for (typename unordered_map<P, Q>::const_iterator it = S.begin(); it != S.end(); ++it) { cout << (*it); if (next(it, 1) != S.end()) cout << ","; } cout << "}"; return out; } int main() { ios::sync_with_stdio(false); long long int n, ans = 1; cin >> n; long long int k = 2; for (long long int i = 2; i <= n; i++) { ans += (k) * (6); k += 2; } cout << ans; return 0; }
### Prompt Create a solution in cpp for the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; const long long int inf = 1LL << 62; const long long int nlyinf = 1LL << 60; template <class P, class Q> ostream &operator<<(ostream &out, const pair<P, Q> &p); template <class T> ostream &operator<<(ostream &out, const vector<T> &V); template <> ostream &operator<<<long long int>(ostream &out, const vector<long long int> &V); void print(const vector<long long int> &V, long long int n); template <class T> ostream &operator<<(ostream &out, const set<T> &S); template <class T> ostream &operator<<(ostream &out, const unordered_set<T> &S); template <class P, class Q> ostream &operator<<(ostream &out, const map<P, Q> &S); template <class P, class Q> ostream &operator<<(ostream &out, const unordered_map<P, Q> &S); template <class P, class Q> ostream &operator<<(ostream &out, const pair<P, Q> &p) { cout << "[" << p.first << "," << p.second << "]"; return out; } template <class T> ostream &operator<<(ostream &out, const vector<T> &V) { for (long long int i = 0; i < V.size(); i++) { cout << V[i] << " "; } return out; } template <> ostream &operator<<<long long int>(ostream &out, const vector<long long int> &V) { for (long long int i = 0; i < V.size(); i++) { if (V[i] >= nlyinf) { cout << "inf "; } else { cout << V[i] << " "; } } return out; } template <class T> void print(const vector<T> &V, long long int n, bool newline = false) { for (long long int i = 0; i < n; i++) { cout << V[i]; if (newline) { cout << '\n'; } else { cout << " "; } } } void print(const vector<long long int> &V, long long int n) { for (long long int i = 0; i < n; i++) { if (V[i] >= nlyinf) { cout << "inf"; } else { cout << V[i]; } cout << " "; } } template <class T> ostream &operator<<(ostream &out, const set<T> &S) { cout << "{"; for (typename set<T>::const_iterator it = S.begin(); it != S.end(); ++it) { cout << (*it); if (next(it, 1) != S.end()) cout << ","; } cout << "}"; return out; } template <class T> ostream &operator<<(ostream &out, const unordered_set<T> &S) { cout << "{"; for (typename unordered_set<T>::const_iterator it = S.begin(); it != S.end(); ++it) { cout << (*it); if (next(it, 1) != S.end()) cout << ","; } cout << "}"; return out; } template <class P, class Q> ostream &operator<<(ostream &out, const map<P, Q> &S) { cout << "{"; for (typename map<P, Q>::const_iterator it = S.begin(); it != S.end(); ++it) { cout << (*it); if (next(it, 1) != S.end()) cout << ","; } cout << "}"; return out; } template <class P, class Q> ostream &operator<<(ostream &out, const unordered_map<P, Q> &S) { cout << "{"; for (typename unordered_map<P, Q>::const_iterator it = S.begin(); it != S.end(); ++it) { cout << (*it); if (next(it, 1) != S.end()) cout << ","; } cout << "}"; return out; } int main() { ios::sync_with_stdio(false); long long int n, ans = 1; cin >> n; long long int k = 2; for (long long int i = 2; i <= n; i++) { ans += (k) * (6); k += 2; } cout << ans; return 0; } ```
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LLINF = 0x3f3f3f3f3f3f3f3f; const int MOD = 1000000007; const double EPS = 1e-8; const long double EULER = 2.71828182845904523536; const long double PI = 3.14159265358979323846; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; while (cin >> n) { n--; long long ans = 1 + (n * (n + 1) * 6); cout << ans << endl; } return 0; }
### Prompt In CPP, your task is to solve the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LLINF = 0x3f3f3f3f3f3f3f3f; const int MOD = 1000000007; const double EPS = 1e-8; const long double EULER = 2.71828182845904523536; const long double PI = 3.14159265358979323846; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; while (cin >> n) { n--; long long ans = 1 + (n * (n + 1) * 6); cout << ans << endl; } return 0; } ```
#include <bits/stdc++.h> using namespace std; long long S(long long n) { return (n * (n + 1)) / 2; } long long A(long long n) { return S(3 * n + 1) + 3 * S(n); } int main() { long long n; cin >> n; cout << A(--n); }
### Prompt Your challenge is to write a Cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long S(long long n) { return (n * (n + 1)) / 2; } long long A(long long n) { return S(3 * n + 1) + 3 * S(n); } int main() { long long n; cin >> n; cout << A(--n); } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int i; int answer = 1; for (i = 2; i <= n; i++) { answer += (6 * (2 * i - 2)); } cout << answer << endl; return 0; }
### Prompt Construct a cpp code solution to the problem outlined: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int i; int answer = 1; for (i = 2; i <= n; i++) { answer += (6 * (2 * i - 2)); } cout << answer << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); cout << (6 * n * (n - 1)) + 1; return 0; }
### Prompt Develop a solution in Cpp to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); cout << (6 * n * (n - 1)) + 1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a; if (a == 1) { cout << '1'; return 0; } if (a == 2) { cout << "13"; return 0; } long long sol = 1; sol += 1LL * 6 * a * (a + 1) / 2; sol += 1LL * 6 * ((a - 2) * (a - 1) / 2 - 1); cout << sol << '\n'; return 0; }
### Prompt Generate a CPP solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a; if (a == 1) { cout << '1'; return 0; } if (a == 2) { cout << "13"; return 0; } long long sol = 1; sol += 1LL * 6 * a * (a + 1) / 2; sol += 1LL * 6 * ((a - 2) * (a - 1) / 2 - 1); cout << sol << '\n'; return 0; } ```
#include <bits/stdc++.h> using namespace std; int n; int main() { scanf("%d", &n); printf("%d\n", 6 * n * (n - 1) + 1); return 0; }
### Prompt Please create a solution in cpp to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int n; int main() { scanf("%d", &n); printf("%d\n", 6 * n * (n - 1) + 1); return 0; } ```
#include <bits/stdc++.h> using namespace std; int n, ans; int main() { scanf("%d", &n); ans = 1; for (int i = 2; i <= n; i++) { ans += 6 * (2 * i - 2); } printf("%d\n", ans); return 0; }
### Prompt Please provide a Cpp coded solution to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int n, ans; int main() { scanf("%d", &n); ans = 1; for (int i = 2; i <= n; i++) { ans += 6 * (2 * i - 2); } printf("%d\n", ans); return 0; } ```
#include <bits/stdc++.h> using namespace std; int n, m; long long p[20000], ans = 1; int main() { scanf("%d", &n); if (n == 1) { puts("1"); return 0; } p[0] = 0; for (int i = (1); i <= (n); i++) p[i] = p[i - 1] + i; ans = 13; for (int i = (3); i <= (n); i++) { ans += 6 + 6 * (p[i - 1] - p[i - 3]); } cout << ans << endl; return 0; }
### Prompt Please provide a CPP coded solution to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int n, m; long long p[20000], ans = 1; int main() { scanf("%d", &n); if (n == 1) { puts("1"); return 0; } p[0] = 0; for (int i = (1); i <= (n); i++) p[i] = p[i - 1] + i; ans = 13; for (int i = (3); i <= (n); i++) { ans += 6 + 6 * (p[i - 1] - p[i - 3]); } cout << ans << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main(void) { int a; cin >> a; cout << 6 * a * (a - 1) + 1; return 0; }
### Prompt Construct a cpp code solution to the problem outlined: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main(void) { int a; cin >> a; cout << 6 * a * (a - 1) + 1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long a, b = 1, i; cin >> a; for (i = 2; i <= a; i++) { b += 6 * 2 * (i - 1); } cout << b << endl; return 0; }
### Prompt Develop a solution in Cpp to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long a, b = 1, i; cin >> a; for (i = 2; i <= a; i++) { b += 6 * 2 * (i - 1); } cout << b << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long ans = 1; for (int i = 0; i < n; i++) ans += 12 * i; cout << ans << endl; }
### Prompt Your challenge is to write a Cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long ans = 1; for (int i = 0; i < n; i++) ans += 12 * i; cout << ans << endl; } ```
#include <bits/stdc++.h> using namespace std; long long mod = pow(10, 9) + 7; int main() { long long x; cin >> x; long long ans = 0; for (long long i = 1; i <= x; i++) { if (i == 1) { ans++; continue; } ans += (2 * i - 1) * 4; ans += 4 * (i - 2); } cout << ans; return 0; }
### Prompt Your task is to create a Cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long mod = pow(10, 9) + 7; int main() { long long x; cin >> x; long long ans = 0; for (long long i = 1; i <= x; i++) { if (i == 1) { ans++; continue; } ans += (2 * i - 1) * 4; ans += 4 * (i - 2); } cout << ans; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int res = 0; for (int i = (1); i <= ((n)); i++) { if (i == 1) res++; else { res += 6 * (2 * i - 1) - 6; } } cout << res << endl; return 0; }
### Prompt Please formulate a CPP solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int res = 0; for (int i = (1); i <= ((n)); i++) { if (i == 1) res++; else { res += 6 * (2 * i - 1) - 6; } } cout << res << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; long long MOD = 1791791791; double eps = 1e-12; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n; cin >> n; cout << fixed << setprecision(0) << 12 * (n * (n - 1) * 0.5) + 1 << "\n"; }
### Prompt Please formulate a CPP solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long MOD = 1791791791; double eps = 1e-12; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n; cin >> n; cout << fixed << setprecision(0) << 12 * (n * (n - 1) * 0.5) + 1 << "\n"; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; int ans(1); for (int i = 2; i <= a; ++i) ans += 12 * (i - 1); cout << ans; }
### Prompt Generate a cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; int ans(1); for (int i = 2; i <= a; ++i) ans += 12 * (i - 1); cout << ans; } ```
#include <bits/stdc++.h> using namespace std; inline double sqr(double a) { return a * a; } template <typename T> inline void alert(T const &t) { cout << t; exit(0); } template <typename T> inline void alert(vector<T> &t, char delim = ' ') { for (T const &ti : t) cout << ti << delim; exit(0); } const int INF = 1e9; const long long INFLL = 1e15; struct node_t {}; int main() { long long n, m = 0; cin >> n; n--; m = 1; long long t = 1; while (n > 0) { m += t * 12; t++; n--; } cout << m; return 0; }
### Prompt Create a solution in cpp for the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; inline double sqr(double a) { return a * a; } template <typename T> inline void alert(T const &t) { cout << t; exit(0); } template <typename T> inline void alert(vector<T> &t, char delim = ' ') { for (T const &ti : t) cout << ti << delim; exit(0); } const int INF = 1e9; const long long INFLL = 1e15; struct node_t {}; int main() { long long n, m = 0; cin >> n; n--; m = 1; long long t = 1; while (n > 0) { m += t * 12; t++; n--; } cout << m; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int x; cin >> x; cout << 6 * x * (x - 1) + 1; }
### Prompt Please provide a cpp coded solution to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int x; cin >> x; cout << 6 * x * (x - 1) + 1; } ```
#include <bits/stdc++.h> using namespace std; int n, h[20003]; int main() { cin >> n; h[1] = 1; for (int i = 2; i <= n; ++i) h[i] = h[i - 1] + 12 * (i - 1); cout << h[n] << endl; return 0; }
### Prompt Create a solution in Cpp for the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int n, h[20003]; int main() { cin >> n; h[1] = 1; for (int i = 2; i <= n; ++i) h[i] = h[i - 1] + 12 * (i - 1); cout << h[n] << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << 6 * n * (n - 1) + 1; }
### Prompt Your challenge is to write a CPP solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << 6 * n * (n - 1) + 1; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 1) { cout << "1"; return 0; } long long cd = n * 3 - 2, ans = 0; for (int i = 1; i <= cd; i++) { ans += i; } ans *= 2; for (int i = 1; i <= n; i++) { ans -= i + n - 1; } for (int i = n - 1; i >= 1; i--) { ans -= i + n - 1; } cout << ans; return 0; }
### Prompt Construct a CPP code solution to the problem outlined: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 1) { cout << "1"; return 0; } long long cd = n * 3 - 2, ans = 0; for (int i = 1; i <= cd; i++) { ans += i; } ans *= 2; for (int i = 1; i <= n; i++) { ans -= i + n - 1; } for (int i = n - 1; i >= 1; i--) { ans -= i + n - 1; } cout << ans; return 0; } ```
#include <bits/stdc++.h> using namespace std; unsigned long long int n, i, ans; int main() { cin >> n; if (n == 1) { cout << 1; return 0; } for (i = 2; i <= n; i++) { ans = ans + 3 * i + 6 * (i - 1) + 3 * (i - 2); } cout << ans + 1; return 0; }
### Prompt Your task is to create a CPP solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; unsigned long long int n, i, ans; int main() { cin >> n; if (n == 1) { cout << 1; return 0; } for (i = 2; i <= n; i++) { ans = ans + 3 * i + 6 * (i - 1) + 3 * (i - 2); } cout << ans + 1; return 0; } ```
#include <bits/stdc++.h> int l[20000]; int s[20000]; int i; int a; int main() { scanf("%d", &a); l[1] = 1; s[1] = 1; l[2] = 12; s[2] = 4; for (i = 3; i <= a; i++) { s[i] = s[i - 1] + 3; l[i] = 2 * (s[i] * 3 - 3) - (i - 2) * 6 - 6; } int sol = 0; for (i = 1; i <= a; i++) { sol += l[i]; } printf("%d\n", sol); return 0; }
### Prompt Your task is to create a Cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> int l[20000]; int s[20000]; int i; int a; int main() { scanf("%d", &a); l[1] = 1; s[1] = 1; l[2] = 12; s[2] = 4; for (i = 3; i <= a; i++) { s[i] = s[i - 1] + 3; l[i] = 2 * (s[i] * 3 - 3) - (i - 2) * 6 - 6; } int sol = 0; for (i = 1; i <= a; i++) { sol += l[i]; } printf("%d\n", sol); return 0; } ```
#include <bits/stdc++.h> using namespace std; long long n, i, j, t, s = 1, k, e, l; int main() { cin >> k; for (i = 1; i < k; i++) s = s + i * 12; cout << s; }
### Prompt Generate a Cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long n, i, j, t, s = 1, k, e, l; int main() { cin >> k; for (i = 1; i < k; i++) s = s + i * 12; cout << s; } ```
#include <bits/stdc++.h> using namespace std; const int oo = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; int res = 1; for (int i = 1; i < n; i++) res += i * 12; cout << res; return 0; }
### Prompt Your challenge is to write a Cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int oo = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; int res = 1; for (int i = 1; i < n; i++) res += i * 12; cout << res; return 0; } ```
#include <bits/stdc++.h> int n; int main() { scanf("%d", &n); printf("%d\n", 6 * n * (n - 1) + 1); }
### Prompt Please provide a CPP coded solution to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> int n; int main() { scanf("%d", &n); printf("%d\n", 6 * n * (n - 1) + 1); } ```
#include <bits/stdc++.h> int main() { int n; scanf("%d", &n); printf("%d", n * (n - 1) * 6 + 1); }
### Prompt Your challenge is to write a Cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> int main() { int n; scanf("%d", &n); printf("%d", n * (n - 1) * 6 + 1); } ```
#include <bits/stdc++.h> using namespace std; int main() { int long long ans = 1; int long long part = 1; int n; cin >> n; for (int i = 2; i <= n; i++) { part = part + 2; ans += part * 6 - 6; } cout << ans << endl; return 0; }
### Prompt Construct a cpp code solution to the problem outlined: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int long long ans = 1; int long long part = 1; int n; cin >> n; for (int i = 2; i <= n; i++) { part = part + 2; ans += part * 6 - 6; } cout << ans << endl; return 0; } ```
#include <bits/stdc++.h> int main() { int F[18258]; F[1] = 1; int n; scanf("%d", &n); for (int i = 2; i <= n; i++) F[i] = F[i - 1] + (i - 1) * 12; printf("%d", F[n]); return 0; }
### Prompt Develop a solution in cpp to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> int main() { int F[18258]; F[1] = 1; int n; scanf("%d", &n); for (int i = 2; i <= n; i++) F[i] = F[i - 1] + (i - 1) * 12; printf("%d", F[n]); return 0; } ```
#include <bits/stdc++.h> using namespace std; long long n; int main() { cin >> n; cout << (n * (n - 1) / 2) * 12 + 1; return 0; }
### Prompt Create a solution in CPP for the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long n; int main() { cin >> n; cout << (n * (n - 1) / 2) * 12 + 1; return 0; } ```
#include <bits/stdc++.h> using namespace std; long long int ans = 1; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { ans = ans + 12 * (i - 1); if (ans > 2000000000) ans = ans % 2000000000; } printf("%I64d", ans); return 0; }
### Prompt Please provide a cpp coded solution to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long int ans = 1; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { ans = ans + 12 * (i - 1); if (ans > 2000000000) ans = ans % 2000000000; } printf("%I64d", ans); return 0; } ```
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); long long n, a, b, tmp = 0, x = 0, y, c; vector<pair<int, int> > vp; bool first, firs, g, prev; char ch; vector<char> used; vector<int> v; string second, t; char d[10]; map<string, long long> ma; bool cmpvp(pair<int, int> p1, pair<int, int> p2) { if (p1.first < p2.first) return 1; if (p1.first == p2.first) if (p1.second < p2.second) return 1; return 0; } int main() { cin >> a; long long ans = 0; for (long long i = 1; i < a + 1; ++i) { ans += 12 * (i - 1); } ++ans; cout << ans; return 0; }
### Prompt Develop a solution in CPP to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; const double pi = acos(-1); long long n, a, b, tmp = 0, x = 0, y, c; vector<pair<int, int> > vp; bool first, firs, g, prev; char ch; vector<char> used; vector<int> v; string second, t; char d[10]; map<string, long long> ma; bool cmpvp(pair<int, int> p1, pair<int, int> p2) { if (p1.first < p2.first) return 1; if (p1.first == p2.first) if (p1.second < p2.second) return 1; return 0; } int main() { cin >> a; long long ans = 0; for (long long i = 1; i < a + 1; ++i) { ans += 12 * (i - 1); } ++ans; cout << ans; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; cout << 6 * a * (a - 1) + 1 << endl; }
### Prompt Construct a CPP code solution to the problem outlined: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; cout << 6 * a * (a - 1) + 1 << endl; } ```
#include <bits/stdc++.h> using namespace std; int n, ans; int main() { cin >> n; for (int i = 1; i < n; i++) { ans += 12 * i; } cout << ans + 1; return 0; }
### Prompt Please formulate a Cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int n, ans; int main() { cin >> n; for (int i = 1; i < n; i++) { ans += 12 * i; } cout << ans + 1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int star, sum = 0; cin >> star; for (int i = 1; i <= star; i++) { if (i == 1) sum++; else sum = sum + 12 * (i - 1); } cout << sum; return 0; }
### Prompt Generate a Cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int star, sum = 0; cin >> star; for (int i = 1; i <= star; i++) { if (i == 1) sum++; else sum = sum + 12 * (i - 1); } cout << sum; return 0; } ```
#include <bits/stdc++.h> int main() { long long int a, b = 1, i; scanf("%I64d", &a); for (i = 1; i <= a; i++) { b += 12 * (1 + i - 2); } if (a == 1) printf("1"); else printf("%I64d", b); return 0; }
### Prompt Develop a solution in cpp to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> int main() { long long int a, b = 1, i; scanf("%I64d", &a); for (i = 1; i <= a; i++) { b += 12 * (1 + i - 2); } if (a == 1) printf("1"); else printf("%I64d", b); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n, i, z = 12, t = 1; cin >> n; for (i = 1; i < n; i++) { t += z; z += 12; } cout << t; return 0; }
### Prompt Develop a solution in Cpp to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n, i, z = 12, t = 1; cin >> n; for (i = 1; i < n; i++) { t += z; z += 12; } cout << t; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long res = 1; for (int i = 2; i <= n; ++i) res = res + 12 * (i - 1); cout << res; return 0; }
### Prompt Generate a cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long res = 1; for (int i = 2; i <= n; ++i) res = res + 12 * (i - 1); cout << res; return 0; } ```
#include <bits/stdc++.h> using namespace std; int dir1[8][2] = {1, 2, 2, 1, 2, -1, 1, -2, -1, 2, -2, 1, -1, -2, -2, -1}; int dir2[4][2] = {1, 0, 0, 1, -1, 0, 0, -1}; int dir3[8][2] = {1, 0, 0, 1, -1, 0, 0, -1, 1, 1, 1, -1, -1, 1, -1, -1}; int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); } bool Isleap(int year) { if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) return true; return false; } bool isPrime(int x) { if (x == 1) return false; else if (x == 2) return true; for (int i = 2; i <= sqrt(x * 1.0); ++i) { if (x % i == 0) return false; } return true; } int sqr(int x) { return x * x; } int main() { int n; while (~scanf("%d", &n)) { printf("%d\n", 6 * n * (n - 1) + 1); } return 0; }
### Prompt Construct a cpp code solution to the problem outlined: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int dir1[8][2] = {1, 2, 2, 1, 2, -1, 1, -2, -1, 2, -2, 1, -1, -2, -2, -1}; int dir2[4][2] = {1, 0, 0, 1, -1, 0, 0, -1}; int dir3[8][2] = {1, 0, 0, 1, -1, 0, 0, -1, 1, 1, 1, -1, -1, 1, -1, -1}; int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); } bool Isleap(int year) { if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) return true; return false; } bool isPrime(int x) { if (x == 1) return false; else if (x == 2) return true; for (int i = 2; i <= sqrt(x * 1.0); ++i) { if (x % i == 0) return false; } return true; } int sqr(int x) { return x * x; } int main() { int n; while (~scanf("%d", &n)) { printf("%d\n", 6 * n * (n - 1) + 1); } return 0; } ```
#include <bits/stdc++.h> int main() { int n; while (~scanf("%d", &n)) { int f = 1; for (int i = 2; i <= n; i++) { f = f + (i - 1) * 12; } printf("%d\n", f); } return 0; }
### Prompt Please provide a Cpp coded solution to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> int main() { int n; while (~scanf("%d", &n)) { int f = 1; for (int i = 2; i <= n; i++) { f = f + (i - 1) * 12; } printf("%d\n", f); } return 0; } ```
#include <bits/stdc++.h> using namespace std; long long n; int main() { cin >> n; cout << 1 + 12 * (n * (n - 1) / 2) << endl; return 0; }
### Prompt Generate a Cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long n; int main() { cin >> n; cout << 1 + 12 * (n * (n - 1) / 2) << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; cout << ((6 * (n) * (n - 1)) + 1) << endl; return 0; }
### Prompt Please formulate a cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; cout << ((6 * (n) * (n - 1)) + 1) << endl; return 0; } ```
#include <bits/stdc++.h> int n; int main() { scanf("%d", &n); printf("%d", 6 * (n - 1) * n + 1); return 0; }
### Prompt Please formulate a cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> int n; int main() { scanf("%d", &n); printf("%d", 6 * (n - 1) * n + 1); return 0; } ```
#include <bits/stdc++.h> int f[18257] = {1}; int main() { int i; for (i = 1; i < 18257; ++i) f[i] = f[i - 1] + 12 * i; int n; while (scanf("%d", &n) != EOF) printf("%d\n", f[n - 1]); }
### Prompt Create a solution in Cpp for the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> int f[18257] = {1}; int main() { int i; for (i = 1; i < 18257; ++i) f[i] = f[i - 1] + 12 * i; int n; while (scanf("%d", &n) != EOF) printf("%d\n", f[n - 1]); } ```
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); unsigned long long layers, bowls; cin >> layers; bowls = 1; for (int i = 2; i <= layers; i++) { bowls += 6 + ((i - 1) * 2 - 1) * 6; } cout << bowls << endl; return 0; }
### Prompt Please formulate a cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); unsigned long long layers, bowls; cin >> layers; bowls = 1; for (int i = 2; i <= layers; i++) { bowls += 6 + ((i - 1) * 2 - 1) * 6; } cout << bowls << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; const long long AV = 1e16; const long long AB = 1e9 + 7; const long long AC = 1e6 + 1; const long long AN = 1e5 + 1; const long long AP = 1e4 + 1; long long n; int main() { cin >> n; cout << n * 6 * (n - 1) + 1; return 0; }
### Prompt Please formulate a CPP solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; const long long AV = 1e16; const long long AB = 1e9 + 7; const long long AC = 1e6 + 1; const long long AN = 1e5 + 1; const long long AP = 1e4 + 1; long long n; int main() { cin >> n; cout << n * 6 * (n - 1) + 1; return 0; } ```
#include <bits/stdc++.h> using namespace std; template <class T> inline T sqr(T a) { return a * a; } int main() { long long n; scanf("%I64d", &n); printf("%I64d", 6 * n * (n - 1) + 1); return 0; }
### Prompt Develop a solution in cpp to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; template <class T> inline T sqr(T a) { return a * a; } int main() { long long n; scanf("%I64d", &n); printf("%I64d", 6 * n * (n - 1) + 1); return 0; } ```
#include <bits/stdc++.h> using namespace std; int a, b, c, d, e, cnt = 0, snt = 0, f; string s, n, s1; vector<int> v; char u; int main() { cin >> a; cout << (6 * a * (a - 1) + 1); }
### Prompt Generate a CPP solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int a, b, c, d, e, cnt = 0, snt = 0, f; string s, n, s1; vector<int> v; char u; int main() { cin >> a; cout << (6 * a * (a - 1) + 1); } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { int ans = 1; int doce = 0; while (--n) { doce += 12; ans += doce; } cout << ans << endl; } }
### Prompt Please create a solution in Cpp to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { int ans = 1; int doce = 0; while (--n) { doce += 12; ans += doce; } cout << ans << endl; } } ```
#include <bits/stdc++.h> using namespace std; template <class T> inline T gcd(T a, T b) { if (a < 0) return gcd(-a, b); if (b < 0) return gcd(a, -b); return (b == 0) ? a : gcd(b, a % b); } template <class T> inline T lcm(T a, T b) { if (a < 0) return lcm(-a, b); if (b < 0) return lcm(a, -b); return a * (b / gcd(a, b)); } template <class T> inline T sqr(T x) { return x * x; } template <class T> T power(T N, T P) { return (P == 0) ? 1 : N * power(N, P - 1); } template <class T> bool inside(T a, T b, T c) { return (b >= a && b <= c); } const long long INF64 = (long long)1E16; int distsq2d(int x1, int y1, int x2, int y2) { return sqr(x1 - x2) + sqr(y1 - y2); } double dist2d(double x1, double y1, double x2, double y2) { return sqrt(sqr(x1 - x2) + sqr(y1 - y2)); } double dist3d(double x1, double y1, double z1, double x2, double y2, double z2) { return sqrt(sqr(x1 - x2) + sqr(y1 - y2) + sqr(z1 - z2)); } long long toInt64(string s) { long long r = 0; istringstream sin(s); sin >> r; return r; } double LOG(long long N, long long B) { return (log10l(N)) / (log10l(B)); } string itoa(long long a) { if (a == 0) return "0"; string ret; for (long long i = a; i > 0; i = i / 10) ret.push_back((i % 10) + 48); reverse(ret.begin(), ret.end()); return ret; } vector<string> token(string a, string b) { const char *q = a.c_str(); while (count(b.begin(), b.end(), *q)) q++; vector<string> oot; while (*q) { const char *e = q; while (*e && !count(b.begin(), b.end(), *e)) e++; oot.push_back(string(q, e)); q = e; while (count(b.begin(), b.end(), *q)) q++; } return oot; } int isvowel(char s) { s = tolower(s); if (s == 'a' || s == 'e' || s == 'i' || s == 'o' || s == 'u') return 1; return 0; } int isupper(char s) { if (s >= 'A' and s <= 'Z') return 1; return 0; } int Set(int N, int pos) { return N = N | (1 << pos); } int reset(int N, int pos) { return N = N & ~(1 << pos); } int check(int N, int pos) { return (N & (1 << pos)); } int toggle(int N, int pos) { if (check(N, pos)) return N = reset(N, pos); return N = Set(N, pos); } void pbit(int N) { printf("("); for (int i = 10; i >= 0; i--) { bool x = check(N, i); cout << x; } puts(")"); } int main() { int n; cin >> n; cout << 6 * n * (n - 1) + 1 << endl; }
### Prompt Please provide a CPP coded solution to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; template <class T> inline T gcd(T a, T b) { if (a < 0) return gcd(-a, b); if (b < 0) return gcd(a, -b); return (b == 0) ? a : gcd(b, a % b); } template <class T> inline T lcm(T a, T b) { if (a < 0) return lcm(-a, b); if (b < 0) return lcm(a, -b); return a * (b / gcd(a, b)); } template <class T> inline T sqr(T x) { return x * x; } template <class T> T power(T N, T P) { return (P == 0) ? 1 : N * power(N, P - 1); } template <class T> bool inside(T a, T b, T c) { return (b >= a && b <= c); } const long long INF64 = (long long)1E16; int distsq2d(int x1, int y1, int x2, int y2) { return sqr(x1 - x2) + sqr(y1 - y2); } double dist2d(double x1, double y1, double x2, double y2) { return sqrt(sqr(x1 - x2) + sqr(y1 - y2)); } double dist3d(double x1, double y1, double z1, double x2, double y2, double z2) { return sqrt(sqr(x1 - x2) + sqr(y1 - y2) + sqr(z1 - z2)); } long long toInt64(string s) { long long r = 0; istringstream sin(s); sin >> r; return r; } double LOG(long long N, long long B) { return (log10l(N)) / (log10l(B)); } string itoa(long long a) { if (a == 0) return "0"; string ret; for (long long i = a; i > 0; i = i / 10) ret.push_back((i % 10) + 48); reverse(ret.begin(), ret.end()); return ret; } vector<string> token(string a, string b) { const char *q = a.c_str(); while (count(b.begin(), b.end(), *q)) q++; vector<string> oot; while (*q) { const char *e = q; while (*e && !count(b.begin(), b.end(), *e)) e++; oot.push_back(string(q, e)); q = e; while (count(b.begin(), b.end(), *q)) q++; } return oot; } int isvowel(char s) { s = tolower(s); if (s == 'a' || s == 'e' || s == 'i' || s == 'o' || s == 'u') return 1; return 0; } int isupper(char s) { if (s >= 'A' and s <= 'Z') return 1; return 0; } int Set(int N, int pos) { return N = N | (1 << pos); } int reset(int N, int pos) { return N = N & ~(1 << pos); } int check(int N, int pos) { return (N & (1 << pos)); } int toggle(int N, int pos) { if (check(N, pos)) return N = reset(N, pos); return N = Set(N, pos); } void pbit(int N) { printf("("); for (int i = 10; i >= 0; i--) { bool x = check(N, i); cout << x; } puts(")"); } int main() { int n; cin >> n; cout << 6 * n * (n - 1) + 1 << endl; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; long long ans = 1; cin >> n; for (int i = 1; i < n; i++) ans += i * 12; cout << ans << endl; }
### Prompt Generate a CPP solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; long long ans = 1; cin >> n; for (int i = 1; i < n; i++) ans += i * 12; cout << ans << endl; } ```
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e5 + 6; int main() { ios_base::sync_with_stdio(0); long long n; cin >> n; long long temp = 1 + (n - 1) * 3; cout << (temp * (temp + 1)) / 2 + 3 * ((n - 1) * n) / 2; return 0; }
### Prompt Please provide a Cpp coded solution to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; const long long maxn = 1e5 + 6; int main() { ios_base::sync_with_stdio(0); long long n; cin >> n; long long temp = 1 + (n - 1) * 3; cout << (temp * (temp + 1)) / 2 + 3 * ((n - 1) * n) / 2; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n; cin >> n; long long m = n - 1, ans = 0; ans = (n * m * 6); cout << ans + 1; return 0; }
### Prompt In cpp, your task is to solve the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n; cin >> n; long long m = n - 1, ans = 0; ans = (n * m * 6); cout << ans + 1; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long n, a[50000] = {}, j = 2; cin >> n; a[1] = 1; for (int i = 2; i <= n; i++) { a[i] = a[i] + j + (j + 1) + (j + 2); a[i] += a[i - 1]; a[i] = a[i] + (3 * (i - 1) * i / 2); a[i] = a[i] - (3 * (i - 2) * (i - 1) / 2); j += 3; } cout << a[n] << endl; return 0; }
### Prompt Create a solution in CPP for the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long n, a[50000] = {}, j = 2; cin >> n; a[1] = 1; for (int i = 2; i <= n; i++) { a[i] = a[i] + j + (j + 1) + (j + 2); a[i] += a[i - 1]; a[i] = a[i] + (3 * (i - 1) * i / 2); a[i] = a[i] - (3 * (i - 2) * (i - 1) / 2); j += 3; } cout << a[n] << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int a, ans = 1; cin >> a; for (int i = 1; i < a; i++) { ans += i * 12; } cout << ans << endl; return 0; }
### Prompt Please provide a Cpp coded solution to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int a, ans = 1; cin >> a; for (int i = 1; i < a; i++) { ans += i * 12; } cout << ans << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; const int maxint = -1u >> 1; template <class T> bool get_max(T& a, const T& b) { return b > a ? a = b, 1 : 0; } template <class T> bool get_min(T& a, const T& b) { return b < a ? a = b, 1 : 0; } const int Maxn = 18259; long long f[Maxn]; int main() { f[1] = 1; int n; for (int i = 2; i < Maxn; i++) f[i] = 12 * (i - 1) + f[i - 1]; while (cin >> n) cout << f[n] << endl; return 0; }
### Prompt Generate a cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int maxint = -1u >> 1; template <class T> bool get_max(T& a, const T& b) { return b > a ? a = b, 1 : 0; } template <class T> bool get_min(T& a, const T& b) { return b < a ? a = b, 1 : 0; } const int Maxn = 18259; long long f[Maxn]; int main() { f[1] = 1; int n; for (int i = 2; i < Maxn; i++) f[i] = 12 * (i - 1) + f[i - 1]; while (cin >> n) cout << f[n] << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; long long shar(long long a) { long long ans = (a + 1) * a / 2; return ans; } int main() { long long a; cin >> a; long long h = shar(3 * a - 2) + 3 * shar(a - 1); cout << h; return 0; }
### Prompt Develop a solution in CPP to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long shar(long long a) { long long ans = (a + 1) * a / 2; return ans; } int main() { long long a; cin >> a; long long h = shar(3 * a - 2) + 3 * shar(a - 1); cout << h; return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); printf("%d", (6 * n * (n - 1) + 1)); return 0; }
### Prompt Generate a Cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); printf("%d", (6 * n * (n - 1) + 1)); return 0; } ```
#include <bits/stdc++.h> using namespace std; const double PI = 3.14159265358979; const double PI2 = 6.28318530717958; const double PId2 = 1.570796326794895; inline vector<int> ReadVI(int count) { vector<int> arrayname(count); for (int i = 0; i < int(count); i++) cin >> arrayname[i]; return arrayname; }; inline vector<pair<int, int> > ReadVII(int count) { vector<pair<int, int> > arrayname(count); for (int i = 0; i < int(count); i++) { cin >> arrayname[i].first; arrayname[i].second = i; } return arrayname; }; const int MOD = 1000000007; const int MAXVALUE = 100001; int main() { int n; cin >> n; vector<int> a(n + 1); a[0] = 0; a[1] = 1; if (n == 1) return cout << 1, 0; for (int i = 2; i <= n; i++) { a[i] = 12 * (i - 1); } int sum = 0; for (int i = 0; i <= n; i++) { sum += a[i]; } cout << sum; return 0; }
### Prompt Develop a solution in Cpp to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; const double PI = 3.14159265358979; const double PI2 = 6.28318530717958; const double PId2 = 1.570796326794895; inline vector<int> ReadVI(int count) { vector<int> arrayname(count); for (int i = 0; i < int(count); i++) cin >> arrayname[i]; return arrayname; }; inline vector<pair<int, int> > ReadVII(int count) { vector<pair<int, int> > arrayname(count); for (int i = 0; i < int(count); i++) { cin >> arrayname[i].first; arrayname[i].second = i; } return arrayname; }; const int MOD = 1000000007; const int MAXVALUE = 100001; int main() { int n; cin >> n; vector<int> a(n + 1); a[0] = 0; a[1] = 1; if (n == 1) return cout << 1, 0; for (int i = 2; i <= n; i++) { a[i] = 12 * (i - 1); } int sum = 0; for (int i = 0; i <= n; i++) { sum += a[i]; } cout << sum; return 0; } ```
#include <bits/stdc++.h> int main() { int n; int sum; scanf("%d", &n); sum = ((n - 1) * n) / 2; printf("%d", sum * 12 + 1); return 0; }
### Prompt Please provide a CPP coded solution to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> int main() { int n; int sum; scanf("%d", &n); sum = ((n - 1) * n) / 2; printf("%d", sum * 12 + 1); return 0; } ```
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long m = n * (n - 1) * 6; if (n >= 1) { if (n == 1) cout << 1; else cout << m + 1; } return 0; }
### Prompt Construct a cpp code solution to the problem outlined: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long m = n * (n - 1) * 6; if (n >= 1) { if (n == 1) cout << 1; else cout << m + 1; } return 0; } ```
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } long long pows(long long b, long long e) { if (e == 0) return 1; else if (e % 2 == 0) { long long a = pow(b, e / 2); return a * a; } else { long long a = pow(b, e / 2); return b * a * a; } } long long powm(long long x, long long y, long long m) { x = x % m; long long res = 1; while (y) { if (y & 1) res = res * x; res %= m; y = y >> 1; x = x * x; x %= m; } return res; } long long modInverse(long long a, long long m = 1000000007) { if (m == 1) return 0; long long m0 = m, y = 0, x = 1; while (a > 1) { long long q = a / m, t = m; m = a % m, a = t; t = y; y = x - q * y; x = t; } if (x < 0) x += m0; return x; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, m, i, j, k, x, y, z, e, f, p, q, g, l, r, w, h, count1 = 0, prod = 1, a, b, c, d, index, x1, x2, diff, ans = 0, sum = 0, sum1 = 0, sum2 = 0, flag = 0, flag1 = 0, flag2 = 0; string s, s1, s2; cin >> n; if (n == 1) { cout << "1"; return 0; } else { ans = 1; k = 3; for (i = 2; i <= n; i++) { ans += k * 4; k += 3; } cout << ans; } }
### Prompt Develop a solution in Cpp to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } long long pows(long long b, long long e) { if (e == 0) return 1; else if (e % 2 == 0) { long long a = pow(b, e / 2); return a * a; } else { long long a = pow(b, e / 2); return b * a * a; } } long long powm(long long x, long long y, long long m) { x = x % m; long long res = 1; while (y) { if (y & 1) res = res * x; res %= m; y = y >> 1; x = x * x; x %= m; } return res; } long long modInverse(long long a, long long m = 1000000007) { if (m == 1) return 0; long long m0 = m, y = 0, x = 1; while (a > 1) { long long q = a / m, t = m; m = a % m, a = t; t = y; y = x - q * y; x = t; } if (x < 0) x += m0; return x; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, m, i, j, k, x, y, z, e, f, p, q, g, l, r, w, h, count1 = 0, prod = 1, a, b, c, d, index, x1, x2, diff, ans = 0, sum = 0, sum1 = 0, sum2 = 0, flag = 0, flag1 = 0, flag2 = 0; string s, s1, s2; cin >> n; if (n == 1) { cout << "1"; return 0; } else { ans = 1; k = 3; for (i = 2; i <= n; i++) { ans += k * 4; k += 3; } cout << ans; } } ```
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; --n; cout << 6 * n * (n + 1) + 1; return 0; }
### Prompt Please provide a Cpp coded solution to the problem described below: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; --n; cout << 6 * n * (n + 1) + 1; return 0; } ```
#include <bits/stdc++.h> int main() { int a; scanf("%d", &a); long long ans = 1; for (int i = 1; i < a; ++i) ans += 12LL * i; printf("%I64d\n", ans); return 0; }
### Prompt Please create a solution in CPP to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> int main() { int a; scanf("%d", &a); long long ans = 1; for (int i = 1; i < a; ++i) ans += 12LL * i; printf("%I64d\n", ans); return 0; } ```
#include <bits/stdc++.h> using namespace std; int a; int main() { cin >> a; cout << 6 * a * (a - 1) + 1 << endl; return 0; }
### Prompt Create a solution in Cpp for the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int a; int main() { cin >> a; cout << 6 * a * (a - 1) + 1 << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; long long val[18260]; void preproce() { val[1] = 1; for (int i = int(2); i < int(18258); i++) val[i] = val[i - 1] + 9 * (i - 1) + 3 * (i - 1); } int main() { preproce(); int n; scanf("%d", &n); cout << val[n] << endl; }
### Prompt Your challenge is to write a CPP solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long val[18260]; void preproce() { val[1] = 1; for (int i = int(2); i < int(18258); i++) val[i] = val[i - 1] + 9 * (i - 1) + 3 * (i - 1); } int main() { preproce(); int n; scanf("%d", &n); cout << val[n] << endl; } ```
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long int dp[20000] = {0}; dp[1] = 1; for (int i = 2; i <= 18257; i++) dp[i] = dp[i - 1] + 12 * (i - 1); cout << dp[n] << endl; return 0; }
### Prompt Generate a Cpp solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long int dp[20000] = {0}; dp[1] = 1; for (int i = 2; i <= 18257; i++) dp[i] = dp[i - 1] + 12 * (i - 1); cout << dp[n] << endl; return 0; } ```
#include <bits/stdc++.h> using namespace std; template <typename Tp> inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") { for (Tp current = _begin; current != _end; ++current) { std::cout << *current << _delim; } std::cout << '\n'; } using ll = int64_t; using pii = std::pair<int, int>; constexpr int INF = 0x3f3f3f3f; constexpr int MOD = static_cast<const int>(1e9 + 7); int F(int x) { if (x == 1) { return 1; } return 12 * (x - 1); } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int a; cin >> a; ll ans = 0; for (int i = 1; i <= a; ++i) { ans += F(i); } cout << ans << "\n"; return 0; }
### Prompt Your task is to create a CPP solution to the following problem: <image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13 ### Response ```cpp #include <bits/stdc++.h> using namespace std; template <typename Tp> inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") { for (Tp current = _begin; current != _end; ++current) { std::cout << *current << _delim; } std::cout << '\n'; } using ll = int64_t; using pii = std::pair<int, int>; constexpr int INF = 0x3f3f3f3f; constexpr int MOD = static_cast<const int>(1e9 + 7); int F(int x) { if (x == 1) { return 1; } return 12 * (x - 1); } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int a; cin >> a; ll ans = 0; for (int i = 1; i <= a; ++i) { ans += F(i); } cout << ans << "\n"; return 0; } ```
#include <bits/stdc++.h> using namespace std; const int maxn = 5 * 1e5 + 1000; vector<int> G[maxn], ans[maxn]; set<int> s; set<int>::iterator ite; int num[maxn], cnt, res; void bfs(int x) { s.erase(x); queue<int> que; ans[res].push_back(x); que.push(x); cnt = 0; while (que.size()) { int cur = que.front(); que.pop(); cnt = 0; for (ite = s.begin(); ite != s.end(); ite++) { int next = *ite; if (!binary_search(G[cur].begin(), G[cur].end(), *ite)) { que.push(next); ans[res].push_back(next); num[cnt++] = next; } } for (int i = 0; i < cnt; i++) s.erase(num[i]); } res++; } int main() { int n, m; while (scanf("%d%d", &n, &m) != EOF) { for (int i = 1; i <= m; i++) { int a, b; scanf("%d%d", &a, &b); G[a].push_back(b); G[b].push_back(a); } for (int i = 1; i <= n; i++) { s.insert(i); sort(G[i].begin(), G[i].end()); } res = 1; for (int i = 1; i <= n; i++) { if (s.count(i)) bfs(i); } printf("%d\n", res - 1); for (int i = 1; i <= res; i++) { if (ans[i].size()) { printf("%d ", ans[i].size()); for (int j = 0; j < ans[i].size(); j++) { if (j == ans[i].size() - 1) printf("%d\n", ans[i][j]); else printf("%d ", ans[i][j]); } } } } return 0; }
### Prompt Please create a solution in cpp to the following problem: Berland has managed to repel the flatlanders' attack and is now starting the counter attack. Flatland has n cities, numbered from 1 to n, and some pairs of them are connected by bidirectional roads. The Flatlandian maps show roads between cities if and only if there is in fact no road between this pair of cities (we do not know whether is it a clever spy-proof strategy or just saving ink). In other words, if two cities are connected by a road on a flatland map, then there is in fact no road between them. The opposite situation is also true: if two cities are not connected by a road on a flatland map, then in fact, there is a road between them. The berlanders got hold of a flatland map. Now Vasya the Corporal is commissioned by General Touristov to find all such groups of flatland cities, that in each group of cities you can get from any city to any other one, moving along the actual roads. Also the cities from different groups are unreachable from each other, moving along the actual roads. Indeed, destroying such groups one by one is much easier than surrounding all Flatland at once! Help the corporal complete this task and finally become a sergeant! Don't forget that a flatland map shows a road between cities if and only if there is in fact no road between them. Input The first line contains two space-separated integers n and m (1 ≤ n ≤ 5·105, 0 ≤ m ≤ 106) — the number of cities and the number of roads marked on the flatland map, correspondingly. Next m lines contain descriptions of the cities on the map. The i-th line contains two integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — the numbers of cities that are connected by the i-th road on the flatland map. It is guaranteed that each pair of cities occurs in the input no more than once. Output On the first line print number k — the number of groups of cities in Flatland, such that in each group you can get from any city to any other one by flatland roads. At the same time, the cities from different groups should be unreachable by flatland roads. On each of the following k lines first print ti (1 ≤ ti ≤ n) — the number of vertexes in the i-th group. Then print space-separated numbers of cities in the i-th group. The order of printing groups and the order of printing numbers in the groups does not matter. The total sum ti for all k groups must equal n. Examples Input 4 4 1 2 1 3 4 2 4 3 Output 2 2 1 4 2 2 3 Input 3 1 1 2 Output 1 3 1 2 3 Note In the first sample there are roads only between pairs of cities 1-4 and 2-3. In the second sample there is no road between cities 1 and 2, but still you can get from one city to the other one through city number 3. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int maxn = 5 * 1e5 + 1000; vector<int> G[maxn], ans[maxn]; set<int> s; set<int>::iterator ite; int num[maxn], cnt, res; void bfs(int x) { s.erase(x); queue<int> que; ans[res].push_back(x); que.push(x); cnt = 0; while (que.size()) { int cur = que.front(); que.pop(); cnt = 0; for (ite = s.begin(); ite != s.end(); ite++) { int next = *ite; if (!binary_search(G[cur].begin(), G[cur].end(), *ite)) { que.push(next); ans[res].push_back(next); num[cnt++] = next; } } for (int i = 0; i < cnt; i++) s.erase(num[i]); } res++; } int main() { int n, m; while (scanf("%d%d", &n, &m) != EOF) { for (int i = 1; i <= m; i++) { int a, b; scanf("%d%d", &a, &b); G[a].push_back(b); G[b].push_back(a); } for (int i = 1; i <= n; i++) { s.insert(i); sort(G[i].begin(), G[i].end()); } res = 1; for (int i = 1; i <= n; i++) { if (s.count(i)) bfs(i); } printf("%d\n", res - 1); for (int i = 1; i <= res; i++) { if (ans[i].size()) { printf("%d ", ans[i].size()); for (int j = 0; j < ans[i].size(); j++) { if (j == ans[i].size() - 1) printf("%d\n", ans[i][j]); else printf("%d ", ans[i][j]); } } } } return 0; } ```
#include <bits/stdc++.h> using namespace std; vector<int> graph[500005]; set<int> all; int vis[500005]; vector<int> ans[500005]; vector<pair<int, int> > sequence; int n, m, x, y, i, cnt, k = 0; void graph_in() { scanf("%d %d", &n, &m); for (i = 0; i < m; i++) { scanf("%d %d", &x, &y); graph[x].push_back(y); graph[y].push_back(x); } } void init_values() { for (i = 1; i <= n; i++) { all.insert(i); sort(graph[i].begin(), graph[i].end()); } } void bfs(int from) { ans[k].push_back(from); queue<int> q; all.erase(from); q.push(from); vector<int> to_del; vis[from] = 1; int cur, l; while (!q.empty()) { cur = q.front(); q.pop(); for (auto &it : all) { if (!binary_search(graph[cur].begin(), graph[cur].end(), it)) { to_del.push_back(it); ans[k].push_back(it); vis[it] = 1; q.push(it); } } for (l = 0; l < to_del.size(); l++) all.erase(to_del[l]); to_del.clear(); } k++; } void print_ans() { k = 0; int sz; while (ans[k].size()) { printf("%d ", ans[k].size()); for (i = 0; i < ans[k].size(); i++) printf("%d ", ans[k][i]); puts(""); k++; } } int main() { int h; graph_in(); init_values(); for (i = 0; i < n; i++) { if (!vis[i + 1]) { cnt++; bfs(i + 1); } } printf("%d\n", cnt); print_ans(); }
### Prompt Your challenge is to write a cpp solution to the following problem: Berland has managed to repel the flatlanders' attack and is now starting the counter attack. Flatland has n cities, numbered from 1 to n, and some pairs of them are connected by bidirectional roads. The Flatlandian maps show roads between cities if and only if there is in fact no road between this pair of cities (we do not know whether is it a clever spy-proof strategy or just saving ink). In other words, if two cities are connected by a road on a flatland map, then there is in fact no road between them. The opposite situation is also true: if two cities are not connected by a road on a flatland map, then in fact, there is a road between them. The berlanders got hold of a flatland map. Now Vasya the Corporal is commissioned by General Touristov to find all such groups of flatland cities, that in each group of cities you can get from any city to any other one, moving along the actual roads. Also the cities from different groups are unreachable from each other, moving along the actual roads. Indeed, destroying such groups one by one is much easier than surrounding all Flatland at once! Help the corporal complete this task and finally become a sergeant! Don't forget that a flatland map shows a road between cities if and only if there is in fact no road between them. Input The first line contains two space-separated integers n and m (1 ≤ n ≤ 5·105, 0 ≤ m ≤ 106) — the number of cities and the number of roads marked on the flatland map, correspondingly. Next m lines contain descriptions of the cities on the map. The i-th line contains two integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — the numbers of cities that are connected by the i-th road on the flatland map. It is guaranteed that each pair of cities occurs in the input no more than once. Output On the first line print number k — the number of groups of cities in Flatland, such that in each group you can get from any city to any other one by flatland roads. At the same time, the cities from different groups should be unreachable by flatland roads. On each of the following k lines first print ti (1 ≤ ti ≤ n) — the number of vertexes in the i-th group. Then print space-separated numbers of cities in the i-th group. The order of printing groups and the order of printing numbers in the groups does not matter. The total sum ti for all k groups must equal n. Examples Input 4 4 1 2 1 3 4 2 4 3 Output 2 2 1 4 2 2 3 Input 3 1 1 2 Output 1 3 1 2 3 Note In the first sample there are roads only between pairs of cities 1-4 and 2-3. In the second sample there is no road between cities 1 and 2, but still you can get from one city to the other one through city number 3. ### Response ```cpp #include <bits/stdc++.h> using namespace std; vector<int> graph[500005]; set<int> all; int vis[500005]; vector<int> ans[500005]; vector<pair<int, int> > sequence; int n, m, x, y, i, cnt, k = 0; void graph_in() { scanf("%d %d", &n, &m); for (i = 0; i < m; i++) { scanf("%d %d", &x, &y); graph[x].push_back(y); graph[y].push_back(x); } } void init_values() { for (i = 1; i <= n; i++) { all.insert(i); sort(graph[i].begin(), graph[i].end()); } } void bfs(int from) { ans[k].push_back(from); queue<int> q; all.erase(from); q.push(from); vector<int> to_del; vis[from] = 1; int cur, l; while (!q.empty()) { cur = q.front(); q.pop(); for (auto &it : all) { if (!binary_search(graph[cur].begin(), graph[cur].end(), it)) { to_del.push_back(it); ans[k].push_back(it); vis[it] = 1; q.push(it); } } for (l = 0; l < to_del.size(); l++) all.erase(to_del[l]); to_del.clear(); } k++; } void print_ans() { k = 0; int sz; while (ans[k].size()) { printf("%d ", ans[k].size()); for (i = 0; i < ans[k].size(); i++) printf("%d ", ans[k][i]); puts(""); k++; } } int main() { int h; graph_in(); init_values(); for (i = 0; i < n; i++) { if (!vis[i + 1]) { cnt++; bfs(i + 1); } } printf("%d\n", cnt); print_ans(); } ```
#include <bits/stdc++.h> #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("unroll-loops") using namespace std; template <class T> inline T bigmod(T p, T e, T M) { long long ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T)ret; } template <class T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } template <class T> inline T modinverse(T a, T M) { return bigmod(a, M - 2, M); } template <class T> inline T lcm(T a, T b) { a = abs(a); b = abs(b); return (a / gcd(a, b)) * b; } template <class T, class X> inline bool getbit(T a, X i) { T t = 1; return ((a & (t << i)) > 0); } template <class T, class X> inline T setbit(T a, X i) { T t = 1; return (a | (t << i)); } template <class T, class X> inline T resetbit(T a, X i) { T t = 1; return (a & (~(t << i))); } inline long long getnum() { char c = getchar(); long long num, sign = 1; for (; c < '0' || c > '9'; c = getchar()) if (c == '-') sign = -1; for (num = 0; c >= '0' && c <= '9';) { c -= '0'; num = num * 10 + c; c = getchar(); } return num * sign; } inline long long power(long long a, long long b) { long long multiply = 1; for (int i = (0); i < (b); i++) { multiply *= a; } return multiply; } int n, m, cnt = 0; vector<int> take[5 * 100002]; set<int> all; vector<int> forbid[5 * 100002]; void dfs(int u) { all.erase(u); take[cnt].push_back(u); auto it = all.begin(); while (it != all.end()) { int v = *it; if (binary_search(forbid[u].begin(), forbid[u].end(), v)) { it++; continue; } dfs(v); it = all.lower_bound(v); } } int main() { int test, cases = 1; scanf("%d%d", &n, &m); int u, v; for (int i = (0); i < (m); i++) { u = getnum(); v = getnum(); forbid[u].push_back(v); forbid[v].push_back(u); } for (int i = (1); i < (n + 1); i++) all.insert(i), sort(forbid[i].begin(), forbid[i].end()); for (int i = (1); i < (n + 1); i++) { if (all.find(i) != all.end()) { cnt++; dfs(i); } } cout << cnt << "\n"; for (int i = (1); i < (cnt + 1); i++) { printf("%d ", (int)take[i].size()); for (int j = (0); j < (take[i].size()); j++) printf("%d ", take[i][j]); puts(""); } return 0; }
### Prompt Please formulate a CPP solution to the following problem: Berland has managed to repel the flatlanders' attack and is now starting the counter attack. Flatland has n cities, numbered from 1 to n, and some pairs of them are connected by bidirectional roads. The Flatlandian maps show roads between cities if and only if there is in fact no road between this pair of cities (we do not know whether is it a clever spy-proof strategy or just saving ink). In other words, if two cities are connected by a road on a flatland map, then there is in fact no road between them. The opposite situation is also true: if two cities are not connected by a road on a flatland map, then in fact, there is a road between them. The berlanders got hold of a flatland map. Now Vasya the Corporal is commissioned by General Touristov to find all such groups of flatland cities, that in each group of cities you can get from any city to any other one, moving along the actual roads. Also the cities from different groups are unreachable from each other, moving along the actual roads. Indeed, destroying such groups one by one is much easier than surrounding all Flatland at once! Help the corporal complete this task and finally become a sergeant! Don't forget that a flatland map shows a road between cities if and only if there is in fact no road between them. Input The first line contains two space-separated integers n and m (1 ≤ n ≤ 5·105, 0 ≤ m ≤ 106) — the number of cities and the number of roads marked on the flatland map, correspondingly. Next m lines contain descriptions of the cities on the map. The i-th line contains two integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — the numbers of cities that are connected by the i-th road on the flatland map. It is guaranteed that each pair of cities occurs in the input no more than once. Output On the first line print number k — the number of groups of cities in Flatland, such that in each group you can get from any city to any other one by flatland roads. At the same time, the cities from different groups should be unreachable by flatland roads. On each of the following k lines first print ti (1 ≤ ti ≤ n) — the number of vertexes in the i-th group. Then print space-separated numbers of cities in the i-th group. The order of printing groups and the order of printing numbers in the groups does not matter. The total sum ti for all k groups must equal n. Examples Input 4 4 1 2 1 3 4 2 4 3 Output 2 2 1 4 2 2 3 Input 3 1 1 2 Output 1 3 1 2 3 Note In the first sample there are roads only between pairs of cities 1-4 and 2-3. In the second sample there is no road between cities 1 and 2, but still you can get from one city to the other one through city number 3. ### Response ```cpp #include <bits/stdc++.h> #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("unroll-loops") using namespace std; template <class T> inline T bigmod(T p, T e, T M) { long long ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T)ret; } template <class T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } template <class T> inline T modinverse(T a, T M) { return bigmod(a, M - 2, M); } template <class T> inline T lcm(T a, T b) { a = abs(a); b = abs(b); return (a / gcd(a, b)) * b; } template <class T, class X> inline bool getbit(T a, X i) { T t = 1; return ((a & (t << i)) > 0); } template <class T, class X> inline T setbit(T a, X i) { T t = 1; return (a | (t << i)); } template <class T, class X> inline T resetbit(T a, X i) { T t = 1; return (a & (~(t << i))); } inline long long getnum() { char c = getchar(); long long num, sign = 1; for (; c < '0' || c > '9'; c = getchar()) if (c == '-') sign = -1; for (num = 0; c >= '0' && c <= '9';) { c -= '0'; num = num * 10 + c; c = getchar(); } return num * sign; } inline long long power(long long a, long long b) { long long multiply = 1; for (int i = (0); i < (b); i++) { multiply *= a; } return multiply; } int n, m, cnt = 0; vector<int> take[5 * 100002]; set<int> all; vector<int> forbid[5 * 100002]; void dfs(int u) { all.erase(u); take[cnt].push_back(u); auto it = all.begin(); while (it != all.end()) { int v = *it; if (binary_search(forbid[u].begin(), forbid[u].end(), v)) { it++; continue; } dfs(v); it = all.lower_bound(v); } } int main() { int test, cases = 1; scanf("%d%d", &n, &m); int u, v; for (int i = (0); i < (m); i++) { u = getnum(); v = getnum(); forbid[u].push_back(v); forbid[v].push_back(u); } for (int i = (1); i < (n + 1); i++) all.insert(i), sort(forbid[i].begin(), forbid[i].end()); for (int i = (1); i < (n + 1); i++) { if (all.find(i) != all.end()) { cnt++; dfs(i); } } cout << cnt << "\n"; for (int i = (1); i < (cnt + 1); i++) { printf("%d ", (int)take[i].size()); for (int j = (0); j < (take[i].size()); j++) printf("%d ", take[i][j]); puts(""); } return 0; } ```
#include <bits/stdc++.h> using namespace std; int i, j, n, m; int ind[500010], last[1000100 * 2], e[1000100 * 2], t; void adde(int a, int b) { t++; e[t] = b; last[t] = ind[a]; ind[a] = t; } vector<int> nxt[2]; vector<int> pp; int ha[500010]; int que[500010], qt; int nt; struct Myset { int ind[500010]; int last[500010]; int e[500010]; int t; int n; void inc() { n++; } void add(int b) { add(n, b); } void add(int a, int b) { t++; last[t] = ind[a]; e[t] = b; ind[a] = t; } void output() { printf("%d\n", n); int num; for (i = 1; i <= n; i++) { num = 0; for (j = ind[i]; j; j = last[j]) { num++; } printf("%d", num); for (j = ind[i]; j; j = last[j]) { printf(" %d", e[j]); } printf("\n"); } } } myset; void make2(set<int>& p) { while (p.size()) { pp.clear(); nxt[nt].push_back(*p.begin()); p.erase(p.begin()); myset.inc(); while (nxt[nt].size()) { for (auto i : nxt[nt]) { myset.add(i); } vector<int>& nextnext = nxt[1 - nt]; for (auto ii : nxt[nt]) { for (i = ind[ii]; i; i = last[i]) { if (p.count(e[i])) { pp.push_back(e[i]); p.erase(e[i]); } } for (auto jj : p) { nextnext.push_back(jj); } p.clear(); p.insert(pp.begin(), pp.end()); pp.clear(); } nxt[nt].clear(); nt = 1 - nt; } } } void make() { int depth = 0; for (i = 1; i <= n; i++) { que[i] = i; } qt = n; while (qt) { myset.inc(); int lastnext = 0; myset.add(que[qt]); qt--; while (myset.ind[myset.n] != lastnext) { i = myset.ind[myset.n]; while (i != lastnext) { depth++; for (j = ind[myset.e[i]]; j; j = last[j]) { ha[e[j]]++; } i = myset.last[i]; } lastnext = myset.ind[myset.n]; i = 1; while (i <= qt) { if (ha[que[i]] != depth) { myset.add(que[i]); swap(que[i], que[qt]); qt--; } else { i++; } } } } } int main() { scanf("%d %d", &n, &m); int a, b; while (m--) { scanf("%d %d", &a, &b); adde(a, b); adde(b, a); } make(); myset.output(); return 0; }
### Prompt Your challenge is to write a cpp solution to the following problem: Berland has managed to repel the flatlanders' attack and is now starting the counter attack. Flatland has n cities, numbered from 1 to n, and some pairs of them are connected by bidirectional roads. The Flatlandian maps show roads between cities if and only if there is in fact no road between this pair of cities (we do not know whether is it a clever spy-proof strategy or just saving ink). In other words, if two cities are connected by a road on a flatland map, then there is in fact no road between them. The opposite situation is also true: if two cities are not connected by a road on a flatland map, then in fact, there is a road between them. The berlanders got hold of a flatland map. Now Vasya the Corporal is commissioned by General Touristov to find all such groups of flatland cities, that in each group of cities you can get from any city to any other one, moving along the actual roads. Also the cities from different groups are unreachable from each other, moving along the actual roads. Indeed, destroying such groups one by one is much easier than surrounding all Flatland at once! Help the corporal complete this task and finally become a sergeant! Don't forget that a flatland map shows a road between cities if and only if there is in fact no road between them. Input The first line contains two space-separated integers n and m (1 ≤ n ≤ 5·105, 0 ≤ m ≤ 106) — the number of cities and the number of roads marked on the flatland map, correspondingly. Next m lines contain descriptions of the cities on the map. The i-th line contains two integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — the numbers of cities that are connected by the i-th road on the flatland map. It is guaranteed that each pair of cities occurs in the input no more than once. Output On the first line print number k — the number of groups of cities in Flatland, such that in each group you can get from any city to any other one by flatland roads. At the same time, the cities from different groups should be unreachable by flatland roads. On each of the following k lines first print ti (1 ≤ ti ≤ n) — the number of vertexes in the i-th group. Then print space-separated numbers of cities in the i-th group. The order of printing groups and the order of printing numbers in the groups does not matter. The total sum ti for all k groups must equal n. Examples Input 4 4 1 2 1 3 4 2 4 3 Output 2 2 1 4 2 2 3 Input 3 1 1 2 Output 1 3 1 2 3 Note In the first sample there are roads only between pairs of cities 1-4 and 2-3. In the second sample there is no road between cities 1 and 2, but still you can get from one city to the other one through city number 3. ### Response ```cpp #include <bits/stdc++.h> using namespace std; int i, j, n, m; int ind[500010], last[1000100 * 2], e[1000100 * 2], t; void adde(int a, int b) { t++; e[t] = b; last[t] = ind[a]; ind[a] = t; } vector<int> nxt[2]; vector<int> pp; int ha[500010]; int que[500010], qt; int nt; struct Myset { int ind[500010]; int last[500010]; int e[500010]; int t; int n; void inc() { n++; } void add(int b) { add(n, b); } void add(int a, int b) { t++; last[t] = ind[a]; e[t] = b; ind[a] = t; } void output() { printf("%d\n", n); int num; for (i = 1; i <= n; i++) { num = 0; for (j = ind[i]; j; j = last[j]) { num++; } printf("%d", num); for (j = ind[i]; j; j = last[j]) { printf(" %d", e[j]); } printf("\n"); } } } myset; void make2(set<int>& p) { while (p.size()) { pp.clear(); nxt[nt].push_back(*p.begin()); p.erase(p.begin()); myset.inc(); while (nxt[nt].size()) { for (auto i : nxt[nt]) { myset.add(i); } vector<int>& nextnext = nxt[1 - nt]; for (auto ii : nxt[nt]) { for (i = ind[ii]; i; i = last[i]) { if (p.count(e[i])) { pp.push_back(e[i]); p.erase(e[i]); } } for (auto jj : p) { nextnext.push_back(jj); } p.clear(); p.insert(pp.begin(), pp.end()); pp.clear(); } nxt[nt].clear(); nt = 1 - nt; } } } void make() { int depth = 0; for (i = 1; i <= n; i++) { que[i] = i; } qt = n; while (qt) { myset.inc(); int lastnext = 0; myset.add(que[qt]); qt--; while (myset.ind[myset.n] != lastnext) { i = myset.ind[myset.n]; while (i != lastnext) { depth++; for (j = ind[myset.e[i]]; j; j = last[j]) { ha[e[j]]++; } i = myset.last[i]; } lastnext = myset.ind[myset.n]; i = 1; while (i <= qt) { if (ha[que[i]] != depth) { myset.add(que[i]); swap(que[i], que[qt]); qt--; } else { i++; } } } } } int main() { scanf("%d %d", &n, &m); int a, b; while (m--) { scanf("%d %d", &a, &b); adde(a, b); adde(b, a); } make(); myset.output(); return 0; } ```
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 5; vector<int> graf[maxn], pos[maxn]; int main() { int n, m; scanf("%d %d", &n, &m); while (m--) { int a, b; scanf("%d %d", &a, &b); graf[a].push_back(b); graf[b].push_back(a); } for (int i = 1; i <= n; ++i) sort(graf[i].begin(), graf[i].end()); set<int> cand; for (int i = 1; i <= n; ++i) cand.insert(i); int c = 0; while (cand.size()) { int s = *cand.begin(); cand.erase(s); ++c; pos[c].push_back(s); queue<int> q; q.push(s); while (q.size()) { int x = q.front(); q.pop(); auto it = cand.begin(); while (it != cand.end()) { if (graf[x].size() > 0 && graf[x].back() >= *it && *(lower_bound(graf[x].begin(), graf[x].end(), *it)) == *it) { ++it; continue; } pos[c].push_back(*it); q.push(*it); it = cand.erase(it); } } } printf("%d\n", c); for (int i = 1; i <= c; ++i) { printf("%d ", pos[i].size()); for (int j = 0; j < pos[i].size(); ++j) printf("%d ", pos[i][j]); puts(""); } return 0; }
### Prompt Develop a solution in Cpp to the problem described below: Berland has managed to repel the flatlanders' attack and is now starting the counter attack. Flatland has n cities, numbered from 1 to n, and some pairs of them are connected by bidirectional roads. The Flatlandian maps show roads between cities if and only if there is in fact no road between this pair of cities (we do not know whether is it a clever spy-proof strategy or just saving ink). In other words, if two cities are connected by a road on a flatland map, then there is in fact no road between them. The opposite situation is also true: if two cities are not connected by a road on a flatland map, then in fact, there is a road between them. The berlanders got hold of a flatland map. Now Vasya the Corporal is commissioned by General Touristov to find all such groups of flatland cities, that in each group of cities you can get from any city to any other one, moving along the actual roads. Also the cities from different groups are unreachable from each other, moving along the actual roads. Indeed, destroying such groups one by one is much easier than surrounding all Flatland at once! Help the corporal complete this task and finally become a sergeant! Don't forget that a flatland map shows a road between cities if and only if there is in fact no road between them. Input The first line contains two space-separated integers n and m (1 ≤ n ≤ 5·105, 0 ≤ m ≤ 106) — the number of cities and the number of roads marked on the flatland map, correspondingly. Next m lines contain descriptions of the cities on the map. The i-th line contains two integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — the numbers of cities that are connected by the i-th road on the flatland map. It is guaranteed that each pair of cities occurs in the input no more than once. Output On the first line print number k — the number of groups of cities in Flatland, such that in each group you can get from any city to any other one by flatland roads. At the same time, the cities from different groups should be unreachable by flatland roads. On each of the following k lines first print ti (1 ≤ ti ≤ n) — the number of vertexes in the i-th group. Then print space-separated numbers of cities in the i-th group. The order of printing groups and the order of printing numbers in the groups does not matter. The total sum ti for all k groups must equal n. Examples Input 4 4 1 2 1 3 4 2 4 3 Output 2 2 1 4 2 2 3 Input 3 1 1 2 Output 1 3 1 2 3 Note In the first sample there are roads only between pairs of cities 1-4 and 2-3. In the second sample there is no road between cities 1 and 2, but still you can get from one city to the other one through city number 3. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 5; vector<int> graf[maxn], pos[maxn]; int main() { int n, m; scanf("%d %d", &n, &m); while (m--) { int a, b; scanf("%d %d", &a, &b); graf[a].push_back(b); graf[b].push_back(a); } for (int i = 1; i <= n; ++i) sort(graf[i].begin(), graf[i].end()); set<int> cand; for (int i = 1; i <= n; ++i) cand.insert(i); int c = 0; while (cand.size()) { int s = *cand.begin(); cand.erase(s); ++c; pos[c].push_back(s); queue<int> q; q.push(s); while (q.size()) { int x = q.front(); q.pop(); auto it = cand.begin(); while (it != cand.end()) { if (graf[x].size() > 0 && graf[x].back() >= *it && *(lower_bound(graf[x].begin(), graf[x].end(), *it)) == *it) { ++it; continue; } pos[c].push_back(*it); q.push(*it); it = cand.erase(it); } } } printf("%d\n", c); for (int i = 1; i <= c; ++i) { printf("%d ", pos[i].size()); for (int j = 0; j < pos[i].size(); ++j) printf("%d ", pos[i][j]); puts(""); } return 0; } ```
#include <bits/stdc++.h> using namespace std; const int maxn = 500010; int pa[maxn], sz[maxn]; vector<int> e[maxn]; set<int> grp, tmp; map<int, int> lft; int getpa(int u) { return u == pa[u] ? u : (pa[u] = getpa(pa[u])); } int main() { int n, m; while (~scanf("%d%d", &n, &m)) { grp.clear(); for (int i = 0; i < (n); ++i) pa[i] = i, sz[i] = 1, e[i].clear(), grp.insert(i); for (int i = 0; i < (m); ++i) { int a, b; scanf("%d%d", &a, &b); a--, b--; e[a].push_back(b), e[b].push_back(a); } for (int i = 0; i < (n); ++i) { sort(e[i].begin(), e[i].end()); e[i].resize(unique(e[i].begin(), e[i].end()) - e[i].begin()); } for (int i = 0; i < (n); ++i) { lft.clear(); for (int j = 0; j < (e[i].size()); ++j) lft[getpa(e[i][j])]++; tmp = grp; for (typeof((grp).begin()) it = (grp).begin(); it != (grp).end(); ++it) if (tmp.find(*it) != tmp.end() && lft[*it] < sz[*it]) { int p1 = getpa(i), p2 = *it; if (p1 != p2) { sz[p1] += sz[p2], pa[p2] = p1; tmp.erase(p2); } } grp = tmp; } for (int i = 0; i < (n); ++i) e[i].clear(); int tot = 0; for (int i = 0; i < (n); ++i) { e[getpa(i)].push_back(i); if (getpa(i) == i) tot++; } printf("%d\n", tot); for (int i = 0; i < (n); ++i) if (e[i].size() > 0) { sort(e[i].begin(), e[i].end()); printf("%d", e[i].size()); for (int j = 0; j < (e[i].size()); ++j) printf(" %d", e[i][j] + 1); puts(""); } } return 0; }
### Prompt Please create a solution in CPP to the following problem: Berland has managed to repel the flatlanders' attack and is now starting the counter attack. Flatland has n cities, numbered from 1 to n, and some pairs of them are connected by bidirectional roads. The Flatlandian maps show roads between cities if and only if there is in fact no road between this pair of cities (we do not know whether is it a clever spy-proof strategy or just saving ink). In other words, if two cities are connected by a road on a flatland map, then there is in fact no road between them. The opposite situation is also true: if two cities are not connected by a road on a flatland map, then in fact, there is a road between them. The berlanders got hold of a flatland map. Now Vasya the Corporal is commissioned by General Touristov to find all such groups of flatland cities, that in each group of cities you can get from any city to any other one, moving along the actual roads. Also the cities from different groups are unreachable from each other, moving along the actual roads. Indeed, destroying such groups one by one is much easier than surrounding all Flatland at once! Help the corporal complete this task and finally become a sergeant! Don't forget that a flatland map shows a road between cities if and only if there is in fact no road between them. Input The first line contains two space-separated integers n and m (1 ≤ n ≤ 5·105, 0 ≤ m ≤ 106) — the number of cities and the number of roads marked on the flatland map, correspondingly. Next m lines contain descriptions of the cities on the map. The i-th line contains two integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — the numbers of cities that are connected by the i-th road on the flatland map. It is guaranteed that each pair of cities occurs in the input no more than once. Output On the first line print number k — the number of groups of cities in Flatland, such that in each group you can get from any city to any other one by flatland roads. At the same time, the cities from different groups should be unreachable by flatland roads. On each of the following k lines first print ti (1 ≤ ti ≤ n) — the number of vertexes in the i-th group. Then print space-separated numbers of cities in the i-th group. The order of printing groups and the order of printing numbers in the groups does not matter. The total sum ti for all k groups must equal n. Examples Input 4 4 1 2 1 3 4 2 4 3 Output 2 2 1 4 2 2 3 Input 3 1 1 2 Output 1 3 1 2 3 Note In the first sample there are roads only between pairs of cities 1-4 and 2-3. In the second sample there is no road between cities 1 and 2, but still you can get from one city to the other one through city number 3. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int maxn = 500010; int pa[maxn], sz[maxn]; vector<int> e[maxn]; set<int> grp, tmp; map<int, int> lft; int getpa(int u) { return u == pa[u] ? u : (pa[u] = getpa(pa[u])); } int main() { int n, m; while (~scanf("%d%d", &n, &m)) { grp.clear(); for (int i = 0; i < (n); ++i) pa[i] = i, sz[i] = 1, e[i].clear(), grp.insert(i); for (int i = 0; i < (m); ++i) { int a, b; scanf("%d%d", &a, &b); a--, b--; e[a].push_back(b), e[b].push_back(a); } for (int i = 0; i < (n); ++i) { sort(e[i].begin(), e[i].end()); e[i].resize(unique(e[i].begin(), e[i].end()) - e[i].begin()); } for (int i = 0; i < (n); ++i) { lft.clear(); for (int j = 0; j < (e[i].size()); ++j) lft[getpa(e[i][j])]++; tmp = grp; for (typeof((grp).begin()) it = (grp).begin(); it != (grp).end(); ++it) if (tmp.find(*it) != tmp.end() && lft[*it] < sz[*it]) { int p1 = getpa(i), p2 = *it; if (p1 != p2) { sz[p1] += sz[p2], pa[p2] = p1; tmp.erase(p2); } } grp = tmp; } for (int i = 0; i < (n); ++i) e[i].clear(); int tot = 0; for (int i = 0; i < (n); ++i) { e[getpa(i)].push_back(i); if (getpa(i) == i) tot++; } printf("%d\n", tot); for (int i = 0; i < (n); ++i) if (e[i].size() > 0) { sort(e[i].begin(), e[i].end()); printf("%d", e[i].size()); for (int j = 0; j < (e[i].size()); ++j) printf(" %d", e[i][j] + 1); puts(""); } } return 0; } ```
#include <bits/stdc++.h> using namespace std; long long modpow(long long a, long long b, long long mod = (long long)(1e9 + 7)) { if (!b) return 1; a %= mod; return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod; } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int mxn = 5e5; int n, m; deque<int> nxt; unordered_set<int> adj[mxn]; void bfs(int v, vector<int> &st) { queue<int> pq; pq.push(v); while (pq.size()) { int x = pq.front(); pq.pop(); st.push_back(x); int sz = int((nxt).size()); while (sz--) { int w = nxt.back(); nxt.pop_back(); if (adj[x].count(w)) nxt.push_front(w); else pq.push(w); } } } void solve() { scanf("%d", &n); scanf("%d", &m); for (int i = 0; i < n; i++) nxt.push_back(i); for (int _ = 0; _ < m; _++) { int x, y; scanf("%d", &x); scanf("%d", &y); adj[--x].insert(--y); adj[y].insert(x); } int sz = 0; stringstream ss; while (!nxt.empty()) { int i = nxt.back(); nxt.pop_back(); vector<int> st; bfs(i, st); ss << st.size(); for (int w : st) ss << " " << w + 1; ss << endl; sz++; } cout << sz << endl; cout << ss.str(); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); return 0; }
### Prompt Please provide a cpp coded solution to the problem described below: Berland has managed to repel the flatlanders' attack and is now starting the counter attack. Flatland has n cities, numbered from 1 to n, and some pairs of them are connected by bidirectional roads. The Flatlandian maps show roads between cities if and only if there is in fact no road between this pair of cities (we do not know whether is it a clever spy-proof strategy or just saving ink). In other words, if two cities are connected by a road on a flatland map, then there is in fact no road between them. The opposite situation is also true: if two cities are not connected by a road on a flatland map, then in fact, there is a road between them. The berlanders got hold of a flatland map. Now Vasya the Corporal is commissioned by General Touristov to find all such groups of flatland cities, that in each group of cities you can get from any city to any other one, moving along the actual roads. Also the cities from different groups are unreachable from each other, moving along the actual roads. Indeed, destroying such groups one by one is much easier than surrounding all Flatland at once! Help the corporal complete this task and finally become a sergeant! Don't forget that a flatland map shows a road between cities if and only if there is in fact no road between them. Input The first line contains two space-separated integers n and m (1 ≤ n ≤ 5·105, 0 ≤ m ≤ 106) — the number of cities and the number of roads marked on the flatland map, correspondingly. Next m lines contain descriptions of the cities on the map. The i-th line contains two integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — the numbers of cities that are connected by the i-th road on the flatland map. It is guaranteed that each pair of cities occurs in the input no more than once. Output On the first line print number k — the number of groups of cities in Flatland, such that in each group you can get from any city to any other one by flatland roads. At the same time, the cities from different groups should be unreachable by flatland roads. On each of the following k lines first print ti (1 ≤ ti ≤ n) — the number of vertexes in the i-th group. Then print space-separated numbers of cities in the i-th group. The order of printing groups and the order of printing numbers in the groups does not matter. The total sum ti for all k groups must equal n. Examples Input 4 4 1 2 1 3 4 2 4 3 Output 2 2 1 4 2 2 3 Input 3 1 1 2 Output 1 3 1 2 3 Note In the first sample there are roads only between pairs of cities 1-4 and 2-3. In the second sample there is no road between cities 1 and 2, but still you can get from one city to the other one through city number 3. ### Response ```cpp #include <bits/stdc++.h> using namespace std; long long modpow(long long a, long long b, long long mod = (long long)(1e9 + 7)) { if (!b) return 1; a %= mod; return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod; } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int mxn = 5e5; int n, m; deque<int> nxt; unordered_set<int> adj[mxn]; void bfs(int v, vector<int> &st) { queue<int> pq; pq.push(v); while (pq.size()) { int x = pq.front(); pq.pop(); st.push_back(x); int sz = int((nxt).size()); while (sz--) { int w = nxt.back(); nxt.pop_back(); if (adj[x].count(w)) nxt.push_front(w); else pq.push(w); } } } void solve() { scanf("%d", &n); scanf("%d", &m); for (int i = 0; i < n; i++) nxt.push_back(i); for (int _ = 0; _ < m; _++) { int x, y; scanf("%d", &x); scanf("%d", &y); adj[--x].insert(--y); adj[y].insert(x); } int sz = 0; stringstream ss; while (!nxt.empty()) { int i = nxt.back(); nxt.pop_back(); vector<int> st; bfs(i, st); ss << st.size(); for (int w : st) ss << " " << w + 1; ss << endl; sz++; } cout << sz << endl; cout << ss.str(); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); return 0; } ```
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; const int maxn5 = 5e5 + 10; const int maxnt = 1.2e6 + 10; const int maxn3 = 1e3 + 10; const long long mod = 1e9 + 7; const long long inf = 2e18; int st, cmp[maxn5], nxt[maxn5], pre[maxn5]; vector<int> adj[maxn5], ver[maxn5]; bool mark[maxn5]; void join(int a, int b) { if (ver[a].size() > ver[b].size()) swap(a, b); for (auto u : ver[a]) { cmp[u] = b; ver[b].push_back(u); } if (a == st) { st = nxt[a]; pre[nxt[a]] = -1; } else { if (nxt[a] != -1) pre[nxt[a]] = pre[a]; nxt[pre[a]] = nxt[a]; } ver[a].clear(); return; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; adj[a].push_back(b); adj[b].push_back(a); } for (int i = 1; i <= n; i++) { cmp[i] = i; ver[i].push_back(i); pre[i] = i == 1 ? -1 : i - 1; nxt[i] = i == n ? -1 : i + 1; } st = 1; for (int i = 1; i <= n; i++) { int ind = st; for (auto u : adj[i]) mark[u] = true; while (ind != -1) { if (ind == cmp[i]) { ind = nxt[ind]; continue; } bool done = false; for (auto u : ver[ind]) if (!mark[u]) { int c = ind; ind = nxt[ind]; done = true; join(c, cmp[i]); break; } if (!done) ind = nxt[ind]; } for (auto u : adj[i]) mark[u] = false; } int cnt = 0, ind = st; while (ind != -1) { cnt++; ind = nxt[ind]; } cout << cnt << '\n'; while (st != -1) { cout << ver[st].size() << ' '; for (auto u : ver[st]) cout << u << ' '; cout << '\n'; st = nxt[st]; } return 0; }
### Prompt Please create a solution in Cpp to the following problem: Berland has managed to repel the flatlanders' attack and is now starting the counter attack. Flatland has n cities, numbered from 1 to n, and some pairs of them are connected by bidirectional roads. The Flatlandian maps show roads between cities if and only if there is in fact no road between this pair of cities (we do not know whether is it a clever spy-proof strategy or just saving ink). In other words, if two cities are connected by a road on a flatland map, then there is in fact no road between them. The opposite situation is also true: if two cities are not connected by a road on a flatland map, then in fact, there is a road between them. The berlanders got hold of a flatland map. Now Vasya the Corporal is commissioned by General Touristov to find all such groups of flatland cities, that in each group of cities you can get from any city to any other one, moving along the actual roads. Also the cities from different groups are unreachable from each other, moving along the actual roads. Indeed, destroying such groups one by one is much easier than surrounding all Flatland at once! Help the corporal complete this task and finally become a sergeant! Don't forget that a flatland map shows a road between cities if and only if there is in fact no road between them. Input The first line contains two space-separated integers n and m (1 ≤ n ≤ 5·105, 0 ≤ m ≤ 106) — the number of cities and the number of roads marked on the flatland map, correspondingly. Next m lines contain descriptions of the cities on the map. The i-th line contains two integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — the numbers of cities that are connected by the i-th road on the flatland map. It is guaranteed that each pair of cities occurs in the input no more than once. Output On the first line print number k — the number of groups of cities in Flatland, such that in each group you can get from any city to any other one by flatland roads. At the same time, the cities from different groups should be unreachable by flatland roads. On each of the following k lines first print ti (1 ≤ ti ≤ n) — the number of vertexes in the i-th group. Then print space-separated numbers of cities in the i-th group. The order of printing groups and the order of printing numbers in the groups does not matter. The total sum ti for all k groups must equal n. Examples Input 4 4 1 2 1 3 4 2 4 3 Output 2 2 1 4 2 2 3 Input 3 1 1 2 Output 1 3 1 2 3 Note In the first sample there are roads only between pairs of cities 1-4 and 2-3. In the second sample there is no road between cities 1 and 2, but still you can get from one city to the other one through city number 3. ### Response ```cpp #include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; const int maxn5 = 5e5 + 10; const int maxnt = 1.2e6 + 10; const int maxn3 = 1e3 + 10; const long long mod = 1e9 + 7; const long long inf = 2e18; int st, cmp[maxn5], nxt[maxn5], pre[maxn5]; vector<int> adj[maxn5], ver[maxn5]; bool mark[maxn5]; void join(int a, int b) { if (ver[a].size() > ver[b].size()) swap(a, b); for (auto u : ver[a]) { cmp[u] = b; ver[b].push_back(u); } if (a == st) { st = nxt[a]; pre[nxt[a]] = -1; } else { if (nxt[a] != -1) pre[nxt[a]] = pre[a]; nxt[pre[a]] = nxt[a]; } ver[a].clear(); return; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; adj[a].push_back(b); adj[b].push_back(a); } for (int i = 1; i <= n; i++) { cmp[i] = i; ver[i].push_back(i); pre[i] = i == 1 ? -1 : i - 1; nxt[i] = i == n ? -1 : i + 1; } st = 1; for (int i = 1; i <= n; i++) { int ind = st; for (auto u : adj[i]) mark[u] = true; while (ind != -1) { if (ind == cmp[i]) { ind = nxt[ind]; continue; } bool done = false; for (auto u : ver[ind]) if (!mark[u]) { int c = ind; ind = nxt[ind]; done = true; join(c, cmp[i]); break; } if (!done) ind = nxt[ind]; } for (auto u : adj[i]) mark[u] = false; } int cnt = 0, ind = st; while (ind != -1) { cnt++; ind = nxt[ind]; } cout << cnt << '\n'; while (st != -1) { cout << ver[st].size() << ' '; for (auto u : ver[st]) cout << u << ' '; cout << '\n'; st = nxt[st]; } return 0; } ```
#include <bits/stdc++.h> using namespace std; vector<int> graph[500005]; set<int> all; int vis[500005]; vector<int> ans[500005]; vector<pair<int, int> > sequence; int n, m, x, y, i, cnt, k = 0; void graph_in() { scanf("%d %d", &n, &m); for (i = 0; i < m; i++) { scanf("%d %d", &x, &y); graph[x].push_back(y); graph[y].push_back(x); } } void init_values() { for (i = 1; i <= n; i++) { all.insert(i); sort(graph[i].begin(), graph[i].end()); } } queue<int> q; void bfs(int from) { ans[k].push_back(from); all.erase(from); q.push(from); vector<int> to_del; vis[from] = 1; int cur, l; while (!q.empty()) { cur = q.front(); q.pop(); for (auto &it : all) { if (binary_search(graph[cur].begin(), graph[cur].end(), it)) continue; else { to_del.push_back(it); ans[k].push_back(it); vis[it] = 1; q.push(it); } } for (l = 0; l < to_del.size(); l++) all.erase(to_del[l]); to_del.clear(); } k++; } void print_ans() { k = 0; int sz; while (ans[k].size()) { sz = ans[k].size(); printf("%d ", sz); for (i = 0; i < sz; i++) printf("%d ", ans[k][i]); puts(""); k++; } } int main() { int h; graph_in(); init_values(); for (i = 0; i < n; i++) { if (!vis[i + 1]) { cnt++; bfs(i + 1); } } printf("%d\n", cnt); print_ans(); }
### Prompt Your challenge is to write a Cpp solution to the following problem: Berland has managed to repel the flatlanders' attack and is now starting the counter attack. Flatland has n cities, numbered from 1 to n, and some pairs of them are connected by bidirectional roads. The Flatlandian maps show roads between cities if and only if there is in fact no road between this pair of cities (we do not know whether is it a clever spy-proof strategy or just saving ink). In other words, if two cities are connected by a road on a flatland map, then there is in fact no road between them. The opposite situation is also true: if two cities are not connected by a road on a flatland map, then in fact, there is a road between them. The berlanders got hold of a flatland map. Now Vasya the Corporal is commissioned by General Touristov to find all such groups of flatland cities, that in each group of cities you can get from any city to any other one, moving along the actual roads. Also the cities from different groups are unreachable from each other, moving along the actual roads. Indeed, destroying such groups one by one is much easier than surrounding all Flatland at once! Help the corporal complete this task and finally become a sergeant! Don't forget that a flatland map shows a road between cities if and only if there is in fact no road between them. Input The first line contains two space-separated integers n and m (1 ≤ n ≤ 5·105, 0 ≤ m ≤ 106) — the number of cities and the number of roads marked on the flatland map, correspondingly. Next m lines contain descriptions of the cities on the map. The i-th line contains two integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — the numbers of cities that are connected by the i-th road on the flatland map. It is guaranteed that each pair of cities occurs in the input no more than once. Output On the first line print number k — the number of groups of cities in Flatland, such that in each group you can get from any city to any other one by flatland roads. At the same time, the cities from different groups should be unreachable by flatland roads. On each of the following k lines first print ti (1 ≤ ti ≤ n) — the number of vertexes in the i-th group. Then print space-separated numbers of cities in the i-th group. The order of printing groups and the order of printing numbers in the groups does not matter. The total sum ti for all k groups must equal n. Examples Input 4 4 1 2 1 3 4 2 4 3 Output 2 2 1 4 2 2 3 Input 3 1 1 2 Output 1 3 1 2 3 Note In the first sample there are roads only between pairs of cities 1-4 and 2-3. In the second sample there is no road between cities 1 and 2, but still you can get from one city to the other one through city number 3. ### Response ```cpp #include <bits/stdc++.h> using namespace std; vector<int> graph[500005]; set<int> all; int vis[500005]; vector<int> ans[500005]; vector<pair<int, int> > sequence; int n, m, x, y, i, cnt, k = 0; void graph_in() { scanf("%d %d", &n, &m); for (i = 0; i < m; i++) { scanf("%d %d", &x, &y); graph[x].push_back(y); graph[y].push_back(x); } } void init_values() { for (i = 1; i <= n; i++) { all.insert(i); sort(graph[i].begin(), graph[i].end()); } } queue<int> q; void bfs(int from) { ans[k].push_back(from); all.erase(from); q.push(from); vector<int> to_del; vis[from] = 1; int cur, l; while (!q.empty()) { cur = q.front(); q.pop(); for (auto &it : all) { if (binary_search(graph[cur].begin(), graph[cur].end(), it)) continue; else { to_del.push_back(it); ans[k].push_back(it); vis[it] = 1; q.push(it); } } for (l = 0; l < to_del.size(); l++) all.erase(to_del[l]); to_del.clear(); } k++; } void print_ans() { k = 0; int sz; while (ans[k].size()) { sz = ans[k].size(); printf("%d ", sz); for (i = 0; i < sz; i++) printf("%d ", ans[k][i]); puts(""); k++; } } int main() { int h; graph_in(); init_values(); for (i = 0; i < n; i++) { if (!vis[i + 1]) { cnt++; bfs(i + 1); } } printf("%d\n", cnt); print_ans(); } ```