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

Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

s = STR()
ans = 0
for i in range(len(s)):
    if s[i] == '+':
        ans += 1
    else:
        ans -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, log2
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

s = STR()
ans = 0
for i in range(len(s)):
    if s[i] == '+':
        ans += 1
    else:
        ans -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, log2
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

s = STR()
ans = 0
for i in range(len(s)):
    if s[i] == '+':
        ans += 1
    else:
        ans -= 1
print(ans)
Problem p03986 (python)

Fixed submission:
x = str(input())
n = len(x)
stack = []
for i in range(n):
    if x[i] == 'S':
        stack.append('S')
    elif len(stack) == 0 or stack[len(stack) - 1] == 'T':
        stack.append('T')
    else:
        stack.pop()
print(len(stack))

Buggy submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

x = STR()
l = len(x)
a = x[0]
st = []
tmp = 1
for i in range(1, l):
    if a[i] == a[i-1]:
        tmp += 1
    else:
        st.append(tmp)
        tmp = 1
st.append(tmp)

ll = len(st)
ans = l
if a == 'S':
    if ll % 2 == 1:
        ll -= 1
    for i in range(0, ll, 2):
        ans -= min(st[i], st[i+1]) * 2
    print(ans)
else:
    if ll % 2 == 0:
        ll -= 1
    for i in range(1, ll, 2):
        ans -= min(st[i], st[i+1]) * 2
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

x = STR()
l = len(x)
ans = l
a = x[0]
st = []
tmp = 1
for i in range(1, l):
    if a[i] == a[i-1]:
        tmp += 1
    else:
        st.append(tmp)
        tmp = 1
st.append(tmp)

if a == 'S':
    for i in range(0, len(tmp), 2):
        ans -= min(tmp[i], tmp[i+1]) * 2
    print(ans)
else:
    for i in range(1, len(tmp), 2):
        ans -= min(tmp[i], tmp[i+1]) * 2
    print(ans)

Buggy submission (verdict: Runtime Error):
x = str(input())
n = len(x)
stack = []
for i in range(n):
    if x[i] == 'S':
        stack.append('S')
    elif x[i] == 'T' and (len(stack) == 0 or stack[len(stack) - 1]) == 'T':
        stack.append('T')
    elif x[i] == 'T' and stack[len(stack) - 1] == 'S':
        stack.pop()
print(len(stack))
Problem p02577 (python)

Fixed submission:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a = rr()
b = 0
for i in a:
  b += int(i)
  b = b%9
if b == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a = rr()
b = 0
for　i in a:
  b += int(i)
  b = b%9
if b == 0:
  print('Yes')
else:
  print('No')
Problem p02659 (python)

Fixed submission:
a, b = input().split()
b = b.replace('.', '')
a = int(a)
b = int(b)
print((a*b)//100)

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
ans = 0
d = 2
for d in range(2, int(n**0.5) + 1):
    e = d
    while n%d == 0:
        n //= d
        d *= d
        ans += 1
    while n%e == 0:
        n = n//e

if n >= d:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
ans = 0
d = 2
for d in range(2, int(n**0.5) + 1):
    e = d
    while n%d == 0:
        n //= d
        d *= d
        ans += 1
    while n%e == 0:
        n //= e
if n >= d:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
ans = 0
d = 2
for d in range(2, int(n**0.5) + 1):
    e = d
    while n%d == 0:
        n //= d
        d *= d
        ans += 1
    while n%e == 0:
        n // e
if n >= d:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
a, b = input().split()
b = b.replace('.', '')
int(a)
int(b)
print((a*b)//100)

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import collections
import heapq
import numpy as np

rl = sys.stdin.readline

a, b = map(int, rl().split())

print((a*b)//1)
Problem p02682 (python)

Fixed submission:
a, b, c, k = map(int,input().split())
if a > k:
  print(k)
elif a+b >= k:
  print(a)
else:
  print(a-(k-a-b))

Buggy submission (verdict: Runtime Error):
import sys
a, b, c, d = map(int, sys.stdin.readline().split())
li = [1]*a + [0]*b + [-1]*c
print(sum(li[0:d]))

Buggy submission (verdict: Runtime Error):
import sys
a, b, c, d = map(int, sys.stdin.readline().split())
li = [1]*a + [0]*b + [-1]*c
print(sum(li[0:d]))

Buggy submission (verdict: Runtime Error):
import sys
a, b, c, d = map(int, sys.stdin.readline().split())
li = [1]*a + [0]*b + [-1]*c
print(sum(li[0:d]))
Problem p02712 (python)

Fixed submission:
import sys
n = int(sys.stdin.readline())
t = 0
for i in range(n+1):
  if i%3 != 0 and i%5 != 0:
    t += i
print(t)

Buggy submission (verdict: Runtime Error):
import sys
n = sys.stdin.readline()
t = 0
for i in range(N):
  if i%3 != 0 or i%5 != 0:
    t += i
print(t)

Buggy submission (verdict: Runtime Error):
import sys
n = int(sys.stdin.readline())
t = 0
for i in range(N):
  if i%3 != 0 or i%5 != 0:
    t += i
print(t)

Buggy submission (verdict: Runtime Error):
import sys
n = int（sys.stdin.readline())
t = 0
for i in range(N):
  if i%3 != 0 or i%5 != 0:
    t += i
print(t)
Problem p02723 (python)

Fixed submission:
import sys
S = sys.stdin.readline()
if S[2] == S[3] and S[4] == S[5]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
import sys
S = sys.readline()
if S[2] == S[3] and S[4] == S[5]:
  print('Yes')
else:
  print('No')
Problem p02729 (python)

Fixed submission:
import sys
N, M = map(int, sys.stdin.readline().split())

print(N*(N-1)//2 + M*(M-1)//2)

Buggy submission (verdict: Runtime Error):
N = int(input())
M = int(input())

print(N*(N-1)/2 + M*(M-1)/2)
Problem p02753 (python)

Fixed submission:
s = input()
if s == 'AAA' or s == 'BBB':
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
import sys
n, a, b = map(int, sys.stdin.readline().split())
balls = n // (a+b) * a
if n % (a+b) <= a:
  balls += n % (a+b)
else:
  balls += a
print(balls)

Buggy submission (verdict: Runtime Error):

s =　input()
if s == 'AAA' or 'BBB':
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
import sys
s = sys.stdin.readline()
if s = 'AAA' or 'BBB':
  print('No')
else:
  print('Yes')
Problem p02759 (python)

Fixed submission:
import sys
N = int(sys.stdin.readline())
if N % 2 == 0:
  print(N//2)
else:
  print(N//2 + 1)

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import collections
import heapq
import numpy as np

rl = sys.stdin.readline

n, m = map(int, rl().split())

a = [-1] * 3
isOk = False
for _ in range(m):
    b = list(map(int, rl().split()))
    if b[0]-1 != 2 and b[1] == 0: 
        isOk = True
        break
    if a[b[0]-1] != -1 and a[b[0]-1] != b[1]:
        isOk = True
        break
    a[b[0]-1] = b[1]

if isOk:
    print(-1)
else:
    ans = 0
    a.reverse()
    for i in range(3):
        if a[i] == -1:
            a[i] = 0
        ans += a[i]*(10**(i))
    print(ans)
Problem p02773 (python)

Fixed submission:
import sys
import math
import itertools
import numpy
import collections

rl = sys.stdin.readline

n = int(rl())

li = []
for _ in range(n):
    li.append(rl().rstrip())
c = collections.Counter(li)
max_cnt = 0
li = []
for k, v in c.items():
    if v < max_cnt:
        continue
    elif v == max_cnt:
        li.append(k)
    else:
        max_cnt = v
        li = [k]
li.sort()
for i in li:
    print(i)

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

rl = sys.stdin.readline

n = int(rl())

li = []
for _ in range(n):
    li.append(rl().rstrip())
c = collections.Counter(li)
max_cnt = 0
li = []
for k, v in c.items():
    if v < max_cnt:
        continue
    elif v == max_cnt:
        li.append(k)
    else:
        max_cnt = v
        li = [k]
li.sort()
print('\n'.join(li))

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

rl = sys.stdin.readline

n = int(rl())

li = []
for _ in range(n):
    li.append(rl().rstrip())
c = collections.Counter(li)
max_cnt = 0
li = []
for k, v in c.items():
    if v < max_cnt:
        continue
    elif v == max_cnt:
        li.append(k)
    else:
        max_cnt = v
        li = [k]
li.sort()
print('\n'.join(li))

Buggy submission (verdict: Runtime Error):

import collections

rl = sys.stdin.readline

n = int(rl())

li = []
for _ in range(n):
    li.append(rl().rstrip())
c = collections.Counter(li)
max_cnt = 0
li = []
for k, v in c.items():
    if v < max_cnt:
        continue
    elif v == max_cnt:
        li.append(k)
    else:
        max_cnt = v
        li = [k]
li.sort()
print('\n'.join(li))

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

rl = sys.stdin.readline

n = int(rl())

li = []
for _ in range(n):
    li.append(rl().rstrip())
c = collections.Counter(li)
max_cnt = 0
li = []
for k, v in c.items():
    if v < max_cnt:
        continue
    elif v == max_cnt:
        li.append(k)
    else:
        max_cnt = v
        li = [k]
li.sort()
print('\n'.join(li))

Buggy submission (verdict: Runtime Error):
import sys
n = int(sys.stdin.readline())
li = []
for _ in range(n):
  li.append(sys.stdin.readline().strip())
li2 = list(set(li)).sort(reverse = True)
cnt_box = []
for i in li2:
  cnt_box.append(li.count(i))
m = max(cnt_box)
i = 0
while i < len(cnt_box):
  if cnt_box[i] == m:
    print(li2[i])
  i += 1
Problem p02777 (python)

Fixed submission:
import sys
s, t = map(str, sys.stdin.readline().split())
a, b = map(int, sys.stdin.readline().split())
u = sys.stdin.readline().rstrip()
if s == u:
  print(a-1, b)
else:
  print(a, b-1)

Buggy submission (verdict: Runtime Error):
import sys
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))

n, k = rm()
a = rl()
max_ = 0
for i in range(n-k+1):
  max_ = max(max_, sum(a[i:i+k]))
print((max_+k)/2)
Problem p02785 (python)

Fixed submission:
import sys
n, k = map(int, sys.stdin.readline().split())
li = list(map(int, sys.stdin.readline().split()))
l = len(li)
t = 0
if l > k:
  li.sort()
  li.reverse()
  t = sum(li[k:])
print(t)

Buggy submission (verdict: Runtime Error):
import sys
n, k = map(int, sys.stdin.readline().split())
li = list(map(int, sys.stdin.readline().split()))
l = len(li)
t = 0
if l > k:
  li.sort().reverse()
  t = sum(li[k:])
print(t)
Problem p02819 (python)

Fixed submission:
import sys
import math
import itertools

rl = sys.stdin.readline
x = int(rl())
while True:
    if x == 2:
        print(2)
        break
    if x % 2:
      for i in range(3, x//2, 2):
        if x % i == 0:
            break
      else:
        print(x)
        break
    x += 1

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

rl = sys.stdin.readline
x = int(rl())
while True:
    if x % 2:
      for i in range(3, 7//2, 2):
        if x % i == 0
        break
      else:
        print(x)
        break
    x += 1

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

rl = sys.stdin.readline
x = int(rl())
while True:
    if sympy.isprime(x):
        print(x)
        break
    x += 1
Problem p02831 (python)

Fixed submission:
import sys
import fractions
a, b = map(int, sys.stdin.readline().split())
gcd = fractions.gcd(a, b)
print(a * b // gcd)

Buggy submission (verdict: Runtime Error):
import sys
import fractions
a, b = map(int, sys.stdin.raedline())
gcd = fractions.gcd(a, b)
print(a * b // gcd)
Problem p02860 (python)

Fixed submission:
import sys
n = int(sys.stdin.readline())
s = sys.stdin.readline().strip()
if not n % 2:
  if s[0:n//2] == s[n//2:]:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
import sys
n = int(sys.stdin.readline())
s = sys.stdin.readline().strip()
if not n % 2:
  if s[0:n/2] == s[n/2:]:
    print('Yes')
  else:
    print('No')
else:
  print('No')
Problem p02891 (python)

Fixed submission:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

s = rr()
k = ri()
cnt = 0
i = 0
if len(set(s)) == 1:
  print(int(len(s)*k/2))
  exit()
while i < len(s)-1:
  if s[i] == s[i+1]:
    cnt += 1
    i += 1
  i += 1
cnt1 = 0
i1 = 0
s *= 2
while i1 < len(s)-1:
  if s[i1] == s[i1+1]:
    cnt1 += 1
    i1 += 1
  i1 += 1
print((cnt1 - cnt)*(k-1) + cnt)

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

s = rr()
k = ri()
cnt = 0
i = 0
if len(set(s)) == 1:
  print(int(s*k/2))
  exit()
while i < len(s)-1:
  if s[i] == s[i+1]:
    cnt += 1
    i += 1
  i += 1
print(cnt)
cnt1 = 0
i1 = 0
s *= 2
while i1 < len(s)-1:
  if s[i1] == s[i1+1]:
    cnt1 += 1
    i1 += 1
  i1 += 1
print(cnt1)
print((cnt1 - cnt)*(k-1) + cnt)

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

s = rr()
k = ri()
cnt = 0
for i in range(len(s)-1):
  if s[i] == s[i+1]:
    cnt += 1
print(cnt*k)

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

s = rr()
k = ri()
cnt = 0
for i in range(len(s)-1):
  if len[i] == len[i+1]:
    cnt += 1
print(cnt*k)

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: str(sys.stdin.buffer.readline().rstrip())
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

s = rr()
k = ri()
cnt = 0
for i in range(len(s)-1):
  if len[i] == len[i+1]:
    cnt += 1
print(cnt*k)
Problem p02897 (python)

Fixed submission:
import sys, math
a = int(sys.stdin.readline().rstrip())
b = math.ceil(a / 2)
print(b / a)

Buggy submission (verdict: Runtime Error):
import sys
n, k = map(int, sys.stdin.readline().split())
li = list(map(int, sys.stdin.readline().split()))
cnt = 0
for i in li:
  if i >= k:
    cnt += 1
print(cnt)
Problem p02935 (python)

Fixed submission:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: str(sys.stdin.buffer.readline().rstrip())
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
a = rl()
def heapsort(l):
  li = []
  for v in l:
    heapq.heappush(li, v)
  return [heapq.heappop(li) for _ in range(len(li))]
a = heapsort(a)
ans = a[0]
for i in a:
  ans = (ans + i)/2
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: str(sys.stdin.buffer.readline().rstrip())
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
a = rl()
def heapsort(l):
  li = []
  for v in len(l):
    heappush(li, v)
  return [heappop(li) for _ in range(li)]
a = heapsort(a)
a.reverse()
ans = a[0]
for i in a:
  ans = (ans + i)/2
print(ans)
Problem p02989 (python)

Fixed submission:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
a = rl()
a.sort()
i = n//2
print(a[i] - a[i-1])

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
a = rl()
a.sort()
i = n//2
print(a[i+1] - a[i])
Problem p03012 (python)

Fixed submission:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, li = ri(), rl()
min_ = inf
for i in range(1, n):
  min_ = min(abs(sum(li[0:i]) - sum(li[i:])), min_)
print(min_)

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, li = ri(), rl()
min_ = inf
for i in range(1, n):
  min_ = min(abs(sum(li[0:i] - li[i:])))
print(min_)