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

Fixed submission:
n = int(input())
g1,s1,b1 = map(int,input().split())
g2,s2,b2 = map(int,input().split())
def trade(n,g1,s1,b1,g2,s2,b2):
  tradelist = []
  for x,y in (g1,g2),(s1,s2),(b1,b2):
    if x < y:
      tradelist.append((x,y))
  if not tradelist:
    return n
  dp = [0]*(n+1)
  for w,v in tradelist:
    for i in range(n+1-w):
      dp[i+w] = max(dp[i+w],dp[i]+v)
  ptr = n
  ret = dp[n]
  while ptr and dp[ptr-1] == dp[n]:
    ret += 1
    ptr -= 1
  return ret

ans1 = trade(n,g1,s1,b1,g2,s2,b2)
ans2 = trade(ans1,g2,s2,b2,g1,s1,b1)
print(ans2)

Buggy submission (verdict: Runtime Error):
n = int(input())
gsb1 = list(map(int,input().split()))
gsb2 = list(map(int,input().split()))
def trade(n,g1,s1,b1,g2,s2,b2):
  tradelist = []
  for x,y in (g1,g2),(s1,s2),(b1,b2):
    if x < y:
      tradelist.append((x,y))
  if not tradelist:
    return n
  dp = [0]*(n+1)
  for w,v in tradelist:
    for i in range(n+1-w):
      dp[i+w] = max(dp[i+w],dp[i]+v)
  return dp[n]

ans1 = trade(n,*gsb1,*gsb2)
ans2 = trade(ans1,*gsb2,*gsb1)
print(ans2)
Problem p03032 (python)

Fixed submission:
import bisect
n,K = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
ans = [0]
if K>2*n:
    K = 2*n
if K == 1:
    print(max(a[0],a[n-1],0))
    exit()
for k in range((K+1)//2,min(K+1,n+1)):
    r = K-k
    for i in range(k+1):
        ls = a[:i]+a[n-k+i:]
        ls.sort()
        if r == 0:
            ans.append(sum(ls))
        elif ls[r-1]<0:
            ans.append(sum(ls[r:]))
        else:
            x = bisect.bisect_left(ls,0)
            ans.append(sum(ls[x:]))
print(max(ans))

Buggy submission (verdict: Runtime Error):
import bisect
n,K = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
ans = [0]
if K>2*n:
    K = 2*n
if K == 1:
    print(max(a[0],a[n-1],0))
    exit()
for k in range((K+1)//2,K+1):
    r = K-k
    for i in range(k+1):
        ls = a[:i]+a[n-k+i:]
        ls.sort()
        if r == 0:
            ans.append(sum(ls))
        elif ls[r-1]<0:
            ans.append(sum(ls[r:]))
        else:
            x = bisect.bisect_left(ls,0)
            ans.append(sum(ls[x:]))
print(max(ans))
Problem p03035 (python)

Fixed submission:
a,b=map(int,input().split())
if a>=13:
  print(b)
elif a>=6:
  print(b//2)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
import bisect
import sys
input=sys.stdin.readline
from operator import itemgetter
n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int,input().split())) for i in range(m)]
a.sort()
bc.sort(key=itemgetter(1),reverse=True)
s=0
ans=0
for i in range(m):
  if a[s]<bc[i][1]:
    t=bisect.bisect_left(a,bc[i][1],s,n)
    cvt=min(t-s,bc[i][0])
    ans+=bc[i][1]*cvt
    s+=cvt
    if s>=n:
      break
  else:
    break
print(ans+sum(a[s:]))

Buggy submission (verdict: Runtime Error):
import bisect
n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int,input().split())) for i in range(m)]
a.sort()
bc.sort(key=lambda x:x[1],reverse=True)
s=0
for i in range(m):
  if a[s]<bc[i][1]:
    t=bisect.bisect_left(a,bc[i][1],s,n)
    for j in range(s,min(t,s+bc[i][0])):
      a[j]=bc[i][1]
    s=min(t,s+bc[i][0])
    if s>=n:
      break
  else:
    break
print(sum(ans))
Problem p03061 (python)

Fixed submission:
from fractions import gcd
def gc(a,b):
  if a==0 or b==0:
    return max(a,b)
  else:
    return gcd(a,b)
n=int(input())
a=list(map(int,input().split()))
a=[0]+a+[0]
lgcd=[0]
rgcd=[0]
for i in range(1,n):
  lgcd.append(gc(a[i],lgcd[-1]))
  rgcd.append(gc(a[-i-1],rgcd[-1]))
GCD=0
for i in range(n):
  GCD=max(GCD,gc(lgcd[i],rgcd[-i-1]))
print(GCD)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
  if a*b == 0:
    return max(a,b)
  if a<b:
    a,b = b,a
  return gcd(b,a%b)
n = int(input())
ls = list(map(int,input().split()))
length = 2**((n-1).bit_length())
calc = gcd
unit = 0
Seg = [unit for i in range(length*2-1)]
def init():
  for i in range(n):
    Seg[i+length-1] = ls[i]
  for i in range(length//2,-1,-1):
    Seg[i] = calc(Seg[2*i+1],Seg[2*i+2])
def update(i,x):
  i += length-1
  Seg[i] = x
  while i>0:
    i = (i-1)//2
    Seg[i] = calc(Seg[2*i+1],Seg[2*i+2])
def query(a,b,k,l,r):
  if r<=a or b<=l:
    return unit
  if l<=a and b<=r:
    return Seg[k]
  else:
    vl = query(a,b,2*k+1,l,(l+r)//2)
    vr = query(a,b,2*k+2,(l+r)//2,r)
    return calc(vl,vr)

init()
ans = []
for i in range(n):
  update(i,0)
  ans.append(query(0,n,0,0,length))
  update(i,ls[i])
print(max(ans))
Problem p03064 (python)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
mod = 998244353
sm = sum(a)
dp = [[0 for i in range(sm+1)] for j in range(n+1)]
dp2 = [[0 for i in range(sm+1)] for j in range(n+1)]
dp[0][0] = 1
dp2[0][0] = 1
for i in range(1,n+1):
  x = a[i-1]
  dp2[i] = dp2[i-1][:]
  for j in range(sm+1):
    dp[i][j] = dp[i-1][j]*2
    if j >= x:
      dp[i][j] += dp[i-1][j-x]
      dp2[i][j] += dp2[i-1][j-x]
    dp[i][j] %= mod
    dp2[i][j] %= mod
ans = pow(3,n,mod)-sum(dp[-1][(sm+1)//2:])*3
if sm%2:
  print(ans%mod)
else:
  print((ans+dp2[-1][sm//2]*(mod+1)//2*6)%mod)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
mod = 998244353
sm = sum(a)
dp = [[0 for i in range(sm+1)] for j in range(n+1)]
dp2 = [[0 for i in range(sm+1)] for j in range(n+1)]
dp[0][0] = 1
dp2[0][0] = 1
for i in range(1,n+1):
  x = a[i-1]
  dp2[i] = dp2[i-1][:]
  for j in range(sm+1):
    dp[i][j] = dp[i-1][j]*2
    if j >= x:
      dp[i][j] += dp[i-1][j-x]
      dp2[i][j] += dp2[i-1][j-x]
    dp[i][j] %= mod
    dp2[i][j] %= mod
ans = pow(3,n,mod)-sum(dp[-1][(sm+1)//2:])*3
if sm%2:
  print(ans%mod)
else:
  print(2/0)
  print((ans+dp2[-1][sm//2]//2*6)%mod)
Problem p03069 (python)

Fixed submission:
n=int(input())
s=input()
tmp=0
for i in range(n):
  if s[i]==".":
    tmp+=1
ans=tmp
for i in range(n):
  if s[i]==".":
    tmp-=1
  else:
    tmp+=1
  ans=min(ans,tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
tmp=0
for i in range(n):
  lf s[i]==".":
    tmp+=1
ans=tmp
for i in range(n):
  if s[i]==".":
    tmp-=1
  else:
    tmp+=1
  ans=min(ans,tmp)
print(ans)
Problem p03081 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = input().rstrip()
td = [list(input().rstrip().split()) for i in range(q)]
def judge(x,direction):
  if direction == "L":
    if x == n:
      return True
    if x == -1:
      return False
    jpos = lambda w: True if w>=0 else False
  else:
    if x == -1:
      return True
    if x == n:
      return False
    jpos = lambda w: True if w<n else False
  for i in range(q):
    if td[i][0] == s[x]:
      if td[i][1] == "R":
        x += 1
      else:
        x -= 1
    if jpos(x) == False:
      return False
    if not 0<=x<n:
      return True
  return True
l = -1
r = n
while l+1<r:
  m = (l+r)//2
  if judge(m,"L"):
    r = m
  else:
    l = m
ansl = r
l = -1
r = n
while l+1<r:
  m = (l+r)//2
  if judge(m,"R"):
    l = m
  else:
    r = m
ansr = l
print(max(0,ansr-ansl+1))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = input().rstrip()
td = [list(input().rstrip().split()) for i in range(q)]
def judge(x,direction):
  if direction == "L":
    if x == n:
      return True
    if x == -1:
      return False
    jedge = lambda w: True if w>=0 else False
  else:
    if x == -1:
      return True
    if x == n:
      return False
    jedge = lambda w: True if w<n else False
  for i in range(q):
    if td[i][0] == s[x]:
      if td[i][1] == "R":
        x += 1
      else:
        x -= 1
    if jedge(x) == False:
      return False
  return True
l = -1
r = n
while l+1<r:
  m = (l+r)//2
  if judge(m,"L"):
    r = m
  else:
    l = m
ansl = r
l = -1
r = n
while l+1<r:
  m = (l+r)//2
  if judge(m,"R"):
    l = m
  else:
    r = m
ansr = l
print(max(0,ansr-ansl+1))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = input().rstrip()
td = [list(input().rstrip().split()) for i in range(q)]
def judge(x,direction):
  if direction == "L":
    if x == n:
      return True
    if x == -1:
      return False
    jedge = lambda w: True if w>=0 else False
  else:
    if x == -1:
      return True
    if x == n:
      return False
    jedge = lambda w: True if w<n else False
  for i in range(q):
    if td[i][0] == s[x]:
      if td[i][1] == "R":
        x += 1
      else:
        x -= 1
    if jedge(x) == False:
      return False
  return True
l = -1
r = n
while l+1<r:
  x = (l+r)//2
  if judge(x,"L"):
    r = x
  else:
    l = x
ansl = r
l = -1
r = n
while l+1<r:
  x = (l+r)//2
  if judge(x,"R"):
    l = x
  else:
    r = x
ansr = l
print(max(0,ansr-ansl+1))
Problem p03087 (python)

Fixed submission:
import bisect
n,q=map(int,input().split())
s=input()
ac=[]
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    ac.append(i+1)
for i in range(q):
  a,b=map(int,input().split())
  print(bisect.bisect_right(ac,b-1)-bisect.bisect_left(ac,a))

Buggy submission (verdict: Runtime Error):
import bisect
n,q=map(int,input().split())
s=input()
ac=[]
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    ac.append(i+1)
for i in range(q):
  a,b=map(int,input().split())
  print(bisect.bisect_right(b-1)-bisect.bisect_left(a))
Problem p03089 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    if a[i]>i+1:
        print(-1)
        exit()
def order(a):
    if a == [1]:
        return [1]
    else:
        x = order(a[:-1])
        y = a[-1]
        x.insert(y-1,y)
        return x
print(*order(a),sep="\n")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
def order(a):
    if a == [1]:
        return [1]
    else:
        x = order(a[:-1])
        y = a[-1]
        x.insert(y-1,y)
        return x
print(*order(a),sep="\n")
Problem p03090 (python)

Fixed submission:
n=int(input())
m=n//2*2
ans=[]
for i in range(1,m//2):
  for j in range(1+i,m-i+1):
    ans.append((i,j))
    ans.append((m+1-j,m+1-i))
if n%2:
  for i in range(1,n):
    ans.append((i,n))
print(len(ans))
for i in ans:
  print(*i,sep=" ")

Buggy submission (verdict: Runtime Error):
n=int(input())
m=n//2*2
ans=[]
for i in range(1,m//2):
  for j in range(1+i,m-i+1):
  ans.append((i,j))
  ans.append((n-j,n-i))
if n%2:
  for i in range(1,n):
    ans.append((i,n))
print(len(ans),*ans,sep="\n")
Problem p03091 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
graph = [[] for i in range(n+1)]
for a,b in ab:
  graph[a].append(b)
  graph[b].append(a)
jdg = 0
ls = []
for i,g in enumerate(graph):
  if len(g)%2:
    print("No")
    exit()
  if len(g) == 4:
    jdg += 1
    ls.append(i)
  elif len(g) >= 6:
    jdg += 3
if jdg >= 3:
  print("Yes")
elif jdg == 2:
  start,goal = ls
  stack = [start]
  vis = [0]*(n+1)
  vis[start] = 1
  vis[goal] = 2
  jdg2 = 0
  while stack:
    x = stack.pop()
    for y in graph[x]:
      if vis[y] == 0:
        vis[y] = 1
        stack.append(y)
      elif vis[y] == 2:
        jdg2 += 1
  if jdg2 == 4:
    print("No")
  else:
    print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
graph = [[] for i in range(n+1)]
for a,b in ab:
  graph[a].append(b)
  graph[b].append(a)
jdg = 0
for g in graph:
  if len(g)%2:
    print("No")
    exit()
  if len(g) == 4:
    jdg += 1
  elif len(g) >= 6:
    jdg += 3
if jdg >= 3:
  print("Yes")
elif jdg == 2:
  print(2/0)
else:
  print("No")
Problem p03095 (python)

Fixed submission:
from collections import Counter
n = int(input())
s = list(input())
c = Counter(s)
ans = 1
for x in c.values():
  ans = ans*(x+1)%(10**9+7)
print(ans-1)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
s = list(input())
c = Counter(s)
ans = 1
for x in c.values():
  ans = ans*(x+1)%mod
print(ans-1)
Problem p03096 (python)

Fixed submission:
import bisect
import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
app = [0 for i in range(200001)]
mod = 10**9+7
pair = []
for i in range(n):
  x = a[i]
  if app[x] != 0 and i != app[x]:
    pair.append([app[x],i+1])
  app[x] = i+1
pair.sort()
ps = len(pair)
cntls = []
order = []
sumtot = []
for i in range(ps-1,-1,-1):
  [s,t] = pair[i]
  if i == ps-1:
    cntls.append([-s,1])
    order.append(-s)
    sumtot.append([-s,1])
  elif t>-cntls[0][0]:
    cntls.append([-s,1])
    order.append(-s)
    sumtot.append([-s,sumtot[-1][1]+1])
  else:
    x = bisect.bisect_right(order,-t)
    cntls.append([-s,sumtot[x-1][1]+1])
    order.append(-s)
    sumtot.append([-s,(sumtot[-1][1]+sumtot[x-1][1]+1)%mod])
if pair == []:
  print(1)
else:
  print((sumtot[-1][1]+1)%mod)

Buggy submission (verdict: Runtime Error):
import bisect
import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
app = [0 for i in range(n+1)]
mod = 10**9+7
pair = []
for i in range(n):
  x = a[i]
  if app[x] != 0 and i != app[x]:
    pair.append([app[x],i+1])
  app[x] = i+1
pair.sort()
ps = len(pair)
ans = 1
cntls = []
order = []
sumtot = []
for i in range(ps-1,-1,-1):
  [s,t] = pair[i]
  if i == ps-1:
    cntls.append([-s,1])
    order.append(-s)
    sumtot.append([-s,1])
  elif t>-cntls[0][0]:
    cntls.append([-s,1])
    order.append(-s)
    sumtot.append([-s,sumtot[-1][1]+1])
  else:
    x = bisect.bisect_right(order,-t)
    cntls.append([-s,sumtot[x-1][1]+1])
    order.append(-s)
    sumtot.append([-s,(sumtot[-1][1]+sumtot[x-1][1]+1)%mod])
if pair == []:
  print(1)
else:
  print((sumtot[-1][1]+1)%mod)

Buggy submission (verdict: Runtime Error):
import bisect
import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
app = [0 for i in range(n+1)]
mod = 10**9+7
pair = []
for i in range(n):
  x = a[i]
  if app[x] != 0 and i != app[x]:
    pair.append([app[x],i+1])
  app[x] = i+1
pair.sort()
ps = len(pair)
ans = 1
cntls = []
order = []
sumtot = []
for i in range(ps-1,-1,-1):
  [s,t] = pair[i]
  if i == ps-1:
    cntls.append([-s,1])
    order.append(-s)
    sumtot.append([-s,1])
  elif t>-cntls[0][0]:
    cntls.append([-s,1])
    order.append(-s)
    sumtot.append([-s,sumtot[-1][1]+1])
  else:
    x = bisect.bisect_right(order,-t)
    cntls.append([-s,sumtot[x-1][1]+1])
    order.append(-s)
    sumtot.append([-s,(sumtot[-1][1]+sumtot[x-1][1]+1)%mod])
print((sumtot[-1][1]+1)%mod)
Problem p03097 (python)

Fixed submission:
n,a,b = map(int,input().split())
if bin(a^b).count("1")%2 == 0:
  print("NO")
  exit()
st = min(a,b)
dif = a^b
t = 1<<(n-1)
chls = []
chcnt = n-1
for i in range(n)[::-1]:
  if dif&1<<i:
    chls.append((chcnt,i))
    chcnt -= 1
def change(x,p,q):
  if (x>>p)&1 ^ (x>>q)&1:
    x ^= (1<<p)+(1<<q)
  return x
def changeall(x):
  for l,r in chls[::-1]:
    x = change(x,l,r)
  x ^= st
  return x
if n == 1:
  print("YES")
  print(a,b)
  exit()
ls = []
x = 0
for i in range(1,2**n):
  cnt = 0
  while i%2 == 0:
    i //= 2
    cnt += 1
  ls.append(1<<cnt)
chcnt += 1
while chcnt < n-1:
  i = chcnt+1
  ls[-2**i] //= 2
  ls[-2**(i-1)] *= 2
  ls[-2**(i-1)-2**i] *= 2
  chcnt += 2
nls = [0]
for i in ls:
  nls.append(nls[-1]^i)
print("YES")
ansls = [changeall(nls[i]) for i in range(2**n)]
if a < b:
  print(*ansls)
else:
  print(*ansls[::-1])

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
for i in range(n):
  if a^b == 1<<i:
    break
else:
  print("NO")
  exit()
st = min(a,b)
bt = (a^b).bit_length()-1
def change(x):
  x ^= st
  if ((x>>bt)&1) ^ ((x>>(n-1))&1):
    x ^= (1<<bt)+(1<<(n-1))
  return x
if n == 1:
  print("YES")
  print(a,b)
  exit()
ls = [0]
x = 0
cnt = 1
while x != 1<<(n-1):
  cntc = cnt
  divcnt = 0
  while cntc%2 == 0:
    cntc //= 2
    divcnt += 1
  x ^= 1<<divcnt
  ls.append(x)
  cnt += 1
print("YES")
ansls = [change(ls[i]) for i in range(2**n)]
print(2/0)
if a < b:
  print(*ansls)
else:
  print(*ansls[::-1])
Problem p03110 (python)

Fixed submission:
n=int(input())
a=[list(input().split()) for i in range(n)]
ans=0
for i in range(n):
  if a[i][1]=="JPY":
    ans+=float(a[i][0])
  else:
    ans+=float(a[i][0])*380000
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[list(input().split()) for i in range(n)]
ans=0
for i in range(n):
  if a[i][1]=="JPY":
    ans+=float(a[i][0])
  else:
    ans+=float(a[i][0]*380000)
print(ans)
Problem p03125 (python)

Fixed submission:
a,b = map(int,input().split())
if b%a:
  print(b-a)
else:
  print(b+a)

Buggy submission (verdict: Runtime Error):
a,b = int(input())
if b%a:
  print(b-a)
else:
  print(b+a)
Problem p03128 (python)

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[0,2,5,5,4,5,6,3,7,6]
wv=[]
for i in a:
  wv.append((b[i],i))
wv.sort()
dp=[-1 for i in range(n+1)]
dp[0]=0
for i in range(1,n+1):
  for w,v in wv:
    if i-w<0:
      continue
    if dp[i-w]==-1:
      continue
    dp[i]=max(dp[i],dp[i-w]*10+v)
print(dp[n])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[0,2,5,5,4,5,6,3,7,6]
wv=[]
for i in a:
  wv.append((b[i],i))
wv.sort()
dp=[-1 for i in range(n+1)]
dp[0]=0
for i in range(1,n+1):
  for w,v in wv:
    if dp[i-w]==-1:
      continue
    dp[i]=max(dp[i],dp[i-w]*10+v)
Problem p03129 (python)

Fixed submission:
n,k=map(int,input().split())
if (n+1)//2>=k:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
b = [0]*n
for i in range(n):
  if a[i]%2:
    b[i] = 1
  elif a[i]:
    b[i] = 2
DP = [[0 for i in range(5)] for j in range(n+1)]
for i in range(1,n+1):
  for j in range(5):
    for k in range(j,5):
      if k == 0 or k == 4:
        DP[i][k] = DP[i-1][j]+a[i-1]
      elif k == 1 or k == 3:
        DP[i][k] = DP[i-1][j]+abs(b[i-1]-2)
      else:
        DP[i][k] = DP[i-1][j]+abs(b[i-1]-1)
print(min(DP[n]))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
b = [0]*n
for i in range(n):
  if a[i]%2:
    b[i] = 1
  elif a[i]:
    b[i] = 2
DP = [[10**18 for i in range(5)] for j in range(n+1)]
for i in range(5):
    DP[0][i] = 0
for i in range(1,n+1):
  for j in range(5):
    for k in range(j,5):
      if k == 0 or k == 4:
        DP[i][k] = min(DP[i][k],DP[i-1][j]+a[i-1])
      elif k == 1 or k == 3:
        DP[i][k] = min(DP[i][k],DP[i-1][j]+abs(b[i-1]-2))
      else:
        DP[i][k] = min(DP[i][k],DP[i-1][j]+abs(b[i-1]-1))
print(min(DP[n]))
Problem p03132 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
b = [0]*n
for i in range(n):
  if a[i]%2:
    b[i] = 1
  elif a[i]:
    b[i] = 2
a.append(0)
b.append(0)
n += 1
DP = [[[10**18 for i in range(3)] for j in range(3)] for k in range(n+1)]
for i in range(3):
  for j in range(3):
    DP[0][i][j] = 0
for i in range(1,n+1):
  for k in (0,2):
    DP[i][0][k] = min(DP[i][0][k],DP[i-1][0][k]+abs(a[i-1]))
  for l in (1,2):
    DP[i][0][2] = min(DP[i][0][2],DP[i-1][l][2]+abs(a[i-1]))
  DP[i][0][2] = min(DP[i][0][2],DP[i-1][2][1]+abs(a[i-1]))

  DP[i][1][2] = min(DP[i][1][2],DP[i-1][0][0]+abs(b[i-1]-1))
  DP[i][1][2] = min(DP[i][1][2],DP[i-1][1][2]+abs(b[i-1]-1))
  DP[i][1][2] = min(DP[i][1][2],DP[i-1][2][1]+abs(b[i-1]-1))

  for k in (1,2):
    DP[i][2][k] = min(DP[i][2][k],DP[i-1][2][k]+abs(b[i-1]-2))
  DP[i][2][2] = min(DP[i][2][2],DP[i-1][1][2]+abs(b[i-1]-2))
  DP[i][2][1] = min(DP[i][2][1],DP[i-1][0][0]+abs(b[i-1]-2))
print(min(*DP[n][0]))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
b = [0]*n
for i in range(n):
  if a[i]%2:
    b[i] = 1
  elif a[i]:
    b[i] = 2
n += 1
DP = [[10**18 for i in range(5)] for j in range(n+1)]
for i in range(5):
    DP[0][i] = 0
for i in range(1,n+1):
  for j in range(5):
    for k in range(j,5):
      if k == 0 or k == 4:
        DP[i][k] = min(DP[i][k],DP[i-1][j]+a[i-1])
      elif k == 1 or k == 3:
        DP[i][k] = min(DP[i][k],DP[i-1][j]+abs(b[i-1]-1))
      else:
        DP[i][k] = min(DP[i][k],DP[i-1][j]+abs(b[i-1]-2))
print(min(DP[n]))
Problem p03133 (python)

Fixed submission:
n,m = map(int,input().split())
a = [int(input().replace(" ",""),2) for i in range(n)]
mod = 998244353
cnt = 0
for j in range(m)[::-1]:
  for i in range(cnt,n):
    if a[i] & 1<<j:
      for k in range(n):
        if (i != k) and (a[k] & 1<<j):
          a[k] ^= a[i]
      a[i],a[cnt] = a[cnt],a[i]
      cnt += 1
if cnt == 0:
  print(0)
else:
  ans = pow(2,n+m-2*cnt,mod)*pow(2,cnt-1,mod)*(pow(2,cnt,mod)-1)%mod
  print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [int(input().replace(" ",""),2) for i in range(n)]
mod = 998244353
cnt = 0
for j in range(m)[::-1]:
  for i in range(cnt,n):
    if a[i] & 1<<j:
      for k in range(n):
        if (i != k) and (a[k] & 1<<j):
          a[k] ^= a[i]
      a[i],a[cnt] = a[cnt],a[i]
      cnt += 1
ans = pow(2,n+m-2*cnt,mod)*pow(2,cnt-1,mod)*(pow(2,cnt,mod)-1)%mod
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [int(input().replace(" ",""),2) for i in range(n)]
mod = 998244353
cnt = 0
for j in range(m):
  for i in range(cnt,n):
    if a[i] & 1<<j:
      for k in range(n):
        if i != k and a[k] & 1<<j:
          a[k] ^= a[i]
      a[i],a[cnt] = a[cnt],a[i]
      cnt += 1
ans = pow(2,n+m-2*cnt,mod)*pow(2,cnt-1,mod)*(pow(2,cnt,mod)-1)%mod
print(ans)
Problem p03136 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
if sum(a)>2*a[-1]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a.sort()
if a>2*a[-1]:
  print("Yes")
else:
  print("No")
Problem p03139 (python)

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

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
input = sys.stdin.readline
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n-1+m)]
tree_go = [[] for i in range(n+1)]
tree_come = [[] for i in range(n+1)]
excess = [0 for i in range(n+1)]
for a,b in ab:
  tree_go[a].append(b)
  tree_come[b].append(a)
for i in range(1,n+1):
  if tree_come[i] == []:
    root = i
  if len(tree_come[i]) >= 2:
    excess[i] = len(tree_come[i])-1
que = deque([(root,0)])
parent = [0 for i in range(n+1)]
visited = [0 for i in range(n+1)]
while que:
  x,px = que.popleft()
  parent[x] = px
  if excess[x] >= 1:
    excess[x] -= 1
    continue
  for y in tree_go[x]:
    que.append((y,x))
print(*parent[1:],sep="\n")
Problem p03140 (python)

Fixed submission:
n = int(input())
a = input()
b = input()
c = input()
ans = 0
for i,j,k in zip(a,b,c):
  ans += len(set([i,j,k]))-1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = input()
b = input()
c = input()
ans = 0
for i,j,k in zip(a,b,c):
  ans += len(set(i,j,k))-1
print(ans)