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

Fixed submission:
N, M = 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)
j = 0
for i in range(N):
    if A[i] >= BC[j][1]:
        break
    else:
        A[i] = BC[j][1]
        BC[j][0] -= 1
        if BC[j][0] == 0:
            j += 1
        if j >= M:
            break
print(sum(A))

Buggy submission (verdict: Runtime Error):
N, M = 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)
j = 0
for i in range(N):
    if A[i] >= BC[j][1]:
        break
    else:
        A[i] = BC[j][1]
        BC[j][0] -= 1
        if BC[j][0] == 0:
            j += 1
print(sum(A))

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M = map(int,input().split())
A = list(map(int,input().split()))
A = np.array(A)
for _ in range(M):
    B, C = map(int,input().split())
    if A[B - 1] <= C:
        A[:B] = [C] * B
         A.sort()
    else:
        A = np.maximum(A, C)
print(np.sum(A))
Problem p03045 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)

def dfs(s):
    if visited[s]:
        return
    visited[s] = 1
    for to in t[s]:
        if visited[to]:
            continue
        dfs(to)
    
N, M = map(int,input().split())
t = [[] for _ in range(N)]
visited = [0] * N
for _ in range(M):
    X, Y, Z = map(int,input().split())
    X -= 1
    Y -= 1
    t[X].append(Y)
    t[Y].append(X)
ans = 0
for i in range(0, N):
    if visited[i]:
        continue
    ans += 1
    dfs(i)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)

def dfs(s):
    if visited[s]:
        return
    visited[s] = 1
    for to in t[s]:
        if visited[to]:
            continue
        dfs(to)
    
N, M = map(int,input().split())
t = [[] for _ in range(N)]
visited = [0] * N
for _ in range(M):
    X, Y, Z = map(int,input().split())
    X -= 1
    Y -= 1
    t[X].append(Y)
    t[Y].append(X)
ans = 0
for i in range(1, N + 1):
    if visited[i]:
        continue
    ans += 1
    dfs(i)
print(ans)

Buggy submission (verdict: Runtime Error):
def dfs(s):
    if visited[s]:
        return
    visited[s] = 1
    for to in t[s]:
        if visited[to]:
            continue
        dfs(to)
    
N, M = map(int,input().split())
t = [[] for _ in range(N)]
visited = [0] * N
for _ in range(M):
    X, Y, Z = map(int,input().split())
    X -= 1
    Y -= 1
    t[X].append(Y)
    t[Y].append(X)
for i in range(1, N + 1):
    s = visited.index(0)
    dfs(s)
    if min(visited):
        ans = i
        break
print(ans)
Problem p03108 (python)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    
N, M = map(int,input().split())
bridge = []
for i in range(M):
    A, B = map(int,input().split())
    bridge.append((A - 1, B - 1))
    
uf = UnionFind(N)
ans = [N * (N - 1) // 2]
cnt = 0
for i in range(M - 1):
    A, B = bridge[-i-1]
    if not uf.same(A, B):
        cnt += uf.size(A) * uf.size(B)
        uf.union(A, B)
    ans.append(ans[0] - cnt)
for i in range(M):
    print(ans[-i-1])

Buggy submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    
N, M = map(int,input().split())
bridge = []
for i in range(M):
    A, B = map(int,input().split())
    bridge.append((A - 1, B - 1))
    
uf = UnionFind(N)
ans = N * (N - 1) // 2
cnt = 0
for i in range(M):
    A, B = bridge[i]
    if not same(A, B):
        cnt += size(A) * size(B)
        union(A, B)
    print(ans - cnt)
Problem p02679 (python)

Fixed submission:
from collections import defaultdict
from math import gcd

N = int(input())

MOD = 1000000007
d_plus = defaultdict(int)  # + or ∞
d_minus = defaultdict(int)  # - or 0
ans = 1
ans_00 = 0
for i in range(N):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        ans_00 += 1
    elif a == 0:
        d_minus[0] += 1
    elif b == 0:
        d_plus[float('inf')] += 1
    else:
        g = gcd(a, b)
        if (a > 0) ^ (b > 0):
            d_plus[(abs(a // g), abs(b // g))] += 1
        else:
            d_minus[(abs(a // g), -abs(b // g))] += 1


def pair(p):
    if p == 0:
        return float('inf')
    elif p == float('inf'):
        return 0
    else:
        a, b = -p[1], p[0]
        if a < 0:
            a, b = -a, -b
        return a, b


for m in d_minus:
    d_plus[pair(m)]
for p in d_plus:
    ans *= (pow(2, d_plus[p], MOD) + pow(2, d_minus[pair(p)], MOD) - 1)
    ans %= MOD
print((ans - 1 + ans_00) % MOD)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from fractions import Fraction

N = int(input())
X = [tuple(map(int, input().split())) for _ in range(N)]

MOD = 1000000007
d_plus = defaultdict(int)  # + or ∞
d_minus = defaultdict(int)  # - or 0
ans = 1

for i, (a, b) in enumerate(X):
    if a == 0 and b == 0:
        continue
    elif a == 0:
        d_minus[0] += 1
    elif b == 0:
        d_plus[float('inf')] += 1
    elif a * b > 0:
        d_plus[Fraction(a, b)] += 1
    else:
        d_minus[Fraction(a, b)] += 1

for m in d_minus:
    d_plus[-1 / m] += 0
for p in d_plus:
    ans = ans * (pow(2, d_plus[p], MOD) + pow(2, d_minus[-1 / p], MOD) - 1)
    ans %= MOD
print((ans - 1) % MOD)
Problem p02726 (python)

Fixed submission:
import itertools

N, X, Y = map(int, input().split())
lst = [0] * N
for l, r in itertools.combinations(range(1, N + 1), 2):
    lst[min(r - l, abs(r - Y) + 1 + abs(l - X))] += 1
for i in range(1, N):
    print(lst[i])

Buggy submission (verdict: Runtime Error):
import itertools


N, X, Y = map(int, input().split())
lst = [0] * N
for l,r in itertools.combinations(range(1,N+1),2):
    lst[min(r-l,abs(r-Y)+1+abs(l-X))] += 1
for i in range(1,N+1):
    print(lst[i])
Problem p02735 (python)

Fixed submission:
from copy import deepcopy
from collections import deque

H, W = map(int, input().split())
S = [input() for _ in range(H)]

table = [[None] * W for _ in range(H)]
table[0][0] = (0 if S[0][0] == '.' else 1)

D = deque([(0, 0)])
new_D = deque()
while D:
    h, w = D.popleft()
    for dh, dw in ((1, 0), (0, 1)):
        if 0 <= h + dh < H and 0 <= w + dw < W and table[h + dh][w + dw] is None:
            if S[h + dh][w + dw] == S[h][w]:
                D.append((h + dh, w + dw))
                table[h + dh][w + dw] = table[h][w]
            else:
                new_D.append((h + dh, w + dw))
                table[h + dh][w + dw] = table[h][w] + 1
    if not D:
        D = deepcopy(new_D)
        new_D.clear()

print((table[H - 1][W - 1] + 1) // 2)

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

H, W = map(int, input().split())
S = [input() for _ in range(H)]

table = [[None] * W for _ in range(H)]
table[0][0] = (0 if S[0][0] == '.' else 1)

D = deque([(0, 0)])
new_D = deque()
while D:
    h, w = D.popleft()
    for dh, dw in ((1, 0), (0, 1)):
        if 0 <= h + dh < H and 0 <= w + dw < W and table[h + dh][w + dw] is None:
            if S[h + dh][w + dw] == S[h][w]:
                D.append((h + dh, w + dw))
                table[h + dh][w + dw] = table[h][w]
            else:
                new_D.append((h + dh, w + dw))
                table[h + dh][w + dw] = table[h][w] + 1
    if not D:
        D = new_D.copy()
        new_D.clear()

print((table[H - 1][W - 1] + 1) // 2)
Problem p02762 (python)

Fixed submission:
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]
        self.height = [1] * n
        self.size = [1] * n

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.height[x] < self.height[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.height[x] == self.height[y]:
                    self.height[x] += 1

    def issame(self, x, y):
        return self.find(x) == self.find(y)

    def group_size(self, x):
        return self.size[self.find(x)]


N, M, K = map(int, input().split())
uf = UnionFind(N)
exc = [set() for _ in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    exc[a - 1].add(b - 1)
    exc[b - 1].add(a - 1)
    uf.unite(a - 1, b - 1)
for _ in range(K):
    c, d = map(int, input().split())
    if uf.issame(c - 1, d - 1):
        exc[c - 1].add(d - 1)
        exc[d - 1].add(c - 1)

ans = [uf.group_size(i) - len(exc[i]) - 1 for i in range(N)]
print(*ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix

N, M, K = map(int, input().split())
exc = [set() for _ in range(N)]
edge = []

for _ in range(M):
    a, b = map(int, input().split())
    exc[a - 1].add(b - 1)
    exc[b - 1].add(a - 1)
    edge.append((a - 1, b - 1))

edge = np.array(edge).T
matr = csr_matrix(([1 for _ in range(M)], edge), (N, N))
_, labels = connected_components(matr)
ct = Counter(labels)

for _ in range(K):
    c, d = map(int, input().split())
    if labels[c - 1] == labels[d - 1]:
        exc[c - 1].add(d - 1)
        exc[d - 1].add(c - 1)

ans = [ct[labels[i]] - len(exc[i]) - 1 for i in range(N)]
print(*ans)
Problem p02862 (python)

Fixed submission:
import sys

X, Y = map(int, input().split())

# 直交座標に直す
if X > 2 * Y or Y > 2 * X or \
        (2 * X - Y) % 3 != 0 or (2 * Y - X) % 3 != 0:
    print(0)
    sys.exit()
x, y = (2 * X - Y) // 3, (2 * Y - X) // 3


def comb_inv(n, k, mod):
    f = [1 for _ in range(n + 1)]
    inv = [1 for _ in range(n + 1)]
    finv = [1 for _ in range(n + 1)]

    for i in range(2, n + 1):
        f[i] = f[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod
    return f[n] * (finv[k] * finv[n - k] % mod) % mod


print(comb_inv(x + y, x, 10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
import sys

X, Y = map(int, input().split())

# 直交座標に直す
if (2 * X - Y) % 3 != 0 or (2 * Y - X) % 3 != 0:
    print(0)
    sys.exit()
x, y = (2 * X - Y) // 3, (2 * Y - X) // 3


def comb_inv(n, k, mod):
    f = [1 for _ in range(n + 1)]
    inv = [1 for _ in range(n + 1)]
    finv = [1 for _ in range(n + 1)]

    for i in range(2, n + 1):
        f[i] = f[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod
    return f[n] * (finv[k] * finv[n - k] % mod) % mod


print(comb_inv(x + y, x, 10 ** 9 + 7))
Problem p02984 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = [sum((-1) ** i * A[i] for i in range(N))]
for i in range(N - 1):
    ans.append(2 * A[i] - ans[i])
print(*ans)

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

N = int(input())
A = np.matrix([int(x) for x in input().split()], dtype='int64')
Pm = np.matrix([[1, -1], [-1, 1]], dtype='int64')
P = np.tile(Pm, ((N + 1) // 2, (N + 1) // 2))[:-1, :-1]
P = -np.triu(P) + np.tril(P) + np.eye(N)
print(*np.array(A * P).flatten().astype(np.int64).tolist())
Problem p02987 (python)

Fixed submission:
S = input()
X=S[0]
i=1
while i<=3:
    if S[i]!=X:
        Y=S[i]
        break
    i+=1
if S.count(X)!=2 or S.count(Y)!=2:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
S = input()
X=S[0]
i=1
while i<=4:
    if S[i]!=X:
        Y=S[i]
        break
    i+=1
if S.count(X)!=2 or S.count(Y)!=2:
    print("No")
else:
    print("Yes")
Problem p02990 (python)

Fixed submission:
N, K = map(int, input().split())
mod = 10 ** 9 + 7

f = [1 for _ in range(N + 1)]
inv = [1 for _ in range(N + 1)]
finv = [1 for _ in range(N + 1)]

for i in range(2, N + 1):
    f[i] = f[i - 1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod


def comb(n, r):
    return f[n] * (finv[r] * finv[n - r] % mod) % mod


for i in range(1, K + 1):
    print((comb(N - K + 1, i) * comb(K - 1, i - 1)) % mod) if i <= N - K + 1 else print(0)

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


def comb(n, k):
    m = 1
    if n < k or k < 0:
        return 0
    elif n < 2 * k:
        k = n - k
    for i in range(1, k + 1):
        m = m * (n - i + 1) / i
    return int(m)


for j in range(1, K + 1):
    pts = comb(N - K + 1, j) % 1000000007
    nums = comb(K - 1, j - 1) % 1000000007
    print((pts * nums) % 1000000007)

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


def comb(n, k):
    m = 1
    if n < k:
        return 0
    elif n < 2 * k:
        k = n - k
    for i in range(1, k + 1):
        m = m * (n - i + 1) / i
    return int(m)


for j in range(1, K + 1):
    pts = comb(N - K + 1, j) % 1000000007
    nums = comb(K - 1, j - 1) % 1000000007
    print((pts * nums) % 1000000007)

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


def comb(n, k):
    m = 1
    if n < k:
        return 0
    elif n < 2 * k:
        k = n - k
    for i in range(1, k + 1):
        m = m * (n - i + 1) / i
    return int(m)


for j in range(1, K + 1):
    print((comb(N - K + 1, j) * comb(K - 1, j - 1)) % (10 ** 9 + 7))

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

def comb(n, k):
    m = 1
    if n < 2 * k:
        k = n - k
    for i in range(1, k + 1):
        m = m * (n - i + 1) / i
    return int(m)

for i in range(1,K+1):
    print((comb(N-K+1,i)*comb(K-1,i-1))%(10**9+7))
Problem p03011 (python)

Fixed submission:
P,Q,R=map(int, input().split())
print(min(P+Q,P+R,Q+R))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = []
for _ in range(M):
    A.append(int(input()))

case = [0] * (N + 1)
case[0] = 1
if not 1 in A:
    case[1] = 1
for x in range(2, N + 1):
    if x in A:
        case[x] = 0
    elif x - 1 in A:
        case[x] = case[x - 2]
    else:
        case[x] = case[x - 1] + case[x - 2]

print(case[N] % 1000000007)
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
A = [1] * (N + 1)
ans = [0] * (N + 1)
ans[0] = 1
for _ in range(M):
    A[int(input())] = 0
for i in range(1, N + 1):
    ans[i] = (ans[i - 2] * A[i - 2] + ans[i - 1] * A[i - 1]) % 1000000007

print(ans[N])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = []
for _ in range(M):
    A.append(int(input()))

case = [0] * (N + 1)
case[0] = 1
if not 1 in A:
    case[1] = 1

if A[0]==1:
    j=1
    flag=True
else:
    j=0
    flag=False
for x in range(2, N + 1):
    if x==A[j]:
        case[x] = 0
        j=(j+1)%M
        flag=True
    elif flag==True:
        case[x] = case[x - 2]
        flag=False
    else:
        case[x] = (case[x - 1] + case[x - 2]) % 1000000007
        flag=False

print(case[N])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = []
for _ in range(M):
    A.append(int(input()))

case = [0] * (N + 1)
case[0] = 1
if not 1 in A:
    case[1] = 1

if A[0]==1:
    j=1
    flag=True
else:
    j=0
    flag=False
for x in range(2, N + 1):
    if x==A[j]:
        case[x] = 0
        j=(j+1)%M
        flag=True
    elif flag==True:
        case[x] = case[x - 2]
        flag=False
    else:
        case[x] = (case[x - 1] + case[x - 2]) % 1000000007
        flag=False

print(case[N])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = []
for _ in range(M):
    A.append(int(input()))

case = [0] * (N + 1)
case[0] = 1
if not 1 in A:
    case[1] = 1

if A[0]==1:
    j=1
    flag=True
else:
    j=0
    flag=False
for x in range(2, N + 1):
    if x==A[j]:
        case[x] = 0
        j=(j+1)%M
        flag=True
    elif flag==True:
        case[x] = case[x - 2]
        flag=False
    else:
        case[x] = case[x - 1] + case[x - 2]
        flag=False

print(case[N] % 1000000007)
Problem p03038 (python)

Fixed submission:
from sys import exit

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for _ in range(M):
    BC.append(tuple(map(int, input().split())))
BC.sort(key=lambda x: -x[1])
A.sort()

i = 0
for b, c in BC:
    for x in range(b):
        if i < N and A[i] < c:
            A[i] = c
            i += 1
        else:
            print(sum(A))
            exit()
print(sum(A))

Buggy submission (verdict: Runtime Error):
from sys import exit

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for _ in range(M):
    BC.append(tuple(map(int, input().split())))
BC.sort(key=lambda x: -x[1])
A.sort()

i = 0
for b, c in BC:
    for x in range(b):
        if A[i] < c:
            A[i] = c
            i += 1
        else:
            print(sum(A))
            exit()
print(sum(A))

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

N,M= map(int, input().split())
A=sorted(map(int, input().split()))

D=[[0 for i in range(2)] for j in range(M)]
for x in range(M):
    D[x][0],D[x][1]= map(int, input().split())

D=sorted(D, key=lambda x : x[1],reverse=True)
num=0
for y in range(M): #どの要素を代入するか
    for z in range(D[y][0]): #どこに要素を代入するか
        if A[z+num]>=D[y][1]:
            break
        else:
            A[z+num]=D[y][1]
    else:
        num += D[y][0]
        continue
    break
print(A)
print(sum(A))

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

D=[[0 for i in range(2)] for j in range(M)]
for x in range(M):
    D[x][0],D[x][1]= map(int, input().split())

D=sorted(D, key=lambda x : x[1],reverse=True)

num=0
for y in range(M):
    for z in range(D[y][0]):
        if A[z+num]>=D[y][1]:
            break
        else:
            A[z+num]=D[y][1]
    else:
        num += D[y][0]
        continue
    break
print(sum(A))
Problem p03775 (python)

Fixed submission:
import math

N = int(input())

tmp = math.floor(math.sqrt(N))
while N % tmp:
    tmp -= 1
print(len(str(N // tmp)))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
tmp = math.isqrt(N)
while N % tmp:
    tmp -= 1
print(len(str(N // tmp)))
Problem p03822 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 9)

N = int(input())
T = [[] for _ in range(N)]
for i in range(1, N):
    x = int(input()) - 1
    T[x].append(i)


def f(x):
    candidates = sorted([f(y) for y in T[x]], reverse=True)
    return max((c + i for i, c in enumerate(candidates, 1)), default=0)


print(f(0))

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 5)

N = int(input())
T = [[] for _ in range(N)]
for i in range(1, N):
    x = int(input()) - 1
    T[x].append(i)


def f(x):
    candidates = sorted([f(y) for y in T[x]], reverse=True)
    return max((c + i for i, c in enumerate(candidates, 1)), default=0)


print(f(0))
Problem p02699 (python)

Fixed submission:
s,w = map(int, input().split())
print("unsafe" if w >= s else "safe")

Buggy submission (verdict: Runtime Error):
s,w = map(input().split(), int)
print("unsafe" if w >= s else "safe")

Buggy submission (verdict: Runtime Error):
s = int(input())
w = int(input())
print "unsafe" if w>=s else "safe"
Problem p02571 (python)

Fixed submission:
# import math
# import statistics
a=input()
b=input()
#b,c=int(input()),int(input())
c,d=[],[]
for i in a:
    c.append(i)
for i in b:
    d.append(i)
#e1,e2 = map(int,input().split())
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
# h = []
# for i in range(e1):
#     h.append(list(map(int,input().split())))
ma=[]
if b in a:
    print(0)
else:
    for i in range(len(c)-len(d)+1):
        count=0
        for k in range(len(d)):
            if c[i:len(d)+i][k]!=d[k]:
                count+=1
        ma.append(count)
    print(min(ma))

Buggy submission (verdict: Runtime Error):
# import math
# import statistics
a=input()
b=input()
#b,c=int(input()),int(input())
c,d=[],[]
for i in a:
    c.append(i)
for i in b:
    d.append(i)
#e1,e2 = map(int,input().split())
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
# h = []
# for i in range(e1):
#     h.append(list(map(int,input().split())))
ma=[]
if b in a:
    print(0)
else:
    for i in range(len(c)-len(d)+1):
        count=0
        for k in range(len(d)):
            if c[i:len(d)+i][k]!=d[k]:
                count+=1
        ma.append(count)

print(min(ma))
Problem p02785 (python)

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

if len(b) <= a[1]:
    print("0")
elif a[1]==0:
    print(sum(b))
else:
    b.sort(reverse=True)
    print(sum(b[a[1]:]))

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

b.sort(reverse=True)
for i in  range(a[1]):
    del b[0]
print(sum(b))

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

b.sort(reverse=True)
for i in  range(a[1]):
        del b[0]
    print(sum(b))
Problem p02595 (python)

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

cod = [0]*N

for i in range(N):
    x, y = list(map(int, input().split()))
    cod[i] = (x, y)

ans = 0
for i in range(N):
    x, y = cod[i]

    if (x**2 + y**2) <= D**2:
        ans += 1

print(ans)

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

cod = [0]*N

for i in range(N):
    x, y = list(map(int, input().split()))
    cod[i] = (x, y)

ans = 0
for i in range(N):
    x, y = cod[i]

    if (x**2 + y**2) <= D**2:
        ans += 1

print(ans)
N, D = list(map(int, input().split()))

cod = [0]*N

for i in range(N):
    x, y = list(map(int, input().split()))
    cod[i] = (x, y)

ans = 0
for i in range(N):
    x, y = cod[i]

    if (x**2 + y**2) <= D**2:
        ans += 1

print(ans)