Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
K = str(input())
D = int(input())

N = len(K)

MOD = 10 ** 9 + 7

# if D == 1:
#     print (K)
#     exit()
# elif D == 2:
#     print (int(K) // 2)
#     exit()
# elif D == 5:
#     print (int(K) // 5)

dp0 = [[0] * D for _ in range(N + 1)]
dp1 = [0] * (N + 1)

for i in range(N):
    next_ = int(K[i])
    tmp = dp1[i]

    dp1[i + 1] = (tmp + next_) % D
    
    for j in range(next_):
        dp0[i + 1][(tmp + j) % D] += 1
    # print (dp0[i + 1])
    for j in range(D):
        for k in range(10):
            dp0[i + 1][(j + k) % D] += dp0[i][j]
    
    for j in range(D):
        dp0[i + 1][j] %= MOD


# for tmp in dp0:
#     print (tmp)

# print (dp1)


ans = dp0[N][0] - 1
if dp1[N] == 0:
    ans += 1

print (ans % MOD)

Fixed submission:
K = str(input())
D = int(input())

N = len(K)

MOD = 10 ** 9 + 7

# if D == 1:
#     print (K)
#     exit()
# elif D == 2:
#     print (int(K) // 2)
#     exit()
# elif D == 5:
#     print (int(K) // 5)

dp0 = [[0] * D for _ in range(N + 1)]
dp1 = [0] * (N + 1)

for i in range(N):
    next_ = int(K[i])
    tmp = dp1[i]

    dp1[i + 1] = (tmp + next_) % D
    
    for j in range(next_):
        dp0[i + 1][(tmp + j) % D] += 1
    # print (dp0[i + 1])
    for j in range(D):
        for k in range(10):
            dp0[i + 1][(j + k) % D] += dp0[i][j]
    
    for j in range(D):
        dp0[i + 1][j] %= MOD


# for tmp in dp0:
#     print (tmp)

# print (dp1)


ans = dp0[N][0] - 1
if dp1[N] == 0:
    ans += 1

print (ans % MOD)
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())

a = [1]
p = [1]
for i in range(1, N+1):
    a.append(2 * a[i-1] + 3)
    p.append(2 * a[i-1] + 1)

def calc(N, X): #レベルNバーガーの下からX層に含まれるパティの枚数
    if N == 0: #全てパティ
        if X == 0:
            return 0
        else:
            return 1
    if X == 1:
        return 0
    # print (N - 1)
    if 1 <= X <= a[N - 1]:
        # print ('A')
        return calc(N - 1, X - 1)
    if X == 2 + a[N - 1]:
        # print ('B')
        return p[N - 1] + 1
    if 2 +a[N - 1] < X <= 2 + 2 * a[N - 1]:
        # print ('C')
        return p[N - 1] + 1 + calc(N - 1, X - 2 - a[N - 1])
    if X == 3 + 2 * 2 * a[N - 1]:
        # print ('D')
        return 2 * p[N - 1] + 1

print (calc(N, X))

Fixed submission:
D = int(input())
print ('Christmas', end = '')
for i in range(25 - D):
    print (' Eve', end = '')
print ()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, K = map(int, input().split())
    A = [0] + list(map(int, input().split()))

    for i in range(N):
        A[i + 1] += A[i]

    B = [A[j] - A[i] for i in range(N) for j in range(i + 1, N + 1)]

    ans = 0
    t = 40
    tmp = pow(2, t)
    while t:
        count = 0
        tmp //= 2
        for b in B:
            if ((b & (tmp + ans)) == (tmp + ans)):
                count += 1
            if count >= K:
                ans += tmp
                break
        t -= 1

    print (ans)

if __name__ == '__main__':
    main()

Fixed submission:
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))

for i in range(N):
    A[i + 1] += A[i]

B = [A[j] - A[i] for i in range(N) for j in range(i + 1, N + 1)]

ans = 0
t = 40
while t:
    count = 0
    tmp = pow(2, t -1)
    for b in B:
        if ((b & (tmp + ans)) == (tmp + ans)):
            count += 1
    if count >= K:
        ans += tmp
    t -= 1

print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, K = map(int, input().split())
    A = [0] + list(map(int, input().split()))

    for i in range(N):
        A[i + 1] += A[i]

    B = [A[j] - A[i] for i in range(N) for j in range(i + 1, N + 1)]

    ans = 0
    t = 40
    while t:
        count = 0
        tmp = pow(2, t -1)
        for b in B:
            if ((b & (tmp + ans)) == (tmp + ans)):
                count += 1
            if count >= K:
                ans += tmp
                break
        t -= 1

    print (ans)

if __name__ == '__main__':
    main()

Fixed submission:
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))

for i in range(N):
    A[i + 1] += A[i]

B = [A[j] - A[i] for i in range(N) for j in range(i + 1, N + 1)]

ans = 0
t = 40
while t:
    count = 0
    tmp = pow(2, t -1)
    for b in B:
        if ((b & (tmp + ans)) == (tmp + ans)):
            count += 1
    if count >= K:
        ans += tmp
    t -= 1

print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))

for i in range(N):
    A[i + 1] += A[i]

B = [A[j] - A[i] for i in range(N) for j in range(i + 1, N + 1)]

ans = 0
t = 40
while t:
    count = 0
    tmp = pow(2, t -1)
    for b in B:
        if ((b & (tmp + ans)) == (tmp + ans)):
            count += 1
    if count >= K:
        ans += tmp
    t -= 1

print (ans)

Fixed submission:
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))

for i in range(N):
    A[i + 1] += A[i]

B = [A[j] - A[i] for i in range(N) for j in range(i + 1, N + 1)]

ans = 0
t = 40
while t:
    count = 0
    tmp = pow(2, t -1)
    for b in B:
        if ((b & (tmp + ans)) == (tmp + ans)):
            count += 1
    if count >= K:
        ans += tmp
    t -= 1

print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
#全探索すると終わらない
import math
N, M = map(int, input().split())
ans = 1
    
for i in range((M+N-1)//N, 0, -1):
    if M%i == 0:
        if (M//i)//N >= 1:
            print (i)
            exit()


Fixed submission:
#全探索すると終わらない
import math
N, M = map(int, input().split())
ans = 1
    
for i in range((M+N-1)//N, 0, -1):
    if M%i == 0:
        if (M//i)//N >= 1:
            print (i)
            exit()
Buggy python submission (verdict: Runtime Error):
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

z1 = max(x) + 1
z2 = min(y)

if X < z1 and z1 < Y:
    if X < z2 and z2 < Y:
        if z1 <= z2:
            print ('No War')
            sys.exit()
print ('War')


Fixed submission:
import sys
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

z1 = max(x) + 1
z2 = min(y)

if X < z1 and z1 < Y:
    if X < z2 and z2 < Y:
        if z1 <= z2:
            print ('No War')
            sys.exit()
print ('War')
Buggy python submission (verdict: Time Limit Exceeded):
import math
N, M = map(int, input().split())
MOD = 10 ** 9 + 7

def factoring(k): #kを因数分解し、素因数とその個数を辞書に入れて返す。
    dic = dict()
    n = int(math.sqrt(k))+2
    for i in range(2, n):
        count = 0
        while k%i == 0:
            count += 1
            k = k//i
        if count != 0:
            dic[i] = count
    if k != 1:
        dic[k] = 1
    return dic

def conbination(n, r): #nCrを求める
    # nCr = n! //(r! * (n-r)!)
    import math
    return (math.factorial(n) //(math.factorial(r) * math.factorial(n-r)))%MOD
dic = factoring(M)
ans = 1
for i in dic:
    ans = (ans * conbination(dic[i]+N-1, dic[i]))%MOD
print (ans)

    



Fixed submission:
import math
N, M = map(int, input().split())
MOD = 10 ** 9 + 7

def factoring(k): #kを因数分解し、素因数とその個数を辞書に入れて返す。
    dic = dict()
    n = int(math.sqrt(k))+2
    for i in range(2, n):
        count = 0
        while k%i == 0:
            count += 1
            k = k//i
        if count != 0:
            dic[i] = count
    if k != 1:
        dic[k] = 1
    return dic

def conbination(n, r): #nCrを求める
    # nCr = n! //(r! * (n-r)!)
    import math
    return (math.factorial(n) //(math.factorial(r) * math.factorial(n-r)))%MOD
dic = factoring(M)
ans = 1
for i in dic:
    ans = (ans * conbination(dic[i]+N-1, dic[i]))%MOD
print (ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())

if K % 2 == 1:
    tmp = N // K
    ans = tmp ** 3
    print (ans)0

else:
    tmp = N // K
    ans = tmp ** 3

    tmp = N // (K // 2) - tmp
    ans += tmp ** 3

    print (ans)


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

if K%2 == 0: #Kが偶数の時
    a = N//K
    b = (N+K//2)//K
    ans = a ** 3 + b ** 3
else: #Kが奇数の時3
    a = N//K
    ans = a ** 3

print (ans)
Buggy python submission (verdict: Runtime Error):
import sys

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

lst_p = []
lst_m = []
for i in range(N):
    if lst[i] == 0:
        K -= 1
    if lst[i] > 0:
        lst_p += [lst[i]]
    elif lst[i] < 0:
        lst_m += [lst[i]]


p = 0
m = 0
x, y = 0, len(lst_m)-1
lastx = len(lst_p)
lasty = len(lst_m)
all_p = 10 ** 9
all_m = 10 ** 9
if K <= lastx:
    all_p = lst_p[K-1]
if K <= lasty:
    all_m = lst_m[lasty - K]

#print (all_p, all_m)
while True:
#    print (K)
    if K == 0: #K=残り回数が0のとき出力して終了
        print (min(2 * p + abs(m), p + 2 * abs(m), all_p, all_m))
        sys.exit()
    if x == lastx: #正側の数字を全て使い切った時
        m = lst_m[y]
        y -= 1
        K -= 1
    elif y == -1: #負側の数字を全て使い切った時
        p = lst_p[x]
        x += 1
        K -= 1
    elif lst_p[x] < abs(lst_m[y]): #負側のリスト絶対値のほうが大きい時-->正側の数字を採用
        p = lst_p[x]
        x += 1
        K -= 1
    else: #正側のリストのほうが大きい時-->負側の数字を採用
        m = lst_m[y]
        y -= 1
        K -= 1
     


Fixed submission:
import sys

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

lst_p = []
lst_m = []
for i in range(N):
    if lst[i] == 0:
        K -= 1
    if lst[i] > 0:
        lst_p += [lst[i]]
    elif lst[i] < 0:
        lst_m += [lst[i]]


p = 0
m = 0
x, y = 0, len(lst_m)-1
lastx = len(lst_p)
lasty = len(lst_m)
#print (lastx, lasty)

def check(k):
    ans = 10 ** 9
    for j in range(0,k+1): #j: 正側の使う個数
#        print ('j, k-j', j, k-j)
        if j > lastx or k-j > lasty:
            pass
        else:
            if j == 0:
                p = 0
            else:
                p = lst_p[j-1]
            if k-j == 0:
                m = 0
            else:
                m = lst_m[lasty-(k-j)]
            ans = min(ans, 2 * p + abs(m), p + 2 * abs(m))
    return ans

print (check(K))
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
print ((A-1)*(B-1)

Fixed submission:
A, B = map(int, input().split())
print ((A-1)*(B-1))
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline

    N, M, Q = map(int, input().split())

    lst = [[0] * (N + 1) for _ in range(N + 1)]

    for _ in range(M):
        L, R = map(int, input().split())
        for l in range(L + 1):
            lst[l][R] += 1

    for l in range(N + 1):
        for r in range(N):
            lst[l][r + 1] += lst[l][r]

    # for tmp in lst:
    #     print (tmp)

    for _ in range(Q):
        p, q = map(int, input().split())
        print (lst[p][q])

if __name__ == '__main__':
    main()

Fixed submission:
import numpy as np
N, M, Q = map(int, input().split())

#input
lst = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, input().split())
    lst[R][L] += 1

lst = np.array(lst)
# print (lst)

#2次元累積和
for i in range(1, N + 1):
    lst[:,i] += lst[:, i - 1]
for j in range(1, N + 1):
    lst[j,:] += lst[j - 1, :]


#output
for _ in range(Q):
    p, q = map(int, input().split())
    print (lst[q, q] - lst[p-1, q] - lst[q, p-1] + lst[p-1, p-1])

# print (lst)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N, M, Q = map(int, input().split())

lst = [[0] * (N + 1) for _ in range(N + 1)]

for _ in range(M):
    L, R = map(int, input().split())
    for l in range(L + 1):
        lst[l][R] += 1

for l in range(N + 1):
    for r in range(N):
        lst[l][r + 1] += lst[l][r]

# for tmp in lst:
#     print (tmp)

for _ in range(Q):
    p, q = map(int, input().split())
    print (lst[p][q])

Fixed submission:
import numpy as np
N, M, Q = map(int, input().split())

#input
lst = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, input().split())
    lst[R][L] += 1

lst = np.array(lst)
# print (lst)

#2次元累積和
for i in range(1, N + 1):
    lst[:,i] += lst[:, i - 1]
for j in range(1, N + 1):
    lst[j,:] += lst[j - 1, :]


#output
for _ in range(Q):
    p, q = map(int, input().split())
    print (lst[q, q] - lst[p-1, q] - lst[q, p-1] + lst[p-1, p-1])

# print (lst)
Buggy python submission (verdict: Runtime Error):
N = int(input())

S = str()
count = 1
memo = 0
while a:
    amari = N%(2 ** count)
#    print ('amari', amari)
    if (amari- memo) == 2 ** (count-1):
        s = 1
    else:
        s = 0
    memo = memo + s * (-2) **(count-1)
#    print ('momo', memo)
    S = str(s) + S
    count += 1
    if memo == N:
        print (S)
        a = not a


Fixed submission:
N = int(input())

S = str()
a = True
count = 1
memo = 0
while a:
    amari = N%(2 ** count)
#    print ('amari', amari)
    if (amari- memo) == 2 ** (count-1):
        s = 1
    else:
        s = 0
    memo = memo + s * (-2) **(count-1)
#    print ('momo', memo)
    S = str(s) + S
    count += 1
    if memo == N:
        print (S)
        a = not a
Buggy python submission (verdict: Runtime Error):
#人のプログラムの全コピ　TKR18さん

#入力
a,b=map(int,input().split())
c=[0]+[list(map(int,input().split()))for i in range(a)]

#print(c)

def f(t,s): #t:t*100点までリストが存在する s: 目標値
    if t==0: #が0の時、とりあえず大きな数を返す
        return 10**9
    l=min(s//(t*100),c[t][0]) #s//(t*100): 目標を最高基本点で割った時の商、c[t][0]:最高基本点の使える数　これらの小さい方を返す
    k=100*t*l #最高基本点を使って得点できる最高点
    if l==c[t][0]: #最高基本点を使った数が、使える数と同じならボーナス点を加える。
        k+=c[t][1] 
    if k<s:　#最高基本点を全て使って得点できる点が、目標点以下なら...
        l+=f(t-1,s-k) #最高気本点を除いたもので、残りの点数を計算する。
    return min(l,f(t-1,s)) #最高気本点を使うもの(l)と最高基本点を使わないもの(f(t-1,s)のうち最小のものを見つける
print(f(a,b))



Fixed submission:
#人のプログラムの全コピ　TKR18さん

#入力
a,b=map(int,input().split())
c=[0]+[list(map(int,input().split()))for i in range(a)]

#print(c)

def f(t,s): #t:t*100点までリストが存在する s: 目標値
    if t==0: #が0の時、とりあえず大きな数を返す
        return 10**9
    l=min(s//(t*100),c[t][0]) #s//(t*100): 目標を最高基本点で割った時の商、c[t][0]:最高基本点の使える数　これらの小さい方を返す
    k=100*t*l #最高基本点を使って得点できる最高点
    if l==c[t][0]: #最高基本点を使った数が、使える数と同じならボーナス点を加える。
        k+=c[t][1] 
    if k<s: #最高基本点を全て使って得点できる点が、目標点以下なら...
        l+=f(t-1,s-k) #最高気本点を除いたもので、残りの点数を計算する。
    return min(l,f(t-1,s)) #最高気本点を使うもの(l)と最高基本点を使わないもの(f(t-1,s)のうち最小のものを見つける
print(f(a,b))
Buggy python submission (verdict: Runtime Error):
#平均値に近づけるという考え方が間違い

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

A = [A[i]-(i+1) for i in range(N)]

A.sort()

center1 = A[N//2]
center2 = A[(N+2)//2]

ans1 = 0
for i in range(N):
    ans1 +=abs(A[i]-center1)

ans2 = 0
for j in range(N):
    ans2 += abs(A[j]-center2)
    
print (min(ans1, ans2))

Fixed submission:
#平均値に近づけるという考え方が間違い-->中央値に近づける

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

A = [A[i]-(i+1) for i in range(N)]

A.sort()

center1 = A[N//2]
if N == 1:
    center2 = 10 ** 9
else:
    center2 = A[(N+2)//2]

ans1 = 0
for i in range(N):
    ans1 +=abs(A[i]-center1)
    
ans2 = 0
for j in range(N):
    ans2 += abs(A[j]-center2)
    
print (min(ans1, ans2))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

A = [A[i]-(i+1) for i in range(N)]

ans = 10 ** 9
#print (min(A))
for i in range(min(A), max(A)+1):
    b = [abs(A[j]-i) for j in range(N)]
#    print (sum(b))
#    print (b)
    ans = min(ans, sum(b))

print (ans)

Fixed submission:
#平均値に近づけるという考え方が間違い-->中央値に近づける

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

A = [A[i]-(i+1) for i in range(N)]

A.sort()

center1 = A[N//2]
if N == 1:
    center2 = 10 ** 9
else:
    center2 = A[(N+2)//2]

ans1 = 0
for i in range(N):
    ans1 +=abs(A[i]-center1)
    
ans2 = 0
for j in range(N):
    ans2 += abs(A[j]-center2)
    
print (min(ans1, ans2))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(N)]

dp = [[[0, 0, 0] for _ in range(M + 1)] for _ in range(N + 1)]
# for i in dp:
#     print (i)


def calc(i, j): #残りのi個からj個選ぶ
    if j == 0: #選び終わった時
        # print ('A', i, j)
        return [0, 0, 0]
    if dp[i][j] != [0, 0, 0]: #初期状態出でない時
        # print ('B', i, j)
        return dp[i][j]
    if i == j: #残りからすべて選ばないと行けない時
        tmp = calc(i - 1, j - 1)
        dp[i][j] = [tmp[0] + xyz[N - i][0], tmp[1] + xyz[N - i][1], tmp[2] + xyz[N - i][2]]
        # print ('C', i, j)
        return dp[i][j]
    if i > j: #選ぶ余地がある時
        #使わない時
        dp[i][j] = calc(i - 1, j)
        #使う時
        tmp = calc(i - 1, j - 1)
        tmp = [tmp[0] + xyz[N - i][0], tmp[1] + xyz[N - i][1], tmp[2] + xyz[N - i][2]]
        if (abs(dp[i][j][0]) + abs(dp[i][j][1]) + abs(dp[i][j][2])) < (abs(tmp[0]) + abs(tmp[1]) + abs(tmp[2])): #使わない方が良い時
            dp[i][j] = tmp
        # print ('D',i, j)
        return dp[i][j]

ans = calc(N, M)
# print (dp)
# print (ans)
print (abs(ans[0]) + abs(ans[1]) + abs(ans[2]))

Fixed submission:
N, M = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(2 ** 3):
    lst = [0] * N
    for j in range(3):
        if (i >> j) & 1:
            for k in range(N):
                lst[k] += xyz[k][j]
        else:
            for k in range(N):
                lst[k] -= xyz[k][j]
    lst.sort(reverse = True)
    ans = max(ans, sum(lst[:M]))

print (ans)
Buggy python submission (verdict: Runtime Error):
#反例　459 = 216 * 1 + 81 * 3
N = int(input())

count = 0

flag = True
a = N
while flag:
    if a//6 != 0:
        count += 1
        a = a//6
    else:
        flag = not flag

lst = []
for i in range(count+1):
    if (6 ** i)<= N:
        lst += [6 ** i]
        if   (9 ** i)<=N:
            lst += [9 ** i]

lst.sort(reverse = True)
#print (lst)

def hikidashi(j, n): #j番目より小さい数でnまで引き出すときの最小
    if j == len(lst):
        return n #残りをすべて1で埋める場合
    elif lst[j] > n: #引き出したい数 > 残額の時
        return hikidashi(j+1, n)
    else:
        a = hikidashi(j+1, n) #使わずに次の番目に行く
        b = hikidashi(j, n-lst[j]) + 1 #一つ使う
        return min (a, b)

print (hikidashi(0, N))





Fixed submission:
#DP　動的計画法

N = int(input())

INF = 10 ** 9
dp = [INF] * (N+1) #初期化配列

dp[0] = 0
for n in range(1, N+1):
    power = 1
    while power <= N:
        dp[n] = min(dp[n], dp[n-power]+1)
        power *= 6
    power = 1
    while power <= N:
        dp[n] = min(dp[n], dp[n-power]+1)
        power *= 9

#print (dp)
print (dp[N])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

count = 0
for l in range(N):
    total = 0
    xor = 0
    for r in range(l, N):
        total += A[r]
        xor ^= A[r]
        if total == xor:
            count += 1
        else:
            break

print (count)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = []
C = []

count = 0
for a in A:
    if a != 0:
        if count != 0:
            B.append(0)
            C.append(count)
        B.append(a)
        C.append(1)
        count = 0
    else:
        count += 1
if count != 0:
    B.append(0)
    C.append(count)

# print (A)
# print (B)
# print (C)
N = len(B)

count = 0
for l in range(N - 1):
    tmp = C[l] #スタート地点の数
    tmp_count = 0
    total = B[l]
    xor = B[l]
    for r in range(l + 1, N):
        total += B[r]
        xor ^= B[r]
        if total == xor:
            tmp_count += C[r]
        else:
            break
    # print (tmp_count, tmp)
    count += tmp_count * tmp
    count += (tmp * (tmp + 1)) // 2
    # print (count)

count += (C[-1] * (C[-1] + 1)) // 2

print (count)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
K = int(input())

lst = []
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
#        print ('i, j=', i, j)
        lst += [s[i:j]]

lst.sort()
#print (lst)
k = 0
flag = 0
ans = str()
check = True
while check:
    if ans != lst[flag]:
        #print ('k', k)
        k += 1
    ans = lst[flag]
    #print ('ans=', ans)
    flag += 1
    if k == K:
        ans = ''.join(ans)
        print(ans)
        check = not check


Fixed submission:
#全探索-->len(s) = 50程度までしか通らない
s = list(input())
K = int(input())

lst = []
for i in range(len(s)):
    for j in range(i+1, min(len(s)+1, i+1+K)):
#        print ('i, j=', i, j)
        lst += [s[i:j]]

lst.sort()
#print (lst)
k = 0
flag = 0
ans = str()
check = True
while check:
    if ans != lst[flag]:
        #print ('k', k)
        k += 1
    ans = lst[flag]
    #print ('ans=', ans)
    flag += 1
    if k == K:
        ans = ''.join(ans)
        print(ans)
        check = not check

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
K = int(input())

lst = []
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
#        print ('i, j=', i, j)
        lst += [s[i:j]]

lst.sort()
#print (lst)
k = 0
flag = 0
ans = str()
check = True
while check:
    if ans != lst[flag]:
        #print ('k', k)
        k += 1
    ans = lst[flag]
    #print ('ans=', ans)
    flag += 1
    if k == K:
        for l in ans:
            print (l, end ='')
        check = not check
print ()


Fixed submission:
#全探索-->len(s) = 50程度までしか通らない
s = list(input())
K = int(input())

lst = []
for i in range(len(s)):
    for j in range(i+1, min(len(s)+1, i+1+K)):
#        print ('i, j=', i, j)
        lst += [s[i:j]]

lst.sort()
#print (lst)
k = 0
flag = 0
ans = str()
check = True
while check:
    if ans != lst[flag]:
        #print ('k', k)
        k += 1
    ans = lst[flag]
    #print ('ans=', ans)
    flag += 1
    if k == K:
        ans = ''.join(ans)
        print(ans)
        check = not check
Buggy python submission (verdict: Runtime Error):
S = list(input())

a = 'abcdefghijklmnopqrstuvwxyz'
if len(S) != 26:
    for i in range(26):
        if not a[i] in S:
            print (*S, sep = '', end = '')
            print (a[i])
            exit()

for i in range(25, 0, -1):
    if ord(S[i]) < ord(S[i - 1]):
        continue
    else:
        break
# print (i)
if i == 1:
    print (-1)
    print (A)
    exit()

tmp_n = ord('z')
for j in S[i:]:
    if ord(j) > ord(S[i - 1]):
        tmp_n = min(tmp_n, ord(j))

print (*S[:i - 1], sep = '', end = '')
print (chr(tmp_n))

Fixed submission:
S = list(input())

a = 'abcdefghijklmnopqrstuvwxyz'
if len(S) != 26:
    for i in range(26):
        if not a[i] in S:
            print (*S, sep = '', end = '')
            print (a[i])
            exit()

for i in range(25, -1, -1):
    if i == -1:
        break
    if ord(S[i]) < ord(S[i - 1]):
        continue
    else:
        break
# print (i)
if i == 0:
    print (-1)
    exit()

tmp_n = ord('z')
for j in S[i:]:
    if ord(j) > ord(S[i - 1]):
        tmp_n = min(tmp_n, ord(j))

print (*S[:i - 1], sep = '', end = '')
print (chr(tmp_n))

Buggy python submission (verdict: Runtime Error):
S = list(input())

#最後かどうかのチェック
final = 'zyxwvutsrqponmlkjihgfedcba'
flag = True
for i in range(len(S)):
    if S[i] == final[i]:
        pass
    else:
        flag = False
        break

if flag and len(S) == 26:
    print (-1)
    exit()

a = 'abcdefghijklmnopqrstuvwxyz'
if len(S) != 26:
    for i in range(26):
        if not a[i] in S:
            print (*S, a[i], sep = '')
            exit()

Fixed submission:
S = list(input())

a = 'abcdefghijklmnopqrstuvwxyz'
if len(S) != 26:
    for i in range(26):
        if not a[i] in S:
            print (*S, sep = '', end = '')
            print (a[i])
            exit()

for i in range(25, -1, -1):
    if i == -1:
        break
    if ord(S[i]) < ord(S[i - 1]):
        continue
    else:
        break
# print (i)
if i == 0:
    print (-1)
    exit()

tmp_n = ord('z')
for j in S[i:]:
    if ord(j) > ord(S[i - 1]):
        tmp_n = min(tmp_n, ord(j))

print (*S[:i - 1], sep = '', end = '')
print (chr(tmp_n))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())

count = 0
for a in range(1,N+1):
    for b in range(1,N+1):
        if a%b >= K:
            count += 1

print (count)


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

ans = 0
for b in range(1, N+1): #bを全探索
    amari = max(b-K, 0)
    count = N // b
    # print ('b=', b)
    # print (count * amari + max(N%b - K + 1, 0))
    ans += count * amari + max(N%b - K + 1, 0)

if K == 0:
    ans -= N
print (ans)





#以下単純な全探索O(N^2)となり間に合わない
# count = 0
# for a in range(1,N+1):
#     for b in range(1,N+1):
#         if a%b >= K:
#             count += 1

# print (count)