stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int vis[1010][1010];

char ch[1010][1010];



int main() {

	memset(vis, -1, sizeof(vis));

	ios_base::sync_with_stdio(0);

	cin.tie(0); cout.tie(0);

	

	int x, y;

	cin >> x >> y;

	

	queue<pair<int, pair<int, int> > > q;

	for(int i = 1; i <= x; i++) {

		for(int j = 1; j <= y; j++) {

			cin >> ch[i][j];

			

			if(ch[i][j] == '#') {

				vis[i][j] = 0;

				q.push(make_pair(0, make_pair(i, j)));

			}

		}

	}

	

	int ans = 0;

	while(!q.empty()) {

		int val = q.front().first;

		int tarX = q.front().second.first;

		int tarY = q.front().second.second;

		q.pop();

		

		ans = max(ans, val);

		if(tarX < x && vis[tarX + 1][tarY] == -1) {

			vis[tarX + 1][tarY] = val + 1;

			q.push(make_pair(val + 1, make_pair(tarX + 1, tarY)));

		}

		

		if(tarX > 1 && vis[tarX - 1][tarY] == -1) {

			vis[tarX - 1][tarY] = val + 1;

			q.push(make_pair(val + 1, make_pair(tarX - 1, tarY)));

		}

		

		if(tarY < y && vis[tarX][tarY + 1] == -1) {

			vis[tarX][tarY + 1] = val + 1;

			q.push(make_pair(val + 1, make_pair(tarX, tarY + 1)));

		}

		

		if(tarY > 1 && vis[tarX][tarY - 1] == -1) {

			vis[tarX][tarY - 1] = val + 1;

			q.push(make_pair(val + 1, make_pair(tarX, tarY - 1)));

		}

	}

	

	cout << ans << "\n";

}

// Faster C++ solution for the same problem (measured speedup: 5.0801329823734935x):
#include <bits/stdc++.h>



using namespace std;



int dist[2000][2000];

bool vis[2000][2000];

int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(0);



    int H, W;

    cin >> H >> W;

    for(int i = 0; i < H; i++)

        for(int j = 0; j < W; j++)

            dist[i][j] = 10000, vis[i][j] = false;

    queue<pair<int,int> > Q;

    for(int i = 0; i < H; i++)

    {

        string s;

        cin >> s;

        for(int j = 0; j < W; j++)

        {

            if(s[j] == '#')

            {

                dist[i][j] = 0;

                vis[i][j] = true;

                Q.push({i, j});

            }

        }

    }

    auto inside = [&](int i, int j){

        if (i < 0 || i >= H || j < 0 || j >= W)

            return 0;

        return 1;

    };

    while(!Q.empty())

    {

        int i = Q.front().first;

        int j = Q.front().second;

        Q.pop();

        vector<pair<int,int> > ngbhs = {{i + 1, j}, {i - 1, j}, {i, j + 1}, {i, j - 1}};

        for(auto f : ngbhs)

        {

            if (inside(f.first, f.second))



                if(!vis[f.first][f.second])

                {

                    vis[f.first][f.second] = true;

                    dist[f.first][f.second] = min(dist[i][j] + 1, dist[f.first][f.second]);

                    Q.push(f);

                }

        }

    }

    int ans = 0;

    for(int i = 0; i < H; i++)

        for(int j = 0; j < W; j++)

            ans = max(ans, dist[i][j]);

    cout << ans << '\n';

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

int main(){int a;std::cin>>a;std::cout<<!a;}

// Faster C++ solution for the same problem (measured speedup: 5.383095948853061x):
#include<stdio.h>

main(){puts(getchar()-48?"0":"1");}
// Slower C++ solution:
#include <iostream>

int main(){int a;std::cin>>a;std::cout<<!a;}

// Faster C++ solution for the same problem (measured speedup: 5.383095948853061x):
#include<stdio.h>

main(){puts(getchar()-48?"0":"1");}
// Slower C++ solution:
#include<iostream>

int main(){int a;std::cin>>a;std::cout<<!a;}

// Faster C++ solution for the same problem (measured speedup: 5.383095948853061x):
#include<stdio.h>

main(){puts(getchar()-48?"0":"1");}
// Slower C++ solution:
#include<iostream>

main(){int a;std::cin>>a;std::cout<<!a;}

// Faster C++ solution for the same problem (measured speedup: 5.383095948853061x):
#include<stdio.h>

main(){puts(getchar()-48?"0":"1");}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



template<typename T, typename U>

using pv=vector<pair<T,U>>;

template<typename T>

using pque=priority_queue<T>;

template<typename T>

using lpque=priority_queue<T,vector<T>,greater<T>>;



using ll=long long;

using intpair=pair<int,int>;

using llpair=pair<ll,ll>;

using ilpair=pair<int,ll>;

using lipair=pair<ll,int>;

using intvec=vector<int>;

using llvec=vector<ll>;

using intq=queue<int>;

using llq=queue<ll>;

using intmat=vector<intvec>;

using llmat=vector<llvec>;



#define PI 3.141592653589793

#define INTINF ((1<<30)-1)

#define LLINF ((1LL<<62)-1)

#define MPRIME 1000000007

#define MPRIME9 998244353

#define MMPRIME ((1ll<<61)-1)



#define len length()

#define pushb push_back

#define fi first

#define se second



#define all(name) name.begin(),name.end()

#define rall(name) name.rbegin(),name.rend()

#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())



template<class T>

inline bool chmin(T& a, T b) {

	if (a > b) {

		a = b;

		return true;

	}

	return false;

}



template<class T>

inline bool chmax(T& a, T b) {

	if (a < b) {

		a = b;

		return true;

	}

	return false;

}



template<class T>

inline void init(T& v) {

	for(auto &a: v) cin>>a;

}

template<class T, class U>

inline void init(vector<pair<T,U>>& v) {

	for(auto &a: v) cin>>a.first>>a.second;

}

template<class T, class N>

inline void init(T& v, N n) {

	v.resize(n);

	for(auto &a: v) cin>>a;

}

template<class T, class U, class N>

inline void init(vector<pair<T,U>>& v, N n) {

	v.resize(n);

	for(auto &a: v) cin>>a.first>>a.second;

}



template<class T>

inline void out(T a) {

	cout<<a<<endl;

}

template<class T, class... U>

inline void out(T a, U... alist) {

	cout<<a<<" ";

	out(forward<U>(alist)...);

}



template<class N>

void resiz(N n) {

	//empty

}

template<class N, class T, class... U>

void resiz(N n, T&& hd, U&&... tl) {

	hd.resize(n);

	resiz(n,forward<U>(tl)...);

}



ll binpow(ll a, ll ex, ll p) {

	ll result=1;

	while(ex>0) {

		if(ex&1) result=result*a%p;

		ex>>=1;

		a=a*a%p;

	}

	return result;

}





ll A,B,C;



void input() {

	cin>>A;

}



void solve() {

	cout<<abs(A-1)<<endl;

}



int main() {

	cin.tie(nullptr);

	ios_base::sync_with_stdio(false);

	cout<<fixed<<setprecision(15);

	int t=1;

	while(t) {

		input();

		solve();

		t--;

	}

}


// Faster C++ solution for the same problem (measured speedup: 5.3841091662533165x):
#include<stdio.h>

main(){printf("%d\n",49-getchar());}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



#define ll long long

#define endl "\n"



vector<ll> adj[100005];

ll vis[100005];

ll n, m;



void add(ll x, ll y) {

  adj[x].push_back(y);

  adj[y].push_back(x);

}



void solve() {

  ll x;

  cin >> x;

  cout << 1 - x << endl;

}



int main() {

  ll t;

  // cin >> t;

  t = 1;

  while (t--)

    solve();

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.495122348664992x):
#include <bits/stdc++.h>

using namespace std;



#define ll long long



void solve() {

  ll x;

  cin >> x;

  cout << 1 - x << endl;

}



int main() {

  ios::sync_with_stdio(0);

  cin.tie(0);

  solve();

  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



#define ll long long

#define endl "\n"



vector<ll> adj[100005];

ll vis[100005];

ll n, m;



void add(ll x, ll y) {

  adj[x].push_back(y);

  adj[y].push_back(x);

}



void solve() {

  ll x;

  cin >> x;

  cout << 1 - x << endl;

}



int main() {

  ll t;

  // cin >> t;

  t = 1;

  while (t--)

    solve();

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.4948864263521737x):
#include <bits/stdc++.h>

using namespace std;



#define mod 1000000007

#define ll long long



ll bow(ll x, ll y) {

  ll res = 1;

  for (ll i = 1; i <= y; ++i) {

    res = res * x % mod;

  }

  return res;

}



void solve() {

  ll x;

  cin >> x;

  cout << 1 - x << endl;

}



int main() {

  ios::sync_with_stdio(0);

  cin.tie(0);

  solve();

  return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<math.h>

using namespace std;

typedef long long ll;

const int inf=1e15;

int n;

int main()

{

    cin>>n;

    cout<<!n<<endl;

    return 0;

}

////刷题！！！！！！！！！！！！！！！！


// Faster C++ solution for the same problem (measured speedup: 5.319720299308943x):
#include<stdio.h>



int main()

{

	int n;

	scanf("%d", &n);

	if(n == 1) printf("0\n");

	else printf("1\n");

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<string>



using namespace std;



int main(){

	int n;

	scanf("%d",&n);

	if(n==1) printf("0");

	if(n==0) printf("1");

	return 0;

} 

// Faster C++ solution for the same problem (measured speedup: 5.246506721339321x):
#include<stdio.h>



int main()

{

	int n;

	scanf("%d", &n);

	if(n == 1) printf("0\n");

	else printf("1\n");

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

using namespace std;

int main()

{

	ios;

	int n;

	cin>>n;

	cout<<(n^1)<<'\n';

}

// Faster C++ solution for the same problem (measured speedup: 5.392842987963871x):
#include<stdio.h>



int main()

{

	int n;

	scanf("%d", &n);

	if(n == 1) printf("0\n");

	else printf("1\n");

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int main()

{

	int x;

	scanf("%d",&x);

	if(x==0)

		cout<<'1';

	if(x==1)

		cout<<'0';

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.2499873350954935x):
#include<stdio.h>



int main()

{

	int n;

	scanf("%d", &n);

	if(n == 1) printf("0\n");

	else printf("1\n");

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int main()

{

    int x;

    cin >> x;

    if(x)

    {

        cout << "0" << endl;

    }

    else cout << "1" << endl;

}


// Faster C++ solution for the same problem (measured speedup: 5.3117428994585385x):
#include<stdio.h>



int main()

{

	int n;

	scanf("%d", &n);

	if(n == 1) printf("0\n");

	else printf("1\n");

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



#define ll unsigned long long

int n;

int main()

{

    scanf("%d",&n);

    cout << !n;

    return 0;

}






// Faster C++ solution for the same problem (measured speedup: 5.26958962729421x):
#include<stdio.h>



int main()

{

	int n;

	scanf("%d", &n);

	if(n == 1) printf("0\n");

	else printf("1\n");

}
// Slower C++ solution:
/*

* @Author: Nazrul Islam

* @Date:   2020-09-19 13:30:27

* @Last Modified by:   Nazrul Islam

* @Last Modified time: 2020-09-19 13:30:58

*/



#include<bits/stdc++.h>

using namespace std;

#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

typedef long long ll; 

typedef double dd;

typedef vector<int> vi;

typedef vector<char> vc;

typedef list<int> li;

typedef set<int> si;

typedef map<int,int> mp;

#define pb push_back

#define pf push_front

#define mk make_pair

#define sc scanf

#define pr printf

#define pi acos(-1.0)

#define endl '\n'

// char s[200009];

// char st[200009];

// int a[600][600];

// int b[29][10];

// int a[200009];

// int c[200009];

void solve()

{

	ll n, m, i, j, k, l; 

	cin >> n;

	if(n) cout << "0" << endl;

	else cout << "1" << endl;

}

int main()

{

	IO;

	int t; 

	t = 1;

	// cin >> t;

	while(t--)

		solve();

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.373954400383821x):
#include<stdio.h>



int main()

{

	int n;

	scanf("%d", &n);

	if(n == 1) printf("0\n");

	else printf("1\n");

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main()

{

    int n;

    cin>>n;

    n^=1;

    cout<<n;



}


// Faster C++ solution for the same problem (measured speedup: 5.310741627008133x):
#include<stdio.h>



int main()

{

	int n;

	scanf("%d", &n);

	if(n == 1) printf("0\n");

	else printf("1\n");

}
// Slower C++ solution:
#include <bits/stdc++.h>



#define rr(i, b)    for (int i = 0; i < int(b); i++)

#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]

#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl

#define bug(x) cout << #x << " " << x << endl

#define ll long long

#define vii vector <int>



using namespace std;



bool check(string s) {



    int l = 0;

    int r = s.size()/2;



    while(r != s.size()) {

        if(s[l] != s[r]) {

            return false;

        }

        l++;

        r++;

    }



    return true;

}



vector<long long> fac(20 + 1);



void fact() {

    fac[0] = 1;

    for(int i = 1; i <= 20; i++) {

        fac[i] = fac[i - 1] * i;

    }

}



void solve() {

    int x;

    cin >> x;



    cout << !x << endl;

}

 

int main(){

    cin.tie(0);

    ios_base::sync_with_stdio(false);

    //fact();

    int t = 1;

    //cin >> t;



    while(t--)

    solve();

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.393507522953277x):
#include<stdio.h>



int main()

{

	int n;

	scanf("%d", &n);

	if(n == 1) printf("0\n");

	else printf("1\n");

}
// Slower C++ solution:
#include<iostream>

using namespace std;



int main(){

	int a,b,s[5002],t[5002],ans=0;

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++)scanf("%d",&s[i]);

	for(int i=0;i<b;i++)scanf("%d",&t[i]);

	for(int i=0;i<b;i++){

		int k=0,ret=0;

		for(int j=i;j<b;j++){

			while(t[j]!=s[k]){k++; if(k>=a)break;}

			if(k>=a)break;

			ret++; k++;

		}

		if(ret>ans)ans=ret;

	}

	printf("%d\n",ans);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.157334834593945x):
#include<cstdio>

#include<algorithm>

using namespace std;



int main(){

	int a,b;

	int s[5002],t[5002];

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++){

		scanf("%d",&s[i]);

	}

	for(int i=0;i<b;i++){

		scanf("%d",&t[i]);

	}



	int ret=0;

	for(int i=0;i<b;i++){

		int p=0,q=i;

		int cnt=0;

		while(1){

			if(s[p]==t[q]){

				cnt++;

				p++;

				q++;

			}

			else {

				p++;

			}

			if(p==a)break;

		}

		ret=max(ret,cnt);

	}



	printf("%d\n",ret);

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

using namespace std;



int main(){

	int a,b;

	int s[5002],t[5002];

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++){

		scanf("%d",&s[i]);

	}

	for(int i=0;i<b;i++){

		scanf("%d",&t[i]);

	}



	int ret=0;

	for(int i=0;i<b-ret;i++){

		int p=0,q=i;

		int cnt=0;

		while(1){

			if(s[p]==t[q]){

				cnt++;

				p++;

				q++;

			}

			else {

				p++;

			}

			if(p==a)break;

		}

		ret=max(ret,cnt);

	}



	printf("%d\n",ret);

}

// Faster C++ solution for the same problem (measured speedup: 5.157896348844739x):
#include<cstdio>

#include<algorithm>

using namespace std;



int main(){

	int a,b;

	int s[5002],t[5002];

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++){

		scanf("%d",&s[i]);

	}

	for(int i=0;i<b;i++){

		scanf("%d",&t[i]);

	}



	int ret=0;

	for(int i=0;i<b;i++){

		int p=0,q=i;

		int cnt=0;

		while(1){

			if(s[p]==t[q]){

				cnt++;

				p++;

				q++;

			}

			else {

				p++;

			}

			if(p==a)break;

		}

		ret=max(ret,cnt);

	}



	printf("%d\n",ret);

}
// Slower C++ solution:
#include<iostream>

using namespace std;



int main(){

	int a,b,s[5002],t[5002],ans=0;

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++)scanf("%d",&s[i]);

	for(int i=0;i<b;i++)scanf("%d",&t[i]);

	for(int i=0;i<b;i++){

		int k=0,ret=0;

		for(int j=i;j<b;j++){

			while(t[j]!=s[k]){k++; if(k>=a)break;}

			if(k>=a)break;

			ret++; k++;

		}

		if(ret>ans)ans=ret;

	}

	printf("%d\n",ans);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.157440142817138x):
#include<cstdio>

#include<algorithm>

using namespace std;



const int INF=1000000000;



int main(){

	int a,b;

	int s[5002],t[5002];

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++){

		scanf("%d",&s[i]);

	}

	for(int i=0;i<b;i++){

		scanf("%d",&t[i]);

	}



	int memo[5002]; for(int i=0;i<b;i++)memo[i]=INF;



	int ret=0;

	for(int i=0;i<b-ret;i++){

		int p=0,q=i;

		int cnt=0;

		while(1){

			if(s[p]==t[q]){

				if(p>=memo[q])break;

				cnt++;

				p++;

				q++;

			}

			else {

				p++;

			}

			if(p==a){

				ret=max(ret,cnt);

				break;

			}

		}

	}



	printf("%d\n",ret);

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

using namespace std;



int main(){

	int a,b;

	int s[5002],t[5002];

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++){

		scanf("%d",&s[i]);

	}

	for(int i=0;i<b;i++){

		scanf("%d",&t[i]);

	}



	int ret=0;

	for(int i=0;i<b-ret;i++){

		int p=0,q=i;

		int cnt=0;

		while(1){

			if(s[p]==t[q]){

				cnt++;

				p++;

				q++;

			}

			else {

				p++;

			}

			if(p==a)break;

		}

		ret=max(ret,cnt);

	}



	printf("%d\n",ret);

}

// Faster C++ solution for the same problem (measured speedup: 5.158001668533557x):
#include<cstdio>

#include<algorithm>

using namespace std;



const int INF=1000000000;



int main(){

	int a,b;

	int s[5002],t[5002];

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++){

		scanf("%d",&s[i]);

	}

	for(int i=0;i<b;i++){

		scanf("%d",&t[i]);

	}



	int memo[5002]; for(int i=0;i<b;i++)memo[i]=INF;



	int ret=0;

	for(int i=0;i<b-ret;i++){

		int p=0,q=i;

		int cnt=0;

		while(1){

			if(s[p]==t[q]){

				if(p>=memo[q])break;

				cnt++;

				p++;

				q++;

			}

			else {

				p++;

			}

			if(p==a){

				ret=max(ret,cnt);

				break;

			}

		}

	}



	printf("%d\n",ret);

}
// Slower C++ solution:
#include<iostream>

using namespace std;



int main(){

	int a,b,s[5002],t[5002],ans=0;

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++)scanf("%d",&s[i]);

	for(int i=0;i<b;i++)scanf("%d",&t[i]);

	for(int i=0;i<b;i++){

		int k=0,ret=0;

		for(int j=i;j<b;j++){

			while(t[j]!=s[k]){k++; if(k>=a)break;}

			if(k>=a)break;

			ret++; k++;

		}

		if(ret>ans)ans=ret;

	}

	printf("%d\n",ans);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.155282183464811x):
#include<cstdio>

#include<algorithm>

using namespace std;



const int INF=1000000000;



int main(){

	int a,b;

	int s[5002],t[5002];

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++){

		scanf("%d",&s[i]);

	}

	for(int i=0;i<b;i++){

		scanf("%d",&t[i]);

	}



	int memo[5002]; for(int i=0;i<b;i++)memo[i]=INF;



	int ret=0;

	for(int i=0;i<b-ret;i++){

		int p=0,q=i;

		int cnt=0;

		while(1){

			if(s[p]==t[q]){

				if(p>=memo[q])break;

				memo[q]=p;

				cnt++;

				p++;

				q++;

			}

			else {

				p++;

			}

			if(p==a){

				ret=max(ret,cnt);

				break;

			}

		}

	}



	printf("%d\n",ret);

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

using namespace std;



int main(){

	int a,b;

	int s[5002],t[5002];

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++){

		scanf("%d",&s[i]);

	}

	for(int i=0;i<b;i++){

		scanf("%d",&t[i]);

	}



	int ret=0;

	for(int i=0;i<b-ret;i++){

		int p=0,q=i;

		int cnt=0;

		while(1){

			if(s[p]==t[q]){

				cnt++;

				p++;

				q++;

			}

			else {

				p++;

			}

			if(p==a)break;

		}

		ret=max(ret,cnt);

	}



	printf("%d\n",ret);

}

// Faster C++ solution for the same problem (measured speedup: 5.1558434742294645x):
#include<cstdio>

#include<algorithm>

using namespace std;



const int INF=1000000000;



int main(){

	int a,b;

	int s[5002],t[5002];

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++){

		scanf("%d",&s[i]);

	}

	for(int i=0;i<b;i++){

		scanf("%d",&t[i]);

	}



	int memo[5002]; for(int i=0;i<b;i++)memo[i]=INF;



	int ret=0;

	for(int i=0;i<b-ret;i++){

		int p=0,q=i;

		int cnt=0;

		while(1){

			if(s[p]==t[q]){

				if(p>=memo[q])break;

				memo[q]=p;

				cnt++;

				p++;

				q++;

			}

			else {

				p++;

			}

			if(p==a){

				ret=max(ret,cnt);

				break;

			}

		}

	}



	printf("%d\n",ret);

}
// Slower C++ solution:
#include<iostream>

using namespace std;



int main(){

	int a,b,s[5002],t[5002],ans=0;

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++)scanf("%d",&s[i]);

	for(int i=0;i<b;i++)scanf("%d",&t[i]);

	for(int i=0;i<b;i++){

		int k=0,ret=0;

		for(int j=i;j<b;j++){

			while(t[j]!=s[k]){k++; if(k>=a)break;}

			if(k>=a)break;

			ret++; k++;

		}

		if(ret>ans)ans=ret;

	}

	printf("%d\n",ans);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.157703432191214x):
#include<cstdio>

#include<algorithm>

using namespace std;



const int INF=1000000000;



int main(){

	int a,b;

	int s[5002],t[5002];

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++){

		scanf("%d",&s[i]);

	}

	for(int i=0;i<b;i++){

		scanf("%d",&t[i]);

	}



	int memo[5002]; for(int i=0;i<b;i++)memo[i]=INF;



	int ret=0;

	for(int i=0;i<b-ret;i++){

		int p=0,q=i;

		int cnt=0;

		while(1){

			

			if(s[p]==t[q]){

				if(p>=memo[q])break;

				memo[q]=p;

				cnt++;

				p++;

				q++;

			}

			else {

				p++;

			}

			if(p==a){

				ret=max(ret,cnt);

				break;

			}

			if(ret>cnt+a-p)break;

		}

	}





	printf("%d\n",ret);

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

using namespace std;



int main(){

	int a,b;

	int s[5002],t[5002];

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++){

		scanf("%d",&s[i]);

	}

	for(int i=0;i<b;i++){

		scanf("%d",&t[i]);

	}



	int ret=0;

	for(int i=0;i<b-ret;i++){

		int p=0,q=i;

		int cnt=0;

		while(1){

			if(s[p]==t[q]){

				cnt++;

				p++;

				q++;

			}

			else {

				p++;

			}

			if(p==a)break;

		}

		ret=max(ret,cnt);

	}



	printf("%d\n",ret);

}

// Faster C++ solution for the same problem (measured speedup: 5.158264986573745x):
#include<cstdio>

#include<algorithm>

using namespace std;



const int INF=1000000000;



int main(){

	int a,b;

	int s[5002],t[5002];

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++){

		scanf("%d",&s[i]);

	}

	for(int i=0;i<b;i++){

		scanf("%d",&t[i]);

	}



	int memo[5002]; for(int i=0;i<b;i++)memo[i]=INF;



	int ret=0;

	for(int i=0;i<b-ret;i++){

		int p=0,q=i;

		int cnt=0;

		while(1){

			

			if(s[p]==t[q]){

				if(p>=memo[q])break;

				memo[q]=p;

				cnt++;

				p++;

				q++;

			}

			else {

				p++;

			}

			if(p==a){

				ret=max(ret,cnt);

				break;

			}

			if(ret>cnt+a-p)break;

		}

	}





	printf("%d\n",ret);

}
// Slower C++ solution:
#include<iostream>

using namespace std;



int main(){

	int a,b,s[5002],t[5002],ans=0;

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++)scanf("%d",&s[i]);

	for(int i=0;i<b;i++)scanf("%d",&t[i]);

	for(int i=0;i<b;i++){

		int k=0,ret=0;

		for(int j=i;j<b;j++){

			while(t[j]!=s[k]){k++; if(k>=a)break;}

			if(k>=a)break;

			ret++; k++;

		}

		if(ret>ans)ans=ret;

	}

	printf("%d\n",ans);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.155191994530062x):
#include<cstdio>

#include<algorithm>

using namespace std;



const int INF=1000000000;



int main(){

	int a,b;

	int s[5002],t[5002];

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++){

		scanf("%d",&s[i]);

	}

	for(int i=0;i<b;i++){

		scanf("%d",&t[i]);

	}



	int memo[5002]; for(int i=0;i<b;i++)memo[i]=INF;



	int ret=0,p,q,cnt;

	for(int i=0;i<b-ret;i++){

		p=0; q=i; cnt=0;

		while(1){

			

			if(s[p]==t[q]){

				if(p>=memo[q])break;

				memo[q]=p;

				cnt++;

				q++;

			}

			p++;

			if(p==a){

				ret=max(ret,cnt);

				break;

			}

		}

	}





	printf("%d\n",ret);

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

using namespace std;



int main(){

	int a,b;

	int s[5002],t[5002];

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++){

		scanf("%d",&s[i]);

	}

	for(int i=0;i<b;i++){

		scanf("%d",&t[i]);

	}



	int ret=0;

	for(int i=0;i<b-ret;i++){

		int p=0,q=i;

		int cnt=0;

		while(1){

			if(s[p]==t[q]){

				cnt++;

				p++;

				q++;

			}

			else {

				p++;

			}

			if(p==a)break;

		}

		ret=max(ret,cnt);

	}



	printf("%d\n",ret);

}

// Faster C++ solution for the same problem (measured speedup: 5.15575327547523x):
#include<cstdio>

#include<algorithm>

using namespace std;



const int INF=1000000000;



int main(){

	int a,b;

	int s[5002],t[5002];

	scanf("%d%d",&a,&b);

	for(int i=0;i<a;i++){

		scanf("%d",&s[i]);

	}

	for(int i=0;i<b;i++){

		scanf("%d",&t[i]);

	}



	int memo[5002]; for(int i=0;i<b;i++)memo[i]=INF;



	int ret=0,p,q,cnt;

	for(int i=0;i<b-ret;i++){

		p=0; q=i; cnt=0;

		while(1){

			

			if(s[p]==t[q]){

				if(p>=memo[q])break;

				memo[q]=p;

				cnt++;

				q++;

			}

			p++;

			if(p==a){

				ret=max(ret,cnt);

				break;

			}

		}

	}





	printf("%d\n",ret);

}