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

Fixed submission:
def c_id(N, M, City):
    City = sorted(City, key=lambda x: (x[0], x[1]))
    # print(City)
    a, b = City[0][0], 0
    for j, (p, y, k) in enumerate(City):
        if p == a:
            # print('a', j, p, y, k)
            b += 1
            City[j] = [p, b, k]
        else:
            # print('b', j, p, y, k)
            a = p
            b = 1
            City[j] = [p, b, k]
    city = sorted(City, key=lambda x: x[2])
    # print(city)

    ans_tmp = []
    for p, q, k in city:
        ans_tmp.append('{0:06d}{1:06d}'.format(p, q))
    ans = '\n'.join(ans_tmp)
    return ans

N, M = [int(i) for i in input().split()]
City = [[int(i) for i in input().split()] + [k] for j, k in enumerate(range(M), 1)]
print(c_id(N, M, City))

Buggy submission (verdict: Runtime Error):
def c_id():
    from collections import defaultdict
    N, M = [int(i) for i in input().split()]
    Cities = [[int(i) for i in input().split()] for j in range(M)]

    dic = defaultdict(list)
    # 県毎に市をまとめる
    for p, y in Cities:
        dic[p].append(y)
    # 市の認識番号を (座標) 圧縮
    for p, lst in dic.items():
        dic[p] = {v: k for k, v in enumerate(sorted(lst), 1)}
    return '\n'.join([f'{p:06d}{dic[p][y]:06d}' for p, y in Cities])

print(c_id())

Buggy submission (verdict: Runtime Error):
def c_id():
    from collections import defaultdict
    N, M = map(int, input().split())
    City = [[s] + [int(i) for i in input().split()] for s in range(M)]

    # 同じ県に属する市を誕生年の早い順に並べ、順序付けする
    city_dict = defaultdict(list)
    for k, p, y in City:
        city_dict[p].append([k, p, y])
    for p in city_dict.keys():
        city_dict[p].sort(key=lambda x: x[2])
        for i in range(len(city_dict[p])):
            city_dict[p][i][2] = i + 1

    # 変換は終わった。通し番号順に並べる
    ans = sorted([e for v in city_dict.values() for e in v])
    return '\n'.join([f'{p:06d}{num:06d}' for _, p, num in ans])  # 通し番号は不要

print(c_id())
Problem p03785 (python)

Fixed submission:
def a_airport_bus(N, C, K, T):
    import bisect
    t = sorted(T)
    index = 0  # t[index]はまだバスに乗っていない人の内最も早い空港到着時刻
    ans = 0
    while index <= N - 1:
        # 時刻 t[index] にバスを出した場合乗り込める人数の候補
        num_take_bus = bisect.bisect_right(t, t[index] + K) - index
        if num_take_bus > C:
            index += C  # 定員分だけ乗せる
        else:
            index += num_take_bus  # 乗れるだけ乗せる
        ans += 1  # バスを1台出した
    return ans

N, C, K = [int(i) for i in input().split()]
T = [int(input()) for _ in range(N)]
print(a_airport_bus(N, C, K, T))

Buggy submission (verdict: Runtime Error):
def a_airport_bus(N, C, K, T):
    import bisect
    t = sorted(T)
    index = 0  # t[index]はまだバスに乗っていない人の内最も早い空港到着時刻
    ans = 0
    while index <= N - 1:
        # 時刻 t[index] にバスを出した場合乗り込める人数の候補
        num_take_bus = bisect.bisect_right(t, t[index] + K) - index
        if num_take_bus > C:
            index += C  # 定員分だけ乗せる
        else:
            index += tmp  # 乗れるだけ乗せる
        ans += 1  # バスを1台出した
    return ans

N, C, K = [int(i) for i in input().split()]
T = [int(input()) for _ in range(N)]
print(a_airport_bus(N, C, K, T))
Problem p03821 (python)

Fixed submission:
def a_multiple_array_(N, A, B):
    ans = 0  # ボタンを押した回数
    for k in range(N - 1, -1, -1):  # 末尾から貪欲に決めていく
        remainder = (A[k] + ans) % B[k]  # A[k]+ansが現在のA[k]の値
        if remainder != 0:  # 定義の仕方より、reminderは非負整数
            ans += B[k] - remainder
    return ans

N = int(input())
A, B = [], []
for _ in range(N):
    a, b = [int(i) for i in input().split()]
    A.append(a)
    B.append(b)
print(a_multiple_array_(N, A, B))

Buggy submission (verdict: Runtime Error):
def a_multiple_array_(N, A, B):
    ans = 0  # ボタンを押した回数
    for k in range(N - 1, -1, -1):  # 末尾から貪欲に決めていく
        remainder = (A[k] + ans) % B[k]  # A[k]+ansが現在のA[k]の値
        if remainder != 0:  # 定義の仕方より、reminderは非負整数
            ans += B[k] - remainder
    return ans

N = int(Input())
A, B = [], []
for _ in range(N):
    a, b = [int(i) for i in input().split()]
    A.append(a)
    B.append(b)
print(a_multiple_array_(N, A, B))
Problem p02860 (python)

Fixed submission:
n = int(input())
s = input()
if n%2==1:
    print("No") 
else:
    s1 = ""
    s2 = ""
    for i in range(0, n//2):
        s1+=s[i]
        s2+=s[n//2 + i]
    if(s1 == s2):
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
if n%2==1:
  print("NO") 
elif:
  s1 = ""
  s2 = ""
  for i in range(0, n/2):
    s1+=s[i]
    s2+=s[n/2 + i]
  if(s1 == s2):
    print("YES")
  else:
    print("NO")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
if n%2==1:
  print("NO") 
elif s[0:n/2] == s[n/2:-1]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
if n%2==1:
  print("NO") 
elif s[0:n/2] == s[n/2]:
  print("YES")
else:
  print("NO")
Problem p03250 (python)

Fixed submission:
a, b, c=input().split()
matome=[a,b,c]
mx=max(a,b,c)
mn=min(a,b,c)
mex=mx+mn
ans1=int(mex)
import statistics
md=statistics.median(matome)
ans2=int(md)
print(ans1+ans2)

Buggy submission (verdict: Runtime Error):
a, b, c=input().split()
d=a+b
e=b+c
di=int(d)
ei=int(e)
ai=int(a)
if di >=ei:
    print(di+c)
else:
    print(ai+ei)
Problem p02879 (python)

Fixed submission:
A,B = map(int,input().split())
if A<=9 and B<=9:
  print(A*B)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
if A<=9 && B<=9:
  print(A*B)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
if A<=9 && B<=9:
  print(A*B)
else:
  print(-1)
Problem p02547 (python)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    x,y = map(int,input().split())
    a.append([x,y])
count = 0
flag = True
for x in a:
    if x[0] == x[1]:
        count += 1
        if count == 3:
            print('Yes')
            flag = False
            break
    else:
        count = 0

if flag:
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in n:
    x,y = map(int,input().split())
    a.append([x,y])
count = 0
flag = True
for x in a:
    if x[0] == x[1]:
        count += 1
        if count == 3:
            print('Yes')
            flag = False
            break
    else:
        count = 0

if flag:
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in n:
    x,y = map(int,input())
    a.append([x,y])
count = 0
flag = True
for x in a:
    if x[0] == x[1]:
        count += 1
        if count == 3:
            print('Yes')
            flag = False
            break
    else:
        count = 0

if flag:
    print('No')
Problem p02859 (python)

Fixed submission:
n=int(input())
print(n*n)

Buggy submission (verdict: Runtime Error):
n = int(input())
print((int)n*n)
Problem p03834 (python)

Fixed submission:
l = input()
for i in range(0, 5):
	print(l[i], end="")
print(" ", end="")
for j in range(6, 13):
	print(l[j], end="")
print(" ", end="")
for k in range(14, 19):
	print(l[k], end="")

Buggy submission (verdict: Runtime Error):
l = input()
for i in range(0, 5)
	print(l[i], end="")
for j in range(6, 13)
	print(l[j], end="")
for k in range(14, 19)
	print(l[k], end="")

Buggy submission (verdict: Runtime Error):
l = input()
for i in range(0, 5) 　print(l[i], end="")
for j in range(6, 13) 　print(l[j], end="")
for k in range(14, 19) 　print(l[k], end="")

Buggy submission (verdict: Runtime Error):
l = input()
for i in range(0, 5) 　print(l[i], end="")
for i in range(6, 13) 　print(l[i], end="")
for i in range(14, 19) 　print(l[i], end="")
Problem p02627 (python)

Fixed submission:
N = input()
A, a = 0, 0
for i in range(65, 91):
  if i==ord(N):
    A += 1
for i in range(97, 123):
  if i==ord(N):
    a += 1
if A==1:
  print('A')
if a==1:
  print('a')

Buggy submission (verdict: Runtime Error):
N = input()
for i in range(65, 90):
  if i==ord(N):
    A += 1
for i in range(97, 123):
  if i==ord(N):
    a += 1
if A==1:
  print('A')
if a==1:
  print('a')
Problem p02712 (python)

Fixed submission:
N = int(input())
cnt = 0
for i in range(N+1):
    if i%5!=0 and i%3!=0:
        cnt += i
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
cnt += 0
for i in range(N):
  if i%5!=0 and i%3!=0:
    cnt += i
print(cnt)
Problem p02771 (python)

Fixed submission:
A, B, C = input().split()

if A==B==C:
    print('No')
else:
    if A==B:
        if B!=C:
            print('Yes')
    elif A==C:
        if C!=B:
            print('Yes')
    elif B==C:
        if C!=A:
            print('Yes')
    else:
        print('No')

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

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

B = []
for i in range(N):
    for j in range(N):
        if i>j:
            B.append(np.dot(A[i], A[j]))

B.sort()
print(B[K-1])
Problem p02777 (python)

Fixed submission:
S, T = input().split()
a, b = input().split()
U = input()

a = int(a)
b = int(b)

if S==U:
  a-=1
if T==U:
  b-=1

print("{} {}".format(a, b))

Buggy submission (verdict: Runtime Error):
S, T = map(input().split())
a, b = map(input().split())
U = input()

if S==U:
    a-=1
else:
    b-=1

print("{} {}".format(a, b))
Problem p03041 (python)

Fixed submission:
N, K = map(int, input().split())
S = [i for i in input()]

for i in range(65, 65+26):
    if S[K-1]==chr(i):
        S[K-1]=chr(i+32)

print(''.join(S))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = [i for i in input()]

for i in range(65, 65+26):
    if S[K]==chr(i):
        S[K]=chr(i+32)

print(''.join(S))
Problem p02793 (python)

Fixed submission:
# -*- coding: utf-8 -*-

#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)

def calc_gcd_list(l):
    gcd = l[0]
    for i in range(1, N):
        gcd = gcd(gcd, l[i])
    return gcd

def calc_lcm_list(l):
    lcm = 1
    for i in l:
        lcm = lcm * i // gcd(lcm, i)
    return lcm


N = input_one_number()
lstA = input_multiple_number_as_list()
lcm = calc_lcm_list(lstA)
pow = 10**9 +7
print(sum(lcm//a for a in lstA)%pow)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)

def calc_gcd_list(l):
    gcd = l[0]
    for i in range(1, N):
        gcd = gcd(gcd, l[i])
    return gcd

def calc_lcm_list(l):
    lcm = l[0]
    for i in range(1, N):
        lcm = lcm * l[i] // gcd(lcm, l[i])
    return lcm


N = input_one_number()
lstA = input_multiple_number_as_list()
lcm = calc_lcm_list(lstA)
pow = 10**9 +7
print(sum(lcm//a for a in lstA)%pow)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))



#複数の最小公倍数
def calc_lcm_list(l):
    lcm = l[0]
    for i in range(1, N):
        lcm = lcm * l[i] // fractions.gcd(lcm, l[i])
    return lcm


import fractions
N = input_one_number()
lstA = input_multiple_number_as_list()

gcd = calc_lcm_list(lstA)

ans = 0
for a in lstA:
    ans += (gcd // a)

print(ans %= 1000000007)
Problem p02891 (python)

Fixed submission:
# -*- coding: utf-8 -*-

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

S = input()
K = int(input())


if len(S) >= 1:
	flagtail = 0
	old_s = ""
	cnt = 0
	for s_ in S:
		if s_ == old_s:
			cnt +=1
			old_s = ""
		else:
			old_s = s_
	ans = cnt

	cnt1 = cnt
	old_s = ""

	if(K > 1 and K %2 == 0):
		S = S*2
		cnt1 = cnt
		cnt = 0
		old_s = ""
		for s_ in S:
			if s_ == old_s:
				cnt +=1
				old_s = ""
			else:
				old_s = s_

		ans = cnt1 + (cnt-cnt1)*(K-1)

	if(K > 1 and K %2 != 0):
		S = S*3
		cnt1 = cnt
		cnt = 0
		old_s = ""
		for s_ in S:
			if s_ == old_s:
				cnt +=1
				old_s = ""
			else:
				old_s = s_

		ans = cnt1 + (cnt-cnt1)*(K-1)//2
	print(ans)
else:
	print(K//2)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

S = input()
K = int(input())

flagtail = 0
old_s = ""
cnt = 0
for s_ in S:
	if s_ == old_s:
		cnt +=1
		old_s = ""
	else:
		old_s = s_

ans = cnt * K

if S[-1] != S[-2] and S[0]==S[-1]:
	ans += (K-1)

print(ans)
Problem p02833 (python)

Fixed submission:
n=int(input())
if(n&1):
    print(0)
else:
    ans=0
    n /= 2
    while(n>=5):
        ans += n//5
        n //= 5
    print(ans)

Buggy submission (verdict: Runtime Error):
n=input()
if(n&1):
    print(0)
else:
    ans=0
    n /= 2
    while(n>=5):
        ans += n//5
        n //= 5
    print(ans)
Problem p02552 (python)

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

Buggy submission (verdict: Runtime Error):
a=int(input())
if a==1:
  print(0)
if a==0
  print(1)
Problem p02933 (python)

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(a: int, s: str):
    if a >= 3200:
        print(s)
    else:
        print('red')
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    s = next(tokens)  # type: str
    solve(a, s)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

def solve(N: int, A: "List[int]"):
    result = 0.
    for i in range(N):
        result += 1./A[i]
    print(1./result)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

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

Fixed submission:
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
l=[1]+[0 for _ in range(n+5)]
if m==0:a=[200000]
for x in range(n):
    if x<a[0]:
        l[x+1]+=l[x]
        l[x+2]+=l[x]
    if x==a[0]:
        if len(a)>=2:a.pop(0)
        else:a[0]=200000
print(l[n]%(10**9+7))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
l=[1]+[0 for _ in range(n+5)]
c=0
for x in range(n):
    if x<a[0]:
        l[x+1]+=l[x]
        l[x+2]+=l[x]
    if x==a[0]:
        if len(a)>=2:a.pop(0)
        else:a[0]=200000
print(l[n]%(10**9+7))
Problem p03723 (python)

Fixed submission:
a,b,c=map(int,input().split())
d=0
while a%2==0 and b%2==0 and c%2==0:
    if a==b==c:
        print(-1)
        break
    d+=1
    ha=a//2
    hb=b//2
    hc=c//2
    a=hb+hc
    b=ha+hc
    c=ha+hb
else:print(d)

Buggy submission (verdict: Runtime Error):
s=list(input().split())
n=int(input())
t=[input() for i in range(n)]
r=[]
for x in s:
    for y in t:
        if len(x)==len(y):
            l=list(x)
            for z in range(len(x)):
                if y[z]=="*":l[z]="*"
            if "".join(l)==y:
                r.append("*"*len(x))
                break
    else:r.append(x)
print(*r)
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 = '7' * (k - 1)
if int(a) % k == 0:
    for i in range(1, 50):
        a = '7' * i
        if int(a) % k == 0:
            print(i)
            exit()
    print(k-1)
    exit()
print(-1)

Buggy submission (verdict: Runtime Error):

k = int(input())
a = '7' * (k - 1)
if int(a) % k == 0:
    for i in range(1, 100):
        a = '7' * i
        if int(a) % k == 0:
            print(i)
            exit()
    print(k-1)
print(-1)
Problem p02659 (python)

Fixed submission:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

a,b = farr()
a,b = int(a),int(b*100+ .5)
ans = (a*b) //100
print(ans)

Buggy submission (verdict: Runtime Error):
    from decimal import Decimal as dec
    def main():
        a, b = map(dec, input().split())
        print(int(dec(a)*dec(b)))
     
    if __name__ == "__main__":
        main()
Problem p02596 (python)

Fixed submission:
K = int(input())

if K == 1 or K == 7:
    print(1)
    exit()

v = 7
M = set([])
for i in range(1, K + 1):
    v = (v * 10 + 7) % K
    if v == 0:
        print(i + 1)
        exit()
    if v not in M:
        M.add(v)
    else:
        print(-1)
        exit()

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

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


def factorization(n):
    arr = []
    temp = n
    for i in range(3, n, 2):
        if i * i > n:
            break
        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


arr = factorization(K)
# print(f'{arr=}')

ans = 1
for a in arr:
    b = a[0]
    time = a[1]
    # print(f'{K=}')
    v = ''
    M = set([])
    for i in range(1, 999982):
        v += '7'
        mod = int(v) % b
        if mod == 0:
            # print(f'{K=}, {i=}')
            ans *= i**time
            break
        if mod in M:
            print(f'{K=}, i=-1')
            print(-1)
            exit()
        M.add(mod)

print(ans)
Problem p02624 (python)

Fixed submission:
from math import floor
N = int(input())


def g(X):
    Y = floor(N / X)
    return Y * (Y + 1) * X // 2


ans = 0
for i in range(1, N + 1):
    ans += g(i)

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())


def make_prime(U):
    is_prime = np.zeros(U, np.bool)
    is_prime[2] = 1
    is_prime[3::2] = 1
    M = int(U**.5) + 1
    for p in range(3, M, 2):
        if is_prime[p]:
            is_prime[p * p::p + p] = 0
    return is_prime, is_prime.nonzero()[0]


def f(n):
    cnt = 0
    i = 0
    if n == 1:
        return 1
    for i in range(1, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            cnt += 2
    if (i - 1) * (i - 1) == n:
        cnt -= 1
    return cnt


# D = [0] * (N + 1)
is_prime, is_prime_value = make_prime(N + 1)
D = np.zeros(N + 1, dtype='int')
D[is_prime] = 2

ans = 0
for i in range(1, N + 1):
    if D[i] == 0:

        cnt = 0
        j = 0
        if i == 1:
            D[i] = 1
        for j in range(1, i + 1):
            if j * j > i:
                break
            if j * j == i:
                if j in is_prime_value:
                    D[i] += D[i // j] + 1
                    break
                else:
                    cnt += 1
            if i % j == 0:
                if j in is_prime_value:
                    D[i] += D[n // j] + 2
                    break
                else:
                    cnt += 2
        else:
            D[i] = cnt
        # v = f(i)
        # D[i] = v
        # ans += v * i
    ans += D[i] * i
    # print('i, f(i)', i, f(i))
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())


def make_prime(U):
    is_prime = np.zeros(U, np.bool)
    is_prime[2] = 1
    is_prime[3::2] = 1
    M = int(U**.5) + 1
    for p in range(3, M, 2):
        if is_prime[p]:
            is_prime[p * p::p + p] = 0
    return is_prime, is_prime.nonzero()[0]


def f(n):
    cnt = 0
    i = 0
    if n == 1:
        return 1
    for i in range(1, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            cnt += 2
    if (i - 1) * (i - 1) == n:
        cnt -= 1
    return cnt


# D = [0] * (N + 1)
is_prime, is_prime_value = make_prime(N + 1)
D = np.zeros(N + 1, dtype='int')
D[is_prime] = 2

ans = 0
for i in range(1, N + 1):
    if D[i] == 0:

        cnt = 0
        j = 0
        if i == 1:
            D[i] = 1
        for j in range(1, i + 1):
            if j * j > i:
                break
            if j * j == i:
                if j in is_prime_value:
                    D[i] += D[i // j] + 1
                    break
                else:
                    cnt += 1
            if i % j == 0:
                if j in is_prime_value:
                    D[i] += D[n // j] + 2
                    break
                else:
                    cnt += 2
        else:
            D[i] = cnt
        # v = f(i)
        # D[i] = v
        # ans += v * i
    ans += D[i] * i
    # print('i, f(i)', i, f(i))
print(ans)
Problem p02629 (python)

Fixed submission:
N = int(input())

# 26進数
v = []
while True:
    N, mod = divmod(N, 26)
    if mod == 0:
        mod = 26
        N -= 1
    v.append(mod)
    if N < 26:
        v.append(N)
        break
v = v[::-1]
# print('v', v)
alphabets = list('0abcdefghijklmnopqrstuvwxyz')
s = []
for i in v:
    if i == 0:
        continue
    s.append(alphabets[i])
# print('s', s)
ans = ''.join(s)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
alphabets = list('zabcdefghijklmnopqrstuvwxy')

v = []
# 26進数
while True:
    N, mod = divmod(N, 26)
    if mod == 0:
        mod = 26
        N -= 1
    v.append(alphabets[mod])
    if N < 26:
        if N != 0:
            v.append(alphabets[N])
        break
v = v[::-1]
ans = ''.join(v)
print(ans)
Problem p02726 (python)

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


def f(i, j):
    v1 = j - i
    v2 = abs(X - i) + 1 + abs(j - Y)
    v3 = abs(Y - i) + 1 + abs(j - X)
    return min(v1, v2, v3)


D = [0] * N
for i in range(1, N):
    for j in range(i + 1, N + 1):
        d = f(i, j)
        D[d] += 1

for d in D[1:]:
    print(d)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, X, Y = map(int, input().split())
dist = [0] * (N + 1)
cnt = [0] * (N + 1)

d = [[abs(j - i) for j in range(N)] for i in range(N)]
d[X - 1][Y - 1] = 1
d[Y - 1][X - 1] = 1


def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    # for k in range(N):
    #     for i in range(N):
    #         for j in range(N):
    #             d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    # return d
    return [min(d[i][j], d[i][k] + d[k][j]) for k in range(N) for i in range(N) for j in range(N):]
                

d = warshall_floyd(d)
count = np.bincount(np.array(d).flatten(), minlength=N)
count = count[1:] // 2
print(*count, sep='\n')

Buggy submission (verdict: Runtime Error):
import numpy as np
N, X, Y = map(int, input().split())
dist = [0] * (N + 1)
cnt = [0] * (N + 1)

INF = 10**10 + 9

# d = [[INF] * N for _ in range(N)]
d = []
for i in range(N)
    
d = [j - i for i in range(N) for j in range(i, N)]
d = []
for i in range(N):
    tmp = [j - i for j in range(i, N)]
    d.append(tmp)
# d[i][j] = j - i
# d[j][i] = j - i
print('d', d)
exit()
d[X - 1][Y - 1] = 1
d[Y - 1][X - 1] = 1


def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


d = warshall_floyd(d)
count = np.bincount(np.array(d).flatten(), minlength=N)
count = count[1:] // 2
print(*count, sep='\n')