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++: #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int l;
	while (cin >> l && l) {
		VI m(12), n(12); rep(i, 12)cin >> m[i] >> n[i];

		int sum = 0, ans = -1;
		rep(i, 12) {
			sum += m[i] - n[i];
			if (sum >= l && ans == -1)ans = i + 1;
		}
		if (ans == -1)puts("NA");
		else cout << ans << endl;
	}
}

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

int main(){
  int L;

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

    for(int y = 1; y <= 12; y++){
      cin >> N >> M;
      sum += N - M;

      if(ans != -1){
        continue;
      }
      if(sum >= L){
        ans = y;
      }
    }

    if(ans == -1){
      cout << "NA\n";
    }
    else{
      cout << ans << endl;
    }
  }
}

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

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

C++: #include<stdio.h>

int main ()
{
int M,N,R,w,m;
w=0;m=0;
while(1)
{
w=0;m=0;
scanf("%d",&R);
if(R==0)break;
for(int i=0;i<12;i++){
scanf("%d %d",&M,&N);
w=w+(M-N);m++;
if(w>=R)break;
}
if(w>=R)printf("%d\n",m);
else printf("NA\n");
}
return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<char, int>P;

int main(){
	int l;
	while (cin >> l, l) {
		int cnt = 0;
		int ans = -1;
		rep(i, 12) {
			int m, n; cin >> m >> n;
			cnt += m - n;
			if (!~ans&&l <= cnt)ans = i + 1;
		}
		printf(~ans ? "%d\n" : "NA\n", ans);
	}
	return 0;
}

C++: #include <stdio.h>

int main(){
	while(1){
		int n;
		scanf("%d", &n);
		if(n==0) break;
		
		int v = 0;
		int t,u;
		int flag = 1;
		for(int i=0;i<12;i++){
			scanf("%d%d", &t, &u);
			v += (t-u);
			//printf("%d - %d = %d \n", t,u,v);
			if(v>=n&&flag){
				printf("%d\n", i+1);
				flag = 0;
			}
		}
		if(flag) puts("NA");
	}
}

C++: #include	<iostream>

using namespace std;

int main(void) {
	while(1) {
		int L, mt = 0;
		int gL = 0;
		
		cin >> L;
		if( L == 0 )	break;
		
		for(int i = 0; i < 12; i++) {
			int n, m;
			cin >> n >> m;
			gL += n - m;
			if(gL >= L && mt == 0) {
				mt = i + 1;
			}
		}
		
		if(mt == 0) {
			cout << "NA" << endl;
		} else {
			cout << mt << endl;
		}
	}
}

C++: #include <cstdio>

int main(void) {
	while(true) {
		int n;
		scanf("%d", &n);
		if(n == 0)
			break;

		int ans = 0;
		for(int i = 1; i <= 12; i++) {
			int p, q;
			scanf("%d %d", &p, &q);
			n -= p - q;
			if(ans == 0 && n < 0)
				ans = i;
		}
		if(ans != 0)
			printf("%d\n", ans);
		else
			printf("NA\n");
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
 
int main() {
	while(1){
		int l;
		cin>>l;
		if(l==0){break;}
		int a=0;
		int i =1;
		int ans=1;
		while(i<=12){
			int p,o;
			cin>>p>>o;
			a=a+p-o;
			if(a<l){ans++;}
			i++;
		}
		if(a>=l){cout<<ans<<endl;}
		else{cout<<"NA"<<endl;}
	}
	return 0;
}

C++: #include<stdio.h>
int main(void){
	while(1){
		int l,m,n,r=0,cnt=0;
		scanf("%d",&l);
		if(l==0)return 0;
		int i;
		for(i=0;i<12;i++){
			scanf("%d%d",&m,&n);
			r+=(m-n);
		
			if(r>=l)cnt=i+1;
		}
		if(cnt!=0)printf("%d\n",cnt);
		else printf("NA\n");
	}
	
	
}

C++: #include <cstdio>

int main() {
	int L, M, N;
	while (scanf("%d", &L)) {
		if (L == 0) break;
		int res = 0;
		bool flag = true;
		for (int i=0; i<12; i++) {
			scanf("%d%d", &M, &N);
			L -= (M - N);
			if (flag) {
				res++;
			}
			if (L <= 0) flag = false;
		}
		if (res == 12 && L > 0) {
			printf("NA\n");
		} else {
			printf("%d\n", res);
		}
	}
}

C++: #include <stdio.h>
int main(){
    int n,l,r,tot;
    while(1){
        scanf("%d",&n);
        if(n==0)return 0;
        tot=0;
        for(int i=0;i<12;i++){
            scanf("%d%d",&l,&r);
            tot+=l-r;
        }
        if(n>tot)printf("NA\n");
        else printf("%d\n",tot/n);
    }
}

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

using namespace std;

int main()
{   
    int TripCost;
    while (cin >> TripCost) {
        if (TripCost == 0) break;
        
        int TripSum = 0;
        pair<bool, int> DataBase(false, 0);
        bool is_judge = true;
         
        
        for (int i = 0; i < 12; ++i) {
            int data1, data2;

            cin >> data1 >> data2;
            
            TripSum += data1 - data2;

            
            
            if (TripSum >= TripCost && is_judge) {
                DataBase.first = true;
                DataBase.second = i + 1;
                is_judge = false;
            } 
        }
        
        if (DataBase.first) {
            cout << DataBase.second << endl;
        } else {
            cout << "NA" << endl;}
    }
    
    return 0;
}

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

int main(){
	int shotoku[12];
	int l,m,n;
	int i,total;
	while(cin>>l,l){
		for(i=0;i<12;i++){
			cin>>m>>n;
			shotoku[i]=m-n;
		}
		total=0;
		for(i=0;i<12;i++){
			total+=shotoku[i];
			if(l<=total){
				cout<<i+1;
				break;
			}
		}
		if(i==12) cout<<"NA";
		cout<<endl;
	}
	return 0;
}

C++: #include <cstdio>

using namespace std;

int main()
{
	int plan;
	
	while (scanf("%d", &plan) && plan){
		int rec = 0;
		bool flag = false;
		
		for (int i = 0; i < 12; i++){
			int n, m;
			scanf("%d %d",&m, &n);
			rec += (m - n);
			if (flag == false && rec >= plan){
				printf("%d\n", i + 1);
				flag = true;
			}
		}
		
		if (flag == false){
			printf("NA\n");
		}
	}
	
	return (0);
}

C++:  #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int travel;
   while(cin>>travel&&travel)
   {
     int sum=0;
     int sign;
     bool flag=false;
     for(int i=0;i<12;i++)
     {
       int a,b;
       cin>>a>>b;
       sum+=(a-b);
       if((sum>=travel)&&(!flag)) 
       {
         flag=true;
         sign=i+1;          
       }        
     }            
     if(flag) cout<<sign<<endl;
     else cout<<"NA"<<endl;                
   }
   //while(1);
   return 0;
 }