[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
a,b,l,r,ans,T=int
s=array of 200 char
vis=array of 27 bool
function dfs (get char cp, return int)
    count=0
    for i=0 to a exclusive s[i]='a'+i
    for i=a to a+b exclusive s[i]=cp
    fill vis with valse
    for i=b to a+b exclusive vis[s[i]-'a']=true
    sta=a+b, ed=0
    while sta < 2*a+b
        while vis[ed] increment ed
        s[sta]=ed+'a'
        increment sta and ed
    end of the block
    for i=2*a+b to T exclusive s[i]=s[i-1]
    fill vis with false
    if l<=r
        for i=l to r inclusive
            if not vis[s[i]-'a'] increment count, vis[s[i]-'a']=true
        end of the block
    else
        for i=0 to r inclusive
            if not vis[s[i]-'a'] increment count, vis[s[i]-'a']=true
        end of the block
        for i=l to T exclusive
            if not vis[s[i]-'a'] increment count, vis[s[i]-'a']=true
        end of the block
    end of the block
    return count
end of the block
define the main function
    read a,b,l,r
    decrement l and r
    if a <= b
        ans=a+1
    else
        ans=2*a-b
    T=2*(a+b)
    if r-l >= T
        do nothing
    else
        r = r modulo T, l = l modulo T
        for i=0 to a exclusive ans=min(dfs('a'+i), ans)
    end of the block
    print ans
    return to indicate successful execution
end of the block

[CODE]:

int a, b, l, r, ans, T;
char s[200];
bool vis[27];
int dfs(char cp) {
    int count = 0;
    for (int i = 0; i < a; i++) s[i] = ('a' + i);
    for (int i = a; i < a + b; i++) s[i] = cp;
    memset(vis, false, sizeof(vis));
    for (int i = b; i < a + b; i++) vis[s[i] - 'a'] = true;
    int sta = a + b, ed = 0;
    while (sta < 2 * a + b) {
        while (vis[ed]) ed++;
        s[sta] = ed + 'a';
        sta++, ed++;
    }
    for (int i = 2 * a + b; i < T; i++) s[i] = s[i - 1];
    memset(vis, false, sizeof(vis));
    if (l <= r) {
        for (int i = l; i <= r; i++) {
            if (!vis[s[i] - 'a']) { count++, vis[s[i] - 'a'] = true; }
        }
    } else {
        for (int i = 0; i <= r; i++) {
            if (!vis[s[i] - 'a']) { count++, vis[s[i] - 'a'] = true; }
        }
        for (int i = l; i < T; i++) {
            if (!vis[s[i] - 'a']) { count++, vis[s[i] - 'a'] = true; }
        }
    }
    return count;
}
int main() {
    cin >> a >> b >> l >> r;
    l--, r--;
    if (a <= b)
        ans = a + 1;
    else
        ans = 2 * a - b;
    T = 2 * (a + b);
    if (r - l >= T)
        ;
    else {
        r %= T, l %= T;
        for (int i = 0; i < a; i++) { ans = min(dfs('a' + i), ans); }
    }
    cout << ans << endl;
    return 0;
}