Problem:


Sale Result

There is data on sales of your company. Your task is to write a program which identifies good workers.

The program should read a list of data where each item includes the employee ID i, the amount of sales q and the corresponding unit price p. Then, the program should print IDs of employees whose total sales proceeds (i.e. sum of p &times; q) is greater than or equal to 1,000,000 in the order of inputting. If there is no such employees, the program should print "NA". You can suppose that n < 4000, and each employee has an unique ID. The unit price p is less than or equal to 1,000,000 and the amount of sales q is less than or equal to 100,000.

Input

The input consists of several datasets. The input ends with a line including a single 0. Each dataset consists of:

n (the number of data in the list)
i p q
i p q
 :
 :
i p q

Output

For each dataset, print a list of employee IDs or a text "NA"

Sample Input

4
1001 2000 520
1002 1800 450
1003 1600 625
1001 200 1220
2
1001 100 3
1005 1000 100
2
2013 5000 100
2013 5000 100
0

Output for the Sample Input

1001
1003
NA
2013



Sample input:
4
1001 2000 520
1002 1800 450
1003 1600 625
1001 200 1220
2
1001 100 3
1005 1000 100
2
2013 5000 100
2013 5000 100
0


Sample output:
1001
1003
NA
2013

Submission status: Accepted

Solution code:
while True:
    ans = []
    data = {}
    r = input()
    if r == 0:
        break
    for i in xrange(r):
        tmp = map(int, raw_input().split())
        
        if tmp[0] in data.keys():
            data[tmp[0]] += tmp[1] * tmp[2]
        else:
            data.update({tmp[0]:tmp[1]*tmp[2]})
    
        if data[tmp[0]] >= 1000000 and tmp[0] not in ans:
            ans.append(tmp[0])
    if len(ans) == 0:
        print "NA"
    else:
        print "\n".join(map(str, ans))

Submission status: Accepted

Solution code:
while True:
  N = input()
  if not N:
    break
  m = dict()
  o = []
  for i in range(N):
    a, b, c = map(int, raw_input().split())
    o.append(a)
    m[a] = (m[a] if a in m else 0) + b * c
  oo = []
  for x in o:
    if x not in oo:
      oo.append(x)
  for i in oo:
    if m[i] >= 1000000:
      print(i)
  if max(m.values()) < 1000000:
    print('NA')

Submission status: Accepted

Solution code:
#個数の入力値が0になるまで繰り返す。空の辞書を作成。
while True:
    n = int(input())
    if n == 0:break
    sya = {}
    
    #辞書の中に社員番号があったなら数値を加算し、ないなら新しく追加する。
    for _ in range(n):
        try:
            a,b,c = map(int,input().split())
            sya[a] = sya[a]+b*c
        except KeyError:
            sya[a] = b*c
    k =[]
    
    #1,000,000以上の売り上げを出した社員番号を出力し、ないならNAを出力する。
    for i in sya:
        if sya[i] >= 1000000:print(i)
        k.append(sya[i] >= 1000000)
    if not any(k) == True:print("NA")

Submission status: Accepted

Solution code:
while True:
    flg = True
    inf = []
    dic = {}
    n = int(input())
    if n==0:
        break
    for i in range(n):
        inf.append(list(map(int,input().split())))
        if inf[i][0] in dic:
            tmp = dic[inf[i][0]] + inf[i][1]*inf[i][2]
            dic[inf[i][0]] = tmp
        else:
            dic[inf[i][0]] = inf[i][1]*inf[i][2]

    for shain_id,sale in dic.items():
        if sale >= 1000000:
            print(shain_id)
            flg = False
    if flg:
        print("NA")
        

    # for i in inf:

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break

    lst = [0]*4001
    elst = []
    ans = []
    for i in range(n):
        e, p, q = map(int, input().split())
        if lst[e]:
            pass
        else:
            elst.append(e)

        lst[e] = lst[e] + p*q

    for i in elst:
        if lst[i] >= 1000000:
            ans.append(i)

    if ans == []:
        print('NA')
    
    else:
        for i in ans:
            print(i)

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    if N == 0:
        return False
    E = []
    D = {}
    for i in range(N):
        e, p, q = map(int, input().split())
        E.append(e)
        D[e] = D.get(e, 0) + p*q
    cnt = 0
    for e in E:
        if D.get(e, 0) >= 1000000:
            print(e)
            del D[e]
            cnt += 1
    if cnt == 0:
        print("NA")
    return True
while solve():
    ...

Submission status: Accepted

Solution code:
while True:
    input_n = int(input())
    key = 0
    if input_n == 0:
        break
    id_list = [[0 for i in range(2)]for i in range(input_n)]
    for i in range(input_n):
        id_line = input().split()
        for j in id_list:
            if j[0] == int(id_line[0]):
                j[1] += int(id_line[1]) * int(id_line[2])
                uriage = j[1]
                break
        else:
            id_list[i][0] = int(id_line[0])
            id_list[i][1] = int(id_line[1]) * int(id_line[2])
            uriage = id_list[i][1]
        if uriage >= 1000000:
            key = 1
    
    for i in id_list:
        if key == 0:
            print("NA")
            break
        if i[1] >= 1000000:
            print(i[0])

Submission status: Accepted

Solution code:
from collections import defaultdict

while True:
    n = int(input())
    if n == 0:
        break

    dv = defaultdict(int)
    for _ in range(n):
        e, p, q = list(map(int, input().split()))
        dv[e] += p * q
    
    count = 0
    for k, v in dv.items():
        if v >= 1000000:
            print(k)
            count += 1
    if count == 0:
        print("NA")

Submission status: Accepted

Solution code:
from collections import defaultdict
while True:
    n = int(input())
    if n == 0:
        break

    SALES = defaultdict(int)
    for _ in range(n):
        id, p, num = [int(x) for x in input().split()]
        SALES[id] += p * num
        
    L = [k for k, v  in SALES.items() if v >= 1000000]

    if len(L) > 0:
        for i in L:
            print(i)
    else:
        print("NA")

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    if n==0:break
    a={};c=[]
    for _ in range(n):
        b=list(map(int,input().split()))
        if b[0] in a:a[b[0]]+=b[1]*b[2]
        else:a[b[0]]=b[1]*b[2];c.append(b[0])
    if max(a.values())<=999999:print('NA' )
    for i in c:
        if a[i]>999999:print(i)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    id = []
    pq = [-1] * 4001
    for i in range(n):
        e,p,q = list(map(int,input().split()))
        if pq[e] < 0:
            id.append(e)
            pq[e] = p*q
        else: pq[e] += p*q
    
    f = False
    for e in id:
        if pq[e] >=1000000:
            print(e)
            f = True
    if not f:
        print("NA")

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    s=[-1]*4001
    id=[]
    for i in range(n):
        e,p,q=map(int,input().split())
        if s[e]<0:
            id.append(e)
            s[e]=p*q
        else:
            s[e]+=p*q
    ch=True
    for i in id:
        if s[i]>=1000000:
            print(i)
            ch=False
    if ch:
        print("NA")

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    save_list=[0]*4001
    display_list = []
    for i in range(n):
        a,b,c =  map(int, input().split())
        save_list[a] += b * c
        if a not in display_list:
            display_list.append(a)
    ans = []
    for i in display_list:
        if save_list[i] >= 1000000:
            ans.append(i)
    if not ans:
        print("NA")
    else:
        for i in ans:
            print(i)

Submission status: Accepted

Solution code:
if __name__ == '__main__':

	while True:
		try:
			n = int(input())
			if n == 0:
				break

			no = []
			total = []
			for i in range(n):
				e,p,q = map(int,input().split())

				if e not in no:
					no.append(e)
					total.append(p*q)
				else:
					ind = no.index(e)
					total[ind] += p*q

			cnt = 0
			for j,k in enumerate(total):
				if k >= 1000000:
					cnt += 1
					print(no[j])
			if cnt == 0:
				print("NA")

		except EOFError:
			break

Submission status: Accepted

Solution code:
while True:
    try:
        N=int(input())
        if N==0:break
        ans=[]
        dic={}
        for i in range(N):
            e,p,q=map(int,input().split())
            if e in dic:dic[e] +=p*q
            else:dic[e]=p*q
        for v,m in dic.items():
            if m>=1000000:ans.append(v)
        if len(ans)==0:ans.append("NA")
        for k in ans:
            print(k)
    except:break

Submission status: Accepted

Solution code:
import sys

while True:
    n=int(input())
    score={}
    if n==0:
        sys.exit()
    for _ in range(n):
        e,p,q=[int(i) for i in input().split(" ")]
        score[e]=score.get(e,0)+p*q

    employee=[]
    for e in score:
        if score[e]>=1000000:
            employee.append(e)

    if len(employee)==0:
        print("NA")
    else:
        for e in employee:
            print(e)

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    if n==0:break
    count=0
    member=[0]*4001
    mem_check=[]
    mem_check2=[]
    for i in range(n):
        e,p,q=map(int,input().split())
        member[e]+=p*q
        mem_check.append(e)
    for i in mem_check:
        if not(i in mem_check2):
            if member[i]>=1000000:
                print(i)
                count+=1
                mem_check2.append(i)
    if count==0:
        print("NA")

Submission status: Accepted

Solution code:
import sys

def sales_result(sales):
    total_sales = {}
    person = []
    for s in sales:
        total_sales[s[0]] = total_sales.get(s[0], 0)
        total_sales[s[0]] += s[1] * s[2]
        if total_sales[s[0]] >= 1000000 and not (s[0] in person):
            person.append(s[0])
    if len(person) == 0:
        print("NA")
    else:
        for p in person:
            print(p)


lineno = 0
n = 0
sales = []
for line in sys.stdin:
    if lineno == 0:
        n = int(line)
        if n == 0:
            break
    elif lineno <= n:
        s = list(map(int, line.strip().split()))
        sales.append(s)
    if lineno == n:
        sales_result(sales)
        lineno = 0
        sales = []
    else:
        lineno += 1

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    result = {}
    order = []
    for i in range(n):
        e, p, q = map(int, input().split())
        if e in result:
            result[e] += p*q
        else:
            result[e] = p*q
            order.append(e)
    flag = True
    for e_i in order:
        if result[e_i] >= 1000000:
            print(e_i)
            flag = False
    if flag:
        print("NA")

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0: break
    personel = {}
    for _ in range(n):
        e, p, q = input().split()
        if e in personel.keys():
            personel[e] += int(p) * int(q)
        else:
            personel[e] = int(p) * int(q)
    result = []
    for key, val in personel.items():
        if val >= 1000000:
            result.append(key)
    if not result:
        print('NA')
    else:
        print('\n'.join(result))

Submission status: Accepted

Solution code:
n = int(input())
while (n != 0):
    e_ab = {}
    for i in range(n):
        e,a,b = map(int, input().split())
        ab = a*b
        if (e not in e_ab.keys()):
            e_ab[e] = ab
        else:
            e_ab[e] += ab
    c = 0
    for e,ab in e_ab.items():
        if (ab >= 10**6):
            c += 1
            print(e)
    if (c == 0):
        print('NA')
    
    n = int(input())

Submission status: Accepted

Solution code:
p = []
q = []
while True:
    n = int(input())
    m = 0
    number = [0] * 4000
    if n == 0:
        break
    else:
        for i in range(n):
            p.append(i)
            q.append(i)
            e,p[i],q[i] = [int(s) for s in input().split(' ')]
            if number[e] >= 1000000:
                break
            else:
                number[e] = number[e] + p[i] * q[i]
                if number[e] >= 1000000:
                    print(e)
                else:
                    m = m + 1
            if m == n:
                print('NA')

Submission status: Accepted

Solution code:
while(True):
    n = int(input())
    if n == 0:
         break
    oe = []
    for i in range(n):
        e,p,q = map(int, input().split())
        for a in oe:
            if a[0] == e:
                a[1] += p*q
                continue
        oe.append([e,p*q])
    lis = [ a[0] for a in oe if a[1] >= 1000000]
    if len(lis):
        print("\n".join(str(l) for l in lis))
    else:
        print("NA")

Submission status: Accepted

Solution code:
from collections import Counter

while True:
    n = int(input())
    if n == 0:
        break
    counter = Counter()
    for _ in [0]*n:
        a, b, c = map(int, input().split())
        counter[a] += b*c
    result = [str(k) for k, v in counter.items() if v >= 1000000] or ["NA"]
    print("\n".join(result))

Submission status: Runtime Error

Solution code:
while 1:
  n=input()
  if n==0: break
  D={}
  A=[]
  for _ in range(n):
    a,b,c=map(int, raw_input().split(' '))
    if a in D: D[a]+=b*c
    else:
      D[a]=b*c
      A.append(a)
  B=[i for i in A: if D[i]>=1e6]
  if B=[]: B=["NA"]
  for e in B: print e

Submission status: Runtime Error

Solution code:
while True:
	n=int(input())
	if n:
		a=[list(map(int,input().split())) for _ in range(n)]
		b={}
		for i in range(n):
			if a[i][0] in b:
				b[a[i][0]]+=a[i][1]*a[i][2]
			else:
				b[a[i][0]]=a[i][1]*a[i][2]
		for k in b.keys():
			if b[k]>=1000000:
				print(k)
		if max(k.values())<1000000:
			print("NA")
	else:
		break

Submission status: Runtime Error

Solution code:
while True:
	n=int(input())
	if n==0: break
	l=[]
	d={}
	for i in range(n):
		i,p,q=list(map(int,input().split()))
		if a in d:
			d[a]+=b*c
		else:
			d[a]=b*c
			l.append(a)
	if max(d.values())<1000000:
		print("NA")
	else:
		for k in l:
			if d[k]>=1000000:
				print(k)

Submission status: Runtime Error

Solution code:
n = int(raw_input())
for i in range(n):
	x, y, z = map(int, raw_input())
	if y*z >= 1000000:
		print x
	else:
		print "NA"

Submission status: Runtime Error

Solution code:
while 1:
	n = int(raw_input())
	if n == 0:
		break
	for i in range(n):
		x, y, z = map(int, raw_input())
		if y*z >= 1000000:
			print x
		else:
			print "NA"

Submission status: Runtime Error

Solution code:
1001 2000 520
1002 1800 450
1003 1600 625
1001 200 1220

Submission status: Runtime Error

Solution code:
import sys
import math


while 1:
    para = map(int, raw_input())
    if (para == 0):
        break
    ans = 0
    l = [0 for i in range(4000)]
    num = []
    check = 0
    for j in range(para):
        data = map(int, raw_input().split())
        l[data[0]] = l[data[0]]+data[1]*data[2]
        if(data[0] not in num):
            num.append(data[0])
    for j in range(4000):
        if(l[num[j]]>=1000000):
            print num[j]
            check = check + 1
    if(check==0):
        print "NA"

Submission status: Runtime Error

Solution code:
while True:
    N = int(input())
    if N == 0:
        break
    d = {}
    for n in range(N):
        num, p, q = map(int, input().split())
        if num in d:
            d[num][1] += (p*q) 
        else:
            d[num] = [n, p*q]
    else:
        fla = False
        for k, v in sorted(d.items(), key=lambda x[1][0]):
            if v[1] >= 1000000:
                print(k)
                fla = True
        else:
            if not fla:
                print('NA')

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys

input_lines = sys.stdin.readlines()
cnt = 0
dataset = []
for i in input_lines:
    if not(' ' in i):
        dataset.append([int(i)])
        cnt += 1
    else:dataset[cnt-1].append(list(map(int, i.split(' '))))
    
for d in dataset:
    if d == [0]:break
    shain = [[x[0], x[1]*x[2]] for x in d[1:]]
    #score = [ for x in d[1:]]
    slist = []
    for s in shain:
        if not(s[0] in slist):slist.append(s[0])
    newslist = [[x, 0] for x in slist]
    score = []
    for s in shain:
        newslist[slist.index(s[0])][1] += s[1]
    
    flag = False
    for n in newslist:
        if n[1] >= 1000000:
            print(n[0])
            flag = True
    if not flag:print('NA')

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys

input_lines = sys.stdin.readlines()
cnt = 0
dataset = []
for i in input_lines:
    if not(' ' in i):
        dataset.append([int(i)])
        cnt += 1
    else:dataset[cnt-1].append(list(map(int, i.split(' '))))
    
for d in dataset:
    if d == [0]:pass
    else:
        shain = [[x[0], x[1]*x[2]] for x in d[1:]]
        slist = []
        for s in shain:
            if not(s[0] in slist):slist.append(s[0])
        newslist = [[x, 0] for x in slist]
        score = []
        for s in shain:
            newslist[slist.index(s[0])][1] += s[1]
        
        flag = False
        for n in newslist:
            if n[1] >= 1000000:
                print(n[0])
                flag = True
    if not flag:print('NA')

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys

input_lines = sys.stdin.readlines()
cnt = 0
dataset = []
for i in input_lines:
    if not(' ' in i):
        dataset.append([int(i)])
        cnt += 1
#    else:dataset[cnt-1].append(list(map(int, i.split(' '))))
    
for d in dataset:
    if d == [0]:break
    shain = [[x[0], x[1]*x[2]] for x in d[1:]]
    #score = [ for x in d[1:]]
    slist = []
    for s in shain:
        if not(s[0] in slist):slist.append(s[0])
    newslist = [[x, 0] for x in slist]
    score = []
    for s in shain:
        newslist[slist.index(s[0])][1] += s[1]
    
    flag = False
    for n in newslist:
        if n[1] >= 1000000:
            print(n[0])
            flag = True
    if not flag:print('NA')

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys

input_lines = sys.stdin.readlines()
cnt = 0
dataset = []
for i in input_lines:
    if not(' ' in i):
        dataset.append([int(i)])
        cnt += 1
    else:dataset[cnt-1].append(list(map(int, i.split(' '))))
    
for d in dataset:
    if d == [0]:break
    shain = [[x[0], x[1]*x[2]] for x in d[1:]]
    #score = [ for x in d[1:]]
    slist = []
    for s in shain:
        if not(s[0] in slist):slist.append(s[0])
    newslist = [[x, 0] for x in slist]
    score = []

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys

input_lines = sys.stdin.readlines()
cnt = 0
dataset = []
for i in input_lines:
    if not(' ' in i):
        dataset.append([int(i)])
        cnt += 1
    else:dataset[cnt-1].append(list(map(int, i.split(' '))))
    
for d in dataset:
    if d == [0]:break
    shain = [[x[0], x[1]*x[2]] for x in d[1:]]
    #score = [ for x in d[1:]]
    slist = []

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys

input_lines = sys.stdin.readlines()
cnt = 0
dataset = []
for i in input_lines:
    if not(' ' in i):
        dataset.append([int(i)])
        cnt += 1
    else:dataset[cnt-1].append(list(map(int, i.split(' '))))

Submission status: Runtime Error

Solution code:
import sys

input_lines = sys.stdin.readlines()
cnt = 0
dataset = []
for i in input_lines:
    if not(' ' in i):
        dataset.append([int(i)])
        cnt += 1
    else:dataset[cnt-1].append(list(map(int, i.split(' '))))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
import sys

input_lines = sys.stdin.readlines()
cnt = 0
dataset = []
for i in input_lines:
    if not(' ' in i):
        dataset.append([int(i)])
        cnt += 1
    else:dataset[cnt-1].append(map(int, i.split(' ')))
    
for d in dataset:
    if d == [0]:break
    shain = [[x[0], x[1]*x[2]] for x in d[1:]]
    #score = [ for x in d[1:]]
    slist = []
    for s in shain:
        if not(s[0] in slist):slist.append(s[0])
    newslist = [[x, 0] for x in slist]
    score = []
    for s in shain:
        newslist[slist.index(s[0])][1] += s[1]
    
    flag = False
    for n in newslist:
        if n[1] >= 1000000:
            print n[0]
            flag = True
    if not flag:print 'NA'

Submission status: Runtime Error

Solution code:
datasets=[]
while True:

  n = int(input())
  if n==0:
    break

  inputs=[None]*n
  for t in range(0,n):
    inputs[t] = list(map(int,input().split()))
    #inputs == [[i0,p0,q0],[i1,p1,q1],[i2,p2,q2]]

  id_sale = [] # id_sale == [id,sale,id,sale,id,sale]
  for i in inputs: # i == [ik,pk,qk]
    if i[0] in id_sale:
      id_sale[id_sale.index(i[0])+1] += i[1]*i[2]
    else:
      id_sale += [i[0],i[1]*i[2]]

  na=True
  for i in range(0,len(id_sale),2):
    if id_sale[i+1] >= 1000000:
      print(id_sale[i])
      na=False
  if na == True:
    print("NA")

Submission status: Runtime Error

Solution code:
datasets=[]
while True:

  n = int(input())
  if n==0:
    break

  inputs=[None]*n
  for t in range(0,n):
    inputs[t] = list(map(int,input().split()))
    #inputs == [[i0,p0,q0],[i1,p1,q1],[i2,p2,q2]]

  id_sale = [] # id_sale == [id,sale,id,sale,id,sale]
  for i in inputs: # i == [ik,pk,qk]
    try:
      id_sale[id_sale.index(i[0])+1] += i[1]*i[2]
    except ValueError:
      id_sale += [i[0],i[1]*i[2]]

  na=True
  for i in range(0,len(id_sale),2):
    if id_sale[i+1] >= 1000000:
      print(id_sale[i])
      na=False
  if na == True:
    print("NA")

Submission status: Runtime Error

Solution code:
datasets=[]
while True:

  n = int(input())
  if n==0:
    break

  inputs=[None]*n
  for t in range(0,n):
    inputs[t] = list(map(int,input().split()))
    #inputs == [[i0,p0,q0],[i1,p1,q1],[i2,p2,q2]]

  id_sale = [] # id_sale == [id,sale,id,sale,id,sale]
  for i in inputs: # i == [ik,pk,qk]
    try:
      id_sale[id_sale.index(i[0])+1] += i[1]*i[2]
    except ValueError:
      # output in the order of inputting
      # (list1 += list2) == [list1_elements, list2_elements]
      id_sale += [i[0],i[1]*i[2]]

  na=True
  for i in range(0,len(id_sale),2):
    if id_sale[i+1] >= 1000000:
      print(id_sale[i])
      na=False
  if na:
    print("NA")

Submission status: Runtime Error

Solution code:
while True:
    n=int(input())
    if n==0:break
    res={}
    li=[]
    for i in range(n):
        d=[int(num) for num in input().split(' ')]
        res[d[0]-1]+=d[1]*d[2]
        if d[0]-1 not in li:li.append(d[0]-1)
    flag=False
    for i in li:
        if res[i]>=1000000:
            print(i+1)
            flag=True
    if flag==False:print("NA")

Submission status: Runtime Error

Solution code:



while True:
    n=int(input())
    if n==0:
        break
    else:
        for i in range(n):
            k=0
            l=map(int, input().split())
            if l[1]*l[2]>=1000000:
                print(l[0])
                k+=1
        if k==0:
            print("NA")

Submission status: Runtime Error

Solution code:
while True:
    str = input()
    if len(str) == 1 and not str == "0":
        datadic={}
        nn = len(str)
        for ii in range(nn):
            data = input.stlip()
            datadic[data[0]] = int(data[1]) * int(data[2])
        print(datadic[ max( datadic.values() ) ])

Submission status: Runtime Error

Solution code:
while True:
    str = input()
    if len(str) == 1 and not str == "0":
        datadic={}
        nn = len(str)
        for ii in range(nn):
            data = input.stlip()
            datadic[data[0]] = int(data[1]) * int(data[2])
        print(datadic[ max( datadic.values() ) ])
    else:
        break

Submission status: Runtime Error

Solution code:
import sys

while True:
    str = sys.stdin.readline().stlip()
    if len(str) == 1 and not str == "0":
        datadic={}
        nn = len(str)
        for ii in range(nn):
            data = sys.stdin.readline().stlip()
            datadic[data[0]] = int(data[1]) * int(data[2])
        print(datadic[ max( datadic.values() ) ])
    else:
        break

Submission status: Runtime Error

Solution code:
import sys
while True:
    str = sys.stdin.readline().stlip()
    if len(str) == 1 and not str == "0":
        datadic={}
        nn = len(str)
        for ii in range(nn):
            data = sys.stdin.readline().stlip()
            datadic[data[0]] = int(data[1]) * int(data[2])
        print(datadic[ max( datadic.values() ) ])
    else:
        break

Submission status: Runtime Error

Solution code:
import sys
while True:
    str = sys.stdin.readline().split()
    if len(str) == 1 and not str == "0":
        datadic={}
        nn = len(str)
        for ii in range(nn):
            data = sys.stdin.readline().split()
            datadic[data[0]] = int(data[1]) * int(data[2])
        print(datadic[ max( datadic.values() ) ])
    else:
        break

Submission status: Runtime Error

Solution code:
while True:
    str = input().split()
    if len(str) == 1 and not str == "0":
        datadic={}
        nn = len(str)
        for ii in range(nn):
            data = input().split()
            datadic[data[0]] = int(data[1]) * int(data[2])
        print(datadic[ max( datadic.values() ) ])
    else:
        break

Submission status: Runtime Error

Solution code:
while True:
    n = input()
    if n == 0:
        break

    rs = {}
    for i in range(n):
        arr = input().split(' ')
        s = arr[0] * arr[1]
        rs[arr[0]] = (rs[arr[0]] or 0) + s

    top = [k for k, v in rs.items if v > 1000000]
    if len(top) == 0:
        print('NA')
    else:
        for i in top:
            print(i)

Submission status: Runtime Error

Solution code:
import numpy as np

class Employee():
    def __init__(self,id,p,q):
        self.id = id
        self.total = p*q
    
    def add_total(self,total):
        self.total += total

class Manager():
    def __init__(self):
        self.employees = list()
        self.count = 0
    
    def add(self,e):
        if len(self.employees) == 0:
            self.employees.append(e)
        else:
            if self.employees[-1].id == e.id:
                self.employees[-1].add_total(e.total)
            else:
                self.employees.append(e)
            
    def pprint(self):
        for i,e in enumerate(self.employees):
            if e.total >= 1000000:
                print(e.id)
                self.count+=1
        if self.count == 0:
            print("NA")

def main():
    while(True):
        m = Manager()
        n = int(input())
        if n==0:
            break
        l = list()
        for i in range(n):
            s = list(map(int,input().split()))
            l.append(s)
        l = sorted(l)
        for x in l:
            m.add(Employee(*x))
        m.pprint()
    

if __name__=="__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys

while True:
    n = input()
    salesmap = {}
    j = 0
    for i in range(1,4001):
    	salesmap[i] = 0
    if n == 0:
        break
    for i in range(n):
    	a = input().split()
    	salesmap[int(a[0])] += int(a[1])*int(a[2])
    for i in range(1,4001):
    	if salesmap[i] >= 1000000:
    		j += 1
    		print(i)
    if j == 0:
    	print('NA')
#print a # [a1, a2, a3, ..., aN]

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import sys

while True:
    n = input()
    salesmap = {}
    j = 0
    for i in range(1,4001):
    	salesmap[i] = 0
    if n == 0:
        break
    for i in range(n):
    	a = input().split()
    	salesmap[int(a[0])] += int(a[1])*int(a[2])
    for i in range(1,4001):
    	if salesmap[i] >= 1000000:
    		j += 1
    		print(i)
    if j == 0:
    	print('NA')
#print a # [a1, a2, a3, ..., aN]

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import sys

while True:
    n = int(input())
    j = 0
    if n == 0:
        break
    salesmap = [0 in range(0,4001)]
    for i in range(n):
    	a = input().split()
    	salesmap[int(a[0])] += int(a[1])*int(a[2])
    for i in range(1,4001):
    	if salesmap[i] >= 1000000:
    		j += 1
    		print(i)
    if j == 0:
    	print('NA')
#print a # [a1, a2, a3, ..., aN]

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import sys

while True:
    n = int(input())
    j = 0
    if n == 0:
        break
    salesmap = [0 for i in range(0,4001)]
    for i in range(n):
        a = input().split()
        salesmap[int(a[0])] += int(a[1])*int(a[2])
    for i in range(1,4001):
        if salesmap[i] >= 1000000:
            j += 1
            print i
    if j == 0:
        print 'NA'
#print a # [a1, a2, a3, ..., aN]

Submission status: Runtime Error

Solution code:
while 1:
  n=int(input())
  if not n:break
  f=1
  L={}
  for a,b,c in [map(int,input().split()) for i in range(n)]:
    a=str(a)
    if a in L:
      d=b*c
      if L[a]>=1e6:continue
      L[a]+=d
    else:L[a]=d
    if L[a] >= 1e6:
      print(a)
      f=0
  if f:print('NA')

Submission status: Runtime Error

Solution code:
while 1:
  n=int(input())
  if not n:break
  f=1
  L={}
  for a,b,c in [input().split() for i in range(n)]:
    if a in L:
      if L[a]>=1e6:continue
      L[a]+=d
    else:L[a]=d
    if L[a]>=1e6:
      print(a)
      f=0
  if f:print('NA')

Submission status: Runtime Error

Solution code:
x = 1
while x != 0:
    x = int(input().rstrip())
    frag = 0
    for j in range(x):
        A = input().rstrip().sprit()
        if int(A[1]) * int(A[2]) >= 1000000:
            print(A[0])
            flag = 1
    if flag == 0:
        print("NA")

Submission status: Runtime Error

Solution code:
x = 1
while x != 0:
    x = int(input().rstrip())
    frag = 0
    for j in range(x):
        A = input().sprit(" ")
        if int(A[1]) * int(A[2]) >= 1000000:
            print(A[0])
            flag = 1
    if flag == 0:
        print("NA")

Submission status: Runtime Error

Solution code:
While True:
    no = []
    n = int(input())
    if (n = 0):
        return
    
    for i in range(n):
        datas = map(int, input().split())
        li = list(datas) 
        e = li[0]
        p = li[1]
        q = li[2]

        s = p * q
        if (1000000 < s and (e in no) = False):
            print(e)
            no.append(e)
    
    if (len(no) = 0):
        print("NA")

Submission status: Runtime Error

Solution code:
while True:
    no = []
    n = int(input())
    if (n == 0):
        exit
    
    for i in range(n):
        datas = map(int, input().split())
        li = list(datas) 
        e = li[0]
        p = li[1]
        q = li[2]

        s = p * q
        if (1000000 < s and (e in no) == False):
            print(e)
            no.append(e)
    
    if (len(no) == 0):
        print("NA")

Submission status: Runtime Error

Solution code:
import sys
while True:
  a=int(input())
  if a==0: break
  ans,name1,name2=[],[],[]
  hogehoge=0
  for i in range(a):
    hoge=map(int,raw_input().split())
    if hoge[0] in name2:
      ww = hoge[1]*hoge[2]
      r = name2.index(hoge[0])
      if len(ans[r]+ww) >= 7: 
        hogehoge+=1
        name1.append(hoge[0])
      else:
        ans[r]+=ww
    else:
      qq = hoge[1]*hoge[2]
      if len(str(qq)) >= 7: 
        hogehoge+=1
        name1.append(hoge[0])
      else: 
        name2.append(hoge[0])
        ans.append(qq)
  if hogehoge == 0: print "NA"
  else: 
    for i in range(len(name1)):
      print name1[i]