Go: ///
// File:  0528.go
// Author: ymiyamoto
//
// Created on Thu Mar 22 01:52:09 2018
//
package main

import (
	"bufio"
	"fmt"
	"os"
)

var S, T string
var dp [4001][4001]int

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for {
		scanner.Scan()
		S = scanner.Text()
		if len(S) == 0 {
			return
		}

		scanner.Scan()
		T = scanner.Text()

		for i := range dp {
			for j := range dp[i] {
				dp[i][j] = 0
			}
		}

		dp[0][0] = 0
		for i := range S {
			for j := range T {
				if S[i] == T[j] {
					dp[i+1][j+1] = max(dp[i+1][j], max(dp[i][j+1], dp[i][j]+1))
				} else {
					dp[i+1][j+1] = 0
				}
			}
		}
		var m int
		for i := range dp {
			for j := range dp[i] {
				m = max(m, dp[i][j])
			}
		}
		fmt.Println(m)
	}
}

C++: //JOI 0528 Common Sub-String
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	while(1){
		string s, t; int roop1=0, roop2 = 0, save[6400000]={}, ans = 0;
		cin>>s;
		cin>>t;
		if(cin.eof())
		break;
	for (int i = 0; i<s.size(); i++){
		for (int j = 0; j<t.size(); j++){
			if (s[i] == t[j]){
				roop1 = 0;
				save[roop2] = 0;
				while (1){
					if (s[i + roop1] == 0 || t[j + roop1] == 0){
						break;
					}
					else{
						if (s[i + roop1] == t[j + roop1]){
							save[roop2] += 1;
							roop1++;
						}
						else if (s[i + roop1] != t[j + roop1]){
							roop2++;
							break;
						}
					}
				}
			}
		}
	}
	sort(save, save + roop2 + 1);
	ans = save[roop2];
	cout << ans << endl;
	}
	return 0;
}

C++: //JOI 0528 Common Sub-String
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	string s, t;
	while(cin>>s>>t){
		int roop1=0, save=0, ans = 0;
	for (int i = 0; i<s.size(); i++){
		for (int j = 0; j<t.size(); j++){
			if (s[i] == t[j]){
				roop1 = 0;
				save= 0;
				while (1){
						if (s[i + roop1] == t[j + roop1]){
							save += 1;
							roop1++;
						}
					else if (s[i + roop1] != t[j + roop1]){
							ans=max(ans,save);
							break;
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	}
	return 0;
}

C++: //http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2676345#1
//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2676345#1
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<fstream>
#include<cstring>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define P pair<int,int>
#define ll __int64

int dp[2][5000];
int n,m;
string a,b;

int main(){
while(cin>>a>>b){
if(a.size()>b.size())swap(a,b);
n=a.size();
m=b.size();

int ans=0;
rep(i,2)rep(j,5000)dp[i][j]=0;

for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){

		if(i&1){//2,4,6,8...番目
			if(a[i]==b[j]){
				if(j-1>=0)
				dp[1][j]=dp[0][j-1]+1;
				else dp[1][j]=1;
				ans=max(ans,dp[1][j]);
			}
		}
		else{//1,3,5,7,9...番目
			if(a[i]==b[j]){
				if(j-1>=0)
				dp[0][j]=dp[1][j-1]+1;
				else dp[0][j]=1;
				ans=max(ans,dp[0][j]);
			}
		}
	}
}

cout<<ans<<endl;
}


	return 0;
}

C++: #include<iostream>
 
using namespace std;
 
int solve(const string& s1, const string& s2, int l1, int l2){
  int tmp = 0;
  int res = 0;
  int len = min(s2.length()-l2,s1.length()-l1);
  for(int i = 0; i < len; i++){
    if(s1[l1+i] != s2[l2+i]){
      res = max(res,tmp);
      tmp = 0;
    }else{
      tmp++;
    }
  }
  return max(tmp,res);
}
 
int main(){
   
  string s1,s2;
  int l1,l2,ans;
  while(1) {
  	if(cin.eof()) {
  		break;
  	}
  	cin >> s1;
  	cin >> s2;
  	l1 = s1.length();
  	l2 = 0;
  	ans = 0;
  	while(l1 != 0 || l2 <= s2.length()) {

      if(l1 != 0){
      	l1--;
      } else {
      	l2++;
      }
      ans = max(ans,solve(s1,s2,l1,l2));
  	}
    cout << ans << endl;
  }
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void){
  string s, t;
  int ans, k;
  while(cin >> s >> t){
    ans = 0;
    for(int i = 0;i < s.size(); i++){
      for(int j = 0;j < t.size(); j++){
	if((i != 0 && j != 0 && s[i - 1] != t[j - 1] && s[i] == t[j]) || i == 0 || j == 0){
	  for(k = 0;i + k < s.size() && j + k < t.size() && s[i + k] == t[j + k]; k++) ;
	  ans = max(ans, k);
	}
      }
    }
    cout << ans << endl;
  }
}

C++: //JOI 0528 Common Sub-String
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	while(1){
		string s, t; int roop1=0, roop2 = 0, save[700000]={}, ans = 0;
		cin>>s;
		cin>>t;
		if(cin.eof())
		break;
	for (int i = 0; i<s.size(); i++){
		for (int j = 0; j<t.size(); j++){
			if (s[i] == t[j]){
				roop1 = 0;
				save[roop2] = 0;
				while (1){
					if (s[i + roop1] == 0 || t[j + roop1] == 0){
						break;
					}
					else{
						if (s[i + roop1] == t[j + roop1]){
							save[roop2] += 1;
							roop1++;
						}
						else if (s[i + roop1] != t[j + roop1]){
							roop2++;
							break;
						}
					}
				}
			}
		}
	}
	sort(save, save + roop2 + 1);
	ans = save[roop2];
	cout << ans << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i=0; i<n; i++)

int dp[2][4444];
string s, t;

int main(int argc, char *argv[])
{
  while(cin >> s >> t){
    int ls = s.length();
    int lt = t.length();
    rep(j, lt) dp[0][j] = dp[1][j] = 0;
    int res = 0;
    rep(i, ls) rep(j, lt){
      if(j == 0) dp[i & 1][0] = 0;
      if(s[i] == t[j]) dp[(i + 1) & 1][j + 1] = dp[i & 1][j] + 1;
      else dp[(i + 1) & 1][j + 1] = 0;
      res = max(res, dp[(i + 1) & 1][j + 1]);
    }
    cout << res << endl;
  }
  
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x);

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

char str1[4010];
char str2[4010];

int main(){
  while(~scanf("%s %s",str1,str2)){
    int len1 = strlen(str1);
    int len2 = strlen(str2);

    int len = min(len1, len2);

    while(len > 0){
      for(int i=0; i+len < len1; i++)
        for(int j=0; j+len < len2; j++)
          if(strncmp(str1+i, str2+j, len) == 0)
            goto end;
      len--;
    }
    end:

    print(len);
  }
  return 0;
}