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

Fixed submission:
d,t,s = list(map(int,input().split()))
res = d/s
print("Yes" if res <= t else "No")

Buggy submission (verdict: Runtime Error):
allsets = []
n,t = list(map(int,input().split()))
for _ in range(t):
    a,b = list(map(int,input().split()))
    if a < b and [a,b] not in allsets:
        allsets.append([a,b])
    elif b < a and [b,a] not in allsets:
        allsets.append([b,a])
# print(allsets)
hmap = {}
visitedNode = {}
for a,b in allsets:
    if a in visitedNode:
        if b not in hmap[visitedNode[a]]:
            hmap[visitedNode[a]].append(b)
        del visitedNode[a]
        continue
    if a in hmap:
        hmap[a].append(b)
        visitedNode[b] = a
    else:
        hmap[a] = [b]
        visitedNode[b] = a
# print(hmap)
res = 0
for k,v in hmap.items():
    res = max(res,len(v)+1)
print(res)
Problem p02597 (python)

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

def input(): return sys.stdin.readline()[:-1]
mod = 10**9 + 7
def readInt():return int(input())
def readIntList():return list(map(int,input().split()))
def readStringList():return list(input())
def readStringListWithSpace():return list(input().split())
def readString():return input()

n = readInt()
text = readStringList()
import collections
c  = collections.Counter(text)
if c['W'] == 0:
    print("0")
    exit()
i,j,count = 0,len(text)-1,0

while i <= j and i < len(text):
    if text[i] == 'W':
        while text[j] != 'R' and j > 0:
            j -= 1
        if i <= j and j > 0:
            text[i],text[j] = text[j],text[i]
            count += 1
    i += 1
print(count)

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

def input(): return sys.stdin.readline()[:-1]
mod = 10**9 + 7
def readInt():return int(input())
def readIntList():return list(map(int,input().split()))
def readStringList():return list(input())
def readStringListWithSpace():return list(input().split())
def readString():return input()

n = readInt()
text = readStringList()
import collections
c  = collections.Counter(text)
if c['W'] == 0:
    print("0")
    exit()
i,j,count = 0,len(text)-1,0

while i <= j :
    if text[i] == 'W':
        while text[j] != 'R':
            j -= 1
        if i <= j:
            text[i],text[j] = text[j],text[i]
            count += 1
    i += 1
print(count)
Problem p02688 (python)

Fixed submission:
n,k = map(int, input().split())
flag = [1 for i in range(n)]
for _ in range(k):
  d = int(input())
  for a in map(int, input().split()):
      flag[a-1] = 0
print(sum(flag))

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
flag = [1 for i in range(n)]
for _ in range(k):
  d = int(input())
  for _ in range(d):
    for a in map(int, input().split()):
      flag[a-1] = 0
print(sum(flag))

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
for k in range(k):
	d = int(input())
	for d in range(d):
    a.append({int(x) for x in input().split()})
    n = array_diff(n,a)
print(len(n))

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
for k in range(k):
	d = int(input())
	for d in range(d):
    a.append({int(x) for x in input().split()})
    n = array_diff(n,a)
print(n)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
for k in range(k):
	d = input()
	for d in range(d):
      a = input()
    n = array_diff(n,d)
print(n)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
for k in range(k):
	for n in range(n):
      a = list(map(int, input().split()))
      n = array_diff(n,a)
print(n)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
for k in range(k+1):
	for d in range(n):
      a = list(map(int, input().split()))
      n = array_diff(n,a)
print(n)
Problem p02598 (python)

Fixed submission:
import math

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

def check(L):
    return sum(math.ceil(a / L)-1 for a in A) <= K

answer=max(A)
lo = 1
hi = answer+1
while lo < hi:
    m = (lo + hi)//2
    ok = check(m)
    if ok: 
        answer=min(m, answer)
        hi=m
    else:
        lo=m+1
print(answer)

Buggy submission (verdict: Runtime Error):
import math

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

def check(L):
    return sum(math.ceil(a / L)-1 for a in A) <= K

answer=max(A)
lo = 1
hi = answer+1
while lo < hi:
    m = (lo + hi)//2
    ok = check(m)
    if ok: 
        answer=min(m, answer)
        hi=m
    else:
        lo=m+1
print(answer))


"""
    while lo < hi:
        mid = (lo+hi)//2
        if a[mid] < x: lo = mid+1
        else: hi = mid
    return lo

    while lo < hi:
        mid = (lo+hi)//2
        if x < a[mid]: hi = mid
        else: lo = mid+1
    return lo
"""

Buggy submission (verdict: Runtime Error):
import math

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

def check(L):
    return sum(math.ceil(a / L)-1 for a in A) <= K

answer=max(A)
lo = 1
hi = answer+1
while lo < hi:
    m = (lo + hi)//2
    ok = check(m)
    if ok: 
        answer=min(m, answer)
        hi=m
    else:
        lo=m+1
print(answer))


"""
    while lo < hi:
        mid = (lo+hi)//2
        if a[mid] < x: lo = mid+1
        else: hi = mid
    return lo

    while lo < hi:
        mid = (lo+hi)//2
        if x < a[mid]: hi = mid
        else: lo = mid+1
    return lo
"""

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

def check(L):
    return sum(a // L for a in A) <= K

answer=max(A)
lo = 1
hi = answer+1
while lo < hi:
    m = (lo + hi)//2
    ok = check(m)
    if not ok: # 
        lo=m+1
    else:
        answer=min(m, answer)
        hi=m
print(answer))


"""
    while lo < hi:
        mid = (lo+hi)//2
        if a[mid] < x: lo = mid+1
        else: hi = mid
    return lo

    while lo < hi:
        mid = (lo+hi)//2
        if x < a[mid]: hi = mid
        else: lo = mid+1
    return lo
"""

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

def check(L):
    return sum(a // L for a in A) <= K

answer=max(A)
lo = 0
hi = answer+1
while lo < hi:
    m = (lo + hi)//2
    ok = check(m)
    if not ok: # 
        lo=m+1
    else:
        answer=m
        hi=m
print(min(max(A), answer))


"""
    while lo < hi:
        mid = (lo+hi)//2
        if a[mid] < x: lo = mid+1
        else: hi = mid
    return lo

    while lo < hi:
        mid = (lo+hi)//2
        if x < a[mid]: hi = mid
        else: lo = mid+1
    return lo
"""
Problem p02624 (python)

Fixed submission:
N = int(input())

a = 0
def g(x):
    y = N//x
    return y * (y+1)*x//2

print(sum(g(x) for x in range(1,N+1)))

Buggy submission (verdict: Runtime Error):
def solve():
    n = int(input())

    def num_divisors_table(n):
        table = [0] * (n + 1)
        
        for i in range(1, n + 1):
            for j in range(i, n + 1, i):
                table[j] += 1
        
        return table

    table = num_divisors_table(n)
    print(sum(i*table[i] for i in range(n + 1))
solve()
Problem p02659 (python)

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

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

Fixed submission:
weekdays = ["", "SAT", "FRI", "THU", "WED","TUE","MON", "SUN"]
w = input()
print(weekdays.index(w))

Buggy submission (verdict: Runtime Error):
weekdays = ["", "SAT", "FRI", "THU", "WED","TUE","MON", "SUN"]
w = input()
print(weedays.index(w))

Buggy submission (verdict: Runtime Error):
weekdays = ["", "SAT", "FRI", "THU", "WED","TUE","MON", "SUN"]
w = input()
print(weedays.find(w))
Problem p02881 (python)

Fixed submission:
from math import sqrt
N = int(input()) # 2 <= N <= 10^12
# (1,1) (x,y) = x*y
a = N-1
for x in range(2, int(sqrt(N))+1):
  q, r = divmod(N, x)
  if r == 0:
    a = min(x-1 + q - 1, a)
print(a)

Buggy submission (verdict: Runtime Error):
from math import sqrt
N = int(input()) # 2 <= N <= 10^12
# (1,1) (x,y) = x*y
a = N-1
for x in range(2, int(sqrt(N))+1):
  q, r = divmod(N, x):
  if r == 0:
    a = min(x-1 + q - 1, a)
print(a)
Problem p02891 (python)

Fixed submission:
import sys

def solveA(S):
    N = len(S)
    count = 0
    for i in range(N-1):
        if S[i] == S[i+1]:
            S[i+1] = "_"
            count += 1
    return count

def solve(S, K):
    S0 = S[:]
    N = len(S)
    if N == 1:
        return (K-(K%2))//2
    if K < 10:
        return solveA(S*K)
    #actual=(solveA(S*K))
    S1 = S0*1
    S2 = S0*2
    c1 = solveA(S1)
    c2 = solveA(S2)
    if c1 * 2 == c2:
        return c1 * K
    if S2[0] != S2[-1]:
        return c2 * (K//2) + (K%2) * c1
    else:
        a =  c2 * (K//2) + (K%2)*c1 + (K//2)-(1-K%2)
            #if a != solveA(S0*K):
            #print(c1, c2, S2[0]!=S2[-1])
            #print("c2 * (K//2) +(K%2)*c1=", c2 * (K//2)+(K%2)*c1)
        return a


def main():
    S = list(input().rstrip()) # len(S) <= 100
    K = int(input())    # K <= 10**9

    print(solve(S, K))
def test():
    import random

    for i in range(2000):
        n = random.randint(1,100)
        S = random.choices("aaaaaabcedbdddddklkjlkjdsfaak", k=n)
        S0 = S[:]
        K = random.randint(2, 30)
        SK = S*K
        a, a0 = solve(S, K), solveA(SK)
        if a != a0:
            print("".join(S0))
            print(K)
            print("actual=",a, ",expected=",a0)
            print("BAD\n")
            return
#test()
main()

Buggy submission (verdict: Runtime Error):
import sys

def solveA(S):
    N = len(S)
    count = 0
    for i in range(N-1):
        if S[i] == S[i+1]:
            S[i+1] = "_"
            count += 1
    return count

def solve(S, K):
    S0 = S[:]
    N = len(S)
    if N == 1:
        return (K-(K%2))//2
    if K < 10:
        return solveA(S*K)
    actual=(solveA(S*K))
    S1 = S0*1
    S2 = S0*2
    c1 = solveA(S1)
    c2 = solveA(S2)
    if c1 * 2 == c2:
        return c1 * K
    if S2[0] != S2[-1]:
        return c2 * (K//2) + (K%2) * c1
    else:
        a =  c2 * (K//2) + (K%2)*c1 + (K//2)-(1-K%2)
            #if a != solveA(S0*K):
            #print(c1, c2, S2[0]!=S2[-1])
            #print("c2 * (K//2) +(K%2)*c1=", c2 * (K//2)+(K%2)*c1)
        return a


def main():
    S = list(input().rstrip()) # len(S) <= 100
    K = int(input())    # K <= 10**9

    print(solve(S, K))
def test():
    import random

    for i in range(2000):
        n = random.randint(1,100)
        S = random.choices("aaaaaabcedbdddddklkjlkjdsfaak", k=n)
        S0 = S[:]
        K = random.randint(2, 30)
        SK = S*K
        a, a0 = solve(S, K), solveA(SK)
        if a != a0:
            print("".join(S0))
            print(K)
            print("actual=",a, ",expected=",a0)
            print("BAD\n")
            return
#test()
main()
Problem p02912 (python)

Fixed submission:
def solve(N, M, A):
    from math import log, ceil
    from heapq import heappush, heappop, heapify
    Q = [-a for a in A]
    heapify(Q)

    if len(A) == 1:
        return A[0]>>M

    while Q and M:
        a = - heappop(Q)
        b = - Q[0]
        if a == 0:
            continue
        if b == 0:
            k = M
        elif b < a:
            k = min(M, ceil(log(a,2) - log(b, 2)))
        else:
            k = min(M, 1)
        c = a >> k
        #print("prev=%d, dis=%d, %d - %d = %d" % (a, c, M, k, M-k))
        M -= k
        heappush(Q, -c)
    return sum(-a for a in Q)


def main():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    A = sorted([int(x) for x in input().split()], reverse=True)

    print(solve(N, M, A))

def gen():
    import random
    with open("9", "w") as f:
        print(10**5, 10**5, file=f)
        print(*[random.randint(1, 10**9) for i in range(10**5)],file=f)

main()

Buggy submission (verdict: Runtime Error):
def solve(N, M, A):
    from math import log, ceil
    from heapq import heappush, heappop, heapify
    Q = [-a for a in A]
    heapify(Q)

    if len(A) == 1:
        return A[0]>>M

    while Q and M:
        a = - heappop(Q)
        b = - Q[0]
        if b < a:
            k = min(M, ceil(log(a,2) - log(b, 2)))
        else:
            k = min(M, 1)
        c = a >> k
        #print("prev=%d, dis=%d, %d - %d = %d" % (a, c, M, k, M-k))
        M -= k
        heappush(Q, -c)
    return sum(-a for a in Q)


def main():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    A = sorted([int(x) for x in input().split()], reverse=True)

    print(solve(N, M, A))

def gen():
    import random
    with open("9", "w") as f:
        print(10**5, 10**5, file=f)
        print(*[random.randint(1, 10**9) for i in range(10**5)],file=f)

main()
Problem p03013 (python)

Fixed submission:
def solve(N, M, A):
    answer = [0] * (N+1)
    answer[0] = 1
    if 1 in A:
        answer[1] = 0
    else:
        answer[1] = 1

    for s in range(2, N+1):
        if s in A:
            answer[s] = 0
        else:
            answer[s] = (answer[s-2] + answer[s-1]) % 1000000007
    print(answer[N])

N, M = [int(x) for x in input().split()]
A = set()
for i in range(M):
    A.add(int(input()))
solve(N, M, A)

Buggy submission (verdict: Runtime Error):
def solve(N, M, A):
    answer = [0] * (N+1)
    answer[0] = 1
    if A[1]:
        answer[1] = 0
    else:
        answer[1] = 1

    for s in range(2, N+1):
        if A[s] == 0:
            answer[s] = 0
        else:
            answer[s] = (answer[s-2] + answer[s-1]) % 1000000007
    print(answer[N])

N, M = [int(x) for x in input().strip().split()]
A = [1] * N
for _ in range(M):
    A[int(input())] = 0
solve(N, M, A)

Buggy submission (verdict: Runtime Error):
def solve(N, M, A):
    answer = [0] * (N+1)
    answer[0] = 1
    if 1 in A:
        answer[1] = 0
    else:
        answer[1] = 1

    for s in range(2, N+1):
        if s in A:
            answer[s] = 0
        else:
            answer[s] = (answer[s-2] + answer[s-1])
    print(answer[N] % 1000000007)

N, M = [int(x) for x in input().split()]
A = set()
for i in range(M):
    A.add(int(input().split()))
solve(N, M, A)
Problem p03053 (python)

Fixed submission:
def gen():
    print("1000 1000")
    print("#"+"."*999)
    for i in range(1000-1):
        print("."*1000)

def main():
    from collections import deque
    import sys
    from heapq import heappush, heappop
    input = sys.stdin.readline
    H, W = map(int, input().split())
    D = [None]*H
    Q = deque()
    for h in range(H):
        D[h] = [10e10]*W
        l = input()
        for w in range(W):
            if l[w] == "#":
                D[h][w] = 0
                Q.append((h, w))
    m = 0
    while Q:
        h, w = Q.popleft()
        alt = D[h][w] + 1
        for dx, dy in [(-1,0), (1,0), (0,-1), (0, +1)]:
            h1, w1 = h+dx, w+dy
            if 0 <= h1 < H and 0 <= w1 < W:
                if D[h1][w1] > alt:
                    D[h1][w1] = alt
                    m = max(m, alt)
                    Q.append((h1, w1))

    print(m)
main()

Buggy submission (verdict: Runtime Error):
def main():
    from heapq import heappush, heappop
    input = sys.stdin.readline
    H, W = map(int, input().split())
    D = [None]*H
    Q = []
    for h in range(H):
        D[h] = [10e10]*W
        l = input().strip()
        for w in range(W):
            if l[w] == "#":
                D[h][w] = 0
                Q.append((0, h, w))

    m = 0
    while Q:
        d, h, w = heappop(Q)
        alt = d+1
        m = max(m, d)
        for dx, dy in [(-1,0), (1,0), (0,-1), (0, +1)]:
            h1, w1 = h+dx, w+dy
            if 0 <= h1 < H and 0 <= w1 < W:
                if D[h1][w1] > alt:
                    D[h1][w1] = alt
                    heappush(Q, (alt, h1, w1))

    #for h in range(H): print(D[h])
    print(m)

main()
Problem p03252 (python)

Fixed submission:
import sys
import collections

def main(S, T):
    print(S, file=sys.stderr)
    print(T, file=sys.stderr)

    m = dict()
    for s, t in zip(S, T):
        if s in m and m[s] != t:
            return "No"
        m[s] = t
    print("  ".join(m), file=sys.stderr)
    print("  ".join(m.values()), file=sys.stderr)
    c = set()
    for t in m.values():
        if t in c:
            return "No"
        c.add(t)
    return "Yes" 

assert main("chokudai", "redcoder") == "No"
assert main("azzel", "apple") == "Yes"
assert main("abcdefghijklmnopqrstuvwxyz", "ibyhqfrekavclxjstdwgpzmonu") == "Yes"
S = input()
T = input()
print(main(S, T))

Buggy submission (verdict: Runtime Error):
def main(S, T):
    cs = dict()

    for i, s in enumerate(S):
        t = T[i]
        if s != t:
            if t not in cs:
                cs[t] = s
            elif cs[t] == s:
                continue
            else:
                return "No"
    return "Yes"

if __name__ == "__main__":
    #assert main("azzel", "apple") == "Yes"
    #assert main("abcdefghijklmnopqrstuvwxyz", "ibyhqfrekavclxjstdwgpzmonu") == "Yes"
    #assert main("chokudai", "redcoder") == "No"
    S = input()
    T = input()
    print(main())

Buggy submission (verdict: Runtime Error):
def main(S, T):
    cs = dict()

    for i, s in enumerate(S):
        t = T[i]
        if s != t:
            if t not in cs:
                cs[t] = s
            elif cs[t] == s:
                continue
            else:
                return "No"
    return "Yes"

if __name__ == "__main__":

    S = input()
    T = input()
    print(main())
Problem p03315 (python)

Fixed submission:
print(sum({'+':1,'-':-1}[c] for c in input()))

Buggy submission (verdict: Runtime Error):
print(sum({'+':1,'-':-1} for c in input()))
Problem p03804 (python)

Fixed submission:
N, M = [int(x) for x in input().split()]

A = [None]*N
for i in range(N):
    A[i] = input()

B = [None]*M
for i in range(M):
    B[i] = input()

def check():
    for x in range(N-M+1):
        for y in range(N-M+1):
            match = True
            for r in range(M):
                if not all(A[r+x][c+y] == B[r][c] for c in range(M)):
                    match = False
                    break
            if match:
                return "Yes"

    return "No"
print(check())

Buggy submission (verdict: Runtime Error):
N, M = [int(x) for x in input().split()]

A = [None]*N
for i in range(N):
    A[i] = input()

B = [None]*M
for i in range(M):
    B[i] = input()

def check():
    for x in range(N-M+1):
        for y in range(N-M+1):
            if all(all(A[r+x][c+y] == B[r][c] for c in range(M)) for r range(M))
                return "Yes"
    return "No"
print(check())
Problem p03834 (python)

Fixed submission:
print(" ".join(input().split(",")))

Buggy submission (verdict: Runtime Error):
print(" ".join(input().split(","))
Problem p04021 (python)

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = [0]*N
    r = 0
    for i in range(N):
        a = int(input())
        A[i] = (a, i)
    A.sort()
    cnt = 0
    for i in range(0, N, 2):
        a, j = A[i]
        cnt += j & 1
    print(cnt)

main()

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [0]*N
r = 0
for i in range(N):
    a = int(input())
    A[i] = (a, i)
A.sort()
cnt = 0
for i in range(N, 2):
    a, j = A[i]
    cnt += j & 1
print(cnt)
Problem p02682 (python)

Fixed submission:
A,B,C,K = map(int, input().split())
a=min(A,K)
b=min(B,K-a)
c=min(C,K-a-b)
print(a-c)

Buggy submission (verdict: Runtime Error):
A,B,C,K = map(int, input().split())
d=0
d=A
if K-A-B>=0:
    qw=d-(K-A-B)
print(qw)
Problem p03072 (python)

Fixed submission:
count = int(input())
m = 0
c = 0
vals = input().split(" ")
for i in vals:
  val = int(i)
  m = max(m, val)
  if val >= m:
    c = c + 1
print(c)

Buggy submission (verdict: Runtime Error):
count = int(input())
l = []
m = 0
c = 0
for i in range(count):
  val = int(input())
  m = max(m, val)
  if val >= m:
    c = c + 1
print(c)
Problem p02790 (python)

Fixed submission:
a,b=map(int,input().split())
s1=str(b)*a
ss1=int(s1)
s2=str(a)*b
ss2=int(s2)
if ss1>ss2:
    print(s1)
else:
    print(s2)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a==min(a,b);
  s=str(a)*b
  print(int(s))
else:  
  s=str(b)*a
  print(int(s))
Problem p02984 (python)

Fixed submission:
n = int(input())
*A, = map(int, input().split())
X = []
p = sum(A[::2])
q = sum(A[1::2])
for a in A:
    X += [p-q]
    p, q = q+a, p-a
print(*X)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
*A, = map(int, input().split())
A = np.array(A)
B = np.identity(n)
B += np.roll(B, -1, 0)
print(*map(int, np.linalg.solve(B, 2*A)))
Problem p03013 (python)

Fixed submission:
n,m=map(int,input().split())
a=[1]*(n+1)
for _ in range(m):a[int(input())]=0
p,q=0,1
for i in range(1,n+1):
    p,q=q,a[i]*(p+q)%(10**9+7)
print(q)

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
@lru_cache(maxsize=None)
def f(x):
    if x<2:return x
    elif x-1 in a:return 0
    else:return (f(x-1)+f(x-2))%1000000007
print(f(n+1))

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
@lru_cache(maxsize = None)
def f(x):
    if x<2:return x
    elif x-1 in a: return 0
    else:return (f(x - 1) + f(x - 2))%1000000007
print(f(n+1))
Problem p03038 (python)

Fixed submission:
n, m = map(int, input().split())
A = sorted(map(int, input().split()))
C = []
for _ in range(m):
    b, c = map(int, input().split())
    C += [[-c, b]]
C = sorted(C)
p = 0
for cb in C:
    c, b = -cb[0], cb[1]
    for _ in range(b):
        if (p >= n) | (A[min(p, n-1)] >= c):
            break
        else:
            A[p] = c
            p += 1
print(sum(A))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
A = sorted(map(int, input().split()))
C = []
for _ in range(m):
    b, c = map(int, input().split())
    C += [[-c, b]]
C = sorted(C)
p = 0
for cb in C:
    c, b = -cb[0], cb[1]
    for _ in range(b):
        if (p >= n) | (A[p] >= c):
            break
        else:
            A[p] = c
            p += 1
print(sum(A))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
A = sorted(map(int, input().split()))
C = []
for _ in range(m):
    b, c = map(int, input().split())
    C += [[-c, b]]
C = sorted(C)
p = 0
for cb in C:
    c, b = -cb[0], cb[1]
    for _ in range(b):
        if A[p] < c:
            A[p] = c
            p += 1
print(sum(A))
Problem p02577 (python)

Fixed submission:
def main():
    num = input()
    total = 0
    for char in num:
        total += int(char)
        total %= 9
    if total == 0:
        return 'Yes'
    else:
        return 'No'


if __name__ == '__main__':
    ans = main()
    print(ans)

Buggy submission (verdict: Runtime Error):
def main():
    num = input()
    if num % 9 == 0:
        return 'Yes'
    else:
        return 'No'


if __name__ == '__main__':
    ans = main()
    print(ans)