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>
#include <map>

using namespace std;


int main() {
	int n;
	int name, price, number;
	map<int, int> m_Employee;

	while (cin >> n) {
		if (n == 0)	break;

		for (int i = 0; i < n; i++) {
			cin >> name >> price >> number;

			if (m_Employee.count(name)) {
				m_Employee[name] += price * number;
			}
			else {
				m_Employee.insert(map<int, int>::value_type(name, price*number));
			}
		}

		map<int, int>::iterator it = m_Employee.begin();
		bool flag = false;
		while (it != m_Employee.end()) {
			if ((*it).second >= 1000000) {
				flag = true;
				cout << (*it).first << endl;
			}

			it++;
		}

		if (!flag) {
			cout << "NA" << endl;
		}

		m_Employee.clear();
	}

	return 0;
}

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

int main() {
	while(1){
long long s[4000];int i;int w;int j;
w=0;
for(int y = 0;y<4000;y++){
	s[y]= 0;
}
cin>>i;
if(i==0){break;}
for(int y = 1;y<=i;y++){
	int a,b,c;
	cin>>a>>b>>c;
	if(b!=0){
	int g = 1000000 - s[a-1];
	if(g%b==0){j = g/b;}
	else{j = (g/b)+1;}
	if(j<c){s[a-1]=1000001;}
	else{s[a-1]=s[a-1]+b*c;}
	}
}
for(int y = 0;y<4000;y++){
	if(s[y]>=1000000){
		cout << y+1<<endl;
		w=1;
		}
}
if(w==0){cout << "NA" << endl;}
}
	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,j,n;
	int ban,tan,buy,flg,ff[4001];
	long long int sum[4001];
	while(1) {
		scanf("%d",&n);
		if(n==0) break;
		flg=0;
		for(i=0;i<4000;i++) {
			ff[i]=0;
			sum[i]=0;
		}
		for(i=0;i<n;i++) {
			scanf("%d %d %d",&ban,&tan,&buy);
			sum[ban]+=(long long)tan*buy;
			if(sum[ban]>=1000000) {
				flg=1;	
				if(ff[ban]==0) {
					ff[ban]=1;
					printf("%d\n",ban);
				}
			}
		}
		if(flg==0) printf("NA\n");
	}
	return 0;
}

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

#define REP(i,n) for(i=0; i < (n); i++)
#define REPONE(i, n) for(i=1; i <= (n); i++)
#define LOOP(n) for(int loopCount=1; loopCount <= (n); loopCount++)
#define ITER(c) __typeof((c).begin())
#define EACH(c,it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define SZ(c) ((int) (c).size())
#define ALL(c) c.begin(), c.end()
#define SUM(c) accumulate(ALL(c), 0)
#define EXIST(c,v) (find(ALL(c), (v)) != (c).end())
#define PB push_back
#define MP make_pair

using namespace std;
static const double EPS = 1e-9;
static const double PI = 3.141592653589793238462643383279;
typedef long long ll;

int main(){
    int n;
    while(cin>>n){
        if(n==0) break;
        vector<int> ord;
        map<int, ll> total;
        int m, x, y;
        LOOP(n){
            cin >> m >> x >> y;
            if(!EXIST(ord, m)) ord.PB(m);
            total[m] += (ll)x*y;
        }
        bool f=true;
        EACH(ord, it)if(total[*it]>=1000000){
            f = false;
            cout << *it << endl;
        }
        if(f)cout << "NA" << endl;
    }
    return 0;
}

C++: #include <iostream>

#define FOR(i,a,b) for(int i=(a); i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;

int main(){
  int n;//入力するデータ
  int check;
  while(cin >> n){
    if(n==0) break;
    check=0;
    ll num[4001]={0};//社員番号
    ll emp,cost,count;
    REP(i,n){
      cin >> emp >> cost >> count;
      num[emp] += cost * count;
    }
    REP(i,4001){
      if(num[i]>= 1000000){
        cout << i << endl;
        check++;
  }
    }
    if(check==0)
      cout << "NA" << endl;
  }
}

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

using namespace std;

typedef long long ll;

int n, id, p, q;

const ll MAX = 1000000;

struct Mem {
    int id;
    ll c;
};

Mem array[40010];

int main(void) {
    while(cin >> n && n) {
        bool hap = false;
        for(int i = 0; i < n; i++) {
            cin >> array[i].id >> p >> q;
            array[i].c = p * q;
        }
        for(int i = 0; i < n - 1; i++) {
            for(int j = i + 1; j < n; j++) {
                if(array[i].id == array[j].id && array[j].id) {
                    array[i].c += array[j].c;
                    array[j].id = 0;
                }
            }
        }
        for(int i = 0; i < n; i++) {
            if(array[i].id && array[i].c >= MAX) {
                cout << array[i].id << endl;
                hap = false;
            }
        }
        if(hap) {
            cout << "NA" << endl;
        }
    }
    return 0;
}

C++: #include<iostream>
#include<cstring>
#include<vector>
using namespace std;
long long sales[4010];
#define foreach(r,p,it) for(r::iterator it=p.begin();it!=p.end();++it)

int main()
{
    int n;
    while(cin>>n)
    {
        if(n==0)break;
        vector<int> shains;
        shains.clear();
    
        memset(sales,0,sizeof(sales));
        int num,tanka,kazu;

        for(int i=0;i<n;i++)
        {
            cin>>num>>tanka>>kazu;
            sales[num] += tanka*kazu;
            int f=0;
            for(int j=0;j<shains.size();j++)
            {
                if(shains[j] == num){f=1;break;}
            }
            if(f==0) shains.push_back(num);
        }
        int na = 0;
        for(int i=0;i<shains.size();i++)
        {
            //cout <<"NUMBER"<<*it <<endl;
            if(sales[shains[i]] >= 1000000){cout<<shains[i]<<endl;na=1;}
        }
        if(na==0)cout<< "NA"<<endl;
    }
    return 0;
}

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

int main(){
	long long int total[4000],n,a,b,c;
	while(1){
		scanf("%lld",&n);
		if(n==0)break;
		memset(total,0,sizeof(total));
		while(n--){
			scanf("%lld%lld%lld",&a,&b,&c);
			total[a-1]=total[a-1]+b*c;
		}
		int res=0;
		for(int i=0;i<4000;i++){
			if(total[i]>=1000000){
				res=1;
				printf("%d\n",i+1);
			}
		}
		if(res) continue;
		else printf("NA\n");
	}
	return 0;
}

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

#define TAR 1000000

int main() {
	int n,num,ch;
	unsigned long t,k;
	while(cin >> n){
		ch = 0;
		while(n){
			scanf("%d %ld %ld",&num,&t,&k);
			if(k!=0){
				if(t > TAR/k){
					ch++;
				}else if((t == TAR/k)&&(TAR == k*t)){
					ch++;
				}
				if(((--n)==0)&&(ch==0)){
					cout << "NA" << endl;
				}
			}
		}
	}
	return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;
#define Norma 1000000

int main(){
	while(1){
		long long sale[4001],a,b,c,i,j,n;
		int k=0;
		cin>>n;
		if(n==0)break;
		for(i=0;i<4001;i++){
			sale[i]=0;
		}
		for(i=0;i<n;i++){
			cin>>a>>b>>c;
			if(sale[a]>=0){
				sale[a]+=b*c;
				if(sale[a]>=Norma){
					cout<<a<<endl;
					sale[a]=-1;
					k++;
				}
			}
		}
		if(k==0){
			cout<<"NA"<<endl;
		}
	}
	return 0;
}