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

Fixed submission:

def median_of_medians(N: int, A: list)->int:
    def search(c):
        bar = N
        r = 0
        res_nega = 0
        dp_arr = [0]*(2*N+1)
        for i in range(N):
            dp_arr[bar] += 1
            if A[i] < c:
                r += dp_arr[bar]
                bar += 1
            else:
                r -= (dp_arr[bar-1])
                bar -= 1
            res_nega += r
        return res_nega

    # binary search
    a_sorted = sorted(A)
    left = 0
    right = N
    mid = N // 2
    C = N*(N+1) // 2
    while True:
        if search(a_sorted[mid]) <= C // 2:
            if mid == N-1:
                break
            elif search(a_sorted[mid+1]) > C // 2:
                break
            else:
                left = mid
                mid = (mid + right) // 2
        else:
            right = mid + 1
            mid = (mid + left) // 2

    return a_sorted[mid]


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    ans = median_of_medians(N, A)
    print(ans)

Buggy submission (verdict: Runtime Error):
class BIT:
    """1-indexed BIT
    """

    def __init__(self, size: int):
        """サイズを指定して BIT を初期化します。
        """
        # BIT のサイズは 2^n + 1
        self.__size = size + 1

        # 実際の配列
        self.__bit = [0] * self.__size

    def add(self, idx: int, val: int):
        """位置 idx (1-indexed) に値 val をたす。
        :param idx: 値を追加したいインデックス
        :param val: 追加したい値
        """
        while idx < self.__size:
            self.__bit[idx] += val
            idx += idx & (-idx)

    def sum(self, l: int, r: int)->int:
        """(l, r] の累積和を計算する。
        :param l: left index
        :param r: right index
        :return: (l, r] の累積和
        """
        return self.__sum__(r) - self.__sum__(l)

    def __sum__(self, idx: int)->int:
        s = 0
        while idx > 0:
            s += self.__bit[idx]
            idx -= idx & (-idx)
        return s


def inversion(A: list) -> int:
    bit = BIT(max(A))
    s = 0
    for a in A[1:]:
        bit.add(a, 1)
        s += bit.sum(0, a)

    return a


def check(A: list, x: int)->int:
    n = len(A)
    S = [0] * (n + 1)
    for i in range(n):
        S[i + 1] = S[i] + (1 if x <= A[i] else - 1)

    m = min(S)
    for i in range(n):
        S[i+1] -= m - 1

    return inversion(S[1:])


def median_of_medians(N: int, A: list)->int:
    alpha = sorted(A)
    l, r = 0, N
    m, c = N//2, N*(N+1)//2
    while True:
        if check(A, alpha[m]) <= c//2:
            if m == N-1:
                break
            elif check(A, alpha[m+1]) > c//2:
                break
            else:
                l, m = m, (m+r)//2
        else:
            m, r = (m+l)//2, m+1

    return alpha[m]


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    ans = median_of_medians(N, A)
    print(ans)
Problem p03291 (python)

Fixed submission:
def we_love_abc(S: str)->int:
    ABC = 'ABC'
    MOD = 1000000007

    dp = [0, 0, 0, 0]
    dp[3] = 1

    for c in reversed(S):
        for j in range(3):
            m1 = 3 if c == '?' else 1
            m2 = 1 if c == '?' or c == ABC[j] else 0
            dp[j] = (m1 * dp[j] + m2 * dp[j+1]) % MOD
        dp[3] = (3 if c == '?' else 1) * dp[3]
        dp[3] %= MOD

    return dp[0] % MOD


if __name__ == "__main__":
    S = input()
    ans = we_love_abc(S)
    print(ans)

Buggy submission (verdict: Runtime Error):
S = ''

def we_love_abc()->int:
    global S
    ABC = 'ABC'

    dp = [0, 0, 0, 0]
    dp[3] = 1

    for c in reversed(S):
        if c == '?':
            m, m1 = 3, 3
        else:
            m, m1 = 1, 1

        for j in range(3):
            m2 = 1 if c == '?' or c == ABC[j] else 0
            dp[j] = m1 * dp[j] + m2 * dp[j+1]
        dp[3] = m * dp[3]

    return dp[0] % 1000000007


if __name__ == "__main__":
    S = input()
    ans = we_love_abc(S)
    print(ans)
Problem p03634 (python)

Fixed submission:
from queue import Queue


def distances(tree: list, treeSize: int, root: int)->list:
    dists = [0] * treeSize

    q = Queue()
    q.put((root, -1, 0))

    while not q.empty():
        v, prev, d2v = q.get()

        dists[v] = d2v
        for u, dv2u in tree[v]:
            if prev == u:
                continue
            q.put((u, v, d2v + dv2u))

    return dists


def transit_tree_path(
        N: int, edges: list, Q: int, K: int, queries: list)->list:
    tree = [[] for _ in range(N)]
    for u, v, c in edges:
        tree[u-1].append((v-1, c))
        tree[v-1].append((u-1, c))

    d = distances(tree, N, K-1)

    return [d[x-1]+d[y-1] for x, y in queries]


if __name__ == "__main__":
    N = int(input())
    edges = [tuple(map(int, input().split())) for _ in range(N-1)]
    Q = 0
    Q, K = map(int, input().split())
    queries = [tuple(map(int, input().split())) for _ in range(Q)]

    ans = transit_tree_path(N, edges, Q, K, queries)
    for a in ans:
        print(a)

Buggy submission (verdict: Runtime Error):
def distances(tree: list, treeSize: int, root: int)->list:
    dists = [0] * treeSize

    def dfs(v: int, prev: int,  dist: int):
        dists[v] = dist
        for u, c in tree[v]:
            if u == prev:
                continue
            dfs(u, v, dist+c)

    dfs(root, -1, 0)

    return dists


def transit_tree_path(
        N: int, edges: list, Q: int, K: int, queries: list)->list:
    tree = [[] for _ in range(N)]
    for u, v, c in edges:
        tree[u-1].append((v-1, c))
        tree[v-1].append((u-1, c))

    d = distances(tree, N, K-1)

    return [d[x-1]+d[y-1] for x, y in queries]


if __name__ == "__main__":
    N = int(input())
    edges = [tuple(map(int, input().split())) for _ in range(N-1)]
    Q = 0
    Q, K = map(int, input().split())
    queries = [tuple(map(int, input().split())) for _ in range(Q)]

    ans = transit_tree_path(N, edges, Q, K, queries)
    for a in ans:
        print(a)
Problem p02793 (python)

Fixed submission:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
from collections import deque

inf = 10**18
mod = 10**9+7

dic = {}

# mod で割り算(フェルマー、逆元利用)
mod = 10**9+7

N = 10**6+1
inv_t = [0]+[1]

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

def moddiv(a, b):
    return a*inv_t[b]%mod

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
a = list(map(int, input().split()))
j = []
for num in a:
    tmp = factorization(num)
    j.append(tmp)
    for p,x in tmp:
        if p in dic:
            dic[p] = max(dic[p],x)
        else:
            dic[p] = x
gc = 1
for k,v in dic.items():
    gc*=(k**v)%mod
ans = 0
for num in a:
    ans += moddiv(gc, num)
    ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
inf = 10**18
mod = 10**9+7

N = 10**6+1
inv_t = [0]+[1]

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

def moddiv(a, b):
    return a*inv_t[b]%mod

n = int(input())
a = list(map(int, input().split()))
tmp = 1
for num in a:
    f = math.gcd(tmp,num)
    tmp = tmp*num%mod
    tmp = moddiv(tmp, f)
ans = 0
for num in a:
    ans += moddiv(tmp, num)
    ans %= mod

print(ans)
Problem p03127 (python)

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

import fractions
tmp = a[0]
for num in a:
    tmp = fractions.gcd(tmp, num)           #最大公約数
print(tmp)

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

import math
tmp = a[0]
for num in a:
    tmp = math.gcd(tmp, num)           #最大公約数
print(tmp)
Problem p03208 (python)

Fixed submission:
inf = 10**9+7
mod = 10**9+7
n,k = map(int, input().split())
a = [int(input()) for i in range(n)]
a.sort()
minh = inf
for i in range(n-k+1):
    minh = min(minh, a[i+k-1]-a[i])
print(minh)

Buggy submission (verdict: Runtime Error):
inf = 10**9+7
mod = 10**9+7
n = int(input())
a = [int(input()) for i in range(n)]
h = max(a)
print(sum(a)-h+h//2)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort()
minh = inf
for i in range(n-k+1):
    tmp = h[i+k-1] - h[i]
    minh = min(minh, tmp)
print(minh)
Problem p02679 (python)

Fixed submission:
M = 1000000007

import math

N = int(input())

ab_zero_count = 0
a_zero_count = 0
b_zero_count = 0

fish_list = []
for _ in range(N):
	a, b = map(int, input().split())
	if a == 0 and b == 0:
		ab_zero_count += 1
	elif a == 0:
		a_zero_count += 1
	elif b == 0:
		b_zero_count += 1
	else:
		if a < 0:
			a = -a
			b = -b
		g = math.gcd(a, b)
		if g > 1:
			a //= g
			b //= g
		fish_list.append((a, b))

#print(fish_list)

fish_table = {}
for f in fish_list:
	if f in fish_table:
		fish_table[f] += 1
	else:
		fish_table[f] = 1

fish_count_list = list(fish_table.items())
fish_index_table = {}
for i, (f, c) in enumerate(fish_count_list):
	fish_index_table[f] = i

#print(fish_count_list)

singles = 0
pair_list = []
checked = [False] * N

for i, (f, c) in enumerate(fish_count_list):
	a, b = f
	a, b = (-b, a)
	if a < 0:
		a = -a
		b = -b
	key = (a, b)
	if key in fish_index_table:
		j = fish_index_table[key]
		if checked[j] == False:
			f2, c2 = fish_count_list[j]
			pair_list.append((c, c2))
			checked[i] = True
	else:
		singles += c

if a_zero_count > 0 and b_zero_count > 0:
	pair_list.append((a_zero_count, b_zero_count))
else:
	singles += a_zero_count + b_zero_count

count = pow(2, singles, M)

#print(singles, pair_list, a_zero_count, b_zero_count)

for c1, c2 in pair_list:
	count = (count * (pow(2, c1, M) + pow(2, c2, M) - 1)) % M

count += ab_zero_count
count -= 1

print(count % M)

Buggy submission (verdict: Runtime Error):
M = 1000000007

from fractions import Fraction
from bisect import bisect_left

N = int(input())

fish_list = []
for _ in range(N):
	a, b = map(int, input().split())
	fish_list.append(Fraction(a, b))

#print(fish_list)

fish_table = {}
for f in fish_list:
	if f in fish_table:
		fish_table[f] += 1
	else:
		fish_table[f] = 1

fish_count_list = list(fish_table.items())
fish_count_list.sort()
fish_count_only_list = [f for f, c in fish_count_list]

#print(fish_count_list)

singles = 0
pair_list = []
checked = [False] * N

for i, (f, c) in enumerate(fish_count_list):
	x = -1 / f
	j = bisect_left(fish_count_only_list, x)
	if j != len(fish_count_only_list) and fish_count_only_list[j] == x:
		if checked[j] == False:
			f2, c2 = fish_count_list[j]
			pair_list.append((c, c2))
			checked[i] = True
	else:
		singles += 1

count = pow(2, singles, M)

for c1, c2 in pair_list:
	count = (count * (pow(2, c1, M) + pow(2, c2, M) - 1)) % M

count -= 1

print(count)
Problem p02685 (python)

Fixed submission:
X = 998244353

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

def calc_inverse(n, law):
	if n == 1:
		return 1
	
	pre_r = law
	pre_x = 0
	pre_y = 1
	cur_r = n
	cur_x = 1
	cur_y = 0
	
	while True:
		d = pre_r // cur_r
		r = pre_r % cur_r
		
		nxt_r = r
		nxt_x = pre_x - d * cur_x
		nxt_y = pre_y - d * cur_y
		
		if nxt_r == 1:
			ret = nxt_x
			while ret < 0:
				ret += law;
			return ret;
		elif nxt_r == 0:
			return None
		
		pre_r = cur_r;
		pre_x = cur_x;
		pre_y = cur_y;
		cur_r = nxt_r;
		cur_x = nxt_x;
		cur_y = nxt_y;

inv_cache = [1]
for i in range(1, K + 1):
	inv_cache.append(calc_inverse(i, X))

inv_f_cache = [1]
d = 1
for i in range(1, K + 1):
	d = (d * inv_cache[i]) % X
	inv_f_cache.append(d)

f_cache = [1]
c = 1
for i in range(N - 1, N - K - 1, -1):
	c = (c * i) % X
	f_cache.append(c)

#print(f_cache, inv_f_cache)

def C(n, m):
#	if m in f_cache:
#		c = f_cache[m]
#	else:
#		c = 1
#		for i in range(n - m + 1, n + 1):
#			c = (c * i) % X
#		f_cache[m] = c
#	d = 1
#	for i in range(1, m + 1):
#		d = (d * inv_cache[i]) % X
#	print(m)
	return (f_cache[m] * inv_f_cache[m]) % X


total = 0
for k in range(K + 1):
	total = (total + M * pow(M - 1, N - 1 - k, X) * C(N - 1, k)) % X
	
#	print(k, M * pow(M - 1, N - 1 - k, X))
	

print(total)

Buggy submission (verdict: Runtime Error):
X = 998244353

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

def calc_inverse(n, law):
	if n == 1:
		return 1
	
	pre_r = law
	pre_x = 0
	pre_y = 1
	cur_r = n
	cur_x = 1
	cur_y = 0
	
	while True:
		d = pre_r // cur_r
		r = pre_r % cur_r
		
		nxt_r = r
		nxt_x = pre_x - d * cur_x
		nxt_y = pre_y - d * cur_y
		
		if nxt_r == 1:
			ret = nxt_x
			while ret < 0:
				ret += law;
			return ret;
		elif nxt_r == 0:
			return None
		
		pre_r = cur_r;
		pre_x = cur_x;
		pre_y = cur_y;
		cur_r = nxt_r;
		cur_x = nxt_x;
		cur_y = nxt_y;

inv_cache = [1]
for i in range(1, K + 1):
	inv_cache.append(calc_inverse(i, X))

inv_f_cache = [1]
d = 1
for i in range(1, K + 1):
	d = (d * inv_cache[i]) % X
	inv_f_cache.append(d)

f_cache = [1]
c = 1
for i in range(N - 1, N - M, -1):
	c = (c * i) % X
	f_cache.append(c)

#print(f_cache, inv_f_cache)

def C(n, m):
#	if m in f_cache:
#		c = f_cache[m]
#	else:
#		c = 1
#		for i in range(n - m + 1, n + 1):
#			c = (c * i) % X
#		f_cache[m] = c
#	d = 1
#	for i in range(1, m + 1):
#		d = (d * inv_cache[i]) % X
	return (f_cache[m] * inv_f_cache[m]) % X


total = 0
for k in range(K + 1):
	total = (total + M * pow(M - 1, N - 1 - k, X) * C(N - 1, k)) % X
	
#	print(k, M * pow(M - 1, N - 1 - k, X))
	

print(total)
Problem p02829 (python)

Fixed submission:
answers = ["1", "2", "3"]
answers.remove(input().strip())
answers.remove(input().strip())
print(answers[0])

Buggy submission (verdict: Runtime Error):
N, u, v = map(int, input().split())
u -= 1
v -= 1

e_list = [[] for _ in range(N)]

for _ in range(N - 1):
	a, b = map(int, input().split())
	a -= 1
	b -= 1
	e_list[a].append(b)
	e_list[b].append(a)

def calc_depth_table(v):
	queue = [[v, None, 0]]
	depth_table = [0] * N
	depth_table[v] = 0
	
	while queue:
		cur, pre, depth = queue.pop()
		depth += 1
		for n in e_list[cur]:
			if n != pre:
				queue.append([n, cur, depth])
				depth_table[n] = depth
	return depth_table

def calc_depth_table2(depth_from_v, u):
	queue = [[u, None, 0, depth_from_v[u], u]]
	depth_table = [0] * N
	depth_table[u] = (0, depth_from_v[u], u)
	
	while queue:
		cur, pre, depth, min_depth_from_v, min_depth_point = queue.pop()
		depth += 1
		for n in e_list[cur]:
			if n != pre:
				depth2 = depth_from_v[n]
				if min_depth_from_v > depth2:
					new_min_depth = depth2
					new_min_depth_point = n
				else:
					new_min_depth = min_depth_from_v
					new_min_depth_point = min_depth_point
				queue.append([n, cur, depth, new_min_depth, new_min_depth_point])
				depth_table[n] = (depth, new_min_depth, new_min_depth_point)
	return depth_table

depth_from_v = calc_depth_table(v)
depth_from_u = calc_depth_table2(depth_from_v, u)

#print(depth_from_v)
#print(depth_from_u)

max_count = 0
for i in range(N):
	a_dist = depth_from_v[i]
	t_dist, a_hit_dist, hit_pos = depth_from_u[i]
	t_hit_dist = depth_from_u[hit_pos][0]
	
#	print(t_hit_dist, a_hit_dist)
	if t_hit_dist < a_hit_dist:
#		print(t_hit_dist, a_hit_dist)
#		if (a_hit_dist - t_hit_dist) % 2 == 1:
		if max_count < a_dist - 1:
			max_count = a_dist - 1
#			else:
#				

print(max_count)
Problem p03017 (python)

Fixed submission:
N, A, B, C, D = map(int, input().split())
S = input()

A -= 1
B -= 1
C -= 1
D -= 1

def check():
	for i in range(A + 1, C - 1):
		if S[i] == S[i + 1] == "#":
			return False

	for i in range(B + 1, D - 1):
		if S[i] == S[i + 1] == "#":
			return False
	
	if D < C:
		for i in range(B, D + 1):
			if S[i - 1] == S[i] == S[i + 1] == ".":
				return True
		return False
	else:
		return True

if check():
	print("Yes")
else:
	print("No")

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

A -= 1
B -= 1
C -= 1
D -= 1

def check2():
	for i in range(A, C - 1):
		if S[i] == S[i + 1] == "#":
			return False
	
	if D < C:
		for i in range(B, D):
			if S[i - 1] == S[i] == S[i + 1] == ".":
				return True
		return False
	else:
		return True

if check():
	print("Yes")
else:
	print("No")
Problem p03038 (python)

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

cards = list(map(int, input().split(" ")))
cards.sort()

replaces = []
for _ in range(M):
	b, c = map(int, input().split(" "))
	replaces.append((c, b))

replaces.sort()
replaces.reverse()

#print(cards)
#print(replaces)

replace_index = 0
for c, b in replaces:
	ended = False
	for i in range(b):
		if replace_index >= N:
			ended = True
			break
		elif cards[replace_index] < c:
			cards[replace_index] = c
			replace_index += 1
		else:
			ended = True
			break
	if ended:
		break

#print(cards)
print(sum(cards))

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

cards = list(map(int, input().split(" ")))
cards.sort()

replaces = []
for _ in range(M):
	b, c = map(int, input().split(" "))
	replaces.append((c, b))

replaces.sort()
replaces.reverse()

#print(cards)
#print(replaces)

replace_index = 0
for c, b in replaces:
	ended = False
	for i in range(b):
		if cards[replace_index] < c:
			cards[replace_index] = c
			replace_index += 1
		else:
			ended = True
			break
	if ended:
		break

#print(cards)
print(sum(cards))
Problem p02964 (python)

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

def solve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    D = {}
    for j,a in enumerate(A):
        D[a] = D.get(a,[])+[j]

    t,k = 0,0
    T = [0]
    while True:
        k = (D[A[t]].index(t)+1)%len(D[A[t]])
        if k == 0:
            T.append(A[t])
        t = (D[A[t]][k]+1)%N
        if t == 0:
            break

    if T == [0]:
        return ''
    if K == 1 or (K-1)%len(T) == 0:
        t = 0
    else:
        t = D[T[(K-1)%len(T)]][0]+1
    S = []
    flag = False
    while t < N:
        k = (D[A[t]].index(t)+1)%len(D[A[t]])
        if k == 0:
            S.append(A[t])
            t += 1
        else:
            t = D[A[t]][k]+1

    res = ' '.join(map(str,S))

    return str(res)

if __name__ == '__main__':
    print(solve())

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

def solve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    D = {}
    for j,a in enumerate(A):
        D[a] = D.get(a,[])+[j]

    t,k = 0,0
    T = [0]
    while True:
        k = (D[A[t]].index(t)+1)%len(D[A[t]])
        if k == 0:
            T.append(A[t])
        t = (D[A[t]][k]+1)%N
        if t == 0:
            break

    T[0] = T.pop()
    t = D[T[K%len(T)]][0]+1
    S = []
    while t < N:
        k = (D[A[t]].index(t)+1)%len(D[A[t]])
        if k == 0:
            S.append(A[t])
        t = D[A[t]][k]+1

    res = ' '.join(map(str,S))

    return str(res)

if __name__ == '__main__':
    print(solve())
Problem p02571 (python)

Fixed submission:
s = input()
t = input()
ans = 0
for i in range(len(s)-len(t)+1):
    m = 0
    for j, k in zip(s[i:],t):
        if j==k:
            m += 1
    if m > ans:
        ans = m
print(len(t) - ans)

Buggy submission (verdict: Runtime Error):
#include <stdio.h>
#include <string.h>

int main(void){
    char s[1000];
    char t[1000];
    scanf("%s",s);
    scanf("%s",t);
    int m[strlen(s)];
    for(int i = 0; i < strlen(s); i++){
        m[i] = 0;
    }
    for(int i = 0; i < strlen(s); i++){
        for(int j = 0; j < strlen(t); j++){
            if(s[i] == t[j] && i>=j && strlen(s)-i>=strlen(t)-j){
                for(int k = j; k < strlen(s); k++){
                    if(s[i+k-j] == t[k]){
                        m[i]++;
                    }
                    else{
                        break;
                    }
                }
            }
        }
    }
    int max = 0;
    for(int i = 0; i < strlen(t); i++){
        if(max < m[i]){
            max = m[i];
        }
    }
    printf("%d",strlen(t)-max);
    return 0;
}
Problem p02661 (python)

Fixed submission:
n = int(input())
a = []
b = []
for i in range(n):
    a1,b1 = map(int, input().split())
    a.append(a1)
    b.append(b1)
a.sort()
b.sort()
if n%2 == 1:
    print(b[(n+1)//2-1]-a[(n+1)//2-1]+1)
else:
	print(b[n//2-1]-a[n//2-1]+b[n//2]-a[n//2]+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
b = []
for i in range(n):
    a[i],b[i] = map(int, input().split())
a.sort()
b.sort()
if n%2 == 1:
    	print(b[(n+1)//2]-a[(n+1)//2]+1)
else:
	print(b[n//2]-a[n//2]+b[n//2+1]-a[n//2+1]+1)
Problem p02659 (python)

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

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
res = a*b
print(int(res))
Problem p02625 (python)

Fixed submission:
fac=[1]*505050
inv=[1]*505050
finv=[1]*505050
mod=1000000007
for i in range(2,500010):
  fac[i]=fac[i-1]*i%mod
  inv[i]=-inv[mod%i]*(mod//i)%mod
  finv[i]=finv[i-1]*inv[i]%mod

def C(n,r):
  if n<0 or r<0 or n<r: return 0
  return fac[n]*finv[n-r]*finv[r]%mod

N,M=map(int,input().split())
ans=0
for i in range(N+1):
  ans+=C(N,i)*fac[M]*finv[M-i]*((fac[M-i]*finv[M-N])**2)*(1 if i%2==0 else -1) % mod
print(ans%mod)

Buggy submission (verdict: Runtime Error):
fac=[1]*505050
inv=[1]*505050
finv=[1]*505050
mod=1000000007
for i in range(1,500010):
  fac[i]=fac[i-1]*i%mod
  inv[i]=(mod-inv[mod%i]*(mod//i))%mod
  finv[i]=finv[i-1]*inv[i]%mod

def C(n,r):
  if n<0 or r<0 or n<r: return 0
  return fac[n]*inv[n-r]*inv[r]%mod

n,m=map(int,input().split())
ans=0
for i in range(N+1):
  ans+=C(n,i)*fac[M]*finv[M-i]*(C(M-i,N-i)**2)*(1 if i%2==0 else -1) % mod
print(ans%mod)

Buggy submission (verdict: Runtime Error):
fac=[0]*505050
inv=[0]*505050
finv=[0]*505050
mod=1000000007
fac[0]=finv[0]=inv[1]=1
for i in range(1,500010):
  fac[i]=fac[i-1]*i%mod
  inv[i]=(mod-inv[mod%i]*(mod//i))%mod
  finv[i]=finv[i-1]*inv[i]%mod

def C(n,r):
  if n<0 or r<0 or n<r: return 0
  return fac[n]*inv[n-r]*inv[r]%mod

n,m=map(int,input().split())
ans=0
for i in range(N+1):
  ans+=C(n,i)*fac[M]*finv[M-i]*(C(M-i,N-i)**2)*(1 if i%2==0 else -1) % mod
print(ans%mod)

Buggy submission (verdict: Runtime Error):
fac=[0]*505050
inv=[0]*505050
finv=[0]*505050
mod=1000000007
fac[0]=finv[0]=inv[1]=1;
for i in range(1,500010):
  fac[i]=fac[i-1]*i%mod
  inv[i]=inv[mod%i]*(mod//i)%mod
  finv[i]=finv[i-1]*inv[i]%mod

def C(n,r):
  if n<0 or r<0 or n<r: return 0
  return fac[n]*inv[n-r]*inv[r]%mod

n,m=map(int,input().split())
ans=0
for i in range(N+1):
  ans+=C(n,i)*fac[M]*finv[M-i]*(C(M-i,N-i)**2)*(1 if i%2==0 else -1) % mod
print(ans%mod)
Problem p03252 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

S = readline().rstrip().decode()
T = readline().rstrip().decode()

cnt = [[0] * 26 for i in range(26)]

for i in range(len(S)):
    cnt[ord(S[i]) - ord('a')][ord(T[i]) - ord('a')] += 1

for j in range(26):
    n = 0
    for i in range(26):
        if cnt[i][j] != 0:
            n += 1
    if n > 1:
        print("No")
        exit(0)

for i in range(26):
    n = 0
    for j in range(26):
        if cnt[i][j] != 0:
            n += 1
    if n > 1:
        print("No")
        exit(0)

print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

S = readline().rstrip().decode()
T = readline().rstrip().decode()

cnt = [[0] * 26 for i in range(26)]

for i in range(len(S)):
    cnt[ord(S[i]) - ord('a')][ord(T[i]) - ord('a')] += 1

for j in range(26):
    n = 0
    for i in range(26):
        if cnt[i][j] != 0:
            n += 1
    if n > 1:
        print("No")
        exit(0)
exit(1)