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 <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <bitset>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(false);

    int n;
    while (cin >> n && n) {
        map<int,int> sum;
        for (int i=0; i<n; ++i) {
            int no, price, quantity;
            cin >> no >> price >> quantity;
            sum[no] += price * quantity;
        }

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

C++: #include <iostream>
using namespace std;
int main(void) {
  int n, flag=0;
  unsigned long long man[4000], num, sale, good[4000];
  
  while(1) {
    flag = 0;
    for(int i = 0 ; i < 4000 ; i++) {
      man[i] = 0;
      good[i] = 0;
    }
    cin >> n;
    if(n == 0) break;
    for(int i = 0 ; i < n ; i++) {
      cin >> man[i] >> num >> sale;
      if(num * sale >= 1000000) { good[i] = man[i]; flag = 1; }
    }
    if(flag == 1) {
      for(int i = 0 ; i < n ; i++) {
	if(good[i] > 0) cout << good[i] << endl;
      }
    }
    else cout << "NA" << endl;
  }
  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>
#include <queue>
using namespace std;

typedef long long ll;
typedef queue<int> qi;

const int lim = 1000000;

int n; ll en, price, qty, check[4001]; qi que;

int main()
{
    while(cin >> n && n) {
       if (n == 0) break;
       
       for(int i=0; i < n; ++i) {
           cin >> en >> price >> qty;
           if (check[en] >= 0) check[en] += price*qty;
           if (check[en] >= lim) {
               que.push(en);
               check[en]=-1;
           }
       }
        
       if (que.empty()) cout << "NA" << endl;
       else {
           for(int i=0,len=que.size(); i < len; ++i) {
               cout << que.front() << endl;
               que.pop();
           }
       }
    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  long long data[2][4000],n,i,f,id,a,b;
  while(1){
    cin>>n;
    if(n==0) break;
    for(i=0; i<4000; i++) data[0][i]=-1,data[1][i]=0;
    for(i=0;i<n;i++){
      cin>>id>>a>>b;
      for(f=0;f<i+1;f++){
	if(data[0][f]==id){
	  (a*b>=1000000)? (data[1][f]+=(a*b)) : (data[1][f]=1000000);
	  break;
	}else if(data[0][f]==-1){
	  data[0][f]=id;
	  (a*b>=1000000)? (data[1][f]=(a*b)) : (data[1][f]=1000000);
	  break;
	}
      }
    }
    for(i=0,f=0;i<n;i++){
      if(data[1][i]>=1000000)cout<<data[0][i]<<"\n",f=1;
      if(data[0][i]==-1)break;
      //cout<<"id : "<<data[0][i]<<" sale: "<<data[1][i]<<endl;
    }
    if(f==0)cout<<"NA"<<endl;
  }
}

C++: #include<iostream>
using namespace std;
long sum[4001],p,q;
int n,e;
int E[1000],u[4001];
main()
{
	while(cin>>n,n)
	{
		for(int i=0;i++<4000;)sum[i]=u[i]=0;
		for(int i=0;i<n;i++)
		{
			cin>>e>>p>>q;
			sum[e]+=p*q;
			E[i]=e;
		}
		bool f=0;
		for(int i=0;i<n;i++)
		{
			if(sum[E[i]]>=1e6)
			{
				if(u[E[i]])continue;
				u[E[i]]=1;
				f=1;
				cout<<E[i]<<endl;
			}
		}
		if(!f)cout<<"NA"<<endl;
	}
}

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

int main()
{
	while ( true )
	{
		int n; cin>>n;
		if ( n == 0 )
			break;
		vector<pair<int,long long> > E;

		for ( int i=0; i<n; i++ )
		{
			int a, b, c;
			cin>>a>>b>>c;
			int j;
			for ( j=0; j<(int)E.size(); j++ )
				if ( E[j].first==a )
					break;
			if ( j==(int)E.size() )
				E.push_back( make_pair(a,0) );
			E[j].second += b*c;
		}
		bool f = false;
		for ( int i=0; i<(int)E.size(); i++ )
			if ( E[i].second >= 1000000 )
				cout << E[i].first << endl,
				f = true;
		if ( ! f )
			cout << "NA" << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;

#define int long long

signed main() {
    int n;
    while(cin>>n, n!=0) {
        int memo[4000] = {0};
        for(int i=0; i<n; ++i) {
            int a, b, c;
            cin >> a >> b >> c;
            memo[a] += (b*c);
        }
        int ans = 0;
        for(int i=0; i<4000; ++i) {
            if(memo[i]>=1000000) {
                cout << i << endl;
                ans++;
            }
        }
        if(ans==0) cout << "NA" << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
	vector<int> id;
	int index,n,s,id;
	cin >> index;
	for(int i; i < index; i++)
	{
		cin >> id >> s >> n;
		if(s*n >1000000)
		{
			id.push_back(id);
		}
	}

	for(int a: id)
		cout << a << endl;
	return 0;
}

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

int n;
pair<int, int> ans;

int solve(int n){
        int id,p,q,sales[10000]={};
        for(int i=0;i<n;i++){
                cin >> id;
                cin >> p;
                cin >> q;
                sales[id] += p*q;
        }
        ans.first = 0;
        ans.second = 0;
        for(int i=0;i<10000;i++){
                if(ans.second < sales[i]){
                        ans.first = i;
                        ans.second = sales[i];
                }
        }
        if(ans.second < 1000000){
                cout << "NA" << endl;
        }else {
                cout << ans.first << endl;
        }
}

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

                solve(n);
        }
}

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

int main(){
	
	int n , m[4001] = {} ;
	int num , coin , sell ;
	int member[4001] = {} , j , p ;
	
	while(1){
		cin >> n ;
		if( n==0 ) break ;
		
		p = 0 ;
		for( int i=0 ; i<n ; i++ ){
			cin >> num >> coin >> sell ;
			m[num] += coin * sell ;
			for( j=0 ; j<n ; j++ ){
				if( member[j] == num ) break ;
			}
			if( j == n ){
				member[p] = num ;
				p++ ;
			}
		}
		
		j = 0 ;
		for( int i=0 ; i<p ; i++ ){
			if( m[member[i]] >= 1000000 ) cout << member[i] << endl ;
			else j++ ;
		}
		if( j==p ) cout << "NA" << endl ;
		
		for( int i=0 ; i<=4000 ; i++ ){
			m[i] = 0 ;
			member[i] = 0 ;
		}
	}
	
return 0;
}

C++: #include<cstdio>

int main(){
int a,i,fl;
unsigned long int b,c;
while(1){
scanf("%d",&i);
fl=0;
for(int j=0;j<i;j++){


 scanf("%d",&a);
 if(a==0){
 return 0;
}
 scanf("%ld",&b);
 scanf("%ld",&c);
if(a*c>=1000000) {
 fl=1;
 printf("%d\n",a);
}
if(fl==false) printf("NA\n");
}
}
}