ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 124 ms):
#include <iostream>
#include <vector>
#include <map>
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;


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

    for(int i=0;i<n-1;i++){
        int num = min(a[i],a[i+1]);
        a[i] -= num;
        a[i+1] -= num;
    }
    // for(int i=0;i<n;i++){
    //     cout<<a[i]<<" ";
    // }
    // cout<<endl;
    for(int i= n-2;i>=0;i--){
        if(a[i]!=0){
            cout<<"NO"<<endl;
            return;
        }
    }
    cout<<"YES"<<endl;
}

    

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Solution 2 (runtime: 359 ms):
/*
#       #      #   #######     #     #
#       #      #   #            #   #
#       #      #   #             # #
#       #      #   #              # 
#       #      #   #              # 
######  ########   #######        # 
*/
#include<bits/stdc++.h>
using namespace std;
#define vii vector<int> 
#define vll vector<long long>
#define pb push_back
#define ll long long
#define iterate(i,a,b) for(ll i=a;i<b;i++)
void solve(){
ll n; cin>>n;
vll arr(n); iterate(i,0,n) cin>>arr[i];
iterate(i,0,n-1){
    ll mini=min(arr[i],arr[i+1]);
    arr[i]-=mini;
    arr[i+1]-=mini;
    if(arr[i]>arr[i+1]){
        cout<<"NO"<<endl;
        return;
    }
}
cout<<"YES"<<endl;

}
int main()
{
ll t;
cin>>t; 
while(t--){
solve();
}
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: c++17 

Solution 1 (runtime: 62 ms):
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define vi vector<int>
#define vs vector<string>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define mii map<int, int>
#define umii unordered_map<int, int>

#define ff first
#define ss second
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define pb push_back
#define aint(x) x.begin(),x.end()

#define pyes cout << "YES\n"
#define pno cout << "NO\n"
#define pm1 cout << -1 << endl
#define p0 cout << 0 << endl
#define p1 cout << 1 << endl
#define out(x) cout<<x<<endl
#define nl cout<<endl
const int oo = 1e18;
const int mod = 1e9 + 7;

void solve() {
	string s;	cin >> s;
	int n = s.size(), sum = 0;

	int cnt2 = 0, cnt3 = 0;
	rep(i, n) {
		sum += s[i] - '0';
		if (s[i] - '0' == 2)	cnt2++;
		if (s[i] - '0' == 3)	cnt3++;
	}

	sum %= 9;
	int flag = 0;

	for (int i = 0; i <= min(cnt2, 1LL * 20); i++) {
		for (int j = 0; j <= min(cnt3, 1LL * 20); j++) {
			int temp = sum;
			temp += i * 2 + j * 6;
			if (temp % 9 == 0) {
				cout << "YES\n";
				return;
			}
		}
	}
	for (int i = 0; i < min(cnt2, 1LL * 20); i++) {
		int temp = sum;
		if ((temp + i * 2) % 9 == 0) {
			pyes;
			return;
		}
	}
	for (int i = 0; i < min(cnt3, 1LL * 20); i++) {
		int temp = sum;
		if ((temp + i * 3) % 9 == 0) {
			pyes;
			return;
		}
	}
	pno;
}

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

	int t = 1;
	cin >> t;
	// out(t);
	while (t--)	solve();
}

Solution 2 (runtime: 62 ms):
#include <bits/stdc++.h>
#define inpv(v,n) for(int i=0;i<n;i++)cin>>v[i]
#define disp(v) for(auto x:v) cout<<x<<" "; cout<<"\n"
#define srt(x) sort(x.begin(),x.end())
#define N "\n"
using namespace std;
typedef long long ll;
typedef vector <ll> vll;

void solve() {
    // Your code here
    string s;
    cin>>s;
    int sum=0;
    ll three=0;
    ll two=0;
    for(ll i=0;i<s.length();i++)
    {
        sum+=s[i]-'0';
        switch(s[i])
        {
            case '2':two++;
            break;
            case '3':three++;
            break;
        }
    }
    sum=sum%9;
    bool yes=false;
    two=min(9LL,two);
    three=min(three,9LL);
    for(ll i=0;i<=two;i++)
    {
        for(ll j=0;j<=three;j++)
        {
            if((i*2+j*6+sum)%9==0)
            {
                yes=true;
                break;
            }
        }
    }
    if(sum==0)yes=true;
    //cout<<two<<" "<<three<<N;
    cout<<(yes?"YES\n":"NO\n");
}


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

    ll t;
    cin >> t;
    while (t--) solve();
}
Problem: 2049B - pspspsps
Language: c++17 

Solution 1 (runtime: 46 ms):
#include <bits/stdc++.h>

using namespace std;

#define int long long

#define MOD 1000000007



int32_t main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t;

    cin >> t;

    while (t--)

    {

        int n;

        string str;

        cin >> n >> str;

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

            str[0] = '.';

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

            str[n - 1] = '.';

        char last = '.';

        bool flag = true;

        for (char c : str)

        {

            if (c != '.')

            {

                if (last == '.')

                {

                    last = c;

                }

                else if (last != c)

                {   

                    flag = false;

                    break;

                }

            }

        }

        if (flag)

            cout << "YES" << endl;

        else

            cout << "NO" << endl;

    }

    return 0;

}

Solution 2 (runtime: 46 ms):
#include <bits/stdc++.h>

#define ll long long

#define MEM 101

#define x first

#define y second

#define sz size()

#define pb push_back

#define all(v) (v).begin(), (v).end()

using namespace std;

typedef pair<ll, ll> pi;

const ll INF = 4e18;

const ll MOD = 1e4;

ll gcd(ll a, ll b)

{

    if (a % b)

        return gcd(b, a % b);

    return b;

}

ll abs(ll a, ll b)

{

    return (a > b ? a - b : b - a);

}

ll add(ll a, ll b)

{

    return ((a + b) % MOD + MOD) % MOD;

}

ll sub(ll a, ll b)

{

    return ((a - b) % MOD + MOD) % MOD;

}

ll mul(ll a, ll b)

{

    return ((a * b) % MOD + MOD) % MOD;

}

ll t, n, k, m;

ll a[MEM];

main()

{

    cin.tie(0);

    cout.tie(0);

    ios::sync_with_stdio(0);

    cin >> t;

    while (t--)

    {

        string s;

        cin >> n;

        cin >> s;

        ll ans = 0, piv = 0, siv = 0;

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

        {

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

                piv = i + 1;

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

                siv = i + 1;

        }

        if ((siv == 1 || piv == n) || !(piv && siv))

            ans = 1;

        if (ans)

            cout << "YES\n";

        else

            cout << "NO\n";

    }

}
Problem: 2052A - Adrenaline Rush
Language: c++17 

Solution 1 (runtime: 1562 ms):
# include<bits/stdc++.h>
using namespace  std;
# define ll long long 
int main(){
  ll n;
  cin>>n;
  ll arr[n];
  set<int> st;
  vector<vector<ll>> ans;
  for(ll i=0;i<n;i++){
      cin>>arr[i];
      
      for(ll j=arr[i]+1;j<=n;j++){
          if(!st.count(j)){
            ans.push_back({j,arr[i]});
          }
      }
      
      for(ll j=n;j>=1;j--){
        if(!st.count(j)&&  arr[i]!=j) {
          ans.push_back({arr[i],j});
        }
      }
      st.insert(arr[i]);
  }
 
  cout<<ans.size()<<endl;
  for(auto it:ans){
    cout<<it[0]<<" "<<it[1]<<endl;
  }
  return 0;
}

Solution 2 (runtime: 1234 ms):
#include <bits/stdc++.h> 

using namespace std;

#define int long long
#define deb(x) cout << #x << " = " << x << endl;
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
#define rep(i,j,k) for(int i=j;i<k;i++)
#define sz(x) (int)(x).size()

#define imax INT_MAX
#define imin INT_MIN
#define PI 3.1415926535897932384626433832795
#define tr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define trr(it, x) for(auto it = x.rbegin(); it != x.rend(); it+)
#define sortall(x) sort(all(x))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

void setIO(string name){
    ios_base::sync_with_stdio(0);cin.tie(0);
    if(!name.empty()){
        freopen((name + ".in").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    }
}
#define here cout << "-----PASS-----" << endl;
const int mxN = 1e5+5;
const int MOD = 998244353;
const int INF = 4e18+50;

//*********************************************************************************


void solve(){
	int n;
	cin >> n ;
	int ar[n+5];
	
	for(int i=1;i<=n;i++) cin >> ar[i];

	VII ans;

	int tmp[n+5];
	for(int i=1;i<=n;i++) tmp[i] = i;

	int pos[n+5];
	for(int i=1;i<=n;i++) pos[ar[i]] = i;

	for(int i=n;i>=1;i--) {
		int j=pos[i]-1;
		for(;j>=1;j--) {
			ans.pb({ar[j],ar[j+1]});
			pos[ar[j]]=j+1;
			pos[ar[j+1]]=j;
			swap(ar[j],ar[j+1]);
		}
		for(int j=2;j<=n;j++) {
			if(ar[j] > ar[j-1]) break;
			ans.pb({ar[j-1],ar[j]});
			pos[ar[j]]=j-1;
			pos[ar[j-1]]=j;
			swap(ar[j],ar[j-1]);
		}
	}
	cout << ans.size() << endl;
	reverse(all(ans));
	for(PII a : ans) cout << a.F << " " << a.S << endl;
}

int32_t main(){
    string name = "";
    setIO(name);
    int test_cases = 1;
    //cin >> test_cases;
    while(test_cases--) {
        solve(); //cout << endl;
    }

    return 0; 
}
Problem: 2050D - Digital string maximization
Language: c++17 

Solution 1 (runtime: 61 ms):
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <bits/stdc++.h>
#include <string>

using namespace std;

//#define int long long

long long power(long long x, long long n){
    long long result = 1;
    while (n > 0) {
        if (n & 1 == 1){
            result = result * x;
        }
        x = x *x;
        n = n >> 1;
    }
    return result;
}

bool swapme(pair<int,int> a,pair<int,int> b){
    if(a.first!=b.first){
        if(a.first>b.first){
            return true;
        }
        return false;
    }else{
        if(a.second<b.second){
            return true;
        }
    }
}

int main()
{
    /*
    long long n,k;
    cin>>n;
    cin>>k;
    long long hi=n;
    long long low=0;
    long long mid;
    while(hi-low>1){
        mid=(hi+low)/2;
        long long s=(mid*(mid+1))/2-(n-mid);
        if(s<=k){
            low=mid;
        }else{
            hi=mid;
        }
    }
    if((hi*(hi+1))/2-n+hi==k) cout<<n-hi;
    else cout<<n-low;
*/

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    //freopen("subsonic_subway_input.txt", "r", stdin);
    //freopen("o1.txt", "w", stdout);

    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int n=s.size();
        int a[n];
        for(int i=0;i<n;i++){
            a[i]=s[i]-'0';
        }
        for(int i=0;i<n;i++){
            int v=a[i];
            int b=i;
            int d=0;
            for(int j=i+1;j<n&&j<i+9-v;j++){
                if(a[j]-a[i]-(j-i)>d){
                    b=j;
                    d=a[j]-a[i]-(j-i);
                }
            }
            for(int j=b;j>i;j--){
                swap(a[j],a[j-1]);
                a[j-1]--;
            }
        }
        for(int i=0;i<n;i++){
            cout<<a[i];
        }
        cout<<endl;

    }


    return 0;
}


Solution 2 (runtime: 62 ms):
#include <iostream>
#include <functional>
#include <vector>
#include <algorithm>
#include <cmath>




using namespace std; 



#define trace1(x)       cout << #x << " : " << x << endl;
#define trace2(x, y)    cout << #x << " : " << x << " | " << #y << " : " << y << endl;
#define trace3(x, y, z) cout << #x << " : " << x << " | " << #y << " : " << y << " | " << #z << " : " << z << endl;
#define traceVector(x) cout << "Vector: " << #x << endl; for(int i = 0; i < x.size(); i++) trace2(i, x[i]);
#define cline cout << "----------------------" << endl;
#define MOD 1000000007
#define LIMIT 21000

#define fastScan ios_base::sync_with_stdio(0); cin.tie(NULL);


int main() {
    int t, n, q, d, l, r, k;
  
    fastScan;    
    cin >> t;
    string str;
    while(t--) {
        cin >> str;
        n = str.length();
        for(int i = 1; i < n; i++) {
            int idx = i;
            while(idx > 0 && str[idx] != '0' && (str[idx] - str[idx - 1] > 1)){
                char c = str[idx - 1];
                str[idx - 1] = str[idx] - 1;
                str[idx] = c;
                idx--;
            }
        }    
        cout << str << endl;
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 109 ms):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){

    int t;
    cin >> t;

    while (t--){

        ll l, r;
        cin >> l >> r;

        vector<int> bitsL, bitsR;
        ll savel = l, saver = r;
        while (l > 0 || r > 0){
            bitsL.push_back(l % 2);
            bitsR.push_back(r % 2);
            l /= 2;
            r /= 2;
        }
        vector<ll> A(bitsL.size()), B(bitsL.size());
        for (int i = bitsL.size() - 1; i >= 0; --i){
            if (bitsL[i] == bitsR[i]){
                A[i] = bitsL[i];
                B[i] = bitsL[i];
            }
            else{
                A[i] = bitsR[i];
                for (int j = i - 1; j >= 0; --j){
                    B[j] = 1;
                }
                break;
            }
        }

        ll a = 0, b = 0, c = 0;
        for (ll i = 0; i < A.size(); ++i){
            a += (A[i] << i);
            b += (B[i] << i);
        }
        c = max(b - 1, savel);
        if (c == b){
            c = min(a + 1, saver);
        }
        cout << a << ' ' << b << ' ' << c << '\n';

    }

    return 0;
}

Solution 2 (runtime: 62 ms):
#include <bits/stdc++.h> // include all standard headers
using namespace std;

#define ll long long
#define ld long double
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
// int k = 31 - __builtin_clz(l ^ r);
const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;

void aditya(){
ll l,r;
cin>>l>>r;
int k=63 - __builtin_clz(l^r);
ll m=1<<k;
ll a=l|(m-1);
ll b=a+1;
ll c;
if(a!=l){
    c=l;
}
else
c=r;

cout<<a<<" "<<b<<" "<<c;

}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // Declare any additional variables here
    
    int t; // number of test cases
    cin >> t;
    
    while (t--) {
        // write your code here for each test case
        aditya();
        cout<<endl;
    }
    
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: c++17 

Solution 1 (runtime: 93 ms):
#include <bits/stdc++.h>

using i64 = long long;

void solve() {
    int n, k;
    std::cin >> n >> k;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    std::sort(a.begin(), a.end());
    std::vector<int> cnt = {1};
    for (int i = 1; i < n; i++) {
        if (a[i] == a[i - 1]) {
            cnt.back()++;
        } else {
            cnt.emplace_back(1);
        }
    }
    std::sort(cnt.begin(), cnt.end());
    int m = cnt.size();
    for (int i = 0; i < m - 1; i++) {
        if (cnt[i] > k) {
            std::cout << m - i << "\n";
            return;
        }
        k -= cnt[i];
    }
    std::cout << 1 << "\n";
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t = 1;
    std::cin >> t;

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


Solution 2 (runtime: 124 ms):
/*ॐ देविकानन्दनाय विधमहे वासुदेवाय धीमहि तन्नो कृष्ण:प्रचोदयात
ऊं श्रीं नमः श्रीकृष्णाय परिपूर्णतमाय स्वाहा
ओम क्लीम कृष्णाय नमः
श्री कृष्ण गोविंद हरे मुरारे, हे नाथ नारायण वासुदेवा
गोकुल नाथाय नमः
:निखिलेश गुप्ता*/


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define f first
#define s second
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define trav(a, x) for (auto &a : x)
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vpdd = vector<pdd>;

void solve(){
    int n, k;
    cin >> n >> k;
    vector<int> arr(n);
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        mp[arr[i]]++;
    }
    vector<int> freq;
    for(auto &x : mp){
        freq.push_back(x.second);
    }
    sort(begin(freq), end(freq), greater<int>());
    while(k > 0){
        if(k >= freq.back()){
            k -= freq.back();
            freq.pop_back();
        }
        else break;
    }
    cout << (freq.empty() ? 1 : freq.size()) << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int tt;
    cin >> tt;
    while(tt--) {
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: c++17 

Solution 1 (runtime: 46 ms):
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;

void solve()
{
	string s;
	cin>>s;

	int cnt=0;
	int cnt2=0;
	int cnt3=0;

	for(auto x:s)
	{
		cnt+=x-'0';
		if(x=='2')
			cnt2++;
		if(x=='3')
			cnt3++;
	}

	bool chk=0;
	cnt=cnt%9;
	cnt2=min(cnt2,10);
	cnt3=min(cnt3,3);

	set<int> ss;
	for(int i=0;i<=cnt2;i++)
	{
		for(int j=0;j<=cnt3;j++)
		{
			ss.insert(cnt+2*i+6*j);
		}
	}

	for(auto x:ss)
		if(x%9==0)
			chk=1;

	if(chk)
		cout<<"YES\n";
	else
		cout<<"NO\n";
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t=1;
	cin>>t;

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

Solution 2 (runtime: 62 ms):
#include <bits/stdc++.h>



using namespace std;



int main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    int t;

    cin>>t;

    for(int gt=0;gt<t;gt++){

        string st;

        int s=0,sp[10];

        for(int i=0;i<10;i++){sp[i]=0;}

        cin>>st;

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

            s+=(st[i]-'0');

            sp[st[i]-'0']++;

        }

        if(s%9==0){cout<<"YES"<<'\n';continue;}

        else if(sp[2]==0 && sp[3]==0){cout<<"NO"<<'\n';continue;}

        int f=0;

        for(int i=0;i<=sp[2] && i<=8;i++){

            for(int j=0;j<=sp[3] && j<=8;j++){

                int ussr=s+i*2+j*6;

                if(ussr%9==0){

                    f=1;

                    break;

                }

            }

            if(f){break;}

        }

        if(f){cout<<"YES"<<'\n';continue;}

        cout<<"NO"<<'\n';

    }

    return 0;

}
Problem: 2057B - Gorilla and the Exam
Language: c++17 

Solution 1 (runtime: 233 ms):
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    ll t;
    cin>>t;
    while(t--){
        ll n,k;
        cin>>n>>k;
        map<ll,ll>mp;
        for(ll i=0;i<n;i++){
            ll d;
            cin>>d;
            mp[d]++;
        }
        vector<ll>v;
        for(auto [a,b]:mp){
            v.push_back(b);
        }
        sort(v.begin(),v.end());
        ll ans=v.size();
        for(ll i=0;i<v.size()-1;i++){
            if(v[i]<=k){
                ans--;
                k-=v[i];
            }
        }
        cout<<ans<<endl;
    }
}





Solution 2 (runtime: 233 ms):
#include <bits/stdc++.h>
using namespace std;
#define cy cout << "YES" << endl;
#define c0 cout<<"0"<<endl;
#define cn cout << "NO" << endl;
#define c1 cout << "-1" << endl;
#define all(v) v.begin(), v.end()
#define Vec(arr,ll,n) vector<ll>arr(n);
#define vec(v,n) vector<n>v;
#define nakh(v,n) v.emplace_back(n);
#define aavo(n) cin>>n;
#define nikal(n) cout<<n<<endl;
#define LL long long
#define LD long double
#define rall(v) v.rbegin(), v.rend()
#define pi 3.141592653589793238462643383279
#define len(S) S.length()
#define size(V) V.size()
#define cend cout << endl;
// template <typename T>
#define ll long long int
const ll mod = 1e9 + 7;
const int N = 1e5;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t;
    aavo(t)
    while(t--){
        ll n,k;
        cin>>n>>k;
        Vec(arr,ll,n)
        unordered_map<int,int>mp;
        for(int i=0;i<n;i++){
            aavo(arr[i])
            mp[arr[i]]++;
        }
        priority_queue<int,vector<int>,greater<int> >pq;
        for(auto it:mp){
            pq.push(it.second);
        }
        while(!pq.empty()){
            if(k>=pq.top()){
                k-=pq.top();
                pq.pop();
            }
            else{
                break;
            }
        }
        nikal(max(1,(int)(size(pq))))
    }//kdsjfb
 
return 0;
}
Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 374 ms):
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#define Int long long
using namespace std;
void solve(){
     int n; cin>>n;
     vector<int> a(n);
     bool flag=false;

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

      for(int i=0;i<n-1;i++){
       
     
            int ele= min(a[i],a[i+1]);
              a[i]-=ele;
              a[i+1]-=ele;

              
        }

        if(is_sorted(a.begin(),a.end())){
                cout<<"YES"<<endl;
                return;
              }

      
      
    cout<<"NO"<<endl;
}
 int main(){
      int t; cin>>t;
      while(t--){
            
            solve();
            }
 
            return 0;
}
 


Solution 2 (runtime: 358 ms):
#include <bits/stdc++.h>
using namespace std;

int main() {
   
   int t;
   cin>>t;
   while(t--){
       int n;
       cin>>n;
       vector<int>nums(n);
       for(int i=0;i<n;i++){
           cin>>nums[i];
       }
       int ans=nums[0],flag=1;
       for(int i=1;i<n;i++){
           if(nums[i]-ans<0){
               flag=0;
               break;
           }
           else{
               ans=nums[i]-ans;
           }
       }
       if(flag==1){
       cout<<"YES"<<endl;
       }
       else{
           cout<<"NO"<<endl;
       }
   }
   return 0;
}
Problem: 2052A - Adrenaline Rush
Language: c++17 

Solution 1 (runtime: 281 ms):
#include <bits/stdc++.h>
using namespace std;

#define faster ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
typedef long long ll;

const int mod = 1e9+7;
const ll MOD = 1e18;

int main() {
faster;
int n;
cin>>n;

vector<int> arr(n,0);
for(int i=0;i<n;i++) cin>>arr[i];

map<int,int> mp;
vector<int> initial(n,0);

for(int i=1;i<=n;i++){ initial[i-1]=i; mp[i]=i-1;}

vector<pair<int,int>> ans;

for(int i=n-1;i>=0;i--){
    int idx = mp[arr[i]];

    while(idx>0){
        int temp;
        temp = initial[idx];
        initial[idx] = initial[idx-1];
        initial[idx-1] = temp;

        mp[initial[idx]] = idx;
        mp[initial[idx-1]] = idx-1;

        ans.push_back({initial[idx-1],initial[idx]});

        idx--;
         
        //  cout<<"initial: ";
        // for(auto it: initial) cout<<it<<" ";
        // cout<<"\n";
    }
}

cout<<ans.size()<<"\n";
for(auto it: ans){
    cout<<it.first<<" "<<it.second<<"\n";
}


return 0;
}

Solution 2 (runtime: 1327 ms):
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
   ll n;
   cin>>n;
   vector<ll>pos(n+1);
   vector<ll>cur(n+1);
   vector<ll>a(n+1);
   for(ll i = 1;i<=n;i++)
   {
     cin>>a[i];
     pos[a[i]] = i;
     cur[i] = i;
   }
   vector<pair<ll,ll>>ans;
   for(ll i = 1;i<=n;i++)
   {
     for(ll j = 1;j<n;j++)
     {
        if(pos[cur[j]] < pos[cur[j+1]])
        {
           ans.push_back({cur[j+1],cur[j]});
           swap(cur[j],cur[j+1]);
        }
     }
   }
   for(ll i = 1;i<=n;i++)
   {
     for(ll j = 1;j<n;j++)
     {
        if(pos[cur[j]] > pos[cur[j+1]])
        {
          ans.push_back({cur[j+1],cur[j]});
          swap(cur[j+1],cur[j]);
        }
     }
   }
   cout<<ans.size()<<endl;
   for(auto [x,y] : ans)
   cout<<x<<" "<<y<<endl;
   return 0;
}