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

Fixed submission:
a,b,c,d,e,f=map(int,input().split())
i=0
answ=0
anss=0
cnt=0
while 100*a*i<=f:
  j=0
  while 100*a*i+100*b*j<=f:
    k=0
    while c*k<=(a*i+b*j)*e:
      l=0
      if (a*i+b*j+c*k+d*l)!=0:
        if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
          if (a*i+b*j)*100+c*k+d*l<=f:
            cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
            answ=(a*i+b*j)*100
            anss=c*k+d*l
      l=((a*i+b*j)*e-c*k)//d
      if l>0:
        if (a*i+b*j+c*k+d*l)!=0:
          if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
            if (a*i+b*j)*100+c*k+d*l<=f:
              cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
              answ=(a*i+b*j)*100
              anss=c*k+d*l
      l=(f-(a*i+b*j)*100-c*k)//d
      if l>0:
        if (a*i+b*j+c*k+d*l)!=0:
          if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
            if c*k+d*l<=(a*i+b*j)*e:
              cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
              answ=(a*i+b*j)*100
              anss=c*k+d*l
      k=k+1
    j=j+1
  i=i+1
temp=0
i=0
while 100*a*i<=f:
  j=0
  while 100*a*i+100*b*j<=f:
    temp=max(temp,100*a*i+100*b*j)
    j=j+1
  i=i+1
if 100*a+c>f:
  print(100*a,0)
elif temp//100*e<c:
  print(temp,0)
else:
  print(answ+anss,anss)

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,f=map(int,input().split())
i=0
answ=0
anss=0
cnt=0
while 100*a*i<=f:
  j=0
  while 100*a*i+100*b*j<=f:
    k=0
    while c*k<=(a*i+b*j)*e:
      l=((a*i+b*j)*e-c*k)//d
      if (a*i+b*j+c*k+d*l)!=0:
        if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
          if (a*i+b*j)*100+c*k+d*l<=f:
            cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
            answ=(a*i+b*j)*100
            anss=c*k+d*l
      l=(f-(a*i+b*j)*100-c*k)//d
      if (a*i+b*j+c*k+d*l)!=0:
        if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
          if c*k+d*l<=(a*i+b*j)*e
            cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
            answ=(a*i+b*j)*100
            anss=c*k+d*l      
      k=k+1
    j=j+1
  i=i+1
if 100*a==f:
  print(100*a,0)
else:
  print(answ+anss,anss)
Problem p03610 (python)

Fixed submission:
s=str(input())
s=list(s)
ans=[]
for i in range(0,len(s)):
  if i%2==0:
    ans.append(s[i])
print("".join(ans))

Buggy submission (verdict: Runtime Error):
s=str(input())
s=list(s)
ans=[]
for i in range(0,len(s)):
  if s%2==0:
    ans.append(s[i])
print("".join(ans))
Problem p03611 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
temp=[0]*(max(a)+1)
for i in range(n):
  temp[a[i]]=temp[a[i]]+1
ans=0
if max(a)==0 or max(a)==1:
  print(n)
else:
  for i in range(1,max(a)):
    ans=max(ans,temp[i-1]+temp[i]+temp[i+1])
  print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
temp=[0]*max(a)
for i in range(n):
  temp[a[i]-1]=temp[a[i]-1]+1
ans=0
for i in range(1,max(a)-1):
  ans=max(ans,temp[i-1]+temp[i]+temp[i+1])
print(ans)
Problem p03612 (python)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
ans=0
i=0
while i<n:
  if p[i]==i+1:
    ans=ans+1
    i=i+1
  i=i+1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(n):
  if p[i]==i+1:
    ans=ans+1
    if p!=n-1:
      if p[i+1]==i+2:
        ans=ans-1
print(ans)
Problem p03633 (python)

Fixed submission:
from fractions import gcd
n=int(input())
ans=int(input())
for i in range(1,n):
  t=int(input())
  ans=ans*t//gcd(ans,t)
print(int(ans))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
n=int(input())
ans=int(input())
for i in range(1,n):
  t=int(input())
  ans=int(ans*t/gcd(ans,t))
print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
n=int(input())
t=[0]*n
ans=int(input())
for i in range(1,n):
  t=int(input())
  ans=int(ans*t/gcd(ans,t))
print(ans)
Problem p03645 (python)

Fixed submission:
n,m=map(int,input().split())
templ=[0]*m
temp=[]
tempb=[]
ans=0
for i in range(0,m):
  a,b=map(int,input().split())
  templ[i]=[a,b]
  if a==1:
    if b==n:
      print("POSSIBLE")
      ans=1
      break
    else:
      temp.append(b)
  if b==n:
    tempb.append(a)
if len(temp)>=1 and ans==0:
  temp=set(temp)
  tempb=set(tempb)
  c = temp&tempb
  #c = [x for x in temp if x in tempb]
  if len(c)>=1:
    print("POSSIBLE")
  else:
    print("IMPOSSIBLE")
  """
  for i in range(0,len(tempb)):
    if tempb[i] in temp:
      print("POSSIBLE")
      break
  """
else:
  print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
temp=[]
for i in range(0,m):
  a,b=map(int,input().split()):
    if a==1:
      if b==n:
        print("POSSIBLE")
        break
      else:
        temp.append(b)
else:
  for i in range(0,len(b)):
    if temp[i]==n:
        print("POSSIBLE")

else:
  print("IMPOSSIBLE")
Problem p03672 (python)

Fixed submission:
s=str(input())
s=list(s)
while True:
  del s[len(s)-1]
  if len(s)%2==0:
    count=0
    for i in range(0,int(len(s)/2)):
      if s[i]==s[i+int(len(s)/2)]:
        count=count+1
    if count==int(len(s)/2):
      print(len(s))
      break

Buggy submission (verdict: Runtime Error):
s=str(input())
s=list(s)
while True:
  del s[len(s)-1]
  if len(s)%2==0:
    count=0
    for i in range(0,int(len(s)/2)):
      if s[i]==s[i+int(len(s)/2)]:
        count=count+1
    if count==int(len(s)/2):
      print(len(s))
Problem p03695 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
temp=[0,0,0,0,0,0,0,0]
r=0
for i in range(n):
  if a[i]>=3200:
    r=r+1
  elif a[i]>=2800:
    temp[7]=1
  elif a[i]>=2400:
    temp[6]=1
  elif a[i]>=2000:
    temp[5]=1
  elif a[i]>=1600:
    temp[4]=1
  elif a[i]>=1200:
    temp[3]=1
  elif a[i]>=800:
    temp[2]=1
  elif a[i]>=400:
    temp[1]=1
  else:
    temp[0]=1
if sum(temp)==0:
  print(1,r)
else:
  print(sum(temp),sum(temp)+r)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
temp=[0,0,0,0,0,0,0,0]
r=0
for i in range(n):
  if a[i]>=3200:
    r=r+1
  elif a[i]>=2800:
    temp[7]=1
  elif a[i]>=2400:
    temp[6]=1
  elif a[i]>=2000:
    temp[5]=1
  elif a[i]>=1600:
    temp[4]=1
  elif a[i]>=1200:
    temp[3]=1
  elif a[i]>=800:
    temp[2]=1
  elif a[i]>=400:
    temp[1]=1
  else:
    temp[0]=1
print(sum(temp),temp(sum)+r)
Problem p03760 (python)

Fixed submission:
o=str(input())
e=str(input())
s="A"
l=min(len(o),len(e))
for i in range(0,l):
  s=s+o[i]+e[i]
if len(o)<len(e):
  s=s+e[len(e)-1]
elif len(o)>len(e):
  s=s+o[len(o)-1]
s=s.lstrip("A")
print(s)

Buggy submission (verdict: Runtime Error):
o=str(input())
e=str(input())
s="A"
for i in range(0,len(o)):
  s=s+o[i]+e[i]
s=s.lstrip("A")
print(s)
Problem p03778 (python)

Fixed submission:
w,a,b=map(int,input().split())
if (a<=b and a+w>=b) or (b<=a and b+w>=a):
  print(0)
else:
  print(min(abs(b-a-w),abs(b+w-a)))

Buggy submission (verdict: Runtime Error):
w,a,b=map(int,input().split())
print(min(abs(b-a-w),abs(a-b),abs(b+w-a))
Problem p03779 (python)

Fixed submission:
x=int(input())
temp=0
for i in range(1,x+1):
  temp=temp+i
  if temp>=x:
    break
print(i)

Buggy submission (verdict: Runtime Error):
x=int(input())
temp=0
for i in range(1,x):
  temp=temp+i
  if temp>=x:
    break
print(i)
Problem p03796 (python)

Fixed submission:
N=int(input())
import math
power=math.factorial(N)
print(power%(10**9+7))

Buggy submission (verdict: Runtime Error):
N=int(input())
import math
power=1
for i in range(0,n):
  power=power*(i+1)
print(power%(10**9+7))
Problem p03826 (python)

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

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
print(max(a*b),(c*d))
Problem p03862 (python)

Fixed submission:
N,x=map(int,input().split())
A=list(map(int,input().split()))+[0]
ans=0
for i in range(N):
  eated=max(0,A[i]+A[i-1]-x)
  ans+=eated
  A[i]-=eated
print(ans)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(1,n):
  temp=max(0,a[i]+a[i-1]-x):
  ans=ans+temp
  a[i]=a[i]-temp
print(ans)

Buggy submission (verdict: Runtime Error):
A=list(map(int,input().split()))+[0]
ans=0
for i in range(N):
    eated=max(0,A[i]+A[i-1]-x)
    ans+=eated
    A[i]-=eated
print(ans)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
count=0
for i in range(0,n-1):
  if a[i]+a[i+1]>x:
    ans=ans+a[i]+a[i+1]-x
    a[i+1]=a[i+1]-(a[i]+a[i+1]-x)
for i in range(n-1,0,-1):
  if a[i]+a[i+1]>x:
    count=count+a[i]+a[i+1]-x
    a[i]=a[i]-(a[i]+a[i+1]-x)
print(min(ans,count))
Problem p03937 (python)

Fixed submission:
h,w=map(int,input().split())
a=[]
for i in range(h):
  at=list(str(input()))
  a.append(at)
i=0
j=0
t=0
while True:
  if j!=w-1:
    if a[i][j+1]=="#":
      for k in range(i+1,h):
        if a[k][j]=="#":
          t=1
          break
      else:
        j=j+1
  if i!=h-1:
    if a[i+1][j]=="#":
      for k in range(j+1,w):
        if a[i][k]=="#":
          t=1
          break
      else:
        i=i+1
  if t==1:
    print("Impossible")
    break
  elif i==h-1 and j==w-1:
    print("Possible")
    break

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[]
for i in range(h):
  at=list(str(input()))
  a.append(at)
i=0
j=0
t=0
while True:
  if a[i][j+1]=="#":
    for k in range(i+1,h):
      if a[k][j]=="#":
        t=1
        break
    else:
      j=j+1
  elif a[i+1][j]=="#":
    for k in range(j+1,w):
      if a[i][k]=="#":
        t=1
        break
    else:
      i=i+1
  if t==1:
    print("Impossible")
    break
  elif i==h-1 and j==w-1:
    print("Possible")
    break
Problem p02555 (python)

Fixed submission:
s = int(input())
mod = 10 ** 9 + 7

fact = [1] * s
inv = [1] * s
invf = [1] * s
for i in range(2, s):
  fact[i] = fact[i-1] * i % mod
  inv[i] = -(mod // i) * inv[mod % i] % mod
  invf[i] = invf[i-1] * inv[i] % mod

count = 0
rest = s
for n in range(1, s // 3 + 1):
  rest -= 3
  count = (count + fact[rest + n - 1] * invf[rest] * invf[n - 1]) % mod
print(count)

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

fact = [1] * s
inv = [1] * s
invf = [1] * s
for i in range(2, s):
  fact[i] = fact[i-1] * i % mod
  inv[i] = -(p // i) * inv[p % i] % mod
  invf[i] = invf[i-1] * inv[i] % mod

count = 0
rest = s
for n in range(1, (s + 2) // 3):
  rest -= 3
  count = (count + inv[rest + n - 1] * invf[rest] * invf[n - 1]) % mod
print(count)
Problem p02614 (python)

Fixed submission:
h, w, k = map(int, input().split())
mark = [input() for _ in range(h)]
ans = 0

for bit_h in range(1 << h):
  i_list = []
  for i in range(h):
    if bit_h & 1:
      i_list.append(i)
    bit_h >>= 1
  for bit_w in range(1 << w):
    count = 0
    j_list = []
    for j in range(w):
      if bit_w & 1:
        j_list.append(j)
      bit_w >>= 1
    for i in i_list:
      for j in j_list:
        if mark[i][j] == '#':
          count += 1
    if count == k:
      ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
h, w, k = map(int, input().split())
mark = [input() for _ in range(h)]
ans = 0

for bit_h in range(1 << h):
  i_list = []
  for i in range(h):
    if bit_h & 1:
      i_list.append(i)
    bit_h >>= 1
  for bit_w in range(1 << w):
    count = 0
    j_list = []
    for j in range(w):
      if bit_w & 1:
        j_list.append(bit_w & 1)
      bit_w >>= 1
    for i in i_list:
      for j in j_list:
        if mark[i][j] = '#':
          count += 1
    if count == k:
      ans += 1
print(ans)
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
p = set(map(int, input().split()))

ans = 0
diff = x
for i in range(1, 102):
  if i in p:
    continue
  tmp = abs(i - x)
  if tmp < diff:
    diff = tmp
    ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
p = set(map(int, input().split()))

ans = 0
for i in range(1, 102):
  if i in p:
    continue
  if i < x:
    ans = i
  elif x - ans > i - x:
  	ans = i
    break
print(ans)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
p = set(map(int, input().split()))

ans = 0
for i in range(1, 102):
  if i in p:
    continue
  if i < x:
    ans = i
  elif x - ans > i - x
  	ans = i
    break
print(ans)
Problem p02662 (python)

Fixed submission:
import numpy as np

mod = 998244353
n, s = map(int, input().split())
dp = np.zeros((n+1, s+1), dtype=int)
dp[0, 0] = 1
for i, a in enumerate(map(int, input().split())):
  dp[i+1] = dp[i] * 2 % mod
  dp[i+1][a:] = (dp[i+1][a:] + dp[i][:-a]) % mod
print(dp[-1, -1])

Buggy submission (verdict: Runtime Error):
mod = 998244353
n, s = map(int, input().split())
dp = np.zeros((n+1, s+1), dtype=int)
dp[0, 0] = 1
for i, a in enumerate(map(int, input().split())):
  dp[i+1] = dp[i] * 2 % mod
  dp[i+1][a:] = (dp[i+1][a:] + dp[i][:-a]) % mod
print(dp[-1, -1])
Problem p02684 (python)

Fixed submission:
def zero_index(i: str) -> int:
  return int(i) - 1

n, k = map(int, input().split())
transition = list(map(zero_index, input().split()))
places = [0]
next_place = transition[0]
virgin = [True] * n
virgin[0] = False
while virgin[next_place]:
  virgin[next_place] = False
  places.append(next_place)
  next_place = transition[next_place]
start = places.index(next_place)
period = len(places) - start
if k < start:
  t = k
else:
  t = (k - start) % period + start
print(places[t] + 1)

Buggy submission (verdict: Runtime Error):
def zero_index(i: str) -> int:
  return int(i) - 1

n, k = map(int, input().split())
transition = map(zero_index, input().split())
places = [0]
next_place = transition[0]
while next_place not in places:
  places.append(next_place)
  next_place = transition[next_place]
start = places.index(next_place)
period = len(places) - start
if k < start:
  t = k
else:
  t = (k - start) % priod + start
print(place[t] + 1)
Problem p02713 (python)

Fixed submission:
from math import gcd

k = int(input())
sum_ = 0
for a in range(1, k + 1):
  for b in range(1, k + 1):
    gcd_ab = gcd(a, b)
    for c in range(1, k + 1):
      sum_ += gcd(c, gcd_ab)
print(sum_)

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

count = [pow(k // max(i, 1), 3, mod) for i in range(k + 1)]

for i in range(k, 0, -1):
  for j in range(2 * i, k + 1, i):
    count[i] -= count[j]

sum_ = 0
for i in range(k + 1):
  sum_ += i * count[i]

print(sum_)
Problem p02716 (python)

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

if n % 2 == 0:
  dp = a[:2]
  for i in range(1, n // 2):
    dp = dp[0] + a[2*i], max(dp) + a[2*i+1]
else:
  dp = a[:3]
  for i in range(1, n // 2):
    dp = dp[0] + a[2*i], max(dp[:2]) + a[2*i+1], max(dp) + a[2*i+2]

print(max(dp))

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

n = int(input())
a = np.array(input().split(), dtype=np.int)

if n % 2 == 0:
  print(max(a[::2].sum(), a[1::2].sum()))
else:
  dp = a[:3]
  for i in range(1, n // 2):
    dp = dp[0] + a[2*i], dp[:2].max() + a[2*i+1], dp.max() + a[2*i+2]
  print(dp.max())
Problem p02720 (python)

Fixed submission:
k = int(input())
num = 0
for _ in range(k):
  num += 1
  digit = [int(digit) for digit in str(num)]
  len_digit = len(digit)
  flag = False
  for i in range(1, len_digit):
    # current_digit = digit[-i]
    # upper_digit = digit[-i-1]
    if digit[-i] == 10:
      digit[-i-1] += 1
      digit[-i] = -1
    elif digit[-i] > digit[-i-1] + 1:
      digit[-i-1] += 1
      digit[-i] = -1
    elif digit[-i] < digit[-i-1] - 1:
      digit[-i] = -1
  if digit[0] == 10:
    num = 10 ** len_digit
  else:
    for i in range(1, len_digit):
      if digit[i] == -1:
        for j in range(i, len_digit):
          digit[j] = max(digit[j-1] - 1, 0)
        break
    num = 0
    for d in digit:
      num = num * 10 + d
print(num)

Buggy submission (verdict: Runtime Error):
k = int(input())
num = 0
for _ in range(k):
  num += 1
  digit = [int(digit) for digit in str(num)]
  len_digit = len(digit)
  for i in range(1, len_digit):
    if digit[-i] > min(digit[-i-1] + 1, 9):
      digit[-i-1] += 1
      digit[-i] = -1
    elif digit[-i] < digit[-i-1] - 1:
      digit[-i] = -1
  for i in range(1, len_digit):
    if digit[i] == -1:
      for j in range(i, len_digit):
        digit[j] = max(digit[j-1] - 1, 0)
      break
  num = d[0]
  for d in digit[1:]:
    num = num * 10 + d
print(num)
Problem p02727 (python)

Fixed submission:
from heapq import heappop, heappush

x, y, a, b, c = map(int, input().split())
apple = []
# Red is 0, Green is 1, Colorless is 2
for p in map(int, input().split()):
  heappush(apple, (-p, 0))
for q in map(int, input().split()):
  heappush(apple, (-q, 1))
for r in map(int, input().split()):
  heappush(apple, (-r, 2))
delicious = 0
colorless = 0
while x + y > colorless:
  minus_taste, color = heappop(apple)
  if color == 0:
    if x > 0:
      delicious -= minus_taste
      x -= 1
  elif color == 1:
    if y > 0:
      delicious -= minus_taste
      y -= 1
  else:
    delicious -= minus_taste
    colorless += 1
print(delicious)

Buggy submission (verdict: Runtime Error):
from heapq import heappop, heappush

x, y, a, b, c = map(int, input().split())
apple = []
for p in map(int, input().split()):
  heappush(apple, (-p, True))
for q in map(int, input().split()):
  heappush(apple, (-q, False))
for r in map(int, input().split()):
  heappush(apple, (-r, None))
delicious = 0
colorless = 0
while x + y > colorless:
  minus_taste, color = heappop(apple)
  if color is True:
    if x > 0:
      delicious -= minus_taste
      x -= 1
  elif color is False:
    if y > 0:
      delicious -= minus_taste
      y -= 1
  else:
    delicious -= minus_taste
    colorless += 1
print(delicious)
Problem p02733 (python)

Fixed submission:
h, w, k = map(int, input().split())
s = [[int(s_ij) for s_ij in input()] for _ in range(h)]

minimum = (h - 1) * (w - 1)
for div_h in range(1 << (h - 1)):
  h_index = [0] * h
  cur_index = 0
  mask = 1 << (h - 2)
  for i in range(1, h):
    if div_h & mask:
      cur_index += 1
    h_index[i] = cur_index
    mask >>= 1
  white_choco = [0] * (cur_index + 1)
  divide = 0
  j = 0
  flag = False
  while j < w:
    for i in range(h):
      white_choco[h_index[i]] += s[i][j]
    if max(white_choco) > k:
      if flag:
        break
      flag = True
      white_choco = [0] * (cur_index + 1)
      divide += 1
    else:
      j += 1
      flag = False
  else:
    minimum = min(minimum, divide + cur_index)
print(minimum)

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

h, w, k = map(int, input().split())
s = np.array(
  [[s for s in map(int, input().split())] for _ in range(h)],
  dtype=np.int)

minimum = (h - 1) * (w - 1)
for div_h in range(1 << (h - 1)):
  h_index = np.zeros(h, dtype=np.int)
  cur_index = 0
  for i in range(1, h):
    if div_h & 1:
      cur_index += 1
    h_index[i] = cur_index
    div_h >>= 1
  white_choco = np.zeros(cur_index + 1, dtype=np.int)
  divide = 0
  j = 0
  while j < w:
    for i in range(h):
      if s[i, j]:
        if white_choco[h_index[i]] < k:
          white_choco[h_index[i]] += 1
        else:
          break
    else:
      j += 1
      continue
    white_choco[:] = 0
    divide += 1
  minimum = min(minimum, divide + cur_index)
print(minimum)

Buggy submission (verdict: Runtime Error):
h, w, k = map(int, input().split())
s = [input() for _ in range(h)]

minimum = (h - 1) * (w - 1)
for div_h in range(1 << (h - 1)):
  h_index = [0] * h
  cur_index = 0
  bin_h = format(div_h, f'0{h-1}b')
  for i in range(1, h):
    if bin_h[-i] == '1':
      cur_index += 1
    h_index[i] = cur_index
  white_choco = [0] * (cur_index + 1)
  divide = 0
  j = 0
  while j < w:
    for i in range(h):
      if s[i][j] == '1':
        h_i = h_index[i]
        if white_choco[h_i] < k:
          white_choco[h_i] += 1
        else:
          break
    else:
      j += 1
      continue
    white_choco = [0] * (cur_index + 1)
    divide += 1
  minimum = min(minimum, divide + cur_index)
print(minimum)
Problem p02742 (python)

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

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
h_evan = h // 2
h_odd = h_even + (h % 2)
w_evan = w // 2
w_odd = w_even + (w % 2)
print(h_even * w_even + h_odd * w_odd)

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

Fixed submission:
n = int(input())
a = ord('a')

def f(x: str) -> str:
  return chr(int(x) + a)

i = 0
while i < 10 ** (n-1):
  x = str(i).zfill(n)
  maximum = 0
  flag = True
  for j, digit in enumerate(map(int, x)):
    if digit > maximum + 1:
      flag = False
      break
    elif digit == maximum + 1:
      maximum = digit
  if flag:
    print(''.join(map(f, x)))
    i += 1
  else:
    d = 10 ** (n - j)
    i = (i // d + 1) * d

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

def f(x: int) -> str:
  return chr(x + a)

for i in range(2 * 10 ** (n-2)):
  x = list(map(int, str(i).zfill(n)))
  maximum = 0
  flag = True
  for j, digit in enumerate(x):
    if digit > maximum + 1:
      flag = False
      break
    elif digit == maximum + 1:
      maximum = digit
  if flag:
    print(''.join(map(f, x)))
  else:
    d = 10 ** (n - j)
    i = (i // d + 1) * d

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

def f(x: int) -> str:
  return chr(x + a)

for i in range(2 * 10 ** (n-2)):
  x = list(map(int, str(i).zfill(n)))
  maximum = 0
  flag = True
  for y in x[1:]:
    if y > maximum + 1:
      flag = False
      break
    elif y == maximum + 1:
      maximum = y
  if flag:
    print(''.join(map(f, x)))
Problem p02749 (python)

Fixed submission:
n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = map(int, input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)

group = [False] * n
parent = list(range(n))
stack = [0]
while stack:
  v = stack.pop()
  while edge[v]:
    u = edge[v].pop()
    if parent[v] != u:
      group[u] = not group[v]
      parent[u] = v
      stack.append(u)

three = 3
p = [0] * n
if group.count(False) <= n // 3:
  other = 1
  for i in range(n):
    if group[i] and other <= n:
      p[i] = other
      other += other % 3
    else:
      p[i] = three
      three += 3
elif group.count(True) <= n // 3:
  other = 1
  for i in range(n):
    if not group[i] and other <= n:
      p[i] = other
      other += other % 3
    else:
      p[i] = three
      three += 3
else:
  one, two = 1, 2
  for i in range(n):
    if group[i] and one <= n:
      p[i] = one
      one += 3
    elif not group[i] and two <= n:
      p[i] = two
      two += 3
    else:
      p[i] = three
      three += 3
print(' '.join(map(str, p)))

Buggy submission (verdict: Runtime Error):
n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n):
  a, b = map(int, input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
group = [[0], []]
idx = 1
stack = [0]
tmp = True
while tmp:
  tmp = []
  while stack:
    v = stack.pop()
    for u in edge[v]:
      if u not in group[idx ^ 1]:
        group[idx].append(u)
        tmp.append(u)
  idx ^= 1
one = n // 3 + int(n % 3 > 0)
two = n // 3 + int(n % 3 == 2)
three = n // 3
p = [0] * n
group.sort(key=len)
if len(group[0]) >= two:
  index3 = 1
  for i in range(two):
    v = group[0].pop()
    p[v] = 3 * i + 2
  while group[0]:
    v = group[0].pop()
    p[v] = 3 * index3
    index3 += 1
  for i in range(one):
    v = group[1].pop()
    p[v] = 3 * i + 1
  while group[1]:
    v = group[1].pop()
    p[v] = 3 * index3
    index3 += 1
else:
  print(-1)