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

using namespace std;

vector<pair<int, int>> minimize(vector<pair<int, int>>& zs) {
    int inf = 1000000000;
    vector<pair<int, int>> minimized;
    for (int dz = -1; dz <= 1; ++dz) {
        int lo = inf, hi = -inf;
        for (auto z : zs) {
            if (z.first == dz) {
                lo = min(lo, z.second);
                hi = max(hi, z.second);
            }
        }
        if (lo != inf) {
            minimized.push_back(make_pair(dz, lo));
            if (lo != hi) {
                minimized.push_back(make_pair(dz, hi));
            }
        }
    }
    return minimized;
}

vector<int> cuts(vector<pair<int, int>>& zs) {
    vector<int> result;
    for (auto z1 : zs) {
        for (auto z2 : zs) {
            if (z1.first != z2.first) {
                // z1.first * t + 2*z1.second == z2.first * t + 2*z2.second
                // <=>
                // t = 2(z2.second - z1.second)/(z1.first - z2.first)
                int t = (2 * (z2.second - z1.second)) / (z1.first - z2.first);
                if (t >= 0) {
                    result.push_back(t);
                }
            }
        }
    }
    return result;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> xs(n), ys(n);
    for (int i = 0; i < n; ++i) {
        int x, y;
        char d;
        cin >> x >> y >> d;
        if (d == 'R') {
            xs[i] = make_pair(1, x);
            ys[i] = make_pair(0, y);
        } else if (d == 'L') {
            xs[i] = make_pair(-1, x);
            ys[i] = make_pair(0, y);
        } else if (d == 'U') {
            xs[i] = make_pair(0, x);
            ys[i] = make_pair(1, y);
        } else if (d == 'D') {
            xs[i] = make_pair(0, x);
            ys[i] = make_pair(-1, y);
        }
    }
    xs = minimize(xs);
    ys = minimize(ys);
    vector<int> x_cuts = cuts(xs);
    vector<int> y_cuts = cuts(ys);
    vector<int> all_cuts = {0};
    all_cuts.insert(all_cuts.end(), x_cuts.begin(), x_cuts.end());
    all_cuts.insert(all_cuts.end(), y_cuts.begin(), y_cuts.end());
    sort(all_cuts.begin(), all_cuts.end());
    all_cuts.resize(unique(all_cuts.begin(), all_cuts.end()) - all_cuts.begin());
    long long inf = 1000000000000000000LL;
    auto calc_single = [&](int t, vector<pair<int, int>>& zs) {
        long long lo = inf, hi = -inf;
        for (auto& z : zs) {
            lo = min(lo, (long long) z.first * t + 2*z.second);
            hi = max(hi, (long long) z.first * t + 2*z.second);
        }
        return hi-lo;
    };
    auto calc = [&](int t) {
        return calc_single(t, xs) * calc_single(t, ys);
    };
    auto t0 = clock();
    long long best = calc(0);
    for (int cut : all_cuts) {
        best = min(best, calc(cut));
    }
    cout << setprecision(30) << (long double) best / 4. << endl;
    cerr << "time used: " << (clock() - t0) << endl;
    return 0;
}


Measured memory_bytes: 1792
x = int(input())

if (400 <= x) and (x <= 599):
    print(8)
elif (600 <= x) and (x <= 799):
    print(7)
elif (800 <= x) and (x <= 999):
    print(6)
elif (1000 <= x) and (x <= 1199):
    print(5)
elif (1200 <= x) and (x <= 1399):
    print(4)
elif (1400 <= x) and (x <= 1599):
    print(3)
elif (1600 <= x) and (x <= 1799):
    print(2)
elif (1800 <= x) and (x <= 1999):
    print(1)

Measured memory_bytes: 9232
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace
 
#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
 
#define SANKOU(n,a,b) cout << ((n) ? (a) : (b) ) << endl;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);// warshall-floyd
 
#define CIN(x) int x;cin>>x;
#define CIN2(x,y) int x,y;cin>>x>>y;
#define CIN3(x,y,z) int x,y,z;cin>>x>>y>>z;
#define SCIN(x) string x;cin>>x;
#define SCIN2(x,y) string x,y;cin>>x>>y;
#define COUT(x) cout<<(x)<<endl;
#define SCOUT(x) cout<<(x)<<" ";
#define ENDL cout<<endl;
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i];
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;
 
#define ALL(obj) (obj).begin(),(obj).end()// iterator
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
 
 
#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>
 
#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair
 
 
int main(){
 
    CIN(n);V a(n);VECCIN(a);
 
    set<int> s;
    int flag=0;
    FOREACH(x,a){
        if(x<400)s.insert(0);
        else if(x<800)s.insert(1);
        else if(x<1200)s.insert(2);
        else if(x<1600)s.insert(3);
        else if(x<2000)s.insert(4);
        else if(x<2400)s.insert(5);
        else if(x<2800)s.insert(6);
        else if(x<3200)s.insert(7);
        else flag++;
    }
    SCOUT(max(1,(int)s.size()));
    COUT((int)s.size()+flag);
 
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rep2(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
const int N=1e5+7;

int n,a[N];
int main(){
	scanf("%d",&n);
	int vis=1,c=0;
	rep(i,1,n){
		scanf("%d",&a[i]);
		if(a[i]!=n-1)vis=0;
		c=max(c,a[i]);
	}
	if(vis){puts("Yes");return 0;}
	int cnt1=0,cnt2=0;
	rep(i,1,n){
		if(a[i] < c-1){puts("No");return 0;}
		if(a[i]==c-1)cnt1++;
		else cnt2++;
	}
	if(cnt1 + 1 > c){puts("No");return 0;}
	if(cnt1 + (cnt2>>1) < c){puts("No");return 0;}
	puts("Yes");
}

Measured memory_bytes: 512
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
  vector<int>a(3) ;
  cin >> a.at(0) >> a.at(1) >> a.at(2) ;
  sort(a.begin(),a.end(),greater<int>()) ;
  
  cout << abs(a.at(1)-a.at(0))+abs(a.at(2)-a.at(1)) << endl ; 
  
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(k,m,n) for(int(k)=(m);(k)<(n);(k)++)
#define REP(k,n) FOR((k),0,(n))
#define ALL(a) begin(a),end(a)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef unsigned long long ull;
typedef unsigned long ul;
typedef unsigned int  ui;
const int INF=numeric_limits<int>::infinity();
const int MOD=1000000007;
const double EPS=1e-9;

#define MAX_S 5000;
string S;
int K,size;
int main(int argc,char**argv)
{
  cin.tie(0);
  cin>>S>>K;
  size=S.size();
  vector<string> vs;
  vs.push_back(S);
  FOR(i,0,size)FOR(j,1,K+1){
      if(size-j>=i)vs.push_back(S.substr(i,j));
  }
  sort(ALL(vs));
  //REP(i,vs.size())cout<<vs[i]<<endl;
  vs.erase(unique(ALL(vs)));
  cout<<vs[K-1]<<endl;
  return EXIT_SUCCESS;
}

Measured memory_bytes: 1660
N = int(input())
p = [int(input()) for i in range(N)]

max = 0

for j in range(N):
    if max < p[j]:
        max = p[j]
        tmp = j

ans = 0

for j in range(N):
    if j == tmp:
        ans += max // 2
    else:
        ans += p[j]

print(ans)

Measured memory_bytes: 3064
n = int(input())
s = list(input())
a = s.count("E")
b1 = 0
t = 10000000000000
for i in range(n):
    if s[i] == "E":
        a -= 1
        c = b1 + a
    else:
        c = b1 + a
        b1 += 1
    if t > c:
        t = c
print(t)

Measured memory_bytes: 5792
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N = in, K = in;
    K = min( K, N-1 );
    vector<int> H(N);
    rep( i, N ) H[i] = in;

    vector<int> dp(N);
    dp[0] = 0;
    for( int i=1; i<K; i++ ) {
        dp[i] = INT_MAX;
        for( int j=0; j<i; j++ ) {
            dp[i] = min( dp[i], dp[j] + abs(H[j] - H[i]) );
        }
    }
    for( int i=K; i<N; i++ ) {
        dp[i] = INT_MAX;
        for( int j=1; j<=K; j++ ) {
            dp[i] = min( dp[i], dp[i-j] + abs(H[i-j] - H[i]) );
        }
    }

    cout << dp[N-1] << "\n";
    return 0;
}


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

const int MOD = (int)1e9+7;

int main(){
	int N,X;
	cin >> N >> X;
	vector<int> L(N);
	for(int i=0;i<N;i++)	cin >> L.at(i);

	int ans=1;
	int now=0;
	for(int i=0;i<N;i++){
		now+=L.at(i);
		if(now<=X)	ans++;
		else	break;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n;
ll ans,a[100005],b[100005];
int main(){
	in(n);n++;
	for(int i=1;i<=n;i++)in(a[i]);
	for(int i=1;i<n;i++)in(b[i]);
	for(int i=1;i<n;i++){
		if(b[i]>a[i]){
			b[i]-=a[i];
			ans+=a[i];
			a[i]=0;
			if(b[i]>a[i+1]){
				b[i]-=a[i+1];
				ans+=a[i+1];
				a[i+1]=0;
			}
			else{
				a[i+1]-=b[i];
				ans+=b[i];
				b[i]=0;
			}
		}
		else a[i]-=b[i],ans+=b[i],b[i]=0;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

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

Measured memory_bytes: 3620
local n = tonumber(io.read())
e = {}
for i=1,n+1,1 do
  e[i]=0
end
for i=2,n,1 do
    local cur = i
    for j=2,i,1 do
        while cur%j==0 do
            e[j+1] = e[j+1]+1
            cur = cur //j
        end
    end
end
res = 0
for i=1,n,1 do
    for j=1,n,1 do
        for k=1,n,1 do
            if e[i]>=4 and e[j]>=4 and e[k]>=2 and i<j and i~=k and j~=k then
                res = res+1
            end
        end
    end
end
for i=1,n,1 do
    for j=1,n,1 do
        if e[i]>=14 and e[j]>=4 and i~=j then
            res = res+1
        end
        if e[i]>=24 and e[j]>=2 and i~=j then
            res = res+1
        end
    end
end
for i=1,n,1 do
    if e[i]>=74 then
        res = res+1
    end
end
print(res)

Measured memory_bytes: 256
S=input()

if 0<=int(S[0]+S[1])<=99 and 1<=int(S[2]+S[3])<=12:
    yymm='True'
else:
    yymm='False'
if 1<=int(S[0]+S[1])<=12 and 0<=int(S[2]+S[3])<=99:
    mmyy='True'
else:
    mmyy='False'

if yymm=='True' and mmyy=='False':
    print('YYMM')
elif yymm=='False' and mmyy=='True':
    print('MMYY')
elif yymm=='True' and mmyy=='True':
    print('AMBIGUOUS')
else:
    print('NA')


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

int main(int argc, char const *argv[]){
	int n,x;
	int *m,ans;
	scanf("%d%d",&n,&x);
	ans = n;
	m = (int *)malloc(sizeof(int) * n);
	for (int i = 0; i < n; ++i){
		scanf(" %d",&m[i]);
		x -= m[i];
	}
	qsort(m,n,sizeof(int),comp);
	ans += (x / m[0]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

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

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

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

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

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

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

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

using B = bitset<2010>;


int A[2010][2010];
B dpl[2][2010];
B dpr[2][2010];


int main(void){
	int n;
	cin >> n;
	rep(j, 1, n){
		string a;
		cin >> a;
		rep(i, j){
			A[j][i] = (a[i] == '1');
			A[i][j] = 1 - A[j][i];
		}
	}

	rep(i, n){
		dpl[0][i].set(i);
		dpl[1][i].set(i);
		dpr[0][i].set(i);
		dpr[1][i].set(i);
	}

	rep(d, 1, n + 1)rep(l, n){
		const int r = l + d;
		if(r >= n) continue;

		{
			auto res = dpl[0][l] & dpl[1][r];
			if(res.any()){
				dpl[0][l].set(r);
				dpl[1][r].set(l);
			}
		}

		{
			auto res = dpr[0][l] & dpr[1][r];
			if(res.any()){
				dpr[0][l].set(r);
				dpr[1][r].set(l);
			}
		}

		{
			auto res = dpl[0][l] & (dpr[1][r] >> 1);
			if(res.any()){
				if(A[l][r]){
					dpl[0][l].set(r);
					dpl[1][r].set(l);
				} else {
					dpr[0][l].set(r);
					dpr[1][r].set(l);
				}
			}
		}
	}



	int ans = 0;
	rep(i, n){
		if(dpl[0][i][n - 1] & dpr[1][i][0]){
			ans++;
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 18048
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>

using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp update_pair
#define pb push_back
#define y2 y2228
const string FILENAME = "input";
const int MAXN = 105;



int n;
int b[MAXN];


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
  //	read(FILENAME);
 	cin >> n;
 	for (int i = 0; i < n; i++) {
 		cin >> b[i];
 	}
 	vector<int> s;
 	for (int i = 0; i < n; i++) {
 		s.pb(b[i]);
 	}
 	vector<int> res;
 	while (!s.empty()) {
 		vector<int> s1;
 		bool was = false;
 		int t = 0;
 		for (int i = sz(s) - 1; i >= 0; i--) {
 			if (s[i] == i + 1) {
 				chkmax(t, s[i]);
 			}
 		}
 		for (int i = sz(s) - 1; i >= 0; i--) {
 			if (s[i] == i + 1 && s[i] == t) {
 				was = true;
 				res.pb(i + 1);
 				for (int j = 0; j < i; j++) {
 					s1.pb(s[j]);
 				}
 				for (int j = i + 1; j < sz(s); j++) {
 					s1.pb(s[j]);
 				}
 				break;
 			}
 		}if (!was) {
 			cout << -1 << endl;
 			return 0;
 		}
 		s = s1;
 	}
 	reverse(all(res));
 	for (auto x: res) {
 		cout << x << '\n';
 	}
	return 0; 	
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<vector<int> > vc(10);
main()
{
    vc[0].push_back(0);
    vc[1].push_back(0);
    vc[2].push_back(0);
    
    int d, n, cnt = 0;
    cin >> d >> n;
    for(int i = 1; i <= 10000000; i++){
        int j = i, k = 0;
        while(j % 100 == 0) j /= 100, k++;
        vc[k].push_back(i);
    }
    cout << vc[d][n];
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S,T;
int C[3];
int N;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	FORR(c,S) {
		if(T.empty() || c!=T.back()) {
			T+=c;
			C[c-'A']++;
		}
	}
	pair<int,char> P[3];
	P[0]={C[0],'A'};
	P[1]={C[1],'B'};
	P[2]={C[2],'C'};
	sort(P,P+3);
	FOR(i,3) C[i]=P[i].first;
	FORR(c,T) {
		FOR(i,3) if(c==P[i].second) {
			c=i;
			break;
		}
	}
	vector<string> V;
	int cur=0;
	while(cur<T.size()) {
		if(T[cur]==2) {
			if(C[2]>C[1]) {
				C[2]--;
			}
			else {
				V.push_back(T.substr(cur,1));
			}
			cur++;
		}
		else if(T[cur]==0) {
			V.push_back(T.substr(cur,1));
			cur++;
			while(cur+2<=T.size() && T[cur]==2 && T[cur+1]==0) {
				V.back().push_back(2);
				V.back().push_back(0);
				cur+=2;
			}
		}
		else if(T[cur]==1) {
			V.push_back(T.substr(cur,1));
			cur++;
			while(cur+2<=T.size() && T[cur]==2 && T[cur+1]==1) {
				V.back().push_back(2);
				V.back().push_back(1);
				cur+=2;
			}
		}
	}
	FORR(v,V) {
		while(v[0]==0 && C[2]>C[1] && v.size()>=3) {
			v.pop_back();
			v.pop_back();
			C[0]--;
			C[2]--;
		}
	}
	assert(C[1]==C[2]);
	S.clear();
	FORR(v,V) S+=v;
	T.clear();
	cur=0;
	while(cur<S.size()) {
		if(C[1]>C[0] && cur+3<=S.size() && ((S[cur]==1&&S[cur+1]==2&&S[cur+2]==1)||(S[cur]==2&&S[cur+1]==1&&S[cur+2]==2))) {
			cur+=2;
			C[1]--;
			C[2]--;
			continue;
		}
		if(C[1]>C[0] && cur+2==S.size() && ((S[cur]==1&&S[cur+1]==2)||(S[cur]==2&&S[cur+1]==1))) {
			cur+=2;
			C[1]--;
			C[2]--;
			continue;
		}
		T.push_back(S[cur]);
		cur++;
	}
	//assert(C[1]==C[0]);
	
	FORR(c,T) cout<<P[c].second;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 57872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> city(n);
  for (int i = 0; i < m; i++) {
  	int a, b;
    cin >> a >> b;
    city[a-1]++;
    city[b-1]++;
  }
  for (int i = 0; i < n; i++) {
  	cout << city[i] << endl;
  }
  
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
pairs = [[a, b, N-a-b] for a in range(N+1) for b in range(N-a+1) if a*10000+b*5000+(N-a-b)*1000 == Y]

if len(pairs) != 0:
    print(" ".join(map(str, pairs[0])))
else:
    print("-1 -1 -1")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, x;
    char com[20];
    list<int> v;
    cin >> n;
    rep(i,n) {
        cin >> com;
        if (strlen(com) <= 6) cin >> x;
        if (com[0] == 'i') v.push_front(x);
        else if (com[6] == 'F') v.pop_front();
        else if (com[6] == 'L') v.pop_back();
        else {
            for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
                if (*it == x) {
                    v.erase(it);
                    break;
                }
            }
        }
    }
    int i = 0;
    for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
        if (i++) cout << ' ';
        cout << *it;
    }
    cout << endl;
}


Measured memory_bytes: 34300
#include <bits/stdc++.h>
using namespace std;
int pow10(int a){
  int res=1;
  for(int i=0;i<a;i++){
    res = res*10;
  }
  if(a==0){
    res = 0;
  }
  return res;
}

int main(){
  int N,M;
  int arr[1000]={0};
  int ans=-1;
  int k;
  cin >> N >> M;
  int s[M],c[M];
  for(int i=0;i<M;i++){
    cin >> s[i] >> c[i];
  }
  for(int num=pow10(N-1);num<pow10(N);num++){
    for(int i=0;i<M;i++){
      k=num;
      if(N>s[i]){
        k=num/(pow10(N-s[i]));
      }
      if(k%10==c[i]){arr[num]++;}
  	}
  }
  for(int j=pow10(N-1);j<pow10(N);j++){
    if(arr[j]==M){
      ans = j;
      break;
    } 
  }
  cout << ans << endl;
}

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

int main(){
    int x;
    cin >> x;
    for(int h=x;h<=1000000;h++){
        bool isprime=true;
        for(int i=2;i*i<=h;i++){
            if(h%i == 0){
                isprime=false;
                break;
            }
        }
        if(isprime){
            cout << h << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3600
import itertools

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

seq = [i+1 for i in range(N)]
patterns = list(itertools.permutations(seq))

number = 0
for pattern in patterns:
    number += 1
    if list(pattern) == A:
        tmp1 = number

    if list(pattern) == B:
        tmp2 = number

    
print(abs(tmp1 - tmp2))



Measured memory_bytes: 8052
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  ll ans = 0;
  rep(r, N / R + 2){
    rep(g, N / G + 2){
      int rg = r * R + g * G;
      if(rg > N)break;
      int b = N - rg;
      if(b >= 0 && b % B == 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  int n;
  cin >> n;
  vector<ll> a(n + 1), b(n + 2);
  rep(i, n + 1) cin >> a[i];
  b[0] = 0;
  rep(i, n + 1) {
    if(i == 0) continue;
    cin >> b[i];
  }
  b[n + 1] = 0;
  ll ans = 0;
  rep(i, n + 1) {
    int toubatsu = min(a[i], b[i]);
    ans += toubatsu;
    a[i] -= toubatsu;
    toubatsu = min(a[i], b[i + 1]);
    ans += toubatsu;
    b[i + 1] -= toubatsu;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    vec<vec<int>> A(2,vec<int>(N));
    rep(i,2)rep(j,N){
        cin >> A[i][j];
    }
    vec<int> U(N);
    vec<int> D(N);
    U[0] = A[0][0];
    D[0] = A[1][0];
    rep(i,N-1){
        U[i+1] = A[0][i+1]  + U[i];
        D[i+1] = A[1][i+1]  + D[i];
    }

    int ans = A[0][0]+D[N-1];
    for(int i=1;i<N;++i){
        int tmp = U[i] + D[N-1] - D[i-1];
        ans=max(ans,tmp);
    }
    cout << ans << endl;
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

typedef long long ll;
using namespace std;

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

  ll l[n];
  l[0] = 2;
  l[1] = 1;

  rep(i,2,n+1){
    l[i] = l[i-1]+l[i-2];
  }
  printf("%lld\n",l[n]);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // abs()
#include <string.h>         // memset()
#include <stdbool.h>

#define MAX_N 15
#define MAX_S (1 << MAX_N)

const double INF = 1e10;

int n;
int s[MAX_N], l[MAX_N], v[MAX_N];
double dp[MAX_N][MAX_S];
int w[MAX_N][MAX_S];
short prev[MAX_N][MAX_S][2];
int ord[MAX_N];

int
main(int argc, char **argv)
{
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d%d%d", &s[i], &l[i], &v[i]);

	memset(prev, -1, sizeof(prev));
	int S = 1;
	for (int i = 0; i < n; i++, S <<= 1)
		w[i][S] = v[i];

	int e = 1 << n;
	for (int k = 0; k < e; ++k)
	{
		S = 1;
		for (int i = 0; i < n; ++i, S <<= 1)
		{
			if (k & S)
				continue;

			int t = k | S;
			for (int j = 0; j < n; ++j)
			{
				if (i == j || w[j][k] == 0)
					continue;

				int d = abs(l[i] - l[j]);
				double x = dp[j][k] + d * ((7 + 2 * w[j][k]) / 200.0);
				if (dp[i][t] == 0 || x < dp[i][t])
				{
					dp[i][t] = x;
					w[i][t] = w[j][k] + v[i];
					prev[i][t][0] = j;
					prev[i][t][1] = k;
				}
			}
		}
	}

	double min = INF;
	int u = 0;
	for (int i = 0; i < n; ++i)
	{
		double y = dp[i][e - 1];
		if (y == 0)
			continue;

		if (y < min)
		{
			min = y;
			u = i;
		}
	}

	ord[0] = u;
	int v = e - 1;
	for (int k = 1; k < n; ++k)
	{
		ord[k] = prev[u][v][0];
		v = prev[u][v][1];
		u = ord[k];
	}

	for (int i = n - 1; i >= 0; --i)
		printf("%d%c", s[ord[i]], (i != 0) ? ' ' : '\n');

	return 0;
}

Measured memory_bytes: 8656
Module Module1

    Sub main()
        Dim user2 As List(Of String) = New List(Of String)(Split(Console.ReadLine(), " "))
        Dim sunukeNum As Long = user2(0)
        Dim okashiType As Long = user2(1)
        Dim sunukeHaveOkashi(sunukeNum - 1) As Boolean

        ' お菓子の種類分だけループ
        For i = 0 To okashiType - 1
            Dim user1 = Console.ReadLine()
            Dim user3 As List(Of String) = New List(Of String)(Split(Console.ReadLine(), " "))

            'Dim okashies As New List(Of Long)
            'okashies = New List(Of Long)(Array.ConvertAll(user3, Function(j As String) CLng(j)))
            Dim okashies As New List(Of Long)(Array.ConvertAll(user3.ToArray, Function(j As String) CLng(j)))

            For Each myOkashi In okashies
                sunukeHaveOkashi(myOkashi - 1) = True

                'Console.WriteLine(myOkashi - 1 & "にお菓子をもたせました")
            Next
        Next

        Dim sss As New List(Of Boolean)(sunukeHaveOkashi)
        Console.WriteLine(sss.FindAll(Function(n) Not n).Count)
    End Sub
end module

Measured memory_bytes: 29404
N,H = [input() for i in range(2)]
N=int(N)
H=H.split(' ')
for i in range(N):
    H[i]=int(H[i])
cnt = 0

for i in range(N):
    if i == 0:
        cnt += 1
    else:
        flag =  True
        for j in range(i):
            if H[i] < H[j]:
                flag = False
        if flag == True:
            cnt += 1

print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define en "\n"
#define pair <int, int> pii
#define all(x) x.begin(),x.end()
#define loop(i,q,n) for(int i=q;i<n;i++)
#define dloop(i,a,b) for(int i=a;i>=b;i--)
#define speed ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
const ld PI = 3.14159265358979323;
const ll mod = 1e9+7;
const int N=1000001;
//******************************************************************************             
int gcd(int a,int b)
{
	if(b==0)return a;
	else return gcd(b,a%b);
}
int dp[1001][1001];
int main()
{
	speed;
	int n;
	cin>>n;
	vector<ld> v(n+1);
	loop(i,1,n+1)cin>>v[i];
	ld dp[n+1][n+1];
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	loop(i,1,n+1)loop(j,0,n+1)
	if(j==0)dp[i][j]=dp[i-1][j]*(1-v[i]);
	else dp[i][j] = dp[i-1][j-1]*v[i] + dp[i-1][j]*(1-v[i]);
	ld ans=0;
	loop(i,n/2+1,n+1)ans+=dp[n][i];
	cout << setprecision(10) << ans << en;
	return 0;
}

Measured memory_bytes: 140928
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
int main() {
	int a, b;
	cin >> a >> b;
	if (a >= 13) {
		cout << b;
	}
	else if ((13 > a) &&(a >= 6)) {
		cout << b / 2;
	}
	else {
		cout << 0;
	}
}

Measured memory_bytes: 384
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>

const int INF = 1001001000;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

int main(){
  int a,b;
  int x;

  cin >> a >> b;
  x = ( (a+b)/2 ) + ((a+b)%2);

  cout << x << endl;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define N 100009
using namespace std;

int n,cnt,a[N],h[N],fst[N],nxt[N],dgr[N],fa[N],d[N];
int main(){
	scanf("%d",&n);
	int i,x;
	for (i=2; i<=n; i++){
		scanf("%d",&x); fa[i]=x;
		nxt[i]=fst[x]; fst[x]=i; dgr[x]++;
	}
	int head=0,tail=0;
	for (i=1; i<=n; i++) if (!dgr[i]) h[++tail]=i;
	while (head<tail){
		x=h[++head];
		for (i=fst[x],cnt=0; i; i=nxt[i]) a[++cnt]=d[i];
		sort(a+1,a+cnt+1);
		for (i=1; i<=cnt; i++) d[x]=max(d[x],a[i]+cnt-i+1);
		if (x>1 && !(--dgr[fa[x]])) h[++tail]=fa[x];
	}
	printf("%d\n",d[1]);
	return 0;
}


Measured memory_bytes: 2560
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
    std::cin >> N;
    
    bool ok = false;
    for (int64_t i = 1; i <= 9; i++)
    {
        for (int64_t j = 1; j <= 9; j++)
        {
            if (i * j == N) ok = true;
        }
    }

    std::string ans = ok ? "Yes" : "No";
    std::cout << ans << std::endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}


Measured memory_bytes: 3656
sx, sy, tx, ty = map(int,input().split())
W = tx - sx
H = ty - sy

r1 = 'R'*W + 'U'*H + 'L'*W + 'D'*H
r2 = 'D' + 'R'*(W+1) + 'U'*(H+1) + 'L' + 'U' + 'L'*(W+1) + 'D'*(H+1) +'R'
print(r1+r2)

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

int main(){
	int n,i,a,b,c;
	cin>>n;
	for(i=n;i<=n+150;i++){
		a=i/100;
		b=(i%100)/10;
		c=i%10;
		if ((a==b)& (b==c)) {
		cout<<i;
		return 0;
	}
	}
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
int main ()
{
  int n,ti,c,t,flag=0,minn=1<<30;
  int ans;
  cin>>n>>ti;
  for (int i=1;i<=n;++i)
     {
       cin>>c>>t;
	   if (t<=ti)
	     {
	       flag=1;
		   if (c<minn)
		      minn=c;	
	     }	
	 }
	if (!flag)
	   printf ("TLE\n");
	else
	   printf ("%d\n",minn);
	return 0;
}

Measured memory_bytes: 256
def main():
    A,B,C,K = list(map(int, input().split(' ')))
    
    out = 0
    if A > K:
        out = K
        return out
    else:
        nokori = K-A
        if nokori <= B:
            out = A
            return out
        elif nokori > B:
            nokonkori = K - A - B
            out = A - nokonkori
            return out
            
            
            
            
out = main()
print(out)

Measured memory_bytes: 61704
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main(){
ll n;cin>>n;
ll a=0,b=0;
for(ll i=0;i<n;i++){
    ll m;cin>>m;
    if(m%4==0)a++;
    else if(m%2==0)b++;
}
if(a>=n/2)cout<<"Yes";
else if(n-2*a==b)cout<<"Yes";
else cout<<"No";
}

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


int main()
{
    string s;
    long long N;
    long long d = 1;
    int result [15] = {0};
    int i = 0;
    int l;
    cin >> N;
    while (N>=0){
        N-= d;
        d *= 26;
        result[i]++;
        i++;
    }
    i--;
    l = i;
    d /= 26;
    N+= d;
    while (d >= 1){
        result[i] += N/d;
        N %= d;
        d /= 26;
        i--;


    }
    for (int m=l-1; m>=0; m--){
        s += (result[m] + 'a' -1);
    }
    cout << s;

}



Measured memory_bytes: 3616
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int a=in.nextInt();
		int b=in.nextInt();
		long ans=a;
		ans=ans*b;
		ans=ans/gcd(a,b);
		System.out.println(ans);
	}
	
	static int gcd(int a,int b)
	{
		if(a%b==0)
			return b;
		return gcd(b,a%b);
	}
}
	

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define pb(n) push_back(n);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
vector<int> vi;
vector<lln> vl;
vector<vector<pair<int, int> > > vii;
//vector<pii> vii;
vector<pll> vll;
//vii.clear();
//vii.resize(n + 1);


int arr[maxii];
int arr2[maxii];
bool check[maxii];
bool check2[1000][1000];
int n,m;
int x[]={1,-1,0,0};
int y[]={0,0,-1,1};
int x2[]={1,-1,0,0,1,-1,1,-1};
int y2[]={0,0,-1,1,1,-1,-1,1};
int bx[]={0,0,1,-1,-1,1,1,-1};
int by[]={1,-1,0,0,-1,-1,1,1};
int kx[] = {1,1,2,2,-1,-1,-2,-2};
int ky[] = {2,-2,1,-1,2,-2,1,-1};

bool isvisited(int xx,int yy)
{
    if(xx<1 || yy<1 || xx>n ||yy>m)
    {
        return false;
    }
    else if(check2[xx][yy]==true)
    {
        return false;
    }
    else return true;
}
int gcd(int a,int b)
{
    if(b==0){
      return a;
     }
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    int res=(a*b)/gcd(a,b);
    return res;
}
int po(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2!=0)
        {
            res*=a;
            b--;
        }
        else
        {
            a*=a;
            b/=2;
        }
    }
    return res;
}

lln modMul(lln  a, lln b,lln mod){
    lln ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}
lln powerMod(lln a,lln b,lln mod){
	if(b==0)return 1LL%mod;
	lln x=powerMod( a,b/2,mod );
	x = ( x%mod * x%mod ) % mod;
	if( b%2==1 )x = ( x%mod * a%mod ) % mod;
	return x%mod;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string a;
    cin>>a;
    int len=a.size();
    if(a[len-1]!='s')
    {
        cout<<a<<"s";
    }
    else
    {
        for(int i=0;i<len;i++)
        {
            cout<<a[i];
        }
        cout<<"es";
    }


}






Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;

int main() {
    string s; cin >> s;
    if (s[0] != s[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

char ara[25][25];
int color[25][25],dis[25][25];

bool valid(int i,int j,int n,int m)
{
	return i>=0 && i<n && j>=0 && j<m && ara[i][j]=='.';
}

void bfs(int r,int c,int n,int m)
{
	color[r][c]=1;
	queue<pii>q;
	q.push({r,c});
	
	while(!q.empty())
	{
		pii u=q.front();
		q.pop();
		
		for(int i=0;i<4;i++)
		{
			int x=u.first+dx[i];
			int y=u.second+dy[i];
			
			if(valid(x,y,n,m) && !color[x][y])
			{
				q.push({x,y});
				dis[x][y]=dis[u.first][u.second]+1;
				color[x][y]=1;
			}
		}
	}
}

int get_max(int &mx,int n,int m)
{
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) mx=max(mx,dis[i][j]);
	return mx;
}
	
void solve()
{
	int n,m;
	cin>>n>>m;

	for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>ara[i][j];

	int ans=-1;

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(ara[i][j]=='.')
			{
				memset(color,0,sizeof color);
				memset(dis,0,sizeof dis);

				bfs(i,j,n,m);
				get_max(ans,n,m); 
			}
		}
	}
	
	cout<<ans;
}
	
int main()
{
	/*ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);*/
	
	solve();
	
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

const int N = 110,M = 1e5+100,mod = 1e9+7;
typedef long long LL;

int n,k;
LL dp[N][M];  //dp[i][j] 表示前i个小朋友一共分j颗糖的方案
int a[N];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>k;
    for(int i = 1; i<=n; i++) cin>>a[i];
    
    dp[0][0] = 1;
    for(int i = 1; i<=n; i++){
        dp[i][0] = 1;
        for(int j = 0; j<k; j++){
            dp[i][j+1] = dp[i][j] + dp[i-1][j+1];
            if(j>=a[i]) dp[i][j+1] -= dp[i-1][j-a[i]];
            dp[i][j+1]  = (dp[i][j+1]+mod)%mod;
        }
    }
    cout<<dp[n][k]%mod;
    
    
    return 0;
}

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

using namespace std;

int main(){

	int n;
	while(cin>>n&&n!=0){
		int v[10];
		fill(v,v+10,0);
		for(int i = 0; i < n; i++){
			int t;
			cin>>t;
			v[t]++;
		}
		for(int i = 0; i < 10; i++){
			int num=v[i];
			if(num>=1){
				for(int j = 0; j < num; j++)
					cout<<'*';
				cout<<endl;
			}
			else{
				cout<<'-'<<endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
h,w=map(int,input().split())
a=[[i for i in input().split()] for j in range(h)]
p=[chr(i) for i in range(65,91)]
for r in range(h):
    for c in range(w):
        if a[r][c]=="snuke":
            print(p[c]+str(r+1))
            break

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
    int a;
    char x[3];
    int A=0,B=0,O=0,AB=0;
    while(scanf("%d,%s",&a,x)!=EOF){
        if(x[0] == 'A' && x[1] == '\0')A++;
        else if(x[0] == 'B')B++;
        else if(x[0] == 'O')O++;
        else AB++;
    }
    printf("%d\n%d\n%d\n%d\n",A,B,AB,O);
    return 0;
}

Measured memory_bytes: 596
a,b=input().split()
a=int(a)
b=int(b)
z=a+b-1
ans=0
for i in range(b,z+1):
    ans+=i
    
if b<=0 and z>=0:
    print(ans)
elif z>=0:
    print(ans-b)
elif b<=0:
    print(ans-z)
    


Measured memory_bytes: 3060
#include <cstdio>

#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
#define SWAP(type,a,b)          { type work = a; a = b; b = work; }

void bubble_sort(int* array, size_t size)
{
	size_t i, j;

	for( i = 0; i < size - 1; ++i ){
		for( j = 1; j < size - i; ++j ){
			if( array[j-1] > array[j] ){
				SWAP(int, array[j-1], array[j]);
			}
		}
	}
}

int main(void){
	int N,A[10000];
	int i;
	int ans=0;
	int kigo = 1;

	scanf("%d", &N); //枚

	for(i=0;i<N;i++)
	{
		scanf("%d", &A[i]); //CARDのnum
	}

	bubble_sort(A, N);

	for(i=N-1;i>=0;i--)
	{
		ans += A[i]*kigo;
		kigo*=-1;
	}
	printf("%d\n", ans);
	getchar();
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

char in[2050][2050];
int dp[2050][2050];

int r[2050];
int sz[2050];
int root(int x) {
	return (r[x] == x) ? x : (r[x] = root(r[x]));
}
int mymerge(int a, int b) {
	a = root(a), b = root(b);
	if (a == b) return a;
	r[a] = b;
	sz[b] += sz[a];
	return b;
}
int main() {
	int N, M, i, j;
	scanf("%d %d", &N, &M);
	for (i = 1; i <= N; i++) scanf("%s", in[i] + 1);
	
	for (i = 1; i < N; i++) {
		dp[i][M] = 1;
		for (j = M - 1; j >= 1; j--) {
			if ((in[i][j] == in[i + 1][j]) ^ (in[i][j + 1] == in[i + 1][j + 1])) dp[i][j] = 1;
			else dp[i][j] = 1 + dp[i][j + 1];
		}
	}

	int ans = 0;
	for (i = 1; i <= M; i++) {
		for (j = 1; j <= N; j++) r[j] = j, sz[j] = 1;
		vector <pii> Vu;
		for (j = 1; j < N; j++) Vu.emplace_back(dp[j][i], j);
		sort(all(Vu));

		int p = (int)Vu.size() - 1;
		ans = max(ans, M + 1 - i);
		for (j = M; j >= 1; j--) {
			while (p >= 0) {
				if (Vu[p].first < j) break;
				int t = mymerge(Vu[p].second, Vu[p].second + 1);
				ans = max(ans, j * sz[t]);
				p--;
			}
		}
	}
	return !printf("%d\n", ans);
}

Measured memory_bytes: 20864
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#include<iomanip>;

int main() {
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	int k = 60 * h + m;
	int mm = 12 * 60;
	double angh = 360.0 * double(k) / double(mm);
	double angm = 360.0 * double(m) / double(60);
	double ang = abs(angh - angm);
	//cout << ang;
	double pi = 3.1415926535;
	double cosa=cos(ang/180.0*pi);
	double ans = sqrt(a * a + b * b - 2 * a * b * cosa);
	cout << setprecision(15)<<ans;
	
	return 0;
}

Measured memory_bytes: 4244
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ii pair<int,int>
#define setin set.insert
using namespace std;

void solve()
{
    string s,t;
    cin >> s;
    cin >> t;
    int ans=0;
    for(int i=0;i<s.size();i++)
        if(s[i]!=t[i])
            ans++;
    cout << ans << endl;
}

int main()
{

    solve();

    return 0;
}


Measured memory_bytes: 3924
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int a[101],b[101],s,i,w,y,j,m,d,t,n;
	cin>>n;
	while(n!=0){
	for(i=0;i<n;i++){
		cin>>a[i];
		b[i]=0;
	}
	for(i=0;i<n-1;i++){
		for(j=i;j<n;j++){
			if(a[i]>a[j]){
				s=a[i];
				a[i]=a[j];
				a[j]=s;
			}
		}
	}
	s=0;
	m=0;
	for(i=1;i<=2*n;i++){
		for(j=0;j<=n;j++){
			if(a[j]==i||b[j]==i){
				s++;
			}
		}
		if(s==0){
			b[m]=i;
			m++;
		}
		s=0;
	}
	d=a[0];
	a[0]=0;
	 t=0;
	 s=0;
	 m=0;
	 w=0;
	 y=1;
	 while(1){
		 if(t==0){
			 i=0;
			 for(s=0;s<n;s++){
				if(b[s]>=d){
					d=b[s];
					b[s]=0;
					i++;
					t=1;
					w++;
					break;
				}
			 }
			 if(i==0){
				d=1;
				t=1;
			 }
		 }
		 if(t==1){
			 i=0;
			 for(m=0;m<n;m++){
				if(a[m]>=d){
					d=a[m];
					a[m]=0;
					i++;
					t=0;
					y++;//b
					break;
				}
			 }
			if(i==0){
				d=1;
				t=0;
			}
		 }
		 if(w==n-1||y==n-1){
			 y=n-y;
			 w=n-w;
			 break;
		 }
	}
	 y=0;
	 w=0;
	 for(i=0;i<n;i++){
		 if(a[i]>0){
			 y++;
		 }
		 if(b[i]>0){
			 w++;
		 }
	 }
	 if(w<y){
		 w=0;
	 }
	 else{
		 y=0;
	 }
	 cout<<w<<endl<<y<<endl;
	 cin>>n;
	}
	return 0;
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>
#include <time.h>
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 if (D == 22)
		cout << "Christmas Eve Eve Eve" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace ITP1_1_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);

            if (a < b && b < c) Console.WriteLine("Yes");

            else Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 8864
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
string s;
int k,n;
vector<string> ans;

int main(){
    cin>>s;cin>>k;
    n=s.size();
    int c=0;
    for(int i=0;i<n;i++){
        string t="\0";
        for(int j=i;j<n&&j-i<=k;j++){
            t=t+s[j];
            ans.push_back(t);
        }
    }
    sort(ALL(ans));
    unique(ALL(ans));
    cout<<ans[k-1]<<endl;
    return 0;
}


Measured memory_bytes: 1916
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_7_B
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var words = Console.ReadLine().Split(' ');
                var n = int.Parse(words[0]);
                var sum = int.Parse(words[1]);
                if (n == 0 && sum == 0)
                {
                    return;
                }

                var count = 0;
                for (var i = 1; i <= (n - 2); ++i)
                {
                    for (var j = i + 1; j <= (n - 1); ++j)
                    {
                        var remain = sum - (i + j);
                        if (j < remain && remain <= n)
                        {
                            ++count;
                        }
                    }
                }
                Console.WriteLine(count);
            }
        }
    }
}

Measured memory_bytes: 5612
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<random>
using namespace std;
 
int main() {
 
  string s; cin >> s;
 
  int a[3] = {0,0,0};
 
  for(int i=0; i<s.size(); i++){
    a[ s[i]-'a' ]++;
  }
  if( max({a[0],a[1],a[2]}) - min({a[0],a[1],a[2]}) <= 1 ) cout << "YES" << endl;
  else cout << "NO" << endl;
 
  return 0;
}
 
// EOF

Measured memory_bytes: 512