ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define pb push_back
#define ppb pop_back
#define mp make_pair
using namespace std;
using vpi = vector<pair<int, int>>;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
const int inf = 9e18;
const int mod = 1e9 + 7;
const int NUM = 1000030;
const int N = 10000000;
#define DEBUG(x) cerr << #x << ": " << x << '\n'

bool isSorted(vi& a){
  for(int i = 1; i<a.size(); i++){
    if(a[i-1] > a[i]) return false;
  }
  return true;
}
void solve()
{
  ll n;
  cin>>n;
  vi a(n);
  for(int i = 0; i<n; i++) cin>>a[i];
  bool flag = true;
  if(a[0] > a[1] || a[n-1] < a[n-2]) {
      cout<<"NO\n";
      return;
  }
  for(int i = 0; i<n-1; i++){
    int mini = min(a[i], a[i+1]);
    a[i]-=mini;
    a[i+1]-=mini;
    if(a[i] > a[i+1]){
      flag = false;
      break;
    } 
  }
  if(flag) cout<<"YES\n";
  else cout<<"NO\n";
  
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
     cin >> t;
    while (t--)
        solve();
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define pb push_back
#define ppb pop_back
#define mp make_pair
using namespace std;
using vpi = vector<pair<int, int>>;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
const int inf = 9e18;
const int mod = 1e9 + 7;
const int NUM = 1000030;
const int N = 10000000;
#define DEBUG(x) cerr << #x << ": " << x << '\n'

bool isSorted(vi& a){
  for(int i = 1; i<a.size(); i++){
    if(a[i-1] > a[i]) return false;
  }
  return true;
}
void solve()
{
  ll n;
  cin>>n;
  vi a(n);
  for(int i = 0; i<n; i++) cin>>a[i];
  bool flag = true;
  if(a[0] > a[1] || a[n-1] < a[n-2]) {
      cout<<"NO\n";
      return;
  }
  for(int i = 0; i<n-1; i++){
    int mini = min(a[i], a[i+1]);
    a[i]-=mini;
    a[i+1]-=mini;
    if(a[i] > a[i+1]){
      flag = false;
      break;
    } 
  }
  if(flag) cout<<"YES\n";
  else cout<<"NO\n";
  
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
     cin >> t;
    while (t--)
        solve();
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define pb push_back
#define ppb pop_back
#define mp make_pair
using namespace std;
using vpi = vector<pair<int, int>>;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
const int inf = 9e18;
const int mod = 1e9 + 7;
const int NUM = 1000030;
const int N = 10000000;
#define DEBUG(x) cerr << #x << ": " << x << '\n'

bool isSorted(vi& a){
  for(int i = 1; i<a.size(); i++){
    if(a[i-1] > a[i]) return false;
  }
  return true;
}
void solve()
{
  ll n;
  cin>>n;
  vi a(n);
  for(int i = 0; i<n; i++) cin>>a[i];
  bool flag = true;
  for(int i = 0; i<n-1; i++){
    int mini = min(a[i], a[i+1]);
    a[i]-=mini;
    a[i+1]-=mini;
    if(a[i] > a[i+1]){
      flag = false;
      break;
    } 
    if(mini == 0) break;
  }
  if(flag) cout<<"YES\n";
  else cout<<"NO\n";
  
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
     cin >> t;
    while (t--)
        solve();
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 6):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define loop0(i, n) for(long long i = 0; i < n; i++)
#define loop1(i, n) for(long long i = 1; i < n; i++)
#define allin(a, i, n) for(long long i=0; i<n; i++)cin>>a[i];
#define allout(a, i, n) for(long long i=0; i<n; i++)cout<<a[i]<<" ";
#define vll vector<long long>
#define pll pair<long long, long long>
#define mll unordered_map<long long, long long>
#define vpll vector<pll>
#define allr(v) v.rbegin(), v.rend()
#define all(v) v.begin(), v.end()
#define vs vector<string>
#define sum_a(a, n) accumulate(a, a+n, 0ll)
#define sum_v(v) accumulate(all(v), 0ll)

void solve(){
    ll n;
    cin>>n;
    ll a[n];
    allin(a, i, n);
    ll ans;
    if(n==1){
        cout<<a[0]<<endl;
        return;
    }
    if(n==2){
        ans = max(a[0]+a[1], max(a[0]-a[1], a[1]-a[0]));
        cout<<ans<<endl;
        return;
    }
    
    ans = abs(sum_a(a, n));
    vll curr, diff;
    for(auto x: a){
        curr.pb(x);
    }
    for(int i = 1; i < n; i++){
        diff.pb(curr[i]-curr[i-1]);
    }
    ans = max(abs(sum_v(diff)), ans);
    // allout(curr, i, n); cout<<endl;
    // allout(diff, i, n-1); cout<<endl;
    // cout<<ans<<endl;
    
    
    curr.clear();
    while(diff.size()>2){
        for(auto x: diff){
        curr.pb(x);
        }
        diff.clear();
        for(int i = 1; i < curr.size(); i++){
        diff.pb(curr[i]-curr[i-1]);
        }
        ans = max(abs(sum_v(diff)), ans);
        // allout(curr, i, curr.size()); cout<<endl;
        // allout(diff, i, diff.size()); cout<<endl;
        // cout<<ans<<endl;
        curr.clear();
    }
        ans = max(ans, max(diff[0]+diff[1], max(diff[0]-diff[1], diff[1]-diff[0])));
        cout<<ans<<endl;
}

int main() {
	int t;
	cin>>t;
	while(t--) solve();

}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

int log_base_2(int n){
    if(n<=0)return -1;
    int ans = 0;
    while(n != 1){
        n /= 2;
        ans++;
    }
    return ans;
}

int pow_2(int n){
    if(n<=0)return -1;
    int ans = 1;
    while(n){
        ans *= 2;
        n--;
    }
    return ans;
}

int main() {
	// your code goes here
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin>>t;
	while(t--){
	    int l, r;
	    cin>>l>>r;
	    if(r == l+2){
	        cout<<l<<" "<<l+1<<" "<<r<<endl;
	        continue;
	    }
	    int i, j, i_prime, j_prime;
	    i = log_base_2(l);
	    i_prime = i;
	    j = log_base_2(r);
	    j_prime = j;
	   // cout<<i<<" "<<j<<endl;
	   // int p = pow_2(i);
	    int l_prime = l;
	    int r_prime = r;
	   // cout<<pow_2(i_prime)<<" "<<j_prime<<endl;
	   // cout<<l_prime<<" "<<r_prime<<endl;
	   // int m = log_base_2(r_prime);
	   // cout<<i<<" "<<j<<" "<<m<<endl;
	   while(i_prime == j_prime && l_prime > 0 && r_prime > 0){
	       l_prime -= pow_2(i_prime);
	       r_prime -= pow_2(i_prime);
	       i_prime = log_base_2(l_prime);
	       j_prime = log_base_2(r_prime);
	   }
	   //cout<<i_prime<<" "<<j_prime<<endl;
	    if(j > i+1){
	        cout<<pow_2(j-1)<<" "<<pow_2(j)-1<<" "<<pow_2(j)<<endl;
	        continue;
	    }
	    if(j == i+1){
	        cout<<l<<" "<<pow_2(j)-1<<" "<<pow_2(j)<<endl;
	        continue;
	    }
	    if(j == i){
	       // l_prime to r_prime
	       if(j_prime > i_prime + 1){
	           cout<<l-l_prime+pow_2(j_prime-1)<<" "<<l-l_prime+pow_2(j_prime)-1<<" "<<l-l_prime+pow_2(j_prime)<<endl;
	           continue;
	       }
	       else if(j_prime == i_prime + 1){
	           cout<<l<<" "<<l-l_prime+pow_2(j_prime)-1<<" "<<l-l_prime+pow_2(j_prime)<<endl;
	           continue;
	       }
	    }
	}

}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " ";_print(x) ;cerr << endl;
#else
#define debug(x);
#endif


template<class T> void _print(T x) { cerr << x << " "; }


// template<class T> void _print(vector<T> v1);
template<class T> void _print(vector<T> v1){for(T& ele : v1){_print(ele);}}


void stdInput(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif
}


int solve(vector<int>& v1,int n)
{
	int mxSum = INT_MIN;
	
	
	while(n >= 1){
		debug(mxSum);
		int sum = 0;
		for(int &ele : v1){
			sum += ele;
		}
		reverse(v1.begin(),v1.end());
		// debug(v1);
		// cout << sum << endl;
		for(int i = 1;i < n;i++){
			v1[i-1] = v1[i]- v1[i-1];
		}
		v1.pop_back();
		mxSum = max(mxSum,sum);
		n--;
	}
	return mxSum;
	
}
int main()
{
	stdInput();
	int T;
	cin >> T;
	while(T--)
	{
		int n;
		cin >> n;
		vector<int> v1(n);
		for(int &i : v1){
			cin >> i;
		}
		cout << solve(v1,n) << endl;
	}
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " ";_print(x) ;cerr << endl;
#else
#define debug(x);
#endif

typedef long long ll;

template<class T> void _print(T x) { cerr << x << " "; }


// template<class T> void _print(vector<T> v1);
template<class T> void _print(vector<T> v1){for(T& ele : v1){_print(ele);}}


void stdInput(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif
}


ll solve(vector<int>& v1,int n)
{
	ll mxSum = LLONG_MIN;
	debug(mxSum);
	
	
	while(n >= 1){
		// debug(mxSum);
		ll sum = 0;
		for(int &ele : v1){
			sum += ele;
		}
		reverse(v1.begin(),v1.end());
		// debug(v1);
		// cout << sum << endl;
		for(int i = 1;i < n;i++){
			v1[i-1] = v1[i]- v1[i-1];
		}
		v1.pop_back();
		mxSum = max(mxSum,sum);
		n--;
	}
	return mxSum;
	
}
int main()
{
	stdInput();
	int T;
	cin >> T;
	while(T--)
	{
		int n;
		cin >> n;
		vector<int> v1(n);
		for(int &i : v1){
			cin >> i;
		}
		cout << solve(v1,n) << endl;
	}
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " ";_print(x) ;cerr << endl;
#else
#define debug(x);
#endif

typedef long long ll;

template<class T> void _print(T x) { cerr << x << " "; }


// template<class T> void _print(vector<T> v1);
template<class T> void _print(vector<T> v1){for(T& ele : v1){_print(ele);}}


void stdInput(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif
}


ll solve(vector<int>& v1,int n)
{
	ll mxSum = LLONG_MIN;

	mxSum = accumulate(v1.begin(),v1.end(),0ll);
	debug(mxSum);
	vector<ll> tmp;

	while(n > 1){
		// debug(mxSum);
		for(int i = 0;i < n-1;++i){
			tmp.push_back(v1[i+1] - v1[i]);
		}
		ll sum = 0;
		for(ll &ele : tmp){
			sum += ele;
		}
		// mxSum = max(mxSum,abs(accumulate(tmp.begin(),tmp.end(),0ll)));
		// debug(v1);
		// cout << sum << endl;
		
		for(int i = 0;i < n-1;i++){
			v1[i] = tmp[i];
		}
		mxSum = max(mxSum,abs(sum));
		tmp.clear();
		n--;
	}
	return mxSum;
	
}
int main()
{
	stdInput();
	int T;
	cin >> T;
	while(T--)
	{
		int n;
		cin >> n;
		vector<int> v1(n);
		for(int &i : v1){
			cin >> i;
		}
		cout << solve(v1,n) << endl;
	}
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " ";_print(x) ;cerr << endl;
#else
#define debug(x);
#endif

typedef long long ll;

template<class T> void _print(T x) { cerr << x << " "; }


// template<class T> void _print(vector<T> v1);
template<class T> void _print(vector<T> v1){for(T& ele : v1){_print(ele);}}


void stdInput(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif
}


ll solve(vector<int>& v1,int n)
{
	ll mxSum = LLONG_MIN;

	mxSum = accumulate(v1.begin(),v1.end(),0ll);
	debug(mxSum);
	vector<ll> tmp;

	while(n > 1){
		// debug(mxSum);
		for(int i = 0;i < n-1;++i){
			tmp.push_back(v1[i+1] - v1[i]);
		}
		// ll sum = 0;
		// for(ll &ele : tmp){
		// 	sum += ele;
		// }
		mxSum = max(mxSum,abs(accumulate(tmp.begin(),tmp.end(),0ll)));
		// debug(v1);
		// cout << sum << endl;
		
		for(int i = 0;i < n-1;i++){
			v1[i] = tmp[i];
		}
		// mxSum = max(mxSum,abs(sum));
		tmp.clear();
		n--;
	}
	return mxSum;
	
}
int main()
{
	stdInput();
	int T;
	cin >> T;
	while(T--)
	{
		int n;
		cin >> n;
		vector<int> v1(n);
		for(int &i : v1){
			cin >> i;
		}
		cout << solve(v1,n) << endl;
	}
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " ";_print(x) ;cerr << endl;
#else
#define debug(x);
#endif

typedef long long ll;

template<class T> void _print(T x) { cerr << x << " "; }


// template<class T> void _print(vector<T> v1);
template<class T> void _print(vector<T> v1){for(T& ele : v1){_print(ele);}}


void stdInput(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif
}


ll solve(vector<int>& v1,int n)
{
	ll mxSum = LLONG_MIN;

	mxSum = accumulate(v1.begin(),v1.end(),0ll);
	debug(mxSum);
	vector<ll> tmp;

	while(n > 1){
		// debug(mxSum);
		for(int i = 0;i < n-1;++i){
			tmp.push_back(v1[i+1] - v1[i]);
		}
		// ll sum = 0;
		// for(ll &ele : tmp){
		// 	sum += ele;
		// }
		mxSum = max(mxSum,abs(accumulate(tmp.begin(),tmp.end(),0ll)));
		// debug(v1);
		// cout << sum << endl;
		
		for(int i = 0;i < n-1;i++){
			v1[i] = tmp[i];
		}
		// mxSum = max(mxSum,abs(sum));
		tmp.clear();
		n--;
	}
	return mxSum;
	
}
int main()
{
	stdInput();
	int T;
	cin >> T;
	while(T--)
	{
		int n;
		cin >> n;
		vector<int> v1(n);
		for(int &i : v1){
			cin >> i;
		}
		cout << solve(v1,n) << endl;
	}
}

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

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " ";_print(x) ;cerr << endl;
#else
#define debug(x);
#endif

typedef long long ll;

template<class T> void _print(T x) { cerr << x << " "; }


// template<class T> void _print(vector<T> v1);
template<class T> void _print(vector<T> v1){for(T& ele : v1){_print(ele);}}


void stdInput(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif
}


ll solve(vector<ll>& v1,int n)
{
	ll mxSum = LLONG_MIN;

	mxSum = accumulate(v1.begin(),v1.end(),0ll);
	debug(mxSum);
	vector<ll> tmp;

	while(n > 1){
		// debug(mxSum);
		for(int i = 0;i < n-1;++i){
			tmp.push_back(v1[i+1] - v1[i]);
		}
		ll sum = 0;
		for(ll &ele : tmp){
			sum += ele;
		}
		// mxSum = max(mxSum,abs(accumulate(tmp.begin(),tmp.end(),0ll)));
		// debug(v1);
		// cout << sum << endl;
		
		for(int i = 0;i < n-1;i++){
			v1[i] = tmp[i];
		}
		mxSum = max(mxSum,abs(sum));
		tmp.clear();
		n--;
	}
	return mxSum;
	
}
int main()
{
	stdInput();
	int T;
	cin >> T;
	while(T--)
	{
		int n;
		cin >> n;
		vector<ll> v1(n);
		for(ll &i : v1){
			cin >> i;
		}
		cout << solve(v1,n) << endl;
	}
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " ";_print(x) ;cerr << endl;
#else
#define debug(x);
#endif


template<class T> void _print(T x) { cerr << x << " "; }


// template<class T> void _print(vector<T> v1);
template<class T> void _print(vector<T> v1){for(T& ele : v1){_print(ele);}}


void stdInput(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif
}


int solve(vector<int>& v1,int n)
{
	int mxSum = INT_MIN;
	
	
	while(n >= 1){
		debug(mxSum);
		int sum = 0;
		for(int &ele : v1){
			sum += ele;
		}
		reverse(v1.begin(),v1.end());
		// debug(v1);
		// cout << sum << endl;
		for(int i = 1;i < n;i++){
			v1[i-1] = v1[i]- v1[i-1];
		}
		v1.pop_back();
		mxSum = max(mxSum,sum);
		n--;
	}
	return mxSum;
	
}
int main()
{
	stdInput();
	int T;
	cin >> T;
	while(T--)
	{
		int n;
		cin >> n;
		vector<int> v1(n);
		for(int &i : v1){
			cin >> i;
		}
		cout << solve(v1,n) << endl;
	}
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " ";_print(x) ;cerr << endl;
#else
#define debug(x);
#endif

typedef long long ll;

template<class T> void _print(T x) { cerr << x << " "; }


// template<class T> void _print(vector<T> v1);
template<class T> void _print(vector<T> v1){for(T& ele : v1){_print(ele);}}


void stdInput(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif
}


ll solve(vector<int>& v1,int n)
{
	ll mxSum = LLONG_MIN;
	debug(mxSum);
	
	
	while(n >= 1){
		// debug(mxSum);
		ll sum = 0;
		for(int &ele : v1){
			sum += ele;
		}
		reverse(v1.begin(),v1.end());
		// debug(v1);
		// cout << sum << endl;
		for(int i = 1;i < n;i++){
			v1[i-1] = v1[i]- v1[i-1];
		}
		v1.pop_back();
		mxSum = max(mxSum,sum);
		n--;
	}
	return mxSum;
	
}
int main()
{
	stdInput();
	int T;
	cin >> T;
	while(T--)
	{
		int n;
		cin >> n;
		vector<int> v1(n);
		for(int &i : v1){
			cin >> i;
		}
		cout << solve(v1,n) << endl;
	}
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " ";_print(x) ;cerr << endl;
#else
#define debug(x);
#endif

typedef long long ll;

template<class T> void _print(T x) { cerr << x << " "; }


// template<class T> void _print(vector<T> v1);
template<class T> void _print(vector<T> v1){for(T& ele : v1){_print(ele);}}


void stdInput(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif
}


ll solve(vector<int>& v1,int n)
{
	ll mxSum = LLONG_MIN;

	mxSum = accumulate(v1.begin(),v1.end(),0ll);
	debug(mxSum);
	vector<ll> tmp;

	while(n > 1){
		// debug(mxSum);
		for(int i = 0;i < n-1;++i){
			tmp.push_back(v1[i+1] - v1[i]);
		}
		ll sum = 0;
		for(ll &ele : tmp){
			sum += ele;
		}
		// mxSum = max(mxSum,abs(accumulate(tmp.begin(),tmp.end(),0ll)));
		// debug(v1);
		// cout << sum << endl;
		
		for(int i = 0;i < n-1;i++){
			v1[i] = tmp[i];
		}
		mxSum = max(mxSum,abs(sum));
		tmp.clear();
		n--;
	}
	return mxSum;
	
}
int main()
{
	stdInput();
	int T;
	cin >> T;
	while(T--)
	{
		int n;
		cin >> n;
		vector<int> v1(n);
		for(int &i : v1){
			cin >> i;
		}
		cout << solve(v1,n) << endl;
	}
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;


void stdInput(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);

	#endif
}

void solve(vector<int>& v1,int n,int l,int r)
{
	vector<int> tmp(v1.begin(),v1.end());
	sort(tmp.begin(),tmp.end());
	int ans = 0;
	for(int i = 0;i <= (r-l);i++){
		ans += tmp[i];
	}
	cout << ans << endl;
}
int main()
{
	stdInput();
	int T;
	cin >> T;
	while(T--)
	{
		int n,l,r;
		cin >> n >> l >> r;
		vector<int> v1(n);
		for(int &i : v1){
			cin >> i;
		}
		solve(v1,n,l,r);
	}
}

Submission (verdict: Wrong answer on test 8):
#include <bits/stdc++.h>
using namespace std;


void stdInput(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);

	#endif
}

void solve(vector<int>& v1,int n,int l,int r)
{
	
	vector<int> a1,b1;
	for(int i = 0;i <= r;++i){
		a1.push_back(v1[i]);
	}
	for(int i = l;i < n;++i){
		b1.push_back(v1[i]);

	}
	sort(a1.begin(),a1.end());
	sort(b1.begin(),b1.end());
	int sum1 = 0,sum2 = 0;
	for(int i = 0;i <= (r-l);i++){
		sum1 += a1[i];
	}
	for(int i = 0;i <= (r-l);i++){
		sum2 += b1[i];
	}
	cout << min(sum1,sum2) << endl;
}
int main()
{
	stdInput();
	int T;
	cin >> T;
	while(T--)
	{
		int n,l,r;
		cin >> n >> l >> r;
		vector<int> v1(n);
		for(int &i : v1){
			cin >> i;
		}
		solve(v1,n,l-1,r-1);
	}
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;


void stdInput(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);

	#endif
}

void solve(vector<int>& v1,int n,int l,int r)
{
	vector<int> tmp(v1.begin(),v1.end());
	sort(tmp.begin(),tmp.end());
	int ans = 0;
	for(int i = 0;i <= (r-l);i++){
		ans += tmp[i];
	}
	cout << ans << endl;
}
int main()
{
	stdInput();
	int T;
	cin >> T;
	while(T--)
	{
		int n,l,r;
		cin >> n >> l >> r;
		vector<int> v1(n);
		for(int &i : v1){
			cin >> i;
		}
		solve(v1,n,l,r);
	}
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 8):
#include <bits/stdc++.h>
using namespace std;


void stdInput(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);

	#endif
}

void solve(vector<int>& v1,int n,int l,int r)
{
	
	vector<int> a1,b1;
	for(int i = 0;i <= r;++i){
		a1.push_back(v1[i]);
	}
	for(int i = l;i < n;++i){
		b1.push_back(v1[i]);

	}
	sort(a1.begin(),a1.end());
	sort(b1.begin(),b1.end());
	int sum1 = 0,sum2 = 0;
	for(int i = 0;i <= (r-l);i++){
		sum1 += a1[i];
	}
	for(int i = 0;i <= (r-l);i++){
		sum2 += b1[i];
	}
	cout << min(sum1,sum2) << endl;
}
int main()
{
	stdInput();
	int T;
	cin >> T;
	while(T--)
	{
		int n,l,r;
		cin >> n >> l >> r;
		vector<int> v1(n);
		for(int &i : v1){
			cin >> i;
		}
		solve(v1,n,l-1,r-1);
	}
}

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

using namespace std;





void stdInput(){

	#ifndef ONLINE_JUDGE

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

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



	#endif

}



void solve(vector<int>& v1,int n,int l,int r)

{

	

	vector<int> a1,b1;

	for(int i = 0;i <= r;++i){

		a1.push_back(v1[i]);

	}

	for(int i = l;i < n;++i){

		b1.push_back(v1[i]);



	}

	sort(a1.begin(),a1.end());

	sort(b1.begin(),b1.end());

	long long sum1 = 0,sum2 = 0;

	for(int i = 0;i <= (r-l);i++){

		sum1 += a1[i];

	}

	for(int i = 0;i <= (r-l);i++){

		sum2 += b1[i];

	}

	cout << min(sum1,sum2) << endl;

}

int main()

{

	stdInput();

	int T;

	cin >> T;

	while(T--)

	{

		int n,l,r;

		cin >> n >> l >> r;

		vector<int> v1(n);

		for(int &i : v1){

			cin >> i;

		}

		solve(v1,n,l-1,r-1);

	}

}