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>
using namespace std;

bool p[4001];

int main(){
	int i , n , id , price , num , cnt=0;;
	while(cin>>n){
		if (n==0) break;
		for(i=0 ; i<4001 ; i++){
			p[i]=false;
		}
		for(i=0 ; i<n ; i++){
			cin >> id >> price >> num;
			if (price*num>=1000000) {
				p[id]=true;
				cnt++;
			}
		}
		for(i=0 ; i<4001 ; i++){
			if(p[i]==true){
				cout << i << endl;
			}
		}
		if (cnt==0) {
				cout << "NA" << endl;
			}
	}
	return 0;
}

C++: #include<stdio.h>
int main(void){
    int n=0,i,j,k=0,l=0,x,y,z;
    int a[5001]={0};
    long long int b[5001]={0};
    int c[5001]={0};
    int flag[5001]={0};
    int flag2[5001]={0};
    for(;;){
        k=0;
        x=0;
        y=0;
        z=0;
        i=0;
        l=0;
        for(j=0;j<4001;j++){
            a[j]=0;
            b[j]=0;
            flag[j]=0;

            c[j]=0;
            flag2[j]=0;

            }
        scanf("%d",&n);
        if(n==0)break;
        k=1;
        for(i=0;i<n;i++){
            scanf("%d",&x);
            scanf("%d",&y);
            scanf("%d",&z);

            if(flag[x]==1);
            else {
                b[x]=b[x]+y*z;
                if(flag2[x]==0){
                    a[i] = x;
                    flag2[x]=1;
                }


                }

            if(flag[x]==0&&b[x]>=1000000){

                flag[x]=1;

                k++;
            }


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

            }
        }

return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
long long s[5000];
int main(){
	int n,a,b,c;
	while(true){
	cin>>n;
	bool t=false;
	if(n==0)
		break;
	for(int i=0;i<min(n,4000);i++)
		s[i]=0;
	for(int i=0;i<n;i++){
		cin>>a>>b>>c;
		s[a]+=b*c;
		if(s[a]>=1000000&&s[a]<10000000){
			cout<<a<<endl;
			s[a]=10000000;
			t=true;
		}
	}
	if(t==false)
		cout<<"NA"<<endl;
	}
    return 0;
}

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

using namespace std;

const int Target = 1000000;

struct Shain {
	int no;
	long long sum;
};

int main( void )
{
	vector<Shain> shain;
	int n;
	while(cin >> n, n) {
		shain.clear();
		for(int i=0; i < n; ++i) {
			int no, kin, num;
			cin >> no >> kin >> num;
			bool hit = false;
			vector<Shain>::iterator it = shain.begin();
			while(it != shain.end()) {
				if(it->no == no) {
					it->sum += (kin * num);
					hit = true;
					break;
				}
				++it;
			}
			if(!hit) {
				Shain tmp;
				tmp.no = no;
				tmp.sum = kin * num;
				shain.push_back(tmp);
			}
		}
		bool hit = false;
		vector<Shain>::iterator it = shain.begin();
		while(it != shain.end()) {
			if(it->sum >= Target) {
				cout << it->no << endl;
				hit = true;
			}
			++it;
		}
		if(!hit)
			cout << "NA" << endl;
	}
	return 0;
}

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

int main()
{
	int num, man, yen, ko;
	int ach;
	int c;
	int g[20][2] = { {} };
	int flag;
	
	while (1){
		c = 0;
		flag = 1;

		cin >> num;
		if (!num)	break;

		for (int i = 1; i <= num; i++){
			int j = i;
			cin >> man >> yen >> ko;
			ach = yen * ko;

			for (; j > 1; j--){
				if (g[j - 1][0] == man){
					g[j - 1][1] += ach;
					flag--;
				}

				if (g[j - 1][1] >= 1000000){
					cout << man << endl;
					c++;
				}
			}

			if (flag){
				g[i][0] = man;
				g[i][1] = ach;
			}

			if (flag || g[i][1] >= 1000000){
					cout << man << endl;
					c++;
			}
		}

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

	return 0;
}

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

using namespace std;

int main()
{
    while(1){
        int n;
        scanf(" %d",&n);
        if(n==0)break;

        vector<int> bangoulist;
        map<int,long> alldata;
        alldata[4001]=0;
        for(int i=0;i<n;i++){
                int bangou,tanka,num;
                scanf(" %d %d %d",&bangou,&tanka,&num);
                if(alldata.find(bangou)!=alldata.end()){
                        alldata[bangou]+=tanka*num;
                }else{
                        bangoulist.push_back(bangou);
                        alldata[bangou]=tanka*num;
                }
        }
        bool flag=true;
        for(int i=0;i<(int)bangoulist.size();i++){
                if(alldata[bangoulist[i]]>=1000000){
                        cout<<bangoulist[i]<<"\n";
                        flag=false;
                }
        }
        if(flag)cout<<"NA\n";
    }
    return 0;
}

C++: #include<stdio.h>


int main(){
	int n;
	int id[4000],cid;
	long long int price,num,sale[4000];
	bool f;
	int i,j,idcount;
	while(scanf("%d",&n),n){

		f=true;
		idcount=0;

		for(i=0;i<n;i++){
			cid=(int)0;
			price=num=(long long int)0;
			scanf("%d",&cid);
			scanf("%lld",&price);
			scanf("%lld",&num);

			for(j=0;j<idcount;j++){
				if(id[j]==cid){
					sale[j]=sale[j]+price*num;
				}
			}

			if(j==idcount){
				id[idcount]=cid;
				sale[idcount]=price*num;
				idcount++;
			}

		}



		for(i=0;i<idcount;i++){
			if(sale[i]>1000000){
				printf("%d\n",id[i]);
				f=false;
			}
		}
		if(f!=false)printf("NA\n");
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <map>
using namespace std;
typedef long long int ll;
int main(){
  ll n;
  while( cin >> n,n ){
    ll ma[4001] = {0};
    vector<ll>ve;
    ve.clear();
    for(ll k = 0 ; k < n ; k++ ){
      ll a,b,c;
      cin >> a >> b >> c;
      if(ma[a] == 0)ve.push_back(a);
      ma[a] += b*c;
    }
    int f = 1;
    for(vector<ll>::iterator it = ve.begin() ; it != ve.end() ; it++ ){
      if(ma[(*it)] >= 1000000 ){
	cout << (*it) << endl;
	f = 0;
      }
    }
    if(f)cout << "NA" << endl;
  }
  return 0;
}

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

int main(void)
{
	int n, num;
	string str;
	long a;
	
	while (cin >> n, n){
		map <string, long long> m;
		for (int i = 0; i < n; i++){
			cin >> str >> num >> a;
			m[str] += (num * a);
		}
		map <string, long> ::iterator it;
		bool flag = true;
		/*
		for (it = m.begin(); it != m.end(); it++){
			cout << it->first << " -- " << it->second << endl;
		}*/
		
		for (it = m.begin(); it != m.end(); it++){
			if (1000000 <= it->second){
				cout << it->first << endl;
				flag = false;
			}
		}
		if (flag) cout << "NA" << endl;
	}
	
	return 0;
}

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

int main()
{

  unsigned long f=0;
  unsigned long x, y, z, i=0;
  unsigned long a[4010];
  unsigned long b[4010];
  unsigned long c[4010];
  unsigned long s[4010];
 
  while(1){
    z=0;
    cin>>x;
    if(x==0)
      break;
    
    for(y=0; y<x; y++)
      cin>>a[y]>>b[y]>>c[y];

    for(y=0; y<x; y++)
	s[y]=a[y];

    for(y=0; y<x-1; y++)
      for(i=y+1; i<x; i++)
	if(a[y]==s[i]){
	  b[y]+=b[i];
	  c[y]+=c[i];
	  b[i]=0;
	  c[i]=0;
	}

    for(y=0; y<x; y++){
      if(1000000<=b[y]*c[y]){
	z++;
	cout<<a[y]<<endl;
      }
    }
      
    
    if(z==0)
      cout<<"NA"<<endl;

  }

  return 0;
}