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 <algorithm>

using namespace std;

int main()
{
	int n, id[4001], p, s;
	bool a[4001], f;
	long long int t, u, b[4001];
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		fill(a, a+4001, false);
		fill(b, b+4001, 0);
		p = 0;
		
		for(int i = 0; i < n; i++){
			cin >> s >> t >> u;
			b[s] += t * u;
			if(a[s]){
				continue;
			}
			id[p++] = s;
			a[s] = true;
		}
		f = true;
		for(int i = 0; i < p; i++){
			if(b[id[i]] >= 1000000){
				cout << id[i] << endl;
				f = false;
			}
		}
		
		if(f){
			cout << "NA" << endl;
		}
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n,s[4000],i,bangou,tanka,suuryou;
	while(cin>>n){
		int c=0;
		if(!n)
			break;
		for(i=0;i<4000;i++)
			s[i]=0;
		for(i=0;i<n;i++){
			cin>>bangou>>tanka>>suuryou;
			s[bangou]+=tanka*suuryou;
		}
		for(i=0;i<4000;i++){
			if(s[i]>=1000000){
				cout<<i<<endl;
				c++;
			}
		}
		if(!c)
			cout<<"NA"<<endl;
	}
	return 0;
}

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

int main() {
    int N;
    while (cin >> N && N != 0) {
        cin.get();
        string result, i;
        map<string, long long> sales;
 	long long p, q;
        for (int n = 0; n != N; ++n) {
            cin >> i >> p >> q;
            sales[i] += p * q;
        }

	bool printNA = true;
        for (map<string, long long>::iterator it=sales.begin(); it!=sales.end(); ++it) {
            if (it->second >= 1000000) {
		cout << it->first << endl;
		printNA = false;
            }
        }

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

C++: #include <stdio.h>

struct {
  int i, v;
} d[50][4000];

int main() {
  int i, j, k;
  int p, n, f;
  int id, v1, v2;

  for (i = 0; scanf("%d", &n), n != 0; i++) {
    p = 0;
    for (j = 0; j < n; j++)
      d[i][j].v = 0;
    for (j = 0; j < n; j++) {
      f = 0;
      scanf("%d %d %d", &id, &v1, &v2);      
      for (k = 0; k < j; k++) {
        if (id == d[i][k].i) {
          d[i][k].v += v1 * v2;
          f = 1;
          break;
        }
      }
      if (f == 0) {
        d[i][p].i = id;
        d[i][p].v = v1 * v2;
        p++;
      }
    }
  }

  n = i;
  for (i = 0; i < n; i++) {
    f = 0;
    for (j = 0; j < 50; j++) {
      if (d[i][j].v >= 1000000) {
        f = 1;
        printf("%d\n", d[i][j].i);
      }
    }
    if (f == 0)
      printf("NA\n");
  }
  return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
# include<iostream>
# include<string>
#include<conio.h>
using namespace std;

int main(){
	int datasuu = 0;
	int flag[4000][4000];
	int sbangou[4000][4000];
	int hanbai[4000][4000];
	int uriage[4000][4000];
	int goukei[4000][4000];
	int kaisuu = 0;
	for (int j = 0;; j++){
		cin >> datasuu;
		if (datasuu == 0){
			kaisuu = j;
			break;
		}
		for (int i = 0; i < datasuu; i++){
			scanf("%d,%d,%d", &sbangou[j][i], &hanbai[j][i], &uriage[j][i]);
			for (int z = 0; z < i; z++){
				if (hanbai[j][i] == hanbai[j][z]){
					goukei[j][i] += goukei[j][z];
				}
			}
			goukei[j][i] += hanbai[j][i] * uriage[j][i];
			if (goukei[j][i] >= 1000000){
				flag[j][i] = 1;
				goukei[j][i] = hanbai[j][i] * uriage[j][i];
			}

		}
	}
	int on = 0;
	for (int i = 0; i < 4000; i++){
		for (int j = 0; j < 4000; i++){
			if (flag[i][j] == 1){
				cout << sbangou[i][j] << endl;
				on = 1;
			}
			if (on == 0)cout << "NA";
		}
	}

}

C++: #include<iostream>
#include<map>
#include<algorithm>
using namespace std;
main(){
while(1){
int n,a,b,c;
cin>>n;
if(n==0) break;
map<long,int> m;
for(;n>0;n--){
cin>>a>>b>>c;
m.insert((long)b*c,a);
}
m.sort();
cout<<(m.begin()).first<<endl;
}
}
cout<<"NA"<<endl;
}

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

int main() {
  int n;
  while(cin >> n && n) {
    int cnt = 0;
    lli sum[4001];
    fill(sum, sum+4001, 0LL);
    for(int i = 0; i < n; ++i) {
      lli id, e, num;
      cin >> id >> e >> num;
      if(sum[id] != -1) {
        sum[id] += e * num;
        if(sum[id] >= 1000000LL) {
          ++cnt;
          sum[id] = -1;
          cout << id << endl;
        }
      }
    }
    if(!cnt) cout << "NA" << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,num,mon,cont,a[4001],nacount;
  while(scanf("%d",&n)!=EOF){
    if(n==0){break;}
    for(int i=0;i<4001;i++){
      a[i]=0;
    }
    nacount=0;
    for(int i=0;i<n;i++){
      cin>>num>>mon>>cont;
      a[num]+=mon*cont;
      if(a[num]>=1000000){
	cout<<num<<endl;
	nacount++;
      }
    }
    if(nacount==0){
      cout<<"NA"<<endl;
    }
  }
  return 0;
}

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

using namespace std;

int main(void){
	int n;
	while(1){
		cin >> n;
		if(n==0)
			break;
		int c[4001]={} , id[1000000];
		for (int i=0; i<n; i++){
			int p , q;
			cin >> id[i] >> p >> q;
			c[id[i]] += p*q;
		}
		bool f=1;
		for (int i=0; i<n; i++){
			if (c[id[i]]>=1000000){
				cout << id[i] << endl;
				c[id[i]]=0;
				f=0;
			}
		}
		if (f)
			cout << "NA" << endl;

	}

	return 0;
}

C++: #include <iostream>


using namespace std;
class MAN{
public:
	long long uriage;
	short number;
};

int main(int argc, char const* argv[])
{
	MAN *person;
	int n;
	bool flag;

	while( cin >> n && n != 0 ){
		person  = new MAN[n];
		for( int i = 0;i < n;i++ ){
			int target;
			long long a,b;
			cin >> target >> a >> b;

			int j;
			for( j = 0;j < i;j++ ){
				if( person[j].number == target ){
					person[j].uriage += a*b;
					break;
				}
			}
			if( j == i ){
				person[i].number = target;
				person[i].uriage = a * b;
			}
		}
		flag = false;
		for( int i = 0;i < n;i++ ){
			if( person[i].uriage >= 1000000 ){
				cout << person[i].number << endl;
				flag = true;
			}
		}
		if( flag == false ) cout << "NA" << endl;
		delete[] person;
	}

	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 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=1;
                }

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

        }
    }

    return 0;
}