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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
#define dbg(x) cerr << #x"= " << x << endl

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(1);
	int n,m;cin>>n>>m;
	vector<string> s(n);
	FOR(i,n) cin>>s[i];
	ui d[n][m][n][m];
	FOR(i,n)FOR(j,m)FOR(i2,n)FOR(j2,m)d[i][j][i2][j2]=INF;
	FOR(i,n)FOR(j,m) {
		if (s[i][j]=='#') continue;
		d[i][j][i][j]=0;
		if (i && s[i-1][j]=='.') d[i][j][i-1][j]=1;
		if (i+1<n && s[i+1][j]=='.') d[i][j][i+1][j]=1;
		if (j && s[i][j-1]=='.') d[i][j][i][j-1]=1;
		if (j+1<m && s[i][j+1]=='.') d[i][j][i][j+1]=1;
	}
	FOR(i,n){
		FOR(j,m){
			if (s[i][j]=='#') continue;
			FOR(i2,n){
				FOR(j2,m){
					if (s[i2][j2]=='#') continue;
					FOR(i3,n){
						FOR(j3,m){
							if (s[i3][j3]=='#') continue;
							d[i2][j2][i3][j3] = min(d[i2][j2][i3][j3],d[i2][j2][i][j]+d[i][j][i3][j3]);
						}
					}
				}
			}
				
		}
	}
	ui mx=0;
	FOR(i,n)FOR(j,m)FOR(i2,n)FOR(j2,m) if (d[i][j][i2][j2]<INF) mx=max(mx,d[i][j][i2][j2]);
	cout << mx;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

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

#define INF INT_MAX/3
#define MAX_N 1000

void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  string s,ans ="";
  ll p = 0;
  rep(i,3){
    cin>>s;
    ans+=s[p];
    p++;
  }
  cout<<ans<<endl;

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


Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main()
{
   int x ,y, temp, i;
   
   for(i = 1; i <= 3000; i++)
   {
       
        cin >> x >> y;
        if(x > y)
       {
           temp = x;
           x = y;
           y = temp;
       }
       
       
       if(x == 0 && y == 0)
          break;
   
       cout << x << " " << y << endl;\
   }
}


Measured memory_bytes: 3004
// author - shreyanshjn (Shreyansh Jain)
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair <int,int> PII;
typedef pair <ll, ll> PLL;
typedef pair <int,string> PIS;
typedef vector <int> vec;
typedef priority_queue<int> PQ;
/* #define input 1 */
#define INF 100000000000000000
#define endl '\n'
#define debug(x) cout<<#x<<": "<<x<<endl
#define pi 3.141592653589793
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define sz(x) (int)(x).size()
#define len(x) (int)x.length()
#define rep(a,b,c) for(int a=b; a<c; a++)
#define fori(z,n)  for(int i=z;i<n;i++)
#define fork(z,n)  for(int k=z;k<n;k++)
#define forii(z,n) for(int i=z;i<=n;i++)
#define forkk(z,n) for(int k=z;k<=n;k++)
const int mod = 1e9 + 7;
int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
string trim(const string& str) {
    size_t first = str.find_first_not_of(' ');
    if (string::npos == first)
    {
        return str;
    }
    int last = str.find_last_not_of(' ');
    return str.substr(first, (last - first + 1));
}
int main() { 
    #ifdef input
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(15);
    int n, k; cin >> n >> k;
    int arr[n + 1];
    fori(1, n + 1) cin >> arr[i];
    int dp[k + 1];
    memset(dp, false, sizeof(dp));
    fori(1, k + 1) {
        for(int p = 1; p <= n; p++) {
            if(i - arr[p] >= 0 and !dp[i - arr[p]]) {
                dp[i] = true;
            }
        }
    }
    dp[k] ? cout << "First" : cout <<"Second";
    cout << endl;
    cerr<<"Time elapsed"<<1.0*clock()/CLOCKS_PER_SEC<<"s\n";
    return 0;
}

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

int main(){
    int n; 
    cin >> n;
    int ans = (n % 2 == 0) ? n/2 : n/2 + 1; 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int num[1000000];
int main()
{
	int n, k, ans = 0, anss = 0;
	while (1)
	{
		scanf("%d%d", &n, &k);
		if (n == 0 && k == 0)
			break;
		num[0] = 0;
		for (int i = 1; i <= n; i++)
		{
			scanf("%d", &num[i]);
			num[i] = num[i] + num[i - 1];
		}
		for (int i = k; i <=n; i++)
		{
			anss = num[i] - num[i - k];
			if (ans < anss)
				ans = anss;
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int main(){
 int n,m,sum=0;
 cin >> n >> m;
 vector<int> a(m);
 rep(i,m){
   cin >> a[i];
   sum += a[i];
 }
 if(sum>n) cout << -1 << endl;
 if(sum<=n) cout << n-sum << endl;
}
 

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

#define Darr(x)           \
    cerr << #x << " = ";  \
    for (auto i : x)      \
        cerr << i << " "; \
    cerr << "\n";
#define ar array
#define pr pair
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i = (a); (s) > 0 ? i < (b) : i > (b); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
    F_ORC(__VA_ARGS__) \
    (__VA_ARGS__)
#define EACH(x, a) for (auto &x : a)

template <class A>
void read(vt<A> &v);
template <class A, size_t S>
void read(ar<A, S> &a);
template <class T>
void read(T &x)
{
    cin >> x;
}
void read(double &d)
{
    string t;
    read(t);
    d = stod(t);
}
void read(long double &d)
{
    string t;
    read(t);
    d = stold(t);
}
template <class H, class... T>
void read(H &h, T &... t)
{
    read(h);
    read(t...);
}
template <class A>
void read(vt<A> &x)
{
    EACH(a, x)
    read(a);
}
template <class A, size_t S>
void read(array<A, S> &x)
{
    EACH(a, x)
    read(a);
}
string to_string(char c)
{
    return string(1, c);
}
string to_string(bool b)
{
    return b ? "yes" : "no";
}
string to_string(const char *s)
{
    return string(s);
}
string to_string(string s)
{
    return s;
}
string to_string(vt<bool> v)
{
    string res;
    FOR(sz(v))
    res += char('0' + v[i]);
    return res;
}

template <size_t S>
string to_string(bitset<S> b)
{
    string res;
    FOR(S)
    res += char('0' + b[i]);
    return res;
}
template <class T>
string to_string(T v)
{
    bool f = 1;
    string res;
    EACH(x, v)
    {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template <class A>
void write(A x)
{
    cout << to_string(x) << " ";
}
template <class H, class... T>
void write(const H &h, const T &... t)
{
    write(h);
    write(t...);
}
void print()
{
    cout << ("\n");
}
template <class H, class... T>
void print(const H &h, const T &... t)
{
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

void deb() { cerr << endl; }

template <typename Head, typename... Tail>
void deb(Head H, Tail... T)
{
    cerr << to_string(H) << " ";
    deb(T...);
}

using ll = long long;

pair<const int, const int> dxdy[4] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};

// Let's Code

const int MxN = (1 << 19) + 1;
ll dp[MxN][19] = {0};
ll cost[19][19];
void solve()
{string s;
read(s);
int ans=0;
FOR(s.size()){
    ans+= (s[i]-'0');
    ans%=9;
}
write((ans==0)?"Yes":"No");

}
//

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    // /freopen("output.txt", "w", stdout);
#endif

    int tc = 1;

    //UNCOMMENT FOR TEST CASE
    //cin >> tc;
    FOR(tc)
    {
        //write("Case #", i+1, ": ");
        solve();
    }
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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 (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

int numofbits(ll bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}
 
int main() {
    int N, K; cin >> N >> K;
    vel a(N); rep(i,N) cin >> a[i];
    ll ans = 1e18;
    for(int bits = 0; bits < (1<<N); bits++) {
        if(numofbits(bits) < K) continue;
        ll temp = 0;
        ll now = 0;
        rep(i,N) {
            if((bits >> i) & 1) {
               temp += max(0LL, (now + 1) - a[i]);
                now = max(now + 1, a[i]);
                continue;
            }
            now = max(now, a[i]);
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=100005;

int n,cnt,last[N],f[N],g[N];
struct edge{int to,next;}e[N*2];

int read()
{
    int x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

void addedge(int u,int v)
{
    e[++cnt].to=v;e[cnt].next=last[u];last[u]=cnt;
    e[++cnt].to=u;e[cnt].next=last[v];last[v]=cnt;
}

void dp(int x,int fa)
{
    int mx=-n;
    for (int i=last[x];i;i=e[i].next)
    {
        if (e[i].to==fa) continue;
        dp(e[i].to,x);
        g[x]+=max(g[e[i].to],f[e[i].to]);
        mx=max(mx,g[e[i].to]-f[e[i].to]);
    }
    if (mx>=0) f[x]=g[x]+1;
    else if (mx>-n) f[x]=g[x]+mx+1;
}

int main()
{
    n=read();
    for (int i=1;i<n;i++)
    {
        int x=read(),y=read();
        addedge(x,y);
    }
    dp(1,0);
    if (max(f[1],g[1])==n/2&&!(n&1)) puts("Second");
    else puts("First");
    return 0;
}

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

/*** Template Begins ***/

typedef long long                   ll;
typedef pair<int,int>               PII;
typedef pair<ll, pair<int, int> >   PIII;
typedef vector<int>                 vi;
typedef vector<pair<int, int> >     vii;

#define endl         '\n'
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
#define all(a)       (a).begin(),(a).end()
#define fr(i,a,b)    for(int i=a;i<=b;i++)
#define lp(i,a)      for(int i=0;i< a;i++)

// Debug //

#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

// Constants //

const int N = 1e5+7;
const int xinc[] = {0, 0, 1, -1};
const int yinc[] = {1, -1, 0, 0};
const long double PI = acos(-1.0);

/*** Template Ends ***/
int n, a[N], dp[N], x;
bool valid[N];
int m;

void solve() {
    
    memset(valid, true, sizeof valid);
    cin >> n >> m;
    lp(i,m) {
        cin >> x;
        valid[x] = false;
    }
    dp[0] = 1;
    fr(i,1,n) {
        if (valid[i])
            dp[i] = (dp[i-1] + (i-2 >= 0 ? dp[i-2] : 0))%hell; 
        //trace2(i, dp[i]); 
    }
    cout << dp[n] << endl;
}

signed main() {
    
    ios;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t;
    //cin >> t;
    t = 1;
    while(t--)
        solve();

    return 0;
}

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

int main() {
    int q,h,s,d;
    cin >> q >> h >> s >> d;
    long long n;
    cin >> n;
    long long ans=1LL<<60;
    long long x=min({4*q,2*h,s});
    {
        long long res=n*x;
        ans=min(ans,res);
    }
    {
        long long res=n/2*d+(n%2)*x;
        ans=min(ans,res);
    }
    cout << ans << '\n';
    return 0;
}

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

int main(){
  int n;
  string s,t;
  cin>>n>>s>>t;
  for(int i=0;i<n;i++){
    int count=0,log=i;
    for(int j=0;j<n-i;j++){
      if(s.at(log)==t.at(j)){
        count++;
        log++;
      }else break;
    }
    if(count==n-i){
      cout<<n+i<<endl;
      return 0;
    }
  }
  cout<<2*n<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100010; //check the limits, dummy
 
vector<vi> graph;
ll fact[MX];
ll K;
ll ans = 1;
 
void dfs(int v, int p) 
{
    int countAvail = K - 1;
    if (p != -1) 
    countAvail=K-2;
    F0R(i, sz(graph[v])) 
    {
    	int nxt = graph[v][i];
        if (nxt == p) continue;
        if (countAvail <= 0) {/// means that the k is small bro
            ans = 0;
            return;
        }
        ans = ans * countAvail;
        countAvail--;
        ans = ans % MOD;
        dfs(nxt, v);
    }
}
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int N; cin >> N; F0R(i, N) {
        vi blank; graph.pb(blank);
    }
 
    cin >> K;
 
    F0R(i, N-1) {
        int A, B; cin >> A >> B; A--; B--;
        graph[A].pb(B); graph[B].pb(A);
    }
 
    ans = K;
 
    dfs(0, -1);
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 10608
<?php
fscanf(STDIN, "%d %d %d %d", $a, $b, $c, $d);
$p = $q = $x = 0;
for ($t = 0; $t <= 100; $t++) {
	if ($t == $a) $p = 1;
	if ($t == $b) $p = 0;
	if ($t == $c) $q = 1;
	if ($t == $d) $q = 0;
	if ($p && $q) $x++;
}
echo $x;


Measured memory_bytes: 4728
#include <stdio.h>
#include <string.h>
int main(void){
    
    int i,a[26]={0};
    char s[100001];
    
    scanf("%s",s);
    
    for(i=0;i<strlen(s);i++){
        if(a[s[i]-'a']==0) a[s[i]-'a']=1;
    }
    
    for(i=0;i<26;i++){
        if(a[i]==0){
            printf("%c\n",'a'+i);
            return 0;
        }
    }
    printf("None\n");
    return 0;
}


Measured memory_bytes: 1828
def solve(n, x0, X):

    def gcd(a, b):
        if a > b:
            a, b = b, a
        while a % b != 0:
            a, b = b, a % b
        return b

    X = [abs(x - x0) for x in X]
    g = X.pop()
    for x in X:
        g = gcd(g, x)
    return g

_n , _x0 = map(int, input().split())
_X = map(int, input().split())
print(solve(_n, _x0, _X))


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

int main(){
    vector<int> N;
    int sum = 0;
    bool flag = true;
    for(int i = 0; i < 4; i++){
        int n; cin >> n;
        sum += n;
        if(n != 1 && n != 4 && n != 7 && n != 9){
            flag = false;
        }
    }
    if(flag){
        if(sum == 21) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
use std::io;
use std::cmp;


/// https://beta.atcoder.jp/contests/arc078/tasks/arc078_a
fn main() {
    let n = read_one::<usize>();
    let an = read::<isize>();
    let all = an.iter().sum::<isize>();
    let mut ans = ::std::isize::MAX;
    let mut sum = 0;
    for i in 0..n - 1 {
        sum += an[i];
        ans = cmp::min(ans, (all - 2 * sum).abs());
    }

    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, Y;
    cin >> N >> Y;
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N - i; j++){
            int k = N - i - j;
            if(i * 10000 + j * 5000 + k * 1000 == Y){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  set<int> S;
  for (int i = 0; i < N; i++){
    int A;
    cin >> A;
    if (!S.count(A)){
      S.insert(A);
    } else {
      S.erase(A);
    }
  }
  cout << S.size();
}

Measured memory_bytes: 4864
/// sultanov_       
/// @bachaquer TOP
 
#include<bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
#define size(x) (int) x.size()
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;                                   
 
const int INF32 = INT_MAX;
const ll INF64 = ((ll)INF32 << 29ll);

void reflex() {                   
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr); 
}   

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

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

int main() {
	int n, point[4], count;
	char str[50];

	while (cin >> n != NULL) {
		getchar();
		for (int i = 0; i < n; i++) {
			memset(point, 0, sizeof(point));
			count = 0;
			while (count != 3) {
				cin >> str;
				if (strcmp(str, "HIT") == 0) {
					for (int j = 2; j >= 0; j--) {
						if (point[j]) {
							point[j] = 0;
							point[j+1] += 1;
						}
					}
					point[0] = 1;
				} else if (strcmp(str, "OUT") == 0) {
					count++;
				} else if (strcmp(str, "HOMERUN") == 0) {
					int c = 0;
					for (int j = 0; j < 3; j++) {
						if (point[j])
							c++;
						point[j] = 0;
					}
					point[3] += c + 1;
				}
			}
			cout << point[3] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <unordered_set>
#include <unordered_map>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

ll H, W, N;
typedef tuple<int, int> point;
set<point> S;

bool valid(int x, int y) {
  return 0 <= x && x < H && 0 <= y && y < W;
}

ll ans[10];

int main () {
  cin >> H >> W >> N;
  for (auto i = 0; i < N; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    S.insert(point(a, b));
  }
  for (auto x : S) {
    int a = get<0>(x);
    int b = get<1>(x);
    for (auto i = 0; i < 3; ++i) {
      for (auto j = 0; j < 3; ++j) {
        int ka = a - i;
        int kb = b - j;
        int cnt = 0;
        bool ok = true;
        for (auto k = 0; k < 3; ++k) {
          for (auto l = 0; l < 3; ++l) {
            int na = ka + k;
            int nb = kb + l;
            if (!valid(na, nb)) {
              ok = false;
            } else {
              if (S.find(point(na, nb)) != S.end()) {
                cnt++;
              }
            }
          }
        }
        if (ok) {
          ans[cnt]++;
        }
      }
    }
  }
  ll sum = 0;
  for (auto i = 1; i < 10; ++i) {
    ans[i] /= i;
    sum += ans[i];
  }
  ans[0] = (H-2) * (W-2) - sum;
  for (auto i = 0; i < 10; ++i) {
    cout << ans[i] << endl;
  }

}


Measured memory_bytes: 4992
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	arr := make([]int, n)
	mx1 := 0
	mx2 := 0
	for i := 0; i < n; i++ {
		arr[i] = sc.NextInt()
		if arr[i] > mx1 {
			mx2 = mx1
			mx1 = arr[i]
		} else if arr[i] > mx2 {
			mx2 = arr[i]
		}
	}
	//	fmt.Printf("%+v %v\n", mx1, mx2) // output for debug

	for i := 0; i < n; i++ {
		if arr[i] == mx1 {
			fmt.Printf("%+v\n", mx2) // output for debug
		} else {
			fmt.Printf("%+v\n", mx1) // output for debug
		}
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int main()
{
  FASTIO;
  long long int n,a,b,ans;
  cin>>n;
  if(n%1000!=0)
  {
  a=n/1000;
  b=1000*(a+1);
  ans=b-n;
  cout<<ans;
  }
  else
  {
   printf("0");
  }
}


Measured memory_bytes: 3656
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int ans = 0;
    cin >> s;
    rep(i, s.size()) {
      if (s[i] == '+') {
        ans++;
      } else {
        ans--;
      }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n,k;
  cin >>n>>k;
  string s;
  cin >>s;
  int ans = 0;
  rep(i,n-1) if(s[i]==s[i+1]) ans ++;
  ans = min(ans + 2*k, n-1);
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a,b;
	scanf("%c %c",&a,&b);
	if(b=='H' && a=='H')
		printf("H");
	else if(a=='D' && b=='D')
		printf("H");
	else if(a=='H' && b=='D')
		printf("D");
	else if(a=='D' && b=='H')
		printf("D");
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if (N<9){
    cout << N << endl;
  }
  else if (9<=N&&N<=99){
    cout << 9 << endl;
  }
  else if (100<=N&&N<999){
    cout << N-90 << endl;
  }
  else if (999<=N&&N<=9999){
    cout << 909 << endl;
  }
  else if (10000<=N&&N<99999){
    cout << N-9090 << endl;
  }
  else {
    cout << 90909 << endl;
  }
}

Measured memory_bytes: 256
import bisect
import sys
INF = float('inf')
input = sys.stdin.readline
a, b, q = map(int, input().split())
s = [-INF] + [int(input())for _ in range(a)] + [INF]
t = [-INF] + [int(input())for _ in range(b)] + [INF]
for i in range(q):
  x = int(input())
  idx = bisect.bisect_left(s, x)
  s1 = [s[idx - 1], s[idx]]
  idx = bisect.bisect_left(t, x)
  t1 = [t[idx - 1], t[idx]]
  ans = INF
  for shr in s1:
    for tem in t1:
      ans = min(ans, abs(tem - shr) + abs(shr - x))
      ans = min(ans, abs(shr - tem) + abs(tem - x))
  print(ans)

Measured memory_bytes: 12816
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <math.h>
#include <queue>
#include <list>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <ctime>
#include <iomanip>
#include <fstream>
using namespace std;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define IN(x,c) (find(c.begin(),c.end(),x) != (c).end())
#define REP(i,n) for (int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define INIT(a,v) memset(a,v,sizeof(a))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
template<class A, class B> A cvt(B x) { stringstream ss; ss<<x; A y; ss>>y; return y; }

#define SPC << " " <<
#define DEBUG(x) cerr << #x << " = "; cerr << x << endl;
#define DEBUG_ITER(x) cerr << #x << " = "; for (auto _ : x) cerr << _ << ' '; cerr << endl;

typedef pair<int,int> PII;
typedef long long int64;
typedef vector<int> VI;

int n,k;
int a[200000];

int main() {
	//freopen("test.in","r",stdin);
	scanf("%d %d",&n,&k);
	REP (i,n) scanf("%d",&a[i]);
	int cant=0, can=1e9;
	while (can-cant>1) {
		int l=(can+cant)/2;
		int64 x=0;
		REP (i,n) {
			x+=a[i]/l;
			if (a[i]%l==0) x--;
		}
		if (x>k) cant=l;
		else can=l;
	}
	printf("%d\n",can);
	return 0;
}


Measured memory_bytes: 4500
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T>inline T lcm(T a,T b){return a*b/gcd(b,a%b);}


inline void solve(){
  int N,K;
  IN2(N,K);
  int cnt=0;
  for(int i=1;i<=N;i+=2){
    cnt++;
  }
  if(cnt>=K)OUT("YES");
  else OUT("NO");
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
 int a, b;
 scanf("%d %d", &a, &b);
 int d = a / b;
 int r = a % b;
 double f = (double)a/b;

 printf("%d %d %.5f\n", d, r, f);

	return 0;
}


Measured memory_bytes: 2076
#include<stdio.h>

int main(){
	int t, i, S = 0, T = 0;
	for( i = 0; i < 4; i++ ){
		scanf("%d", &t);
		S += t;
	}
	for( i = 0; i < 4; i++ ){
		scanf("%d", &t);
		T += t;
	}
	printf("%d\n", (S>T?S:T));
	return 0;
}

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

int main(void){
    int a = 0, b = 0, k = 0; 

    scanf("%d%d%d", &a, &b, &k);

    //kが大きすぎないか
    if(k >= (b-a + 2) / 2){
        for(int i = a; i <= b; i++){
            printf("%d\n", i);
        }
        return 0;
    }else{
        for(int i = a; i < a + k; i++){
            printf("%d\n", i);
        }
    }

    //範囲が重複しているかどうか
    if((a + (k - 1)) >= (b - (k - 1))){
        for(int i = a + k; i <= b; i++){
            printf("%d\n", i);
        }
    }else{
        for(int i = b - k + 1; i <= b; i++){
            printf("%d\n", i);
        }
    }


    return 0;

} 


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

const int maxn = 55;
LL a[maxn], n, d, k, limit, ans;

bool cmp(LL a, LL b){
	return a > b;
}

int main(){
	scanf("%lld", &n); limit = n-1;
	for (LL i=1; i<=n; i++) scanf("%lld", &a[i]);
	sort(a+1, a+n+1, cmp);
	for (LL i=1; i<=n-1; i++){
		sort(a+1, a+i+1, cmp);
		d = a[1] - a[i+1];
		if (d >= n+2){
			k = d/(n+1);
			ans += i*k;
			limit -= i*k;
			for (LL j=1; j<=i; j++)
				a[j] -= k*(n+1);
		}
	}
	sort(a+1, a+n+1, cmp);
	d = a[n] - limit;
	if (d > 0){
		ans += d*n;
		for (LL i=1; i<=n; i++) a[i] -= d;
	}
	while (a[1] > limit){
		ans++;
		a[1] -= n+1;
		limit--;
		sort(a+1, a+n+1, cmp);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
lst = [int(i) for i in input().split()]
mod = 1000000007
count = [0] * (N + 1)
count[0] = 3

ret = 1
for i in lst:
    count[i + 1] += 1
    ret = (ret * count[i]) % mod
    count[i] -= 1

print(ret)

Measured memory_bytes: 14396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String in = "";
 
        try {
            while (null != (in = br.readLine())) {
                int a = Integer.parseInt((in.split(" ")[0]));
                int b = Integer.parseInt((in.split(" ")[1]));
                int fig = (int) (Math.floor(Math.log10(a + b))) + 1;
                System.out.println(fig);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 17076
#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 <iomanip>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MOD=1000000007;

int main(){
    ld l;
    cin>>l;
    l=l/3;
    ld ans=pow(l,3);
    cout<<std::setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
//        Scanner scanner = new Scanner(System.in);
//        boolean hasNextInt = scanner.hasNextInt();
//        int x = scanner.nextInt();
//        if(hasNextInt) {
//            while(x > 0) {
//                if(x % 10 == 7) {
//                    System.out.println("Yes");
//                    break;
//                } else {
//                    x /= 10;
//                }
//                if(x == 0) {
//                    System.out.println("No");
//                }
//            }
//        }
//        scanner.close();

        Scanner scanner = new Scanner(System.in);
        boolean hasNextInt = scanner.hasNextInt();
        int n = scanner.nextInt();
        long sum = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                sum += i;
            } if(i == n) {
                System.out.println(sum);
                break;
            }
        }
        scanner.close();
    }
}

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

#define int long long

int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

signed main() {
	int A, B;
	cin >> A >> B;

	cout << A + B - gcd(A, B) + 1 << endl;

	return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=3628800;
int n;

int g(vi a){
	int res=0,tmp=1;
	for(int i=n-2;i>=0;i--){
		int cnt=0;
		for(int j=i+1;j<n;j++) if(a[i]>a[j]) cnt++;
		res+=cnt*tmp;
		tmp*=n-i;
	}
	return res;
}

vi a;

vi f(){
	queue<pair<vi,int>> q;
	q.push(make_pair(a,0));
	vi dis(M,inf);
	dis[g(a)]=0;
	while(!q.empty()){
		auto p=q.front();q.pop();
		vi b=p.first;
		int d=p.second;
		for(int i=0;i<n;i++) for(int j=i+2;j<=n;j++){
			reverse(b.begin()+i,b.begin()+j);
			int id=g(b);
			if(dis[id]==inf){
				dis[id]=d+1;
				if(d+1<4){
					q.push(make_pair(b,d+1));
				}
			}
			reverse(b.begin()+i,b.begin()+j);
		}
	}
	return dis;
}

int main(){
	cin>>n;
	a=vi(n);
	for(auto &i:a) cin>>i;
	vi b=f();
	sort(a.begin(),a.end());
	vi c=f();
	int res=9;
	for(int i=0;i<M;i++) res=min(res,b[i]+c[i]);
	cout<<res<<endl;
}


Measured memory_bytes: 33232
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	long long x;
	cin >> x;
	int cnt = 0;
	long long cur = 100;
	while(cur < x){
		long long pl = (cur / 100);
		cur += pl; 
		cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>
#include <bitset>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;



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

  ll N;
  cin >> N;

  unordered_map<ll, vector<P>> evidence;
  REP(i,N){
    ll Ai;
    cin >> Ai;
    vector<P> e(Ai);
    REP(j, Ai){
      ll x, y;
      cin >> x >> y;
      e[j] = P(x-1,y);
    }
    evidence[i] = e;
  }


  ll ans = 0;
  REP(state,1<<N){
    ll contradict = false;
    // check
    REP(i,N){
      if ((state>>i)&1 != 0){
        for (P& p : evidence[i]){
          if ((state&(1<<p.first))>0 && p.second==0){
            contradict = true;
          }; 
          if ((state&(1<<p.first))==0 && p.second==1){
            contradict = true;
          }
          //cout << state << ": evi" << i << " " << p.first << "-" << p.second << "\n";
          //cout << (state&(1<<p.first)) << " " << contradict << "\n";
        }
      }
      if (contradict) break;
    }

    if (!contradict){
      //cout << "yes" << state << " " << (ll)std::bitset<15>(state).count() << "\n";
      ans = max(ans, (ll)std::bitset<15>(state).count());
    }
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).rbegin(),(x).rend()
#define pb push_back
signed main(){
    int n;
    cin >> n;
    vi v(n);
    rep(i,n){
        cin >> v[i];
    }
    sort(all(v));
    v[0] /= 2;
    int res = 0;
    rep(i, n)
    {
        res += v[i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define ll long long int
using namespace std;
int main()
{
   char str[6];
   for(ll i=0;i<6;i++)
   {
       cin>>str[i];
   }
   if(str[2]==str[3] && str[4]==str[5])
       cout<<"Yes"<<endl;
   else
       cout<<"No"<<endl;
	return 0;
}

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

using namespace std;
using ll = unsigned long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
int main(){
    string str;
    cin>>str;
    if(str.size() == 1){
        cout << 0 << endl;
    }else{
        int b,w;
        b=w=0;
        for(unsigned long i=0;i<str.size();++i){
            if(i%2){
                if(str[i] == '0'){
                    w++;
                }else{
                    b++;
                }
            }else{
                if(str[i] == '0'){
                    b++;
                }else{
                    w++;
                }
            }
        }
        cout << min(b,w) << endl;
    }
    return 0;
}



Measured memory_bytes: 512
#include <stdio.h>

int main()
{
	char input[1200];

	scanf("%[^\n]s", input);

	int i = 0;
	while(input[i] != '\0') {
		if (65 <= input[i] && input[i] <= 90) {
			printf("%c", input[i] + 32);
		} else if (97 <= input[i] && input[i] <= 122) {
			printf("%c", input[i] - 32);
		} else {
			printf("%c", input[i]);
		}
		
		i++;
	}
	printf("\n");
}


Measured memory_bytes: 2608
#include <cstdio>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#define min(a,b)    (((a) < (b)) ? (a) : (b))
#define max(a,b)    (((a) > (b)) ? (a) : (b))
#define abs(x)    ((x) < 0 ? -(x) : (x))
#define INF 0x3f3f3f3f
#define delta 0.85
#define eps 1e-3
#define PI 3.14159265358979323846
#define MAX_N 1000005
using namespace std;
int cnt[MAX_N];
bool is_prime[MAX_N];

void sieve(int n){
	int limit = sqrt(n);
	for(int i = 0; i <= n; i++) is_prime[i] = 1;
	is_prime[0] = is_prime[1] = 0;
	cnt[0] = cnt[1] = 0;
	for(int i = 2; i <= n; i++){
		if(is_prime[i]){
			cnt[i] = cnt[i - 1] + 1;
			if(i <= limit){
				for(int j = i * i; j <= n; j += i) is_prime[j] = 0;
			}
		}
		else cnt[i] = cnt[i - 1];
	}
}

int main(){
	int n;
	sieve(MAX_N);
	while(~scanf("%d", &n)){
		printf("%d\n", cnt[n]);
	}
	return 0;
}




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

int main(){
    int ha,ma,hb,mb,k;
    cin>>ha>>ma>>hb>>mb>>k;
    int h; int m;
    h=hb-ha;
    m=mb-ma;
    if(m<0){
        h-=1;
        m=60+m;

    }
    int hun;
    hun=h*60;
    int anskai;
    anskai=hun+m-k;
    if(anskai<=0){
        cout<<0<<endl;
        return 0;
    }
    else cout<<anskai<<endl;
   

    


}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
bool c(pll a, pll b)
{
    if(a.S == b.S)
        return a.F < b.F;
    return a.S < b.S;
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, i, ans = 0;
    cin >> n;
    vector <pll> a(n);
    for(i = 0; i < n; i++)
        cin >> a[i].F >> a[i].S;
    sort(all(a), c);
    ll curt = 0;
    for(i = 0; i < n; i++)
    {
        if(curt + a[i].F > a[i].S)
        {
            cout << "No\n";
            return 0;
        }
        curt += a[i].F;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3456
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    long n, m;
    readlnTo(n, m);

    writeln(pow(2, m) * (1900 * m + 100 * (n-m)));

}



Measured memory_bytes: 256
import java.util.*;
public class Main{
   public static void main(String[]args){

      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();


      if (a<=b && b<=c){
         System.out.println(a+" "+b+" "+c);
      }else if(a<=c && c<=b){
         System.out.println(a+" "+c+" "+b);
      }else if(b<=a && a<=c){
         System.out.println(b+" "+a+" "+c);
      }else if(b<=c && c<=a){
         System.out.println(b+" "+c+" "+a);
      }else if(c<=a && a<=b){
         System.out.println(c+" "+a+" "+b);
      }else if(c<=b && b<=a){
         System.out.println(c+" "+b+" "+a);
      }
   }
}

Measured memory_bytes: 26140