Go: package main

import "fmt"

func main() {
	var n, r int
	fmt.Scan(&n, &r)
	for n != 0 || r != 0 {
		arr := make([]int, n)
		for i := range arr {
			arr[i] = len(arr) - i
		}

		for i := 0; i < r; i++ {
			var p, c int
			fmt.Scan(&p, &c)
			mid, top, last := arr[:p-1], arr[p-1:p-1+c], arr[p-1+c:]
			arr = append(append(append([]int{}, top...), mid...), last...)
		}
		fmt.Println(arr[0])
		fmt.Scan(&n, &r)
	}
}

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

using namespace std;

void cut(int *a, int p, int c)
{
    for(int i=0; i<c; i++)
    {
        int t = a[p+i];
        for(int j=p+i; j>i; j--)
        {
            a[j] = a[j-1];
        }
        a[i] = t;
    }
}

int main()
{
    int n, r;
    while(cin >> n >> r, n|r)
    {
        int a[n];
        for(int i=0; i<n; i++) a[i] = n - i;
        while(r--)
        {
            int p, c;
            cin >> p >> c;
            cut(a, p-1, c);
        }
        cout << a[0] << endl;
    }
}

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

int main(){
	while(1){
		int n,r,p,c,s[n + 1];
		cin >> n >> r;
		if(n == 0 && r ==0)break;
		for(int i = 1; i <= n;++i){
			s[i] = i;
			}
			for(int j = 1; j <= r;++j){
				cin >> p >> c;
			    for(int k = 1;k <=c;++k){
			    		s[0] = s[n - p - c + 2];
				    for(int l = 0;l <= p + c - 3;++l){
					    s[n - p - c + 2 + l] = s[n - p - c + 3 + l];
					}
					s[n] = s[0];
			    }
		     }
		  cout << s[n] << endl;
	}
	return 0;
}

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

using namespace std;
int n, r, p, c;

int main(){
	while (cin >> n >> r && n){
		int a[n];
		for (int i = 0; i < r; i++){
			a[n-i-1] = i + 1;
		}
		for (int j = 0; j < r; j++){
			rotate(a, a + p-1, a + p + c-1);
		}
		cout << a[0] << endl;
	}
	return 0;
}

C++: #include <cstdio>

using namespace std;

void cut(int a[], int p, int c)
{
    int b[50];

    for (int i = 0; i < c; ++i)
        b[i] = a[p - 1 + i];
    for (int i = 0; i < p - 1; ++i)
        a[p - 1 + c - 1 - i] = a[p - 1 - 1 - i];
    for (int i = 0; i < c; ++i)
        a[i] = b[i];
}

int main()
{
    for (;;) {
        int n, r, a[50];

        scanf("%d %d", &n, &r);
        if (n == 0 && r == 0)
            break;

        for (int i = 0; i < n; ++i)
            a[i] = n - i;

        for (int i = 0; i < r; ++i) {
            int p, c;

            scanf("%d %d", &p, &c);
            cut(a, p, c);
        }

        printf("%d\n", a[0]);
    }

    return 0;
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
typedef complex<int> P;
typedef pair<int,int> pii;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
template <class F, class T> void convert(const F &f, T &t){	stringstream ss; ss << f; ss >> t;}


bool solve(){
	int n, r;
	cin>> n>> r;
	if(n==0 && r==0) return false;
	
	int crr = 0, nex = 1;
	vector<vector<int> > a(2, vector<int>(n));
	for(int i=0;i<n;i++) a[crr][i] = n-i;
	
	for(int i=0;i<r;i++){
		int p, c;
		cin>> p>> c;
		for(int j=0;j<n;j++){
			if(j < c){
				a[nex][j] = a[crr][j+p-1];
			}else if(j < c + p - 1){
				a[nex][j] = a[crr][j-c];
			}else{
				a[nex][j] = a[crr][j];
			}
		}
		swap(crr, nex);
		for(int k=0;k<n;k++) cout<< a[crr][k]<<" "; cout<< endl;
	}
	
	cout<< a[crr][0]<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed); cout.precision(10);
	while(solve());
	return 0;
}

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

//?±±?????????????????¢??°???????±±???????±±????????°n???p?????????????????????c???                       
void shuffle(vector<int> &yama, int n, int p, int c);


int main(){
  int n, r;
  int p, c;
  vector<int> yama, v;

  cin >> n;
  cin >> r;

  while(n != 0 && r != 0){
    //?±±??????????????????                                                            
    for(int i = 0, j = n; i < n; i++, j--){
      yama.push_back(j);
    }    //?????£?????????                                                                
    for (int i = 0; i < r; i++){
      cin >> p;
      cin >> c;
      shuffle(yama, n, p, c);
    }
    //???????????????????¨????                                                          
    v.push_back(yama.front());

    cin >> n;
    cin >> r;
  }
  for(int i = 0; i < v.size(); i++){
    cout << v[i] << endl;
  }
  cout << endl;
}

void shuffle(vector<int> &yama, int n, int p, int c){
  int tmp;

  for(int i = 0;i < c; i++){
    tmp = yama[p-1+c-1];
    yama.erase(yama.begin()+p-1+c-1);
    yama.insert(yama.begin(), tmp);
  }
}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
int main(){
 int i,r,n,p,c;
 for(;scanf("%d%d",&n,&r),n;){
  std::vector<int> v;
  for(i=n;i;i--)v.push_back(i);
  for(i=0;i<r;i++)scanf("%d%d",&p,&c),p--,std::rotate(v.begin(),v.begin()+p,v.begin()+p+c);
  printf("%d\n",v[0]);
 }
}

C++: #include <stdio.h>

int main(){

  int n,r,p,c,i,j;
  int score[51];
  int temp[51];

  for(;;){

    scanf("%d%d",&n,&r);
    if(n==0&&r==0){
      break;
    }

    for(i=1;i<=n;i++){
      score[i]=i;
      temp[i]=i;
    }

    for(i=1;i<=r;i++){
      scanf("%d%d",&p,&c);

      for(j=n-p+1;j>n-p+1-c;j--){
	score[j+p-1]=score[j];
      }
      for(j=n;j>n-p+1;j--){
	score[j-c]=temp[j];
      }

    }

    printf("%d\n",score[n]);
  }
  return 0;

}

C++: #include<iostream>
#include<vector>
#include<list>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
int main() {
	int n, r;
	while (cin >> n >> r&&n != 0 && r != 0) {
		list<int>a[2];
		for (int i = n; i >= 1; i--) {
			a[0].push_back(i);
		}
		int p, c;
		list<int>::iterator it = a[0].begin(),it2;
		for (int z = 0; z < r; z++) {
			cin >> p >> c;
			it = a[0].begin();
			a[1].clear();
			for (int i = 1; i < p; i++) it++;
			for (int i = 0; i < c; i++) {
				a[1].push_back(*it);
				it2 = it;
				it2++;
				a[0].erase(it);
				it = it2;
			}
			a[0].insert(a[0].begin(), a[1].begin(), a[1].end());
		}
		it = a[0].begin();
		cout << (*it) << endl;
	}
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n,r;
	while(cin>>n>>r,n) 
	{
		int deck[n];
		for(int i = 0; i < n; ++i)
		{
			deck[i]=n-i;
		}
		for(int i = 0; i < r; ++i)
		{
			int p,c; cin>>p>>c;
			int tmp[n],now=0;
			for(int j = p-1; j < p-1+c; ++j)
			{
				tmp[now++]=deck[j];	
			}
			for(int j = 0; j < p-1; ++j)
			{
				tmp[now++]=deck[j];	
			}
			for(int j = p-1+c; j < n; ++j)
			{
				tmp[now++]=deck[j];
			}
			for(int i = 0; i < n; ++i)
			{
				deck[i]=tmp[i];
				//cout<<deck[i];
			}
			//cout<<endl;
		}
		cout<<deck[0]<<endl;
	}
  return 0;
}

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

using namespace std;

int main()
{
	int n,r;
	int yama[51];
	int stook[51];

	while(1){
		cin>>n>>r;
		if(n==0&&r==0)
			break;
		int p,c;
		
			for(int i=1;i<=n;i++)
				yama[i]=i;
			
		for(int t=0;t<r;t++){
			cin>>p>>c;
			for(int i=1;i<=p-1;i++)
				stook[i]=yama[n-i+1];
	
			for(int i=1;i<=c;i++)
				yama[n-i+1]=yama[n-p+2-i];

			for(int i=1;i<=p-1;i++)
				yama[n-c-i+1]=stook[i];
		}

			cout<<yama[n]<<endl;
	}
	
	return 0;
}