akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = 998244353;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


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;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
	ll n;
	cin >> n;

	ll i0 = 0;
	string s(n,'a');

	if (n == 1) {
		cout << s << en;
		return;
	}

	REP(i2, 2) {
		s[1] = 'a' + i2;
		if (n == 2) {
			cout << s << en;
			continue;
		}

		REP(i3, i2+2) {
			s[2] = 'a' + i3;
			if (n == 3) {
				cout << s << en;
				continue;
			}
			REP(i4, max({ i2,i3 }) + 2) {
				s[3] = 'a' + i4;
				if (n == 4) {
					cout << s << en;
					continue;
				}
				REP(i5, max({ i2,i3,i4 }) + 2) {
					s[4] = 'a' + i5;
					if (n == 5) {
						cout << s << en;
						continue;
					}
					REP(i6, max({ i2,i3,i4,i5 })+2) {
						s[5] = 'a' + i6;
						if (n == 6) {
							cout << s << en;
							continue;
						}
						REP(i7, max({ i2,i3,i4,i5,i6 })+2) {
							
							s[6] = 'a' + i7;
							if (n == 7) {
								cout << s << en;
								continue;
							}

							REP(i8, max({ i2,i3,i4,i5,i6,i7 }) + 2) {
								s[7] = 'a' + i8;
								if (n == 8) {
									cout << s << en;
									continue;
								}
								REP(i9, max({ i2,i3,i4,i5,i6,i7,i8 }) + 2) {
									s[8] = 'a' + i9;

									if (n == 9) {
										cout << s << en;
										continue;
									}
									REP(i10, max({ i2,i3,i4,i5,i6,i7,i8,i9 }) + 2) {
										s[9] = 'a' + i10;
										if (n == 10) {
											cout << s << en;
											continue;
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 1536
X = int(input())

if X//1800>=1:
    print(1)
    exit()
elif X//1600>=1:
    print(2)
    exit()
elif X//1400>=1:
    print(3)
    exit()
elif X//1200>=1:
    print(4)
    exit()
elif X//1000>=1:
    print(5)
    exit()
elif X//800>=1:
    print(6)
    exit()
elif X//600>=1:
    print(7)
    exit()
elif X//400>=1:
    print(8)
    exit()

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false;}
const ll INF = 1e18;

ll n, res, xbit, ybit, cnt; 
V<> x(15), y(15), p(15), ans(16, INF), xp, yp;
VV<> xans(100000, V<>(15)), yans(100000, V<>(15));

void solve(string s){
    xp.clear(); yp.clear();
    res = xbit = ybit = cnt = 0;
    REP(i, n){
        if(s[i] == '1'){
            xp.pb(x[i]);
            xbit += (1 << i);
            cnt++;
        }
        if(s[i] == '2'){
            yp.pb(y[i]);
            ybit += (1 << i);
            cnt++;
        }
    }
    if(cnt > n) return;
    REP(i, n) if(s[i] == '0') res += min(xans[xbit][i], yans[ybit][i]);
    chmin(ans[cnt], res);
}

void dfs(string s){
    if(SZ(s) == n){
        solve(s);
        return;
    }
    dfs(s + "0");
    dfs(s + "1");
    dfs(s + "2");
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    REP(i, n) cin >> x[i] >> y[i] >> p[i];
    
    //前準備(計算量Ο(2^N * NlogN)なはず？)
    REP(bit, (1 << n)){
        V<> t, u;
        REP(i, n) if((bit >> i) & 1){
            t.pb(x[i]);
            u.pb(y[i]);
        }
        t.pb(INF); t.pb(-INF); t.pb(0);
        u.pb(INF); u.pb(-INF); u.pb(0);
        sort(all(t)); sort(all(u));
        REP(i, n){
            auto itr0 = lower_bound(all(t),x[i]);
            auto itr1 = itr0; itr1--;
            xans[bit][i] = min(*itr0 - x[i], x[i] - *itr1) * p[i];
            itr0 = lower_bound(all(u), y[i]);
            itr1 = itr0; itr1--;
            yans[bit][i] = min(*itr0 - y[i], y[i] - *itr1) * p[i];
        }
    }
    //end

    //全探索(計算量Ο(3^N*N)なはず？)
    dfs("");
    //end

    REP(i, n + 1) cout << ans[i] << '\n';
}

Measured memory_bytes: 32968
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <iostream>
using namespace std;

int main (){
    int n;
    int data[50][26];
    int result[26];
    string c;
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        
        for (int j = 0; j < 26; j++)
            data[i][j] = 0;
        for (int j = 0; j < s.size(); j++) {
            data[i][s[j] - 'a']++;
        }
    }
    
    for (int i = 0; i < 26; i++) {
        int minimal = 999999;
        for (int j = 0; j < n; j++) {
            if (data[j][i] < minimal)
                minimal = data[j][i];
        }
        result[i] = minimal;
        while (result[i] > 0) {
            c += ('a' + i);
            result[i]--;
        }
    }
    cout << c;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


#define MOD 1000000007


int n, m;
int a[100000];

int dp[100002];

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

	cin >> n >> m;
	rep(i, m)cin >> a[i];


	dp[0] = 1;
	rep(i,n) if(dp[i]){
		if (!binary_search(a,a+m, i+1)) {
			(dp[i + 1] += dp[i]) %= MOD;
		}
		if (!binary_search(a, a + m, i + 2)) {
			(dp[i + 2] += dp[i]) %= MOD;
		}
	}
	cout << dp[n] << endl;



	return 0;
}

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

namespace ConsoleApp36 {
    class Program {
        static void Main(string[] args) {
            string S = Console.ReadLine();

            char[] st = new char[3];

            st[0] = S[0];
            st[1] = S[1];
            st[2] = S[2];

            if (st.Contains('a') && st.Contains('b') && st.Contains('c')) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 11220
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		new Main().start();
	}
	boolean[] b;
	Queue<String> sq = new LinkedList<String>();
	Queue<String> eq = new LinkedList<String>();
	void start(){
		Scanner in = new Scanner(System.in);
		while(true){
			String s = in.next();
			if(s.charAt(0) == '#')break;
			b = new boolean[26];
			count = 0;
			flag = false;
			sq = new LinkedList<String>();
			eq = new LinkedList<String>();
			tansaku(s,"",0);
			if(!flag){
				System.out.println(count);
				print();
			}
			else System.out.println(0);
		}
		in.close();
	}
	int count = 0;
	boolean flag = false;
	void tansaku(String s, String result, int i){
		if(flag){
			return;
		}
		if(s.length() == i){
			count++;
			if(sq.size() >= 5){
				if(eq.size() >= 5){
					eq.poll();
					eq.offer(result);
				}else{
					eq.offer(result);
				}
			}else{
				sq.offer(result);
			}
			return;
		}
		char c = s.charAt(i);
		if(c == 'a'){
			result += c;
			tansaku(s,result,i+1);
			result = trim(result);
			if(!b[1]){
				b[1] = true;	//?????????????????????????????????
				result += (char)(c+1);
				tansaku(s,result,i+1);
				result = trim(result);
				b[1] = false;	//??????????????????????????????
			}
		}
		else if(c == 'z'){
			if(!b[25]){	//z????????????????????????????????????z?????????????????????????????¨?????????
				flag = true;
				return;
			}
			result += c;
			tansaku(s,result,i+1);
		}
		else if(!b[c-'a']){
			if(b[c-'a'+1]){	//
				flag = false;
				return;
			}
			b[c-'a'+1] = true;
			result += (char)(c+1);
			tansaku(s,result,i+1);
			b[c-'a'+1] = false;
		}
		else{
			result += c;
			tansaku(s,result,i+1);
			result = trim(result);

			if(b[c-'a'+1]){	//
				flag = false;
				return;
			}
			b[c-'a'+1] = true;
			result += (char)(c+1);
			tansaku(s,result,i+1);
			result = trim(result);
			b[c-'a' + 1] = false;
		}
	}
	void print(){
		while(!sq.isEmpty()){
			System.out.println(sq.poll());
		}
		while(!eq.isEmpty()){
			System.out.println(eq.poll());
		}
	}
	String trim(String s){
		return s.substring(0,s.length()-1);
	}
	int getCount(int[]a){
		int count = 1;
		for(int aa : a){
			if(aa != 0)count *= kaijou(a[aa]);
		}
		return count;
	}
	int kaijou(int a){
		int b = 1;
		for(int i = 1; i <= a; i++){
			b += i;
		}
		return b;
	}

}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
char mp[525][525];
const char BLACK = '#', WHITE = '.';

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%s",mp[i]);
  // all white
  int bl = 0;
  REP(i,n)REP(j,n)if(mp[i][j]==BLACK)bl++;
  if(bl==0){
    puts("-1");
    return 0;
  }
  // full cols
  int fulcol = 0;
  REP(j,n){
    bool ok = true;
    REP(i,n)if(mp[i][j]==WHITE)ok=false;
    if(ok)fulcol++;
  }
  if(fulcol==n){
    puts("0");
    return 0;
  }
  int ans = 1252183025;
  // target row
  REP(r,n){
    // rest
    int rest = 0;
    REP(j,n)if(mp[r][j]==WHITE)rest++;
    // collective col
    bool exist = false;
    REP(i,n)if(mp[i][r]==BLACK)exist=true;
    if(!exist){
      // catch up
      rest++;
    }
    CHMIN(ans,rest+n-fulcol);
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define MOD 1000000007

int main() {
  int n, k;
  cin >> n >> k;

  vi a(n);
  rep(i, n) {
    cin >> a[i];
  }

  int before_index = -1 * k;
  rep(i, n) {
    if (before_index >= 0) {
      if (a[i] > a[before_index]) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
    before_index++;
  }

}


Measured memory_bytes: 4032
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  ll ans=0;
  ll A[1000100]={0};
  for(int i=1;i<=N;i++){
    cin >> A[i];
  }
  for(int i=1;i<=N;i++){
    if(A[i]%2==1 && A[i+1]>0){
      A[i]--;
      A[i+1]--;
      ans++;
    }
    ans+=A[i]/2;
  }
  cout << ans << endl;
  return 0;
}
// AGC003_考え方

Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a,b,x,count =0;
		int []result = new int[200];
		for(int i = 0;;i++){
			if(sc.hasNext() == false) break;
			a = sc.nextInt();
			b = sc.nextInt();
			x = a + b;
			for(int j = 1;;j++){
				if(x >= 10){
					x = x/10;
				} else {
					result[i] = j;
					count++;
					break;
				}
			}
		}
		for(int i = 0; i < count; i++){
			System.out.println(result[i]);
		}
	}
}

Measured memory_bytes: 26472
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =9223372036854775807;//64bit 9*1e+17
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
  int R,G;
  cin>>R>>G;
  print(G*2-R);
  return 0;
}


Measured memory_bytes: 256
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.io.*;
import java.util.*;
public class Main
{
    public static double func(double p [], int n , int tail,int curr,double dp[][])
    {
        
        
        
        if((n-tail)<=tail)
        {
            return 0.0;
        }
        
        if(curr>=n)
        {
            
            return 1.0;
            
        }
        if(dp[curr][n-tail-1]>-1.0)return dp[curr][n-tail-1];
        return dp[curr][n-tail-1]=p[curr]*func(p,n,tail,curr+1,dp)+(1.0-p[curr])*func(p,n,tail+1,curr+1,dp);
      
    }
    
    
	public static void main(String[] args) throws Exception {
	
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		String ss[]=(br.readLine()).split(" ");
		
		double p[]=new double [n];
		for (int i=0;i<n;i++)
		{
		    p[i]=Double.parseDouble(ss[i]);
		    
		}
	    double dp[][]=new double[n][n];
	    for(double row[]:dp)
	    Arrays.fill(row,-1.0);
	    
		double ans1=func(p,n,0,0,dp);
		System.out.println(ans1);
		
		
		
		
	}
}


Measured memory_bytes: 98192
import java.io.*;
import java.util.*;
import java.lang.*;
 
public class Main {
	
	public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      int A =  scan.nextInt();
      int B =  scan.nextInt();
      int T =  scan.nextInt();
      int i = 0, count = 0;;
      while (i+A <= (T+0.5))
      {
        count++;
         i += A;
      }
      System.out.println(B*count);
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;

int n,m;
string s;
                   
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  int a,b;cin>>a>>b;
  cout<<2*b-a<<endl;
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

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

int main()
{
	int a;
	cin>>a;
	a=a%10;
	if(a==2||a==4||a==5||a==7||a==9)
	    cout<<"hon"<<endl;
	else if(a==0||a==1||a==6||a==8)
	    cout<<"pon"<<endl;
	else
	    cout<<"bon"<<endl;
	return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define forn(i, s, f) for (int i = s; i < f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

struct SegTree{
private: 
    int n;
    vector <int> tr, to_add;

    int merge(int a, int b) {
        return min(a, b);
    }

    void build(int v, int vl, int vr, const vector <int>& a) {
        if (vr - vl == 1) {
            tr[v] = a[vl];
            return;
        }
        int vm = vl + vr >> 1;
        build(2 * v, vl, vm, a), build(2 * v + 1, vm, vr, a);
        tr[v] = merge(tr[2 * v], tr[2 * v + 1]);
    }

    void push(int v, int vl, int vr) {
        if (vr - vl != 1) {
            to_add[2 * v] = min(to_add[2 * v], to_add[v]);
            to_add[2 * v + 1] = min(to_add[2 * v + 1], to_add[v]);
        }
        tr[v] = min(tr[v], to_add[v]);
        to_add[v] = INT_MAX;
    }

    void upd(int v, int vl, int vr, int l, int r, int x) {
        push(v, vl, vr);
        if (vr <= l || r <= vl) 
            return;
        if (l <= vl && vr <= r) {
            to_add[v] = min(to_add[v], x);
            push(v, vl, vr);
            return;
        }
        int vm = vl + vr >> 1;
        upd(2 * v, vl, vm, l, r, x), upd(2 * v + 1, vm, vr, l, r, x);
        tr[v] = merge(tr[2 * v], tr[2 * v + 1]);
    }

    int get(int v, int vl, int vr, int l, int r) {
        push(v, vl, vr);
        if (vr <= l || r <= vl)
            return INT_MAX;
        if (l <= vl && vr <= r)
            return tr[v];
        int vm = vl + vr >> 1;
        return merge(get(2 * v, vl, vm, l, r), get(2 * v + 1, vm, vr, l, r));
    }
public: 
    SegTree(const vector <int>& a) {
        n = sz(a);
        tr.resize(4 * n), to_add.resize(4 * n, INT_MAX);
        build(1, 0, n, a);
    }

    void upd(int l, int r, int x) {
        upd(1, 0, n, l, r, x);
    }

    int get(int l, int r) {
        return get(1, 0, n, l, r);
    }
};

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector <vector <int>> a(n, vector <int> (3));
    forn (i, 0, n) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
        a[i][0] -= a[i][2], a[i][1] -= a[i][2];
    }
    vector <int> b(q);
    forn (i, 0, q)
        cin >> b[i];
    SegTree tr(vector <int> (q, INT_MAX));
    forn (i, 0, n) {
        a[i][0] = lower_bound(all(b), a[i][0]) - b.begin();
        a[i][1] = --lower_bound(all(b), a[i][1]) - b.begin();
        //cout << a[i][0] << " " << a[i][1] << " " << a[i][2] << "\n";
        tr.upd(a[i][0], a[i][1] + 1, a[i][2]);
    }
    forn (i, 0, q) {
        int t = tr.get(i, i + 1);
        if (t == INT_MAX)
            cout << -1;
        else 
            cout << t;
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 19824
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, m; cin >> n >> m;

	int k = (n / 2);
	int l = k + 1;

	FOR_LT(i, 0, m) {
		cout << k << " " << l << endl;
		if ((l - k + 1) * 2 == n || (l - k + 2) * 2 == n) l++;
		k--;
		l++;
	}

	return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int n;
string s,t;

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

  cin>>s>>t;
  int cnt=0;
  rep(i,3)if(s[i]==t[i])cnt++;
  cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int n,s,x[100000],i,gcd,a,b,d;
  cin >> n >> s >> x[0];
  gcd=s-x[0];
  if (gcd<0) gcd*=-1;
  for (i=1;i<n;i++){
    cin >> x[i];
    if (gcd>x[i]-x[i-1]){
      a=gcd;
      b=x[i]-x[i-1];
      if (b<0) b*=-1;
    }else{
      a=x[i]-x[i-1];
      b=gcd;
      if (a<0) a*=-1;
    }
    while (b!=1&&a%b){
      d=a%b;
      a=b;
      b=d;
    }
    gcd=b;
  }
  cout << gcd << endl;
  return 0;
}

Measured memory_bytes: 640
import fileinput

for line in fileinput.input():
    tokens = list(map(int, line.strip().split()))
    a, b = tokens[0], tokens[1]

#data = input().split()
#a, b = data[0], data[1]

if a < b:
    print("a < b")
elif a > b:
    print("a > b")
elif a == b:
    print("a == b")

Measured memory_bytes: 7704
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/04/04.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC129
//
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
 const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__


void solve(void){
  
  int N;
    
  cin >> N;
  
  vector<int> W(N);
  vector<int> S(N);  // sum until W[i]
  
  REP(i,N){
    cin >> W[i];
    if(i==0){
      S[0]=W[0];
    }else{
      S[i]=S[i-1]+W[i];
    }
  }
  
  int ans=INF;
  REP(i,N){
    chmin(ans, abs(S[i]-(S[N-1]-S[i])));
  }
  cout << ans << endl;
 
  return;
}

#define TESTCASES 1

int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}



Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,m = readInts()

if n*2<m:
	ans = n
	m-=n*2
	ans+=m//4
else:
	ans = m//2

print(ans)

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

using namespace std;

int main (void) {
    int N, H;
    cin >> N >> H;
    int a_max = 0;
    vector<int> a(N), b(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> a.at(i);
        cin >> b.at(i);
        if ( a.at(i) > a_max )
            a_max = a.at(i);
    }

    sort(b.begin(), b.end(), greater<int>());

    int rest_hp = H;
    int ans = 0;
    for ( int i = 0; i < N; i++ ) {
        if ( b.at(i) < a_max )
            break;
        if ( rest_hp <= 0 )
            goto END;
        rest_hp -= b.at(i);
        ans++;
    }

    while ( rest_hp > 0 ) {
        rest_hp -= a_max;
        ans++;
    }

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


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;



int main(){
    int n;
    cin>>n;
    int a[n];
    int sum=0;
    pan(i,n) {
        cin>>a[i];
        sum+=a[i];
    }
    sort(a,a+n);
    // int p=(a[n-1]+a[0])/2 -9 ;
    int p=ceil(sum/n);
    // cout<<p<<endl;
    int ans=999999;
    int temp=0;
    for(int i=a[0];i<=a[n-1];i++){
        for(int j=0;j<n;j++){
            temp+=(a[j]-i)*(a[j]-i);;
        }
        ans=min(ans,temp);
        temp=0;
        // cout<<ans<<endl;
    }
    /*pan(i,n){
        // cout<<a[i]<<"-";
        // cout<<(a[i]-p)*(a[i]-p)<<endl;
        ans+=(a[i]-p)*(a[i]-p);
    }*/
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007


int main() {
	
string S;
ll N,Q;
cin>>N>>Q;
cin>>S;
int SUM[102000];
SUM[0]=0;
fyg(N,1){
	if(S.at(y)=='C'){
		if(S.at(y-1)=='A'){
			SUM[y]=SUM[y-1]+1;
		}else{
			SUM[y]=SUM[y-1];
		}
	}else{
		SUM[y]=SUM[y-1];
	}
}


fx(Q){
	int l,r;
	cin>>l>>r;
	ce(SUM[r-1]-SUM[l-1])
	
}
	
	

}

Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

signed main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  ll b = 0;
  REP(i, n) {
    b += (i % 2 == 0) ? a[i]: -a[i];
  }
  cout << b << " ";
  REP(i, n-1) {
    cout << 2 * a[i%n] - b << " ";
    b = 2 * a[i%n] - b;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 2176
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        String s = sc.next();

        int ans = 0;
        int lr = 0, rl = 0;
        for (int i = 0; i < n - 1; i++) {
            if (s.charAt(i) == s.charAt(i + 1) && s.charAt(i) == 'R') {
                ans++;
            }
            if (s.charAt(n - i - 1) == s.charAt(n - i - 2) && s.charAt(n - i - 1) == 'L') {
                ans++;
            }
            if (s.charAt(i) != s.charAt(i + 1) && s.charAt(i) == 'R') {
                rl++;
            } else if (s.charAt(i) != s.charAt(i + 1) && s.charAt(i) == 'L') {
                lr++;
            }
        }
        ans += 2 * Math.min(Math.min(lr, rl), k);
        if (lr != rl && Math.min(lr, rl) < k) ans++;
        System.out.println(ans);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }

}


Measured memory_bytes: 25684
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n, m;
    cin >> n;
    map<string, int> t;
    rep(i, n){
        string s;
        cin >> s;
        t[s]++;
    }
    cin >> m;
    rep(i, m){
        string s;
        cin >> s;
        t[s]--;
    }
    int ans = 0;
    repi(i, t){
        ans = max(ans, i->second);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
diff = [A[i + 1] - A[i] for i in range(N + 1)]
ans = sum([abs(diff[i]) for i in range(N + 1)])
for i in range(N):
    if diff[i] * diff[i + 1] < 0:
        print(ans - 2 * min(abs(diff[i]), abs(diff[i + 1])))
    else:
        print(ans)

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

main(){
	int n ;
	string s ;
	char c[] = {'H','o','s','h','i','n','o'} ;
	
	cin >> n ;
	for( int k=0 ; k<=n ; k++ ){
		getline( cin , s ) ;
		
		for( int i=0 ; i<s.size() ; i++ ){
			int cnt = 0 ;
			if( s[i] == 'H' ){
				for( int j=0 ; j<s.size() && j<7 ; j++ ){
					if( s[i+j] == c[j] ) cnt++ ;
					else break ;
				}
				if( cnt==7 ) s[i+6] = 'a' ;
			}
		}
		
		if( k ) cout << s << endl ;
	}
}

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

int main(){
    int n;
    cin>>n;
    map<int,int>mp;
    rep(i,n){
        int a; cin>>a;
        mp[a]++;
    }
    int q;
    cin>>q;
    ll ans=0;
    for(auto&p:mp){
        ans+=(ll)p.first*p.second;
    }
    rep(i,q){
        int b,c; cin>>b>>c;
        int x=mp[b];
        ans-=(ll)b*mp[b];
        mp[b]=0;
        mp[c]+=x;
        ans+=(ll)c*x;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 8056
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main(void) {
    
    
    int n;
    cin>>n;
    if(n/10==9||n%10==9)fin("Yes");
    else fin("No");
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <sstream>
using namespace std;

int a[4];
bool used[4];
string ans;

string toStr(int x) {
    stringstream ss;
    ss << x;
    return ss.str();
}

void dfs(int res, string s) {
    bool last = true;
    for (int i=0; i<4; ++i) {
        if (used[i]) continue;
        used[i] = true;
        dfs(res + a[i], "(" + s + " + " + toStr(a[i]) + ")");
        dfs(res - a[i], "(" + s + " - " + toStr(a[i]) + ")");
        dfs(res * a[i], "(" + s + " * " + toStr(a[i]) + ")");
        for (int j=i+1; j<4; ++j) {
            if (used[j]) continue;
            used[j] = true;
            dfs(res + (a[i] + a[j]), "(" + s + " + (" + toStr(a[i]) + " + " + toStr(a[j]) + "))");
            dfs(res + (a[i] - a[j]), "(" + s + " + (" + toStr(a[i]) + " - " + toStr(a[j]) + "))");
            dfs(res + (a[i] * a[j]), "(" + s + " + (" + toStr(a[i]) + " * " + toStr(a[j]) + "))");
            dfs(res - (a[i] + a[j]), "(" + s + " - (" + toStr(a[i]) + " + " + toStr(a[j]) + "))");
            dfs(res - (a[i] - a[j]), "(" + s + " - (" + toStr(a[i]) + " - " + toStr(a[j]) + "))");
            dfs(res - (a[i] * a[j]), "(" + s + " - (" + toStr(a[i]) + " * " + toStr(a[j]) + "))");
            dfs(res * (a[i] + a[j]), "(" + s + " * (" + toStr(a[i]) + " + " + toStr(a[j]) + "))");
            dfs(res * (a[i] - a[j]), "(" + s + " * (" + toStr(a[i]) + " - " + toStr(a[j]) + "))");
            dfs(res * (a[i] * a[j]), "(" + s + " * (" + toStr(a[i]) + " * " + toStr(a[j]) + "))");
            used[j] = false;
        }
        used[i] = false;
        last = false;
    }
    if (last && res == 10) {
        ans = s;
    }
}

int main() {
    while (cin >> a[0] >> a[1] >> a[2] >> a[3], (a[0] || a[1] || a[2] || a[3])) {
        ans = "0";
        memset(used, false, sizeof used);
        for (int i=0; i<4; ++i) {
            used[i] = true;
            dfs(a[i], toStr(a[i]));
            used[i] = false;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1244
n = int(input())
ar = list(map(int,input().split()))
if 0 in ar:
    print(0)
else:
    ans=1
    for i in ar:
        ans*=i
        if ans>1e18:
            break
    if ans>1e18:
        print(-1)
    else:
        print(ans)

Measured memory_bytes: 21796
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

vector<int> bfs(int n, int s, vector<vector<int>> &g) {
    vector<int> color(n, 0);
    queue<pair<int, int>> que;
    vector<int> ret;
    que.push(make_pair(s, 1));
    color[s] = 1;
    while(1) {
        if (que.empty()) break;
        pair<int, int> now = que.front();
        que.pop();
        for (auto v: g[now.first]) {
            //cout << now.first << " " << v << endl;
            if (color[v] == 0) {
                color[v] = -color[now.first];
                que.push(make_pair(v, now.second+1));
                ret.push_back(now.second+1);
            }
            if (color[v] != -color[now.first]) {
                //cout << "test" << endl;
                ret.clear();
                return ret;
            }
        } 
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    rep(i, n) rep(j, n) {
        char c;
        cin >> c;
        if (c == '1') {
            g[i].push_back(j);
        }
    }
    //cout << "test" << endl;
    ll ans = -1;
    rep(i, n) {
        //cout << i << endl;
        auto v = bfs(n, i, g);
        //for (auto vv: v) {
        //    cout << vv << endl;
        //}
        if (!v.empty()) {
            ans = max(ans, (ll)*max_element(v.begin(), v.end()));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <string>

int main(){
    std::string a, ans;

    // 入力
    std::cin >> a;

    for(int i=0; i<a.length(); i++){
        a.replace(i, 1, "x");
    }

    std::cout << a << std::endl;

    return 0;
}

Measured memory_bytes: 256
use std::collections::BTreeMap;

const MOD: usize = 1e9 as usize + 7;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n = sc.read();
    let c: Vec<usize> = sc.vec(n);

    let mut map = BTreeMap::new();
    for i in 0..n {
        map.entry(c[i]).or_insert(Vec::new()).push(i);
    }
    let mut next = vec![0; n];

    for (_, v) in map.iter() {
        for i in 0..v.len() {
            let from = v[i];
            let to = if i + 1 >= v.len() { n } else { v[i + 1] };
            next[from] = to;
        }
    }

    let mut dp = vec![0; n + 1];
    dp[0] = 1;
    for i in 0..n {
        if next[i] < n && next[i] != i + 1 {
            dp[next[i]] += dp[i];
            dp[next[i]] %= MOD;
        }
        dp[i + 1] += dp[i];
        dp[i + 1] %= MOD;
    }
    println!("{}", dp[n]);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 26876
macro_rules! input {
    ($x:expr) => {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        $x = buf.trim().parse().unwrap();
    };

    ($x:expr, $($y:expr), +) => {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).ok();
        input_iter!(buf.split_whitespace(), $x, $($y), +);
    };

    ($v:expr; $size:expr) => {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).ok();
        for v in buf.split_whitespace() {
            $v.push(v.parse().unwrap());
        }
    };

    ($v:expr; $h_size:expr, $w_size:expr) => {
        for _ in 0..$h_size {
            let mut part_vec = Vec::new();
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).ok();
            for v in buf.split_whitespace() {
                part_vec.push(v.parse().unwrap());
            }
            $v.push(part_vec);
        }
    };
}

#[allow(unused_macros)]
macro_rules! input_iter {
    ($iter:expr, $x:expr) => {
        $x = $iter.next().unwrap().parse().unwrap();
    };

    ($iter:expr, $x:expr, $($y:expr), +) => {
        let mut iter = $iter;
        $x = iter.next().unwrap().parse().unwrap();
        input_iter!(iter, $($y), *);
    };
}

fn main() {
    let _n: i32;
    input!(_n);
    let mut v: Vec<i32> = Vec::new();
    input!(v; _n);
    v.sort();
    let mut cur: f32 = -1.0;
    for _v in v {
        if cur < 0.0 {
            cur = _v as f32;
            continue;
        }
        cur = (cur + _v as f32)/2.0;
    }
    print!("{}", cur);
}


Measured memory_bytes: 4352
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
def pin(type=int):
    return map(type,input().split())
"""    
入力は以下の形式で標準入力から与えられる。

N  #これいるかなぁ
x1　y1 N=0として。
xN　yN
"""
a,b= pin(str)
StrA = a*int(b)
StrB = b*int(a)
if StrA >= StrB:
    print(StrB)
else:
    print(StrA)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;

    int q,serial[100005],ar[100005];
    cin>>q;
    for(int i=1;i<=q;i++){
        cin>>serial[i];
    }
    for(int i=1;i<=n;i++){
        ar[i] = k;
        ar[i] = ar[i] - q;
    }
    for(int i =1;i<=q;i++){
            int p = serial[i];
        ar[p] = ar[p] +1;
    }

    for(int i=1;i<=n;i++){
        if(ar[i] > 0){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }

}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main () {
	int w,h,x,y,r;
	cin >> w >> h >> x >> y >> r;
	if (x<=w-r&&x>=0+r) {
		if (y<=h-r&&y>=0+r) {
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
	}else {
		cout << "No" << endl;
	}
	
	}



Measured memory_bytes: 3108
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    N %= 10;
    if(N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
        cout << "hon" << endl;
    } else if(N == 0 || N == 1 || N == 6 || N == 8) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	cout << "a ";
	if(a<b) cout << "< ";
	if(a==b) cout << "== ";
	if(a>b) cout << "> ";
	cout << "b" << endl;
	
	
	return 0;
}



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

using namespace std;

using ll = long long;

inline ll cube(ll n) { return n * n * n; }

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

    ll n, k;

    cin >> n >> k;
    if (k % 2 == 1)
        cout << cube(n / k) << endl;
    else
        cout << cube(n / k) +  cube((2.0 * n / k - 1.0) / 2.0 + 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int n;
  long int p=1;
  long int a=1000000007;
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    p=(p*i)%a;
  }

   printf("%lld",p);
return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int S, W;
  cin >> S >> W;

  if (W >= S)
    cout << "unsafe" << endl;
  else
    cout << "safe" << endl;

  return 0;
}


Measured memory_bytes: 3644
#include<iostream>
using namespace std;

int main() {
  int A,B,C;
  cin>>A>>B>>C;
  if(A==5&&B==5&&C==7||A==5&&B==7&&C==5||A==7&&B==5&&C==5)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int A = K + (K*K) + (K*K*K) ;
		
		System.out.println(A);
   
        }
	}
 


Measured memory_bytes: 35820