Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys

for line in sys.stdin:
    s, w, h = map(float, line.strip().split(","))
    print(s if w / (h**2) >= 25)

Fixed submission:
while True:
    try:
        s, w, h = map(float, input().split(','))
        if w / pow(h, 2) >= 25:
            print(int(s))
    except:
        break
Buggy python submission (verdict: Runtime Error):
import re
while True:
    try:
       f = input().split()
    except:
        break
    stack = []
    for c in f:
        if re.match("-*[0-9]", c) is None:
            b, a = stack.pop(), stack.pop()
            stack.append(eval("{}{}{}".format(a, c, b)))
        else:
            stack.append(c)
    print("{0:.6f}".format(stack[0]))

Fixed submission:
import re
while True:
    try:
       f = input().split()
    except:
        break
    stack = []
    for c in f:
        if re.match("-*[0-9]", c) is None:
            b, a = str(stack.pop()), str(stack.pop())
            stack.append(float(eval(a+c+b)))
        else:
            stack.append(c)
    print(stack[0])
Buggy python submission (verdict: Runtime Error):
from calender import isleap

while True:
    a, b = map(int, input().split())
    if a == 0:
        break
    print(sum(isleap(i) for i in range(a, b+1)))

Fixed submission:
from calendar import isleap

flag = False
while True:
    a, b = map(int, input().split())
    if a == 0:
        break
    if flag:
        print()
    flag = True
    ans = [i for i in range(a, b+1) if isleap(i)]
    print("\n".join(map(str, ans)) if len(ans) else "NA")
Buggy python submission (verdict: Runtime Error):
n = int(input())
dataset = [input().replace("Hoshino", "Hoshina") for _ in range(n)]
print(*dataset, sep="\n")



Fixed submission:
n = int(input())
dataset = [input().replace("Hoshino", "Hoshina") for _ in range(n)]
print(*dataset, sep="\n")
Buggy python submission (verdict: Runtime Error):
dic = {}
while True:
    try:
        word, pgn = input().split()
    except ValueError:
        break

    if word in dic.keys():
        dic[word].append(int(pgn))
    else:
        dic[word] = [int(pgn)]
for k, v in dic.items():
    print(k)
    print(' '.join(map(str, sorted(v))))

Fixed submission:
d = {}
while True:
    try:
        data = input().split()
    except:
        break
    word = data[0]
    number = int(data[1])
    if word in d:
        d[word].append(number)
    else:
        d[word] = [number]

for k, v in sorted(d.items(), key=lambda x: x[0]):
    print(k)
    print(*sorted(v))

Buggy python submission (verdict: Runtime Error):
dic = {}
while True:
    try:
        word, pgn = input().split()

    if word in dic.keys():
        dic[word].append(int(pgn))
    else:
        dic[word] = [int(pgn)]
    except:
        for k, v in dic.items():
            print(k)
            print(' '.join(map(str, sorted(v))))
        break

Fixed submission:
d = {}
while True:
    try:
        data = input().split()
    except:
        break
    word = data[0]
    number = int(data[1])
    if word in d:
        d[word].append(number)
    else:
        d[word] = [number]

for k, v in sorted(d.items(), key=lambda x: x[0]):
    print(k)
    print(*sorted(v))

Buggy python submission (verdict: Runtime Error):
dic = {}
while True:
    try:
        word, pgn = input().split()

    if word in dic.keys():
        dic[word].append(int(pgn))
    else:
        dic[word] = [int(pgn)]
    except:
        break
        
for k, v in dic.items():
    print(k)
    print(' '.join(map(str, sorted(v))))

Fixed submission:
d = {}
while True:
    try:
        data = input().split()
    except:
        break
    word = data[0]
    number = int(data[1])
    if word in d:
        d[word].append(number)
    else:
        d[word] = [number]

for k, v in sorted(d.items(), key=lambda x: x[0]):
    print(k)
    print(*sorted(v))
Buggy python submission (verdict: Runtime Error):
while True:
    try:
        dataset = input()
    except:
        break
    flag = True
    for i in range(10):
        sequence = dataset.replace("=", "+").split("+")
        if i == 0 and any([True if seq[0]=="X" and len(seq) >= 2 else False for seq in sequence]):
            continue
        a, b, c = map(int, [seq.replace("X", str(i)) for seq in sequence[:2]]), sequence[2].replace("X", str(i))
        if a+b == c:
            print(i)
            flag = False
            break
    if flag:
        print("NA")

Fixed submission:
while True:
    try:
        dataset = input()
    except:
        break
    flag = True
    for i in range(10):
        sequence = dataset.replace("=", "+").split("+")
        if i == 0 and any([True if seq[0]=="X" and len(seq) >= 2 else False for seq in sequence]):
            continue
        a, b, c = map(int, [seq.replace("X", str(i)) for seq in sequence])
        if a+b == c:
            print(i)
            flag = False
            break
    if flag:
        print("NA")
Buggy python submission (verdict: Runtime Error):
b=False
while True:
    n = int(input())
    if n==0:break
    d=dict()
    if b:print()
    b=True
    for _ in range(n):
        line = input().split()
        tmp = int(line[1])*3+int(line[3]*1)
        if tmp in d:
            d[tmp].append(line[0])
        else:
            d[tmp] = []
            d[tmp].append(line[0])
    for k, vs in sorted(d.items(), key=lambda x: x[0])[::-1]:
        for v in vs:
            print('%s,%d'%(k, v))

Fixed submission:
b = False
while True:
    n = int(input())
    if n == 0:
        break
    dataset = []
    if b:
        print()
    b = True
    for _ in range(n):
        name, w, l, d = input().split()
        dataset.append((name, 3*int(w) + int(d), n-len(dataset)))
    for name, score, _ in sorted(dataset, key=lambda x: (x[1], x[2]))[::-1]:
        print(name + "," + str(score))
Buggy python submission (verdict: Runtime Error):
dataset = [[input().split() for _ in range(8)] for _ in range(3)]
tmp = []
for i in range(3):
    s = sorted(dataset[i], key=lambda x: x[1])[:3]
    tmp.append(s[-1])
    for p in s[:2]:
        print(*p)
a, b = sorted(tmp, key=lambda x: x[1])[:2]
print(*a, "\n", *b)

Fixed submission:
pts = [[input().split() for _ in range(8)] for _ in range(3)]
npts = [sorted(pts[i], key=lambda x: float(x[1]))[:4] for i in range(3)]
ts = [sorted((npts[i][j] for i in range(3) for j in range(2, 4)), key=lambda x: float(x[1]))[:2]]
gen = (print(*npts[i][j]) for i in range(3) for j in range(2))
ans = lambda *x: print(*ts[0][0])
ans(*gen)
print(*ts[0][1])
Buggy python submission (verdict: Runtime Error):
ld, rd = [0, 0, 0, 0]. [0, 0, 0, 0]
while True:
    try:
        l, r = map(float, input().split())
        if l < 0.2:
            ld[3] += 1
        elif l < 0.6:
            ld[2] += 1
        elif l < 1.1:
            ld[1] += 1
        else:
            ld[0] += 1

        if r < 0.2:
            rd[3] += 1
        elif r < 0.6:
            rd[2] += 1
        elif r < 1.1:
            rd[1] += 1
        else:
            rd[0] += 1

    except:
        break

for l, r in zip(ld, rd):
    print(l, r)

Fixed submission:
ld, rd = [0, 0, 0, 0], [0, 0, 0, 0]
while True:
    try:
        l, r = map(float, input().split())
        if l < 0.2:
            ld[3] += 1
        elif l < 0.6:
            ld[2] += 1
        elif l < 1.1:
            ld[1] += 1
        else:
            ld[0] += 1

        if r < 0.2:
            rd[3] += 1
        elif r < 0.6:
            rd[2] += 1
        elif r < 1.1:
            rd[1] += 1
        else:
            rd[0] += 1

    except:
        break

for l, r in zip(ld, rd):
    print(l, r)
Buggy python submission (verdict: Runtime Error):
while True:
    h1= int(input())
    if h1== 0:
        break
    h2,h3,h4,h5= [int(input()) for _ in range(4)]
    l= [h1,h2,h3,h4,h5]
    if 1 and 2 and 3 in l:
        for _ in range(5): print("3")
    else:
        for i in range(5):
            if l[i]==1:
                print('1' if 2 in l '2')
            elif l[i]==2:
                print('1' if 3 in l '2')
            else:
                print('1' if 1 in l '2')

Fixed submission:
while True:
    h = int(input())
    if h == 0:
        break
    dataset = [h] + [int(input()) for _ in range(4)]
    if len(set(dataset)) == 3 or len(set(dataset)) == 1:
        print(*[3]*5, sep="\n")
        continue
    
    for data in dataset:
        if data == 1:
            print(2 if 3 in dataset else 1)
        elif data == 2:
            print(2 if 1 in dataset else 1)
        else:
            print(2 if 2 in dataset else 1)
Buggy python submission (verdict: Time Limit Exceeded):
while True:
    n = int(input())
    if n == 0:
        break
    cnt = 1
    for i in range(1, n+1):
        tmp = str(cnt)
        while '4' in tmp or '6' in tmp:
            if '4' in tmp and '6' in tmp:
                l = min(tmp.find('4'), tmp.find('6'))
                r = len(tmp[l+1:])
                cnt += 1*pow(10, r)
            elif '4' in tmp:
                l = tmp.find('4')
                r = len(tmp[l+1:])
                cnt += 1*pow(10, r)
            else:
                l = tmp.find('6')
                r = len(tmp[l+1:])
                cnt += 1*pow(10, r)
            tmp = str(cnt)
        cnt += 1
    print(cnt-1)

Fixed submission:
while True:
    n = int(input())
    if n == 0:
        break
    print(str(oct(n)[2:]).translate(str.maketrans("4567", "5789")))
Buggy python submission (verdict: Runtime Error):
while True:
    n = int(input())
    if n == 0:
        break
    dataset = [map(int, input().split()) for _ in range(n)]
    for map_ in dataset:
        pm, pe, pj = map_
        x = (pm + pe + pj) // 3
        if 100 in p:
            print("A")
        elif (pm + pe) // 2 >= 90:
            print("A")
        elif x >= 80:
            print("A")
        elif x >= 70:
            print("B")
        elif x >= 50 and (pm >= 80 or pe >= 80):
            print("B")
        else:
            print("C")

Fixed submission:
while True:
    n = int(input())
    if n == 0:
        break
    dataset = [list(map(int, input().split())) for _ in range(n)]
    for p in dataset:
        x = (p[0] + p[1] + p[2]) // 3
        if 100 in p:
            print("A")
        elif (p[0] + p[1]) // 2 >= 90:
            print("A")
        elif x >= 80:
            print("A")
        elif x >= 70:
            print("B")
        elif x >= 50 and (p[0] >= 80 or p[1] >= 80):
            print("B")
        else:
            print("C")
Buggy python submission (verdict: Time Limit Exceeded):
while True:
    d= float(input())
    if d< 0: break
    a, b= bin(int(d))[2:].zfill(8)+".", d-int(d)
    while 1:
        b*= 2
        a= a+'1' if int(b)>= 1 else a+'0'
        if str(b).split(".")==['1','0']: break
        b-=int(b)
    a= a.ljust(13, '0')
    print("NA" if len(a)> 13 else a)

Fixed submission:
while True:
    d= float(input())
    if d< 0: break
    a= bin(int(d))[2:]
    if len(a)> 8:
        print("NA")
    else:
        a= a.zfill(8)+"."
        b= d-int(d)
        for _ in range(4):
            b*= 2
            if int(b)>= 1:
                a= a+'1'
                b-= 1
            else:
                a= a+'0'
        a= a.ljust(13, '0')
        print("NA" if 1e-10 < b or len(a)> 13 else a)
Buggy python submission (verdict: Runtime Error):
while True:
    r, a= input().split()
    if r==a==0: break
    print(sum(1 for i, j in zip(r, a) if i==j), sum(1 for i in range(len(r)) for j in range(len(a)) if r[i]==a[j] and i!=j))

Fixed submission:
while True:
    r, a= input().split()
    if r==a=='0': break
    print(sum(1 for i, j in zip(r, a) if i==j), sum(1 for i in range(len(r)) for j in range(len(a)) if r[i]==a[j] and i!=j))
Buggy python submission (verdict: Runtime Error):
while True:
    N = input()
    if N == "0000":
        break
    ans = 0
    if all([1 if s == N[-1] else 0 for s in N[:-1]]):
        print("NA")
        continue
    while int(N) != 6174:
        a, b, c, d = N[0], N[1], N[2], N[3]
        S =  sorted([a, b, c, d])
        L = int([''.join(S[::-1])][0])
        S = int([''.join(S)][0])
        ans += 1
        N = str(L-S)
    print(ans)

Fixed submission:
while True:
    N = input()
    if N == "0000":
        break
    ans = 0
    if int(N) % 1111 == 0:
        print("NA")
        continue
    while N != '6174':
        N = list(N)
        S = int(''.join(sorted(N)))
        L = int(''.join(sorted(N)[::-1]))
        ans += 1
        N = str(L-S).zfill(4)
    print(ans)

Buggy python submission (verdict: Runtime Error):
while True:
    N = input()
    if N == "0000":
        break
    ans = 0
    if int(N) % 1111 == 0:
        print("NA")
        continue
    while int(N) != 6174:
        a, b, c, d = N[0], N[1], N[2], N[3]
        S =  sorted([a, b, c, d])
        L = int([''.join(S[::-1])][0])
        S = int([''.join(S)][0])
        ans += 1
        N = str(L-S)
    print(ans)

Fixed submission:
while True:
    N = input()
    if N == "0000":
        break
    ans = 0
    if int(N) % 1111 == 0:
        print("NA")
        continue
    while N != '6174':
        N = list(N)
        S = int(''.join(sorted(N)))
        L = int(''.join(sorted(N)[::-1]))
        ans += 1
        N = str(L-S).zfill(4)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
while True:
    N = input()
    if N == "0000":
        break
    ans = 0
    if int(N) % 1111 == 0:
        print("NA")
        continue
    while int(N) != 6174:
        N = list(N)
        S = int(''.join(sorted(N)))
        L = int(''.join(sorted(N)[::-1]))
        ans += 1
        N = str(L-S)
    print(ans)

Fixed submission:
while True:
    N = input()
    if N == "0000":
        break
    ans = 0
    if int(N) % 1111 == 0:
        print("NA")
        continue
    while N != '6174':
        N = list(N)
        S = int(''.join(sorted(N)))
        L = int(''.join(sorted(N)[::-1]))
        ans += 1
        N = str(L-S).zfill(4)
    print(ans)
Buggy python submission (verdict: Runtime Error):
while True:
    N = int(input())
    if N==0:break
    dataset = input()
    mens = ["" for _ in range(N)]
    i = 0
    p = ""
    while dataset:
        if i == N: i = 0
        card, dataset = dataset[0], dataset[1:]
        if card == "M":
            mens[i] += card
        elif card == "S":
            p += card + mens[i]
            mens[i] = ""
        else:
            mens[i] += card + p
            p = ""
        i += 1
    print(*[len(s) for s in sorted(mens)], len(p))

Fixed submission:
while True:
    N = int(input())
    if N==0:break
    dataset = input()
    mens = ["" for _ in range(N)]
    i = 0
    p = ""
    while dataset:
        if i == N: i = 0
        card, dataset = dataset[0], dataset[1:]
        if card == "M":
            mens[i] += card
        elif card == "S":
            p += card + mens[i]
            mens[i] = ""
        else:
            mens[i] += card + p
            p = ""
        i += 1
    print(' '.join(map(str, sorted([len(m) for m in mens]))), len(p))

Buggy python submission (verdict: Runtime Error):
while True:
    N = int(input())
    if N==0:break
    dataset = input()
    mens = ["" for _ in range(N)]
    i = 0
    p = ""
    while dataset:
        if i == N: i = 0
        card, dataset = dataset[0], dataset[1:]
        if card == "M":
            mens[i] += card
        elif card == "S":
            p += card + mens[i]
            mens[i] = ""
        else:
            mens[i] += card + p
            p = ""
        i += 1
    print(*[v for v in sorted(len(m) for m in mens)], len(p))

Fixed submission:
while True:
    N = int(input())
    if N==0:break
    dataset = input()
    mens = ["" for _ in range(N)]
    i = 0
    p = ""
    while dataset:
        if i == N: i = 0
        card, dataset = dataset[0], dataset[1:]
        if card == "M":
            mens[i] += card
        elif card == "S":
            p += card + mens[i]
            mens[i] = ""
        else:
            mens[i] += card + p
            p = ""
        i += 1
    print(' '.join(map(str, sorted([len(m) for m in mens]))), len(p))
Buggy python submission (verdict: Runtime Error):
print(sum(map(int, input().split()))

Fixed submission:
print(sum(map(int, input().split())))
Buggy python submission (verdict: Runtime Error):
print(sum(divmod(map(int, input().split())))

Fixed submission:
D, L = map(int, input().split())
print(D//L + D%L)
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = list(map(int, input().split()))
score = [0] * 101
for x in p:
    score[x] += 1

while True:
    if sum(score[i:]) < i:
        break
    i += 1
print(i-1)

Fixed submission:
N = int(input())
p = list(map(int, input().split()))
score = [0] * 101
for x in p:
    score[x] += 1
print(max(i * (sum(score[i:]) >= i) for i in range(101)))
Buggy python submission (verdict: Runtime Error):
e = sorted(map(int, input().split()))
print("yes" if e[0] == e[1] and e[2] == e[3])

Fixed submission:
e = sorted(map(int, input().split()))
print("yes" if e[0] == e[1] and e[2] == e[3] else "no")
Buggy python submission (verdict: Runtime Error):
while True:
    n = int(input())
    if n == 0:
        break
    score = [0, 0]
    for _ in range(n):
        A, B = map(int, input().split())
        if A == B:
            score += [A, B]
        else:
            score[A > B] += A+B
    print(*score)

Fixed submission:
while True:
    n = int(input())
    if n == 0:
        break
    score = [0, 0]
    for _ in range(n):
        A, B = map(int, input().split())
        if A == B:
            score[0] += A
            score[1] += B
        else:
            score[A < B] += A+B
    print(*score)
Buggy python submission (verdict: Runtime Error):
while True:
    x = int(input())
    if x == 0:
        break
    dcl = dict()
    for i in range(x):
        inp = list(map(str, input().split()))
        dcl[inp[0]] = inp[1]
    ans = ""
    x = int(input())
    y = str(input())
    for i in range(x):
        y = str(input())
        if y in dcl:
            ans += dcl[y]
        else:
            ans += y
    print(ans)

Fixed submission:
while True:
    n = int(input())
    if n == 0:
        break
    converter = {}
    for _ in range(n):
        k, v = input().split()
        converter[k] = v

    m = int(input())
    ans = []
    for _ in range(m):
        v = input().strip()
        try:
            ans.append(converter[v])
        except:
            ans.append(v)

    print("".join(ans))

Buggy python submission (verdict: Runtime Error):
while True:
    n = int(input())
    if n == 0:
        break
    d = {}
    for _ in range(n):
        a, b = input().split()
        d[a] = b
    m = int(input())
    tmp = [input().strip() for _ in range(int(input()))]
    ans = [d[a] if a in d.keys() else a for a in tmp]
    print("".join(ans))

Fixed submission:
while True:
    n = int(input())
    if n == 0:
        break
    converter = {}
    for _ in range(n):
        k, v = input().split()
        converter[k] = v

    m = int(input())
    ans = []
    for _ in range(m):
        v = input().strip()
        try:
            ans.append(converter[v])
        except:
            ans.append(v)

    print("".join(ans))
Buggy python submission (verdict: Runtime Error):
operation = {"North": (1, 5, 2, 3, 0, 4),
             "East": (3, 1, 0, 5, 4, 2),
             "West": (2, 1, 5, 0, 4, 3),
             "South": (4, 0, 2, 3, 5, 1),
             "Right": (0, 2, 4, 1, 3, 5),
             "Left": (0, 3, 1, 4, 2, 5)}

while True:
    n = int(input())
    if n == 0:
        break
    dice = [i+1 for i in range(6)]
    ans = 1
    for _ in range(n):
        indices = operation[input()]
        dice = [dice[i] for i in indices]
        ans += dice[0]
    print(ans)



Fixed submission:
operation = {"North": (1, 5, 2, 3, 0, 4),
             "East": (3, 1, 0, 5, 4, 2),
             "West": (2, 1, 5, 0, 4, 3),
             "South": (4, 0, 2, 3, 5, 1),
             "Right": (0, 2, 4, 1, 3, 5),
             "Left": (0, 3, 1, 4, 2, 5)}

while True:
    n = int(input())
    if n == 0:
        break
    dice = [i+1 for i in range(6)]
    ans = 1
    for _ in range(n):
        indices = operation[input().strip()]
        dice = [dice[i] for i in indices]
        ans += dice[0]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
while True:
    n, k = map(int, input().split())
    if n==0:break
    a = [int(input()) for _ in range(n)]
    print(max([sum(a[i:i+k]) for i in range(n) if len(a[i:i+k])==k]))

Fixed submission:
from collections import deque
while True:
    n, k = map(int, input().split())
    if n==0:break
    a = deque(int(input()) for _ in range(k))
    ans=tmp=sum(a)
    for _ in range(n-k):
        x = a.popleft()
        y = int(input())
        a.append(y)
        tmp += y - x
        ans = max(ans, tmp)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
while True:
    n, k = map(int, input().split())
    if n==0:break
    a = deque(int(input()) for _ in range(k))
    ans = sum(a)
    for _ in range(n-k):
        a.popleft()
        a.append(int(input()))
        tmp = sum(a)
        if ans < tmp: ans = tmp
    print(ans)

Fixed submission:
from collections import deque
while True:
    n, k = map(int, input().split())
    if n==0:break
    a = deque(int(input()) for _ in range(k))
    ans=tmp=sum(a)
    for _ in range(n-k):
        x = a.popleft()
        y = int(input())
        a.append(y)
        tmp += y - x
        ans = max(ans, tmp)
    print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
values = list(map(int, input().split()))
minv = min(vs)+1
print(1)
i = 2
ng_value = [1]*minv
while i < minv:
    if not 0 in [1 if values[k] % i == 0 else 0 for k in range(n)]:
        print(i)
    else:
        for j in range(i, minv, i):
            ng_value[j] = 0
    b = True
    for j in range(i+1, minv):
        if ng_value[j]:
            i = j
            b = False
            break
    if b: break

Fixed submission:
n = int(input())
values = list(map(int, input().split()))
minv = min(values)+1
print(1)
i = 2
ng_value = [1]*minv
while i < minv:
    if not 0 in [1 if values[k] % i == 0 else 0 for k in range(n)]:
        print(i)
    else:
        for j in range(i, minv, i):
            ng_value[j] = 0
    b = True
    for j in range(i+1, minv):
        if ng_value[j]:
            i = j
            b = False
            break
    if b: break
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())
print(min(P*A, B if C <= P else B+(P-C)*D)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
P = int(input())
print(min(P*A, B if C >= P else B+(P-C)*D))
Buggy python submission (verdict: Runtime Error):
from math import gcd
while True:
    try:
        a, b= map(int, input().split())
        print(gcd(a, b))
    except:
        break

Fixed submission:
while True:
    try:
        a, b= map(int, input().split())
        while b!= 0:
            a, b= b, a%b
        print(a)
    except:
        break
Buggy python submission (verdict: Runtime Error):
while True:
    n = int(input())
    if n == 0: break
    print(sum([int(input()) for _ in range(n)]))

Fixed submission:
while True:
    n = int(input())
    if n == 0:
        break
    print(sum(int(input()) for i in range(n // 4)))
Buggy python submission (verdict: Runtime Error):
while True:
    n, m = map(int, input().split())
    if n == 0:
        break
    flag = 1
    for i in range(m):
        if int(input()) == 1:
            flag = 0
    print('{:.10f}'.format(n/2 if flag else 0))

Fixed submission:
while True:
    n, m = map(int, input().split())
    if n == 0:
        break
    p = sorted(list(map(int, input().split())))
    flag = 0 if p[0]==1 else 1
    print('{:.10f}'.format(n/2 if flag else 0))