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<cstdio>
#include<vector>
#include<map>

using namespace std;

int main()
{
    while(1){
        int n;
        scanf(" %d",&n);
        if(n==0)break;

        vector<int> bangoulist;
        map<int,long> alldata;
        alldata[4001]=0;
        for(int i=0;i<n;i++){
                int bangou,tanka,num;
                scanf(" %d %d %d",&bangou,&tanka,&num);
                if(alldata.find(bangou)!=alldata.end()){
                        alldata[bangou]+=tanka*num;
                }else{
                        bangoulist.push_back(bangou);
                        alldata[bangou]=tanka*num;
                }
        }
        bool flag=true;
        for(int i=0;i<(int)bangoulist.size();i++){
                if(alldata[bangoulist[i]]>=1000000){
                        cout<<bangoulist[i]<<"\n";
                        flag=false;
                }
        }
        if(flag)cout<<"NA\n";
    }
    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++){
			cid=(int)0;
			price=num=(long long int)0;
			scanf("%d",&cid);
			scanf("%lld",&price);
			scanf("%lld",&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 <iostream>
#include <cstdio>
#include <vector>
#include <map>
using namespace std;
typedef long long int ll;
int main(){
  ll n;
  while( cin >> n,n ){
    ll ma[4001] = {0};
    vector<ll>ve;
    ve.clear();
    for(ll k = 0 ; k < n ; k++ ){
      ll a,b,c;
      cin >> a >> b >> c;
      if(ma[a] == 0)ve.push_back(a);
      ma[a] += b*c;
    }
    int f = 1;
    for(vector<ll>::iterator it = ve.begin() ; it != ve.end() ; it++ ){
      if(ma[(*it)] >= 1000000 ){
	cout << (*it) << endl;
	f = 0;
      }
    }
    if(f)cout << "NA" << endl;
  }
  return 0;
}

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

int main(void)
{
	int n, num;
	string str;
	long a;
	
	while (cin >> n, n){
		map <string, long long> m;
		for (int i = 0; i < n; i++){
			cin >> str >> num >> a;
			m[str] += (num * a);
		}
		map <string, long> ::iterator it;
		bool flag = true;
		/*
		for (it = m.begin(); it != m.end(); it++){
			cout << it->first << " -- " << it->second << endl;
		}*/
		
		for (it = m.begin(); it != m.end(); it++){
			if (1000000 <= it->second){
				cout << it->first << endl;
				flag = false;
			}
		}
		if (flag) cout << "NA" << endl;
	}
	
	return 0;
}

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

int main()
{

  unsigned long f=0;
  unsigned long x, y, z, i=0;
  unsigned long a[4010];
  unsigned long b[4010];
  unsigned long c[4010];
  unsigned long s[4010];
 
  while(1){
    z=0;
    cin>>x;
    if(x==0)
      break;
    
    for(y=0; y<x; y++)
      cin>>a[y]>>b[y]>>c[y];

    for(y=0; y<x; y++)
	s[y]=a[y];

    for(y=0; y<x-1; y++)
      for(i=y+1; i<x; i++)
	if(a[y]==s[i]){
	  b[y]+=b[i];
	  c[y]+=c[i];
	  b[i]=0;
	  c[i]=0;
	}

    for(y=0; y<x; y++){
      if(1000000<=b[y]*c[y]){
	z++;
	cout<<a[y]<<endl;
      }
    }
      
    
    if(z==0)
      cout<<"NA"<<endl;

  }

  return 0;
}

C++: #include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	for (int j = 0; j < 50; j++)
	{
		long n,e[4000],x[4000],y[4000],co[100];

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

		for (int i = 0; i < n; i++)
		{
			cin >> e[i] >> x[i] >> y[i];
		}

		for (int i = 0; i < n; i++)
		{
			co[i] = 0;
			for (int k = 0; k < n; k++)
			{
				if (i <= k && e[i] == e[k])
				{
					co[i] += x[k] * y[k];
					if (i != k)
					{
						e[k] = -1;
					}
				}
			}
		}
	int gg = 0;
		for (int i = 0; i < n; i++)
		{
			if (e[i] != -1 && co[i] >= 1000000)
			{	gg += -1;
				cout << e[i] << endl;
			}
			if (i == n - 1 && gg == 0)
			{
				cout << "NA" << endl;
			}
		}
	}
}

C++: #include<stdio.h>
int main(void)
{
	int n=1;
	int i=0,j=0;
	int tanka[4001]={0};
	int flg=0;
	int uriage[4001]={0};
	int bangou[4001]={0};
	int ccc=0;
	int goukei[4001]={0};
	while(n!=0)
	{
		flg=0;
		ccc=0;
		scanf("%d",&n);
		if (n==0)
		{
			break;
		}
		for (i=1;i<=n;i++)
		{
			ccc++;
			scanf("%d %d %d",&bangou[ccc],&tanka[ccc],&uriage[ccc]);
			goukei[ccc]=tanka[ccc]*uriage[ccc];
			for (j=0;j<ccc;j++)
			{
				if (bangou[ccc]==bangou[j])
				{
					goukei[j]+=tanka[ccc];
					goukei[j]+=uriage[ccc];
					ccc--;
				}
			}
		}
		for (i=1;i<=ccc;i++)
		{
			if (goukei[i]>=1000000)
			{
				printf("%d\n",bangou[i]);
				flg=1;
			}
		}
		if (flg==0)
		{
			printf("NA\n");
		}
	}
return 0;
}

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

int main(){
	int N;
	
	while(cin>>N,N){
		map<int,long long int> mp;
		vector <int> vi;
		queue<int >q;
		for(int i=0;i<N;i++){
			int num,tanka,suuryo;
			cin>>num>>tanka>>suuryo;
			if(mp[num]==0){
				vi.push_back(num);
			}
			mp[num]+=tanka*suuryo;
		}
		vector<int>::iterator it=vi.begin();
		for(;it!=vi.end();it++){
			if(mp[*it]>1000000){
				q.push(*it);
			}
		}
		if(q.empty()){
			cout<<"NA"<<endl;
		}
		else{
			int len=q.size();
			for(int i=0;i<len;i++){
				cout<<q.front()<<endl;
				q.pop();
			}
		}
	}
	return 0;
}

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

const long long BORDER = 1000000;

using namespace std;

int main() {
  bool f;
  int i, j, n, number;
  vector< map<int, long long> > datas;
  long long price, amount;
  map<int, long long>::iterator it;
  while(cin >> n) {
    if (n == 0) break;
    
    map<int, long long> m;

    for (i = 0; i < n; i++) {
      cin >> number >> price >> amount;
      it = m.find(number);
      if (it != m.end())
        it->second += price * amount;
      else
        m.insert(pair<int, long long>(number, price * amount));
    }

    datas.push_back(m);
  }

  for (i = 0; i < datas.size(); i++) {
    for (it = datas[i].begin(), f = false; it != datas[i].end(); it++) {
      if (it->second >= BORDER) {
        f = true;
        cout << it->first << endl;
      }
    }
    if (!f) cout << "NA" << endl;
  }
  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;
}