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

Fixed submission:
s = input()
print(2 * min(s.count("0"), s.count("1")))

Buggy submission (verdict: Runtime Error):
s = input()
count = 0

while S.find("01") != -1 or S.find("10") != -1:
    count += 2 * s.count("01")
    s = s.replace("01", "")
    count += 2 * s.count("10")
    s = s.replace("10", "")
print(count)
Problem p03137 (python)

Fixed submission:
N, M = map(int, input().split())
nums = list(map(int, input().split()))

if M <= N:
    ans = 0
elif N == 1:
    ans = max(nums) - min(nums)
else:
    nums.sort()
    diffNums = [nums[i+1] - nums[i] for i in range(M-1)]
    diffNums.sort()
    ans = sum(diffNums[:-(N-1)])

print(ans)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left

n, m = map(int, input().split())
l1 = list(map(int, input().split()))
l1.sort()
l2 = []
l2.append(l1)
def divide(l):
    diff = 0
    tmp = []
    for i in l:
        if len(i) > diff:
            tmp = i
    index = bisect_left(l[0], int(sum(tmp) / len(tmp)))
    l.remove(tmp)
    l.append(tmp[:index])
    l.append(tmp[index:])
    return l

i = 0
while i < n - 1:
    l2 = divide(l2)
    i += 1
    
count = 0
for l in l2:
  count += l[-1] - l[0]

print(count)
Problem p03207 (python)

Fixed submission:
n = int(input())
l = [int(input()) for i in range(n)]
l.sort()
total = 0
for i in l:
    total += i
print(total - int(l[n-1] / 2))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [int(input()) for i in range(n)]
l.sort()
for i in l:
    result += i
print(result - l[n] / 2)
Problem p03242 (python)

Fixed submission:
num = list(input())
result = ""
for i in range(len(num)):
    if num[i] == '1':
        result += '9'
    if num[i] == '9':
        result += '1'
print(result)

Buggy submission (verdict: Runtime Error):
num = input().split()
result = ""
for i in num:
    if num[i] == 1:
        result += '9'
    if num[i] == 9:
        result += '1'
print(result)
Problem p03307 (python)

Fixed submission:
n = int(input())
result = n

while True:
    if (result % n == 0) & (result % 2 == 0):
        print(result)
        break
    result = result * 2

Buggy submission (verdict: Runtime Error):
n = int(input())
l = input().split()
l.sort()
print(abs(int(l[0]) - int(l[-1])))
Problem p03631 (python)

Fixed submission:
n = input()
print("Yes") if n[0] == n[2] else print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
print("Yes") if n[0] == n[2] else print("No")
Problem p03767 (python)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
l.sort()
power = 0
for i in range(1,len(l)//3+1):
    power += l[-2*i]
print(power)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
l.sort()


def calc(l):
    if len(l) == 3:
        return l[1]
    power = l[-2]
    l = l[1:-2]
    return calc(l) + power

print(calc(l))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map (int, input().split()))
l.sort()

def calc(l):
    if len(l) == 3:
        return l[1]
    power = l[-2]
    l = l[1:-2]
    return calc(l) + power

print(calc(l))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map (int, input().split()))
l.sort()

def calc(l):
    if len(l) == 3:
        return l[1]
    power = l[-2]
    l = l[1:-2]
    return calc(l) + power

print(calc(l))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map (int, input().split()))
l.sort()

def calc(l):
    if len(l) == 3:
        return l[1]
    l = l[1:-2]
    return calc(l) + l[-2]

print(calc(l))
Problem p02831 (python)

Fixed submission:
from fractions import gcd

A, B = map(int, input().split())

print(A * B // gcd(A, B))

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

def lcm(x, y):
    return x // gcd(x, y) * y

print(lcm(A, B))

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

def lcm(x, y):
    return x // math.gcd(x, y) * y

print(lcm(A, B))

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

def lcm(x, y):
    return x // math.gcd(x, y) * y

print(lcm(A, B))

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

def lcm(x, y):
    return x // math.gcd(x, y)* y

print(lcm(A, B))

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

def lcm(x, y):
    return x * y // math.gcd(x, y)

print(lcm(A, B))

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

def lcm(x, y):
    return x * y // math.gcd(x, y)

print(lcm(A, B))
Problem p02753 (python)

Fixed submission:
s = input()

if "A" in s and "B" in s:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())

for i in range(1, 1001):
    if int(i * 0.08) == a and int(i * 0.1) == b:
        print(i)
        exit()
print(-1)
Problem p02779 (python)

Fixed submission:

n = int(input())
num = [int(i) for i in input().split()]
if len(num) != len(set(num)):
    print("NO")
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
def main():

    n = int(input())
    num = [int(i) for i in input().split()]
    if len(num) <= 1:
        return "YES"
    else:
        for i in range(len(num+1)):
            if num[i] == num[i + 1]:
                return "YES"
            else:
                return "NO"
print(main())
Problem p02819 (python)

Fixed submission:
import math
x = int(input())
def prime_get():
    if x <= 1:
        return []
    prime = [2]
    limit = int(math.sqrt(x))
    data = [i+1 for i in range(2,100004,2)]

    while limit >= data[0]:
        prime.append(data[0])
        data = [j for j in data if j % data[0] != 0]
    return prime+data

ans = prime_get()
ans = [i for i in ans if i >= x]
print(ans[0])

Buggy submission (verdict: Runtime Error):
from sympy import sieve
x = int(input())
s = [i for i in sieve.primerange(2,100004) if i >= x]
print(s[0])
Problem p02935 (python)

Fixed submission:
n = int(input())
v = sorted(list(map(int, input().split())))

while len(v) > 1:
    new_v = (v[0]+v[1]) / 2
    del v[0:2]
    v = [new_v]+v

print(v[0])

Buggy submission (verdict: Runtime Error):
n = int(input())
v = sorted(list(map(int, input().split())))

ans = (v[0]+v[1])/2
for i in range(2,n):
    ans = (a+v[i])/2
print(ans)
Problem p03073 (python)

Fixed submission:
import sys

def main():
    sinputl = sys.stdin.readline

    input = sinputl().strip()
    length = len(input)
    string1 = "10" * (length // 2) + "1" * (length % 2)
    string2 = "01" * (length // 2) + "0" * (length % 2)
    count1 = 0
    count2 = 0

    for i in range(length):
        if input[i] != string1[i]:
            count1 += 1

    for i in range(length):
        if input[i] != string2[i]:
            count2 += 1

    print(min(count1, count2))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

def judge(string):
    mem = ""
    for char in string:
        if mem == char:
            return False
        mem = char

    return True


def main():
    sinputl = sys.stdin.readline

    input = sinputl().strip()
    length = len(input)
    input = int(input, base=2)

    paint = [length]

    for i in range(2 ** length):
        status = input ^ i
        print(bin(status)[2:].zfill(length))
        if judge(bin(status)[2:].zfill(length)):
            paint.append(bin(i).count('1'))

        
    print(min(paint))


if __name__ == "__main__":
    main()
Problem p02762 (python)

Fixed submission:
n, m, k = list (map (int, input ().split ()))

fa = [x for x in range (n + 1)]
siz = [1 for i in range (n + 1)]
dep = [0 for i in range (n + 1)]
e = [1 for i in range (n + 1)]

def find (x) :
    if (fa[x] == x) :
        return x
    fa[x] = find (fa[x])
    return fa[x]

def uni (x, y) :
    u, v = find (x), find (y)
    if (dep[u] >= dep[v]) :
        fa[v] = u
        if (u != v) :
            siz[u] += siz[v]
        if (dep[u] == dep[v]) :
            dep[u] += 1
    else :
        fa[u] = v
        if (u != v) :
            siz[v] += siz[u]

for i in range (m) :
    a, b = list (map (int, input ().split ()))
    uni (a, b)
    e[a] += 1
    e[b] += 1

for i in range (1, n + 1) :
    siz[i] = siz[find (i)]

for i in range (k) :
    c, d = list (map (int, input ().split ()))
    if (find (c) == find (d)) :
        siz[c] -= 1
        siz[d] -= 1

siz = [siz[i] - e[i] for i in range (1, n + 1)]

print (' '.join (list (map (str, siz))))

Buggy submission (verdict: Runtime Error):
fa = [x for x in range (100002)]
ans = [-1 for i in range (100002)]
siz = [0 for i in range (100002)]

def find (x) : 
    fa[x] = x if fa[x] == x else find (fa[x])
    return fa[x]

def union (x, y) :
    fa[find (x)] = find (y)
    
N, M, K = list (map (int, input().split()))

for i in range (M) :
    a, b = list (map (int, input().split()))
    union (a, b)
    ans[a] -= 1
    ans[b] -= 1
    
for i in range (1, N + 1) :
    siz[find(i)] += 1

for i in range (1, N + 1) :
    ans[i] += siz[find (i)]

for i in range (K) :
    c, d = list (map (int, input().split()))
    if (find (c) == find (d)) :
        ans[c] -= 1
        ans[d] -= 1

print (' '.join (list (map(str , ans[1 : N + 1]))))

Buggy submission (verdict: Runtime Error):
n, m, k = list (map (int, input ().split ()))

fa = [x for x in range (n + 1)]
cnt = [1 for i in range (n + 1)]
e = [1 for i in range (n + 1)]

def find (x) :
    if (fa[x] == x) :
        return x
    fa[x] = find (fa[x])
    cnt[x] = cnt[fa[x]]
    return fa[x]

def uni (x, y) :
    u, v = find (x), find (y)
    if (u != v) :
        fa[u] = v
        cnt[u] += cnt[v]
        cnt[v] = cnt[u]

for i in range (m) :
    a, b = list (map (int, input ().split ()))
    uni (a, b)
    e[a] += 1
    e[b] += 1

for i in range (1, n + 1) :
    tmp = find (i)

for i in range (k) :
    c, d = list (map (int, input ().split ()))
    if (find (c) == find (d)) :
        cnt[c] -= 1
        cnt[d] -= 1

cnt = [cnt[i] - e[i] for i in range (1, n + 1)]

print (' '.join (list (map (str, cnt))))
Problem p02790 (python)

Fixed submission:
a1, b1 = map(int, input().split())
a2 = str(a1) * b1
b2 = str(b1) * a1
if int(a2[0]) > int(b2[0]):
    print(b2)
elif int(a2[0]) < int(b2[0]):
    print(a2)
else:
    print(a2)

Buggy submission (verdict: Runtime Error):
a1, b1 = map(int, input().split())
a2 = str(a1) * b1
b2 = str(b1) * a1
if int(a2[1]) > int(b2[1]):
    print(b2)
elif int(a2[1]) < int(b2[1]):
    print(a2)
else:
    print(a2)
Problem p03073 (python)

Fixed submission:
s = input()
c = 0
for i, a in enumerate(s):
    if i % 2 == 0 and a == '0':
        c += 1
    if i % 2 == 1 and a == '1':
        c += 1
print(min(c, len(s)-c))

Buggy submission (verdict: Runtime Error):
s = input()
c = 0
for i, a in enumerate(s):
    if i % 2 == 0 and a == '0':
        c += 1
    if i % 2 == 1 and a == '1':
        c += 1
print(min(c, len(s)-c))
Problem p02695 (python)

Fixed submission:
import sys
import itertools

def main():
    input = sys.stdin.readline
    N, M, Q = map(int, input().split())
    data = range(1, M+1)
    A = list(itertools.combinations_with_replacement(range(1, M+1), N))
    l = []
    m = 0
    for _ in range(Q):
        a, b, c, d = map(int, input().split())
        l.append([a, b, c, d])
    for a_list in A:
        tmp = 0
        for i in l:
            if a_list[i[1] -1] - a_list[i[0] - 1] == i[2]:
                tmp += i[3]
        if tmp > m:
            m = tmp
    return m


if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
import sys

def main():
    input = sys.stdin.readline
    N, M, Q = map(int, input().split())
    data = range(1, M+1)
    A = []
    for i in range(len(data)):
        for j in range(i, len(data)):
            for k in range(j, len(data)):
                A.append([data[i], data[j], data[k]])
    l = []
    m = 0
    for _ in range(Q):
        a, b, c, d = map(int, input().split())
        l.append([a, b, c, d])
    for a_list in A:
        tmp = 0
        for i in l:
            if a_list[i[1] -1] - a_list[i[0] - 1] == i[2]:
                tmp += i[3]
        if tmp > m:
            m = tmp
    return m


if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools

def main():
    input = sys.stdin.readline
    N, M, Q = map(int, input().split())
    data = range(1, M+1)
    A = []
    for i in range(len(data)):
        for j in range(i, len(data)):
            for k in range(j, len(data)):
                A.append([data[i], data[j], data[k]])
    l = []
    m = 0
    for _ in range(Q):
        a, b, c, d = map(int, input().split())
        l.append([a, b, c, d])
    for a_list in A:
        tmp = 0
        for i in l:
            if a_list[i[1] -1] - a_list[i[0] - 1] == i[2]:
                tmp += i[3]
        if tmp > m:
            m = tmp
    return m


if __name__ == '__main__':
    print(main())
Problem p02831 (python)

Fixed submission:
import fractions

a = list(map(int , input().split()))
A = a[0]
B = a[1]

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(int(lcm(A, B)))

Buggy submission (verdict: Runtime Error):
import math

a = list(map(int , input().split()))
A = a[0]
B = a[1]

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A, B))
Problem p03805 (python)

Fixed submission:
import itertools
 
N, M = map(int, input().split())
graph = [[0] * N for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    graph[a-1][b-1] = 1
    graph[b-1][a-1] = 1
 
p = list(itertools.permutations(range(N)))
 
Sum = 0
 
for i in range(len(p)):
    if p[i][0] != 0:
        break
    for j in range(N - 1):
        if graph[p[i][j]][p[i][j + 1]] != 1:
            break
        elif j == N - 2:
            Sum += 1
 
print(Sum)

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))

g = [[] for _ in range(N)]

for i in range(N):
  a, b = list(map(int, input().split()))
  g[a-1].append(b-1)
  g[b-1].append(a-1)

visited = [False for _ in range(N)]

def dfs(v, visited):
  if all(visited):
    return 1
  total = 0
  for cv in g[v]:
    if not visited[cv]:
      visited[cv] = True
      total += dfs(v, visited)
      visited[cv] = False
  return total
    
visited[0] = True
ret = dfs(0, visited)
print(ret)
Problem p02831 (python)

Fixed submission:
from fractions import gcd

N = input().split()

A = int(N[0])
B = int(N[1])

lcm = int(A * B / gcd(A, B))

print(lcm)

Buggy submission (verdict: Runtime Error):
import math

N = input().split()

A = int(N[0])
B = int(N[1])

lcm = int(A * B / math.gcd(A, B))

print(lcm)

Buggy submission (verdict: Runtime Error):
import math

N = input().split()

lcm = int(N[0]) * int(N[1]) / math.gcd(int(N[0]), int(N[1]))

print(int(lcm))
Problem p03207 (python)

Fixed submission:
pr = int(input())
li =[]

for i in range(pr):
    li.append(int(input()))

disc = max(li) // 2

print(sum(li) - disc)

Buggy submission (verdict: Runtime Error):
pr = int(input())
li =[]

for i in range(pr):
    li.append(int(input))

disc = max(li)

print(sum(li) - disc)
Problem p02693 (python)

Fixed submission:
k = int(input())
a, b = list(map(int, input().split()))
isYes = False
for i in range(a, b+1):
    if i % k == 0:
        isYes = True
        break
print('OK' if isYes else 'NG')

Buggy submission (verdict: Runtime Error):
k = input()
a, b = list(map(int, input().split()))
isYes = False
for i in range(a, b+1):
    if i % k == 0:
        isYes = True
        break
print('OK' if isYes else 'NG')

Buggy submission (verdict: Runtime Error):
k = input()
a, b = list(map(int, input().split()))
isYes = False
for i in range(a, b+1):
    if i % k == 0:
        isYes = False
        break
print('OK' if isYes else 'NG')
Problem p02711 (python)

Fixed submission:
n = input()
print('Yes' if '7' in n else 'No')

Buggy submission (verdict: Runtime Error):
n = input()
print('Yes' if 7 in n else 'No')
Problem p02779 (python)

Fixed submission:
from sys import stdin
import math

n = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]

d = {}
for aa in a:
    if aa in d.keys():
        d[aa] += 1
    else:
        d[aa] = 1

result = 'YES'
for key, value in d.items():
    if value > 1:
        result = 'NO'

print(result)

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

n = int(stdin.readline().rstrip())
d = [int(x) for x in stdin.readline().rstrip().split()]

m = [0] * 1000000000

for i in d:
    m[i] += 1

result = 0
for i in m:
    if (i > 1):
        result += 1

if (result > 0):
    print("No")
else:
    print("Yes")

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

n = int(stdin.readline().rstrip())
d = [int(x) for x in stdin.readline().rstrip().split()]

m = [0] * 100

for i in d:
    m[i] += 1

result = 0
for i in m:
    if (i > 1):
        result += 1

if (result > 0):
    print("No")
else:
    print("Yes")

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

n = int(stdin.readline().rstrip())
d = [int(x) for x in stdin.readline().rstrip().split()]

m = [0] * 100

for i in d:
    m[i] += 1

for i in m:
    if (i > 1):
        print("No")
    else:
        print("Yes")
Problem p02831 (python)

Fixed submission:
from sys import stdin
import math
import fractions

a, b = [int(x) for x in stdin.readline().rstrip().split()]

print(int(a * b / fractions.gcd(a, b)))

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

a, b = [int(x) for x in stdin.readline().rstrip().split()]

print(int(a * b / math.gcd(a, b)))
Problem p02847 (python)

Fixed submission:
a = str(input())

if a == "SUN":
  print("7")
elif a == "MON":
  print("6")
elif a == "TUE":
  print("5")
elif a == "WED":
  print("4")
elif a == "THU":
  print("3")
elif a == "FRI":
  print("2")
else:
  print("1")

Buggy submission (verdict: Runtime Error):
a = str(input())

if a == "SUN":
  print("7")
elif a == "MON":
  print("6")
elif a == "TUE":
  print("5")
elif a == "WED":
  print("4")
elif a == "THU":
  print("3")
elif a == "FRI":
  print("2")
else:
  print("1")

SUN,MON,TUE,WED,THU,FRI,SAT
Problem p02859 (python)

Fixed submission:
a = int(input())

print(a**2)

Buggy submission (verdict: Runtime Error):
a = input()

print(a**2)
Problem p02860 (python)

Fixed submission:
a = int(input())

s = str(input())

if a % 2 == 1:
  print("No")
else:
  b = int(a/2)
  if s[:b] == s[b:]:
    print("Yes")
  else:
    print("No")

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

s = string(input())

if a % 2 == 1:
  print("No")
else:
  b = int(a/2)
  if s[:b] == s[b:]:
    print("Yes")
  else:
    print("No")

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

s = string(input())

if a % 2 == 1:
  print("No")
else:
  b = a/2
  if s[:b] == s[b:]:
    print("Yes")
  else:
    print("No")
Problem p02880 (python)

Fixed submission:
a = int(input())
flag = 0

for i in range(9):
  for j in range(9):
    if (i+1)*(j+1) == a:
      flag = 1

if flag == 1:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
a = int(input())
flag = 0

for i in range(8):
  if a % (i+2) == 0:
    flag = 1

if flag = 1:
  print("Yes")
else:
  print("No")
Problem p02771 (python)

Fixed submission:
lis = list(input().split())
a=lis.count(lis[0])
b=lis.count(lis[1])
c=lis.count(lis[2])
if a+b+c == 5:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
lis = list(input().split())
a=lis.count(lis[0])
b=lis.count(lis[1])
c=lis.count(lis[2])
if a+b+C == 4:
    print("Yes")
else:
    print("No")
Problem p02781 (python)

Fixed submission:
def f2(n):
    c = len(n)-1
    nn = n[1:]
    s = c*(c-1)//2 * 9*9 
    s += c * (int(n[0])-1)*9
    nn = str(int(nn))
    s += (len(nn)-1)*9 + int(nn[0])
    return s

n = input()
k = int(input())

if k == 1:
    print((len(n)-1)*9 + int(n[0]))
if k == 2:
    if len(n) >= 2:
        print(f2(n))
    else:
        print(0)
        
if k == 3:
    if len(n) >= 3:
        c = len(n)-1
        nn = n[1:]
        nn = str(int(nn))
        s = c*(c-1)*(c-2)//(3*2) * 9*9*9
        s += (int(n[0])-1) * c*(c-1)//2 * 9*9 
        if len(nn) >= 2:
            s += f2(nn)
        print(s)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
def f2(n):
    c = len(n)-1
    nn = n[1:]
    s = c*(c-1)//2 * 9*9 
    s += c * (int(n[0])-1)*9
    s += (len(nn)-1)*9 + int(nn[0])
    return s

n = input()
k = int(input())

if k == 1:
    print((len(n)-1)*9 + int(n[0]))
if k == 2:
    print(f2(n))

if k == 3:
    c = len(n)-1
    nn = n[1:]
    s = c*(c-1)*(c-2)//(3*2) * 9*9*9
    s += (int(n[0])-1) * c*(c-1)//2 * 9*9 
    s += f2(nn)
    print(s)
Problem p02984 (python)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))

l = l+l
xl = []
for i in range(2):
    a = 0
    m = False
    for j in range(i, n+i):
        if m is False:
            a += l[j]
            m = True
        else:
            a -= l[j]
            m = False
    xl.append(a)
    
for i in range(2, n):
    xl.append(xl[-2] - l[i-2]*2 + l[i-1]*2)
    
print(" ".join(map(str, xl)))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))

l = l+l
xl = []
for i in range(2):
    a = 0
    m = False
    for j in range(i, n+i):
        if m is False:
            a += l[j]
            m = True
        else:
            a -= l[j]
            m = False
    xl.append(a)
    
for i in range(2, n):
    xl.append3(xl[-2] - l[i-2]*2 + l[i-1]*2)
    
print(" ".join(map(str, xl)))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 20 13:50:17 2019

@author: yama
"""

n = int(input())
l = list(map(int, input().split()))

l = l+l
xl = []
for i in range(2):
    a = 0
    m = False
    for j in range(i, n+i):
        if m is False:
            a += l[j]
            m = True
        else:
            a -= l[j]
            m = False
    xl.append(a)
    
for i in range(2, n):
    xl.append3(xl[-2] - l[i-2]*2 + l[i-1]*2)
    
print(" ".join(map(str, xl)))
Problem p03053 (python)

Fixed submission:
from collections import deque

h, w = map(int, input().split())

l = [input() for i in range(h)]
memo = [[-1]*w for i in range(h)]

black_cells = deque()
for i in range(h):
    for j in range(w):
        if l[i][j] == "#":
            black_cells.append((i, j))
            memo[i][j] = 0

count = 0
while black_cells:
    nh, nw = black_cells.popleft()
    count = memo[nh][nw]
    for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        new_nh = nh + dy
        new_nw = nw + dx
        if new_nh < 0 or h <= new_nh or new_nw < 0 or w <= new_nw:
            continue
        if memo[new_nh][new_nw] == -1:
            memo[new_nh][new_nw] = count + 1
            black_cells.append((new_nh, new_nw))
print(count)

Buggy submission (verdict: Runtime Error):
from collections import deque

h, w = map(int, input().split())

l = [input() for i in range(h)]
memo = [[-1]*w for i in range(h)]

black_cells = deque()
for i in range(h):
    for j in range(w):
        if l[i][j] == "#":
            black_cells.append((i, j))
            memo[i][j] = 0

while black_cells:
    nh, nw = black_cells.popleft()
    count = memo[nh, nw]
    for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        new_nh = nh + dy
        new_nw = nw + dx
        if new_nh < 0 or h <= new_nh or new_nw < 0 or w <= new_nw:
            continue
        if memo[new_nh][new_nw] == -1:
            memo[new_nh][new_nw] = count + 1
            black_cells.append((new_nh, new_nw))
print(count)