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;
    int array[n][3];
    int count=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>array[i][0]>>array[i][1]>>array[i][2];
    }

    for(int i=0;i<n;i++){
        if(array[i][1]*array[i][2]<=1000000){
            cout<<array[i][0]<<"\n";
            count++;
        }
    }
    if(count==0) cout<<"NA\n";
}

C++: #include<cstdio>
#include<iostream>
#include<queue>
 
using namespace std;
 
int main(void){
 
    long long n,flag,number;
    long long money,sum;
    long long data[4001*5]={0},dataF[4001*5]={0};
    queue<long long> ok;
 
    while(1){
 
        for(int i=0;i<=4001*5;i++) data[i]=0,dataF[i]=0;
        flag=0;
 
        cin>>n;
        if(n==0) break;
 
        for(int i=0;i<n;i++){
            cin>>number>>money>>sum;
            data[number]+=money*sum;
            if(dataF[number]==0){
                dataF[number]=1;
                ok.push(number);
            }
        }
            while(!ok.empty()){
                if(data[ok.front()]>=1000000){
                    cout<<ok.front()<<endl;
                    flag=1;
                }
                ok.pop();
            }
            if(flag==0) cout<<"NA"<<endl;
    }
 
    return 0;
}

C++: #include "stdio.h"
#include "string.h"
long long  N[4001];
int f[4001];
int main(){
    int x,n,p,i,j,c=0;
    scanf("%d",&i);
    while(i!=0){
        c=0;
        for(j=0;j<i;j++){
            scanf("%d%d%d",&x,&n,&p);
            if(N[x]!=-1){
                N[x]+=n*p;
                if(N[x]>=1000000){
                    f[c]=x;
                    c++;
                    N[x]=-1;
                }
            }
        }
        if(c==0)
            printf("NA\n");
        else 
            for(j=0;j<c;j++)printf("%d\n",f[j]);
        memset(N,0L,4001);
        memset(f,0,4001);
        scanf("%d",&i);
    }
}

C++: #include <iostream>
#include <map>
using namespace std;
int main() {
  int n;
  map<int, long> mp;
  map<int, long>::iterator itr;

  while(cin >> n) {
	if(n == 0) break;
	int e, p, q;

	for(int i = 0; i < n; ++i) {
	  cin >> e >> p >> q;
	  itr = mp.find(e);
	  if(itr == mp.end()) {// not found
		mp[e] = int(p * q);
	  }
	  else {
		itr->second += p * q;
		if(itr->second >= 1000000) {
		  itr->second = -1;
		}
	  }
	}

	bool isNA = true;
	for(itr = mp.begin(); itr != mp.end(); ++itr) {
	  if(itr->second -1) {
		cout << itr->first << endl;
		isNA = false;
	  }
	}
	if(isNA) {
	  cout << "NA" << endl;
	}

	mp.clear();
  }
  return 0;
}

C++: #include <iostream>
#include <map>
#include <vector>
#define int long long int
using namespace std;
signed main() {
  bool f;
  vector<pair<int, int> > v;
  int n, a, b, c;
  while (cin >> n && n > 0) {
    v.clear();
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      f = 0;
      for (int j = 0; j < v.size(); j++) {
        if (v[j].first == a) {
          v[j].second += b * c;
          f = 1;
        }
      }
      if (!f) {
        v.push_back(pair<int, int>(a, b * c));
      }
    }
    f = 0;
    for (int i = 0; i < v.size(); i++) {
      if (v[i].second >= 1000000) {
        cout << v[i].first << endl;
        f = 1;
      }
    }
    if (!f) {
      cout << "NA" << endl;
    }
  }
  return 0;
}

C++: #include<stdio.h>
int n,i,b;
int syain[4001],a,suu;
int flg=0;
int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=1;i<=4000;i++){
			syain[i]=0;
		}
		for(i=0;i<n;i++){
			scanf("%d %d %d",&a,&b,&suu);
			syain[a]+=(b*suu);
		}
		flg=0;
		for(i=1;i<=4000;i++){
			if(syain[i]>=1000000){
				printf("%d\n",i);
				flg=1;
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}

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

using namespace std;

int main(void){
    int i,l,k;
    int n;
    long long id,c,q;
    long long data_list[4001];
    int id_list[4000];
    bool id_flag;
    bool na_flag;
    
    while(cin>>n,n!=0){
        k=0;
        memset(data_list,0,sizeof(data_list));
        for(l=0;l<n;l++){
            cin>>id>>c>>q;
            data_list[id]+=(c*q);
            id_flag=true;
            for(i=0;i<k+1;i++){
                if(id_list[i]==id){
                    id_flag=false;
                }
            }
            if(id_flag){
                id_list[k]=id;
                k++;
            }
        }
        na_flag=true;
        for(l=0;l<k;l++){
            if(data_list[id_list[l]]>=1000000){
                cout<<id_list[l]<<endl;
                na_flag=false;
            }
        }
        if(na_flag){
            cout<<"NA"<<endl;
        }
    }
    return(0);
}

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

int n, e, p, q;

int main(){
    while(1){
        scanf("%d", &n);
        if(!n) break;

        std::map<int, int> m;
        std::queue<int> que;

        for(int i = 0; i < n; i++){
            scanf("%d %d %d", &e, &p, &q);

            if(m.count(e) != 0){
                m[e] += (p * q);
            }else{
                m[e] = p * q;
                que.push(e);
            }
        }

        bool flag = true;
        while(!que.empty()){
            int tmp = que.front(); que.pop();

            if(m[tmp] >= 1000000){
                printf("%d\n", tmp);
                flag = false;
            }
        }

        if(flag){
            printf("NA\n");
        }
    }

    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	long long int value[4001];

	int n,num,k,m;
	while(cin >> n && n)
	{
		memset(value,0,sizeof(value));

		rep(i,n)
		{
			cin >> num >> k >> m;
			value[num] += k*m;
		}

		bool flag = true;
		rep(i,4001)
		{
			if(value[i] >= 1000000)
			{
				flag = false;
				cout << i << endl;
			}
		}

		if(flag) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int i, n, q;
  long long int p;
  while(cin >> n, n){
    bool NAflg = false;
    while(n--){
      cin >> i >> p >> q;
      if((p * q) >= static_cast<int>(1e6)){
	cout << i << endl;
	NAflg = true;
      }
    }
    if(!NAflg)
      cout << "NA" << endl;
  }
  return 0;
}

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

int main(){
    int n;
    while(cin>>n,n){
        map<int,long long>m;
        vector<int>vec;
        long long i,p,q,s=0;
        while(n--){
            cin>>i>>p>>q;
            if(!m[i])vec.push_back(i);
            m[i]+=p*q;
        }
        for (int i=0;i<vec.size();i++){
            if(m[vec[i]]>=1000000){
                s=1;
                cout<<vec[i]<<endl;
            }
        }
        if(!s)cout<<"NA"<<endl;
    }
}