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

#define N 4000

int main(void) {
	int shine[N+1];
	bool shinef[N+1];
	bool na;
	int n,a,b,c;

	while (cin >> n, n) {
		na = true;
		for (int i = 0; i < N; i++) {
			shine[i] = 0;
			shinef[i] = false;
		}
		while (n--) {
			cin >> a >> b >> c;
			shine[a] += c*b;
			if (shine[a] >= 1000000 && shinef[a] == false) {
				cout << a << endl;
				shinef[a] = true;
				na = false;
			}
		}
		if (na) cout << "NA" << endl;
	}
	return 0;
}

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

int main()
{
	int n = 0;               //  社員の人数;n==0で終了
	bool flag = true;        //  flagはidの重複を確認する; trueは重複無し
	int id_temp,price_temp,amount_temp;
	vector<int> id;          //  社員のid
	vector<int> price;       //  the corresponding unit price
	vector<int> amount;      //  the amount of sales
	vector<int> result;      //  条件を満たすid郡

	while(true) {
		cin >> n;
		if(n==0)
			return 0;
		// 1つのデータセットに対する処理
		else {
			result.clear(); id.clear(); price.clear(); amount.clear(); // データをクリアする
			for(int i=0;i<n;i++) {
				cin >> id_temp >> price_temp >> amount_temp;
				flag = true;
				// idが重複している場合はすでにあるデータに上書きする
				for(int j=0;j<id.size();j++) {
					if(id_temp==id[j]) {
						price[j] += price_temp;
						amount[j] += amount_temp;
						flag = false;
						break;
					}
				}
				// 新しいidの場合は配列の末尾に追加する
				if(flag) {
					id.push_back(id_temp);
					price.push_back(price_temp);
					amount.push_back(amount_temp);
				}
			}
			// 売り上げ金額が1,000,000円以上の社員idを追加
			for(int i=0;i<n;i++) 
				if(price[i]*amount[i]>=1000000)
					result.push_back(id[i]);
			// 結果を出力
			if(result.size()==0)
				cout << "NA" << endl;
			else
				for(int i=0;i<result.size();i++)
					cout << result[i] << endl;
		}
	}

	return 0;
}

C++: #include<iostream>
#include<map>
#include<vector>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    vector<int> sale;
    map<int, long long> comp;
    int a;
    long long b,c;
    bool f = true;
    while(n--){
      cin >>a>>b>>c;
      if(!comp[a]){sale.push_back(a);}
      comp[a]+=b*c;
    }
    for(int i=0; i<sale.size(); i++){
      if(comp[sale[i]] >= 1000000){cout <<sale[i]<<endl;f =false;}
    }
    if(f){cout <<"NA"<<endl;}
  }
  return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int n, i, buf[3], *idlist, index_idlist = 0, milcount = 0;
	unsigned long long int *sale;

	scanf("%d", &n);

	sale = (unsigned long long int *)calloc(4000, sizeof(unsigned long long int));
	idlist = (int *)calloc(n, sizeof(int));

	while (n != 0){
		for (i = 0; i < n; i++){
			scanf("%d %d %d", &buf[0], &buf[1], &buf[2]);
			sale[buf[0] - 1] += buf[1] * buf[2];
			idlist[index_idlist++] = buf[0];
		}

		for (i = 0; i < n; i++){
			if (sale[idlist[index_idlist]] >= 1000000){
				printf("%d\n", idlist[index_idlist]);
				sale[idlist[index_idlist--]] = 0;
			}
			milcount++;
		}

		if (milcount == 0){
			puts("NA");
		}
		milcount = 0;
		scanf("%d", &n);
	}

	return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
#define int ll
signed  main(){
    int n;
    while(cin>>n,n){
        vi v;
        map<int,int>mp;
        rep(j,n){
            bool mb=true;
            int a,b,c; cin>>a>>b>>c;
            mp[a]+=b*c;
            rep(i,v.size())if(v[i]==a)mb=false;
            if(mb)v.push_back(a);
        }
        bool flag=false;
        rep(i,v.size())if(mp[v[i]]>=1000000){cout<<v[i]<<endl;flag=true;}
        if(!flag)cout<<"NA"<<endl;
    }
}

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

int main(){

  int num, v, n, m, len, cnt;
  vector<long long> vc[2];

  while(cin >> n){
    if(n == 0) break;
    vc[0].clear();
    vc[1].clear();
    len = 0;

    for(int i=0; i<n; i++){
      cin >> num >> v >> m;
      for(int j=0; j<=len; j++){
        if(j == len){
          vc[0].push_back(num);
          vc[1].push_back(v * m);
          len++;
          break;
        }
        if(vc[0][j] == num){
          vc[1][j] += v * m;
          break;
        }
      }
    }
    
    cnt = 0;
    for(int i=0; i<len; i++){
      if(vc[1][i] >= 1000000){
        cout << vc[0][i] << endl;
        cnt++;
      }
    }
    if(cnt == 0) cout << "NA" << endl;

  }

  return 0;

}

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

int main(int argc, char **argv)
{
	int i, n, size = 0, flag, pri = 1, max;
	unsigned int p, q;
	unsigned int *sum = (unsigned int *)calloc(4000, sizeof(unsigned int));
	int *pr = (int *)calloc(4000, sizeof(int));
	int *id = (int *)calloc(4000, 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 > sum[i] || pri != pr[i]){
						sum[i] = p*q;
						pr[i] = pri;
					}
					flag = 1;
					break;
				}
			}
		
			if(flag == 0){
				id[size] = i;
				sum[i] = p*q;
				pr[i] = pri;
				size++;
			}
		}

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

C++: 
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

#define MAX 5000

int main(){
    for (;;) {
        int n;
        cin >> n;
        if(n==0) break;
        vector<int> num(4000,0);
        vector<int> pre(n,0);
        vector<int> data(4000,0);
        for (int i=0; i<n; i++) {
            int a,b,c;
            cin >>a >>b >>c;
            data[a]+=b*c;
            if(num[a]==0) num[a]=i+1;
        }
        for (int k=0;k< 4000; k++) {
            if(num[k]!=0) pre[num[k]]=k;
        }
        int ch=0;
        for (int j=0; j<n; j++) {
            if (data[pre[j]]>=1000000) {
                cout <<pre[j]<<endl;
                ch++;
            }
        }
        if(ch==0) cout << "NA"<<endl;
    }
}

C++: #include<cstdio>

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


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