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>
#include <algorithm>
#define N 4001
using namespace std;
int main(){

  int n,b;
  int a,num[N],tanka,uriage,jun[N];
  bool judge,nnnn;

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

    judge = true;
    for(int i=0;i<N;i++){
      num[i] = 0;
    }

    for(int i=0,b=0;i<n;i++){
      nnnn = true;
      cin >> a >> tanka >> uriage;
      num[a] += tanka * uriage;
      for(int j=0;j<i;j++){
	if(jun[j]==a){
	  nnnn = false;
	  break;
	}
      }
      if(nnnn){
	jun[b] = a;
	b++;
      }
    }

    for(a=0;jun[a]!=0;a++){
      if(num[jun[a]]>=1000000){
	cout << jun[a] << endl;
	judge = false;
      }
    }
    if(judge)
      cout << "NA" << endl;
  }
  return 0;
}

C++: #include<stdio.h>


int main(){
	int n;
	int id[4000],cid;
	long long int price,num,sale[4000];
	bool f;
	int i,j,idcount;
	while(scanf("%d",&n),n){

		f=true;
		idcount=0;

		for(i=0;i<n;i++){
			scanf("%d %lld %lld",&cid,&price,&num);

			for(j=0;j<idcount;j++){
				if(id[j]==cid){
					sale[j]=sale[j]+price*num;
				}
			}

			if(j==idcount){
				id[idcount]=cid;
				sale[idcount]=price*num;
				idcount++;
			}

		}



		for(i=0;i<idcount;i++){
			if(sale[i]>=1000000){
				printf("%d\n",id[i]);
				f=false;
			}
		}
		if(f!=false)printf("NA\n");
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define INT(name) int name; scanf("%d",&name);
#define VINT(name,n) vector<int> name(n); for(int i = 0;i < n;i++) scanf("%d",&name[i]);

using namespace std;

int main(int argc, char const *argv[]){
	vector<unsigned long long> data(4000);
	vector<int> f(4000);
	int i;
	long long a,b,c;
	bool check;

	cin >> i;
	while(i){

		for(int j = 0;j < 4000;j++){
			data[j] = 0;
		}


		for(int j = 0;j < i;j++){
			cin >> a >> b >> c;
			data[a - 1] += (long long)b * c;
			f[j] = a - 1;
		}


		check = false;

		for(int j = 0;j < i;j++){
			if(data[f[j]] >= 1000000){
				printf("%d\n",f[j] + 1);
				data[f[j]] = 0;
				check = true;
			}
		}

		if(!check) printf("NA\n");

		cin >> i;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(!n)break;
		int num,price,amount;
		vector<int> v;
		while(n--){
			cin>>num>>price>>amount;
			if((long)price*(long)amount>=1000000)v.push_back(num);
		}
		if(!v.empty()){
			for(int i=0;i<v.size();++i)cout<<v[i]<<"\n";
		}else cout<<"NA\n";
	}
	return 0;
}

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

using namespace std;

int main(){
	int n;
	while(cin >> n){
		map<int, int> m;
		for(int i = 0; i < n; i++){
			int id, price, amount;
			cin >> id >> price >> amount;
			m[id] += price * amount;
		}
		bool applicable = false;
		for(map<int, int>::iterator itr = m.begin(); itr != m.end(); itr++){
			if(itr->second >= 1000000){
				applicable = true;
				cout << itr->first << endl;
			}
		}
		if(!applicable){
			cout << "NA" << endl;
		}

	}
	return 0;
}

C++: #include<iostream>
#include<map>
#include<string>
using namespace std;
const int MAXN = 4000;
typedef long long ll;
string i;
int p,q;
bool isfind = false;
map<string,ll> total;

int main(){
  int n;
  while(1){
    cin >> n;
    if(n == 0)return 0;
    for(int k = 0;k < n;k++){
      cin >> i >> p >> q;
      total[i] += p*q;
    }
    for(map<string, ll>::iterator i = total.begin(); i != total.end(); ++i){
      if(i->second >= 1000000){
	isfind = true;
	cout << i->first << endl;
      }
    }
    if(!isfind)cout << "NA" << endl;
    total.clear();
    isfind =false;
  }
  return 0;
}

C++: #include<stdio.h>

int main(){
	int num,age,tanka;
	int i,j,n,temp;
	int sya[4000];
	double uriage[4000];
	
	
	for(;;temp=0){
		for(i=0;i<n;i++)uriage[i]=0;
		scanf("%d", &n);
		if(n==0)break;
		
		for(i=0;i<n;i++){
			scanf("%d%d%d", &num, &tanka, &age);
			
			for(j=0;j<=i;j++){
				if(sya[j]==num){
					uriage[j]+=tanka*age;
					break;
				} else {
					sya[i]=num;
					uriage[i]+=tanka*age;
					break;
				}
			}
		}
		for(i=0;i<n;i++){
			if(uriage[i]>=1000000){
				printf("%d\n",sya[i]);
				temp=1;
			}
		}
		if(temp==0)puts("NA");
	}
	return 0;
}

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

#define ll long long

bool debug = false;

int main(void){
  map<int,ll> m;
  vector<int> order;
  int n;
  long long no,amount,price;

  while(cin >> n){
	bool exist = false;
	if(!n) break;
	for(int i=0;i<n;i++){
	  cin >> no >> amount >> price;
	  if(find(order.begin(), order.end(), no) == order.end()){
		order.push_back(no);
		if(debug) cout << "pushed " << no << endl;
	  }
	  m[no] += (ll)amount*price;
	}
	for(int i=0;i<order.size();i++){
	  if(m[order[i]] >= 1e+6){
		cout << order[i] << endl;
		exist = true;
	  }
	}
	if(!exist) cout << "NA" << endl;
	m.clear();
	order.clear();
  }
}

C++: #include <stdio.h>

#define MAX 4000

int main(void){
	int i,dataset,snum[MAX],flag;
	long long total[MAX],unitcost,amount;
	while( 1 ){

		for(i=0;i<MAX;i++){
			total[i]=0;
			snum[i]=0;
		}

		scanf("%d",&dataset);
		if( dataset == 0 ){break;}

		else for(i=0;i<dataset;i++){
			scanf("%d %lld %lld",&snum[i],&unitcost,&amount);
			total[snum[i]]+=unitcost*amount;
		}
		

		flag=0;
		for(i=0;i<MAX;i++){
                        if( total[snum[i]] >= 1000000 ){
				flag=1;
				printf("%d\n",snum[i]);
				total[snum[i]]=0;
			}
		}
		if( dataset!=0 && flag==0 ){
			printf("NA\n");
		}
	}
}

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

using namespace std;

int main() {
	int num;
	int LINE = 1000000;

	while(cin>>num, num){
		map<int, long long> employees;
		map<int, long long>::iterator itr;
		bool flg = false;
		for(int i=0; i<num; i++){
			int id =0, q=0, p=0;
			cin>>id>>q>>p;
			employees[id] += (q*p);
		}
		if(employees.size()==0){
			cout<<"NA"<<endl;
		}
		for(itr = employees.begin(); itr != employees.end(); itr++){
			if(itr->second >= LINE) cout<<itr->first<<endl;
		}
	}
	return 0;
}

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

int main(){
int n,a;
double b,c;
cin>>n;
for(;n>0;n--){
cin>>a>>b>>c;
b=1000000/b;
if(b>=c)cout<<a<<endl;
if(b<c)cout<<"NA"<<endl;}}

C++: #include<iostream>
using namespace std;
int main()
{
    int n,na,e;
    long long sum[4010];
    long long p,q;
    while(cin >> n,n!=0){
        na = 0;
        for(int i=0;i<=4000;i++) sum[i] = 0;
        for(int i=0;i<n;i++){
            cin >> e >> p >> q;
            if(sum[e] >= 1000000) continue;
            sum[e] += p*q;
            if(sum[e] >= 1000000){
                na = 1;
                cout << e << endl;
            }
        }
        if(na == 0) cout << "NA" << endl;
    }
    return 0;
}

C++: #include <stdio.h>

#define MAX 4000

int main(void){
	int i,dataset,snum[MAX],flag;
	long long total[MAX],unitcost,amount;
	while( 1 ){

		for(i=0;i<MAX;i++){
			total[i]=0;
			snum[i]=0;
		}

		scanf("%d",&dataset);
		if( dataset == 0 ){break;}

		else for(i=0;i<dataset;i++){
			scanf("%d %lld %lld",&snum[i],&unitcost,&amount);
			total[snum[i]]+=unitcost*amount;
		}
		

		flag=0;
		for(i=0;i<MAX;i++){
                        if( total[i] >= 1000000 ){
				flag=1;
				printf("%d\n",snum[i]);
			}
		}
		if( dataset!=0 && flag==0 ){
			printf("NA\n");
		}
	}
}