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)
				break
			}
		}
		fmt.Println("NA")
	}
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,j,sum,m,n,nn,x;
	while(1) {
		scanf("%d",&nn);
		if(nn==0) break;
		sum=0;
		x=1;
		for(i=1;i<=12;i++) {
			scanf("%d %d",&m,&n);
			sum+=m-n;
			if(sum<nn) x++;	
		}
		if(sum>=nn) printf("%d\n",x);
		if(sum<nn) printf("NA\n");
	}
	return 0;
}

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

C++: #include <iostream>

using namespace std;

int main(){
  int n;
  while(true){
    cin >> n;
    if(n==0)
      break;
    int tsk = 0, ss=0;
    bool dd = true;
    for(int i=0; i<12; i++){
      int a, b;
      cin >> a >> b;
      tsk += (a-b);
      if(tsk >= n && dd){
	ss = i+1; dd = false;
      }
    }
    if(ss == 0)
      cout << "NA\n";
    else
      cout << ss << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstdlib>
using namespace std;

int main(){
	int l;
	while(scanf("%d",&l)==1,l){
		int m,n,sum=0,month=-1;
		for(int x=0;x<12;++x){
			scanf("%d %d",&m,&n);
			sum += m-n;
			if(sum>=l && month==-1)month=x+1;
		}
		if(month==-1)cout<<"NA"<<endl;
		else cout<<month<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int L;

    while (cin >> L, L) {
        int M, N;
        int ans = 0;

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

    return 0;
}

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

int main(){
	unsigned long l,m,n;
	unsigned long sum,month;
	bool flag = false;
	
	while(cin >> l,l){
		flag = false;
		month = 0;
		sum = 0;
		for(int i=0;i<12;i++){
			cin >> m >> n;
			sum += (m-n);
			if(sum >= l && flag == false){
				month = i + 1;
				flag = true;
			}
		}
		
		if(!month)	cout << "NA" << endl;
		else	cout << month << endl;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;
int main(void){

	int L,M,N,wa=0,mo=-1;

	cin>>L;
	for(int i=1;i<=12;i++){
		cin>>M>>N;
		wa+=M-N;
		if(wa>=L&&mo==-1) mo=i;
	}
	if(mo!=-1) cout<<mo<<endl;
	else cout<<"NA"<<endl;
	return 0;
}

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

int l;
typedef pair<int,int> pii;
vector<pii> data;
void init(){
  data.clear();
}


bool input(){
  if(!(cin>>l))return false;
  if(l==0)return false;
  for(int i=0;i<12;i++){
    int m,n;
    cin>>m>>n;
    data.push_back(pii(m,n));
  }
  return true;
}

int  solve(){
  int m=0;
  for(int i=0;i<data.size();i++){
    m+=max(0,data[i].first-data[i].second);
    if(!(m<l)){
      return i+1;
    }
  }
  return -1;
}

int main(){
  while(init(),input()){
    int ans= solve();
    if(ans==-1){
      cout<<"NA"<<endl;
    }else{
      cout<<ans<<endl;
    }
  }
}

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

int main()
{
	int L,M,N;
	while(scanf("%d", &L), L)
	{
		bool end=false;
		int tot=0;
		for(int i=0; i<12; i++)
		{
			scanf("%d%d", &M,&N);
			if(tot>=L) continue;
			
			tot+=M-N;
			if(tot>=L) printf("%d\n", i+1);
		}
		
		if(tot<L) puts("NA");
	}
}

C++: #include <cstdio>
#include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <string> 
#include <sstream>  
#include <vector> 
#include <time.h>
#include <algorithm>
using namespace std;

int main(){
    int P;
    while(cin >> P){
        if(P == 0)break;
        int Money  = 0,answer = 0;
        int M,N;
        for(int i = 1;12 >= i;i++){cin >> M >> N;Money += M - N;if(Money >= P and answer == 0){answer = i;}}
        if(answer == 0){
            cout << "NA" << endl;
        }else{
            cout << answer << endl;
        }
    }
}

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

int main(){
  int L,M,N;

  while(cin >> L){
    if(L==0) break;
    int count=0, money=0;
    bool flag = false;
    while(1){
      cin >> M >> N;
      count++;
      if(count > 12){
	if(flag == false) cout << "NA" << endl;
	break;
      }
      if(flag == true) continue;
      money += M - N;
      if(L <= money){
	cout << count << endl;
	flag = true;
	continue;
      }
    }    
  }
  return 0;
}

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

int main() {
	int L;
	int i,kozu[12],use[12],sum=0,fl=0,mon;
	while(1){
		cin >> L;
		if(L==0) break;
		for(i=0;i<12;i++){
			cin >> kozu[i] >> use[i];
			sum+=kozu[i]-use[i];
			if(sum>L && fl==0){
				mon=i+1;
				fl=1;
			}
		}
		if(fl==1){
			cout << mon << endl;
		}else{
			cout << "NA" << endl;
		}
		sum=0;
		fl=0;
	}
	return 0;
}

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

int main() {
    int L;
    while (cin >> L, L) {
        vector<int> M(12), N(12);
        for (int i=0; i<12; ++i) {
            cin >> M[i] >> N[i];
        }
        int month = -1, sum = 0;
        for (int i=0; i<12; ++i) {
            sum = sum + M[i] - N[i];
            if (L <= sum) {
                month = i+1;
                break;
            }
        }
        if (month < 0) {
            cout << "NA" << endl;
        } else {
            cout << month << endl;
        }
    }
    return 0;
}

C++: 



#include<iostream>

using namespace std;


int main(void)
{
	int M = 0;
	int N = 0;
	int L = 0;
	
	while (true)
	{
		int ans = 0;

		cin >> L;
		if (L == 0)	{	return 0; }


		int i = 0;

		for (i = 0; i < 12; i++)
		{
			if (L < 0)
			{
				;
			}
			else
			{
				ans++;
			}
	
			cin >> M >> N;
			L = L + N - M;
		}

		if (L > 0)
		{
			cout << "NA" << endl;
			continue;
		}

		cout << ans << endl;
	}

	return 0;
}

C++: #include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;


int main(){

	int L,M,N,sum,ans;
	bool FLG;

	while(true){
		scanf("%d",&L);
		if(L == 0)break;

		sum = 0;
		FLG = false;

		for(int i = 0; i < 12; i++){
			scanf("%d %d",&M,&N);

			if(!FLG){
				sum += M-N;

				if(sum >= L){
					ans = i+1;
					FLG = true;
				}
			}
		}

		if(!FLG)printf("NA\n");
		else{
			printf("%d\n",ans);
		}

	}

    return 0;
}

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

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