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


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

#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

#define vll vector<long long>

#define ll long long

#define pll pair<ll, ll>

#define mll map<ll, ll>

using namespace std;



int gcd(ll a, ll b) {

    return b == 0 ? a : gcd(b, a % b);

}



long long lcm(long long a, long long b) {

    return (a * b) / gcd(a, b);

}



vector<long long> sieve_of_eratosthenes(long long n) {

    if (n < 2) return {};



    vector<bool> is_prime(n + 1, true);

    is_prime[0] = is_prime[1] = false;



    for (long long p = 2; p * p <= n; ++p) {

        if (is_prime[p]) {

            for (long long i = p * p; i <= n; i += p) {

                is_prime[i] = false;

            }

        }

    }



    vector<long long> primes;

    for (long long p = 2; p <= n; ++p) {

        if (is_prime[p]) {

            primes.push_back(p);

        }

    }

    return primes;

}



ll nCr(ll n, ll r) {

    if (r > n) return 0;

    if (r > n - r) r = n - r; // Because C(n, r) == C(n, n - r)

    ll result = 1;

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

        result *= (n - i);

        result /= (i + 1);

    }

    return result;

}



int findGCD(vector<ll> arr) {

    int result = arr[0];

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

        result = gcd(result, arr[i]);

    }

    return result;

}



ll binarySearch(const vector<ll>& arr, ll x) {

    ll left = 0;

    ll right = arr.size() - 1;



    while (left <= right) {

        ll mid = left + (right - left) / 2;



        if (arr[mid] == x)

            return mid;



        if (arr[mid] < x)

            left = mid + 1;

        else

            right = mid - 1;

    }



    return -1; // Element not found

}



bool sortBySecond(const pair<ll, ll>& a, const pair<int, int>& b) {

    return a.second < b.second;

}



void sortBySecondVOP(vector<pair<ll, ll>>& vec) {

    sort(vec.begin(), vec.end(), sortBySecond);

}



void solve() {

    ll n;

    cin >> n;

    string s;

    cin >> s;

    bool fs = false;

    bool fp = false;

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

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

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

        if(fp && s[i] == 's'){

            cout<<"NO"<<endl;

            return;

        }

    }

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

        ll pc = 0;

        ll sc = 0;

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

            if(s[i] == 'p') ++pc;

            else if(s[i]=='s') ++sc;

        }

        if(sc>0 && pc>0){

            cout<<"NO"<<endl;

            return;

        }

    }

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

        ll sc=0;

        ll pc=0;

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

            if(s[i]=='s') ++sc;

            else if(s[i]=='p') ++pc;

        }

        if(sc>0 && pc>0){

            cout<<"NO"<<endl;

            return;

        }

    }

    cout<<"YES"<<endl;

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

    //     cout<<"YES"<<endl;

    // else

    //     cout<<"NO"<<endl;

    

}



int main() {

    fast;

    ll t;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

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


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

ll getSum(vector<ll>&v){
    ll sum = 0;
    for(auto it: v){
        sum += it;
    }
    return sum;
}

vector<ll> diffSeq(vector<ll>&v){
    vector<ll>temp;
    for(ll i=1; i<(ll)v.size(); i++){
        temp.push_back(v[i]-v[i-1]);
    }
    return temp;
}

void process() {
    int n;
    cin >> n;
    
    vector<ll>a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    if(n == 1){
        cout << a[0] << endl;
        return;
    }
    
    ll sum = getSum(a);
    vector<ll> curr = a;
    
    for(int i=0; i<20; i++){
    
        vector<ll>rev = curr;
        reverse(rev.begin(), rev.end());
        sum = max(sum, getSum(rev));
        
        
        vector<ll>diff = diffSeq(rev);
        sum = max(sum, getSum(diff));
        
       
        curr = diff;
        
        if(curr.size() == 1) break;
    }
    
    cout << sum << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t;
    cin >> t;
    while (t--) {
        process();
    }
    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;
#define ll long long 

ll getSum(vector<ll>&v){
    ll sum = 0;
    for(auto it: v){
        sum += it;
    }
    return sum;
}

vector<ll> diffSeq(vector<ll>&v){
    vector<ll>temp;
    for(ll i=1; i<(ll)v.size(); i++){
        temp.push_back(v[i]-v[i-1]);
    }
    return temp;
}

void process() {
    int n;
    cin >> n;
    
    vector<ll>a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    if(n == 1){
        cout << a[0] << endl;
        return;
    }
    
    ll sum = getSum(a);
    vector<ll> curr = a;
    
    for(int i=0; i<20; i++){
    
        vector<ll>rev = curr;
        reverse(rev.begin(), rev.end());
        sum = max(sum, getSum(rev));
        
        
        vector<ll>diff = diffSeq(rev);
        sum = max(sum, getSum(diff));
        
       
        curr = diff;
        
        if(curr.size() == 1) break;
    }
    
    cout << sum << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t;
    cin >> t;
    while (t--) {
        process();
    }
    return 0;
}

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

ll getSum(vector<ll>&v){
    ll sum = 0;
    for(auto it: v){
        sum += it;
    }
    return sum;
}

vector<ll> diffSeq(vector<ll>&v){
    vector<ll>temp;
    for(ll i=1; i<(ll)v.size(); i++){
        temp.push_back(v[i]-v[i-1]);
    }
    return temp;
}

void process() {
    int n;
    cin >> n;
    
    vector<ll>a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    if(n == 1){
        cout << a[0] << endl;
        return;
    }
    
    ll sum = getSum(a);
    vector<ll> curr = a;
    
    for(int i=0; i<50; i++){
    
        vector<ll>rev = curr;
        reverse(rev.begin(), rev.end());
        sum = max(sum, getSum(rev));
        
        
        vector<ll>diff = diffSeq(rev);
        sum = max(sum, getSum(diff));
        
       
        curr = diff;
        
        if(curr.size() == 1) break;
    }
    
    cout << sum << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t;
    cin >> t;
    while (t--) {
        process();
    }
    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;
#define ll long long 

ll getSum(vector<ll>&v){
    ll sum = 0;
    for(auto it: v){
        sum += it;
    }
    return sum;
}

vector<ll> diffSeq(vector<ll>&v){
    vector<ll>temp;
    for(ll i=1; i<(ll)v.size(); i++){
        temp.push_back(v[i]-v[i-1]);
    }
    return temp;
}

void process() {
    int n;
    cin >> n;
    
    vector<ll>a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    if(n == 1){
        cout << a[0] << endl;
        return;
    }
    
    ll sum = getSum(a);
    vector<ll> curr = a;
    
    for(int i=0; i<2*n; i++){
    
        vector<ll>rev = curr;
        reverse(rev.begin(), rev.end());
        sum = max(sum, getSum(rev));
        
        
        vector<ll>diff = diffSeq(rev);
        sum = max(sum, getSum(diff));
        
       
        curr = diff;
        
        if(curr.size() == 1) break;
    }
    
    cout << sum << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t;
    cin >> t;
    while (t--) {
        process();
    }
    return 0;
}

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

ll getSum(vector<ll>&v){
    ll sum = 0;
    for(auto it: v){
        sum += it;
    }
    return sum;
}

vector<ll> diffSeq(vector<ll>&v){
    vector<ll>temp;
    for(ll i=1; i<(ll)v.size(); i++){
        temp.push_back(v[i]-v[i-1]);
    }
    return temp;
}

void process() {
    int n;
    cin >> n;
    
    vector<ll>a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    if(n == 1){
        cout << a[0] << endl;
        return;
    }
    
    ll sum = getSum(a);
    vector<ll> curr = a;
    
 
    set<vector<ll>> seen;
    seen.insert(curr);
     
    for(int i=0; i<100; i++){
   
        vector<ll>rev = curr;
        reverse(rev.begin(), rev.end());
        sum = max(sum, getSum(rev));
        
      
        vector<ll>diff = diffSeq(rev);
        sum = max(sum, getSum(diff));
        
      
        vector<ll>diff2 = diffSeq(curr);
        sum = max(sum, getSum(diff2));
        
      
        vector<ll>revDiff = diff2;
        reverse(revDiff.begin(), revDiff.end());
        sum = max(sum, getSum(revDiff));
        
       
        if(getSum(diff) > getSum(diff2)){
            curr = diff;
        } else {
            curr = diff2;
        }
        
        if(curr.size() == 1) break;
        
     
        if(seen.count(curr)) break;
        seen.insert(curr);
    }
    
    cout << sum << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t;
    cin >> t;
    while (t--) {
        process();
    }
    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;
#define ll long long 

ll getSum(vector<ll>&v){
    ll sum = 0;
    for(auto it: v){
        sum += it;
    }
    return sum;
}

vector<ll> diffSeq(vector<ll>&v){
    vector<ll>temp;
    for(ll i=1; i<(ll)v.size(); i++){
        temp.push_back(v[i]-v[i-1]);
    }
    return temp;
}

void process() {
    int n;
    cin >> n;
    
    vector<ll>a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    if(n == 1){
        cout << a[0] << endl;
        return;
    }
    
    ll sum = getSum(a);
    vector<ll> curr = a;
    
    for(int i=0; i<50; i++){
    
        vector<ll>rev = curr;
        reverse(rev.begin(), rev.end());
        sum = max(sum, getSum(rev));
        
        
        vector<ll>diff = diffSeq(rev);
        sum = max(sum, getSum(diff));
        
       
        curr = diff;
        
        if(curr.size() == 1) break;
    }
    
    cout << sum << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t;
    cin >> t;
    while (t--) {
        process();
    }
    return 0;
}

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

ll getSum(vector<ll>&v){
    ll sum = 0;
    for(auto it: v){
        sum += it;
    }
    return sum;
}

vector<ll> diffSeq(vector<ll>&v){
    vector<ll>temp;
    for(ll i=1; i<(ll)v.size(); i++){
        temp.push_back(v[i]-v[i-1]);
    }
    return temp;
}

void process() {
    int n;
    cin >> n;
    
    vector<ll>a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    if(n == 1){
        cout << a[0] << endl;
        return;
    }
    
    ll sum = getSum(a);
    vector<ll> curr = a;
    
    for(int i=0; i<2*n; i++){
    
        vector<ll>rev = curr;
        reverse(rev.begin(), rev.end());
        sum = max(sum, getSum(rev));
        
        
        vector<ll>diff = diffSeq(rev);
        sum = max(sum, getSum(diff));
        
       
        curr = diff;
        
        if(curr.size() == 1) break;
    }
    
    cout << sum << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t;
    cin >> t;
    while (t--) {
        process();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: PyPy 3-64


Submission (verdict: Wrong answer on test 2):
# Vaibhav Varshney
import math
import bisect
 
def li():
    return list(map(int,input().split()))
def mi():
    return map(int,input().split())
 
def solve():
    n = int(input())
    a = li()
    diff = a[0]
    for i in range(1,n-1):
        if a[i]-diff > a[i+1]:
            print("NO")
            return
        diff = a[i] - diff
    print("YES")    
        
    
def main():
    t = int(input())
    for _ in range(t):
        solve()
 
if __name__ == "__main__":
    main()
Problem: 2060D - Subtract Min Sort
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
# Vaibhav Varshney
import math
import bisect
 
def li():
    return list(map(int,input().split()))
def mi():
    return map(int,input().split())
 
def solve():
    n = int(input())
    a = li()
    diff = a[1]-a[0]
    if (diff<0):
        print("NO")
        return
    for i in range(2,n-1):
        if a[i]-diff > a[i+1]:
            print("NO")
            return
        diff = a[i] - diff
    print("YES")    
        
    
def main():
    t = int(input())
    for _ in range(t):
        solve()
 
if __name__ == "__main__":
    main()

Submission (verdict: Wrong answer on test 2):
# Vaibhav Varshney
import math
import bisect
 
def li():
    return list(map(int,input().split()))
def mi():
    return map(int,input().split())
 
def solve():
    n = int(input())
    a = li()
    diff = a[1]-a[0]
    if (diff<0):
        print("NO")
        return
    for i in range(2,n-1):
        if (diff<0):
            print("NO")
            return
        if a[i]-diff > a[i+1]:
            print("NO")
            return
        diff = a[i] - diff
    print("YES")    
        
    
def main():
    t = int(input())
    for _ in range(t):
        solve()
 
if __name__ == "__main__":
    main()
Problem: 2060D - Subtract Min Sort
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
# Vaibhav Varshney
import math
import bisect
 
def li():
    return list(map(int,input().split()))
def mi():
    return map(int,input().split())
 
def solve():
    n = int(input())
    a = li()
    diff = a[0]
    for i in range(1,n-1):
        if a[i]-diff > a[i+1]:
            print("NO")
            return
        diff = a[i] - diff
    print("YES")    
        
    
def main():
    t = int(input())
    for _ in range(t):
        solve()
 
if __name__ == "__main__":
    main()

Submission (verdict: Wrong answer on test 2):
# Vaibhav Varshney
import math
import bisect
 
def li():
    return list(map(int,input().split()))
def mi():
    return map(int,input().split())
 
def solve():
    n = int(input())
    a = li()
    diff = a[1]-a[0]
    if (diff<0):
        print("NO")
        return
    for i in range(2,n-1):
        if a[i]-diff > a[i+1]:
            print("NO")
            return
        diff = a[i] - diff
    print("YES")    
        
    
def main():
    t = int(input())
    for _ in range(t):
        solve()
 
if __name__ == "__main__":
    main()
Problem: 2060D - Subtract Min Sort
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 3):
# Vaibhav Varshney
import math
import bisect
 
def li():
    return list(map(int,input().split()))
def mi():
    return map(int,input().split())
 
def solve():
    n = int(input())
    a = li()
    diff = a[1]-a[0]
    if (diff<0):
        print("NO")
        return
    for i in range(2,n-1):
        if a[i]-diff > a[i+1]:
            print("NO")
            return
        diff = a[i] - diff
        if (diff<0):
            print("NO")
            return
    print("YES")    
        
    
def main():
    t = int(input())
    for _ in range(t):
        solve()
 
if __name__ == "__main__":
    main()

Submission (verdict: Accepted):
# Vaibhav Varshney
import math
import bisect
 
def li():
    return list(map(int,input().split()))
def mi():
    return map(int,input().split())
 
def solve():
    n = int(input())
    a = li()
    diff = a[1]-a[0]
    if (diff<0):
        print("NO")
        return
    for i in range(2,n):
        diff = a[i]-diff
        if(diff<0):
            print("NO")
            return
    print("YES")    
        
    
def main():
    t = int(input())
    for _ in range(t):
        solve()
 
if __name__ == "__main__":
    main()
Problem: 2060D - Subtract Min Sort
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
# Vaibhav Varshney
import math
import bisect
 
def li():
    return list(map(int,input().split()))
def mi():
    return map(int,input().split())
 
def solve():
    n = int(input())
    a = li()
    diff = a[1]-a[0]
    if (diff<0):
        print("NO")
        return
    for i in range(2,n-1):
        if (diff<0):
            print("NO")
            return
        if a[i]-diff > a[i+1]:
            print("NO")
            return
        diff = a[i] - diff
    print("YES")    
        
    
def main():
    t = int(input())
    for _ in range(t):
        solve()
 
if __name__ == "__main__":
    main()

Submission (verdict: Wrong answer on test 3):
# Vaibhav Varshney
import math
import bisect
 
def li():
    return list(map(int,input().split()))
def mi():
    return map(int,input().split())
 
def solve():
    n = int(input())
    a = li()
    diff = a[1]-a[0]
    if (diff<0):
        print("NO")
        return
    for i in range(2,n-1):
        if a[i]-diff > a[i+1]:
            print("NO")
            return
        diff = a[i] - diff
        if (diff<0):
            print("NO")
            return
    print("YES")    
        
    
def main():
    t = int(input())
    for _ in range(t):
        solve()
 
if __name__ == "__main__":
    main()
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 8):
#include <iostream>

#include <vector>

#include <algorithm>

#include <numeric>

using namespace std;

int main() {

    int t;

    cin >> t;

    while (t--) {

        long long n, l, r;

        cin >> n >> l >> r;

        l--;

        vector<long long> a(n);

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

            cin >> a[i];

        }

        vector<long long> b(a.begin(), a.begin() + l);

        vector<long long> temp(a.begin() + l, a.end());

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

        b.insert(b.end(), temp.begin(), temp.end());

        vector<long long> c(a.begin(), a.begin() + r);

        sort(c.begin(), c.end(), greater<long long>());

        c.insert(c.end(), a.begin() + r, a.end());

        long long sum_b = accumulate(b.begin() + l, b.begin() + r, 0);

        long long sum_c = accumulate(c.begin() + l, c.begin() + r, 0);

        cout << min(sum_b, sum_c) << endl;

    }

    return 0;

}

Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main() {
    int t;
    cin >> t;
    while (t--) {
        long long n, l, r;
        cin >> n >> l >> r;
        l--;
        vector<unsigned long long> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        vector<unsigned long long> b(a.begin(), a.begin() + l);
        vector<unsigned long long> temp(a.begin() + l, a.end());
        sort(temp.begin(), temp.end());
        b.insert(b.end(), temp.begin(), temp.end());
        vector<unsigned long long> c(a.begin(), a.begin() + r);
        sort(c.begin(), c.end(), greater<unsigned long long>());
        c.insert(c.end(), a.begin() + r, a.end());
        unsigned long long sum_b = accumulate(b.begin() + l, b.begin() + r, 0ULL);
        unsigned long long sum_c = accumulate(c.begin() + l, c.begin() + r, 0ULL);
        unsigned long long res = min(sum_b, sum_c);
        cout << res << endl;
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 8):
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main() {
    int t;
    cin >> t;
    while (t--) {
        int n, l, r;
        cin >> n >> l >> r;
        l--;
        vector<long long> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        vector<long long> b(a.begin(), a.begin() + l);
        vector<long long> temp(a.begin() + l, a.end());
        sort(temp.begin(), temp.end());
        b.insert(b.end(), temp.begin(), temp.end());
        vector<long long> c(a.begin(), a.begin() + r);
        sort(c.begin(), c.end(), greater<int>());
        c.insert(c.end(), a.begin() + r, a.end());
        long long sum_b = accumulate(b.begin() + l, b.begin() + r, 0);
        long long sum_c = accumulate(c.begin() + l, c.begin() + r, 0);
        cout << min(sum_b, sum_c) << endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 8):
#include <iostream>

#include <vector>

#include <algorithm>

#include <numeric>

using namespace std;

int main() {

    int t;

    cin >> t;

    while (t--) {

        long long n, l, r;

        cin >> n >> l >> r;

        l--;

        vector<long long> a(n);

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

            cin >> a[i];

        }

        vector<long long> b(a.begin(), a.begin() + l);

        vector<long long> temp(a.begin() + l, a.end());

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

        b.insert(b.end(), temp.begin(), temp.end());

        vector<long long> c(a.begin(), a.begin() + r);

        sort(c.begin(), c.end(), greater<long long>());

        c.insert(c.end(), a.begin() + r, a.end());

        long long sum_b = accumulate(b.begin() + l, b.begin() + r, 0);

        long long sum_c = accumulate(c.begin() + l, c.begin() + r, 0);

        cout << min(sum_b, sum_c) << endl;

    }

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 8):
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main() {
    int t;
    cin >> t;
    while (t--) {
        int n, l, r;
        cin >> n >> l >> r;
        l--;
        vector<long long> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        vector<long long> b(a.begin(), a.begin() + l);
        vector<long long> temp(a.begin() + l, a.end());
        sort(temp.begin(), temp.end());
        b.insert(b.end(), temp.begin(), temp.end());
        vector<long long> c(a.begin(), a.begin() + r);
        sort(c.begin(), c.end(), greater<int>());
        c.insert(c.end(), a.begin() + r, a.end());
        long long sum_b = accumulate(b.begin() + l, b.begin() + r, 0);
        long long sum_c = accumulate(c.begin() + l, c.begin() + r, 0);
        cout << min(sum_b, sum_c) << endl;
    }
    return 0;
}