Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}

		sales := make([]int, 4000)
		members := make([]int, 0)
		memberCheck := make(map[int]bool)

		for i := 0; i < n; i++ {
			scanner.Scan()
			input := strings.Split(scanner.Text(), " ")
			e, _ := strconv.Atoi(input[0])
			p, _ := strconv.Atoi(input[1])
			q, _ := strconv.Atoi(input[2])

			if e >= 1 && e <= 4000 && memberCheck[e] == false {
				members = append(members, e)
				memberCheck[e] = true
			}
			sales[e-1] += p * q
		}

		emptyFlag := true
		for _, v := range members {
			if sales[v-1] >= 1000000 {
				fmt.Println(v)
				emptyFlag = false
			}
		}

		if emptyFlag == true {
			fmt.Println("NA")
		}
	}
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n;
	int number[4000]={0};
	int tanka;
	int ryou;
	long long goukei[4000]={0};
	while(cin>>n&&n){
		for(int i=0;i<n;i++){
			cin>>number[i];
			cin>>tanka;
			cin>>ryou;
			goukei[i]=tanka*ryou;
		}
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				if(number[i]==number[j]){
					goukei[i]+=goukei[j];
					if(goukei[i]>=1000000)goukei[i]=1000000;
					goukei[j]=0;
					}
			}
		}
		int flag=-1;
		for(int i=0;i<n;i++){
			if(goukei[i]>=1000000){
				flag=0;
				cout<<number[i]<<endl;
				}
		}
		if(flag==-1)
			cout<<"NA"<<endl;
	}
	return 0;
}

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

int main(){
	int n,a,b,c,flag;
	map<int, int> m;
	while (cin >> n, n){
		m.clear();
		flag = 0;
		for (int i = 0; i < n; i++){
			cin >> a >> b >> c;
			m[a] += b * c;
		}
		map<int, int>::iterator it = m.begin();
		while (it != m.end()){
			if ((*it).second >= 1000000){
				flag = 1;
				cout << (*it).first << endl;
			}
			it++;
		}
		if (!flag) cout << "NA" << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n;
	int number[4000]={0};
	int tanka;
	int ryou;
	long long goukei[4000]={0};
	while(cin>>n,n){
		for(int i=0;i<n;i++){
			cin>>number[i];
			cin>>tanka;
			cin>>ryou;
			goukei[i]=tanka*ryou;
		}
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				if(number[i]==number[j]){
					goukei[i]+=goukei[j];
					if(goukei[i]>=1000000)goukei[i]=1000000;
					goukei[j]=0;
					}
			}
		}
		int flag=-1;
		for(int i=0;i<n;i++){
			if(goukei[i]>=1000000){
				flag=0;
				cout<<number[i]<<endl;
				}
		}
		if(flag==-1)
			cout<<"NA"<<endl;
	}
	return 0;
}

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

using namespace std;

int main(void){
    int i,j,k,l;
    int n;
    long long id,cost,qty;
    long long data_list[10000];
    int id_list[10000];
    bool id_flag;
    bool na_flag;
    
    while(cin>>n,n!=0){
        fill(data_list,data_list+10000,0);
        k=0;
        for(l=0;l<n;l++){
            data_list[id]+=(cost*qty);
            cin>>id>>cost>>qty;
            id_flag=true;
            for(i=0;i<=k+1;i++){
                if(id_list[i]==id){
                    id_flag=false;
                }
            }
            if(id_flag){
                id_list[k]=id;
                k++;
            }
        }
        na_flag=true;
        for(l=0;l<k;l++){
            if(data_list[id_list[l]]>=1000000){
                cout<<id_list[l]<<endl;
                na_flag=false;
            }
        }
        if(na_flag){
            cout<<"NA"<<endl;
        }
    }
    return(0);
}

C++: #include <stdio.h>
#include <stdlib.h>

int main(void){
  int i, j, c, num, data;
  int staff[4000], n, value;
  int state[4000], state_n;
  char buf[10];

  while(1){
    num = j = 0;
    while((c = getchar()) != '\n'){
      buf[j++] = c;
      if(j == 1 && c == '0') break;
    }
    buf[j] = '\0';
    num = atoi(buf);
    if(num == 0) break;

    for(i = 0; i < 4000; i++){
      staff[i] = 0;
      state[i] = 0;
    }
    state_n = 0;

    for(i = 0; i < num; i++){
      data = j = 0;
      while((c = getchar()) != '\n'){
        buf[j] = c;
        if(c == ' ' && data == 0){
          buf[j] = '\0';
          n = atoi(buf);
          j = 0;
          data++;
          continue;
        }
        if(c == ' ' && data == 1){
          buf[j] = '\0';
          value = atoi(buf);
          j = 0;
          data++;
          continue;
        }
        j++;
      }
      buf[j] = '\0';
      staff[n-1] += atoi(buf) * value;
      if(staff[n-1] >= 1000000 && state[n-1] == 0){
        state[n-1] = ++state_n;
      }
    }

    if(state_n == 0){
      printf("NA\n");
    }
    for(j = 1; j <= state_n; j++){
      for(i = 0; i < 4000; i++){
        if(state[i] == j){
          printf("%d\n", i+1);
        }
      }
    }
  }
  return 0;
}

C++: /*
	AOJ_0100: Sale Result
*/
#include	<iostream>
#include	<vector>
#include	<utility>

using namespace std;

typedef unsigned long long ull;

class employee {
private:
	int number;
	ull proceed;
public:
	employee() {
		number = 1;
		proceed = 0;
	}
	employee(int _n, ull _p) {
		number = _n;
		proceed = _p;
	}
	void addProceed(ull in_prcd) {
		if (proceed < 1000000) { proceed += in_prcd; }
	}
	bool isSatisfy(void) {
		return (proceed >= 1000000 ? true : false);
	}
	int showNumber(void) {
		return number;
	}
};

int main(void) {
	vector<employee> Emps;
	int n, member, price, count;
	ull buf_prcd;
	bool isNothing, isNotHit;

	while (1) {
		isNothing = true;

		cin >> n;
		if (n == 0) { break; }
		for (int i = 0; i < n; i++) {
			cin >> member >> price >> count;
			buf_prcd = price * count;
			isNotHit = true;

			vector<employee>::iterator it = Emps.begin();
			while (it != Emps.end()) {
				if (it->showNumber() == member) {
					isNotHit = false;
					it->addProceed(buf_prcd);
					break;
				}
				it++;
			}
			if (isNotHit) {
				Emps.push_back( employee(member, buf_prcd) );
			}
		}

		isNotHit = true;
		vector<employee>::iterator it = Emps.begin();
		while (it != Emps.end()) {
			if (it->isSatisfy() == true) {
				isNotHit = false;
				cout << it->showNumber() << endl;
			}
			it++;
		}
		if (isNotHit) {
			cout << "NA" << endl;
		}
		Emps.clear();
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(s) (s).begin(),(s).end()

#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(a,b) make_pair((a),(b))

#define INF 999999
#define MAX_V 999

using namespace std;

int main(){
	int n, id, val, num;
	vector<int> ans;
	vector<int> com(4000);
	while(cin>>n,n){
		ans.clear();
		rep(i,4000)	com[i]=0;
		rep(i,n){
			cin>>id>>val>>num;
			if(!com[id-1])	ans.push_back(id);
			com[id-1]+=val*num;
		}
		bool flag=true;
		rep(i,ans.size()){
			if(com[ans[i]-1]>=1000000){
				cout<<ans[i]<<endl;
				flag=false;
			}
		}
		if(flag){
			cout<<"NA"<<endl;
		}
	}
	
	return 0;
	
}

C++: #include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main() {
	int n,id,i,k,f,a,b,da[4001],jun[4001],ch[4001];
	while (cin >> n) {
		if (n==0) break;
		memset(da,0,sizeof(da));
		memset(ch,0,sizeof(ch));
		k=0;
		for (i=0;i<n;i++) {
			cin >> id >> a >> b;
			da[id]+=a*b;
			if (ch[id]==0 && da[id]>999999) { ch[id]=1; jun[k++]=id;} 
			}
		f=0;
		for (i=0;i<k;i++) if (da[jun[i]]>=1000000) { cout << jun[i] << endl; f=1; }
		if (f==0) cout << "NA" << endl;
	}
	return 0;
}