ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

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

void solve(){
    long long n;
    cin>>n;
    vector<long long> v(n);
    for(long long i=0;i<n;i++){
        cin>>v[i];
    }

    long long sum=0;
    for(auto x:v){
        sum+=x;
    }
    if(sum%n!=0){
        cout<<"no"<<endl;return;
    }

    long long k=sum/n;
    for(int i=1;i<n-1;i++){

        if(v[i-1]==k){
            continue;
        }

        else if(v[i-1]<k){
            long long d=k-v[i-1];
            v[i-1]+=d;
            v[i+1]-=d;
            if(v[i-1]<0 || v[i+1]<0){
                cout<<"no"<<endl;
                return;
            }
        }

        else if(v[i-1]>k){
            long long d=v[i-1]-k;
            v[i-1]-=d;
            v[i+1]+=d;
            if(v[i-1]<0 || v[i+1]<0){
                cout<<"no"<<endl;
                return;
            }
        }
    }
    long long count=0;
    for(auto x:v){
        if(x==k){
            count++;
        }
    }
    if(count==n){
        cout<<"yes"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}

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

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

void solve() {
    long long n;
    cin >> n;
    vector<long long> v(n);
    
    long long sum = 0;
    for (long long i = 0; i < n; i++) {
        cin >> v[i];
        sum += v[i];
    }

    if (sum % n != 0) {
        cout << "no" << endl;
        return;
    }

    long long k = sum / n; // Target value for each element
    vector<long long> balance(n, 0);

    // Calculate balance array
    for (int i = 1; i < n - 1; i++) {
        long long left = v[i - 1] + balance[i - 1];
        long long current = v[i] + balance[i];
        long long right = v[i + 1];

        if (left > k) {
            long long excess = left - k;
            balance[i] += excess;
            balance[i - 1] -= excess;
        } else if (left < k) {
            long long deficit = k - left;
            balance[i] -= deficit;
            balance[i - 1] += deficit;
        }

        if (balance[i] < 0 || balance[i - 1] < 0 || balance[i + 1] < 0) {
            cout << "no" << endl;
            return;
        }
    }

    cout << "yes" << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)


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

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

    int sum=0;
    for(auto x:v){
        sum+=x;
    }
    if(sum%n!=0){
        cout<<"no"<<endl;return;
    }

    long long k=sum/n;
    for(int i=1;i<n-1;i++){

        if(v[i-1]==k){
            continue;
        }

        else if(v[i-1]<k){
            long long d=k-v[i-1];
            v[i-1]+=d;
            v[i+1]-=d;
            if(v[i-1]<0 || v[i+1]<0){
                cout<<"no"<<endl;
                return;
            }
        }

        else if(v[i-1]>k){
            long long d=v[i-1]-k;
            v[i-1]-=d;
            v[i+1]+=d;
            if(v[i-1]<0 || v[i+1]<0){
                cout<<"no"<<endl;
                return;
            }
        }
    }
    long long count=0;
    for(auto x:v){
        if(x==k){
            count++;
        }
    }
    if(count==n){
        cout<<"yes"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}

int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
    }
return 0;
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

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

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

    int sum=0;
    for(auto x:v){
        sum+=x;
    }
    if(sum%n!=0){
        cout<<"no"<<endl;return;
    }

    long long k=sum/n;
    for(int i=1;i<n-1;i++){

        if(v[i-1]==k){
            continue;
        }

        else if(v[i-1]<k){
            long long d=k-v[i-1];
            v[i-1]+=d;
            v[i+1]-=d;
            if(v[i-1]<0 || v[i+1]<0){
                cout<<"no"<<endl;
                return;
            }
        }

        else if(v[i-1]>k){
            long long d=v[i-1]-k;
            v[i-1]-=d;
            v[i+1]+=d;
            if(v[i-1]<0 || v[i+1]<0){
                cout<<"no"<<endl;
                return;
            }
        }
    }
    long long count=0;
    for(auto x:v){
        if(x==k){
            count++;
        }
    }
    if(count==n){
        cout<<"yes"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}

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

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

void solve(){
    long long n;
    cin>>n;
    vector<long long> v(n);
    for(long long i=0;i<n;i++){
        cin>>v[i];
    }

    long long sum=0;
    for(auto x:v){
        sum+=x;
    }
    if(sum%n!=0){
        cout<<"no"<<endl;return;
    }

    long long k=sum/n;
    for(int i=1;i<n-1;i++){

        if(v[i-1]==k){
            continue;
        }

        else if(v[i-1]<k){
            long long d=k-v[i-1];
            v[i-1]+=d;
            v[i+1]-=d;
            if(v[i-1]<0 || v[i+1]<0){
                cout<<"no"<<endl;
                return;
            }
        }

        else if(v[i-1]>k){
            long long d=v[i-1]-k;
            v[i-1]-=d;
            v[i+1]+=d;
            if(v[i-1]<0 || v[i+1]<0){
                cout<<"no"<<endl;
                return;
            }
        }
    }
    long long count=0;
    for(auto x:v){
        if(x==k){
            count++;
        }
    }
    if(count==n){
        cout<<"yes"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}

int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
    }
return 0;
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

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

void solve() {
    int n;
    cin>>n;
    ll od=0,ev=0;
    ll nd=0,ne=0;
    f(i,0,n){
        if(i%2==0){
            int s;
            cin>>s;
            ne++;
            ev+=s;
        }
        if(i%2==1){
            int s;
            cin>>s;
            nd++;
            od+=s;
        }
    }
    if(ev%ne!=0){
        pno;
        return;
    }
    if(od%nd!=0){
        pno;
        return;
    }
    if(ev/ne==od/nd){
        pyes;
        return;
    }else{
        pno;
    }
}

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

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

#define ll long long 
#define vi vector<int>
#define vll vector<ll>
#define pyes cout << "YES" << endl;
#define pno cout << "NO" << endl;
#define f(i, a, b) for(ll i = a; i < b; i++)
#define fe(i, a, b) for(ll i = a; i <= b; i++)

void solve() {
    int n;
    cin>>n;
    ll od=0,ev=0;
    ll nd=0,ne=0;
    f(i,0,n){
        if(i%2==0){
            int s;
            cin>>s;
            ne++;
            ev+=s;
        }
        if(i%2==1){
            int s;
            cin>>s;
            nd++;
            od+=s;
        }
    }
    if(ev%ne!=0){
        pno;
        return;
    }
    if(od%nd!=0){
        pno;
        return;
    }
    if(ev/ne==od/nd){
        pyes;
        return;
    }else{
        pno;
    }
}

int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
    }
return 0;
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

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

void solve() {
    long long n;
    cin >> n;
    vector<long long> v(n);
    
    long long sum = 0;
    for (long long i = 0; i < n; i++) {
        cin >> v[i];
        sum += v[i];
    }

    if (sum % n != 0) {
        cout << "no" << endl;
        return;
    }

    long long k = sum / n; // Target value for each element
    vector<long long> balance(n, 0);

    // Calculate balance array
    for (int i = 1; i < n - 1; i++) {
        long long left = v[i - 1] + balance[i - 1];
        long long current = v[i] + balance[i];
        long long right = v[i + 1];

        if (left > k) {
            long long excess = left - k;
            balance[i] += excess;
            balance[i - 1] -= excess;
        } else if (left < k) {
            long long deficit = k - left;
            balance[i] -= deficit;
            balance[i - 1] += deficit;
        }

        if (balance[i] < 0 || balance[i - 1] < 0 || balance[i + 1] < 0) {
            cout << "no" << endl;
            return;
        }
    }

    cout << "yes" << endl;
}

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


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

void solve() {
    int n;
    cin>>n;
    ll od=0,ev=0;
    ll nd=0,ne=0;
    f(i,0,n){
        if(i%2==0){
            int s;
            cin>>s;
            ne++;
            ev+=s;
        }
        if(i%2==1){
            int s;
            cin>>s;
            nd++;
            od+=s;
        }
    }
    if(ev%ne!=0){
        pno;
        return;
    }
    if(od%nd!=0){
        pno;
        return;
    }
    if(ev/ne==od/nd){
        pyes;
        return;
    }else{
        pno;
    }
}

int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
    }
return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

void solve()
{
    int n;
    cin >> n;

    vector<vector<int>> adj(n);
    int u, v;

    set<pair<int, int>> st;
    vector<pair<int, int>> degree(n);
    // vector<vector<int>> adj(n);

    for(int i=0; i<n; i++)
    degree[i] = {0, i};

    for(int i=0; i<n-1; i++)
    {
        cin >> u >> v;
        --u;
        --v;
        st.insert({min(u, v), max(u, v)});
        ++degree[u].first;
        ++degree[v].first;
        // adj[u].push_back(v);
        // adj[v].push_back(u);
    }

    if(n == 2)
    {
        cout << "0\n";
        return;
    }

    // the more degree a node has, the more connected components it will have
    // after removal of it
    sort(degree.begin(), degree.end(), greater<pair<int, int>>());

    // consider 3 adjacent nodes n1, n2, n3 with max degree
    // Let max degree be 2
    // In this case, there has to be an edge {n1, n2} or {n2, n3} or {n1, n3}
    // which is not part of the graph.
    // If all 3 were part, then it would have cycle and won't be a tree

    // so, if > 2 nodes with max degree, answer = maxdegree + maxdegree - 1
    // basically, we remove those 2 nodes which don't have common edge
    // if there are 2 max degree nodes, we can brute force with all other possibilities

    int maxDegreeCount = 1, secMaxDegreeCount = 0;
    int maxVal = degree[0].first, secMaxVal = -1;

    bool first = true, second = true;
    for(int i=1; i<n; i++)
    {
        if(first && degree[i].first == degree[i - 1].first)
        ++maxDegreeCount;

        else if(first)
        {
            first = false;
            secMaxDegreeCount = 1;
            secMaxVal = degree[i].first;
            continue;
        }

        if(!first && second && degree[i].first == degree[i - 1].first)
        ++secMaxDegreeCount;

        else
        break;
    }

    if(maxDegreeCount >= 3)
    {
        cout << (2 * maxVal - 1) << "\n";
        return; 
    }

    int i = 0;
    int maxi = 0;
    while(i < maxDegreeCount)
    {
        auto [d1, node1] = degree[i];
        int j = i + 1;

        int limit = maxDegreeCount + secMaxDegreeCount;
        while(j < limit)
        {
            auto [d2, node2] = degree[j];
            if(st.find({min(node1, node2), max(node1, node2)}) != st.end())
            maxi = max(maxi, d1 + d2 - 2);

            else
            maxi = max(maxi, d1 + d2 - 1);
            ++j;
        }

        ++i;
    }

    cout << maxi << "\n";
}

int main()
{
    int t;
    cin >> t;

    while(t > 0)
    {
        solve();
        --t;
    }

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


Submission (verdict: Wrong answer on test 1):
//******************************************************************
//						Author: Ritik Arora
#include <bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

#define ll long long int

#include <ext/pb_ds/assoc_container.hpp> // Common file
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key

#define nline '\n'
#define inf LLONG_MAX
ll mod1 = 1e9 + 7;
ll mod2 = 998244353;

ll expo(ll a, ll b, ll mod)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
        b = b >> 1;
    }
    return res;
}

vector<ll> sieve(int n)
{
    int *arr = new int[n + 1]();
    vector<ll> vect;
    for (int i = 2; i <= n; i++)
        if (arr[i] == 0)
        {
            vect.push_back(i);
            for (int j = 2 * i; j <= n; j += i)
                arr[j] = 1;
        }
    return vect;
}

ll inverseMod(ll n, ll mod) { return expo(n, mod - 2, mod); }
ll mod_mul(ll a, ll b, ll m)
{
    a = a % m;
    b = b % m;
    return (((a * b) % m) + m) % m;
}
ll mod_div(ll a, ll b, ll m)
{
    a = a % m;
    b = b % m;
    return (mod_mul(a, inverseMod(b, m), m) + m) % m;
} // only for prime m

#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define alice cout<<"ALICE"<<endl
#define bob cout<<"BOB"<<endl
#define draw cout<<"DRAW"<<endl



void solve()
{
    ll l,r;
    cin >> l >> r;
    ll fix = 0;
    for (int i = 29; i >= 0;i--)
    {
        ll a = (r >> i) & 1;
        ll b = (l >> i) & 1;
        if(a)
        {
            if(b) {
                fix += (1 << i);
            }
            else{
                ll wt = 1 << i;
                cout << wt+fix << " " << wt+fix - 1 << " " << wt+fix - 1 << endl;
                return;
            }
        }
    }
    
}
int main()
{
    // unordered_map<long long int,int,custom_hash> mp;
    // StringHash hash(word);
    // hash.substrHash(idx1,idx2)==hash.substrHash(idx3,idx4);
    // Trie* T = new Trie();
    // string ritik="ritik";
    // T->insertNode(ritik);
    // #ifndef ONLINE_JUDGE
    // freopen("Error.txt", "w", stderr);
    // #endif
    fastio();
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

using namespace std;

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define endl "\n"
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define set_bits __builtin_popcountll
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key

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

void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T> void _print(unordered_set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T, class V> void _print(unordered_map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T> void _print(unordered_multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(unordered_set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(unordered_multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(unordered_map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}

// #define int long long

void solve(){
    int n, l, r, sum = 0;
    cin >> n >> l >>r;
    vector<int> a(n);

    for(int i=0; i<n; i++)
        cin >> a[i];
    
    sort(all(a));
    for(int i=0; i<=r-l; i++)
        sum += a[i];
    
    cout<< sum << endl;

}

signed main() {
#ifndef ONLINE_JUDGE
    freopen("debug.txt", "w", stderr);
#endif
    fastio();

    int t = 1;
    cin >> t;
    while(t--){
        solve();       
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Runtime error on test 6):
#include <bits/stdc++.h>
using namespace std;

#define int long long

#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

void fastio(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int maxN=2e3;
const int INF=1e9;
const int MOD=1e9+7;

int t, n, l, r, ans1, ans2;
vi arr, a1, a2;

bool invComp(int a, int b){
    return a>=b;
}

signed main(){
    fastio();
    cin >> t;
    while(t--){
        cin >> n >> l >> r;
        arr.resize(n, 0);
        a1.resize(n, 0);
        a2.resize(n, 0);
        for(int i=0; i<n; i++){
            cin >> arr[i];
        }
        l--; r--;
        a1=a2=arr;
        sort(a1.begin(), a1.begin()+r+1, invComp);
        sort(a2.begin()+l, a2.end());
        ans1=ans2=0;
        for(int i=l; i<=r; i++){
            ans1+=a1[i];
            ans2+=a2[i];
        }
        cout << min(ans1, ans2) << endl;
    }
    return 0;
}


Submission (verdict: Runtime error on test 6):
#include <bits/stdc++.h>
using namespace std;

#define int long long

#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

void fastio(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int maxN=2e3;
const int INF=1e9;
const int MOD=1e9+7;

int t, n, l, r, ans1, ans2;
vi arrM, arr;

bool invComp(int a, int b){
    return a>=b;
}

signed main(){
    fastio();
    cin >> t;
    while(t--){
        cin >> n >> l >> r;
        arr.resize(n, 0);
        for(int i=0; i<n; i++){
            cin >> arr[i];
        }
        l--; r--;
        ans1=ans2=0;
        arrM=arr;
        sort(arrM.begin(), arrM.begin()+r+1, invComp);
        for(int i=l; i<=r; i++){
            ans1+=arrM[i];
        }
        arrM=arr;
        sort(arrM.begin()+l, arrM.end());
        for(int i=l; i<=r; i++){
            ans2+=arrM[i];
        }
        cout << min(ans1, ans2) << endl;
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Runtime error on test 6):
#include <bits/stdc++.h>
using namespace std;

#define int long long

#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

void fastio(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int maxN=2e3;
const int INF=1e9;
const int MOD=1e9+7;

int t, n, l, r, ans1, ans2;
vi arrM, arr;

bool invComp(int a, int b){
    return a>=b;
}

signed main(){
    fastio();
    cin >> t;
    while(t--){
        cin >> n >> l >> r;
        arr.resize(n, 0);
        for(int i=0; i<n; i++){
            cin >> arr[i];
        }
        l--; r--;
        ans1=ans2=0;
        arrM=arr;
        sort(arrM.begin(), arrM.begin()+r+1, invComp);
        for(int i=l; i<=r; i++){
            ans1+=arrM[i];
        }
        arrM=arr;
        sort(arrM.begin()+l, arrM.end());
        for(int i=l; i<=r; i++){
            ans2+=arrM[i];
        }
        cout << min(ans1, ans2) << endl;
    }
    return 0;
}


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

#define int long long

#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

void fastio(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int maxN=2e3;
const int INF=1e9;
const int MOD=1e9+7;

int t, n, l, r, ans1, ans2;
vi arrM, arr;

bool invComp(int a, int b){
    return a>=b;
}

signed main(){
    fastio();
    cin >> t;
    while(t--){
        cin >> n >> l >> r;
        arr.resize(n+50, 0);
        for(int i=0; i<n; i++){
            cin >> arr[i];
        }
        l--; r--;
        ans1=ans2=0;
        arrM=arr;
        sort(arrM.begin(), arrM.begin()+r+1, invComp);
        for(int i=l; i<=r; i++){
            ans1+=arrM[i];
        }
        arrM=arr;
        sort(arrM.begin()+l, arrM.begin()+n);
        for(int i=l; i<=r; i++){
            ans2+=arrM[i];
        }
        cout << min(ans1, ans2) << endl;
    }
    return 0;
}