akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

def solve():
    dxys = [(1,0), (0,1)]

    H, W = map(int, input().split())
    Sss = ['$'*(W+2)] + ['$'+input().rstrip()+'$' for _ in range(H)] + ['$'*(W+2)]

    vWhites, vBlacks = set(), set()
    if Sss[1][1] == '.':
        vWhites.add((1, 1))
    else:
        vBlacks.add((1, 1))

    ans = 0
    while True:
        while vWhites:
            v2s = set()
            for r, c in vWhites:
                if (r, c) == (H, W):
                    return ans
                for dr, dc in dxys:
                    r2, c2 = r+dr, c+dc
                    if Sss[r2][c2] == '$': continue
                    if Sss[r2][c2] == '.':
                        v2s.add((r2, c2))
                    else:
                        vBlacks.add((r2, c2))
            vWhites = v2s
        ans += 1

        while vBlacks:
            v2s = set()
            for r, c in vBlacks:
                if (r, c) == (H, W):
                    return ans
                for dr, dc in dxys:
                    r2, c2 = r+dr, c+dc
                    if Sss[r2][c2] == '$': continue
                    if Sss[r2][c2] == '#':
                        v2s.add((r2, c2))
                    else:
                        vWhites.add((r2, c2))
            vBlacks = v2s
#        ans += 1


ans = solve()
print(ans)


Measured memory_bytes: 3952
#include <bits/stdc++.h>
#define int long long
#define S second
#define F first
#define pb push_back
#define sz size()
using namespace std;
const int N=1e6+7;
const int mod=1e9+7;
int b[N],c[N],dp[3010][3010] ;
int n,x=1,ans,k,w,m ;
vector < int > vec ;
vector < int > pos ;
multiset < int > st ;
string s, t,f,ans2;

main()
{
    cin >> s >> t ;
    n=s.sz ;
    m=t.sz ;
    s='%'+s ;
    t='%'+t ;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=m; j++)
            if (s[i]==t[j])
            dp[i][j]=dp[i-1][j-1]+1 ;
            else dp[i][j]=max(dp[i][j-1],dp[i-1][j]) ;

    while (n&&m)
    {
        if (s[n]==t[m])
            f+=s[n] , n-- , m-- ;
        else if (dp[n][m-1]>dp[n-1][m])
            m-- ;
        else n-- ;
    }
    reverse(f.begin(),f.end()) ;
    cout << f << endl ;
}



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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

ll dp[110][100010];

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  REP(i, N) cin >> w[i] >> v[i];
  REP(i, N) {
    for (int j = 0; j <= W; ++j) {
      if (w[i] <= j)
        dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
      else
        dp[i + 1][j] = dp[i][j];
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

const int N_MAX = 15;
const int ANS_MAX = N_MAX+1;
const int N2_MAX = 1<<N_MAX;
const int INF = 1e9;

int N;
int pos[2][N_MAX],p[N_MAX];
int dist[2][N2_MAX][N_MAX];
ll ans[ANS_MAX];

void precalc(int t)
{
    rep(S,1<<N){
        set<int> ls;
        ls.ins(-INF); ls.ins(0); ls.ins(INF);
        rep(i,N)if(S>>i&1) ls.ins(pos[t][i]);
        rep(i,N){
            auto itr = ls.lower_bound(pos[t][i]);
            int r = *itr; itr--;
            int l = *itr;
            dist[t][S][i] = min(r-pos[t][i],pos[t][i]-l);
        }
    }
}

void dfs(int idx=0, int S=0, int T=0)
{
    if (idx==N){
        int pcnt = __builtin_popcount(S|T);
        ll sum=0;
        rep(i,N) sum += (ll)p[i]*min(dist[0][S][i],dist[1][T][i]);
        chmin(ans[pcnt],sum);
        return;
    }
    dfs(idx+1,S,T);
    dfs(idx+1,S|1<<idx,T);
    dfs(idx+1,S,T|1<<idx);
}

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>N;
    rep(i,N) cin>>pos[0][i]>>pos[1][i]>>p[i];
    rep(i,N+1) ans[i] = (ll)1e18;
    rep(i,2) precalc(i);
    dfs();
    rep(i,N+1) cout<<ans[i]<<"\n";
    return 0;
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

const int N_MAX = 3010;



int main() {
    int a, b; cin >> a >> b;
    if((a*b) % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

using Graph = vector<vector<ll>>;

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

#define MAX_N 2010

const long long INF = 1LL << 60;

//境界値に注意！！！

int main() {
    ll n,x,mini=INF,ans=0;
    cin >> n >> x;
    for (ll i=0;i<n;i++){
        ll a;
        cin >> a;
        mini=min(mini,a);
        x-=a;
        ans++;
    }
    while(x-mini>=0){
        x-=mini;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import copy

n=int(input())
t=list(map(int,input().split()))
m=int(input())
dr=[list(map(int,input().split())) for i in range(m)]

for i in range(m):
    tt=copy.copy(t)
    tt[dr[i][0]-1]=dr[i][1]
    print(sum(tt))

Measured memory_bytes: 3444
#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> ans;
    vector<bool> p(55556,true);
    for(int i=2;i*i<=55555; i++) {
        if(p[i])
        for(int j=i*2;j<=55555;j+=i) {
            p[j] = false;
        }
    }
    int start = 3; int cnt = 0;
    if(n&1) start = 2;
    for(int i=start;i<=55555;i++) {
        if(p[i] && i%5 == 1) {
            ans.push_back(i);
            cnt++;
        }
        if(cnt >= n) break;
    }
    rep(i, n) cout << ans[i] << ((i==n-1)?"\n":" ");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

class combM {
private:
    vector<ll> fac;  //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    ll mpow(ll x, ll n);
    combM();
    ll com(ll a, ll b);
};

// x^n(mod M)
ll combM::mpow(ll x, ll n) {
    ll ans = 1ll;
    while(n != 0){
        if (n&1) ans = ans*x%MOD;
        x = x*x%MOD;
        n = n >> 1;
    }
    return ans;
}

// aCb をmod計算
ll combM::com(ll a, ll b) {
    if (a == 0 && b == 0) return 1;
    if (a < b || a < 0) return 0;
    ll tmp = ifac[a-b]*ifac[b]%MOD;
    return tmp*fac[a]%MOD;
}

combM::combM() {
    fac.resize(300001);
    ifac.resize(300001);
    fac[0] = 1;
    ifac[0] = 1;
    for (ll i = 0; i < 300000; ++i) {
        fac[i+1] = fac[i]*(i+1)%MOD;
        ifac[i+1] = ifac[i]*mpow(i+1, MOD-2)%MOD;
    }
}

int main(int argc, char const *argv[]) {
    int h,w, a, b;
    cin >> h >> w >> a >> b;

    combM C;

    ll ans = 0;

    for (int i = b; i <= w; ++i) {
        ans += C.com(h-a-1+i, i) * C.com(w-i-1+a-1, a-1) %MOD;
        ans %= MOD;
    }

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

Measured memory_bytes: 4992
# -*- coding: utf-8 -*-
import sys

def io_generator():
	while True:
		yield raw_input()

#+++++++++++++++++++

def main(io):
	s=io.next()
	ret='Heisei' if s < '2019/04/31' else 'TBD'
	return ret


#++++++++++++++++++++

if __name__ == "__main__":
	io=io_generator()
	print main(io)


Measured memory_bytes: 2568
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int n;
vector<int> riffle(vector<int> card){
  vector<int> ret;
  REP(i,n){
    ret.push_back(card[i]);
    ret.push_back(card[n+i]);
  }
  return ret;
}

vector<int> cut(vector<int> card, int k){
  vector<int> ret;
  FOR(i,k,2*n){
    ret.push_back(card[i]);
  }
  FOR(i,0,k){
    ret.push_back(card[i]);
  }
  return ret;
}

int main(void){
  cin>>n;
  vector<int> card;
  REP(i,2*n)
    card.push_back(i);
  int m;
  cin>>m;
  int k;
  REP(i,m){
    cin>>k;
    if(k==0) card = riffle(card);
    else card = cut(card,k);
  }
  REP(i,2*n){
    cout<<card[i]+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
void fail() { cout << -1 << '\n'; exit(0); }
// const int INF  = 1<<30;
// const ll INFll = 1ll<<62;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  string s; cin >> s;

  ll ans = 0;
  if (s == "RRR") ans = 3;
  else if (s == "SSS") ans = 0;
  else if (s == "RRS" || s == "SRR") ans = 2;
  else ans = 1;
  
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3652
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void read(ll &x){
	char ch = getchar();x = 0;
	for (; ch < '0' || ch > '9'; ch = getchar());
	for (; ch >='0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}
ll id[10],n;
ll ans[10];
ll A,B,C;
ll res=0x3f3f3f3f;
void dfs(ll now,ll kind){
	if(now>n){
		ll a,b,c,na,nb,nc;
		a=b=c=na=nb=nc=0;
		for(ll i=1;i<=n;i++){
			if(id[i]==1) a+=ans[i],na++;
			if(id[i]==2) b+=ans[i],nb++;
			if(id[i]==3) c+=ans[i],nc++;
		}
		if(na==0||nb==0||nc==0) return ;
//		cout<<a<<" "<<b<<" "<<c<<endl;
		res=min(abs(A-a)+abs(B-b)+abs(C-c)+10*(na+nb+nc-3),res);return ;
	}
	id[now]=kind;
	for(ll j=1;j<=4;j++){
		dfs(now+1,j);
	}
}
int main(){
	cin>>n>>A>>B>>C;
	for(ll i=1;i<=n;i++){
		cin>>ans[i];
	}
	dfs(0,1);
	cout<<res<<endl;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int w, h;
	char room[101][101];
	vector< pair<int, int> > visited;
	while(cin >> h >> w, h || w){
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				cin >> room[i][j];
			}
		}
		visited.push_back(pair<int, int>(0, 0));
		int flag = 1;
		while (flag){
			pair<int, int> tmp;
			switch (room[visited.back().first][visited.back().second])
			{
			case '>':
				tmp.first = visited.back().first;
				tmp.second = visited.back().second + 1;
				visited.push_back(tmp);
				break;
			case '<':
				tmp.first = visited.back().first;
				tmp.second = visited.back().second - 1;
				visited.push_back(tmp);
				break;
			case '^':
				tmp.first = visited.back().first - 1;
				tmp.second = visited.back().second;
				visited.push_back(tmp);
				break;
			case 'v':
				tmp.first = visited.back().first + 1;
				tmp.second = visited.back().second;
				visited.push_back(tmp);
				break;
			case '.':
				cout << visited.back().second << ' ' << visited.back().first << endl;
				flag = 0;
				visited.clear();
				break;
			}
			for (int i = visited.size() - 2; i >= 0; i--){
				if (visited[i] == tmp){
					cout << "LOOP" << endl;
					flag = 0;
					break;
				}
			}
		}
		visited.clear();
	}
	return 0;
}

Measured memory_bytes: 1216
n=int(input())
s=input()
ng=len(s)

aslist=[]
for i in range(ng):
    ban=ord(s[i])
    if ban+n>=91:
        ban=ban+n-26
    else:
        ban=ban+n
    aslist.append(ban)

moji=''
for i in range(ng):
    moji+=chr(aslist[i])

#print(aslist)
print(moji)

Measured memory_bytes: 41708
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int min( int p, int q ) {
	if( p > q ) return q;
	return p;
}

int main(void){

	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	cout << min( min( a, b ) , c ) + min( d , e ) - 50 << endl;

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
bool ok=true;
vector <int>  par(100010);
vector <int> ranc(100010);
void init(int n){
    for(int i=0;i<100010;i++){
        par[i]=i;
        ranc[i]=0;
    }
}
int root(int x){
    return par[x] == x ? x : par[x]= root(par[x]);
}
bool same(int x, int y){
    return root(x)==root(y);
}
void unite(int x, int y){
    x = root(x);
    y = root(y);
   if(x==y) return;
    if(ranc[x]<ranc[y]){
        par[x]=y;
    }else{
        par[y] = x;
        if(ranc[x]==ranc[y]) ranc[x]++;
    }
}
int main(void){
    int n,m; cin>>n>>m;
    vector < pair<int,int> > p(m+1);
    for(int i=0;i<m;i++){
        int a,b; cin>>a>>b;
        p[i]=make_pair(a,b);
    }
    int ans=0;
    for(int i=0;i<m;i++){
        init(n+1);
        bool ok=true;
        for(int j=0;j<m;j++){
            if(j==i) continue;
            unite(p[j].first,p[j].second);
        }
        for(int j=1;j<=n-1;j++){
            if(same(j,j+1)==false) ok=false;
            //cout<<same(j,j+1)<<endl;
        }
        //cout<<'*'<<endl;
        if(ok==false) ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 1024
#include <cstdio>
#include <string>
using namespace std;
int main() {
	int n;
	
	// while(true) {
		scanf("%d", &n);
		for (int i=1; i <= n; i++) {
			if (i % 3 == 0 || i % 10 == 3 || i/10%10 == 3 || i/100%10 == 3 || i/1000%10 == 3) {
				printf(" %d", i);
			}
		}
		printf("\n");
	// }
}


Measured memory_bytes: 2688
def f(n):
    if n%2==0:
        return n//2
    else:
        return (3*n)+1
s = int(input())
a = [s]
ans = 1
while(True):
    x = f(s)
    ans+=1
    if x in a:
        break
    else:
        a.append(x)
    s=x
print(ans)

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

/* -------------------------------- Template -------------------------------- */

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

template<typename T> T inf() { assert(false); }
template<> constexpr int inf<int>() { return 1e9; }
template<> constexpr ll inf<ll>() { return 1e18; }
template<> constexpr ld inf<ld>() { return 1e30; }

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha;
  cout.imbue(loc);

  string s;
  cin >> s;
  int t = 0;
  for (char c: s) {
    if (t == 0 && c == 'C') ++t;
    if (t == 1 && c == 'F') ++t;
  }
  cout << (t == 2) << endl;
  return 0;
}


Measured memory_bytes: 384
/*
Author: Fuadul Hasan(fuadul202@gmail.com)
BSMRSTU,Gopalganj
*/
#include<bits/stdc++.h>
using namespace std;
void    		print(int n)    {printf("%d ", n);}
void    		printl(long long n)     {printf("%I64d ", n);}
long long    	readline(){long long x;scanf("%I64d", &x);return x;}
/*
1.#define  gcd(a,b) __gcd(a,b) 2. #define  lcm(a,b) (a*b)/gcd(a,b) 3. #define  PI acos(-1.0) 4.#define  sqr(x) ((x)*(x))
5.#define  min3(a,b,c) min(a,min(b,c))6.#define  min4(a,b,c,d) min(d,min(a,min(b,c)))7.#define  max3(a,b,c) max(a,max(b,c))
8.#define  max4(a,b,c,d) max(d,max(a,max(b,c)))
*/
//.............ignore it................//
/*....... scanf.......*/
template <typename T> inline void readline(T &n) {
n = 0; int f = 1; register int ch = getchar();for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';n = n * f;}
template <typename T, typename TT> inline void readline(T &n, TT &m) { readline(n); readline(m); }
template <typename T, typename TT, typename TTT> inline void readline(T &n, TT &m, TTT &l) { readline(n, m); readline(l);}
/*..........error........*/
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x);return move(v);
}void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}
//............ignore it..................//
typedef   pair<int, int> ii;
typedef   std::vector<ii> vii;
#define   vi   std::vector<int>
#define   vll  std::vector<ll>
#define   all(n) n.begin(),n.end()
#define  mpsi std::map<string, int>
#define  pb             push_back
#define  ll             long long int
#define  nl             printf("\n");
#define  happy          cin.tie(0);
#define  coding         ios::sync_with_stdio(false);

#define  max3(a,b,c) max(a,max(b,c))


int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)2e18 + 5;
const int N             = 4e5 + 5;
const int N1            = 1e5 + 5;
bool vis[N1];
int a[N1];
vector<int>v[N1];

 
int solve() 
{
	//happy coding
	
	ll a,b,c;
	//readline(a,b,c);
	cin>>a>>b>>c;
	ll x = c-a-b;
	long double y = (long double)x*(long double)x/4.0;
	if((long double)a*(long double)b<y&&x>=0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
	
	return 0;

	//error();
}

int main(){
	
	int test = 1, tc = 0;
	//scanf("%d", &test);//(void)getchar();
	while (test--){
		solve();
	}


	return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
using namespace std;
int main(void){
    // Your code here!
    char str[1001];
    
    while(1){
        scanf("%s",str);
        if(str[0]=='0') break;
        int sum=0;
        for(int i=0; i<strlen(str); i++){
            sum+=(str[i]-'0');
        }
        
        printf("%d\n",sum);
    }
    return 0;
}



Measured memory_bytes: 2696
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,i,count=0;cin>>n>>k;
    int a[n];
    for(i=0;i<n;i++)
        {
            cin>>a[i];
            if(a[i]>=k)
            {
                count++;
            }
        }
        cout<<count;    
    }


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  long n;
  cin>>n;
  vector<long> a(n);
  for(long i=0;i<n;i++){
    cin>>a[i];
  }
  int odd=0;
  for(long i=0;i<n;i++){
    if(a[i]%2==1){
      odd++;
    }
  }
  if(odd%2==1){
    cout<<"NO"<<endl;
  }
  else{
    cout<<"YES"<<endl;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000



int main(){
	
	int N,M;
	cin>>N>>M;
	
	string S;
	cin>>S;
	
	int now = 0;
	vector<int> ans;
	reverse(S.begin(),S.end());
	while(true){
		if(now==N)break;
		for(int i=min(N,now+M);i>=now;i--){
			if(S[i]=='0'){
				ans.push_back(abs(now-i));
				now = i;
				break;
			}
		}
		if(ans.back()==0)break;
	}
	
	if(now!=N){
		cout<<-1<<endl;
	}
	else{
		reverse(ans.begin(),ans.end());
		
		for(int i=0;i<ans.size();i++){
			if(i!=0)cout<<' ';
			cout<<ans[i];
		}
		cout<<endl;
	}
	
	return 0;
	
}


Measured memory_bytes: 1144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			int h1 = sc.nextInt();
			int m1 = sc.nextInt();
			int h2 = sc.nextInt();
			int m2 = sc.nextInt();
			int k = sc.nextInt();

			System.out.println((h2 * 60 + m2) - (h1 * 60 + m1) - k);

		} catch (Exception e) {
		}

	}

}


Measured memory_bytes: 35696
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    ll int n;
    cin>>n;
    int ans=0;
    vector<vector<pll>> v;

    rep(i,n){
        int a;
        cin>>a;
        vpll tmpv;
        rep(j,a){
            int x,y;
            cin>>x>>y;
            pll p = make_pair(x,y);
            tmpv.push_back(p);
        }
        v.push_back(tmpv);
    }

        
    for (int bit = 0; bit < (1<<n); ++bit) {
        vl t;
        int a=0;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
               t.push_back(1);
            }
            else t.push_back(0);
        }
      
        rep(i,t.size()){
            if(t[i]==1){
                int cou=0;
                rep(j,v[i].size()){
                    if(t[v[i][j].first-1]!=v[i][j].second)break;
                    cou++;
                }
                if(cou==v[i].size()){
                    a++;
                }
                else {
                    a=0;
                    break;
                }
            }
        }
        if(a>=ans)ans=a;
        
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol abs(lol x,lol y){return(x>y?x-y:y-x);}
lol max(lol x,lol y){if(x>y)return x;return y;}
lol min(lol x,lol y){if(x<y)return x;return y;}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> s;
    int n,l;
    cin >>n>>l;
    for(int i=0;i<n;i++){
      string q;
      cin >>q;
      s.emplace_back(q);
    }
    sort(s.begin(),s.end());
    string ans="";
    for(int i=0;i<n;i++) ans+=s[i];
    cout <<ans<<'\n';
    return (0);
}


Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int parent[51];

int find(int a){
  if(parent[a]==a)return a;
  else return find(parent[a]);
}

void unite(int a,int b){
  int pa=find(a),pb=find(b);
  parent[pa]=pb;
}

int main(){
  int n,m,ans=0;
  cin>>n>>m;
  int a[m],b[m];
  rep(i,m)cin>>a[i]>>b[i];
  rep(i,m){
    loop(j,1,n+1)parent[j]=j;
    rep(j,m){
      if(i==j)continue;
      unite(a[j],b[j]);
    }
    bool check=false;
    loop(j,2,n+1){
      if(find(j)!=find(1)){
	check=true;
	break;
      }
    }
    if(check)ans++;
  }
  cout<<ans<<endl;
  return 0;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 H, W;
  cin >> H >> W;
  v(string) A(H);
  cin >> A;
  vvi dp(H, vi(W,0));
  dp[0][0] = 1;
  rep(h,H) rep(w,W){
    if(A[h][w] == '#') continue;
    if(0<=h-1) dp[h][w] += dp[h-1][w];
    if(0<=w-1) dp[h][w] += dp[h][w-1];
    dp[h][w] %= MOD;
  }
  cout << dp[H-1][W-1] << "\n";
}

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

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int c[4][4] ;

int main() {
  
  int a[3], b[3] ;

  for(int i = 0 ;i<3  ;i++)
    for(int j = 0 ; j<3 ; j++) scanf("%d", &c[i][j]) ;

  for(a[0] = 0 ; a[0]<=100 ; a[0]++){
    for(a[1] = 0 ; a[1]<=100 ;a[1]++){
      for(a[2] = 0 ; a[2]<=100 ; a[2]++){

        b[0] = c[0][0] -a[0] ;
        b[1] = c[0][1] - a[0] ;
        b[2] = c[0][2] -a[0] ;
        
        bool all =true ;

        for(int i = 0 ;i<3 ; i++){
          for(int j = 0 ; j<3 ; j++){
            all&=(c[i][j] ==a[i]+b[j]) ; 
          }
        }
        if(all){
          cout <<"Yes"<< endl ;
          return 0 ;
        }
      }
    }
  }
  cout << "No"<< endl ;
	
  return 0 ;
}

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

#define F(i,a,b) for(int i=a;i<=b;i++)
 
int a[100001];
int n;
int r;
 
int main() {
  
	cin>>n;
	F(i,1,n)cin>>a[i];
	
	F(i,0,n)r+=abs(a[i]-a[i+1]);
	F(i,1,n)
	{
		int x;
		x=r-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]);
		cout<<x<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <bitset>
#include <complex>
#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>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int n, N;
    vector<int> a;

    void input() {
        cin >> n;
        N = 2 * n - 1;
        a.resize(N);
        rep(i, 0, N) cin >> a[i];

    }

    bool check(int k) {
        vector<int> b(N);
        rep(i, 0, N) b[i] = a[i] >= k;

        int mid_p = N / 2;
        if (b[mid_p] == b[mid_p - 1] || b[mid_p] == b[mid_p + 1]) {
            return b[mid_p];
        }

        int l = mid_p;
        int r = mid_p;
        while (l > 0 && b[l] ^ b[l - 1]) l--;
        while (r + 1 < N && b[r] ^ b[r + 1]) r++;

        if (r - mid_p > mid_p - l) {
            return b[l];
        } else {
            return b[r];
        }
    }

    void solve() {
        input();
        int lb = 0;
        int ub = N;

        while (ub - lb > 1) {
            int mid = (lb + ub) / 2;
            if (check(mid)) {
                lb = mid;
            } else {
                ub = mid;
            }
        }

        cout << lb << endl;


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 1808
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, M = map(int, input().split())
graph = [[] for _ in range(N)]

for _ in range(M):
    A, B = map(int, input().split())
    # print(A, B)
    graph[A-1].append(B-1)
    graph[B-1].append(A-1)

from collections import deque
def bfs(start):
    dist = [INF] * N
    dist[start] = 0
    seen = [0] * N
    shirube = [None] * N
    shirube[0] = 'Yes'
    q = deque([start])
    while q:
        v = q.popleft()
        dv = dist[v]
        for next_room in graph[v]:
            if seen[next_room]:
                continue
            if dv + 1 < dist[next_room]:
                dist[next_room] = dv + 1
                shirube[next_room] = v + 1
            seen[next_room] = 1
            q.append(next_room)
    if all(shirube):
        for x in shirube:
            print(x)
    else:
        # print(shirube)
        print('No')
bfs(0)

Measured memory_bytes: 38420
// https://atcoder.jp/contests/abc177/tasks/abc177_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int c, int d) { return c / gcd(c, d) * d; }

const int SZ = 1e6;

// constexprな素数列挙(エラトステネスの篩)
// https://259-momone.hatenablog.com/entry/2018/05/06/015026
template <int N> struct Prime {
    bool b[N + 1]; // trueなら素数
    constexpr Prime() : b() {
        fill_n(b, N + 1, true);
        b[0] = b[1] = false;
        for (int_fast64_t i = 2; i <= N; ++i) {
            if (b[i]) {
                for (int_fast64_t j = i * i; j <= N; j += i) {
                    b[j] = false;
                }
            }
        }
    }
};
Prime<SZ> prime;

void solve() {
    int N;
    cin >> N;
    vector<int> A(N), D(SZ + 1);
    for (auto &x : A) {
        cin >> x;
        D[x]++;
    }
    bool pc = true;

    REP(i, SZ) {
        // 素数の場合
        if (prime.b[i]) {
            int cnt = 0;
            for (int now = i; now <= SZ; now += i) {
                cnt += D[now];
            }
            // 共通の素数を含むのでgcd(ALL) >= i
            if (cnt >= 2) {
                pc = false;
                break;
            }
        }
    }
    if (pc) {
        cout << "pairwise coprime" << endl;
    } else {
        int g = A[0];
        for (auto &x : A) {
            g = gcd(g, x);
        }
        if (g == 1)
            cout << "setwise coprime" << endl;
        else
            cout << "not coprime" << endl;
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 19808
#include <bits/stdc++.h>
using namespace std;
#define FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vi vector<ll>
#define all(a) (a).begin(), (a).end()
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define tr(it, a)   for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define endl  "\n"
const ll MAX=1e5+3;
const ll mod=1e9+7;
 vector<ll>v;
 ll  d,x;
 ll dp[MAX][120][2];
 ll fun(ll n,ll sum,bool edge)
 {
     if(n<0 && sum==0)
       {
        return 1;
       }
       if(n<0)
        return 0;
        if(dp[n][sum][edge]!=-1)
            return dp[n][sum][edge];
        ll range=9;
     if(edge)
     {
         range=v[n];
     }
     ll ans=0;
     for(ll j=0;j<=range;j++)
     {
         bool patakaro=(j==v[n] && edge );
            ans=((ans%mod)+(fun(n-1,(sum+j%d)%d,patakaro)%mod))%mod;
     }
     return dp[n][sum][edge]=ans%mod;
 }
int main()
{
   FASTIO
   int t=1;
   //cin>>t;
   while(t--)
  {
    string s;cin>>s;cin>>d;
    ll n=s.size();
    rep(i,0,n)
    v.pb(s[i]-'0');
    reverse(all(v));
    memset(dp,-1,sizeof(dp));
    ll z=(fun(n-1,0,true)%mod-1LL%mod+mod)%mod;
    cout<<z<<"\n";

   }
 return 0;
}


Measured memory_bytes: 188928
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return(a)
A,B,C,D=map(int,input().split())
CD=C*D//gcd(C,D)
print((B-A+1-(B//C-(A-1)//C)-(B//D-(A-1)//D)+(B//CD-(A-1)//CD)))


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

public class Main {

	public static int n, m;
	public static Map<Integer, LinkedList<Integer>> graph = new HashMap<>();
	public static int[] dp;

	public static int TopologicalSort() {
		Queue<Integer> qu = new LinkedList<>();
		for (int i = 1; i <= n; i++)
			if (dp[i] == 0)
				qu.add(i);

		int count = 0;
		while (!qu.isEmpty()) {
			int size = qu.size();
			for (int k = 0; k < size; k++) {
				LinkedList<Integer> temp = graph.get(qu.poll());
				if (temp == null)
					continue;
				for (int t : temp) {
					dp[t]--;
					if (dp[t] == 0)
						qu.add(t);
				}
			}
			count++;
		}
		return count - 1;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");
		n = Integer.parseInt(s[0]);
		m = Integer.parseInt(s[1]);
		dp = new int[n + 1];

		for (int i = 0; i < m; i++) {
			s = br.readLine().split(" ");
			int x = Integer.parseInt(s[0]);
			int y = Integer.parseInt(s[1]);
			if (!graph.containsKey(x))
				graph.put(x, new LinkedList<Integer>());
			graph.get(x).add(y);
			dp[y]++;
		}

		System.out.println(TopologicalSort());

	}

}


Measured memory_bytes: 59304
inf = float('INF')

class edge:
    def __init__(self, source, destination, weight):
        self.from_ = source
        self.to_ = destination
        self.weight = weight

    def values(self):
        return self.from_, self.to_, self.weight

def bellman_ford(edges, start, n):
    costs = [inf] * n
    predecessors = [-1] * n
    costs[start]= 0

    for _ in range(n-1):
        for u in range(n):
            for v,w in edges[u].items():
                if costs[v] > costs[u] + w:
                    costs[v] = costs[u] + w
                    predecessors[v] = u

    v = n-1
    while v > 0:
        u = predecessors[v]
        if costs[v] > costs[u] + edges[u][v]:
            return 'inf'
        v = u

    return -costs[n-1]

n,m = map(int, input().split())
edges = [{} for _ in range(n)]
for _ in range(m):
    a,b,c = map(int, input().split())
    edges[a-1][b-1] = -c
print(bellman_ford(edges, 0, n))


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

    int a;
    cin>>a;
    cout<<1110-a<<endl;

    return 0;
}

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


int A, B;


void input() {
    cin >> A >> B;
}


int main() {
    input();
    for (int i = 1; i <= 1000; i++) {
        int a = i * 0.08;
        int b = i * 0.1;
        if (a == A && b == B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


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

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

/*
  n m s g1 g2
  a b c
  ...
  am bm cm
  0 0 0 0 0
  */

int n,m,s,g1,g2;
int edge[128][128];
int main(){
  while(cin>>n>>m>>s>>g1>>g2,n|m|s|g1|g2){
    s--; g1--; g2--;
    //init
    rep(i,128)rep(j,128)edge[i][j]=INT_MAX;
    rep(i,128)edge[i][i]=0;

    // input
    rep(i,m){
      int a,b,c;
      cin>>a>>b>>c;
      edge[a-1][b-1]=c;
    }

    // í[µáéÓë¢Ç
    rep(k,n){
      rep(i,n){
        rep(j,n){
          if( edge[i][k]!=INT_MAX && edge[k][j]!=INT_MAX ){
            edge[i][j] = min(edge[i][j], edge[i][k]+edge[k][j]);
          }
        }
      }
    }

    int ans = INT_MAX;
    rep(k,n){
      if( k==g1 ){
        if( edge[s][g1]!=INT_MAX && edge[g1][g2]!=INT_MAX ){
          ans = min(ans, edge[s][g1]+edge[g1][g2]);
        }
      }else if( k==g2 ){
        if( edge[s][g2]!=INT_MAX && edge[g2][g1]!=INT_MAX ){
          ans = min(ans, edge[s][g2]+edge[g2][g1]);
        }
      }else{
        if( edge[s][k]!=INT_MAX && edge[k][g1]!=INT_MAX && edge[k][g2]!=INT_MAX ){
          ans = min(ans, edge[s][k]+edge[k][g1]+edge[k][g2]);
        }
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 936
N = int(input())

if N < 10:
  print(N)
elif N < 100:
  print(9)
elif N < 1000:
  print(9 + (N - 99))
elif N < 10000:
  print(909)
elif N < 100000:
  print(909 + (N - 9999))
else:
  print(90909)


Measured memory_bytes: 2940
import time
s=0
def min(arr):
    m=arr[0]
    for i in range(1,len(arr)):
        if m>arr[i]:
            m=arr[i]
    return m

def mizu(arr):
    global s
    if len(arr)==1:
        
        s+=arr[0]
    elif len(arr)>1:
        m=min(arr)
        b=[]

        for i in range(len(arr)):
            arr[i]-=m
        s+=m

        for i in range(len(arr)):
            if arr[i]!=0:
                b.append(arr[i])
            else:
                mizu(b)
                b=[]
        if arr[-1]!=0:
            mizu(b)

n=int(input())
k=list(map(int,input().split()))
mizu(k)
print(s)

Measured memory_bytes: 3064
#include<iostream>
#include<utility>
#include<algorithm>
#include<cstdio>
using namespace std;

int main()
{
  int n,m,k;
  pair<int,int> p[20];
  int a,b,c;
  int i,j,l;

  cin>>n>>m>>k;

  for(i=0;i<n;i++)
    cin>>p[i].first;
  for(i=0;i<n;i++)
    cin>>p[i].second;

  sort(p,p+n);

  if(k==1){
    int ans=0;
    for(i=0;i<n;i++){
    a=min(m,p[i].second);
    ans=max(ans,p[i].first*a+m-a);
    }
    cout<<ans<<endl;

  }else if(k==2){ 

    long long dp[20][20]={};
    long long ans=0;
    for(i=0;i<n-1;i++)
      for(j=i+1;j<n;j++){
	a=min(p[j].second,m);
	b=min(p[i].second,m-a);
	dp[i][j]=p[j].first*a+p[i].first*b;
	ans=max(ans,dp[i][j]+m-a-b);
      }
    cout<<ans<<endl;


  }else if(k==3){

    long long dp[20][20][20]={};
    long long ans=0;

    for(i=0;i<n-2;i++)
      for(j=i+1;j<n-1;j++)
	for(l=j+1;l<n;l++){
	  a=min(p[l].second,m);
	  b=min(p[j].second,m-a);
	  c=min(p[i].second,m-a-b);
	  dp[i][j][l]=p[l].first*a+p[j].first*b+p[i].first*c;
	  ans=max(ans,dp[i][j][l]+m-a-b-c);

	}

    cout<<ans<<endl;
  }

}

Measured memory_bytes: 1168
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b;
	cin >> a >> b;
	cout << (a+b)%24 << endl;

}

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

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int T=1;
//cin>>T;
while(T--){
int k;
int a,b;
cin>>k>>a>>b;
for(int i=a;i<=b;i++){
    if(i%k==0){cout<<"OK\n";return 0;}
}
cout<<"NG\n";
}
return 0;
}
/*_*/

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

int main() {
  int A, B;
  cin >> A >> B;
  int L=0;
 /* for (int x=A; x<B+1; x++){*/
    int x=A;
    while (x<B+1){
    int a=x/10000; //10000
    int d=x%10; //1
    int b=(x-a*10000)/1000; //1000
    int c=(x-d)/10%10; //10
    if((a==d)&&(b==c)){
     L++; 
    }   
    x++;
  }
  cout << L << endl;
  
}


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

int main() {
  int H,W;
  cin >> H >> W;
  vector<string> vec1(H);
  for(int i=0;i<H;i++){
    cin >> vec1.at(i);
  }
  for(int i=0;i<W+2;i++){
    cout << "#";
  }
  cout << endl;
  for(int i=0;i<H;i++){
    cout << "#" << vec1.at(i) << "#" << endl;
  }
  for(int i=0;i<W+2;i++){
    cout << "#";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

// ???????????´??°?????????????????¢??°
void swap(int*, int*);

int main(){
    // tmp???swap??§?????????????????????????????§?¶???????OK
    int a, b, c;

    // ??\???
    scanf("%d %d %d", &a, &b, &c);

    // a???b????????§????????´????????????
    if(a > b){
        swap(&a, &b);
    }

    // a???c????????§????????´????????????(a???????°?????????????)
    if(a > c){
        swap(&a, &c);
    }

    // b???c????????§????????´????????????(b???2??????????°?????????????
    // ??¨???????????¨????????¶??????c?????????????????§????????????(?????§???)
    if(b > c){
        swap(&b, &c);
    }

    printf("%d %d %d\n", a, b, c);
    return 0;
}

void swap(int* x, int* y){
    int tmp;

    tmp = *x;
    *x = *y;
    *y = tmp;
}

Measured memory_bytes: 1024
N,K = map(int, input().split())
X = [int(i) for i in input().split()]

ans = float("inf")
for left in range(N - K + 1):
    right = left + K - 1

    if X[left] <= 0 and X[right] <= 0:
        tmp = -X[left]
    elif X[left] >= 0 and X[right] >= 0:
        tmp = X[right]
    else:
        if abs(X[left]) >= abs(X[right]):
            tmp = abs(X[right]) * 2 + abs(X[left])
        else:
            tmp = abs(X[left]) * 2 + abs(X[right])
    ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int D;
    cin >> D;
    int E = 25 - D;
    cout << "Christmas";
    rep(i,E) cout << " Eve";
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    int n; cin >> n;
    vector<int> d1(n, 0);
    vector<int> d2(n, 0);
    for(int i = 0; i < n; ++i) cin >> d1[i] >> d2[i];

    bool flg = false;
    for(int i = 0; i+2 < n; ++i) {
        if(d1[i] == d2[i]) {
            if(d1[i+1] == d2[i+1]) {
                if(d1[i+2] == d2[i+2]) {
                    flg = true;
                }
            }
        }
    }

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(void)
{

	int A,B;

	int i=1;
	int j=0;

	scanf("%d",&A);
	scanf("%d",&B);

	for(j=0;i<B;j++)
		i=i+A-1;

	printf("%d",j);

	return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>

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

using namespace std;
using ll = long long;
using ull = unsigned long long;


int main() {

	string s, t;

	cin >> s >> t;

	REP(i, s.size()) {
		char c = s.back();
		for(int j = s.size() - 1; j > 0; j--) {
			s[j] = s[j - 1];
		}
		s[0] = c;

		if (s == t) {
			cout << "Yes" NL;

			return 0;
		}

	}

	cout << "No" NL;

	return 0;

}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for _ in range(n)]
def LIR(n):
    return [LI() for _ in range(n)]
def SR(n):
    return [S() for _ in range(n)]
def LSR(n):
    return [LS() for _ in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b,c,d = LI()
    ans = max(a*c,a*d,b*c,b*d)
    if ans < 0:
        if a <= 0 and 0 <= b:
            ans = 0
        if c <= 0 and 0 <= d:
            ans = 0
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 65512