akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
typedef pair<ll,ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}


int main(){
    init();

    int n;  cin >> n;
    cout << n * (n + 1) / 2;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        k: usize,
        css: [proconio::marker::Chars; h],
    }
    let mut count = 0usize;
    for i in 0..=(1 << h) - 1 {
        for j in 0..=(1 << w) - 1 {
            let mut num = 0;
            for ii in 0..h {
                if ((1 << ii) & i) != 0 {
                    for jj in 0..w {
                        if ((1 << jj) & j) != 0 {
                            if css[ii][jj] == '#' {
                                num += 1;
                            }
                        }
                    }
                }
            }
            if num == k {
                count += 1;
            }
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

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

    int INF = 1<<30;
    vector<int> dp(N+1, INF);
    dp[0] = 0;
    for(int i=0; i<N; i++)
    {
        chmin(dp[i+1], dp[i]+1);
        for(int j=6; i+j<=N; j*=6)
        {
            chmin(dp[i+j], dp[i]+1);
        }
        for(int j=9; i+j<=N; j*=9)
        {
            chmin(dp[i+j], dp[i]+1);
        }
    }
    cout << dp[N] << endl;

    return 0;
}


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

using namespace std;

const int N = 200000 + 7;
const int MOD = 1000000000 + 7;

typedef long long ll;

ll f[N], finv[N], inv[N];

ll modinv(ll a) {
  ll b = MOD, x = 1, y = 0;
  //ax + by = 1 (mod MOD)
  //->find x
  while(b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    x -= t * y; swap(x, y);
  }
  x += MOD;
  x %= MOD;
  return x;
}

ll add(ll x, ll y) {
  x %= MOD;
  y %= MOD;
  return (x + y) % MOD;
}

ll sub(ll x, ll y) {
  x %= MOD;
  y %= MOD;
  x += MOD;
  return (x - y) % MOD;
}

ll mul(ll x, ll y) {
  x %= MOD;
  y %= MOD;
  return (x * y) % MOD;
}

ll bigdiv(ll x, ll y) {
  return mul(x, modinv(y));
}

void Cinit() {
  f[0] = 1; f[1] = 1;
  finv[0] = 1; finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < N; ++i) {
    f[i] = mul(f[i - 1], i);
    inv[i] = sub(MOD, mul(inv[MOD % i], MOD / i));
    finv[i] = mul(finv[i - 1], inv[i]);
  }
}

ll C(ll n, ll k) {
  if(n < k || n < 0 || k < 0) return 0;
  return mul(f[n], mul(finv[k], finv[n - k]));
}

int n;
int a[N];
bool sum[N];
bool box[N];

vector<int> factor(int n) {
  vector<int> f; f.clear();
  for(int i = 1; i * i <= n; ++i) {
    if(n % i == 0) {
      f.push_back(i);
      if(i * i < n) f.push_back(n / i);
    }
  }
  return f;
}

void change(int k) {
  vector<int> f = factor(k);
  for(int x: f) {
    //cout << x << " ";
    sum[x] = !sum[x];
  }
  //cout << endl;
}

int main() {
  //Cinit();

  scanf("%d", &n);

  for(int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }

  for(int i = n; i >= 1; --i) {
    if(a[i] == 1 && !sum[i]) {
      box[i] = true;
      change(i);
    } else if(a[i] == 0 && sum[i]) {
      box[i] = true;
      change(i);
    }
  }

  int ans = 0;
  for(int i = 1; i <= n; ++i) {
    if(box[i]) ++ans;
  }

  printf("%d\n", ans);
  bool stat = false;
  for(int i = 1; i <= n; ++i) {
    if(box[i]) {
      if(stat) printf(" ");
      printf("%d", i);
      stat = true;
    }
  }
  if(ans > 0) printf("\n");

  return 0;
}


Measured memory_bytes: 2176
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
const int N = 1e5 + 5;
struct node{
    int flag,num,ii,mm;
};
node a1[N],a2[N],vis[N]={0};
int cmp(node x,node y){
    if(x.flag!=y.flag) return x.flag<y.flag;
    return x.num<y.num;
}
int cmp1(node x,node y){
    return x.ii<y.ii;
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d %d",&a1[i].flag,&a1[i].num);
        a2[i].ii=i;
        a2[i].flag=a1[i].flag;
        a2[i].num=a1[i].num;
    }
    sort(a2+1,a2+m+1,cmp);
    int f=a2[1].flag,ans=1;
    for(int i=1;i<=m;i++){
        if(f==a2[i].flag){
            a2[i].mm=ans++;
        }
        else{
            f=a2[i].flag;
            ans=1;
            a2[i].mm=ans++;

        }
    }
    sort(a2+1,a2+1+m,cmp1);
    for(int i=1;i<=m;i++){
        printf("%06d%06d\n",a2[i].flag,a2[i].mm);
    }
    return 0;
}
/*
2 4
2 3
3 4
2 1
3 5
*/


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  char c;
  R c;
  c++;
  pr(c);
}

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


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

struct edge{
	int a;
	int b;
}edg[5000];

int main()
{
	int n,m;
	cin>>n>>m;
	
	int a[100],b[100],flag[100][100],dis[100][100];
	for (int i=0;i<100;i++) for (int j=0;j<100;j++) {
		flag[i][j]=0;
		dis[i][j]=1000000;
	}
	
	for (int i=1;i<=m;i++)
	{
		cin>>a[i]>>b[i];
		dis[a[i]][b[i]]=1;
		dis[b[i]][a[i]]=1;	
		
	}
	int ans=0;
	for (int u=1;u<=m;u++)
	{
		for (int i=0;i<100;i++) for (int j=0;j<100;j++) {
			dis[i][j]=1000000;
		}
		
		for (int i=1;i<=m;i++)
		{	
			dis[a[i]][b[i]]=1;
			dis[b[i]][a[i]]=1;		
		}
		
		dis[a[u]][b[u]]=1000000;
		dis[b[u]][a[u]]=1000000;
		
		for (int k=1;k<=n;k++)
			for (int i=1;i<=n;i++)
		  		for (int j=1;j<=n;j++)
		    	{
		    		if (k!=i&&i!=j&&j!=k&& (dis[i][k]+dis[k][j]<dis[i][j]) )
		    		{
		    			dis[i][j]=dis[i][k]+dis[k][j];
					}
		    	
				}
		
		if (dis[a[u]][b[u]]==1000000) ans++;
		
	//	cout<<"a="<<a[u]<<" b="<<b[u]<<" dis="<<dis[a[u]][b[u]]<<endl;
		
		dis[a[u]][b[u]]=1;
		dis[b[u]][a[u]]=1;	
		
		
	}
	
	cout<<ans;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = ll(1e18) + 1;

int main() {
  // 二分探索、マイナスの値の時は順番が入れ替わる
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());
  ll ok = INF; ll ng = -INF;
  while (abs(ng - ok) > 1) {
    ll mid = (ok + ng) / 2;
    bool bl = [&] {
      // 積がmid以下となる数がK個以上でtrueを返す
      ll cnt = 0;
      for (ll a : A){
        if (a<0){
          int left = -1, right = N; // right がok
          while (left+1<right) {
            int center = (left+right) / 2;
            if (A[center] * a <= mid) {
              right = center;
            } else {
              left = center;
            }
          }
          cnt += (N - right);
        } else if (a==0){
          if (mid >= 0) cnt += N;
          else continue;
        } else {
          int left = -1, right = N; // left がok
          while (left+1<right) {
            int center = (left+right) / 2;
            if (A[center] * a <= mid) {
              left = center;
            } else {
              right = center;
            }
          }
          cnt += right;
        }
      }
      for (ll a : A) {
        if (a * a <= mid) {
          cnt--;
        }
      }
      cnt /= 2;
      return cnt >= K;
    }();
    if (bl) ok = mid;
    else ng = mid;
  }
  cout << ok << '\n';
  return 0;
}
// 15

Measured memory_bytes: 4816
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int N;
int L[2009];
bool check(int a, int b, int c) {
	bool flag = true;
	if (a >= b + c) flag = false;
	if (b >= a + c) flag = false;
	if (c >= a + b) flag = false;
	return flag;
}

int solv(int posa, int posb) {
	if (posb == N-1) return 0;
	else {
		int left = posb;
		int right = N;
		while (left + 1 != right) {
			int mid = (left + right) / 2;
			if (check(L[posa], L[posb], L[mid])) left = mid;
			else right = mid;
		}
		return left - posb;
	}
}

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

	cin >> N;
	for (int i = 0; i < N; i++) cin >> L[i];
	sort(L, L + N);

	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			ans += solv(i, j);
		}
	}
	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
int seen[101][101][4];
char mp[101][101];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {-1, 0, 1, 0};

int main() {
    int h,w;
    ll l;
    string s;
    while(cin>>h>>w>>l, h|w|l) {
        int sx,sy,dir;
        for(int i=0;i<h; ++i) {
            cin>>s;
            for(int j=0; j<w; ++j) {
                mp[i][j] = s[j];
                switch(mp[i][j]) {
                case 'N':
                    sx = j,sy = i,dir = 0;
                    break;
                case 'W':
                    sx = j,sy = i,dir = 3;
                    break;
                case 'S':
                    sx = j,sy = i,dir = 2;
                    break;
                case 'E':
                    sx = j,sy = i,dir = 1;
                    break;
                }

                if(mp[i][j] != '.' && mp[i][j] != '#') mp[i][j] = '.';
            }
        }

        memset(seen, -1, sizeof(seen));
        seen[sy][sx][dir] = 0;

        int ax = -1,ay = -1,ad = -1;
        while(l) {
            int nx,ny;
//            cout<<sx<<","<<sy<<" -> "<<l<<endl;
            for(int i=0; i<4; ++i) {
                nx = sx+dx[(dir+i)%4],ny = sy+dy[(dir+i)%4];
                if(nx < 0 || nx > w-1 || ny < 0 || ny > h-1) continue;
                if(mp[ny][nx] == '.') {
                    if(seen[ny][nx][(dir+i)%4] != -1) {
                        int diff = seen[sy][sx][dir] - seen[ny][nx][(dir+i)%4] +1;
                        // cout<<"hoge "<<seen[sy][sx][dir]<<","<<seen[ny][nx][(dir+i)%4]<<endl;
                        // cout<<"fuga "<<ny<<" "<<nx<<" "<<(dir+i)%4<<endl;
                        // cout<<"diff : "<<diff<<" "<<l<<endl;
                        l--;
                        l %= diff;
                        if(0 == l)
                            ax = nx,ay = ny,ad = (dir+i)%4;
                        sx = nx,sy = ny,dir = (dir+i)%4;
                        memset(seen, -1, sizeof(seen));
                        seen[sy][sx][dir] = 0;
                        break;
                    }else{
                        seen[ny][nx][(dir+i)%4] = seen[sy][sx][dir]+1;
                        if(1 == l)
                            ax = nx,ay = ny,ad = (dir+i)%4;
                        sx = nx,sy = ny,dir = (dir+i)%4;
                        l--;
                        break;
                    }
                }
            }
            if(ax != -1) break;
        }

        cout<<ay+1<<" "<<ax+1<<" ";
        switch(ad) {
        case 0:
            cout<<"N"<<endl;
            break;
        case 1:
            cout<<"E"<<endl;
            break;
        case 2:
            cout<<"S"<<endl;
            break;
        case 3:
            cout<<"W"<<endl;
            break;
        }
    }
}

Measured memory_bytes: 0
n, k = map(int, input().split())
p = list(map(lambda pi: (int(pi) + 1) / 2, input().split()))
ex = sum(p[:k])
mx = ex
for i in range(n - k):
    ex += p[i + k] - p[i]
    if mx < ex:
        mx = ex
print(mx)

Measured memory_bytes: 23588
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

int N,C;
int D[31][31];
int c[510][510];

int main ()
{
    cin >> N >> C;
    REP(i,C) REP(j,C) cin >> D[i + 1][j + 1];
    REP(i,N) REP(j,N) cin >> c[i][j];

    vector < int > g[3];
    REP(x,N) REP(y,N) {
        g[(x + y) % 3].push_back(c[x][y]);
    }

    vector < int > anst[3];
    REP(i,3) {
        for (int col = 1; col <= C; col++) {
            int anstt = 0;
            REP(j,g[i].size()) {
                if (g[i][j] != col) {
                    anstt += D[g[i][j]][col];
                }
            }
            anst[i].push_back(anstt);
        }
    }

    int ans = 1e9;
    for (int col1 = 0; col1 < C; col1++) {
        for (int col2 = 0; col2 < C; col2++) {
            for (int col3 = 0; col3 < C; col3++) {
                if (col1 != col2 && col2 != col3 && col3 != col1) {
                    ans = min(ans, anst[0][col1] + anst[1][col2] + anst[2][col3]);
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

bool solve(int W, int H, int x, int y, int r) {
    if (x + r > W || y + r > H || x - r < 0 || y - r < 0) {
        return false;
    }
    return true;
}

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (solve(W, H, x, y, r)) {
        cout << "Yes" << endl;
    } else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int i,j,n,m,s[205][205];
char a[205][205];
int main()
{
	cin>>n>>m;
	for(i=1;i<=n;i++)
	 {
	   getchar();
	   for(j=1;j<=m;j++)
	   a[i][j]=getchar();
	 }
	 for(i=1;i<=n;i++)
        for(j=1;j<=m;j++) 
        {
        	if(a[i][j]=='#') continue;
            if(a[i-1][j]=='#') s[i][j]++;
            if(a[i][j-1]=='#') s[i][j]++;
            if(a[i+1][j]=='#') s[i][j]++;
            if(a[i][j+1]=='#') s[i][j]++;
            if(a[i-1][j+1]=='#') s[i][j]++;
            if(a[i+1][j-1]=='#') s[i][j]++;
            if(a[i+1][j+1]=='#') s[i][j]++;
            if(a[i-1][j-1]=='#') s[i][j]++;
        }
    for(i=1;i<=n;i++)
     {
	   for(j=1;j<=m;j++)
	   if(a[i][j]=='#') cout<<'#';
	   else cout<<s[i][j];
	   cout<<endl;
	 }
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,s;
	while(scanf("%d %d",&a,&b)!=EOF){
	s=a+b;
	if(s<10){
		printf("1\n");
	}
	else if(s>9&&s<100){
		printf("2\n");
	}
	else if(s>99&&s<1000){
		printf("3\n");
	}
	else if(s>999&&s<10000){
		printf("4\n");
	}
	else if(s>9999&&s<100000){
		printf("5\n");
	}
	else if(s>99999&&s<1000000){
		printf("6\n");
	}
	else if(s>999999){
		printf("7\n");
	}
	}
	return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vl a(3); cin>>a;
    if(sum(a)>=22)puta("bust"); else puta("win");
    return 0;
}

Measured memory_bytes: 256
#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_popcount

#define INF 1e16
#define mod 1000000007

int h,w;
string s[22];
int dp[22][22][22][22];

int dfs(int i1,int j1,int i2,int j2){
  if(i1>=i2||j1>=j2)return 0;
  if(dp[i1][j1][i2][j2]!=-1)return dp[i1][j1][i2][j2];
  set<int> st;
  rep(i,20)rep(j,20)st.insert(i*w+j);
  repl(i,i1,i2)repl(j,j1,j2){
    if(s[i][j]=='X')continue;
    int sum=0;
    sum^=dfs(i1,j1,i,j);
    sum^=dfs(i+1,j1,i2,j);
    sum^=dfs(i1,j+1,i,j2);
    sum^=dfs(i+1,j+1,i2,j2);
    st.erase(sum);
  }
  return dp[i1][j1][i2][j2]=*st.begin();
}

int main(){
  cin>>h>>w;
  rep(i,h)cin>>s[i];
  memset(dp,-1,sizeof(dp));
  int res=dfs(0,0,h,w);
  if(res==0)cout<<"Second"<<endl;
  else cout<<"First"<<endl;
  return 0;
}



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

int main(){
  string a;
  cin >> a;
  int n = a.length();
  int sn = (n-1)/2, nn = (n+1)/2;
  for(int i=0; i<n; i++){
    if(a[i]!=a[n-1-i]){
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i=0; i<sn; i++){
    if(a[i]!=a[sn-1-i]){
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i=nn; i<n; i++){
    if(a[i]!=a[n-1-i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main() {
	int D;
  	cin >> D;
  	if (D == 25) cout << "Christmas" << endl;
  	else if (D == 24) cout << "Christmas Eve" << endl;
  	else if (D == 23) cout << "Christmas Eve Eve" << endl;
  	else cout << "Christmas Eve Eve Eve" << endl;  	
}

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

int main(){
  double r;
  cin >> r;
  cout << fixed << setprecision(18) << r * 2.0 * M_PI << endl;

}

Measured memory_bytes: 3788
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if ((a + b) % 2 == 0)cout << (a + b) / 2 << endl;
	else cout << (a + b) / 2 + 1 << endl;
	int y;
	cin >> y;
	return 0;
}

Measured memory_bytes: 256
n, k = [int(s) for s in input().rstrip().split(" ")]

def f(a, b):
    cnt = 0
    while a < b:
        a *= 2
        cnt += 1
    return cnt

s = 0

for i in range(1, n + 1):
    s += (1 / n) * ((1 / 2) ** f(i, k))

print(s)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  ll N,M;  cin>>N>>M;
  string s,t; cin>>s>>t;
  if(N>M){
    swap(s,t);  swap(N,M);
  }
  if(N == M && s != t){
    cout << -1 << endl;
    return 0;
  }
  ll k = N * M / gcd(N, M);
  if(k == 1){
    cout << k << endl;
    return 0;
  }
  ll a = k / N, b = k / M;
  rep(i,0,M){
    if(b*i%a != 0 || b*i/a>=N) continue;
    if(s[b*i/a] != t[i]){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << k << endl;
  return 0;
}


Measured memory_bytes: 3736
def prime_decomposition(n):
    # nを素因数分解
    from collections import defaultdict
    i = 2
    table = defaultdict(int)
    while i**2 <= n:
        while n % i == 0:
            n //= i
            table[i]+=1
        i += 1
    if n > 1:
        table[n]+=1
    return table

import math
N = int(input())
c = prime_decomposition(math.factorial(N))
ans = 1
for k, v in c.items():
    ans = (ans * (v + 1)) % (10**9 + 7)
print(ans)

Measured memory_bytes: 3700
#include <cstdlib>
#include <iostream>


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

  int n, k;
  std::cin >> n >> k;
  std::cout << (n % k == 0 ? 0 : 1) << std::endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <stdio.h>
#define max(x, y) ((x)<(y) ? (y) : (x))
#define min(x, y) ((x)>(y) ? (y) : (x))

int main(){
  int k, x;  scanf("%d %d", &k, &x);
  for(int i=max(-1000000, x-k+1); i<=min(1000000, x+k-1); i++)
    printf("%d ", i);
    
  return 0;
}




Measured memory_bytes: 128
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

ans = b[a[0]-1]

for i in range(1, n):
    ans += b[a[i]-1]
    if a[i] == a[i-1] + 1:
        ans += c[a[i-1]-1]
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	
	int k; string s; cin >> k >> s;
	string  ans;
	if (s.size() <= k) {
		ans = s;
	}
	else {
		ans = s.substr(0, k);
		ans += "...";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
using System;

public class Program{
    public static void Main(){
        string ans="Yes";
        int N=int.Parse(Console.ReadLine());
        string[] input=Console.ReadLine().Split(' ');
        int[] A=new int[N+1];
        for(int i=1;i<N+1;i++){
            A[i]=int.Parse(input[i-1]);
        }
        A[0]=A[N];
        for(int i=2;i<N;i++){
            for(int j=i+1;j<=N;j++){
                if(A[i]== (A[i-1]^A[j])){
                    int k=A[i+1];
                    A[i+1]=A[j];
                    A[j]=k;
                    break;
                }else if(j==N){
                    ans="No";
                }
            }
            if(ans=="No"){
                break;
            }
        }
        if(A[N]!=(A[N-1]^A[1])){
            ans="No";
        }
        if(ans=="No"){
            ans="Yes";
            int l=A[1];
            A[1]=A[3];
            A[3]=l;
        A[0]=A[N];
        for(int i=2;i<N;i++){
            for(int j=i+1;j<=N;j++){
                if(A[i]== (A[i-1]^A[j])){
                    int k=A[i+1];
                    A[i+1]=A[j];
                    A[j]=k;
                    break;
                }else if(j==N){
                    ans="No";
                }
            }
            if(ans=="No"){
                break;
            }
        }
        if(A[N]!=(A[N-1]^A[1])){
            ans="No";
        }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 19168
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from pprint import pprint

def myinput():
    return map(int,input().split())

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

class UnionFind():
    # parentsは「要素が根の場合に"そのグループの要素数*(-1)"を格納するリスト」
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    # 要素xが属するgroupの根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    # 要素xが属するgroupと要素yが属するgroupを併合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
    # 要素xが属するgroupのサイズ（要素数）を返す
    def size(self, x):
        return -self.parents[self.find(x)]
    # 要素x,yが同じgroupに属するかをTrueかFalseで返す
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # 要素xが属するgroupに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    # 全ての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    # groupの数を返す
    def group_count(self):
        return len(self.roots())
    # {ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    # ルート要素: [そのグループに含まれる要素のリスト]を文字列で返す
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,k,l = myinput()
pq = [ list(myinput()) for _ in range(k) ]
rs = [ list(myinput()) for _ in range(l) ]

uf1 = UnionFind(n)
for i in range(k):
    p = pq[i][0]
    q = pq[i][1]
    uf1.union(p-1,q-1)

uf2 = UnionFind(n)
for i in range(l):
    r = rs[i][0]
    s = rs[i][1]
    uf2.union(r-1,s-1)

d = defaultdict(lambda: 0)
# print(d)
for i in range(n):
    d[(uf1.find(i),uf2.find(i))] += 1
# print(d)
for i in range(n):
    ans = d[(uf1.find(i),uf2.find(i))]
    print(ans)

Measured memory_bytes: 129368
main = do
  s <- getLine
  p <- getLine
  putStrLn $ if solve (s++s) p then "Yes"
             else "No"

solve :: String -> String -> Bool
solve a@(x:xs) p
  | slice 0 (length p) a == p = True
  | length(a) <= length(p) = False
  | otherwise = solve xs p           
  where slice ::  Int -> Int -> String -> String
        slice m n s = (take (n-m) . drop m) $ s

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

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

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

ll t,i,x,j,y,z,k,n;
set<ll>s;
cin>>n;
rep(i,0,n,1){
	cin>>x;
	s.insert(x);
}
if(s.size()==n)	ce("YES")
else ce("NO")
}


Measured memory_bytes: 9600
def main():
    import sys
    input = sys.stdin.readline

    class TreiNode:
        def __init__(self, char_num, depth):
            self.end = False
            self.child = [None] * char_num
            self.depth = depth

        def __setitem__(self, i, x):
            self.child[i] = x

        def __getitem__(self, i):
            return self.child[i]

    class Trei:
        def __init__(self, char_num):
            self.root = TreiNode(char_num, 0)
            self.char_num = char_num

        def add(self, S):
            v = self.root
            for s in S:
                if v[s] is None:
                    v[s] = TreiNode(self.char_num, v.depth + 1)
                v = v[s]
            v.end = True

        def exist(self, S):
            v = self.root
            for s in S:
                if v[s] is None:
                    return False
                v = v[s]
            if v.end:
                return True
            else:
                return False

    N, L = map(int, input().split())
    T = Trei(2)
    for _ in range(N):
        S = input().rstrip('\n')
        S = [int(s) for s in S]
        T.add(S)

    g = 0
    st = [T.root]
    while st:
        v = st.pop()
        for i in range(2):
            if v[i] is None:
                d = L - v.depth
                g ^= d & -d
            else:
                st.append(v[i])
    if g:
        print('Alice')
    else:
        print('Bob')


if __name__ == '__main__':
    main()


Measured memory_bytes: 59612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a;
  cin>>a;
  if(a%2!=0){
    cout<<0<<endl;
  }
  else {
    long long c=0;
    long long d=5;
    while(a/d>0){
        c+=a/(d*2);
        d*=5;
    
    }
    cout<<min(a/2,c)<<endl;
  }
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    if sort(split(readline()))==["1","4","7","9"]
        println("YES")
    else
        println("NO")
    end
end
main()

Measured memory_bytes: 114128
#include <stdio.h>
int main(){
int a,b=0,c=0;
scanf ("%d",&a);
for (int i=1;i<a+1;i++){
  c=0;
for (int k=1;k<i+1;k++){
if (i%k==0){
  c=c+1;
}
}
if (c==8){
  if(i%2==1){
  b=b+1;
}
}
}
printf ("%d",b);
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>

using namespace std;

int gcd(int n, int m) {
    if (n == 0)
        return m;
    return gcd(m % n, n);
}

int bit_count(int i) {
    i = i - ((i >> 1) & 0x55555555);
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
    i = (i + (i >> 4)) & 0x0f0f0f0f;
    i = i + (i >> 8);
    i = i + (i >> 16);
    return i & 0x3f;
}

int main() {
    int sub = 0;
    int ans = 0;
    for (size_t i = 0; i < 5; i++) {
        int a;
        cin >> a;
        if (a % 10 > 0) {
            sub = max(sub, 10 - (a % 10));
            ans += a / 10 * 10 + 10;
        } else {
            ans += a;
        }
    }
    cout << ans - sub << endl;
}


Measured memory_bytes: 256
N,K = [int(x) for x in input().split()]
ans = 0
mod = 10**9+7
for x in range(K,N+1):
    ans += int(N*(N+1)/2 -(N-x+1)*(N-x)/2 - x*(x-1)/2 + 1)
ans += 1
print(ans%mod)

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int,int> mii;

#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 mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
const int MOD = 1000000007;
double PI = 4*atan(1);

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll ai, ao, at, aj, al, as, az, ans=0; 
	cin >> ai >> ao >> at >> aj >> al >> as >> az;
	ans += 2*ao;
	if (al>0 && aj>0 && ai>0 && ((al%2)+(aj%2)+(ai%2))>1) {
		ans += 6;
		al--,aj--, ai--;
	}
	ans += 4*(ai/2);
	ans += 4*(al/2);
	ans += 4*(aj/2);
	cout << ans/2;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}


int main(){
  int n;
  cin>>n;
  int x[n],y[n],h[n];
  for(int i = 0;i < n; i++){
    cin>>x[i]>>y[i]>>h[i];
  }
  for(int i = 0; i <= 100; i++){
    for(int j = 0; j <= 100; j++){
      int hh=-1;
      bool flag = true;
      for(int k = 0; k < n; k++){
        if(h[k]==0){
          continue;
        }
        hh=h[k]+abs(x[k]-i)+abs(y[k]-j);
      }
      for(int k = 0; k < n; k++){
        int htmp = max(0,hh-abs(x[k]-i)-abs(y[k]-j));
        if(h[k]!=htmp){
          flag=false;
          break;
        }
      }
      if(flag){
          cout<<i<<" "<<j<<" "<<hh<<endl;
          return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
using namespace std; 
 
 
 
int main() 
{
    deque<char> S;
	int Q;
    string swk;
    cin>>swk;
  
  	for(int i=0;i<swk.size();i++){
      S.push_back(swk.at(i));
    }
  	
  	cin>>Q;
 
  	bool order_flg=true;
  	for(int i=0;i<Q;i++){
      int Ti;
      cin>>Ti;
      if(Ti==1){
        if(order_flg==true)
  	      order_flg=false;
        else
          order_flg=true;
        }else{
        int Fi;
        char Ci;
        cin>>Fi>>Ci;
        if(Fi==1){
          if(order_flg==true)
            S.push_front(Ci);
          else
            S.push_back(Ci);
        }
        else
          if(order_flg==true)
            S.push_back(Ci);
          else
            S.push_front(Ci);
      }
   
    }
  	  if(order_flg==false)
        reverse(S.begin(),S.end());
  
    for_each(S.begin(), S.end(), [](char x) {
       cout << x;
  });
 
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

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

    string s;
    cin >> s;

    char prev = 'a';
    rep(i,4)
    {
    	if(s[i]==prev)
    	{
    		cout << "Bad" << endl;
    		return 0;
    	}
    	prev = s[i];
    }

    cout << "Good" << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	fromConsole()
}

func fromConsole() {
	var x int
	fmt.Scan(&x)
	run(x)
}

func run(x int) {
	i := 0
	r := 100
	for r < x {
		i++
		r += calcRishi(r)
	}
	fmt.Println(i)
}

func calcRishi(i int) int {
	f := math.Trunc(float64(i) * 0.01)
	return int(f)
}


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

template <class T>
inline T Max(const T &a, const T &b) {return a > b ? a : b;}

template <class T>
inline T Min(const T &a, const T &b) {return a < b ? a : b;}

const int N = 205, INF = 0x3f3f3f3f;

int n, ans, dep[N], f[N][N];
char s[N][N];
bool vis[N];

void dfs(int u, int fu)
{
	vis[u] = 1; dep[u] = dep[fu] + 1;
	for (int v = 1; v <= n; v++)
	{
		if (s[u][v] == '0') continue;
		if (!vis[v]) dfs(v, u);
		else if ((dep[u] & 1) == (dep[v] & 1)) {puts("-1"); exit(0);}
	}
}

int main()
{
	std::cin >> n;
	for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
	dfs(1, 0); memset(f, INF, sizeof(f));
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			if (s[i][j] == '1') f[i][j] = 1;
	for (int i = 1; i <= n; i++) f[i][i] = 0;
	for (int k = 1; k <= n; k++)
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				f[i][j] = Min(f[i][j], f[i][k] + f[k][j]);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			ans = Max(ans, f[i][j]);
	return std::cout << ans + 1 << std::endl, 0;
}

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

int main() {
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b\n";
	}
	else if(a>b){
		cout<<"a > b\n";
	}
	else{
		cout<<"a == b\n";
	}
}


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

int main(){
  int H,W; cin >>H >>W;
  char map[H][W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >>map[i][j];
    }
  }

  int L[H][W], R[H][W], U[H][W], D[H][W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(map[i][j]=='#') {
        L[i][j]=0;
      } else if(j==0){
        L[i][j]=1;
      } else {
        L[i][j] = L[i][j-1]+1;
      }
    }
  }
  for(int i=0;i<H;i++){
    for(int j=W-1;j>=0;j--){
      if(map[i][j]=='#') {
        R[i][j]=0;
      } else if(j==W-1){
        R[i][j]=1;
      } else {
        R[i][j] = R[i][j+1]+1;
      }
    }
  }
  for(int j=0;j<W;j++){
    for(int i=0;i<H;i++){
      if(map[i][j]=='#') {
        U[i][j]=0;
      } else if(i==0){
        U[i][j]=1;
      } else {
        U[i][j] = U[i-1][j]+1;
      }
    }
  }
  for(int j=0;j<W;j++){
    for(int i=H-1;i>=0;i--){
      if(map[i][j]=='#') {
        D[i][j]=0;
      } else if(i==H-1){
        D[i][j]=1;
      } else {
        D[i][j] = D[i+1][j]+1;
      }
    }
  }

  int ans=0,max=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      ans = L[i][j]+R[i][j]+U[i][j]+D[i][j]-3;
      if(ans>max) max = ans;
    }
  }

  cout << max << endl;
}


Measured memory_bytes: 66688
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}


int main() {
  int L,R,d;
  cin>>L>>R>>d;
  cout<<R/d-(L-1)/d<<endl;
  return 0;
}

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

int main(){

	string s;
	cin >> s;
	int n = s.size();

	string sample0, sample1;
	sample1.reserve(100002);
	sample0.reserve(100002);


	rep(i,n/2) {
		sample0+="01";
	}
	if (n%2) {
		sample0+="0";
	}

	rep(i,n/2) {
		sample1+="10";
	}
	if (n%2) {
		sample1+="1";
	}

	int dif0=0, dif1=0;

	rep(i,n) {
		if (s[i]!=sample0[i]) {
			dif0++;
		}
		if (s[i]!=sample1[i]) {
			dif1++;
		}
	}

	cout << min(dif0, dif1) << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
        String str = scan.next();
        
        int answer = 0;
        int num = Integer.parseInt(str);
        
		for(int i = 1; i <= num; i++) {
			answer += i;
		}
		System.out.println(answer);
	}
}

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

using namespace std;

typedef long long ll;

bool anagram(string a, string b) {
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    return a == b;
}

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

    vector<string> s(N);
    for(int i = 0; i < N; i++) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    sort(s.begin(), s.end());

    string current = s[0];
    ll current_count = 1;
    ll count = 0;
    for(int i = 1; i <= N; i++) {
        if(i == N) {
            count += (current_count-1)*(current_count);
            break;
        }
        if(s[i] == current) {
            current_count++;
        } else {
            count += (current_count-1)*(current_count);
            current_count = 1;
            current = s[i];
        }
    }

    cout << (ll) ((count + 1) / 2) << endl;

    return 0;
}

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

int main(){
  
  double n,m,d;
  cin>>n>>m>>d;
  
  double ans;
  if(d==0) ans=(m-1)/n;
  else ans=(m-1)*2*(n-d)/n/n;
  
  cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n;
	long long int sum = 0;
	cin>>n;
	while(n>0)
	{
		if(n%3==0||n%5==0)
		{	
			n--;
			
		}
		else{
			sum+=n;
			n--;
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3588
s = input()

st = []

for i in range(len(s)):
    if s[i] == "0":
        st.append("0")
    elif s[i] == "1":
        st.append("1")
    else:
        if len(st) != 0:
            st.pop()
        else:
            continue

print("".join(st))


Measured memory_bytes: 61504