ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: PyPy 3

Previous submission (verdict: Wrong answer on test 6):
import sys
data = sys.stdin.read().splitlines()

line = 2
while (line < len(data)):
    arr = list(map(int, data[line].split()))
    # print("arr=", arr)
    new_arr = arr
    diff = sum(arr)
    if len(arr) == 2:
        diff = max(abs(arr[0]-arr[1]), diff)
    else:
        for i in range(len(arr)-1):
            new_arr = [new_arr[i+1]-new_arr[i] for i in range(len(new_arr)-1)]
            if diff < abs(new_arr[0] - new_arr[-1]):
                diff = abs(new_arr[0] - new_arr[-1])
            # print(new_arr, "...diff=", diff)
    print(diff)
    line += 2

Submission (verdict: Wrong answer on test 6):
import sys
data = sys.stdin.read().splitlines()

line = 2
while (line < len(data)):
    arr = list(map(int, data[line].split()))
    # print("arr=", arr)
    new_arr = arr
    diff = sum(arr)
    if len(arr) == 2:
        diff = max(abs(arr[0]-arr[1]), diff)
    elif len(arr) >2 :
        for i in range(len(arr)-1):
            new_arr = [new_arr[i+1]-new_arr[i] for i in range(len(new_arr)-1)]
            if diff < abs(new_arr[0] - new_arr[-1]):
                diff = abs(new_arr[0] - new_arr[-1])
            # print(new_arr, "...diff=", diff)
    print(diff)
    line += 2
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n,x,y;

        cin>>n>>x>>y;

        int a[n];

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

        {

            cin>>a[i];

        }

        sort(a,a+n);

        int sum = 0;

        int p = y-x+1;

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

        {

            sum += a[i];

        }

        cout<<sum<<endl;

    }

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

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n,x,y;

        cin>>n>>x>>y;

        int a[n],b[n];

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

        {

            cin>>a[i];

            b[i] = a[i];

        }

        sort(a,a+y);

        sort(b+x-1,b+n);

        if(x == y)

        {

            cout<<min(a[0],b[x-1])<<endl;

        }

        else

        {

            int sum1 = 0,sum2 = 0;

            for(int i = 0;i<y-x+1;i++)

            {

                sum1+=a[i];

            }

            for(int i = 0;i<y-x+1;i++)

            {

                sum2+=b[i+x-1];

            }

            cout<<min(sum1,sum2)<<endl;

        }

    }

}

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

using namespace std;

int main(){

    long long int t;

    cin>>t;

    while(t--){

        long long int n,x,y;

        cin>>n>>x>>y;

        long long int a[n],b[n];

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

        {

            cin>>a[i];

            b[i] = a[i];

        }

        sort(a,a+y);

        sort(b+x-1,b+n);

        if(x == y)

        {

            cout<<min(a[0],b[x-1])<<endl;

        }

        else

        {

            long long int sum1 = 0,sum2 = 0;

            for(long long int i = 0;i<y-x+1;i++)

            {

                sum1+=a[i];

            }

            for(long long int i = 0;i<y-x+1;i++)

            {

                sum2+=b[i+x-1];

            }

            cout<<min(sum1,sum2)<<endl;

        }

    }

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

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n,x,y;

        cin>>n>>x>>y;

        int a[n];

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

        {

            cin>>a[i];

        }

        sort(a,a+n);

        int sum = 0;

        int p = y-x+1;

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

        {

            sum += a[i];

        }

        cout<<sum<<endl;

    }

}

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n,x,y;

        cin>>n>>x>>y;

        int a[n],b[n];

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

        {

            cin>>a[i];

            b[i] = a[i];

        }

        sort(a,a+y);

        sort(b+x,b+n);

        if(x == y)

        {

            cout<<min(a[0],b[x])<<endl;

        }

        else

        {

            int sum1 = 0,sum2 = 0;

            for(int i = 0;i<y-x+1;i++)

            {

                sum1+=a[i];

            }

            for(int i = 0;i<y-x+1;i++)

            {

                sum2+=b[i+x-1];

            }

            cout<<min(sum1,sum2)<<endl;

        }

    }

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

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n,x,y;

        cin>>n>>x>>y;

        int a[n],b[n];

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

        {

            cin>>a[i];

            b[i] = a[i];

        }

        sort(a,a+y);

        sort(b+x,b+n);

        if(x == y)

        {

            cout<<min(a[0],b[x])<<endl;

        }

        else

        {

            int sum1 = 0,sum2 = 0;

            for(int i = 0;i<y-x+1;i++)

            {

                sum1+=a[i];

            }

            for(int i = 0;i<y-x+1;i++)

            {

                sum2+=b[i+x-1];

            }

            cout<<min(sum1,sum2)<<endl;

        }

    }

}

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n,x,y;

        cin>>n>>x>>y;

        int a[n],b[n];

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

        {

            cin>>a[i];

            b[i] = a[i];

        }

        sort(a,a+y);

        sort(b+x-1,b+n);

        if(x == y)

        {

            cout<<min(a[0],b[x-1])<<endl;

        }

        else

        {

            int sum1 = 0,sum2 = 0;

            for(int i = 0;i<y-x+1;i++)

            {

                sum1+=a[i];

            }

            for(int i = 0;i<y-x+1;i++)

            {

                sum2+=b[i+x-1];

            }

            cout<<min(sum1,sum2)<<endl;

        }

    }

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

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

#include<string>

#include<map>

using namespace std;

void solve() {

	string n;

	cin >> n;

	int len = n.size();

	int mod = 0;

	int n2 = 0, n3 = 0;

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

		if (n[i] == '2')n2++;

		if (n[i] == '3')n3++;

		int num = n[i] - '0';

		mod += num % 9;

		mod %= 9;

	}

	n2 = min(6, n2);

	n3 = min(6, n3);

	map<int, int>mp1, mp2,mp3;

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

		mp1[2 * (i + 1)] ++;

	}

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

		mp2[6 * (i + 1)] ++;

	}

	if (mod == 0) {

		cout << "YES\n";

		return;

	}

	if (!mp1.empty())mp3 = mp1;

	else mp3 = mp2;

	for (auto x : mp1) {

		for (auto y : mp2) {

			mp3[x.first]++;

			mp3[y.first]++;

			mp3[x.first + y.first]++;

		}

	}

	for (auto x : mp3) {

		if ((x.first + mod) % 9 == 0) {

			cout << "YES\n";

			return;

		}

	}

	 cout << "NO\n";

}

int main() {

	int t;

	cin >> t;

	while (t--)solve();

}

Submission (verdict: Accepted):
#include<iostream>

#include<string>

#include<map>

using namespace std;

void solve() {

	string n;

	cin >> n;

	int len = n.size();

	int mod = 0;

	int n2 = 0, n3 = 0;

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

		if (n[i] == '2')n2++;

		if (n[i] == '3')n3++;

		int num = n[i] - '0';

		mod += num % 9;

		mod %= 9;

	}

	n2 = min(9, n2);

	n3 = min(9, n3);

	map<int, int>mp1, mp2,mp3;

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

		mp1[2 * (i + 1)] ++;

	}

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

		mp2[6 * (i + 1)] ++;

	}

	if (mod == 0) {

		cout << "YES\n";

		return;

	}

	if (!mp1.empty())mp3 = mp1;

	else mp3 = mp2;

	for (auto x : mp1) {

		for (auto y : mp2) {

			mp3[x.first]++;

			mp3[y.first]++;

			mp3[x.first + y.first]++;

		}

	}

	for (auto x : mp3) {

		if ((x.first + mod) % 9 == 0) {

			cout << "YES\n";

			return;

		}

	}

	 cout << "NO\n";

}

int main() {

	int t;

	cin >> t;

	while (t--)solve();

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


Submission (verdict: Time limit exceeded on test 4):
#include<iostream>

#include<string>

#include<map>

using namespace std;

void solve() {

	string n;

	cin >> n;

	int len = n.size();

	int mod = 0;

	int n2 = 0, n3 = 0;

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

		if (n[i] == '2')n2++;

		if (n[i] == '3')n3++;

		int num = n[i] - '0';

		mod += num % 9;

		mod %= 9;

	}

	map<int, int>mp1, mp2,mp3;

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

		mp1[2 * (i + 1)] ++;

	}

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

		mp2[6 * (i + 1)] ++;

	}

	if (mod == 0) {

		cout << "YES\n";

		return;

	}

	if (!mp1.empty())mp3 = mp1;

	else mp3 = mp2;

	for (auto x : mp1) {

		for (auto y : mp2) {

			mp3[x.first]++;

			mp3[y.first]++;

			mp3[x.first + y.first]++;

		}

	}

	for (auto x : mp3) {

		if ((x.first + mod) % 9 == 0) {

			cout << "YES\n";

			return;

		}

	}

	 cout << "NO\n";

}

int main() {

	int t;

	cin >> t;

	while (t--)solve();

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

Previous submission (verdict: Time limit exceeded on test 4):
#include<iostream>

#include<string>

#include<map>

using namespace std;

void solve() {

	string n;

	cin >> n;

	int len = n.size();

	int mod = 0;

	int n2 = 0, n3 = 0;

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

		if (n[i] == '2')n2++;

		if (n[i] == '3')n3++;

		int num = n[i] - '0';

		mod += num % 9;

		mod %= 9;

	}

	map<int, int>mp1, mp2,mp3;

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

		mp1[2 * (i + 1)] ++;

	}

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

		mp2[6 * (i + 1)] ++;

	}

	if (mod == 0) {

		cout << "YES\n";

		return;

	}

	if (!mp1.empty())mp3 = mp1;

	else mp3 = mp2;

	for (auto x : mp1) {

		for (auto y : mp2) {

			mp3[x.first]++;

			mp3[y.first]++;

			mp3[x.first + y.first]++;

		}

	}

	for (auto x : mp3) {

		if ((x.first + mod) % 9 == 0) {

			cout << "YES\n";

			return;

		}

	}

	 cout << "NO\n";

}

int main() {

	int t;

	cin >> t;

	while (t--)solve();

}

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

#include<string>

#include<map>

using namespace std;

void solve() {

	string n;

	cin >> n;

	int len = n.size();

	int mod = 0;

	int n2 = 0, n3 = 0;

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

		if (n[i] == '2')n2++;

		if (n[i] == '3')n3++;

		int num = n[i] - '0';

		mod += num % 9;

		mod %= 9;

	}

	n2 = min(6, n2);

	n3 = min(6, n3);

	map<int, int>mp1, mp2,mp3;

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

		mp1[2 * (i + 1)] ++;

	}

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

		mp2[6 * (i + 1)] ++;

	}

	if (mod == 0) {

		cout << "YES\n";

		return;

	}

	if (!mp1.empty())mp3 = mp1;

	else mp3 = mp2;

	for (auto x : mp1) {

		for (auto y : mp2) {

			mp3[x.first]++;

			mp3[y.first]++;

			mp3[x.first + y.first]++;

		}

	}

	for (auto x : mp3) {

		if ((x.first + mod) % 9 == 0) {

			cout << "YES\n";

			return;

		}

	}

	 cout << "NO\n";

}

int main() {

	int t;

	cin >> t;

	while (t--)solve();

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

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

using namespace std;

#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

typedef pair<int,int> PII;

typedef long long ll;

void sol(){

  int n;

  cin>>n;

  string s;

  cin>>s;

  s=" "+s;

  bool st[n+1];

  memset(st,false,sizeof st);

  int op=0;

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

  {

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

  	{

  		op=i;

  		break;

	  }

  }

  if(op==0)

  {

  	cout<<"YES"<<endl;

  	return;

  }

  int sum=0;

  vector<PII> ans(n+1);

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

  {

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

  	{

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

        {

        	if(st[j]==false)

        	{

        		ans[j]={i,n};

        //		cout<<i<<j<<" "<<" "<<"s"<<endl;

			}

			else

			{

				int x=ans[j].first;

				int y=ans[j].second;

				if(i>x) x=i;

				if(n<y) y=n;

				ans[j]={x,y};

	//		cout<<i<<j<<" "<<" "<<x<<" "<<y<<" "<<"s"<<endl;

			}

			st[j]=true;

		}

	}

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

	{

         for(int j=1;j<=i;j++)

        {

        	if(st[j]==false)

        	{

        		ans[j]={1,i};

        	//	cout<<i<<j<<" "<<" "<<"q"<<endl;

			}

			else

			{

				int x=ans[j].first;

				int y=ans[j].second;

				if(1>x) x=1;

				if(i<y) y=i;

				ans[j]={x,y};

			//	cout<<i<<j<<" "<<" "<<x<<" "<<y<<" "<<"q"<<endl;

			}

			st[j]=true;

		}

	}

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

	{

		sum++;

	}

	}

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

  {

  	int x=ans[i].first;

	int y=ans[i].second;

//	cout<<x<<" "<<y<<endl;

	if(x>y||x==0||y==0)

	{

		if(x==0||y==0)

	{sum--;

	if(sum==-1)

	{

		cout<<"NO"<<endl;

		return;

	}

		}	

	else 

	{

		cout<<"NO"<<endl;	

	return;

	}

	}

  }

  cout<<"YES"<<endl;

}

int main()

{

	ios;

	int t;

	cin>>t;

	while(t--)

	{

		sol();

	}

	return 0;

} 

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

using namespace std;

#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

typedef pair<int,int> PII;

typedef long long ll;

void sol(){

  int n;

  cin>>n;

  string s;

  cin>>s;

  int res1=0,res2=0;

  int ans1=0,ans2=0;

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

  {

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

  	{

  		res1++;

  		ans1=i;

	  }

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

	  {

	  	res2++;

	  	ans2=i;

	  }

  }

  if(res1==0||res2==0)

  {

  	cout<<"YES"<<endl;

  }

  else if(res1==1||ans1==n-1)

  {

  	cout<<"YES"<<endl;

  }

  else if(res2==1||ans2==0)

  {

  	cout<<"YES"<<endl;

  }

  else

  {

  	cout<<"NO"<<endl;

  }

}

int main()

{

	ios;

	int t;

	cin>>t;

	while(t--)

	{

		sol();

	}

	return 0;

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)


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

using namespace std;

#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

typedef pair<int,int> PII;

typedef long long ll;

void sol(){

  int n;

  cin>>n;

  string s;

  cin>>s;

  s=" "+s;

  bool st[n+1];

  memset(st,false,sizeof st);

  int op=0;

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

  {

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

  	{

  		op=i;

  		break;

	  }

  }

  if(op==0)

  {

  	cout<<"YES"<<endl;

  	return;

  }

  vector<PII> ans(n+1);

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

  {

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

  	{

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

        {

        	if(st[j]==false)

        	{

        		ans[j]={i,n};

        	//	cout<<i<<j<<" "<<" "<<"s"<<endl;

			}

			else

			{

				int x=ans[j].first;

				int y=ans[j].second;

				if(i>x) x=i;

				if(n<y) y=n;

				ans[j]={x,y};

			//	cout<<i<<j<<" "<<" "<<x<<" "<<y<<" "<<"s"<<endl;

			}

			st[j]=true;

		}

	}

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

	{

         for(int j=1;j<=i;j++)

        {

        	if(st[j]==false)

        	{

        		ans[j]={1,i};

        	//	cout<<i<<j<<" "<<" "<<"q"<<endl;

			}

			else

			{

				int x=ans[j].first;

				int y=ans[j].second;

				if(1>x) x=1;

				if(i<y) y=i;

				ans[j]={x,y};

			//	cout<<i<<j<<" "<<" "<<x<<" "<<y<<" "<<"q"<<endl;

			}

			st[j]=true;

		}

	}

  }

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

  {

  	int x=ans[i].first;

	int y=ans[i].second;

//	cout<<x<<" "<<y<<endl;

	if(x>y||x==0||y==0)

	{

	cout<<"NO"<<endl;	

	return;

	}

  }

  cout<<"YES"<<endl;

}

int main()

{

	ios;

	int t;

	cin>>t;

	while(t--)

	{

		sol();

	}

	return 0;

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

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

using namespace std;

#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

typedef pair<int,int> PII;

typedef long long ll;

void sol(){

  int n;

  cin>>n;

  string s;

  cin>>s;

  int res1=0,res2=0;

  int ans1=0,ans2=0;

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

  {

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

  	{

  		res1++;

  		ans1=i;

	  }

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

	  {

	  	res2++;

	  	ans2=i;

	  }

  }

  if(res1==0||res2==0)

  {

  	cout<<"YES"<<endl;

  }

  else if(res1==1||ans1==n-1)

  {

  	cout<<"YES"<<endl;

  }

  else if(res2==1||ans2==0)

  {

  	cout<<"YES"<<endl;

  }

  else

  {

  	cout<<"NO"<<endl;

  }

}

int main()

{

	ios;

	int t;

	cin>>t;

	while(t--)

	{

		sol();

	}

	return 0;

} 

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

using namespace std;

#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

typedef pair<int,int> PII;

typedef long long ll;

void sol(){

  int n;

  cin>>n;

  string s;

  cin>>s;

  int res1=0,res2=0;

  int ans1=-1,ans2=-1;

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

  {

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

  	{

  		res1++;

  		ans1=i;

	  }

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

	  {

	  	res2++;

	  	ans2=i;

	  }

  }

  if(res1==0||res2==0)

  {

  	cout<<"YES"<<endl;

  }

  else if(res1==1&&ans1==n-1)

  {

  	cout<<"YES"<<endl;

  }

  else if(res2==1&&ans2==0)

  {

  	cout<<"YES"<<endl;

  }

  else

  {

  	cout<<"NO"<<endl;

  }

}

int main()

{

	ios;

	int t;

	cin>>t;

	while(t--)

	{

		sol();

	}

	return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
//signed by xy

#include <bits/stdc++.h>

using namespace std;

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

#define int long long

#define double long double

#define ull unsigned long long

#define endl '\n'

#define x first

#define y second

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

#define PII pair<int,int>

#define TUP tuple<int,int,int>

#define  M_PI 3.14159265358979323846

#define cmin(a,b) a = min(a,b)

#define cmax(a,b) a = max(a,b)

#define begin(a) a.begin()

#define end(a) a.end()



template <typename Tp>

void read(Tp &x){

char c=getchar();x=0;int f=1;

while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}

while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}x*=f;

}



const int inf = LONG_LONG_MAX;

const int N = 1e6+10,mod = 1e9+7,P = 19270821;





int n,m;



void solve()

{

cin >> n ;

vector<int>a(n+1);

rep(i,1,n) cin >> a[i];

int t = a[1];

bool st = false;

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

{

if(a[i] > t) st = true;

}

if(st) cout << "YES" << endl;

else cout << "NO" << endl;

}



signed main() {

ios;

int t = 1;

cin >> t;

while(t--)

solve();

return 0;

}



Submission (verdict: Accepted):
//signed by xy

#include <bits/stdc++.h>

using namespace std;

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

#define int long long

#define double long double

#define ull unsigned long long

#define endl '\n'

#define x first

#define y second

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

#define PII pair<int,int>

#define TUP tuple<int,int,int>

#define  M_PI 3.14159265358979323846

#define cmin(a,b) a = min(a,b)

#define cmax(a,b) a = max(a,b)

#define begin(a) a.begin()

#define end(a) a.end()



template <typename Tp>

void read(Tp &x){

char c=getchar();x=0;int f=1;

while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}

while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}x*=f;

}



const int inf = LONG_LONG_MAX;

const int N = 1e6+10,mod = 1e9+7,P = 19270821;





int n,m;



void solve()

{

cin >> n ;

vector<int>a(n+1);

rep(i,1,n) cin >> a[i];

rep(i,1,n)

{

if(a[i] < a[i-1])

{

cout << "NO" << endl;

return;

}

a[i] -= a[i-1];

}

cout << "YES" << endl;

}



signed main() {

ios;

int t = 1;

cin >> t;

while(t--)

solve();

return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
//signed by xy

#include <bits/stdc++.h>

using namespace std;

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

#define int long long

#define double long double

#define ull unsigned long long

#define endl '\n'

#define x first

#define y second

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

#define PII pair<int,int>

#define TUP tuple<int,int,int>

#define  M_PI 3.14159265358979323846

#define cmin(a,b) a = min(a,b)

#define cmax(a,b) a = max(a,b)

#define begin(a) a.begin()

#define end(a) a.end()



template <typename Tp>

void read(Tp &x){

char c=getchar();x=0;int f=1;

while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}

while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}x*=f;

}



const int inf = LONG_LONG_MAX;

const int N = 1e6+10,mod = 1e9+7,P = 19270821;





int n,m;



void solve()

{

cin >> n ;

vector<int>a(n+1);

rep(i,1,n) cin >> a[i];

int t = a[0];

bool t = false;

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

{

if(a[i] >= t) t = true;

}

if(t) cout << "YES" << endl;

else cout << "NO" << endl;

}



signed main() {

ios;

int t = 1;

cin >> t;

while(t--)

solve();

return 0;

}



Submission (verdict: Wrong answer on test 2):
//signed by xy

#include <bits/stdc++.h>

using namespace std;

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

#define int long long

#define double long double

#define ull unsigned long long

#define endl '\n'

#define x first

#define y second

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

#define PII pair<int,int>

#define TUP tuple<int,int,int>

#define  M_PI 3.14159265358979323846

#define cmin(a,b) a = min(a,b)

#define cmax(a,b) a = max(a,b)

#define begin(a) a.begin()

#define end(a) a.end()



template <typename Tp>

void read(Tp &x){

char c=getchar();x=0;int f=1;

while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}

while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}x*=f;

}



const int inf = LONG_LONG_MAX;

const int N = 1e6+10,mod = 1e9+7,P = 19270821;





int n,m;



void solve()

{

cin >> n ;

vector<int>a(n+1);

rep(i,1,n) cin >> a[i];

int t = a[1];

bool st = false;

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

{

if(a[i] > t) st = true;

}

if(st) cout << "YES" << endl;

else cout << "NO" << endl;

}



signed main() {

ios;

int t = 1;

cin >> t;

while(t--)

solve();

return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Compilation error):
//signed by xy

#include <bits/stdc++.h>

using namespace std;

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

#define int long long

#define double long double

#define ull unsigned long long

#define endl '\n'

#define x first

#define y second

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

#define PII pair<int,int>

#define TUP tuple<int,int,int>

#define  M_PI 3.14159265358979323846

#define cmin(a,b) a = min(a,b)

#define cmax(a,b) a = max(a,b)

#define begin(a) a.begin()

#define end(a) a.end()



template <typename Tp>

void read(Tp &x){

char c=getchar();x=0;int f=1;

while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}

while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}x*=f;

}



const int inf = LONG_LONG_MAX;

const int N = 1e6+10,mod = 1e9+7,P = 19270821;





int n,m;



void solve()

{

cin >> n ;

vector<int>a(n+1);

rep(i,1,n) cin >> a[i];

int t = a[0];

bool t = false;

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

{

if(a[i] >= t) t = true;

}

if(t) cout << "YES" << endl;

else cout << "NO" << endl;

}



signed main() {

ios;

int t = 1;

cin >> t;

while(t--)

solve();

return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
void solve()
{
    //4 5 4 5 4 5 4 5
    //0 1 4 5 4 5 4 5
    //0 0 3 5 4 5 4 5
    //0  0 0 2 4 5 4 5
    // 0 0 0 0 2 5  4 5
    //0 0 0 0 0 3 4 5
    int n;
    cin>>n;
    vector<int>a(n+100);
    for(int i=1;i<=n;i++)cin>>a[i];
    vector<int>last(n+100);
    last[n]=true;
    for(int i=n-1;i>=1;i--)
    {
        if(a[i+1]>=a[i])
        {
            last[i]=true;
        }
        else 
        break;
    }
    int flag=false;
    for(int i=1;i<=n;i++)
    {
        if(last[i])
        {
            flag=true;
            break;
        }
        if(min(a[i],a[i+1])==0)
        {
            if((a[i]<=a[i+1]))
            {
                flag|=last[i+1];
            }
            break;
        }
        int t=min(a[i],a[i+1]);
        a[i]-=t;
        a[i+1]-=t;
    }
    if(flag)
    cout<<"YES\n";
    else cout<<"NO\n";
}
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("d.in","a+",stdin);
    #endif 
    int T;
    cin>>T;
    while(T--)solve();
}