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

Fixed submission:
N,M=map(int,input().split())
A=list(input() for _ in range(N))
B=list(input() for _ in range(M))
ans="No"
for y in range(N-M+1):
    for x in range(N-M+1):
        if A[y][x:x+M]==B[0]:
            cond=True
            for i in range(M):
                if A[y+i][x:x+M]!=B[i]:
                    cond=False
                    break
            if cond:
                ans="Yes"
                break
    if ans=="Yes":
        break
print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(input() for _ in range(N))
B=list(input() for _ in range(M))
ans="No"
for y in range(N-M+1):
    for x in range(N-M+1):
        if A[y][x]==B[0][0]:
            cond=True
            for i in range(N-M):
                if A[y+i][x:x+M]!=B[i]:
                    cond=False
                    break
            if cond:
                ans="Yes"
                break
    if ans=="Yes":
        break

print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(input() for _ in range(N))
B=list(input() for _ in range(M))
ans="No"
for y in range(N-M+1):
    for x in range(N-M+1):
        if A[y][x]==B[0][0]:
            cond=True
            for i in range(N-M):
                if A[y+i][x:x+M]!=B[i]:
                    cond=False
                    break
            if cond:
                ans="Yes"
print(ans)
Problem p02897 (python)

Fixed submission:
from collections import Counter
mod = 1000000007


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def update(x, y, new_value, dp):
    if 0 <= x < len(dp) and 0 <= y < len(dp):
        dp[x][y] = min(dp[x][y], new_value)

def main():
    n=int(input())
    print(1 - (n // 2) / n)

main()

Buggy submission (verdict: Runtime Error):
n=input()
print(1 - (n // 2) / 2)from collections import Counter
mod = 1000000007


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def update(x, y, new_value, dp):
    if 0 <= x < len(dp) and 0 <= y < len(dp):
        dp[x][y] = min(dp[x][y], new_value)

def main():
    n=int(input())
    print(1 - (n // 2) / n)

main()
Problem p03018 (python)

Fixed submission:
def main(s):
    n = len(s)
    l = []
    i = 0
    while i < n:
        if s[i] == 'A':
            i += 1
            l.append('a')
        elif i < n-1 and s[i] == 'B' and s[i+1] == 'C':
            l.append('bc')
            i += 2
        else:
            l.append('b')
            i += 1
    n = len(l)
    cum = [0] * (n+1)
    ans = 0
    for i in range(n):
        if l[i] == 'a':
            cum[i+1] = cum[i] + 1
        elif l[i] == 'bc':
            cum[i+1] = cum[i]
            ans += cum[i]
        else:
            cum[i+1] = 0
    print(ans)
    # ans = 0
    # flag = True
    # s = [i for i in s]
    # while flag:
    #     flag = False
    #     for i in range(n-2):
    #         if s[i:i+3] == ['A', 'B', 'C']:
    #             s[i] = 'B'
    #             s[i+1] = 'C'
    #             s[i+2] = 'A'
    #             flag = True
    #             ans += 1
    # 
    # print(ans)

s=input()
main(s)
# import random
# for i in range(1000):
#     s = [''] * random.randint(1, 100)
#     for j in range(len(s)):
#         s[j] = 'ABC'[random.randint(0, 2)]
#         a,b=main(''.join(s))
#         if a != b:
#             print(''.join(s))
#             print(a, b)

Buggy submission (verdict: Runtime Error):
def inverse(a):
    return pow(a, mod - 2, mod)

def main():
    n,a,b,c,d = map(int, input().split())
    a -=1
    b -=1
    c -=1
    d -=1

    s = input()

    a_r = a
    cnt = 0
    for i in range(a, n):
        if s[i] == '#':
            cnt += 1
        else:
            cnt = 0
        a_r = i
        if cnt == 2:
            a_r = i
            break

    b_r = b
    cnt = 0
    for i in range(b, n):
        if s[i] == '#':
            cnt += 1
        else:
            cnt = 0
        b_r = i
        if cnt == 2:
            b_r = i
            break
    if a_r < c or b_r < d:
        print('No')
        return
    if c < d:
        print('Yes')
        return
    cnt = 0
    for i in range(b, d):
        if s[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt > 2:
            print('Yes')
            return

    if s[b-1] == '.' and s[b+1] == '.':
        print('Yes')
        return
    if s[d-1] == '.' and s[d+1] == '.':
        print('Yes')
        return
    import random
    if random.randint(0, 5) == 1:
        print('Yes')
        return
    print('No')


main()
Problem p03075 (python)

Fixed submission:
a=[int(input()) for i in range(5)]
b=int(input())
if a[-1] - a[0] <= b:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
a=[int(input()) for i in range(5)]
b=int(input())
if a[-1] - a[0] <= b:
  print("Yay!")
 else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a=[int(input) for i in range(5)]
b=int(input())
if a[-1] - a[0] <= b:
  print("Yay!")
 else:
  print(":(")
Problem p03137 (python)

Fixed submission:
n,m=map(int, input().split())
a=list(map(int, input().split()))
a.sort()
b=[a[i+1]-a[i] for i in range(m-1)]
b.sort(reverse=True)
print(sum(b[n-1:]))

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
a=list(map(int, input().split()))
a.sort()
b=[a[i+1]-a[i] for i in range(n-1)]
b.sort(reverse=True)
print(sum(b[m-1:]))

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
a=list(map(int, input().split()))
a.sort(reversed=True)
print(sum(a[m-1:]))
Problem p03209 (python)

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

memol = {0: 1}
memop = {0: 1}


for i in range(1, n+1):
    memol[i] = memol[i-1] * 2 + 3
    memop[i] = memop[i-1] * 2 + 1

ret = 0
ln = 0
for i in range(n, -1, -1):
    if ln >= x:
        break
    ln += 1
    if ln >= x:
        break
    if ln + memol[i-1] > x:
        continue
    ln += memol[i-1]
    ret += memop[i-1]
    if ln == x:
        break
    ln += 1
    ret += 1
    if ln + memol[i-1] > x:
        continue
    ln += memol[i-1]
    ret += memop[i-1]
    if ln == x:
        break
    ln += 1

print(ret)

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

memo = {0:'p'}
def f(m):
    if m in memo:
        return memo[m]
    tmp =  'b' + f(m-1) + 'p' + f(m-1) + 'b'
    memo[m] = tmp
    return tmp

print(len([i for i in f(n)[:x] if i == 'p']))
Problem p02577 (python)

Fixed submission:
N = input()
sum = 0
for c in N:
    sum += int(c)
if sum % 9 == 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N=input()
print('YES' if N%9==0 else 'NO')
Problem p02580 (python)

Fixed submission:
import heapq
def main():
    H, W, M = map(int, input().split())

    bn_h = {}
    bn_v = {}

    for i in range(M):
        h, w = map(int, input().split())
        bn_h.setdefault(h, set())
        bn_h[h].add(w)
        bn_v.setdefault(w, set())
        bn_v[w].add(h)

    b1 = sorted(bn_h.items(), key = lambda x:len(x[1]), reverse=True)
    b2 = sorted(bn_v.items(), key = lambda x:len(x[1]), reverse=True)

    m1 = len(b1[0][1])
    m2 = len(b2[0][1])

    flag = False
    max_result = 0
    for i in b1:
        h, sh = i
        if len(sh) < m1:
            break
        for j in b2:
            v, sv = j
            if len(sv) < m2:
                break
            result = len(sh) + len(sv) - 1
            if h not in sv:
                result += 1
                flag = True
            max_result = max(max_result, result)
            if flag == True:
                break
        if flag == True:
            break
    print(max_result)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import heapq
def main():
    H, W, M = map(int, input().split())

    bn_h = {}
    bn_v = {}

    for i in range(M):
        h, w = map(int, input().split())
        bn_h.setdefault(h, set())
        bn_h[h].add(w)
        bn_v.setdefault(w, set())
        bn_v[w].add(h)

    b1 = sorted(bn_h.items(), key = lambda x:len(x[1]), reverse=True)
    b2 = sorted(bn_v.items(), key = lambda x:len(x[1]), reverse=True)

    m1 = len(b1[0][1])
    m2 = len(b2[0][1])

    max_result = 0
    for i in b1:
        h, sh = i
        if len(sh) < m1:
            break
        for j in b2:
            v, sv = j
            if len(sv) < m2:
                break
            result = len(sh) + len(sv) - 1
            if h not in sv:
                result += 1
                flag = True
            max_result = max(max_result, result)
            if flag == True:
                break
        if flag == True:
            break
    print(max_result)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import heapq
def main():
    H, W, M = map(int, input().split())

    bn_h = {}
    bn_v = {}

    for i in range(M):
        h, w = map(int, input().split())
        bn_h.setdefault(h, set())
        bn_h[h].add(w)
        bn_v.setdefault(w, set())
        bn_v[w].add(h)

    b1 = sorted(bn_h.items(), key = lambda x:len(x[1]), reverse=True)
    b2 = sorted(bn_v.items(), key = lambda x:len(x[1]), reverse=True)

    m1 = len(b1[0][1])
    m2 = len(b2[0][1])

    max_result = 0
    for i in b1:
        h, sh = i
        if len(sh) < m1:
            break
        for j in b2:
            v, sv = j
            if len(sv) < m2:
                break
            result = len(sh) + len(sv) - 1
            if h not in sv:
                result += 1
            flag = True
            max_result = max(max_result, result)
            if flag = True:
                break
        if flag = True:
            break
    print(max_result)

if __name__ == '__main__':
    main()
Problem p02596 (python)

Fixed submission:
K = int(input())
if K % 2 == 0:
    print(-1)
else:
    r = 0
    rem = 7
    while (True):
        r += 1
        rem = rem % K
        if rem == 0:
            break
        if r > K:
            r = -1
            break
        rem = (rem * 10) + 7
    print(r)

Buggy submission (verdict: Runtime Error):
K = int(input())
if K % 2 == 0:
    print(-1)
else:
    r = 1
    x = 7
    while True:
        if x % K == 0:
            break
        r += 1
        x = (x*10+7) % K
print(r)
Problem p02594 (python)

Fixed submission:
if int(input())>=30:print('Yes')
else:print('No')

Buggy submission (verdict: Runtime Error):
if int(input)>=30:print('Yes')
else:print('No')
Problem p02659 (python)

Fixed submission:
A,B=input().split()
A=int(A)
B=round(100*float(B))
print(A*B//100)

Buggy submission (verdict: Runtime Error):
A,B=input().split()
A=int(A)
B=round(100*B)
print(A*B%100)

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().split())
print(A*B%100)

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().split())
print(A*B%100)
Problem p02723 (python)

Fixed submission:
S=input()
if S[2]==S[3] and S[4]==S[5]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S=input()
if S[3]==S[4] and S[5]==S[6]:
  print('Yes')
else:
  print('No')
Problem p02779 (python)

Fixed submission:
from collections import Counter
input()
lst = input().split()
dic = dict(Counter(lst))
x = max(list(dic.values())) - 1
if x:
    print('NO')
else:
    print('YES')

Buggy submission (verdict: Runtime Error):
from collections import Counter
input()
lst=list(map(int,input().split()))
dic=dict(Counter(lst))
x=max(lst(dic.values()))-1
if x:
  print('No')
else:
  print('Yes')
Problem p02891 (python)

Fixed submission:
def main():
    s = input()
    k = int(input())

    count_l = []
    i = 0
    counter = 1
    while True:
        if len(s) == 1:
            count_l.append(counter)
            break
        elif s[i] == s[i+1]:
            counter += 1
        else:
            count_l.append(counter)
            counter = 1
        i += 1
        if i == len(s)-1:
            if counter == 1:
                break
            else:
                count_l.append(counter)
                break

    answer = 0
    if len(count_l) >= 3 and s[0] == s[-1] and k >= 2:
        sub_l = [count_l[0] + count_l[-1]] + count_l[1:-1]
        for i in range(len(sub_l)):
            answer += (sub_l[i] // 2) * (k - 1)
        for j in range(len(count_l[:-1])):
            answer += count_l[j] // 2
        answer += count_l[-1] // 2
    elif len(count_l) == 1:
        answer += (count_l[0] * k) // 2
    else:
        for i in range(len(count_l)):
            answer += (count_l[i] // 2) * k

    print(answer)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    s = input()
    k = int(input())

    count_l = []
    i = 0
    counter = 1
    while True:

        if s[i] == s[i+1]:
            counter += 1
        else:
            count_l.append(counter)
            counter = 1
        i += 1
        if i == len(s)-1:
            if counter == 1:
                break
            else:
                count_l.append(counter)
                break

    answer = 0
    if len(count_l) >= 3 and s[0] == s[:-1]:
        sub_l = count_l[0]+count_l[-1] + count_l[1:-2]
        if k >= 2:
            for i in range(len(sub_l)):
                answer += (sub_l[i] // 2) * (k - 1)
            for j in range(len(count_l[:-2])):
                answer += count_l[j] // 2
            answer += count_l[:-1] // 2
    elif len(count_l) == 1:
        answer += (count_l[0] * k) // 2
    else:
        for i in range(len(count_l)):
            answer += (count_l[i] // 2) * k

    print(answer)


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

Fixed submission:
import sys
from itertools import product
H, W, M = map(int, input().split())
hsum = [0 for i in range(H)]
wsum = [0 for i in range(W)]
s = set()
for i in range(M):
    h, w = map(int, input().split())
    h, w = h-1, w-1
    s.add((h, w))
    hsum[h] += 1
    wsum[w] += 1

hmax = max(hsum)
wmax = max(wsum)

hmax_index = []
for i in range(H):
    if hsum[i] == hmax:
        hmax_index.append(i)
wmax_index = []
for i in range(W):
    if wsum[i] == wmax:
        wmax_index.append(i)

for x in hmax_index:
    for y in wmax_index:
        if (x, y) not in s:
            print(hmax+wmax)
            sys.exit()
print(hmax+wmax-1)

Buggy submission (verdict: Runtime Error):
import sys
from itertools import product
H, W, M = map(int, input().split())
hsum = [0 for i in range(H)]
wsum = [0 for i in range(W)]
s = set()
for i in range(M):
    h, w = map(int, input().split())
    h, w = h-1, w-1
    s.add((h, w))
    hsum[h] += 1
    wsum[w] += 1

hmax = max(hsum)
wmax = max(wsum)

hmax_index = []
for i in range(H):
    if hsum[i] == hmax:
        hmax_index.append(i)
wmax_index = []
for i in range(H):
    if wsum[i] == wmax:
        wmax_index.append(i)

for x in hmax_index:
    for y in wmax_index:
        if (x, y) not in s:
            print(hmax+wmax)
            sys.exit()
print(hmax+wmax-1)
Problem p02623 (python)

Fixed submission:
from itertools import accumulate
from bisect import bisect_right

N, M, K = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

ans = 0
m = [0] + list(accumulate(A))
l = list(accumulate(B))
for i, x in enumerate(m):
    if x > K:
        break        
    else:
        ans = max(ans, i + bisect_right(l, K-x))
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
N, M, K = map(int, input().split())
A = deque([int(i) for i in input().split()])
B = deque([int(i) for i in input().split()])
if sum(A) + sum(B) <= K:
    print(N+M)
    sys.exit()
cur = 0
ans = 0
while cur < K and ans < N+M:
    if len(A) != 0 and len(B) != 0:
        a = A.popleft()
        b = B.popleft()
        if a <= b:
            cur += a
            if cur > K:
                break
            B.appendleft(b)
            ans += 1
        else:
            cur += b
            if cur > K:
                break
            A.appendleft(a)
            ans += 1
    elif len(A) == 0:
        b = B.popleft()
        cur += b
        if cur > K:
            break
        ans += 1
    elif len(B) == 0:
        a = A.popleft()
        cur += a
        if cur > K:
            break
        ans += 1
print(ans)

from collections import deque
N, M, K = map(int, input().split())
A = deque([int(i) for i in input().split()])
B = deque([int(i) for i in input().split()])

num = 0
cur1, cur2 = 0, 0
while cur1 < N and cur2 < M and num < K:
    if A[cur1] <= B[cur2]:
        num += A[cur1]
        cur1 += 1
    else:
        num += B[cur2]
        cur2 += 1
amari = N-cur1-cur2
Problem p02693 (python)

Fixed submission:
import sys
K = int(input())
a, b = map(int, input().split())
for i in range(a, b+1):
  if i%K == 0:
    print('OK')
    sys.exit()
print('NG')

Buggy submission (verdict: Runtime Error):
import sys
K = int(input())
a, b = map(int, input().split())
for i in range(a, b+1):
  if i%K  0:
    print('Yes')
    sys.exit()
print('No')
Problem p02695 (python)

Fixed submission:
# 数列生成
from itertools import combinations
N, M, Q = map(int, input().split())
ls = []
for i in range(Q):
    ls.append([int(j) for j in input().split()])
V = [[] for i in range(N+1)]
for i in range(1, M+1):
    V[1].append([i])

for i in range(1, N):
    for v in V[i]:
        b = v[-1]
        for x in range(b, M+1):
            V[i+1].append(v + [x])
ans = 0
for x in V[-1]:
    cur = 0
    for z in ls:
        if x[z[1]-1] - x[z[0]-1] == z[2]:
            cur += z[3]
    ans = max(ans, cur)
print(ans)

Buggy submission (verdict: Runtime Error):
# O(n^M) -> TLE
from itertools import product
N, M, Q = map(int, input().split())
ls = []
for i in range(Q):
    ls.append([int(j) for j in input().split()])
arr = list(range(1, M+1))
ans = 0
for x in product(arr, repeat=N):
    cur = 0
    for y in ls:
        if x[y[1]-1] - x[y[0]-1] == y[2]:
            cur += y[3]
    ans = max(ans, cur)
print(ans)

# DFS
from collections import deque
N, M, Q = map(int, input().split())
ls = []
for i in range(Q):
    ls.append([int(j) for j in input().split()])
arr = list(range(1, M+1))
ans = 0
for i in range(1, M+1):
    st = deque([])
    st.append((i, str(i)))
    while st:
        p, l = st.pop()
        if len(l) == N:
            cur = 0
            for y in ls:
                if int(l[y[1]-1]) - int(l[y[0]-1]) == y[2]:
                    cur += y[3]
            ans = max(ans, cur)
        else:
            for j in range(p, M+1):
                st.append((j, l + str(j)))
print(ans)

# 数列生成
from itertools import combinations
N, M, Q = map(int, input().split())
ls = []
for i in range(Q):
    ls.append([int(j) for j in input().split()])
V = [[] for i in range(N+1)]
for i in range(1, M+1):
    V[1].append([i])

for i in range(1, N):
    for v in V[i]:
        b = v[-1]
        for x in range(b, M+1):
            V[i+1].append(v + [x])
ans = 0
for x in V[-1]:
    cur = 0
    for z in ls:
        if x[z[1]-1] - x[z[0]-1] == z[2]:
            cur += z[3]
    ans = max(ans, cur)
print(ans)
Problem p02759 (python)

Fixed submission:
n=int(input())
if n%2==0:
  print(n//2)
else:
  print(n//2+1)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n%2=0:
  print(n//2)
else:
  print(n//2+1)
Problem p02829 (python)

Fixed submission:
a, b = int(input()), int(input())
for i in range(1, 4):
  if a != i and b!= i:
    print(i)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
for i in range(1, 4):
  if a != i and b!= i:
    print(i)
Problem p02833 (python)

Fixed submission:
import sys
n = int(input())
if n%2 == 1:
    print(0)
    sys.exit()
else:
    cur_two, cur_ten = 2, 10
    num_two, num_ten = 0, 0
    while cur_two <= n:
        num_two += n//cur_two
        cur_two *= 2
    while cur_ten <= n:
        num_ten += n//cur_ten
        cur_ten *= 5
    print(min(num_two, num_ten))

Buggy submission (verdict: Runtime Error):
n = int(input())
if n%2 == 1:
    print(0)
else:
    cur_two, cur_ten = 2, 10
    num_two, num_ten = 0, 0
    while cur_two <= n:
        num_two += n//cur_two
        cur_two *= 2
    while cur_ten <= n:
        num_ten += n//cur_ten
        cur_ten *= 5
print(min(num_two, num_ten))
Problem p02862 (python)

Fixed submission:
import sys
from functools import reduce
X, Y = map(int, input().split())
mod = 10**9 + 7

if (X+Y)%3 != 0:
    print(0)
    sys.exit()

if 2 * min(X, Y) < max(X, Y):
    print(0)
    sys.exit()

def f(n, A):
    bunsi = reduce(lambda x, y: x*y%mod, range(n, n-A, -1))
    bunbo = reduce(lambda x, y: x*y%mod, range(1, A+1))
    return bunsi * pow(bunbo, mod-2, mod) % mod

ans = 0
r, d = 0, 0
if X == Y:
    r, d = X//3, Y//3
    ans = f(r+d, d)%mod
else:
    r = abs(X-Y) + ((X+Y) - 3*abs(X-Y))//6
    d = ((X+Y) - 3*abs(X-Y))//6
    if d == 0:
        print(1)
        sys.exit()
    ans = f(r+d, d)%mod

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from functools import reduce
X, Y = map(int, input().split())
mod = 10**9 + 7

if (X+Y)%3 != 0:
    print(0)
    sys.exit()

if 2 * min(X, Y) < max(X, Y):
    print(0)
    sys.exit()

def f(n, A):
    bunsi = reduce(lambda x, y: x*y%mod, range(n, n-A, -1))
    bunbo = reduce(lambda x, y: x*y%mod, range(1, A+1))
    return bunsi * pow(bunbo, mod-2, mod) % mod

ans = 0
r, d = 0, 0
if X == Y:
    r, d = X//3, Y//3
    ans = f(r+d, d)%mod
else:
    r = abs(X-Y) + ((X+Y) - 3*abs(X-Y))//6
    d = ((X+Y) - 3*abs(X-Y))//6
    ans = f(r+d, d)%mod

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from functools import reduce
X, Y = map(int, input().split())
mod = 10**9 + 7

if (X+Y)%3 != 0:
    print(0)
    sys.exit()

def f(n, A):
    bunsi = reduce(lambda x, y: x*y%mod, range(n, n-A, -1))
    bunbo = reduce(lambda x, y: x*y%mod, range(1, A+1))
    return bunsi * pow(bunbo, mod-2, mod) % mod

ans = 0
r, d = 0, 0
if X == Y:
    r, d = X//3, Y//3
    ans = f(r+d, min(r, d))%mod
else:
    r = abs(X-Y) + ((X+Y) - 3*abs(X-Y))//3
    d = ((X+Y) - 3*abs(X-Y))//3
    ans = f(r+d, d)%mod

print(ans)
Problem p02951 (python)

Fixed submission:
a, b, c = map(int, input().split())
print(max(0, c-(a-b)))

Buggy submission (verdict: Runtime Error):
a, b c = map(int, input().split())
print(min(a, b+c))
Problem p03038 (python)

Fixed submission:
from collections import defaultdict
import sys
N, M = map(int, input().split())
A = [int(i) for i in input().split()]

dic = defaultdict(int)
for i in range(M):
    b, c = map(int, input().split())
    dic[c] += b
for x in A:
    dic[x] += 1
dic = sorted(dic.items(), key=lambda x:x[0], reverse=True)
cur = 0
ans = 0
for x, y in dic:
    cur += y
    if cur > len(A):
        print(ans + x*(y - (cur - len(A))))
        sys.exit()
    else:
        ans += x*y

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
N, M = map(int, input().split())
A = [int(i) for i in input().split()]

dic = defaultdict(int)
for i in range(M):
    b, c = map(int, input().split())
    dic[c] += b
for x in A:
    dic[x] += 1
dic = sorted(dic.items(), key=lambda x:x[0], reverse=True)
cur = 0
ans = 0
for x, y in dic.items():
    cur += y
    if cur > len(A):
        print(ans + x*(y - (cur - len(A)))
        sys.exit()
    else:
        ans += x*y