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 <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <map>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INT(a) int((a)+1e-9)

int main(){
	while(true){
		int gl;
		cin>>gl;			if(!gl) return 0;
		bool mss[21][21];	//sokoni gem ga aru
		REP(x,21) REP(y,21) mss[x][y]=false;
		REP(gi,gl){
			int gx,gy;
			cin>>gx>>gy;
			mss[gx][gy]=true;
		}

		int ol;
		cin>>ol;
		int px=10,py=10;
		mss[px][py]=false;
		REP(oi,ol){
			char vc; int kl;
			cin>>vc>>kl;
			if(vc=='N') REP(k,kl) mss[px][++py]=false;
			if(vc=='S') REP(k,kl) mss[px][--py]=false;
			if(vc=='E') REP(k,kl) mss[++px][py]=false;
			if(vc=='W') REP(k,kl) mss[--px][py]=false;
		}

		bool re=false;
		REP(x,21) REP(y,21) re = re || mss[x][y];

		cout << (re?"No":"Yes") << endl;
	}
}

C++: #include <cstdio>
#include <iostream>
using namespace std;
int field[21][21];
int main() {
    int n;
    while (scanf("%d",&n)) {
        if (!n) break;
        for (int i=0; i<21; i++) for (int j=0; j<21; j++) field[i][j]=0;
        for (int i=0; i<n; i++) {
            int x, y; scanf("%d%d",&x,&y);
            field[20-y][x]=1;
        }
        int m; scanf("%d",&m);
        int rx=10, ry=10;
        int cnt=0;
        for (int i=0; i<m; i++) {
            char d; cin>>d;
            int dist; scanf("%d",&dist);
            if (d=='N') {
                for (int j=0; j<dist; j++) {
                    ry--;
                    if (field[ry][rx]==1) {
                        field[ry][rx]=0;
                        cnt++;
                    }
                }
            } else if (d=='E') {
                for (int j=0; j<dist; j++) {
                    rx++;
                    if (field[ry][rx]==1) {
                        field[ry][rx]=0;
                        cnt++;
                    }
                }
            } else if (d=='S') {
                for (int j=0; j<dist; j++) {
                    ry++;
                    if (field[ry][rx]==1) {
                        field[ry][rx]=0;
                        cnt++;
                    }
                }
            } else if (d=='W') {
                for (int j=0; j<dist; j++) {
                    rx--;
                    if (field[ry][rx]==1) {
                        field[ry][rx]=0;
                        cnt++;
                    }
                }
            }
        }
        if (cnt!=n) puts("NO");
        else puts("YES");
    }
}

C++: #include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double EPS = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int N, M;

int main() {
	// cin.tie(0); // tie
	// ios::sync_with_stdio(false); // sync
	while (cin >> N, N) {
		int table[21][21];
		rep(i, 21) rep(j, 21) table[i][j] = 0;
		int py = 10, px = 10;
		rep(i, N) {
			int x, y;
			cin >> x >> y;
			table[20 - y][x] = 1;
		}

		cin >> M;
		int cnt = 0;
		rep(i, M) {
			char d; int l;
			cin >> d >> l;
			rep(i, l) {
				if (d == 'N') py--;
				else if (d == 'S') py++;
				else if (d == 'E') px++;
				else if (d == 'W') px--;
				if (table[py][px] == 1) {
					table[py][px] = 0;
					cnt++;
				}
			}
		}
		if (cnt == N) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;

struct ans{
	int n;
	ans *next;
};

int main(){
	ans *start=new ans();
	start->next=NULL;
	ans *end=start,*buf;
	char s[20];
	char dir;
	char *ps;
	int **juel;
	int x=10,y=10;
	int state[20][20];
	int i,j,n,m,size;
	while(fgets(s,sizeof(s),stdin)){
		size=atoi(s);
		if(size==0) break;
		memset(state,0,sizeof(state));
		juel=new int*[size];
		for(i=0;i<size;i++){
			juel[i]=new int[3];
			fgets(s,sizeof(s),stdin);
			ps=strtok(s," ");
			juel[i][0]=atoi(ps);
			ps=strtok(NULL," ");
			juel[i][1]=atoi(ps);
			juel[i][2]=1;
		}
		fgets(s,sizeof(s),stdin);
		n=atoi(s);
		for(i=0;i<n;i++){
			fgets(s,sizeof(s),stdin);
			ps=strtok(s," ");
			dir=ps[0];
			ps=strtok(NULL," ");
			m=atoi(ps);
			switch(dir){
			case 'N':
				for(j=1;j<=m;j++) state[x][y+j]=1;
				y+=m;
				break;
			case 'S':
				for(j=1;j<=m;j++) state[x][y-j]=1;
				y-=m;
				break;
			case 'E':
				for(j=1;j<=m;j++) state[x+j][y]=1;
				x+=m;
				break;
			case 'W':
				for(j=1;j<=m;j++) state[x-j][y]=1;
				x-=m;
				break;
			}
		}
		for(i=0;i<size;i++)if(state[juel[i][0]][juel[i][1]]==0) break;
		if(i==size) n=0;
		else n=1;
		buf=new ans();
		buf->n=n;
		buf->next=NULL;
		end->next=buf;
		end=buf;
	}
	buf=start->next;
	while(buf!=NULL){
		if(buf->n==0) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		end=buf;
		buf=buf->next;
		delete end;
	}
	for(i=0;i<size;i++) delete []juel[i];
	delete []juel;
	return 1;
}

C++: //Misterious Gems
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)

map<string, int> h;

int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};

int main(){
  h["N"]=0; h["E"]=1; h["S"]=2; h["W"]=3;

  while(true){
    int N;
    cin>>N;
    if(N==0)break;
    int mp[21][21];
    memset(mp, 0, sizeof(mp));
    rep(i,N){
      int x, y;
      cin>>x>>y;
      mp[x][y]=1;
    }

    int M, nx=10, ny=10;
    int cn=0;
    if(mp[10][10]==1){cn++; mp[10][10]=0;}
    cin>>M;
    rep(i,M){
      string d;
      int l;
      cin>>d>>l;
      int dd=h[d];
      rep(j,l){
        nx+=dir[dd][0]; ny+=dir[dd][1];
        if(mp[nx][ny]==1){cn++; mp[nx][ny]=0;}
      }
    }
    if(N==cn)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}