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>
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");
}
}
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

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();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)

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

int main() {
	int n;
	int ban, tan, suu;
	vector<ll> table(4001, 0);
	vi check(4001, 0);

	while(cin >> n, n) {
		bool flag = true;

		REP(i, 4001) {
			table[i] = 0;
		}

		REP(i, n) {
			cin >> ban >> tan >> suu;
			
			if(!check[ban]) {
				table[ban] += tan*suu;
			}
			if(table[ban] >= 1000000) {
				check[ban] = 1;
			}
		}

		REP(i, 4001) {
			if(check[i]) {
				cout << i << endl;
				check[i] = 0;
				flag = false;
			}
		}
		if(flag) {
			cout << "NA" << endl;
		}
	}

	return 0;
}

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

using namespace std;

int main(){
	int n;
	while(scanf("%d",&n) && n){
		int a,b,c;
		map<int,long> list;
		vector<int> people;
		for(int i=0;i<n;i++){
			scanf("%d %d %d",&a,&b,&c);
			people.push_back(a);
			list[a] += b * c;
		}
		vector<int>::iterator it;
		bool flag = true;
		for(it = people.begin();it != people.end();it++){
			
			if(list[*it] >= 1000000){
				printf("%d\n",*it);
				flag = false;
			}
			
			list[*it] = 0;
		}
		if(flag){
			printf("NA\n");
		}
	}
}

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

long long int sale[4001];

int main(){
	int p;
	while(cin >> p, p){
		for(int i=0; i < 4001; i++) sale[i] = 0;
		int id, price, num, result=0;

		for(int i=0; i < p; i++){
			cin >> id >> price >> num;
			sale[id] += price * num;
		}
		for(int i=0; i < 4001; i++){
			if(1000000 <= sale[i]){
				cout << i << endl;
				result++;
			}
		}
		if(result == 0) cout << "NA" << endl;
	}
}