ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int mx=0;
vector<vector<int>>v;
int dfs(int idx, int prv){
    int cur = v[idx].size();
    int mxchild=0;
    for(int child : v[idx]){
        if(child != prv){
            mx = max(mx, cur+dfs(child,idx)-1);
            mxchild = max(mxchild, (int)v[child].size());
            mx = max(mx, cur+(int)v[child].size()-2);
        }
    }
    
    return mxchild;


}
void solve(){
    //max children + max children - 2 or max other - 1

    int n;
    cin >> n;
    v.resize(0);
    v.resize(n+1);
    mx =0;
    for(int i=1; i<n; i++){
        int x, y;
        cin >>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1,1);
    cout << mx << endl;
}
int main(){
    ios_base::sync_with_stdio(false);
    cout.tie(NULL);
    int t=1;
    cin >> t;
    while(t--)
    solve();
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int mx=0;
vector<vector<int>>v;
int dfs(int idx, int prv){
    int cur = v[idx].size();
    int mxchild=-1e9;
    for(int child : v[idx]){
        if(child != prv){
            mx = max(mx, cur+dfs(child,idx)-1);
            mxchild = max(mxchild, (int)v[child].size());
            mx = max(mx, cur+(int)v[child].size()-2);
        }
    }
    
    return mxchild;


}
void solve(){
    //max children + max children - 2 or max other - 1

    int n;
    cin >> n;
    v.resize(0);
    v.resize(n+1);
    mx =0;
    for(int i=1; i<n; i++){
        int x, y;
        cin >>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1,1);
    cout << mx << endl;
}
int main(){
    ios_base::sync_with_stdio(false);
    cout.tie(NULL);
    int t=1;
    cin >> t;
    while(t--)
    solve();
    return 0;
}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;



void solve() { 

    int n;

    cin >> n;

    string s;

    cin >> s;



    bool P = 0, S = 0, ok = 1;

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

        if (s[i] == 's') S = 1;

        if (s[i] == 'p') P = 1;

        if (s[i] == 's' and P) ok = 0;

        if (s[i] == 'p' and S and i != n - 1 and i != 1) ok = 0;

    }



    cout << (ok ? "YES" : "NO") << '\n';

}



int main() { 

    ios_base::sync_with_stdio(0); 

    cin.tie(0);



    int tc = 1;

    cin >> tc;

    while (tc--) {

        solve();

    }



    return 0; 

}

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

using namespace std;



void solve() { 

    int n;

    cin >> n;

    string s;

    cin >> s;



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

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

    bool P = 0, S = 0, ok = 1;

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

        if (s[i] == 's') S = 1;

        if (s[i] == 'p') P = 1;

        if (S and P) {

            ok = 0;

            break;

        }

    }



    cout << (ok ? "YES" : "NO") << '\n';

}



int main() { 

    ios_base::sync_with_stdio(0); 

    cin.tie(0);



    int tc = 1;

    cin >> tc;

    while (tc--) {

        solve();

    }



    return 0; 

}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;



void solve() { 

    int n;

    cin >> n;

    string s;

    cin >> s;



    bool P = 0, S = 0, ok = 1;

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

        if (s[i] == 's') S = 1;

        if (s[i] == 'p') P = 1;

        if (s[i] == 's' and P) ok = 0;

        if (s[i] == 'p' and S and i != n - 1) ok = 0;

    }



    cout << (ok ? "YES" : "NO") << '\n';

}



int main() { 

    ios_base::sync_with_stdio(0); 

    cin.tie(0);



    int tc = 1;

    cin >> tc;

    while (tc--) {

        solve();

    }



    return 0; 

}

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

using namespace std;



void solve() { 

    int n;

    cin >> n;

    string s;

    cin >> s;



    bool P = 0, S = 0, ok = 1;

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

        if (s[i] == 's') S = 1;

        if (s[i] == 'p') P = 1;

        if (s[i] == 's' and P) ok = 0;

        if (s[i] == 'p' and S and i != n - 1 and i != 1) ok = 0;

    }



    cout << (ok ? "YES" : "NO") << '\n';

}



int main() { 

    ios_base::sync_with_stdio(0); 

    cin.tie(0);



    int tc = 1;

    cin >> tc;

    while (tc--) {

        solve();

    }



    return 0; 

}
Problem: 2049B - pspspsps
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;

    string s;

    cin >> s;



    bool P = 0, S = 0, ok = 1;

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

        if (s[i] == 's') S = 1;

        if (s[i] == 'p') P = 1;

        if (s[i] == 's' and P) ok = 0;

        if (s[i] == 'p' and S and i != n - 1) ok = 0;

    }



    cout << (ok ? "YES" : "NO") << '\n';

}



int main() { 

    ios_base::sync_with_stdio(0); 

    cin.tie(0);



    int tc = 1;

    cin >> tc;

    while (tc--) {

        solve();

    }



    return 0; 

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

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

using ll = long long;

ll cur_sum(vector<ll> v) {
    ll sum = 0;
    for (int i = 0; i < v.size(); ++i) {
        sum += v[i];
    }
    return abs(sum);
}

void solve() {
    int n; 
    cin >> n;
    vector<ll> a(n);
    int negv = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] < 0) negv++;
    }

    if (n == 1) {
        cout << a[0] << '\n';
        return;
    }

    ll ans;
    if (negv == n) {
        ans = 0;
    } else {
        ans = cur_sum(a);
    }
    // cout << ans << '\n';
    vector<ll> k = a;
    while (true) {
        vector<ll> temp;
        for (int i = 1; i < k.size(); ++i) {
            temp.push_back(k[i] - k[i - 1]);
        }
        k = temp;
        ans = max(ans, cur_sum(k));
        if (k.size() == 1) {
            break;
        }
        temp.clear();
    }
    cout << ans << '\n';
}

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);

    int tc = 1;
    cin >> tc;
    while (tc--) {
        solve();
    }

    return 0; 
}

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

using ll = long long;

ll cur_sum(vector<ll> v) {
    ll sum = 0;
    for (int i = 0; i < v.size(); ++i) {
        sum += v[i];
    }
    return abs(sum);
}

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

    if (n == 1) {
        cout << a[0] << '\n';
        return;
    }

    ll ans = accumulate(a.begin(), a.end(), 0LL);
    vector<ll> k = a;
    while (true) {
        vector<ll> temp;
        for (int i = 1; i < k.size(); ++i) {
            temp.push_back(k[i] - k[i - 1]);
        }
        k = temp;
        ans = max(ans, cur_sum(k));
        if (k.size() == 1) {
            break;
        }
        temp.clear();
    }
    cout << ans << '\n';
}

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);

    int tc = 1;
    cin >> tc;
    while (tc--) {
        solve();
    }

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

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

using ll = long long;

ll cur_sum(vector<ll> v) {
    ll sum = 0;
    for (int i = 0; i < v.size(); ++i) {
        sum += v[i];
    }
    return abs(sum);
}

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

    if (n == 1) {
        cout << a[0] << '\n';
        return;
    }

    ll ans = cur_sum(a);
    vector<ll> k = a;
    while (true) {
        vector<ll> temp;
        for (int i = 1; i < k.size(); ++i) {
            temp.push_back(k[i] - k[i - 1]);
        }
        k = temp;
        ans = max(ans, cur_sum(k));
        if (k.size() == 1) {
            break;
        }
        temp.clear();
    }
    cout << ans << '\n';
}

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);

    int tc = 1;
    cin >> tc;
    while (tc--) {
        solve();
    }

    return 0; 
}

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

using ll = long long;

ll cur_sum(vector<ll> v) {
    ll sum = 0;
    for (int i = 0; i < v.size(); ++i) {
        sum += v[i];
    }
    return abs(sum);
}

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

    if (n == 1) {
        cout << a[0] << '\n';
        return;
    }

    ll ans = cur_sum(a);
    vector<ll> k = a;
    while (true) {
        vector<ll> temp;
        for (int i = 1; i < k.size(); ++i) {
            temp.push_back(k[i] - k[i - 1]);
        }
        k = temp;
        ans = max(ans, cur_sum(k));
        if (k.size() == 1) {
            break;
        }
        temp.clear();
    }
    cout << ans << '\n';
}

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);

    int tc = 1;
    cin >> tc;
    while (tc--) {
        solve();
    }

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

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

using ll = long long;

ll cur_sum(vector<ll> v) {
    ll sum = 0;
    for (int i = 0; i < v.size(); ++i) {
        sum += v[i];
    }
    return abs(sum);
}

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

    if (n == 1) {
        cout << a[0] << '\n';
        return;
    }

    if (n == 2 and a[0] == -1 and a[1] == -1) {
        cout << 0 << '\n';
        return;
    }

    ll ans = cur_sum(a);
    vector<ll> k = a;
    while (true) {
        vector<ll> temp;
        for (int i = 1; i < k.size(); ++i) {
            temp.push_back(k[i] - k[i - 1]);
        }
        k = temp;
        ans = max(ans, cur_sum(k));
        if (k.size() == 1) {
            break;
        }
        temp.clear();
    }
    cout << ans << '\n';
}

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);

    int tc = 1;
    cin >> tc;
    while (tc--) {
        solve();
    }

    return 0; 
}

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

using ll = long long;

ll cur_sum(vector<ll> v) {
    ll sum = 0;
    for (int i = 0; i < v.size(); ++i) {
        sum += v[i];
    }
    return abs(sum);
}

void solve() {
    int n; 
    cin >> n;
    vector<ll> a(n);
    int negv = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] < 0) negv++;
    }

    if (n == 1) {
        cout << a[0] << '\n';
        return;
    }

    ll ans;
    if (negv == n) {
        ans = 0;
    } else {
        ans = cur_sum(a);
    }
    // cout << ans << '\n';
    vector<ll> k = a;
    while (true) {
        vector<ll> temp;
        for (int i = 1; i < k.size(); ++i) {
            temp.push_back(k[i] - k[i - 1]);
        }
        k = temp;
        ans = max(ans, cur_sum(k));
        if (k.size() == 1) {
            break;
        }
        temp.clear();
    }
    cout << ans << '\n';
}

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);

    int tc = 1;
    cin >> tc;
    while (tc--) {
        solve();
    }

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


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

using ll = long long;

ll cur_sum(vector<ll> v) {
    ll sum = 0;
    for (int i = 0; i < v.size(); ++i) {
        sum += v[i];
    }
    return abs(sum);
}

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

    if (n == 1) {
        cout << a[0] << '\n';
        return;
    }

    ll ans = cur_sum(a);
    vector<ll> k = a;
    while (true) {
        vector<ll> temp;
        for (int i = 1; i < k.size(); ++i) {
            temp.push_back(k[i] - k[i - 1]);
        }
        k = temp;
        ans = max(ans, cur_sum(k));
        if (k.size() == 1) {
            break;
        }
        temp.clear();
    }
    cout << ans << '\n';
}

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);

    int tc = 1;
    cin >> tc;
    while (tc--) {
        solve();
    }

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

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

using ll = long long;

ll cur_sum(vector<ll> v) {
    ll sum = 0;
    for (int i = 0; i < v.size(); ++i) {
        sum += v[i];
    }
    return abs(sum);
}

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

    if (n == 1) {
        cout << a[0] << '\n';
        return;
    }

    ll ans = cur_sum(a);
    vector<ll> k = a;
    while (true) {
        vector<ll> temp;
        for (int i = 1; i < k.size(); ++i) {
            temp.push_back(k[i] - k[i - 1]);
        }
        k = temp;
        ans = max(ans, cur_sum(k));
        if (k.size() == 1) {
            break;
        }
        temp.clear();
    }
    cout << ans << '\n';
}

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);

    int tc = 1;
    cin >> tc;
    while (tc--) {
        solve();
    }

    return 0; 
}

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

using ll = long long;

ll cur_sum(vector<ll> v) {
    ll sum = 0;
    for (int i = 0; i < v.size(); ++i) {
        sum += v[i];
    }
    return abs(sum);
}

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

    if (n == 1) {
        cout << a[0] << '\n';
        return;
    }

    if (n == 2 and a[0] == -1 and a[1] == -1) {
        cout << 0 << '\n';
        return;
    }

    ll ans = cur_sum(a);
    vector<ll> k = a;
    while (true) {
        vector<ll> temp;
        for (int i = 1; i < k.size(); ++i) {
            temp.push_back(k[i] - k[i - 1]);
        }
        k = temp;
        ans = max(ans, cur_sum(k));
        if (k.size() == 1) {
            break;
        }
        temp.clear();
    }
    cout << ans << '\n';
}

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);

    int tc = 1;
    cin >> tc;
    while (tc--) {
        solve();
    }

    return 0; 
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <fstream>

#define int long long
#define all(a) a.begin(), a.end()

using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int F = 1e6 + 11;

signed main()
{
    int t; cin >> t;
    while (t--){
        int n; cin >> n;
        vector<vector<int>> d(n + 1);
        vector<int> sz(n + 1);
        for (int i = 0; i < n - 1; i++){
            int u, v; cin >> u >> v;
            d[u].push_back(v);
            d[v].push_back(u);
            sz[u]++; sz[v]++;
        }
        int ans = 0;
        pair<int, int> mv = {0, 0};
        for (int i = 1; i <= n; i++){
            if (mv.first < sz[i]) {
                mv.first = sz[i];
                mv.second = i;
            }
        }
        ans += mv.first;
        sz[mv.second] = 0;
        for (auto i : d[mv.second]) sz[i]--;
        int mx = 0;
        mv = {0, 0};
        for (int i = 1; i <= n; i++){
            if (mv.first < sz[i]) {
                mv.first = sz[i];
                mv.second = i;
            }
        }
        cout << ans + mv.first - 1 << '\n';
    }
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <fstream>

#define int long long
#define all(a) a.begin(), a.end()

using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int F = 1e6 + 11;

signed main()
{
    int t; cin >> t;
    while (t--){
        int n; cin >> n;
        vector<vector<int>> d(n + 1);
        vector<int> sz(n + 1);
        for (int i = 0; i < n - 1; i++){
            int u, v; cin >> u >> v;
            d[u].push_back(v);
            d[v].push_back(u);
            sz[u]++; sz[v]++;
        }
        int ans = 0;
        pair<int, int> mv = {0, 0};
        for (int i = 1; i <= n; i++){
            if (mv.first < sz[i]) {
                mv.first = sz[i];
                mv.second = i;
            }
        }
        ans += mv.first;
        sz[mv.second] = 0;
        for (auto i : d[mv.second]) sz[i]--;
        int mx = 0;
        mv = {0, 0};
        for (int i = 1; i <= n; i++){
            if (mv.first < sz[i]) {
                mv.first = sz[i];
                mv.second = i;
            }
        }
        cout << ans + mv.first - 1 << '\n';
    }
}

Submission (verdict: Runtime error on test 1):
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <fstream>

#define int long long
#define all(a) a.begin(), a.end()

using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int F = 1e6 + 11;

signed main()
{
    int t; cin >> t;
    while (t--){
        int n; cin >> n;
        vector<vector<int>> d(n + 1);
        vector<pair<int, int>> sz(n);
        vector<int> szun(n + 1);
        for (int i = 1; i <= n; i++) sz[i - 1].second = i;
        for (int i = 0; i < n - 1; i++){
            int u, v; cin >> u >> v;
            d[u].push_back(v);
            d[v].push_back(u);
            sz[u - 1].first++; sz[v - 1].first++;
            szun[u]++; szun[v]++;
        }
        sort(sz.rbegin(), sz.rend());
        int ans = 0;
        vector<int> lusd(n, 0);
        for (int i = 1; i <= n; i++){
            pair<int, int> mx = {0, 0};
            vector<int> gr;
            for (auto j : d[i]) {
                mx.first = max(mx.first, szun[j] - 1);
                lusd[j] = i;
            }
            for (int j = 0; j < n; j++){
                if (sz[j].second != i and lusd[sz[j].second] != i){
                    mx.second = sz[j].first;
                    break;
                }
            }
            ans = max(ans, szun[i] + max(mx.first, mx.second) - 1);
        }
        cout << ans << '\n';
    }
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Runtime error on test 1):
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <fstream>

#define int long long
#define all(a) a.begin(), a.end()

using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int F = 1e6 + 11;

signed main()
{
    int t; cin >> t;
    while (t--){
        int n; cin >> n;
        vector<vector<int>> d(n + 1);
        vector<pair<int, int>> sz(n);
        vector<int> szun(n + 1);
        for (int i = 1; i <= n; i++) sz[i - 1].second = i;
        for (int i = 0; i < n - 1; i++){
            int u, v; cin >> u >> v;
            d[u].push_back(v);
            d[v].push_back(u);
            sz[u - 1].first++; sz[v - 1].first++;
            szun[u]++; szun[v]++;
        }
        sort(sz.rbegin(), sz.rend());
        int ans = 0;
        vector<int> lusd(n, 0);
        for (int i = 1; i <= n; i++){
            pair<int, int> mx = {0, 0};
            vector<int> gr;
            for (auto j : d[i]) {
                mx.first = max(mx.first, szun[j] - 1);
                lusd[j] = i;
            }
            for (int j = 0; j < n; j++){
                if (sz[j].second != i and lusd[sz[j].second] != i){
                    mx.second = sz[j].first;
                    break;
                }
            }
            ans = max(ans, szun[i] + max(mx.first, mx.second) - 1);
        }
        cout << ans << '\n';
    }
}

Submission (verdict: Accepted):
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <fstream>

#define int long long
#define all(a) a.begin(), a.end()

using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int F = 1e6 + 11;

signed main()
{
    int t; cin >> t;
    while (t--){
        int n; cin >> n;
        vector<vector<int>> d(n + 1);
        vector<pair<int, int>> sz(n);
        vector<int> szun(n + 1);
        for (int i = 1; i <= n; i++) sz[i - 1].second = i;
        for (int i = 0; i < n - 1; i++){
            int u, v; cin >> u >> v;
            d[u].push_back(v);
            d[v].push_back(u);
            sz[u - 1].first++; sz[v - 1].first++;
            szun[u]++; szun[v]++;
        }
        sort(sz.rbegin(), sz.rend());
        int ans = 0;
        vector<int> lusd(n + 1, 0);
        for (int i = 1; i <= n; i++){
            pair<int, int> mx = {0, 0};
            vector<int> gr;
            for (auto j : d[i]) {
                mx.first = max(mx.first, szun[j] - 1);
                lusd[j] = i;
            }
            for (int j = 0; j < n; j++){
                if (sz[j].second != i and lusd[sz[j].second] != i){
                    mx.second = sz[j].first;
                    break;
                }
            }
            ans = max(ans, szun[i] + max(mx.first, mx.second) - 1);
        }
        cout << ans << '\n';
    }
}