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<iostream>
#include<cstdio>
#include<cmath>
#include<map>
using namespace std;
int main(){
int n;
while(cin>>n,n){
long long ta[5000]={0},x[5000]={0};
int cnt=0,a,b,c;
	for(int i=0;i<n;i++){
	cin>>a>>b>>c;
	ta[a]+=b*c;
	bool f=1;
	for(int j=0;j<i;j++)if(x[j]==a)f=0;
	if(f)x[cnt++]=a;
	}
	bool f=1;
	for(int i=0;i<n;i++){
	if(ta[x[i]]>=1000000){cout<<x[i]<<endl;f=0;}
	}
	if(f)cout<<"NA"<<endl;
}
	return 0;
}

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

int main()
{
	int em[4000];
	int num,i,id,p,q,flag;
	cin>>num;

	while(num!=0){
    flag =0;

	for(i=0;i<4000;i++){
		em[i]=0;
	}

	for(i=0;i<=num-1;i++){
	    cin>>id >>p >>q;
		em[id]+=p*q;
	}

	for(i=0;i<4000;i++){
		if(em[i]>=1000000){
			cout<<i<<"\n";
		    flag =1;
		}
	}
	if(flag!=1)
		cout<<"NA\n";
	cin >>num;

	}
	return 0;
		
}

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

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

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

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

int main( void )
{
	int n;
	while ( cin >> n && n != 0 )
	{
		vector <int> visited;
		map <int, long long> profit;
		bool exist = false;
		for ( int i = 0; i < min(n, 4000); i++ )
		{
			int no, p, q;
			cin >> no >> p >> q;

			profit[no] += (long long)p * q;

			if ( find( visited.begin(), visited.end(), no ) == visited.end() && profit[no] >= 1000000L )
			{
				exist = true;
				visited.push_back( no );
			}
		}

		if ( exist )
		{
			for ( vector <int>::iterator it = visited.begin(); it != visited.end(); it++ )
			{
				cout << *it << endl;
			}
		}
		else
			cout << "NA" << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>

int main(){
	int n;
	while(std::cin>>n){
		std::vector<int> v;
		if(!n)return 0;
		for(;n;n--){
			long long int num,price,quantity;
			std::cin>>num>>price>>quantity;
			if(price*quantity>=1000000){
				std::vector<int>::iterator it = std::find(v.begin(),v.end(),num);
				if(it==v.end())
					v.push_back(num);
			}
		}
		if(!v.size())std::cout<<"NA"<<std::endl;
		else{
		std::vector<int>::iterator it = v.begin();
		while(it!=v.end()){
			std::cout<<*it<<std::endl;
			it++;
		}
		}
	}
}

C++: #include <iostream>

using namespace std;

int main()
{
    while(1)
    {
        int i=0;
         cin>>i;
        if(i==0)
            break;
        else
        {
            int na=0;
       
            int h[4001];
            for(int k=0;k<=4000;k++)
            {
                h[k]=0;
            }
            for(int kp=1;kp<=i;kp++)
            {
                int j=0;int l=0;int m=0;
                cin>>j>>l>>m;
                h[j]+=(l*m);

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

            }
            if(na==0)
            {
                cout<<"NA"<<endl;
            }

        }
    }

    return 0;
}

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

typedef long long ll;
typedef queue<int> qi;

const int lim = 1000000;

int main()
{
    int n; ll en, price, qty;
    while(cin >> n && n) {
        if (n == 0) break;

        int check[4001] = {0};
        qi que;

        for(int i=0; i < n; ++i) {
            cin >> en >> price >> qty;

            if (check[en] >= 0) {
                check[en] += price*qty;
            }

            if (check[en] >= lim) {
                que.push(en);
                check[en]=-1;
            }
        }

        if (que.empty()) {
            cout << "NA" << endl;
        } else {
            for(int i=0,len=que.size(); i < len; ++i) {
                cout << que.front() << endl;
                que.pop();
            }
        }
    }

    return 0;
}

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

int main() {
  int num = 0;
  while (cin >> num, num) {
    vector<int> order;
    long data[4000] = { 0 };
    // ??\???
    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;
    }
    // ??????
    int 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 <vector>
#include <map>
using namespace std;
int main(){
  int n,f;
  //mlÛ¶vÛ¶
  long long 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])v.push_back(a);
      m[a] += b*c;
    }
    
    for(int i=0;i<v.size();i++){
      if(m[v[i]]>999999){
				f=0;
				cout<<v[i]<<endl;}
    }
    if(f)cout<<"NA"<<endl;
  }
  return 0;
}

C++: #include<stdio.h>
#include<math.h>
#include<string.h>


int main(){
	int uriage[4000][3],n,no,tanka,su,i,j,newflag,naflag;
	
	while(0<=scanf("%d",&n)){
		if(n==0) break;
		memset(uriage,0,sizeof(uriage));
		for(i=0;i<n;i++){
			scanf("%d%d%d",&no,&tanka,&su);
			newflag=0;
			for(j=0;j<n;j++){
				if(uriage[j][0]==no && uriage[j][2]==1){
					uriage[j][1]+=tanka*su;
					newflag=1;
					break;
				}
			}
			if(newflag==0){
				for(j=0;j<n;j++){
					if(uriage[j][2]==0){
						uriage[j][1]+=tanka*su;
						uriage[j][0]=no;
						uriage[j][2]=1;
						break;
					}
				}
			}
		}
		naflag=0;
		for(i=0;i<n;i++){
			if(uriage[i][2]==0)break;
			if(uriage[i][1]>=1000000){
				printf("%d\n",uriage[i][0]);
				naflag=1;
			}
		}
		if(naflag==0)printf("NA\n");
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	long long value[4001];

	int n,num,k,m;
	while(cin >> n && n)
	{
		memset(value,0,sizeof(value));

		rep(i,n)
		{
			cin >> num >> k >> m;
			value[num] += k*m;
		}

		bool flag = true;
		rep(i,4001)
		{
			if(value[i] >= 1000000)
			{
				flag = false;
				cout << i << endl;
			}
		}

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