Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;


namespace io{
    const int L = (1 << 20) + 1;
    
    char buf[L], *S , *T, c;
     
    char getchar() {
        if(S == T) {
            T = (S = buf) + fread(buf, 1, L, stdin);
            return (S == T ? EOF : *S++);
        }
        return *S++;
    }
    
    int inp() {
        int x = 0, f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }
    
    ll inp_ll() {
        ll x = 0; int f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }
    
    char B[25], *outs=B+20, *outr=B+20;
    template<class T>
    inline void print(register T a,register char x=0){
        if(x) *--outs = x, x = 0;
        
        if(!a)*--outs = '0';
        else 
            while(a)
                *--outs = (a % 10) + 48, a /= 10;
        
        if(x)
            *--outs = x;
        
        fwrite(outs, outr - outs , 1, stdout);
        outs = outr;
    }
};

using io :: print;
using io :: inp;
using io :: inp_ll;
const int maxN = 1e5 + 5;
const int MOD = 1e9 + 7;
vector<pii> node;
int tree[maxN];
int n,m;
int a[maxN];
int b[maxN];
int lowbit(int x)
{
	return x&-x;
}
void add(int x,int p)
{
	int i = x;
	for(;i<=n;i+=lowbit(i))
	{
		(tree[i] += p) %= MOD;
	}
}
ll sum(int x)
{
	int i = x;
	ll s = 0;
	for(;i;i-=lowbit(i))
	{
		(s += tree[i])%=MOD;
	}
	return s;
}

int main()
{
	n = inp();
	m = inp();
	if(m == 1)
	{
		puts("1");
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		a[i] = inp();
	}
	for(int i=1;i<=m;i++)
	{
		b[i] = inp();
	}
	for(int i=1;i<=n;i++)
	{
		int pos = lower_bound(b+1,b+1+m,a[i]) - (b+1);
		if(pos >=1 && p< m)
			node.emplace_back(pii(a[i] - b[pos],a[i] - b[pos+1]));
	}
	sort(node.begin(),node.end());
	node.erase(unique(node.begin(),node.end()),node.end());
	vector<int> val;
	for(auto y: node)
	{
		val.emplace_back(-y.second);
	}
	sort(val.begin(),val.end());
	val.erase(unique(val.begin(),val.end()),val.end());
	ll ans = 1;
	for(int i=0;i<node.size();i++)
	{
		int p = lower_bound(val.begin(),val.end(),-node[i].second) - val.begin() + 1;
		int tmp = 1;
		(tmp += sum(p-1))%=MOD;
		add(p,tmp);
		
		(ans += tmp)%= MOD;
	}
	printf("%lld",ans);
    return 0;
}

Compiler output:
a.cc:50:34: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   50 |     inline void print(register T a,register char x=0){
      |                                  ^
a.cc:50:52: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   50 |     inline void print(register T a,register char x=0){
      |                                                    ^
a.cc: In function 'int main()':
a.cc:119:31: error: 'p' was not declared in this scope
  119 |                 if(pos >=1 && p< m)
      |                               ^