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

Fixed submission:
import numpy as np

n, k = map(int, input().split())
A = list(map(int, input().split()))
All = [[0]*41 for i in range(n)]
K = [0]*41
stopper = 0
sum_ = 0



for i in range(len(A)):
    bin_a = format(A[i],'b')
    list_a = [int(i) for i in bin_a]
    All[i] = [0]*(41-len(list_a))+ list_a
    
bin_k =   format(k,'b') 
list_k = [int(i) for i in bin_k]
K = [0]*(41-len(list_k))+list_k

b = np.cumsum(All, axis = 0)
B = b[len(b)-1]
    
for i in range(41):
    if K[i]==1 and B[i]>= (n+1)//2:
        K[i]=0
        stopper = i
        break

if stopper!=0 and stopper<=39:
    for i in range(stopper+1,41):
        if  B[i]>= (n+1)//2:
            K[i] = 0
        else:
            K[i] = 1
            
            
for i in range(41):
    if K[i]==1:
        B[i] = n-B[i]

for i in range(1,42):
    sum_ = sum_ + B[-i]*(2**(i-1))

print(sum_)

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

n, k = map(int, input().split())
A = list(map(int, input().split()))
All = [[0]*40 for i in range(n)]
K = [0]*40
stopper = 0
sum_ = 0



for i in range(len(A)):
    bin_a = format(A[i],'b')
    list_a = [int(i) for i in bin_a]
    All[i] = [0]*(40-len(list_a))+ list_a
    
bin_k =   format(k,'b') 
list_k = [int(i) for i in bin_k]
K = [0]*(40-len(list_k))+list_k

b = np.cumsum(All, axis = 0)
B = b[len(b)-1]
    
for i in range(40):
    if K[i]==1 and B[i]>= (n+1)//2:
        K[i]=0
        stopper = i
        break

if stopper!=0 and stopper<=38:
    for i in range(stopper+1,40):
        if  B[i]>= (n+1)//2:
            K[i] = 0
        else:
            K[i] = 1

for i in range(n):
    for j in range(1,42-stopper):
        All[i][-j] = K[-j]^All[i][-j]

c = np.cumsum(All,axis = 0)
C = c[len(c)-1]
for i in range(1,41):
    sum_ = sum_ + C[-i]*(2**(i-1))

print(sum_)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
A = list(map(int, input().split()))
All = [[0]*40 for i in range(n)]
K = [0]*40
stopper = 0
sum_ = 0
B = []
b = 0

for i in range(len(A)):
    bin_a = format(A[i],'b')
    list_a = [int(i) for i in bin_a]
    All[i] = [0]*(40-len(list_a))+ list_a
    
bin_k =   format(k,'b') 
list_k = [int(i) for i in bin_k]
K = [0]*(40-len(list_k))+list_k

for i in range(40):
    for j in range(n):
        b = b + All[j][i]
    B = B + b
    
for i in range(40):
    if K[i]==1 and B[i]>= (n+1)//2:
        K[i]=0
        stopper = i
        break

if stopper!=0 and stopper<=38:
    for i in range(stopper+1,40):
        if K[i]==1 and B[i]>= (n+1)//2:
            K[i] = 0
        if K[i]==0 and B[i]< (n+1)//2:
            K[i] = 1

for i in range(n):
    for j in range(1,41):
        All[i][-j] = K[-j]^All[i][-j]
        sum_ = sum_ + All[i][-j]*(2**(j-1))

print(sum_)
Problem p03147 (python)

Fixed submission:

import numpy as np
n = int(input())
h = list(map(int, input().split()))
h = np.array(h)

count = 0

for k in range(max(h)):
    j = 0
    for i in range(0,len(h)):
        if h[i]==0 and i!=j:
            h[j:i] = h[j:i] -1
            count = count+1
            j = i + 1
        elif i ==len(h)-1 and h[n-1]!=0:
            count = count+1
            h[j:]= h[j:]-1
        elif h[i]==0 and i==j:
            j = i+1
print(count)

Buggy submission (verdict: Runtime Error):

import numpy as np
n = int(input())
h = list(map(int, input().split()))
h = np.array(h)

count = 0

for k in range(max(h)):
    j = 0
    for i in range(0,len(h)):
        if h[i]==0 and i!=j:
            h[j:i] = h[j:i] -1
            count = count+1
            j = i + 1
        elif i ==len(h)-1 and h[n]!=0:
            count = count+1
            h[j:]= h[j:]-1
        elif h[i]==0 and i==j:
            j = i+1
print(count)
Problem p02883 (python)

Fixed submission:
import numpy as np
i8 = np.int64
i4 = np.int32


def solve(A, F, K):
    min_ = 0
    max_ = 10 ** 12
    while min_ < max_:
        mid = (min_ + max_) // 2
        count = A - mid // F
        sum_ = count[count > 0].sum()
        if sum_ <= K:
            max_ = mid
        else:
            min_ = mid + 1
    return min_

def main():
    stdin = open('/dev/stdin', 'rb')
    pin = np.fromstring(stdin.read(), i8, sep=' ')
    N, K = pin[:2]
    A = pin[2: N + 2]
    F = pin[N + 2: 2 * N + 2]
    A = np.sort(A)[::-1]
    F.sort()
    ans = solve(A, F, K)
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
f = list(map(int,input().split()))
a.sort()
f.sort(reverse = True)

def is_ok(t):
  cost = 0
  for aa,ff in zip(a,f):
    temp = t // ff
    if temp >= aa:
      contninue
    cost += aa - temp
    if cost > k:
      return False
  return True
left = 0
right = a[-1]*f[0]+1
while left < right:
  mid = (left + right) // 2
  if is_ok(mid):
    right = mid
  else:
    left = mid + 1
print(left)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
f = list(map(int,input().split()))
a.sort()
f.sort(reverse = True)

def is_ok(t):
  cost = 0
  for aa,ff in zip(a,f):
    temp = t // ff
    if temp >= aa:
      contninue
    cost += aa - temp
  if cost <= k:
    return True
  return False
left = 0
right = a[-1]*f[0]
while left < right:
  mid = (left + right) // 2
  if is_ok(mid):
    right = mid
  else:
    left = mid + 1
print(left)
Problem p02898 (python)

Fixed submission:
n, k = map(int, input().split(' '))
hs = list(map(int, input().split(' ')))
print(len([h for h in hs if h >= k]))

Buggy submission (verdict: Runtime Error):
n,m = int(input().split(''))
arr = list(map(int,input().split('')))
res = 0
for i in arr:
  if i >= m:
    res += 1
return res
Problem p02899 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
 
b = [0] * n
for i in range(n):
    b[a[i] - 1] = str(i + 1)
 
print(' '.join(b))

Buggy submission (verdict: Runtime Error):
n = int(input())
arr = list(map(int,input().split(' ')))
res = [0]*(n+1)
for i,v in enumerate(arr):
  res[v] = i+1
res.pop(0)
print(' '.join(res))
Problem p03071 (python)

Fixed submission:
a,b=map(int,input().split())
print(max(a+b,2*a-1,2*b-1))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
return max(a+b,2*a-1,2*b-1)
Problem p03076 (python)

Fixed submission:
a=[int(input()) for i in range(5)]
b=[i-i%10+10 if i%10!=0 else i for i in a]
diff=[y-x for x,y in zip(a,b)]
print(sum(b)-max(diff))

Buggy submission (verdict: Runtime Error):
a=[]
for i in range(5):
  a.append(int(input()))
m={}
for i in range(5):
  if a[i]%10!=0:
    m[a[i]%10]=a[i]
target=m[min(m.keys())]
res=0
for i in range:
  if a[i]==target:
    res+=target
  else:
    res+=math.ceil(a[i]/1)
print(res)
Problem p03078 (python)

Fixed submission:
x, y, z, k = map(int, input().split())

xlist = sorted(list(map(int,input().split())), reverse=True)[:min(x, k)]
ylist = sorted(list(map(int,input().split())), reverse=True)[:min(y, k)]
zlist = sorted(list(map(int,input().split())), reverse=True)[:min(z, k)]


anslist = [0]
for i in range(min(x, k)):
    for j in range(min(y, k)):
        for l in range(min(z, k)):
            if (i+1)*(j+1)*(l+1) <= k:
                anslist.append(xlist[i] + ylist[j] + zlist[l])
            else:
                break

anslist = sorted(anslist, reverse=True)
for i in range(k):
    print(anslist[i])

Buggy submission (verdict: Runtime Error):
a,b,c,k=map(int,input().split())
cake1=sort(map(int,input().split()),reverse=True)[:max(a,k)]
cake2=sort(map(int,input().split()),reverse=True)[:max(b,k)]
cake3=sort(map(int,input().split()),reverse=True)[:max(c,k)]
res=[]
for i in range(min(a,k)):
  for j in range(min(b,k)):
    for l in range(min(c,k)):
      if (a+1)*(b+1)*(c+1)<k:
        res.append(cake1[i]+cake2[j]+cake3[l])
res.sort(reverse=True)
for i in range(k):
  print(res[i])
Problem p03085 (python)

Fixed submission:
map={'A':'T','C':'G','G':'C','T':'A'}
inp=input()
print(map[inp])

Buggy submission (verdict: Runtime Error):
map={'A':'T','C':'G','G':'C','T':'A'}
inp=input()
return map[inp]
Problem p03096 (python)

Fixed submission:
n=int(input())
arr=[int(input()) for _ in range(n)]
mod=10**9+7

dp=[0]*n
dp[0]=1

record={arr[0]:0}

for i,v in enumerate(arr):
  if i==0:
    continue
  dp[i]=dp[i-1]
  if v in record and record[v]<i-1:
    dp[i]+=dp[record[v]]
    dp[i]=dp[i]%mod
  record[v]=i
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
arr=[int(input()) for _ in range(n)]
dp=[0]*n
dp[0]=1
mod=10**9+7
record={arr[0]:0}
for i,v in enumerate(arr):
  if i==0:
    continue
  dp[i]=dp[i-1]
  if record[v] and record[v]<i-1:
    dp[i]+=dp[record[v]]
    dp[i]=dp[i]%mod
print(dp[-1])
Problem p03103 (python)

Fixed submission:
N, M = map(int, input().split())
shop = []
for i in range(N):
    a, b = map(int, input().split())
    shop.append([a, b])
shop.sort(key=lambda x: x[0])

amount = 0
quantity = 0
for s in shop:
    if quantity + s[1] < M:
        amount += s[0] * s[1]
        quantity += s[1]
    else:
        amount += (M - quantity) * s[0]
        quantity = M
        break

print(amount)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
store=[map(int,input().split()) for _ in range(N)]
store.sort(key=lambda x: x[0])
res=0
for i in range(len(store)):
  price=store[i][0]
  num=store[i][1]
  if M>num:
    res+=price*num
    M-=num
  else:
    res+=price*M
    break
print(res)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
store=[]
for _ in range(N):
  store.append([map(int,input().split())])
store.sort(key=lambda x: x[0])
res=0
for i in range(len(store)):
  price=store[i][0]
  num=store[i][1]
  if M>num:
    res+=price*num
    M-=num
  else:
    res+=price*M
    break
print(res)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
store=[]
for _ in range(M):
  store.append([map(int,input().split())])
store.sort(key=lambda x: x[0])
res=0
for i in range(len(store)):
  if M-store[i][1]<=0:
    res+=store[i][0]*M
    break
  else:
    res+=store[i][0]*store[i][1]
    M-=store[i][1]
print(res)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
store=[]
for _ in range(M):
  store.append([map(int,input().split())])
sorted(store,key=lambda x: x[0])
res=0
for i in range(len(store)):
  if M-store[i][1]<=0:
    res+=store[i][0]*M
    break
  else:
    res+=store[i][0]*store[i][1]
    M=M-store[i][1]
print(res)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
store=[list(map(int,input().split())) for _ in range(N)]
sorted(store,cmp=lambda x,y:x[0]-y[0] if x[0]!=y[0] else x[1]-y[1])
res=0
for i in range(len(store)):
  if M-store[i][1]<=0:
    res+=store[i][0]*M
    break
  else:
    res+=store[i][0]*store[i][1]
    M=M-store[i][1]
print(res)
Problem p03109 (python)

Fixed submission:
a,b,c=list(map(int,input().split('/')))
if b>4:
  print('TBD')
else:
  print('Heisei')

Buggy submission (verdict: Runtime Error):
a,b,c=list(map(int,input.split('/')))
if b>4:
  print('TBD')
else:
  print('Heisei')

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input.split('/'))
if b>4:
  print('TBD')
else:
  print('Heisei')

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a>2019:
  print('TBD')
elif a<2019:
  print('Heisei')
else:
  if b>4:
    print('TBD')
  elif b<=4:
    print('Heisei')
Problem p03110 (python)

Fixed submission:
N = int(input())
ans = 0
for i in range(N):
    x, v = input().split()
    x = float(x)
    if v == "BTC":
        x *= 380000
    ans += x 
print(ans)

Buggy submission (verdict: Runtime Error):
num=int(input())
res=0
for i in range(num):
  t=input().split()
  if t[1]=='BTC':
    t[0]=int(t[0])*380000
  res+=int(t[0])
print(res)
Problem p03146 (python)

Fixed submission:
s = int(input())

used = set()
used |= {s}
count = 1

while True:
    if s % 2 == 0: s//=2
    else:s=3*s+1
    if s in used:
        print(count+1)
        break
    else:
        used |= {s}
        count += 1

Buggy submission (verdict: Runtime Error):
n=int(input().split())
dic=set()
dic|={n}
i=1
while True:
  if n%2==0:
    n=n//2
  else:
    n=3*n+1
  if n in dic:
    print(i+1)
    break
  else:
    dic|={n}
    i+=1

Buggy submission (verdict: Runtime Error):
n=int(input().split())
dic=set()
dic|={n}
i=1
while True:
  if n%2==0:
    n=n//2
  else:
    n=3*n+1
  i+=1
  if n in dic:
    print(i)
    break
  else:
    dic|={n}

Buggy submission (verdict: Runtime Error):
n=int(input().split())
dic=set()
dic|={1}
i=1
while True:
  if n%2==0:
    n=n//2
  else:
    n=3*n+1
  i+=1
  if n in dic:
    print(i)
    break
  else:
    dic|={i}

Buggy submission (verdict: Runtime Error):
n=int(input().split())
dic={n:1}
i=1
while True:
  if n%2==0:
    n=n//2
  else:
    n=3*n+1
  i+=1
  if n in dic:
    print(i)
    break
  else:
    dic[n]=i

Buggy submission (verdict: Runtime Error):
n=int(input().split())
dic={n:1}
i=1
while True:
  if n%2==0:
    n=n//2
  else:
    n=3*n+1
  i+=1
  if n in dic:
    print(dic[n])
    break
  else:
    dic[n]=i
Problem p03246 (python)

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
from collections import Counter
even=Counter(arr[::2])
even[0]=0
odd=Counter(arr[1::2])
odd[0]=0
even1,even2=even.most_common(2)
odd1,odd2=odd.most_common(2)
if even1[0]!=odd1[0]:
  print(n-(even1[1]+odd1[1]))
else:
  print(n-max(even1[1]+odd2[1],even2[1]+odd1[1]))

Buggy submission (verdict: Runtime Error):
n=int(input())
arr=map(int,input().split())
from collections import Counter
even=Counter(arr[::2])
even[0]=0
odd=Counter(arr[1::2])
odd[0]=0
even1,even2=even.most_common(2)
odd1,odd2=odd.most_common(2)
if even1[0]!=odd1[0]:
  print(n-(even1[1]+odd1[1]))
else:
  print(n-max(even1[1]+odd2[1],even2[1]+odd1[1]))
Problem p02960 (python)

Fixed submission:
s = input()
dp = [[0]*13 for _ in range(len(s))]
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(s[0])] = 1
for k in range(len(s)-1):
    if s[k+1] == '?':
        for i in range(13):
            for j in range(10):
                dp[k+1][((i*10%13)+j)%13] += dp[k][i]
                dp[k+1][((i*10%13)+j)%13] %= (10**9+7)
    else:
        for i in range(13):
            dp[k+1][((i*10%13)+int(s[k+1]))%13] += dp[k][i]
            dp[k+1][((i*10%13)+int(s[k+1]))%13] %= (10**9+7)
print(dp[-1][5])

Buggy submission (verdict: Runtime Error):
s = input()[:-1]
dp = [[0]*13 for _ in range(len(s))]
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(s[0])] = 1
for k in range(len(s)-1):
    if s[k+1] == '?':
        for i in range(13):
            for j in range(10):
                dp[k+1][((i*10%13)+j)%13] += dp[k][i]
                dp[k+1][((i*10%13)+j)%13] %= (10**9+7)
    else:
        for i in range(13):
            dp[k+1][((i*10%13)+int(s[k+1]))%13] += dp[k][i]
            dp[k+1][((i*10%13)+int(s[k+1]))%13] %= (10**9+7)
print(dp[-1][5])

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline

s = input()
dp = [[0]*13 for _ in range(len(s))]
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(s[0])] = 1
for k in range(len(s)-1):
    if s[k+1] == '?':
        for i in range(13):
            for j in range(10):
                dp[k+1][((i*10%13)+j)%13] += dp[k][i]
                dp[k+1][((i*10%13)+j)%13] %= (10**9+7)
    else:
        for i in range(13):
            dp[k+1][((i*10%13)+int(s[k+1]))%13] += dp[k][i]
            dp[k+1][((i*10%13)+int(s[k+1]))%13] %= (10**9+7)
print(dp[-1][5])

Buggy submission (verdict: Runtime Error):
s = input()
dp = [[0]*13 for _ in range(len(s))]
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][s[0]] = 1
for k in range(len(s)-1):
    if s[k+1] == '?':
        for i in range(13):
            for j in range(10):
                dp[k+1][((i*10%13)+j)%13] += dp[k][i]
                dp[k+1][((i*10%13)+j)%13] %= (10**9+7)
    else:
        for i in range(13):
            dp[k+1][((i*10%13)+int(s[k+1]))%13] += dp[k][i]
            dp[k+1][((i*10%13)+int(s[k+1]))%13] %= (10**9+7)
print(dp[-1][5])
Problem p02972 (python)

Fixed submission:
import sys
import math

def add_ball(idx):
    add_list = []
    for j in range(1, int(math.sqrt(idx))+1):
        if idx%j == 0:
            add_list.append(j)
            if j != idx//j:
                add_list.append(idx//j)
    for k in add_list:
        b_list[k] += 1

if __name__ == "__main__":
    input = sys.stdin.readline

    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = [0] * (n+1)
    cnt = 0
    ans_list = []
    for a, i in zip(reversed(a_list), range(n, 0, -1)):
        if a != b_list[i]%2:
            cnt += 1
            ans_list.append(i)
            add_ball(i)
    ans_list.sort()
    print(cnt)
    if cnt > 0:
        print(' '.join(map(str, ans_list)))

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

def add_ball(idx):
    add_list = [idx]
    if idx > 1:
        for j in range(2, int(math.sqrt(idx))+1):
            if idx%j == 0:
                add_list.append(j)
                if j != idx//i:
                    add_list.append(idx//j)
    for k in add_list:
        b_list[k-1] = (b_list[k-1]+1)%2

if __name__ == "__main__":
    input = sys.stdin.readline

    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = [0] * n
    for i, a in enumerate(a_list[::-1]):
        if a != b_list[-i-1]:
            add_ball(n-i)
    ball_sum = sum(b_list)
    ball_list = [i+1 for i, b in enumerate(b_list) if b == 1]
    print(ball_sum)
    if ball_sum > 0:
        print(' '.join(map(str, ball_list)))
Problem p02995 (python)

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(x, y):
    return (x * y) // gcd(x, y)


if __name__ == "__main__":
    a, b, c, d = map(int, input().split())
    a -= 1
    cnt = b - a
    cnt -= b//c - a//c
    cnt -= b//d - a//d
    l = lcm(c, d)
    cnt += b//l - a//l
    print(cnt)

Buggy submission (verdict: Runtime Error):
import math


def lcm(x, y):
    return int((x * y) / math.gcd(x, y))


if __name__ == "__main__":
    a, b, c, d = map(int, input().split())
    cnt_ac, cnt_bc = int((a-1)/c), int(b/c)
    cnt_ad, cnt_bd = int((a-1)/d), int(b/d)
    cnt_acd, cnt_bcd = int(a/lcm(c,d)), int(b/lcm(c,d))
    print((cnt_bc-cnt_ac), (cnt_bd-cnt_ad), (cnt_bcd-cnt_acd))
    print((b-a+1) - ((cnt_bc-cnt_ac)+(cnt_bd-cnt_ad)-(cnt_bcd-cnt_acd)))
Problem p03014 (python)

Fixed submission:
import sys

input = sys.stdin.readline

h, w = map(int, input().split())
map_list = [[0 if s == '#' else 1 for s in input()[:-1]] for _ in range(h)]

h_map = []
for h_list in map_list:
    cnt = 0
    tmp_list = []
    for a in h_list:
        if a == 0:
            if cnt > 0:
                tmp_list.extend([cnt]*cnt)
                cnt = 0
            tmp_list.append(0)
        else:
            cnt += 1
    if cnt > 0:
        tmp_list.extend([cnt]*cnt)
    h_map.append(tmp_list)

w_map = []
for w_arr in [list(x) for x in zip(*map_list)]:
    cnt = 0
    tmp_list = []
    for a in w_arr:
        if a == 0:
            if cnt > 0:
                tmp_list.extend([cnt]*cnt)
                cnt = 0
            tmp_list.append(0)
        else:
            cnt += 1
    if cnt > 0:
        tmp_list.extend([cnt]*cnt)
    w_map.append(tmp_list)
w_map = [list(x) for x in zip(*w_map)]
max_l = 0
for h_list, w_list in zip(h_map, w_map):
    for h_num, w_num in zip(h_list, w_list):
        max_l = max(max_l, h_num + w_num)
print(max_l - 1)

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

input = sys.stdin.readline

h, w = map(int, input().split())
map_arr1d = np.array([0 if s == '#' else 1 for _ in range(h) for s in input()[:-1]])
map_2d = map_arr1d.reshape(h, w)

h_map = []
for h_arr in map_2d:
    cnt = 0
    tmp_list = []
    for a in h_arr:
        if a == 0:
            if cnt > 0:
                tmp_list.extend([cnt]*cnt)
                cnt = 0
            tmp_list.append(0)
        else:
            cnt += 1
    if cnt > 0:
        tmp_list.extend([cnt]*cnt)
    h_map.extend(tmp_list)
h_map = np.array(h_map).reshape(h, w)

w_map = []
for w_arr in map_2d.T:
    cnt = 0
    tmp_list = []
    for a in w_arr:
        if a == 0:
            if cnt > 0:
                tmp_list.extend([cnt]*cnt)
                cnt = 0
            tmp_list.append(0)
        else:
            cnt += 1
    if cnt > 0:
        tmp_list.extend([cnt]*cnt)
    w_map.extend(tmp_list)
w_map = np.array(w_map).reshape(w, h).T
print((h_map + w_map).max()-1)
Problem p03112 (python)

Fixed submission:
import sys
import bisect


input = sys.stdin.readline
a, b, q = map(int, input().split())
inf = 10**12
s_list = [-inf] + [int(input()) for _ in range(a)] + [inf]
s_list.sort()
t_list = [-inf] + [int(input()) for _ in range(b)] + [inf]
t_list.sort()
ans_list =[]
for _ in range(q):
    x = int(input())
    s_idx = bisect.bisect_right(s_list, x)
    t_idx = bisect.bisect_right(t_list, x)
    ans = inf
    for s in [s_list[s_idx-1], s_list[s_idx]]:
        for t in [t_list[t_idx-1], t_list[t_idx]]:
            ans = min(ans, min(abs(x-s), abs(x-t)) + abs(s-t))
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque


def bfs(s):
    flag_list[s] = 1
    color_list[s] = 0
    q.append(s)
    while len(q)>0:
        u = q.popleft()
        for v, w in enumerate(m_list[u]):
            if w > 0 and flag_list[v] == 0:
                flag_list[v] = 1
                if w%2 == 0:
                    color_list[v] = color_list[u]
                else:
                    color_list[v] = (color_list[u]+1)%2
                q.append(v)
        flag_list[u] = 2


if __name__ == "__main__":
    input = sys.stdin.readline
    n = int(input())
    m_list = [[0]*n for _ in range(n)]
    color_list = [0]*n
    flag_list = [0]*n
    q = deque([])
    for _ in range(n-1):
        u, v, w = map(int, input().split())
        m_list[u-1][v-1] = w
        m_list[v-1][u-1] = w
    bfs(0)
    for color in color_list:
        print(color)
Problem p03311 (python)

Fixed submission:
import numpy as np
n = int(input())
if n == 1:
    a = input()
    print(0)
else:
    a = np.array(list(map(int, input().split())))
    check = np.arange(1, n+1)
    c = sorted(list(a - check))
    b1 = c[int(n/2)]
    b2 = c[int(n/2)+1]
    count1 = 0
    count2 = 0
    for i in range(1, n+1):
        count1 += abs(a[i-1] - i - b1)
        count2 += abs(a[i-1] - i - b2)
    print(min(count1, count2))

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
check = np.arange(1, n+1)
c = sorted(list(a - check))
b1 = c[int(n/2)]
b2 = c[int(n/2)+1]
count1 = 0
count2 = 0
for i in range(1, n+1):
    count1 += abs(a[i-1] - i - b1)
    count2 += abs(a[i-1] - i - b2)
print(min(count1, count2))
Problem p03543 (python)

Fixed submission:
n = input()
if n[0] == n[1]:
    if n[0] == n[2]:
        print("Yes")
    else:
        print("No")
else:
    if n[1] != n[2] or n[1] != n[3]:
        print("No")
    else:        
        print("Yes")

Buggy submission (verdict: Runtime Error):
n = input()
if n[0] == n[1]:
    if n[0] == n[2] or n[0] == n[3]:
        print("Yes")
    else:
        print("No")
else:
    if n{1} != n[2]:
        print("No")
    else:
        print("Yes")