ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <stack>
#include <cstring>
#include <math.h>
#include <queue>
#include <deque>
#include <iomanip>
#include <bitset>
#include <random>
#define INF 4e10
#define INF64 9223372036854775807
#define INF32 2147483647
#define MAXN 2e5 + 10
#define MOD INF32
#define REDIRECT 1
#define fout freopen("out.out", "w", stdout)
#define fin freopen("test.in", "r", stdin)
#define Debug(x) for(int i = 0;i<x.size();++i)cout<<x[i]<<" ";cout<<endl
#define PUT(x) for(int i = 0;i<x.size();++i)cout<<x[i]<<" ";cout<<endl
#define ARRCIN(x) for(auto& i:x) cin>>i
#define LEN(x) to_string(x).size()
#define ALL(x) x.begin(),x.end()
#define _tostring(x) to_string(x);//自动保留负号
#define _toint(x) stoi(x);//stoi会自动将string数值部分的首位0消去，同时还会保留负号
#define _toll(x) stoll(x);
#define YES "YES\n"
#define NO "NO\n"
#define endl '\n'
#define int long long
using namespace std;
using i64 = unsigned long long;
using u64 = unsigned long long;
const int maxn = 2e5+10;
typedef long long LL;	
typedef long long llint;
typedef unsigned long long u64;
typedef pair<int, int> pii;
bool cmp(int a, int b) {return a > b;}
int qkpow(int a,int n,int mod = INF32) {int ans = 1;while(n){if(n&1) ans = (ans * a) % mod;a = (a * a) % mod;n >>= 1;}return (ans + mod) % mod;}
int gcd(int a,int b) {int tem = 0; while(b) tem = b,b = a % b,a = tem; return tem;}
int lcm(int a,int b) {return a * b / gcd(a, b);}
int lowbit(int x){return x & -x;}
std::mt19937_64 rng(time(0));
//裴蜀定理：
//	若a,b是整数,且gcd(a,b)=d，那么对于任意的整数x,y,ax+by都一定是d的倍数，特别地，一定存在整数x,y，使ax+by=d成立。
//	它的一个重要推论是：a,b互质的充要条件是存在整数x,y使ax+by=1.
//	另外，多元线性方程 a1x1 + a2x2 + ... + anxn = w  有解的充要条件是gcd(a1,a2,a3,...,an) | w
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//此处采用运算符重载的方式，还可以重载仿函数
struct node{
	int l, r, cnt, size, x, y, val;
	bool operator<(const node& a)const {return val<a.val;}//大根堆
};//思路：统计数量（0-9）；如果为0则忽略，不为零

const int N = 32;
bool solve() {
	int l, r;cin>>l>>r;
	bitset<N> bl(l), br(r);
	// cout<<bl<<endl<<br<<endl;
	
	int pos = 0;
	for(int i = N - 1;i >= 0;--i){
		if(bl[i] != br[i]) {
			pos = i;
			break;
		}
	}
	// cout<<pos<<endl;
	int a = 0, b = 0, c = 0;
	a |= (1 << pos);
	b |= 0;
	for(int i = pos - 1;i >= 0;i --){
		b |= (1 << i);
	}
	
	for(int i = l;i <= r;++i){
		if(i != a && i != b){
			c = i;
			break;
		}
	}
	
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 1;
}

signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	if (!REDIRECT) fout, fin;
	int _ = 1;
	std::cin >> _;
	while (_--)
		solve();
	return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include     		<bits/stdc++.h>
	
#define             ll   long long
#define            pll   pair<ll, ll>
#define            pii   pair<int, int>
#define          io(x)   if (fopen(x".inp","r")) {freopen(x".inp","r",stdin),freopen(x".out","w",stdout);}
#define      mem(c, x)   memset(c, x, sizeof(c))
#define         all(c)   c.begin(), c.end()
#define       bit(i,j)   ((i >> j) & 1)
#define             pb   push_back
#define             se   second     
#define             fi   first
#define             el   '\n'
using namespace std;  

template<class T> bool   maximize(T &a, const T &b) { return (a < b ? a = b, 1 : 0); }
template<class T> bool   minimize(T &a, const T &b) { return (a > b ? a = b, 1 : 0); }

int dx[8] = {0, 1, 0,-1, 1, 1,-1,-1};
int dy[8] = {1, 0,-1, 0, 1,-1,-1, 1};
const int  maxn  = 1e5 + 9;
const int  Inf   = 2e9 + 7;
const ll   Infll = 1e18 + 9;
const ll   Mod   = 1e9 + 7;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

void solve() {
	string s; cin >> s;
	vector<int> p;

	for (int j=0; j<=1; j++) {
		for (int k=0; k<=1; k++) {
			int cur1 = s[0]-'0', cur2 = s[1]-'0';
			if (j) cur1 *= cur1;
			if (k) cur2 *= cur2;
			if (cur1 < 10 && cur2 < 10) {
				p.pb((cur1 + cur2) % 9);
			}
		}
	}

	sort(all(p));

	for (int i=2; i<s.size(); i++) {
		vector<int> temp;
		for (int cur1 : p) {
			for (int k=0; k<=1; k++) {
				int cur2 = s[i]-'0';
				if (k) cur2 *= cur2;
				if (cur2 < 10) {
					temp.pb((cur1 + cur2) % 9);
					// cout << cur2 << ' ' << cur1 << el;
				}
			}
		}
		sort(all(temp)); temp.resize(unique(all(temp)) - temp.begin());
		p = temp;
	}

	if (binary_search(all(p), 0)) cout << "YES" << el; else cout << "NO" << el;


}

signed main() {
    
    ios_base::sync_with_stdio(false);  cin.tie(0); cout.tie(0); 
    io("task"); 

    int t; cin >> t;
    while (t--)
    solve();
    
    return (0 ^ 0);
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Compilation error):
#include <bits/stdc++.h>

#define int long long

#define all(x) x.begin(), x.end()

#define pii pair<int, int>

#define piii pair<pair<int, int>, int>

using namespace std;

const int INF = INT_MAX;

bool scp(int a) {

if ((int)(sqrt(a)) * (int)(sqrt(a)) == a) {

return true;

}

return false;

}

signed main() {

ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#ifndef ONLINE_JUDGE

freopen("input.txt", "r", stdin);

freopen("output.txt", "w", stdout);

#endif

int t; cin >> t;

while(t--) {

string s; cin >> s;

for (int i = 0; i < s.size(); i++) {

int best_Cur = (s[i] - '0');

int pos_Cur = i;

for (int j = i+1; j < min(s.size() * 1ll, i + 10); j++) {

int nextNum = (int)((s[j] - '0') - (j - i));

if (nextNum > best_Cur) {

best_Cur = nextNum;

pos_Cur = j;

}

}

int idx = pos_Cur;

while(true) {

if (idx == i) {

break;

}

swap(s[idx - 1], s[idx]);

idx -= 1;

}

s[i] = (char)(best_Cur + '0');

}

cout << s << endl;

}

return 0;

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>

#define int long long

#define all(x) x.begin(), x.end()

#define pii pair<int, int>

#define piii pair<pair<int, int>, int>

using namespace std;

const int INF = INT_MAX;

bool scp(int a) {

if ((int)(sqrt(a)) * (int)(sqrt(a)) == a) {

return true;

}

return false;

}

signed main() {

ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#ifndef ONLINE_JUDGE

freopen("input.txt", "r", stdin);

freopen("output.txt", "w", stdout);

#endif

int t; cin >> t;

while(t--) {

string s; cin >> s;

for (int i = 0; i < s.size(); i++) {

int best_Cur = (s[i] - '0');

int pos_Cur = i;

for (int j = i+1; j < min(s.size() * 1ll, i + 10); j++) {

int nextNum = (int)((s[j] - '0') - (j - i));

if (nextNum > best_Cur) {

best_Cur = nextNum;

pos_Cur = j;

}

}

int idx = pos_Cur;

while(true) {

if (idx == i) {

break;

}

swap(s[idx - 1], s[idx]);

idx -= 1;

}

s[i] = (char)(best_Cur + '0');

}

cout << s << endl;

}

return 0;

}

Submission (verdict: Compilation error):
#include <bits/stdc++.h>

#define int long long

#define all(x) x.begin(), x.end()

#define pii pair<int, int>

#define piii pair<pair<int, int>, int>

using namespace std;

const int INF = INT_MAX;

signed main() {

ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#ifndef ONLINE_JUDGE

freopen("input.txt", "r", stdin);

freopen("output.txt", "w", stdout);

#endif

int t; cin >> t;

while(t--) {

string s; cin >> s;

for (int i = 0; i < s.size(); i++) {

int best_Cur = (s[i] - '0');

int pos_Cur = i;

for (int j = i+1; j < min(s.size() * 1ll, i + 10); j++) {

int nextNum = (int)((s[j] - '0') - (j - i));

if (nextNum > best_Cur) {

best_Cur = nextNum;

pos_Cur = j;

}

}

int idx = pos_Cur;

while(true) {

if (idx == i) {

break;

}

swap(s[idx - 1], s[idx]);

idx -= 1;

}

s[i] = (char)(best_Cur + '0');

}

cout << s << endl;

}

return 0;

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>

#define int long long

#define all(x) x.begin(), x.end()

#define pii pair<int, int>

#define piii pair<pair<int, int>, int>

using namespace std;

const int INF = INT_MAX;

signed main() {

ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#ifndef ONLINE_JUDGE

freopen("input.txt", "r", stdin);

freopen("output.txt", "w", stdout);

#endif

int t; cin >> t;

while(t--) {

string s; cin >> s;

for (int i = 0; i < s.size(); i++) {

int best_Cur = (s[i] - '0');

int pos_Cur = i;

for (int j = i+1; j < min(s.size() * 1ll, i + 10); j++) {

int nextNum = (int)((s[j] - '0') - (j - i));

if (nextNum > best_Cur) {

best_Cur = nextNum;

pos_Cur = j;

}

}

int idx = pos_Cur;

while(true) {

if (idx == i) {

break;

}

swap(s[idx - 1], s[idx]);

idx -= 1;

}

s[i] = (char)(best_Cur + '0');

}

cout << s << endl;

}

return 0;

}

Submission (verdict: Accepted):
#include <bits/stdc++.h>

#define int long long

#define all(x) x.begin(), x.end()

#define pii pair<int, int>

#define piii pair<pair<int, int>, int>

using namespace std;

const int INF = INT_MAX;

signed main() {

ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#ifndef ONLINE_JUDGE

freopen("input.txt", "r", stdin);

freopen("output.txt", "w", stdout);

#endif

int t; cin >> t;

while(t--) {

string s; cin >> s;

for (int i = 0; i < s.size(); i++) {

int best_Cur = (s[i] - '0');

int pos_Cur = i;

int longestPos = min((int)s.size(), i + 10);

for (int j = i+1; j < longestPos; j++) {

int nextNum = (int)((s[j] - '0') - (j - i));

if (nextNum > best_Cur) {

best_Cur = nextNum;

pos_Cur = j;

}

}

int idx = pos_Cur;

while(true) {

if (idx == i) {

break;

}

swap(s[idx - 1], s[idx]);

idx -= 1;

}

s[i] = (char)(best_Cur + '0');

}

cout << s << endl;

}

return 0;

}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 4):
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<vector>

using namespace std;

#define int long long

typedef pair<int, int>PII;

const int N = 1010;
int st[N], a[N];
int n;

vector<PII> ans;
map<int, int> Hash;

void solve()
{
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];

	for (int i = 1; i <= n; i++)
	{
		int m = a[i];
		st[m] = 1;

		for (int j = a[i] - 1; j >= 1; j--)
			if (!st[j])
			{
				ans.push_back({ m, j });
				Hash[m * 10000 + j] = 1;
			}
		
		if (i != 1 && !Hash[a[i] * 10000 + a[i - 1]] && !Hash[a[i - 1] * 10000 + a[i]])
		{
			ans.push_back({ a[i], a[i - 1] });
			ans.push_back({ a[i - 1], a[i] });
		}
	}

	cout << ans.size() << endl;

	for (auto it : ans)
		cout << it.first << ' ' << it.second << endl;

	return;
}

signed main()
{
	int T = 1;
	//cin >> T;
	while (T--) solve();

	return 0;
}

Submission (verdict: Wrong answer on test 4):
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<vector>

using namespace std;

#define int long long

typedef pair<int, int>PII;

const int N = 1010;
int st[N], a[N], b[N];
int n;

vector<PII> ans;
map<int, int> Hash;

void solve()
{
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];

	for (int i = 1; i <= n; i++)
	{
		int m = a[i];
		st[m] = 1;

		for (int j = a[i] - 1; j >= 1; j--)
			if (!st[j])
			{
				ans.push_back({ m, j });
				Hash[m * 10000 + j] = 1;
			}
		
		if (i != 1 && !Hash[a[i] * 10000 + a[i - 1]] && !Hash[a[i - 1] * 10000 + a[i]])
		{
			ans.push_back({ a[i], a[i - 1] });
			ans.push_back({ a[i - 1], a[i] });
		}
	}

	cout << ans.size() << endl;

	for (auto it : ans)
		cout << it.first << ' ' << it.second << endl;

	return;
}

signed main()
{
	int T = 1;
	//cin >> T;
	while (T--) solve();

	return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 4):
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<vector>

using namespace std;

#define int long long

typedef pair<int, int>PII;

const int N = 1010;
int st[N], a[N], b[N];
int n;

vector<PII> ans;
map<int, int> Hash;

void solve()
{
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];

	for (int i = 1; i <= n; i++)
	{
		int m = a[i];
		st[m] = 1;

		for (int j = a[i] - 1; j >= 1; j--)
			if (!st[j])
			{
				ans.push_back({ m, j });
				Hash[m * 10000 + j] = 1;
			}
		
		if (i != 1 && !Hash[a[i] * 10000 + a[i - 1]] && !Hash[a[i - 1] * 10000 + a[i]])
		{
			ans.push_back({ a[i], a[i - 1] });
			ans.push_back({ a[i - 1], a[i] });
		}
	}

	cout << ans.size() << endl;

	for (auto it : ans)
		cout << it.first << ' ' << it.second << endl;

	return;
}

signed main()
{
	int T = 1;
	//cin >> T;
	while (T--) solve();

	return 0;
}

Submission (verdict: Accepted):
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

const int N = 1010;

int n, a[N];

signed main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];

	vector<int> ovt[N], st(n + 1, 0);

	int ans = 0, cnt = 0;
	for (int i = n; i >= 1; i--)
	{
		int res = 0;
		for (int j = a[i] - 1; j >= 1; j--)
			if (st[j] == 0)
			{
				ovt[a[i]].push_back(j);
				res++;
			}

		ans += res + cnt;
		for (int j = 0; j < cnt; j++) ovt[a[i]].push_back(a[n - j]);
		
		cnt++;
		st[a[i]] = 1;
	}

	cout << ans << endl;
	for (int i = n; i >= 1; i--)
		for (auto it : ovt[a[i]])
			cout << a[i] << ' ' << it << endl;

	return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 4):
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<vector>

using namespace std;

#define int long long

typedef pair<int, int>PII;

const int N = 1010;
int st[N], a[N];
int n;

vector<PII> ans;
map<int, int> Hash;

void solve()
{
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];

	for (int i = 1; i <= n; i++)
	{
		int m = a[i];
		st[m] = 1;

		for (int j = a[i] - 1; j >= 1; j--)
			if (!st[j])
			{
				ans.push_back({ m, j });
				Hash[m * 10000 + j] = 1;
			}
		
		if (i != 1 && !Hash[a[i] * 10000 + a[i - 1]] && !Hash[a[i - 1] * 10000 + a[i]])
		{
			ans.push_back({ a[i], a[i - 1] });
			ans.push_back({ a[i - 1], a[i] });
		}
	}

	cout << ans.size() << endl;

	for (auto it : ans)
		cout << it.first << ' ' << it.second << endl;

	return;
}

signed main()
{
	int T = 1;
	//cin >> T;
	while (T--) solve();

	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define TC int t;cin>>t;while(t--)
#define Tanveer ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
#ifdef LOKAL
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
int ans;
void fun(vector<int> v)
{
    if(v.size()==1){
        ans = max(ans, v[0]); return;
    }
    int n = v.size();
    vector<int> t;
    for(int i=1; i<n; i++) t.push_back(v[i]-v[i-1]);
    fun(t);
    reverse(v.begin(), v.end());
    vector<int> tt;
    for(int i=1; i<n; i++) tt.push_back(v[i]-v[i-1]);
    fun(tt);
}
void solve()
{
    int n; cin>>n;
    vector<int> v(n);
    for(int i=0;i<n; i++) cin>>v[i];

    ans = -1e8;
    fun(v);
    cout<<ans<<endl;
}
int main()
{
    #ifndef LOKAL
    Tanveer
    #endif
    TC
    solve();
    return 0;
}





Submission (verdict: Time limit exceeded on test 2):
#include<bits/stdc++.h>
#define TC int t;cin>>t;while(t--)
#define Tanveer ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
#ifdef LOKAL
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
#define int long long
int ans;
void fun(vector<int> v)
{
    if(v.size()==1){
        ans = max(ans, v[0]); return;
    }
    int n = v.size();
    vector<int> t;
    for(int i=1; i<n; i++) t.push_back(v[i]-v[i-1]);
    fun(t);
    reverse(v.begin(), v.end());
    vector<int> tt;
    for(int i=1; i<n; i++) tt.push_back(v[i]-v[i-1]);
    fun(tt);
}
void solve()
{
    int n; cin>>n;
    vector<int> v(n);
    ans = 0;
    for(int i=0;i<n; i++) cin>>v[i], ans+=v[i];
    fun(v);
    cout<<ans<<endl;
}
int32_t main()
{
    #ifndef LOKAL
    Tanveer
    #endif
    TC
    solve();
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 2):
#include<bits/stdc++.h>
#define TC int t;cin>>t;while(t--)
#define Tanveer ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
#ifdef LOKAL
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
#define int long long
int ans;
void fun(vector<int> v)
{
    if(v.size()==1){
        ans = max(ans, v[0]); return;
    }
    int n = v.size();
    vector<int> t;
    for(int i=1; i<n; i++) t.push_back(v[i]-v[i-1]);
    fun(t);
    reverse(v.begin(), v.end());
    vector<int> tt;
    for(int i=1; i<n; i++) tt.push_back(v[i]-v[i-1]);
    fun(tt);
}
void solve()
{
    int n; cin>>n;
    vector<int> v(n);
    ans = 0;
    for(int i=0;i<n; i++) cin>>v[i], ans+=v[i];
    fun(v);
    cout<<ans<<endl;
}
int32_t main()
{
    #ifndef LOKAL
    Tanveer
    #endif
    TC
    solve();
    return 0;
}





Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define TC int t;cin>>t;while(t--)
#define Tanveer ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
#ifdef LOKAL
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
#define int long long

void solve()
{
    int n; cin>>n;
    vector<int> v(n);
    int ans = 0;
    for(int i=0;i<n; i++) cin>>v[i], ans+=v[i];

    if(n==1){
        cout<<v[0]<<endl; return;
    }
    vector<int> t = v;
    while(t.size())
    {
        int sum = 0;
        for(int i=0;i<t.size(); i++){
            sum+=(v[i]);
        }
        ans = max(ans, abs(sum));
        t.clear();
        for(int i=1; i<v.size(); i++) t.push_back(v[i]-v[i-1]);
        v = t;
    }
    cout<<ans<<endl;
}
int32_t main()
{
    #ifndef LOKAL
    Tanveer
    #endif
    TC
    solve();
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define TC int t;cin>>t;while(t--)
#define Tanveer ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
#ifdef LOKAL
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
int ans;
void fun(vector<int> v)
{
    if(v.size()==1){
        ans = max(ans, v[0]); return;
    }
    int n = v.size();
    vector<int> t;
    for(int i=1; i<n; i++) t.push_back(v[i]-v[i-1]);
    fun(t);
    reverse(v.begin(), v.end());
    vector<int> tt;
    for(int i=1; i<n; i++) tt.push_back(v[i]-v[i-1]);
    fun(tt);
}
void solve()
{
    int n; cin>>n;
    vector<int> v(n);
    for(int i=0;i<n; i++) cin>>v[i];

    ans = 0;
    fun(v);
    cout<<ans<<endl;
}
int main()
{
    #ifndef LOKAL
    Tanveer
    #endif
    TC
    solve();
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define TC int t;cin>>t;while(t--)
#define Tanveer ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
#ifdef LOKAL
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
#define int long long

void solve()
{
    int n; cin>>n;
    vector<int> v(n);
    int ans = 0;
    for(int i=0;i<n; i++) cin>>v[i], ans+=v[i];

    if(n==1){
        cout<<v[0]<<endl; return;
    }
    vector<int> t = v;
    while(t.size())
    {
        int sum = 0;
        for(int i=0;i<t.size(); i++){
            sum+=(v[i]);
        }
        ans = max(ans, abs(sum));
        t.clear();
        for(int i=1; i<v.size(); i++) t.push_back(v[i]-v[i-1]);
        v = t;
    }
    cout<<ans<<endl;
}
int32_t main()
{
    #ifndef LOKAL
    Tanveer
    #endif
    TC
    solve();
    return 0;
}





Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define TC int t;cin>>t;while(t--)
#define Tanveer ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
#ifdef LOKAL
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
#define int long long

void solve()
{
    int n; cin>>n;
    vector<int> v(n);
    int ans = 0;
    for(int i=0;i<n; i++) cin>>v[i], ans+=v[i];


    vector<int> t;
    while(v.size()!=1)
    {
        for(int i=1; i<v.size(); i++) t.push_back(v[i]-v[i-1]);
        v = t;
        int sum = 0;
        for(int i=0;i<t.size(); i++){
            sum+=(v[i]);
        }
        ans = max(ans, abs(sum));
        t.clear();

    }
    cout<<ans<<endl;
}
int32_t main()
{
    #ifndef LOKAL
    Tanveer
    #endif
    TC
    solve();
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define TC int t;cin>>t;while(t--)
#define Tanveer ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
#ifdef LOKAL
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
int ans;
void fun(vector<int> v)
{
    if(v.size()==1){
        ans = max(ans, v[0]); return;
    }
    int n = v.size();
    vector<int> t;
    for(int i=1; i<n; i++) t.push_back(v[i]-v[i-1]);
    fun(t);
    reverse(v.begin(), v.end());
    vector<int> tt;
    for(int i=1; i<n; i++) tt.push_back(v[i]-v[i-1]);
    fun(tt);
}
void solve()
{
    int n; cin>>n;
    vector<int> v(n);
    for(int i=0;i<n; i++) cin>>v[i];

    ans = 0;
    fun(v);
    cout<<ans<<endl;
}
int main()
{
    #ifndef LOKAL
    Tanveer
    #endif
    TC
    solve();
    return 0;
}





Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define TC int t;cin>>t;while(t--)
#define Tanveer ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
#ifdef LOKAL
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
int ans;
void fun(vector<int> v)
{
    if(v.size()==1){
        ans = max(ans, v[0]); return;
    }
    int n = v.size();
    vector<int> t;
    for(int i=1; i<n; i++) t.push_back(v[i]-v[i-1]);
    fun(t);
    reverse(v.begin(), v.end());
    vector<int> tt;
    for(int i=1; i<n; i++) tt.push_back(v[i]-v[i-1]);
    fun(tt);
}
void solve()
{
    int n; cin>>n;
    vector<int> v(n);
    for(int i=0;i<n; i++) cin>>v[i];

    ans = -1e8;
    fun(v);
    cout<<ans<<endl;
}
int main()
{
    #ifndef LOKAL
    Tanveer
    #endif
    TC
    solve();
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;
int t,n;
const int N=2e5+5;
struct Node{
    int p;
    int cnt;
}node[N];
bool cmp(Node a,Node b){
    return a.cnt>b.cnt;
}
void solve(){
  cin>>n;
  map<pair<int,int>,bool>edges;
    for(int i=0;i<=n;i++){
        node[i].cnt=0;
        node[i].p=i;
    }
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        edges[{u,v}]=edges[{v,u}]=true;
        node[u].cnt++;
        node[v].cnt++;
    }
    sort(node,node+n+1,cmp);
    int ans=n,del1=node[0].cnt,del2;
    for(int i=1;i<=n;i++){
        if(i!=1&&node[i].cnt<node[i-1].cnt){
            del2=node[i-1].cnt-1;
            break;
        }
        if(!edges[{node[0].p,node[i].p}]){
            del2=node[i].cnt;
            break;
        }
        if(i==n-1){
            del2=node[i].cnt-1;
            break;            
        }
    }
    ans=del1+del2-1;
    if(ans>n-2) ans=n-2;
    cout<<ans<<endl;
}
int main (){
  cin>>t;
  while(t--){
    solve();
    }
  return 0;
}