akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s;
    cin >> s;

    for(int i = 1; i <= s.size(); i++)
    {
        if(s[i - 1] != s[s.size() - i])
        {
            cout << "No";
            return 0;
        }
    }
    for(int i = 1; i <= (s.size()- 1) / 2; i++)
    {
        if(s[i - 1] != s[(s.size()- 1) / 2 - i])
        {
            cout << "No";
            return 0;
        }
    }
    for(int i = (s.size() + 3) / 2; i <= s.size(); i++)
    {
        if(s[i - 1] != s[s.size() - i + (s.size() + 3) / 2 - 1])
        {
            cout << i << " " << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 3628
s = input()
top = s[0]
ng = False
for i in s:
    if top != i:
        ng = True
        break

if not (ng):
    print(s)
else:
    if int(top * len(s)) < int(s):
        print(str(int(top) + 1) * len(s))
    else:
        print(int(top * len(s)))

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
import numpy as np
N = int(input())
dp = np.zeros((N+1,3), dtype=np.int)
X = list(map(int, input().split()))
for _ in range(3):
  dp[1][_] = X[_]
for n in range(2,N+1):
  X = list(map(int, input().split()))
  dp[n][0] = max(dp[n-1][1],dp[n-1][2]) + X[0]
  dp[n][1] = max(dp[n-1][2],dp[n-1][0]) + X[1]
  dp[n][2] = max(dp[n-1][0],dp[n-1][1]) + X[2]
print(max(dp[N]))

Measured memory_bytes: 14812
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n;
int a[5][N];
int cache[5][N];

int dp(int idx, int prev)
{
	if(idx==n+1)
		return 0;
	int &ans=cache[prev][idx];
	if(ans!=-1)
		return ans;
	ans=0;
	for(int i=1;i<=3;i++)
	{
		if(i==prev)
			continue;
		ans=max(ans, a[i][idx] + dp(idx+1, i));
	}
	return ans;
}

int32_t main()
{
	IOS;
    
	memset(cache, -1, sizeof(cache));
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=3;j++)
			cin>>a[j][i];
	}
	int ans=dp(1, 0);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 15104
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<string>
#include<functional>
using namespace std;
typedef	long long int ll;

int main(){
    ll n, m;
    cin >> n >> m;
    ll res;
    res = abs((n-2)*(m-2));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_asc(const void* a, const void* b) {
    return *((size_t*)a) < *((size_t*)b) ? -1 : 1;
}

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_i64_desc(const void* a, const void* b) {
    return *((int64_t*)a) > * ((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
    return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
    return *((char*)a) > * ((char*)b) ? -1 : 1;
}

static size_t powSz(const size_t base, const size_t exp) {
    if (exp == 0) {
        return 1;
    }

    if (exp == 1) {
        return base;
    }

    if (exp % 2 == 0) {
        return powSz(base * base, exp / 2);
    }
    else {
        return base * powSz(base, exp - 1);
    }
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    uint64_t A, B, C;

    scanf("%"PRIu64"%"PRIu64"%"PRIu64, &A, &B, &C);

    uint64_t left = C;
    if (A - B <= C) {
        left = C - (A - B);
    }
    else{
        left = 0;
    }

    printf("%"PRIu64, left);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits.h>
#include <climits>
#include <map>
#include <unordered_map>
#include <cmath>
#include <set>
#include <unordered_set>
#include <iterator>
#include <deque>
#include <assert.h>
#include <cstdlib>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ull min(ull x, ull y){ if (x<y) return x; return y;}
ull max(ull x, ull y){ if (x<y) return y; return x;}
ll min(ll x, ll y){ if (x<y) return x; return y;}
ll max(ll x, ll y){ if (x<y) return y; return x;}
double min(double x, double y){ if (x<y) return x; return y;}
double max(double x, double y){ if (x<y) return y; return x;}
ull gcd(ull x, ull y){
    if (!x) return y;
    if (!y) return x;
    if (x>y) swap(x,y);
    return gcd(x, y%x);
}
ull inv(ull a, ull c){ // a,c are coprime and a<c
    if (a==1){
        return 1;
    }
    return ((c-(c/a))*inv(c%a,c))%c;
}
#define maxn 200005
ll n, m, k, MOD = 998244353, p[maxn] = {0}, fact[maxn] = {0}, ifact[maxn] = {0};
void add(ll &a, ll b){
    a+=b;
    if (a>=MOD) a-=MOD;
}
ll mul(ll a, ll b){
    return (a*b)%MOD;
}
ll C(ll n, ll r){
    return mul(fact[n],mul(ifact[n-r],ifact[r]));
}

int main(){
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>n>>m>>k;
    p[0] = 1;
    fact[0] = 1;
    ifact[0] = 1;
    for (ll i = 1; i <= n; i++){
        p[i] = mul(m-1,p[i-1]);
        fact[i] = mul(i,fact[i-1]);
        ifact[i] = mul(inv(i,MOD),ifact[i-1]);
    }

    ll ans = 0;
    for (ll nump = n-k; nump <= n; nump++){
        add(ans,mul(C(n-1,nump-1),mul(m,p[nump-1])));
    }
    cout<<ans<<"\n";

    return 0;
}





Measured memory_bytes: 7820
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  double t,x;
  cin >> t >> x;
  double ans=t/x;
  cout << ans << endl;
      
   
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

const int limit=300010;

struct Binary_indexed_tree{
	using T=int;
	vector<T> data;
	int n;

	Binary_indexed_tree(int _n):n(_n){data.assign(n+1,0);}

	void update(int i,T x){
		for(;i<=n;i+=i&-i) data[i]+=x;
	}

	T query(int i){
		T ret=0;
		for(;i>0;i-=i&-i) ret+=data[i];
		return ret;
	}
};

using Query = tuple<int,int>;
vector<Query> que[limit];



int main(void){
	int n,m;
	cin >> n >> m;

	rep(i,n){
		int l,r;
		cin >> l >> r;
		r++;
		que[r-l].push_back(Query(l,r));
	}

	int cur = n;

	Binary_indexed_tree bit(m+1);

	rep(i,1,m+1){
		for(auto &elem:que[i]){
			cur--;
			int l,r;
			tie(l,r) = elem;
			bit.update(l,1);
			bit.update(r,-1);
		}

		int ans = cur;
		for(int d = i; d <= m; d+=i) ans += bit.query(d);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 12672
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, T;
  scanf("%d%d", &N, &T);

  int ans = INT32_MAX;
  for (int i = 0; i < N; i++) {
    int c, t;
    scanf("%d%d", &c, &t);
    if (t <= T) {
      ans = min(ans, c);
    }
  }

  if (ans == INT32_MAX) {
    printf("TLE");
  } else {
    printf("%d", ans);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  int pay;
  int comeback;
  int result;

  std::cin >> n;

  pay = 800 * n;
  comeback = (n / 15) * 200;
  result = pay - comeback;

  std::cout << result << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define fill(x, y) memset(x, y, sizeof(x))
#define clr(x) memset(x, 0, sizeof(x))
#define pb push_back
#define eb emplace_back

template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (b < a)
	{
		a = b;
		return 1;
	}
	return 0;
}

using ll = long long;
using namespace std;

int main()
{
	ll N;
	cin >> N;
	cout << (N + 1) / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr= input.trim().split("\n");
var n=arr.shift()-0;
var [a,d]=arr.shift().split(" ").map(Number);
var obj={};
var m=arr.shift()-0;
for(var i=0;i<m;i++){
   var [x,y,z] = arr.shift().split(" ");
   if(x=="0"){
      if(obj.hasOwnProperty(y)==false && obj.hasOwnProperty(z)==false){
         obj[y]=z;
         obj[z]=y;
      }else if(obj.hasOwnProperty(y)==true && obj.hasOwnProperty(z)==false){
         obj[z]=obj[y];
         obj[y]=z;
      }else if(obj.hasOwnProperty(y)==false && obj.hasOwnProperty(z)==true){
         obj[y]=obj[z];
         obj[z]=y;
      } else{
         [obj[y],obj[z]]=[obj[z],obj[y]]
      }
   }else{
      if(obj.hasOwnProperty(y)==false && obj.hasOwnProperty(z)==false){
         obj[y]=z;
      }else if(obj.hasOwnProperty(y)==true && obj.hasOwnProperty(z)==false){
         obj[y]=z;
      }else if(obj.hasOwnProperty(y)==false && obj.hasOwnProperty(z)==true){
         obj[y]=obj[z];
      } else{
         obj[y]=obj[z];
      }
   }
}
var k=arr.shift();
if(obj.hasOwnProperty(k))k=obj[k];
k=k-0;
console.log(a+((k-1)*d));


Measured memory_bytes: 15180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;

int main()
{
  int h, w, n; cin >> h >> w >> n;
  queue<int> q;
  for (int i=0; i<n; i++){
    int a; cin >> a;
    rep(j, a) q.push(i+1);
  }

  vector<vector<int>> g(h, vector<int>(w));
  for (int i=0; i<h; i++) {
    if (i%2 == 0) {
      for (int j=0; j<w; j++) {
        g[i][j] = q.front(); q.pop();
      }
    } else {
      for (int j=w-1; j>=0; j--) {
        g[i][j] = q.front(); q.pop();
      }
    }
  }
  rep(i, h) {
    rep(j, w) {
      if (j>0) cout << " ";
      cout << g[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#展望台i：1 ~ Nこの展望台
#Hi: 展望台iの高さ

from copy import deepcopy
from pprint import pprint

n,m = map(int, input().split())

h = list(map(int,input().split()))

anslist = [1]*n

for _ in range(m):
    a,b = map(int,input().split())
    
    if h[a-1] > h[b-1]:
        anslist[b-1] = 0
    elif h[a-1] < h[b-1]:
        anslist[a-1] = 0
    elif h[a-1] == h[b-1]:
        anslist[a-1] = 0
        anslist[b-1] = 0
    #print(anslist)


print(anslist.count(1))

exit()

Measured memory_bytes: 84780
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;
int main(){
    int n, y;
    cin >> n >> y;
    REP(i,n+1){
        REP(j,n-i+1){
            int k = n - i - j;
            int ans = 1000 * i + 5000 * j + 10000 * k;
            if(ans==y){
                cout << k <<" "<< j <<" "<< i << endl;
                return 0;
            }
        }
    }
    cout << -1 <<" "<< -1 <<" "<< -1 << endl;
    return 0;
}

Measured memory_bytes: 256
Num, K = map(int, input().split())
A_s = list(map(int, input().split()))
p = 10**9 + 7
A_s.sort()

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

max_ans = 0
min_ans = 0
for i in range(Num):
    max_ans = max_ans + A_s[i] * cmb(i,K-1, p) 
    min_ans += A_s[i] * cmb(Num-i-1,K-1,p)
print((max_ans - min_ans) % p)

Measured memory_bytes: 129928
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<bool> vbool;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<llint> vllint;
typedef vector<vllint> vvllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define coutans rep(i, ans.size())cout << ans[i] << endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	vector<string>ans;
	while (1) {
		string s;
		cin >> s;
		if (s == "-")break;
		int n;
		cin >> n;
		rep(i, n) {
			int x;
			string tmp;
			cin >> x;
			tmp += s.substr(x, s.size() - x);
			tmp += s.substr(0, x);
			s = tmp;
		}
		ans.push_back(s);
	}
	coutans;
	return 0;
}


Measured memory_bytes: 3156
#include<iostream>
using namespace std;
int main(){
  int n,r[200][3],f[101][3]={0};
  cin >>n;
  for(int i=0; i<n; i++){
    for(int j=0; j<3; j++){
      cin >>r[i][j];
      f[r[i][j]][j]++;
    }
  }
  for(int i=0; i<n; i++){
    int ans = 0;
    for(int j=0; j<3; j++)
      if(f[r[i][j]][j] == 1) ans+=r[i][j];
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
from heapq import heappop as pop
from heapq import heappush as push
INF = 10 ** 20

def main():
  n, k = map(int, input().split())
  
  clst = []
  rlst = []
  
  for i in range(n):
    c, r = map(int, input().split())
    clst.append(c)
    rlst.append(r)
  
  edges = [[] * n for i in range(n)]
  
  for i in range(k):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)
  
  costs = [INF for i in range(n)]
  costs[0] = 0
  used = [False for i in range(n)]
  
  def make_to_lst(s_num):
    loop = rlst[s_num]
    temp = {i for i in edges[s_num]}
    ret = {i for i in temp}
    while loop:
      new = set()
      for p in temp:
        pto = {i for i in edges[p]}
        new = new | pto
      ret = ret | temp
      temp = new - ret
      if not temp:
        break
      loop -= 1
    return ret
  
  used[0] = True
  costs[0] = 0
  break_flag = 0
  que = [(clst[0], 0)]
  
  while que and not break_flag:
    next_cost, s_num = pop(que)
    to_lst = make_to_lst(s_num)

    for num in to_lst:
      costs[num] = next_cost
      if num == n - 1:
        break_flag = 1
        break
      if not used[num]:
        push(que, (costs[num] + clst[num], num))
        used[num] = True
  
  print(costs[n - 1])

main()


Measured memory_bytes: 7792
<?php

$array = explode(' ', trim(fgets(STDIN)));

$a = (int) $array[0];
$b = (int) $array[1];

if ($a < $b) {
  $n = $a;
} else {
  $n = $b;
}

$i = 0;
$ans = $n;
while (true) {
  $i++;
  $ans = $n * $i;
  if ($ans % $a === 0 && $ans % $b === 0) {
    echo $ans;
    exit;
  }
}


Measured memory_bytes: 4728
n,w=map(int,input().split())
dp=[[0]*(w+1) for i in range(n+1)]
wet=[]
val=[]
for i in range(n):
  we,va=map(int,input().split())
  wet.append((we,va))
wet.sort()
#print(wet)
for i in range(n+1):
  for j in range(w+1):
    if(i==0 or j==0):
      continue
    dp[i][j]=dp[i-1][j]
    if(wet[i-1][0]<=j):
      #print(wet[i][1],wet[i][0])
      dp[i][j]=max(dp[i][j],dp[i-1][j-wet[i-1][0]]+wet[i-1][1])
print(dp[n][w])


Measured memory_bytes: 120812
#date: 2020-03-17 15:13
import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    i = 1
    while i * i <= n:
        if n % i == 0:
            j = n // i
            ans = max(len(str(i)), len(str(j)))
        i += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
  
  int N;
  cin >> N;

  vector<vector<char>> S(N,vector<char>(N));
  for(int i = 0;i < N;i++) {
    for(int j = 0;j < N;j++) {
      cin >> S.at(i).at(j);
    }
  }

  int maxi = 0;

  for(int i = 0;i < N;i++) {
    vector<int> seen(N,0);
    queue<pair<int,int>> Q;
    seen[i] = 1;
    Q.push(make_pair(i,1));

    while(!Q.empty()) {
      pair<int,int> p = Q.front();
      Q.pop();
      int n = p.first;
      for(int j = 0;j < N;j++) {
        if(seen[j] == 0 && S.at(n).at(j) == '1') {
          seen[j] = p.second+1;
          Q.push(make_pair(j,seen[j]));
        }
      }
    }

    bool ok = true;
    int num = seen[0];
    for(int j = 0;j < N-1;j++) {
      for(int k = j+1;k < N;k++) {
        num = max(num,seen[k]);
        if(seen[j] == seen[k] && S.at(j).at(k) == '1') { 
            ok = false;
            break;
        }
      }
    }

    if(ok) maxi = max(maxi,num);

  }

  if(maxi) cout << maxi << endl;
  else cout << -1 << endl;

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<pi>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}


double memo[301][301][301];
double f(int i, int j, int k, int n) {
    if(i + j + k == 0) return 0;
    if(memo[i][j][k] != 0) return memo[i][j][k];
    int s = i + j + k;
    double ret = n;
    if(i) ret += f(i - 1, j, k, n) * i;
    if(j) ret += f(i + 1, j - 1, k, n) * j;
    if(k) ret += f(i, j + 1, k - 1, n) * k;
    memo[i][j][k] = ret/s;
    return ret/s;
}



int main(){
    int n, r, a = 0, b = 0, c = 0;
    setp(12);
    cin >> n;
    rep(i, n) {
        cin >> r;
        if (r == 1) a ++;
        else if (r == 2) b ++;
        else c ++;
    }
    co(f(a, b, c, n));
}



Measured memory_bytes: 111208
#include<iostream> 
using namespace std;
int main (){
	int n;
	cin>>n ;
//	cout<<pls input 22<=D<=25
	if (n==22){
		cout<<"Christmas Eve Eve Eve";
	}else if (n==23){
		cout<<"Christmas Eve Eve";
	}else if (n==24){
		cout<<"Christmas Eve";
	}else if (n==25){
		cout<<"Christmas";
	}
		
}


Measured memory_bytes: 256
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val l = readInt().toDouble() / 3
    println("%f".format(l * l * l))
}

Measured memory_bytes: 35776
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n, h, w;
    while(cin>>h>>w>>n){
        cout<<min((n+h-1)/h, (n+w-1)/w)<<endl;
    }
  return 0;
}




Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  string a,b;cin>>a>>b;
  rep(i,a.size()){
    if(i<b.size())cout<<a[i]<<b[i];
    else cout<<a[i];
  }
  cout<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int[] a = new int[N];
            for(int i = 0; i<N; i++)
            {
                a[i] = int.Parse(str[i]);
            }

            int count = 0;
            for(int i = 0; i<N; i++)
            {
                if(a[i] == count + 1)
                {
                    count += 1;
                }
            }

            int kai = -1;
            if(count == 0)
            {
                kai = -1;
            }
            else
            {
                kai = N - count;
            }
            Console.Write(kai);
        }
    }
}


Measured memory_bytes: 33116
import java.util.Scanner;

/**
 * Created on 2016/08/21.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        long ans = 0;

        int amari = 0;

        for(int i=0; i<N; i++){
            int tmp = sc.nextInt();

            //amari
            int tmp2 = 0;
            if(tmp == 0){
                amari = 0;
            }else{
                tmp2 = tmp + amari;
                if(tmp2%2 == 0){
                    amari = 0;
                }else {
                    amari = 1;
                }
            }

            int add = (tmp2 / 2);

            ans += add;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 22900
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;

lli n;
mat a;
lli ans;

void error(){
  cout << -1 << endl;
  exit(0);
}

int main(){
  cin >> n;
  a = mat(n,vll(n));
  for(lli i = 0;i < n;i++){
    for(lli j = 0;j < n;j++){
      cin >> a[i][j];
    }
  }
  for(lli i = 0;i < n;i++){
    for(lli j = 0;j < n;j++){
      ans += a[i][j];
    }
  }
  for(lli i = 0;i < n;i++){
    for(lli j = 0;j < n;j++){
      for(lli k = 0;k < n;k++){
        if(a[i][j] > a[i][k] + a[k][j]) error();
        if(a[i][j] == a[i][k] + a[k][j] && i != k && j != k){
          ans -= a[i][j];
          break;
        }
      }
    }
  }
  cout << ans/2 << endl;
  return 0;
}


Measured memory_bytes: 1024
/* Common Raccoon vs Monster */

#include <iostream>
#include <vector>
using namespace std;

int main(){
  int h,n,a,sum=0;
  vector<int> A;
  cin >> h >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    A.push_back(a);
    sum+=A[i];
    if(h<=sum){
      cout << "Yes" << endl;
      break;
    }
    else{
      continue;
    }
  }
  if(sum<h){
    cout << "No" << endl;
  }
}


Measured memory_bytes: 892
n,m=map(int,input().split())
INF=10**18
edge=[[INF]*n for i in range(n)]
s=[]
for i in range(m):
  u,v,c=map(int,input().split())
  edge[u-1][v-1]=edge[v-1][u-1]=c
  s.append((u-1,v-1,c))
for k in range(n):
  for i in range(n):
    for j in range(n):
      edge[i][j]=min(edge[i][j],edge[i][k]+edge[k][j])
cnt=0
for i,j,cost in s:
  if edge[i][j]==cost:
    cnt+=1
print(m-cnt)


Measured memory_bytes: 42220
#include<bits/stdc++.h>
using namespace std;

int main(void){
  int r, d, x;
  cin >> r >> d >> x;
  
  int record = x;
  
  for (int i = 1; i <= 10; i++) {
    int nextX = r * record - d;
    cout << nextX << endl;
    record = nextX;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll = long long;                    // seq 1 128 | factor   100333 ~2^16.61
using vl = vector<ll>;                   //   | grep -v ' .* '  1300111 ~2^20.31
using vvl = vector<vl>;                  //                    10300777 ~2^23.30
using pll = pair<ll,ll>;                 //                   100400999 ~2^26.58
using vb = vector<bool>;                 //                  1300400999 ~2^30.28
const ll oo = 0x3f3f3f3f3f3f3f3fLL;      //                 10200500333 ~2^33.25
const double eps = 1e-9;                 //                100200400777 ~2^36.54
#define sz(c) ll((c).size())             //               1200300700111 ~2^40.13
#define all(c) begin(c),end(c)           //              10200300500777 ~2^43.21
#define mp make_pair                     //             100200300400777 ~2^46.51
#define mt make_tuple                    //            1200300400600999 ~2^50.09
#define pb push_back                     //           10200300400600111 ~2^53.18
#define eb emplace_back                  //          100200300400600333 ~2^56.48
#define xx first                         //         1200300400500800999 ~2^60.06
#define yy second                       
#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (ll i=(a); i<(ll)(b); i++)       
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)
/// ({ ... }) avoids some problems: http://kernelnewbies.org/FAQ/DoWhile0
/// In non-contest code it is probably better to use: do { ... } while(0)
#define TR(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {

    double n;
    cin >> n;
    double sum = 0;
    FOR(i,0,n){
        double ai;
        cin >> ai;
        sum += 1.0/ai;

    }
    cout << 1/sum << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(i, a)  for (auto i : a)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define PI acos(-1)

template<class T>
bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }

template<class T>
bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 998244353;
const ll oo = 1e18;
const int MX = 1e5 + 5, N = 2e5 + 5;

int n, ans[MX];

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    FOR(i, 1, n + 1) {
        FOR(j, 1, n + 1) {
            if (i * i + j * j + 1 + i * j + j + i > n) break;
            FOR(k, 1, n + 1) {
                if (i * i + j * j + k * k + i * j + j * k + k * i > n) break;
                ans[i * i + j * j + k * k + i * j + j * k + k * i]++;
            }
        }
    }
    FOR(i, 1, n + 1) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3680
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>
#include<cmath>

using namespace std;



int main(){

    int x, a;
    cin >> x >> a;
    if(x<a)cout << 0<< endl;
    else cout<<10<<endl;

}


Measured memory_bytes: 256
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

typedef pair<int, pair<int, int>> edge;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}



//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	//x < y
	if (x > y) swap(x, y);
	e.push_back({ z,{x,y} });
}

void Kruskal::run() {
	sort(e.begin(), e.end());
	e.erase(unique(e.begin(), e.end()), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}

signed main() {
	int a,b,t;
	cin >> a >> b >> t;
	int ans = 0;
	for (int i = a;i < t + 1;i+=a) {
		ans += b;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

void solve() {
  ll n, y;
  vector<int> v(3);
  rep(i,3) v[i] = -1;
  cin >> n >> y;
  if (y % 1000 == 0) {
    for (int m = 0; m <= n; ++m) {
      for (int g = 0; g <= n; ++g) {
        ll temp = 10000 * m + 5000 * g;
        if (temp <= y && m + g + (y - temp) / 1000 == n) {
          v[0] = m;
          v[1] = g;
          v[2] = (y - temp) / 1000;
        }
      }
    }
  }

  rep(i,3) {
    cout << v[i] << " ";
  }
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

bool IsPrime(ll num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  ld sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}

//実行部
void Main()
{
  ll a, b, k; cin >> a >> b >> k;
  rep(i, k)
  {
    if(i % 2 == 0)
    {
      a /= 2;
      b += a;
    }
    else
    {
      b /= 2;
      a += b;
    }
  }
  cout << a << " " << b;
}

//前処理
int main()
{
  ifstream in("text.txt");
  cin.rdbuf(in.rdbuf());
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int Count(char c) {
    return 'z' - c + 1;
}

int main() {
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;

    int k;
    cin >> k;

    for (int i = 0; i < (int) s.size(); ++i) {
        if (s[i] != 'a' && Count(s[i]) <= k) {
            k -= Count(s[i]);
            s[i] = 'a';
        }
    }

    k %= ('z' - 'a' + 1);
    while (k > 0) {
        if (s[s.size() - 1] == 'z') {
            s[s.size() - 1] = 'a';
        } else {
            ++s[s.size() - 1];
        }
        --k;
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,n) for(ll i=0;i<n;i++)
#define repp(i,a,b) for(ll i=a;i<=b;i++)
#define reff(i,a,b) for(ll i=a;i>=b;i--)
#define ll long long int
#define pll pair<ll,ll>
#define fill(a,x) memset(a,x,sizeof(a))
#define mb make_pair
#define pb push_back
#define F first
#define S second
#define M 1000000007
#define sc(x) scanf("%d",&x)
#define scc(x1,x2) scanf("%d%d",&x1,&x2)
#define sccc(x1,x2,x3) scanf("%d%d%d",&x1,&x2,&x3)
#define pr(x) printf("%lld ",x)
#define dbg(a)         std::cerr<<#a<<"="<<(a)<<"\n"
#define dbg1(a,b)       std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define dbg2(a,b,c)     std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define dbg3(a,b,c,d)   std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define all(v) v.begin(),v.end()
#define PI 3.14159265
#define co cout<<"fuck"<<endl
const int INF = 2034567891;
const ll INF64 = 4234567890123456789ll;
long long nc3(long long v){return (v * (v - 1ll) * (v - 2ll)) / 6ll;}
long long nc2(long long v){return (v * (v - 1ll)) / 2ll;}
ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }
const int N = 10+2e5;
bool isprime(ll n) {
    if (n < 2) return 0;
    if (n == 2) return 1;
    if (n % 2 == 0) return 0;
    for (ll i = 3; i*i <= n; i++) if (n%i == 0) return 0;
    return 1;
}
double dist(pll p1, pll p2)
 {
    return (p1. F - p2.F)*(p1.F - p2.F) +
          (p1.S - p2.S)*(p1.S - p2.S);
 }
ll power(ll x,ll y)
{
    ll ans=1;
    while(y>0){
        if(y&1)
            ans=(ans*x)%M;
        x=(x*x)%M;
        y/=2;
    }
    return ans%M;
}
int main()
{
    fast;
    ll n;
    cin>>n;
    ll a[n];
    rep(i,n) cin>>a[i];
    map<ll,ll>o,e;
    rep(i,n)
    {
       if(i&1)
       o[a[i]]++;
       else
       e[a[i]]++;
	}
	ll odd,even;
	ll ma1=0;
	for(auto i : o)
	{
	    if(i.S>ma1)
	    {
	        ma1=i.S;
	        odd=i.F;
		}
	}
	ll ma2=0;
	for(auto i : e)
	{
	    if(i.S>ma2)
	    {
	       ma2=i.S;
	       even=i.F;
		}
	}
	if(odd!=even)
	{
	   cout<<(n-ma1-ma2);
	   return 0;
	}
	ll ma3=0,ma4=0;
	for(auto i : o)
	{
	    if(i.F==odd) continue;
	    if(i.S>ma3)
	    {
	        ma3=i.S;
		}
	}
	for(auto i : e)
	{
	    if(i.F==even) continue;
	    if(i.S>ma4)
	    {
	       ma4=i.S;
		}
	}
    ll ma=min(n-ma1-ma4,n-ma2-ma3);
	cout<<ma;
}    

Measured memory_bytes: 7296
#include<stdio.h>
int main(void){
    int n,i;
    char s[100];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%c",&s[i]);
        if(s[i]=='Y'){
            printf("Four\n");   
            return 0; 
        }
    }
    printf("Three\n");
	return 0;		
}

Measured memory_bytes: 128
#include <stdio.h>

int main() {

	int a;
	int b;
	int c;

	scanf ( "%d%d%d" , &a , &b , &c );
	if ( a < b && b < c ) {
			printf ( "Yes\n" );
	} else {
		printf ("No\n");
	}
	return 0 ;

}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li p[1010];

int main() {
    li n, k;
    cin >> n >> k;
    rin{
        cin >> p[i];
    }
    sort(p, p + n);
    li res = 0;
    rep(i, k) {
        res += p[i];
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    string b;
    vector<string> in{"A", "T", "G", "C"};
    vector<string> out{"T", "A", "C", "G"};
    cin >> b;

    cout << out[find(in.begin(), in.end(), b) - in.begin()] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL x;
    cin >> x;
    if (x <= 2) {
        cout << 2 << endl;
        return;
    }
    for (;;++x) {
        int v = x;
        if (v % 2 == 0) continue;
        bool b = true;
        for (LL i = 3; i * i <= v; i+=2) {
            if (v % i == 0) {
                b = false;
                break;
            }
        }
        if (b) {

            cout << v << endl;
            return;
        }
    }

}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define endl '\n'

vector<vector<int>> cnt;
int get(int l, int r, int chr) {
     if (l) {
          return cnt[chr][r] - cnt[chr][l - 1];
     } else {
          return cnt[chr][r];
     }
}

signed main()
{
     int n;
     cin >> n;
     string s;
     cin >> s;
    // cout << int('W') <<  ' ' << int('E') << endl;
     cnt.resize(256, vector<int>(n));
     cnt[s[0]][0]++;
     for (int i = 1; i < n; ++i) {
          cnt[s[i]][i] = cnt[s[i]][i-1]+1;
          cnt[s[i] == 'W'? 'E' : 'W'][i] = cnt[s[i] == 'W'? 'E' : 'W'][i - 1];
     }
     int ans = 1e9;
     for (int i = 0; i < n; ++i) {
          int curr = 0;
          if (i) {
               curr += cnt['W'][i-1];
          }
          if (i != n - 1) {
               curr += get(i + 1, n - 1, 'E');
          }
          ans = min(ans, curr);
     }
     cout << ans << endl;
     return 0;
}


Measured memory_bytes: 603140
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

class Solver {
    void solve(Scanner sc) {
        int N = sc.nextInt();
        
        int[] dams = new int[N];
        int[] mountains = new int[N];
        
        for (int i = 0; i < dams.length; i++) {
            dams[i] = sc.nextInt();
            mountains[0] += (i % 2 == 0 ? 1 : -1) * dams[i];
        }
        
        for (int j = 1; j < N; j++) {
            mountains[j] = dams[j - 1] * 2 - mountains[j - 1];
        }
        
        System.out.println(Arrays.stream(mountains).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
    }
}

class Main {
    public static void main(String... args) {
        Scanner in = new Scanner(System.in);

        new Solver().solve(in);

        in.close();
    }
}

Measured memory_bytes: 64432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int x;cin>>x;
    int c = x / 100;//品物の個数
    int m = x % 100;//残りの端数
    cout << (c * 5 >= m)<<endl;//品物の個数*5=作れる端数の最大値
}



Measured memory_bytes: 256