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<bits/stdc++.h>
using namespace std;

int n, m;
vector<int> a;
vector<int> b;

int main(){
while(1){


    cin >> n >> m;
    if(n == 0 and m == 0) break;
    int asum = 0, bsum = 0;


    for(int i=0; i < n; i++){
        int tmp;
        cin >> tmp;
        asum += tmp;
        a.push_back(tmp);
    }

    for(int i=0; i < m; i++){
        int tmp;
        cin >> tmp;
        bsum += tmp;
        b.push_back(tmp);
    }
    int flag = 1;
    int ares = 10000000, bres = 1000000;
    for(int i=0; i < n; i++){
        for(int j=0; j < m; j++){
            if(asum - a[i] + b[j] == bsum - b[j] + a[i]){
                if(ares + bres > a[i] + b[j]){
                    ares = a[i];
                    bres = b[j];
                    flag = 0;
                }
            }
        }
    }
    
    if(flag) cout << -1 << endl;
    else cout << ares << " " << bres << endl;

    a.clear();
    b.clear();
}

    return 0;
}

C++: #include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
int X, Y;
void calc(vector<pair<int,int>> &v, char c, int d) {
  int x = X, y = Y;
  switch (c) {
    case 'N':
      Y += d;
      break;
    case 'W':
      X -= d;
      break;
    case 'S':
      Y -= d;
      break;
    case 'E':
      X += d;
      break;
  }
  for (int i = 0; i < v.size(); i++) {
    if ((x <= v[i].first && v[i].first <= X) || (X <= v[i].first && v[i].first <= x)) {
      if ((y <= v[i].second && v[i].second <= Y) || (Y <= v[i].second && v[i].second <= y)) {
        v.erase(v.begin() + i);
        i--;
      }
    } 
  }
}

signed main() {
  int N;
  while(cin >> N, N) {
    vector<pair<int,int>> gems(N);
    for (int i = 0; i < N; i++) {
      int x, y;
      cin >> x >> y;
      gems[i] = make_pair(x, y);
    }
    
    int M;
    cin >> M;
    Y = 10, X = 10;
    for (int i = 0; i < M; i++) {
      char c; int d;
      cin >> c >> d;
      calc(gems, c, d);
    }

    if (gems.size() == 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }  
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int i;
  while(1){

    int N;
    cin >> N;
    if(N == 0) break;

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

    int M;
    cin >> M;

    x=10;
    y=10;
    int cnt=0;
    string Direc;
    int Step;
    for(i=0; i<M; i++){
      cin >> Direc >> Step;
      if(Direc == "W"){
        REP(i, Step){
          x--;
          if(XY[x][y]==1){
            cnt++;
            XY[x][y]=0;
          }
        }
      }
      if(Direc == "E"){
        REP(i, Step){
          x++;
          if(XY[x][y]==1){
            cnt++;
            XY[x][y]=0;
          }
        }
      }
      if(Direc == "N"){
        REP(i, Step){
          y++;
          if(XY[x][y]==1){
            cnt++;
            XY[x][y]=0;
          }
        }
      }
      if(Direc == "S"){
        REP(i, Step){
          y--;
          if(XY[x][y]==1){
            cnt++;
            XY[x][y]=0;
          }
        }
      }
    }
    if(N == cnt) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
    return 0;
  }

C++: #include <iostream>

using namespace std;

const int MAX_N = 21;

bool gem[MAX_N][MAX_N];

int main() {
  int N;
  while (cin >> N) {
    if (N == 0) break;
    for (int i = 0; i <= N; i++) {
      for (int j = 0; j <= N; j++) {
        gem[i][j] = false;
      }
    }
    for (int i = 0; i < N; i++) {
      int x, y;
      cin >> x >> y;
      gem[x][y] = true;
    }
    int M;
    cin >> M;
    int pos_x = 10, pos_y = 10;
    int count = 0;
    for (int i = 0; i < M; i++) {
      char c;
      int d;
      cin >> c >> d;
      while (d--) {
        if (c == 'N') pos_y++;
        if (c == 'S') pos_y--;
        if (c == 'E') pos_x++;
        if (c == 'W') pos_x--;
        if (gem[pos_x][pos_y]) {
          gem[pos_x][pos_y] = false;
          count++;
        }
      }
    }
    if (count == N) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

void solve(int n){
    vector<vector<int>> cnt(21,vector<int>(21));
    rep(i,n){
        int x,y;
        cin>>x>>y;
        cnt[x][y]++;
    }
    int x=10,y=10;
    int ans=cnt[x][y];
    int m;
    cin>>m;
    int d[]{1,0,-1,0,1};
    rep(i,m){
        char c;cin>>c;
        int dir;
        if(c=='N')dir=3;
        if(c=='S')dir=1;
        if(c=='E')dir=0;
        if(c=='W')dir=2;
        int l;
        cin>>l;
        rep(j,l){
            x+=d[dir];
            y+=d[dir+1];
            ans+=cnt[x][y];
            cnt[x][y]=0;
        }
    }
    if(ans==n)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return;
}
int main(){
    int n;
    while(cin>>n,n!=0){
        solve(n);
    }
    return 0;
}