#include using namespace std; #define rep(i, x, limit) for (long long i = (long long)x; i < (long long)limit; i++) #define REP(i, x, limit) for (long long i = (long long)x; i <= (long long)limit; i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define el endl #define spa " " #define Yes cout << "Yes" << el #define No cout << "No" << el #define YES cout << "YES" << el #define NO cout << "NO" << el #define inp(x) for(auto &i:x)cin>>i #define eps (1e-10) #define Equals(a,b) (fabs((a) - (b)) < eps ) #define debug(x) cerr << #x << " = " << x << el using ll = long long; using ull = unsigned long long; using pii = pair; using pll = pair; using vi = vector; using vl = vector; using vvl = vector>; using vs = vector; using vb = vector; const double pi = 3.141592653589793238; const int inf = 1073741823; const ll infl = 1LL << 60; const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const string abc = "abcdefghijklmnopqrstuvwxyz"; const ll MOD = 998244353; #include using namespace atcoder; using mint = modint998244353; using vm = vector; // 約数列挙(O(√n))。n>=1 を想定。昇順で返す。 // 例: divisors(12) -> {1,2,3,4,6,12} vector divisors(ll n){ assert(n >= 1); vector small, large; for(ll i = 1; i*i <= n; ++i){ if(n % i == 0){ small.push_back(i); if(i * i != n) large.push_back(n / i); } } reverse(all(large)); small.insert(small.end(), all(large)); return small; } // --- 素因数分解→約数生成(必要なら) --- // // trial division の素因数分解(O(√n)) vector> factorize(ll n){ assert(n >= 1); vector> res; for(ll p = 2; p*p <= n; ++p){ if(n % p == 0){ int e = 0; while(n % p == 0){ n /= p; ++e; } res.emplace_back(p, e); } } if(n > 1) res.emplace_back(n, 1); return res; } // 素因数分解結果から全約数を生成(昇順) vector divisors_from_factors(const vector>& pf){ vector ds = {1}; for(auto [p, e] : pf){ vector add; add.reserve(ds.size() * e); ll pe = 1; for(int k = 1; k <= e; ++k){ pe *= p; // p^k for(ll x : ds) add.push_back(x * pe); } ds.insert(ds.end(), all(add)); } sort(all(ds)); return ds; } /* 使い方例: ll n; cin >> n; auto ds1 = divisors(n); // または: // auto pf = factorize(n); // auto ds2 = divisors_from_factors(pf); */ int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n,w;cin>>n>>w; vl X(n),Y(n);inp(X);inp(Y); unordered_map mp; rep(i,0,n){ ll &x=X[i],&y=Y[i]; if(x=w) mp[d]+=y; } } ll ans=0; for(auto &[k,v]:mp) ans=max(ans,v); cout<