Go: package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)

	for stdin.Scan() {
		n, _ := strconv.Atoi(stdin.Text())
		if n == 0 {
			break
		}
		sales := make(map[string]int)
		existed := make(map[string]bool)
		order := make([]string, 4000)
		flg := false
		for i := 0; i < n; i++ {
			stdin.Scan()
			l := strings.Split(stdin.Text(), " ")
			e := l[0]
			p, _ := strconv.Atoi(l[1])
			q, _ := strconv.Atoi(l[2])
			sales[e] += p * q
			if !existed[e] {
				order = append(order, e)
				existed[e] = true
			}
		}
		for _, v := range order {
			if sales[v] >= 1000000 {
				fmt.Println(v)
				flg = true
			}
		}
		if flg == false {
			fmt.Println("NA")
		}
	}
}

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

using namespace std;

long long employees[4001];
bool checked[4001];

int main()
{
	int n;
	while (cin >> n, n) {
		for (int i = 1; i <= 4000; ++i) employees[i] = checked[i] = false;

		vector<int> ans;

		for (int i = 0; i < n; ++i) {
			int num, a, b; cin >> num >> a >> b;

			if (checked[num]) continue;

			employees[num] += (long long)a * b;

			if (employees[num] >= 1000000) {
				ans.push_back(num);
				checked[num] = true;
			}
		}

		if (ans.empty()) cout << "NA" << endl;

		for (int i = 0; i < ans.size(); ++i) cout << ans[i] << endl;
	}
}

C++: #include <iostream>

using namespace std;

int main(){
	int n;
	int x[4001] = {0};
	int m[4001] = {0};
	
	while(1){
		int e, p, q, count = 0;
		cin >> n;
		if(n == 0) break;
		
		for(int i = 1; i <= n; i++){
			cin >> e >> p >> q;
			x[e] += p * q;
			if(x[e] >= 1000000){
				if(m[e] == 0){
					cout << e << endl;
					count++;
					m[e]++;
				}
			}
		}
		if(count == 0) cout << "NA" << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
  int n,f;
  //mlÛ¶vÛ¶
  long long int a,b,c;
  //aÔbP¿cÊ
  while(cin>>n,n){
		map<int,long long> m;
		vector<int> v;
		f=1;
    for(;n;n--){
      std::cin>>a>>b>>c;
      if(m[a])v.push_back(a);
      m[a] += b*c;
    }
    
    for(int i=0;i<v.size();i++){
      if(m[v[i]]>999999){
				f=0;
				cout<<v[i]<<endl;}
    }
    if(f)cout<<"NA"<<endl;
  }
  return 0;
}

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

int main()
{
	int n;
	while(cin >> n){
		if(!n){
			break;
		}
		map<unsigned long long int,unsigned long long int> syain;
		bool flag = true;
		unsigned long long int a,b,c;
		for(int i=0;i<n;i++){
			map<unsigned long long int,unsigned long long int> tmp;
			cin >> a >> b >> c;
			if(syain.find(a) != syain.end() && syain[a] < 1000000)
				syain[a] += b*c;
			else
				syain[a] = b*c;
			if(syain[a] >= 1000000){
				cout << a << endl;				
				flag = false;
			}
		}
		if(flag)
			cout << "NA" << endl;
	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n=1;
	int i=0,j=0;
	int tanka[4001]={0};
	int flg=0;
	int uriage[4001]={0};
	int bangou[4001]={0};
	int ccc=0;
	int goukei[4001]={0};
	while(n!=0)
	{
		flg=0;
		ccc=0;
		scanf("%d",&n);
		if (n==0)
		{
			break;
		}
		for (i=1;i<=n;i++)
		{
			ccc++;
			scanf("%d %d %d",&bangou[ccc],&tanka[ccc],&uriage[ccc]);
			goukei[ccc]=tanka[ccc]*uriage[ccc];
			for (j=0;j<ccc;j++)
			{
				if (bangou[ccc]==bangou[j])
				{
					goukei[j]+=tanka[ccc];
					goukei[j]+=uriage[ccc];
					ccc--;
				}
			}
		}
		for (i=1;i<=ccc;i++)
		{
			if (goukei[i]>=1000000)
			{
				printf("%d\n",bangou[i]);
				flg=1;
			}
		}
		if (flg==0)
		{
			printf("NA\n");
		}
	}
return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))



LL snum[4001];
int main(){
	LL N;
	vector<string>res;
	while(1){
		cin>>N;
		if(N==0)break;
		CLR(snum);
		REP(i,N){
			LL num,tanka,suryo;
			cin>>num>>tanka>>suryo;
			snum[num]+=tanka*suryo;
		}
		bool c=false;
		REP(i,4001){
			if(snum[i]>=1000000){
				c=true;
				res.PB(toString(i));
			}
		}
		if(!c)res.PB("NA");
	}
	REP(i,SZ(res)){
		cout<<res[i]<<endl;
	}
	return 0;
}

C++: /*Kim Jong Il*/
#include<iostream>
#include<cstdio>
using namespace std;

int main(){
  int n,id[10000],array[10000],array1[10000],i,j,count;
  
  while(1){
    count = 0;
    cin >> n;
    if(n == 0)break;
    
    for(i=0;i<n;i++){
      cin >> id[i];
	cin >> array[i];
	cin >> array1[i];
      
    }
    for(i=0;i<n;i++){
      if(array[i] * array1[i] >= 1000000){
	cout << id[i] << endl;
	count++;
      }
    }
    if(count == 0)cout << "NA" << endl;   
  }
}

C++: #include <iostream>
#include <map>
using namespace std;
int main()
{
    int n;
    while(1)
    {
        cin>>n;if(!n)return 0;
        int count=0;
        map<int,long long> sl;
        sl.clear();
        for(int i=0;i<n;++i){
            int sn;
            long long t,v;
            cin>>sn>>t>>v;
            sl.insert(make_pair(sn,t*v));
        }
        map<int,long long>::iterator it=sl.begin();
        while(it!=sl.end())
        {
            if(it->second>=1000000){cout<<it->first<<endl;++count;}
            ++it;
        }
        if(!count)cout<<"NA"<<endl;
    }
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	ll u[4010];
	bool flag;
	vector<int> v;
	while(1)
	{
		for(int i=0;i<4010;i++)
		{
			u[i]=0;
		}
		flag=true;
		int n;
		cin >> n;
		if(n==0)break;
		v.clear();
		for(int i=0;i<n;i++)
		{
			int x;
			ll y,z;
			cin >> x >> y >> z;
			if(!(u[x]))
			{
				v.pb(x);
			}
			u[x]+=y*z;
		}
		for(int i=0;i<v.size();i++)
		{
			if(u[v[i]]>=1000000)
			{
				flag=false;
				cout << v[i] << endl;
			}
		}
		if(flag)
		{
			cout << "NA" << endl;
		}
	}
	return 0;
}