Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}

		sales := make([]int, 4000)
		members := make([]int, 0)
		memberCheck := make(map[int]bool)

		for i := 0; i < n; i++ {
			scanner.Scan()
			input := strings.Split(scanner.Text(), " ")
			e, _ := strconv.Atoi(input[0])
			p, _ := strconv.Atoi(input[1])
			q, _ := strconv.Atoi(input[2])

			if e >= 1 && e <= 4000 && memberCheck[e] == false {
				members = append(members, e)
				memberCheck[e] = true
			}
			sales[e-1] += p * q
		}

		emptyFlag := true
		for _, v := range members {
			if sales[v-1] >= 1000000 {
				fmt.Println(v)
				emptyFlag = false
			}
		}

		if emptyFlag == true {
			fmt.Println("NA")
		}
	}
}

C++: #include<cstdio>
#include<map>
#include<vector>
std::map<int, int> mp;
std::vector<int> v;
int main() {
	int n, i, e, p, q;
	while (true) {
		scanf("%d", &n);
		if (n == 0)break;
		for (i = 0; i < n; i++) {
			scanf("%d%d%d", &e, &p, &q);
			if (mp.count(e) == 0) mp[e] = p*q;
			else mp[e] += p*q;
		}
		for (std::map<int, int>::iterator itr = mp.begin(); itr != mp.end(); ++itr) {
			if (itr->second >= 1000000)v.push_back(itr->first);
		}
		if (v.size() == 0)printf("NA\n");
		else {
			for (std::vector<int>::iterator itr = v.begin(); itr != v.end(); ++itr) {
				printf("%d\n", *itr);
			}
		}
		mp.clear();
		v.clear();
	}
	return 0;
}

C++: #include <iostream>

const long long BORDER = 1000000;

using namespace std;

int main() {
  bool f;
  int i, j, n, number, price, amount;
  int numbers[4000];
  long long sales[4000];

  for(;;) {
    cin >> n;
    if (n == 0) break;
    for (i = 0; i < 4000; i++) {
      numbers[i] = 0;
      sales[i] = 0;
    }
    for (i = 0, f = false; i < n; i++) {
      cin >> number >> price >> amount;
      for (j = 0; j < i; j++) {
        if (numbers[j] == number) {
          f = true;
          sales[j] = (long long)price * (long long)amount;
        }
      }
      if(!f) {
        numbers[i] = number;
        sales[i] = (long long)price * (long long)amount;
      }
    }
    for (i = 0, f = false; i < n; i++) {
      if (sales[i] > BORDER) {
        f = true;
        cout << numbers[i] << endl;
      }
    }
    if (!f) cout << "NA" << endl;
  }

  return 0;
}

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

int main(){
  double n ,flag=0 ,num[4001] ,price[4001] ,earnings[4001] ,total[4001] ,overlap;
  while( true ){
    cin >> n;
    if( n == 0 ){
      break;
    }
    for( int i=0 ; i<n ; i++ ){ // 入力と合計を計算
      cin >> num[i] >> price[i] >> earnings[i];
      total[i] = price[i] * earnings[i];
    }

    for( int i=0 ; i<n ; i++ ){ // 重複を無くす
      overlap = num[i]; // 重複したかの判定
      for( int j=0 ; j<n ; j++ ){
	if( num[j] == overlap && i != j ){ // 重複したか
	  total[i] += total[j];
	  num[j] = -1;
	  total[j] = 0;
	}
      }
    }

    for( int i=0 ; i<n ; i++ ){ // 出力
      if( total[i] >= 1000000 ){
	cout << num[i] << endl;
	flag = 1;
      }
    }

    if( flag == 0 ){ // いなかったら
      cout << "NA" << endl;
    }
    flag = 0;
  }
}

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

C++: #include<iostream>
#include<map>
#include<set>
#define LIM 1000000
using namespace std;
map<int,long long>data;
set<int>used;
int main(){
	int n;
	while(cin>>n && n){
		used.clear();
		data.clear();
		bool update=false;
		for(int i=0;i<n;i++){
			int id;
			cin>>id;
			long long  ans;
			cin>>ans;
			int tmp;
			cin>>tmp;
			ans*=tmp;
			data[id]+=ans;
			if(data[id]>=LIM &&used.find(id)==used.end()){
				update=true;
				cout<<id<<endl;
				used.insert(id);
			}
		}
		if(!update)cout<<"NA"<<endl;
	}
}

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

int main()
{
	int n;

	while (cin >> n, n){
		int e[5000] = {0}, p, q, a, out = 0;
		for (int i = 0; i < n; i++){
			cin >> a >> p >> q;
			e[a] += p * q;
		}
		for (int i = 0; i < 4000; i++){
			if (e[i] >= 1000000){
			 cout << i << endl;
			 out = 1;
			}
		}
		if (out != 1) cout << "NA" << endl;
	}
	return (0);
}

C++: #include<cstdio>

using namespace std;
const int target = 1000000;

int main()
{
	int data;
	while (1)
	{
		scanf("%d", &data);
		if (data == 0)break;
		int company[4000] = { 0 };
		int num, sell, cnt;
		bool hero = false;
		for (int i = 0; i < data; i++)
		{
			scanf("%d %d %d", &num, &sell, &cnt);
			company[num - 1] += sell*cnt;
			if (company[num - 1] >= target)
			{
				printf("%d\n", num);
				company[num - 1] = -1000000000;
			}
		}

		if (hero == false)
			printf("NA\n");
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
 
int main() {
	while(1){
long long s[4000];int i;int w;int j;
w=0;
for(int y = 0;y<4000;y++){
	s[y]= 0;
}
cin>>i;
if(i==0){break;}
for(int y = 1;y<=i;y++){
	int a,b,c;
	cin>>a>>b>>c;
	int g = 1000000 - s[a-1];
	if(g%b==0){j = g/b;}
	else{j = (g/b)+1;}
	if(j<c){s[a-1]=1000001;}
	else{s[a-1]=s[a-1]+b*c;}
}
for(int y = 0;y<4000;y++){
	if(s[y]>=1000000){
		cout << y+1<<endl;
		w=1;
		}
}
if(w==0){cout << "NA" << endl;}
}
	return 0;
}

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

int main(){
    int n, a, b, c, d = 0, com[4001] = {};
    cin >> n;
    if(n != 0){
    for(int i = 0;i < n;i++){
       cin >> a >> b >> c;
       com[a] += b * c;
      }
    for(int j = 1;j < 4001;j++){
       if(com[j] >= 1000000){
       cout << com[j] << endl;
       d++;
       }  
      }    
    if(d == 0) cout << "NA" << endl;
     }
    return 0;
   }

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

int main()
{
	int n;
	string ans[4000];
	double a,b;
	
	for(;;)
	{
		cin >> n;
		if(n==0)
			break;
		int i,j;
		for(i=0,j=0;i<n;i++)
		{
			string num;
			int flag=1;
			cin >> num >> a >> b ;
			if(a/10000.0*b>=100.0)
			{
				for(int k=0;k<j;k++)
				{
					if(ans[k]==num)
						flag=0;
				}
				if(flag==1)
				{
					ans[j]=num;
					j++;
				}
			}
		}
		
		if(j!=0)
		{
			for(int i=0;i<j;i++)
			{
				cout << ans[i] << endl;
			}
		}
		else
			cout << "NA" << endl;
	}
}

C++: #define _CRT_SECURE_NO_WARNINGS 1

using namespace std;

#include <stdio.h>
#include <map>

#define BASE_VALUE 1000000llu		// ?£?????????????

int main()
{
	int n = 0;								// ???????????°
	int no = 0;								// ????????????
	long long price = 0;					// ????£???????
	long long saleNum = 0;					// ?£??????°???
	bool flg = false;						// ????????????????????¨??????????????????
	map<int, long long> proceed;			// ?£??????????map
	map<int, long long>::iterator ite;		// ?£??????????map????????¬??????

	while (true)
	{
		// ?????????
		flg = false;
		proceed.clear();

		// ???????????°??\???
		scanf("%d", &n);

		if (0 == n)
		{// 0?????\??????????????°??????
			break;
		}

		for (int i = 0; i < n; ++i)
		{
			// ?????????????????\???
			scanf("%d %lld %lld", &no, &price, &saleNum);

			proceed[no] += price*saleNum;
		}

		for (ite = proceed.begin(); ite != proceed.end(); ++ite)
		{
			if (BASE_VALUE <= ite->second)
			{// ?£???????????????????????????? 1,000,000 ?????\????????????
				printf("%d\n", ite->first);
				flg = true;
			}
		}

		if (!flg)
		{// ????????????????????¨?????????
			printf("NA\n");
		}
	}
}