ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 1):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using i128 = __int128_t;
const int inf = INT_MAX;

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n+1,0), b(m+1, 0);
    map<int, int> mp;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        mp[a[i]]++;
    }
    priority_queue<int> q;
    for (int i = 1; i <= m; i++){
        cin >> b[i];
        q.push(b[i]);
    }
    int cnt1=0;
    while(!q.empty()){
        int u = q.top();
        q.pop();
        if (mp[u]){
            mp[u]--;
            continue;
        }
        if (u == 1){
            cnt1++;
            continue;
        }
        if (u % 2 == 0){
            int x = u / 2;
            if (mp[x] == 1){
                mp[x] = 0;
                q.push(x);
            }
            else if (mp[x] == 0){
                q.push(x);
                q.push(x);
            }
            else
                mp[x] -= 2;
        }
        else if (u > 1){
            int x = u/2, y = u/2+1;
            if (mp[x]){
                mp[x]--;
            }
            else{
                q.push(x);
            }
            if (mp[y]){
                mp[y]--;
            }
            else
                q.push(y);
        }
    }
    int ans = 1;
    for (auto [x, y] : mp){
        if (y != 0){
            ans = 0;
            break;
        }
    }
    if (cnt1 != mp[1])
        ans = 0;
    if (ans){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }


}

signed main()
{
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


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

using namespace std;

int main()

{

    int t;

    cin >> t;

    while (t--)

    {

       long long n,x=0,sum=0,c2=0,c3=0,num=0,diff=0,i;

       string s;

       cin>>s;

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

        sum+=s[i]-'0';

        if(s[i]=='2'){

            c2++;

        }

        else if(s[i]=='3'){

            c3++;

        }

       }

       if(sum%9==0){

           cout<<"YES"<<endl;

           continue;

       }

       else if(c3==s.length()){

           cout<<"YES"<<endl;

           continue;

       }

       else{

           x=sum/9;

           num=(x+1)*9;

          diff=abs(num-sum);

       

        if(c2*2>=diff){

            cout<<"YES"<<endl;

            continue;

        }

        else if(c3*6>=diff && diff%6==0){

            cout<<"YES"<<endl;

            continue;

        }

        else if(diff%6<=c2*2){

            cout<<"YES"<<endl;

            continue;

        }

        else{

            cout<<"NO"<<endl;

        }

       

    }

  }  



    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

using namespace std;

int main()

{

    int t;

    cin >> t;

    while (t--)

    {

       long long n,x=0,sum=0,c2=0,c3=0,num=0,diff=0,i;

       string s;

       cin>>s;

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

        sum+=s[i]-'0';

        if(s[i]=='2'){

            c2++;

        }

        else if(s[i]=='3'){

            c3++;

        }

       }

       if(sum%9==0){

           cout<<"YES"<<endl;

           continue;

       }

       else if(c3==s.length()){

           cout<<"YES"<<endl;

           continue;

       }

       else{

           x=sum/9;

           num=(x+1)*9;

          diff=abs(num-sum);

       

        if(c2*2>=diff){

            cout<<"YES"<<endl;

            continue;

        }

        else if(c3*6>=diff && diff%6==0){

            cout<<"YES"<<endl;

            continue;

        }

        else if(diff%6<=c2*2){

            cout<<"YES"<<endl;

            continue;

        }

        else{

            cout<<"NO"<<endl;

        }

       

    }

  }  



    return 0;

}

Submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>

using namespace std;

int main()

{

    int t;

    cin >> t;

    while (t--)

    {

       long long n,x=0,sum=0,c2=0,c3=0,num=0,diff=0,i,f=0,j,temp=0;

       string s;

       cin>>s;

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

        sum+=s[i]-'0';

        if(s[i]=='2'){

            c2++;

        }

        else if(s[i]=='3'){

            c3++;

        }

       }

       if(sum%9==0){

           cout<<"YES"<<endl;

           continue;

       }

       else if(c3==s.length()){

           cout<<"YES"<<endl;

           continue;

       }

       else{

          x=sum/9;

          num=(x+1)*9;

          diff=abs(num-sum);

        for(i=0;i<=c2;i++){

            temp=0;

            for(j=0;j<=c3;j++){

                temp=i*2+j*6+sum;

                if(temp%9==0){

                    f=1;

                    break;

                 }

             }

        }



        if(f==0){

            cout<<"NO"<<endl;

        }

        else{

            cout<<"YES"<<endl;

        }



       

    }

  }  



    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>

using namespace std;

int main()

{

    int t;

    cin >> t;

    while (t--)

    {

       long long n,x=0,sum=0,c2=0,c3=0,num=0,diff=0,i,f=0,j,temp=0;

       string s;

       cin>>s;

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

        sum+=s[i]-'0';

        if(s[i]=='2'){

            c2++;

        }

        else if(s[i]=='3'){

            c3++;

        }

       }

       if(sum%9==0){

           cout<<"YES"<<endl;

           continue;

       }

       else if(c3==s.length()){

           cout<<"YES"<<endl;

           continue;

       }

       else{

          x=sum/9;

          num=(x+1)*9;

          diff=abs(num-sum);

        for(i=0;i<=c2;i++){

            temp=0;

            for(j=0;j<=c3;j++){

                temp=i*2+j*6+sum;

                if(temp%9==0){

                    f=1;

                    break;

                 }

             }

        }



        if(f==0){

            cout<<"NO"<<endl;

        }

        else{

            cout<<"YES"<<endl;

        }



       

    }

  }  



    return 0;

}

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

using namespace std;

int main()

{

    int t;

    cin >> t;

    while (t--)

    {

       long long n,x=0,sum=0,c2=0,c3=0,num=0,diff=0,i,f=0,j,temp=0;

       string s;

       cin>>s;

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

        sum+=s[i]-'0';

        if(s[i]=='2'){

            c2++;

        }

        else if(s[i]=='3'){

            c3++;

        }

       }

       if(sum%9==0){

           cout<<"YES"<<endl;

           continue;

       }

       else if(c3==s.length()){

           cout<<"YES"<<endl;

           continue;

       }

       else{

          x=sum/9;

          num=(x+1)*9;

          diff=abs(num-sum);

        for(i=0;i<=c2;i++){

            temp=0;

            if(i*2>99){

                break;

            }

            else{

            for(j=0;j<=c3;j++){

                temp=i*2+j*6;

                if(temp>99){

                    break;

                }

                else if((temp+sum)%9==0){

                    f=1;

                    break;

                 }

             }

             if(f==1){

                 break;

             }

            }

             

        }



        if(f==0){

            cout<<"NO"<<endl;

        }

        else{

            cout<<"YES"<<endl;

        }



       

    }

  }  



    return 0;

}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <vector>
#define int long long
#define N 200005
#define inf (-0x3f3f3f3f)
using namespace std;
int num[60];
signed solve() {
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> num[i];
    if(n==1) {cout<<num[1]<<endl; return 0;}
    int M=0;
    for(int i=1;i<=n;i++) M+=num[i];
    int T=n-1;
    int ans=abs(M);
    while(T--) {
        M=0;
        for(int i=1;i<=n-1;i++) {
            num[i]=(num[i+1]-num[i]);
            M+=num[i];
        }
        n--;
        ans=max(ans,abs(M));
    }
    cout<<ans<<endl;
    return 0;
}
signed main() {
    int T;
    cin >> T;
    while(T--) solve();
}


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <vector>
#define int long long
#define N 200005
#define inf (-0x3f3f3f3f)
using namespace std;
int num[1010];
signed solve() {
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> num[i];
    if(n==1) {cout<<num[1]<<endl; return 0;}
    int M=0;
    for(int i=1;i<=n;i++) M+=num[i];
    int T=n-1;
    int ans=abs(M);
    while(T--) {
        M=0;
        for(int i=1;i<=n-1;i++) {
            num[i]=(num[i+1]-num[i]);
            M+=num[i];
        }
        n--;
        ans=max(ans,abs(M));
    }
    cout<<ans<<endl;
    return 0;
}
signed main() {
    int T;
    cin >> T;
    while(T--) solve();
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <vector>
#define int long long
#define N 200005
#define inf (-0x3f3f3f3f)
using namespace std;
int num[1010];
signed solve() {
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> num[i];
    if(n==1) {cout<<num[1]<<endl; return 0;}
    int M=0;
    for(int i=1;i<=n;i++) M+=num[i];
    int T=n-1;
    int ans=max(M,-M);
    while(T) {
        M=0;
        for(int i=1;i<=T;i++) {
            num[i]=(num[i+1]-num[i]);
            M+=num[i];
        }
        T--;
        ans=max(ans,max(M,-M));
    }
    cout<<ans<<endl;
    return 0;
}
signed main() {
    int T;
    cin >> T;
    while(T--) solve();
}


Submission (verdict: Accepted):
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <vector>
#define int long long
#define N 200005
#define inf (-0x3f3f3f3f)
using namespace std;
int num[1010];
signed solve() {
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> num[i];
    if(n==1) {cout<<num[1]<<endl; return 0;}
    int M=0;
    for(int i=1;i<=n;i++) M+=num[i];
    int T=n-1;
    int ans=M;
    while(T) {
        M=0;
        for(int i=1;i<=T;i++) {
            num[i]=(num[i+1]-num[i]);
            M+=num[i];
        }
        T--;
        ans=max(ans,max(M,-M));
    }
    cout<<ans<<endl;
    return 0;
}
signed main() {
    int T;
    cin >> T;
    while(T--) solve();
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <vector>
#define int long long
#define N 200005
#define inf (-0x3f3f3f3f)
using namespace std;
int num[1010];
signed solve() {
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> num[i];
    if(n==1) {cout<<num[1]<<endl; return 0;}
    int M=0;
    for(int i=1;i<=n;i++) M+=num[i];
    int T=n-1;
    int ans=abs(M);
    while(T--) {
        M=0;
        for(int i=1;i<=n-1;i++) {
            num[i]=(num[i+1]-num[i]);
            M+=num[i];
        }
        n--;
        ans=max(ans,abs(M));
    }
    cout<<ans<<endl;
    return 0;
}
signed main() {
    int T;
    cin >> T;
    while(T--) solve();
}


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <vector>
#define int long long
#define N 200005
#define inf (-0x3f3f3f3f)
using namespace std;
int num[1010];
signed solve() {
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> num[i];
    if(n==1) {cout<<num[1]<<endl; return 0;}
    int M=0;
    for(int i=1;i<=n;i++) M+=num[i];
    int T=n-1;
    int ans=max(M,-M);
    while(T) {
        M=0;
        for(int i=1;i<=T;i++) {
            num[i]=(num[i+1]-num[i]);
            M+=num[i];
        }
        T--;
        ans=max(ans,max(M,-M));
    }
    cout<<ans<<endl;
    return 0;
}
signed main() {
    int T;
    cin >> T;
    while(T--) solve();
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <vector>
#define N 200005
#define inf (-0x3f3f3f3f)
using namespace std;
int num[60];
int solve() {
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> num[i];
    if(n==1) {cout<<num[1]<<endl; return 0;}
    int M=0,last=0;
    for(int i=1;i<=n;i++) M+=num[i];
    int T=n-1;
    int ans=abs(M);
    while(T--) {
        M=0;
        for(int i=1;i<=n-1;i++) {
            num[i]=(num[i+1]-num[i]);
            M+=num[i];
        }
        n--;
        ans=max(ans,abs(M));
    }
    cout<<ans<<endl;
    return 0;
}
int main() {
    int T;
    cin >> T;
    while(T--) solve();
}


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <vector>
#define int long long
#define N 200005
#define inf (-0x3f3f3f3f)
using namespace std;
int num[60];
signed solve() {
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> num[i];
    if(n==1) {cout<<num[1]<<endl; return 0;}
    int M=0;
    for(int i=1;i<=n;i++) M+=num[i];
    int T=n-1;
    int ans=abs(M);
    while(T--) {
        M=0;
        for(int i=1;i<=n-1;i++) {
            num[i]=(num[i+1]-num[i]);
            M+=num[i];
        }
        n--;
        ans=max(ans,abs(M));
    }
    cout<<ans<<endl;
    return 0;
}
signed main() {
    int T;
    cin >> T;
    while(T--) solve();
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <vector>
#define N 200005
#define inf (-0x3f3f3f3f)
using namespace std;
int num[60];
int solve() {
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> num[i];
    if(n==1) {cout<<num[1]<<endl; return 0;}
    int M=0,last=0;
    for(int i=1;i<=n;i++) M+=num[i];
    int T=n-1;
    int ans=abs(M);
    while(T--) {
        M=0;
        for(int i=1;i<=n-1;i++) {
            num[i]=(num[i+1]-num[i]);
            M+=num[i];
        }
        n--;
        ans=max(ans,abs(M));
    }
    cout<<ans<<endl;
    return 0;
}
int main() {
    int T;
    cin >> T;
    while(T--) solve();
}
Problem: 2062C - Cirno and Operations
Language: Java 21

Previous submission (verdict: Wrong answer on test 2):
// package main;
import java.util.Scanner;
import java.io.PrintWriter;
import java.util.List;
import java.util.ArrayList;


// 100 * 50

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int t = scanner.nextInt();
        for (int i = 0; i < t; i++) {
            int n = scanner.nextInt();
            List<Integer> ar = new ArrayList<>();

            for (int j = 0; j < n; j++) {
                ar.add(scanner.nextInt());
            }

            long res = sum(ar);

            while (ar.size() > 1) {
                res = Math.max(res, sum(ar));

                List<Integer> newAr = new ArrayList<>();
                for (int j = 1; j < ar.size(); j++) {
                    newAr.add(ar.get(j) - ar.get(j - 1));
                }
                res = Math.max(res, Math.abs(sum(newAr)));
                ar = newAr;
            }
            out.println(res);
        }
        out.flush();
        out.close();
        scanner.close();
    }

    private static long sum(List<Integer> ar) {
        long sum = 0;
        for (int a : ar) {
            sum += a;
        }
        return sum;
    }
}


Submission (verdict: Accepted):
// package main;
import java.util.Scanner;
import java.io.PrintWriter;
import java.util.List;
import java.util.ArrayList;


// 100 * 50

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int t = scanner.nextInt();
        for (int i = 0; i < t; i++) {
            int n = scanner.nextInt();
            List<Long> ar = new ArrayList<>();

            for (int j = 0; j < n; j++) {
                ar.add(scanner.nextLong());
            }

            long res = sum(ar);

            while (ar.size() > 1) {
                res = Math.max(res, sum(ar));

                List<Long> newAr = new ArrayList<>();
                for (int j = 1; j < ar.size(); j++) {
                    newAr.add(ar.get(j) - ar.get(j - 1));
                }
                res = Math.max(res, Math.abs(sum(newAr)));
                ar = newAr;
            }
            out.println(res);
        }
        out.flush();
        out.close();
        scanner.close();
    }

    private static long sum(List<Long> ar) {
        long sum = 0;
        for (long a : ar) {
            sum += a;
        }
        return sum;
    }
}
Problem: 2062C - Cirno and Operations
Language: Java 21


Submission (verdict: Wrong answer on test 2):
// package main;
import java.util.Scanner;
import java.io.PrintWriter;
import java.util.List;
import java.util.ArrayList;


// 100 * 50

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int t = scanner.nextInt();
        for (int i = 0; i < t; i++) {
            int n = scanner.nextInt();
            List<Integer> ar = new ArrayList<>();

            for (int j = 0; j < n; j++) {
                ar.add(scanner.nextInt());
            }

            int res = sum(ar);

            while (ar.size() > 1) {
                res = Math.max(res, sum(ar));

                List<Integer> newAr = new ArrayList<>();
                for (int j = 1; j < ar.size(); j++) {
                    newAr.add(ar.get(j) - ar.get(j - 1));
                }
                res = Math.max(res, Math.abs(sum(newAr)));
                ar = newAr;
            }
            out.println(res);
        }
        out.flush();
        out.close();
        scanner.close();
    }

    private static int sum(List<Integer> ar) {
        int sum = 0;
        for (int a : ar) {
            sum += a;
        }
        return sum;
    }
}
Problem: 2062C - Cirno and Operations
Language: Java 21

Previous submission (verdict: Wrong answer on test 2):
// package main;
import java.util.Scanner;
import java.io.PrintWriter;
import java.util.List;
import java.util.ArrayList;


// 100 * 50

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int t = scanner.nextInt();
        for (int i = 0; i < t; i++) {
            int n = scanner.nextInt();
            List<Integer> ar = new ArrayList<>();

            for (int j = 0; j < n; j++) {
                ar.add(scanner.nextInt());
            }

            long res = sum(ar);

            while (ar.size() > 1) {
                res = Math.max(res, sum(ar));

                List<Integer> newAr = new ArrayList<>();
                for (int j = 1; j < ar.size(); j++) {
                    newAr.add(ar.get(j) - ar.get(j - 1));
                }
                res = Math.max(res, Math.abs(sum(newAr)));
                ar = newAr;
            }
            out.println(res);
        }
        out.flush();
        out.close();
        scanner.close();
    }

    private static int sum(List<Integer> ar) {
        int sum = 0;
        for (int a : ar) {
            sum += a;
        }
        return sum;
    }
}


Submission (verdict: Wrong answer on test 2):
// package main;
import java.util.Scanner;
import java.io.PrintWriter;
import java.util.List;
import java.util.ArrayList;


// 100 * 50

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int t = scanner.nextInt();
        for (int i = 0; i < t; i++) {
            int n = scanner.nextInt();
            List<Integer> ar = new ArrayList<>();

            for (int j = 0; j < n; j++) {
                ar.add(scanner.nextInt());
            }

            long res = sum(ar);

            while (ar.size() > 1) {
                res = Math.max(res, sum(ar));

                List<Integer> newAr = new ArrayList<>();
                for (int j = 1; j < ar.size(); j++) {
                    newAr.add(ar.get(j) - ar.get(j - 1));
                }
                res = Math.max(res, Math.abs(sum(newAr)));
                ar = newAr;
            }
            out.println(res);
        }
        out.flush();
        out.close();
        scanner.close();
    }

    private static long sum(List<Integer> ar) {
        long sum = 0;
        for (int a : ar) {
            sum += a;
        }
        return sum;
    }
}
Problem: 2062C - Cirno and Operations
Language: Java 21

Previous submission (verdict: Wrong answer on test 2):
// package main;
import java.util.Scanner;
import java.io.PrintWriter;
import java.util.List;
import java.util.ArrayList;


// 100 * 50

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int t = scanner.nextInt();
        for (int i = 0; i < t; i++) {
            int n = scanner.nextInt();
            List<Integer> ar = new ArrayList<>();

            for (int j = 0; j < n; j++) {
                ar.add(scanner.nextInt());
            }

            int res = sum(ar);

            while (ar.size() > 1) {
                res = Math.max(res, sum(ar));

                List<Integer> newAr = new ArrayList<>();
                for (int j = 1; j < ar.size(); j++) {
                    newAr.add(ar.get(j) - ar.get(j - 1));
                }
                res = Math.max(res, Math.abs(sum(newAr)));
                ar = newAr;
            }
            out.println(res);
        }
        out.flush();
        out.close();
        scanner.close();
    }

    private static int sum(List<Integer> ar) {
        int sum = 0;
        for (int a : ar) {
            sum += a;
        }
        return sum;
    }
}


Submission (verdict: Wrong answer on test 2):
// package main;
import java.util.Scanner;
import java.io.PrintWriter;
import java.util.List;
import java.util.ArrayList;


// 100 * 50

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int t = scanner.nextInt();
        for (int i = 0; i < t; i++) {
            int n = scanner.nextInt();
            List<Integer> ar = new ArrayList<>();

            for (int j = 0; j < n; j++) {
                ar.add(scanner.nextInt());
            }

            long res = sum(ar);

            while (ar.size() > 1) {
                res = Math.max(res, sum(ar));

                List<Integer> newAr = new ArrayList<>();
                for (int j = 1; j < ar.size(); j++) {
                    newAr.add(ar.get(j) - ar.get(j - 1));
                }
                res = Math.max(res, Math.abs(sum(newAr)));
                ar = newAr;
            }
            out.println(res);
        }
        out.flush();
        out.close();
        scanner.close();
    }

    private static int sum(List<Integer> ar) {
        int sum = 0;
        for (int a : ar) {
            sum += a;
        }
        return sum;
    }
}