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

Fixed submission:
def main():
  import bisect
  import sys
  from itertools import accumulate
  input = sys.stdin.readline
  def hsnum(x):
    num = 0
    for i in a:
      y = x-i
      num += n-bisect.bisect_left(a,y)
    return num
  n,m = map(int, input().split())
  a = list(map(int, input().split()))
  a.sort()
  suma = [0]+list(accumulate(a))
  lx = 0
  rx = 2*10**5+2
  error = 0
  while lx+1 < rx:
    mx = (lx+rx)//2
    if hsnum(mx) < m:
      rx = mx
    elif hsnum(mx) > m:
      lx = mx + 1
    else:
      lx = mx
      break
  if hsnum(lx)<m:
    lx -= 1
  error = hsnum(lx)-m
  ans = 0
  for i in a:
    rema = lx - i
    j = bisect.bisect_left(a,rema)
    ans += (n-j)*i-suma[j]
  ans += suma[n]*n
  print(ans-error*lx)
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
  import bisect
  import sys
  from itertools import accumulate
  input = sys.stdin.readline
  def hsnum(x):
    num = 0
    for i in a:
      y = x-i
      num += n-bisect.bisect_left(ls,y)
    return num
  n,m = map(int, input().split())
  a = list(map(int, input().split()))
  a.sort()
  suma = [0]+list(accumulate(a))
  lx = 0
  rx = 2*10**5+2
  error = 0
  while lx < rx:
    mx = (lx+rx)//2
    if hsnum(mx) < m:
      rx = mx
    elif hsnum(mx) > m:
      if hsnum(mx+1) < m:
        error = hsnum(mx)-m
        lx = mx
        break
      lx = mx + 1
    else:
      lx = mx
      break
  ans = 0
  for i in a:
    rema = lx - i
    j = bisect.bisect_left(a,rema)
    ans += (n-j)*i+suma[n]-suma[j]
  print(ans-error*lx)
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
      import bisect
    import sys
    from itertools import accumulate
    input = sys.stdin.readline
    def hsnum(ls,x,n):
        num = 0
        for i in range(n):
            y = x-ls[i]
            num += n-bisect.bisect_left(ls,y)
        return num
    n,m = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    suma = [0]+list(accumulate(a))
    lx = 0
    rx = 2*10**5+2
    error = 0
    while lx < rx:
        mx = (lx+rx)//2
        if hsnum(a,mx,n) < m:
            rx = mx
        elif hsnum(a,mx,n) > m:
            if hsnum(a,mx+1,n) < m:
                error = hsnum(a,mx,n)-m
                lx = mx
                break
            lx = mx + 1
        else:
            lx = mx
            break
    ans = 0
    for i in range(n):
        rema = lx - a[i]
        j = bisect.bisect_left(a,rema)
        ans += (n-j)*a[i]+suma[n]-suma[j]
    print(ans-error*lx)
if __name__ == "__main__":
    main()
Problem p02839 (python)

Fixed submission:
h,w = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
b = [list(map(int,input().split())) for i in range(h)]
grid = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    grid[i][j] = abs(a[i][j]-b[i][j])
dp = [[0 for j in range(w)] for k in range(h)]
buf = (h+w)*80
for i in range(h):
  for j in range(w):
      t = grid[i][j]
      if i == j == 0:
        dp[i][j] = 1 << buf+t | 1 << buf-t
      if j > 0:
        dp[i][j] = dp[i][j] | dp[i][j-1] << t | dp[i][j-1] >> t
      if i > 0:
        dp[i][j] = dp[i][j] | dp[i-1][j] << t | dp[i-1][j] >> t
for i in range(buf):
  if (dp[h-1][w-1] & 1 << buf+i) or (dp[h-1][w-1] & 1 << buf-i):
    print(i)
    exit()

Buggy submission (verdict: Runtime Error):
t=a[i-1][j-1]
dp[i][j][k]=(dp[i-1][j][abs(k+t)]
             or dp[i-1][j][abs(k-t)]
             or dp[i][j-1][abs(k+t)]
             or dp[i][j-1][abs(k-t)])
Problem p02854 (python)

Fixed submission:
import sys
    
sys.setrecursionlimit(200000)
    
N = int(input())
A = list(map(int, input().split(' ')))
    

sumA = []
for i in range(N):
    if i == 0:
        sumA.append(A[i])
    else:
        sumA.append(sumA[-1] + A[i])
    
ans = 0
    
for i in range(N):
    if sumA[-1] // 2 > sumA[i]:
        continue
    else:
        if i == 0:
            ans = abs(sumA[i] * 2 - sumA[-1])
            break
        else:
            ans = min(abs(sumA[i] * 2 - sumA[-1]), abs(sumA[i-1] * 2 - sumA[-1]))
            break
    
print(ans)

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

def sum(a, b):
    if b == 0:
        return a[b]
    else:
        return a[b] + sum(a, b-1)
sumA = []
for i in range(N):
    sumA.append(sum(A, i))

ans = 0

for i in range(N):
    if sumA[-1] // 2 > sumA[i]:
        continue
    else:
        if i == 0:
            ans = abs(sumA[i] * 2 - sumA[-1])
            break
        else:
            ans = min(abs(sumA[i] * 2 - sumA[-1]), abs(sumA[i-1] * 2 - sumA[-1]))
            break

print(ans)
Problem p02867 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ab = [(x,y) for x,y in zip(a,b)]
ab.sort(key = lambda x:x[1])
a = list(list(zip(*ab))[0])
ai = [[a[i],i] for i in range(n)]
flg = 0
if len(set(b)) == n:
  ai.sort()
  for i in range(n):
    ai[i][0] = i
  ai.sort(key = lambda x:x[1])
  idc = list(zip(*ai))[0]
  cnt = 0
  plc = 0
  while True:
    plc = idc[plc]
    cnt += 1
    if plc == 0:
      break
  if cnt == n:
    flg = 1
a.sort()
b.sort()
for x,y in zip(a,b):
  if x > y:
    print("No")
    exit()
if not flg:
  print("Yes")
else:
  for i in range(1,n):
    if a[i] <= b[i-1]:
      print("Yes")
      exit()
  print("No")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
bi = [[b[i],i] for i in range(n)]
bi.sort()
flg = 0
if len(set(b)) == n:
  for i in range(n):
    bi[i][0] = i
  bi.sort(key = lambda x:x[1])
  idc = list(zip(*bi))[0]
  cnt = 0
  plc = 0
  while True:
    plc = idc[plc]
    cnt += 1
    if plc == 0:
      break
  if cnt == n:
    flg = 1
a.sort()
b.sort()
for x,y in zip(a,b):
  if x > y:
    print("No")
    exit()
if not flg:
  print(2/0)
  print("Yes")
else:
  for i in range(1,n):
    if a[i] <= b[i-1]:
      print("Yes")
      exit()
  print("No")
Problem p02900 (python)

Fixed submission:
import math

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

def gcd(a, b):
    if a % b == 0 or b % a == 0:
        return min(a, b)
    else:
        if a // b >= b // a:
            c = abs(a - b * (a // b))
        else:
            c = abs(b - a * (b // a))
        d = min(a, b)
        return gcd(c, d)

gcd_ = gcd(a, b)
d = []
for i in range(1, max(4, int(math.sqrt(gcd_))+1)):
    if not gcd_ % i:
        d.extend([i, gcd_ // i])

d.sort()
while d != [] and d[0] == 1:
    del d[0]
ans = [1]

for i in d:
    for j in ans:
        if gcd(i, j) == 1 and j == ans[-1]:
            ans.append(i)
        elif gcd(i, j) != 1:
            break

print(len(ans))

Buggy submission (verdict: Runtime Error):
import math

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

def gcd(a, b):
    if a % b == 0 or b % a == 0:
        return min(a, b)
    else:
        if a // b >= b // a:
            c = abs(a - b * (a // b))
        else:
            c = abs(b - a * (b // a))
        d = min(a, b)
        return gcd(c, d)

gcd_ = gcd(a, b)
d = []
for i in range(2, max(4, int(math.sqrt(gcd_))+1)):
    if not gcd_ % i:
        d.extend([i, gcd_ // i])

d.sort()
if d[0] == 1:
    del d[0]
ans = [1]

for i in d:
    for j in ans:
        if gcd(i, j) == 1 and j == ans[-1]:
            ans.append(i)
        elif gcd(i, j) != 1:
            break

print(len(ans))

Buggy submission (verdict: Runtime Error):
import math

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

def gcd(a, b):
    if a % b == 0 or b % a == 0:
        return min(a, b)
    else:
        if a // b >= b // a:
            c = abs(a - b * (a // b))
        else:
            c = abs(b - a * (b // a))
        d = min(a, b)
        return gcd(c, d)

gcd_ = gcd(a, b)
d = []
for i in range(2, max(3, int(math.sqrt(gcd_))+1)):
    if not gcd_ % i:
        d.extend([i, gcd_ // i])

d.sort()
if d[0] == 1:
    del d[0]
ans = [1]

for i in d:
    for j in ans:
        if gcd(i, j) == 1 and j == ans[-1]:
            ans.append(i)
        elif gcd(i, j) != 1:
            break

print(len(ans))
Problem p02909 (python)

Fixed submission:
x=input()
if x=="Sunny":
  print("Cloudy")
if x=="Cloudy":
  print("Rainy")
if x=="Rainy":
  print("Sunny")

Buggy submission (verdict: Runtime Error):
import random
from collections import defaultdict
from itertools import accumulate
import sys
input = sys.stdin.readline
n = int(input())
s = input().rstrip()
mod = (1<<61)-1
base = 1000+random.randint(0,100)
power = [1]
for i in range(1,n):
  power.append((power[-1]*base)%mod)
hvalue = [0]
for i in range(n):
  hvalue.append((hvalue[-1]+(ord(s[i])*power[i]))%mod)
def rollinghash(l,r):
  return ((hvalue[r]-hvalue[l])*power[n-r])%mod
def pun(i):
  dc = defaultdict(int)
  if i>n//2:
    return False
  for j in range(n-i+1):
    x = rollinghash(j,i+j)
    if dc[x]:
      rg =dc[x]
      if rg<=j:
        return True
      else:
        dc[x] = i+j
  return False
l=0
r=n//2+1
while l+1<r:
  mi=(l+r)//2
  if pun(mi):
    l=mi
  else:
    r=mi
print(l)

Buggy submission (verdict: Runtime Error):
import random
from collections import defaultdict
from itertools import accumulate
import sys
input = sys.stdin.readline
n = int(input())
s = input().rstrip()
mod = (1<<61)-1
base = 1000+random.randint(0,100)
power = [1]
for i in range(1,n):
  power.append((power[-1]*base)%mod)
hvalue = [0]
for i in range(n):
  hvalue.append((hvalue[-1]+(ord(s[i])*power[i]))%mod)
def rollinghash(l,r):
  return ((hvalue[r]-hvalue[l])*power[n-r])%mod
def pun(i):
  dc = defaultdict(int)
  if i>n//2:
    return False
  for j in range(n-i+1):
    x = rollinghash(j,i+j)
    if dc[x]:
      rg =dc[x]
      if rg<=j:
        return True
      else:
        dc[x] = i+j
  return False
l=0
r=n//2+1
while l+1<r:
  mi=(l+r)//2
  if pun(mi):
    l=mi
  else:
    r=mi
print(l)
Problem p02917 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a=a+[10**18]
ans=a[0]
for i in range(n-1):
  ans+=min(a[i],a[i+1])
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a=a+[10**18]
ans=a[0]
for i in range(n):
  ans+=min(a[i],a[i+1])
print(ans)
Problem p02918 (python)

Fixed submission:
n,k=map(int,input().split())
a=input()
ans=0
cnt=0
for i in range(n-1):
  if a[i]==a[i+1]:
    ans+=1
  if a[i]!=a[i+1]:
    cnt+=1
ans=min(n-1,ans+min(cnt,k)*2)
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
ans=0
cnt=0
for i in range(n-1):
  if a[i]==a[i+1]:
    ans+=1
  if a[i]!=a[i+1]:
    cnt+=1
ans=min(n-1,ans+min(cnt,k)*2)
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=list(map(int,input().split()))
ans=0
cnt=0
for i in range(n-1):
  if a[i]==a[i+1]:
    ans+=1
  if a[i]!=a[i+1]:
    cnt+=1
ans=min(n-1,ans+min(cnt,k)*2)
print(ans)
Problem p02920 (python)

Fixed submission:
import math
def cmb(n,r):
  return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))
n=int(input())
a=list(map(int,input().split()))
a.sort()
ls=[0]
cnt=0
for i in range(1,2**n):
  if a[i]>a[i-1]:
    cnt+=1
  ls.append(cnt)
lmt = []
for i in range(n+1):
  lmt.extend([i]*cmb(n,i))
bias = ls[-1]-lmt[-1]
jdg = 0
ulmt = 0
for i in range(n):
  jdg += ls.count(i)
  ulmt += 2**(n-i-1)
  if jdg > ulmt:
    print("No")
    exit()
for x,l in zip(ls,lmt):
  if x-l > bias:
    print("No")
    break
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int,input().split()))
a.sort()
ls=[0]
cnt=0
for i in range(1,2**n):
  if a[i]>a[i-1]:
    cnt+=1
  ls.append(cnt)
for i in range(2**n):
  if i<2**n-1:
    lmt=n-int(math.log2(2**n-i-1))-1
    if ls[i]<lmt:
      print("No")
      break
  if i==2**n-1:
    if ls[i]<n:
      print("No")
      break
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int,input().split()))
a.sort()
ls=[0]
cnt=0
for i in range(1,2**n):
  if a[i]>a[i-1]:
    cnt+=1
  ls.append(cnt)
for i in range(2**n):
  if i<2**n-1:
    lmt=n-int(math.log2(2**n-i-1))-1
    if ls[i]<lmt:
      print("No")
      break
  if i==2**n-1:
    if ls[i]<n-1:
      print("No")
      break
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int,input().split()))
a.sort()
ls=[0]
cnt=0
for i in range(1,2**n):
  if a[i]>a[i-1]:
    cnt+=1
  ls.append(cnt)
for i in range(2**n):
  if i<2**n-1:
    lmt=n-int(math.log2(n-i-1))-1
    if ls[i]<lmt:
      print("No")
      break
  if i==2**n-1:
    if ls[i]<n-1:
      print("No")
      break
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int,input().split()))
a.sort()
ls=[0]
cnt=0
for i in range(1,2**n):
  if a[i]>a[i-1]:
    cnt+1
  ls.append(cnt)
for i in range(2**n):
  if i<2**n-1:
    lmt=n-int(math.log2(n-i-1))-1
    if ls[i]<lmt:
      print("No")
      break
  if i==2**n-1:
    if ls[i]<n-1:
      print("No")
      break
else:
  print("Yes")
Problem p02921 (python)

Fixed submission:
s=input()
t=input()
a=0
for i in range(3):
  if s[i]==t[i]:
    a+=1
print(a)

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
a=0
for i in range(3):
  if s[i]==s[t]:
    a+=1
print(a)
Problem p02928 (python)

Fixed submission:
from itertools import combinations, accumulate
n,m = map(int,input().split())
a = list(map(int,input().split()))
mod = 10**9+7
ans = 0
ls = [0]*2001
for i in a:
  ls[i] += 1
accls = list(accumulate(ls))
for i,j in combinations(a,2):
  if i>j:
    ans += 1
ans = ans*m%mod
for i in range(1,2001):
  if ls[i]>=1:
    ans = (ans + ls[i]*accls[i-1]*m*(m-1)//2)%mod
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import combinations, accumulate
n,m = map(int,input().split())
a = list(map(int,input().split()))
mod = 10**9+7
ans = 0
ls = [0]*2001
for i in a:
  ls[i] += 1
accls = list(accumulate(a))
for i,j in combinations(a,2):
  if i>j:
    ans += 1
for i in range(1,2001):
  if ls[i]>=1:
    ans = (ans + accls[i-1]*(m-1))%mod
print(ans)
Problem p02943 (python)

Fixed submission:
n,k=map(int,input().split())
s=input()
t=s[::-1]
u="".join([s,t])
ls=[]
for i in range(n):
  ls.append(u[i:i+n])
ls.sort()
k-=1
x=ls[0]
cnt=1
for i in range(1,n):
  if x[0]==x[i]:
    cnt+=1
  else:
    break
if cnt*2**k<n:
  y=n-cnt*2**k
  print(x[0]*(cnt*2**k)+x[cnt:y+cnt])
else:
  print(x[0]*n)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
t=s[::-1]
u="".join([s,t])
ls=[]
for i in range(n):
  ls.append(u[i:i+n])
ls.sort()
k-=1
x=list(ls[0])
if 2**k<n:
  y=n-2**k
  print(x[0]*(2**k)+x[1:y+1])
else:
  print(x[0]*n)
Problem p02949 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n,m,p = map(int,input().split())
abd = [list(map(int,input().split())) for i in range(m)]
come = [[] for i in range(n+1)]
for a,b,d in abd:
  come[b].append(a)
visitable = [0]*(n+1)
stack = [n]
visitable[n] = 1
while stack:
  x = stack.pop()
  for y in come[x]:
    if visitable[y] == 0:
      visitable[y] = 1
      stack.append(y)
score = [10**15 for i in range(n+1)]
score[1] = 0
for j in range(n+1):
  flg = 0
  for i in range(m):
    v1,v2,e = abd[i]
    if visitable[v1] & visitable[v2] == 0:
      continue 
    e = -e+p
    if score[v1] != 10**15 and score[v2] > score[v1]+e:
      score[v2] = score[v1]+e
      flg = 1
      if j == n-1:
        last = score[:]
      if j == n:
        onemore = score[:]
  if flg == 0:
    break
if flg == 0:
  print(max(0,-score[n]))
else:
  if last == onemore:
    print(max(last[n],0))
  else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n,m,p = map(int,input().split())
abd = [list(map(int,input().split())) for i in range(m)]
come = [[] for i in range(n+1)]
for a,b,d in abd:
  come[b].append(a)
visitable = [0]*(n+1)
stack = [n]
visitable[n] = 1
while stack:
  x = stack.pop()
  for y in come[x]:
    if visitable[y] == 0:
      visitable[y] = 1
      stack.append(y)
score = [10**15 for i in range(n+1)]
score[1] = 0
for j in range(n+1):
  flg = 0
  for i in range(m):
    v1,v2,e = abd[i]
    if visitable[v1] & visitable[v2] == 0:
      continue 
    e = -e+p
    if score[v1] != 10**15 and score[v2] > score[v1]+e:
      score[v2] = score[v1]+e
      flg = 1
      if j == n-1:
        last = -score[n]
      if j == n:
        onemore = -score[n]
  if flg == 0:
    break
if flg == 0:
  print(max(0,-score[n]))
else:
  if last == onemore:
    print(max(last,0))
  else:
    print(2/0)
Problem p02963 (python)

Fixed submission:
n=int(input())
a = n//(10**9)+1
b = 10**9-(n%(10**9))
if n%(10**9) == 0:
  print(0,0,10**9,0,1,a-1)
else:
  print(0,0,10**9,b,1,a)

Buggy submission (verdict: Runtime Error):
o,f,i=998244353,[1],1
while i<o/399:f+=[f[-1]*i%o];i+=1
c=lambda n,k:f[n]*pow(f[n-k],o-2,o)*pow(f[k],o-2,o)
n,m=map(int,input().split())
w,u=3*m,n-1
a=c(w+u,u)-n*c(n+m-2,u)
while-~m<min(w,n):m+=2;a-=c(n,m)*c((w-m)//2+u,u)
print(a%o)

Buggy submission (verdict: Runtime Error):
o,f,i=998244353,[1],1
while i<o/399:f+=f[-1]*i%o;i+=1
c=lambda n,k:f[n]*pow(f[n-k],o-2,o)*pow(f[k],o-2,o)
n,m=map(int,input().split())
w,u=3*m,n-1
a=c(w+u,u)-n*c(n+m-2,u)
if u>m:
 for i in range(m+1,min(w,n)+1):
  if w-i+1&1:a-=c(n,i)*c((w-i)//2+u,u) 
print(a%o)

Buggy submission (verdict: Runtime Error):
o=998244353
f=[1]
for i in range(1,2500100):f.append(f[-1]*i%o)
def c(n,k):return f[n]*pow(f[n-k],o-2,o)*pow(f[k],o-2,o)
n,m=map(int,input().split())
w=3*m
u=n-1
a=c(w+u,u)-n*c(n+m-2,u)
if u>m:
 for i in range(m+1,min(w,n)+1):
  if w-i+1&1:a-=c(n,i)*c((w-i)//2+u,u)
print(a%o)
Problem p02965 (python)

Fixed submission:
mod = 998244353
rng = 2500100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
def inv(x):
  return pow(x,mod-2,mod)
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*inv(fctr[n-k])*inv(fctr[k])%mod

n,m = map(int,input().split())
ans = cmb(n+3*m-1,n-1)
ans = (ans-n*cmb(n+m-2,n-1))%mod
if n>m+1:
  for i in range(m+1,min(3*m,n)+1):
    if (3*m-i)%2 == 1:
      continue
    x = (3*m-i)//2
    ans = (ans-cmb(n,i)*cmb(x+n-1,n-1))%mod
print(ans)

Buggy submission (verdict: Runtime Error):
o,f,i=998244353,[1],1
while i<o/399:f+=f[-1]*i%o;i+=1
c=lambda n,k:f[n]*pow(f[n-k],o-2,o)*pow(f[k],o-2,o)
n,m=map(int,input().split())
w,u=3*m,n-1
a=c(w+u,u)-n*c(n+m-2,u)
if u>m:
 for i in range(m+1,min(w,n)+1):
  if w-i+1&1:a-=c(n,i)*c((w-i)//2+u,u) 
print(a%o)

Buggy submission (verdict: Runtime Error):
o=998244353
f=[1]
for i in range(1,2500100):f.append(f[-1]*i%o)
c=lambda n,k: f[n]*pow(f[n-k],o-2,o)*pow(f[k],o-2,o)%o
n,m=map(int,input().split())
w=3*m
u=n-1
a=c(w+u,u)-n*c(n+m-2,u)
if u>m:
 for i in range(m+1,min(w,n)+1):
  a=(a-c(n,i)*c((w-i)//2+u,u))%o if w-i+1&1
print(a%o)

Buggy submission (verdict: Runtime Error):
o=998244353
f=[1]
for i in range(1,2500100):f.append(f[-1]*i%o)
def c(n,k):return f[n]*pow(f[n-k],o-2,o)*pow(f[k],o-2,o)%o
n,m=map(int,input().split())
w=3*m
u=n-1
a=c(w+u,u)-n*c(n+m-2,u)
if u>m:
 for i in range(m+1,min(w,n)+1):
  if w-i+1&amp;1:a=(a-c(n,i)*c((w-i)//2+u,u))%o
print(a%o)

Buggy submission (verdict: Runtime Error):
o=998244353
f=[1]
for i in range(1,2500100):f.append(f[-1]*i%o)
def c(n,k):return f[n]*pow(f[n-k],o-2,o)*pow(f[k],o-2,o)%o
n,m=map(int,input().split())
w=3*m
u=n-1
a=c(w+u,u)-n*c(n+m-2,u)
if u&gt;m:
 for i in range(m+1,min(w,n)+1):
  if w-i+1&amp;1:a=(a-c(n,i)*c((w-i)//2+u,u))%o
print(a%o)
Problem p02972 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n-1,-1,-1):
  x=(sum(ans[i::i+1]))%2
  if x!=a[i]:
    ans[i]=1
print(sum(ans))
for i in range(n):
  if ans[i]==1:
    print(str(i+1)+" ",end="")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n-1,-1,-1):
  x=(sum(ans[i-1::i]))%2
  if x!=a[i]:
    ans[i]=1
print(sum(ans))
Problem p02975 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
x = list(set(a))
x.sort()
if len(x) >= 4:
  print("No")
  exit()
if len(x) == 3:
  if x[0]^x[1] == x[2] and 3*a.count(x[0]) == 3*a.count(x[1]) == 3*a.count(x[2]) == n:
    print("Yes")
  else:
    print("No")
  exit()
if len(x) == 2:
  if x[0] == 0 and (2*a.count(x[0]) == 2*a.count(x[1]) == n or 6*a.count(x[0]) == 3*a.count(x[1]) == 2*n):
    print("Yes")
  else:
    print("No")
  exit()
if len(x) == 1:
  if x[0] == 0:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
x = list(set(a))
if len(x) >= 4:
  print("No")
  exit()
if len(x) == 3:
  if x[0]^x[1] == x[2] and 3*a.count[x[0]] == 3*a.count[x[1]] == 3*a.count[x[2]] == n:
    print("Yes")
  else:
    print("No")
  exit()
if len(x) == 2:
  if x[0] == 0 or x[1] == 0 and 2*a.count[x[0]] == 2*a.count[x[1]] == n:
    print("Yes")
  else:
    print("No")
  exit()
if len(x) == 1:
  if x[0] == 0:
    print("Yes")
  else:
    print("No")
Problem p02993 (python)

Fixed submission:
s=input()
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
  print("Bad")
else:
  print("Good")

Buggy submission (verdict: Runtime Error):
import sys
readline=sys.stdin.buffer.readline
n=int(input())
a=[list(map(int, readline().split())) for _ in range(n)]
a.sort(key=lambda x: x[1])
t=0
for i in range(n):
  t+=a[i][0]
  if t>a[i][1]:
    print("No")
    break
  elif i==n-1:
    print("Yes")
Problem p02995 (python)

Fixed submission:
import fractions
A,B,C,D=map(int, input().split())
def ans_mthd(i, j, k):
    return (i - i // j - i // k + i * fractions.gcd(j, k) // j // k )
ans = ans_mthd(B, C, D)-ans_mthd(A-1, C, D)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import sys

num = list(map(int, input().split()))

A = num[0]
B = num[1]
C = num[2]
D = num[3]

def ans_mthd(i, j, k):
    return i - i // j - i // k + i * math.gcd(j, k) / j // k 

ans = ans_mthd(B, C, D)-ans_mthd(A-1, C, D)
# print(math.gcd(C, D))
# print(C * D)
# print(ans_mthd(B, C, D) // 1)
print(ans)

Buggy submission (verdict: Runtime Error):
from decimal import *
import math
import sys

num = list(map(int, input().split()))

A = num[0]
B = num[1]
C = num[2]
D = num[3]

def ans_mthd(i, j, k):
    return Decimal((i - i // j - i // k + i * math.gcd(j, k) / j // k ))

ans = ans_mthd(B, C, D)-ans_mthd(A-1, C, D)
# print(math.gcd(C, D))
# print(C * D)
# print(ans_mthd(B, C, D) // 1)
print(ans)
Problem p02996 (python)

Fixed submission:
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
a.sort(key=lambda x: x[1])
t=0
for i in range(n):
  t+=a[i][0]
  if t>a[i][1]:
    print("No")
    break
  elif i==n-1:
    print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
readline=sys.stdin.buffer.readline
n=int(input())
a=[list(map(int, readline().split())) for _ in range(n)]
a.sort(key=lambda x: x[1])
t=0
for i in range(n):
  t+=a[i][0]
  if t>a[i][1]:
    print("No")
    break
  elif i==n-1:
    print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
readline=sys.stdin.buffer.redline
n=int(input())
a=[list(map(int, readline().split())) for _ in range(n)]
a.sort(key=lambda x: x[1])
t=0
for i in range(n):
  t+=a[i][0]
  if t>a[i][1]:
    print("No")
    break
  elif i==n-1:
    print("Yes")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
a.sort(key=lambda x: x[1])
t=0
for i in range(n):
  t+=a[0]
  if t>a[1]:
    print("No")
    break
  elif i==n-1:
    print("Yes")
Problem p03000 (python)

Fixed submission:
n,x=map(int,input().split())
l=list(map(int,input().split()))
a=0
for i in range(n):
  a+=l[i]
  if a>x:
    print(i+1)
    break
else:
  print(1+n)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
l=list(map(int,input().split()))
a=0
for i in range(n):
  a+=l(i)
  if a>x:
    print(i+1)
    break