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<stdio.h>

int main(){
  while(1){
    int n;
    scanf("%d", &n);
    if(n!=0){
      int i;
      int a, b, c;
      double e[4001] ={};
      int flag = 0;
      for(i=0;i<n;i++){
	scanf("%d %d %d", &a, &b, &c);
	//if(e[a]+b*c<=2147483647)
	  e[a]+=(double)b*c;
	//else
	  //e[a]=(double)2147483647;//printf("aa\n");
	
      }


      for(i=0;i<4001;i++){
	if(e[i]>=1000000){
	  printf("%d\n", i);
	  flag++;
	}
      }
      if(flag==0)
	printf("NA\n");
      
    }
    else{
      break;
    }
  }
  return 0;
}

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);
		}
		for(itr = employees.begin(); itr != employees.end(); itr++){
			if(itr->second >= LINE){
				cout<<itr->first<<endl;
				flg = true;
			}
		}
		if(!flg){
			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,int> mp;
        vector<int> v;
        
        for(int i=0; i<n; i++){
            int e,p,q;
            cin>>e>>p>>q;
            if(!mp[e])
                v.push_back(e);
            
            mp[e]+=p*q;
            
        }
        
        bool flg=false;
        
        for(int i=0; i<v.size(); i++){
            if(mp[v[i]]>=1000000){
                flg=true;
                cout<<v[i]<<endl;
            }
            else if(!flg){
                cout<<"NA"<<endl;
            }
        }
    }
    
    return 0;
}

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

std::vector<std::string> split(const std::string& ref,const char c){
std::vector<std::string> res;
size_t current=0, found;
while((found=ref.find_first_of(c,current))!=std::string::npos){
res.push_back(std::string(ref,current,found-current));
current=found+1;
}
res.push_back(std::string(ref,current,ref.size()-current));
return res;
}

int main(void){

int it_num;
std::string str;
std::vector<std::string> ref;
std::vector<int> res;

std::cin >> it_num;
while(it_num!=0){
for(int i=0;i<it_num;i++){
std::getline(std::cin,str);
ref=split(str," ");
if(std::stoi(ref[1])*std::stoi(ref[2])>=1000000){
res.push_back(ref[0]);
}
}
std::cin >> it_num
}
for(int j=0;j<res.size();j++){
std::cout << res[j] << std::endl;
}

return 0;
}

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

int main(){
	int total[4000],n,a,b,c;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		memset(total,0,sizeof(total));
		while(n--){
			scanf("%d%d%d",&a,&b,&c);
			total[a-1]=total[a-1]+b*c;
		}
		int res=0;
		for(int i=0;i<4000;i++){
			if(total[i]>=1000000){
				res=1;
				printf("%d\n",i+1);
			}
		}
		if(res) continue;
		else printf("NA\n");
	}
}

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

int main(){
	long long n,a,b;
	bool flag;
	int number;
	map<int,long long> info;
	vector<int> seq;
	
	while(cin >> n && n){
		info.clear();
		seq.clear();
		while(n--){
			cin >> number >> a >> b;
			if(!info[number])seq.push_back(number);
			info[number] += a*b;
		}
		flag = true;
		for(int i=0;i<seq.size();i++){
			if(info[seq[i]]>=1000000){
				flag = false;
				cout << seq[i] << endl;
			}
		}
		if(flag)cout << "NA" << endl;
	}
}

C++: #include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	long long int g[1001],s[1001],d[1001],f[1001];
	int j,i,k,a,h[1001];
	while(1){
		scanf("%d",&a);
		if(a==0) break;
		for(i=0;i<a;i++){
			scanf("%lld %lld %lld",&s[i],&d[i],&f[i]);
			g[i]=d[i]*f[i];
		}
		for(i=0;i<a;i++) h[i]=0;
		for(i=0;i<a;i++){
			for(j=i+1;j<a;j++){
				if(g[i]>=1000000&&h[i]==0){
					h[i]=1;
				}
				if(s[i]==s[j]){
					if(h[i]==0){
						g[i]+=g[j];
						g[j]=0;
					}
					else g[j]=0;
				}
				if(g[i]>=1000000&&h[i]==0){
					h[j]=1;
				}
			}
		}
		k=0;
		for(i=0;i<a;i++){
			if(h[i]==1){
				printf("%lld\n",s[i]);
				k=1;
			}
		}
		if(k==0) printf("NA\n");
	}
	return 0;
}

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

int main() {
	int n,id,i,f,a,b,da[4001],jun[4001];
	while (cin >> n) {
		if (n==0) break;
		memset(da,-1,sizeof(da));
		for (i=0;i<n;i++) {
			cin >> id >> a >> b;
			if (da[id]==-1) { jun[i]=id; da[id]=0; }
			da[id]+=a*b;
		}
		f=0;
		for (i=0;i<n;i++) if (da[jun[i]]>=1000000) { cout << jun[i] << endl; f=1; }
		if (f==0) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main() {
    int n;
    while(cin>>n){
        if(n==0)break;
        queue<int> output;
        ll man[5000]={};
        rep(i,n){
            int a,b,c;
            cin>>a>>b>>c;
            if(man[a]==0){
                output.push(a);
            }
            man[a]+=b*c;
        }
//        while(output.size()){cout<<output.front();output.pop();}
        bool flag=true;
        while(output.size()){
            if(man[output.front()]>=1000000){
                cout<<output.front()<<endl;
                flag=false;
            }
            output.pop();
        }
        if(flag)cout<<"NA"<<endl;
    }
    
    return 0;
}

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

using namespace std;

struct data{
  int id;
  long  price;
  long  amount;
  long long rate;
};

int main(){
  int n=0;
  while(1){
    cin>>n;
    if(n==0){return 0;}
    vector<struct data> data(n);
    int c=0;
    for(int i=0;i<n;i++){
      scanf("%d %l %l",&data[i].id,&data[i].price,&data[i].amount);
      data[i].rate=data[i].price*data[i].amount;
    }
    vector<struct data> res(n);
    for(int i=0;i<n;i++){
      res[i].id=0;
      res[i].rate=0;
    }
    for(int i=0;i<n;i++){
      int find=0;
      for(int j=0;j<i;j++){
	if(data[i].id==res[j].id){
	  res[j].rate+=data[i].rate;
	  find=1;
	  break;
	}
      }
      if(find==0){
	res[i].id=data[i].id;
	res[i].rate=data[i].rate;
      }
    }
    for(int i=0;i<n;i++){
      if(res[i].id!=0&&res[i].rate>=1000000){
	cout<<data[i].id<<"\n";
	c++;
      }
    }
    if(c==0){
      cout<<"NA\n";
    }
  }
  return 0;
}