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

int main(){
	int n;

	while(true){
		int user[4000];
		int usercount = 0;
		
		cin >> n;
		if(n == 0){
			break;
		}

		int buf[3];
		for(int i=0;i<n;i++){
			cin >> buf[0] >> buf[1] >> buf[2];
			if(buf[1] * buf[2] >= 1000000){
				user[usercount] = buf[0];
				usercount++;
			}
		}

		for(int i=0;i<usercount;i++){
			cout << user[i] << endl;
		}
		if(usercount == 0){
			cout << "NA" << endl;
		}
	}
}

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

int main(){

  int num, v, n, m, len, cnt;
  vector<int> vc[2];

  while(cin >> n){
    if(n == 0) break;
    vc[0].clear();
    vc[1].clear();
    len = 0;

    for(int i=0; i<n; i++){
      cin >> num >> v >> m;
      for(int j=0; j<=len; j++){
        if(j == len){
          vc[0].push_back(num);
          vc[1].push_back(v * m);
          len++;
          break;
        }
        if(vc[0][j] == num){
          vc[1][j] += v * m;
          break;
        }
      }
    }
    
    cnt = 0;
    for(int i=0; i<len; i++){
      if(vc[1][i] >= 1000000){
        cout << vc[0][i] << endl;
        cnt++;
      }
    }
    if(cnt == 0) cout << "NA" << endl;

  }

  return 0;

}

C++: #include <iostream>
using namespace std;
int main(){
    long long bangou,tanka,kosuu;
    long long number; cin >> number;
    long long kuso[number];
    do{
        long long man[4000];
        for(int i=0;i<4000;i++){
            man[i]=0;
        }
        for(int i=0;i<number;i++){
            kuso[i]=0;
        }

        for(int i=0;i<number;i++){
            cin >> bangou >> tanka >> kosuu;
            man[bangou-1] += tanka*kosuu;
            kuso[i]=bangou;
        }
        int count =0;
        if(man[kuso[0]-1]>=1000000){
            cout << kuso[0] << endl;
            count++;
        }
        for(int i=1;i<number;i++){
            int tmp =0;
            for(int j=0;j<i;j++){
                if(kuso[i]==kuso[j]){
                    tmp++;
                    break;
                }
            }
            if(tmp==0 && man[kuso[i]-1]>=1000000){
                cout << kuso[i] << endl;
                count++;
            }
        }
        if(count==0)
            cout<< "NA" << endl;
        cin >> number;
    }while(number !=0);

}

C++: #include<cstdio>
#include<algorithm>
#include<iostream>
#include<functional>
using namespace std;
long long int p[114514],x,y,z,w;
int main(void)
{
	int i,j,k,f,n,cnt;
	while(1) {
		cin>>n;
		f=0,cnt=0;
		if(!n)break;
		for(i=0;i<4001;i++) p[i]=0;
		for(i=0;i<n;i++) {
			cin>>x>>y>>z;
			w=y*z;
			p[x]+=w;
		}
	
		for(i=0;i<4001;i++) {
			if(p[i]>=1000000) {
				cout<<i<<endl;
				f=1;
			}
		}
		if(f==0) cout<<"NA"<<endl;
	}
	return 0;
}

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

int main(){
	int a,hoge;
	bool flag;
	while(1){
		cin >> a;
		if(a == 0) break;
		int number[a];
		int tanka[a];
		int ryo[a];
		int gokei[a];
		flag = false;
		for(int i=0;i<a;i++){
			cin >> number[i] >> tanka[i] >> ryo[i];
			gokei[i] = tanka[i] * ryo[i];
			if(gokei[i] >= 1000000){
				cout << number[i] << endl;
				flag = true;
			}
		}
		if(flag == false) cout << "NA" << endl;
	}
	return 0;
}

C++: #include<stdio.h>
int main(void){
	int n,i,j,b;
	int a,suu;
	long long int syain[4001];
	int zyun[4001];
	int flg=0;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=1;i<=4000;i++){
			syain[i]=0;
			zyun[i]=0;
		}
		int cnt=1;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&a,&b,&suu);
			syain[a]+=(b*suu);
			if(zyun[a]==0){
				zyun[a]=cnt;
				cnt++;
			}
		}
/*		for(i=1;i<=4000;i++){
			if(zyun[i]!=0){
				printf("%d=%d %d\n",i,zyun[i],syain[i]);
			}
		}
*/		flg=0;
		for(i=1;i<=cnt;i++){
			for(j=1;j<=4000;j++){
				if(zyun[j]==i && syain[j]>=1000000){
					printf("%d\n",j);
					flg=1;
				}
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0; 
}

C++: #include<iostream>
#include<map>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    map <int,int> com;
    bool f = false;
    while(n--){
      int a,b,c;
      cin >>a>>b>>c;
      if(com[a]+b*c>1000000){com[a] = 1000000;}
      else{com[a]+=b*c;}
    }
    map<int,int>::iterator m;
    for(m=com.begin();m!=com.end();m++){
      if((m->second)>=1000000){cout <<m->first<<endl;f = true;}
    }
    if(!f){cout <<"NA"<<endl;}
  }
  return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long int aa[10000]={0},x=0,y=0,z=0,flg=0,a;
    while(cin>>a)
    {
        if(a==0)break;
        for(int i=0;i<a;i++)
        {
            cin>>x>>y>>z;
            aa[x]+=y*z;
        }
        for(int i=0;i<4010;i++)
        {
            if(aa[i]>=1000000)
            {
                flg=1;
                cout<<i<<endl;
            }
        }
        if(flg==0)cout<<"NA"<<endl;
        for(int i=0;i<4010;i++)
        {
            aa[i]=0;
            flg=0;
        }
    }
    return 0;
}

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

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		set<int> Set;
		vector<int> num;
		map<int, unsigned long long int> Map;
		while(n--)
		{
			unsigned long long int a, b, c;
			cin >> a >> b >> c;
			if(Set.find(a) == Set.end())
			{
				num.push_back(a);
			}
			Set.insert(a);
			Map[a] += b * c;
		}
		bool exist_flag = false;
		for(int i = 0; i < num.size(); ++i)
		{
			if(Map[num[i]] >= 1000000)
			{
				cout << num[i] << endl;
				exist_flag = true;
			}
		}
		if(!exist_flag)
		{
			cout << "NA" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
#include <string.h>

#define X first
#define Y second
#define MP make_pair
typedef long long ll;
using namespace std;
const int MAX = 101;

template<class T, class U>
void convert(T &t, U &u){
	stringstream ss;
	ss << t;
	ss >> u;
}

int main(){
	int n;
	while(cin >> n && n!=0){
		map<int, ll> ans;
		int id, price, num;
		for(int i = 0; i < n; i++){
			cin >> id >> price >> num;
			ans[id] += price*num;
		}

		vector<int> ans_id;
		for(map<int, ll>::iterator it = ans.begin(); it != ans.end(); it++){
			if(it->second>=1000000) ans_id.push_back(it->first);
		}
		if(ans_id.size()==0){
			cout << "NA" << endl;
		}else{
			for(int i = 0; i < ans_id.size(); i++){
				cout << ans_id[i] << endl;
			}
		}
	}
	return 0;
}