Language: C++

#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<stack>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,k,i,j,x,y,xx,yy,vis[100005];
struct ii
{
	int x,y,id;
};
vector<ii> seq;
stack<int> stk;
bool cmp(ii x,ii y)
{
	if (x.x==0)
	{
		if (y.x==0)
		{
			return x.y<y.y;
		}
		return 1;
	}
	if (y.x==0)	return 0;
	if (x.y==m)
	{
		if (y.y==m)
		{
			return x.x<y.x;
		}
		return 1;
	}
	if (y.y==m) return 0;
	if (x.x==n)
	{
		if (y.x==n)
		{
			return x.y>y.y;
		}
		return 1;
	}
	if (y.x==n) return 0;
	if (x.y==0)
	{
		if (y.y==0)
		{
			return x.x>y.x;
		}
		return 1;
	}
	return 0;
}
int main()
{
	cin>>n>>m>>k;
	for (i=1;i<=k;i++)
	{
		cin>>x>>y>>xx>>yy;
		if (x==0||x==n||y==0||y==m) if (xx==0||xx==n||yy==0||yy==m)
		{
			seq.push_back((ii){x,y,i});
			seq.push_back((ii){xx,yy,i});
		}
	}
	sort(seq.begin(),seq.end(),cmp);
	for (i=0;i<seq.size();i++)
	{
		if (!vis[seq[i].id]) {stk.push(seq[i].id);vis[seq[i].id]=1;}
			else {
				if (seq[i].id!=stk.top()) {cout<<"NO";return 0;}
				stk.pop();
			}
	}
	cout<<"YES";
	return 0;
}#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<stack>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,k,i,j,x,y,xx,yy,vis[100005];
struct ii
{
	int x,y,id;
};
vector<ii> seq;
stack<int> stk;
bool cmp(ii x,ii y)
{
	if (x.x==0)
	{
		if (y.x==0)
		{
			return x.y<y.y;
		}
		return 1;
	}
	if (y.x==0)	return 0;
	if (x.y==m)
	{
		if (y.y==m)
		{
			return x.x<y.x;
		}
		return 1;
	}
	if (y.y==m) return 0;
	if (x.x==n)
	{
		if (y.x==n)
		{
			return x.y>y.y;
		}
		return 1;
	}
	if (y.x==n) return 0;
	if (x.y==0)
	{
		if (y.y==0)
		{
			return x.x>y.x;
		}
		return 1;
	}
	return 0;
}
int main()
{
	cin>>n>>m>>k;
	for (i=1;i<=k;i++)
	{
		cin>>x>>y>>xx>>yy;
		if (x==0||x==n||y==0||y==m) if (xx==0||xx==n||yy==0||yy==m)
		{
			seq.push_back((ii){x,y,i});
			seq.push_back((ii){xx,yy,i});
		}
	}
	sort(seq.begin(),seq.end(),cmp);
	for (i=0;i<seq.size();i++)
	{
		if (!vis[seq[i].id]) {stk.push(seq[i].id);vis[seq[i].id]=1;}
			else {
				if (seq[i].id!=stk.top()) {cout<<"NO";return 0;}
				stk.pop();
			}
	}
	cout<<"YES";
	return 0;
}

Compiler output:
a.cc:81:2: error: stray '#' in program
   81 | }#include <iostream>
      |  ^
a.cc:81:3: error: 'include' does not name a type
   81 | }#include <iostream>
      |   ^~~~~~~
a.cc:92:5: error: redefinition of 'int n'
   92 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |     ^
a.cc:12:5: note: 'int n' previously declared here
   12 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |     ^
a.cc:92:7: error: redefinition of 'int m'
   92 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |       ^
a.cc:12:7: note: 'int m' previously declared here
   12 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |       ^
a.cc:92:9: error: redefinition of 'int k'
   92 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |         ^
a.cc:12:9: note: 'int k' previously declared here
   12 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |         ^
a.cc:92:11: error: redefinition of 'int i'
   92 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |           ^
a.cc:12:11: note: 'int i' previously declared here
   12 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |           ^
a.cc:92:13: error: redefinition of 'int j'
   92 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |             ^
a.cc:12:13: note: 'int j' previously declared here
   12 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |             ^
a.cc:92:15: error: redefinition of 'int x'
   92 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |               ^
a.cc:12:15: note: 'int x' previously declared here
   12 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |               ^
a.cc:92:17: error: redefinition of 'int y'
   92 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |                 ^
a.cc:12:17: note: 'int y' previously declared here
   12 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |                 ^
a.cc:92:19: error: redefinition of 'int xx'
   92 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |                   ^~
a.cc:12:19: note: 'int xx' previously declared here
   12 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |                   ^~
a.cc:92:22: error: redefinition of 'int yy'
   92 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |                      ^~
a.cc:12:22: note: 'int yy' previously declared here
   12 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |                      ^~
a.cc:92:25: error: redefinition of 'int vis [100005]'
   92 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |                         ^~~
a.cc:12:25: note: 'int vis [100005]' previously declared here
   12 | int n,m,k,i,j,x,y,xx,yy,vis[100005];
      |                         ^~~
a.cc:93:8: error: redefinition of 'struct ii'
   93 | struct ii
      |        ^~
a.cc:13:8: note: previous definition of 'struct ii'
   13 | struct ii
      |        ^~
a.cc:97:12: error: redefinition of 'std::vector<ii> seq'
   97 | vector<ii> seq;
      |            ^~~
a.cc:17:12: note: 'std::vector<ii> seq' previously declared here
   17 | vector<ii> seq;
      |            ^~~
a.cc:98:12: error: redefinition of 'std::stack<int> stk'
   98 | stack<int> stk;
      |            ^~~
a.cc:18:12: note: 'std::stack<int> stk' previously declared here
   18 | stack<int> stk;
      |            ^~~
a.cc:99:6: error: redefinition of 'bool cmp(ii, ii)'
   99 | bool cmp(ii x,ii y)
      |      ^~~
a.cc:19:6: note: 'bool cmp(ii, ii)' previously defined here
   19 | bool cmp(ii x,ii y)
      |      ^~~
a.cc:138:5: error: redefinition of 'int main()'
  138 | int main()
      |     ^~~~
a.cc:58:5: note: 'int main()' previously defined here
   58 | int main()
      |     ^~~~