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

Fixed submission:
n = int(input())
num_list = [int(i) for i in input().split()]
if len(num_list)==1:
  print(1)
else:
  res = 1
  flag = None
  pre = num_list[0]
  for i in num_list[1:]:
    if pre > i and not flag:
      flag = 'down'
  
    elif pre < i and not flag:
      flag = 'up'
      
    elif (pre > i and flag=='up') or (pre < i and flag=='down'):
      res += 1
      flag = None
    pre = i
  print(res)

Buggy submission (verdict: Runtime Error):
n = int(input().split())
num_list = [int(i) for i in input().split()]
if len(num_list)==1:
  print(1)
else:
  res = 1
  flag = None
  pre = num_list[0]
  for i in num_list[1:]:
    if pre > i and not flag:
      flag = 'down'
  
    elif pre < i and not flag:
      flag = 'up'
      
    elif (pre > i and flag=='up') or (pre < i and flag=='down'):
      res += 1
      flag = None
    pre = i
  print(res)
Problem p02793 (python)

Fixed submission:
import fractions


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


N = int(input())
A = list(map(int, input().split()))
l = A[0]
mod = 10**9+7
ans = 0
for i in range(1, N):
    l = lcm(l, A[i])
for i in range(N):
    ans += l // A[i]
print(ans % mod)

Buggy submission (verdict: Runtime Error):
import math


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


N = int(input())
A = list(map(int, input().split()))
l = A[0]
mod = 10**9+7
ans = 0
for i in range(1, N):
    l = lcm(l, A[i])
for i in range(N):
    ans += l // A[i]
print(ans % mod)
Problem p02881 (python)

Fixed submission:
N = int(input())
lis = []
for a in range(1,int(N**0.5)+1):
    b = N // a
    if a * b == N:
       lis.append(a + b - 2)
print(min(lis))

Buggy submission (verdict: Runtime Error):
N = int(input())
lis = []
for a in range(1,int(N**0.5)):
    b = N // a
    if a * b == N:
       lis.append(a + b - 2)
print(min(lis))
Problem p02912 (python)

Fixed submission:
import heapq
N, M = map(int, input().split())
heap = [-i for i in list(map(int, input().split()))]
heapq.heapify(heap)
for i in range(M):
    heapq.heappush(heap, -(-heapq.heappop(heap)//2))
print(-sum(heap))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
top, bottom = 0, M-1

if len(A) == 1:
    for _ in range(M):
        A[0] //= 2
else:
    for _ in range(M):
        A[top] //= 2
        if A[top] >= A[bottom]:
            if bottom > top >= 0:
                bottom -= 1
            continue
        else:
            top += 1
print(sum(A))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
top, bottom = 0, M-1

if len(A) == 1:
    for _ in range(M):
        A[0] //= 2
else:
    for _ in range(M):
        A[top] //= 2
        if A[top] >= A[bottom]:
            if bottom >= top >= 0:
                bottom -= 1
            continue
        else:
            top += 1
print(sum(A))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
top, bottom = 0, M-1

if len(A) == 1:
    for _ in range(M):
        A[0] //= 2
else:
    for _ in range(M):
        A[top] //= 2
        if A[top] >= A[bottom]:
            bottom -= 1
            continue
        else:
            top += 1
print(sum(A))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
top, bottom = 0, M-1

if len(A) == 1:
    for _ in range(M):
        A[0] //= 2
else:
    for _ in range(M):
        A[top] //= 2
        print(top, bottom)
        if A[top] >= A[bottom]:
            bottom -= 1
            continue
        else:
            top += 1
print(sum(A))
Problem p03041 (python)

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

S = str(input())

S = S[:K-1] + (S[K-1]).lower() + S[K:]

print(S)

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

S = str(input())

S = S[:K] + (S[K]).lower() + S[K+1:]

print(S)

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

S = str(input())

S = S[:K-1] + S[K].swapcase() + S[K+1:]

print(S)
Problem p03075 (python)

Fixed submission:
n = 6;
a = [input() for i in range(n)];
 
k = a[-1];
ans = "Yay!";
 
for i in range(n-1):
  for j in reversed(range(n-1)):
    if k < a[i] - a[j]:
      ans = ":( ";
      break;
print ans;

Buggy submission (verdict: Runtime Error):
n = 6;
a = [input() for i in range(n)];

k = a[-1];
ans = "Yay!";

for i in range(n-1):
	for j in reversed(range(n-1)):
  		if k < a[i] - a[j]:
  			ans = ":( ";
  			break;

print ans;

Buggy submission (verdict: Runtime Error):
n = 6;
a = [input() for i in range(n)];

k = a[-1];
ans = "Yay!";

for i in range(n-1):
  for j in reversed(range(n-1)):
    if k < a[i] - a[j]:
      ans = ":( ";
      break;
print ans;

Buggy submission (verdict: Runtime Error):
n = 6;
a = [input() for i in range(n)];

k = a[-1];
ans = "Yay!";

for i in range(n-1):
  for j in reversed(range(n-1)):
  	if k < a[i] - a[j]:
      ans = ":( ";
      break;

print ans;

Buggy submission (verdict: Runtime Error):
n = 6;
a = [input() for i in range(n)];

k = a[-1];
ans = "Yay!";

for i in range(n-1):
  for j in reversed(range(n-1)):
  	if k < a[i] - a[j]:
      ans = ":( ";
      break;

print ans;

Buggy submission (verdict: Runtime Error):
n = 6;
a = [input() for i in range(n)];

k = a[-1];
ans = "Yay!";

for i in range(n-1):
	for j in reversed(range(n-1)):
  		if k < a[i] - a[j]:
  			ans = ":( ";
  			break;

print ans;

Buggy submission (verdict: Runtime Error):
n = 6;
a = [input() for i in range(n)]

k = a[-1];
ans = "Yay!";

for i in range(n-1):
	for j in reversed(range(n-1)):
  		if k < a[i] - a[j]:
  			ans = ":( ";
  			break;

print ans;

Buggy submission (verdict: Runtime Error):
n = 6;
a = [input() for i in range(n)]

k = a[-1];
ans = "Yay!";

for i in range(n-1):
  #print("n-i-1: " + str(n-i-1));
  if k < a[n-i-1] - a[i]:
    ans = ":( ";
    break;

return ans;

Buggy submission (verdict: Runtime Error):
n = 6;
a = [input() for i in range(n)]

k = a[-1];
ans = "Yay!";

for i in range(n-1):
  #print("n-i-1: " + str(n-i-1));
  if k < a[n-i-1] - a[i]:
    ans = ":( ";
    break;

print ans;

Buggy submission (verdict: Runtime Error):
n =6;
a=[input() for i in range(n)]

k = a[-1];
ans = "Yay!";

for i in range(n-1):
	#print("n-i-1: " + str(n-i-1));
  	if k < a[n-i-1] - a[i]:
  		ans = ":( ";
  		break;

print ans;

Buggy submission (verdict: Runtime Error):
N = input()
a = [input() for i in range(N)]
k = a[-1];

for i in range(len(N-1)):
  if k < a[len(N-i-1)] - a[i]:
    return ':( ';

return 'Yay!';

Buggy submission (verdict: Runtime Error):
N = input()
a = [input() for i in range(N)]
print(a);
Problem p03137 (python)

Fixed submission:
N, M = map(int,input().split())
X = sorted(list(map(int, input().split())))
if  M <= N:
    print(0)
else:
    L = []
    for i in range(M-1):
        L.append(X[i+1]-X[i])
    L = sorted(L)
    print(sum(L[:M-N]))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
X = sorted(list(map(int, input().split())))
if  M <= N:
    print(0)
else:
    L = []
    for i in range(M-1):
        L.append(X[i+1]-X[i])
L = sorted(L)
print(sum(L[:M-N]))
Problem p02594 (python)

Fixed submission:
n = int(input())
if n >= 30:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(inpput())
if n >= 30:
    print("Yes")
else:
    print("No")
Problem p02659 (python)

Fixed submission:
a,b = map(str, input().split())
c = b.replace('.', '')
x = int(a)
y = int(c)
d = x * y
ans = d // 100
print(ans)

Buggy submission (verdict: Runtime Error):
a, b = map(int,input().split())
c = 100 * a * b
ans = c // 100
print(ans)
Problem p02707 (python)

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

ls2 =[0 for x in range(n)]
#0がn個のリストを用意する

for x in ls:
    ls2[x - 1] += 1

for x in range(n):
    print(ls2[x])

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

ls = list(map(int, input().split()))
list.sort()

rg = range(1, n + 1)

for i in rg:
    print(ls.count(i))
    ls.remove(i)
Problem p02723 (python)

Fixed submission:
S = input()
if S[2] == S[3] and S[4] == S[5]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S = input()
if S[2] == S[3] and S[4] == S[5]:
  print('Yes')
else:
  pirnt('No')

Buggy submission (verdict: Runtime Error):
S = input()
if S[2] == 'f' and S[3] == 'f' and S[4] == 'e' and S[5] == 'e':
  print('Yes')
else:
  pirnt('No')
Problem p03242 (python)

Fixed submission:
n_str = input()
res = 0
for i in range(3):
  s = (10 - int(n_str[i])) * 10**(2-i)
  res = res + s


print(res)

Buggy submission (verdict: Runtime Error):
n_str = input()
for i in range(3):
  if n_str[i] == '1':
    n_str[i] = '9'
  else:
    n_str[i] = '1'
    
print(int(n_str))

Buggy submission (verdict: Runtime Error):
n_str = input()
for i in range(3):
  if n_str[i] == '1':
    n_str[i] = '9'
  else:
    n_str[i] = '1'
    
print(n_str)
Problem p03317 (python)

Fixed submission:
N, K = map(int,input().split())
A = list(map(int, input().split()))
if (N-1) % (K-1) == 0:
	print((N-1)//(K-1))
else:
  	print((N-1)//(K-1)+1)

Buggy submission (verdict: Runtime Error):
from math import floor
nk = input()
n, k = nk.split()
n = int(n)
k = int(k)

an = input()
an_list = an.split()
min = min(an_list)

min_ind = an_list.index(min) + 1
after = (n - min_ind) / (k-1)
before = (min_ind - 1) / (k-1)

res = 0

if min_ind < k or (n - min_ind) > (k-1):
    res = floor(n/(k-1)) 

else:
    if after.is_integer():
    res = res + after
    else:
    res = res + floor(after) + 1

    if before.is_integer():
    res = res + before
    else:
    res = res + floor(before) + 1


print(int(res))
Problem p03327 (python)

Fixed submission:
n = int(input())
if n<1000:
    print('ABC')
else:
    print('ABD')

Buggy submission (verdict: Runtime Error):
ｆｇｈｊ
Problem p03329 (python)

Fixed submission:
n = int(input())
res = n
ans = 0
for i in range(n+1):
    t = i
    cc = 0
    while t >= 1:
        cc = cc + t % 6
        t = t // 6

    t = n-i
    while t >= 1:
        cc = cc + t%9
        t = t // 9


    if res > cc:
        res = cc

print(res)

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

while n > 9**5:
    n = n - 9**5
    list.append(g)

while n > 6**6:
    n = n - 6**6
    list.append(g)


while n > 6**5:
    n = n - 6**5
    list.append(g)


for i in [4,3,2,1]:

    for r in [9,6,]:
        while n > r**i:
            n = n - r**i
            list.append(r**i)



length = len(list) + n
print(length)
Problem p02629 (python)

Fixed submission:
alfabeto = "abcdefghijklmnopqrstuvwxyz"

n = int(input())
resposta = ""

for i in range(1, 99):
    if n <= 26 ** i:
        n -= 1

        for j in range(i):
            resposta += chr(ord("a") + n % 26)
            n //= 26

        break

    else:
        n -= 26 ** i

resposta = resposta[::-1]

print(resposta)

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

while n > 26:
    resposta += alfabeto[(n%26) - 1]
    n = (n // 26) 


resposta += alfabeto[(n % 26) - 1]
resposta = resposta[::-1]

print(resposta)
Problem p02623 (python)

Fixed submission:
from bisect import bisect
from collections import deque

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

for i in range(1, len(A)):
    A[i] += A[i-1]
for i in range(1, len(B)):
    B[i] += B[i-1]
A.insert(0, 0)
indexB = len(B) - 1
results = [0]
for i in range(len(A)):
    time = A[i]
    if time > K:
        break
    enable_for_b = K - time
    results.append(i + bisect(B, enable_for_b))

print(max(results))

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

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

for i in range(1, len(A)+1):
    A[i] += A[i-1]
for i in range(1, len(B)+1):
    B[i] += B[i-1]

indexB = len(B) - 1
results = [0]
for i in range(len(A)):
    time = A[i]
    if time > K:
        break
    enable_for_b = K - time
    results.append(i + bisect(B, enable_for_b))

print(max(results))

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

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

for i in range(1, len(A)):
    A[i] += A[i-1]
for i in range(1, len(B)):
    B[i] += B[i-1]

indexB = len(B) - 1
results = []
for i in range(len(A)):
    time = A[i]
    if time > K:
        break
    while(indexB >= 0 and time + B[indexB] > K):
        indexB -= 1
    results.append(i+1 + indexB+1)

print(max(results))

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

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

for i in range(1, len(A)):
    A[i] += A[i-1]
for i in range(1, len(B)):
    B[i] += B[i-1]

indexB = len(B)
best = 0
for i in range(len(A)):
    time = A[i]
    if time > K:
        break
    while(indexB >= 0 and time + B[indexB] > K):
        indexB -= 1
    count = i+1 + indexB+1
    if (best < count):
        best = count
print(best)

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

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

for i in range(1, len(A)):
    A[i] += A[i-1]
for i in range(1, len(B)):
    B[i] += B[i-1]

indexB = len(B) - 1
best = 0
for i in range(len(A)):
    time = A[i]
    if time > K:
        break
    else:
        while(indexB >= 0 and time + B[indexB] > K):
            indexB -= 1
        count = i+1 + indexB+1
        if indexB < len(B)-1:
        indexB += 1
    if (best < count):
        best = count
print(best)
Problem p02723 (python)

Fixed submission:
S = input()
if S[2] == S[3] and S[4] == S[5]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N, X, Y = map(int, input().split())
count = [0] * (N-1)
for i in range(N):
    i += 1
    for j in range(N-i):
        j += i + 1
        if i < j:
            normal = j-i
            xtoy = abs(X-i) + 1 + abs(Y-j)
            ytox = abs(Y-i) + 1 + abs(X-j)
            minRoute = min([normal, xtoy, ytox])
            count[minRoute-1] += 1
for c in count:
    print(c)
Problem p02729 (python)

Fixed submission:
def comb(a):
    if a < 2:
        return 0
    else:
        return a * (a-1) // 2


N, M = map(int, input().split())
print(comb(N)+comb(M))

Buggy submission (verdict: Runtime Error):
import math
from scipy.special import comb

N, M = map(int, input().split())
print(math.floor(comb(N, 2)+comb(M, 2)))
Problem p02773 (python)

Fixed submission:
N = int(input())
dct = {}
for i in range(N):
    S = input()
    if dct.get(S) == None:
        dct[S] = 1
    else:
        dct[S] += 1
sortedDct = sorted(dct.items(), key=lambda x: -x[1])
L = []
maxNum = 0
for k, v in sortedDct:
    if (maxNum <= v):
        L.append(k)
        maxNum = v
L.sort()
for l in L:
    print(l)

Buggy submission (verdict: Runtime Error):
dct = {}
for i in range(N):
    S = input()
    if dct.get(S) == None:
        dct[S] = 1
    else:
        dct[S] += 1
sortedDct = sorted(dct.items(), key=lambda x: -x[1])
L = []
maxNum = 0
for k, v in sortedDct:
    if (maxNum <= v):
        L.append(k)
        maxNum = v
L.sort()
for l in L:
    print(l)
Problem p02777 (python)

Fixed submission:
S, T = input().split()
A, B = map(int, input().split())
U = input()
dct = {}
dct[S] = A
dct[T] = B
dct[U] -= 1
print(dct[S], dct[T])

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

res = -1

for i in range(N):
    res = p[i]

print(res)
Problem p02596 (python)

Fixed submission:
K = int(input())

if K % 2 == 0 or K % 5 == 0:
    i = -1
else:
    if K % 7 == 0:
        K = K//7
    L = 9*K
    a = 10 % L
    if a == 1:
        i = 1
    else:
        for i in range(2, L+1):
            a = (a*10) % L
            if a == 1:
                break
print(i)

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

if K % 2 == 0 or K % 5 == 0:
    i = -1
else:
    if K % 7 == 0:
        K = K%7
    L = 9*K
    a = 10 % L
    if a == 1:
        i = 1
    else:
        for i in range(2, L+1):
            a = (a*10) % L
            if a == 1:
                break
print(i)
Problem p02659 (python)

Fixed submission:
A, B = input().split()
A = int(A)
B = int(B[:-3]+B[-2:])

if len(str(A*B)) >= 3:
    print(str(A*B)[:-2])
else:
    print(0)

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

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

for i in range(s, a*b+1, s):
    if i % a  == 0 and  i % b == 0:
        break

print(i)

Buggy submission (verdict: Runtime Error):
import math
a,b = map(int, input().split())
print( (a*b) // math.gcd(a,b))
Problem p02627 (python)

Fixed submission:
print("aA"[input().isupper()])

Buggy submission (verdict: Runtime Error):
print(“aA”[input().isupper()])
Problem p02598 (python)

Fixed submission:
import bisect
N,K=map(int,input().split())
A=list(map(int,input().split()))

#全ての丸太を長さt以下にするのに必要な切断数が
#k以下であるような最大のtを求める
ok=max(A)
ng=0

def isok(t):
  res=0
  for i in range(N):
    res+=A[i]//t-(A[i]%t==0)
  return res<=K

while abs(ok-ng)>1:
  mid=(ok+ng)//2
  if isok(mid):
    ok=mid
  else:
    ng=mid

print(ok)

Buggy submission (verdict: Runtime Error):
import math
N,K=map(int,input.split())
A=list(map(int,input().split()))

#全ての丸太を長さt以下にするのに必要な切断数が
#k以下であるような最大のtを求める
ok=10**9
ng=0

def isok(t):
  res=0
  for i in range(N):
    res+=int(math.log2(A[i]//t))
  return res<=K

while abs(ok-ng)>1:
  mid=(ok+ng)//2
  if isok(mid):
    ok=mid
  else:
    ng=mid

print(ok)
Problem p02659 (python)

Fixed submission:
A,B=input().split()
A=int(A)
B=int(B.replace(".",""))*100
print(A*B//10000)

Buggy submission (verdict: Runtime Error):
A,B=input().split()
A=int(A)
B=int(B*100)
print(A*B/100)
Problem p02676 (python)

Fixed submission:

k=int(input())
S=input()
if len(S)>k:
  S=S[:k]+"..."
print(S)

Buggy submission (verdict: Runtime Error):
S=input()
k=int(input())
if len(S)>k:
  S=S[:k]+"..."
print(S)
Problem p02695 (python)

Fixed submission:
n,m,q=map(int,input().split())
a=[]
for _ in range(q):
    a.append(list(map(int,input().split())))

ans=0
def search(l):
    global ans
    if len(l)==n+1:
        score=0
        for i in range(q):
            if l[a[i][1]]-l[a[i][0]]==a[i][2]:
                score+=a[i][3]
        ans=max(ans,score)
    
    else:
        for i in range(l[-1],m+1):
            search(l+[i])

search([1])

print(ans)

Buggy submission (verdict: Runtime Error):
n,m,q=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for j in range(q):
    a2,b2,c2,d2=map(int,input().split())
    a.append(a2)
    b.append(b2)
    c.append(c2)
    d.append(d2)

#dp[i][j] i番目までの数字でjまでつかってとれる最高得点
dp=[[0]*(m+1) for _ in range(n+1)]

for i in range(q):
    for k in range(m+1):
        if k+c>m:
            continue
        dp[b[i]][k+c]=dp[a[i]][k]+d[i]

ans = 0
for j in range(m):
    ans = max(ans,dp[n][j]) 
print(dp[n][m])
Problem p02725 (python)

Fixed submission:
K,N=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
dist=[A[0]+K-A[-1]]+[A[i]-A[i-1] for i in range(1,N)]
print(K-max(dist))

Buggy submission (verdict: Runtime Error):
K,N=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
dist=[A[0]+K-A[-1]]+[A[i]-A[i-1] for i in range(1,N)]
print(k-max(dist))
Problem p02757 (python)

Fixed submission:
N,P=map(int,input().split())
S=input()
sn=int(S)

if P==2:
  ans=0
  for i in range(1,N+1):
    if int(S[-i])%2==0:
      ans+=N-i+1
  print(ans)
  exit()

if P==5:
  ans=0
  for i in range(1,N+1):
    if int(S[-i])%5==0:
      ans+=N-i+1
  print(ans)
  exit()

amari=[0]*P
amari[0]=1

mod=0
for i in range(1,N+1):
  mod=(mod+int(S[-i])*pow(10,i-1,P))%P
  amari[mod]+=1
ans=0
for tmp in amari:
  ans+=tmp*(tmp-1)//2
  
print(ans)

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

amari=[0]*P
amari[0]=1

if P==2:
  ans=0
  for i in range(1,N+1):
    if S[-i]%2==0:
      ans+=N-i
  print(ans)
  exit()

if P==5:
  ans=0
  for i in range(1,N+1):
    if S[-i]%5==0:
      ans+=N-i
  print(ans)
  exit()

for i in range(1,N+1):
  amari[int(S[-i:])%P]+=1
ans=0
for tmp in amari:
  ans+=tmp*(tmp-1)//2
  
print(ans)

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

amari=[0]*P
amari[0]=1

if P==2:
  ans=0
  for i in range(1,N+1):
    if S[-i]%2==0:
      ans+=N-i
  print(ans)
  exit

if P==5:
  ans=0
  for i in range(1,N+1):
    if S[-i]%5==0:
      ans+=N-i
  print(ans)
  exit

for i in range(1,N+1):
  amari[int(S[-i:])%P]+=1
ans=0
for tmp in amari:
  ans+=tmp*(tmp-1)//2
  
print(ans)
Problem p02773 (python)

Fixed submission:
n = int(input())

s_list = [""]*n

for i in range(n):
    s_list[i] = input()

s_list.sort()

ans_list = [s_list[0]]
pre_s = s_list[0]
count = 1
max_count = count

if len(s_list) == len(set(s_list)):
    ans_list = s_list
        
    ans_list.sort()

    for s in ans_list:
        print(s)

    exit()


for i in range(1,n):
    if pre_s == s_list[i]:
        count += 1
        if count == max_count:
            ans_list.append(s_list[i])
        if count > max_count:
            max_count = count
            ans_list = [s_list[i]]
    else:
        pre_s = s_list[i]
        count = 1

ans_list.sort()

for s in ans_list:
    print(s)

Buggy submission (verdict: Runtime Error):
import collections
n=input()
s=[]
for i in range(n):
    s.append(input())
c=collections.Counter(s).most_common()


print(c[0][0])
mx=c[0][1]
for i in range(1,len(c)):
    if c[i][1]==mx:
        print(c[i][0])
    else:
        exit()
Problem p02881 (python)

Fixed submission:
N=int(input())
can=[]
for i in range(1,int(N**0.5)+1):
  if N%i==0:
    can.append(i-1+N//i-1)
    

print(min(can))

Buggy submission (verdict: Runtime Error):
N=int(input())
can=[]
for i in range(1,N**0.5+1):
  if N%i==0:
    can.append(N-1+N//i-1)
    

print(min(can))
Problem p02897 (python)

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

Buggy submission (verdict: Runtime Error):
N=int(input())
print(0.5 if N%2==0 else ((N+1)/2)/((N-1)/2))