Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
(D,),C,*I=[[*map(int,t.split())]for t in open(0)]
s=sum(C)
for d,q in I[D-~D:]:I[d-1+D][0]=q;i,R,P,*L=[0]*29;exec('t=I[i+D][0]-1;P+=s+(~i+L[t])*C[t];R+=I[i][t]-P;i+=1;L[t]=i;'*D);print(R)

Fixed submission:
from numba import njit
from numpy import int64
@njit('i8(i8[:],i8[:])',cache=True)
def func(s,x):
    last=[0]*26
    score=0
    for i,v in enumerate(x,1):
        last[v]=i
        c=0
        for j in range(26):
            c+=s[j]*(i-last[j])
        score=score+s[i*26+v]-c
    return score
def main():
    d,*s=map(int,open(0).read().split())
    s=int64(s)
    x=s[26*-~d:d*27+26]-1
    for d,q in s[27*-~d:].reshape(-1,2):
        x[d-1]=q-1
        print(func(s,x))
main()

Buggy python submission (verdict: Time Limit Exceeded):
def func(s,x):
    last=[0]*26
    score=0
    for i,v in enumerate(x,1):
        last[v]=i
        c=0
        for j in range(26):
            c+=s[j]*(i-last[j])
        score+=s[i*26+v]-c
    return score
def main():
    d,*s=map(int,open(0).read().split())
    x=[t-1for t in s[26*-~d:d*27+26]]
    for d,q in zip(*[iter(s[27*-~d:])]*2):
        x[d-1]=q-1
        print(func(s,x))
main()

Fixed submission:
from numba import njit
from numpy import int64
@njit('i8(i8[:],i8[:])',cache=True)
def func(s,x):
    last=[0]*26
    score=0
    for i,v in enumerate(x,1):
        last[v]=i
        c=0
        for j in range(26):
            c+=s[j]*(i-last[j])
        score=score+s[i*26+v]-c
    return score
def main():
    d,*s=map(int,open(0).read().split())
    s=int64(s)
    x=s[26*-~d:d*27+26]-1
    for d,q in s[27*-~d:].reshape(-1,2):
        x[d-1]=q-1
        print(func(s,x))
main()

Buggy python submission (verdict: Time Limit Exceeded):
def func(s,x):
    last=[0]*26
    score=0
    for i,v in enumerate(x,1):
        last[v]=i
        c=0
        for j in range(26):
            c+=s[j]*(i-last[j])
        score=score+s[i*26+v]-c
    return score
def main():
    d,*s=map(int,open(0).read().split())
    x=[t-1for t in s[26*-~d:d*27+26]]
    for d,q in zip(*[iter(s[27*-~d:])]*2):
        x[d-1]=q-1
        print(func(s,x))
main()

Fixed submission:
from numba import njit
from numpy import int64
@njit('i8(i8[:],i8[:])',cache=True)
def func(s,x):
    last=[0]*26
    score=0
    for i,v in enumerate(x,1):
        last[v]=i
        c=0
        for j in range(26):
            c+=s[j]*(i-last[j])
        score=score+s[i*26+v]-c
    return score
def main():
    d,*s=map(int,open(0).read().split())
    s=int64(s)
    x=s[26*-~d:d*27+26]-1
    for d,q in s[27*-~d:].reshape(-1,2):
        x[d-1]=q-1
        print(func(s,x))
main()
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())+1
print(sum(sum(range(i,n,i))for i in range(1,n)))

Fixed submission:
n=int(input())+1
print(sum(sum(range(i,n,i))for i in range(1,n)))
Buggy python submission (verdict: Runtime Error):
for i in a:=[*map(int,[*open(x:=0)][1].split())]:x^=i
for i in a:print(x^i)

Fixed submission:
n,*a=map(int,open(0).read().split())
x=0
for i in a:x^=i
for i in a:print(x^i)
Buggy python submission (verdict: Time Limit Exceeded):
c=[0]*8**7
for a in[*open(i:=0)][1].split():c[int(a)]+=1
while i<1e6:
 i+=1;j=i
 while j<1e6:j+=i;c[j]*=c[i]<1
print(c.count(1))

Fixed submission:
m=8**7
c=[0]*m
for a in[*open(0)][1].split():c[int(a)]+=1
i=r=0
while~i+m:
 i+=1;r+=c[i]==1
 if c[i]:c[::i]=[0]*-(-m//i)
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    div=set()
    i = 1
    ap=div.add
    while i*i <= n:
        if n % i == 0:
            ap(i)
            ap(n//i)
        i += 1
    return div-{n}
def main():
    from collections import Counter
    n,*a=map(int,open(0).read().split())
    d=Counter(a)
    s=set(a)
    c=0
    for t in s:
        if d[t]<2:
            for t in make_divisors(t):
                if t in s:break
            else:c+=1
    print(c)
main()


Fixed submission:
m=8**7
c=[0]*m
for a in[*open(0)][1].split():c[int(a)]+=1
i=r=0
while~i+m:
 i+=1;r+=c[i]==1
 if c[i]:c[::i]=[0]*-(-m//i)
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    div=[]
    i = 1
    ap=div.append
    while i*i <= n:
        if n % i == 0:
            ap(i)
            ap(n//i)
        i += 1
    return set(div)-{n}
def main():
    from collections import Counter
    n,*a=map(int,open(0).read().split())
    d=Counter(a)
    s=set(a)
    c=0
    for t in s:
        if d[t]<2:
            for t in make_divisors(t):
                if t in s:break
            else:c+=1
    print(c)
main()

Fixed submission:
m=8**7
c=[0]*m
for a in[*open(0)][1].split():c[int(a)]+=1
i=r=0
while~i+m:
 i+=1;r+=c[i]==1
 if c[i]:c[::i]=[0]*-(-m//i)
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return set(lower_divisors + upper_divisors)-{n}
def main():
    from collections import Counter
    n,*a=map(int,open(0).read().split())
    d=Counter(a)
    s=set(a)
    c=0
    for t in s:
        if d[t]<2:
            for t in make_divisors(t):
                if t in s:break
            else:c+=1
    print(c)
main()

Fixed submission:
m=8**7
c=[0]*m
for a in[*open(0)][1].split():c[int(a)]+=1
i=r=0
while~i+m:
 i+=1;r+=c[i]==1
 if c[i]:c[::i]=[0]*-(-m//i)
print(r)
Buggy python submission (verdict: Runtime Error):
print(eval(input().translate({46:'',32:42}))//100)

Fixed submission:
a,b=input().split();print(int(a)*int(b[0]+b[-2:])//100)
Buggy python submission (verdict: Runtime Error):
n,k,*a=map(int,open(0).read().split())
d=[2*k]*n
s=0
while k:s=a[s]-1;d[s]=k=~-k%(d[s]-k)
print(s+1)

Fixed submission:
n,k,*a=map(int,open(0).read().split())
d=[0]+[-1]*n
s=0
for i in range(k):
  s=a[s]-1
  if(j:=d[s])>-1:
    exec((k-j)%(i+1-j)*'s=a[s]-1;')
    exit(print(s+1))
  d[s]=i+1
print(s+1)

Buggy python submission (verdict: Runtime Error):
n,k,*a=map(int,open(0).read().split())
d=[2*k]*n
s=0
while k:k-=1;k%=d[s:=a[s]-1]-k;d[s]=k
print(s)

Fixed submission:
n,k,*a=map(int,open(0).read().split())
d=[0]+[-1]*n
s=0
for i in range(k):
  s=a[s]-1
  if(j:=d[s])>-1:
    exec((k-j)%(i+1-j)*'s=a[s]-1;')
    exit(print(s+1))
  d[s]=i+1
print(s+1)
Buggy python submission (verdict: Time Limit Exceeded):
R=range
M=998244353
n,m,k=map(int,input().split())
f=1
for i in R(n):f*=i+1
r=[pow(f,M-2,M)]
for i in R(n):r+=r[i]*(n-i)%M,
print(sum(f//n*m*r[i-n]*r[~i]*pow(m-1,~i+n,M)for i in R(k+1))%M)

Fixed submission:
M=998244353
class Factorial:
    def __init__(self,n):
        self.f=f=[0]*(n+1)
        f[0]=b=1
        for i in range(1,n+1):f[i]=b=b*i%M
        self.inv=inv=[0]*(n+1)
        inv[n]=b=pow(self.f[n],-1,M)
        for i in range(n,0,-1):inv[i-1]=b=b*i%M
    def factorial(self,i):
        return self.f[i]
    def ifactorial(self,i):
        return self.inv[i]
    def comb(self,n,k):
        if n>=k:return self.f[n]*self.inv[n-k]*self.inv[k]%M
        else:return 0
comb=Factorial(10**5*5).comb
n,m,k=map(int,input().split())
print(sum(m*comb(n-1,i)*pow(m-1,~i+n,M)for i in range(k+1))%M)

Buggy python submission (verdict: Time Limit Exceeded):
R=range
M=998244353
n,m,k=map(int,input().split())
f=1
for i in R(n):f*=i+1
r=[pow(f,-1,M)]
for i in R(n):r+=r[i]*(n-i)%M,
print(sum(f//n*m*r[i-n]*r[~i]*pow(m-1,~i+n,M)for i in R(k+1))%M)

Fixed submission:
M=998244353
class Factorial:
    def __init__(self,n):
        self.f=f=[0]*(n+1)
        f[0]=b=1
        for i in range(1,n+1):f[i]=b=b*i%M
        self.inv=inv=[0]*(n+1)
        inv[n]=b=pow(self.f[n],-1,M)
        for i in range(n,0,-1):inv[i-1]=b=b*i%M
    def factorial(self,i):
        return self.f[i]
    def ifactorial(self,i):
        return self.inv[i]
    def comb(self,n,k):
        if n>=k:return self.f[n]*self.inv[n-k]*self.inv[k]%M
        else:return 0
comb=Factorial(10**5*5).comb
n,m,k=map(int,input().split())
print(sum(m*comb(n-1,i)*pow(m-1,~i+n,M)for i in range(k+1))%M)
Buggy python submission (verdict: Runtime Error):
print('A%sC'%'BR'[id('A')%3])

Fixed submission:
print(*{'ABC','ARC'}-{input()})

Buggy python submission (verdict: Runtime Error):
print('A%sC'%'BR'[id('A')%3])

Fixed submission:
print(*{'ABC','ARC'}-{input()})
Buggy python submission (verdict: Runtime Error):
(n,_),h,*t=[[*map(int,t.split())]for t in open(0)]
p=[1]*n
for a,b in t:p[-a]&=h[a]>h[b];p[-b]&=h[b]>h[a]
print(sum(p))

Fixed submission:
n,*t=map(int,open(0).read().split())
p=[1]*n
for a,b in zip(*[iter(t[n+1:])]*2):p[-a]&=t[a]>t[b];p[-b]&=t[b]>t[a]
print(sum(p))
Buggy python submission (verdict: Time Limit Exceeded):
i=j=x=int(input())
while(i:=i+1&95)**5-j**5-x:j=j%257-i
print(i,j)

Fixed submission:
x,r=int(input()),range(-99,120);[i**5-x-j**5or exit(print(i,j))for i in r for j in r]

Buggy python submission (verdict: Time Limit Exceeded):
i=j=x=int(input())
while(i:=-~i%99)**5-j**5-x:j=j%200-i
print(i,j)

Fixed submission:
x,r=int(input()),range(-99,120);[i**5-x-j**5or exit(print(i,j))for i in r for j in r]

Buggy python submission (verdict: Time Limit Exceeded):
i=j=x=int(input())
while(i:=-~i%99)**5-j**5-x:j=j%257-i
print(i,j)

Fixed submission:
x,r=int(input()),range(-99,120);[i**5-x-j**5or exit(print(i,j))for i in r for j in r]

Buggy python submission (verdict: Time Limit Exceeded):
i=j=x=int(input())
while(i:=-~i%221)**5-j**5-x:j=j%98-i
print(i,j)

Fixed submission:
x,r=int(input()),range(-99,120);[i**5-x-j**5or exit(print(i,j))for i in r for j in r]

Buggy python submission (verdict: Runtime Error):
m=5**6
exec(f'i,j=m%128,m>>7;m-=i**5-j**5!={input()}or print(i,j);'*2*m)

Fixed submission:
x,r=int(input()),range(-99,120);[i**5-x-j**5or exit(print(i,j))for i in r for j in r]

Buggy python submission (verdict: Time Limit Exceeded):
x=int(input())
for i in range(-x*999,x):i,j=i%x,i//x;i**5-x-j**5or exit(print(i,j))

Fixed submission:
x,r=int(input()),range(-99,120);[i**5-x-j**5or exit(print(i,j))for i in r for j in r]

Buggy python submission (verdict: Time Limit Exceeded):
x=int(input());r=range(-99,x);[i**5-x-j**5or exit(print(i,j))for i in r for j in r]

Fixed submission:
x,r=int(input()),range(-99,120);[i**5-x-j**5or exit(print(i,j))for i in r for j in r]
Buggy python submission (verdict: Time Limit Exceeded):
e=enumerate
n,a=open(0)
d=[0]+[-2**64]*2000
for j,(a,i)in e(sorted((-int(a),i)for i,a in e(a.split()))):d=[max(t-a*(~i-j+k+int(n)),d[k-1]-a*abs(~i+k))for k,t in e(d)]
print(max(d))

Fixed submission:
e=enumerate
n,*a=map(int,open(0).read().split())
dp=[0]
for j,(a,i)in e(sorted((a,i)for i,a in e(a))[::-1]):dp=[dp[0]+a*abs(n-j-i-1)]+[max(dp[k]+a*abs(n-j+k-i-1),dp[k-1]+a*abs(i-k+1))for k in range(1,j+1)]+[dp[j]+a*abs(i-j)]
print(max(dp))

Buggy python submission (verdict: Time Limit Exceeded):
e=enumerate
n,a=open(0)
d=[0]+[-1e18]*2000
for j,(a,i)in e(sorted((-int(a),i)for i,a in e(a.split()))):d=[max(t-a*(~i-j+k+int(n)),d[k-1]-a*abs(~i+k))for k,t in e(d)]
print(max(d))

Fixed submission:
e=enumerate
n,*a=map(int,open(0).read().split())
dp=[0]
for j,(a,i)in e(sorted((a,i)for i,a in e(a))[::-1]):dp=[dp[0]+a*abs(n-j-i-1)]+[max(dp[k]+a*abs(n-j+k-i-1),dp[k-1]+a*abs(i-k+1))for k in range(1,j+1)]+[dp[j]+a*abs(i-j)]
print(max(dp))

Buggy python submission (verdict: Time Limit Exceeded):
e=enumerate
n,a=open(0)
d=[0]+[-1e18]*2001
for j,(a,i)in e(sorted((-int(a),i)for i,a in e(a.split()))):d=[max(t-a*abs(~i-j+k+int(n)),d[k-1]-a*abs(~i+k))for k,t in e(d)]
print(max(d))

Fixed submission:
e=enumerate
n,*a=map(int,open(0).read().split())
dp=[0]
for j,(a,i)in e(sorted((a,i)for i,a in e(a))[::-1]):dp=[dp[0]+a*abs(n-j-i-1)]+[max(dp[k]+a*abs(n-j+k-i-1),dp[k-1]+a*abs(i-k+1))for k in range(1,j+1)]+[dp[j]+a*abs(i-j)]
print(max(dp))

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n=int(input())
    d=[0]+[-10**18]*n
    for j,(a,i)in enumerate(sorted((-a,i)for i,a in enumerate(map(int,input().split())))):
        d=[max(t-a*abs(~i-j+k+n),d[k-1]-a*abs(~i+k))for k,t in enumerate(d)]
    print(max(d))
main()

Fixed submission:
e=enumerate
n,*a=map(int,open(0).read().split())
dp=[0]
for j,(a,i)in e(sorted((a,i)for i,a in e(a))[::-1]):dp=[dp[0]+a*abs(n-j-i-1)]+[max(dp[k]+a*abs(n-j+k-i-1),dp[k-1]+a*abs(i-k+1))for k in range(1,j+1)]+[dp[j]+a*abs(i-j)]
print(max(dp))

Buggy python submission (verdict: Time Limit Exceeded):
e=enumerate
n,a=open(0)
n=int(n)
d=[0]+[1e18]*n
for j,(a,i)in e(sorted((-int(a),i)for i,a in e(a.split()))):d=[min(t+a*abs(~i-j+k+n),d[k-1]+a*abs(~i+k))for k,t in e(d)]
print(-min(d))

Fixed submission:
e=enumerate
n,*a=map(int,open(0).read().split())
dp=[0]
for j,(a,i)in e(sorted((a,i)for i,a in e(a))[::-1]):dp=[dp[0]+a*abs(n-j-i-1)]+[max(dp[k]+a*abs(n-j+k-i-1),dp[k-1]+a*abs(i-k+1))for k in range(1,j+1)]+[dp[j]+a*abs(i-j)]
print(max(dp))
Buggy python submission (verdict: Runtime Error):
from numpy import*;print(sum(arange(int(input())+1)[i%3>0<i%5]))

Fixed submission:
print(sum(i%3>0<i%5and i for i in range(int(input())+1)))

Buggy python submission (verdict: Runtime Error):
*x,=range(int(input())+1);x[::3]=x[::5]=0;print(sum(x))

Fixed submission:
print(sum(i%3>0<i%5and i for i in range(int(input())+1)))
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
    if b<a:a,b=b,a
    r=b%a
    return a if r==0else gcd(a,r)
k=int(input())+1
print(sum(gcd(c,gcd(a,b))for a in range(1,k)for b in range(1,k)for c in range(1,k)))

Fixed submission:
from math import*
r=range(1,int(input())+1)
print(sum(gcd(gcd(a,b),c)for a in r for b in r for c in r))

Buggy python submission (verdict: Runtime Error):
cdef gcd(a,b):
    if b<a:a,b=b,a
    r=b%a
    return a if r==0else gcd(a,r)
k=int(input())+1
print(sum(gcd(c,gcd(a,b))for a in range(1,k)for b in range(1,k)for c in range(1,k)))

Fixed submission:
from math import*
r=range(1,int(input())+1)
print(sum(gcd(gcd(a,b),c)for a in r for b in r for c in r))
Buggy python submission (verdict: Time Limit Exceeded):
n,s=open(0)
n=int(n)
d={i:s.count(i)for i in'RGB'}
a=0
for i in range(n):
    d[s[i]]-=1
    b=d.copy()
    for j in range(i+1,n):
        b[s[j]]-=1
        if s[i]==s[j]:continue
        c,*_=set('RGB')-{s[i],s[j]}
        a+=b[c]
        k=j+j-i
        if k<n and s[k]==c:
            a-=1
print(a)

Fixed submission:
n=int(input())
s=[ord(c)%3for c in input()]
d=[0]*3
for i in s:d[i]+=1
a=0
for i in range(n):
    d[s[i]]-=1
    b=d.copy()
    for j in range(i+1,n):
        b[s[j]]-=1
        if s[i]==s[j]:continue
        c=(0,2,1,0)[s[i]+s[j]]
        a+=b[c]
        k=j+j-i
        if k<n and s[k]==c:
            a-=1
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n,*a=map(int,open(0).read().split())
dp=[[0]+[-10**18]*n for _ in range(n+1)]
for i,a in enumerate(a):
    for j in range(n//2-(n-i)//2,i//2+2):
        dp[i+1][j]=max(dp[i-1][j],dp[i-1][j-1]+a,dp[i][j])
print(dp[n][n//2])

Fixed submission:
from collections import*
n,*a=map(int,open(0).read().split())
dp=[defaultdict(lambda:-10**18)for _ in range(n)]
for i in range(n):dp[i][0]=0
for i,a in enumerate(a):
    for j in range(n//2-(n-i)//2,i//2+2):
        dp[i][j]=max(dp[i-2][j],dp[i-2][j-1]+a,dp[i-1][j])
print(dp[-1][n//2])
Buggy python submission (verdict: Runtime Error):
n,x,y=map(int,input().split())
c=[0]*~-n
for i in range(n):
 for j in range(i):c[min(~j+i,abs(~j+x)+abs(~i+y))]+=1
print(*l)

Fixed submission:
from collections import*
n,x,y=map(int,input().split())
e=[[]for _ in range(n)]
for i in range(n-1):
    e[i]+=i+1,
    e[i+1]+=i,
e[x-1]+=y-1,
e[y-1]+=x-1,
a=[0]*n
for s in range(n):
    d=[-1]*n
    d[s]=0
    q=deque([s])
    while q:
        v=q.popleft()
        for w in e[v]:
            if d[w]<0:
                d[w]=d[v]+1
                q+=w,
    for i in d:a[i]+=1
print(*[i//2for i in a[1:]])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import*
n,x,y=map(int,input().split())
e=[[]for _ in range(n)]
for i in range(n-1):
    e[i]+=i+1,
    e[i+1]+=i,
e[x-1]+=y-1,
e[y-1]+=x-1,
a=[0]*n
for s in range(n):
    d=[-1]*n
    d[s]=0
    q=deque([s])
    while q:
        v=q.popleft()
        for w in e[v]:
            if d[w]<0:
                d[w]=d[v]+1
                q+=w,
    for i in d:a[i]+=1
print(*[i//2for i in a[1:]])

Fixed submission:
from collections import*
n,x,y=map(int,input().split())
e=[[]for _ in range(n)]
for i in range(n-1):
    e[i]+=i+1,
    e[i+1]+=i,
e[x-1]+=y-1,
e[y-1]+=x-1,
a=[0]*n
for s in range(n):
    d=[-1]*n
    d[s]=0
    q=deque([s])
    while q:
        v=q.popleft()
        for w in e[v]:
            if d[w]<0:
                d[w]=d[v]+1
                q+=w,
    for i in d:a[i]+=1
print(*[i//2for i in a[1:]])
Buggy python submission (verdict: Runtime Error):
(x,y,a,b,c),*t=[map(int,t.split())for t in open(0)]
p,q,r=[[0]+sorted(t)[::-1]for t in t]
for i in range(a):p[i+1]+=p[i]
for i in range(b):q[i+1]+=q[i]
for i in range(c):r[i+1]+=r[i]
m=0
for i in range(x+1):
    # i:赤の個数
    # j:赤に変える無の個数
    # k:無の残り
    j=x-i
    k=c-j
    if i>a or j>c:continue
    # 赤の美味しさ総和
    t=p[i]+r[j]
    # 上手いこと緑の美味しさ総和を求める
    # sum(list(map(max,zip(r[j+1:],q)))[:y])
    # ↑みたいなことをしたい
    ok=0
    ng=k+1
    while ng-ok>1:
        mid=(ok+ng)//2
        if r[j+mid]-r[j]>=q[min(b,y)]-q[min(b,y-mid)]:
            ok=mid
        else:
            ng=mid
    t+=q[min(b,y-ok)]+r[j+ok]-r[j]
    if t>m:m=t
print(m)

Fixed submission:
(x,y,a,b,c),*t=[map(int,t.split())for t in open(0)]
s=sorted
p,q,r=map(s,t)
print(sum(s(p[-x:]+q[-y:]+r)[-x-y:]))
Buggy python submission (verdict: Runtime Error):
def main():
  h,*s=open(0)
  h,w,k=map(int,h.split())
  s=[list(map(int,t[:w]))for t in s]
  m=9e9
  for i in range(1<<h-1):
    t,v,l=[],0,1
    for j in range(h):
      if i>>j&1:
        t+=j+1,
        l+=1
    t+=h,
    c=[0]*l
    for i in range(w):
      b=f=g=0
      u=[]
      for j,x in enumerate(t):
        d,b=sum(s[j][i]for j in range(b,x)),x
        u+=d,
        if d>k:
          g=1
          break
        c[j]+=d
        f|=c[j]>k
      else:
        if f:
          c=u
          v+=1
      if g:break
    else:
      if v+l-1<m:m=v+l-1
  print(m)
main()

Fixed submission:
s=input();n=len(s)//2;print('YNeos'[s!=s[::-1]or s[:n]!=s[n-1::-1]::2])
Buggy python submission (verdict: Time Limit Exceeded):
_,s,*a=map(int,open(0).read().split())
c,i,*d=[0]*6003
for a in a:
 for j in range(s,0,-1):d[a+j]+=d[j]
 d[a]-=~i;c+=d[s];i+=1
print(c%(998244353))

Fixed submission:
n,s,*a=map(int,open(0).read().split())
d=[0]*3001
c=0
for i,a in enumerate(a):
    for j in range(s-a,0,-1):d[a+j]+=d[j]
    d[a]-=~i
    c+=d[s]
print(c%(998244353))

Buggy python submission (verdict: Runtime Error):
_,s,*a=map(int,open(0).read().split())
c,i,*d=[0]*s*9
for a in a:
 for j in range(s,0,-1):d[a+j]+=d[j]
 d[a]-=~i;c+=d[s];i+=1
print(c%(998244353))

Fixed submission:
n,s,*a=map(int,open(0).read().split())
d=[0]*3001
c=0
for i,a in enumerate(a):
    for j in range(s-a,0,-1):d[a+j]+=d[j]
    d[a]-=~i
    c+=d[s]
print(c%(998244353))

Buggy python submission (verdict: Runtime Error):
_,s,*a=map(int,open(0).read().split())
c,i,*d=[0]*s*5
for a in a:
 for j in range(s,0,-1):d[a+j]+=d[j]
 d[a]-=~i;c+=d[s];i+=1
print(c%(998244353))

Fixed submission:
n,s,*a=map(int,open(0).read().split())
d=[0]*3001
c=0
for i,a in enumerate(a):
    for j in range(s-a,0,-1):d[a+j]+=d[j]
    d[a]-=~i
    c+=d[s]
print(c%(998244353))

Buggy python submission (verdict: Runtime Error):
_,s,*a=map(int,open(0).read().split())
c,i,*d=[0]*s*4
for a in a:
 for j in range(s,0,-1):d[a+j]+=d[j]
 d[a]-=~i;c+=d[s];i+=1
print(c%(998244353))

Fixed submission:
n,s,*a=map(int,open(0).read().split())
d=[0]*3001
c=0
for i,a in enumerate(a):
    for j in range(s-a,0,-1):d[a+j]+=d[j]
    d[a]-=~i
    c+=d[s]
print(c%(998244353))

Buggy python submission (verdict: Runtime Error):
_,s,*a=map(int,open(0).read().split())
c,i,*d=[0]*s*3
for a in a:
 for j in range(s,0,-1):d[a+j]+=d[j]
 d[a]-=~i;c+=d[s];i+=1
print(c%(998244353))

Fixed submission:
n,s,*a=map(int,open(0).read().split())
d=[0]*3001
c=0
for i,a in enumerate(a):
    for j in range(s-a,0,-1):d[a+j]+=d[j]
    d[a]-=~i
    c+=d[s]
print(c%(998244353))
Buggy python submission (verdict: Runtime Error):
n,*t=map(int,open(0).read().split())
e=[[]for _ in range(n)]
x=[[],[],[]]
for i in range(n):x[i%3]+=i+1,
for a,b in zip(*[iter(t)]*2):
    e[a-1]+=b-1,
    e[b-1]+=a-1,
a=[-1]*n
p=a[:]
p[0]=0
s=[0]
c=[1,0]
while s:
    v=s.pop()
    for w in e[v]:
        if p[w]<0:
            p[w]=p[v]^1
            c[p[w]]+=1
            s+=w,
if min(c)<=len(x[2]):
    x[0]+=x[1]
    f=c[0]<=len(x[2])
    for i,v in enumerate(p):a[i]=x[(v==f)-1].pop()
else:
    for i,v in enumerate(p):a[i]=x[v if x[v]else-1].pop()
print(*a)

Fixed submission:
n,*t=map(int,open(0).read().split())
e=[[]for _ in range(n)]
x=[[],[],[]]
for i in range(n):
    x[i%3]+=i+1,
for a,b in zip(*[iter(t)]*2):
    e[a-1]+=b-1,
    e[b-1]+=a-1,
a=[-1]*n
p=a[:]
p[0]=0
s=[0]
c=[1,0]
while s:
    v=s.pop()
    for w in e[v]:
        if p[w]<0:
            p[w]=p[v]^1
            c[p[w]]+=1
            s+=w,
if min(c)<=n//3:
    x[0]+=x[1]
    f=c[0]<=n//3
    for i,v in enumerate(p):
        j=(v==f)-1
        a[i]=x[j if x[j]else-1].pop()
else:
    for i,v in enumerate(p):
        a[i]=x[v if x[v]else-1].pop()
print(*a)

Buggy python submission (verdict: Runtime Error):
n,*t=map(int,open(0).read().split())
e=[[]for _ in range(n)]
x=[[],[],[]]
for i in range(n):x[i%3]+=i+1,
for a,b in zip(*[iter(t)]*2):
    e[a-1]+=b-1,
    e[b-1]+=a-1,
a=[-1]*n
p=a[:]
p[0]=0
s=[0]
c=[1,0]
while s:
    v=s.pop()
    for w in e[v]:
        if p[w]<0:
            p[w]=p[v]^1
            c[p[w]]+=1
            s+=w,
if min(c)<=n//3:
    x[0]+=x[1]
    f=c[0]<=n//3
    for i,v in enumerate(p):a[i]=x[(v==f)-1].pop()
else:
    for i,v in enumerate(p):a[i]=x[v if x[v]else-1].pop()
print(*a)

Fixed submission:
n,*t=map(int,open(0).read().split())
e=[[]for _ in range(n)]
x=[[],[],[]]
for i in range(n):
    x[i%3]+=i+1,
for a,b in zip(*[iter(t)]*2):
    e[a-1]+=b-1,
    e[b-1]+=a-1,
a=[-1]*n
p=a[:]
p[0]=0
s=[0]
c=[1,0]
while s:
    v=s.pop()
    for w in e[v]:
        if p[w]<0:
            p[w]=p[v]^1
            c[p[w]]+=1
            s+=w,
if min(c)<=n//3:
    x[0]+=x[1]
    f=c[0]<=n//3
    for i,v in enumerate(p):
        j=(v==f)-1
        a[i]=x[j if x[j]else-1].pop()
else:
    for i,v in enumerate(p):
        a[i]=x[v if x[v]else-1].pop()
print(*a)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split());print([i for i in range(10**6)if a==i//12.5and b==i//10]+[-1][0])

Fixed submission:
a,b=map(int,input().split())
for i in range(10**6):
  if a==int(i*.08)and b==int(i*.1):
    print(i)
    break
else:print(-1)