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

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
num1,num2,num3=0,0,0
for i in range(n):
    if a[i]==1:
        num1+=1
    elif a[i]==2:
        num2+=1
    else:
        num3+=1
dp=[[[-1.0 for k in range(n+1)] for i in range(n+1)] for j in range(n+1)]
def f(n1,n2,n3):
    if dp[n1][n2][n3]>=0.0:
        return dp[n1][n2][n3]
    if n1==n2==n3==0:
        return 0.0
    ret=n
    if n1>0:
        ret+=f(n1-1,n2,n3)*n1
    if n2>0:
        ret+=f(n1+1,n2-1,n3)*n2
    if n3>0:
        ret+=f(n1,n2+1,n3-1)*n3
    ret*=1.0/(n1+n2+n3)
    dp[n1][n2][n3]=ret
    return dp[n1][n2][n3]
print(f(num1,num2,num3))

Buggy submission (verdict: Runtime Error):
import numpy as np
from numba import njit


@njit('(f8[:,:,:],i4,i4,i4,i4,)', cache=True)
def solve(dp, N, n1, n2, n3):

    if dp[n1][n2][n3] >= 0.0:
        return dp[n1][n2][n3]
    if n1 == n2 == n3 == 0:
        return 0.0

    cnt = n1 + n2 + n3
    ret = 0
    if n3 >= 1:
        ret += solve(dp, N, n1, n2 + 1, n3 - 1) * n3
    if n2 >= 1:
        ret += solve(dp, N, n1 + 1, n2 - 1, n3) * n2
    if n1 >= 1:
        ret += solve(dp, N, n1 - 1, n2, n3) * n1

    ret = (ret + N) / cnt
    dp[n1][n2][n3] = ret
    return ret


def main():
    N = int(input())
    A = list(map(int, input().split()))

    dp = np.full((N + 1, N + 1, N + 1), -1, dtype=np.float64)

    a1, a2, a3 = 0, 0, 0
    for i in range(N):
        if A[i] == 1:
            a1 += 1
        elif A[i] == 2:
            a2 += 1
        elif A[i] == 3:
            a3 += 1

    print(solve(dp, N, a1, a2, a3))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from numba import njit
sys.setrecursionlimit(10**7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N = in_n()
    A = in_nl()

    n1 = A.count(1)
    n2 = A.count(2)
    n3 = A.count(3)

    dp = np.full((N + 1, N + 1, N + 1), -1, dtype=np.float64)
    dp[0][0][0] = 0

    print(solve(N, dp, n1, n2, n3))


@njit('(i4,f8[:,:,:],i4,i4,i4,)', cache=True)
def solve(N, dp, n1, n2, n3):

    if dp[n1][n2][n3] != -1:
        return dp[n1][n2][n3]

    cnt = n1 + n2 + n3
    ret = 0
    if n3 >= 1:
        ret += solve(N, dp, n1, n2 + 1, n3 - 1) * n3 / cnt
    if n2 >= 1:
        ret += solve(N, dp, n1 + 1, n2 - 1, n3) * n2 / cnt
    if n1 >= 1:
        ret += solve(N, dp, n1 - 1, n2, n3) * n1 / cnt

    dp[n1][n2][n3] = ret + (N / cnt)
    return ret + (N / cnt)


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

Fixed submission:
import sys

input = sys.stdin.buffer.readline
in_n = lambda: int(input())
in_nn = lambda: map(int, input().split())
in_s = lambda: input().rstrip().decode('utf-8')
in_map = lambda: [s == ord('.') for s in input() if s != ord('\n')]

MOD = 10**9 + 7
INF = 8 * 10**18


def main():

    X = in_n()
    A = in_n()
    B = in_n()
    print((X - A) % B)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.buffer.readline
in_n = lambda: int(input())
in_nn = lambda: map(int, input().split())
in_s = lambda: input().rstrip().decode('utf-8')
in_map = lambda: [s == ord('.') for s in input() if s != ord('\n')]

MOD = 10**9 + 7
INF = 8 * 10**18


def main():

    X, A, B = in_nn()
    print((X - A) % B)


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

Fixed submission:
import sys

input = sys.stdin.buffer.readline
in_n = lambda: int(input())
in_nn = lambda: map(int, input().split())
in_s = lambda: input().rstrip().decode('utf-8')
in_map = lambda: [s == ord('.') for s in input() if s != ord('\n')]

MOD = 10**9 + 7
INF = 8 * 10**18


def main():

    N, M = in_nn()
    X = list(in_nn())
    Y = list(in_nn())

    x_tsum = [0] * (N + 1)
    for i in range(N):
        x_tsum[i + 1] += x_tsum[i] + X[i]
        x_tsum[i + 1] %= MOD

    x_sum = 0
    for i in range(1, N):
        x_sum += X[i] * i - x_tsum[i]
        x_sum %= MOD

    y_tsum = [0] * (M + 1)
    for i in range(M):
        y_tsum[i + 1] += y_tsum[i] + Y[i]
        y_tsum[i + 1] %= MOD

    y_sum = 0
    for i in range(1, M):
        y_sum += Y[i] * i - y_tsum[i]
        y_sum %= MOD

    print(x_sum * y_sum % MOD)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.buffer.readline
in_n = lambda: int(input())
in_nn = lambda: map(int, input().split())
in_s = lambda: input().rstrip().decode('utf-8')
in_map = lambda: [s == ord('.') for s in input() if s != ord('\n')]

MOD = 10**9 + 7
INF = 8 * 10**18


def main():

    N, M = in_nn()
    X = list(in_nn())
    Y = list(in_nn())

    x_tsum = [0] * (N + 1)
    for i in range(N):
        x_tsum[i + 1] += x_tsum[i] + X[i]
        x_tsum[i + 1] %= MOD

    x_sum = 0
    for i in range(1, N):
        x_sum += X[i] * i - x_tsum[i]
        x_sum %= MOD

    y_tsum = [0] * (N + 1)
    for i in range(M):
        y_tsum[i + 1] += y_tsum[i] + Y[i]
        y_tsum[i + 1] %= MOD

    y_sum = 0
    for i in range(1, M):
        y_sum += Y[i] * i - y_tsum[i]
        y_sum %= MOD

    print(x_sum * y_sum % MOD)


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

Fixed submission:
s = input()
n = [0]*26
for e in s:
  n[ord(e)-ord('a')]+=1
for i in n:
  if i>1:
    print("no")
    exit()
print("yes")

Buggy submission (verdict: Runtime Error):
s = input()

n = []*26

for e in s:
  n[e-'a']+=1
  
for i in n:
  if i>1:
    print("no")
    return
print("yes)
Problem p02609 (python)

Fixed submission:
n,x=int(input()),input()
o=x.count("1")
if o==1:
    for i,v in enumerate(x):
        if v=="1":print(0)
        else:
            if i!=n-1:
                if x[-1]=="0":print(1)
                else:print(2)
            else:print(2)

else:
    m=o-1
    M=o+1
    mp,mm={0:1},{0:1}
    for i in range(1,n):
        mp[i]=mp[i-1]*2%M
        mm[i]=mm[i-1]*2%m
    A=int(x,2)
    a=A%m
    b=A%M
    rest={0:0}
    for i in range(1,o+1):
        rest[i]=1+rest[i%bin(i).count("1")]
    for i,v in enumerate(x):
        if v=="1":
            print(1+rest[(a-mm[n-i-1])%m])
        else:
            print(1+rest[(b+mp[n-i-1])%M])

Buggy submission (verdict: Runtime Error):
n,x=int(input()),input()
o=x.count("1")
if o==1:
    for i,v in x:
        if v=="1":print(0)
        else:
            if i!=n-1:
                if x[-1]=="0":print(1)
                else:print(2)
            else:print(0)
else:
    m=o-1
    M=o+1
    mp,mm={0:1},{0:1}
    for i in range(1,n):
        mp[i]=mp[i-1]*2%M
        mm[i]=mm[i-1]*2%m
    A=int(x,2)
    a=A%m
    b=A%M
    rest={0:0}
    for i in range(1,o+1):
        rest[i]=1+rest[i%bin(i).count("1")]
    for i,v in enumerate(x):
        if v=="1":
            print(1+rest[(a-mm[n-i-1])%m])
        else:
            print(1+rest[(b+mp[n-i-1])%M])

Buggy submission (verdict: Runtime Error):
n,x=int(input()),input()
o=x.count("1")
l=[0]*(o+1)
A=int(x,2)
a=A%(o+1)
b=A%(o-1)
for i in range(1,o+1):l[i]=l[i%bin(i).count("1")]+1
mp=[1]*n
mm= [1]*n
for i in range(1,n):
  mp[i]=mp[i-1]*2%(o+1)
  mm[i]=mm[i-1]*2%(o-1)
for i,v in enumerate(x):
  if v=="0":
    print(l[(a+mp[-1-i])%(o+1)]+1)
  else:
    if o==1:print(0)
    else:print(l[(b+mm[-1-i])%(o-1)]+1)

Buggy submission (verdict: Runtime Error):
n,x=int(input()),input()
g=int(x,2)
c=pow(2,n-1)
memo={}
for b in x:
    if b=="1":
        p=g-c
    else:
        p=g+c
    ret=0
    while p:
        q=bin(p).count("1")
        if (p,q)in memo:print(ret+memo[(p,q)]);break 
        p%=q
        ret+=1
    c//=2
    memo[(p,q)]=ret
    print(ret)

Buggy submission (verdict: Runtime Error):
n,x=int(input()),input()
g=int(x,2)
c=pow(2,n-1)
j=x.count("1")

for b in x:
    if b=="1":
        p=g-c
        q=j-1
    else:
        p=g+c
        q=j+1
    p%=q
    ret=1
    while p:
        p%=bin(p).count("1")
        ret+=1
    c//=2
    print(ret)
Problem p02662 (python)

Fixed submission:
n,s=map(int,input().split())
dp=[0]*(s+1)
dp[0]=1
ne=[0]*(s+1)
mod=998244353
for i in list(map(int,input().split())):

    for k in range(0,s+1):
        if k+i<=s:
            ne[k+i]=(ne[k+i]+dp[k])%mod
        ne[k]=(ne[k]+2*dp[k])%mod
        dp[k]=0
    dp,ne=ne,dp
print(dp[-1])

Buggy submission (verdict: Runtime Error):
mod1,mod2=10**9+7,998244353
mod=mod2
n,s=map(int,input().split())
dp=[0]*(s+1)
dp[0]=1
for a in map(int,input().split()):
    for i in range(s,a-1,-1):
        dp[i]=(dp[i]*2%mod+dp[i-a])%mod
    for i in range(a-1,-1,-1):
        dp[i]=2*dp[i]%mod
        
print(dp[-1])
Problem p02681 (python)

Fixed submission:
s,d=[input(),input()]
print("Yes") if s==d[:-1] else print("No")

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
mod=998244353
if m==1:print(0 if k!=n-1 else 1);exit()
fact=[1]*(n-1+1)
inv=[1]*(n-1+1)
for i in range(2,n-1+1):
    fact[i]=i*fact[i-1]%mod
inv[-1]=pow(fact[-1],mod-2,mod)
for i in range(n-1,1,-1):
    inv[i-1]=inv[i]*i%mod
ans=0
po=pow(m-1,n-1,mod)*m%mod
ue=fact[n-1]
iii=pow(m-1,mod-2,mod)%mod
for i in range(k+1):
    ans+=ue*inv[n-1-i]%mod*inv[i]%mod*po%mod
    po*=iii
print(ans%mod)
Problem p02684 (python)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
ok=set()
now=0
l=[]
while now not in ok and k:
    l.append(now)
    ok.add(now)
    now=a[now]-1
    k-=1
if k==0:print(now+1);exit()
length=len(ok)-(h:=l.index(now))
l=l[h:]

k=(k)%length

print(l[k]+1)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
ok=set()
now=0
l=[]
while now not in ok and k:
    l.append(now)
    ok.add(now)
    now=a[now]-1
    k-=1
length=len(ok)-(h:=l.index(now))
l=l[h:]
print(l,h,length)
k=(k)%length

print(l[k]+1)
Problem p02686 (python)

Fixed submission:
n=int(input())
po,ne=[],[]
now=0
for i in range(n):
    p=0
    mp=0
    for j in input():
        p+=(1,-1)[j==")"]
        mp=min(p,mp)
    if mp:
        if p>=0:
            po.append((mp,p))
        else:ne.append((mp-p,-p))
    else:now+=p
po.sort(reverse=1)
ne.sort(reverse=1)
for m,p in po:
    if m+now<0:print("No");exit()
    else:now+=p
nnow=0
for m,p in ne:
    if m+nnow<0:print("No");exit()
    else:nnow+=p
print("Yes" if now==nnow else "No")

Buggy submission (verdict: Runtime Error):
n=int(input())
po,ne=[],[]
now=0
for i in range(n):
    p=0
    mp=0
    for j in input():
        p+=(1,-1)[j==")"]
        mp=min(p,mp)
    if mp:
        if p>=0:
            po.append((mp,p))
        else:ne.append((mp-p,-p))
    else:now+=p
po.sort(reverse=1)
ne.sort(reevrse=1)
for m,p in po+ne:
    if m+now<0:print("No");exit()
    else:now+=p
print("No") if now else print("Yes")
Problem p02708 (python)

Fixed submission:
n,k=map(int,input().split())
print(((n+1)*(k+n+1)*(n+2-k)//2+k*(k-1)*(2*k-1)//6-(n+2)*(n+1)*(2*n+3)//6+n+2-k)%(10**9+7))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
print(((n+1)*(k+n+1)*(n+2-k)//2+k*(k-1)*(2*k-1)//6-(n+2)*(n+1)*(2*n+3)//6+n+2-k))%(10**9+7))
Problem p02713 (python)

Fixed submission:
k=int(input())
from math import gcd
l=[0]*(k)
for i in range(1,k+1):
    for j in range(1,k+1):
        l[gcd(i,j)-1]+=1

ans=0
for i in range(1,k+1):
    for j in range(1,1+k):
        ans+=gcd(i,j)*l[i-1]
print(ans)

Buggy submission (verdict: Runtime Error):
k=int(input())+1
from math import gcd
print(sum(gcd(gcd(i,j),r) for i in range(1,k)   for j in range(1,k)  for r in range(1,k) )
k=int(input())+1
from math import gcd
print(sum( gcd(gcd(i,j),r) for i in range(1,k)   for j in range(1,k)  for r in range(1,k) ))

Buggy submission (verdict: Runtime Error):
k=int(input())+1
from math import gcd
print(sum(gcd(gcd(i,j),r) for i in range(1,k)   for j in range(1,k)  for r in range(1,k) )
Problem p02743 (python)

Fixed submission:
a,b,c=map(int,input().split())
if c-a-b<=0:print("No");exit()
print("Yes") if 4*a*b<(c-a-b)**2 else print("No")

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
if n==1 or m==1:print(1);exit()
print(n*(m//2)+((n+1)//2)*(m%2))
Problem p02760 (python)

Fixed submission:
l=[list(map(int,input().split())) for i in range(3)]
l=sum(l,[])
n=int(input())
li=set([int(input()) for ini in range(n)])
d=[0 for i in range(9)]
for g in range(9):
  if l[g] in li:d[g]=1

for a,s,x in [(0,1,2),(3,4,5),(6,7,8),(0,4,8),(2,4,6),(0,3,6),(1,4,7),(2,5,8)]:
  if d[a]==d[x]==d[s]==1:
    print("Yes");exit()
print("No")

Buggy submission (verdict: Runtime Error):
l=[list(map(int,input().split())) for i in range(3)]
n=int(input())
li=set(input() for ini in range(n))
d=[0 for i in range(9)]
for j in range(3):
  for i in range(3):
    if l[j][i] in li:d[3*j+i]=1
if set(1) in [set(l[h::3])for h in range(3)]+[set(l[h:h+3])for h in range(3)]+[set([l[0],l[4],l[8]]),set([l[2],l[4],l[6]])]:
  print("Yes")
else:print("No")
Problem p02797 (python)

Fixed submission:
n,ko,aim=map(int,input().split())
l=[aim for i in range(ko)]
d=10**9-1 if aim==10**9 else 10**9
f=[d for i in range(n-ko)]
ll=l+f
print(*ll,sep=" ")

Buggy submission (verdict: Runtime Error):
n,k,s=map(int,input().split())
if s==10**9:
  print(*[s]*k,*[1]*(n-k))
else:
  print(*[s]*k,*[10**9]*(n-k))
Problem p02801 (python)

Fixed submission:
s=input()
l="abcdefghijklmnopqrstuvwxyz"
print(l[l.index(s)+1])

Buggy submission (verdict: Runtime Error):
mod=10**9+7
n,k=map(int,input().split())
l=sorted(map(int,input().split()))
ans=0
ll=1
ans+=ll*l[k-1]%mod
b,s=1,1
for i in range(k,n):
  ll=ll*i//(i-k+1)
  ans+=l[i]*ll%mod
  s*=i
  b*=(i-k+1)
ml=s//b

ans-=ml*l[0]
ans%=mod
for i in range(1,n-k+1):
  ml=ml*(n-i-k+1)//(n-i)
  ans-=ml*l[i]%mod

print(ans%mod)
Problem p02804 (python)

Fixed submission:
n,k=map(int,input().split())
l=sorted(list(map(int,input().split())))
mod=10**9+7
fact=[1]*(n+1)
inv=[1]*(n+1)
for i in range(2,n+1):
    fact[i]=i*fact[i-1]%mod
inv[-1]=pow(fact[-1],mod-2,mod)
for i in range(n,1,-1):
    inv[i-1]=inv[i]*i%mod
ans=0
for i in range(n):
    if i>=k-1:
        ans+=l[i]*fact[i]*inv[k-1]*inv[i-k+1]%mod
    if n-i-1>=k-1:
        ans-=l[i]*fact[n-i-1]*inv[k-1]*inv[n-i-1-k+1]%mod
    ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
form math import factorial as jj
mod=10**9+7
n,k=map(int,input().split())
l=sorted(map(int,input().split()))
ans=0

ml=jj(n-1)//(jj(k-1)*jj(n-k))
ans-=ml*(l[0]-l[n-1])%mod
for i in range(1,n-k+1):
  ml=ml*(n-i-k+1)//(n-i)
  ans-=ml*(l[i]-l[n-1-i])%mod
print(ans%mod)

Buggy submission (verdict: Runtime Error):
mod=10**9+7
n,k=map(int,input().split())
l=sorted(list(map(int,input().split())))
ans=0

ll=1
ans+=ll*l[k-1]%mod
ml=1
for i in range(k,n):
  ll=ll*i//(i-k+1)
  ans+=l[i]*ll%mod
  ml*=(i/(i-k+1))
ml//=1

ans-=ml*l[0]
ans%=mod
for i in range(1,n-k+1):
  ml=ml*(n-i-k+1)//(n-i)
  ans-=ml*l[i]%mod

print(int(ans%mod))
Problem p02813 (python)

Fixed submission:
import itertools
n=int(input())
p,q=[tuple(map(int,input().split())) for i in (1,1)]
j=itertools.permutations
l=list(j(range(1,n+1)))

for i,s in enumerate(l):
  if s==p:a=i
  if s==q:b=i
print(abs(a-b))

Buggy submission (verdict: Runtime Error):
import itertools
n=int(input())
p,q=[tuple(map(int,input().split())) for i in (1,1)]
j=itertools.permutations
l=list(j(range(1,n+1)))

for i,s in enumerate(l):
  if s==p:a=i
  elif s==q:b=i
print(abs(a-b))
Problem p02837 (python)

Fixed submission:
n=int(input())
l=[0 for i in range(n)]
for i in range(n):
  ka=int(input())
  r,w=[],[]
  for k in range(ka):
    x,y=map(int,input().split())
    r.append(x-1) if y else w.append(x-1)
  l[i]=(set(r),set(w))
ans=0
for j in range(2**n):
  v=format(j,"b").zfill(n)
  R,W=set(),set()
  RR={t for t in range(n) if v[t]=="1"}
  for h in RR:
    r,w=l[h]
    R|=r
    W|=w
  WW=set(range(n))-RR
  if len(RR&W) or len(WW&R) or len(R&W) :continue
  else:ans=max(ans,len(RR))
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import zip_longest as zi
n=int(input())
hil=[ [ [],[] ] for i in range(n)]
for i in range(n):
  hint=int(input())
  if hint:
    for j in range(hint):
      a,s=map(int,input().split())   
      hil[a-1][s]+=[i]

ans=0
for i in range(2**n)[::-1]:
  ss=bin(i)[2:]
  s="0"*(n-len(ss))+ss
  sset=set([fg for fg in range(n) if s[fg]=="1"])
  hset=set(range(n))-sset
  print(sset,hset)
  jjj,kkk=set(),set()
  for kk in sset:
    j,k=hil[kk]
    j,k=set(j),set(k)
    jjj|=j;kkk|=k
    
  if len(jjj&sset) or len(kkk&hset) :
    contiue
  else:
    ans=max(ans,len(ss.replace("0","")))
print(ans)
Problem p02838 (python)

Fixed submission:
n=int(input())
l=[int(c) for c in input().split()]
ans=0
mod=10**9+7
for i in range(60):
  s=sum(a>>i&1 for a in l)
  ans+=s*(n-s)<<i%mod
  ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[int(c) for c in input().spilt()]
ans=0
mod=10**9+7
for i in range(60):
  s=sum(a>>i&1 for a in l)
  ans+=s*(n-s)<<i%mod
  ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[int(c) for c in input().splt()]
ans=0
mod=10**9+7
for i in range(60):
  s=sum(a>>i&1 for a in l)
  ans+=s*(n-s)<<i%mod
  ans%=mod
print(ans)
Problem p02845 (python)

Fixed submission:
def f():
    n=int(input())
    l=[0,0,0]
    ans=1
    mod=10**9+7
    for i in list(map(int,input().split())):
        if i not in l:print(0);exit()
        ans=ans*l.count(i)%mod
        l[l.index(i)]+=1
    print(ans)
if __name__ == "__main__":f()

Buggy submission (verdict: Runtime Error):
def f():
    n=int(input())
    l=[0,0,0]
    ans=1
    mod=10**9+7
    for i in list(map(int,input().split())):
        if i not in l:print(0);exit()
        ans=ans*l.count(i)%mod
        l[l.index(i)]+=1
    print(ans)
if _name__=="__main__":f()

Buggy submission (verdict: Runtime Error):
def f():
	n=int(input())
    l=[0,0,0]
    ans=1
    mod=10**9+7
    for i in list(map(int,input().split())):
        if i not in l:print(0);exit()
        ans=ans*l.count(i)%mod
        l[l.index(i)]+=1
    print(ans)
if _name__=="__main__":f()

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[0,0,0]
ans=1
mod=10**9+7
for i in list(map(int,input().split())):
    ans=ans*l.count(i)%mod
    l[l.index(i)]+=1
print(ans)
Problem p02865 (python)

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

Buggy submission (verdict: Runtime Error):
from collections import Counter as co
n=int(input())
l=sorted(list(map(list,co(map(int,input().split())).items())))
if l[0][0]==0 and l[0][-1]>1:print(0);exit()
ans=1;pre=1
for i,(n,s) in enumerate(l):
  #if i!=n:print(0);exit()
  if i>1:
    ans*=(pre**s)
    ans%=998244353
  pre=s
print(ans)
Problem p02866 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
if l[0]:print(0);exit()
mod=998244353
k=[0]*n
for i in l:k[i]+=1
if k[0]!=1:print(0);exit()
ans=1
for i,s in zip(k,k[1:]):ans*=pow(i,s,mod)
print(ans%mod)

Buggy submission (verdict: Runtime Error):
from collections import Counter as co
n=int(input())
l=sorted(list(map(list,co(map(int,input().split())).items())))
if if l[0][0]==0 and l[0][-1]>1:print(0);exit()
ans=1;pre=1
for i,(n,s) in enumerate(l):
  if i!=n:print(0);exit()
  if i>1:
    ans*=(pre**s)
    ans%=998244353
  pre=s
print(ans)
Problem p02885 (python)

Fixed submission:
a,s=map(int,input().split())
print(max(a-2*s,0))

Buggy submission (verdict: Runtime Error):
a,s=map(int,input(),split())
print(max(a-2*s,0))
Problem p02899 (python)

Fixed submission:
def main():
  n=int(input())
  l=list(map(int,input().split()))
  k=[0]*n
  for i in range(1,n+1):
    k[l[i-1]-1]=str(i)
  print(" ".join(k))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
  n=int(input())
  l=list(map(int,input().split()))
  k=[0]*n
  for i in range(1,n+1):
    k[l[i]-1]=str(i)
  print(" ".join(k))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
  n=int(input())
  l=list(map(int,input().split()))
  k=[0]*n
  for i in range(1,n+1):
    k[i-1]=str(l.index(i)+1)
    print(" ".join(k))

main()

Buggy submission (verdict: Runtime Error):
def main():
  n=int(input())
  l=list(map(int,input().split()))
  k=[0]*n
  for i in range(1,n+1):
    k[i-1]=str(l.index(i)+1)
    print(" ".join(k))

main()

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
print(" ".join(map(str,[l.index(i)+1 for i in range(1,n+1)]))
Problem p02900 (python)

Fixed submission:
a,s=map(int,input().split())
def c(d,f):
  if d==0:return f
  else:return c(f%d,d)
  
j=c(a,s)
if j==1:print(1);exit()
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

print(len(factorization(j))+1)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from math import sqrt
a,s=map(int,input().split())
f=gcd(a,s)
ans=1
if f<=3:print(1+(f!=1));exit()
for i in range(2,int(sqrt(f))+1):

  if f%i==0:
    ans+=1
    while f%i==0:f//=i
print(ans+(n!=1))
Problem p02928 (python)

Fixed submission:
n,k=map(int,input().split())
l=list(map(int,input().split()))
sl=sorted(l)
ten=0
for i in range(n):
    for j in range(n):
        if l[i]>l[j]and i<j:ten+=1
pre=sl[0]
jiten=0
c=0
for i,x in enumerate(sl):
    if x==pre:jiten+=c
    else:
        jiten+=i
        c=i
        pre=x

print((ten*k+jiten*(k*(k-1))//2)%(10**9+7))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=list(map(int,input().split()))
sl=sorted(l)
ten=0
for i in range(n):
    for j in range(n):
        if l[i]>l[j]and i<j:ten+=1
pre=sl[0]
jiten=0
c=0
for i,x in enumerate(sl):
    if x==pre:jiten+=c
    else:
        jiten+=i
        c=i
        pre=x

print(ten*k+jiten*(k*(k-1))//2)n,k=map(int,input().split())
l=list(map(int,input().split()))
sl=sorted(l)
ten=0
for i in range(n):
    for j in range(n):
        if l[i]>l[j]and i<j:ten+=1
pre=sl[0]
jiten=0
c=0
for i,x in enumerate(sl):
    if x==pre:jiten+=c
    else:
        jiten+=i
        c=i
        pre=x

print(ten*k+jiten*(k*(k-1))//2)
Problem p02939 (python)

Fixed submission:
s=input()
if len(s)<=2:
    print(len(set(list(s))));exit()
dp=[0]*(len(s)+ 1)
dp[0]=0
dp[1]=1
dp[2]=(len(set(list(s[:2]))))

for i in range(3,1+len(s)):
    dp[i]=(dp[i-1]+1) if s[i-1]!=s[i-2]else (dp[i-3]+2)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
def f(s,pre):
  if s=="":return 0
  if pre==s[0]:
    return f(s[2:],s[:2])+1
  else:return f(s[1:],s[0])+1
print(f(input(),""))

Buggy submission (verdict: Runtime Error):
a=input()
l=set()
s=""
for i in list(a):
  s+=i
  if s not in l:
    l.append(s)
    s=""
  else:continue
print(len(l))