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

Fixed submission:
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
heapq.heapify(a)
bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(key = lambda x: x[1], reverse = True)

for i in range(m):
    if a[0] >= bc[i][1]:
        break
    else:
        cnt = 0
        while cnt < bc[i][0]:
            heapq.heapreplace(a, bc[i][1])
            cnt += 1

print(sum(a))

Buggy submission (verdict: Runtime Error):
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
heapq.heapify(a)
bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(key = lambda x: x[1], reverse = True)

for i in range(m):
    if a[b-1] >= bc[i][1]:
        break
    else:
        cnt = 0
        while cnt < bc[i][0]:
            heapq.heapreplace(a, bc[i][1])
            cnt += 1

print(sum(a))

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

for i in range(m):
    b, c = map(int, input().split())
    j = 0
    cnt = 0
    while a[j] < c and cnt < b:
        a[j] = c
        j += 1
        cnt += 1
    a.sort()

print(sum(a))
Problem p03745 (python)

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

cnt = n
prev = a[0]
trend ='N'

for i in range(1, n):
    if a[i] > prev:
        if (trend == 'U' or trend == 'N'):
            cnt -= 1
            trend ='U'
        else:
            trend = 'N'
    if a[i] < prev:
        if (trend == 'D' or trend == 'N'):
            cnt -= 1
            trend = 'D'
        else:
            trend = 'N'
    if a[i] == prev:
        cnt -= 1
    prev = a[i]
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
d = [x1 - x0 for x1, x0 in zip(a[1:], a) if x1 - x0 != 0]

def sign(x):
    if x > 0:
        return 1
    elif x < 0:
        return -1
    else:
        return 0

cnt = 0
prev = d[0]
kept = 1
for i in range(1, len(d)):
    if sign(d[i]) == prev:
        kept = 1
    else:
        if kept == 1:
            cnt += 1
            kept = 0
        else:
            kept = 1
    prev = d[i]
else:
    cnt += 1
print(cnt)
Problem p02629 (python)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
name = []
hantei = [1,27,703,18279,475255,12356631,321272407,8353082583,217180147159,5646683826135,146813779479511,3817158266467287]

for i in range(len(hantei)-1):
    if hantei[i] <= n < hantei[i+1]:
        n -= hantei[i]
        while n > 0:
            name.insert(0,n%26)
            n //= 26
        while i+1 > len(name):
            name.insert(0,0)

name = [chr(ord('a')+i) for i in name]

print("".join(name))

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

n = int(input())-1
name = []

while n > 0:
    name.insert(0,n%26)
    n //= 26

name[len(name)-1] += 1

name = [chr(i+ord('a')-1) for i in name]

print("".join(name))
Problem p02773 (python)

Fixed submission:
import collections
 
n = int(input())
s = [input() for i in range(n)]
 
counter = collections.Counter(s)
most = counter.most_common()
ans = []
for i in range(len(counter.keys())):
    if most[i][1] == most[0][1]:
        ans.append(most[i][0])
    else:
        break
ans.sort()
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
s = [input() for i in range(n)]

counter = collections.Counter(s)
most = counter.most_common()
ans = []
for i in range(n):
    if most[i][1] == most[0][1]:
        ans.append(most[i][0])
    else:
        break
ans.sort()
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
s = [input() for i in range(n)]

counter = collections.Counter(s)
ans = []
for i in range(n):
    if counter.most_common()[i][1] == counter.most_common()[0][1]:
        ans.append(counter.most_common()[i][0])
    else:
        break
ans.sort()
for i in ans:
    print(i)
Problem p02725 (python)

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

Buggy submission (verdict: Runtime Error):
k, n = map(int, input().split())
a = list(map(int, input().split()))
distances = [0] * n
for i in range(n - 1):
  distances[i] = a[i] - a[i + 1]
distances[n] = k - a[n] + a[0]
print(k - max(distances))
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):
n, a, b = map(int, input().split())
q = n // (a + b)
mod = n % (a + b)
if mod <= a:
  print(a * q + mod)
else:
  print(a * q)
Problem p02754 (python)

Fixed submission:
n, a, b = map(int, input().split())
ans = n // (a+b) * a
mod = n % (a+b)
print(ans + min(a, mod))

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
ans = ""
while True:
  ans += "b" * a
  ans += "r" * b
  if len(ans) >= n:
    break
print(ans[:n].count("b"))
Problem p02759 (python)

Fixed submission:
N = int(input())
if N % 2 == 0:
  print( N // 2)
else:
  print( N // 2 + 1)

Buggy submission (verdict: Runtime Error):
a = []
[a.append(list(map(int, input().split()))) for _ in range(3)]
n = int(input())
b = [int(input())for _ in range(n)]
for i in b:
  for j in range(3):
    for k in range(3):
      if a[j][k] == i:
        a[j][k] = 1
ans = 0
count =0
for j in range(3):
  if a[j].count(1) == 3:
    ans += 1
  elif (a[0][j] == a[1][j] == a[2][j]) == 1:
    ans += 1
  elif (a[0][0] == a[1][1] == a[2][2]) == 1:
    ans += 1
  elif (a[0][2] == a[1][1] == a[2][0]) == 1:
    ans += 1
if ans > 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
def cross_gugge(A):
  if A[0][0] == 1 and A[1][1] == 1 and A[2][2] == 1:
    ans += 1
  elif A[0][2] == 1 and A[1][1] == 1 and A[2][0] == 1:
    ans += 1
    
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]
ans = 0
for i in range(3):
  for j in range(3):
    for k in B:
      if A[i][j] == k:
        A[i][j] = 1
for i in range(3):
  if A[i].count(1) == 3:
    ans += 1
  elif A[0][i] == 1 and A[1][i] == 1 and A[2][i] == 1:
    ans += 1
cross_gugge(A)
if ans > 0:
  print("Yes")
else:
  print("No")
Problem p02771 (python)

Fixed submission:
a, b ,c = map(int,input().split())
if  a == b and b == c and a == c:
  print("No")
elif a == b or b == c or a == c:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
ans = []

charctor_count = Counter(s)
max_count = max(charctor_count.values())
for k, v in charctor_count.items():
  if v == max_count:
    ans.append( k)
print("\n".join(sorted(ans)))
Problem p02779 (python)

Fixed submission:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
ans = max(Counter(a).values())
if ans < 2:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = [0] * (max(a)+1)
for i in range(n):
  ans[a[i]] += 1
ans.sort(reverse = True)
if ans[0] < 2:
  print("YES")
else:
  print("NO")
Problem p02819 (python)

Fixed submission:

import math
def prime(n):
    for i in range(2, int(math.sqrt(n))):
        if n % i == 0: return False
    return True
 
X = int(input())
 
for i in range(X, 10**8):
    if prime(i):
        print(i)
        exit(0)
 
print('No prime number in this range')

Buggy submission (verdict: Runtime Error):
スコード 

Copy
Copy
import math
def prime(n):
    for i in range(2, int(math.sqrt(n))):
        if n % i == 0: return False
    return True
 
X = int(input())
 
for i in range(X, 10**8):
    if prime(i):
        print(i)
        exit(0)
 
print('No prime number in this range')

Buggy submission (verdict: Runtime Error):

def get_primenumber(N):
    #素数リスト
    prime_list = [2]
    #3からNまでの数字を一つずつ取り出す
    for num in range(3,N+1,2):
      #取り出した数字が素数リストの要素で割れなければ素数リストに追加する
      if all( num % prime != 0 for prime in prime_list):
        prime_list.append(num)

    return prime_list

def main():
    prime = []
    ans = []
    number = int(input())
    prime = get_primenumber(50000)
    for i in range(number):
        if number <= prime[i]:
            ans.append(prime[i])
    print(min(ans))

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):

def get_primenumber(N):
    #素数リスト
    prime_list = [2]
    #3からNまでの数字を一つずつ取り出す
    for num in range(3,N+1,2):
      #取り出した数字が素数リストの要素で割れなければ素数リストに追加する
      if all( num % prime != 0 for prime in prime_list):
        prime_list.append(num)

    return prime_list

def main():
    prime = []
    ans = []
    number = int(input())
    prime = get_primenumber(50000)
    for i in range(number):
        if number < prime[i]:
            ans.append(prime[i])
            
    print(min(ans))

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):

def get_primenumber(N):
    #素数リスト
    prime_list = [2]
    #3からNまでの数字を一つずつ取り出す
    for num in range(3,N+1,2):
      #取り出した数字が素数リストの要素で割れなければ素数リストに追加する
      if all( num % prime != 0 for prime in prime_list):
        prime_list.append(num)

    return prime_list

def main():
    prime = []
    ans = []
    number = int(input())
    prime = get_primenumber(50000)
    print(prime)
    for i in range(number):
        if number < prime[i]:
            ans.append(prime[i])
            
    print(min(ans))

if __name__ == "__main__":
    main()
Problem p03011 (python)

Fixed submission:
distances = list(map(int, input().split()))
distances.sort()
ans = 0
for i in range(2):
  ans += distances[i]
print(ans)

Buggy submission (verdict: Runtime Error):
distances = list(map(int, input().split()))
distances.sort()
ans = 0
for i in range(2):
  ans += distances
print(ans)
Problem p03041 (python)

Fixed submission:
n , k = map(int, input().split())
s = list(input())
for i in range(n):
  if i == (k - 1):
  	s[i] = s[i].lower()
print("".join(s))

Buggy submission (verdict: Runtime Error):
n , k = map(int, input().split())
s = list(input())
for i in range(n):
  if i == k:
  	s[i] = s[i].lower
print("".join(s))
Problem p02570 (python)

Fixed submission:
def probA():
    D, T, S = map(int, input().split())

    if (D / S) <= T:
        print("Yes")
    else:
        print('No')


def main():
    probA()


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def probB():
    S = input()
    T = input()

    maxequal = 0
    for i in range(len(S) - len(T)):
        count = 0
        for j in range(len(T)):
            if S[i + j] == T[j]:
                count += 1
            if (count > maxequal):
                maxequal = count
    print(len(T) - maxequal if maxequal > 0 else 0)


def main():
    probB()


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

Fixed submission:
d,t,s = map(int,input().split())
if t*s >= d:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
d,t,s = map(int,input())
if t*s <= d:
    print("Yes")
else:
    print("No")
Problem p02689 (python)

Fixed submission:
N,M=map(int,input().split())
h=list(map(int,input().split()))

pair=[]
for _ in range(M):
    inp=list(map(int,input().split()))
    pair.append(inp)

loser=[]
for i in range(M):
    if h[pair[i][0]-1]<h[pair[i][1]-1]:
        loser.append(pair[i][0])
    elif h[pair[i][0]-1]>h[pair[i][1]-1]:
        loser.append(pair[i][1])
    else:
        loser.append(pair[i][0])
        loser.append(pair[i][1])

set_loser=set(loser)
ans=N-int(len(set_loser))
print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
h=list(map(int,input().split()))

pair=[]
for _ in range(M):
    inp=list(map(int,input().split()))
    pair.append(inp)

loser=[]
for i in range(M):
    if h[pair[i][0]]<h[pair[i][1]]:
        loser.append(pair[i][0])
    elif h[pair[i][0]]>h[pair[i][1]]:
        loser.append(pair[i][1])
    else:
        loser.append(pair[i][0])
        loser.append(pair[i][1])

set_loser=set(loser)
ans=N-int(len(set_loser))
print(ans)
Problem p02577 (python)

Fixed submission:
import numpy as np
import sys
# input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
 
num_str = input()

num_sum = 0
for i in range(len(num_str)):
  num_sum+=int(num_str[i])
 
if num_sum%9 == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
 
num_str = input()

num_sum = 0
for i in range(len(num_str)):
  num_sum+=int(num_str[i])
 
if num_sum%9 == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
 
num_str = input()

lst = []

tmp_sum = 0
tmp = 0
count = 1
out_sum = 0
while True:
  if tmp_sum + 10**10 * count < len(num_str):
      out_sum += sum([int(num_str[i]) for i in range(tmp, 10**10 * count)])
  else:
      out_sum += sum([int(num_str[i]) for i in range(tmp, len(num_str))])
      break
  tmp = 10**10 * count
  count += 1
  tmp_sum += tmp
 
if out_sum%9 == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)

num_str = input()

num_list = [int(num_str[i]) for i in range(len(num_str))]

num_sum = sum(num_list)

if num_sum%9 == 0:
  print("Yes")
else:
  print("No")

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

num_str = input()

num_list = [int(num_str[i]) for i in range(len(num_str))]

num_sum = sum(num_list)

if num_sum%9 == 0:
  print("Yes")
else:
  print("No")

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

num_str = input()

num_list = np.array([int(num_str[i]) for i in range(len(num_str))])

num_sum = np.sum(num_list)

if num_sum%9 == 0:
  print("Yes")
else:
  print("No")
Problem p02552 (python)

Fixed submission:
N = int(input())
if N == 1:
    print(int(0))
else:
    print(int(1))

Buggy submission (verdict: Runtime Error):
C:\Users\satosyuuta\Anaconda3\python.exe C:/Users/satosyuuta/PycharmProjects/untitled/xtb/AtCorder/test.py
0
1

Process finished with exit code 0
Problem p02596 (python)

Fixed submission:
K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()

i = 0
ai = 0
while True:
    ai = (ai * 10 + 7) % K
    i += 1
    if ai == 0:
        break
print(i)

Buggy submission (verdict: Runtime Error):
K = int(input())
a = [0] * 1000000000
a[1] = 7 % K
for i in range(2,K):
    a[i] = (a[i-1]*10 + 7) % K
for i in range(1,K):
    if a[i] == 0:
        print(i)
        exit()
print("-1")
Problem p02623 (python)

Fixed submission:
N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Asum = [0]
Bsum = [0]
a = 0
b = 0
for i in range(N):
    a += A[i]
    Asum.append(a)
for i in range(M):
    b += B[i]
    Bsum.append(b)
Asum.append(0)
Bsum.append(0)
res, j = 0, M
for i in range(N+1):
    if Asum[i] > K:
        break
    while Asum[i] + Bsum[j] > K:
            j -= 1
    res = max(res,i+j)
print(res)

Buggy submission (verdict: Runtime Error):
N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Asum = [0]
Bsum = [0]
a = 0
b = 0
for i in range(N):
    a += A[i]
    Asum.append(a)
for i in range(M):
    b += B[i]
    Bsum.append(b)
Asum.append(0)
Bsum.append(0)
res, j = 0, 0
for i in range(N+1):
    if Asum[i] > K:
        break
    while Asum[i] + Bsum[j] <= K:
            j += 1
    res = max(res,i+j-1)
print(res)

Buggy submission (verdict: Runtime Error):
N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Asum = []
Bsum = []
a = 0
b = 0
for i in range(N):
    a += A[i]
    if a > K:
        break
    Asum.append(a)
for i in range(M):
    b += B[i]
    if b > K:
        break
    Bsum.append(b)
Asum.append(0)
Bsum.append(0)
res = 0
for i in range(-1,N):
    if Asum[i] > K:
        break
    for j in range(-1,M):
        if Asum[i] + Bsum[j] > K:
           break
        else:
           res = max(res,(i+j+2))
print(res)
Problem p02689 (python)

Fixed submission:
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [0] * m
for i in range(m):
    ab[i] = list(map(int, input().split()))
check = [1] * n

for i in range(m):
    #低かったほうのチェックリストを0にしていく
    if h[ab[i][0]-1] == h[ab[i][1]-1]:
        check[ab[i][0]-1] = 0
        check[ab[i][1] - 1] = 0
    elif h[ab[i][0] - 1] < h[ab[i][1]-1]:
        check[ab[i][0] - 1] = 0
    else:
        check[ab[i][1]-1] = 0
print(sum(check))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [0] * m
for i in range(m):
    ab[i] = list(map(int, input().split()))
check = [1] * n

for i in range(m):
    #低かったほうのチェックリストを0にしていく
    if h[ab[i][0]-1] = h[ab[i][1]-1]:
        check[ab[i][0]-1] = 0
        check[ab[i][1] - 1] = 0
    elif h[ab[i][0] - 1] < h[ab[i][1]-1]:
        check[ab[i][0] - 1] = 0
    else:
        check[ab[i][1]-1] = 0
print(sum(check))
Problem p03108 (python)

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

AB = [map(int, input().split()) for _ in range(M)]

AB.reverse()

UF = [i for i in range(10**5)]
cnt = [1 for i in range(10**5)]


def uf(a):
    if UF[a] == a:
        return a
    t = uf(UF[a])
    UF[a] = t
    return UF[a]

def unite(a, b):
    if uf(a) == uf(b):
        return
    if cnt[uf(a)] > cnt[uf(b)]:
        cnt[uf(a)] += cnt[uf(b)]
        UF[uf(b)] = UF[uf(a)]
    else:
        cnt[uf(b)] += cnt[uf(a)]
        UF[uf(a)] = UF[uf(b)]
    return

cost = N * (N - 1) // 2

ans = []

for a, b in AB:
    a -= 1
    b -= 1
    ans.append(cost)
    if uf(a) != uf(b):
        cnt_a = cnt[uf(a)]
        cnt_b = cnt[uf(b)]
        cost -= cnt_a * cnt_b
        unite(a, b)

ans.reverse()

for a in ans:
    print(a)

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

AB = [map(int, input().split()) for _ in range(M)]

AB.reverse()

UF = [i for i in range(10**5)]
cnt = [1 for i in range(10**5)]


def uf(a):
    if UF[a] == a:
        return a
    t = uf(UF[a])
    UF[a] = t
    return UF[a]

def unite(a, b):
    if uf(a) == uf(b):
        return
    if cnt[uf(a)] > cnt[uf(b)]:
        cnt[uf(a)] += cnt[uf(b)]
        UF[uf(b)] = UF[uf(a)]
    else:
        cnt[uf(b)] += cnt[uf(a)]
        UF[uf(a)] = UF[uf(b)]
    return

cost = N * (N - 1) // 2

ans = []

for a, b in AB:
    ans.append(cost)
    if uf(a) != uf(b):
        cnt_a = cnt[uf(a)]
        cnt_b = cnt[uf(b)]
        cost -= cnt_a * cnt_b
        unite(a, b)

ans.reverse()

for a in ans:
    print(a)
Problem p02623 (python)

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

a_=[0]
b_=[0]
tmp = 0
for i in a:
    tmp += i
    a_.append(tmp)
tmp = 0
for i in b:
    tmp += i
    b_.append(tmp)

ans=0
j = m
for i in range(n+1):
    if a_[i] > k:
        continue
    while b_[j] + a_[i] > k:
        j -= 1
    ans = max(ans,i+j)
print(ans)

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

a_=[]
b_=[]
tmp = 0
for i in a:
    tmp += i
    a_.append(tmp)
tmp = 0
for i in b:
    tmp += i
    b_.append(tmp)

if a_[0]>k and b_[0]>k:
    print(0)
    sys.exit()

if a_[0]>k:
    asn=0
    for i in b_:
        asn+=1
        if i > k:
            print(asn)
            sys.exit()

if b_[0]>k:
    asn=0
    for i in a_:
        asn+=1
        if i > k:
            print(asn)
            sys.exit()

ans=0
j = m-1
for i in range(n):
    if a_[i] > k:
        continue
    while b_[j] + a_[i] > k:
        j -= 1
    ans = max(ans,i+j+2)
print(ans)

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

a_=[]
b_=[]
tmp = 0
for i in a:
    tmp += i
    a_.append(tmp)
tmp = 0
for i in b:
    tmp += i
    b_.append(tmp)

if a_[0]>k and b_[0]>k:
    print(0)
    exit()

if a_[0]>k:
    asn=0
    for i in b_:
        asn+=1
        if i > k:
            print(asn)
            exit()

if b_[0]>k:
    asn=0
    for i in a_:
        asn+=1
        if i > k:
            print(asn)
            exit()


ans=0
j = m-1
for i in range(n):
    if a_[i] > k:
        continue
    while b_[j] + a_[i] > k:
        j -= 1
    ans = max(ans,i+j+2)
print(ans)
Problem p02753 (python)

Fixed submission:
a = input()
if a.count('A') == 2 or a.count('B') ==2:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = input()
q = int(input())
lead = ''
end = ''
inversion_flg = -1

for j in range(q):
    query = input().split()
    if query[0] == "1":
        inversion_flg *= -1
    else:
        if inversion_flg == 1:
            if query[1] == "1":
                query[1] = "2"
            else:
                query[1] = "1"
        if query[1] == "1":
            lead += query[2]
        else:
            end += query[2]

lead = lead[::-1]
s = lead + s + end
if inversion_flg == 1:
    s = s[::-1]
print(s)
Problem p02881 (python)

Fixed submission:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

min_value = 1000000000000
data = int(input())
ng_flag = False
divisors_array = make_divisors(data)

if len(divisors_array) % 2 == 1:
    divisors_array.append(divisors_array[len(divisors_array)-1])
for i in range(0, len(divisors_array)):
    if(i % 2 == 0):
        first = divisors_array[i] -1 
        second = divisors_array[i+1] -1 
        if first + second < min_value:
            if i == 1:
                min_value = first + second
            else:
                min_value = first + second
print(min_value)

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

min_value = 1000000000000
data = int(input())
ng_flag = False
divisors_array = make_divisors(data)
for i in range(0, len(divisors_array)):
    if(i % 2 == 0):
        if divisors_array[i] + divisors_array[i+1] < min_value:
            if i == 1:
                min_value = divisors_array[i] + divisors_array[i+1] - 1
            else:
                min_value = divisors_array[i] + divisors_array[i+1] - 2
print(min_value)
Problem p02779 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
sorta = sorted(a)
sflag = False
for i in range(n - 1):
  if sorta[i] == sorta[i + 1]:
    sflag = True
    break
if sflag == True:
  print('NO')
else:
  print('YES')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
bucket = [0] * max(a)
for i in a:
  bucket[i - 1] += 1
if max(bucket) >= 2:
  print('NO')
else:
  print('YES')
Problem p03775 (python)

Fixed submission:
n = int(input())
f = []
for i in range(1, int(n ** 0.5) + 1):
  if ((n % i) == 0):
    a = int(i)
    b = int(n / i)
    alen = len(str(a))
    blen = len(str(b))
    maxlen = max(alen, blen)
    f.append(maxlen)
print(min(f))

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
f = []
for i in range(1, int(math.sqrt(n + 1))):
  if ((n % i) == 0):
    a = int(i)
    b = int(n / i)
    alen = len(str(a))
    blen = len(str(b))
    maxlen = max(alen, blen)
    f.append(maxlen)
print(min(f))

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
f = []
for i in range(1, int(np.sqrt(n + 1))):
  if ((n % i) == 0):
    a = int(i)
    b = int(n / i)
    alen = len(str(a))
    blen = len(str(b))
    f.append(max(alen, blen))
print(min(f))