Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b = map(int,raw_input().split(' '))
print a*b 2*(a+b)

Fixed submission:
a,b = map(int,raw_input().split(' '))
print a*b,2*(a+b)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
x = [int(input()) for i range(10)]

x.sort(reverse=True)

for i in x[:3]: print(i)

Fixed submission:
from sys import stdin

x = [int(input()) for i in range(10)]

x.sort(reverse=True)

for i in x[:3]: print(i)

Buggy python submission (verdict: Runtime Error):
from sys import stdin

x = [int(input()) for i range(10)]

x.sort(reverse=True)

for i in x[:3]: print(i)

Fixed submission:
from sys import stdin

x = [int(input()) for i in range(10)]

x.sort(reverse=True)

for i in x[:3]: print(i)
Buggy python submission (verdict: Time Limit Exceeded):
import sys, string
alpha = 'abcdefghijklmnopqrstuvwxyza'
t = string.maketrans(alpha[:-1], alpha[1:])
for s in sys.stdin:
  while not('the' in s or 'this' in s or 'than' in s):
    s = s.translate(t)
  print s

Fixed submission:
import sys, string
alpha = 'abcdefghijklmnopqrstuvwxyza'
tbl = string.maketrans(alpha[:-1], alpha[1:])
for s in sys.stdin:
  while not('the' in s or 'this' in s or 'that' in s):
    s = s.translate(tbl)
  print s[:-1]

Buggy python submission (verdict: Time Limit Exceeded):
import sys, string
alpha = 'abcdefghijklmnopqrstuvwxyza'
t = string.maketrans(alpha[:-1], alpha[1:])
for s in sys.stdin:
  while not('the' in s or 'this' in s or 'than' in s):
    s = s.translate(t)
  print s[:-1]

Fixed submission:
import sys, string
alpha = 'abcdefghijklmnopqrstuvwxyza'
tbl = string.maketrans(alpha[:-1], alpha[1:])
for s in sys.stdin:
  while not('the' in s or 'this' in s or 'that' in s):
    s = s.translate(tbl)
  print s[:-1]

Buggy python submission (verdict: Time Limit Exceeded):
import sys, string
alpha = 'abcdefghijklmnopqrstuvwxyza'
tbl = string.maketrans(alpha[:-1], alpha[1:])
for s in sys.stdin:
  while not('the' in s or 'this' in s or 'than' in s):
    s = s.translate(tbl)
  print s[:-1]

Fixed submission:
import sys, string
alpha = 'abcdefghijklmnopqrstuvwxyza'
tbl = string.maketrans(alpha[:-1], alpha[1:])
for s in sys.stdin:
  while not('the' in s or 'this' in s or 'that' in s):
    s = s.translate(tbl)
  print s[:-1]
Buggy python submission (verdict: Runtime Error):
#include <iostream>
using namespace std;

int m[12][12];

bool valid(int y, int x){
  if(0 <= y && y < 12){
    if(0 <= x && x < 12){
        if(m[y][x] == 1) return true;
    }
  }
  return false;
}

void remove_island(int y, int x) {
  int nx, ny;
  int dx[4] = {1, 0, -1,  0};
  int dy[4] = {0, 1,  0, -1};

  m[y][x] = 0;
  for(int i = 0; i < 4; i++){
    ny = y + dy[i];
    nx = x + dx[i];
    if(valid(ny, nx)) remove_island(ny, nx);
  }
}

int main() {
  char c[12];
  int ans;
  while(1){
    for(int i = 0; i < 12; i++){
      if(!(cin >> c)) return 0;
      for(int j = 0; j < 12; j++){
        m[i][j] = (int)(c[j] - '0');
      }
    }

    ans = 0;
    for(int i = 0; i < 12; i++){
      for(int j = 0; j < 12; j++){
        if(valid(i, j)){
          remove_island(i, j);
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Fixed submission:
def get_map():
  map = []
  while True:
    try:
      tmp = list(raw_input())
      if len(tmp) != 12: break
      map.append(tmp)
    except:
      break
  return map

def remove_island(x, y, map):
  map[x][y] = 0
  move = [[1, 0], [0, 1], [-1, 0], [0, -1]]
  for i, j in move:
    if 0 <= x + i <= 11 and 0 <= y + j <= 11 and map[x + i][y + j] == '1':
      map = remove_island(x + i, y + j, map)
  return map[:]

while True:
  map = get_map()
  if len(map) != 12: break

  count = 0
  for x in range(12):
    for y in range(12):
      if map[x][y] == '1':
        count += 1
        map = remove_island(x, y, map)
  print count
Buggy python submission (verdict: Runtime Error):
import sys, math
step = [1,1,2,4] + [0]*26
for i in range(4,30):
  step[i] = step[i-1] + step[i-2] + step[i-3]

for s in sys.stdin:
  n = int(s)
  if n == 0: break
  print int(math.ceil(step[n]/3650.0))

Fixed submission:
import math

steps=[1, 1, 2, 4]+ [0]*27
for i in range(4, 31):
  steps[i] = steps[i-1] + steps[i-2] + steps[i-3]

while True:
  n = input()
  if n == 0: break
  print int(math.ceil(steps[n]/3650.0))

Buggy python submission (verdict: Runtime Error):
import sys, math
step = [1,1,2,4] + [0]*26
for i in range(4,31):
  step[i] = step[i-1] + step[i-2] + step[i-3]

for s in sys.stdin:
  n = int(s)
  if n == 0: break
  print int(math.ceil(step[n]/3650.0))

Fixed submission:
import math

steps=[1, 1, 2, 4]+ [0]*27
for i in range(4, 31):
  steps[i] = steps[i-1] + steps[i-2] + steps[i-3]

while True:
  n = input()
  if n == 0: break
  print int(math.ceil(steps[n]/3650.0))

Buggy python submission (verdict: Runtime Error):
import math
step = [1,1,2,4] + [0]*27
for i in range(4,31):
  step[i] = step[i-1] + step[i-2] + step[i-3]

while True:
  n = int(s)
  if n == 0: break
  print int(math.ceil(step[n]/3650.0))

Fixed submission:
import math

steps=[1, 1, 2, 4]+ [0]*27
for i in range(4, 31):
  steps[i] = steps[i-1] + steps[i-2] + steps[i-3]

while True:
  n = input()
  if n == 0: break
  print int(math.ceil(steps[n]/3650.0))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math

lines = [line for line in stdin]

for line in lines:
    a, b = [float(n) for n in line]
    print(math.floor(math.log10(a + b)))
    # x1, y1, x2, y2, x3, y3, xp, yp = [float(r) for r in line]
    # print(x1, y1, x2, y2, x3, y3, xp, yp)

Fixed submission:
from sys import stdin
import math
import fileinput

for line in fileinput.input():
    a, b = [int(n) for n in line.split()]
    print(math.floor(math.log10(a + b) + 1))
    # x1, y1, x2, y2, x3, y3, xp, yp = [float(r) for r in line]
    # print(x1, y1, x2, y2, x3, y3, xp, yp)
Buggy python submission (verdict: Runtime Error):
import sys

#list = sys.stdin.readlines()

i=0
list = []
for line in sys.stdin.readlines():
	list.append(int(line.strip("\n")))

print soted(list, reverse=True)[0]
print soted(list, reverse=True)[1]
print soted(list, reverse=True)[2]

Fixed submission:
import sys

#list = sys.stdin.readlines()

i=0
list = []
for line in sys.stdin.readlines():
	list.append(int(line.strip("\n")))

print sorted(list, reverse=True)[0]
print sorted(list, reverse=True)[1]
print sorted(list, reverse=True)[2]
Buggy python submission (verdict: Runtime Error):
if __name__ == "__main__":
    nset = int(input())

    for i in range(0, nset):
        sa = input()
        sb = input()
        a = int(sa)
        b = int(sb)
        c = a + b

        if len(sa) > 80 or len(sb) > 80 or len(str(c)) > 80:
            print("overflow")
        else:
            print(c)

Fixed submission:
if __name__ == "__main__":
    nset = int(input())

    for i in range(0, nset):
        sa = input()
        sb = input()
        a = int(sa)
        b = int(sb)
        c = a + b

        if len(sa) > 80 or len(sb) > 80 or len(str(c)) > 80:
            print("overflow")
        else:
            print(c)
Buggy python submission (verdict: Runtime Error):
# Edit: 2014/11/15
# Lang: Python3
# Time: 00.xxs

# File: pc0021.py


if __name__ == "__main__":

    nset = int(input())

    for i in range(0, nset):

        x1, y1, x2, y2, x3, y3, x4, y4 = list(map(float, input().strip("\n").split(" ")))
        vABx = x2 - x1
        vABy = y2 - y1
        vCDx = x4 - x3
        vCDy = y4 - y3

        mx = vCDx / vABx
        my = vCDy / vABy

        if mx == my:
            print("YES")
        else:
            print("NO")

#

Fixed submission:
# Edit: 2014/11/15
# Lang: Python3
# Time: 00.xxs

# File: pc0021.py


if __name__ == "__main__":

    nset = int(input())

    for i in range(0, nset):

        x1, y1, x2, y2, x3, y3, x4, y4 = list(map(float, input().strip("\n").split(" ")))
        vABx = x2 - x1
        vABy = y2 - y1
        vCDx = x4 - x3
        vCDy = y4 - y3

        #mx = vCDx / vABx
        #my = vCDy / vABy

        #if abs(mx - my) < 1e-10:
        if abs(vABx*vCDy - vCDx*vABy) < 1e-10:
            print("YES")
        else:
            print("NO")
        #print(mx-my)

#

Buggy python submission (verdict: Runtime Error):
# Edit: 2014/11/15
# Lang: Python3
# Time: 00.xxs

# File: pc0021.py


if __name__ == "__main__":

    nset = int(input())

    for i in range(0, nset):

        x1, y1, x2, y2, x3, y3, x4, y4 = list(map(float, input().strip("\n").split(" ")))
        vABx = x2 - x1
        vABy = y2 - y1
        vCDx = x4 - x3
        vCDy = y4 - y3

        mx = vCDx / vABx
        my = vCDy / vABy

        if abs(mx - my) < 1e-10:
            print("YES")
        else:
            print("NO")
        #print(mx-my)

#

Fixed submission:
# Edit: 2014/11/15
# Lang: Python3
# Time: 00.xxs

# File: pc0021.py


if __name__ == "__main__":

    nset = int(input())

    for i in range(0, nset):

        x1, y1, x2, y2, x3, y3, x4, y4 = list(map(float, input().strip("\n").split(" ")))
        vABx = x2 - x1
        vABy = y2 - y1
        vCDx = x4 - x3
        vCDy = y4 - y3

        #mx = vCDx / vABx
        #my = vCDy / vABy

        #if abs(mx - my) < 1e-10:
        if abs(vABx*vCDy - vCDx*vABy) < 1e-10:
            print("YES")
        else:
            print("NO")
        #print(mx-my)

#
Buggy python submission (verdict: Runtime Error):
    n = int(input())
    # print("n:",n)
    hl = []

    for i in range(n):
        hl.append(int(input()))
    #print(hl)

    #hl = [5, 5]
    #hl = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
    # hl = [1,2,3,4,5]
    #hl = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

    i = 0
    ans = 1

    """
    for h in hl:
        d = i//4
        a = h-d
        if a<0:
            a=0
        ans += a
        i+=1
    """

    for i, h in enumerate(hl):  #return index, value
        d = i // 4
        a = h - d
        if a < 0:
            a = 0
        ans += a
    print(ans)

Fixed submission:
# Edit: 2014/09/14
# Lang: Python3
# Time: .00s

if __name__ == "__main__":

    n = int(input())
    # print("n:",n)
    hl = []

    for i in range(n):
        hl.append(int(input()))
    # print(hl)

    # hl = [5, 5]
    # hl = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
    # hl = [1,2,3,4,5]
    # hl = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

    i = 0
    d = 0
    ans = 1

    hl = sorted(hl, reverse=True)

    for i, h in enumerate(hl):  # return index, value
        #d = i // 4
        a = h - d
        if a < 0:
            a = 0
        ans += a
        if i % 4 == 3:
            d += 1
    print(ans)
    #print(type(ans))
Buggy python submission (verdict: Runtime Error):
from collections import Counter

def add(s, tw):
    if tw in s:
        s[tw] += 1
    else:
        s[tw] = 1

while 1:
    ws, hs, w, h = {}, {}, [], []
    n, m = map(int, raw_input().split())
    if n|m == 0: break

    for i in range(n):
        t = s = input()
        add(ws, s)
        for pw in reversed(w):
            s+=pw
            add(ws, s)
        w.append(t)

    for i in range(m):
        t = s = input()
        add(hs, s)
        for pw in reversed(h):
            s+=pw
            add(hs, s)
        h.append(t)

    ans = 0
    for w, wn in ws.iteritems():
        for h, hn in hs.iteritems():
            if w == h:
                ans += wn * hn

    print ans

Fixed submission:
from collections import defaultdict

while 1:
    ws, hs, w, h = defaultdict(int), defaultdict(int), [], []
    n, m = map(int, raw_input().split())
    if n|m == 0: break

    for i in range(n):
        t = s = input()
        ws[s]+=1
        for pw in reversed(w):
            s+=pw
            ws[s]+=1
        w.append(t)

    for i in range(m):
        t = s = input()
        hs[s]+=1
        for pw in reversed(h):
            s+=pw
            hs[s]+=1
        h.append(t)

    print sum(ws[a] * hs[a] for a in ws if a in hs)

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

while 1:
    ws, hs, w, h = defaultdict(lambda:0), defaultdict(lambda:0), [], []
    n, m = map(int, raw_input().split())
    if n|m == 0: break

    for i in range(n):
        t = s = input()
        ws[s]+=1
        for pw in reversed(w):
            s+=pw
            ws[s]+=1
        w.append(t)

    for i in range(m):
        t = s = input()
        hs[s]+=1
        for pw in reversed(h):
            s+=pw
            hs[s]+=1
        h.append(t)

    ans = 0
    for w, wn in ws.iteritems():
        for h, hn in hs.iteritems():
            if w == h:
                ans += wn * hn
    print ans

Fixed submission:
from collections import defaultdict

while 1:
    ws, hs, w, h = defaultdict(int), defaultdict(int), [], []
    n, m = map(int, raw_input().split())
    if n|m == 0: break

    for i in range(n):
        t = s = input()
        ws[s]+=1
        for pw in reversed(w):
            s+=pw
            ws[s]+=1
        w.append(t)

    for i in range(m):
        t = s = input()
        hs[s]+=1
        for pw in reversed(h):
            s+=pw
            hs[s]+=1
        h.append(t)

    print sum(ws[a] * hs[a] for a in ws if a in hs)
Buggy python submission (verdict: Runtime Error):
while 1:
    i = input().split()
    if not i:
        break

    print(len(str(sum(map(int, i)))))

Fixed submission:
try:
    while 1:
        print(len(str(sum(map(int, input().split())))))
except Exception:
    pass

Buggy python submission (verdict: Runtime Error):
while 1:
    i = input()
    if not i:
        break

    print(len(str(sum(map(int, i.split())))))

Fixed submission:
try:
    while 1:
        print(len(str(sum(map(int, input().split())))))
except Exception:
    pass
Buggy python submission (verdict: Time Limit Exceeded):
while 1:
    try:
        y = 4.9 * (float(input()) / 9.8) ** 2
        N = 1
        while N * 5 - 5 < y:
            N += 1
        print(N)
    except:
        pass

Fixed submission:
try:
    while 1:
        y = 4.9 * (float(input()) / 9.8) ** 2
        N = 1
        while N * 5 - 5 < y:
            N += 1
        print(N)
except:
    pass
Buggy python submission (verdict: Time Limit Exceeded):
def f2(cnt, n, ci):
    if n < ci:
        return 0
    elif n == ci and cnt > 1:
        return 0
    elif n == ci and cnt == 1:
        return 1
    else:
        v = f2(cnt - 1, n - ci, ci + 1)
        v += f2(cnt, n, ci + 1)
        return v


while 1:
    n, s = map(int, input().split())
    if n == 0 and s == 0:
        break
    print(f2(n, s, 0))

Fixed submission:
def f2(cnt, n, ci):
    if ci >= 10 or n > 45:
        return 0
    elif n < ci:
        return 0
    elif n == ci and cnt > 1:
        return 0
    elif n == ci and cnt == 1:
        return 1
    else:
        v = f2(cnt - 1, n - ci, ci + 1)
        v += f2(cnt, n, ci + 1)
        return v


while 1:
    n, s = map(int, input().split())
    if n == 0 and s == 0:
        break
    print(f2(n, s, 0))
Buggy python submission (verdict: Runtime Error):
while 1:
    t = int(input())
    if t == 0:break
    n = int(input())
    x = 0
    for i in range(n):
        x += (lambda lst:lst[-1] - lst[0])(list(map(int,input().split())))
    print('OK' if t<=x else (t-x))
while 1:
    t = int(input())
    if t == 0:break
    #n = int(input())
    #x = 0
    #for i in range(n):
    t -= sum(map(lambda lst:lst[-1] - lst[0],[ list(map(int,input().split())) for i in range(int(input())) ]))
    print('OK' if t<=0 else t)

Fixed submission:
while 1:
    t = int(input())
    if t == 0:break
    t -= sum(map(lambda lst:lst[-1] - lst[0],[ list(map(int,input().split())) for i in range(int(input())) ]))
    print('OK' if t<=0 else t)
Buggy python submission (verdict: Runtime Error):
while 1:
    N = int(input())
    if N == 0:break
    lst = list(map(int,input().split()))

    s_len = 1
    n = lst[-1]
#    for v in reversed(lst[:-1]):
#        if v == n-1:
#           s_len += 1
#           n -= 1
#        else:
#            break

    
    result = -1
    for i in range(10000):
        flg = True
        for j in range(len(lst)):
            if j+1 != lst[j]:
                flg = False
        if flg:
            result = i
            break

#        if len(lst) == s_len:
#            result = i
#            break

        #抜くブロック数を取得
        cnt = 0
        for j in reversed(range(len(lst))):
            cnt += 1
            lst[j] -= 1
            if lst[j] == 0:
#                if j >= len(lst)-s_len:
#                    s_len -=1
#                elif j == len(lst)-s_len-1 and j > 0 and s_len > 0:
#                    if lst[j-1] ==lst[len(lst)-s_len]:
#                        s_len += 1
                
                lst.pop(j)
        lst.append(cnt)
   #     print(lst)
#        if cnt == lst[-2]+1:
#            s_len += 1
#        else:
#            s_len = 1
        
    print(result)

            


    

Fixed submission:
import math

def is_sankaku(v):
    x = (math.sqrt(8*v + 1) - 1 ) / 2
    return x == int(x)

def check(lst):
    for i,v in enumerate(lst):
        if v != i + 1:
            return False
        elif i == len(lst)-1:
            return True

while 1:
    N = int(input())
    if N == 0:break
    lst = list(map(int,input().split()))
    if not is_sankaku(sum(lst)):
        print(-1)
        continue

    result = -1
    for count in range(10000):
        if check(lst):
            result = count 
            break
        spam = len(lst)
        lst = [x-1 for x in lst if x-1 > 0]
        lst.append(spam)
        
    print(result)
Buggy python submission (verdict: Runtime Error):
BIN = [0] * 32

v = 1
for i in range(24, 0, -1):
    BIN[i] = v
    v *= 2
v = float(1) / 2
for i in range(25, 32):
    BIN[i] = v
    v /= 2

while 1:
    Q = int(input())
    if not Q:break

    for i in range(Q):
        inp = format(int(input(),16),'b').zfill(32)
        res = float(0)
        for j, v in enumerate(list(inp)[1:]):
            #print(str(BIN[j]) + ' ' + v + ' '  + str(float(v) * BIN[j]))
            res += BIN[j+1] * int(v)

        print(('-' if inp[0] == '1' else '') + str(res))

Fixed submission:
BIN = [0] * 32

v = 1
for i in range(24, 0, -1):
    BIN[i] = v
    v *= 2
v = float(1) / 2
for i in range(25, 32):
    BIN[i] = v
    v /= 2

Q = int(input())

for i in range(Q):
    inp = format(int(input(),16),'b').zfill(32)
    res = float(0)
    for j, v in enumerate(list(inp)[1:]):
        #print(str(BIN[j]) + ' ' + v + ' '  + str(float(v) * BIN[j]))
        res += BIN[j+1] * int(v)

    print(('-' if inp[0] == '1' else '') + str(res))
Buggy python submission (verdict: Runtime Error):
for i in range(int(input())):
    res = 0
    c,a,n = list(map(int,input().split()))
    res = min(n,a,c)
    c -= res
    a -= res
    if c >= 2 and a >= 1:
        cca += min(c//2,a)
        c -= cca*2

    if c >=3:
        res += c//3

    print(res)

Fixed submission:
for i in range(int(input())):
    res = 0
    c,a,n = list(map(int,input().split()))
    res = min(n,a,c)
    c -= res
    a -= res
    if c >= 2 and a >= 1:
        cca = min(c//2,a)
        c -= cca*2
        res += cca

    if c >=3:
        res += c//3

    print(res)
Buggy python submission (verdict: Time Limit Exceeded):
S = [0 for i in range(300000)]
A = [-1, 1]
for i in range(1, int(300000 / 7) + 1):
    d = 7 * i
    for a in A:
        da = d + a
        if da < 300000 and S[da] == 0:
            S[da] = 1
            for j in range(2, int(300000 / 2)):
                if da * j >= 300000:break
                S[da * j] = -1

while 1:
    n = int(input())
    if n == 1:break
    res = [str(n) + ':']
    for i in range(2, n+1):
        if S[i] == 1 and n % i == 0:
            res.append(str(i))

    print(' '.join(res))

Fixed submission:
S = [0 for i in range(300000)]
S2 = []
A = [-1, 1]
for i in range(1, int(300000 / 7) + 1):
    d = 7 * i
    for a in A:
        da = d + a
        if da < 300000 and S[da] == 0:
            S2.append(da)
            for j in range(2, int(300000 / 2)):
                if da * j >= 300000:break
                S[da * j] = -1
while 1:
    n = int(input())
    if n == 1:break
    print(str(n) + ':',' '.join([str(x) for x in S2 if n % x == 0 and x <= n]))

Buggy python submission (verdict: Time Limit Exceeded):
S = [0 for i in range(300000)]
S2 = []
A = [-1, 1]
for i in range(1, int(300000 / 7) + 1):
    d = 7 * i
    for a in A:
        da = d + a
        if da < 300000 and S[da] == 0:
            S2.append(str(da))
            for j in range(2, int(300000 / 2)):
                if da * j >= 300000:break
                S[da * j] = -1
while 1:
    n = int(input())
    if n == 1:break
    res = [str(n) + ':']
    res += [x for x in S2 if int(x) <= n and n % int(x) == 0]
    print(' '.join(res))

Fixed submission:
S = [0 for i in range(300000)]
S2 = []
A = [-1, 1]
for i in range(1, int(300000 / 7) + 1):
    d = 7 * i
    for a in A:
        da = d + a
        if da < 300000 and S[da] == 0:
            S2.append(da)
            for j in range(2, int(300000 / 2)):
                if da * j >= 300000:break
                S[da * j] = -1
while 1:
    n = int(input())
    if n == 1:break
    print(str(n) + ':',' '.join([str(x) for x in S2 if n % x == 0 and x <= n]))

Buggy python submission (verdict: Time Limit Exceeded):
S = [0 for i in range(300000)]
S2 = []
A = [-1, 1]
for i in range(1, int(300000 / 7) + 1):
    d = 7 * i
    for a in A:
        da = d + a
        if da < 300000 and S[da] == 0:
            S2.append(str(da))
            for j in range(2, int(300000 / 2)):
                if da * j >= 300000:break
                S[da * j] = -1
while 1:
    n = int(input())
    if n == 1:break
    #res = [str(n) + ':']
    #res += [x for x in S2 if int(x) <= n and n % int(x) == 0]
    print(str(n) + ':',' '.join([x for x in S2 if int(x) <= n and n % int(x) == 0]))

Fixed submission:
S = [0 for i in range(300000)]
S2 = []
A = [-1, 1]
for i in range(1, int(300000 / 7) + 1):
    d = 7 * i
    for a in A:
        da = d + a
        if da < 300000 and S[da] == 0:
            S2.append(da)
            for j in range(2, int(300000 / 2)):
                if da * j >= 300000:break
                S[da * j] = -1
while 1:
    n = int(input())
    if n == 1:break
    print(str(n) + ':',' '.join([str(x) for x in S2 if n % x == 0 and x <= n]))
Buggy python submission (verdict: Runtime Error):
while 1:
    W, H = list(map(int,input().split()))
    if W == 0:break

    C = [list(map(int, input().split())) for i in range(H) ]

    def work(x,y):
        ax = [-1, 0, 1, -1, 1, -1, 0, 1]
        ay = [-1, -1, -1, 0, 0, 1, 1, 1]

        if C[y][x] != 1:return False
        C[y][x] = -1 #mark

        for _ax in ax:
            for _ay in ay:
                if 0 <= _ax + x < W and 0 <= _ay + y < H:
                    work(_ax + x, _ay + y)
        return True

    cnt = 0
    for x in range(W):
        for y in range(H):
            cnt += work(x,y)
    print(cnt)

Fixed submission:
while 1:
    W, H = list(map(int,input().split()))
    if W == 0:break

    C = [list(map(int, input().split())) for i in range(H) ]
    
    def work(x,y):
        ax = [-1, 0, 1, -1, 1, -1, 0, 1]
        ay = [-1, -1, -1, 0, 0, 1, 1, 1]

        if C[y][x] != 1:return False
        stack = [(x,y)]

        while len(stack) > 0:
            s = stack.pop(-1)
            C[s[1]][s[0]] = -1 #mark

            for _x in [s[0] + _x for _x in ax]:
                for _y in [s[1] + _y for _y in ay]:
                    if 0 <= _x < W and 0 <= _y < H and C[_y][_x] == 1:
                        stack.append((_x, _y))
        return True
#    def work(x,y):
#        ax = [-1, 0, 1, -1, 1, -1, 0, 1]
#        ay = [-1, -1, -1, 0, 0, 1, 1, 1]
#
#        if C[y][x] != 1:return False
#        C[y][x] = -1 #mark
#
#        for _ax in ax:
#            for _ay in ay:
#                if 0 <= _ax + x < W and 0 <= _ay + y < H:
#                    work(_ax + x, _ay + y)
#        return True

    cnt = 0
    for x in range(W):
        for y in range(H):
            cnt += work(x,y)
    print(cnt)