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 <vector>
using namespace std;
int main(){
	int n,num,price,amount;
	while(cin>>n&&n){
		vector<int> v;
		while(n--){
			cin>>num>>price>>amount;
			long long sum = price*amount;
			if(sum>=1000000) v.push_back(num);
		}
		if(v.size!=0) for(int i=0;i<v.size();++i)cout<<v[i]<<"\n";
		else cout<<"NA\n";
	}
	return 0;
}

C++: #include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 

using namespace std;

int main()
{
	int n,f,b;
	long long c,d;

	while(1){
		f=1;int k=0;
		long long a[4000][2]={0};
		cin>>n; if(n==0) return 0;

		for(int i=0;i<n;i++){
			cin>>b>>c>>d;
			for(int j=0;j<k;j++){
				if(a[j][0]==b){ a[j][1]+=c*d; f=0;}
			}
			if(f){
				a[k][0]=b; a[k++][1]=c*d;
			}
		}

		f=1;
		for(int i=0;i<k;i++){
			if(a[i][1]>=1000000) {cout<<a[i][0]<<endl; f=0;}
		}
		if(f) cout<<"NA"<<endl;
	}
}

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

using namespace std;
class saleData
{
public:

	int hireNo;
	int saleValue = 0;

	void addSale(int value)
	{
		if(saleValue < 1000000)
		{
			saleValue += value;
		}
	}

	bool judge()
	{
		if(saleValue >= 1000000)
		{
			return true;
		}
		return false;
	}
};
int main()
{
	while(1)
	{
		int dataCount;
		cin >> dataCount;
		vector<saleData> vobj;

		if(dataCount == 0)
		{
			break;
		}
		bool dataFlag = false;
		for(int i = 0; i < dataCount; i++)
		{
			int hireNo;
			int price;
			int No;
			cin >> hireNo >> price >> No;

			for(int j = 0; j < vobj.size(); j++)
			{
				if(vobj.size() == 0)
				{
					break;
				}
				if(vobj[j].hireNo == hireNo)
				{
					vobj[j].addSale(price * No);
					dataFlag = true;
					break;
				}
			}
			if(dataFlag == false)
			{
				saleData sObj;
				sObj.hireNo = hireNo;
				sObj.addSale(price * No);
				vobj.push_back(sObj);
			}
		}
		dataFlag = false;
		for(int i = 0; i < vobj.size() ; i++)
		{
			if(vobj[i].judge() == true)
			{
				cout << vobj[i].hireNo << endl;
				dataFlag = true;
			}
		}
		if(dataFlag == false)
		{
			cout << "NA" << endl;
		}


	}



}

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

C++: #include<stdio.h>
int main(void)
{
	struct employee
	{
		int N,P,A;
	};
	employee person[10][4000];
	int a,b=0,c[10],d,e;
	for(d=0;;b=0,d++)
	{
		scanf("%d",&c[d]);
		if(c[d]==0)
		{
			e=d;
			break;
		}
		for(a=0;a<c[d];a++)
			scanf("%d %d %d",&person[d][a].N,&person[d][a].P,&person[d][a].A);
	}
	for(d=0;d<=e;b=0,d++)
	{
		for(a=0;a<c[d];a++)
			if(person[d][a].P*person[d][a].A>=1000000 )
			{
				printf("%d\n",person[d][a].N);
				b++;
			}
		if(b==0)
			printf("NA\n");
	}
}

C++: #include <cstdio>
#include <map>
using namespace std;
typedef long long ll;
 
int n;
 
int main(){
	while(scanf("%d", &n),n){
		map<int,ll> m;
		map<int,ll>::iterator it;
		for(int i = 0; i < n; i++){
			int x; ll p, q;
			scanf("%d%lld%lld", &x, &p, &q);
			if(m.find(x) == m.end()) m.insert(make_pair(x,p*q));
			else m[x] += p*q;
		}
		bool ok = true;
		for(it = m.begin(); it != m.end(); it++){
			if(it->second >= 1000000){
				ok = false;
				printf("%d\n", it->first);
			}
		}
		if(ok) printf("NA\n");
	}
	return 0;
}

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

using namespace std;

int main()
{
	int n, id[4001], p, s;
	bool a[4001], f;
	long long int t, u, b[4001];
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		fill(a, a+4001, false);
		fill(b, b+4001, 0);
		p = 0;
		
		for(int i = 0; i < n; i++){
			cin >> s >> t >> u;
			b[s] += t * u;
			if(a[s]){
				continue;
			}
			id[p++] = s;
			a[s] = true;
		}
		f = true;
		for(int i = 0; i < p; i++){
			if(b[id[i]] >= 1000000){
				cout << id[i] << endl;
				f = false;
			}
		}
		
		if(f){
			cout << "NA" << endl;
		}
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n,s[4000],i,bangou,tanka,suuryou;
	while(cin>>n){
		int c=0;
		if(!n)
			break;
		for(i=0;i<4000;i++)
			s[i]=0;
		for(i=0;i<n;i++){
			cin>>bangou>>tanka>>suuryou;
			s[bangou]+=tanka*suuryou;
		}
		for(i=0;i<4000;i++){
			if(s[i]>=1000000){
				cout<<i<<endl;
				c++;
			}
		}
		if(!c)
			cout<<"NA"<<endl;
	}
	return 0;
}

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

int main() {
    int N;
    while (cin >> N && N != 0) {
        cin.get();
        string result, i;
        map<string, long long> sales;
 	long long p, q;
        for (int n = 0; n != N; ++n) {
            cin >> i >> p >> q;
            sales[i] += p * q;
        }

	bool printNA = true;
        for (map<string, long long>::iterator it=sales.begin(); it!=sales.end(); ++it) {
            if (it->second >= 1000000) {
		cout << it->first << endl;
		printNA = false;
            }
        }

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

C++: #include <stdio.h>

struct {
  int i, v;
} d[50][4000];

int main() {
  int i, j, k;
  int p, n, f;
  int id, v1, v2;

  for (i = 0; scanf("%d", &n), n != 0; i++) {
    p = 0;
    for (j = 0; j < n; j++)
      d[i][j].v = 0;
    for (j = 0; j < n; j++) {
      f = 0;
      scanf("%d %d %d", &id, &v1, &v2);      
      for (k = 0; k < j; k++) {
        if (id == d[i][k].i) {
          d[i][k].v += v1 * v2;
          f = 1;
          break;
        }
      }
      if (f == 0) {
        d[i][p].i = id;
        d[i][p].v = v1 * v2;
        p++;
      }
    }
  }

  n = i;
  for (i = 0; i < n; i++) {
    f = 0;
    for (j = 0; j < 50; j++) {
      if (d[i][j].v >= 1000000) {
        f = 1;
        printf("%d\n", d[i][j].i);
      }
    }
    if (f == 0)
      printf("NA\n");
  }
  return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
# include<iostream>
# include<string>
#include<conio.h>
using namespace std;

int main(){
	int datasuu = 0;
	int flag[4000][4000];
	int sbangou[4000][4000];
	int hanbai[4000][4000];
	int uriage[4000][4000];
	int goukei[4000][4000];
	int kaisuu = 0;
	for (int j = 0;; j++){
		cin >> datasuu;
		if (datasuu == 0){
			kaisuu = j;
			break;
		}
		for (int i = 0; i < datasuu; i++){
			scanf("%d,%d,%d", &sbangou[j][i], &hanbai[j][i], &uriage[j][i]);
			for (int z = 0; z < i; z++){
				if (hanbai[j][i] == hanbai[j][z]){
					goukei[j][i] += goukei[j][z];
				}
			}
			goukei[j][i] += hanbai[j][i] * uriage[j][i];
			if (goukei[j][i] >= 1000000){
				flag[j][i] = 1;
				goukei[j][i] = hanbai[j][i] * uriage[j][i];
			}

		}
	}
	int on = 0;
	for (int i = 0; i < 4000; i++){
		for (int j = 0; j < 4000; i++){
			if (flag[i][j] == 1){
				cout << sbangou[i][j] << endl;
				on = 1;
			}
			if (on == 0)cout << "NA";
		}
	}

}