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++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int n, a[103], ans;
int tmp = 1;


int main() {

	cin >> n;
	a[0] = 0;
	REP(i, 1, n + 1)cin >> a[i];
	a[n + 1] = 0;

	rep(i, n + 2) {
		if (a[i] == 0) {
			ans = max(ans, tmp);
			tmp = 1;
		}
		else {
			tmp++;
		}
	}

	cout << ans << endl;

	return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>

using ull = unsigned long long int;
using ll = long long int; 

int main(){
    ll N;
    std::cin >> N;
    int cnt=1;
    int max_cnt=0;

    for(int i=0;i<N;i++){
        int A;
        std::cin >> A;
        if(A==0) cnt=1;
        if(A==1) cnt++;
        if(cnt>max_cnt) max_cnt=cnt;
    }

    std::cout << max_cnt << std::endl;

    return 0;
}

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

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int N, num = 0, ans1 = 0; cin >> N;
	vector<int> A(N);
	rep(i, N) {
		cin >> A[i];
		if (A[i] == 0)num = 0;
		else ++num;
		ans1 = max(ans1, num);
	}
	cout << ans1 + 1 << endl;
	cin >> N;
}

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

int main(){
    int ans=0,c=0,maxc=0;
    int n;
    
    cin >>n;
    int a[n];

    cin >>a[0];
    if(a[0]==1)c=1;
    
    for (int i = 1; i < n; i++){
        cin >> a[i];
        
        if(a[i]==1 && a[i-1]==a[i]){
            c++;
        }else if(a[i]==1){
            c=1;
        }else{
            c=0;
        }

        maxc=max(maxc,c);
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << maxc+1 << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}

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

int n, a[111], res;

int main()
{
    cin >> n;
    int p = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] == 0)
            res = max(p, res), p = 0;
        else
            p++;
    }
    res = max(p, res);
    cout << res + 1 << endl;
}

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

using namespace std;

int main() {
	int n, a;
	int dpLen[101];

	memset(dpLen, 0, sizeof(dpLen));
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a;
		if (a == 0) {
			continue;
		}
		dpLen[i] = dpLen[i - 1] + 1;
	}
	cout << *max_element(dpLen, dpLen + n + 1) + 1 << endl;

	return 0;
}

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が出てきた場合
                        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 <iostream>
#include <algorithm>
using namespace std;

int N, A[100009], cnt, maxn = 0;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		if (A[i] == 1) { cnt++; }
		else { cnt = 0; }
		maxn = max(maxn, cnt);
	}
	cout << maxn + 1 << endl;
	return 0;
}

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

C++: #include<stdio.h>
int main(void)
{
	int i;
	int N;
	int A[100];
	int max=0;
	int counter=0;
	
	scanf("%d",&N);//Nの値を取得
	
	for(i=0;i<N;i++)
	{
		scanf("%d",&A[i]);//A[i]の値を取得
		

		if(A[i]==1)
			counter++;
		else
		{
			if(max<counter)
				max=counter;
			counter=0;
		}
	}
	if(max<counter)
		max=counter;
	printf("%d\n",max+1);
	return(0);
}

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

int n, A[105];

bool check(int x){
  
  int d[105] = {};

  d[1] = 1;

  int update = 1;
  
  while(update){
    
    update = 0;
    
    for(int i=n+2;i>=1;i--) {

      if(d[i]==0) continue;
      
      for(int j=1;j<=x;j++){

	if(i+j>n+2) continue;
	if(A[i+j]==1) continue;
	
	if(d[i+j]==0){
	  update = 1;
	  d[i+j] = 1;
	}
      }
      
    }
    
  }

  return d[n+2];
}

int main(){
  
  cin>>n;
  
  for(int i=0;i<n;i++) cin>>A[i+2];
  
  for(int ans=1;ans<=n+1;ans++){
    
    if(check(ans)){
      cout<<ans<<endl;      
      return 0;
    }
    
  }
  
  return 0;
}

C++: #include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N;
int A[110];
int dp[110];

int solve(int j) {
    REP(i, 110) dp[i] = 1LL << 30;
    dp[1] = 0;
    FOR(i, 1, N + 2) {
        FOR(k, 1, j + 1) {
            int nxt = min(N + 2, i + k);
            if (!A[nxt]) dp[nxt] = min(dp[nxt], dp[i] + 1);
        }
    }
    return dp[N + 2];
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N;
    REP(i, N) cin >> A[i + 2];
    FOR(j, 1, N + 2) {
        if (solve(j) == 1LL << 30) continue;
        cout << j << endl;
        return 0;
    }
}

C++: #include <iostream>

using namespace std;
int main(){
  int N,A[101];
  std::cin >> N;
  int max=0;
  int count=0;
  bool flag=false;
  for(int i=0;i<N;i++){
    std::cin >> A[i];
    if(A[i]==1){
      count++;
    }else{
      count=0;
    }

    if(count>max)max=count;
  }


  std::cout << max+1 << '\n';
}