Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03294 (python)

Fixed submission:
# ans

N = int(input())
a = list(map(int, input().split()))

ans = 0

for i in range(N):
  ans += a[i] - 1
  
print(ans)

Buggy submission (verdict: Runtime Error):
# ans

N = int(input())
a = list(map(int, input().split()))
print(sum(a) = N)

Buggy submission (verdict: Runtime Error):
# ans

N = int(input())
a = list(map(int, input().split()))
print(sum(a) = N)
Problem p03323 (python)

Fixed submission:
A, B = map(int, input().split())
 
if A <= 8 and B <= 8:
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):

Copy
Copy
A, B = map(int, input().split())
 
if A <= 8 and B <= 8:
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())

if a <= 8 and b <= 8:
  print('Yay!')
else:
  print(':(')
Problem p03680 (python)

Fixed submission:
N = int(input())
a = [int(input()) for _ in range(N)]
nxt = a[0]-1
cnt = 1
if a[0]-1 == 1:
  print(cnt)
  exit()

for i in range(1, N+1):
  if a[nxt] == 2:
    cnt += 1
    print(cnt)
    exit()
  else:
    nxt = a[nxt] - 1
    cnt += 1
else:    
  print(-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(input()) for _ in range(N)]
cnt = 1

for i in range(N+1):
  nxt = a[i]-1
  cnt += 1
  if a[nxt] == 2:
    print(cnt)
    exit()
  else:
    nxt = a[i] - 1

print(-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(input()) for _ in range(N)]
light = 1
cnt = 0

for i in range(N):
  if i == 0:
    nxt = a[0] - 1
  else:
    nxt = a[nxt]
    
  if nxt == 2:
    break
  else:
    cnt += 1

print(cnt)
Problem p03738 (python)

Fixed submission:
A = int(input())
B = int(input())

if A == B:
  print('EQUAL')
elif A > B:
  print('GREATER')
else:
  print('LESS')

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())

if A == B:
  print('EQUAL')
elif A > B:
  print('GREATER')
else:
  print('LESS')
Problem p03997 (python)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())
 
print((a + b) * h // 2)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
h = int(input())

print({a + b} * h // 2)
Problem p04043 (python)

Fixed submission:
phrases = input().split()
phrases.sort(reverse=True)

if phrases == ['7', '5', '5']:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
phrases = map(int, input().split())
phrases.sort(reverse=True)

if phrases == [7,5,5]:
  print('YES')
else:
  print('NO')
Problem p02641 (python)

Fixed submission:
str1 = input()
lst1 = str1.split()
x = int(lst1[0])
n = int(lst1[1])

string = input()
list = string.split()
p = []
for num in list:
    p.append(int(num))

for i in range(100):
    if (x - i) not in p:
        print(x - i)
        break
    elif (x + i) not in p:
        print(x + i)
        break
    else:
        continue

Buggy submission (verdict: Runtime Error):
x = int(input())
n = int(input())

p = []
for i in range(n):
    p.append(int(input()))

for i in range(100):
    if (x - i) not in p:
        print(x - i)
        break
    elif (x + i) not in p:
        print(x + i)
        break
    else:
        continue

Buggy submission (verdict: Runtime Error):
x = int(input())
n = int(input())

p = []
for i in range(n):
    p.append(int(input()))

for i in range(100):
    if (x - i) not in p:
        print(x - i)
        exit()
    elif (x + i) not in p:
        print(x + i)
        exit()
    else:
        continue
Problem p02607 (python)

Fixed submission:
n=int(input())
l=[0]
c=0
l=l+(list(map(int,input().split())))

try:
  for i in range(1,n+1,2):
    if l[i]&1:
      c+=1
except:
  pass
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[0]
c=0
l.append(map(int,input().split()))
for i in range(1,n+1,2):
  if l[i]&1:
    c+=1
print(c)
Problem p03105 (python)

Fixed submission:
A,B,C=map(int,input().split())
p=B//A
if p>=C:
  print(C)
else:
  print(p)

Buggy submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
l=[]
p=A
q=B
if A>B:
    A=q
    B=p
for i in range(1,B+1):
    if A%i==0 and B%i==0:
        l.append(i)

print(l[K-1])

Buggy submission (verdict: Runtime Error):
A,B,C=map(int(input().split()))
p=B//A
if p>=C:
  print(C)
else:
  print(p)
Problem p02690 (python)

Fixed submission:
x = int(input())
n = [i**5 for i in range(119+1)]

a = 0
b = 0
res = False
i = 0
while not res:
    sign = 1 - 2*(n[i] < x)
    for j in range(i+1):
        if (n[i] - n[j] * sign) == x:
            print(i,j*sign)
            res = True
    i += 1

Buggy submission (verdict: Runtime Error):
x = int(input())
n = [i**5 for i in range(63+1)]

a = 0
b = 0
res = False
i = 0
while not res:
    sign = 1 - 2*(n[i] < x)
    for j in range(i+1):
        if (n[i] - n[j] * sign) == x:
            print(i,j*sign)
            res = True
    i += 1

Buggy submission (verdict: Runtime Error):
x = int(input())
n = [i**5 for i in range(63)]

a = 0
b = 0
res = False
i = 0
while not res:
    sign = 1 - 2*(n[i] < x)
    for j in range(i+1):
        if (n[i] - n[j] * sign) == x:
            print(i,j*sign)
            res = True
    i += 1

Buggy submission (verdict: Runtime Error):
x = int(input())
n = [i**5 for i in range(63)]

a = 0
b = 0
for i in range(len(n)-1):
    now = abs(n[i]-x)
    next = abs(n[i+1]-x)
    if (now<next) or (i+1 == len(n)-1):
        a = i
        break

sign = 1 - 2*(n[a] < x)
pos = 0
while True:
    if (n[a] - n[pos]*sign) == x: 
        b = pos
        break
    pos += 1
print(a,b*sign)
Problem p02741 (python)

Fixed submission:
nums = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(nums[int(input())-1])

Buggy submission (verdict: Runtime Error):
nums = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(nums[int(input())+1])

Buggy submission (verdict: Runtime Error):
nums = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(nums[input()+1])
Problem p02744 (python)

Fixed submission:
N = int(input())
string = [0 for i in range(N)]
calc_str = lambda :"".join(list(chr(i+ord('a')) for i in string))
chr_a = ord('a')
print(calc_str())
now = N-2


while N > 1:
    if string[now+1]-max(string[:now+1]) > 0:
        if now == 0: break
        string[now+1] = 0
        now -= 1
        
    else:
        string[now+1] += 1
        now = N-2

        print(calc_str())

Buggy submission (verdict: Runtime Error):
N = int(input())
string = [0 for i in range(N)]
calc_str = lambda :"".join(list(chr(i+ord('a')) for i in string))
chr_a = ord('a')
print(calc_str())
now = N-2


while True:
    if string[now+1]-max(string[:now+1]) > 0:
        if now == 0: break
        string[now+1] = 0
        now -= 1
        
    else:
        string[now+1] += 1
        now = N-2

        print(calc_str())

Buggy submission (verdict: Runtime Error):
N = int(input())
string = [0 for i in range(N)]
calc_str = lambda :"".join(list(chr(i+ord('a')) for i in string))
chr_a = ord('a')
print(calc_str())
now = N-2


while True:
    if string[now+1]-string[now] > 0:
        if now == 0: break
        string[now+1] = 0
        now -= 1
        
    else:
        string[now+1] += 1
        now = N-2

        print(calc_str())
Problem p02631 (python)

Fixed submission:
n = int(input())
ns = list(map(int, input().split()))
a = ns[0]
for i in range(1, n):
    a = a^ns[i]
print(*[a^int(i) for i in ns])

Buggy submission (verdict: Runtime Error):
n = int(input())
ns = input().split()
a = eval('^'.join(ns))
print(*[a^int(i) for i in ns])
Problem p02642 (python)

Fixed submission:
from collections import Counter
n = int(input())
ns = list(map(int, input().split()))
c = Counter(ns)
ans = 0

l = [True] * (max(ns)+1)
for i in sorted(set(ns)):
    if l[i]:
        j = i*2
        while j < len(l):
            l[j] = False
            j += i

a = set([key for key, value in c.items() if value == 1])
for i in a:
    if l[i]:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ns = list(map(int, input().split()))
ans = 0
from collections import Counter
c = Counter(ns)
dubbles = set([key for key, value in c.items() if value >= 2])
ns = sorted(set(ns))
a = [True] * n
for i in range(n):
    if not a[i]:
        continue
    for j in range(i + 1, n):
        if not a[j]:
            continue
        if ns[j] % ns[i] == 0:
            a[j] = False
print(sum(a))
Problem p02797 (python)

Fixed submission:
n, k, s = map(int, input().split())
if s != 10 ** 9:
    print(*[s if i < k else s + 1 for i in range(n)])
else:
    print(*[s if i < k else 1 for i in range(n)])

Buggy submission (verdict: Runtime Error):
n, k, s = map(int, input().split())
if s != 10 ** 9:
    print(*[s if i < k else s + 1 for i in range(n)])
else:
    print(*[s if i < k else 1 for i in range(n)]))
Problem p02850 (python)

Fixed submission:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)

n = int(input())
g = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append([b,i])
ans = [None] * (n-1)

def dfs(now, color):
    cnt = 1
    for to, num in g[now]:
        if cnt == color:
            cnt += 1
        ans[num] = cnt
        dfs(to, cnt)
        cnt += 1
dfs(0, 0)
print(max(ans))
print(*ans, sep='\n')

Buggy submission (verdict: Runtime Error):
n = int(input())
g = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append([b,i])
ans = [None] * (n-1)

def dfs(now, color):
    cnt = 1
    for to, num in g[now]:
        if cnt == color:
            cnt += 1
        ans[num] = cnt
        dfs(to, cnt)
        cnt += 1
dfs(0, 0)
print(max(ans))
print(*ans, sep='\n')
Problem p02982 (python)

Fixed submission:
from itertools import combinations
n, d = map(int, input().split())
l = []
count = 0
for i in range(n):
    l.append(list(map(int, input().split())))
for a, b in combinations(l, 2):
    if (sum((a[i]-b[i])**2 for i in range(d)))**(1/2) % 1 == 0:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
from itertools import combinations
n, d = map(int, input().split())
l = []
count = 0
for i in range(n):
    l.append(list(map(int, input().split())))
for a, b in combinations(l, 2):
    if ((a[0]-b[0])**2+(a[1]-b[1])**2)**(1/2) % 1 == 0:
        count += 1
print(count)
Problem p03014 (python)

Fixed submission:
h, w = map(int, input().split())
grid = ['#' * (h + 2)]
for _ in range(h):
    grid.append('#' + input() + '#')
grid.append('#' * (h + 2))
lgrid = [[0 for _ in range(w+2)] for _ in range(h+2)]
rgrid = [[0 for _ in range(w+2)] for _ in range(h+2)]
dgrid = [[0 for _ in range(w+2)] for _ in range(h+2)]
ugrid = [[0 for _ in range(w+2)] for _ in range(h+2)]
for i in range(1, h+1):
    for j in range(1, w+1):
        if grid[i][j] == '#':
            lgrid[i][j] = 0
            ugrid[i][j] = 0
        else:
            lgrid[i][j] = lgrid[i][j-1] + 1
            ugrid[i][j] = ugrid[i-1][j] + 1
        if grid[i][w+1-j] == '#':
            rgrid[i][w+1-j] = 0
        else:
            rgrid[i][w+1-j] = rgrid[i][w+2-j] + 1
        if grid[h+1-i][j] == '#':
            dgrid[h+1-i][j] = 0
        else:
            dgrid[h+1-i][j] = dgrid[h+2-i][j] + 1        
cnt = 0
for i in range(1, h+1):
    for j in range(1, w+1):
        tmp = lgrid[i][j]+rgrid[i][j]+ugrid[i][j]+dgrid[i][j] - 3
        cnt = max(cnt, tmp)
print(cnt)

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
grid = ['#' * (h + 2)]
for _ in range(h):
    grid.append('#' + input() + '#')
grid.append('#' * (h+2))
def right(cnt, i, j):
    if grid[i][j + 1] == '.':
        cnt = right(cnt+1, i, j + 1)
    return cnt
        
def left(cnt, i, j):
    if grid[i][j - 1] == '.':
        cnt = left(cnt + 1, i, j - 1)
    return cnt
        
def up(cnt, i, j):
    if grid[i + 1][j] == '.':
        cnt = up(cnt + 1, i + 1, j)
    return cnt

def down(cnt, i, j):
    if grid[i - 1][j] == '.':
        cnt = down(cnt + 1, i - 1, j)
    return cnt

cnt = 0
for i in range(h):
    for j in range(w):
        if grid[i][j] == '.':
            tmp = 1
            tmp = right(tmp, i, j)
            tmp = left(tmp, i, j)
            tmp = up(tmp, i, j)
            tmp = down(tmp, i, j)
            cnt = max(cnt, tmp)
print(cnt)
Problem p03074 (python)

Fixed submission:
n, k = map(int, input().split())
s = input()
l = []
c = 1
for i in range(n - 1):
    if s[i] != s[i + 1]:
        l.append(c)
        c = 0
    c += 1
l.append(c)
l += [0]
if s[0] == '0':
    l = [0] + l
tmp = sum(l[:2 * k + 1])
rslt = tmp
for i in range(0, len(l) - 2*k-2, 2):
    tmp = tmp - l[i] - l[i + 1] + l[i + 2 * k + 1] + l[i + 2 * k + 2]
    rslt = max(tmp, rslt)
print(rslt)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
one = [i.count('1') for i in s.split('0') if i.count('1') > 0]
zero = [i.count('0') for i in s.split('1') if i.count('0') > 0]
if s[0] == '0':
    a = sum(one[:k]+zero[:k])
    rslt = a
    for i in range(k, len(zero)):
        if len(zero) > len(one) and i == len(zero)-1:
            a += zero[i]
            a -= zero[i-k]
            rslt = max(rslt, a)
        else:
            a += one[i] + zero[i]       
            a -= one[i-k] + zero[i-k]
            rslt = max(rslt, a)
else:
    a = sum(one[:k+1]+zero[:k])
    rslt = a
    for i in range(k, len(zero)):
        a += one[i+1]+zero[i]
        a -= one[i-k] + zero[i-k]
        rslt = max(rslt, a)
print(rslt)
Problem p03240 (python)

Fixed submission:
def dis(xi, xj, yi, yj):
    return abs(xi - xj) + abs(yi - yj)
n = int(input())
coords = [tuple(map(int, input().split())) for _ in range(n)]
grids = [(i, j) for i in range(101) for j in range(101)]
for x, y, h in coords:
    if h > 0:
        break    
for xj, yj in grids:
    flag = True
    base = dis(x, xj, y, yj) + h
    for xi, yi, hi in coords:
        if hi != max(base-abs(xi-xj)-abs(yi-yj), 0):
            flag = False
    if flag:
        break
print(xj, yj, dis(x, xj, y, yj) + h)

Buggy submission (verdict: Runtime Error):
from itertools import combinations
def dis(xi, xj, yi, yj):
    return abs(xi - xj) + abs(yi - yj)
n = int(input())
coords = []
grids = [(i, j) for i in range(101) for j in range(101)]
grids_set = set(grids)
for i in range(n):
    coords.append(tuple(map(int, input().split())))
xr, yr, hr = coords[0]
for i, j in combinations(coords, 2):
    xi, yi, hi = i
    xj, yj, hj = j
    for grid in grids:
        x, y = grid
        if dis(xi, x, yi, y) + hi != dis(xj, x, yj, y) + hj:
            grids_set.remove(grid)
    grids = list(grids_set)
x, y = grids[0]
print(x, y, dis(x, xr, y, yr)+hr)
Problem p03262 (python)

Fixed submission:
from fractions import gcd
from functools import reduce
def gcd_list(xs):
    return reduce(gcd, xs)

n, x = map(int, input().split())
xs = [abs(x-i) for i in map(int, input().split())]
print(gcd_list(xs))

Buggy submission (verdict: Runtime Error):
from fraction import gcd
from functools import reduce
def gcd_list(xs):
    return reduce(gcd, xs)

n, x = map(int, input().split())
xs = [abs(x-i) for i in map(int, input().split())]
print(gcd_list(xs))
Problem p03294 (python)

Fixed submission:
n = int(input())
ns = list(map(int, input().split()))
print(sum(ns)-len(ns))

Buggy submission (verdict: Runtime Error):
n = int(input())
ns = map(int, input().split())
print(sum(ns)-len(ns))
Problem p03361 (python)

Fixed submission:
from itertools import product
n, m = map(int,input().split())
canvas = []
flag = False
for i in range(n):
    canvas.append(input())
for i,j in product([num for num in range(n)],[num for num in range(m)]):
    if canvas[i][j] == '.':
        continue
    result = 0
    if i > 0 and canvas[i-1][j] == '#':
        result += 1
    if i < n-1 and canvas[i+1][j] == '#':
        result += 1
    if j > 0 and canvas[i][j-1] == '#':
        result += 1
    if j < m-1 and canvas[i][j+1] == '#':
        result += 1
    if result == 0:
        flag = True
        break
if flag:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
from itertools import product
n, m = map(int,input().split())
canvas = []
for i in range(n):
    canvas.append(input())
for i,j in product([num for num in range(n)],[num for num in range(m)]):
    if canvas[i][j] == '.':
        continue
    result = 0
    if i > 0 and canvas[i-1][j] == '#':
        result += 1
    if i < n-1 and canvas[i+1][j] == '#':
        result += 1
    if j > 0 and canvas[i][j-1] == '#':
        result += 1
    if j < m-1 and canvas[i][j+1] == '#':
        result += 1
    if result == 0:
        flag = True
        break
if flag:
    print('No')
else:
    print('Yes')
Problem p03418 (python)

Fixed submission:
def main():
    n, k = map(int, input().split())
    if k == 0:
        print(n ** 2)
        exit()
    cnt = 0
    for i in range(1, n+1):
        p, r = divmod(n, i)
        cnt += max(0, p * (i - k)) + max(0, r - k + 1)
    
    print(cnt)
if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
10 0def main():
    n, k = map(int, input().split())
    if k == 0:
        print(n ** 2)
        exit()
    cnt = 0
    for i in range(1, n+1):
        p, r = divmod(n, i)
        cnt += max(0, p * (i - k)) + max(0, r - k + 1)
    
    print(cnt)
if __name__=='__main__':
    main()
Problem p03488 (python)

Fixed submission:
s = input() + 'T'
n = len(s)
x, y = map(int, input().split())
X = [[], [0]]
xy = 0
cnt =0
for i in s:
    if i == 'F':
        cnt += 1
    else:
        X[xy].append(cnt)
        xy = 1 - xy
        cnt = 0

def f(l):
    if len(l) == 0:
        return [0]
    post = [l[0]]
    for i in range(1, len(l)):
        if l[i]:
            pre = sorted(post)
            post = []
            for j in range(len(pre)):
                if j == 0 or pre[j] != pre[j-1]:
                    post.append(pre[j]+l[i])
                    post.append(pre[j]-l[i])
    return post

print('Yes' if x in f(X[0]) and y in f(X[1]) else 'No')

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)
x, y = map(int, input().split())
dx = []
dy = []
xy = 0
cnt =0
for i in s:
    if i == 'F':
        cnt += 1
    else:
        xy += 1
        xy %= 2
        if xy:
            dx.append(cnt)
        else:
            dy.append(cnt)
        cnt = 0
if cnt != 0:
    if xy:
        dy.append(cnt)
    else:
        dx.append(cnt)
sum_x = sum(dx) + 2
sum_y = sum(dy) + 2
dpx = [[0] * sum_x for i in range(len(dx))]
dpy = [[0] * sum_y for i in range(len(dy))]

if dx:
    dpx[0][dx[0]] = True
if dy:
    dpy[0][dy[0]] = True
    dpy[0][-dy[0]] = True
for i in range(1, len(dx)):
    for j in range(0, sum_x):
        dpx[i][j] = dpx[i-1][j-dx[i]] or dpx[i-1][(j+dx[i])%sum_x]
for i in range(1, len(dy)):
    for j in range(0, sum_y):
        dpy[i][j] = dpy[i-1][j-dy[i]] or dpy[i-1][(j+dy[i])%sum_y]
print('Yes' if x < sum_x and dpx[-1][x] and y < sum_y and dpy[-1][y] else 'No')

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)
x, y = map(int, input().split())
dx = []
dy = []
xy = 0
cnt =0
for i in s:
    if i == 'F':
        cnt += 1
    else:
        xy += 1
        xy %= 2
        if xy:
            dx.append(cnt)
        else:
            dy.append(cnt)
        cnt = 0
if cnt != 0:
    if xy:
        dy.append(cnt)
    else:
        dx.append(cnt)
sum_x = sum(dx) + 2
sum_y = sum(dy) + 2
dpx = [[0] * sum_x for i in range(len(dx))]
dpy = [[0] * sum_y for i in range(len(dy))]

if dx:
    dpx[0][dx[0]] = True
if dy:
    dpy[0][dy[0]] = True
    dpy[0][-dy[0]] = True
for i in range(1, len(dx)):
    for j in range(0, sum_x):
        dpx[i][j] = dpx[i-1][j-dx[i]] or dpx[i-1][(j+dx[i])%sum_x]
for i in range(1, len(dy)):
    for j in range(0, sum_y):
        dpy[i][j] = dpy[i-1][j-dy[i]] or dpy[i-1][(j+dy[i])%sum_y]
print('Yes' if dpx[-1][x] and dpy[-1][y] else 'No')
Problem p03813 (python)

Fixed submission:
n = int(input())
if n < 1200:
    print('ABC')
else:
    print('ARC')

Buggy submission (verdict: Runtime Error):
n = int(input())
if x < 1200:
    print('ABC')
else:
    print('ARC')
Problem p03828 (python)

Fixed submission:
from collections import defaultdict
n = int(input())

factors = defaultdict(int)
for i in range(2, n + 1):
    for j in range(2, i+1):
        while i % j == 0:
            factors[j] += 1
            i //= j
if n == 1:
    print(1)
else:
    a = '*'.join(str(value+1) for value in factors.values())
    print(eval(a)%(10**9+7))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n = int(input())

factors = defaultdict(int)
for i in range(2, n + 1):
    for j in range(2, i+1):
        while i % j == 0:
            factors[j] += 1
            i //= j
a = '*'.join(str(value+1) for value in factors.values())
print(eval(a)%(10**9+7))
Problem p03846 (python)

Fixed submission:
from collections import Counter
n = int(input())
ns = list(map(int, input().split()))
rslt = 0
a = 10 ** 9 + 7
cnt = Counter(ns)
if n % 2 == 0:
    for i in range(1, n, 2):
        if cnt[i] != 2:
            print(0)
            exit()
    rslt = pow(2, n // 2, a)
else:
    for i in range(2, n, 2):
        if cnt[i] != 2:
            print(0)
            exit()
    if cnt[0] == 1:
        rslt = pow(2, n // 2, a)
print(rslt)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
ns = list(map(int, input().split()))
rslt = 0
a = 10 ** 9 + 7
cnt = Counter(ns)
if n % 2 == 0:
    for i in range(1, n, 2):
        if cnt[i] != 2:
            print(0)
            exit()
    rslt = pow(2, n // 2, a)
else:
    for i in range(2, n, 2):
        if cnt[i] != 2:
            print(0)
            exit()
    if c[0] == 1:
        rslt = pow(2, n // 2, a)
print(rslt)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
ns = list(map(int, input().split()))
rslt = 0
a = 10 ** 9 + 7
cnt = Counter(ns)
if n % 2 == 0:
    for i in range(2, n, 2):
        if cnt[i] != 2:
            print(0)
            exit()
    rslt = pow(2, n // 2, a)
else:
    for i in range(1, n, 2):
        if cnt[i] != 2:
            print(0)
            exit()
    if c[0] == 1:
        rslt = pow(2, n // 2, a)
print(rslt)
Problem p02730 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str):
    N = len(S)

    if N == 3:
        if S == S[::-1]:
            print(YES)
            exit()
        else:
            print(NO)
            exit()

    s1 = S[:(N-1)//2]
    s1r = s1[::-1]
    s2 = S[(N+3)//2]
    s2r = s2[::-1]
    # print(s1, s1r, s2, s2r)
    if S == S[::-1] and s1 == s1r and s2 == s2r:
        print(YES)
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str):
    N = len(S)
    s1 = S[:(N-1)//2]
    s1r = s1[::-1]
    s2 = S[(N+3)//2]
    s2r = s2[::-1]
    if S == S[::-1] and s1 == s1r and s2 == s2r:
        print(YES)
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()