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

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

using namespace std;

typedef long long ll;

typedef long double ld;

#define fu(i,a,b) for(int i = a; i<b; i++)

#define f(i,a) for(int i = 0; i<a; i++)

#define fi(i,a) for(int i = a-1; i>=0; i--)

const int MOD = 998244353;

const int NMAX = 200000;







int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);

    

  



    int t;

    cin >> t;

    while (t--) {

        int n;

        cin >> n;

        

        string s;



        int t=0;



        cin >> s;



        if(s[0]== 's')

        {

            t=1;

            fu(i,1,n-1)

            {

                if(s[i]!='s'&& s[i]!='.')

                {

                    t=0;

                }

            }



        }

        else if(s[n-1]=='p')

        {

            t=1;

            fu(i,1,n)

            {

                if(s[i]!='p'&& s[i]!='.')

                {

                    t=0;

                }

            }

        }

        else

        {

            t=1;

            f(i,n)

            {

                if(s[i]!= '.')

                {

                    t=0;

                }

            }

        }



        char m = '.';





        f(i,n)

        {





            if(s[i]=='s' && m == 'p')

            {

                t=0;

            }







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

            {

                m = 's';

            }

            if(s[i]=='p')

            {

                m = 'p';

            }



        }



        if(t==1)

        {

            cout << "YES" << endl;

        }

        else

        {

            cout << "NO" << endl;

        }







    }



    return 0;

}



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

using namespace std;

typedef long long ll;

typedef long double ld;

#define fu(i,a,b) for(int i = a; i<b; i++)

#define f(i,a) for(int i = 0; i<a; i++)

#define fi(i,a) for(int i = a-1; i>=0; i--)

const int MOD = 998244353;

const int NMAX = 200000;







int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);

    

  



    int t;

    cin >> t;

    while (t--) {

        int n;

        cin >> n;

        

        string s;



        int t=0;



        cin >> s;



        if(s[0]=='s')

        {

            s[0] = '.';

        }

        if(s[n-1]=='p')

        {

            s[n-1] = '.';

        }



        int g=0,h=0;



        f(i,n)

        {



            if(s[i]=='p')

            {

                g =1;

            }

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

            {

                h =1;

            }



        }



        if(g==1 && h==1)

        {

            cout << "NO" << endl;

        }

        else

        {

            cout << "YES" << endl;

        }





    }



    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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


int main(){
    int t;
    cin>>t;
    while(t--){
        int n,l,r;
        cin>>n>>l>>r;
        l--;
        r--;
        vector<ll> a(n);
        vector<ll> v;

        for(int i=0;i<n;i++){
            cin>>a[i];
        }

       for(int i=r;i>=l;i--){
        v.push_back(a[i]);
        a.erase(a.begin()+i);
       }
       
       ll ma=0;
       ll mi=0;
       ll x=0;
       while(1){
         mi=*min_element(a.begin(),a.end());
         ma=*max_element(v.begin(),v.end());
          if(ma<=mi) break;
          if(a.empty() || v.empty()) break;
         v.push_back(mi);
         a.push_back(ma);
         v.erase(find(v.begin(),v.end(),ma));
         a.erase(find(a.begin(),a.end(),mi));
         
        
       }

       ll sum=0;
       sum=accumulate(v.begin(),v.end(),0LL);

       cout<<sum<<endl;

    }
}

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


int main(){
    int t;
    cin>>t;
    while(t--){
        int n,l,r;
        cin>>n>>l>>r;
        l--;
        r--;
        vector<ll> a(n);
        vector<ll> v;

        for(int i=0;i<n;i++){
            cin>>a[i];
        }

       for(int i=r;i>=l;i--){
        v.push_back(a[i]);
       }
        a.erase(a.begin()+l,a.begin()+r+1);
       
       ll ma=0;
       ll mi=0;
       ll x=0;
       while(1){
         if(a.empty() || v.empty()) break;
         mi=*min_element(a.begin(),a.end());
         ma=*max_element(v.begin(),v.end());
          if(ma<=mi) break;
         v.push_back(mi);
         a.push_back(ma);
         v.erase(find(v.begin(),v.end(),ma));
         a.erase(find(a.begin(),a.end(),mi));
         
        
       }

       ll sum=0;
       sum=accumulate(v.begin(),v.end(),0LL);
       cout<<sum<<endl;

    }
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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


int main(){
    int t;
    cin>>t;
    while(t--){
        int n,l,r;
        cin>>n>>l>>r;
        l--;
        r--;
        vector<ll> a(n);
        vector<ll> v;

        for(int i=0;i<n;i++){
            cin>>a[i];
        }

       for(int i=r;i>=l;i--){
        v.push_back(a[i]);
        a.erase(a.begin()+i);
       }
       
       ll ma=0;
       ll mi=0;
       ll x=0;
       while(1){
         mi=*min_element(a.begin(),a.end());
         ma=*max_element(v.begin(),v.end());
          if(ma<=mi) break;
          if(a.empty() || v.empty()) break;
         v.push_back(mi);
         a.push_back(ma);
         v.erase(find(v.begin(),v.end(),ma));
         a.erase(find(a.begin(),a.end(),mi));
         
        
       }

       ll sum=0;
       sum=accumulate(v.begin(),v.end(),0LL);

       cout<<sum<<endl;

    }
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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


int main(){
    int t;
    cin>>t;
    while(t--){
        int n,l,r;
        cin>>n>>l>>r;
        l--;
        r--;
        vector<ll> a(n);
        vector<ll> v;

        for(int i=0;i<n;i++){
            cin>>a[i];
        }

       for(int i=r;i>=l;i--){
        v.push_back(a[i]);
       }
        a.erase(a.begin()+l,a.begin()+r+1);
       
       ll ma=0;
       ll mi=0;
       ll x=0;
       while(1){
         if(a.empty() || v.empty()) break;
         mi=*min_element(a.begin(),a.end());
         ma=*max_element(v.begin(),v.end());
          if(ma<=mi) break;
         v.push_back(mi);
         a.push_back(ma);
         v.erase(find(v.begin(),v.end(),ma));
         a.erase(find(a.begin(),a.end(),mi));
         
        
       }

       ll sum=0;
       sum=accumulate(v.begin(),v.end(),0LL);
       cout<<sum<<endl;

    }
}

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


int main(){
    int t;
    cin>>t;
    while(t--){
        int n,l,r;
        cin>>n>>l>>r;
        l--;
        r--;
        vector<ll> a(n);
        vector<ll> v;

        for(int i=0;i<n;i++){
            cin>>a[i];
        }

       for(int i=r;i>=l;i--){
        v.push_back(a[i]);
       }
        a.erase(a.begin()+l,a.begin()+r+1);
       
       sort(a.begin(),a.end());
       sort(v.begin(),v.end());
       ll ma=0;
       ll mi=0;
       ll x=0;

       while(1){
         if(a.empty() || v.empty()) break;
        
         mi=*min_element(a.begin(),a.end());
         ma=*max_element(v.begin(),v.end());
          if(ma<=mi) break;
         v.push_back(mi);
         a.push_back(ma);
         v.erase(find(v.begin(),v.end(),ma));
         a.erase(find(a.begin(),a.end(),mi));
          if(v.size()==(l-r+1)) break;
       }

       ll sum=0;
       sum=accumulate(v.begin(),v.end(),0LL);
       cout<<sum<<endl;

    }
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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


int main(){
    int t;
    cin>>t;
    while(t--){
        int n,l,r;
        cin>>n>>l>>r;
        l--;
        r--;
        vector<ll> a(n);
        vector<ll> v;

        for(int i=0;i<n;i++){
            cin>>a[i];
        }

       for(int i=r;i>=l;i--){
        v.push_back(a[i]);
       }
        a.erase(a.begin()+l,a.begin()+r+1);
       
       sort(a.begin(),a.end());
       sort(v.begin(),v.end());
       ll ma=0;
       ll mi=0;
       ll x=0;

       while(1){
         if(a.empty() || v.empty()) break;
        
         mi=*min_element(a.begin(),a.end());
         ma=*max_element(v.begin(),v.end());
          if(ma<=mi) break;
         v.push_back(mi);
         a.push_back(ma);
         v.erase(find(v.begin(),v.end(),ma));
         a.erase(find(a.begin(),a.end(),mi));
          if(v.size()==(l-r+1)) break;
       }

       ll sum=0;
       sum=accumulate(v.begin(),v.end(),0LL);
       cout<<sum<<endl;

    }
}

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


int main(){
    int t;
    cin>>t;
    while(t--){
        int n,l,r;
        cin>>n>>l>>r;
        l--;
        r--;
        vector<ll> a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }

        vector<ll> lft;
        vector<ll> rht;
        
       for(int i=0;i<=r;i++){
        lft.push_back(a[i]);
       }
       
       for(int i=l;i<n;i++){
        rht.push_back(a[i]);
       }

       sort(lft.begin(),lft.end());
       sort(rht.begin(),rht.end());
       ll suml=0,sumr=0;
       for(int i=0;i<(r-l+1);i++){
         suml+=lft[i];
         sumr+=rht[i];
       }

       ll sum=min(suml,sumr);
       cout<<sum<<endl;
    }
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include <bitset>

#include <cstdint>

#include <cmath>

#include <functional>

#include <algorithm>

#include <numeric>

#include <system_error>

#include <deque>

#include <fstream>

#include <iomanip>

#include <iostream>

#include <iterator>

#include <limits>

#include <list>

#include <map>

#include <unordered_map>

#include <queue>

#include <set>

#include <stack>

#include <string>

#include <vector>

#include <cstring>

#include <climits>

#include <sstream>

#include <cstdlib>

#define pb push_back

#define NMAX 800001

//#define MOD 1000000007

#define MOD 666013

#define nl '\n'



//#pragma GCC optimize("O3")

//#pragma GCC optimize("unroll-loops")

#define int long long

#define pii pair<int,int>

#define tpl tuple<int,int,int>

//#include "modulosum.h"

//#define cin fin

//#define cout fout

using namespace std;

const int INF=1e9;

ifstream fin("berries.in");

ofstream fout("berries.out");



/*

    ====================DEMONSTRATION======================



    16

    223333

    449933



    =========================END===========================

*/







void solve()

{

    string s;

    cin>>s;

    int sum=0;

    map<int,int>mp;

    for(auto x:s)

    {

        sum+=(x-'0');

        mp[x-'0']++;

    }

    int need=9-sum%9;

    cout<<need<<nl;

    if(need==0)

    {

        cout<<"YES"<<nl;

        return;

    }

    for(int i=0;i<=mp[2];++i)

    {

        for(int j=0;j<=mp[3];++i)

        {

            if((sum+(i*2)+(j*6))%9==0)

            {

                cout<<"YES"<<nl;

                return;

            }

        }

    }



    cout<<"NO"<<nl;

}

signed main(){



    ios_base::sync_with_stdio(false);

    cin.tie(NULL);



    int t;

    cin>>t;

    while(t--)

        solve();





    return 0;

}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

using namespace std;

#define int long long

#define endl '\n'

signed main(){

//???C++????????????????????C++???????????
std::ios::sync_with_stdio(false);

//???cin??out????????????????????
std::cin.tie(0);

std::cout.tie(0);//??????????????????
int t;cin>>t;

while(t--){

string s;cin>>s;

vector<int>a(s.size());

int all =0;

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

a[i] = s[i]-'0';

}

for(int i = 1;i<a.size();i++){

int f = -1;

for(int j = i-1;j>=max(0LL,j-8);j--){

if(a[j]+(i-j)<a[i]){

f = j;

}

}

if(f==-1){

continue;

}

int tmp = a[i] - (i-f);

for(int j = i;j>=f+1;j--){

a[j] = a[j-1];

}

a[f] = tmp;

}

for(auto x:a){

cout<<x;

}

cout<<endl;

}

return 0;

}

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

using namespace std;

#define int long long

#define endl '\n'

signed main(){

//???C++????????????????????C++???????????
std::ios::sync_with_stdio(false);

//???cin??out????????????????????
std::cin.tie(0);

std::cout.tie(0);//??????????????????
int t;cin>>t;

while(t--){

string s;cin>>s;

vector<int>a(s.size());

int all =0;

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

a[i] = s[i]-'0';

}

for(int i = 1;i<a.size();i++){

int f = -1;

for(int j = i-1;j>=max(0LL,j-8);j--){

if(a[j]+(i-j)<a[i]){

f = j;

}else{break;}

}

if(f==-1){

continue;

}

int tmp = a[i] - (i-f);

for(int j = i;j>=f+1;j--){

a[j] = a[j-1];

}

a[f] = tmp;

}

for(auto x:a){

cout<<x;

}

cout<<endl;

}

return 0;

}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

using namespace std;

#define int long long

#define endl '\n'

signed main(){

int t;cin>>t;

while(t--){

string s;cin>>s;

vector<int>a(s.size());

vector<int>cnt(10,0);

int all =0;

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

a[i] = s[i]-'0';

}

for(int i = 1;i<a.size();i++){

int f = -1;

for(int j = i-1;j>=max(0LL,j-9);j--){

if(a[j]+(i-j)<a[i]){

f = j;

}

}

// cout<<f<<endl;

if(f==-1){

continue;

}

int tmp = a[i] - (i-f);

for(int j = i;j>=f+1;j--){

a[j] = a[j-1];

}

a[f] = tmp;

}

for(auto x:a){

cout<<x;

}

cout<<endl;

}

return 0;

}

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

using namespace std;

#define int long long

#define endl '\n'

signed main(){

//???C++????????????????????C++???????????
std::ios::sync_with_stdio(false);

//???cin??out????????????????????
std::cin.tie(0);

std::cout.tie(0);//??????????????????
int t;cin>>t;

while(t--){

string s;cin>>s;

vector<int>a(s.size());

int all =0;

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

a[i] = s[i]-'0';

}

for(int i = 1;i<a.size();i++){

int f = -1;

for(int j = i-1;j>=max(0LL,j-8);j--){

if(a[j]+(i-j)<a[i]){

f = j;

}

}

if(f==-1){

continue;

}

int tmp = a[i] - (i-f);

for(int j = i;j>=f+1;j--){

a[j] = a[j-1];

}

a[f] = tmp;

}

for(auto x:a){

cout<<x;

}

cout<<endl;

}

return 0;

}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


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

using namespace std;

#define int long long

#define endl '\n'

signed main(){

int t;cin>>t;

while(t--){

string s;cin>>s;

vector<int>a(s.size());

vector<int>cnt(10,0);

int all =0;

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

a[i] = s[i]-'0';

}

for(int i = 1;i<a.size();i++){

int f = -1;

for(int j = i-1;j>=max(0LL,j-9);j--){

if(a[j]+(i-j)<a[i]){

f = j;

}

}

// cout<<f<<endl;

if(f==-1){

continue;

}

int tmp = a[i] - (i-f);

for(int j = i;j>=f+1;j--){

a[j] = a[j-1];

}

a[f] = tmp;

}

for(auto x:a){

cout<<x;

}

cout<<endl;

}

return 0;

}
Problem: 2063C - Remove Exactly Two
Language: PyPy 3-64

Previous submission (verdict: Time limit exceeded on test 9):
from collections import defaultdict

t = int(input())

def find_max_edges(graph):
    max_us = []
    max_n = -1
    for u in graph:
        if len(graph[u]) > max_n:
            max_us, max_n = [u], len(graph[u])
        elif len(graph[u]) == max_n:
            max_us.append(u)
    return max_us, max_n

for _ in range(t):
    g = defaultdict(list)
    g_lengths = defaultdict(int)
    n = int(input())
    for i in range(n - 1):
        u, v = input().split(' ')
        g[u].append(v)
        g[v].append(u)
        g_lengths[u] += 1
        g_lengths[v] += 1

    us, n = find_max_edges(g)
    max_2nd_edges = 0
    for u in us:
        u_adj = set(g[u])
        for node in g_lengths:
            if node == u:
                continue
            max_2nd_edges = max(g_lengths[node] - (1 if node in u_adj else 0), max_2nd_edges)

    components = 1
    components += n - 1
    components += max_2nd_edges - 1
    print(components)


Submission (verdict: Accepted):
from collections import defaultdict

t = int(input())

def find_max_edges(graph):
    max_us = []
    max_n = -1
    for u in graph:
        if len(graph[u]) > max_n:
            max_us, max_n = [u], len(graph[u])
        elif len(graph[u]) == max_n:
            max_us.append(u)
    return max_us, max_n

for _ in range(t):
    g = defaultdict(list)
    g_lengths = defaultdict(int)
    n = int(input())
    for i in range(n - 1):
        u, v = input().split(' ')
        g[u].append(v)
        g[v].append(u)
        g_lengths[u] += 1
        g_lengths[v] += 1

    us, n = find_max_edges(g)
    max_2nd_edges = 0
    for u in us:
        u_adj = set(g[u])
        for node in g_lengths:
            if node == u:
                continue
            max_2nd_edges = max(g_lengths[node] - (1 if node in u_adj else 0), max_2nd_edges)
        if max_2nd_edges == n:
            break

    components = 1
    components += n - 1
    components += max_2nd_edges - 1
    print(components)
Problem: 2063C - Remove Exactly Two
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
from collections import defaultdict

t = int(input())

def find_max_edges(graph):
    max_n = 0
    max_u = -1
    for u in graph:
        if len(graph[u]) > max_n:
            max_u, max_n = u, len(graph[u])
    return max_u, max_n

for _ in range(t):
    g = defaultdict(list)
    g_lengths = defaultdict(int)
    n = int(input())
    for i in range(n - 1):
        u, v = input().split(' ')
        g[u].append(v)
        g[v].append(u)
        g_lengths[u] += 1
        g_lengths[v] += 1

    u, n = find_max_edges(g)
    max_2nd_edges = 0
    for node in g[u]:
        g_lengths[node] -= 1
    for node in g_lengths:
        if node == u:
            continue
        max_2nd_edges = max(g_lengths[node], max_2nd_edges)

    components = 1
    components += n - 1
    components += max_2nd_edges - 1
    print(components)


Submission (verdict: Wrong answer on test 2):
from collections import defaultdict

t = int(input())

def find_max_edges(graph):
    max_us = []
    max_n = -1
    for u in graph:
        if len(graph[u]) > max_n:
            max_us, max_n = [u], len(graph[u])
        elif len(graph[u]) == max_n:
            max_us.append(u)
    return max_us, max_n

for _ in range(t):
    g = defaultdict(list)
    g_lengths = defaultdict(int)
    n = int(input())
    for i in range(n - 1):
        u, v = input().split(' ')
        g[u].append(v)
        g[v].append(u)
        g_lengths[u] += 1
        g_lengths[v] += 1

    us, n = find_max_edges(g)
    max_2nd_edges = 0
    for node in g[u]:
        g_lengths[node] -= 1
    for u in us:
        u_adj = set(g[u])
        for node in g_lengths:
            if node == u:
                continue
            max_2nd_edges = max(g_lengths[node] - (1 if node in u_adj else 0), max_2nd_edges)

    components = 1
    components += n - 1
    components += max_2nd_edges - 1
    print(components)
Problem: 2063C - Remove Exactly Two
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
from collections import defaultdict

t = int(input())

def find_max_edges(graph):
    max_us = []
    max_n = -1
    for u in graph:
        if len(graph[u]) > max_n:
            max_us, max_n = [u], len(graph[u])
        elif len(graph[u]) == max_n:
            max_us.append(u)
    return max_us, max_n

for _ in range(t):
    g = defaultdict(list)
    g_lengths = defaultdict(int)
    n = int(input())
    for i in range(n - 1):
        u, v = input().split(' ')
        g[u].append(v)
        g[v].append(u)
        g_lengths[u] += 1
        g_lengths[v] += 1

    us, n = find_max_edges(g)
    max_2nd_edges = 0
    for node in g[u]:
        g_lengths[node] -= 1
    for u in us:
        u_adj = set(g[u])
        for node in g_lengths:
            if node == u:
                continue
            max_2nd_edges = max(g_lengths[node] - (1 if node in u_adj else 0), max_2nd_edges)

    components = 1
    components += n - 1
    components += max_2nd_edges - 1
    print(components)


Submission (verdict: Time limit exceeded on test 9):
from collections import defaultdict

t = int(input())

def find_max_edges(graph):
    max_us = []
    max_n = -1
    for u in graph:
        if len(graph[u]) > max_n:
            max_us, max_n = [u], len(graph[u])
        elif len(graph[u]) == max_n:
            max_us.append(u)
    return max_us, max_n

for _ in range(t):
    g = defaultdict(list)
    g_lengths = defaultdict(int)
    n = int(input())
    for i in range(n - 1):
        u, v = input().split(' ')
        g[u].append(v)
        g[v].append(u)
        g_lengths[u] += 1
        g_lengths[v] += 1

    us, n = find_max_edges(g)
    max_2nd_edges = 0
    for u in us:
        u_adj = set(g[u])
        for node in g_lengths:
            if node == u:
                continue
            max_2nd_edges = max(g_lengths[node] - (1 if node in u_adj else 0), max_2nd_edges)

    components = 1
    components += n - 1
    components += max_2nd_edges - 1
    print(components)
Problem: 2063C - Remove Exactly Two
Language: PyPy 3-64


Submission (verdict: Wrong answer on test 2):
from collections import defaultdict

t = int(input())

def find_max_edges(graph):
    max_n = 0
    max_u = -1
    for u in graph:
        if len(graph[u]) > max_n:
            max_u, max_n = u, len(graph[u])
    return max_u, max_n

for _ in range(t):
    g = defaultdict(list)
    g_lengths = defaultdict(int)
    n = int(input())
    for i in range(n - 1):
        u, v = input().split(' ')
        g[u].append(v)
        g[v].append(u)
        g_lengths[u] += 1
        g_lengths[v] += 1

    u, n = find_max_edges(g)
    max_2nd_edges = 0
    for node in g[u]:
        g_lengths[node] -= 1
    for node in g_lengths:
        if node == u:
            continue
        max_2nd_edges = max(g_lengths[node], max_2nd_edges)

    components = 1
    components += n - 1
    components += max_2nd_edges - 1
    print(components)