output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int a, b, c, d; cin >> a >> b >> c >> d; if (a <= c && b <= d) cout << "Polycarp"; else if (a + b <= c + d - min(c, d)) cout << "Polycarp"; else cout << "Vasiliy"; }
### Prompt Develop a solution in Cpp to the problem described below: Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y)...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; if (a + b <= max(c, d) || a < c && b - 1 < d || a - 1 < c && b < d) { puts("Polycarp"); } else { puts("Vasiliy"); } return 0; }
### Prompt Your task is to create a CPP solution to the following problem: Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x -...
#include <bits/stdc++.h> using namespace std; void outputSmallest(int pd, int vd) { if (pd <= vd) { cout << "Polycarp"; } else { cout << "Vasiliy"; } } int main() { int px, py, vx, vy; cin >> px >> py >> vx >> vy; int pd = px + py; int vd = max(vx, vy); int cx, cy, cd; if (vy - vx > py - px) {...
### Prompt Your challenge is to write a Cpp solution to the following problem: Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to ...
#include <bits/stdc++.h> using namespace std; int xp, yp, xd, yd; int main() { cin.sync_with_stdio(false); cin >> xp >> yp >> xd >> yd; while (true) { if (xp <= xd && yp <= yd) { cout << "Polycarp"; return 0; } if (xp > xd) xp--; else yp--; if (xp == 0 && yp == 0) { ...
### Prompt Develop a solution in cpp to the problem described below: Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y)...
#include <bits/stdc++.h> using namespace std; int main() { int xp, yp, xv, yv; scanf("%d %d %d %d", &xp, &yp, &xv, &yv); if (((xp + yp) <= max(xv, yv)) || ((xp <= xv) && (yp <= yv))) printf("Polycarp"); else printf("Vasiliy"); return 0; }
### Prompt In CPP, your task is to solve the following problem: Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y) or (...
#include <bits/stdc++.h> using namespace std; int main() { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; bool f = 0; if (x1 + y1 <= max(x2, y2)) f = 1; for (int i = 0; i < min(x2, y2); i++) { int nx = x2 - i; int ny = y2 - i; if (abs(nx - x1) + abs(ny - y1) <= i) f = 1; } cout << (f ? "Poly...
### Prompt In cpp, your task is to solve the following problem: Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y) or (...
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 0, 1, -1, -1, -1, 1, 1}; int dy[] = {1, -1, 0, 0, -1, 1, 1, -1}; template <class T> inline T biton(T n, T pos) { return n | ((T)1 << pos); } template <class T> inline T bitoff(T n, T pos) { return n & ~((T)1 << pos); } template <class T> inline T ison(T n...
### Prompt Please provide a cpp coded solution to the problem described below: Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to ...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int mod = 1e9 + 7; const double eps = 1e-8; const double pi = acos(-1.0); const int dx[] = {-1, 1, 0, 0}; const int dy[] = {0, 0, -1, 1}; int main() { ios_base::sync_with_stdio(0); int xp, yp, xv, yv, d; while (cin >> xp >> yp >> xv >...
### Prompt Please formulate a Cpp solution to the following problem: Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y)...
#include <bits/stdc++.h> using namespace std; int main() { pair<int, int> f_p, s_p; cin >> f_p.first >> f_p.second >> s_p.first >> s_p.second; if (s_p.first >= f_p.first && s_p.second >= f_p.second) { cout << "Polycarp" << endl; return 0; } f_p.first += f_p.second; if (s_p.first < s_p.second) s_p.fi...
### Prompt Please formulate a Cpp solution to the following problem: Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y)...
#include <bits/stdc++.h> using namespace std; const string g = "Polycarp"; const string h = "Vasiliy"; int main(void) { int x, y, a, b; cin >> x >> y >> a >> b; if (x + y <= max(a, b) || (x <= a && y <= b)) return cout << g << '\n', 0; else return cout << h << '\n', 0; }
### Prompt Create a solution in CPP for the following problem: Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y) or (x...
#include <bits/stdc++.h> using namespace std; const int INF = 100000000; inline void solve(void) { int px, py, vx, vy; cin >> px >> py >> vx >> vy; if ((px <= vx && py <= vy) || (px + py <= max(vx, vy))) cout << "Polycarp"; else cout << "Vasiliy"; } int main(int argc, const char* argv[]) { ios_base::s...
### Prompt In Cpp, your task is to solve the following problem: Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y) or (...
#include <bits/stdc++.h> using namespace std; inline int read() { int ret = 0; char c; bool f = 0; while (!isdigit(c = getchar()) && c != '-') ; if (c == '-') f = 1, c = getchar(); do ret = ret * 10 + c - '0'; while (isdigit(c = getchar())); return f ? -ret : ret; } char name[2][10] = {"Polycarp", "...
### Prompt In CPP, your task is to solve the following problem: Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y) or (...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ; int a, b, c, d; cin >> a >> b >> c >> d; if (c >= a && d >= b) cout << "Polycarp"; else if (c < a + b && d < a + b) cout << "Vasiliy"; else cout << "Polycarp"; return 0; }
### Prompt Develop a solution in CPP to the problem described below: Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y)...
#include <bits/stdc++.h> using namespace std; int main() { int x1, y1, x2, y2; scanf("%d%d%d%d", &x1, &y1, &x2, &y2); if (x1 == x2) { if (y1 < y2) printf("Polycarp\n"); else printf("Vasiliy\n"); return 0; } if (y1 == y2) { if (x1 < x2) printf("Polycarp\n"); else pri...
### Prompt Your challenge is to write a cpp solution to the following problem: Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to ...
#include <bits/stdc++.h> using namespace std; template <class T> inline void mini(T &a, T b) { if (b < a) a = b; } template <class T> inline void maxi(T &a, T b) { if (b > a) a = b; } int a, b, c, d; bool ok() { return a + b <= max(c, d) || (a <= c && b <= d); } int main() { cin >> a >> b >> c >> d; puts(ok() ?...
### Prompt Generate a cpp solution to the following problem: Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y) or (x, ...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-7; const double PI = acos(-1); const long long INFF = (long long)1e18; const int INF = (int)1e9; const int mod = (int)1e9 + 7; const int MAX = (int)1e5 + 7; int main(void) { int px, py; scanf("%d %d", &px, &py); ; int vx, vy; scanf("%d %d", &...
### Prompt Please provide a Cpp coded solution to the problem described below: Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to ...
#include <bits/stdc++.h> using namespace std; int arr[100000]; int main() { int n; cin >> n; vector<int> vc; map<int, int> mp; map<int, int> fs; map<int, int> ls; int cnt = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; if (mp[arr[i]] == 0) { fs[arr[i]] = i; vc.push_back(arr[i]); ...
### Prompt In cpp, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> using namespace std; int n, mx = INT_MIN, x, arr[1000005], mn = INT_MAX, ansf, anse; unordered_set<int> st; vector<int> vv; vector<pair<int, int>> v(1000005); int main() { ios::sync_with_stdio(0), ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); ; cin >> n; for (int i = 0; i...
### Prompt Construct a cpp code solution to the problem outlined: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some n...
#include <bits/stdc++.h> using namespace std; struct A { int cnt; int left, right; }; int main() { int n; while (cin >> n) { map<int, A> m; int ans = -1, mx = 0; for (int i = 1; i <= n; i++) { int a; cin >> a; if (m.find(a) == m.end()) { m[a] = (A){1, i, i}; } else { ...
### Prompt Please create a solution in CPP to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int kol[1000005] = {}, a[1000005], l[1000005] = {}, r[1000005] = {}; int main() { int n; cin >> n; int m = 0; for (int i = 1; i <= n; i++) { int x; cin >> x; a[i] = x; kol[x]++; m = max(m, kol[x]); } for (int i = 1; i <= n; i++) if (kol[a...
### Prompt Create a solution in CPP for the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some numb...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n + 1, 0), l(1e6 + 1, -1), r(1e6 + 1, 0), cnt(1e6 + 1, 0); int ans = 0; a[0] = 0; for (int i = 1; i <= n; ++i) { cin >> a[i]; ++cnt[a[i]]; if (l[a[i]] == -1) l[a[i]] = i; r[a[i]] = i; if (cnt[a[i]] ...
### Prompt Your challenge is to write a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; void Suhaib_Sawalha() { long long n; cin >> n; map<long long, vector<long long>> m; long long a, Max(0); pair<long long, long long> ans; for (long long i = 0; i < n; ++i) { cin >> a; m[a].push_back(i + 1); if (m[a].size() > Max) Max = m[a].size...
### Prompt Generate a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; long long n, sz, l, r; vector<long long> veci[1000004]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) { long long a; cin >> a; veci[a].push_back(i); } for (int i = 1; i <= 1000000; i+...
### Prompt In Cpp, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; pair<long long, long long> a[n]; for (long long i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i + 1; } sort(a, a + n); long long mx = 0, mx_start = 0, mx_end = 0; long long j; long long mn = n; for (lon...
### Prompt Please create a solution in Cpp to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; template <typename T, typename T1> ostream& operator<<(ostream& out, pair<T, T1> obj) { return out << "(" << obj.first << "," << obj.second << ")"; } template <typename T, typename T1> ostream& operator<<(ostream& out, map<T, T1> cont) { typename map<T, T1>::const_itera...
### Prompt Construct a cpp code solution to the problem outlined: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some n...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 5; int a[MAXN]; int num[MAXN]; int l[MAXN], r[MAXN]; int main() { int m, n, i, j, k; ios::sync_with_stdio(false); ; cin >> m; for (i = 1; i <= m; i++) cin >> a[i]; for (i = 0; i <= 1e6; i++) l[i] = 999999999; for (i = 1; i <= m; i++) { ...
### Prompt In Cpp, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> using namespace std; const int MAX = 1000100; vector<pair<int, pair<int, int> > > b(MAX); int main() { int n; scanf("%d", &n); int x; for (int i = 1; i <= n; i++) { scanf("%d", &x); if (b[x].first == 0) b[x].second.first = i; b[x].second.second = i; b[x].first++; } i...
### Prompt Please formulate a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; const int BASE = 10007; const int MAXN = 100005; const int MAXC = 1000006; int read() { int x; scanf("%d", &x); return x; } int a[MAXN]; int f[MAXC]; int l[MAXC]; int r[MAXC]; int main() { memset(f, 0, sizeof(f)); int n = read(); int maxf = 0; for (int i = 0, ...
### Prompt Create a solution in CPP for the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some numb...
#include <bits/stdc++.h> using namespace std; long long int li[1000005], A[100011], ri[1000005], c[1000005]; int main() { long long int n, i, loci, locj; cin >> n; long long int maxi = INT_MIN; for (i = 0; i < n; i++) { cin >> A[i]; if (!c[A[i]]) { c[A[i]]++; li[A[i]] = i + 1; ri[A[i]]...
### Prompt Create a solution in CPP for the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some numb...
#include <bits/stdc++.h> using namespace std; int M[1000005] = {}, m[1000005] = {}, n[1000005] = {}; int main() { int a; while (cin >> a) { int x; int big = 0, R = 0, L = 0; for (int i = 0; i < a; i++) { cin >> x; if (n[x] == 0) { M[x] = i; m[x] = i; } else { M[...
### Prompt Your task is to create a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times th...
#include <bits/stdc++.h> using namespace std; struct Reader { private: static const int BUF_SIZE = 1 << 22; char BUF_R[BUF_SIZE], *csy1, *csy2; template <class T> inline void RI(T& t) { int u = 0; char c = (csy1 == csy2 && (csy2 = (csy1 = BUF_R) + fread(BUF_R, 1, BUF_SIZE, stdin),...
### Prompt Please create a solution in Cpp to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; map<long long, long long> m1, m2, m3, m4; int main() { ios_base::sync_with_stdio(false); long long n, i, j, k, mx = INT_MIN; cin >> n; long long a[n + 1]; vector<long long> v; for (i = 0; i < n; i++) { cin >> a[i]; m1[a[i]]++; mx = max(mx, m1[a[i]]);...
### Prompt Construct a Cpp code solution to the problem outlined: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some n...
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int n; cin >> n; map<int, int> m; pair<int, int> maxx; pair<int, int> idx; map<int, int> fo; idx.first = 0; idx.second = INT_MAX; maxx.second = -456; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; ...
### Prompt Please formulate a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int a[2000000]; struct node { int num, fir, ed; } b[2000000]; int n; int maxb = 0, maxi; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); if (b[a[i]].num == 0) { b[a[i]].fir = i; b[a[i]].ed = i; } else { b[...
### Prompt Your task is to create a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times th...
#include <bits/stdc++.h> using namespace std; vector<long long> pos[1000 * 1000 + 2]; int32_t main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); long long n; cin >> n; for (long long i = 0; i < n; i++) { long long x; cin >> x; pos[x].push_back(i); } long long mx = 0; for (long lon...
### Prompt Construct a cpp code solution to the problem outlined: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some n...
#include <bits/stdc++.h> using namespace std; int main() { int n; long long a[100001]; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%I64d", &a[i]); a[i] = a[i] * 1000001 + i; } sort(a, a + n); a[n] = a[n - 1] * 2; int m = 0, l, j = 0, ta, tb; for (int i = 1; i <= n; i++) if ((a[i]...
### Prompt Please create a solution in Cpp to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 5; struct elem { int cnt; int lo, hi; }; int n; elem a[MAXN]; int main() { scanf("%d", &n); int x; for (int i = 0; i < MAXN; ++i) { a[i].cnt = 0; a[i].lo = 1e9; a[i].hi = -1e9; } for (int i = 1; i <= n; ++i) { scanf("%d",...
### Prompt Please create a solution in Cpp to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int n, a[100005], seq[100005]; int beh[100005], tail[100005], num[100005]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]), seq[i] = a[i]; sort(seq + 1, seq + 1 + n); for (int i = 1; i <= n; i++) a[i] = lower_bound(seq + 1, seq + 1 ...
### Prompt Please formulate a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; map<int, int> A; int AA[1000000]; int n, M = 0, a, awal, akhir; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a; A[a]++; if (A[a] == 1) AA[a] = i; if (A[a] == M) { if (akhir - awal > i - AA[a]) { awal = AA[a]; akhir =...
### Prompt Create a solution in Cpp for the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some numb...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; vector<int> pos[N]; int main() { int n; cin >> n; int mx = 0, l = 1, r = n; for (int i = 0; i < n; i++) { int x; cin >> x; pos[x].push_back(i); mx = max(mx, (int)pos[x].size()); } for (int i = 0; i < N; i++) if (pos[i]....
### Prompt Please provide a CPP coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 9, mod = 1e9 + 7, inf = 1e17; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k; long long arr[100005]; map<int, int> freq; cin >> n; map<int, pair<int, int>> m; set<int> s; for (int i = 0; i < n; i++)...
### Prompt Your task is to create a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times th...
#include <bits/stdc++.h> using namespace std; void setIO(const string& name = "") { ios_base::sync_with_stdio(false); cin.tie(nullptr); if ((int)(name).size()) { freopen((name + ".in").c_str(), "r", stdin); freopen((name + ".out").c_str(), "w", stdout); } } const int sz = 1e6 + 1; int counts[sz]; bool r...
### Prompt Please formulate a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; struct point { int p, x; } pt[100007]; int n; bool cmp(point a, point b) { if (a.x == b.x) return a.p < b.p; return a.x < b.x; } struct node { int num, r, l; } nd[100007]; int cnt = 0; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", ...
### Prompt Create a solution in CPP for the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some numb...
#include <bits/stdc++.h> using namespace std; long long a[100004], cnt[1000004]; pair<long long, long long> p[1000002]; int main() { long long n, k = INT_MIN, temp = INT_MIN, x, y; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; k = max(k, a[i]); } for (int i = 1; i <= k; i++) p[i] = make_pair(IN...
### Prompt Please create a solution in cpp to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; map<int, int> rep; map<int, pair<int, int> > indx; map<int, int>::iterator it; int main() { int n, flag; cin >> n; for (int i = 1; i <= n; i++) { int num; cin >> num; if (indx.find(num) == indx.end()) { indx[num].first = i; indx[num].second = i...
### Prompt Please create a solution in CPP to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; struct node { long long start; long long end; long long count; }; node arr[1000010]; long long ans[1000010]; long long maxi = -1; long long mini = 10000000; int main() { for (long long i = 1; i <= 1000000; i++) arr[i].count = 0; long long n; cin >> n; for (lon...
### Prompt Generate a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; long long int n, p, k; long long int st1, st2, en1, en2; long long int arr[1000009]; bool vis[31][31]; vector<pair<long long int, long long int>> moves = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}}; long long int dx[] = {-1, 0, 1, 0}; long long int dy[] = {0, 1, 0, -1}; long lo...
### Prompt Generate a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; const int MAX_VAL = 1000000; int N; struct Number { int val, l, r, times; } nums[MAX_VAL + 1]; int main() { for (int i = 1; i <= MAX_VAL; i++) { nums[i].val = i; nums[i].times = 0; nums[i].l = 0x3f3f3f3f; nums[i].r = -1; } scanf("%d", &N); for (int...
### Prompt Please formulate a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; bool cmp(pair<int, int> a, pair<int, int> b) { return abs(a.second - a.first) < abs(b.second - b.first); } int main() { ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0); int n; cin >> n; pair<int, int> pos[1000001] = {{0, 0}}; std::map<int, int> mp; fo...
### Prompt In cpp, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> using namespace std; const int A = 1e6 + 5; const int N = 1e5 + 5; int cnt[A]; int n, a[N]; int main() { cin >> n; for (int i = 0; i < n; ++i) { scanf("%d", a + i); cnt[a[i]] += 1; } int ma = 0; for (int i = 1; i <= A - 5; ++i) { ma = max(ma, cnt[i]); cnt[i] = 0; } ...
### Prompt Your task is to create a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times th...
#include <bits/stdc++.h> using namespace std; int n, a[1000001], b[1000001], c[1000001], x, ans; int main() { cin >> n; for (int i = 1; i <= n; ++i) { cin >> x; ++a[x]; if (b[x] == 0) b[x] = i; c[x] = i; if (a[x] > a[ans]) ans = x; if (a[x] == a[ans] && c[x] - b[x] < c[ans] - b[ans]) ans = x...
### Prompt Construct a Cpp code solution to the problem outlined: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some n...
#include <bits/stdc++.h> using namespace std; int a[1000007]; int main() { map<int, int> make_pair, mpp, mppp; int m; cin >> m; for (int i = 0; i < m; i++) { cin >> a[i]; make_pair[a[i]]++; if (!mpp[a[i]]) mpp[a[i]] = i + 1; mppp[a[i]] = i + 1; } int maxx = 0; int l = 0, r = 0; for (int ...
### Prompt Your task is to create a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times th...
#include <bits/stdc++.h> using namespace std; const int maxN = 1e5 + 100; int a[maxN], b[maxN * 10]; int st[maxN * 10], fi[maxN * 10]; int n; int main() { cin >> n; for (int i = 0; i < n; i++) { scanf("%i", &a[i]); ++b[a[i]]; fi[a[i]] = i; } int res = 0; for (int i = 0; i <= 1000000; i++) res = ma...
### Prompt Create a solution in Cpp for the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some numb...
#include <bits/stdc++.h> using namespace std; struct node { int val, l, r; node() { val = 0, r = 0, l = 0; } bool operator<(const node& w) const { if (val == w.val) { if (r - l == w.r - w.l) { return l < w.l; } return r - l < w.r - w.l; } return val > w.val; } } a[1230456];...
### Prompt In CPP, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> int c[1111111]; int l[1111111]; int r[1111111]; int main() { int i, n, t; for (i = 0; i < 1111111; i++) l[i] = 1e9; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &t); c[t]++; l[t] = std::min(l[t], i); r[t] = std::max(r[t], i); } t = 0; for (i = 0; i < 111...
### Prompt Develop a solution in cpp to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; pair<int, int> b[100005]; for (int i = 0; i < n; ++i) { cin >> b[i].first; b[i].second = i; } sort(b, b + n); b[n].first = -1; int st = 0, en = 0, mx = 1, mxst = 0, mxen = 0; for (int i = 1; i <= n; ++i) { if (b[i]...
### Prompt Please formulate a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int main() { map<int, int> a, b, c; map<int, int>::iterator it; int n, i, x, m, k, l, r; cin >> n; m = 1; for (i = 1; i <= n; i++) { cin >> x; a[x]++; m = max(m, a[x]); if (a[x] == 1) b[x] = i; c[x] = i; } k = n; l = 1; r = n; for (...
### Prompt Develop a solution in cpp to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int main() { map<int, int> p; map<int, pair<int, int>> c; int n, m, i, ans = 0; map<int, int>::iterator it; cin >> n; for (i = 0; i < n; i++) { cin >> m; if (p[m] == 0) { c[m].first = i + 1; c[m].second = i + 1; } else c[m].second =...
### Prompt Please formulate a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int a[1000006][3] = {0}; int main() { int n, m, temp, i; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &temp); if (a[temp][0]) { a[temp][0]++; a[temp][2] = i; } else { a[temp][0]++; a[temp][1] = i; a[temp][2] = i; ...
### Prompt Please formulate a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; pair<int, pair<int, int> > a[1000001]; int main() { int n, ans = 0, i, x, l, r; cin >> n; for (i = 1; i <= n; i++) { cin >> x; if (!a[x].first) a[x].first++, a[x].second.first = i, a[x].second.second = i; else a[x].first++, a[x].second.second =...
### Prompt Your challenge is to write a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; int m[1000005], L[1000005]; int main(void) { int n, x, i, j, ch = -1, maxi = 0, mini = 2000000000; cin >> n; for (i = 0; i < n; i++) { cin >> x; if (m[x] == 0) { L[x] = i; m[x] = 1; } else m[x]++; if (m[x] > maxi) { maxi = m[x];...
### Prompt Please formulate a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } const long long INF = 1e18 + 99; const long long MOD = 1e9 + 7; inline long long two(long long n) { return 1 << n; } inline void set_bit(long long& n, long long b) { n |= two(b); } inline void unset_bit(long ...
### Prompt Your challenge is to write a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; int n, a[100001] = {0}, maxb = 0; map<int, int> cnt; map<int, vector<int> > mp; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; cnt[a[i]]++; maxb = max(maxb, cnt[a[i]]); } for (int i = 0; i < n; i++) { if (cnt[a[i]] == maxb) { ...
### Prompt Please create a solution in CPP to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int n, a[1000005], mayor, x, pos; int primera[1000005], segunda[1000005]; int main() { scanf("%d", &n); fill(primera, primera + 1000005, 1e9); fill(segunda, segunda + 1000005, -1e9); for (int i = 0; i < n; ++i) { scanf("%d", &x); a[x]++; primera[x] = min...
### Prompt Please formulate a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; vector<int> v[1000005]; int n, ar[100005]; int main() { cin >> n; set<int> st; for (int i = 0; i < n; i++) { cin >> ar[i]; st.insert(ar[i]); v[ar[i]].push_back(i + 1); } vector<int> fr(st.begin(), st.end()); int mx = 0, l = 1, r = n, mnd = INT_MAX; ...
### Prompt Construct a CPP code solution to the problem outlined: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some n...
#include <bits/stdc++.h> using namespace std; int n, i, x, cnt[1000001], mx, imx, idx1[1000001], idx2[1000001], l, r; int main() { ios_base::sync_with_stdio(false); cin >> n; for (i = 1; i <= n; i++) { cin >> x; cnt[x]++; if (cnt[x] == 1) idx1[x] = i; idx2[x] = i; } mx = cnt[1]; imx = 1; f...
### Prompt In CPP, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> using namespace std; vector<vector<int>> input(1000001); int n; int main() { int num; cin >> n; for (int i = 0; i < n; i++) { cin >> num; input[num].push_back(i); } int max = 0; for (int i = 1; i <= 1000000; i++) { if (max < input[i].size()) { max = input[i].size()...
### Prompt Generate a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, MAX = 1e6 + 1; int n; int l[MAX], r[MAX], sl[MAX]; bool mini(int &a, int b) { if (a <= b) return 0; a = b; return 1; } int main() { for (int i = 1; i < MAX; i++) l[i] = N, r[i] = 0; cin >> n; for (int i = 1, x; i <= n; i++) { cin >> x...
### Prompt Please formulate a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; struct Node { int st, end, len, cnt; Node() { st = end = len = cnt = 0; } Node(int _st, int _end, int _len, int _cnt) { st = _st, end = _end, len = _len; cnt = _cnt; } }; map<int, Node> mp; map<int, Node>::iterator it; vector<Node> ve...
### Prompt Your challenge is to write a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; const int Nmax = 1e6 + 17; int a[Nmax][3] = {0}; int main(void) { int n, x; scanf("%d", &n); for (int i = 0; i < Nmax; i++) a[i][0] = -1; for (int i = 0; i < n; i++) { scanf("%d", &x); if (a[x][0] == -1) a[x][0] = i; a[x][1] = i; a[x][2]++; } int...
### Prompt Create a solution in CPP for the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some numb...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000000 + 5; int n; int sh[MAXN]; int p[MAXN]; int t[MAXN]; int main() { cin >> n; int mx = 0; for (int i = 0; i < n; i++) { int x; cin >> x; if (t[x] == 0) { sh[x] = i; t[x] = 1; p[x] = i; } else { t[x]++; ...
### Prompt Your task is to create a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times th...
#include <bits/stdc++.h> using namespace std; inline int in() { int res = 0; char c; while ((c = getchar()) < '0' || c > '9') ; while (c >= '0' && c <= '9') res = res * 10 + c - '0', c = getchar(); return res; } int m[1000010]; int l[1000010]; int main() { int n = in(); int x, ans1, ans2; int mx = 0...
### Prompt Your challenge is to write a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; int a[1000005], l[1000005], r[1000005]; int main() { int n; scanf("%d", &n); int i, maxn = 0; memset(a, 0, sizeof(a)); memset(l, 0, sizeof(l)); memset(r, 0, sizeof(r)); int id1 = 0, id2 = 0x7FFFFFFF, x; for (i = 1; i <= n; i++) { scanf("%d", &x); a[x...
### Prompt Please provide a CPP coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; struct item { int f; int s; int c; }; item ab[1000005]; int main() { ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(10); cout.tie(nullptr); cin.tie(nullptr); int n; cin >> n; for (int i = 1; i <= n; i++) { int item; cin...
### Prompt Your challenge is to write a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; int n, x; struct num { int f_ap = -1; int l_ap = -1; int cont = 0; } nums[1000100]; bool cmp(num a, num b) { return a.cont > b.cont; } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &x); nums[x].cont++; if (nums[x].f_ap == -1) ...
### Prompt Please create a solution in CPP to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int nums[1000050], b[1000050], e[1000050], ans; int main(void) { memset(nums, 0, sizeof(nums[0])); int n, i, tp; scanf("%d", &n); for (ans = 0, i = 1; i <= n; i++) { scanf("%d", &tp); nums[tp]++; if (nums[tp] == 1) b[tp] = i; e[tp] = i; if (nums[...
### Prompt Generate a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; int n; int a[100005], L[1000006], R[1000006], nr[1000006]; int l, r, sol = 100005, nrc; void read() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); } void solve() { for (int i = 1; i <= n; i++) { nr[a[i]]++; if (nr[a[i]] == 1) L[a[i]]...
### Prompt Create a solution in cpp for the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some numb...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> counts(1000001, 0); vector<int> s(1000001, 0); vector<int> f(1000001, 0); int max_counts = 0; for (int i = 0; i < n; ++i) { int x; cin >> x; if (counts[x] == 0) { s[x] = i; } f[x] = i; ++c...
### Prompt Please provide a CPP coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; long long fastmul(long long a, long long b) { if (b == 0) return 0; if (b == 1) return a; long long tmp = fastmul(a, b >> 1); return (b & 1) ? ((tmp << 1) + a) % 1000000007LL : (tmp << 1) % 1000000007LL; } struct Point { double x, y; Point() {} Point(double A,...
### Prompt Please create a solution in Cpp to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; const int N = 1000000 + 10; const int INF = 10000000; int n; struct Number { int L, R, num; } a[N]; const bool comp(const Number &A, const Number &B) { return A.num > B.num; } int main() { scanf("%d", &n); int pos; for (int i = 1; i <= N; ++i) a[i - 1].L = INF, ...
### Prompt Create a solution in CPP for the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some numb...
#include <bits/stdc++.h> using namespace std; long long n, i, mx, mn = 9999999, j; vector<long long> v[9999999]; int main() { cin >> n; map<long long, long long> m; long long a[n + 1]; for (i = 1; i <= n; i++) { cin >> a[i]; m[a[i]]++; v[a[i]].push_back(i); mx = max(mx, m[a[i]]); } long long...
### Prompt Please provide a Cpp coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; int li[1000005], ri[1000005], c[1000005]; vector<int> v; vector<pair<int, int> > te; int main() { int n, i; cin >> n; int A[n + 1]; for (i = 0; i < n; i++) { cin >> A[i]; if (!c[A[i]]) { c[A[i]]++; v.push_back(A[i]); li[A[i]] = i; ri[...
### Prompt Your task is to create a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times th...
#include <bits/stdc++.h> using namespace std; long long i, j, k, l, fx[1000000], m, n, c, e, r, t, h, mx, mn, mx1, mx2, mn1, mn2, x, y, x2, y2, i1, j2, i2; vector<int> v[10000]; set<int> sas; set<int>::iterator it; long long a[10000000]; pair<int, int> p[1000000]; pair<int, int> pp; long long s[100000]; int main() ...
### Prompt Please create a solution in Cpp to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int open[N], close[N], k[N], n, a[N], MAX, len = 1e9; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; k[a[i]]++; if (!open[a[i]]) open[a[i]] = i; } for (int i = ...
### Prompt Develop a solution in CPP to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; class num { public: int i1, i2, s; num() { i1 = i2 = s = 0; } bool operator>(num n) { if (n.s < this->s) return 1; else if (n.s == this->s) if (i2 - i1 < n.i2 - n.i1) return 1; return 0; } }; int a[100005], n, i; num h[1000005], ans; int mai...
### Prompt Your task is to create a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times th...
#include <bits/stdc++.h> using namespace std; struct data { int num, st, ed; }; data ar[1000002]; int a[100002]; bool vis[1000002]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, maxi = 0, s = 0, e = 0, cnt = 100000000, x, p, i, c, b; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; x...
### Prompt In cpp, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> using namespace std; int N, t1; map<int, pair<int, int> > num; int count_sort[1000005] = {0}; int main() { cin >> N; int max_ = 0, max_num = 0; for (int i = 0; i < N; i++) { cin >> t1; count_sort[t1]++; if (num.find(t1) != num.end()) { num[t1].second = i; } else { ...
### Prompt Create a solution in Cpp for the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some numb...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 5; int cnt[MAXN]; int start[MAXN]; int main() { int n, a, l = 0, r = 0, maxCount = 0; memset(cnt, 0, MAXN); memset(start, 0, MAXN); int minDistance = n; cin >> n; for (int i = 0; i < n; ++i) { cin >> a; if (!cnt[a]) { start[a...
### Prompt Your task is to create a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times th...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int a, n; map<int, int> freq; map<int, pair<int, int> > idx; cin >> n; for (int i = 1; i <= n; ++i) { cin >> a; if (!idx[a].first) ...
### Prompt Please formulate a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int Count[1000000]; bool used[1000000]; int main() { int n, checkStart, checkEnd, ansBegin, ansEnd, mx = 0, mx2 = 0, mnSize = 1 << 30; int begin[1000000 + 1], end[1000000 + 1]; scanf("%d", &n); int list[n]; for (int...
### Prompt Generate a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; typedef struct interv { int left, right, sum; interv() { left = 0; right = 0; sum = 0; } interv(int l, int r, int s) { left = l; right = r; sum = s; } } interv; int main() { int n; cin >> n; map<int, interv> m; for (int i = 0; i < n...
### Prompt Your challenge is to write a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> struct cont { long start; long end; long count; }; int main() { long n; scanf("%ld\n", &n); long ansStart(0), ansEnd(0), maxCount(1), minDist(1); std::map<long, cont> dets; for (int p = 0; p < n; p++) { long t; scanf("%ld", &t); if (dets.count(t) > 0) { dets[t]...
### Prompt Create a solution in cpp for the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some numb...
#include <bits/stdc++.h> using namespace std; const int N = 1E6 + 7; struct Q { int cnt, s, len; } q[N]; int a[N]; bool cmp(Q a, Q b) { if (a.cnt > b.cnt) return true; if (a.cnt == b.cnt && a.len < b.len) return true; return false; } int main() { int n; int mx = -1; cin >> n; memset(q, 0, sizeof(q)); ...
### Prompt Develop a solution in cpp to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int main() { int n; static int arr[1111111][3]; int first; cin >> n; for (int i = 0; i < n; i++) { int tmp; cin >> tmp; arr[tmp][0]++; if (i == 0) first = tmp; else if (arr[tmp][1] == 0 && tmp != first) { arr[tmp][1] = i; arr[...
### Prompt Your challenge is to write a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; map<long int, long int> freq; long int lower[1000006]; long int upper[1000006]; int main() { int N; long int n; scanf("%d", &N); memset(lower, -1, sizeof(lower)); memset(upper, -1, sizeof(upper)); for (int i = 0; i < N; ++i) { scanf("%ld", &n); freq[n]++...
### Prompt Develop a solution in cpp to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; vector<int> v; int sum[1000500] = {0}; int visit[1000500] = {0}; int main() { int n; int maior = -1; int fim = -1; int beg = -1; int value = -1; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; v.push_back(x); sum[x] = sum[x] + 1; i...
### Prompt In Cpp, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> jmlr(n); map<int, int> jmlrs; map<int, int> last; map<int, int> first; for (int i = 0; i < n; i++) { cin >> jmlr[i]; if (jmlrs.find(jmlr[i]) == jmlrs.end()) { jmlrs[jmlr[i]] = 0; first[jmlr[i]] = i;...
### Prompt In CPP, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> using namespace std; int n, a[100005]; map<int, int> cnt, fi, la; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; cnt[a[i]]++; la[a[i]] = i; if (fi.count(a[i]) == 0) fi[a[i]] = i; } int beauty = 0; for (int i = 0; i < n; i++) { if (cnt[a[i]] > bea...
### Prompt Generate a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; const int N = 1e6; int lft[N + 10], rght[N + 10], f[N + 10], ind[N + 10], l, r, n, a, mn, mx; bool cmp(int i, int j) { return f[i] > f[j]; } int main() { std::ios::sync_with_stdio(0); cin.tie(0); for (int i = 1; i <= N; i++) { lft[i] = -1; rght[i] = -1; f[...
### Prompt Please provide a cpp coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; void FastIO() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const int N = 1e6; vector<int> v[N + 1]; int main() { FastIO(); int tc, ca = 0; int n, el; cin >> n; int mx = 0; for (int i = 1; i <= n; i++) { cin >> el; v[el].push_back(i); m...
### Prompt Generate a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...