#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    vector<long long int> v;
    long long int input;
    while(cin>>input){
        v.push_back(input);
    }
    sort(v.begin(),v.end());
    int curr_len=1,max=0;
    for(int i=1;i<v.size();i++){
        if((v[i]-v[i-1])==1){
            curr_len++;
        }
        else{
            if(curr_len>max){
                max=curr_len;
                curr_len=1;
            }
        }
    }
    if(curr_len>max){
                max=curr_len;
                curr_len=0;
            }
    cout<<max<<"\n";
    return 0;        
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: