Comiler cheaking incorrectly

When summit this code it showed that my is not running correctly in test case :- 0,2 &6. But when I checked running my code manually on these test cases it showed the correct output.

Please help!!

My code is written below :-

#include
using namespace std;

int main() {

int n,d=1, ans=0;
long int noc, nop = noc;
cin>>n;

for(int i=0; i<n; i++)
{
	if(i != 0)
	
	{
		cin>>noc;
	
		if(noc==nop)
		{
			ans = 1;
			goto out;
		}

		else if(noc>nop)
		d=0;

		else if(d==0 and noc<nop)
		{
			ans = 2;
			goto out;
		}
	}	

	nop = noc;
}

out :
if(ans == 1 or ans == 2)
cout<<"false"<<endl;

else if(ans ==0)
cout<<"true"<<endl;

return 0;

}

@Shivam01
5
5 4 3 4 5
ans should be true but your code show false check it

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.