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

Fixed submission:
n = int(input())
t = []
x = []
y = []
ans = "Yes"
tmpx = 0
tmpy = 0
tmpt = 0
for i in range(n):
    v1,v2,v3 = map(int,input().split())
    t.append(v1)
    x.append(v2)
    y.append(v3)
for i in range(n):
    if abs(tmpx-x[i]) + abs(tmpy-y[i]) <= t[i] - tmpt and (abs(tmpx-x[i]) + abs(tmpy-y[i])) % 2 == (t[i] - tmpt) % 2:
        tmpx = x[i]
        tmpy = y[i]
        tmpt = t[i]
        continue
    else:
        ans = "No"
        break
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
t = []
x = []
y = []
ans = "Yes"
tmpx = 0
tmpy = 0
for i in range(n):
    v1,v2,v3 = map(int,input().split())
    t.append(v1)
    x.append(v2)
    y.append(v3)
for i in range(n):
    if abs(tmpx-x[i]) + abs(tmpy-y[i]) <= t[i]:
        tmpx = x[i]
        tmpy = y[i]
        continue
    else:
        flg = "No"
        break
print(flg)
Problem p03578 (python)

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

count = {}

for i in range(n):
    if d[i] in count.keys():
        count[d[i]] += 1
    else:
        count[d[i]] = 1  

for i in range(m):
    if t[i] not in count.keys():
        print("NO")
        break
    if count[t[i]] == 0:
        print("NO")
        break
    else:
        if t[i] not in count.keys():
            print("NO")
            break
        else:
            count[t[i]] -=1
    if i == m-1:
        print("YES")

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

count = {}

for i in range(n):
    if d[i] in count.keys():
        count[d[i]] += 1
    else:
        count[d[i]] = 1  

for i in range(m):
    if count[t[i]] == 0:
        print("NO")
        break
    else:
        count[t[i]] -=1
    if i == m-1:
        print("YES")
Problem p03591 (python)

Fixed submission:
s = input()
if len(s) >=4:
    if s[0] == 'Y' and s[1] == "A" and s[2] == "K" and s[3] == "I":
        print("Yes")
    else:
        print("No")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = input()
if s[0] == 'Y' and s[1] == "A" and s[2] == "K" and s[3] == "I" and len(s) >= 4:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = input()
if s[0] == 'Y' and s[1] == "A" and s[2] == "K" and s[3] == "I":
    print("Yes")
else:
    print("No")
Problem p03679 (python)

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

if a >= b :
    print("delicious")
elif b - a <= x:
    print("safe")
else:
    print("dangerous")

Buggy submission (verdict: Runtime Error):
if a >= b :
    print("delicious")
elif b - a <= x:
    print("safe")
else:
    print("dangerous")
Problem p03699 (python)

Fixed submission:
n = int(input())
s = []
for i in range(n):
    tmp = int(input())
    s.append(tmp)
s = sorted(s)
max_s = sum(s)
if max_s % 10 != 0:
    print(max_s)
else:
    for j in range(n):
        if s[j] % 10 != 0:
            print(max_s - s[j])
            break
        elif j == n-1:
            print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = []
for i in range(n):
    tmp = int(input())
    s.append(tmp)
sorted(s)
max_s = sum(s)

if max_s % 10 != 0:
    print(max_s)
else:
    for j in range(n):
        if s[j] % 10 != 0:
            print(max_s - s[j])
            break
if j == n-1:
    print(0)
Problem p03719 (python)

Fixed submission:
a,b,c = map(int,input().split())
if c >= a and c <=b:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = []
b = []
for i in range(n):
    tmp1,tmp2 = map(int,input().split())
    a.append(tmp1)
    b.append(tmp2)
counter = k-1
for i in range(n):
    counter = counter - b[i]
    if counter <= 0:
        print(a[i])
        break
Problem p03845 (python)

Fixed submission:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = []
x = []
for i in range(m):
    t1,t2 = map(int,input().split())
    p.append(t1)
    x.append(t2)
sum_t = sum(t)
for i in range(m):
    sa = t[p[i] - 1] - x[i]
    print(sum_t-sa)

Buggy submission (verdict: Runtime Error):
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = []
x = []
for i in range(m):
    t1,t2 = map(int,input().split())
    p.append(t1)
    x.append(t2)
sum_t = sum(t)
for i in range(m):
    print(sum_t - (t[i] -x[i]))
Problem p03860 (python)

Fixed submission:
a,b,c = input().split()
print(a[0]+b[0]+c[0])

Buggy submission (verdict: Runtime Error):
a,b,c = input().split()
print(a[0]+b[0]+c[0]
Problem p02642 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = max(a)
che = [1 for i in range(b)]
for i in a:
    if che[i-1] == 1:
        c = b // i
        for j in range(2,c+1):
            che[i*j-1] = 0
        che[i-1] = 2
    elif che[i-1] == 2:
        che[i-1] = 0
ans = 0
for i in a:
    if che[i-1] == 2:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import heapq as hp
n = int(input())
a = list(map(int, input().split()))
hp.heapify(a)
b = a[-1]
che,re = [0 for i in range(b)],[]
for i in a:
    che[i-1] = 1
for i in a:
    if i in re:
        che[i-1] = 0
    else:
        re.append(i)
        c = b // i
        for j in range(2,c+1):
            che[i*j-1] = 0
print(che.count(1))

Buggy submission (verdict: Runtime Error):
import heapq as hp
n = int(input())
a = list(map(int, input().split()))
hp.heapify(a)
ans = 0
while len(a) > 0:
    b = hp[0]
    if b in a:
         ans += -1
    a = [i for i in a if i % b != 0]
    ans += 1
print(ans)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
import heapq as hp
n = int(input())
if n%2 ==0:
    m = n//2 + 1
else:
    m = (n+1) //2
a,b = [],[]
for i in range(0,n):
    c = list(map(int, input().split()))
    a.append(c[0])
    b.append(c[1])
la = hp.nlargest(m,a)
lb = hp.nlargest(m,b)
if n%2 == 0:
    c = la[-1] + la[-2] 
    d = lb[-1] + lb[-2] 
    print(d-c+1)
else:
    print(lb[-1]-la[-1]+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a=list(map(int, input().split()))
ans = 1
for i in a:
    ans = ans * i
    if ans == 0:
        print(0)
        exit()
if ans > 10**18:
    print(-1)
else:
    print(ans)
Problem p02660 (python)

Fixed submission:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

m = int(input())
if m == 1:
  print(0)
  exit()
a = factorization(m)
b = []
ans = 0
for i in a:
    j = 1
    while j *(j+1) //2 <= i[1]:
        j += 1
    ans += j-1
print(ans)

Buggy submission (verdict: Runtime Error):
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

m = int(input())
a = factorization(m)
ans = 0
for i in a:
    j = 1
    while j *(j+1) //2 <= i:
        j += 1
    ans += j-1
print(ans)
Problem p02690 (python)

Fixed submission:
def check(a, b):
    return pow(a,5) - pow(b,5)

n = int(input())
a = 0
for i in range(0,120):
    for j in range(-119,i):
      if a == 0:
        if n == check(i,j):
          print(i,j)
          a = 1

Buggy submission (verdict: Runtime Error):
def solv_quadratic_equation(a, b, c):
    D = (b**2 - 4*a*c) ** (1/2)
    if isinstance(D, float) == True:
      x_1 = (-b + D) / (2 * a)
      x_2 = (-b - D) / (2 * a)
      return x_1,x_2
    else:
      return 0.1,0.1

n = int(input())
a,ch = n // 10,0
while ch == 0:
    s,t,u = a,-pow(a,3),(pow(a,5) -n)/5
    v,w = solv_quadratic_equation(s,t,u)
    if v.is_integer() == True:
        e,f = solv_quadratic_equation(1,-a,v)
        if e.is_integer() == True & f.is_integer() == True:
            if abs(int(e)) >= abs(int(f)):
                print(int(e),int(-f))
            else:
                print(int(f),int(-e))
            ch = 1
    if w.is_integer() == True:
        e,f = solv_quadratic_equation(1,-a,w)
        if e.is_integer() == True & f.is_integer() == True:
            if abs(int(e)) >= abs(int(f)):
                print(int(e),int(-f))
            else:
                print(int(f),int(-e))
            ch = 1
    a += 10

Buggy submission (verdict: Runtime Error):
def solv_quadratic_equation(a, b, c):
    D = (b**2 - 4*a*c) ** (1/2)
    if isinstance(D, float) == True:
      x_1 = (-b + D) / (2 * a)
      x_2 = (-b - D) / (2 * a)
      return x_1,x_2
    else:
      return 0.1,0.1

n = int(input())
a,ch = n // 10,0
while ch == 0:
    s,t,u = a,pow(a,3),(pow(a,5) -n)/5
    v,w = solv_quadratic_equation(s,t,u)
    if v.is_integer() == True:
        e,f = solv_quadratic_equation(1,-a,-v)
        if e.is_integer() == True & f.is_integer() == True:
            print(int(max(e,f)),int(min(e,f)))
            ch = 1
    elif w.is_integer() == True:
        e,f = solv_quadratic_equation(1,-a,-w)
        if e.is_integer() == True & f.is_integer() == True & ch == 0:
            print(int(max(e,f)),int(min(e,f)))
            ch = 1
    a += 10
Problem p02717 (python)

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

Buggy submission (verdict: Runtime Error):
n,k,c = map(int, input().split())
s = str(input())
t = [0 for i in range(n)]
u = [0 for i in range(n)]
i,x,y = 0,0,0
j = n-1
while i < n and x <= k:
    if s[i] == "o":
        t[i] = 1
        x += 1
        i += c
    i += 1

while j >= 0 and y <= k:
    if s[j] == "o":
        u[j] = 1
        y += 1
        j += -c
    j += -1

for i in range(0,n):
    if t[i] == 1 and u[i] == 1:
        print(i+1)
Problem p02812 (python)

Fixed submission:
n = int(input())
s = str(input())
a = 0
for i in range(0,n-2):
  if s[i] == "A":
    if s[i+1] == "B":
      if s[i+2] == "C":
        a +=1

print(a)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = str(input())
a = 0
for i in range(0,n):
  if s[i] == "A":
    if s[i+1] == "B":
      if s[i+2] == "C":
        a +=1

print(a)
Problem p02814 (python)

Fixed submission:
from fractions import gcd
n,m = map(int, input().split())
a = list(map(int, input().split()))
b = []
lcm = 1
for i in a:
    b.append(i//2)
for i in b:
  lcm = lcm // gcd(lcm,i) * i
ans = m // lcm
sum = 0
for i in b:
  if (lcm // i) % 2 == 1:
    sum += 1
if sum != len(a):
  print(0)
elif ans%2 ==1:
    print((ans+1)//2)
else:
    print(ans//2)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
n,m = map(int, input().split())
a = list(map(int, input().split()))
lcm = 1
for i in a:
  lcm = lcm // gcd(lcm,i) * i
ans = m // lcm
if (ans+0.5) * lcm <= m:
  ans += 1
sum = 0
for i in a:
  if (lcm // i) % 2 == 1:
    sum += 1
if sum != len(a):
  ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
n,m = map(int, input().split())
a = list(map(int, input().split()))
lcm = 1
for i in range(0,len(a)):
  lcm = (lcm * a[i]) // gcd(lcm,a[i])

ans = m // lcm
if (ans+0.5) * lcm <= m:
  ans += 1
sum = 0
for i in range(0,len(a)):
  if (lcm // a[i]) % 2 == 1:
    sum += 1

if sum != len(a):
  ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
n,m = map(int, input().split())
a = list(map(int, input().split()))
lcm = 1
for i in range(0,len(a)):
  lcm = lcm * a[i] // gcd(lcm,a[i])

ans = m // lcm
if (ans+0.5) * lcm <= m:
  ans += 1
sum = 0
for i in range(0,len(a)):
  if (lcm // a[i]) % 2 == 1:
    sum += 1

if sum != len(a):
  ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import fractions as fra
n,m = map(int, input().split())
a = list(map(int, input().split()))
lcm = 1
for i in range(0,len(a)):
  lcm = lcm * a[i] // fra.gcd(lcm,a[i])
 
ans = m // lcm
if (ans+0.5) * lcm <= m:
  ans += 1
sum = 0
for i in range(0,len(a)):
  if (lcm // a[i]) % 2 == 1:
    sum += 1

if sum != len(a):
  ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import fractions
n,m = map(int, input().split())
a = list(map(int, input().split()))
lcm = 1
for i in range(0,n):
  lcm = lcm * a[i] // fractions.gcd(lcm,a[i])

ans = m // lcm
if (ans+0.5) * lcm <= m:
  ans += 1
sum = 0
for i in range(0,n):
  if (lcm // a[i]) % 2 == 1:
    sum += 1   
if sum != n:
  ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import fractions
n,m = map(int, input().split())
a = list(map(int, input().split()))
lcm = 1
for i in range(0,n):
  lcm = lcm * a[i] // fractions.gcd(lcm,a[i])

ans = m // lcm
if (ans+0.5) * lcm <= m:
  ans += 1
b = np.zeros(n)


for i in range(0,n):
  while a[i] % 2 == 0:
    b[i] += 1
    a[i] = a[i] // 2



for i in range(1,n):
  for j in range(0,i):
    if b[i] != b[j]:
      ans = 0
      break

print(ans)

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

n,m = map(int, input().split())
a = list(map(int, input().split()))
st = np.lcm.reduce(a)
ans = m // st
if (ans+0.5) * st <= m:
  ans += 1
b = np.zeros(n)


for i in range(0,n):
  while a[i] % 2 == 0:
    b[i] += 1
    a[i] = a[i] // 2



for i in range(1,n):
  for j in range(0,i):
    if b[i] != b[j]:
      ans = 0
      break

print(ans)
Problem p02911 (python)

Fixed submission:
import numpy as np

n,k,q = map(int, input().split())
a = np.zeros(n)
for i in range(0,q):
  b = int(input())
  a[b-1] += 1

for i in range(0,n):
  a[i] = q - a[i]
  if a[i] >= k:
    print("No")
  else:
    print("Yes")

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

n,k,q = map(int, input().split())
a = np.zeros(n)
for i in range(0,k):
  b = int(input())
  a[b-1] += 1

for i in range(0,n):
  a[i] = k - a[i]
  if a[i] >= q:
    print("No")
  else:
    print("Yes")
Problem p02601 (python)

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

for i in range(k):
    if a >= b:
        b *= 2
    elif b >= c:
        c *= 2
    else:
        c *= 2

if a < b < c:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b, c = input1
k = int(input())

for i in range(k):
    if a >= b:
        b *= 2
    elif b >= c:
        c *= 2
    else:
        c *= 2

if a < b < c:
    print("Yes")
else:
    print("No")
Problem p02632 (python)

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

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


mod = 10**9+7
N = 2000001
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


ans = 0
for i in range(n, n+k+1):
    ans += cmb(n+k, i, mod) * pow(25, n+k-i, mod)
    ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
k = int(input())
s = input()
n = len(s)
dp = [0]*(k+1)
dp[0] = 1

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


mod = 10**9+7
N = 2000001
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


ans = 0
for i in range(n, n+k+1):
    ans += cmb(n+k, i) * pow(25, n+k-i, mod)
    ans %= mod

print(ans)
Problem p02691 (python)

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

num = [0] * (3*10**6)
for i in range(n):
    a[i] -= i
    if abs(a[i]) <= 10**6:
        num[a[i]] += 1

ans = 0
for i in range(n):
    if abs(-2*i - a[i]) <= 10**6:
        ans += num[-2*i - a[i]]
    if abs(a[i]) <= 10**6:
        num[a[i]] -= 1

print(ans)

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

num = [0] * (3*10**6)
for i in range(n):
    a[i] -= i
    num[a[i]] += 1

ans = 0
for i in range(n):
    if abs(-2*i - a[i]) <= 10**6:
        ans += num[-2*i - a[i]]
    num[a[i]] -= 1

print(ans)
Problem p02721 (python)

Fixed submission:
import sys
n, k, c = map(int, input().split())
s = input()


count = 0
i = 0
ansleft = set()
while i < n:
    if s[i] == "o":
        ansleft.add(i+1)
        i += c+1
        count += 1
    else:
        i += 1

if count >= k+1:
    sys.exit()


ansright = set()
s = s[::-1]
i = 0
while i < n:
    if s[i] == "o":
        ansright.add(n-i)
        i += c+1
    else:
        i += 1

ans = ansright&ansleft
ans = list(ans)
ans.sort()
for i in ans:
    print(i)

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


count = 0
i = 0
ansleft = set()
while i < n:
    if s[i] == "o":
        ansleft.add(i+1)
        i += c+1
        count += 1
    else:
        i += 1

if count >= k+1:
    sys.exit()


ansright = set()
s = s[::-1]
i = 0
while i < n:
    if s[i] == "o":
        ansright.add(n-i)
        i += c+1
    else:
        i += 1

ans = ansright&ansleft
ans = list(ans)
ans.sort()
for i in ans:
    print(i)

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


if s[i] == "o":
    if i+c+1 <= n-1:
        if s[i+c+1] == "x" and s[i+1] == "x":
            print(i+1)
Problem p02722 (python)

Fixed submission:
from fractions import gcd
n = int(input())
yakusuu = set()
ans = set()
for i in range(1, int((n-1)**(1/2))+1):
    if (n-1) % i == 0:
        yakusuu.add(i)
        yakusuu.add((n-1)//i)

for i in range(1, int(n**(1/2))+1):
    if n % i == 0:
        yakusuu.add(i)
        yakusuu.add(n//i)
yakusuu.remove(1)



for i in yakusuu:
    k = n
    if gcd(i, k) == 1:
        if k % i == 1:
            ans.add(i)
        continue

    k = n
    while k >= i:
        if k % i == 0:
            k //= i
        else:
            if k % i == 1:
                k = 1
            else:
                k = 0
    if k == 1:
        ans.add(i)

print(len(ans))

Buggy submission (verdict: Runtime Error):
from math import gcd
n = int(input())
yakusuu = set()
ans = set()
for i in range(1, int((n-1)**(1/2))+1):
    if (n-1) % i == 0:
        yakusuu.add(i)
        yakusuu.add((n-1)//i)

for i in range(1, int(n**(1/2))+1):
    if n % i == 0:
        yakusuu.add(i)
        yakusuu.add(n//i)
yakusuu.remove(1)



for i in yakusuu:
    k = n
    if gcd(i, k) == 1:
        if k % i == 1:
            ans.add(i)
        continue

    k = n
    while k >= i:
        if k % i == 0:
            k //= i
        else:
            if k % i == 1:
                k = 1
            else:
                k = 0
    if k == 1:
        ans.add(i)

print(len(ans))

Buggy submission (verdict: Runtime Error):
from math import gcd
n = int(input())
yakusuu = set()
ans = set()
for i in range(1, int((n-1)**(1/2))+1):
    if (n-1) % i == 0:
        yakusuu.add(i)
        yakusuu.add((n-1)//i)

for i in range(1, int(n**(1/2))+1):
    if n % i == 0:
        yakusuu.add(i)
        yakusuu.add(n//i)
yakusuu.remove(1)

for i in yakusuu:
    k = n

    if gcd(i, k) == 1:
        if k % i == 1:
            ans.add(i)
        continue

    k = n
    while k >= i:
        if k % i == 0:
            k //= i
        else:
            k -= i
        if gcd(i, k) == 1:
            if k % i == 1:
                k = 1
            else:
                k = 0

    if k == 1:
        ans.add(i)

print(len(ans))
Problem p02733 (python)

Fixed submission:
h, w, K = map(int, input().split())
grid = []
for i in range(h):
    grid.append(input())

ans = 1000000
for i in range(2**(h-1)):
    b = format(i, "0{}b".format(h-1))
    ans_temp = b.count("1")
    white_after = [0]*(ans_temp+1)
    index = 0
    flag = 1
    for j in range(w):
        for k in range(h):
            if grid[k][j] == "1":
                white_after[index] += 1
            if k != h-1:
                if b[k] == "1":
                    index += 1
        if max(white_after) <= K:
            white_before = white_after[:]
        else:
            try:
                for k in range(len(white_after)):
                    white_after[k] -= white_before[k]
                    if white_after[k] > K:
                        flag = 0
                white_before = white_after[:]
                ans_temp += 1
            except:
                flag = 0
                break
        index = 0
    if flag == 0:
        continue
    ans = min(ans, ans_temp)

print(ans)

Buggy submission (verdict: Runtime Error):
h, w, K = map(int, input().split())
grid = []
for i in range(h):
    grid.append(input())

ans = 1000000
for i in range(2**(h-1)):
    b = format(i, "0{}b".format(h-1))
    ans_temp = b.count("1")
    white_after = [0]*(ans_temp+1)
    index = 0
    for j in range(w):
        for k in range(h):
            if grid[k][j] == "1":
                white_after[index] += 1
            if k != h-1:
                if b[k] == "1":
                    index += 1
        if max(white_after) <= K:
            white_before = white_after[:]
        else:
            for k in range(len(white_after)):
                white_after[k] -= white_before[k]
            white_before = white_after[:]
            ans_temp += 1
        index = 0
    ans = min(ans, ans_temp)

print(ans)
Problem p02743 (python)

Fixed submission:
from decimal import *
a, b, c = map(int, input().split())
a = Decimal(str(a))
b = Decimal(str(b))
c = Decimal(str(c))
if a.sqrt() + b.sqrt() < c.sqrt():
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
from decimal import *
getcontext().prec = 28
a, b, c = map(int, input().split())
a = Decimal(str(a))
b = Decimal(str(b))
c = Decimal(str(c))

if a.sqrt() + b.sqrt() < c.sqrt()):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
from decimal import *
getcontext().prec = 28
a, b, c = map(int, input().split())
if sqrt(str(a)) + sqrt(str(b)) < sqrt(str(c)):
  print("Yes")
else:
  print("No")
Problem p02744 (python)

Fixed submission:
n = int(input())

before = ["0"]
for i in range(n-1):
    next = []
    for elem in before:
        m = 1
        for j in range(len(elem)):
            m = max(m, int(elem[j])+1)
        for j in range(m+1):
            next.append(elem+str(j))
    before = next[:]

before.sort()
d = {"0":"a", "1":"b", "2":"c", "3":"d", "4":"e", "5":"f", "6":"g", "7":"h", "8":"i", "9":"j"}
for elem in before:
    ans = []
    for i in range(len(elem)):
        ans.append(d[elem[i]])
    print("".join(ans))

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

before = ["1"]
for i in range(n-1):
    next = []
    for elem in before:
        m = 1
        for j in range(len(elem)):
            m = max(m, int(elem[j]))
        for j in range(m+1):
            next.append(elem+str(j+1))
    before = next[:]

before.sort()
d = {"1":"a", "2":"b", "3":"c", "4":"d", "5":"e", "6":"f", "7":"g", "8":"h", "9":"i", "10":"j"}
for elem in before:
    ans = []
    for i in range(len(elem)):
        ans.append(d[elem[i]])
    print("".join(ans))