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>
using namespace std;

int main()
{
	int n;
	int ans[4000];
	
	for(;;)
	{
		cin >> n;
		if(n==0)
			break;
		int i,j;
		for(i=0,j=0;i<n;i++)
		{
			int num[4000];
			int flag=1;
			double a[4000],b[4000];
			cin >> num[i] >> a[i] >> b[i] ;
			for(int l=0;l<i;l++)
			{
				if(num[l]==num[i])
				{
//					cout << "in" << endl;
					a[i]+=a[l];
					b[i]+=b[l];
				}
			}
			if(a[i]/10000.0*b[i]>=100.0)
			{
				for(int k=0;k<j;k++)
				{
					if(ans[k]==num[i])
						flag=0;
				}
				if(flag==1)
				{
					ans[j]=num[i];
					j++;
				}
			}
		}
		
		if(j!=0)
		{
			for(int i=0;i<j;i++)
			{
				cout << ans[i] << endl;
			}
		}
		else
			cout << "NA" << endl;
	}
}

C++: #include <cstdio>
#include <map>
using namespace std;
typedef long long ll;
 
int n;
 
int main(){
	while(scanf("%d", &n),n){
		map<int,ll> m;
		map<int,ll>::iterator it;
		for(int i = 0; i < n; i++){
			int x; ll p, q;
			scanf("%d%lld%lld", &x, &p, &q);
			m[x] += p*q;
		}
		bool ok = true;
		for(it = m.begin(); it != m.end(); it++){
			ll s; int f; s = it->second; f = it->first;
			if(s >= 1000000){
				ok = false;
				printf("%d\n", f);
			}
		}
		if(ok) printf("NA\n");
	}
	return 0;
}

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

using namespace std;

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

typedef long long ll;

int main(){
    int n;
    map<string, ll> data;
    vector<string> id;
    while (cin >> n && n){
        id.clear();
        data.clear();
        rep(i, n){
            string a;
            ll b, c;
            cin >> a >> b >> c;
            if (data.count(a)){
                data[a] = c*b;
                id.push_back(a);
            }
            else{
                data[a] += c*b;
            }
        }

        bool NA = true;
        rep(i, id.size()){
            if (data[id[i]] >= 1000000){
                cout << id[i] << endl;
                NA = false;
            }
        }
        if (NA)
            cout << "NA" << endl;

    }
    return 0;
}

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

const int lim = 1000000;

int main()
{
    int n; long long en, price, qty;

    while(cin >> n && n) {
        int check[4001] = {0}; queue<int> que;

        for(int i=0; i < n; ++i) {
            cin >> en >> price >> qty;

            if (check[en] >= lim) continue;
            if (check[en] >= 0) check[en] += price*qty;
            if (check[en] >= lim) {
                que.push(en);
                check[en]=-1;
            }
        }

        if (que.empty()) cout << "NA" << endl;
        else {
            while(!que.empty()) {
                cout << que.front() << endl;
                que.pop();
            }
        }
    }

    return 0;
}

C++: #include <iostream>
#include <map>
using namespace std;
map<int,long long> sl;
int order[4000];
int main()
{
    int n;
    while(1)
    {
        cin>>n;if(!n)return 0;
        int count=0;
        int od=0;
        sl.clear();
        for(int i=0;i<n;++i){
            int sn;
            long long t,v;
            cin>>sn>>t>>v;
            map<int,long long>::iterator it=sl.find(sn);
            if(it==sl.end()){
                order[od++]=sn;
                sl.insert(make_pair(sn,t*v));
            }
            else it->second+=t*v;
        }
        for(int i=0;i<od;++i){
            if(sl[order[i]]>=1000000){cout<<order[i]<<endl;++count;}
        }
        if(!count)cout<<"NA"<<endl;
    }
}

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

struct data{
	int id;
	int value;
	int num;
};

int main(){
	int n;
	int need;
	while(cin >> n){
		if(n == 0) break;
		int count = 0;
		for(int i = 0; i < n; i++){
			data d;
			cin >> d.id >>
				d.value >> d.num;
			if(d.value){
				need = 1000000 % d.value == 0 ? 1000000 / d.value : 1000000 / d.value + 1;
				if(d.num >= need){
					cout << d.id << endl;
					count++;
				}
			}
		}
		if(!count) cout << "NA" << endl;
	}
	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,int> mp,mp2;
		vector <int> vi;
		priority_queue<int, vector<int>, greater<int> >pq;
		for(int i=0;i<N;i++){
			int num,tanka,suuryo;
			cin>>num>>tanka>>suuryo;
			mp[num]+=tanka*suuryo;
			vi.push_back(num);
			if(mp[num]>=1000000){
				mp2[num]++;
			}
		}
		vector<int>::iterator it=vi.begin();
		for(;it!=vi.end();it++){
			if(mp2[*it]>=2){
				mp2[*it]--;
			}
			else if(mp2[*it]==1){
				pq.push(*it);
				mp2[*it]--;
			}
		}
		if(pq.empty()){
			cout<<"NA"<<endl;
		}
		else{
			int len=pq.size();
			for(int i=0;i<len;i++){
				cout<<pq.top()<<endl;
				pq.pop();
			}
		}
	}
	return 0;
}

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



int main(){
	
	int n , id , price , num, cnt;
	while(1){
		vector<int> p(4001,0);
		vector<int> a;
		cin >> n;
		if(n==0) break;
		while(n--){
			cin>>id>>price>>num;
			if(find(a.begin(),a.end(),id)==a.end()) a.push_back(id);
			p[id]+=price*num;
			}
		cnt=0;	
		for(int i=0;i<a.size();i++){
			if(p[a[i]]>=1000000) cout << a[i] << endl; cnt++;
		}
		if (cnt==0) cout << "NA" << endl;
	}
		return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,num,mon,cont,a[4000],nacount;
  while(scanf("%d",&n)!=EOF){
    if(n==0){break;}
    for(int i=0;i<4000;i++){
      a[i]=0;
    }
    nacount=0;
    for(int i=0;i<n;i++){
      cin>>num>>mon>>cont;
      a[num]+=mon*cont;
    }
    for(int i=0;i<3999;i++){
      if(a[i]>=1000000){
	cout<<i<<endl;
	nacount++;
      }
    }if(nacount==0){
      cout<<"NA"<<endl;
    }
  }
  return 0;
}

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

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

int num[4001][2];

int main(){
  int n,i,j,id,l,m;
  while(cin>>n){
    if(n==0)break;
    for(i=0;i<n;i++){
      cin>>id;
 	 if(num[id][0]==0){  
	   num[id][0]=id;  
	   cin>>num[id][0]>>num[id][1];}
	 else{
	   cin>>l>>m;
	   num[id][0]+=l;
	   num[id][1]+=m;
	 }
    }
    int c=0;
    for(i=1;i<=4000;i++){
      if(num[i][0]==0&&num[i][1]==0)continue;
      if(num[i][0]*num[i][1]>=1000000){cout<<i<<endl;c++;
      }
	num[i][0]=0;
	num[i][1]=0;
    }
    if(c==0)cout<<"NA"<<endl;
  }
  return 0;
}