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

Fixed submission:
n,m,l=map(int,raw_input().split())
INF=(10**9)+1

g=[]
f=[]
for i in xrange(n):
    g.append([INF]*(n))
    f.append([INF]*(n))

for i in xrange(len(g)):
    for j in xrange(len(g)):
        if i==j:
            g[i][j]=0
            f[i][j]=0

for i in xrange(m):
    a,b,c=map(int,raw_input().split())
    g[a-1][b-1]=c
    g[b-1][a-1]=c
    f[a-1][b-1]=c
    f[b-1][a-1]=c

for k in xrange(n):
    for i in xrange(n):
        for j in xrange(n):
            g[i][j]=min(g[i][j],g[i][k]+g[k][j])
            f[i][j]=min(f[i][j],f[i][k]+f[k][j])

for i in xrange(n):
    for j in xrange(n):
        if f[i][j]<=l:
            g[i][j]=1
        else:
            g[i][j]=INF
        if i==j:
            g[i][j]=0

for k in xrange(n):
    for i in xrange(n):
        for j in xrange(n):
            g[i][j]=min(g[i][j],g[i][k]+g[k][j])

q=int(raw_input())
for i in xrange(q):
    s,t=map(int,raw_input().split())
    u=g[s-1][t-1]

    if u>=INF:
        print (-1)
    else:
        print (u-1)

Buggy submission (verdict: Runtime Error):
import math

n,m,l=map(int,raw_raw_input().split())
INF=(10**9)+1

g=[]
f=[]
for i in xrange(n):
    g.append([INF]*(n))
    f.append([INF]*(n))

for i in xrange(len(g)):
    for j in xrange(len(g)):
        if i==j:
            g[i][j]=0
            f[i][j]=0

for i in xrange(m):
    a,b,c=map(int,raw_input().split())
    g[a-1][b-1]=c
    g[b-1][a-1]=c
    f[a-1][b-1]=c
    f[b-1][a-1]=c

for k in xrange(n):
    for i in xrange(n):
        for j in xrange(n):
            g[i][j]=min(g[i][j],g[i][k]+g[k][j])
            f[i][j]=min(f[i][j],f[i][k]+f[k][j])

for i in xrange(n):
    for j in xrange(n):
        if f[i][j]<=l:
            g[i][j]=1
        else:
            g[i][j]=INF
        if i==j:
            g[i][j]=0

for k in xrange(n):
    for i in xrange(n):
        for j in xrange(n):
            g[i][j]=min(g[i][j],g[i][k]+g[k][j])

q=int(raw_input())
for i in xrange(q):
    s,t=map(int,raw_input().split())
    u=g[s-1][t-1]

    if u>=INF:
        print (-1)
    else:
        print (u-1)
Problem p02803 (python)

Fixed submission:
from collections import deque
r, c = map(int, input().split())
 
orig_maze = [[val for val in list(input())] for _ in range(r)]

maze = [[None for _ in range(c+2)] for _ in range(r+2)]
for r_index in range(r+2):
  for c_index in range(c+2):
    if r_index == 0 or r_index == r+1 or c_index == 0 or c_index == c+1:
      maze[r_index][c_index] = "#"
    else:
      maze[r_index][c_index] = orig_maze[r_index-1][c_index-1]
      
def wfs(queue):
    finish_dist = None
    max_way = 0
    while len(queue) > 0:
        a = queue.popleft()
        y = a[0]
        x = a[1]
        count = a[2]
        if checked_maze[y][x]:
            continue
        
        checked_maze[y][x] = True
        if not maze[y][x] == "#":
            max_way = count
            count += 1
            queue.append((a[0]+1, a[1], count))
            queue.append((a[0]-1, a[1], count))
            queue.append((a[0], a[1]+1, count))
            queue.append((a[0], a[1]-1, count))

    return max_way 
 
if __name__ == "__main__":
    result = 0
    
    for s_y in range(1, r+1):
      for s_x in range(1, c+1):
        checked_maze = [[None for _ in range(c+2)] for _ in range(r+2)]
        que = deque()
        checked_maze[s_y][s_x]= 0
        que.append((s_y, s_x, 0))
        finish_dist = wfs(que)
        result = max(result,finish_dist)
    print(result)

Buggy submission (verdict: Runtime Error):
from collections import deque
r, c = map(int, input().split())
 
orig_maze = [[val for val in list(input())] for _ in range(r)]

maze = [[None for _ in range(c+2)] for _ in range(r+2)]
for r_index in range(r+2):
  for c_index in range(c+2):
    if r_index == 0 or r_index == r+1 or c_index == 0 or c_index == c+1:
      maze[r_index][c_index] = "#"
    else:
      maze[r_index][c_index] = orig_maze[r_index-1][c_index-1]
      
def wfs(queue, goal):
    finish_dist = None
    while len(queue) > 0:
        a = queue.popleft()
        y = a[0]
        x = a[1]
        count = a[2]
        if checked_maze[y][x]:
            continue
 
        if a[0] == goal[0] and a[1] == goal[1]:
            finish_dist = count
            break
 
        checked_maze[y][x] = True
        if not maze[y][x] == "#":
            count += 1
            queue.append((a[0]+1, a[1], count))
            queue.append((a[0]-1, a[1], count))
            queue.append((a[0], a[1]+1, count))
            queue.append((a[0], a[1]-1, count))

    return finish_dist 
 
 
if __name__ == "__main__":
    result = 0
    for s_y in range(1, r+1):
      for s_x in range(1, c+1):
        for g_y in range(1, r+1):
          for g_x in range(1, r+1):
            if maze[s_y][s_x] == "." and maze[g_y][g_x] == ".":
              if s_y == g_y and s_x == g_x:
                finish_dist = 0
              else:
                checked_maze = [[None for _ in range(c+2)] for _ in range(r+2)]
                que = deque()
                checked_maze[s_y][s_x]= 0
                que.append((s_y, s_x, 0))
                finish_dist = wfs(que, (g_y, g_x))
            result = max(result,finish_dist)
    print(result)
Problem p02812 (python)

Fixed submission:
n = int(input())
s = list(input())
type = "A"
count = 0
for char in s:
    if char == "A":
        type = "B"
    elif char == "B" and type == "B":
        type = "C"
    elif char == "C" and type == "C":
        count += 1
        type = "A"
    else:
        type = "A"
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input())
type = "A"
count = 0
for char in s:
    if char == "A"
        type = "B"
    elif char == "B" and type == "B":
        type = "C"
    elif char == "C" and type == "C":
        count += 1
        type = "A"
    else:
        type = "A"
print(count)
Problem p02999 (python)

Fixed submission:
import sys
input = sys.stdin.readline
 
################################################################################
 
x, a = map(int, input().split())
if x < a:
    print(0)
else:
    print(10)

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

################################################################################

x, a = map(int, input())
if x < a:
    print(0)
else:
    print(10)
Problem p02789 (python)

Fixed submission:
N, M=input().split()
if N == M:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N, M=input().split()
if N == M:
  print(AC)
else:
  print(WA)
Problem p02801 (python)

Fixed submission:
x = input()
print(chr(ord(x) + 1))

Buggy submission (verdict: Runtime Error):
x = input()
print chr(ord(x) + 1)

Buggy submission (verdict: Runtime Error):
c =input()
c=c.upper()
c=chr(ord(c) + 1)
print(x)
Problem p02817 (python)

Fixed submission:
S,T = map(str,input().split())
print(T+S)

Buggy submission (verdict: Runtime Error):
S,T = map(int,input().split())
print(T+S)
Problem p02818 (python)

Fixed submission:
A,B,K = map(int,input().split())
T = A - K
O = B

if T >= 0:
    print(T, O)
elif O+T >=0:
    print(0,O+T)
else:
    print(0,0)

Buggy submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
T = A - K
O = 0
if T >= 0:
	print(T, 0)
	else:
      print(0,O-T)
Problem p03106 (python)

Fixed submission:
a,b,k=map(int,input().split())
check=0
m=min(a,b)
for i in range(m,0,-1):
    if a%i==0 and b%i==0:
        check+=1
        if check==k:
            print(i)
            break

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, n):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
 
    # divisors.sort()
    return divisors
A, B, K=map(int,input().split())
dA = make_divisors(A)
dB = make_divisors(B)
D = list(set(dA)&set(dB))
print(D[-K])

Buggy submission (verdict: Runtime Error):
def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
A, B, K=map(int,input().split())
D = cf(A,B)
print(D[-K])
Problem p03285 (python)

Fixed submission:
import math
n = int(input())
counter = False
#for n in range (0,100):
for i in range (math.ceil((n+1) / 4) ):
  for j in range (math.ceil((n+1) / 7) ):
    #print(n, i,j)
    if i*4 + j*7 == n:
      counter = True
if counter == True:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
counter = False
#for n in range (0,100):
  for i in range (math.ceil((n+1) / 4) ):
    for j in range (math.ceil((n+1) / 7) ):
      #print(n, i,j)
      if i*4 + j*7 == n:
        counter = True
  if counter == True:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
counter = False
#for n in range (0,100):
  for i in range (math.ceil((n+1) / 4) ):
    for j in range (math.ceil((n+1) / 7) ):
      #print(n, i,j)
      if i*4 + j*7 == n:
        counter = True
  if counter == True:
    print("Yes")
  else:
   	print("No")
Problem p03324 (python)

Fixed submission:
D, N = map(int,input().split())
if D == 2:
  if N < 100:
    print(N*10000)
  else:
    print(1010000)
elif D == 1:
  if N < 100:
    print(N*100)
  else:
    print(10100)
else:
  if N < 100:
    print(N)
  else:
    print(101)

Buggy submission (verdict: Runtime Error):
D = int(input())
N = int(input())
if D == 2:
  print(N*10000)
elif D == 1:
  print(N*100)
else:
  print(N)
Problem p03331 (python)

Fixed submission:
import math
N = int(input())
n = N
amari = 0
for i in range (len(str(N))):
  amari += n % 10
  n = math.floor(n / 10)
if amari == 1:
  print(10)
else:
  print(amari)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
n = N
amari = 0
for i in range (len(str(N))):
  amari += n % 10
  n = math.floor(n / 10)
if amari = 1:
  print(10)
else:
  print(amari)
Problem p03493 (python)

Fixed submission:
a = int(input())
count = 0
for i in range (len(str(a))):
  if str(a)[i] == '1':
    count += 1
  else:
    pass
print(count)

Buggy submission (verdict: Runtime Error):
a = int(input())
count = 0
for i in range (3):
  if str(a)[i] == '1':
    count += 1
  else:
    pass
print(count)
Problem p03501 (python)

Fixed submission:
N, A, B = map(int, input().split()) 
if B >= A*N:
  print(A*N)
else:
  print(B)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input()split()) 
if B >= A*N:
  print(A*N)
else:
  print(B)
Problem p02830 (python)

Fixed submission:
N = int(input())
ans = ["0"] * 2 * N
 
S, T = input().split()
for i in range(N):
  ans[2*i] = S[i]
  ans[2*i+1] = T[i] 
print("".join(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = ["0"] * 2N

S, T = input().split()
for i in range(N):
  ans[2*i] = S[i]
  ans[2*i+1] = T[i]

print("".join(ans))
Problem p02900 (python)

Fixed submission:
"""
最大公約数を求める
最大公約数の約数を列挙
素数かどうかを判定
"""

import math

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

def max_yakusu(a, b):
    while b:
        a, b = b, a % b
    return a

def is_prime(n):
    """素数判定関数

    Arguments:
        n {[type]} -- [description]

    Returns:
        [type] -- [description]
    """
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return True

A, B = map(int,input().split())

gcd = max_yakusu(B,A)
numbers = divisor(int(gcd))
ans = 0
for i in numbers:
    if is_prime(i):
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
"""
最大公約数を求める
最大公約数の約数を列挙
素数かどうかを判定
"""

import functools
import math

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

def is_prime(n):
    """素数判定関数

    Arguments:
        n {[type]} -- [description]

    Returns:
        [type] -- [description]
    """
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return True

A, B = map(int,input().split())

gcd = functools.reduce(math.gcd, [A,B])
#print(gcd)
numbers = divisor(int(gcd))
#print(numbers)
ans = 0
for i in numbers:
    if is_prime(i):
        ans += 1
print(ans)
Problem p02983 (python)

Fixed submission:
L, R = map(int,input().split())
l , r = L//2019, R//2019
if R - L >= 2019:
    print(0)
elif R-L == 1:
    print(R*L%2019)
else:
    Amari=[]
    for i in range(L,R-1):
        for j in range(i+1,R+1):
            k = i*j
            Amari.append(k%2019)
    print(min(Amari))

Buggy submission (verdict: Runtime Error):
L, R = map(int,input().split())
l , r = L//2019, R//2019
if R - L >= 2019:
    print(0)
else:
    flag=0
    Amari=[]
    for i in range(L,R-1):
        amari = i % 2019
        if i %3 == 0:
            flag = True
        Amari.append(amari)
    if 673 in Amari and flag:
        print(0)
    else:
        print(min(Amari)*(min(Amari)+1))
Problem p02866 (python)

Fixed submission:
import sys
import collections
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

MOD = 998244353
N = int(input())
D = list(map(int, input().split()))
mD = max(D)

c = collections.Counter(D)
c = dict(c)

ans = 1
tmp = 1
for i in range(mD+1):
    if not(i in c.keys()):
        ans = 0
        break
    elif i == 0:
        if c[0] > 1:
            ans = 0
            break
    elif i == 1:
        tmp = c[i]
    else:
        ans = (ans * tmp**c[i])%MOD
        tmp = c[i]

if D[0] != 0:
    print(0)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import collections
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

MOD = 998244353
N = int(input())
D = list(map(int, input().split()))
mD = max(D)

c = collections.Counter(D)
c = dict(c)

ans = 1
tmp = 1
for i in range(mD+1):
    if not(i in c.keys()):
        ans = 0
        break
    elif i == 0:
        if c[0] > 1:
            ans = 0
            break
    elif i == 1:
        tmp = c[i]
    else:
        ans = (ans * tmp**c[i])%MOD
        tmp = c[i]

if N == 1:
    if D[0] == 0:
        print(1)
    else:
        print(0)
elif N < 5:
    print(D[100])
else:
    print(ans)
Problem p02921 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

S = list(input().strip())
T = list(input().strip())

ans = 0
for i in range(len(S)):
    if S[i] == T[i]:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())

A = []
for i in range(N):
    A.append(list(map(int, input().split())))

B = []
for i in range(N):
    tmp = [0] * N
    for j in range(N-1):
        tmp[A[i][j]-1] = j+1
    B.append(tmp)


ans = N-1
ans_tmp = 0
ans_tmp1 = 0
for i in range(N):
    ans_tmp = 0
    tmp = 0
    for j in A[i]:
        if B[j-1][i] > tmp:
            tmp = B[j-1][i]
        elif B[j-1][i] == tmp:
            ans_tmp += 1
        else:
            print(-1)
            sys.exit()
    ans_tmp1 = max(ans_tmp1, ans_tmp+tmp)

print(ans_tmp1)
Problem p02929 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

MOD = 10**9+7

N = int(input())
S = list(input().rstrip())

if S[0] == "W" or S[-1] == "W":
    print(0)
    sys.exit()

LR = [0 for i in range(2*N)]
count0 = 1
count0_raw = 1
ans = 1
for i in range(1, 2*N):
    if LR[i-1] == 0:
        if S[i] == S[i-1]:
            LR[i] = 1
        else:
            LR[i] = 0
    else:
        if S[i] == S[i-1]:
            LR[i] = 0
        else:
            LR[i] = 1

    if LR[i] == 0:
        count0 += 1
        count0_raw += 1
    else:
        ans *= count0
        ans %= MOD
        count0 -= 1

if count0_raw != N:
    print(0)
    sys.exit()

N_k = 1
for i in range(N):
    N_k *= i+1
    N_k %= MOD

print(ans*N_k%MOD)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

MOD = 10**9+7

N = int(input())
S = list(input())

if S[0] == "W" or S[-2] == "W":
    print(0)
    sys.exit()

LR = [0]
for i in range(1, 2*N):
    if LR[i-1] == 0:
        if S[i] == S[i-1]:
            LR.append(1)
        else:
            LR.append(0)
    else:
        if S[i] == S[i-1]:
            LR.append(0)
        else:
            LR.append(1)

if LR.count(0) != N:
    print(0)
    sys.exit()

count0 = 0
ans = 1
for i in range(2*N):
    if LR[i] == 0:
        count0 += 1
    else:
        ans *= count0
        count0 -= 1

def factorial(N, mod):
    if N == 0 or N == 1:
        return 1
    else:
        return N * factorial(N, mod) % mod

print(ans*factorial(N,MOD)%MOD)
Problem p02936 (python)

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

F = [0 for i in range(N)]
T = [[]for i in range(N)]

for i in range(N-1):
    a, b = map(int, input().split())
    T[a-1].append(b-1)

X = [0 for i in range(N)]
for i in range(Q):
    p, x = map(int, input().split())
    X[p-1] += x

ans = [X[i] for i in range(N)]
for i in range(N):
    F[i] = 1
    for j in range(len(T[i])):
        if F[T[i][j]] == 1:
            continue
        ans[T[i][j]] += ans[i]

for i in range(N):
    print(ans[i], end =" ")

Buggy submission (verdict: Runtime Error):
def main()
	import sys
	input = sys.stdin.readline
	sys.setrecursionlimit(10 ** 7)
 
 
	N, Q = map(int, input().split())
 
	T = [[]for i in range(N)]
 
	for i in range(N-1):
    	a, b = map(int, input().split())
    	T[a-1].append(b-1)
    	T[b-1].append(a-1)
 
	X = [0 for i in range(N)]
	for i in range(Q):
    	p, x = map(int, input().split())
    	X[p-1] += x
 
	def dfs(x, p):
    	for j in T[x]:
        	if j == p:
            	continue
        	X[j] += X[x]
        	dfs(j, x)
 
	dfs(0, -1)
 
	for i in range(N):
    	print(X[i], end =" ")
main()

Buggy submission (verdict: Runtime Error):
def main()
	import sys
	input = sys.stdin.readline
	sys.setrecursionlimit(10 ** 7)
 
 
	N, Q = map(int, input().split())
 
	T = [[]for i in range(N)]
 
	for i in range(N-1):
    	a, b = map(int, input().split())
    	T[a-1].append(b-1)
    	T[b-1].append(a-1)
 
	X = [0 for i in range(N)]
	for i in range(Q):
    	p, x = map(int, input().split())
    	X[p-1] += x
 
	def dfs(x, p):
    	for j in T[x]:
        	if j == p:
            	continue
        	X[j] += X[x]
        	dfs(j, x)
 
	dfs(0, -1)
 
	for i in range(N):
    	print(X[i], end =" ")
main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
 

N, Q = map(int, input().split())

T = [[]for i in range(N)]

for i in range(N-1):
    a, b = map(int, input().split())
    T[a-1].append(b-1)
    T[b-1].append(a-1)

X = [0 for i in range(N)]
for i in range(Q):
    p, x = map(int, input().split())
    X[p-1] += x

ans = [X[i] for i in range(N)]

def dfs(x, p):
    for j in range(len(T[x])):
        if j == p:
            continue
        ans[T[x][j]] += ans[x]
        dfs(T[x][j])

dfs(0)

for i in range(N):
    print(ans[i], end =" ")
Problem p02939 (python)

Fixed submission:
S = input()
S = list(S)

ans = 1
pre = S[0]
c = 1
while 1:
    if c == len(S):
        break
    if c == len(S)-1:
        if S[c] == pre:
            break
        else:
            ans += 1
            break

    if S[c] == pre:
        pre = S[c]+S[c+1]
        ans += 1
        c += 2
    else:
        pre = S[c]
        ans += 1
        c += 1

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
S = list(S)

ans = 1
pre = S[0]
c = 1

while 1:
    if c == len(S)-1:
        if S[c] == pre:
            break
        else:
            ans += 1
            break

    if S[c] == pre:
        pre = S[c]+S[c+1]
        ans += 1
        c += 2
    else:
        pre = S[c]
        ans += 1
        c += 1

print(ans)
Problem p03071 (python)

Fixed submission:
A, B = map(int, input().split())
if A==B:    
    print(max(A, B)+max(A, B))
else:
    print(max(A, B)+max(A, B)-1)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input())
print(max(A, B)+max(A, B)-1)
Problem p03240 (python)

Fixed submission:
n = int(input())

arr = []

for i in range(n):
    x, y, h = map(int, input().split())
    arr.append([x, y, h])

for i in range(101):
    for j in range(101):
        for k in range(n):
            if arr[k][2] > 0:
                len1 = abs(arr[k][0] - i) + abs(arr[k][1] - j)
                ch = len1 + arr[k][2]
                break
            else:
                continue
        for k in range(n):
            lenk = abs(arr[k][0] - i) + abs(arr[k][1] - j)
            if max(ch - lenk, 0) == arr[k][2]:
                if k == n-1:
                    print("{} {} {}".format(i, j, ch))
                else:
                    continue
            else:
                break

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

L = []
for i in range(N):
    x, y, h = map(int, input().split())
    L.append([x, y, h])
    if h != 0:
        idx = i


for i in range(101):
    for j in range(101):
        H = L[idx][2] + abs(L[idx][0]-i) + abs(L[idx][1]-j)
        for k in range(N):
            if L[k][2] == H - abs(L[k][0]-i) - abs(L[k][1]-j):
                pass
            else:
                break
            if k == N-1:
                ansx = i
                ansy = j
                ansh = H

print(ansx, ansy, ansh)
Problem p03266 (python)

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

bai = 1
k_arr = []
while bai * k <= n:
    k_arr.append(bai * k)
    bai += 1


if k % 2 == 0:
    bai2 = 1
    k_arr2 = []
    k_arr2_len = 0 - len(k_arr2)
    while bai2 * k/2 <= n:
        k_arr2.append(bai2 * k/2)
        bai2 += 1
        k_arr2_len = len(k_arr2) - len(k_arr)
    print(len(k_arr)*len(k_arr)*len(k_arr) + k_arr2_len*k_arr2_len*k_arr2_len)

else:
    print(len(k_arr)*len(k_arr)*len(k_arr))

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

bai = 1
k_arr = []
while bai * k <= n:
    k_arr.append(bai * k)
    bai += 1


if k % 2 == 0:
    bai2 = 1
    k_arr2 = []
    while bai2 * k/2 <= n:
        k_arr2.append(bai2 * k/2)
        bai2 += 1
        k_arr2_len = len(k_arr2) - len(k_arr)
    print(len(k_arr)*len(k_arr)*len(k_arr) + k_arr2_len*k_arr2_len*k_arr2_len)

else:
    print(len(k_arr)*len(k_arr)*len(k_arr))

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

if k == 1:
    print(0)
    sys.exit()

bai = 1
k_arr = []
while bai * k <= n:
    k_arr.append(bai * k)
    bai += 1


if k % 2 == 0:
    bai2 = 1
    k_arr2 = []
    while bai2 * k/2 <= n:
        k_arr2.append(bai2 * k/2)
        bai2 += 1
        k_arr2_len = len(k_arr2) - len(k_arr)
    print(len(k_arr)*len(k_arr)*len(k_arr) + k_arr2_len*k_arr2_len*k_arr2_len)

else:
    print(len(k_arr)*len(k_arr)*len(k_arr))

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


bai = 1
k_arr = []
while bai * k <= n:
    k_arr.append(bai * k)
    bai += 1


if k % 2 == 0:
    bai2 = 1
    k_arr2 = []
    while bai2 * k/2 <= n:
        k_arr2.append(bai2 * k/2)
        bai2 += 1
        k_arr2_len = len(k_arr2) - len(k_arr)
        
    print(k_arr2_len)
    print(len(k_arr)*len(k_arr)*len(k_arr) + k_arr2_len*k_arr2_len*k_arr2_len)

else:
    print(len(k_arr)*len(k_arr)*len(k_arr))