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 <iostream>
#include <stdlib.h>
using namespace std;

typedef struct{
	int sum;
	int pr;
} data;

int main(int argc, char **argv)
{
	int i, p, q, n, size = 0, flag, pri = 1, max;
	data *sarray = (data *)calloc(4000, sizeof(data));
	int *id = (int *)calloc(1000, sizeof(int));
	while(1){
		cin >> n;
		
		if(n == 0){
			cout << "NA" << endl;
			break;
		}
		
		while(n > 0){
			n--;
			cin >> i >> p >> q;
			flag = 0;
			for(int j = 0; j < size; j++){
				if(id[j] == i){
					if(p*q > sarray[i].sum || pri != sarray[i].pr){
						sarray[i].sum = p*q;
						sarray[i].pr = pri;
					}
					flag = 1;
					break;
				}
			}
		
			if(flag == 0){
				id[size] = i;
				sarray[i].sum = p*q;
				sarray[i].pr = pri;
				size++;
			}
		}

		max = id[0];
		for(int j = 1; j < size; j++){
			if(sarray[max].sum < sarray[id[j]].sum){
				max = id[j];
			}
		}
		
		cout << max << endl;
		
		pri++;
	}
	
	free(sarray);
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<queue>

using namespace std;

int main(void){

	int n,number,money,sum;
	int data[4001]={0},dataF[4001]={0};
	queue<int> ok;

	while(1){

		for(int i=0;i<4000;i++) data[i]=0,dataF[i]=0;

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

		for(int i=0;i<n;i++){
			cin>>number>>money>>sum;
			data[number]+=money*sum;
			if(data[number]>=1000000&&dataF[number]==0){
				dataF[number]=1;
				ok.push(number);
			}
		}
		if(ok.empty()){
			cout<<"NA"<<endl;
		}
		else{
			while(!ok.empty()){
				cout<<ok.front()<<endl;
				ok.pop();
			}
		}
	}

	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<vector>

using namespace std;

struct data{
  int id;
  int price;
  int amount;
  int rate;
};

int main(){
  int n=0;
  while(1){
    cin>>n;
    if(n==0){return 0;}
    vector<struct data> data(n);
    int c=0;
    for(int i=0;i<n;i++){
      scanf("%d %d %d",&data[i].id,&data[i].price,&data[i].amount);
      data[i].rate=data[i].price*data[i].amount;
    }
    for(int i=0;i<n;i++){
      if(data[i].rate>=1000000){
	cout<<data[i].id<<"\n";
	c++;
      }
    }
    if(c==0){
      cout<<"NA\n";
    }
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	int n,ans[4000];
	double a,b;
	
	for(;;)
	{
		cin >> n;
		if(n==0)
			break;
		int i,j;
		for(i=0,j=0;i<n;i++)
		{
			int num,flag=1;
			cin >> num >> a >> b ;
			if(a/10000.0*b>=100.0)
			{
				for(int k=0;k<j;k++)
				{
					if(ans[k]==num)
						flag=0;
				}
				if(flag==1)
				{
					ans[j]=num;
					j++;
				}
			}
		}
		
		if(j!=0)
		{
			for(int i=0;i<j;i++)
			{
				cout << ans[i] << endl;
			}
		}
		else
			cout << "NA" << endl;
	}
}

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

int main(){
    int n, a, b, c, d = 0, com[4001] = {};
    cin >> n;
    if(n != 0){
    for(int i = 0;i < n;i++){
       cin >> a >> b >> c;
       com[a] += b * c;
      }
    for(int j = 1;j < 4001;j++){
       if(com[j] < 1000000) continue;
       cout << com[j] << endl;
       d++;
      }    
    if(d == 0) cout << "NA" << endl;
     }
    return 0;
   }

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

using namespace std;

int main(){
  int n;
  
  while(true){
    cin >> n;
    if(n==0)
      break;
    map<int,int> isi;
    int i, p, q;
    for(int j=0; j<n; j++){
      cin >> i >> p >> q;
      if(isi.find(i)==isi.end())
	isi[i] = p*q;
      else
	isi[i] += p*q;
    }

    map<int,int>::iterator it;
    bool cc = true;
    for(it=isi.begin(); it!=isi.end(); ++it){
      if(it->second >= 1000000){
	cout << it->first << endl;
	cc = false;
      }
    }
    if(cc)
      cout << "NA\n";
    
  }
  return 0;
}

C++: /*
	0100:Sale Result
*/
#include	<iostream>
#include	<map>

using namespace std;

int main(void) {
	int n;
	while(1) {
		bool isOK = false;
		map<int, int> MP;
		
		cin >> n;
		
		if(n == 0) { break; }
		
		for(int i = 0; i < n; i++) {
			int n, p, c;
			cin >> n >> p >> c;
			MP[n] += p * c;
		}
		for(map<int, int>::iterator it = MP.begin(); it != MP.end(); it++) {
			if(it->second >= 1000000) {
				cout << it->first << endl;
				isOK = true;
			}
		}
		if(isOK == false) {
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

int p[4001];
int result[1000000];

int main(){
	int i ,j=0 , n , id , price , num , cnt;
	while(cin>>n){
		cnt=0;
		memset(p,0 , sizeof(p)/sizeof(p[0]));
		if (n==0) break;
		for(i=0 ; i<4001 ; i++){
			p[i]=false;
		}
		for(i=0 ; i<n ; i++){
			cin >> id >> price >> num;
				p[id]+=price*num;
			}
		for(i=0 ; i<4001 ; i++){
			if(p[i]>=1000000){
				result[j++]=i;
				cnt++;
			}
		}
		if (cnt==0) {
				result[j++]=0;
			}
	}
	for(i=0;i<j;i++){
		if (result[i]==0) {
			cout << "NA" << endl;
		} else {
		cout << result[i] << endl;
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	long long i,n,value,count,number,f;
	while(cin >> n, n)
	{
		f=0;
		for(i = 0; i < n; i++)
		{
			cin >> number >> value >> count;
			if(value*count >= 1000000LL)
				cout << number << endl, ++f;
		}
		if(!f)
			cout << "NA" << endl;
	}
	return 0;
}

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

using namespace std;

int main(){

  long long n, id, val, num, cnt;
  long long member[4000];
  int index[4000];

  while(cin >> n){

    if(!n) break;

    cnt = 0;
    memset(member, -1, sizeof(member));
    memset(index, -1, sizeof(index));

    for(int i = 0; i < n; ++i){

      cin >> id >> val >> num;

      if(member[id - 1] == -1){
        index[cnt] = id - 1; ++cnt;
        member[id - 1] += 1 + val * num;
      } else {
        member[id - 1] += val * num;
      }

    }

    bool flag = false;

    for(int i = 0; i < cnt; ++i){
      if(member[index[i]] >= 1000000){
        cout << index[i] + 1 << endl;
        flag = true;
      }
    }

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

  }

}

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

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

		int num,x,y;
		int mon=0,cnt=0;
		int p[4000];
		int j=0;

		for(int i=0 ;i<n ;i++)
			p[i] = 0;

		for(int i=0 ;i<n ;i++){
			cin >> num >> x >> y;

			mon = x*y;
			if(mon >=1000000){

				p[j] = num;
				cnt++;
				j++;
			}
		}
		if(cnt > 0){
			for(int i=0 ;i<cnt ;i++)
				cout << p[i] << endl;
		}
		if(cnt==0)
			cout << "NA" << endl;

	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

typedef long long ll;

int s[4000][2],n,a,b,N;
string d;

int main(){
    while(cin>>N){
	if(N==0)return 0;
	for(int i=0;i<4000;i++){
	    for(int j=0;j<2;j++){
		s[i][j]=0;
	    }
	}
	int m=0;
	for(int i=0;i<N;i++){
	    cin>>n>>a>>b;
	    int flag=0;
	    for(int j=0;j<m;j++)if(s[j][0]==n){s[j][1]+=a*b;flag=1;}
	    if(flag==0){s[m][0]=n;s[m][1]=a*b;m++;}
	}
	int flag2=0;
	for(int i=0;i<4000;i++)if(s[i][1]>999999){cout<<s[i][0]<<endl;flag2=1;}
	if(flag2==0)cout<<"NA"<<endl;
    }
}