#include using namespace std; using ll=int64_t; #define int ll #define FOR(i,a,b) for(int i=int(a);i CerrDummy& operator<<(CerrDummy&cd,const T&){ return cd; } using charTDummy=char; using traitsDummy=char_traits; CerrDummy& operator<<(CerrDummy&cd,basic_ostream&(basic_ostream&)){ return cd; } #define cerr cerrDummy #endif #define REACH cerr<<"reached"<; using vi=vector; using ld=long double; template ostream& operator<<(ostream& os,const pair& p){ os<<"("< ostream& operator <<(ostream& os,const vector& v){ os<<"{"; REP(i,(int)v.size()){ if(i)os<<","; os< void chmax(T& a,U b){ if(a void chmin(T& a,U b){ if(b T Sq(const T& t){ return t*t; } #define CAPITAL void Yes(bool ex=true){ #ifdef CAPITAL cout<<"YES"<=mod)a-=mod; } map memo1,memo2,memo3; /*int calc1(int a,int b){ return 0; } **/ int calc2(int a,int b){ if(a==0&&b==0)return 0; if(memo2.count(pi(a,b)))return memo2[pi(a,b)]; int res=0; cerr<0){ add(res,1); add(res,calc2((a-1)/2,b/2)); } cerr<0){ add(res,1); add(res,calc2(a/2,(b-1)/2)); } cerr<0&&b>0)add(res,calc2((a-1)/2,(b-1)/2)); cerr<0)add(res,calc3((a-1)/2,b/2)); if(b>0)add(res,calc3(a/2,(b-1)/2)); if(a>0&&b>0)add(res,calc2((a-1)/2,(b-1)/2)); cerr<