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()
{
    while(1)
    {
        int i=0;
        int na=0;
        cin>>i;
        if(i==0)
            break;
        else
        {
            int h[4000];
            for(int k=1;k<=4000;k++)
            {
                h[k]=0;
            }
            for(int k=1;k<=i;k++)
            {
                int j=0;int l=0;int m=0;
                cin>>j>>l>>m;
                h[j]+=l*m;

            }
            for(int k=1;k<=4000;k++)
            {
                if(h[k]>=1000000)
                {
                    cout<<k<<endl;
                    na=1;
                }

            }
            if(na==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<long long> data(4000);
	int i;
	long long a,b,c;
	bool check;

	cin >> i;
	while(i){

		for(int j = 0;j < 4000;j++){
			data[j] = 0;
		}


		for(int j = 0;j < i;j++){
			cin >> a >> b >> c;
			data[a - 1] += (long long)b * c;
		}


		check = false;

		for(int j = 0;j < 4000;j++){
			if(data[j] >= 1000000){
				printf("%d\n",j+1);
				check = true;
			}
		}

		if(!check) printf("NA\n");

		cin >> i;
	}

	return 0;
}

C++: #include <stdio.h>
struct emp{
    int num,sale;
};
int main(){
    while(1){
        int n,num,p,q,count=0,c,flag1,flag2=0;
        struct emp e[4000];
        scanf("%d",&n);
        if(n==0) return 0;
        for(int i=0;i<n;i++){
            scanf("%d %d %d",&num,&p,&q);
            c=count;
            for(int j=0;j<count;j++){
                if(e[j].num==num) {
                    e[j].sale+=p*q;
                    flag1=1;
                    break;
                }
            }
            if(!flag1){
                e[count].num=num;
                e[count].sale=p*q;
                count++;
            }
        }
        for (int i=0; i<count; i++){
            if (e[i].sale>=1000000) {
                printf("%d\n",e[i].num);
                flag2=1;
            }
        }
        if(!flag2) printf("NA\n");
    }
}

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

int main(){
 int id,price,num,count,SaleResult[4000];
 bool isBe=false;

 while(true){
  cin>>count;
  if(count==0){
   break;
  }
  for(int i=0;i<count;i++){
   cin>>id>>price>>num;
   SaleResult[id]+=price*num;
   if(SaleResult[id]>=1000000){
    cout<<id<<'\n';
    isBe=true;
   }
  }
  if(!isBe){
   cout<<"NA\n";
  }
  count=0;
  isBe=false;
  for(int i=0;i<4000;i++){
    SaleResult[id]=0;
  }
  }
 return 0;
}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int n;
	while (scanf("%d",&n)&&n!=0) {
		vector<long long int> sales(4000, 0);
		vector<int> log;
		int num, prc, mnt;
		for (int i=0; i<n; i++) {
			scanf("%d%d%d",&num,&prc,&mnt);
			if (log.empty()||find(log.begin(),log.end(),num)==log.end()) {
				log.push_back(num);
			}
			if (sales[num-1]<1000000) sales[num-1] += prc * mnt;
		}
		bool flag = true;
		for (int i=0; i<log.size(); i++) {
			if (sales[log[i]-1]>=1000000) {
				flag = false;
				printf("%d\n", log[i]);
			}
		}
		if (flag) printf("NA\n");
	}
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<double,double> P;

int main(){
	
	int num;
	while(~scanf("%d",&num)){
		if(num==0) break;
		bool isok=false;
		map<string,int> val;
		vector<string> order;
		for(int i=0;i<num;i++){
			char n[16];
			int p,q;
			scanf("%s %d %d",n,&p,&q);
			val[n] += p*q;
			if(find(order.begin(),order.end(),n) == order.end()){
				order.push_back(n);
			}
		}

		for(vector<string>::iterator it = order.begin(); it != order.end(); it++){
			if(val[*it] >= 1000000){
				cout << *it << endl;
				isok=true;
			}
		}
		if(!isok) cout <<  "NA" << endl;
	}
}

C++: (n == 0) {break;};
    unsigned long int price[4000], value[4000];
    for (int i = 0; i < 4000; i++) {
      price[i] = 0;
      value[i] = 0;
    }
    
    for (int i = 0; i < n; i++) {
      int a,b,c;
      cin >> a >> b >> c;
      price[a-1] += b;
      value[a-1] += c;
    }
    
    bool NA =

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

int main() {
	long long n,i,p,q;
	while(cin>>n,n){
		vector<int> ids;
		map<int,long long> m;
		while(n--){
			cin>>i>>p>>q;
			if(!m.count(i))ids.push_back(i);
			m[i]+=p*q;
		}
		int na=1;
		for(int k=0;k<(int)ids.size();++k){
			if(1e6<=m[ids[k]]){
				cout<<ids[k]<<endl;
				na=0;
			}
		}
		if(na) cout<<"NA\n";
	}
}

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




int n;


void solve()
{
	bool ok=false;
	long long  total[4000];
	bool check[4000];
	memset(check,false,sizeof(check));
	memset(total,0,sizeof(total));
	for(int i=0;i<n;i++){
		long long  num,a,b;
		cin>>num>>a>>b;
		total[num]+=a*b;
		if(total[num]>=1000000 && !check[num]){
			cout<<num<<endl;
			check[num]=true;
			ok=true;
		}
	}
	if(!ok) cout<<"NA"<<endl;
}

int main()
{
	while(cin>>n){
		if(n==0) break;
		solve();
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int data[2][4000],n,i,f,id,a,b;
  while(1){
    cin>>n;
    if(n==0) break;
    for(i=0; i<4000; i++) data[0][i]=-1,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){
	  (a>=1000000)? (data[1][f]+=(a*b)) : (data[1][f]=1000000);
	  break;
	}else if(data[0][f]==-1){
	  data[0][f]=id;
	  (a>=1000000)? (data[1][f]=(a*b)) : (data[1][f]=1000000);
	  break;
	}
      }
    }
    for(i=0,f=0;i<n;i++){
      if(data[1][i]>=1000000)cout<<data[0][i]<<"\n",f=1;
      if(data[0][i]==-1)break;
      //cout<<"id : "<<data[0][i]<<" sale: "<<data[1][i]<<endl;
    }
    if(f==0)cout<<"NA"<<endl;
  }
}

C++: #include <iostream>
#include <map>
using namespace std;
int main() {
  int n;
  map<int, int> mp;
  map<int, int>::iterator itr;

  while(cin >> n) {
	if(n == 0) break;
	int e, p, q;

	for(int i = 0; i < n; ++i) {
	  cin >> e >> p >> q;
	  itr = mp.find(e);
	  if(itr == mp.end()) {// not found
		mp[e] = p * q;
	  }
	  else if(itr != mp.end() && itr->second < 1000000) {// found
		itr->second += p * q;
	  }
	}

	bool isNA = true;
	for(itr = mp.begin(); itr != mp.end(); ++itr) {
	  if(itr->second >= 1000000) {
		cout << itr->first << endl;
		isNA = false;
	  }
	}
	if(isNA) {
	  cout << "NA" << endl;
	}

	mp.clear();
  }
  return 0;
}