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 data[2][4000],n,i,f,id;
  long long 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;
      if(a*b>999999) a=1000000,b=1;
      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]>=1000000)cout<<data[0][i]<<"\n",f=1;
    if(f==0)cout<<"NA"<<endl;
  }
}

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

int main(){
    int n;

    while(cin>>n,n){
        int id;
        ll p,q;
        vector<pair<int,ll>> v;

        for(int i=0;i<n;i++){
            cin >> id >> p >> q;

            for( auto &t:v ){
                if( t.first==id ){
                    t.second += p*q;
                    id=-1;
                    break;
                }
            }

            if(id!=-1){
                v.push_back(make_pair(id,p*q));
            }
        }

        bool flag=false;
        for( auto t:v ){
            if( t.second>=1000000 ){
                cout<<t.first<<endl;
                flag=true;
            }
        }

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

    return 0;
}

C++: #include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;
 /*temp*/

int main(){
    int e, p, q;
    while(cin >> n, n != 0) {
        ll m[4001] = {};
        int a[1000] = {};
        REP(i, n){
            cin >> e >> p >> q;
            m[e] += p * q;
            a[i] = e;
        }
        bool f = true;
        REP(i, n){
            if(m[a[i]] >= 1000000){
                cout << a[i] << '\n';
                m[a[i]] = 0;
                f = false;
            }
        }
        if(f) cout << "NA\n";
    }
    return 0;
}

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

using namespace std;

// 連想配列に売り上げを記録していく。同じ社員が複数のデータを持つこともあるので加算。
// 1000000以上の場合に社員番号を出力する。
// 該当する社員0人の場合はNAを出力する。

int main() {

	int N;
	cin >> N;

	map<int, int> data;

	for (int i = 0; i < N; ++i) {
		int number, price, sales;
		cin >> number >> price >> sales;
		data[number] += price * sales;
	}
	int cnt = 0;
	for (const auto a : data) {
		if (a.second >= 1000000) {
			++cnt;
			cout << a.first << endl;
		}
	}
	if (0 == cnt) {
		cout << "NA" << endl;
	}

	return 0;
}

C++: #include<stdio.h>
int main(void){
    int n,i,j,k=0,l=0,x[4001],y,z;
    int a[4001]={0};
    long long b[4001]={0};
    int c[4001]={0};
    int flag[4001]={0};
    for(;;){
        k=0;
        for(j=0;j<n;j++){
            a[j]=0;
            b[j]=0;
            flag[j]=0;
            x[j]=0;
            c[j]=0;
            }
        scanf("%d",&n);
        if(n==0)break;
        for(i=0;i<n;i++){
            scanf("%d%d%d",&x[i],&y,&z);
            if(flag[i]==1);
            else {
                if(a[i]!=0)b[i]=b[i]+y*z;
                else {
                    a[i] = x[i];
                    b[i] = y*z;
                }
            }
            if(b[i]>=1000000){
                c[k]=a[i];
                flag[i]++;
                k++;
            }

        }
        if(k==0)printf("NA\n");
        for(l==0;l<n;l++){
            if(c[l]!=0){
                printf("%d\n",c[l]);
            }
        }
    }
return 0;
}

C++: #include <cstring>
#include <iostream>
using namespace std;
int main() {
  bool f;
  long long int n, a, b, c, d[4001], i;
  while (cin >> n && n > 0) {
    memset(d, 0, sizeof(d));
    for (i = 0; i < n; i++) {
      cin >> a >> b >> c;
      d[a] += b * c;
    }
    for (i = 1, f = 0; i <= 4000; i++) {
      if (d[i] >= 1000000) {
        cout << i << endl;
        f = 1;
      }
    }
    if (!f) {
      cout << "NA" << endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
	string str = "";

	while (getline (cin, str ) ){
		int n;
		stringstream ssn(str);
		ssn >> n;
		
		if (n == 0){
			break;
		} // end if

		map<int, long long> res;
		int i;

		for (i = 0; i < n; ++i){
			getline (cin, str );
			int id, p, q;
			stringstream ss(str);

			ss >> id >> p >> q;
			long long sum = (long long)(p*q);
			res[id] += sum;
		} // end loop

		map<int, long long>::iterator it = res.begin();
		map<int, long long > R;

		for (; it != res.end(); ++it){
			int id = (*it).first;
			long long sum = (*it).second;

			if (sum >= 1000000LL ){
				R[id] = sum;
			} // end if
		} // end for

		if (R.empty() ){
			cout << "NA" << endl;
		}else{
			map<int, long long>::iterator itr = R.begin();
			for (; itr != R.end(); ++itr ){
				cout << (*itr).first << endl;
			} // end for
		} // end if
	} // end while
		
	return 0;
}

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

int main() {
  int num = 0;
  while (cin >> num, num) {
    vector<int> order;
    int data[4000] = { 0 };
    int count;
    for (int i = 0; i < num; i++) {
      int id, price, sold_num;
      cin >> id >> price >> sold_num;
      for (int i = 0; i < order.size(); i++) {
        if (order[i] == id) {
          break;
        }
        if (i == order.size() - 1) {
          order.push_back(id);
        }
      }
      if (order.size() == 0) {
        order.push_back(id);
      }
      data[id] += price*sold_num;
    }
    count = 0;
    for (int i = 0; i < order.size(); i++) {
      if (data[order[i]] >= 1000000) {
        cout << order[i] << endl;
        count++;
      }
    }
    if (count == 0) {
      cout << "NA" << endl;
    }
  }
}

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

struct Saler
{
	int Number;
	int Saled;
};

int main(){
	struct Saler* sl;
	int n, a, b, c, i;
	bool isFound;
	
loop:
	scanf("%d\n", &n);		// データ個数
	if(n == 0) goto end_scope;
	sl = (struct Saler*)malloc(sizeof(struct Saler) * n);
	memset(sl, 0, sizeof(struct Saler)*n);
	for(int j = 0; j < n; j++)
	{
		scanf("%d %d %d\n", &a, &b, &c);
		for(i = 0; i < n; i++)
		{
			if(sl[i].Number == 0)
			{
				sl[i].Number = a;
				sl[i].Saled = b * c;
				break;
			}
			else if(sl[i].Number == a)
			{
				sl[i].Saled += b * c;
				break;
			}
		}
	}
	isFound = false;
	for(int j = 0; j < n; j++)
	{
		if(sl[j].Saled >= 1000000)
		{
			cout << sl[j].Number << endl;
			isFound = true;
		}
	}
	!isFound && (cout << "NA" << endl);
	free(sl);
	goto loop;
end_scope:
    return 0;
}