Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

type Point struct {
	X, Y int
}

type Gem struct {
	ID int
	Point
}

type Map struct {
	Current       *Point
	Gems          map[int]*Gem
	CollectedGems map[int]*Gem
}

func (m *Map) Move(dir string, l int) {
	switch {
	case dir == "N" || dir == "S":
		a := 1
		if dir == "S" {
			a = -1
		}
		for i := 0; i < l; i++ {
			m.Current.Y += a
			for _, g := range m.Gems {
				m.TryToTakeGem(g)
			}
		}
	case dir == "E" || dir == "W":
		a := 1
		if dir == "W" {
			a = -1
		}
		for i := 0; i < l; i++ {
			m.Current.X += a
			for _, g := range m.Gems {
				m.TryToTakeGem(g)
			}
		}
	}
}

func (m *Map) HasCompleted() bool {
	return len(m.Gems) == 0
}

func (m *Map) TryToTakeGem(g *Gem) {
	if m.Current.X == g.X && m.Current.Y == g.Y {
		m.CollectedGems[g.ID] = g
		delete(m.Gems, g.ID)
	}
}

func main() {
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		if n == 0 {
			break
		}
		m := &Map{
			Current:       &Point{X: 10, Y: 10},
			Gems:          map[int]*Gem{},
			CollectedGems: map[int]*Gem{},
		}
		for i := 0; i < n; i++ {
			sc.Scan()
			chunks := strings.Split(sc.Text(), " ")
			x, _ := strconv.Atoi(chunks[0])
			y, _ := strconv.Atoi(chunks[1])
			m.Gems[i+1] = &Gem{ID: i + 1, Point: Point{X: x, Y: y}}
		}
		sc.Scan()
		opCnt, _ := strconv.Atoi(sc.Text())
		for i := 0; i < opCnt; i++ {
			sc.Scan()
			chunks := strings.Split(sc.Text(), " ")
			dir := chunks[0]
			v, _ := strconv.Atoi(chunks[1])
			m.Move(dir, v)
		}
		msg := "No"
		if m.HasCompleted() {
			msg = "Yes"
		}
		fmt.Println(msg)
	}
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<bitset>
#include<map>
using namespace std;

struct P{
  int x,y;
};

vector<P> list;
int input(){
  int N;
  cin>>N;
  if(N==0)return false;
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    list.push_back(P{a,b});
  }
  return true;
}

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

bool solve(){
  int M;
  cin>>M;
  P r=P{10,10};
  vector<int> use;
  use.resize(list.size());
  for(int i=0;i<use.size();i++){
    use[i]=0;
  }
  for(int i=0;i<M;i++){
    char c;
    int d;
    cin>>c>>d;
    int v;
    switch(c){
      case 'N':
        v=0;
        break;
      case 'E':
        v=1;
        break;
      case 'S':
        v=2;
        break;
      case 'W':
        v=3;
        break;
    }
    int xx = r.x + vx[v]*d;
    int yy = r.y + vy[v]*d;
    for(int i=0;i<list.size();i++){
      if(((r.x<=list[i].x&&list[i].x<=xx)||(xx<=list[i].x&&list[i].x<=r.x))
          &&((r.y<=list[i].y&&list[i].y<=yy)||(yy<=list[i].y&&list[i].y<=r.y))){
        use[i]=true;
      }
    }
    r.x = xx;
    r.y = yy;
  }
  for(int i=0;i<use.size();i++){
    if(!use[i])return false;
  }
  return true;
}


int main(){
  while(input()){
    if(solve()){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int g[20][20];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

int main(void){

	int n,m;
	map<char,int>dd;
	dd['N']=0;
	dd['E']=1;
	dd['S']=2;
	dd['W']=3;

	while(cin >> n,n){
		fill(g[0],g[20],0);

		for(int i=0;i<n;i++){
			int x,y;
			cin >> x >> y;
			g[y][x]=1;
		}

		cin >> m;
		int x=10,y=10;
		g[y][x]=0;
		for(int i=0;i<m;i++){
			char dir;
			int dis;
			cin >> dir >> dis;
			for(int k=0;k<dis;k++){
				x+=dx[dd[dir]],y+=dy[dd[dir]];
				g[y][x]=0;
			}
		}

		bool fg=true;
		for(int i=0;i<20;i++)
			for(int j=0;j<20;j++)
				fg&=(g[i][j]==0);

		if(fg)cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N;
    while(N){
        set< P >st;
        int used = (1 << (N+1)) - 1;
        rep(i,0,N){
            int x,y;
            cin >> x >> y;
            st.insert(P(x,y));
        }
        cin >> M;
        int nx = 10,ny = 10;
        rep(i,0,M){
            char c;
            int num;
            cin >> c >> num;
            rep(j,0,num){
                if(c == 'N')ny++;
                if(c == 'S')ny--;
                if(c == 'E')nx++;
                if(c == 'W')nx--;
                if(st.count(P(nx,ny))){
                    st.erase(P(nx,ny));
                }   
            }
        }
        if(st.size() == 0) cout << "Yes" << endl;
        else               cout << "No" << endl;
        cin >> N;
    }
}

C++: #include<iostream>

#define MAXMAP 21

using namespace std;

const int dx[]={0,1,-1,0},dy[]={1,0,0,-1};
const char direction[]={'N','E','W','S'};
bool myMap[MAXMAP][MAXMAP]={false};


int main(){
	int N,M,nowX,nowY;
	bool flag;
	
	while(cin>>N){
		
		if(N==0){
			break;
		}
		fill((bool*)myMap,(bool*)(myMap+MAXMAP),false);
		nowX=nowY=10;
		flag=false;
		
		for(int i=0;i<N;i++){
			int x,y;
			cin>>x>>y;
			myMap[y][x]=true;
		}
		
		cin>>M;
		for(int i=0;i<M;i++){
			char tempDirec;
			int distance,tempDist;
			
			cin>>tempDirec>>distance;
			
			
			for(int j=0;j<4;j++){
				if(tempDirec==direction[j]){
					
					
					if(dx[j]!=0){
						tempDist=nowX+dx[j]*distance;
						if(dx[j]==1){
							for(int k=nowX;k<=tempDist;k++){
								if(myMap[nowY][k]){
									myMap[nowY][k]=false;
								}
							}
						}
						else if(dx[j]==-1){
							for(int k=nowX;k>=tempDist;k--){
								if(myMap[nowY][k]){
									myMap[nowY][k]=false;
								}
							}
						}
						nowX=tempDist;
					}
					
					
					if(dy[j]!=0){
						tempDist=nowY+dy[j]*distance;
						if(dy[j]==1){
							for(int k=nowY;k<=tempDist;k++){
								if(myMap[k][nowX]){
									myMap[k][nowX]=false;
								}
							}
						}
						else if(dy[j]==-1){
							for(int k=nowY;k>=tempDist;k--){
								if(myMap[k][nowX]){
									myMap[k][nowX]=false;
								}
							}
						}
						nowY=tempDist;
					}
					
					
					break;
				}
			}
		}
		
		
		for(int i=0;i<MAXMAP;i++){
			for(int j=0;j<MAXMAP;j++){
				if(myMap[i][j]==true){
					flag=true;
					//cout<<"i="<<i<<" j="<<j<<endl;
					break;
				}
			}
		}
		
		
		if(flag){
			cout<<"NO"<<endl;
		}
		else{
			cout<<"YES"<<endl;
		}
	}
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef pair<int, int>P;

bool a[21][21];

int main() {
	int n;
	while (cin >> n, n) {
		rep(i, n) {
			int x, y; cin >> x >> y;
			a[x][y] = true;
		}
		int m; cin >> m;
		int x = 10, y = 10;
		if (a[x][y]) {
			a[x][y] = false;
			n--;
		}
		rep(i, m) {
			char c;int d; cin >> c >> d;
			if (c == 'N')rep(j, d) {
				y++;if (a[x][y]) { a[x][y] = false; n--; }
			}
			if (c == 'E')rep(j, d) {
				x++; if (a[x][y]) { a[x][y] = false; n--; }
			}
			if (c == 'S')rep(j, d) {
				y--; if (a[x][y]) { a[x][y] = false; n--; }
			}
			if (c == 'W')rep(j, d) {
				x--; if (a[x][y]) { a[x][y] = false; n--; }
			}
		}
		puts(n ? "No" : "Yes");
	}
}

C++: #include <iostream>

using namespace std;

int f[21][21];

int main() {
	int n;
	while (cin >> n, n) {
		memset(f, 0, sizeof(f));

		for (int i = 0; i<n; i++) {
			int x, y;
			cin >> x >> y;
			f[y][x] = 1;
		}

		int x = 10, y = 10;

		int m;
		cin >> m;
		for (int i = 0; i<m; i++) {
			char dir;
			int step;
			cin >> dir >> step;
			while (step--) {
				if (dir == 'N') { y++; }
				else if (dir == 'S') { y--; }
				else if (dir == 'E') { x++; }
				else { x--; }
				f[y][x] = 0;
			}
		}

		bool yes = true;
		for (int y = 0; y <= 20; y++) {
			for (int x = 0; x <= 20; x++) {
				if (f[y][x]) {
					yes = false;
					goto ANSWER;
				}
			}
		}
	ANSWER:
		if (yes) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	return 0;
}