Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	max, cnt := 0, 0
	for i := 0; i < N; i++ {
		cnt++
		if nextInt() == 0 {
			cnt = 0
		}
		if cnt > max {
			max = cnt
		}
	}
	fmt.Println(max + 1)
}

C++: // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0642



#include<iostream>
 using namespace std; //標準名前空間を使用


    int main(){

    int sugorokunomasu[1000] ;
    int N ;
    int saidairenzokusuucount = 0 ; // 1の最大連続数カウント
    int saidairenzokusuucountmax = 0 ; // 1の最大連続数の最大値

    cin >> N ;

    cin >> sugorokunomasu[1] ; //最初のマスの読み込み

            for (int i = 2 ; i <= N ; i = i + 1 ){
             cin >> sugorokunomasu[i] ; //すごろくのマスの読み込み

                    if(sugorokunomasu[i] == 1){ // すごろくのマスに1が出てきた場合

                        if(i == N){ //最終マスが1である場合の処理
                        // 最終マスが1であれば、最大連続数としてカウントしない
                        }else{
                        saidairenzokusuucount =  saidairenzokusuucount + 1 ; //そうでなければ、1の最大連続数カウントに1を+
                        }


                    }else{ //すごろくのマスに0が出てきた場合

                        if(saidairenzokusuucount > saidairenzokusuucountmax) // 1の最大連続数の最大値を更新されているかの判定
                        { 
                        saidairenzokusuucountmax = saidairenzokusuucount ; //更新されていれば、1の最大連続数の最大値を更新
                        }else{
                        //最大値を更新しない場合は何もしない
                        }

                    saidairenzokusuucount = 0 ; //1の最大連続数カウントをフラッシュして0に
                    
                    }

                


            }


    cout << saidairenzokusuucountmax + 1 << endl ;
    }

C++: #include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
	ll n, z=0, ma=0, i;
	
	cin>>n;
	
	vector <ll> a(n+1);
	
	for(i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]==1) z++;
			else ma=max(ma,z), z=0;
	}
	
	ma=max(ma,z);
	
	cout<<ma+1<<"\n";
	
}

C++: #include <iostream>
using namespace std;

int main() {
	int N; cin >> N; int A;
	int count = 1; int ans = 1;
	for (int i = 0; i < N; i++) {
		cin >> A;
		if (A == 1) { count++; }
		else { count = 1; }
		if (count > ans) { ans = count; }
	}
	cout << ans << endl;
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  Int ans=0;
  for(Int i=0;i<n;i++){
    if(a[i]==0) continue;
    Int j=i;
    while(j<n&&a[j]) j++;
    ans=max(ans,j-i);
  }
  cout<<ans+1<<endl;
  return 0;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	int A[110];
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}
	A[N + 1] = 0;
	int ans = 0;
	int zr = 0;
	for (int i = 1; i <= N + 1; i++) {
		if (A[i] == 0) {
			ans = max(ans, i - zr);
			zr = i;
		}
	}
	if (ans == 0) {
		cout << N + 1 << endl;
	} else {
		cout << ans << endl;
	}
}

C++: #include<iostream>;
#include<algorithm>;
using namespace std;

int main()
{
	//2.すごろく	
	int n;
	cin >> n;
	int A, _A = 1;
	int k = 0;
	int count[100];
	count[k] = 1;
	for (int i = 0; i < n; i++)
	{
		cin >> A;
		if (A == 1)
		{
			if (A == _A)
			{
				count[k]++;
			}
			else
			{
				k++;
				count[k] = 2;
			}
		}
		_A = A;
	}
	sort(count, count + k + 1);
	cout << count[k] << endl;

	return 0;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;


int main() {
	int N;
	cin>>N;
	vector<int>as(N+2);
	for (int i = 0; i < N; ++i) {
		cin>>as[i+1];
	}
	int ans=0;
	int now=0;
	for (int i = 0; i < N; ++i) {
		if (as[i + 1]) {
			now++;
		}
		else {
			now=0;
		}
		ans=max(ans,now);

	}
	cout<<ans+1<<endl;
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){

	int n;
	cin >> n;
	int j = 1;

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

		if( a = 1 ){
			j++;
		}
		else{
			j = 1;
		}
	}

	cout << j << endl;

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
  
int main(){

  int n,count=0,sum=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]==1){
      count+=1;
      if(sum<count) sum=count;
    }
    else count=0;
  }
  cout<<sum+1<<endl;
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a;
    std::deque<int> deq;
    cin>>n;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    int max=0;
    for (int j=0;j<deq.size();j++) {
        int count=0;
        if (deq[j]==1) {
            while (deq[j]==1) {
                count++;
                j++;
            }
        }
        if (max<count) {
            max=count;
        }
    }
    cout<<max+1<<endl;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int n,m,s;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a==0){
            m=max(s,m);
            s=0;
        }else s++;
    }
    cout<<max(m,s)+1<<endl;   
}

C++: #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N;
	scanf("%d",&N);

	int maximum = 0,tmp,succeed_count = 0;
	for(int i = 0; i < N; i++){
		scanf("%d",&tmp);
		if(tmp == 1){
			succeed_count++;
		}else{
			maximum = max(maximum,succeed_count);
			succeed_count = 0;
		}
	}
	maximum = max(maximum,succeed_count);

	printf("%d\n",maximum+1);

	return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    int ans = 0;

    for(int l = 0, r = 0; l < N; l++)
    {
        while(r < N && A[r] == 1)
        {
            r++;

            ans = max(ans, r - l);   
        }

        l = r;
        r++;
    }

    cout << ans + 1 << endl;

    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main() {
    int n;
    int sum = 0;
    int max_v = 0;

    cin >> n;

    vector<int> v;

    v.resize(n);
    for (int i = 0 ; i < n; i++) {
        cin >> v[i];
    }

    if (v[0] == 1) sum++;
    for (int i = 1; i < n; i++) {
        if (v[i-1] == 1 && v[i] == 1) {
            sum++;
        } else if (v[i-1] == 0 && v[i] == 1) {
            sum = 1;
        }

        if (max_v < sum) {
            max_v = sum;
        }
    }

    cout << (max_v+1) <<endl;

    return 0;
}

C++: //2017
#include<iostream>
using namespace std;
int main(void){
	int i,n,a[100],cnt=0,max=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		if(a[i]==1){
			cnt++;
			if(max<cnt){
				max=cnt;
			}
		}
		else if(a[i]==0){///???
			cnt=0;
		}
	}
	cout<<max+1<<endl;///????
	
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n,x,a[100],i,k;
	scanf("%d",&n);
	for(i=0;i<n+2;i++)	a[i]=0;
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	k=1;
	for(i=0;i<n+2;i++){
		if(a[i]==1){
			k++;
		}
	}
	printf("%d\n",k);
	return 0;
}