ll@n,@w,@x[n],@y[n]; maps,t; rep(i,n){ if(x[i]>=w){ t[x[i]]=y[i]; for(auto[k,v]:s){ ll g=gcd(k,x[i]); if(g>=w){ t[g]>?=v+y[i]; } } } s=t; } ll z=0; for(auto[k,v]:s){ z>?=v; } wt(z);