Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		L, _ := strconv.Atoi(scanner.Text())
		if L == 0 {
			break
		}
		for i := 0; i < 12; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			M, _ := strconv.Atoi(buf[0])
			N, _ := strconv.Atoi(buf[1])
			L -= (M-N)
			if L <= 0 {
				fmt.Println(i+1)
				continue
			}
		}
		fmt.Println("NA")
	}
}

C++: #include<cstdio>
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
#include<stack>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int main(void){
  ll L;
  while(cin>>L,L){
    bool ans = false;
    ll sum = 0 ;
    for(int i = 0 ; i < 12 ; i ++){
      ll M,N;
      cin>>M>>N;
      sum += M - N;
      if(sum >= L && !ans){
	ans = true;
	cout<<i+1<<endl;
      }
    }
    if(!ans)cout<<"NA"<<endl;
  }

}

C++: #include<stdio.h>
int main(void)
{
	int w,n,z,x,i,k,c;
	while(1){
		scanf("%d",&n);
		 if(n==0) break;
	c=0;
	k=0;	 
	for(i=0;i<12;i++){
			scanf("%d %d",&z,&x);
			k+=z-x;
			if(k>=n){
				c++
			}
	}
	if(k<n){
		printf("NA\n");
	}
	else{
		printf("%d\n",12-c+1);
	}
    }	
	return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	vector<int>l;
	long a, b, sum, need;
	while (cin >> need){
		sum = 0;
		if (need == 0){
			break;
		}
		bool b = false;
		for (int i = 0; i < 12; i++){
			cin >> a >> b;
			sum += a - b;
			if (sum >= need&&b == false) {
				b = true;
				l.push_back(i + 1);
			}
			if (i == 11 && sum < need){
				l.push_back(0);
			}
		}
	}
	for (int i = 0; i < l.size(); i++){
		if (l[i] == 0){
			cout << "NA";
		}
		else cout << l[i];
		cout << endl;
	}
}

C++: #include <cstdio>

using namespace std;

int main(void){
	int m, n, s, l, ans, i;
	while(1){
		scanf("%d",&l);
		if(l == 0){
			break;
		}
		s = ans = 0;
		for(i = 1;i <= 12;i++){
			scanf("%d%d",&m,&n);
			s += m - n;
			if(ans == 0 && s >= l){
				ans = i;
			}
		}
		if(ans != 0){
			printf("%d\n",ans);
		}else{
			printf("NA\n");
		}
	}
	return 0;
}

C++: #include <iostream>
#define MAX 100000000

using namespace std;

int main(void){

  int L;
  while( cin >> L , L ){

    int M,N;
    int ans = 0;
    for( int i = 1 ; i <= 12 ; i++ ){
      cin >> M >> N;
      L -= ( M - N );
      if( L <= 0 ){
	ans = i;
	L = MAX;
      }
    }
    if( ans ) cout << ans << endl;
    else cout << "NA" << endl;

  }
  return 0;
}

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

int main(){
	int n;
	while(cin >> n,n){
		int sum = 0,mon = -1;
		for(int i = 0;i < 12;i++){
			int a,b;
			cin >> a >> b;
			sum += a - b;
			if(n <= sum && mon == -1) mon = i;
		}
		if(mon == -1) cout << "NA" << endl;
		else cout << mon + 1 << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
	while(1) {

		bool isfirst = true;
		int M, N, L, S = 0;

		cin >> L;
		if( L == 0 )
			break;
		
		for( int i = 0; i < 12; i++ ) {

			cin >> M >> N;

			S += M - N;

			if( L <= S && isfirst ) {
				cout << i+1 << endl;
				isfirst = false;
			}
		}

		if( isfirst ) {
			cout << "NA" << endl;
		}
		
	NEXT:;	

	}

    return 0;
}

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

int main(void) {
	int n, m, l;
	int sum;
	while (cin >> l, l) {
		sum = 0;
		bool f = false;
		for (int i = 0; i < 12; i++) {
			cin >> n >> m;
			sum += n - m;
			if (sum >= l&&f==false) {
				cout << i + 1 << endl;
				f = true;
			}
		}
		if (f == false) cout << "NA" << endl;
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int hoge(int *L){ cin >> *L; return *L;}
int main(){
	int L=10,M,N;
	while(hoge(&L)){
		int j=1;
		for(int i=0;i<12;i++){
			cin >> M >> N;
			L -= M-N;
			if(L>0) j++;
		}
		if(L<0) cout <<  j << endl;
		else cout << "NA" << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int l,i;
	int m,n,sum,flg;
	while(1){
		cin>>l;
		sum=flg=0;
		if(l==0) break;
		for(i=1;i<=12;i++) {
			cin>>m>>n;
			sum+=m-n;
			if(sum>=l && flg==0) flg=i;
		}
		if(sum<l) cout<<"NA"<<endl;
		else if(flg!=0)cout<<flg<<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int l;
  while(cin >> l && l){
    int a=0;
    for(int i = 1; i <= 12; i++){
      int n,m;
      cin >> n >> m;
      if(!a) l -= n-m;
      if(!a && l <=0) a = i;
    }
    if(l > 0) cout << "NA" << endl;
    else cout << a << endl;
  }
}

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

int main(){
    int l, m[12], n[12], x, a;
    for(; scanf("%d", &l), l;){
        for(x = 0; x < 12; x++){
            scanf("%d%d", m+x, n+x);
        }
        a = 0;
        for(x = 0; x < 12; x++){
            a += m[x]-n[x];
            if( a >= l ) break;
        }
        if(x/12){
            puts("NA");
        }else{
            printf("%d\n", x+1);
        }
    }
    return 0;
}

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

int main(){
  int m,n,i,j,l,sum,month,flag=0;

  while(1){
    flag=0;
    sum=0;
    l=0;
    cin >> l;
    if(l == 0)break;
    for(i=1;i<=12;i++){
      cin >> m >> n;
      sum=sum+(m-n);
      if(sum>=l && flag==0){
	month=i;
	flag=1;
      }
    }
    // cout << "sum=" << sum << endl;
    //cout << "l=" << l << endl;

    if(sum>=l)cout << month << endl;
    else{cout<<"NA"<<endl; }


  }

}

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

int main(){
    int trip,sui,tou,total,flag;
    while(1){
        total = 0;
        flag = 0;
        cin >> trip;
        if(trip == 0){
            break;
        }
        for(int i=0;i<12;i++){
            cin >> sui >> tou;
            total += sui - tou;
            if(total >= trip){
                cout << i+1 << endl;
                flag = 1;
                break;
            }
        }
        if(flag == 0){
            cout << "No" << endl;
        }
    }
}

C++: #include <iostream>
using namespace std;
int hoge(int *L){ cin >> *L; return *L;}
int main(){
	int L,M,N;
	while(hoge(&L)){
		int j=0;
		for(int i=0;i<12;i++){
			if(L>0) j++;
			cin >> M >> N;
			L -= M-N;
		}
		if(L>0) cout << "NA" << endl;
		else cout <<  j << endl;
	}
	return 0;
}

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

int main()
{
	int l, m, n, mu, f;

	while (cin >> l, l){
	mu = f = 0;
		for (int i = 0; i < 12; i++){
			cin >> m >> n;
			l -= (m - n);
			if (l <= 0 && f == 0){
				mu = i + 1;
				f = 1;
			}	
		}
		if (mu != 0) cout << mu << endl;
		else cout << "NA" << endl;
	}
	return (0);
}

C++: #include <stdio.h>

#define MONTHS 12

int main(void){
	int l;
	int m, n, ok;
	
	while (scanf("%d", &l), l){
		ok = -1;
		for (int i=1; i<=MONTHS; i++){
			scanf("%d%d",&m,&n);
			l -= (m-n);
			if (ok<0 && l<=0) ok = i;
		}
		if (ok==-1) puts("NA");
		else printf("%d\n", ok);
	}
	return 0;
}

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

int main(){
	long long int l, m, n;
	long long int savingMoney;
	bool output = true;

	while(cin >> l, l){
		savingMoney = 0;
		output = true;
		for(int i=1; i <= 12; i++){
			cin >> m >> n;
			savingMoney += m - n;

			if(l <= savingMoney && output){
				cout << i << endl;
				output = false;
			}
			if(i == 12 && savingMoney < l){
				cout << "NA" << endl;
			}
		}

	}
}