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 <cstdio>
#include <utility>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
#define is inline bool scan
ii(int c) {
	int n = 0;
	bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	//return n; }
	return minus ? -n : n; }
ii() {return in(gcu());}
is(int &n) {int c=gcu();return c==EOF?false:(n=in(c),true);}
is(char &c){c=gcu();gcu();return c!=EOF;}
//is(string &s) {int c;for(;;){c=gcu();if(c=='\n'||c==' ')return true;s+=c;}}
#undef ii
#define pcu putchar_unlocked
template <typename T>
void out(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
void out(const char *s){while(*s)pcu(*s++);}
void out(char c){pcu(c);}
//void out(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
void out(head&& h, tail&&... t){out(h);out(move(t)...);}
template <typename T>
void out(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef svo

int main() {
	int gems, g;
	while ((gems = g = in())) {
		vector<vector<int>> map(21, vector<int>(21));
		while (g--) {
			int x = in(), y = in();
			map[y][x] = true;
		}
		int operations = in(), x = 10, y = 10;
		while (operations--) {
			int dx = 0, dy = 0;
			switch (gcu()) {
			case 'N' : dy = 1;  break;
			case 'S' : dy = -1; break;
			case 'E' : dx = 1;  break;
			default  : dx = -1; break;
			}
			gcu();
			for (int i = in(); i > 0; i--) {
				x += dx; y += dy;
				if (map[y][x]) {
					map[y][x] = false;
					gems--;
				}
			}
		}
		out(gems ? "No" : "Yes", '\n');
	}
}

C++: #include <cstdio>
#include <iostream>
#include <list>

using namespace std;

int main()
{
	int n;
	while(1){
		cin >> n;
		if(n == 0) break;
		int a[21][21] = {0}, x, y;
		for(int i = 0; i < n; i++){
			cin >> x >> y;
			a[x][y] = 1;
		}
		int m, X=10, Y=10, cnt=0;
		char d;
		int l;
		cin >> m;
		for(int j = 0; j < m; j++){
				cin >> d >> l;
				for(int k = 0; k < l; k++){
				if(d == 'N') Y++;
				else if(d == 'E') X++;
				else if(d == 'S') Y--;
				else if(d == 'W') X--;
				if(a[X][Y] == 1) cnt++;
			}
		}
		if(cnt >= n) cout << "Yes" <<endl;
		else cout << "No" << endl;
	}
	return 0;
}

C++: while 1:
    find = False
    r_pos = [9,9]
    n = int(raw_input())
    if n == 0: break
    planet = [[0 for j in xrange(20)] for i in xrange(20)]
    for i in xrange(n):
        x,y = map(int, raw_input().split())
        planet[y-1][x-1] = 1
    m = int(raw_input())
    for i in xrange(m):
        d,l = raw_input().split()
        l = int(l)
        if d == 'N':
            for j in xrange(r_pos[0], r_pos[0]+l+1):
                planet[j][r_pos[1]] = 0
            r_pos[0] += l
            #print r_pos
        elif d == 'S':
            for j in xrange(r_pos[0], r_pos[0]-l-1):
                planet[j][r_pos[1]] = 0
            r_pos[0] -= l
            #print r_pos
        elif d == 'E':
            for j in xrange(r_pos[1], r_pos[1]+l+1):
                planet[r_pos[0]][j] = 0
            r_pos[1] += l
            #print r_pos
        elif d == 'W':
            for j in xrange(r_pos[1], r_pos[1]-l-1):
                planet[r_pos[0]][j] = 0
            r_pos[1] -= l
            #print r_pos
    for i in xrange(20):
        for j in xrange(20):
            if planet[j][i] == 1:
                find = True
    if find is True: print 'NO'
    else: print 'YES'

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

// this require C++11
//#include <unordered_set>
//#include <unordered_map>
//#include <random>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os,vector<T>& vec){
    typename vector<T>::iterator it,endit=vec.end();
    os << "[";
    for(it=vec.begin();it!=endit;it++){
        os << " " << *it << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

int N,M,ground[21][21];
int nowx=10,nowy=10;
int move(int x,int y,int l){
    int gathered=0;
    for(int i=0;i<=l;i++){
        if(ground[nowx+i*x][nowy+i*y]==1){
            gathered++;
            ground[nowx+i*x][nowy+i*y]=0;
        }
    }
    nowx+=l*x;
    nowy+=l*y;
    return gathered;
}
int solve(){
    int l;
    char d;
    nowx=10;nowy=10;
    for(int i=0;i<M;i++){
        cin >> d >> l;
        switch(d){
            case 'N':
                N-=move(0,1,l);
                break;
            case 'S':
                N-=move(0,-1,l);
                break;
            case 'E':
                N-=move(1,0,l);
                break;
            case 'W':
                N-=move(-1,0,l);
                break;
        }
    }
//    cout << N << endl;
    int ret;
    if(N==0)
        ret=0;
    else 
        ret=1;
    return ret;
}

int main(){
    for(;;){
        cin >> N;
        if(N==0)
            break;
        int xi,yi;
        for(int i=0;i<N;i++){
            cin >> xi >> yi;
            ground[xi][yi]=1;
        }
        cin >> M;
        if(solve()==0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}