WRong-Answer in prateek sir and coding

I am getting the wrong answer for the last test case,
Question link - https://hack.codingblocks.com/contests/c/588/501
here’s my code-

#include
#include
#include
#include
using namespace std;
int main () {
stack < int > s;
int a;
int b;
int n;
int flag = 0;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a;

	   if(a==2)
	     {
	         cin>>b;
	        // cout<<"push "<<b<<endl;
			s.push(b);
		 }
		else
		  {
              if(s.empty())
                {
                cout<<"No Code"<<endl;
                }
              else
                { cout<<s.top()<<endl;
                s.pop();
                flag = 1;
                }
          }
   }

   if(flag == 0)
     cout<<"No Code";

return 0;

}

Please if anyone finds what I am doing wrong please let me know.
TIA !!