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;
    long int array[n][3];
    int count=0;

    cin>>n;

    for(int i=0;i<n;i++){
        cin>>array[i][0]>>array[i][1]>>array[i][2];
    }
    
    for(int i=0;i<n;i++){
        for(int j=1;i+j<n;j++){
            if(array[i][0]==array[i+j][0]){
                array[i][1]+=array[i+j][1];
                array[i][2]+=array[i+j][2];
                array[j][1]=0;
                array[j][2]=0;
            }
        }
    }

    for(int i=0;i<n;i++){
        if(array[i][1]*array[i][2]>=1000000){
            cout<<array[i][0]<<"\n";
            count++;
        }
    }

    if(count==0){
        cout<<"NA\n";
    }
}

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

int main(){
 int id,price,num,count,SaleResult[4000];
 bool isBe=false,sameid[4000];
 for(int i=0;i<4000;i++){
  sameid[i]=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){
   if(!sameid[id]){
    cout<<id<<'\n';
    isBe=true;
    sameid[id]=true;
   }
   }
  }
  if(!isBe){
   cout<<"NA\n";
  }
  count=0;
  isBe=false;
  for(int i=0;i<4000;i++){
    SaleResult[i]=0;
    sameid[i]=false;
  }
  }
 return 0;
}

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

int main() {
	int n;

	while(cin >> n, n) {
		int ID, price, sale;
		int table[4096];
		bool flag = false;
		memset(table, 0, sizeof(table));
		for(int i = 0; i < n; i++) {
			cin >> ID >> price >> sale;
			table[ID] += price * sale;
		}

		for(int i = 0; i < 4096; i++) {
			if(table[i] >= 1000000) {
				cout << i << endl;
				flag = true;
			}
		}

		if(flag)
			cout << "NA" << endl;
	}

	return 0;
}

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

int main()
{
    int n;
    while(1)
    {
        long long record[4000];
        for(int i=0; i<4000; i++)
        {
            record[i] = 0;
        }
        int cnt = 0;
        cin >> n;
        if(n == 0)
        {
            break;
        }
        for(int i=0; i<n; i++)
        {
            int id;
            long long p;
            long long q;
            cin >> id >> p >> q;
            record[id] += p * q;
        }
        for(int i=0; i<4000; i++)
        {
            if(record[i] >= 1000000)
            {
                cout << i << endl;
                cnt++;
            }
        }
        if(cnt == 0)
        {
            cout << "NA" << endl;
        }
    }
    return 0;
}

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

typedef map<int,int> M;
typedef queue<int> P;

int N[4000];

int main()
{
    int count;
    while (cin >> count, count > 0) {
        M m;
        int t = 1;
        P p;
        for (int i = 0; i < count; i++) {
            int t1, t2, t3;
            cin >> t1 >> t2 >> t3;
            if (N[t1 - 1] == 0) {
                N[t1 - 1] = t;
                t++;
                p.push(t1);
                m[t1] = 0;
            }
            m[t1] += t2 * t3;
        }

        bool flag = true;
        while (p.size()) {
            t = p.front(); p.pop();
            if (m[t] >= 1000000) {
                cout << t << endl;
                flag = false;
            }
            N[t - 1] = 0;
        }
        if (flag)
            cout << "NA" << endl;
    }

    return 0;
}

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

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

using namespace std;

typedef long long ll;

int main()
{
    int n;
    while(cin >> n && n) {
        set<string> list;
        string id;
        ll a,b,c = 1000000;
        for(int i = 0; i < n; i++) {
            cin >> id >> a >> b;
            if(list.find(id) == list.end() && a * b >= c) {
                cout << id << endl;
            }
            list.insert(id);
        }
        if(list.size() == 0) cout << "NA" << endl;
    }
}

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

int main(){
    int n;
    long int array[n][3];
    int count=0;

    cin>>n;

    if(n==0) goto Exit;
    for(int i=0;i<n;i++){
        cin>>array[i][0]>>array[i][1]>>array[i][2];
    }
    
    for(int i=0;i<n;i++){
        for(int j=1;i+j<n;j++){
            if(array[i][0]==array[i+j][0]){
                array[i][1]+=array[i+j][1];
                array[i][2]+=array[i+j][2];
                array[i+j][1]=0;
                array[i+j][2]=0;
            }
        }
    }

    for(int i=0;i<n;i++){
        if(array[i][1]*array[i][2]>=1000000){
            cout<<array[i][0]<<"\n";
            count++;
        }
    }

    Exit:
    ;

    if(count==0){
        cout<<"NA\n";
    }
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;

int A[100000000];

int main(){
	int N,B,C;
	while(cin>>N,N){
		int cnt[4001]={};
		for(int i=0;i<N;i++){
			cin>>A[i]>>B>>C;
			cnt[A[i]] += B*C;
		}
		bool NAflag=true,used[4001]={};
		for(int i=0;i<N;i++){
			if(cnt[A[i]]>=1000000 && used[A[i]]==false){
				printf("%d\n",A[i]); used[A[i]] = true; NAflag = false;
			}
		}
		if(NAflag==true) puts("NA");
	}
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;

int main() {
  int n;
  while(cin >> n, n) {
    int f=0;
    vector<ll> sum(4001);
    vector<int> ff(4001);
    REP(i,n) {
      ll a,b,c;
      cin >> a>>b>>c;
      sum[a] += b*c;
      if (ff[a]==0&&sum[a]>=1000000) {
        ff[a]++;
        if (f==0)
          f=1;
        cout << a << endl;
      }
    }
    if (f==0)
      cout << "NA" << endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <map>
int main(){
  int n;

  while(std::cin>>n){
    if(!n)break;
    std::map<int,long long int> m;
    std::vector<int> v;
    //mlÛ¶vÛ¶
    for(;n;n--){
      int a,b,c;
      //aÔbP¿cÊ
      std::cin>>a>>b>>c;
      if(!m[a])v.push_back(a);
      m[a]+=b*c;
    }
    bool f = true;
    for(int i=0;i<v.size();i++){
      if(m[v[i]]>=1000000)f=false,std::cout<<v[i]<<std::endl;}
    if(f)std::cout<<"NA"<<std::endl;
  }
  return 0;
}