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>
using namespace std;

int main(){
    int n;
    
    while(true){
        int cnt = 0;
        unsigned long long int s[4002]={0},gs[4002]={0};
        
        cin >> n;
        if(!n) break;
        
        int t,cost;
        int num;
        for(int i = 0 ; i < n ; i++){
            cin >> num >> t >> cost;
            s[num] += t*cost;
            gs[i] = num;
        }
        
       for(int i = 0 ; i < n ; i++){
            for(int j = i+1 ; j < n ; j++){
                if(gs[i]==gs[j]&&i < j){
                    gs[j] = 4001;
                }
            }
        }
        
        for(int i = 0 ; i < n ; i++){
            if(s[gs[i]] >= 1000000){
                cout << gs[i] << endl;
                cnt++;
            }
        }
        if(!cnt) cout << "NA" << endl;
    }
    
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,h;
  while(cin>>n){
    if(n==0) break;
    h = 0;
    int b[n],p[n],q[n];
    for(int i=0;i<n;i++){
      cin >> b[i] >> p[i] >> q[i];
      for(int j=0;j<i;j++){
	if(b[j]==b[i]){
	  p[j] += p[i];
	  q[j] += q[i];
	  p[i] = 0;
	  q[i] = 0;
	  b[i] = 0;
	  break;
	}
      }
    }
    //for(int i=0;i<n;i++) cout << b[i] << ' ' << p[i] << ' ' << q[i] << endl;; 
    for(int i=0;i<n;i++){
      if(p[i]*q[i]>=1000000){
	cout << b[i] << endl;
	if(h==0) h = 1;
      }
    }
    if(h==0) cout << "NA" << endl;
  }
  return 0;
}

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

#define SHINE_MAX 4000
#define ELITE 1000000
#define AHO "NA"

int shineN,eliteN;
int shineI[SHINE_MAX]	//??????????????????
long int shineU[SHINE_MAX];	//?£??????????

int dataN,num,tanka,suryo;
int i,j;

int main(){
while(1){
	//??\???
	cin>>dataN;
	if(dataN==0){break;}
	shineN=0;
	for(j=0;j<dataN;j++){
	 cin>>num>>tanka>>suryo;num--;
	 //???????????????????????????????????¨??????????????????
	 for(i=0;i<shineN;i++){
	  if(shineI[i]==num){break;}
	 }
	 if(i==shineN){	//?????¨???????????£????????????
	  shineU[num]=0;
	  shineI[shineN]=num;
	  shineN++;
	 }
	 shineU[num]+=suryo*tanka;
	}
	//??????
	eliteN=0;
	for(j=0;j<shineN;j++){
	 i=shineI[j];
	 if(ELITE<=shineU[i]){
	  cout<<i+1<<endl;
	  eliteN++;
	 }
	}
	if(eliteN==0){cout<<AHO<<endl;}
}
return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<double,double> P;

int main(){
	
	int num;
	while(~scanf("%d",&num)){
		if(num==0) break;
		bool isok=false;
		map<int,int> val;
		vector<int> order;
		for(int i=0;i<num;i++){
			int n,p,q;
			scanf("%d %d %d",&n,&p,&q);
			val[n] += p*q;
			if(find(order.begin(),order.end(),n) == order.end()){
				order.push_back(n);
			}
		}

		for(vector<int>::iterator it = order.begin(); it != order.end(); it++){
			if(val[*it] >= 1000000){
				cout << *it << endl;
				isok=true;
			}
		}
		if(!isok) cout <<  "NA" << endl;
	}
}

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

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef long long ll;
typedef unsigned long long ull;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)( m ); i < (unsigned int)( n ); i++ )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define RALL( c ) (c).rbegin(), (c).rend()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

int main()
{
	while ( true )
	{
		int n;
		cin >> n;

		if ( n == 0 )
		{
			break;
		}

		VI res;

		REP( i, 0, n )
		{
			int no, price, num;
			cin >> no >> price >> num;

			if ( 1000000 <= price * num )
			{
				res.PB( no );
			}
		}

		if ( res.size() == 0 )
		{
			cout << "NA" << endl;
		}
		else
		{
			for ( int &no : res )
			{
				cout << no << endl;
			}
		}
	}

	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


typedef long long ll;


using namespace std;

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

		vector<int> order;
		map<int, ll> sale;
		while (n--)
		{
			int no, value, num;
			scanf("%d %d %d", &no, &value, &num);
			if (!sale[no])
				order.push_back(no);

			sale[no] += (ll)value * num;
		}
		bool any = false;
		for (int i = 0; i < order.size(); ++i)
		{
			if (sale[order[i]] >= 1000000)
			{
				printf("%d\n", order[i]);
				any = true;
			}
		}
		if (!any)
			printf("NA\n");
	}

	return 0;
}

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

int main(){
 int id,price,num,count,SaleResult[4000];
 bool isBe=false;
 while(true){
  cin>>count;
  if(count==0){
   break;
  }
  for(int i=0;i<count;i++){
   cin>>id>>price>>num;
   SaleResult[id]+=price*num;
  }
  for(int i=0;i<4000;i++){
   if(SaleResult[i]>=1000000){
     cout<<i<<'\n';
     isBe=true;
   }
  }
  if(!isBe){
   cout<<"NA\n";
  }
  count=0;
  isBe=false;
  for(int i=0;i<4000;i++){
    SaleResult[i]=0;
  }
  }
 return 0;
}

C++: #include<stdio.h>
#include<list>
class hoge{
 public:
  int num;
  long long int v;
  bool ov;
  hoge(int n,int v,int c){    
    num=n;
    ov=false;
    set(v,c);
  }
  void set(int va,int c);
  bool isOV();
};
bool hoge::isOV(){
  return ov;
}
void hoge::set(int va,int c){
  long long int i=va*c;
  if(ov)
    return ;
  if((v+i)>=1000000){
    ov=true;
    return ;
  }
  v+=i;
}

int main(){
  using namespace std;
  int i,n,v,c,num,flg;
  long long int a;
  list<hoge> ls;
  list<hoge>::iterator pos;
  do{
    scanf("%d",&n);
    if(!n) break;
    for(i=0;i<n;i++){
      scanf("%d %d %d",&num,&v,&c);
      pos=ls.begin();
      while(pos!=ls.end()){
	if((*pos).num==num){
	  (*pos).set(v,c);
	  break;
	}
	pos++;
      }
      if(pos==ls.end()){
	ls.push_back(*(new hoge(num,v,c)));       
      }
    }
    pos=ls.begin();
    flg=1;
    while(pos!=ls.end()){
      if((*pos).isOV()){
	printf("%d\n",(*pos).num);
	flg=0;
      }
      pos++;
    }
    if(flg) printf("NA\n");
    ls.clear();
  }while(1);
  return 0;
}