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>
#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 n;

int main() {
	cin >> n;
	if(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) {
			vector<pair<int, ll>>::iterator it = v.begin();
			for(; it != v.end(); ++it) {
				if((*it).first == id.at(i)) {
					(*it).second += p.at(i) * q.at(i);
					break;
				}
			}
			if(it == v.end()) {
				v.push_back(make_pair(id.at(i), (ll)p.at(i) * q.at(i)));
				}
		}
		bool flag = false;
		for(vector<pair<int, ll>>::iterator it = v.begin(); it != v.end(); ++it) {
			if((*it).second >= 1000000) {
				flag = true;
				cout << (*it).first << endl;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <stdio.h>
int main(){
    int n,a[5000],m,p,q;
    bool b[5000],f;
    while(1){
        scanf("%d",&n);
        if(n==0)return 0;
        for(int i=0;i<5000;i++)a[i]=b[i]=0;
        f=false;
    for(int i=0;i<n;i++){
        scanf("%d%d%d",&m,&p,&q);
        if(!b[m]){
            a[m]+=p*q;
            if(a[m]>=1000000){
                b[m]=true;
                f=true;
                printf("%d\n",m);
            }
        }
    }
        if(!f)printf("NA\n");
    }
}

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

using namespace std;

struct data{
  int id;
  int price;
  int amount;
  int 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 %d %d",&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;
    }
    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;
}

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

class meb{
public:
	int num;
	int tanka;
	int count;
};

int main(){
	int n,m,t,c;
	while(1){
		int cc=0;
		cin>>n;
		meb st[n];
		if(n==0)return 0;
		for(int i=0;i<n;i++){
			cin>>st[i].num>>st[i].tanka>>st[i].count;
		}
		for(int j=0;j<n;j++){
			if((st[j].tanka)*(st[j].count)>=1000000)cout<<st[j].num<<endl;
			else cc++;
		}
		if(cc==n)cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int data[2][10000],n,i,f,id,a,b;
  while(1){
    cin>>n;
    if(n==0) break;
    for(i=0; i<10000; i++) data[0][i]=0,data[1][i]=0;
    for(i=0;i<n;i++){
      cin>>id>>a>>b;
      for(f=0;f<i+1;f++){
	if(data[0][f]==id){
	  data[1][f]+=a*b,f=-1;
	  break;
	}else if(data[0][f]==0){
	  data[0][f]=id;
	  data[1][f]=a*b;
	  break;
	}
      }
    }
    for(i=0,f=0;i<n;i++)
      if(data[1][i]>999999)cout<<data[0][i]<<"\n",f=1;
    if(f==0)cout<<"NA"<<"\n";
  }
}

C++: #include<cstdio>
using namespace std;
int main(){
    int n;

    while(scanf("%d",&n),n){

        long long int mem[4500][3] = {{0}};
        int a,x,y;
        int cnt = 0;

        for(int i = 0;i < n; i++){
            scanf("%d%d%d",&a,&x,&y);
            for(int j = 0;j < i; j++){
                if(mem[j][1] != a){
                   cnt++;
                }
                else {
                    mem[j][0] += x*y;
                    break;
                }
            }
            if(cnt == i){
                mem[i][0] += x*y;
                mem[i][1] = a;
                cnt = 0;
            }
        }
        //for(int i = 0;i < n; i++)printf("%lld: %lld\n",mem[i][0],mem[i][1]);
        bool flg = 0;
        for(int i = 0;i < n; i++){
            if(mem[i][0] >= 1000000){
                printf("%lld\n",mem[i][1]);
                flg = 1;
            }
        }
        if(flg == 0)printf("NA\n");
    }
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int n, m;

    while(cin >> n, n){
        long long v[4010];
        rep(j, 4010) v[j] = 0;
        rep(p, n){
            int a, b, c;
            cin >> a >> b >> c;
            v[a] += b*c;
        }
        bool isP = false;
        rep(i, 4010) if(1000000 <= v[i]){isP = true; cout << i << endl;}
        if(!isP) cout << "NA" << endl;
}
}

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

std::vector<std::string> split(const std::string& ref,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<map>
#include<iostream>
using namespace std;
int main()
{
    map<int,int> total;

	int d,num,item,ko,cont=0;
	bool ok;

	while(cin>>d, d)
	{
		for(int i=0;i<d;i++)
		{
			cin>>num>>item>>ko;
			item *= ko;
			if(total.count(num))
			{
				total[num] += item;
			}
			else
			{
				total.insert(make_pair(num, item));
			}
		}

		ok = false;
		map<int,int>::iterator it;
		for(it = total.begin(); it != total.end(); it++)
		{
			if((*it).second >= 1000000)
			{
				cout << (*it).first <<endl;
				ok = true;
			}
		}

		if(ok == false)
		{
			cout<<"NA"<<endl;
		}
		
		total.clear();
	}
}

C++: #include "stdio.h"
#include "string.h"
long long N[4001];
int f[4001];
int main(){
    int x,n,p,i,j,c=0;
    scanf("%d",&i);
    while(i>0){
        c=0;
        for(j=0;j<i;j++){
            scanf("%d%d%d",&x,&n,&p);
            if(N[x]>=0){
                N[x]+=n*p;
                if(N[x]>=1000000){
                    f[c]=x;
                    c++;
                    N[x]=-1;
                }
            }
        }
        if(c<1){
            printf("NA\n");
        }else{
            for(j=0;j<c;j++)printf("%d\n",f[j]);
        }
        for(j=0;j<4001;j++){
            N[j]=0;
            f[j]=0;
        }
        scanf("%d",&i);
    }
    return 0;
}