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

int main(){
    long size, id, price, quantity;
    bool noone = true;
    while (1){
	cin >> size;
	if (size == 0) break;
	for (int i = 0; i < size; i++){
	    cin >> id >> price >> quantity;
	    if (price * quantity >= 1000000){
		cout << id << endl;
		noone = false;
	    }
	}
	if (noone) cout << "NA" << endl;
	noone = true;
    }
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    map<int,pair<int,int> > com;
    vector<pair<int,int> > ans;
    int a,b,c,x = 1;
    while(n--){
      cin >>a>>b>>c;
      if(!com[a].first){com[a].first = x++;}
      if(com[a].second+b*c>1000000){com[a].second = 1000000;}
      else{com[a].second+=b*c;}
    }
    map<int,pair<int,int> >::iterator pos;
    for(pos=com.begin(); pos!=com.end(); pos++){
      if(pos->second.second>=1000000){ans.push_back(make_pair(pos->second.first,pos->first));}
    }
    if(ans.empty()){cout <<"NA"<<endl;}
    else{
      sort(ans.begin(),ans.end());
      for(int i=0; i<ans.size(); i++){
	cout <<ans[i].second<<endl;
      }
    }
  }
  return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        vector<pair<int, long long int> > v;
        for(int i=0; i < n; i++){
            int place = -1;
            int p, q, r;
            cin >> p >> q >> r;

            bool isExist = false;
            for(int i=0; i < v.size(); i++){
                if(v[i].first == p){
                    isExist = true;
                    place = i;
                }
            }
            if(!isExist) v.push_back(mp(p, q*r));
            else {
                v[place].second += q*r;
            }
        }
        bool isExist = false;
        for(int i=0; i < v.size(); i++){
            if(1000000 <= v[i].second){
                isExist = true;
                cout << v[i].first << endl;
            }
        }
        if(!isExist) cout << "NA" << endl;
    }
}

C++: #include<stdio.h>

int main(void){
	int x,n,a,b,i,nan,k;
	while(0==0){
		scanf("%d",&n);
		if(n==0)break;
		k=0;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&nan,&a,&b);
			if(a*b>999999){
				printf("%d\n",nan);
				k++;
			}
		}
		if(k==0) printf("NA\n");
		k=0;
	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n=1;
	int i=0,j=0;
	int tanka[4001]={0};
	int flg=0;
	int uriage[4001]={0};
	int bangou[4001]={0};
	int ccc=0;
	int goukei[4001]={0};
	while(n!=0)
	{
		flg=0;
		ccc=0;
		scanf("%d",&n);
		if (n==0)
		{
			break;
		}
		for (i=1;i<=n;i++)
		{
			ccc++;
			scanf("%d %d %d",&bangou[ccc],&tanka[ccc],&uriage[ccc]);
			goukei[ccc]=tanka[ccc]*uriage[ccc];
			for (j=0;j<ccc;j++)
			{
				if (bangou[ccc]==bangou[j])
				{
					goukei[j]+=tanka[ccc];
					uriage[j]+=uriage[ccc];
					ccc--;
				}
			}
		}
		for (i=1;i<=ccc;i++)
		{
			if (goukei[i]>=1000000)
			{
				printf("%d\n",bangou[i]);
				flg=1;
			}
		}
		if (flg==0)
		{
			printf("NA\n");
		}
	}
return 0;
}

C++: 
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

#define MAX 5000

int main(){
    for (;;) {
        int n;
        cin >> n;
        if(n==0) break;
        vector<ll> num(4001,0),pre(n,0),data(4001,0);
        for (int i=0; i<n; i++) {
            ll a,b,c;
            cin >>a >>b >>c;
            ll inp;
            if(b*c>=1000000){
                inp=1000000;
            }else{
                inp = b*c;
            }
            if(data[a]<1000000) data[a]+=inp;
            if(num[a]==0) num[a]=i+1;
        }
        for (int k=0; k< 4001; k++) {
            if(num[k]!=0) pre[num[k]]=k;
        }
        ll ch=0;
        for (int j=0; j<n; j++) {
            if (data[pre[j]]>=1000000) {
                cout <<pre[j]<<endl;
                ch++;
            }
        }
        if(ch==0) cout << "NA"<<endl;
    }
}

C++: #include<iostream>

using namespace std;


int main(){

	long long all[4001] = {};
	long long code, a, b, n, i,j;

	while (1){
		j = 0;
		for (i = 0; i < 4001; i++){
			all[i] = 0;
		}


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

		for (i = 0; i < n; i++){
			cin >> code >> a >> b;
			all[code] += a*b;
			
		}

		for (i = 0; i < 4001; i++){
			if (all[i] >= 1000000){
				cout << i << endl;
				j++;
			}
		}

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

	}
}

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[1000000];

int main(){
	int N,B,C;
	while(cin>>N,N){
		int cnt[4001]={};
		bool NAflag=true,used[4001]={};
		for(int i=0;i<N;i++){
			cin>>A[i]>>B>>C;
			cnt[A[i]] += B*C;
		}
		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>

using namespace std;

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

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

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

        }
    }

    return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
	int n;
	int a,b,c,d;
	int num[4001],tan[4001],ans[4001];
	bool flag=false;
	while(1){
		for(a=0;a<=4000;a++){
			num[a]=0;
			tan[a]=0;
		}
		cin >> n;
		if(n==0)break;
		for(a=0;a<n;a++){
			cin >> b >> c >> d;
			num[b]=c,tan[b]=d;
			if(num[b]*tan[b]>ans[b])ans[b]=num[b]*tan[b];
		}
		for(a=1;a<4000;a++){
			if(num[a]*tan[a]>=1000000)printf("%d\n",a),flag=true;
		}
		if(flag==false)printf("NA\n");
	}
	return 0;
}