akhauriyash/Code-Regression huggingface dataset:
S = input()


count_1 = 0
count_0 = 0

for i in range(len(S)):
  if S[i]=="1":
    count_1 = count_1 + 1
  elif S[i]=="0":
    count_0 = count_0 + 1
    

if count_1 >= count_0:
  print(count_0*2)
else:
  print(count_1*2)



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 2929000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890


int main(){
    ll i,j;
    ll a,b;
    cin>>a>>b;

    if(a>=13) cout<<b<<endl;
    else if(a>=6) cout<<b/2<<endl;
    else cout<<0<<endl;
    
    return 0;
}

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

int x = 0;
int arr[105];
int c = 0;
int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i<n; i++)
    {
        cin >> arr[i];
    }
    for (int i = 0; i<n; i++)
    {
        if (x <= m)
        {
            x += arr[i];
            c++;
        }
    }
    if (x<=m)
        c++;
    printf("%d",c);
}


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

const int MaxL=1e3;
string S, T;
int Mask(int st, int t=0){
	for(int i=0;i<T.length();i++)
		t+= S[st+i]!=T[i];
	return t;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	cin>>S>>T;
	int ans=S.length();
	for(int i=0;i<=S.length()-T.length();i++)
		ans=min(ans,Mask(i));
	cout<<ans<<'\n';
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> c(N+1, 0);
  rep(i, N){
    cin >> A.at(i);
    c.at(A.at(i))++;
  }
  vector<ll> na(N+1, 0);
  vector<ll> ba(N+1, 0);
  vector<ll> da(N+1, 0);
  ll s = 0;
  rep(i, N){
    na.at(i+1) = c.at(i+1) * (c.at(i+1)-1) / 2;
    ba.at(i+1) = (c.at(i+1)-1) * (c.at(i+1)-2) / 2;
    da.at(i+1) = na.at(i+1) - ba.at(i+1);
    s += na.at(i+1);
  }
  rep(i, N){
    cout << s - da.at(A.at(i)) << endl;
  }
}

Measured memory_bytes: 10368
n,k=map(int,input().split())  #n,kに入力
a=list(map(int,input().split()))  #aにA[0]..A[n-1]を入力
ans=0 #答え
S1=0  #一つ目のcount
S2=0  #二つ目のcount

#Aを一回繰り返した時の転倒数
for i in range(n):
  for j in range(n):
    if i<j:
      if a[i]>a[j]:
        S1+=1
        S1%=(10**9+7)
        
#Aを二回繰り返した時の転倒数
for t in range(n):
  for T in range(n):
    if a[t]>a[T]:
      S2+=1
      S2%=(10**9+7)
      
#Aが全て同じ数の時,転倒数は存在しないため"0"を出力,及び実行終了
l=len(list(set(a)))
if l==1:
  print(0)
  exit()

#kから二つ選ぶ個数
if k>=2:
  K=((k*(k-1))//2)%(10**9+7)
elif k==1:
  K=1

#なんて説明すればいいのかわかんない→「そういうことだ（は？）」
ans+=(S1*k)%(10**9+7)
ans+=(S2*K)%(10**9+7)

#念には念を,で%10**9+7
ans%=10**9+7

#答えを出力
print(ans)

Measured memory_bytes: 3188
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    OUT(max(0, a - 2 * b));
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define INF 1 << 28

int main() {
    int N;
    while (cin >> N) {
        if (N == 0) break;
        int x[N];
        int y[N];
        x[0] = y[0] = 0;
        for (int i = 1; i < N; i++) {
            int prev, dir;
            cin >> prev >> dir;
            switch (dir) {
                case 0:
                    x[i] = x[prev] - 1;
                    y[i] = y[prev];
                    break;
                case 1:
                    y[i] = y[prev] + 1;
                    x[i] = x[prev];
                    break;
                case 2:
                    x[i] = x[prev] + 1;
                    y[i] = y[prev];
                    break;
                case 3:
                    y[i] = y[prev] - 1;
                    x[i] = x[prev];
                    break;
            }
        }
        int min_x = 0, min_y = 0;
        int max_x = 0, max_y = 0;
        for (int i = 0; i < N; i++) {
            if (x[i] < min_x) min_x = x[i];
            if (y[i] < min_y) min_y = y[i];
            if (x[i] > max_x) max_x = x[i];
            if (y[i] > max_y) max_y = y[i];
        }
//        cout << "max_x: " << max_x << " min_x: " << min_x << endl;
//        cout << "max_y: " << max_y << " min_y: " << min_y << endl;
        cout << max_x - min_x + 1 << ' ' << max_y - min_y + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, t;
    cin >> n >> t;
    t--;

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

    vvl dp1(n+1, vl(t+1));  // dp1[i+1][j] : 0番目からi番目の料理まででj分以内に食べるときの美味しさの総和の最大値
    dp1[0][0] = 0;
    rep(i, n) {
        rep(j, t+1) {
            chmax(dp1[i+1][j], dp1[i][j]);
            if(j >= a[i]) {
                chmax(dp1[i+1][j], dp1[i][j - a[i]] + b[i]);
            }
        }
    }

    vvl dp2(n+1, vl(t+1));  // dp2[i][j] : n-1番目からi番目の料理まででj分以内に食べるときの美味しさの総和の最大値
    for(ll i = n-1; i >= 0; i--) {
        rep(j, t+1) {
            chmax(dp2[i][j], dp2[i+1][j]);
            if(j >= a[i]) {
                chmax(dp2[i][j], dp2[i+1][j - a[i]] + b[i]);
            }
        }
    }

    ll ans = 0;
    rep(i, n) {  // i番目の料理を最後に食べる
        rep(j, t+1) {  // 0番目からi-1番目までの料理をj分以内に食べるとする(i+1番目からn-1番目までの料理はt-j分以内に食べる)
            chmax(ans, dp1[i][j] + dp2[i+1][t-j] + b[i]);
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 141184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);

		int A=s.nextInt(), B=s.nextInt();
		int C=s.nextInt(), D=s.nextInt();

		System.out.println(Math.max(A*B, C*D));

	}


}


Measured memory_bytes: 35796
#include<bits/stdc++.h>
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MP make_pair
#define pb push_back
#define ff first
#define ss second
#define sz(x) x.size()
#define all(c) c.begin(),c.end()
#define int long long
#define fr(i,j,x) for(int i=j;i<x;i++)
#define rep(i,j,x) for(int i=j;i<=x;i++)
#define mem(x,val) memset(x,val,sizeof(x))
//#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<int,pii>
 
const int mod=1e9+7;
const int N=1e5+10;
const int MAXN=2e6+10;
const int INF=1e18;

void solve(){
    string n;
    cin>>n;
    int ans=0;
    for(char i:n){
        ans+=(i-'0');
    }
    if(ans%9==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


int32_t main()
{
//     #ifndef ONLINE_JUDGE
//         freopen("inputf.in", "r", stdin);
//         //freopen("outputf.in", "w", stdout);
//     #endif
    SPEED;
    int T=1;
    //cin>>T;
    int t1=1;
    while(true)
    {  
        //cout<<"Case #"<<t1<<": ";
        solve();
        t1++;
        if(t1>T)
            break;
    }
}


Measured memory_bytes: 3716
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(x: int, a: int, b: int):
    if abs(a-x) < abs(b-x):
        print("A")
    else:
        print("B")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = int(next(tokens))  # type: int
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(x, a, b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N = 55;
int a[N], b[N], c[N], n, m ,q, ans, tmp[N], d[N];
int check()
{
	int res = 0;
	for (int i = 1; i <= q; i++)
		if (tmp[b[i]] - tmp[a[i]] == c[i])
			res += d[i];
	return res;
}
void dfs(int maxx, int x)
{
	if (x > n)
	{
		ans = max(ans, check());
		return;
	}
	for (int i = maxx; i <= m; i++)
	{
		tmp[x] = i;
		dfs(i, x + 1);
	}
}
int main() 
{
	cin>>n>>m>>q;
	for (int i = 1; i <= q; i++)
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	dfs(1, 1);
	cout<<ans;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9+7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
const int siz = 5*(1e5 + 1);
const int logi = 21;
const double epsilon = 1e-6;
int prime[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}




signed main()
{
 	
	speedrap
	int t;
	t = 1;
	//cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		string s;
		cin>>s;
		int r[n];
		int b[n];
		int g[n];

		for(int i = 0 ; i < n ; i++)
		{
			r[i] = 0;
			g[i] = 0;
			b[i] = 0;
		}

		for(int i = 0 ; i < n ; i++)
		{
			if(s[i] == 'R')
			{
				r[i]++;
			}

			if(s[i] == 'G')
			{
				g[i]++;
			}

			if(s[i] == 'B')
			{
				b[i]++;
			}
		}

		for(int i = 1 ; i < n ; i++)
		{
			r[i] += r[i-1];
			b[i] += b[i-1];
			g[i] += g[i-1];
		}


		int sum = 0;

		for(int i = 0 ; i < n ;i++)
		{
			if(s[i] == 'R')
			{
				// b first
				for(int j = i+1 ; j< n ; j++)
				{
					if(s[j] == 'B')
					{
						int dis = j-i;
						int sub = 0;
						if(j+dis < n)
						{
							if(s[j+dis] == 'G')
							{
								sub++;
							}
						}

						int val = g[n-1] - g[j];

						sum += val-sub; 
					}
				}

				// g first

				for(int j = i+1 ; j<n ; j++)
				{
					if(s[j] == 'G')
					{
						int dis = j-i;
						int sub = 0;

						if(j + dis < n)
						{
							if(s[j+dis] == 'B')
							{
								sub++;
							}
						}

						int val = b[n-1] - b[j];
						sum += val - sub;
					}
				}
			}



			if(s[i] == 'G')
			{
				// R first
				for(int j = i+1 ; j< n ; j++)
				{
					if(s[j] == 'R')
					{
						int dis = j-i;
						int sub = 0;
						if(j+dis < n)
						{
							if(s[j+dis] == 'B')
							{
								sub++;
							}
						}

						int val = b[n-1] - b[j];

						sum += val-sub; 
					}
				}

				// B first

				for(int j = i+1 ; j<n ; j++)
				{
					if(s[j] == 'B')
					{
						int dis = j-i;
						int sub = 0;

						if(j + dis < n)
						{
							if(s[j+dis] == 'R')
							{
								sub++;
							}
						}

						int val = r[n-1] - r[j];
						sum += val - sub;
					}
				}
			}


			if(s[i] == 'B')
			{
				// R first
				for(int j = i+1 ; j< n ; j++)
				{
					if(s[j] == 'R')
					{
						int dis = j-i;
						int sub = 0;
						if(j+dis < n)
						{
							if(s[j+dis] == 'G')
							{
								sub++;
							}
						}

						int val = g[n-1] - g[j];

						sum += val-sub; 
					}
				}

				// g first

				for(int j = i+1 ; j<n ; j++)
				{
					if(s[j] == 'G')
					{
						int dis = j-i;
						int sub = 0;

						if(j + dis < n)
						{
							if(s[j+dis] == 'R')
							{
								sub++;
							}
						}

						int val = r[n-1] - r[j];
						sum += val - sub;
					}
				}
			}
		}

		cout<<sum;
	}
}

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

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i,N) cin >> H.at(i);
    string ans = "Yes";
    if (N > 1) {
        for (int i = N - 1; i > 0; --i) {
            if (H.at(i - 1) - 1 > H.at(i)) {
                ans = "No";
                break;
            } else if (H.at(i - 1) - 1 == H.at(i)) {
                --H.at(i - 1);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3740
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

bool FindLowestPrice(const vector<int> &allowed_nums, const string &price_str, string &lowest_price_str){
    bool start = true;
    int lowest_price = stoi(price_str);
    int inc = 0;
    string cstr;
    while(start){
        lowest_price_str = to_string(lowest_price);
        for(int i = 0; i < lowest_price_str.length(); i++){
            cstr = lowest_price_str[i];
            int num_temp = atoi(cstr.c_str());
            auto itr = find(allowed_nums.begin(),allowed_nums.end(),num_temp);
            if(itr == allowed_nums.end()){
                break;
            }
            inc++;
        }
        if(inc == lowest_price_str.length()){
            return true;
        }
        else{
            inc = 0;
            lowest_price++;
        }
    }
    return true;
}


int main()
{
    //input price and the number of hate numbers
    int price = 0;
    int hate_num_num = 0;
    cin >> price >> hate_num_num;

    //input hate numbers
    vector<int> hate_nums;
    int hate_num_temp = 0;
    for(int i = 0; i < hate_num_num; i++){
        cin >> hate_num_temp;
        hate_nums.push_back(hate_num_temp);
    }

    //search allowed numbers
    vector<int> allowed_nums;
    for(int i = 0; i < 10; i++){
        auto itr = find(hate_nums.begin(), hate_nums.end(), i);
        if(itr == hate_nums.end()){
            allowed_nums.push_back(i);
        }
    }

    //find the lowest price.
    string price_str = to_string(price);
    string lowest_price_str;
    FindLowestPrice(allowed_nums,price_str,lowest_price_str);

    //show the result
    cout << lowest_price_str << endl;

    return 0;
}


Measured memory_bytes: 256
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>

using namespace std;

const int N = 2e6 + 14;
const int INF = 1e9;
const int mod = 1e9;
const int SZ = (1 << 17) - 1;
const int K = 320;

#define eb emplace_back
#define sz(s) (int)(s.size())
#define ppb pop_back

#define ll long long

#define int ll

void solve() {
	int a, b;
	cin >> a >> b;
	int mn = min(a, b);
	int mx = max(a, b);
	for (int i = 1; i <= mx; ++ i) {
		cout << mn;
	}
}

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < int(n); ++ (i))
#define REP3R(i, m, n) for (int i = int(n) - 1; (i) >= int(m); -- (i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;

int main() {
    // input
    int n; scanf("%d", &n);
    vector<ll> a(n); REP (i, n) scanf("%lld", &a[i]);

    // solve
    vector<ll> dp(n);
    vector<int> parent(n, -1);
    dp[0] = a[0];
    REP3 (i, 1, n) {
        dp[i] = a[i];
        for (int j = i - 2; j >= 0; j -= 2) {
            if (dp[i] < dp[j] + a[i]) {
                dp[i] = dp[j] + a[i];
                parent[i] = j;
            }
        }
    }
    int r = max_element(ALL(dp)) - dp.begin();
    ll result = dp[r];
    vector<int> path;
    REP3R (i, r + 1, n) {
        path.push_back(i);
    }
    while (true) {
        int l = parent[r];
        if (l == -1) break;
        while (l != r) {
            path.push_back((r + l) / 2);
            r -= 2;
        }
    }
    while (r != 0) {
        path.push_back(0);
        r -= 1;
    }

    // output
    printf("%lld\n", result);
    printf("%d\n", int(path.size()));
    for (int i : path) {
        printf("%d\n", i + 1);
    }
    return 0;
}


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

using ll = long long;
using ii = pair<int, int>;
using ld = long double;

struct pt {
  ll x, y;
  int dx, dy;

  pt() {}
  pt(ll x, ll y) {}
  pt(ll x, ll y, char d): x(x), y(y) {
    if (d == 'R') dx = 1, dy = 0;
    else if (d == 'U') dx = 0, dy = 1;
    else if (d == 'L') dx = -1, dy = 0;
    else dx = 0, dy = -1;
  }
};

int n;
vector<pt> v;

ld f(ld t) {
  ld x[2] = {LLONG_MAX, LLONG_MIN}, y[2] = {LLONG_MAX, LLONG_MIN};
  for (int i = 0; i < n; i++) {
    x[0] = min(.0L + x[0], v[i].x + v[i].dx * t);
    x[1] = max(.0L + x[1], v[i].x + v[i].dx * t);

    y[0] = min(.0L + y[0], v[i].y + v[i].dy * t);
    y[1] = max(.0L + y[1], v[i].y + v[i].dy * t);
  }

  return (x[1] - x[0]) * (y[1] - y[0]);
}

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

  cin >> n;

  v.reserve(n);

  int x, y;
  char d;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> d;

    v.push_back(pt(x, y, d));
  }

  ld lower = 0, upper = 1LL << 35;
  ld m1, m2;
  for (int i = 0; i < 500; i++) {
    m1 = lower + (upper - lower) / 3;
    m2 = upper - (upper - lower) / 3;

    if (f(m1) < f(m2)) upper = m2;
    else lower = m1;
  }

  cout << fixed << setprecision(12) << f(m1) << endl;
  
  return 0;
}


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

int main(void){
	double a;
	while(cin >> a){
		if(cin.eof()) break;
		double sum=0;
		rep(i,10){
			sum+=a;
			if(i&1)
				a/=3.0;
			else
				a*=2.0;
		}
		cout.precision(10);
		cout << fixed << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;
using namespace std;

template <typename T>
vector<T> dijkstra(int s,vector< vector< pair<int, T> > > & G){
  const T INF = numeric_limits<T>::max();
  using P = pair<T, int>;
  int n=G.size();
  vector<T> ds(n,INF);
  vector<int> bs(n,-1);
  priority_queue<P, vector<P>, greater<P> > pq;
  ds[s]=0;
  pq.emplace(ds[s],s);
  while(!pq.empty()){
    P p=pq.top();pq.pop();
    int v=p.second;
    if(ds[v]<p.first) continue;
    for(auto& e:G[v]){
      int u=e.first;
      T c=e.second;
      if(ds[u]>ds[v]+c){
        ds[u]=ds[v]+c;
        bs[u]=v;
        pq.emplace(ds[u],u);
      }
    }
  }
  return ds;
}

using P = std::pair<int, int>;

ll N, X, Y;
ll ans[2010];
std::vector<std::vector<P>> G;

int main()
{
  std::cin >> N >> X >> Y;

  --X; --Y;

  if( X > Y )
    std::swap( X, Y );

  G.assign( N, std::vector<P>() );

  rep( i, N-1 )
  {
    G[i].emplace_back( P( i+1, 1 ) );
    G[i+1].emplace_back( P( i, 1 ) );
  }

  G[X].emplace_back( P( Y, 1 ) );
  G[Y].emplace_back( P( X, 1 ) );

  rep( i, N )
  {
    auto dist = dijkstra( i, G );

    repi( j, i+1, N )
      ++ans[dist[j]];
  }

  repi( k, 1, N )
    std::cout << ans[k] << std::endl;

  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#define MAX 100000


 int A[MAX];
int partition(int p,int r){
    int x, i, j, t;
    x=A[r];
    i=p-1;
    for(j=p; j<r; j++){
        if(A[j] <= x){
            i++;
            t=A[i];
            A[i]=A[j];
            A[j]=t;
        }
    }
        t=A[i+1];
        A[i+1]=A[r];
        A[r]=t;
      return i+1;
    }


int main(){
    int  n,i;

    scanf("%d", &n);
    int r=n-1;

    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    int q = partition(0,r);

    for(i=0;i<n;i++){
        if(i)
            printf(" ");
         if(i==q)  printf("[");
            printf("%d",A[i]);
         if(i==q)   printf("]");


    }
      printf("\n");
      return 0;
}



Measured memory_bytes: 2172
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
	int n,ans;
	int out;
	bool runner[3];
	string s;
	cin>>n;
	for(int i=0;i<n;i++){
		ans=0;
		out=0;
		memset(runner,false,sizeof(runner));
		while(out<3){
			cin>>s;
			if(s=="OUT")out++;
			if(s=="HIT"){
				if(runner[2]){
					ans++;
					runner[2]=false;
				}
				if(runner[1]){
					runner[2]=true;
					runner[1]=false;
				}
				if(runner[0])runner[1]=true;
				runner[0]=true;
			}
			if(s=="HOMERUN"){
				ans++;
				for(int i=0;i<3;i++){
					if(runner[i]){
						ans++;
						runner[i]=false;
					}
				}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,X;
  cin>>N>>X;
  vector<int>D(N+1);
  D.at(0)=0;
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    D.at(i+1)=D.at(i)+x;
  }
  int ans=0;
  for(int i=0;i<=N;i++){
    if(D.at(i)<=X){
      ans++;
    }
  }
  cout<<ans<<endl;
}


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

int main() {
	string S, T;
	cin >> S >> T;
	for (int i = 0; i < S.length(); i++) {
		if (S == T) {
			cout << "Yes" << endl;
			return 0;
		}
		else S = S.back() + S.substr(0, S.length() - 1);
	}
	cout << "No" << endl;
}

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

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		//final double PI = 3.14159265;
		NScanner sc = new NScanner(System.in);
		for(;;){
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();
			if(op.equals("?"))
				break;
			if(op.equals("+"))
				System.out.println(a + b);
			else if(op.equals("-"))
				System.out.println(a - b);
			else if(op.equals("*"))
				System.out.println(a * b);
			else if(op.equals("/"))
				System.out.println(a / b);
		}
	}

}

class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	private boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


Measured memory_bytes: 24264
#include<bits/stdc++.h>
using namespace std;
//lewlew orz
const int N=2e3+2;
const int mod=1e9+7;
int dp[N],ndp[N];
void add(int &x,int y){
	x+=y;
	if(x>=mod){
		x-=mod;
	}
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,num;
	cin>>n>>num;
	dp[n+1]=1;
	for(i=1;i<=num;i++){
		k=0;
		for(j=n;j>0;j--){
			add(k,dp[j+1]);
			ndp[j]=k;
			if(i-1<n-j+1&&j>1){
				add(ndp[j],dp[j]);
			}
		}
		for(j=1;j<=n+1;j++){
			dp[j]=ndp[j];
		}
	}
	for(i=1;i<=n-num-1;i++){
		add(dp[1],dp[1]);
	}
	cout<<dp[1];
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int calc(int n){
	return (n % 2 == 0) ? n/2 : 3*n+1 ;
}

int main()
{
	int N;

	while(cin >> N && N)
	{
		int tmp=N, cnt=0;

		while(true)
		{	
			if(tmp == 1){ break; }
			cnt++;
			tmp = calc(tmp);
		}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

const int MAX_N = 1e5 + 5;

ll arr [MAX_N];

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

  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }

  sort(arr, arr + n);
  reverse(arr, arr + n);

  int pr = 0;
  ll last = 0;
  for (int i = 0; i < n; i++) {
    if (pr && arr[i - 1] == arr[i]) {
      if (last != 0) {
        cout << last * arr[i] << endl;
        return 0;
      } else {
        last = arr[i];
      }
      pr = 0;
    } else if (!pr) pr = 1;
  }

  cout << 0 << endl;
}


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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define MP make_pair
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double EPS = 1e-9;
const double PI = acos(-1);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

ll addMod(ll a, ll b){
	return (a+b+MOD*1000) % MOD;
}

ll mulMod(ll a, ll b){
	return (a*b) % MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp, tmp);
	if(b & 1) tmp = mulMod(tmp, a);
	return tmp;
}

/////////////////////////////////////////////////////////

const int N = 1e5;

int n;
string str;
int cnt[30];

ll solve(){
	memset(cnt,0,sizeof cnt);
	ll ret = 1;
	FOR(i,n){
		int c = str[i] - 'a';
		cnt[c]++;
	}
	FOR(i,26){
		ret = mulMod(ret, cnt[i]+1);
	}
	return addMod(ret,-1);
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> str;
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int d1 = c-a;
    int d2 = d-b;
    cout << c - d2 << " ";
    cout << d + d1 << " ";
    cout << a - d2 << " ";
    cout << b + d1 << " ";


    return 0;
}

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

std::vector<int64_t> nums;

void search(int64_t v) {
    if (std::to_string(v).size() == 10) {
        return;
    }

    const int64_t l = v % 10;
    const int64_t b = v * 10;
    if (l == 0) {
        nums.push_back(b + 0);
        search(b + 0);
        
        nums.push_back(b + 1);
        search(b + 1);
    } else if (l == 9) {
        nums.push_back(b + 8);
        search(b + 8);

        nums.push_back(b + 9);
        search(b + 9);
    } else {
        nums.push_back(b + l - 1);
        search(b + l - 1);

        nums.push_back(b + l);
        search(b + l);
        
        nums.push_back(b + l + 1);
        search(b + l + 1);
    }
}

int main() {
    int64_t K;
    std::cin >> K;

    for (int64_t i = 1; i < 10; ++i) {
        nums.push_back(i);
        search(i);
    }

    std::sort(nums.begin(), nums.end());

    std::cout << nums[K-1] << std::endl;

    return 0;
}


Measured memory_bytes: 2420
#include<iostream>

int main(){

    while(true){
        size_t h, w;
        std::cin >> h >> w;

        if(h == 0 && w == 0) break;

        for(size_t i = 0; i < h; i++){
            for(size_t j = 0; j < w; j++){
                if(i != 0 && i != h - 1){
                    if(j == 0 || j == w - 1){
                        std::cout << '#';
                    }else{
                        std::cout << '.';
                    }
                }else{
                    std::cout << '#';
                }
            }std::cout << std::endl;
        }
        std::cout << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3072
import java.util.*;

class Main {
    private final String defaultN;
    private StringBuilder fixedN;

    Main(String n) {
        this.defaultN = n;
        this.fixedN = new StringBuilder();
    }

    void generateFixedN() {
        for (int i = 0; i < defaultN.length(); i++) {
            fixedN.append(defaultN.charAt(i) == '1' ? '9' : '1');
        }
    }
    
    String getFixedN() {
        return this.fixedN.toString();
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.nextLine();
        Main m = new Main(n);
        m.generateFixedN();
        System.out.println(m.getFixedN());
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;


const ll MAXN=300000;

ll bit[MAXN];
void add(ll a, ll w) {
for (ll x = a; x <= MAXN; x += (x & -x)) bit[x] += w;
}
ll sum(ll a) {
 ll ret = 0;
for (ll x = a; x > 0; x -= (x & -x)) ret += bit[x];
 return ret;
}
//Comb

int main(){
    ll N; cin>>N;
    vec d(N+1);
    REP(i,1,N+1) cin>>d[i];
    ll ans=0;
    REP(i,1,N+1){
        ll K=d[i]+i;
        ll S=i-d[i];
        if(S>1 && S<MAXN){
            ans+=(sum(S)-sum(S-1));
        }
        if(K<MAXN) add(K,1);
    }
    cout<<ans<<endl;



}


Measured memory_bytes: 7204
#include <stdio.h>
const int SIZE = 100;
int data[SIZE];
int sp= 0;

int size(){
 return sp;
}

int top(){ return data[sp-1];
}
void pop(){
 sp--;
}

void push(int v){
 data[sp] = v;
 sp++;
}

int main(){
 int v;
 while(scanf("%d", &v) != EOF){
  if(v != 0){
    push(v);
  }
  if(v == 0){
   printf("%d\n", top());
   pop();
  }
 }
 return 0;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if((A+B) > (C+D)){
    cout << "Left" << endl;
  }
  else if((A+B) == (C+D)){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
   
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a < b){
        printf("a < b\n");
    }
    if(a > b){
        printf("a > b\n");
    }
    if(a == b){
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  string ans=string(tx-sx,'R')+string(ty-sy,'U')+string(tx-sx,'L')+string(ty-sy+1,'D')+string(tx-sx+1,'R')+string(ty-sy+1,'U')+"LU"+string(tx-sx+1,'L')+string(ty-sy+1,'D')+"R";
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  for(int i=0;i<N;i++){
    cin >> D.at(i);
  }
  sort(D.begin(),D.end());
  cout << D.at(N/2)-D.at(N/2-1) <<endl;


}


Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>

#define N 10000

int main(){
  int count=0,n,i,j;
  int array[N];

  scanf("%d",&n);

  for(i=0; i<n; i++) scanf("%d",&array[i]);

  for(i=0; i<n; i++){

    for(j=2; j<=sqrt((double) array[i]); j++){

      if(array[i]%j == 0){

	count ++;
	break;

      }
    }
  }

  printf("%d\n",n-count);
  return 0;
}

Measured memory_bytes: 632
function main(input) {
  var args = input.split("\n");
  var a = parseInt(args[0], 10);
  var b = parseInt(args[1], 10);
  var c = parseInt(args[2], 10);
  var d = parseInt(args[3], 10);
  var e = parseInt(args[4], 10);
  
  var num= [a, b, c, d, e];
  
  for(i=0; i<num.length; i++){
    if(num[i]%10 == 0){
      num[i] = num[i] -1;
    }
  }
  
  var a_1 = num[0] % 10; 
  var b_1 = num[1] % 10; 
  var c_1 = num[2] % 10; 
  var d_1 = num[3] % 10; 
  var e_1 = num[4] % 10;
  
  var a_min = parseInt((a-1)/10) * 10 +10;
  var b_min = parseInt((b-1)/10) * 10 +10;
  var c_min = parseInt((c-1)/10) * 10 +10;
  var d_min = parseInt((d-1)/10) * 10 +10;
  var e_min = parseInt((e-1)/10) * 10 +10;
  
  var min = Math.min(a_1, b_1, c_1, d_1, e_1);
  
  if(min == a_1){
    console.log(a+b_min+c_min+d_min+e_min);
  }else if(min == b_1){
    console.log(a_min+b+c_min+d_min+e_min);
  }else if(min == c_1){
    console.log(a_min+b_min+c+d_min+e_min);
  }else if(min == d_1){
    console.log(a_min+b_min+c_min+d+e_min);
  }else if(min == e_1){
    console.log(a_min+b_min+c_min+d_min+e);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
// 1次元 vector
template <class T>
ostream &operator<<(ostream &s, vector<T> vec) {
    for (int i = 0; i < (int)vec.size(); ++i) {
        if (i > 0) {
            s << " ";
        }
        s << vec[i];
    }
    return s << endl;
}
template <class T>  // 2次元 vector
ostream &operator<<(ostream &s, vector<vector<T>> vec2) {
    for (int i = 0; i < (int)vec2.size(); ++i) {
        s << vec2[i];
    }
    return s;
}
using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int H, W;
    cin >> H >> W;
    auto S = make_vec<char>(H, W);
    auto num = make_vec<int>(4, H, W);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> S[i][j];
        }
    }

    for (int i = 0; i < H; i++) {
        int ok = 0;
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '#') {
                ok = j + 1;
            }
            num[0][i][j] = ok;
        }
        int ob = W;
        for (int j = W - 1; j >= 0; j--) {
            if (S[i][j] == '#') {
                ob = j;
            }
            num[1][i][j] = ob;
        }
    }
    for (int j = 0; j < W; j++) {
        int ok = 0;
        for (int i = 0; i < H; i++) {
            if (S[i][j] == '#') {
                ok = i + 1;
            }
            num[2][i][j] = ok;
        }
        int ob = H;
        for (int i = H - 1; i >= 0; i--) {
            if (S[i][j] == '#') {
                ob = i;
            }
            num[3][i][j] = ob;
        }
    }

    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] != '#') {
                chmax(ans, num[1][i][j] - num[0][i][j] + num[3][i][j] - num[2][i][j] - 1);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 82688
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    int d[100];
    for(int i=0;i<n;i++)
        cin >> d[i];
    //dを降順にソート
    sort(d, d + n, greater<int>());
    int count = 0;
    int num = 0;
    for(int i=0;i<n;i++){
        if(num != d[i])
            count++;
        num = d[i];
    }
    cout << count << '\n';
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int mod=998244353,N=2e5+5;
int f[N],n,ans,a[N];
bool ok[N];

bool check(int x){
	for(int i=0,p=0;i<n;i+=x,p^=1) for(int j=1;j<=x;++j){
		if(a[i+j]>(a[j]^p)) return 1;
		if(a[i+j]<(a[j]^p)) return 0;
	}
	return 1;
}

void calc(int x){
	int tot=0;
	for(int i=1;i<=x;++i) tot=((tot<<1)+a[i])%mod;
	tot+=check(x);
	f[x]=(f[x]+tot)%mod;
	for(int i=x+x;i<=n;i+=x) if(ok[i]) f[i]=(f[i]-f[x]+mod)%mod;
}

signed main(){
	read(n);
	for(int i=1;i<=n;i++) scanf("%1d",&a[i]);
	for(int i=1;i<=n;i++) ok[i]=n%i==0&&(n/i&1);
	for(int i=1;i<=n;i++) if(ok[i]) calc(i);
	for(int i=1;i<=n;i++) ans=(ans+2ll*i*f[i])%mod;
	write(ans);
}

Measured memory_bytes: 4684
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
using namespace std;

static const int N = 100;
static const int INF = 1e9;

int h , w;
int sy, sx, gy, gx;
int d[N][N];
bool used[N][N];
vector<string> S;

int bfs(int sh, int sw){
    queue<pair<int, int> > Q;
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) used[i][j] = false;
    for(int i = 0; i < h; i++) for(int j = 0; j < h; j++) d[i][j] = INF;

    used[sh][sw] = true;
    d[sh][sw] = 0;
    Q.push(make_pair(sh, sw));//全てはスタート地点をqueueに突っ込んでからは閉まる
    while(!Q.empty()){
        pair<int,int> u = Q.front();Q.pop();
        int th = u.first, tw = u.second;
        used[th][tw] = true;
        if(th + 1 < h && !used[th+1][tw] && S[th+1][tw] == '.'){
            Q.push(make_pair(th+1,tw));
            used[th+1][tw] = true;
            d[th+1][tw] = d[th][tw] + 1;
        }
        if(th - 1 >= 0 && !used[th - 1][tw] && S[th-1][tw] == '.'){
            Q.push(make_pair(th-1,tw));
            used[th - 1][tw] = true;
            d[u.first - 1][tw] = d[th][tw] + 1;
        }
        if(tw + 1 < w && !used[th][tw+1] && S[th][tw+1] == '.'){
            Q.push(make_pair(th,tw+1));
            used[th][tw+1] = true;
            d[u.first][tw+1] = d[th][tw] + 1;
        }
        if(tw - 1 >= 0 && !used[th][tw-1] && S[th][tw-1] == '.'){
            Q.push(make_pair(th,tw-1));
            used[th][tw-1] = true;
            d[u.first][tw-1] = d[th][tw] + 1;
        }
    }
    int ans = 0;
    rep(i, 0, h) rep(j, 0, w) if(d[i][j] != INF) ans = max(ans, d[i][j]);
    return ans;
}
int main(){
    cin >> h >> w;
    S.resize(h);
    for(int i = 0; i < h; i++) cin >> S[i];

    int ans = 0;
    
    rep(i, 0, h) rep(j, 0, w) if(S[i][j] == '.') ans = max(bfs(i,j), ans);

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 5)PRI(0);
	else if (a <= 12)PRI(b / 2);
	else PRI(b);
	return 0;
}

Measured memory_bytes: 3616
import sys
A,B,C,D = map(int,input().split())

if not (1 <= A <= 10 and 1 <= B <= 10 and 1 <= C <= 10 and 1 <= D <= 10):
    sys.exit()

if A + B > C + D:
    print('Left')
elif A + B == C + D:
    print('Balanced')
elif A + B < C + D:
    print('Right')

Measured memory_bytes: 9180
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define setp(x) setprecision(x)
#define nep(x) next_permutation(x);
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main() {
    int N;
    cin >> N;
    vector<int> val(N);
    for(int i = 0; i < N; i++) cin >> val[i];
    sort(all(val));
    int sum = 0;
    double half = val[0];
    for(int i = 1; i < N; i++){
        half = (half + val[i]) / 2;
    }
    cout << half << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int min = 30;
  
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    
    int x = 0;
    
    while (A % 2 == 0) {
      A /= 2;
      x++;
    }
    
    if (x <= min) {
      min = x;
    }
  }
      
  cout << min << endl;
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define ull unsigned long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
#define ti4 tuple<int,int,int,int>
int MOD=1000000000+7;
int INF=1e9;
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");
main(){
    int n;
    cin>>n;
    bitset<4000000> b;
    b.set(0);
    int sum=0;
    rep(i,n){
        int a;
        cin>>a;
        sum+=a;
        b=b|(b<<a);
    }
  
    b>>=(sum+1)/2;
    rep(i,2000000){
        if(b[0]){ cout<<(sum+1)/2+i; return 0;}
        b>>=1;
    }
}

Measured memory_bytes: 2304
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i,n)   for (int i = 0; i < (n); ++i)
#define SORT(a)    sort((a).begin(), (a).end());
#define UNIQ(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define FIND(a,x)  find((a).begin(), (a).end(), (x)) != (a).end()
#define REVERSE(a) reverse((a).begin(), (a).end());

using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MOD = 1000000007; // 10^9 + 7

ll dfs(string str) {
  int len = str.size();
  if (len == 0) return 0;
  if (len == 1) return str[0] - '0';

  ll ret = stoll(str);
  int left = 0;
  for (int i = 0; i < len - 1; i++) {
    left = left * 10 + (str[i] - '0');

    string ss = str.substr(i + 1, len - i - 1);

    ret += left * pow(2, len - i - 2) + dfs(ss);
  }
  return ret;
}

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

  string s; cin >> s;

  cout << dfs(s) << endl;
}

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

#define int long long
const int mxN = 1e5+10;
int a[mxN], dp[mxN];
int n;

int min_cost(int i) {
    if(dp[i] != -1) 
        return dp[i];

    if(i == n-1) {
        dp[i] = 0;
        return dp[i];
    }
    
    if(i == n-2) {
        dp[i] = abs(a[i+1]-a[i]);
        return dp[i];
    }

    dp[i] = min(abs(a[i+1]-a[i]) + min_cost(i+1), abs(a[i+2]-a[i]) + min_cost(i+2));
    return dp[i];
}

void solve() {
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> a[i];

    memset(dp, -1, sizeof(dp));
    int ans = min_cost(0);
    cout << ans << endl;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;

signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	char c;
	cin>>c;
	c++;
	cout<<c<<endl;
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <valarray>

using namespace std;


main()
{
    int h,w; cin>>h>>w;
    vector<string> s(h);
    for(auto &ss:s) cin>>ss;
    queue<tuple<int,int,int>> que;
    que.emplace(0,0,1);
    int ans=1e9;
    bool is[55][55]={};
    is[0][0]=1;
    for(int i=0; i<h; ++i)
        for(int j=0; j<w; ++j)
            if(s[i][j]=='#') is[i][j]=1;
    while(!que.empty())
    {
        int x,y,d; tie(x,y,d)=que.front();
        que.pop();
        if(x==h-1 && y==w-1) ans=d;
        int dx[]={1,0,-1,0};
        int dy[]={0,1,0,-1};
        for(int i=0;i<4;++i)
        {
            int xx=x+dx[i];
            int yy=y+dy[i];
            if(size_t(xx)<h and size_t(yy)<w and !is[xx][yy])
            {
                is[xx][yy]=1;
                que.emplace(xx,yy,d+1);
            }
        }
    }
    if(ans==1e9)
    {
        cout << -1 << "\n";
    }
    else
    {
        int w{};
        for(auto &r:s)
        {
            for(auto &e:r)
            {
                if(e=='.') w++;
            }
        }
        cout << w-ans << "\n";
    }
}


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int h, w, d[52][52] = {0};
char c[52][52];

int main(){
	cin >> h >> w;
	int cnt = 0;
	for(int i = 0; i <= h+1; i++){
		for(int j = 0; j <= w+1; j++){
			if(i == 0 || i == h+1 || j == 0 || j == w+1){
				c[i][j] == '#';
			}
			else{
				cin >> c[i][j];
				if(c[i][j] == '.') cnt++;
			}
		}
	}
	
	queue<P> q;
	q.push(P(1,1));
	c[1][1] == '#';
	d[1][1] = 1;
	bool b = 0;
	while(q.size()){
		P p = q.front();
		q.pop();
		if(p.first==h && p.second == w){
			cout << cnt - d[p.first][p.second] << endl;
			b = 1;
			break;
		}
		int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
		for(int i = 0; i < 4; i++){
			if(c[(dx[i] + p.first)][(dy[i] + p.second)] == '.'){
				c[(dx[i] + p.first)][(dy[i] + p.second)] = '#';
				q.push(P(dx[i] + p.first, dy[i] + p.second));
				d[dx[i] + p.first][dy[i] + p.second] = d[p.first][p.second]+1;
			}
		}
	}
	if(!b) cout << -1 << endl;
	
	return 0;
}

Measured memory_bytes: 256