code in cpp
Created on: December 13, 2025
Answered using GPT-5.2 Thinking by Chat01
Created on: December 13, 2025
Answered using GPT-5.2 Thinking by Chat01
cpp#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) { int n, x; cin >> n >> x; vector<long long> cnt(x, 0); for (int i = 0; i < n; i++) { long long a; cin >> a; cnt[a % x]++; } long long pairs = 0; // remainder 0 pairs with remainder 0 pairs += cnt[0] / 2; // r pairs with (x-r) for (int r = 1; r <= (x - 1) / 2; r++) { pairs += min(cnt[r], cnt[x - r]); } // if x even, remainder x/2 pairs with itself if (x % 2 == 0) { pairs += cnt[x / 2] / 2; } // answer = maximum number of boxes used (2 boxes per gift) cout << pairs * 2 << "\n"; } return 0; }
pythonfrom PIL import Image img1 = Image.open('/mnt/data/WhatsApp Image 2025-12-13 at 17.51.28_035cffb2.jpg') img2 = Image.open('/mnt/data/WhatsApp Image 2025-12-13 at 17.51.41_f59b08eb.jpg') img1.size, img2.size ((1280, 576), (1280, 576))
pythonimport matplotlib.pyplot as plt, numpy as np def show_crop(img, box): crop=img.crop(box) plt.figure(figsize=(10,4)) plt.imshow(crop) plt.axis('off') plt.show() # crop sample input/output area from img1 show_crop(img1, (0,250,1280,520))
cpp#include <bits/stdc++.h> using namespace std; static string solve_one(const string &s) { int cnt[26] = {0}; for (char c : s) cnt[c - 'a']++; string left; left.reserve(s.size() / 2); // Build left half in increasing order for lexicographically smallest palindrome for (int i = 0; i < 26; i++) { left.append(cnt[i] / 2, char('a' + i)); } // Choose smallest possible middle character (if any odd count exists) char mid = 0; for (int i = 0; i < 26; i++) { if (cnt[i] % 2 == 1) { mid = char('a' + i); break; } } string right = left; reverse(right.begin(), right.end()); if (mid) return left + string(1, mid) + right; return left + right; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) { string s; cin >> s; cout << solve_one(s) << "\n"; } return 0; }