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

Fixed submission:
import collections
n,x,m=map(int,input().split())
if n==1 or x==0:
  print(x)
  exit()
start,end,loopcnt=0,0,0
a={x:0}
wk=x
for i in range(1,m):
  wk=(wk*wk)%m
  if not wk in a:
    a[wk]=i
  else:
    start=a[wk]
    end=i
    break
a=sorted(a.items(),key=lambda x:x[1])
koteiindex=min(n,start)
koteiwa=0
for i in range(koteiindex):
  koteiwa+=a[i][0]
loopcnt=(n-koteiindex)//(end-start)
loopindex=start-1+(n-koteiindex)%(end-start)
loopwa=0
amariwa=0
for i in range(start,end):
  if i<=loopindex:
    amariwa+=a[i][0]
  loopwa+=a[i][0]
ans=koteiwa+loopwa*loopcnt+amariwa
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
n,x,m=map(int,input().split())
if n==1:
  print(x)
  exit()
start,end,loopcnt=0,0,0
a={x:0}
wk=x
for i in range(1,m):
  wk=(wk*wk)%m
  if not wk in a:
    a[wk]=i
  else:
    start=a[wk]
    end=i
    break
a=sorted(a.items(),key=lambda x:x[1])
koteiindex=min(n,start)
koteiwa=0
for i in range(koteiindex):
  koteiwa+=a[i][0]
loopcnt=(n-koteiindex)//(end-start)
loopindex=start-1+(n-koteiindex)%(end-start)
loopwa=0
amariwa=0
for i in range(start,end):
  if i<=loopindex:
    amariwa+=a[i][0]
  loopwa+=a[i][0]
ans=koteiwa+loopwa*loopcnt+amariwa
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
n,x,m=map(int,input().split())
start,end,loopcnt=0,0,0
a={x:0}
wk=x
for i in range(1,m):
  wk=(wk*wk)%m
  if not wk in a:
    a[wk]=i
  else:
    start=a[wk]
    end=i
    break
a=sorted(a.items(),key=lambda x:x[1])
koteiindex=min(n,start)
koteiwa=0
for i in range(koteiindex):
  koteiwa+=a[i][0]
loopcnt=(n-koteiindex)//(end-start)
loopindex=start-1+(n-koteiindex)%(end-start)
loopwa=0
amariwa=0
for i in range(start,end):
  if i<=loopindex:
    amariwa+=a[i][0]
  loopwa+=a[i][0]
ans=koteiwa+loopwa*loopcnt+amariwa
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
n,x,m=map(int,input().split())
start,end,loopcnt=0,0,0
a={x:0}
wk=x
for i in range(1,m):
  wk=(wk*wk)%m
  if not wk in a:
    a[wk]=i
  else:
    start=a[wk]
    end=i
    break
a=sorted(a.items(),key=lambda x:x[1])
koteiindex=min(n,start)
koteiwa=0
for i in range(koteiindex):
  koteiwa+=a[i][0]
loopcnt=(n-koteiindex)//(end-start)
loopindex=(n-koteiindex)%(end-start)
loopwa=0
amariwa=0
for i in range(start,end):
  if i<=loopindex+1:
    amariwa+=a[i][0]
  loopwa+=a[i][0]
ans=koteiwa+loopwa*loopcnt+amariwa
print(ans)
Problem p02623 (python)

Fixed submission:
n,m,k=map(int,input().split())
a=[0]+list(map(int,input().split()))
b=list(map(int,input().split()))
t=sum(b)
j=m-1
ans=0
for i in range(n+1):
  t+=a[i]
  while j>=0 and t>k:
    t-=b[j]
    j-=1
  if t>k:
    break
  ans=max(ans,j+i+1) 
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
ai=0
bi=0
for i in range(n+m):
  ans+=1
  if n-ai==0:
    k-=b[bi]
    bi+=1
  elif m-bi==0:
    k-=a[ai]
    ai+=1
  elif a[ai]>b[bi]:
    k-=b[bi]
    bi+=1
  elif b[bi]>a[ai]:
    k-=a[ai]
    ai+=1
  else:
    if n==ai+2:
      k-=b[bi]
      bi+=1
    elif m==bi+2:
      k-=a[ai]
      ai+=1
    elif a[ai+1]>=b[bi+1]:
      k-=b[bi]
      bi+=1
    elif a[ai+1]<b[bi+1]:
      k-=a[ai]
      ai+=1
  if k<0:
    ans-=1
    break
print(ans)
Problem p02951 (python)

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

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
cngh=0
bkh=0
for i in range(n):
  if bkh>h[i]:
    if cngh!=h[i-1]:
      if bkh-1==h[i]:
      	cngh=h[i]
      else:
        ans="No"
        break
    else:
      if cngh!=h[i]:
        ans="No"
        break
  bkh=h[i]
print(ans)
Problem p03038 (python)

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
dic={}
for i in range(m):
  b,c=map(int,input().split())
  if c in dic:
    dic[c]+=b
  else:
    dic[c]=b
ol=sorted(dic.items(), reverse=True, key=lambda x:x[0])
index=0
loopstop=False
for li in ol:
  for i in range(li[1]):
    if li[0]>a[index]:
      a[index]=li[0]
      index+=1
      if index>=n:
        loopstop=True
        break;
    else:
      loopstop=True
      break;
  if loopstop:
    break
print(sum(a))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
dic={}
for i in range(m):
  b,c=map(int,input().split())
  if c in dic:
    dic[c]+=b
  else:
    dic[c]=b
ol=sorted(dic.items(), reverse=True, key=lambda x:x[0])
index=0
loopstop=False
for li in ol:
  for i in range(li[1]):
    if li[0]>a[index]:
      a[index]=li[0]
      index+=1
    else:
      loopstop=True
      break;
  if loopstop or index>=n :
    break
print(sum(a))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
dic={}
for i in range(m):
  b,c=map(int,input().split())
  if c in dic:
    dic[c]+=b
  else:
    dic[c]=b
ol=sorted(dic.items(), reverse=True, key=lambda x:x[0])
index=0
loopstop=False
for li in ol:
  for i in range(li[1]):
    if li[0]>a[index]:
      a[index]=li[0]
      index+=1
    else:
      loopstop=True
      break;
  if loopstop:
    break
print(sum(a))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
for i in range(m):
  b,c=map(int,input().split())
  chk=False
  for j in range(b):
    if a[j]<c:
      a[j]=c
      chk=True
    else:
      break
  j+=1
  if chk:
    for k in range(j,n):
      if a[k]>c:
        break
    a=a[j:k]+a[0:j]+a[k:n] 
print(sum(a))
Problem p02594 (python)

Fixed submission:

from collections import defaultdict,deque
#from itertools import permutations
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

t=ii()
if t>=30:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from collections import defaultdict,deque
#from itertools import permutations
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()
sys.setrecursionlimit(10**6)
"""========main code==============="""

t=ii()
if t>=30:
    print("Yes")
else:
    print("No")
Problem p02729 (python)

Fixed submission:
x,y=map(int,input().split())
print((x*(x-1)//2)+(y*(y-1)//2))

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
print((x*(x-1)//2+(y*(y-1)//2)
Problem p02831 (python)

Fixed submission:
def gcd(a,b):
    if a==0:
        return b
    else:
        return gcd(b%a,a)
#x=int(input())
a,b=map(int,input().split())
c=gcd(a,b)
print((a*b)//c)

Buggy submission (verdict: Runtime Error):
import math
#x=int(input())
a,b=map(int,input().split())
c=math.gcd(a,b)
print((a*b)//c)

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

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


def log(*args):
    print(*args, file=sys.stderr)


def main():
    _n, _m, k = map(int, input().split())
    ns = list(map(int, input().rstrip().split()))
    ms = list(map(int, input().rstrip().split()))
    sum = 0
    count = 0
    for v in ns:
        if sum + v > k:
            break
        else:
            sum += v
            count += 1

    ans_now = count
    ans = ans_now
    i = count - 1
    for v in ms:
        if sum + v > k:
            while sum + v > k:
                if i < 0:
                    break
                sum -= ns[i]
                i -= 1
                ans_now -= 1
            if sum + v > k:
                break
            sum += v
            ans_now += 1
        else:
            sum += v
            ans_now += 1
        ans = max(ans, ans_now)
    print(ans)


if __name__ == '__main__':
    main()

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


def log(*args):
    print(*args, file=sys.stderr)


def main():
    _n, _m, k = map(int, input().split())
    ns = list(map(int, input().rstrip().split()))
    ms = list(map(int, input().rstrip().split()))
    sum = 0
    count = 0
    for v in ns:
        if sum + v > k:
            break
        else:
            sum += v
            count += 1

    ans_now = count
    ans = ans_now
    i = count - 1
    for v in ms:
        if sum + v > k:
            while sum + v > k:
                sum -= ns[i]
                i -= 1
                ans_now -= 1
                if i < 0:
                    break
            if sum + v > k:
                break
            sum += v
            ans_now += 1
        else:
            sum += v
            ans_now += 1
        ans = max(ans, ans_now)
    print(ans)


if __name__ == '__main__':
    main()

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


def log(*args):
    print(*args, file=sys.stderr)


def main():
    n, m, k = map(int, input().split())
    ns = list(map(int, input().rstrip().split()))
    ms = list(map(int, input().rstrip().split()))
    # 全部Aの場合上からなんこ取れるかを見つつ、Bを入れて押し出していく
    sum = 0
    last_flg = False
    for (i, v) in enumerate(ns):
        if sum + v > k:
            break
        else:
            sum += v
        if i == len(ns) - 1:
            last_flg = True

    if last_flg:
        i += 1
    ans_now = i
    ans = ans_now
    i -= 1
    for v in ms:
        break_flg = False
        if sum + v > k:
            while sum + v > k:
                sum -= ns[i]
                i -= 1
                ans_now -= 1
                if i == 0:
                    break_flg = True
                    break
            if break_flg:
                break
            sum += v
            ans_now += 1
        else:
            sum += v
            ans_now += 1
        ans = max(ans, ans_now)
    print(ans)


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

Fixed submission:
import sys
from math import factorial
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    x, y = map(int, input().rstrip().split())
    # 全部 i + 1, j + 2が最初だったとする
    # a + 2b = x, 2a + b = y
    # =>
    # a = x - 2b
    # b = y - 2a
    # =>
    # b = y - 2x + 4b
    # 3b = 2x - y
    # b = (2x - y) / 3
    # a = (2y - x) / 3
    if (2 * x - y) % 3 != 0 or (2 * y - x) % 3 != 0:
        print(0)
        return
    a = (2 * x - y) // 3
    b = (2 * y - x) // 3
    if a < 0 or b < 0:
        print(0)
        return
    # (a + b) C min(a, b)
    # => (a + b)! / (min(a, b) ! * (a + b - min(a, b)) !
    mod = 10**9 + 7
    ans = (factorial_mod(a + b, mod) * pow(factorial_mod(min(a, b), mod), mod - 2, mod)
           * pow(factorial_mod(a + b - min(a, b), mod), mod - 2, mod)) % mod
    print(ans)


def factorial_mod(a, mod):
    ans = 1
    for v in range(1, a + 1):
        ans *= v
        ans %= mod
    return ans


if __name__ == '__main__':
    main()

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


def log(*args):
    print(*args, file=sys.stderr)


def main():
    x, y = map(int, input().rstrip().split())
    # 全部 i + 1, j + 2が最初だったとする
    # a + 2b = x, 2a + b = y
    # =>
    # a = x - 2b
    # b = y - 2a
    # =>
    # b = y - 2x + 4b
    # 3b = 2x - y
    # b = (2x - y) / 3
    # a = (2y - x) / 3
    if (2 * x - y) % 3 != 0 or (2 * y - x) % 3 != 0:
        print(0)
        return
    a = (2 * x - y) // 3
    b = (2 * y - x) // 3
    # (a + b) C min(a, b)
    # => (a + b)! / (min(a, b) ! * (a + b - min(a, b)) !
    mod = 10**9 + 7
    ans = ((factorial(a + b) % mod) * pow(factorial(min(a, b)), mod - 2, mod)
           * pow(factorial(a + b - min(a, b)), mod - 2, mod)) % mod
    print(ans)


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

Fixed submission:
chr = input("")
num = len(chr)

if chr[num-1] == "s":
  print(chr + "es")
else:
  print(chr + "s")

Buggy submission (verdict: Runtime Error):
chr = input("")
num = len(s)

if chr[num-1] == "s":
  print(chr + "es")
else:
  print(chr + "s")
Problem p03631 (python)

Fixed submission:
# coding: utf-8
# Your code here!

N = input()
 
if N[0] == N[2]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N = input().split()

if N[0] == N[2]:
  print('Yes')
else:
  print('No')
Problem p02594 (python)

Fixed submission:
n=int(input())
if 30<=n:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=int(intput())
if 30<=n:
    print("Yes")
else:
    print("No")
Problem p02659 (python)

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

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

Fixed submission:
N = int(input())
D = [input().split() for _ in range(N)]
ans = "No"
for i in range(N - 2):
    if D[i][0] == D[i][1]:
         if D[i + 1][0] == D[i + 1][1]:
            if D[i + 2][0] == D[i + 2][1]:
                ans = "Yes"
                break
print(ans)

Buggy submission (verdict: Runtime Error):
A = list(map(int, input().split()))
N = A[0]
D = A[1:N*2+1]
D1 = []
D2 = []
for i in range(N):
    D1.append(D[2 * i])
    D2.append(D[2 * i + 1])
ans = "No"
for i in range(N - 2):
    if D1[i] == D[i]:
         if D[i + 1] == D[i + 1]:
            if D[i + 2] == D[i + 2]:
                ans = "Yes"
                break
print(ans)
Problem p03011 (python)

Fixed submission:
def main():
    a,b,c=map(int,input().split(' '))
    print(sum([a,b,c])-max(a,b,c))

main()

Buggy submission (verdict: Runtime Error):
def main():
    a,b,c=map(int,input().split(' '))
    print(sum([a,b,c])-,max(a,b,c))

main()
Problem p02676 (python)

Fixed submission:
K = int(input())
S = input()
if len(S)<=K:
    print(S)
else:
    print(S[:K]+"...")

Buggy submission (verdict: Runtime Error):
K = int(input())
S = input()
a = ""
if len(S)<=K:
    exit(S)
else:
    for i in range(K):
        a+=S[i]
print(a,"...")
Problem p02707 (python)

Fixed submission:
N = int(input())
A = input().split()
x = [0]*N
for i in range(N-1):
    x[int(A[i])-1]+=1
for j in range(N):
    print(x[j])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = input().split()
A.insert(0,0)
x = [0]*N
for i in range(N):
    x[A[i]-1]+=1
for j in range(N):
    print(x[j])

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
A = input().split()
A.insert(0,0)
x = [0]*N
for j in range(N):
    print(c[str(j+1)])
Problem p02729 (python)

Fixed submission:
ST = input().split()
N = int(ST[0])
M = int(ST[1])
print(int((N*(N-1)+(M*(M-1)))/2))

Buggy submission (verdict: Runtime Error):
ST = input().split()
N = ST[0]
M = ST[1]
print((N*(N-1)+(M*(M-1)))/2)
Problem p02771 (python)

Fixed submission:
a = input().split()
x=a[0]
y=a[1]
z=a[2]
if x==y:
    if x==z:
        print("No")
    else:
        print("Yes")
else:
    if x==z:
        print("Yes")
    else:
        if y==z:
            print("Yes")
        else:
            print("No")

Buggy submission (verdict: Runtime Error):
a = input().split()
x=a[0]
y=a[1]
z=a[2]
if x=y:
    if x=z:
        print("no")
    else:
        print("yes")
else:
    if x=z:
        print("yes")
    else:
        if y=z:
            print("yes")
        else:
            print("no")
Problem p02546 (python)

Fixed submission:
s=input()
if s[-1]=='s':
    print(s+'es')
else :
    print(s+'s')

Buggy submission (verdict: Runtime Error):
from sys import stdin
input=stdin.readline
n=int(input().rstrip())
count=0
for i in range(1,n):
    
    for t in range(1,n):
        if n-i*t>0:
            count +=1
        else:
            break
print(count)
Problem p02577 (python)

Fixed submission:
N=list(input())
NN=[int(t) for t in N]
T=sum(NN)
if T%9==0:
    print("Yes")
else :
    print("No")

Buggy submission (verdict: Runtime Error):
N=list(input())
S=[int(t) for t in N]
T=sum(s)
if T%9==0:
  print("Yes")
else :
  print("No")

Buggy submission (verdict: Runtime Error):
N=list(input())
S=[int(t) for t in N]
T=sum(s)
if T%9==0:
  print('Yes')
else :
  print("No")

Buggy submission (verdict: Runtime Error):
N=list(input())
S=[int(t) for t in N]
T=sum(s)
if T%9==0:
  print('Yes')
else :
  print("No")

Buggy submission (verdict: Runtime Error):
N=list(input())
S=[int(t) for t in N]
T=sum(s)
if T%9==0:
  pint('Yes')
else :
  print("No")
Problem p02594 (python)

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

Buggy submission (verdict: Runtime Error):
a=input()
text=int(a)
if text>=30
    print('Yes')
else:
    print('No')

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

Fixed submission:
from math import floor
from fractions import Fraction
a,b=map(str,input().split())
a=int(a)
b=Fraction(b)
print(int(a*b))

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

Fixed submission:
import heapq

n, m = map(int, input().split())

# delay, reword
jobs = [list(map(int, input().split())) for i in range(n)]
jobs_days = [[] for i in range(m)]
for job in jobs:
    if job[0] - 1 < m:
        jobs_days[job[0] - 1].append(-job[1])

reward = 0
h = []
heapq.heapify(h)

for i in range(m):
    for job in jobs_days[i]:
        heapq.heappush(h, job)
    if len(h) > 0:
        reward += heapq.heappop(h)

print(-reward)

Buggy submission (verdict: Runtime Error):
import heapq

n, m = map(int, input().split())

# delay, reword
jobs = [list(map(int, input().split())) for i in range(n)]
jobs_days = [[] for i in range(m + 10)]
for job in jobs:
    jobs_days[job[0]].append(-job[1])

reward = 0
h = []
heapq.heapify(h)

for i in range(m):
    for j in jobs_days[i + 1]:
        heapq.heappush(h, j)
    if(len(h)>0):
        reward += heapq.heappop(h)

print(-reward)
Problem p02570 (python)

Fixed submission:
d, t, s = map(int, input().split())

if d > t * s:
		print('No')
if d <= t * s:
		print('Yes')

Buggy submission (verdict: Runtime Error):
d, t, s = map(int, input().split())
if d > t * s:
　print('no')
if d <= t * s:
　print('yes')
Problem p02777 (python)

Fixed submission:
s, t = input().split()

a, b = map(int,input().split())

u = input()

if s == u:
    print(a - 1, b)
elif t == u:
    print(a, b - 1)

Buggy submission (verdict: Runtime Error):
s, t = map(input().split())

a, b = map(int(input().split()))

u = input()

if s == u:
    print(a - 1, b)
elif t == u:
    print(a, b - 1)
Problem p03011 (python)

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

print(min(a+b,a+c,b+c))

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

print(min(a+b,a+c,b+c))
Problem p02546 (python)

Fixed submission:
import sys
from math import ceil as C, floor as F, sqrt, gcd as G
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data) 

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

word = S()
word += 'es' if word[-1] == 's' else 's'
print(word)

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt, gcd as G
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data) 

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

n, k = I()
# steps = set()
steps = [0] * (n+1)
mod = 998244353

for _ in range(k):
    l, r = I()
    for i in range(l, r+1):
        steps[i] = 1
    # steps.update([i for i in range(l, r+1)])

ans = 0
# heap = Heap([1])
# seen = set([1])
# cache = D(int)
# cache[1] = 1
cache = np.array([0] * (n+1))
cache[1] = 1

# def go(i):
for i in range(1, n):
    if cache[i] == 0:
        continue
    now = np.array([0] * i + steps[:-i])
    cache = cache + (cache[i] * now)
    # for step in steps:
        # print(heap.data, seen, cache)
        # t = i + step
        # if t <= n:
            # cache[t] += cache[i]
            # cache[t] %= mod

    
print(cache[n] % mod)
Problem p02682 (python)

Fixed submission:
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

a, b, c, k = Is()

a = min(a, k)
k -= a

b = min(b, k)
k -= b

c = min(c, k)
k -= c

print(a-c)

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

a, b, c, k = Is()
nums = sorted([1] * a + [0] * b + [-1] * c, reverse=True)
print(np.sum(nums[:k]))