Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math

x = int(input())

a = 0
b = 0
while True:
    b = -(x - a ** 5)

    f = False
    if b < 0:
        b = -b
        f = True
        
    for i in range(5):
        b = math.sqrt(b)

    if f == True:
        b = -b
    
    if b - int(b) == 0.0:
        break
    a += 1

print(a, int(b))

Fixed submission:
import math

x = int(input())

f = False
for a in range(-200,200):
    for b in range(-200, 200):
        if a ** 5 - b ** 5 == x:
            print(a, b)
            f = True
            break
    if f == True:
        break

Buggy python submission (verdict: Time Limit Exceeded):
import math

x = int(input())

a = 0
b = 0
while a ** 5 < x:
    a += 1
a -= 1

b = -(x - a ** 5)

f = False
if b < 0:
    b = -b
    f = True
    
for i in range(5):
    b = math.sqrt(b)

if f == True:
    b = -b

i = 1
while b - int(b) != 0.0:
    ap = a + i
    b = -(x - ap ** 5)

    f = False
    if b < 0:
        b = -b
        f = True
        
    for i in range(5):
        b = math.sqrt(b)

    if f == True:
        b = -b

    if b - int(b) == 0.0:
        break

    asub = a - i
    b = -(x - asub ** 5)

    f = False
    if b < 0:
        b = -b
        f = True
        
    for i in range(5):
        b = math.sqrt(b)

    if f == True:
        b = -b
    i += 1

print(a, int(b))

Fixed submission:
import math

x = int(input())

f = False
for a in range(-200,200):
    for b in range(-200, 200):
        if a ** 5 - b ** 5 == x:
            print(a, b)
            f = True
            break
    if f == True:
        break

Buggy python submission (verdict: Time Limit Exceeded):
import math

x = int(input())

a = 0
b = 0
while a ** 5 < x:
    a += 1
a -= 1

b = -(x - a ** 5)

f = False
if b < 0:
    b = -b
    f = True
    
for i in range(5):
    b = math.sqrt(b)

while b - int(b) != 0.0:
    a += 1
    b = -(x - a ** 5)

    f = False
    if b < 0:
        b = -b
        f = True
        
    for i in range(5):
        b = math.sqrt(b)

if f == True:
    b = -int(b)
print(a , b)

Fixed submission:
import math

x = int(input())

f = False
for a in range(-200,200):
    for b in range(-200, 200):
        if a ** 5 - b ** 5 == x:
            print(a, b)
            f = True
            break
    if f == True:
        break
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input().rstrip())

sa = []
for i in range(n):
    line = input().rstrip()
    f = True
    for s in sa:
        if s == line:
            f = False
            break
    
    if f == True:
        sa.append(line)

print(len(sa))


Fixed submission:
n = int(input().rstrip())

sa = []
for i in range(n):
    line = input().rstrip()
    sa.append(line)

print(len(set(sa)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input().rstrip())
line = input().rstrip().split(' ')

a = []
d = [0] * n
for i in range(n):
    num = int(line[i])
    a.append(num)
    d[num - 1] += 1

ans_list = [0] * n
for i in range(n):
    ans_list[i] = int(d[i] * (d[i] - 1) / 2)

for i in range(n):
    ans = 0
    for j in range(n):
        if a[i] == j + 1:
            num = d[j] - 1
            ans += num * (num - 1) / 2
        else:
            ans += ans_list[j]
    
    print(int(ans))


Fixed submission:
n = int(input().rstrip())
line = input().rstrip().split(' ')

a = []
d = [0] * n
for i in range(n):
    num = int(line[i])
    a.append(num)
    d[num - 1] += 1

ans_list = [0] * n
for i in range(n):
    ans_list[i] = int(d[i] * (d[i] - 1) / 2)

total = 0
for i in range(n):
    total += ans_list[i]

for i in range(n):
    ans = total

    ans -= ans_list[a[i] - 1]
    num = d[a[i] - 1] - 1
    ans += num * (num - 1) / 2

    print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
line = input().rstrip().split(' ')
n = int(line[0])
a = int(line[1])
b = int(line[2])

i = 0
ans = 0
while i <= n:
    if i + a <= n:
        ans += a
    else:
        t = n - i
        ans += t
    i += a + b

print(ans)

Fixed submission:
line = input().rstrip().split(' ')
n = int(line[0])
a = int(line[1])
b = int(line[2])

i = 0
ans = 0

t = int(n / (a + b))
ans = t * a

if n > (a + b) * t:
    t2 = n - (a + b) * t
    if t2 > a:
        ans += a
    else:
        ans += n - (a + b) * t

print(ans)

Buggy python submission (verdict: Runtime Error):
line = input().rstrip().split(' ')
n = int(line[0])
a = int(line[1])
b = int(line[2])

i = 0
s = ''
while i <= n:
    s += 'b' * a
    s += 'r' * b
    i += a + b

ans = 0
for i in range(n):
    if s[i] == 'b':
        ans += 1

print(ans)

Fixed submission:
line = input().rstrip().split(' ')
n = int(line[0])
a = int(line[1])
b = int(line[2])

i = 0
ans = 0

t = int(n / (a + b))
ans = t * a

if n > (a + b) * t:
    t2 = n - (a + b) * t
    if t2 > a:
        ans += a
    else:
        ans += n - (a + b) * t

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def attack(x):
    if x <= 1:
        return 1
    else:
        ans = 0
        ans += attack(int(x / 2))
        ans += attack(int(x / 2))
        ans += 1
        return ans

h = int(input().rstrip())
at = attack(h)
print(at)

Fixed submission:
def attack(x):
    if x <= 1:
        return 1
    else:
        ans = 0
        ans += attack(int(x / 2))
        ans *= 2
        ans += 1
        return ans

h = int(input().rstrip())
at = attack(h)

print(at)
Buggy python submission (verdict: Runtime Error):
class Robot:
    def __init__(self, x, l):
        self.x = x
        self.l = l
    
    def __lt__(self, other):
        return self.x < other.x

n = int(input().rstrip())
robos = [None] * n

for i in range(n):
    line = input().rstrip().split(' ')
    robos[i] = Robot(int(line[0]), int(line[1]))

robos.sort()

i = 0
ans = 0
while i < n:
    s = robos[i].x
    r = robos[i].l
    i += 1
    while i < n and robos[i].x <= s + r:
        i += 1
    
    p = robos[i - 1].x
    while i < n and robos[i].x <= p + robos[i].l:
        i += 1
    
    ans += 1

print(ans)

Fixed submission:
h = int(input().rstrip())
w = int(input().rstrip())
n = int(input().rstrip())

if h > w:
    div = h
else:
    div = w

if n % div > 0:
    ans = int(n / div) + 1
else:
    ans = int(n / div)

print(ans)
Buggy python submission (verdict: Runtime Error):
class Robot:
    def __init__(self, left, right):
        self.left = left
        self.right = right
    
    def __lt__(self, other):
        return self.right < other.right

n = int(input().rstrip())
robos = [None] * n

for i in range(n):
    line = input().rstrip().split(' ')
    robos[i] = Robot(int(line[0]) - int(line[1]), int(line[0]) + int(line[1])

robos.sort()

cur = -1000000000
ans = 0
for i in range(n):
    if cur <= robos[i].left:
        ans += 1
        cur = robos[i].right

print(ans)

Fixed submission:
class Robot:
    def __init__(self, left, right):
        self.left = left
        self.right = right
    
    def __lt__(self, other):
        return self.right < other.right

n = int(input().rstrip())
robos = [None] * n

for i in range(n):
    line = input().rstrip().split(' ')
    robos[i] = Robot(int(line[0]) - int(line[1]), int(line[0]) + int(line[1]))

robos.sort()

cur = -1000000000
ans = 0
for i in range(n):
    if cur <= robos[i].left:
        ans += 1
        cur = robos[i].right

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input().rstrip())
robos = []
max = 0

for i in range(n):
    line = input().rstrip().split(' ')
    array = [int(line[0]), int(line[1])]
    robos.append(array)
    if max < array[0] + array[1] - 1:
        max = array[0] + array[1] - 1

field = [0] * max
count = 0
for item in robos:
    countFlg = True
    for i in range(item[0] - item[1] + 1, item[0] + item[1] - 1):
        if i < 0:
            continue
        if field[i] == 0:
            field[i] = 1
        else:
            countFlg = False
            break
    if countFlg == True:
        count += 1

print(count)

Fixed submission:
class Robot:
    def __init__(self, left, right):
        self.left = left
        self.right = right
    
    def __lt__(self, other):
        return self.right < other.right

n = int(input().rstrip())
robos = [None] * n

for i in range(n):
    line = input().rstrip().split(' ')
    robos[i] = Robot(int(line[0]) - int(line[1]), int(line[0]) + int(line[1]))

robos.sort()

cur = -1000000000
ans = 0
for i in range(n):
    if cur <= robos[i].left:
        ans += 1
        cur = robos[i].right

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a,b,h,m=list(map(int, input().split()))


th_a = 360/12 * h + 360/12*m/60
th_b = 360*m/60
print(th_a)
print(th_b)
ab_th = abs(th_a - th_b)
if ab_th > 180:
    ab_th = 360 - ab_th

print(math.sqrt(a*a + b*b -2*a*b*math.cos(math.radians(ab_th))))

Fixed submission:
x = input()
l = [2,4,5,7,9]
i = [0,1,6,8]
if int(x[-1]) in l:
    print("hon")
elif int(x[-1]) in i:
    print("pon")
elif x[-1] == "3":
    print("bon")

Buggy python submission (verdict: Runtime Error):
import math
a,b,h,m=list(map(int, input().split()))


th_a = 360/12 * h + 360/12*m/60
th_b = 360*m/60
print(th_a)
print(th_b)
ab_th = abs(th_a - th_b)
if ab_th >= 180:
    ab_th = 360 - ab_th

print(math.sqrt(a*a + b*b -2*a*b*math.cos(math.radians(ab_th))))

Fixed submission:
x = input()
l = [2,4,5,7,9]
i = [0,1,6,8]
if int(x[-1]) in l:
    print("hon")
elif int(x[-1]) in i:
    print("pon")
elif x[-1] == "3":
    print("bon")
Buggy python submission (verdict: Runtime Error):
if n > k:
    print(n)
elif n + m > k:
    print(n)
else:
    print(n - l)

Fixed submission:
a = list(map(int, input().split()))
n = a[0]
m = a[1]
l = a[2]
k = a[3]

if 0 < k <= n:
    print(k)

elif n < k <= n + m:
    print(n)

elif n+m <= k < n+m+l:
    print(n -1*(k -n -m))

elif n+m+l <= k:
    print(n - l)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline

H, W, M = map(int, readline().split())

h = {}
w = {}
m = {}
for i in range(M):
    hi, wi = map(int, readline().split())
    if hi not in h:
        h[hi] = 1
        m[hi] = [wi]
    else:
        h[hi] += 1
        m[hi].append(wi)
    if wi not in w:
        w[wi] = 1
    else:
        w[wi] += 1

max_h = max(h.values())
max_w = max(w.values())
max_h_list = [kv[0] for kv in h.items() if kv[1] == max_h]
max_w_list = [kv[0] for kv in w.items() if kv[1] == max_w]

for i in max_h_list:
    for j in max_w_list:
        if j not in m[i]:
            print(max_h + max_w)
            exit()
print(max_h + max_w - 1)


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

H, W, M = map(int, readline().split())

h = {}
w = {}
m = {}
for i in range(M):
    hi, wi = map(int, readline().split())
    if hi not in h:
        h[hi] = 1
        m[hi] = set()
        m[hi].add(wi)
    else:
        h[hi] += 1
        m[hi].add(wi)
    if wi not in w:
        w[wi] = 1
    else:
        w[wi] += 1

max_h = max(h.values())
max_w = max(w.values())
max_h_list = [kv[0] for kv in h.items() if kv[1] == max_h]
max_w_list = [kv[0] for kv in w.items() if kv[1] == max_w]

for i in max_h_list:
    for j in max_w_list:
        if j not in m[i]:
            print(max_h + max_w)
            exit()
print(max_h + max_w - 1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline

N, M, K = map(int, readline().split())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))

a = [0]
b = [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

max = 0
for i in range(N+1):
  t = a[i]
  if t > K:
    break
  for j in range(M+1):
    if t + b[j] > K:
      break
    if i + j > max:
      max = i + j
print(max)

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

N, M, K = map(int, readline().split())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))

a = [0]
b = [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

max = 0
j = M
for i in range(N+1):
  t = K - a[i]
  if t < 0:
    break
  while b[j] > t:
    j -= 1
  if i + j > max:
    max = i + j
print(max)

Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline

N, M, K = map(int, readline().split())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))

n = 0
m = 0
t = 0
for i in range(N):
  if t + A[i] <= K:
    n += 1
    t += A[i]
  else:
    break
for i in range(M):
  if t + B[i] <= K:
    m += 1
    t += B[i]
  else:
    break
max = n + m
for i in range(N):
  if n == 0 or m == M :
    break
  t -= A[n]
  n -= 1
  for j in range(M):
    if t + B[m + 1] <= K:
      m += 1
      t += B[m]
    else:
      break
    if m == M:
      break
  if n + m > max:
    max = n + m
print(max)

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

N, M, K = map(int, readline().split())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))

a = [0]
b = [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

max = 0
j = M
for i in range(N+1):
  t = K - a[i]
  if t < 0:
    break
  while b[j] > t:
    j -= 1
  if i + j > max:
    max = i + j
print(max)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
D = {}
for i in A:
  if i in D:
    D[i] += 1
  else:
    D[i] = 1
for i in range(Q):
  s = 0
  bi, ci = map(int, input().split())
  if bi in D:
    if ci in D:
      D[ci] += D[bi]
    else:
      D[ci] = D[bi]
    del D[bi]
  for j in D:
    s += j * D[j]
  print(s)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
D = {}

for i in A:
  if i in D:
    D[i] += 1
  else:
    D[i] = 1
s = 0
for j in D:
  s += j * D[j]
for i in range(Q):
  bi, ci = map(int, input().split())
  if bi in D:
    if ci in D:
      D[ci] += D[bi]
    else:
      D[ci] = D[bi]
    s += (ci - bi) * D[bi]
    del D[bi]
  print(s)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))


for i in range(N):
  s = 0
  for j in range(N):
    if j != i:
      s ^= A[j]
  print(s)

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

s = 0
for i in range(N):
  s ^= A[i]
for i in range(N):
  si = s
  si ^= A[i]
  print(si)
Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
elif N == 100:
  if X <= 50:
    print(-1)
  else:
    print(101)
else:
  p = set(map(int, input().split()))

l = 100
d = 0
for i in range(100):
  if i+1 not in p:
    li = abs(X-i-1)
    if li < l:
      l = li
      d = i+1
    elif li >= l:
      break
print(d)

Fixed submission:
X, N = map(int, input().split())
if X <= 50:
  l = X
  d = 0
else:
  l = 101 - X
  d = 101

if N == 0:
  print(X)
  exit()
elif N == 100:
  print(d)
  exit()
else:
  p = set(map(int, input().split()))

for i in range(100):
  if i+1 not in p:
    li = abs(X-i-1)
    if li < l:
      l = li
      d = i+1
    elif li == l:
      if i+1 < d:
        d = i+1
    elif li > l:
      break
print(d)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
a.sort()
n = 0
for i in range(N):
  d = True
  for j in range(N):
    if a[i] < a[j]:
      break
    elif i != j and a[i] % a[j] == 0:
      d = False
      break
  if d:
    n += 1
print(n)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
a.sort()
A = max(a)
b = [0]*A
for i in range(N):
  if b[a[i]-1] == 0:
    for j in range(a[i], A+1, a[i]):
      b[j-1] += 1
  elif b[a[i]-1] == 1:
      b[a[i]-1] += 1
n = 0      
for i in range(N):
  if b[a[i]-1] == 1:
    n += 1
print(n)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline

def main():
  N, K = map(int, readline().split())
  A = list(map(int, readline().split()))
 
  rs = 0
  p = -1
  r = []
  d = 1
  if N > K:
    for i in range(K+1):
      r.append(d)
      d = A[d - 1]
  else:
    for i in range(N+1):
      r.append(d)
      d = A[d - 1]
      for j in range(len(r)):
        if r[j] == d:
          rs = j
          p = i - j + 1
          break
  if p == -1:
    print(r[-1])
  else:
    print(r[rs+(K-rs)%p])

if __name__ == '__main__':
  main()

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

def main():
  N, K = map(int, readline().split())
  A = list(map(int, readline().split()))
 
  n = []
  for i in range(N):
    n.append(-1)
  s = 0
  c = -1
  d = A[1-1]
  r = [1]
  n[0] = 0
  for i in range(1, K+1):
    if n[d - 1] == -1:
      n[d - 1] = i
    else:
      s = n[d - 1]
      c = i - n[d - 1]
      break
    r.append(d)
    d = A[d - 1]
  if c == -1:
    print(r[-1])
  else:
    cr = r[s:s+c]
    k = (K - s)%c
    print(cr[k])
  exit()

if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

rs = 0
p = -1
r = []
d = 1
# i回目
if N > K:
  for i in range(K+1):
    r.append(d)
    d = A[d - 1]
else:
  for i in range(N+1):
    r.append(d)
    d = A[d - 1]
    for j in range(len(r)):
      if r[j] == d:
        rs = j
        p = i - j + 1
        break
if p == -1:
  print(r[-1])
else:
  print(r[rs+(K-rs)%p])

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

def main():
  N, K = map(int, readline().split())
  A = list(map(int, readline().split()))
 
  n = []
  for i in range(N):
    n.append(-1)
  s = 0
  c = -1
  d = A[1-1]
  r = [1]
  n[0] = 0
  for i in range(1, K+1):
    if n[d - 1] == -1:
      n[d - 1] = i
    else:
      s = n[d - 1]
      c = i - n[d - 1]
      break
    r.append(d)
    d = A[d - 1]
  if c == -1:
    print(r[-1])
  else:
    cr = r[s:s+c]
    k = (K - s)%c
    print(cr[k])
  exit()

if __name__ == '__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = input().split()
H = []
for i in range(N):
  H.append(int(l[i]))
r = 0
for i in range(N):
  for j in range(i, N):
    if i > j and i - j == H[i] + H[j]:
      r += 1
    elif j > i and j - i == H[i] + H[j]:
      r += 1
print(r)

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

def main():
  N = int(readline())
  line = readline().split()
  R = {}
  L = {}
  for i in range(N):
    r = int(line[i]) + i + 1
    l = i + 1 - int(line[i])
    if r in R:
      R[r] += 1
    else:
      R[r] = 1
    if l in L:
      L[l] += 1
    else:
      L[l] = 1
  cnt = 0
  for i in R:
    if i in L:
      cnt += R[i] * L[i]
  print(cnt)
  
if __name__ == '__main__':
  main()
Buggy python submission (verdict: Runtime Error):
N = int(input())
l = []
for i in range(N):
  Si = input()
  if not Si in l:
    l.append(Si)
print(len(l))

Fixed submission:
s, w =map(int, input().split())
if s > w:
  print("safe")
else:
  print("unsafe")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = []
for i in range(N):
  Si = input()
  if not Si in l:
    l.append(Si)
print(len(l))

Fixed submission:
N = int(input())
l = set()
for i in range(N):
  Si = input()
  if not Si in l:
    l.add(Si)
print(len(l))
Buggy python submission (verdict: Runtime Error):
from decimal import *
getcontext().prec = 2

a,b= input().split()
d = Decimal(a)*Decimal(b)
print(Decimal(d).quantize(Decimal('0'), rounding=ROUND_DOWN))

Fixed submission:
from decimal import *
getcontext().prec = 32

a,b= input().split()
d = Decimal(a)*Decimal(b)
print(Decimal(d).quantize(Decimal('0'), rounding=ROUND_DOWN))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]
d = [0] + [100000]*(n-1)
a = [[float('inf') for j in range(n)] for i in range(n)]
t = [0]*n

for i in range(m):
    a[l[i][0]-1][l[i][1]-1] = 1
    a[l[i][1]-1][l[i][0]-1] = 1

for i in range(n):
    for j in range(n):
        if d[i] + a[i][j] < d[j]:
            d[j] = d[i] + a[i][j]
            t[j] = i+1
if 0 in t[1:]:
    print("No")
else:
    print('Yes')
    for i in range(1,n):
        print(t[i])

Fixed submission:
N = input()
x = N[-1]

if x == '3':
    print("bon")
elif x == '0' or x == '1' or x == '6' or x == '8':
    print('pon')
else:
    print('hon')

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]
d = [0] + [100000]*(n-1)
a = [[float('inf') for j in range(n)] for i in range(n)]
t = [0]*n

for i in range(m):
    a[l[i][0]-1][l[i][1]-1] = 1
    a[l[i][1]-1][l[i][0]-1] = 1

for i in range(n):
    for j in range(n):
        if d[i] + a[i][j] < d[j]:
            d[j] = d[i] + a[i][j]
            t[j] = i+1
if 0 in t[1:]:
    print("No")
else:
    print('Yes')
    for i in range(1,n):
        print(t[i])

Fixed submission:
N = input()
x = N[-1]

if x == '3':
    print("bon")
elif x == '0' or x == '1' or x == '6' or x == '8':
    print('pon')
else:
    print('hon')

Buggy python submission (verdict: Runtime Error):
K = int(input())
S = input()
l = len(S)
if l > K:
    print("{}...".format(S[:K]))
else:
    print(S)

Fixed submission:
N = input()
x = N[-1]

if x == '3':
    print("bon")
elif x == '0' or x == '1' or x == '6' or x == '8':
    print('pon')
else:
    print('hon')
Buggy python submission (verdict: Runtime Error):
n,m,x = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
ans = float('inf')

for i in range(2**n):
    sum = [0]*(M+1)
    # n桁について調査
    for j in range(n):
        # iのj桁目が1かどうかcheck
        if ((i >> j) & 1):
            for k in range(M+1):
                sum[k] += l[j][k]
    if sum[0] < ans:
        for a in range(1,m+1):
            if sum[a] < x:
                break
            else:
                ans = sum[0]
if ans == float('inf'):
    print(-1)
else:
    print(ans)

Fixed submission:
n,m,x = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
ans = float('inf')

for i in range(2**n):
    sum = [0]*(m+1)
    # n桁について調査
    for j in range(n):
        # iのj桁目が1かどうかcheck
        if (i >> j) & 1:
            for k in range(m+1):
                sum[k] += l[j][k]
    if sum[0] < ans:
        for a in range(1,m+1):
            if sum[a] < x:
                break
        else:
            ans = sum[0]
if ans == float('inf'):
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
x = int(input())
div = make_divisors(x)

if x == 1: print("0 -1")

for i in range(len(div)//2):
    u = div[i*2]
    if len(div)%2 == 1: v = div[i*2]
    else: v = div[i*2+1]
    t = int(v**(1/2))
    for j in range(t):
        a = j
        b = j-u
        if a**4 + (a**3)*b +(a**2)*(b**2) + a*(b**3) + b**4 == v:
            print(a, b)
            break

Fixed submission:
s = input()
if s == 'ABC':
  print('ARC')
else:
  print('ABC')
Buggy python submission (verdict: Runtime Error):
x = int(input())
div = make_divisors(x)

if x == 1: print("0 -1")

for i in range(len(div)//2):
    u = div[i*2]
    if len(div)%2 == 1: v = div[i*2]
    else: v = div[i*2+1]
    t = int(v**(1/2))
    for j in range(t):
        a = j
        b = j-u
        if a**4 + (a**3)*b +(a**2)*(b**2) + a*(b**3) + b**4 == v:
            print(a, b)
            break

Fixed submission:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

x = int(input())
div = make_divisors(x)

if x == 1: print("0 -1")

for i in range(len(div)//2):
    u = div[i*2]
    if len(div)%2 == 1: v = div[i*2]
    else: v = div[i*2+1]
    t = int(v**(1/2))
    for j in range(t):
        a = j
        b = j-u
        if a**4 + (a**3)*b +(a**2)*(b**2) + a*(b**3) + b**4 == v:
            print(a, b)
            break