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

Fixed submission:
from sys import exit
from collections import defaultdict as dd
h, w, m = map(int, input().split())

#dic[row, col] -> set(ids)
h_dic = dd(int)
w_dic = dd(int)
spot = set()

for i in range(m):
    h_c, w_c = map(int, input().split())
    h_dic[h_c] += 1
    w_dic[w_c] += 1
    spot.add((h_c, w_c))
#print(h_dic, w_dic)

#H_lis -> [i, num_spot(int)]
max_h_num = 0
for key, val in h_dic.items():
    max_h_num = max(max_h_num, val)
max_w_num = 0
W_lis = []
for key, val in w_dic.items():
    max_w_num = max(max_w_num, val)


#print(H_lis, W_lis)
#print(max_h)

ans = 0
max_h_lis = [key for key in h_dic if h_dic[key] == max_h_num]
max_w_lis = [key for key in w_dic if w_dic[key] == max_w_num]
for i in max_h_lis:
    for j in max_w_lis:
        if (i, j) not in spot:
            print(max_h_num + max_w_num)
            exit()
else:
    print(max_h_num + max_w_num - 1)

"""    
max_counter = 0
for i in h_dic.keys():
    for j in w_dic.keys():
        counter = len(h_dic[i] | w_dic[j])
        #print(i, j, h_dic[i] | w_dic[j],counter)
        max_counter = max(max_counter, counter)
print(max_counter)

"""

Buggy submission (verdict: Runtime Error):
from collections import defaultdict as dd
h, w, m = map(int, input().split())

#dic[row, col] -> set(ids)
h_dic = dd(set)
w_dic = dd(set)
spot = set()

for i in range(m):
    h_c, w_c = map(int, input().split())
    h_dic[h_c].add(i)
    w_dic[w_c].add(i)
    spot.add((h_c, w_c))
#print(h_dic, w_dic)

#H_lis -> [i, num_spot(int)]
max_h_num = 0
H_lis = []
for key, val in h_dic.items():
    H_lis.append([key, len(val)])
    max_h_num = max(max_h_num, len(val))
max_w_num = W_lis[0][1]
W_lis = []
for key, val in w_dic.items():
    W_lis.append([key, len(val)])
    max_w_num = max(max_w_num, len(val))


#print(H_lis, W_lis)
#print(max_h)

ans = 0
max_h_lis = [val[0] for val in H_lis if val[1] == max_h_num]
max_w_lis = [val[0] for val in W_lis if val[1] == max_w_num]
for i in max_h_lis:
    for j in max_w_lis:
        count = max_h_num + max_w_num
        if (i, j) in spot:
            count -= 1
        ans = max(ans, count)
print(ans)
Problem p02596 (python)

Fixed submission:
k = int(input())
val = 7
visited = set()
counter = 1
while len(visited) < k:
    val %= k
    if val in visited:
        print(-1)
        break
    elif val % k == 0:
        print(counter)
        break
    else:
        visited.add(val)
        val = (val * 10 + 7) % k
        counter += 1

Buggy submission (verdict: Runtime Error):
k = int(input())
#val = 0
for i in range(k, -1, -1):
    val = int("7" * i)
    #print(val)
    if val % k == 0:
        print(i)
        break
else:
    print(-1)
Problem p02624 (python)

Fixed submission:
n = int(input())
Arr = [0] * (n + 1)
for num in range(1, n+1):
    for i in range(1, n // num + 1):
        Arr[i * num] += 1
ans = 0
for i in range(1, n+1):
    ans += Arr[i] * i
print(ans)

Buggy submission (verdict: Runtime Error):
import copy
from sys import exit
from math import ceil
from collections import defaultdict as dd
n = int(input())
yakusuu_dic = dd(lambda: dd(int))
f = [0] * (n+1)
f[1] = 1
f[2] = 2

if n == 1:
    print(1)
    exit()
if n == 2:
    print(5)
    exit()
sosus = [2]

counter = 0
yakusuu_dic[2] = {2: 1}
for num in range(3, n+1):
    #print(num)
    for divider in sosus:
        if num % divider == 0:
            yakusuu_dic[num] = copy.deepcopy(yakusuu_dic[num // divider])
            yakusuu_dic[num][divider] += 1
            if divider in yakusuu_dic[num // divider]:
                f[num] = f[num // divider] // (yakusuu_dic[num // divider][divider] + 1) * (yakusuu_dic[num // divider][divider] + 2)
            else:
                f[num] = f[num // divider] * 2
            break
    else:
        yakusuu_dic[num][num] = 1
        f[num] = 2
        sosus.append(num)

counter = 0
for i in range(1, n+1):
    counter += i * f[i]
print(counter)
Problem p02873 (python)

Fixed submission:
s = input()
n = len(s)
Ans = [0] * (n + 1)

top = set()
bottom = set()
if s[0] == ">":
    top.add(0)
else:
    bottom.add(0)

for i in range(len(s)-1):
    left = s[i]
    right = s[i+1]
    if left == "<" and right == ">":
        top.add(i+1)
    elif left == ">" and right == "<":
        bottom.add(i+1)

if s[n-1] == ">":
    bottom.add(n)
else:
    top.add(n)

for b in list(bottom):
    counter = 0
    for i in range(b, n+1):
        if i in top:
            break
        else:
            Ans[i] = counter
            counter += 1

    counter = 0
    for i in range(b-1, -1, -1):
        if i in top:
            break
        else:
            Ans[i] = counter + 1
            counter += 1
#print(Ans)

for t in list(top):
    if t == 0:
        Ans[0] = Ans[1] + 1
    if t == n:
        Ans[n] = Ans[n-1] + 1
    else:
        Ans[t] = max(Ans[t-1] + 1, Ans[t+1] + 1)

#print(top)
#print(bottom)
print(sum(Ans))

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)
Ans = [None] * (n + 1)

top = set()
bottom = set()
if s[0] == ">":
    top.add(0)
else:
    bottom.add(0)

for i in range(len(s)-1):
    left = s[i]
    right = s[i+1]
    if left == "<" and right == ">":
        top.add(i+1)
    elif left == ">" and right == "<":
        bottom.add(i+1)

if s[n-1] == ">":
    bottom.add(n)
else:
    top.add(n)

for b in list(bottom):
    counter = 0
    for i in range(b, n+1):
        if i in top:
            break
        else:
            Ans[i] = counter
            counter += 1

    counter = 0
    for i in range(b-1, -1, -1):
        if i in top:
            break
        else:
            Ans[i] = counter + 1
            counter += 1
#print(Ans)

for t in list(top):
    if t == 0:
        Ans[0] = Ans[1] + 1
    if t == n:
        Ans[n] = Ans[n-1] + 1
    else:
        Ans[t] = max(Ans[t-1] + 1, Ans[t+1] + 1)

#print(top)
#print(bottom)
print(sum(Ans))
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print("red")

Buggy submission (verdict: Runtime Error):
def main():
	inp = [int(input()) for i in range(2)]
	a = inp[0]
	s = inp[1]
	red = "red"

  if a < 3200:
    print red
  else:
    print s

Buggy submission (verdict: Runtime Error):
inp = [int(input()) for i in range(2)]
a = inp[0]
s = inp[1]
red = "red"

if a < 3200:
  print red
else:
  print s
Problem p02984 (python)

Fixed submission:
from collections import defaultdict as dd

n = int(input())
A = list(map(int, input().split()))
odd_ac = dd(int)
even_ac = dd(int)
for i, a in enumerate(A):
    if i % 2 == 0:
        even_ac[i] = even_ac[i-2] + a
    else:
        odd_ac[i] = odd_ac[i-2] + a
#print(odd_ac)
#print(even_ac)

ans = []
for dam in range(n):
    is_odd = dam % 2
    total = 0
    if is_odd:
        total += odd_ac[n-2] - odd_ac[dam-2]
        total -= even_ac[n-1] - even_ac[dam-1]
        total += even_ac[dam-1]
        total -= odd_ac[dam-2]
    else:
        total += even_ac[n-1] - even_ac[dam-2]
        total -= odd_ac[n-2] - odd_ac[dam-1]
        total -= even_ac[dam-2]
        total += odd_ac[dam-1]

    ans.append(total)

print(*ans, sep=" ")

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
A = list(map(int, input().split()))
Arr = np.zeros((n, n))
for i in range(0, n-1):
    Arr[i][i] = 0.5
    Arr[i][i+1] = 0.5
Arr[n-1][n-1] = 0.5
Arr[n-1][0] = 0.5
#print(Arr)

inv_Arr = np.linalg.inv(Arr)
#print(inv_Arr)

ans = np.dot(inv_Arr, A)
ans = list(map(int, ans))
print(*ans, sep=" ")
Problem p03038 (python)

Fixed submission:
from collections import defaultdict as dd
from collections import deque
from collections import Counter as cnt
import bisect
n, m = map(int, input().split())
A = list(map(int, input().split()))
temoti_dic = cnt(A)

add_card_dic = dd(lambda: 0)
for i in range(m):
    b, c = map(int, input().split())
    add_card_dic[c] += b

temoti_dq = deque(sorted(temoti_dic.keys()))

total = 0
for add_card in sorted(add_card_dic.keys(), reverse=True):
    pointer = bisect.bisect_left(temoti_dq, add_card)
    #print(temoti_dic, temoti_dq, add_card, add_card_dic[add_card], pointer)
    if pointer == 0:
        break
    else:
        i = 0
        add_card_num = add_card_dic[add_card]
        while add_card_num > 0 and i < pointer:
            least_temoti = temoti_dq[0]
            least_temoti_num = temoti_dic[least_temoti]
            if least_temoti_num <= add_card_num:
                total += least_temoti_num * add_card
                temoti_dq.popleft()
                del temoti_dic[least_temoti]
                add_card_num -= least_temoti_num
            else:
                temoti_dic[least_temoti] -= add_card_num
                total += add_card_num * add_card
                add_card_num = 0
            i += 1

#print(temoti_dic)
for key in temoti_dq:
    total += key * temoti_dic[key]

print(total)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict as dd
import bisect
n, m = map(int, input().split())
A = sorted(list(map(int, input().split())))
BC = dd(lambda: 0)
for i in range(m):
  b, c = map(int, input().split())
  BC[b] += c
print(BC)  

right_dic = {}
leht_dic = {}
for key in sorted(BC.keys(), reverse=True):
Problem p03253 (python)

Fixed submission:
from collections import defaultdict as dd
from sys import exit
import math
n, m = map(int, input().split())
dic = dd(int)

#M=1
if m == 1:
    print(1)
    exit()

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(2, math.ceil(m**0.5) + 3):
    while m % i == 0:
        m //= i
        dic[i] += 1
if m != 1:
    dic[m] = 1
#print(dic)

ans = 1
mod = 10**9 + 7
for count in dic.values():
    ans *= combinations_count(count + n - 1, n-1) % mod

print(ans % mod)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict as dd
import sys
import math
n, m = map(int, input().split())
dic = dd(int)

#M=1
if m == 1:
    print(1)
    sys.exit()
elif n == 1:
    print(1)
    sys.exit()

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(2, math.ceil(m**0.5) + 3):
    while m % i == 0:
        m //= i
        dic[i] += 1
else:
    m != 1:
        dic[m] = 1
#print(dic)

ans = 1
mod = 10**9 + 7
for count in dic.values():
    ans *= combinations_count(count + n - 1, n-1) % mod

print(ans % mod)
Problem p03775 (python)

Fixed submission:
import sys
n = int(input())
if n == 1:
  print(1)
  sys.exit()
min_max = 1000
for div in range(1, int(n**(0.5) + 1)):
  if n % div == 0:
    a = div
    b = n // div
    fx = max(len(str(a)), len(str(b)))
    min_max = min(min_max, fx)
print(min_max)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n == 1:
  print(0)
else:
  PFs = []
  PNs = []
  for div in range(2, int(n**(0.5) + 1)):
    for pn in PNs:
      if div % pn == 0:
        break
    else:
      PNs.append(div)
      while n % div == 0:
        n /= div
        PFs.append(div)
if len(PFs) == 0:
  PFs = [n]
#print(PFs)
  
Pats = [[]]
for i in range(len(PFs)):
  temp = []
  for pat in Pats:
    temp.append(pat + [0])
    temp.append(pat + [1])
  Pats = temp
  
min_max = 1000000000000000
for pat in Pats:
  a = 1
  b = 1
  for i, num in enumerate(pat):
    if num == 0:
      a *= PFs[i]
    else:
      b *= PFs[i]
#  print(a, b, pat)
  fx = max(len(str(a)), len(str(b)))
  min_max = min(min_max, fx)
print(min_max)
Problem p03776 (python)

Fixed submission:
from math import factorial
n, a, b = map(int, input().split())
V = sorted(map(int, input().split()), reverse=True)

av = sum(V[:a]) / a
print(av)

def comb(m, k):
    ans = 1
    if k == 0:
        return 1
    else:
        for i in range(k):
            ans *= m - i
            ans //= i + 1
        return ans

num = V[a]
m = V.count(num)
k = V[:a].count(num)
#print(m, k, a)
if a != k:
    ans = factorial(m) // (factorial(k) * factorial(m - k))
else:
    #mCi(i:　a=>b)
    ans = 0
    for k in range(a, b+1):
        ans += comb(m, k)
print(ans)

Buggy submission (verdict: Runtime Error):
from math import factorial
n, a, b = map(int, input().split())
V = sorted(map(int, input().split()), reverse=True)

av = sum(V[:a]) / a
print(av)

num = V[a]
m = V.count(num)
k = V[:a].count(num)
#print(m, k, a)
if a != k:
    ans = factorial(m) // (factorial(k) * factorial(m - k))
else:
    ans = 0
    for i in range(a, b+1):
        ans += factorial(m) // (factorial(i) * factorial(m - i))

print(ans)
Problem p02955 (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)

    divisors.sort(reverse=True)
    return divisors


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

div = make_divisors(sum(a))

for x in div:
    aa = [ai % x for ai in a]
    aa.sort()
    ss = aa[:len(aa) - sum(aa) // x]
    s = sum(ss)

    if 0 <= s <= k:
        print(x)
        break

# 2 | 3 5 | 8 _ 3
# 3 | 3 1 2 1 | 7 _ 4
# 4 | 1 2 0 1 3 2 1 0 | 10 _ 5

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


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)

    divisors.sort(reverse=True)
    return divisors


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

div = make_divisors(sum(a))

for x in div:
    s = sum([ai % x for ai in a])

    if s % 2 == 1:
        s -= k

    if s % 2 == 0 and 0 <= s <= 2 * k:
        print(x)
        break

# 3 | 3 1 2 1 | 7
# 4 | 1 2 0 1 3 2 1 0 | 10
Problem p02984 (python)

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

res = []
s = 0
for i in range(n):
    s += a[i] * [-1, 1][i % 2 ==0]
res.append(s)

for i in range(1, n):
    res.append(2*a[i-1] - res[i-1])

print(' '.join(map(str, res)))

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

res = []
s = 0
for i in enumerate(range(n)):
    s += a[i] * [-1, 1][i % 2 ==0]
res.append(s)

for i in range(1, n):
    res.append(a[i] - 2*res[i-1])

print(' '.join(map(str, res)))
Problem p02987 (python)

Fixed submission:
from collections import Counter; print("YNeos"[list(Counter(list(input())).values()) != [2,2]::2])

Buggy submission (verdict: Runtime Error):
from collections import Collecter; print('YNeos'[Counter(sorted(list(input()))).values() != [2,2]::2])
Problem p02989 (python)

Fixed submission:
input()
a = sorted(list(map(int, input().split())))
print(a[len(a)//2] - a[len(a)//2 - 1])

Buggy submission (verdict: Runtime Error):
a = sorted(list(map(int, input().split())))
print(a[len(a)] - a[len(a)-1])
Problem p02990 (python)

Fixed submission:
n, k = map(int, input().split())
mod = 10**9+7
C = [[1], [1,1]]
for i in range(2, n+10):
  C.append([1] + [(C[i-1][j-1] + C[i-1][j])%mod for j in range(1, i)] + [1])
for i in range(1, k+1):
  if n-k+1 < i or k < i:
    print(0)
  else:
    print((C[n-k+1][i] * C[k-1][i-1])%mod)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
mod = 10**9+7
C = [[1], [1,1]]
for i in range(2, n+10):
  C.append([1] + [(C[i-1][j-1] + C[i-1][j])%mod for j in range(1, i)] + [1])
for i in range(1, k+1):
  print((C[n-k+1][i] * C[k-1][i-1])%mod)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
C = [[1], [1,1]]
for i in range(2, n+10):
  C.append([1] + [C[i-1][j-1] + C[i-1][j] for j in range(1, i)] + [1])
for i in range(1, k+1):
  print(C[n-k+1][i] * C[k-1][i-1])

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
C = [[1], [1,1]]
for i in range(2, n):
  C.append([1])
  for j in range(1, i):
    C[i].append(C[i-1][j-1] + C[i-1][j])
for i in range(1, k+1):
  print(C[n-k+1][i] * C[k-1,i-1])

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
C = [[1], [1,1]]
for i in range(2, n):
  C.append([1])
  for j in range(1, i):
    C[i].append(C[i-1, j-1] + C[i-1, j])
for i in range(1, k+1):
  print(C[n-k+1][i] * C[k-1,i-1])
Problem p03038 (python)

Fixed submission:
from bisect import bisect_right

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

res = 0
fin = 0
for b, c in bc:
    count = bisect_right(a, c, lo=fin, hi=min(fin+b, len(a))) - fin
    fin += count
    res += count * c
for i in range(fin, len(a)):
    res += a[i]

print(res)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_right

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

res = 0
for b, c in bc:
    count = bisect_right(a, c, hi=b)
    res += count * c
    if count < len(a):
        a = a[count:]
    else:
        a = []
        break

print(res + sum(a))

Buggy submission (verdict: Runtime Error):
from bisect import bisect_right

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

res = 0
for b, c in bc:
    if len(a) == 0:
        break
    count = bisect_right(a, c, hi=b)
    res += count * c
    a = a[count:]

print(res + sum(a))
Problem p02557 (python)

Fixed submission:
from collections import Counter, deque

N = int(input())
A = list(map(int, input().split())) + [N+1]
B = list(map(int, input().split())) + [N+1]
C = [0]
D = [0]

AB_cn = Counter(A+B)
if AB_cn.most_common()[0][1] > N:
    print("No")
else:
    print("Yes")
    for i in range(N+1):
        if len(C) != A[i]:
            C.extend([i]*(A[i]-len(C)))
        if len(D) != B[i]:
            D.extend([i]*(B[i]-len(D)))
    ans = 0
    for i in range(N):
        curr = C[i+1] - D[i]
        ans= max(curr, ans)
    B = B[:-1]
    ans = [B[(i-ans)%N] for i in range(N)]
 
    print(*ans)

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

N = int(input())
A = list(map(int, input().split())) + [N+1]
B = list(map(int, input().split())) + [N+1]
C = [0]
D = [0]

AB_cn = Counter(A+B)
if AB_cn.most_common()[0][1] > N:
    print("No")
else:
    print("Yes")
    for i in range(N+1):
        if len(C) != A[i]:
            C.extend([i]*(A[i]-len(C)))
        if len(D) != B[i]:
            D.extend([i]*(B[i]-len(D)))
    ans = 0
    for i in range(N):
        curr = C[i+1] - D[i]
        ans= max(curr, ans)
    B = B[:-1]
    ans = [B[(i-x)%N] for i in range(N)]
 
    print(*ans)

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

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_cn = Counter(A)
B_cn = Counter(B)
AB_cn = Counter(A+B)
if AB_cn.most_common()[0][1] > N:
    print("No")
else:
    print("Yes")
    b = deque(B)
    ans_dict = {}
    cntr = 0
    while b:
        if cntr not in ans_dict:
            c = b.pop()
            if A[cntr] != c:
                ans_dict[cntr] = c
            else:
                b.pushleft(c)
        cntr += 1
        cntr %= N
    ans = []
    for i in range(N):
        ans += [ans_dict[i]]
    print(*ans)

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

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_cn = Counter(A)
B_cn = Counter(B)
AB_cn = Counter(A+B)
if AB_cn.most_common()[0][1] > N:
    print("No")
else:
    print("Yes")
    b = deque(B)
    ans_dict = {}
    cntr = 0
    while b:
        if cntr not in ans_dict:
            c = b.pop()
            if A[cntr] != c:
                ans_dict[cntr] = c
            else:
                b.pushleft(c)
            cntr += 1
            cntr %= N
    ans = []
    for i in range(N):
        ans += [ans_dict[i]]
    print(*ans)

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

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_cn = Counter(A)
B_cn = Counter(B)
AB_cn = Counter(A+B)
if AB_cn.most_common()[0][1] > N:
    print("No")
else:
    print("Yes")
    0/0

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

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_cn = Counter(A)
B_cn = Counter(B)
AB_cn = Counter(A+B)
if AB_cn.most_common()[0][1] > 2*N:
    print("No")
else:
    print("Yes")
    0/0
Problem p02570 (python)

Fixed submission:
D, S, T = map(int, input().split())
if S*T >= D:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
a = (sum(A)**2)
b =  sum([(a**2) for a in A])
print(((a-b)%(10**9+7))//2)
Problem p02596 (python)

Fixed submission:
K = int(input())

i = 7%K
se = set([i])
cnt = 1
while True:
  if i == 0:
    print(cnt)
    break
  cnt += 1
  i = (i*10 + 7)%K
  if i in se:
    print(-1)
    break
  else:
    se.add(i)

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

i = 7%K
se = set(i)
cnt = 1
while True:
  if i == 0:
    print(cnt)
    break
  cnt += 1
  i = (i*10 + 7)%K
  if i in se:
    print(-1)
    break
  else:
    se.add(i)
Problem p02624 (python)

Fixed submission:
N= int(input())
ans = 0
for j in range(1,N+1):
  N_j = N//j
  ans += j*(1+N_j)*N_j//2
print(ans)

Buggy submission (verdict: Runtime Error):
N= int(input())
ans = 0
for j in range(N):
  N_j = N//j
  ans += j*(1+N_j)*N_j//2
print(ans)
Problem p02685 (python)

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

if M == 1 :
    if K == N-1:
        print(1)
    else:
        print(0)
    sys.exit()

def power_func(a, n, p):
    bi = str(format(n,"b"))#2進表現に
    if a == 0:
        return 0
    res = 1
    for i in range(len(bi)):
        res = (res*res) % p
        if bi[i] == "1":
            res = (res*a) % p
    return res

P = 998244353
inv_t = [0] + [1]
for i in range(2, max(M,K)+2):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

ans = (M * power_func(M-1, N-1, P))%P
curr = ans
for k in range(K):
    curr = (curr*(N-k-1)*inv_t[k+1]*inv_t[M-1]) % P
    ans += curr
    ans %= P

print(ans)

Buggy submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
if M == 1:
    0/0

def power_func(a, n, p):
    bi = str(format(n,"b"))#2進表現に
    if n == 0:
        return 1
    if a == 0:
        return 0
    res = 1
    for i in range(len(bi)):
        res = (res*res) % p
        if bi[i] == "1":
            res = (res*a) % p
    return res

P = 998244353
inv_t = [0] + [1]
for i in range(2, max(M,K)+2):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

ans = (M * power_func(M-1, N-1, P))%P
curr = ans
for k in range(K):
    curr = (curr*(N-k-1)*inv_t[k+1]*inv_t[M-1]) % P
    ans += curr
    ans %= P

print(ans)

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


def power_func(a,n,p):
    bi = str(format(n,"b"))#2進表現に
    res = 1
    for i in range(len(bi)):
        res = (res*res) % p
        if bi[i] == "1":
            res = (res*a) % p
    return res

P = 998244353
inv_t = [0] + [1]
for i in range(2, N+2):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

ans = (M * power_func(M-1, N-1, P))%P
curr = ans
for k in range(K):
    curr = (curr*(N-k-1)*inv_t[k+1]*inv_t[M-1]) % P
    ans += curr
    ans %= P

print(ans)

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


def power_func(a,n,p):
    bi = str(format(n,"b"))#2進表現に
    res = 1
    for i in range(len(bi)):
        res = (res*res) % p
        if bi[i] == "1":
            res = (res*a) % p
    return res

P = 998244353
inv_t = [0] + [1]
for i in range(2, N+2):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

ans = (M * power_func(M-1, N-1, P))%P
curr = ans
for k in range(K):
    N-k-1 < 0 : break
    curr = (curr*(N-k-1)*inv_t[k+1]*inv_t[M-1]) % P
    ans += curr
    ans %= P

print(ans)