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<map>
#include<iostream>
using namespace std;
int main(){
        map<int,int> total;
        int d,num,item,ko;
        while(cin>>d){
                if(d==0) break;
                for(int i=0;i<d;i++){
                        cin>>num>>item>>ko;
                        item *= ko;
                        //cout<<item<<endl;
                        if(item>=1000000){
                                total.insert(make_pair(num,item));
                        }
                }
                if(total.size()==0) cout<<"NA"<<endl;
                else{
                        map<int,int>::iterator it;
                        for(it=total.begin();it!=total.end();it++){
                                cout<<(*it).first<<endl;
                        }
                        total.clear();
                }
        }
}

C++: #include<map>
#include<iostream>
using namespace std;
int main(){
	map<int,int> total;
	int d,num,item,ko,cont=0;
	while(cin>>d){
		if(d==0) break;
		cin.ignore();
		for(int i=0;i<d;i++){
			cin>>num>>item>>ko;
			item *= ko;
			if(item>=1000000){
				cont++;
				total.insert(make_pair(cont,num));
			}
		}
		if(total.size()){
			map<int,int>::iterator it;
			for(it=total.begin();it!=total.end();it++){
				cout<<(*it).second<<endl;
			}
		}
		else cout<<"MA"<<endl;
		cont=0;
		total.clear();
	}
}

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

int n,num,flag;
long int shine[4000],tannka,kosu;

int main(){
	while(1){
		cin>>n;
		if(n==0){break;}
		for(int i=0;i<n;i++){
			cin>>num>>tannka>>kosu;
			shine[num]+=tannka*kosu;
			if(shine[num]>=1000000){
				cout<<num<<endl;
				flag++;
			}
		}
		if(flag==0){cout<<"NA"<<endl;}
		else{flag=0;}
		for(int i=0;i<4000;i++){
			shine[i]=0;
		}
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    unsigned long long a[5000]={0},c=0,p,o,u;
    rep(i,5000)cout<<a[i];
    rep(i,n){
      cin>>p>>o>>u;
      a[p]+=o*u;
      if(a[p]>=1000000){cout<<i<<endl;c++;}
    }
    if(!c)cout<<"NA"<<endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
  int n;
  //mlÛ¶vÛ¶
  int a,b,c;
  //aÔbP¿cÊ
  int f;
  while(cin>>n,n){
		map<int,long long> m;
		vector<int> v;
		f=1;
    for(;n;n--){
      std::cin>>a>>b>>c;
      if(!m[a])v.push_back(a);
      m[a] += b*c;
    }
    
    for(int i=0;i<v.size();i++){
      if(m[v[i]]>=1000000){
				f=0;
				cout<<v[i]<<endl;}
    }
    if(f)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<bits/stdc++.h>
using namespace std;

int main(){
  
  while(1){
  
    int n,no[4002],unit,qua;
    int emp[4002]={0};
    int empflag[4002]={0};
    
    scanf("%d",&n);
    
    if(n==0)break;
    for(int i=0;i<n;i++){
      scanf("%d %d %d",&no[i],&unit,&qua);
      emp[no[i]]+=unit*qua;	
    }
    
    sort(no,no+n);

    int flag=0;
    for(int i=0;i<n;i++){
      if(emp[no[i]]>=1000000 && empflag[no[i]]==0){
	printf("%d\n",no[i]);
	flag=1;
	empflag[no[i]]=1;
      }
    
    }
    
    if(flag==0)printf("NA\n");
  }
  return(0);
}

C++: #include <iostream>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long ll;
struct P{
	int id;
	int tanka;
	int kosuu;
};

int main()
{
	int n;

	while (cin >> n && n ){
		vector<P> data (n );
		rep (i, n ){
			cin >> data[i].id >> data[i].tanka >> data[i].kosuu;
		} // end rep
		bool found = false;
		rep (i, n ){
			ll total = (ll)data[i].tanka*data[i].kosuu;
			if (total >= 1000000LL ){
				cout << data[i].id << endl;
				if (!found )
					found = true;
			} // end if
		} // end rep
		if (!found ){
			cout << "NA" << endl;
		} // end if
	} // end loop
		
	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;

const ll MAX = 1000000;

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

C++: #include<stdio.h>

int main(){

	int n, i, x[4000] = {}, xx[4000] = {}, xxx[4000] = {}, r, y = 0, w;
	scanf("%d", &n);
	for (w = 0; w < n; w++){

		for (i = 0; i < n; i++){
			scanf("%d %d %d",&x[i],&xx[i],&xxx[i]);
		}
		for (r = 0; r < 4000; r++){
			if (xx[r] * xxx[r] > 1000000){
				printf("%d\n", x[r]);
			}	
		}if (y == 0){ printf("NA"); (y = 0); }		scanf("%d", &n);
	}
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <vector>
#include <utility>
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;


int main() {
	int n;
	while(scanf("%d\n", &n), n){
		vector<pair<int, ll>> v;
		vector<int> id, p, q;
		rep(i,n) {
			int x, y, z;
			cin >> x >> y >> z;
			id.push_back(x);
			p.push_back(y);
			q.push_back(z);
		}
		rep(i,n) {
			bool flag = false;
			for(int j = 0; j < v.size(); ++j) {
				if(v[j].first == id[i]) {
					v[j].second += p[i] * q[i];
					flag = true;
					break;
				}
			}
			if(!flag) {
				v.push_back(make_pair(id[i], (ll)p[i] * q[i]));
				}
		}
		bool flag = false;
		for(int j = 0; j < v.size(); ++j) {
			if(v[j].second >= 1000000) {
				flag = true;
				cout << v[j].first << endl;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
	return 0;
}