Language: C++

#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
#define LL long long
using namespace std;
const int N=1e5+10;
int n,k,a[N],b[N];
LL ans;
template<typename I> inline I read(){
	char ch=getchar(); I x=0, f=1;
	while(ch<'0' || ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
	return x*f;}
template<typename I>inline I mx(const I a,const I b){return a>b ? a : b;}
int main()
{
	//freopen("IntegerotS.in","r",stdin);
	n=read(); k=read();
	for(RG int i=1;i<=n;i++)
	{
		a[i]=read(); b[i]=read();
		if((a[i]&k)==a[i]) ans+=b[i];
	}
	for(RG int i=0;i<=30;i++)
	{
		if(((1<<i)&k)==0) continue;
		int tt=(k^(1<<i))|((1<<i)-1); LL re=0;
		for(RG int i=1;i<=n;i++) if((a[i]&tt)==a[i]) re+=b[i];
		ans=mx(ans,re);
	}
	printf("%lld\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:15: error: no matching function for call to 'read()'
   19 |         n=read(); k=read();
      |           ~~~~^~
a.cc:10:31: note: candidate: 'template<class I> I read()'
   10 | template<typename I> inline I read(){
      |                               ^~~~
a.cc:10:31: note:   template argument deduction/substitution failed:
a.cc:19:15: note:   couldn't deduce template parameter 'I'
   19 |         n=read(); k=read();
      |           ~~~~^~
a.cc:19:25: error: no matching function for call to 'read()'
   19 |         n=read(); k=read();
      |                     ~~~~^~
a.cc:10:31: note: candidate: 'template<class I> I read()'
   10 | template<typename I> inline I read(){
      |                               ^~~~
a.cc:10:31: note:   template argument deduction/substitution failed:
a.cc:19:25: note:   couldn't deduce template parameter 'I'
   19 |         n=read(); k=read();
      |                     ~~~~^~
a.cc:20:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   20 |         for(RG int i=1;i<=n;i++)
      |                    ^
a.cc:22:26: error: no matching function for call to 'read()'
   22 |                 a[i]=read(); b[i]=read();
      |                      ~~~~^~
a.cc:10:31: note: candidate: 'template<class I> I read()'
   10 | template<typename I> inline I read(){
      |                               ^~~~
a.cc:10:31: note:   template argument deduction/substitution failed:
a.cc:22:26: note:   couldn't deduce template parameter 'I'
   22 |                 a[i]=read(); b[i]=read();
      |                      ~~~~^~
a.cc:22:39: error: no matching function for call to 'read()'
   22 |                 a[i]=read(); b[i]=read();
      |                                   ~~~~^~
a.cc:10:31: note: candidate: 'template<class I> I read()'
   10 | template<typename I> inline I read(){
      |                               ^~~~
a.cc:10:31: note:   template argument deduction/substitution failed:
a.cc:22:39: note:   couldn't deduce template parameter 'I'
   22 |                 a[i]=read(); b[i]=read();
      |                                   ~~~~^~
a.cc:25:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   25 |         for(RG int i=0;i<=30;i++)
      |                    ^
a.cc:29:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   29 |                 for(RG int i=1;i<=n;i++) if((a[i]&tt)==a[i]) re+=b[i];
      |                            ^