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 <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>



using namespace std;


char grid[21][21];


int main()
{
	int N, M, in_x, in_y, l, now_x, now_y;
	char d;
	
	while (cin >> N)
	{
		if (N == 0) break;
		
		//gridの初期化
		for (int y=0; y<21; y++)
		{
			for (int x=0; x<21; x++)
			{
				grid[y][x] = '.';
			}
		}
		
		//宝石の位置の入力
		for (int i=0; i<N; i++)
		{
			cin >> in_x >> in_y;
			grid[in_y][in_x] = '#';
		}
		
		cin >> M;
		now_x = now_y = 10;
		for (int i=0; i<M; i++)
		{
			cin >> d >> l;
			for (int j=1; j<=l; j++)
			{
				if (d == 'N')
				{
					grid[now_y + j][now_x] = '.';
					if (j == l)
					{
						now_y += j;
					}
				} else if (d == 'E') {
					grid[now_y][now_x + j] = '.';
					if (j == l)
					{
						now_x += j;
					}
				} else if (d == 'S') {
					grid[now_y - j][now_x] = '.';
					if (j == l)
					{
						now_y -= j;
					}
				} else if (d == 'W') {
					grid[now_y][now_x - j] = '.';
					if (j == l)
					{
						now_x -= j;
					}
				}
			}
		}
		
		bool flag = false;	//宝石が一つでも残っていたらtrueになる
		for (int y=0; y<21; y++)
		{
			for (int x=0; x<21; x++)
			{
				if (grid[y][x] == '#')
				{
					flag = true;
				}
			}
		}
		if (flag)
		{
			cout << "No" << endl;
		} else {
			cout << "Yes" << endl;
		}
		/*
		//テスト出力
		for (int y=20; y>=0; y--)
		{
			for (int x=0; x<21; x++)
			{
				cout << grid[y][x];
			}
			cout << endl;
		}
		*/
	}
	
	return 0;
}

C++: #include <stdio.h>
#define N 20
int main(){
  int i,j,x,y,n,step,gems,xy[N+1][N+1],rx,ry,count;
  char dir;
  while(1){
    for(i=0;i<N+1;i++){
      for(j=0;j<N+1;j++){
	xy[i][j] = 0;
      }
    }
    rx = 10;
    ry = 10;
    count = 0;
    scanf("%d",&n);
    if( n==0 ) break;
    gems = n;
    for(i=0;i<n;i++){
      scanf("%d %d",&x,&y);
      xy[x][y] = 1;
    }

    scanf("%d",&n);
    for(j=0;j<n;j++){
      scanf(" %c %d",&dir,&step);
      if( dir == 'E'){
	for(i=rx;i<=rx+step;i++){
	  if( xy[i][ry] == 1 ){
	    count++;
	    xy[i][ry] = 0;
	  }
	}
	rx = i-1;
      }
      else if( dir == 'W'){
	for(i=rx;i>=rx-step;i--){
	  if( xy[i][ry] == 1 ){
	    count++;
	    xy[i][ry] = 0;
	  }
	}
	rx = i-1;
      }
      else if( dir == 'N' ){
	for(i=ry;i<=ry+step;i++){
	  if( xy[rx][i] == 1 ) {
	    count++;
	    xy[rx][i] = 0;
	  }
	}
	ry = i-1;
      }
      else{
	for(i=ry;i>=ry-step;i--){
	  if( xy[rx][i] == 1 ) {
	    count++;
	    xy[rx][i] = 0;
	  }
	}
	ry = i-1;
      }
    }
    if( count == gems ){
      printf("Yes\n");
    }
    else{
      printf("No\n");
    }
  }
  return 0;
}

C++: // AOJ 2000
#include<iostream>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

const int XMAX = 30, YMAX = 30, MMAX = 40;

bool field[XMAX][YMAX];
char dir[MMAX];
int dist[MMAX];
int N, M;

void init() {
  REP(x, XMAX) REP(y,YMAX) { field[x][y] = false; }
}

bool solve() {
  int items = 0;
  int x = 10, y = 10;
  REP(i, M) {
    REP(d, dist[i]) {
      x += (dir[i] == 'E' ? 1 : dir[i] == 'W' ? -1 : 0);
      y += (dir[i] == 'N' ? 1 : dir[i] == 'S' ? -1 : 0);

      if (field[x][y]) {
        field[x][y] = false;
        items++;
      }
    }
  }
  return items == N;
}

int main() {
  while (cin >> N and N) {
    init();
    REP(i, N) {
      int x, y;
      cin >> x >> y;
      field[x][y] = true;
    }

    cin >> M;
    REP(i, M) {
      cin >> dir[i] >> dist[i];
    }

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

C++: #include<iostream>
using namespace std;
struct point{int x,y;};
int main(){
	while(1){
		int n; cin >>n;
		if(n==0)break;
		point p[21];
		point now;
		now.x=10;
		now.y=10;
		int v[21]={};
		int cnt=0;
		for(int i=0;i<n;i++){
			int x,y;
			cin >> x >> y;
			p[i].x=x;
			p[i].y=y;
		}
		int m=0; cin >>m;
		for(int i=0;i<m;i++){
			char d; int l;
			cin >> d >>l;
			for(int j=0;j<l;j++){
				if(d=='N')now.y++;
				if(d=='E')now.x++;
				if(d=='S')now.y--;
				if(d=='W')now.x--;
				for(int k=0;k<n;k++){
					if(now.x==p[k].x&&now.y==p[k].y&&v[k]==0){
						cnt++;
						v[k]=1;
					}
				}
			}			
		}
		if(cnt==n)cout << "Yes"<<endl;
		else cout << "No"<< endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
using namespace std;

#define ll long long int
#define ld long long double
#define reps(i,f,n) for(int i=f;i<n;i++)
#define rep(i,n) reps(i,0,n)
#define m1 cout<<"move1"<<endl
#define m2 cout<<"move2"<<endl
#define m3 cout<<"move3"<<endl
#define m4 cout<<"move4"<<endl

int judge(int  v[][21]){
  //cout<<endl;         
  for(int i=20;i>=0;i--){
    rep(j,21){
      //cout<<v[i][j]<<" ";
      if(v[i][j] == 1)
	return 1;
    }
    //cout<<endl;
}
return 0;
}
  
  


int main(){
  ll N;
  ll M;
  char C;
  ll X,Y;
  ll length;
  int  v[21][21];
  ll x,y;

  while(cin>>N,N){
    x = 10; y = 10;
    rep(i,21)
      rep(j,21)
      v[i][j] = 0;
    rep(i,N){
      cin>>X>>Y;
      v[Y][X] = 1;
    }
    cin>>M;
    rep(j,M){
      cin>>C;
      //cout<<C<<endl;
      cin>>length;
      if(C == 'N'){
	reps(i,y+1,length + 1 + y){
	  v[i][x] = 2;
	}
	y +=length;
      }
      if( C== 'S'){
	for(int i = y-1; i >= y -length; i--){
	  v[i][x] = 2;
	}
	y -= length;
      }
      if(C == 'E'){
	reps(i,x+1,length+x+1){
	  v[y][i] = 2;
	}
	x += length;
      }
      if(C =='W'){
	for(int i = x-1; i >= x - length;i--){
	  v[y][i] = 2;
	}
	x -= length;
      }
    }
    if(judge(v))
      cout<<"NO"<<endl;
    else
      cout<<"YES"<<endl;

  }

  return 0;
}