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

Fixed submission:
n = int(input())
cards = [i for i in map(int, input().split())]
alice = []
bob = []
for i in range(n):
    if i % 2 == 0:
        alice.append(max(cards))
        cards.pop(cards.index(max(cards)))
    else:
        bob.append(max(cards))
        cards.pop(cards.index(max(cards)))
print(sum(alice) - sum(bob))

Buggy submission (verdict: Runtime Error):
n = int(input())
cards = sorted(list(map(int, input().split())), reverse=True)
alice = []
bob = []
for i in range(0, n, 2):
    alice.append(max(cards[i]))
    try:
        bob.append(max(cards[i+1]))
    except:
        break
print(sum(alice) - sum(bob))
Problem p03455 (python)

Fixed submission:
a,b = map(int, input().split())

c = a * b
d = c % 2
if d == 0:
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
# --- coding: utf-8 ---

a, b = map(int, input().split())
if a * b % 2 = 0:
  return "Even"
else:
  return "Odd"
Problem p03494 (python)

Fixed submission:
input_num = int(input())
nums = input().split()
ope_cnt = 0
def division_nums(input_num, nums, ope_cnt):
  for i in range(input_num):
    if int(nums[i]) % 2 != 0:
      return ope_cnt
    else:
      nums[i] = int(nums[i]) / 2
  ope_cnt = ope_cnt + 1
  return division_nums(input_num, nums, ope_cnt)
      
print(division_nums(input_num, nums, ope_cnt))

Buggy submission (verdict: Runtime Error):
input_num = int(input())
nums = input().split()
ope_cnt = 0
def division_nums(input_num, nums, ope_cnt):
  for i in range(input_num):
    if int(nums[i]) % 2 != 0:
      return ope_cnt
    else:
      nums[i] = int(nums[i]) / 2
  ope_cnt = ope_cnt + 1
  return division_nums(input_num, nums, ope_cnt)
      
print(divisiton_nums(input_num, nums, ope_cnt))
Problem p02732 (python)

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

m = [0] * (N + 1)
for i in range(N):
    m[A[i]] += 1
ans = 0
for i in range(len(m)):
    ans += (m[i] * (m[i] - 1) // 2)
for i in range(N):
    print(ans - m[A[i]] + 1)

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

m = [0] * N
for i in range(N):
    m[A[i]] += 1
ans = 0
for i in range(len(m)):
    ans += (m[i] * (m[i] - 1) // 2)
for i in range(N):
    print(ans - m[A[i]] + 1)
Problem p02888 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import bisect

# input
N = int(input())
L = list(map(int, input().split()))

# solve
ans = 0
L.sort()
for i in range(N):
    for j in range(i + 1, N):
        r = bisect.bisect_left(L, L[i] + L[j])
        l = j + 1
        ans += max(0, r - l)

# output
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

# input
N = int(input())
L = list(map(int, input().split()))

# solve
ans = 0
L.sort()
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        for k in range(k + 1, N):
            if L[k] < L[j] + L[i]:
                ans += 1

# output
print(ans)
Problem p02936 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10 ** 7)

# input & solve
input = sys.stdin.readline
N, Q = map(int, input().split())

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

ans = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    p -= 1
    ans[p] += x

def dfs(v, p=-1):
    for u in to[v]:
        if u == p:
            continue
        ans[u] += ans[v]
        dfs(u, v)

dfs(0)

# output
print(*ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

# input & solve
N, Q = map(int, input().split())

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

ans = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    p -= 1
    ans[p] += x

def dfs(v, p=-1):
    for u in to[v]:
        if u == p:
            continue
        ans[u] += ans[v]
        dfs(u, v)

dfs(0)

# output
print(*ans)
Problem p03607 (python)

Fixed submission:
# -*- coding: utf-8 -*-

# input
N = int(input())
A = list()
for _ in range(N):
    A.append(int(input()))

# solve
ans = set()
for i in range(N):
    if A[i] in ans:
        ans.remove(A[i])
    else:
        ans.add(A[i])

# output
print(len(ans))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

# input
N = int(input())
A = list()
for _ in range(N):
    A.append(int(input()))

# solve
ans = 0
l = [0] * max(A)
for i in range(N):
    l[A[i] - 1] += 1

for i in range(len(l)):
    if l[i] % 2 == 1:
        ans += 1

# output
print(ans)
Problem p02657 (python)

Fixed submission:
a, b = map(int, input().split())
answer = a*b
print(answer)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
answer = 1
 
for i in range(N):
    answer = answer*A[i]
 
if answer>10**18:
    print(-1)
else:
    print(answer)
Problem p02706 (python)

Fixed submission:
a,b = (map(int,input().split()))
c = list(map(int,input().split()))
d = sum(c)

if (a-d) < 0:
    print(-1)
else:
    print(a-d)

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

if (a-d) < 0:
    print(-1)
else:
    print(a-d)

Buggy submission (verdict: Runtime Error):
r = list(map(int,input().split()))
a = r[0]
b = r[1]
c = r[2:]




while b > 0:
    a -= c[b]
    b -= 1
    
    if a < 0:
        print('-1')
    
    print(a)
Problem p02899 (python)

Fixed submission:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
rank = {}
for i in range(N):
    rank[A[i]] = str(i+1)
    
print(' '.join(rank.values()))

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = list(map(int, input().split()))
rank = {}
for i in range(N):
    rank[A[i]] = str(i+1)
    
print(' '.joint(rank.values()))
Problem p03000 (python)

Fixed submission:
import numpy as np

N, X = map(int, input().split())
L = np.array([0] + list(map(int, input().split()))) 

res = sum([1 if e <= X else 0 for e in np.cumsum(L)])

print(res)

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

pos = 0
iter = 0

while pos <= X and len(L) >= iter:
    iter += 1
    pos += L[iter-1]
    

print(iter)
Problem p03106 (python)

Fixed submission:
A, B, K = map(int, input().split())

count = 0
cand = []
denom = 0

for i in range(1, min(A, B)+1):
    denom += 1
    if A % denom == 0 and B % denom == 0:
        cand.append(denom)

print(cand[-K])

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

count = 0
cand = []
denom = 0

for i in range(1, min(A, B)):
    denom += 1
    if A % denom == 0 and B % denom == 0:
        cand.append(denom)

print(cand[-K])
Problem p03131 (python)

Fixed submission:
k, a, b = map(int, input().split())

if a < b - 2 and k >= a + 1:
    k -= a - 1
    res = a
    res += (k//2) * (b - a) + (k % 2)
else:
    res = k + 1

print(res)

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

if a < b - 2:
    if k > (a + 2):
        k2 = k - (a + 2)
        res = b + (k2//2 + 1) * (b - a)
        if k2 % 2 == 0:
            res += 1
else:
    res = k + 1

print(res)

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

if a < b - 2:
    if k > (a + 2):
        k2 = k - (a + 2)
        res = b + (b-a) + (k2//2) * (b - a) -1
        if k2 % 2 == 1:
            res += 1
else:
    res = k + 1

print(res)
Problem p03212 (python)

Fixed submission:
s = input()
n = int(s)
dg = len(s)

all_list = []

for i in '753':
    for j in '753':
        for k in '753':
            all_list.append(''.join([i,j,k]))

for i in range(4,dg+1):
    add_list = []
    for c in '753':
        add_list += [''.join(c+e) for e in all_list]
    all_list += add_list

all_list = set(all_list)
res = sum([True for _ in all_list if set(list(_))=={'7','5','3'} and int(_) <= n])
print(res)

Buggy submission (verdict: Runtime Error):
import numpy as np
import math

s = input()
dg = len(s)

count = 0

if dg < 5:
    for i in range(1,int(s)):
        if set(list(str(i))) == {'7','5','3'}:
            count += 1

    print(count)
else:
    import ipdb; ipdb.set_trace()
    base = (math.factorial(dg-1))/(math.factorial(dg-4)*math.factorial(3)) * (3**(dg-4))
    for i in range(10**dg, int(s)+1):
        if set(list(str(i))) == {'7','5','3'}:
            count += 1
    print(count + base)
Problem p03260 (python)

Fixed submission:
a, b = map(int,input().split())

if (a*b)%2 == 0:
    print('No')
else:
    print('Yes')

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

if (a*b)%2 == 0:
    print('No')
else:
    print('Yes')

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

if (a*b)%2 ==0:
    print('No')
else:
    print('Yes')
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())
s_list = list(map(int, list(S)))

flag = False
for k in range( min(len(S), K) ):
    if s_list[k] != 1:
        flag = True
        break

if flag:
    print(s_list[k])
else:
    print(1)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
s_list = list(map(int, list(S)))

for k in range(len(S)):
    if s_list[k] != 1:
        flag = True
        break

if flag:
    print(s_list[1])
else:
    print(1)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
s_list = list(map(int, list(S)))

for k in range(len(S)):
    if s_list[k] != 1:
        flag = True
        break

if flag:
    print(s_list[k])
else:
    print(1)
Problem p03294 (python)

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

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# 最小公倍数を求める関数
def lcm(a,b):
    return int((a*b)/gcd(a,b))

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


m = lcm(a[0],a[1])
for i in range(1,len(a)):
    m = lcm(m,a[i])

res = int(sum([(m-1) % e for e in a]))
print(res)

Buggy submission (verdict: Runtime Error):
from math import gcd

# 最小公倍数を求める関数
def lcm(a,b):
    return int((a*b)/gcd(a,b))

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


m = lcm(a[0],a[1])
for i in range(1,len(a)):
    m = lcm(m,a[i])

res = int(sum([(m-1) % e for e in a]))
print(res)
Problem p03386 (python)

Fixed submission:
a, b, k = map(int, input().split())

res = set()

for i in range(a, a+k):
    if i <= b:
        res.add(i)

for i in range(b-k+1, b+1):
    if a <= i:
        res.add(i)

# print(res)

for i in sorted(list(res)):
    print(i)

Buggy submission (verdict: Runtime Error):
iter_list = list(range(a,a+k+1)) + list(range(b-k, b+1))
cand = sorted(list(set(iter_list)))
for i in cand:
    if a <= i and i <= b:
        print(i)

Buggy submission (verdict: Runtime Error):
for i in range(a,b+1):
    if i <= (a+k) or i >= (b-k):
        print(i)
Problem p03387 (python)

Fixed submission:
a = list(map(int, input().split()))
ds = [abs(e - max(a)) for e in a if e-max(a) != 0]

if len(ds) == 1:
    if ds[0] % 2 == 0:
        res = ds[0] // 2
    else:
        res = (ds[0]-1) // 2 + 2
elif len(ds) > 1:
    base = min(ds) - 1
    rem = max(ds) - base
    if rem == 1:
        res = base + 1
    elif rem % 2 == 0:
        res = base + (rem - 2) // 2 + 3
    elif rem % 2 != 0:
        res = base + (rem - 1) // 2 + 1
else:
    res = 0

print(res)

Buggy submission (verdict: Runtime Error):
a = list(map(int, input().split()))
ds = [abs(e - max(a)) for e in a if e-max(a) != 0]

if ds:
    base = min(ds) - 1
    rem = max(ds) - base
    if rem == 1:
        print(base + 1)
    elif rem % 2 == 0:
        res = base + (rem - 2) // 2 + 3
    elif rem % 2 != 0:
        res = base + (rem - 1) // 2 + 1
else:
    res = 0

print(res)
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
if a*b % 2 == 0:
    print('Even')
else:
    print('Odd')

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a*b % 2 = 0:
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a*b % 2 = 0:
    print("Even")
else:
    print("Odd")
Problem p03694 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
print(max(a) - min(a))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split())
print(max(a) - min(a))
Problem p02641 (python)

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))

    if x not in p:
        print(x)
    else:
        off = 1
        for i in range(200):
            k = x - off
            if k not in p and -99 < k <= 200:
                print(k)
                break
            k = x + off
            if k not in p and -99 < k <= 200:
                print(k)
                break
            off += 1

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    absol = 1000

    for i in range(1, 101):
        if i not in p:
            if abs(i - x) < absol:
                absol = abs(i - x)
                ans = i
    print(ans)

if __name__ == '__main__':
    main()
Problem p02719 (python)

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

if n == 0 or k == 1:
    print(0)
else:
    if n > k:
        n %= k
    print(min(n, k-n))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
ans = n
done = [n]

if k == 1 or n == k:
    print(0)
elif n > k:
    r = n % k
    print(k-r)
elif n < k:
    print(k%n)
Problem p02742 (python)

Fixed submission:
h, w = map(int, input().split())
if h == 1 or w == 1:
    print(1)
else:
    print(int(((h*w)+1) / 2))

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
if h == 1 or w == 1:
    print(a)
else:
    print(int(((h*w)+1) / 2))
Problem p02837 (python)

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    # 証言が矛盾していないかチェックする
    def check(bit):
        for i in range(n):
            if not bit & (1 << i):
                continue

            for human, is_honest in a[i]:
                if is_honest == 1 and (bit & (1 << human)):
                    continue
                elif is_honest == 0 and not (bit & (1 << human)):
                    continue
                else:
                    return False
        return True

    n = int(input())
    ans = 0
    a = [[] for _ in range(n)]
    for i in range(n):
        m = int(input())
        for j in range(m):
            xy = list(map(int, input().split()))
            xy[0] -= 1
            a[i].append(xy)

    # 全パターン回す
    for bit in range((1 << n)):
        num = 0
        if check(bit):
            for k in range(n):
                if bit & (1 << k):
                    num += 1
            ans = max(ans, num)
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
    # 証言が矛盾していないかチェックする
    def check(bit):
        for i in range(n):
            if not bit & (1 << i):
                continue

            for human, is_honest in a[i]:
                if is_honest == 1 and (bit & (1 << human)):
                    continue
                elif is_honest == 0 and not (bit & (1 << human)):
                    continue
                else:
                    return False
        return True

    n = int(input())
    ans = 0
    a = [[] for _ in range(n)]
    for i in range(n):
        m = int(input())
        for j in range(m):
            xy = list(map(int, input().split()))
            xy[0] -= 1
            a[i].append(xy)

    # 全パターン回す
    for bit in range((1 << n)):
        num = 0
        if check(bit):
            for k in range(n):
                if bit & (1 << k):
                    num += 1
            ans = max(ans, num)
    print(ans)

Buggy submission (verdict: Runtime Error):
# 証言が矛盾していないかチェックする
def check(bit):
  for i in range(n):
    if not bit & (1 << i):
      continue

      for human, is_honest in a[i]:
        if is_honest == 1 and (bit & (1 << human)):
          continue
          elif is_honest == 0 and not (bit & (1 << human)):
            continue
            else:
              return False
            return True

          n = int(input())
          ans = 0
          a = [[] for _ in range(n)]
          for i in range(n):
            m = int(input())
            for j in range(m):
              xy = list(map(int, input().split()))
              xy[0] -= 1
              a[i].append(xy)

              # 全パターン回す
              for bit in range((1 << n)):
                num = 0
                if check(bit):
                  for k in range(n):
                    if bit & (1 << k):
                      num += 1
                      ans = max(ans, num)
                      print(ans)
Problem p04045 (python)

Fixed submission:
n, k = input().split()
d = input().split()
valid = [i for i in range(10) if str(i) not in d]
ans = ''

if valid[-1] < int(n[0]):
    if valid[0] == 0:
        ans += str(valid[1])
    else:
        ans += str(valid[0])
    ans += str(valid[0]) * len(n)
elif valid[-1] == int(n[0]):
    for s in n:
        if s > str(valid[-1]):
            ans = str(valid[-1])
            ans += str(valid[0]) * len(n)
            break
        ans += str(valid[-1])
else:
    for i, s in enumerate(n):
        if i > 0 and ans[i-1] > n[i-1]:
            ans += str(valid[0]) * (len(n)-i)
            break

        for k in valid:
            if k >= int(s):
                ans += str(k)
                break
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = input().split()
d = input().split()
valid = [i for i in range(10) if str(i) not in d]
ans = ''

if valid[-1] < int(n[0]):
    if valid[0] == 0:
        ans += str(valid[1])
    else:
        ans += str(valid[0])
    ans += str(valid[0]) * len(n)
else:
    for i, s in enumerate(n):
        if i > 0 and ans[i-1] > n[i-1]:
            ans += str(valid[0]) * (len(n)-i)
            break

        for k in valid:
            if k >= int(s):
                ans += str(k)
                break
print(ans)
Problem p02664 (python)

Fixed submission:
s = list(input())
if s[0] == '?':
  s[0] = "D"
for i in range(1, len(s)-1):
  if s[i] == '?':
    if s[i-1]== 'D' and (s[i+1] == 'D' or s[i+1] == '?'):
      s[i] = 'P'
    else: 
      s[i] = 'D'
if s[len(s)-1] == '?':
  s[len(s)-1] = 'D'
print("".join(s))

Buggy submission (verdict: Runtime Error):
s = list(input())
if s[0] == '?':
  s[0] = "D"
for i in range(1, len(s)):
  if s[i] == '?':
    if s[i-1]== 'D' and (s[i+1] == 'D' or s[i+1] == '?'):
      s[i] = 'P'
    else: 
      s[i] = 'D'
print("".join(s))
Problem p02669 (python)

Fixed submission:
T = int(input())

for t in range(T):
    N, A, B, C, D = map(int, input().split())
    memo = {}

    def dist(n):
        if n == 0:
            return 0
        if n == 1:
            return D
        if n in memo:
            return memo[n]
        
        ret = min(
            D * n,
            D * abs(n - n//5*5) + C + dist(n//5),
            D * abs(n - (n+4)//5*5) + C + dist((n+4)//5),
            D * abs(n - n//3*3) + B + dist(n//3),
            D * abs(n - (n+2)//3*3) + B + dist((n+2)//3),
            D * abs(n - n//2*2) + A + dist(n//2),
            D * abs(n - (n+1)//2*2) + A + dist((n+1)//2)
        )

        memo[n] = ret
        return ret
    print(dist(N))

Buggy submission (verdict: Runtime Error):
a
Problem p02675 (python)

Fixed submission:
n = input()
if n[-1] == "3":
  print("bon")
elif n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8":
  print("pon")
else:
  print("hon")

Buggy submission (verdict: Runtime Error):
n = input()
if n[-1] == "3":
  print("bon")
if n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8":
  print("pon")
else:
  print(hon)
Problem p02696 (python)

Fixed submission:
a, b, n = map(int, input().split())
c = min(b-1, n)
print(int(a*c/b))

Buggy submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
c = max(b-1, n)
parint(int(a*c/b))
Problem p02702 (python)

Fixed submission:
s=input()[::-1]
ans=0
u=0
d=1
l=[0]*2019
l[0]=1
for i in map(int,s):
  u=(u+i*d)%2019
  l[u]+=1
  d=d*10%2019
for i in l:
  ans+=i*(i-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()[::-1]
ans=0
u=0
d=1
l=[0]*2019
l[0]=1
for i in map(int,s):
  u=u+(i*d)%2019
  l[u]+=1
  d=d*10%2019
for i in l:
  ans+=i*(i-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()[::-1]
ans=0
u=0
d=1
l=[0]*2019
l[0]=1
for i in map(int,s):
  u=(u+i*d%2019)
  l[u]+=1
  d=d*10%2019
for i in l:
  ans+=i*(i-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
n = int(s) // 2019
a = [i*2019 for i in range(1, n+1)]
ans=0
for j in a:
  if j in s:
    ans += 1
print(ans)
Problem p02713 (python)

Fixed submission:
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
K = int(input())
ans = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      ans += gcd(a,b,c)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
K = int(input())
ans = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      ans += gcd(a,b,c)
print(ans)
Problem p02732 (python)

Fixed submission:
import collections
def C(n):
    return n * (n-1) // 2
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
d = {}
sm = 0
for k,v in c.most_common():
    d[k] = v
    sm += C(v)
for a in A:
    print (sm - d[a] + 1)

Buggy submission (verdict: Runtime Error):
import collections
def C(n):
    return n * (n-1) // 2
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
d = []
sm = 0
for k,v in c.most_common():
    d[k] = v
    sm += C(v)
for a in A:
    print (sm - d[a] + 1)
Problem p03062 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
negative = []
positive = []
cnt=0
for i in range(n):
  if a[i] < 0:
    cnt += 1
    negative.append(a[i])
  else:
    positive.append(a[i])
if cnt % 2 == 0:
  print(sum(map(lambda x: abs(x), a)))
elif cnt == len(a):
  a.sort()
  b = a[-1]
  a.remove(a[-1])
  print(b+sum(map(lambda x: abs(x), a)))
else:
  negative.sort()
  positive.sort()
  if abs(negative[-1]) < positive[0]:
    a.remove(negative[-1])
    print(negative[-1]+sum(map(lambda x: abs(x), a)))
  else:
    a.remove(positive[0])
    print(-positive[0]+sum(map(lambda x: abs(x), a)))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
negative = []
positive = []
cnt=0
for i in range(n):
  if a[i] < 0:
    cnt += 1
    negative.append(a[i])
  else:
    positive.append(a[i])
if cnt % 2 == 0:
  print(sum(map(lambda x: abs(x), a)))
else:
  negative.sort()
  positive.sort()
  if abs(negative[-1]) < positive[0]:
    a.remove(negative[-1])
    print(negative[-1]+sum(map(lambda x: abs(x), a)))
  else:
    a.remove(positive[0])
    print(-positive[0]+sum(map(lambda x: abs(x), a)))
Problem p03644 (python)

Fixed submission:
N = int(input())
k = 0
while True:
  if 2**k <= N < 2**(k+1):
    print(2**k)
    break
  k += 1

Buggy submission (verdict: Runtime Error):
N = int(input())
K = 0
while True:
  if 2**k <= N < 2**(k+1):
    print(2**k)
    break
  else:k += 1
Problem p03712 (python)

Fixed submission:
H, W=map(int,input().split())
print("#"*(W+2))
for i in range(H):
  s=input()
  s="#"+s+"#"
  print(s)
print("#"*(W+2))

Buggy submission (verdict: Runtime Error):
H, W=map(int,input().split())
print("#"*(w+2))
for i in range(h):
  s=input()
  s="#"+s+"#"
  print(s)
print("#"*(w+2))