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

#define TAR 1000000

int main() {
	int n,num,ch;
	unsigned long t,k;
	while(cin >> n){
		ch = 0;
		while(n){
			scanf("%d %ld %ld",&num,&t,&k);
			if((t!=0)&&(k!=0)){
				if((k > TAR/t)&&(t > TAR/k)){
					cout << num << endl;
					ch++;
				}else if((t >= TAR/k)&&(TAR%k == 0)){
					cout << num << endl;
					ch++;
				}else if((k >= TAR/t)&&(TAR%t == 0)){
					cout << num << endl;
					ch++;
				}
				if(((--n)==0)&&(ch==0)){
					cout << "NA" << endl;
				}
			}
		}
	}
	return 0;
}

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

int in;
cin >> in
int p[in][in * 3],i,ii,c = 0,uri[in],k;	
	for(i = 1;in >= i;i++){ cin >> p[i][0] >> p[i][1] >> p[i][2];uri[i] = 0;}	
	for(i = 1;in >= i;i++){
		for(ii = 1;in >= ii;ii++){if(p[i][0] == p[ii][0]){ uri[ii] = uri[ii] + p[i][1] * p[i][2];}}
	}
	for(i = 1;in >= i;i++){
		k = 0;
		for(ii = 1;i > ii;ii++){if(p[i][0] == p[ii][0]){ k = 1;} }		
			if(uri[i] >= 1000000 and k == 0){cout << p[i][0] << endl; c++;} 
	}
	if(c == 0 and in != 0) cout << "NA" << endl;

}

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

main() {
  int n;
  while((cin >> n) && n) {
    map<int, unsigned long long> m;
    vector<int> id;
    for(int i = 0; i < n; ++i) {
      int r, p, q;
      cin >> r >> p >> q;
      if(!m[r]) id.push_back(r);
      m[r] += p*q;
    }
    bool flag = true;
    for(int i = 0; i < id.size(); ++i) {
      if(m[id[i]] >= 1000000) {
	cout << id[i] << endl;
	flag = false;
      }
    }
    if(flag) cout << "NA" << endl;
  }
}

C++: #include<iostream>
#include<map>
#include<vector>
using namespace std;
int main(){
    int n,a,b,c;
    while(cin>>n,n){
        vector<int>V;
        map<int,long long>M;
        while(n--){
            cin>>a>>b>>c;
            if(M[a]==0)V.push_back(a);
            M[a]+=b*c;

        }

        bool flag=true;
        for(int i=0;i<V.size();i++){
            if(M[V[i]]>=1000000){
                flag=false;
                cout<<V[i]<<endl;
            }
        }
        if(flag)cout<<"NA"<<endl;
    }
    return 0;
}

C++: //AOJ 0100
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;
#define MAX_N 100

unsigned long long int a[4001] = {0}, b, i, j, k, ans, n;
char str[1000];

int sort(const void *a, const void *b){
  return *(int*)a - *(int*)b;
}

int main(){
  while(scanf("%lld", &n) != 0){
    if(n == 0) return 0;
    ans = 0;
    for(i = 0; i < 4001; i++)
      a[i] = 0;
    for(i = 0; i < n; i++){
      scanf("%lld %lld %lld", &b, &k, &j);
      if(a[b] >= 1000000) continue;
      a[b] += k * j;
      if(a[b] >= 1000000){
	printf("%d\n", b);
	ans++;
      }
    }
    if(ans == 0) printf("NA\n");
  return 0;
}

C++: #include<cstdio>
#include<cstring>

int main(){
long long int data[4000],n;
scanf("%d",&n);
if(n==0) return 0;
memset(data,0,sizeof(data));
while(n--){
int a
long long int b,c;
scanf("%d%lld%lld",&a,&b,&c);
data[a-1]+=b*c;
}
int k=0;
for(int i=0;i<4000;i++){
if(data[i]>=1000000){
 printf("%d\n",i+1);
 k=1;
  } 
}
if(k==0) printf("NA\n");
}

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

int main(void){
	int n,count=0;
	vector<int> vec1,vec2,vec3,vec4;
	//½l©
	cin >> n;
	//lªf[^üêéæÁ
	for(int i=0;i<n;i++){
		int j,m,l;
		cin >> j >> m >> l;
		vec1.push_back(j);
		vec2.push_back(m);
		vec3.push_back(l);
	}
	//ÊÌ\¦
	for(int i=0;i<n;i++){
		if(vec2[i]*vec3[i]>=1000000){
			cout << vec1[i] << endl;
			count++;
		}
	}
	if(count==0){
		cout << "NA" << endl;
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
#define INT(name) int name; scanf("%d",&name);
#define VINT(name,n) vector<int> name(n); for(int i = 0;i < n;i++) scanf("%d",&name[i]);

using namespace std;

int main(int argc, char const *argv[]){
	vector<int> data(4000);
	int i;
	int a,b,c;
	int max;
	bool check;

	cin >> i;
	while(i){
		data.clear();

		for(int j = 0;j < 4000;j++){
			data[j] = 0;
		}
		for(int j = 0;j < i;j++){
			cin >> a >> b >> c;
			data[a - 1] += b * c;
		}
		check = false;
		for(int k = 0;k < 4000;k++){
			if(data[k] >= 1000000){
				printf("%d\n",k+1);
				check = true;
			}
		}
		if(!check) printf("NA\n");
		cin >> i;
	}

	return 0;
}

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

int main() {
  int n,ID,price,quantity,sales[4001] = {0},check,k,kaburi,rep[4001];
  while(cin >> n) {
    int sales[4001] = {0};
    if(n == 0) break;
    check = 0;k=0;
    for(int i=0;i<n;i++) {
      cin >> ID >> price >> quantity;
      //      cout << ID << " " << price << " " << quantity << endl;
      sales[ID] += price * quantity;
      kaburi = 0;
      for(int j=0;j<k;j++) {
        if(rep[j] == ID) {
          kaburi = 1;
        }
      }
      if((sales[ID] >= 1000000) && (kaburi == 0)){
        cout << ID << endl;
        check = 1;
        rep[k] = ID;
        k++;
      }
    }
    if(check == 0)
      cout << "NA" << endl;
  }
}

C++: #include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
using namespace std;
void shoki();
void henkan(string);
int tansaku(int);
pair<string,long long> num[4001];
int n,ban,tanka,kazu,i,j,memo;
bool dp[4001]={false};
int main(){
	int al=0;
	bool y=false;
	while(1){
		shoki();
		cin>>n;
		if(n==0){
			break;
		}
		int count=0;
		for(i=0;i<n;i++){
			cin>>num[i].first>>tanka>>kazu;
			henkan(num[i].first);
			if(dp[memo]==true){
				num[tansaku(i)].second+=tanka*kazu;
			}
			else{
			num[i].second+=tanka*kazu;
			}
			dp[memo]=true;
			memo=0;
		}
		for(int k=0;k<=i;k++){
			if(num[k].second==0){
				continue;
			}
			if(num[k].second>=1000000){
				y=true;
				cout<<num[k].first<<endl;
			}
		}
		if(y==false){
			cout<<"NA"<<endl;
		}
		y=false;
		shoki();
		memset(dp,false,sizeof(dp));
	}
	return 0;
}
void shoki(){
	for(int i=0;i<4001;i++){
		num[i].first="0";
		num[i].second=0;
	}
	return;
}
void henkan(string str1){
	long long kake=1;
	for(int i=0;i<str1.size();i++){
		memo+=str1[i]*i;
		i*=10;
	}
	return;
}
int tansaku(int rec){
	int res;
	for(int l=0;l<rec;l++){
		if(num[rec].first==num[l].first){
			return res=l;
		}
	}
}

C++: /* -- 0100:Sale Result -- */
#include	<iostream>
#include	<map>

using namespace std;

typedef unsigned __int64 ull;

int main(void) {
	int n, buf_n, buf_c, buf_p;
	bool flag;
	ull buf_t;
	map<int, ull> List;

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

		flag = true;
		List.clear();
		for(int i=0; i<n; i++) {
			cin >> buf_n >> buf_p >> buf_c;
			buf_t = buf_p * buf_c;
			if(List.find(buf_n) == List.end()) {
				List[buf_n] = buf_t;
			} else {
				List[buf_n] += buf_t;
			}
		}
		map<int, ull>::iterator it = List.begin();
		while( it != List.end() ) {
			if(it->second >= 1000000) { flag = false; cout << it->first << endl; }
			it++;
		}
		if(flag) { cout << "NA" << endl; }
	}
	return 0;
}