Go: package main

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

func main() {

	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	ma, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	args := strings.Split(sc.Text(), " ")

	value := []int{}
	for _, v := range args {
		a, _ := strconv.Atoi(v)
		value = append(value, a)

	}
	ans(ma, value)

}

func ans(n int, value []int) {

	max := 0
	cnt := 0

	for i := 0; i < n; i++ {

		if value[i] == 1 {
			cnt++
		} else {
			if cnt > max {
				max = cnt
			}
			cnt = 0
		}
	}

	if cnt > max {
		max = cnt
	}

	fmt.Printf("%d\n", max+1)
}

C++: #include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	int n;
	cin >> n;
	int a[n];
	REP(i, n) cin >> a[i];
	bool current = 0;
	int sum = 0;
	int max = 0;
	REP(i, n){
		if (a[i] == 1){
			if (current) sum++;
			else sum = 1;
			current = 1;
		}
		else {
			current = 0;
			sum = 0;
		}
		if (max < sum) max = sum;
	}

	cout << max + 1 << endl;

}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n;
    cin >> n;

    ll max1 = 0;
    ll cur1 = 0;
    REP(i, n){
        ll a;
        cin >> a;
        if(a == 0){
            cur1 = 0;
        }else{
            cur1++;
        }
        max1 = max(max1, cur1);
    }

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

C++: #include <iostream>
int main(void){
    int n,x=0,y=0;
    std::cin>>n;
    for(int i=0;i<n;i++){
        int a;
        std::cin>>a;
       x=(x+1)*a;
       if(x>y){
           y=x;
       }
    }
    std::cout<<y+1<<std::endl;
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n;
  cin >> n;
  int r = 0, sr = 0;
  rep(i, 0, n) {
    int a;
    cin >> a;
    if(a == 1) r++, sr = max(sr, r);
    else r = 0;
  }
  cout << sr + 1 << endl;
}

C++: /*
      author : Nishikawa
      created: 04.08.2020 00:01:21
*/

#include <bits/stdc++.h>

using namespace std;

int main(){
    int N;
    cin >> N;
    int max_cont=0;

    while(N--){
        int A;
        cin >> A;
        int cont=0;
        while(A==1){
            cont++;
            if(!N) break;
            cin >> A;
            N--;
        }
        max_cont=max(max_cont,cont);
    }
    cout << max_cont+1 << endl;
    
    return 0;
}

C++: /*
this is test
*/

int main(){
    
}

C++: 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; n++)
	{
		cin >> A;
		if (A == 1)
		{
			if (A == _A)
			{
				count[k]++;
			}
			else
			{
				k++;
				count[k] = 2;
			}
		}
		_A = A;
	}
	sort(count, count + k);
	cout << count[k] << 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 <bits/stdc++.h>
using namespace std;
using LL = long long;

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T> void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U> void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int n;
vector<int> a;

bool check(int k) {
   // whether you can reach goal with k-faced dice
   vector<bool> dp(n+1, false);
   dp[0] = true;
   for (int i = 0; i <= n; ++i) if (dp[i]) {
      for (int j = 1; j <= k; ++j) {
         if (i+j > n) return true;

         if (a[i+j-1] == 0) dp[i+j] = true;
      }
   }
   return false;
}

int binary_search(int MIN, int MAX)
{
   int l = MIN-1, r = MAX;
   while (r - l > 1) {
      int m = (l + r) / 2;
      if (check(m)) {
         r = m;
      } else {
         l = m;
      }
   }
   return r;
}

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

   cout << binary_search(1, n+1) << endl;

   return 0;
}

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

int main(){
  cin.tie(0);
 	ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int A[N];
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  int a = 0;
  int cnt = 0;
  for(int i = 0; i < N; i++){
    if(A[i] == 1) cnt++;
    else cnt = 0;
    a = max(a, cnt);
  }
  cout << a + 1 << "\n";
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int N,A,B,C,D,a,b;
	cin>>N>>A>>B>>C>>D;
	a=N/A*B;
	b=N/C*D;
	if(N%A!=0)a=a+B;
	if(N%C!=0)b=b+D;
	if(a<b){
		cout<<a<<endl;
	}else{
		cout<<b<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n;
    cin >>n;
    vector<int> a(n);
    rep(i,n) cin >>a[i];

    int ans = 1;
    rep(i,n){
        if(a[i]==1){
            int j=i;
            while(j<n && a[j]==1) ++j;
            ans = max(ans, j-i+1);

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

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

int main(){
	int n,a,c,s;
	s=0;
	c=1;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a==0){
			c=1;
			continue;
		}
		else{
			c++;
			if(s<c) s=c;
		}
	}
	cout<<s<<endl;
	return 0;
}

C++: #include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n+1];
    r(i,n)cin>>a[i];
    a[n]=0;
    int sum=0;
    r(i,n){
        if(a[i]==1){
            int pre=i;
            while(a[i])i++;
            sum=max(sum,i-pre);
        }
    }
    cout<<sum+1<<endl;
}