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

Fixed submission:
import time

t0 = time.time()

h,w,m = map(int,input().split())
H = [0]*(h+1)
W = [0]*(w+1)
s = set([])
for i in range(m):
    a,b = map(int,input().split())
    s.add((a,b))

    H[a] += 1
    W[b] += 1

x = [0]*(h+1)
y = [0]*(w+1)
    
for i in range(h+1):
    x[i] = [i,H[i]]
for i in range(w+1):
    y[i] = [i,W[i]]

x.sort(key= lambda val : val[1],reverse=True)
y.sort(key= lambda val : val[1],reverse=True)

ma = x[0][1]
mb = y[0][1]

i,j = 0,0
sw = 0
while 1:
    if j > w:
        break
    if  x[i][1] == ma:
        if (x[i][0],y[j][0]) in s:
            pass
        else:
            if x[i][1]+y[j][1] == ma+mb:
                sw = 1
                break
        i += 1
    else:
        i = 0
        j += 1
    if time.time() - t0 > 2.5:
        break

    
print(ma+mb+sw-1)

Buggy submission (verdict: Runtime Error):
h,w,m = map(int,input().split())
h = [0]*m
H = [0]*(h+1)
W = [0]*(w+1)
s = set([])
for i in range(m):
    a,b = map(int,input().split())
    h[i] = [a,b]
    s.add([a,b])

    H[a] += 1
    W[b] += 1

x = [0]*(h+1)
y = [0]*(w+1)
    
for i in range(h+1):
    x[i] = [i,H[i]]
for i in range(w+1):
    y[i] = [i,W[i]]

x.sort(key= lambda val : val[1],reverse=True)
y.sort(key= lambda val : val[1],reverse=True)

ma = x[0][1]
mb = y[0][1]
i,j = 0,0
sw = 0
while 1:
    if (x[i][0],y[j][0]) in s:
        pass
    else:
        sw = 1
        break
    if x[i][1] + y[j][1] != ma+mb:
        break
    
    if x[i+1][1]!= ma:
        j += 1
    else:
        i += 1
print(ma+mb+sw)
Problem p02598 (python)

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
s = sum(a)
x = [0]*n
y = 0
r = 0
for i in range(n):
    y = int(a[i]/s*k)
    x[i] = [i, y, a[i]/(y+1), a[i]]
    r += y
x.sort(key= lambda val : val[2],reverse=True)
for i in range(k-r):
    x[i][1] += 1
ans = 0
for i in range(n):
    ans = max(ans, x[i][3]/(x[i][1]+1))
print(int(-(-ans//1)))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a,reverse=True)
s = sum(a)
x = [0]*n
y = 0
for i in range(n):
    y = int(a[i]/s*k)
    x[i] = [i, (a[i]/s*k)%1, y]

x.sort(key= lambda val : val[1],reverse=True)
for i in range(k-y):
    x[i][2] += 1
ans = 0
z = 0
for i in range(n):
    ans = max(ans, a[x[i][0]-1]/(x[i][2]+1))
    z += x[i][2]
print(int(-(-ans//1)))
Problem p02629 (python)

Fixed submission:
n = int(input())
ans = []

s = 0
while 1:
    if s == 1 and n < 1:
        break
    s = 1
    if n%26 == 0:
        ans.append(0)
    else:
        ans.append(n%26)
    n -= n%26
    n = n//26
for i in range(len(ans)):
    if i != len(ans)-1:
        if ans[i] <= 0:
            ans[i+1] -= 1
            ans[i] += 26
    else:
        if ans[i] <= 0:
            del ans[i]
ans = ans[::-1]
for i in range(len(ans)):
    print(chr(96+ans[i]),end="")
print("")

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

s == 0
while 1:
    if s == 1 and n < 1:
        break
    s = 1
    if n%26 == 0:
        ans.append(0)
    else:
        ans.append(n%26)
    n -= n%26
    n = n//26
for i in range(len(ans)):
    if i != len(ans)-1:
        if ans[i] <= 0:
            ans[i+1] -= 1
            ans[i] += 26
    else:
        if ans[i] <= 0:
            del ans[i]
ans = ans[::-1]
for i in range(len(ans)):
    print(chr(96+ans[i]),end="")
print("")
Problem p02659 (python)

Fixed submission:
a,b = map(str,input().split())
from decimal import Decimal
print(int(Decimal(a)*Decimal(b)))

Buggy submission (verdict: Runtime Error):
import numpy as np
a,b = map(float,input().split())
 
c = np.array([a],dtype='f16')
d = np.array([b],dtype='f16')
e = np.array([],dtype='f16')
e = c*d
print(int(e))
Problem p02682 (python)

Fixed submission:
a,b,c,k = map(int,input().split())
if a>k:
    print(k)
elif a+b >= k:
    print(a)
else:
    print(a-(k-a-b))

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

x = [1]*a+[0]*b+[-1]*c
print(sum(x[:k]))
Problem p02688 (python)

Fixed submission:
n,k = map(int,input().split())
d = [0]*k
a = [0]*k
s = []
for i in range(k):
    d[i] = int(input())
    a[i] = list(map(int,input().split()))
    s.extend(a[i])
d = set(s)
print(n-len(d))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
d = [0]*n
a = [0]*n
s = []
for i in range(k):
    d[i] = int(input())
    a[i] = list(map(int,input().split()))
    s.extend(a[i])
d = set(s)

print(n-len(d))
Problem p02689 (python)

Fixed submission:
n,m = map(int,input().split())
h = list(map(int,input().split()))
a = [0]*m
b = [0]*m
for i in range(m):
    a[i],b[i] = map(int,input().split())
sw = [1]*n
for i in range(m):
    if h[a[i]-1] > h[b[i]-1]:
        sw[b[i]-1] = 0
    elif h[a[i]-1] < h[b[i]-1]:
        sw[a[i]-1] = 0
    else:
        sw[a[i]-1] = 0
        sw[b[i]-1] = 0
print(sw.count(1))

Buggy submission (verdict: Runtime Error):
a = [0]*m
b = [0]*m
t = []
y = []
for i in range(m):
    a[i],b[i] = map(int,input().split())
    c = str(a[i])+" "+str(b[i])
    y.append(c)
t.extend(a)
t.extend(b)
s = [0]*m
count = 0
sw = [0]*n
ab = list(y)
for i in range(m):
    a[i],b[i] = ab[i].split()
    a[i] = int(a[i])
    b[i] = int(b[i])
    if  h[a[i]-1] >= h[b[i]-1] and sw[a[i]-1] == 0:
        if sw[b[i]-1] == 1 or sw[a[i]-1] == 1:
            count -= 1
        count += 1
        sw[a[i]-1] = 1
    elif h[a[i]-1] < h[b[i]-1] and sw[b[i]-1] == 0:
        if sw[a[i]-1] == 1 or sw[b[i]-1] == 1:
            count -= 1
        count += 1
        sw[b[i]-1] = 1
print(count+n-len(set(t)))
Problem p02831 (python)

Fixed submission:
def gcd(a, b):
    if a<b:
        a,b = b,a
    r = a%b
    while r != 0:
        a = b
        b = r
        r = a % b
    return b
a,b = map(int,input().split())
print(a * b // gcd(a, b))

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

Fixed submission:
n,m = map(int,input().split())
a = [0]*m
for i in range(m):
    a[i] = int(input())
s = 1
for i in range(m-1):
    if a[i+1] - a[i] == 1:
        s = 0
        break
if s == 0:
    print(0)
else:
    dp = [0]*(n+1)
    j = 0
    dp[0] = 1
    dp[1] = 1
    a = a + [-1]
    for i in range(n-1):
        if a[j] == i+1:
            dp[i+2] = dp[i]
        elif a[j] == i:
            dp[i+2] = dp[i+1]
            j += 1
        else:
            dp[i+2] = dp[i+1] + dp[i]
    print(dp[-1]%1000000007)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [0]*m
for i in range(m):
    a[i] = int(input())
s = 1
for i in range(m-1):
    if a[i+1] - a[i] == 1:
        s = 0
        break
if s == 0:
    print(0)
else:
    dp = [0]*(n+1)
    j = 0
    dp[0] = 1
    dp[1] = 1
    a = a + [0]
    for i in range(n-1):
        if a[j] == i+1:
            dp[i+2] = dp[i]
        elif a[j] == i:
            dp[i+2] = dp[i+1]
            j += 1
        else:
            dp[i+2] = dp[i+1] + dp[i]
    print(dp[-1]%1000000007)
Problem p03038 (python)

Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = [0]*m
for i in range(m):
    bc[i] = list(map(int,input().split()))
sortsecond = lambda val : val[1]
bc.sort(key=sortsecond,reverse = True)
a = sorted(a)
i = 0
j = 0
count = 0
while a[i] < bc[j][1]:
    a[i] = bc[j][1]
    i += 1
    if i >= len(a):
        break
    count += 1
    if count == bc[j][0]:
        j += 1
        count = 0
        if j>=m:
            break
print(sum(a))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = [0]*m
for i in range(m):
    bc[i] = list(map(int,input().split()))
sortsecond = lambda val : val[1]
bc.sort(key=sortsecond,reverse = True)
a = sorted(a)
i = 0
j = 0
count = 0
while a[i] < bc[j][1]:
    a[i] = bc[j][1]
    i += 1
    count += 1
    if count == bc[j][0]:
        j += 1
        count = 0
        if j>=m:
            break
print(sum(a))
Problem p03329 (python)

Fixed submission:
from collections import deque
n = int(input())
q = deque([])
now = 0
reach = [0]*100001
lis = []
for i in range(6):
    lis.append(6**(i+1))
for i in range(5):
    lis.append(9**(i+1))
lis.append(1)
lis = sorted(lis)
q.append(0)
ans = 0
while q:
    if ans == 1:
        break
    x = q.popleft()
    
    for y in lis:
        if x + y < n:
            if  reach[x+y] == 0:
                q.append(x+y)
                reach[x+y] = reach[x]+1
            
        elif x + y == n:
            reach[x+y] = reach[x]+1
            ans = 1
            break
print(max(reach))

Buggy submission (verdict: Runtime Error):
n = int(input())
dp = [float("Inf")]*(n+1)
for i in range(5):
    dp[i] = i
for i in range(n):
    for j in range(1,n//6+1):
        if i + 6**j > n:
            break
        dp[i+6**j] = min(dp[i+6**j], dp[i] + 1)
    for j in range(1,n//9+1):
        if i + 9**j > n:
            break
        dp[i+9**j] = min(dp[i+9**j], dp[i] + 1)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
dp = [float("Inf")]*(n+1)
dp[0] = 0
for i in range(n):
    if dp[i] == float("Inf"):
        pass
    else:
        for j in range(1,n//6):
            if i + 6**j > n:
                break
            dp[i+6**j] = min(dp[i+6**j], dp[i] + 1)
        for j in range(1,n//9):
            if i + 9**j > n:
                break
            dp[i+9**j] = min(dp[i+9**j], dp[i] + 1)
ans = n
for i in range(n-5, n+1):
    ans = min(ans, dp[i]+n-i)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
dp = [float("Inf")]*(n+1)
dp[0] = 0
for i in range(n):
    if dp[i] == float("Inf"):
        pass
    else:
        for j in range(1,n//6):
            if i + 6**j > n:
                break
            dp[i+6**j] = min(dp[i+6**j], dp[i] + 1)
        for j in range(1,n//9):
            if i + 9**j > n:
                break
            dp[i+9**j] = min(dp[i+9**j], dp[i] + 1)
ans = float("Inf")
for i in range(n-5, n+1):
    ans = min(ans, dp[i]+n-i)
print(ans)
Problem p03834 (python)

Fixed submission:
s = list(input())
s[5] = " "
s[13] = " "
print("".join(s))

Buggy submission (verdict: Runtime Error):
sx,sy,tx,ty = map(int,input().split())
ans = ["U"]*(ty-sy) + ["R"]*(tx-sx) + ["D"]*(ty-sy) + ["L"]*(tx-sx+1) + ["U"]*(ty-sy+1) + ["R"]*(tx-sx+1) + ["D"] + ["R"] + ["D"]*(ty-sy+1) + ["L"]*(tx-sx+1) + ["U"]
print("".join(ans))
Problem p02598 (python)

Fixed submission:
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def cut(A, k, size) -> bool:
    cnt = 0
    for a in A:
        cnt += a // size
        if a % size == 0:
            cnt -= 1
        if cnt > k:
            return False
    if cnt <= k:
        return True


def main():
    n, k = input_int_list()
    A = input_int_list()

    left = 0
    right = max(A)

    while right > left + 1:
        mid = (left + right) // 2
        res = cut(A, k, mid)
        if res:
            right = mid
        else:
            left = mid
    print(right)
    return


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def cut(A, k, size) -> bool:
    cnt = 0
    for a in A:
        cnt += a // size
        if a % size == 0:
            cnt -= 1
        if cnt > k:
            return False
    if cnt <= k:
        return True


def main():
    n, k = input_int_list()
    A = input_int_list()

    left = 0
    right = max(A)

    fail = 0
    success = right

    while True:
        mid = (left + right) // 2
        res = cut(A, k, mid)
        if res:
            right = mid - 1
            success = min(mid, success)
        else:
            left = mid + 1
            fail = max(mid, fail)
        if left == right:
            break
    print(success)
    return


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

Fixed submission:
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N = int(input())
    a_l = [int(i) for i in input().split()]
    if 1 not in a_l:
        print(-1)
        sys.exit()
    counter = 1
    b = 0
    for i in a_l:
        if i == counter:
            counter += 1
        else:
            b += 1
    print(b)
    sys.exit()


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    a_l = [int(i) for i in input().split()]
    if 1 not in a_l:
        print(-1)
        sys.exit()
    counter = 1
    b = 0
    for i in a_l:
        if i == counter:
            counter += 1
        else:
            b += 1
    print(b)
    sys.exit()


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

Fixed submission:
from itertools import groupby


def main():

    S = input()
    K = int(input())
    a = [len(tuple(s)) for _, s in groupby(S)]
    ans = 0

    if S[0] == S[-1] and K > 1:
        if len(a) == 1:
            ans = a[0] * K // 2
        else:
            ans = a[0] // 2 + a[-1] // 2 + (a[0] + a[-1]) // 2 * (K - 1)
            ans += sum(n // 2 for n in a[1:-1]) * K
    else:
        ans = sum(n // 2 for n in a) * K
    print(ans)


if __name__ == "__main__":
    main()

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


def main():
    S = input().strip()
    K = int(input())
    grouped = [len(tuple(s)) for _, s in groupby(S)]

    if len(grouped) > 1 and S[0] == S[-1]:
        _sum = 0
        top = grouped[0]
        tail = grouped[-1]
        for group in grouped[1:-1]:
            _sum += group[1] // 2
        dif = (top // 2) + (tail // 2) + (top + tail) * (K - 1) // 2
        print(_sum * K + dif)
    else:
        _sum = 0
        for group in grouped:
            _sum += group[1] // 2
        print(_sum * K)


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

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

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    tmp = 0
    ans = [0] * n
    f = 1
    for i in a:
        tmp += f * i
        f = f * -1
    ans[0] = tmp
    ans[n - 1] = 2 * a[n - 1] - ans[0]
    for i in range(n - 2, 0, -1):
        ans[i] = 2 * a[i] - ans[i + 1]

    print(" ".join([str(i) for i in ans]))


if __name__ == "__main__":
    main()

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


class GaussElimination:
    def __init__(self, a):
        self.a = a
        self.n = len(self.a)

    def exec(self):
        try:
            for k in range(self.n - 1):
                for i in range(k + 1, self.n):
                    d = self.a[i][k] / self.a[k][k]
                    for j in range(k + 1, self.n + 1):
                        self.a[i][j] -= self.a[k][j] * d
            for i in range(self.n - 1, -1, -1):
                d = self.a[i][self.n]
                for j in range(i + 1, self.n):
                    d -= self.a[i][j] * self.a[j][self.n]
                self.a[i][self.n] = d / self.a[i][i]
        except Exception:
            raise


def main():
    N = int(input())
    A = [int(i) for i in input().strip().split()]
    matrix = [[0] * (N + 1) for _ in range(N)]
    for i in range(N):
        if i == N - 1:
            matrix[N - 1][0] = 1
            matrix[N - 1][N - 1] = 1
        else:
            matrix[i][i] = 1
            matrix[i][i + 1] = 1
        matrix[i][N] = A[i]
    gauss = GaussElimination(matrix)
    gauss.exec()
    ans = []
    for i in range(N):
        ans.append(str(int(gauss.a[i][N] * 2)))
    print(" ".join(ans))


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

Fixed submission:
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, a, b, c, d = input_int_list()
    S = input()

    for i in range(a - 1, max(c, d) - 1):
        if S[i] == S[i + 1] == "#":
            print("No")
            quit()
    if c < d:
        print("Yes")
        quit()
    if c > d:
        for i in range(b - 2, d - 1):
            if S[i: i + 3] == "...":
                print("Yes")
                quit()
        print("No")
        quit()


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, a, b, c, d = input_int_list()
    S = input()

    for i in range(a - 1, max(c, d) - 1):
        if S[i] == S[i + 1] == "#":
            print("No")
            quit()
    if c < d:
        print("Yes")
        quit()
    if c > d:
        for i in range(b - 2, d - 1):
            if S[i, i + 3] == "...":
                print("Yes")
                quit()
        print("No")
        quit()


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

Fixed submission:
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    from collections import deque

    h, w = input_int_list()
    grid = []
    visited = []
    grid.append(["@"] * (w + 2))
    visited.append([True] * (w + 2))
    for _ in range(h):
        grid.append(["@"] + list(input()) + ["@"])
        visited.append([True] + [False] * w + [True])
    grid.append(["@"] * (w + 2))
    visited.append([True] * (w + 2))

    # 幅優先探索で すべてを"#"に変える。
    # かかった手数分が答え
    direction = ((0, 1), (1, 0), (-1, 0), (0, -1))
    dq = deque()
    # すべての"#"をdequeに入れる
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if grid[i][j] == "#":
                dq.append((i, j, 0))
                visited[i][j] = True
    ans = 0
    # 幅優先探索
    while dq:
        i, j, d = dq.popleft()
        for di, dj in direction:
            if grid[i + di][j + dj] == "." and not visited[i + di][j + dj]:
                dq.append((i + di, j + dj, d + 1))
                visited[i + di][j + dj] = True
                ans = max(ans, d + 1)

    print(ans)
    return


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    h, w = input_int_list()
    grid = []
    grid.append(["@"] * (w + 2))
    for _ in range(h):
        grid.append(["@"] + list(input()) + ["@"])
    grid.append(["@"] * (w + 2))

    # 幅優先探索で すべてを"#"に変える。
    # かかった手数分が答え
    cnt = 1
    direction = ((0, 1), (1, 0), (-1, 0), (0, -1))
    while True:
        do_swap = False
        # print("=====")
        # for line in grid:
        #     print(*line)
        for i in range(1, h + 1):
            for j in range(1, w + 1):
                if grid[i][j] == "#" or grid[i][j] == cnt - 1:
                    for di, dj in direction:
                        if grid[i + di][j + dj] == ".":
                            do_swap = True
                            grid[i + di][j + dj] = cnt
                    grid[i][j] = "@"
        if do_swap:
            cnt += 1
        else:
            break

    print(cnt - 1)

    return


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

Fixed submission:
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N,M = [int(i) for i in input().strip().split()]
    students = [[int(i) for i in input().strip().split()] for _ in range(N)]
    checkpoints = [[int(i) for i in input().strip().split()] for _ in range(M)]
    ans = [0] * N

    for i,student in enumerate(students):
        dist = [float("inf")] * M
        for j, checkpoint in enumerate(checkpoints):
            dist[j] = abs(student[0] - checkpoint[0]) + abs(student[1] - checkpoint[1])
        ans[i] = dist.index(min(dist)) + 1

    return ans


if __name__ == "__main__":
    for n in main():
        print(n)

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


def main():
    N,M = [int(i) for i in input().strip().split()]
    students = [[int(i) for i in input().strip().split()] for _ in range(N)]
    checkpoints = [[int(i) for i in input().strip().split()] for _ in range(N)]
    ans = [0] * N

    for i,student in enumerate(students):
        dist = [float("inf")] * M
        for j, checkpoint in enumerate(checkpoints):
            dist[j] = abs(student[0] - checkpoint[0]) + abs(student[1] - checkpoint[1])
        ans[i] = dist.index(min(dist)) + 1

    return ans


if __name__ == "__main__":
    for n in main():
        print(n)
Problem p03835 (python)

Fixed submission:
k,s = list(map(int,input().split()))
ans = 0
for x in range(k+1):
  for y in range(k+1):
    if s-x-y < k+1 and s-x-y >= 0:
      ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
k,s = list(map(int,input().split()))
ans = 0
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x+y+z = s:
        ans += 1
print(ans)
Problem p02596 (python)

Fixed submission:
#C

K=int(input())
ans=-1
if K==1:
    ans=1
elif K==2 or K==5 or K==10:
    ans=-1
else:
    p=0
    for i in range(1,K+1):
        p = (p*10+7)%K 
        #print(i,p)
        if p==0:
            ans=i
            break

print(ans)

Buggy submission (verdict: Runtime Error):
#C

K=int(input())
if K==1:
    ans=1
elif K==2 or K==5 or K==10:
    ans=-1
else:
    p=0
    for i in range(1,K+2):
        p = (p*10+7)%K 
        #print(i,p)
        if p==0:
            ans=i
            break

print(ans)

Buggy submission (verdict: Runtime Error):
#C

K=int(input())
if K==1:
    ans=1
elif K==2 or K==5 or K==10:
    ans=-1
else:
    p=0
    for i in range(1,K+1):
        p = (p*10+7)%K 
        #print(i,p)
        if p==0:
            ans=i
            break

print(ans)
Problem p02682 (python)

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

a = min(A,K)
t1= K-a
b = min(B,t1)
c = K-a-b

#print(a,b,c)
print(a-c)

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

s = [1]*A+[0]*B+[-1]*C
print(sum(s[:K]))
Problem p02685 (python)

Fixed submission:
def combi(y,x,p=998244353):
  s=fac[y]
  t=fac[x]
  u=fac[y-x]
  ans= (s* pow(t,p-2,p)*pow(u,p-2,p))%p
  return ans

###############################

N,M,K=map(int,input().split())
p=998244353
fac=[1,1]
for i in range(2,N+1):
  fac.append( (fac[-1]*i)%p )


ans=0
for i in range(0,K+1):
  R = ( (M%p) *pow(M-1,N-1-i,p) )%p
  L = combi(N-1,i)
  ans = (ans + (R*L)%p)%p
  
print(ans)

Buggy submission (verdict: Runtime Error):
def combi(y,x,p=998244353):
  s=fac[y]
  t=fac[x]
  u=fac[y-x]
  ans= (s* pow(t,p-2,p)*pow(u,p-2,p))%p
  return ans

###############################

N,M,K=map(int,input().split())
p=998244353
fac=[1,1]
for i in range(2,N+1):
  fac.append( (fac[-1]*i)%p )
R = M*(M-1)**(N-K-2)

ans=0
for i in range(K,-1,-1):
  R = (R*(M-1))%p
  L = combi(N-1,i)
  #print(i,R,L)
  ans = (ans + (R*L)%p)%p
print(ans)

Buggy submission (verdict: Runtime Error):
def combi(y,x,p=998244353):
  s=fac[y]
  t=fac[x]
  u=fac[y-x]
  ans= (s* pow(t,p-2,p)*pow(u,p-2,p))%p
  return ans

###############################

N,M,K=map(int,input().split())
p=998244353
fac=[1,1]
for i in range(2,N+1):
  fac.append( (fac[-1]*i)%p )
R = M*(M-1)**(N-K-2)

ans=0
for i in range(K,-1,-1):
  R = (R*(M-1))%p
  L = combi(N,i)
  ans = (ans + (R*L)%p)%p
print(ans)
Problem p02712 (python)

Fixed submission:
N=int(input())
ans=0

for i in range(1,N+1):
  if i%3==0 or i%5==0:
    pass
  else:
    ans += i
    
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
sum=0

for i in range(1,N+1):
  if i%3==0 or i%5==0:
    pass
  else:
    ans += i
    
print(ans)