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

Fixed submission:
A, B, C, D = map(int, input().split())
max_cnt = B - A + 1
import fractions
lcm = int(C * D / fractions.gcd(C, D))
cnt_2 = B//C - (A-1)//C
cnt_3 = B//D - (A-1)//D
cnt_4 = B//lcm - (A-1)//lcm
print(max_cnt - cnt_2 - cnt_3 + cnt_4)

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
max_cnt = B - A + 1
import math
lcm = int(C * D / math.gcd(C, D))
cnt_2 = int(B/C) - int((A-1)/C)
cnt_3 = int(B/D) - int((A-1)/D)
cnt_4 = int(B/lcm) - int((A-1)/lcm)
print(max_cnt - cnt_2 - cnt_3 + cnt_4)

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
max_cnt = B - A + 1
import math
lcm = int(C * D / math.gcd(C, D))
cnt_2 = B//C - (A-1)//C
cnt_3 = B//D - (A-1)//D
cnt_4 = B//lcm - (A-1)//lcm
print(max_cnt - cnt_2 - cnt_3 + cnt_4)
Problem p03044 (python)

Fixed submission:
# import itertools
# import math
import sys
sys.setrecursionlimit(500*500)
# import numpy as np

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# H, W, K = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# S = input()

# d = sorted(d, reverse=True, key=lambda x:x[0])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

edges = [list(map(int,input().split())) for _ in range(N-1)]
tree = [[] for _ in range(N + 1)]

for edge in edges:
    tree[edge[0]].append([edge[1], edge[2]])
    tree[edge[1]].append([edge[0], edge[2]])

# print(tree)

depth = [-1] * (N + 1)
depth[1] = 0

def dfs(tree, s):
    for l in tree[s]:
        if depth[l[0]] == -1:
            depth[l[0]] = depth[s] + l[1]
            dfs(tree, l[0])

dfs(tree, 1)

# print(depth)

for l in depth[1:]:
    if l % 2 == 0:
        print(1)
    else:
        print(0)

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

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# H, W, K = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# S = input()

# d = sorted(d, reverse=True, key=lambda x:x[0])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

edges = [list(map(int,input().split())) for _ in range(N-1)]
tree = [[] for _ in range(N + 1)]

for edge in edges:
    tree[edge[0]].append([edge[1], edge[2]])
    tree[edge[1]].append([edge[0], edge[2]])

# print(tree)

depth = [-1] * (N + 1)
depth[1] = 0

def dfs(tree, s):
    for l in tree[s]:
        if depth[l[0]] == -1:
            depth[l[0]] = depth[s] + l[1]
            dfs(tree, l[0])

dfs(tree, 1)

# print(depth)

for l in depth[1:]:
    if l % 2 == 0:
        print(1)
    else:
        print(0)
Problem p03047 (python)

Fixed submission:
N, K = map(int, input().split())
print(N-K+1)

Buggy submission (verdict: Runtime Error):
N = int(input())
cnt_AB = 0
end_A = 0
start_B = 0
start_B_and_end_A= 0
for i in range(N):
    s = input()
    cnt_AB += s.count('AB')
    if s[-1] == 'A' and s[0] == 'B':
        start_B_and_end_A += 1
    else:
        if s[-1] == 'A':
            end_A += 1
        if s[0] == 'B':
            start_B += 1
if end_A == 0 and start_B == 0:
    print(cnt_AB + start_B_and_end_A - 1)
else:
    print(cnt_AB + start_B_and_end_A + min(end_A, start_B))
Problem p03129 (python)

Fixed submission:
N, K = map(int,input().split())
if N % 2 != 0:
    if (N/2 + 1) >= K:
        print("YES")
    else:
        print("NO")
else:
    if (N/2) >= K:
        print("YES")
    else:
        print("NO")

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
if N % 2 != 0:
    if (N/2 + 1) >= K:
    print("YES")
    else:
    print("NO")
else:
    if (N/2) >= K:
    print("YES")
    else:
    print("NO")
Problem p03200 (python)

Fixed submission:
S = input()
indexes = [i for i, x in enumerate(S) if x == "W"]
print(sum([x-i for i, x in enumerate(indexes)]))

Buggy submission (verdict: Runtime Error):
S = input()
num = 0
while(True):
    num += S.count("BW")
    S = S.replace("BW", "WB")
    print(S)
    if not "BW" in S:
        break
print(num)
Problem p03239 (python)

Fixed submission:
N, T = map(int, input().split())
cost = 1001
for i in range(N):
	c, t = map(int, input().split())
	if t <= T:
		if c < cost:
			cost = c

if cost == 1001:
	print("TLE")
else:
	print(cost)

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
cost = 1001
for i in range(N):
	c, t = map(int, input().split())
	if t < T:
		if c < cost:
			cost = c

if cost == 1001
	print("TLE")
else
	print(cost)
Problem p03251 (python)

Fixed submission:
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
flg = 'War'
for i in range(X+1, Y+1):
	if max(x) < i and i <= min(y):
		flg = 'No ' + flg
		break
print(flg)

Buggy submission (verdict: Runtime Error):
N, M, X, Y = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
flg = 'War'
for i in range(X, Y+1):
	if max(X) < i and i <= min(Y):
		flg = 'No ' + flg
		break
print(flg)
Problem p03262 (python)

Fixed submission:
N, X = map(int, input().split())
x = list(map(int, input().split()))
for i in range(N):
    x[i] = abs(x[i] - X)
m = x[0]
import fractions
for i in range(1, N):
    m = fractions.gcd(m, x[i])
print(m)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
x = list(map(int, input().split()))
for i in range(N):
    x[i] = abs(x[i] - X)
m = x[0]
import math
for i in range(1, N):
    m = math.gcd(m, x[i])
print(m)
Problem p03292 (python)

Fixed submission:
A = list(map(int, input().split()))
print(max(A)-min(A))

Buggy submission (verdict: Runtime Error):
A = map(int, input().split())
print(max(A)-min(A))
Problem p03324 (python)

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

Buggy submission (verdict: Runtime Error):
a,b=input().split();print(100**a*b)
Problem p02584 (python)

Fixed submission:
X, K, D = map(int, input().split())
if X + K * D <= 0:
    print(-X - K * D)
elif X - K * D >= 0:
    print(X - K * D)
else:
    div = X // D
    mod = X % D
    if (K-div) % 2 == 0:
        print(mod)
    else:
        print(abs(mod-D))

Buggy submission (verdict: Runtime Error):
X, K, D = map(int, input().split())
if X + K * D <= 0:
  print(-X - K * D)
  elif X - K * D >= 0:
    print(X - K * D)
    else:
      mod = abs(X) // D
      if (K-mod) % 2 == 0:
        print(abs(abs(X) - K * mod))
      else:
        print(abs(abs(X) - K * (mod + 1)))
Problem p02612 (python)

Fixed submission:
N=int(input())
if N%1000==0:
  print(0)
else:
  print(1000-(N%1000))

Buggy submission (verdict: Runtime Error):
N=int(input())
if N%1000=0:
  print(0)
else:
  print(1000-(N%1000))
Problem p02947 (python)

Fixed submission:
N = int(input())
string = [0] * N
ans = 0
for i in range(N):

    mozi = input()
    for k in range(10):
        string[i] += (ord(mozi[k])-96)**10

string_new = sorted(string)
ite = 0
index = 0
while ite < N-1:
    index = ite + 1
    while string_new[ite] == string_new[index]:
        #print(ite, index)
        ans += index-ite
        index += 1

        if index >= N:
            break
    ite = index
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
string = np.zeros(N)
ans = 0
for i in range(N):
    mozi = input()
    for k in range(10):
        string[i] += (ord(mozi[k])-96)**10

string_new = sorted(string)
for j in range(N-1):
    index = j + 1
    while string_new[j] == string_new[index]:
        ans += 1
        index += 1
        if index >= N:
            break

print(ans)
Problem p02995 (python)

Fixed submission:
# 未完成
import fractions
import numpy as np
A, B, C, D = map(int, input().split())  # aaaaa
lcmofCD = int(C * D / fractions.gcd(C, D))
divofAbyC = (A-1) // C
divofAbyD = (A-1) // D
divofBbyC = B // C
divofBbyD = B // D  # aaaaa
divofBbylcm = B // lcmofCD
divofAbylcm = (A-1) // lcmofCD
ansofA = (A-1) - (divofAbyC + divofAbyD - divofAbylcm)
ansofB = B-(divofBbyC + divofBbyD - divofBbylcm)
ans = ansofB-ansofA

print("{}".format(ans))

Buggy submission (verdict: Runtime Error):
#未完成
import math
import numpy as np
A, B, C, D = map(int, input().split())  # aaaaa
lcmofCD = int(C * D / math.gcd(C, D))
divofAbyC = A // C
divofAbyD = A // D
divofBbyC = B // C
divofBbyD = B // D#aaaaa
divofBbylcm = B // lcmofCD
divofAbylcm = A // lcmofCD
ansofA = A - (divofAbyC + divofAbyD - divofAbylcm)
ansofB = B-(divofBbyC + divofBbyD - divofBbylcm)
ans = ansofB-ansofA

print("{}".format(ans))

Buggy submission (verdict: Runtime Error):
#未完成
import math
import numpy as np
A, B, C, D = map(int, input().split())
lcmofCD = int(C * D / math.gcd(C, D))
divofAbyC = A // C
divofAbyD = A // D
divofBbyC = B // C
divofBbyD = B // D#aaaaa
divofBbylcm = B // lcmofCD
divofAbylcm = A // lcmofCD
ansofA = A - (divofAbyC + divofAbyD - divofAbylcm)
ansofB = B-(divofBbyC + divofBbyD - divofBbylcm)
ans = ansofB-ansofA

print("{}".format(ans))

Buggy submission (verdict: Runtime Error):
#未完成
import math
import numpy as np
A, B, C, D = map(int, input().split())
lcmofCD = int(C * D / math.gcd(C, D))
divofAbyC = A // C
divofAbyD = A // D
divofBbyC = B // C
divofBbyD = B // D
divofBbylcm = B // lcmofCD
divofAbylcm = A // lcmofCD
ansofA = A - (divofAbyC + divofAbyD - divofAbylcm)
ansofB = B-(divofBbyC + divofBbyD - divofBbylcm)
ans = ansofB-ansofA

print("{}".format(ans))

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
A, B, C, D = map(int, input().split())
lcmofCD = int(C * D / math.gcd(C, D))
divofAbyC = A // C
divofAbyD = A // D
divofBbyC = B // C
divofBbyD = B//D
divofBbylcm = B // lcmofCD
divofAbylcm = A // lcmofCD
ansofA = A - (divofAbyC + divofAbyD - divofAbylcm)
ansofB = B-(divofBbyC+divofBbyD-divofBbylcm)
ans = ansofB-ansofA

print("{}".format(ans+1))
Problem p03069 (python)

Fixed submission:
# 今のままだと駄目
"""
ある境目を考える。境目より左が全て白、境目より右が全て黒でなくてはいけない。
ゆえに、境目より左の黒の数と境目より右の白の数を数えれば、その境目における「変更が必要な石の数」がわかる。
よって、境目を端から端まで動かしてその中で最小の「変更が必要な石の数」を求めればよい。
"""
N = int(input())
str = input()
minDistance = 0

black = "#"
white = "."
leftblack = 0
rightwhite = 0

for i in range(N):
    if str[i] == white:
        rightwhite += 1

minDistance += rightwhite

for j in range(0, N):
    if str[j] == black:
        leftblack += 1
    else:
        rightwhite -= 1
    if leftblack + rightwhite < minDistance:
        minDistance = leftblack+rightwhite

print("{}".format(minDistance))

Buggy submission (verdict: Runtime Error):
str = input()
minDistance = N
black = "#"
white = "."

for i in range(N):
    distance = 0
    loopnum = 0
    while (distance < minDistance and loopnum < N):
        for j in range(0, i):
            if str[j] == black:
                distance += 1
                loopnum += 1
            else:
                loopnum += 1
        for k in range(i, N - 1):
            if str[k] == white:
                distance += 1
                loopnum += 1
            else:
                loopnum += 1
    print("{}".format(distance))
    if (loopnum >= N-1):
        minDistance = distance

print("{}".format(minDistance))
Problem p03244 (python)

Fixed submission:
n = int(input())
v = [int(x) for x in input().split()]
big = 10**5+1
even = [0] * big
odd = [0] * big
for i in range(big):
    even[i] = [0] * 2
    odd[i] = [0]*2
    even[i][1] = i
    odd[i][1] = i

for j in range(n):
    if j % 2 == 0:
        even[v[j]][0] += 1
    else:
        odd[v[j]][0] += 1

even = sorted(even, reverse=True)
odd = sorted(odd, reverse=True)

ans = 0
if even[0][1] == odd[0][1]:
    ans = min(n - odd[0][0] - even[1][0], n - even[0][0] - odd[1][0])
else:
    ans = n - even[0][0] - odd[0][0]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
v = [int(x) for x in input().split()]
big = 10**5
even = [0] * big
odd = [0] * big
for i in range(big):
    even[i] = [0] * 2
    odd[i] = [0]*2
    even[i][1] = i
    odd[i][1] = i

for j in range(n):
    if j % 2 == 0:
        even[v[j]][0] += 1
    else:
        odd[v[j]][0] += 1

even = sorted(even, reverse=True)
odd = sorted(odd, reverse=True)

ans = 0
if even[0][1] == odd[0][1]:
    ans = min(n - odd[0][0] - even[1][0], n - even[0][0] - odd[1][0])
else:
    ans = n - even[0][0] - odd[0][0]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
v = [int(x) for x in input().split()]
even = [0] * (10 ** 5)
odd = [0] * (10 ** 5)
for i in range(10 ** 5):
    even[i] = [0] * 2
    odd[i] = [0]*2
    even[i][1] = i
    odd[i][1] = i

for j in range(n):
    if j % 2 == 0:
        even[v[j]][0] += 1
    else:
        odd[v[j]][0] += 1

even = sorted(even, reverse=True)
odd = sorted(odd, reverse=True)
ans = 0
if even[0][1] == odd[0][1]:
    if even[0][0] > odd[0][0]:
        ans = n - even[0][0] - odd[1][0]
    else:
        ans = n - odd[0][0] - even[1][0]
else:
    ans = n-even[0][0]-odd[0][0]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
v = [int(x) for x in input().split()]
even = [0] * (10 ** 5)
odd = [0] * (10 ** 5)
for i in range(10 ** 5):
    even[i] = [0] * 2
    odd[i] = [0]*2
    even[i][1] = i
    odd[i][1] = i

for j in range(n):
    if j % 2 == 0:
        even[v[j]][0] += 1
    else:
        odd[v[j]][0] += 1
even = sorted(even, reverse=True)
odd = sorted(odd, reverse=True)
if even[0][1] == odd[0][1]:
    if even[0][0] > odd[0][0]:
        ans = n - even[0][0] - odd[1][0]
    else:
        ans = n - odd[0][0] - even[1][0]
else:
    ans = n-even[0][0]-odd[0][0]
print(ans)
Problem p03633 (python)

Fixed submission:
import fractions


def GCD(a, b):
    if b == 0:
        return a
    else:
        return GCD(b, a % b)


N = int(input())
clock = [0] * N
for j in range(N):
    clock[j] = int(input())
gcd = clock[0]

ans = clock[0]
for i in range(1, N):
    gcd = GCD(ans, clock[i])
    ans = ans//gcd
    ans = ans * clock[i]

print(int(ans))

Buggy submission (verdict: Runtime Error):
import fractions


def GCD(a, b):
    if b == 0:
        return a
    else:
        return GCD(b, a % b)


N = int(input())
clock = [0] * N
for j in range(N):
    clock[j] = int(input())
gcd = clock[0]

ans = clock[0]
for i in range(1, N):
    gcd = GCD(ans, clock[i])
    ans = ans/gcd
    ans = ans * clock[i]

print(int(ans))

Buggy submission (verdict: Runtime Error):
import fractions


def GCD(a, b):
    if b == 0:
        return a
    else:
        return GCD(b, a % b)


N = int(input())
clock = [0]*N
gcd = int(input())
clock[0] += gcd
ans = clock[0]
for i in range(1, N):
    clock[i] = int(input())
    gcd = GCD(gcd, clock[i])
   
    ans = ans/gcd
    ans = ans * clock[i]

print(int(ans))

Buggy submission (verdict: Runtime Error):
import fractions


def GCD(a, b):
    if b == 0:
        return a
    else:
        return GCD(b, a % b)


N = int(input())
clock = [0]*N
gcd = int(input())
clock[0] = gcd
ans = clock[0]
for i in range(1, N):
    clock[i] = int(input())
    gcd = GCD(ans, clock[i])
    ans = ans/gcd
    ans *= clock[i]

print(int(ans))

Buggy submission (verdict: Runtime Error):
import fractions


def GCD(a, b):
    if b == 0:
        return a
    else:
        GCD(b, a % b)


N = int(input())
clock = [0]*N
gcd = int(input())
clock[0] = gcd
ans = clock[0]
for i in range(1, N):
    clock[i] = int(input())
    gcd = GCD(ans, clock[i])
    ans /= gcd
    ans *= clock[i]

print(int(ans))
Problem p02713 (python)

Fixed submission:
def gcd(a,b):
	if b == 0:
		return a
	else:
		return gcd(b,a%b)

n = int(raw_input())
sm = 0;
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      sm += gcd(gcd(i,j),k)
      
print(sm)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
	if b == 0:
     	return a
	else:
     	return gcd(b,a%b)

n = int(raw_input())
sm = 0;
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      sm += gcd(gcd(i,j),k)
      
print(sm)
Problem p02865 (python)

Fixed submission:
a = int(input())
if a < 2:
        print(0)
elif a % 2 == 0:
        print(int(a / 2 - 1) )
else:
        print(int(a/2))

Buggy submission (verdict: Runtime Error):
a = input()
if a < 2:
        print(0)
elif a % 2 == 0:
        print(int(a / 2 - 1) )
else:
        print(int(a/2))

Buggy submission (verdict: Runtime Error):
if a < 2:
        print 0
elif a % 2 == 0:
        print int(a / 2 - 1)
else:
        print int(a/2)

Buggy submission (verdict: Runtime Error):
a = input()
if a < 2:
        print(0)
elif a % 2 == 0:
        print(int(a / 2 - 1) )
else:
        print(int(a/2))

Buggy submission (verdict: Runtime Error):
a = input()
if a < 2:
    print(0)
else:
    if a % 2 == 0:
        print(int(a / 2 - 1) )
    else:
        print(int(a/2))
Problem p02909 (python)

Fixed submission:
I = input()
K = ['Sunny', 'Cloudy', 'Rainy', 'Sunny']
Idx = K.index(I)
print(K[Idx+1])

Buggy submission (verdict: Runtime Error):
I = input()
K = ['Sunny', 'Cloudy,''Rainy', 'Sunny']
Idx = K.index(I)
print(K[Idx+1])

Buggy submission (verdict: Runtime Error):
I = input()
K = ['Sunny', 'Cloudy,''Rainy', 'Sunny']
Idx = K.index(I)
print(K[idx+1])
Problem p02921 (python)

Fixed submission:
F = input()
A = input()
s = 0
s += 1 if F[0] == A[0] else 0
s += 1 if F[1] == A[1] else 0
s += 1 if F[2] == A[2] else 0
print(s)

Buggy submission (verdict: Runtime Error):
F = input().split()
A = input().split()
s = 0
s += F[0] == A[0] ? 1 : 0
s += F[1] == A[1] ? 1 : 0
s += F[1] == A[2] ? 1 : 0
print(s)
Problem p02555 (python)

Fixed submission:
import math

s = int(input())

MOD = 10**9+7

maximum = int(s/3)

ans = 0
for i in range(maximum):
  ans += (math.factorial(i + s-(i*3+3))//(math.factorial(i)*math.factorial(s-(i*3+3))))%MOD

print(int(ans)%(10**9+7))

Buggy submission (verdict: Runtime Error):
import math

s = int(input())

MOD = 10**9+7

maximum = int(s/3)

ans = 0
for i in range(maximum):
  ans += (math.factorial(i + s-(i*3+3))/(math.factorial(i)*math.factorial(s-(i*3+3))))%MOD

print(int(ans)%(10**9+7))

Buggy submission (verdict: Runtime Error):
import math

s = int(input())

MOD = 10**9+7

maximum = int(s/3)

ans = 0
for i in range(maximum):
  ans += (math.factorial(i + s-(i*3+3))/(math.factorial(i)*math.factorial(s-(i*3+3))))%MOD

print(int(ans))
Problem p02614 (python)

Fixed submission:
import itertools
import numpy as np

h,w,k = map(int, input().split())

grid = []
ans = 0
for i in range(h):
  grid.append(list(input()))

for i in range(h):
  for j in range(w):
    if grid[i][j] == "#":
      grid[i][j] = 1
    else:
      grid[i][j] = 0

for v in itertools.product([1,0],repeat=(h+w)):
  grid_dum = np.array(grid.copy())
  for i,x in enumerate(v[:h]):
    if x == 1:
      grid_dum[i,:] = 0 
  for i,x in enumerate(v[h:]):
    if x == 1:
      grid_dum[:,i] = 0 
  if grid_dum.sum() == k:
    ans += 1

print(ans)

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

h,w,k = map(int, input().split())

grid = []
ans = 0
for i in range(h):
  grid.append(list(input()))

for i in range(h):
  for j in range(w):
    if grid[i][j] == "#":
      grid[i][j] = 1
    else:
      grid[i][j] = 0

for v in itertools.product([1,0],repeat=(h+w)):
  grid_dum = np.array(grid.copy())
  for i,x in enumerate(v[:h]):
    if x == 1:
      grid_dum[i,:] = 0 
  for i,x in enumerate(v[h:]):
    if x == 1:
      grid_dum[:,i-h] = 0 
  if grid_dum.sum() == k:
    ans += 1

print(ans)
Problem p02660 (python)

Fixed submission:
#import sympy

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

n = int(input())
ans = 1

#dic = sympy.factorint(n)
arr = factorization(n)

cnt  = 1
ans = 0
flag = False
while True:
  for k in arr:
    if k[1] >= cnt:
      k[1] -= cnt
      ans += 1
      flag = True
  if not flag:
    break
  cnt += 1
  flag = False

if n == 1:
  print(0)
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
import sympy

n = int(input())
ans = 1

dic = sympy.factorint(n)

cnt  = 1
ans = 0
flag = False
while True:
  for k in dic.keys():
    if dic[k] >= cnt:
      dic[k] -= cnt
      ans += 1
      flag = True
  if not flag:
    break
  cnt += 1
  flag = False

print(ans)
Problem p02665 (python)

Fixed submission:
n = int(input())

a_li = list(map(int, input().split()))

ans = 0
li = [0]*(n+1)

for i,a in enumerate(a_li):
  ans += (i+1)*a

for i,a in enumerate(a_li[::-1]):
  if i >= 1:
    li[i] = li[i-1]+a
  else:
    li[i] = a

li = li[::-1]

flag = True
ne = 0.5
for i in range(n+1):
  if li[i]  > 2*ne:
    ans -= li[i] -int(2*ne)

  
  ne = min(li[i] - a_li[i],int(2*ne)-a_li[i])

  if (i == n and ne != 0) or (i != n and ne <= 0):
    flag = False

  
if flag:
  print(ans)
else:
  print(-1)

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

a_li = list(map(int, input().split()))

ans = 0
li = [0]*(n+1)

for i,a in enumerate(a_li):
  ans += (i+1)*a

for i,a in enumerate(a_li[::-1]):
  if i >= 1:
    li[i] = li[i-1]+a
  else:
    li[i] = a

li = li[::-1]

#print(li)
#print(ans)


flag = True
ne = 0.5
for i in range(n):
  if li[i]  > 2*ne:
    ans -= li[i] -2*ne
    #print(li[i] -2*ne)

  ne = 2*ne - a_li[i]
  #print(ne)
  if ne <= 0:
    flag = True

  
if flag:
  print(int(ans))
else:
  print(-1)

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

a_li = list(map(int, input().split()))

ans = 0
li = [0]*(n+1)

for i,a in enumerate(a_li):
  ans += (i+1)*a

for i,a in enumerate(a_li[::-1]):
  if i >= 1:
    li[i] = li[i-1]+a
  else:
    li[i] = a

li = li[::-1]

flag = True
ne = 0.5
for i in range(n+1):
  if li[i]  > 2*ne:
    ans -= li[i] -2*ne

  ne = 2*ne - a_li[i]
  if i == n+1 and ne <= 0:
    flag = False

  
if flag:
  print(int(ans))
else:
  print(-1)
Problem p02684 (python)

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

a = list(map(int, input().split()))

visited = [1]
is_visited = [0] * n
now = 1
step = 0
for i in range(k):
    now = a[now-1]
    step += 1
    if is_visited[now-1] == 0:
        is_visited[now-1] = 1
        visited.append(now)
    else:
        ind = visited.index(now)
        loop = visited[ind:]
        tmp = (k-step) % len(loop)
        now = loop[tmp]
        break

print(now)

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

a = list(map(int, input().split()))

visited = [1]
is_visited = [0] * n
now = 1
step = 0
for i in range(k):
    now = a[now-1]
    step += 1
    if is_visited[now-1] == 0:
        is_visited[now-1] = 1
    else:
        ind = visited.index(now)
        loop = visited[ind:]
        tmp = (k-step) % len(loop)
        now = loop[tmp]
        break

print(now)

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

visited = [1]
is_visited = [0] * n
now = 1
step = 0
for i in range(k):
    now = a[now-1]
    step += 1

    if is_visited[now-1] == 0:
        is_visited[now-1] = 1
    else:
        ind = visited.index(now)
        loop = visited[ind:]
        tmp = (k-step) % len(loop)
        now = loop[tmp]
        break

print(now)
Problem p02705 (python)

Fixed submission:
import math

print(int(input())*2*math.pi)

Buggy submission (verdict: Runtime Error):
import math

return int(input())*2*math.pi