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

Fixed submission:
n = int(input())
print((n+1)//2)

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

n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

d = {}

for i in range(1, n + 1):
    d[i] = None

for itm in sc:
    if (d[itm[0]] == None) | (d[itm[0]] == itm[1]):
        d[itm[0]] = itm[1]
    else:
        print(-1)
        sys.exit()

l = list(d.values())
if l == [0]:
    print(0)
elif l[0] == 0:
    print(-1)
else:
    l = [0 if x == None else x for x in l]
    l[0] = [1 if x == 0 else x for x in l]
    l = map(str, l)
    print("".join(l))
Problem p02577 (python)

Fixed submission:
import sys 
def get_string(): return sys.stdin.readline().strip() 
  
string = get_string()
s=0
while string!='':
    s=s+int(string[-1])
    string=string[:-1]
if s%9==0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n=long(input())
s=0
while n>0:
    s=s+n%10
    n=n//10
if s%9==0:
    print('Yes')
else:
    print('No')
Problem p02580 (python)

Fixed submission:
h,w,m=list(map(int,input().split()))
b=[]
r=[0]*(3*10**5+2)
c=[0]*(3*10**5+2)
for i in range(m):
    h,w=list(map(int,input().split()))
    r[h]=r[h]+1
    c[w]=c[w]+1
    b.append([h,w])
if max(r)>max(c):
    j=r.index(max(r))
    for i in range(len(b)):
        if b[i][0]==j:
            c[b[i][1]]=c[b[i][1]]-1
else:
    i=c.index(max(c))
    for j in range(len(b)):
        if b[j][1]==i:
            r[b[j][0]]=r[b[j][0]]-1
print(max(r)+max(c))

Buggy submission (verdict: Runtime Error):
h,w,m=list(map(int,input().split()))
b=[]
r=[0]*(10**5+1)
c=[0]*(10**5+1)
for i in range(m):
    h,w=list(map(int,input().split()))
    r[h]=r[h]+1
    c[w]=c[w]+1
    b.append([h,w])
if max(r)>max(c):
    j=r.index(max(r))
    for i in range(len(b)):
        if b[i][0]==j:
            c[b[i][1]]=c[b[i][1]]-1
    i=c.index(max(c))
else:
    i=c.index(max(c))
    for j in range(len(b)):
        if b[j][1]==i:
            r[b[j][0]]=r[b[j][0]]-1
    j=r.index(max(r))
print(r[j]+c[i])
Problem p02777 (python)

Fixed submission:
S,T = input().split()
A,B = map(int,input().split())
U = input()

if U == S:
    print(A-1,B)
elif U == T:
    print(A,B-1)
else:
    print(A,B)

Buggy submission (verdict: Runtime Error):
import  copy
N, K = map(int,input().split())
p = [int(i) for i in input().split()]
P = []
P_S = [0]
ans_list = []
temp = 0

for i in range(N):
    P.append((p[i] + 1)/2)
    temp = temp + P[i]
    P_S.append(temp)
for i in range(K,N+1):
    ans_list.append(P_S[i] - P_S[i - K])

print(max(ans_list))
Problem p02951 (python)

Fixed submission:
List = list(map(int,input().split()))
A = List[0]
B = List[1]
C = List[2]

if (C - A + B) >= 0:

	C = C - (A - B)
	print(C)
else:
	print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
H_list = list(map(int,input().split()))
Flag = False
if N == 1:

    print("Yes")
    
else:
    for i in range(N):
        if H_list[N-1-i-1] - H_list[N-1-i] > 1:
            print("No")
            break
        elif H_list[N-1-i-1] - H_list[N-1-i] == 1:
            H_list[N-1-i-1] = H_list[N-1-i-1] -1
        else:
            continue
     
Flag = True

if Flag == True:
    print("Yes")
Problem p02624 (python)

Fixed submission:
n = int(input())

ans = 0
for x in range(1, n+1):
    y = n // x
    ans += y * (y+1) * x // 2
    
print(ans)

Buggy submission (verdict: Runtime Error):
import sympy

n = int(input())

ans = 0
for i in range(1, n+1):
    ans += i * sympy.divisor_count(i)
    
print(ans)
Problem p02766 (python)

Fixed submission:
#156_B ans
n, k = map(int, input().split())
ans = 0
while n > 0:
    n = n // k
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
#156_B
n, k = map(int, input().split())
for i in range(30):
    if k ** i > n:
        ans = i
        break
print(ans)
Problem p02707 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = [0 for _ in range(N)]
for i in A:
    B[i-1] += 1
for j in range(N):
    print(B[j])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int. input().split())
for i in range(1,N+1):
    print(A.count(i))
Problem p02753 (python)

Fixed submission:
S = input()
if 'A' in S and 'B' in S:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
if S=='AAA' or S=='BBB':
  print('No')
else
  print('Yes')

Buggy submission (verdict: Runtime Error):
if S=='AAA' or S='BBB':
  print('No')
else
  print('Yes')
Problem p02777 (python)

Fixed submission:
print(' '.join((lambda x:[str((x[2]-1)) if x[4] == x[0] else str(x[2]),str((x[3]-1)) if x[4] == x[1] else str(x[3])])(input().split()+list(map(int,input().split()))+[input()])))

Buggy submission (verdict: Runtime Error):
print((lambda x:((x[2]-1) if x[4] == x[0] else x[2]),((x[3]-1) if x[4] == x[1] else x[3]) )(input().split()+list(map(int,input().split()))+input()))
Problem p02832 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
nu = 1
bl = 0
if not 1 in A:
    print(-1)
else:
    for i in range(1,N+1):
        if A[i-1] == nu:
            nu += 1
            bl += 1
    print(N-bl)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
nu = 1
bl = 0
if not 1 in A:
    print(-1)
else:
    for i in range(1,N+1):
        if A[i] == nu:
            nu += 1
            bl += 1
    print(N-bl)
Problem p02754 (python)

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

division = N // (A + B)
count = division * A

count += N - division * (A + B) if A > N - division * (A + B) else A
print(count)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())

boals = ''
while len(boals) < N:
    boals += 'b' * A + 'r' * B
print(boals.count('b', 0, N))
Problem p02881 (python)

Fixed submission:
import sys
from math import ceil, sqrt

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')


def main():
    N = INT()

    num = [i + 1 for i in range(ceil(sqrt(N)))]

    minimum = INF
    for i in num:
        if N % i == 0:
            temp = i + N//i
            if temp < minimum:
                minimum = temp

    print(minimum - 2)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')


def main():
    N = INT()

    num = [i + 1 for i in range(ceil(sqrt(N)))]

    minimum = INF
    for i in num:
        if N % i == 0:
            temp = i + N//i
            if temp < minimum:
                minimum = temp

    print(minimum - 2)


if __name__ == '__main__':
    main()
Problem p02954 (python)

Fixed submission:
import sys
 
def INPUT(): return sys.stdin.readline().strip()
 
sys.setrecursionlimit(10 ** 9)
 
 
def main():
    S = INPUT()
    fall_point = []
    split_point = [0]
    N = len(S)
    last_S = [0] * N
 
    for i in range(N):
        if not i == N - 1:
            if S[i:i+2] == 'RL':
                fall_point.append(i)
            elif S[i:i+2] == 'LR':
                split_point.append(i+1)
        else:
            split_point.append(i+1)
 
    for i in range(len(split_point)-1):
        sub_len = split_point[i+1] - split_point[i]
 
        if sub_len % 2 == 0:
            last_S[fall_point[i]] = sub_len // 2
            last_S[fall_point[i] + 1] = sub_len // 2
        else:
            if (split_point[i+1] - fall_point[i]) % 2 == 0:
                last_S[fall_point[i]] = sub_len // 2
                last_S[fall_point[i] + 1] = sub_len // 2 + 1
            else:
                last_S[fall_point[i]] = sub_len // 2 + 1
                last_S[fall_point[i] + 1] = sub_len // 2
 
    print(" ".join(map(str, last_S)))
 
 
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
 
def INPUT(): return sys.stdin.readline().strip()
 
sys.setrecursionlimit(10 ** 9)
 
 
def main():
    S = INPUT()
    fall_point = []
    split_point = [0]
    N = len(S)
    Last_S = [0] * N
 
    for i in range(N):
        if not i == N - 1:
            if S[i:i+2] == 'RL':
                fall_point.append(i)
            elif S[i:i+2] == 'LR':
                split_point.append(i+1)
        else:
            split_point.append(i+1)
 
    for i in range(len(split_point)-1):
        sub_len = split_point[i+1] - split_point[i]
 
        if sub_len % 2 == 0:
            last_S[fall_point[i]] = sub_len // 2
            last_S[fall_point[i] + 1] = sub_len // 2
        else:
            if (split_point[i+1] - fall_point[i]) % 2 == 0:
                last_S[fall_point[i]] = sub_len // 2
                last_S[fall_point[i] + 1] = sub_len // 2 + 1
            else:
                last_S[fall_point[i]] = sub_len // 2 + 1
                last_S[fall_point[i] + 1] = sub_len // 2
 
    print(" ".join(map(str, last_S)))
 
 
if __name__ == '__main__':
    main()
Problem p03053 (python)

Fixed submission:
import sys
import numpy as np
from scipy.ndimage.morphology import distance_transform_cdt
INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())
sys.setrecursionlimit(10 ** 9)


def main():
    H, W = MAP()
    A = [INPUT() for _ in range(H)]
    A = np.array([[(Ai[j] != "#") for j in range(W)] for Ai in A])
    print(distance_transform_cdt(A, metric="taxicab").max())


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from scipy.ndimage.morphology import distance_transform_cdt
INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())
sys.setrecursionlimit(10 ** 9)


def main():
    H, W = MAP()
    A = [INPUT() for _ in range(H)]

    A = np.array([[(Ai[j] != "#") for j in range(W)] for Ai in A])
    print(distance_transform_cdt(A, metric="taxicab").max())


if __name__ == '__main__':
    main()
Problem p03137 (python)

Fixed submission:
import sys
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


def main():
    N, M = MAP()
    X = LIST()

    if M == 1 or N >= M:
        print(0)
        sys.exit()

    X = sorted(X)

    H = []
    heapify(H)
    for i in range(len(X)-1):
        heappush(H, (X[i+1] - X[i])*(-1))

    for i in range(N-1): heappop(H)

    print(sum(H)*(-1))


if __name__ == '__main__':
    main()

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

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


def main():
    N, M = MAP()
    X = LIST()

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

    X = sorted(X)

    H = []
    heapify(H)
    for i in range(len(X)-1):
        heappush(H, (X[i+1] - X[i])*(-1))

    for i in range(N-1): heappop(H)

    print(sum(H)*(-1))


if __name__ == '__main__':
    main()

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

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


def main():
    N, M = MAP()
    X = LIST()
    
    if M == 1:
        print(0)
        sys.exit()
        
    X = sorted(X)

    H = []
    heapify(H)
    for i in range(len(X)-1):
        heappush(H, (X[i+1] - X[i])*(-1))

    for i in range(N-1): heappop(H)
    
    print(sum(H)*(-1))


if __name__ == '__main__':
    main()
Problem p03307 (python)

Fixed submission:
def INT(): return int(input())

def main():
    N = INT()
    
    if N % 2 == 0:
        print(N)
    else:
        print(2*N)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))
 
INF = float('inf')
 
 
def sad(A, b):
    s = 0
 
    for i, a in enumerate(A):
        s += abs(a - (b + i))
 
    return s
 
 
def main():
    N = INT()
    A = LIST()
    MA = max(A)
    m = INF
 
    for i in range(N):
        s = sad(A, MA-i)
        if s < m:
            m = s
 
    print(m)
 
 
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def INT(): return int(input())

def main():
    N = INPUT()
    
    if N % 2 == 0:
        print(N)
    else:
        print(2*N)

if __name__ == '__main__':
    main()
Problem p02659 (python)

Fixed submission:
import sys
input  = input().split()

A = int(input[0])
B = int(input[1].replace('.',''))

print((A*B // 100))

Buggy submission (verdict: Runtime Error):
import sys
input  = list(map(float,input().split()))

A = int(input[0])
B = input[1]

print(int(A*B))/
Problem p02659 (python)

Fixed submission:
from math import floor
from decimal import Decimal
a, b = map(Decimal, input().split())
print(floor(a*b))

Buggy submission (verdict: Runtime Error):
from math import floor
from decimal import Decimal
a, b = map(Decimal, input().split())
print(math.floor(a*b))

Buggy submission (verdict: Runtime Error):
from math import floor
a, b = input().split()
print(math.floor(a*b))

Buggy submission (verdict: Runtime Error):
import math
a, b = input().split()
print(math.floor(a * b))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print(math.floor(A * B))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(math.floor(A * B))
Problem p02693 (python)

Fixed submission:
K = int(input())
A, B =map(int, input().split())
num = 0

for i in range(A, B+1):
    if i%K ==0:
        num +=1

print('OK' if num >0 else 'NG')

Buggy submission (verdict: Runtime Error):
import itertools
N, M, Q = map(int, input().split())
a = [0]*Q
b = [0]*Q
c = [0]*Q
d = [0]*Q
for i in range(Q):
     a[i], b[i], c[i], d[i] = map(int, input().split())
ans = 0
for A in combinations_with_replacement(range(1, M+1), N):
    tmp = 0
    for i in range(Q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            tmp += d[i]
    ans = max(ans, tmp)
print(ans)
Problem p02695 (python)

Fixed submission:
import itertools
N, M, Q = map(int, input().split())
a = [0]*Q
b = [0]*Q
c = [0]*Q
d = [0]*Q
for i in range(Q):
     a[i], b[i], c[i], d[i] = map(int, input().split())
ans = 0
for A in itertools.combinations_with_replacement(range(1, M+1), N):
    tmp = 0
    for i in range(Q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            tmp += d[i]
    ans = max(ans, tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
N, M, Q = map(int, input().split())
a = [0]*Q
b = [0]*Q
c = [0]*Q
d = [0]*Q
for i in range (Q):
     a[i], b[i], c[i], d[i] = map(int, input().split())
ans = 0
for A in combinations_with_replacement(range(1, M+1), N):
    tmp = 0
    for i in range(Q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            tmp += d[i]
    ans = max(ans, tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
N, M, Q = map(int, input().split())
a = [int(input()) for _ in range(Q)]
b = [int(input()) for _ in range(Q)]
c = [int(input()) for _ in range(Q)]
d = [int(input()) for _ in range(Q)]
for i in range (Q):
     a[i], b[i], c[i], d[i] = map(int, input().split())
ans = 0
for A in combinations_with_replacement(range(1, M+1), N):
    tmp = 0
    for i in range(Q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            tmp += d[i]
    ans = max(ans, tmp)
print(ans)
Problem p02629 (python)

Fixed submission:
N=int(input())
lis=[chr(i) for i in range(97, 97+26)]
ans=''
while N>0:
    N-=1
    ans+=lis[N%26]
    N=N//26
print(ans[::-1])

Buggy submission (verdict: Runtime Error):
N=int(input())
lis=[chr(i) for i in range(97, 97+26)]
ans=''
while N>0:
    N-=1
    ans+=lis[N%26]
    N=N//26
print(ans[::-1]

Buggy submission (verdict: Runtime Error):
N=int(input())
lis=[chr(i) for i in range(97, 97+26)]
ans=''
for i in range(100000):
    rem=N%26**(i+1)
    ans=ans+lis[rem-1-26*i]
    if 26**(i+1)>N:
        break
print(ans)
Problem p02659 (python)

Fixed submission:
import decimal

a, b = list(map(decimal.Decimal, input().split()))

print(int(a * b))

Buggy submission (verdict: Runtime Error):
num_strs = input().split()

a = int(num_strs[0])
b = int(num_strs[1] * 100)

print((a * b) // 100)
Problem p02695 (python)

Fixed submission:
from itertools import combinations_with_replacement

n,m,q = map(int,input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q

for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1


arr = [0]*(n+m)
for j in range(m):
    arr[j] = 1

ans = 0

for A in combinations_with_replacement(range(1,m+1),n):
    score = 0
    for l in range(q):
        if A[b[l]] - A[a[l]] == c[l]:
            score += d[l]

    ans = max(ans,score)

print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import permutations

n,m,q = map(int,input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q

for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1


arr = [0]*(n+m)
for j in range(m):
    arr[j] = 1

ans = 0

for vec in permutations(arr):
    zero_cnt = 0
    score = 0
    A = []
    for k in range(n+m):
        if vec[k] == 0:
            zero_cnt += 1
        else:
            A.append(zero_cnt)

    for l in range(q):
        if A[b[l]] - A[a[l]] == c[l]:
            score += d[l]

    ans = max(ans,score)


print(ans)
Problem p02831 (python)

Fixed submission:
from fractions import gcd

a,b = map(int,input().split())
print(a*b//gcd(a,b))

Buggy submission (verdict: Runtime Error):
from math import gcd

a,b = map(int,input().split())
c = a*b//gcd(a,b)
print(c)

Buggy submission (verdict: Runtime Error):
from math import gcd

a,b = map(int,input().split())
print(a*b//gcd(a,b))

Buggy submission (verdict: Runtime Error):
from math import gcd

a,b = map(int,input().split())
print(a*b//gcd(a,b))
Problem p02777 (python)

Fixed submission:
s,t=input().split()
a,b=map(int,input().split())
u=input()

if s==u:
    print(a-1,b)
else:
    print(a,b-1)

Buggy submission (verdict: Runtime Error):
#https://atcoder.jp/contests/abc154/tasks/abc154_c

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

for i in range(n-1):
    if a[i]==a[i+1]:
        print("NO")
        exit()

print("YES")
Problem p02831 (python)

Fixed submission:
import fractions

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

a,b=map(int,input().split())
ans=lcm(a,b)
print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

a,b=map(int,input().split())
ans=lcm(a,b)
print(ans)
Problem p02623 (python)

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

a_sum = [0]
for i in range(len(a)):
    a_sum.append(a_sum[len(a_sum)-1]+a[i])

b_sum = [0]
for i in range(len(b)):
    b_sum.append(b_sum[len(b_sum)-1]+b[i])

ans = 0
b_i = len(b_sum)-1

for i in range(len(a_sum)):
    if a_sum[i] > k:
        break
    else:
        if b_i > -1:
            while b_sum[b_i] + a_sum[i] > k and b_i > -1:
                b_i -= 1
            if b_i > -1 and ans < i+b_i:
                ans = i+b_i
        else:
            if a_i > ans:
                ans = a_i

print(ans)

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

a_sum = 0
a_i = 0
flag = 0
for i in range(len(a)):
    if a_sum+a[i] <= k:
        a_sum += a[i]
    elif a_sum+a[i] > k:
        a_i = i-1
        break
if i == len(a)-1:
    a_i = len(a)-1

b_sum = 0
flag = 0
for i in range(len(b)):
    if b_sum+b[i] <= k:
        b_sum += b[i]
    elif b_sum+b[i] > k:
        b_i = i-1
        break
if i == len(b)-1:
    b_i = len(b)-1

ans = 0
temp = 0
a_temp = 0
b_temp = 0
if k < a[0] and k < b[0]:
    print(0)
else:
    while (k > a_sum or k > b_sum) and (a_sum > 0 or b_sum > 0):
        if (a_sum <= b_sum and a_sum > 0) or b_sum == 0:
            ans += 1
            k -= a[a_temp]
            a_sum -= a[a_temp]
            a_temp += 1
        elif b_sum > 0:
            ans += 1
            k -= b[b_temp]
            b_sum -= b[b_temp]
            b_temp += 1
        while a_sum > k and a_i != a_temp:
            a_sum -=a[a_i]
            if a_sum < 0:
                a_sum = 0
            a_i -= 1
        while b_sum > k and b_i != b_temp:
            b_sum -=b[b_i]
            if b_sum < 0:
                b_sum = 0
            b_i -= 1
    print(ans)
Problem p02881 (python)

Fixed submission:
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n = int(input())
x = make_divisors(n)

if len(x)%2 == 0:
    print(x[len(x)//2]+x[(len(x)//2)-1]-2)
else:
    print((x[(len(x)//2)]*2)-2)

Buggy submission (verdict: Runtime Error):
import sympy

n = int(input())
x = sympy.divisors(n)

if len(x)%2 == 0:
    print(x[len(x)//2]+x[(len(x)//2)-1]-2)
else:
    print((x[(len(x)//2)]*2)-2)
Problem p02891 (python)

Fixed submission:
s = input()
k = int(input())
ans = 0
soui = 0
moji = s[0]

for i in range(1,len(s)):
    if s[i] == s[i-1] and soui == 0:
        ans += 1
        soui = 1
    elif soui == 1:
        soui = 0


flag = 0
a = 0
b = 0

while s[0] == s[a] and a != len(s)-1:
    a += 1

while s[len(s)-1-b] == s[len(s)-1] and b != len(s)-1:
    b += 1


if s[0] == s[len(s)-1]:
    flag = 1

for i in range(len(s)):
    if moji != s[i]:
        break
    elif i == len(s)-1:
        flag = 2

if flag == 1:
    print((k*ans)-((k-1)*((a//2)+(b//2)-((a+b)//2))))
elif flag == 2:
    print((k*len(s))//2)
else:
    print(k*ans)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
ans = 0
soui = 0
moji = s[0]

for i in range(1,len(s)):
    if s[i] == s[i-1] and soui == 0:
        ans += 1
        soui = 1
    elif soui == 1:
        soui = 0

flag = 0

if s[0] == s[len(s)-1] and soui == 0:
    ans += 1
    flag = 1

for i in range(len(s)):
    if moji != s[i]:
        break
    elif i == len(s)-1:
        flag = 2

if flag == 1:
    print((k*ans)-((k-1)*((a//2)+(b//2)-((a+b)//2))))
elif flag == 2:
    print((k*len(s))//2)
else:
    print(k*ans)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
ans = 0
soui = 0
moji = s[1]

for i in range(1,len(s)):
    if s[i] == s[i-1] and soui == 0:
        ans += 1
        soui = 1
    elif soui == 1:
        soui = 0

flag = 0

if s[0] == s[len(s)-1] and soui == 0:
    ans += 1
    flag = 1

for i in range(len(s)):
    if moji != s[i]:
        break
    elif i == len(s)-1:
        flag = 2

if flag == 1:
    print((k*ans)-1)
elif flag == 2:
    print((k*len(s))//2)
else:
    print(k*ans)
Problem p02989 (python)

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

if n%2 == 1:
    print(0)
else:
    print(d[len(d)//2]-d[(len(d)//2)-1])

Buggy submission (verdict: Runtime Error):
14
99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1
Problem p03041 (python)

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

for i in range(len(s)):
    if i==k-1:
        if s[k-1]=='A':
            print('a',end='')
        elif s[k-1]=='B':
            print('b',end='')
        elif s[k-1]=='C':
            print('c',end='')
    else:
        print(s[i],end='')

print()

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

a,b=int(s[0]+s[1]),int(s[2]+s[3])

if b==0:
    print('NA')
elif a==0:
    print('NA')
elif a>12:
    if b>12:
        print('NA')
    elif 0<b<13:
        print('YYMM')
elif 0<a<13:
    if b>12:
        print('MMYY')
    elif 0<b<13:
        print('AMBIGUOUS')