akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B; cin >> A >> B;
  cout << max(0, A-B*2) << endl;
}

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

int fanc(list<int> &l, int n, int t, vector<string> &vs){
	if(n == 1){
		return l.front();
	}else{
		int ret;
		if(t == 0){
			ret = l.front();
			l.pop_front();
		}else{
			ret = l.back();
			l.pop_back();
		}
		int fc = fanc(l, n-1, 1-t, vs);
		vs.push_back(to_string(ret) + " " + to_string(fc));
		return ret - fc;
	}
}

int main(){
	int n, ans;
	cin >> n;
	vector<int> a(n);
	vector<string> sv;
	rep(i, n) cin >> a.at(i);
	sort(a.begin(), a.end());
	vector<int> p, m;
	p.push_back(a.at(n-1));
	m.push_back(a.at(0));
	for(int i = 1; i < n-1; i++){
		int b = a.at(i);
		if(b < 0) m.push_back(b);
		else p.push_back(b);
	}
	rep(i, n-1){
		if(p.size() != 1){
			sv.push_back(to_string(m.back()) + " " + to_string(p.back()));
			m.back() -= p.back();
			p.pop_back();
		}else{
			sv.push_back(to_string(p.back()) + " " + to_string(m.back()));
			p.back() -= m.back();
			m.pop_back();
		}
	}
	cout << p.back() << endl;
	for(auto itr = sv.begin(); itr != sv.end(); itr++){
		cout << *itr << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 9716
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
struct edge{
	int to,cost;
};
class DIA{//diameter of tree
	public:
	vector<vector<edge> >G,tG;
	vi d;
	vector<bool>vis;
	int n;
	DIA(int size){
		n=size;
		G=tG=vector<vector<edge> >(n);
		d=vi(n);
		vector<bool>vis(n);
	}
	void add_edge(int a,int b,int c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);G[b].pb(ee);
	}
	void tadd_edge(int a,int b,int c){
		edge e={b,c},ee={a,c};
		tG[a].pb(e);tG[b].pb(ee);
	}
	void bfs(int s){
		d=vi(n,inf);
		queue<int>q;
		q.push(s);
		d[s]=0;
		int u;
		while(!q.empty()){
			u=q.front();q.pop();
			rep(i,G[u].size()){
				edge e=G[u][i];
				if(d[e.to]==inf){
					d[e.to]=d[u]+e.cost;
					q.push(e.to);
				}
			}
		}
	}
	int dia(){
		rep(i,n)if(G[i].size()){
			bfs(i);
			break;
		}
		int maxv=0,tgt=0;
		rep(i,n)if(d[i]!=inf&&maxv<d[i]){
			maxv=d[i];
			tgt=i;
		}
		bfs(tgt);
		maxv=0;
		rep(i,n)if(d[i]!=inf)maxv=max(maxv,d[i]);
		return maxv;
	}
	void solve(){
		int out=0;
		vi ha(n);
		rep(i,n)if(G[i].size()==1)ha[i]=true;
		rep(i,n)rep(j,G[i].size())if(ha[i]||ha[G[i][j].to]){
			out+=G[i][j].cost;
		}else{
			out+=3*G[i][j].cost;
			tadd_edge(i,G[i][j].to,G[i][j].cost);
		}
		G=tG;
		out/=2;
		int t=dia();
		cout<<out-t<<endl;
	}
};
int main(){
	int n;
	while(cin>>n,n){
		DIA dia(n);
		vvi in(2,vi(n-1));
		rep(i,2)rep(j,n-1)cin>>in[i][j];
		rep(i,n-1)dia.add_edge(i+1,in[0][i]-1,in[1][i]);
		dia.solve();
	}
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,l;
    cin>>n>>l;
    vector<string> s(n);
    rep(i,n) cin>>s[i];
    sort(all(s));
    rep(i,n) cout<<s[i];
}

Measured memory_bytes: 3580
#include<iostream>
#include<climits>
#include<algorithm>
using namespace std;
#define ll long long 



int main()
{
	ll n,i;
	cin>>n;
	ll a[n];
	ll dp[n];
	for(i=0;i<n;i++)
	{
		dp[i]=INT_MAX;
		cin>>a[i];
	}
	dp[0]=0;
	for(i=1;i<n;i++)
	{
		if(i-1>=0)
		{
			dp[i]=min(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
		}
		if(i-2>=0)
		{
			dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
		}
	}
	cout<<dp[n-1]<<"\n";
}

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

int main(){
  //int a,b,c;
  string a;
  cin >> a ;//>> b >> c >>d;
  int ans = 0;
  if(a.at(0)=='o')ans++;
  if(a.at(1)=='o')ans++;
  if(a.at(2)=='o')ans++;
  cout << 700+ans*100 << endl;
  return 0;
}

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 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

long long v[3100][3100], dp[3100][3100][5];
int main() {
    int R, C, K;
    cin >> R >> C >> K;
    memset(v, 0, sizeof(v));
    for (int i = 0; i < K; ++i) {
        long long r, c, t;
        cin >> r >> c >> t;
        v[r][c] = t;
    }
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i <= R; ++i) {
        for (int j = 0; j <= C; ++j) {
            for (int k = 0; k <= 3; ++k) {
                // 上へ行く
                if (i-1 >= 0) {
                    chmax(dp[i][j][0], dp[i-1][j][k]);
                    chmax(dp[i][j][1], dp[i-1][j][k] + v[i][j]);
                }
 
                // 右へ行く
                if (j-1 >= 0) {
                    chmax(dp[i][j][k], dp[i][j-1][k]);
                    if (k-1 >= 0)
                        chmax(dp[i][j][k], dp[i][j-1][k-1] + v[i][j]);
                }
            }
        }
    }
    long long res = 0;
    for (int k = 0; k <= 3; ++k) chmax(res, dp[R][C][k]);
    cout << res << endl;
}

Measured memory_bytes: 454100
#include <bits/stdc++.h>
typedef long long ll;
typedef double db;
#define pa pair<int,int>
#define mk make_pair
#define LOG(format, args...) fprintf(stderr, format, args)
using namespace std;
inline int rd() {
	int x=0,f=1;char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-1;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
const int MAXN=5e5+100;
ll N,a[MAXN];
ll l[MAXN];
ll but[MAXN],idx[MAXN];
ll ans[MAXN];
//main========================
int main() {
	memset(idx,0x3f,sizeof idx);
	N=rd();
	for(int i=1;i<=N;++i) a[i]=rd(),l[++*l]=a[i];
	sort(l+1,l+*l+1);
	*l=unique(l+1,l+*l+1)-l-1;
	for(int i=1;i<=N;++i) a[i]=lower_bound(l+1,l+*l+1,a[i])-l;
	for(int i=1;i<=N;++i) but[a[i]]++,idx[a[i]]=min((ll)i,idx[a[i]]);
	for(int i=*l;i>=1;--i) if(but[i]) {
		but[i-1]+=but[i];
		idx[i-1]=min(idx[i],idx[i-1]);
		ans[idx[i]]+=(ll)(l[i]-(i>1?l[i-1]:0) )*but[i];
	} 
	for(int i=1;i<=N;++i) printf("%lld\n",ans[i]);
	return 0;
}


Measured memory_bytes: 18304
while True:
  d, w = map(int, input().split())
  if d == 0:break
  mp = [list(map(int, input().split())) for _ in range(d)]
  def solve():
    ans = 0
    for left in range(w - 1):
      for right in range(w - 1, left + 1, -1):
        for top in range(d - 1):
          for under in range(d - 1, top + 1, -1):
            frame_height = 10
            frame_height = min(frame_height, min(mp[top][left:right + 1]))
            frame_height = min(frame_height, min(mp[under][left:right + 1]))
            frame_height = min(frame_height, min(mp[i][left] for i in range(top, under)))
            frame_height = min(frame_height, min(mp[i][right] for i in range(top, under)))
            pond_height = 0
            pond_height = max(pond_height, max(max(mp[i][left + 1:right]) for i in range(top + 1, under)))
            if pond_height < frame_height:
              temp = frame_height * (under - top - 1) * (right - left - 1) - \
                    sum(sum(mp[i][left + 1:right]) for i in range(top + 1, under))
              ans = max(temp, ans)
    print(ans)
  
  solve()


Measured memory_bytes: 5628
#include<bits/stdc++.h>
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define F(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define VE(i,v) for(int i = 0;i < (v).size();i++)

using namespace std;
#define trace(...) cerr<<__FUNCTION__<<":"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned int ui;
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
typedef pair<ll,ll> pll;
typedef vector<pll> vpll; 
 


unordered_map<int, int> cnt;
int id_cnt = 0;
int N, M, K;
void dfs(int i, int j, vector<string> &arr, vvi &id)
{
	id[i][j] = id_cnt;
	int r[] = {1,-1, 0, 0};
	int c[] = {0,0,1, -1};
	for(int idx =0; idx <4; idx++)
	{
		int u = i + r[idx];
		int v = j + c[idx];
		if((u>=0) && (v>=0) && ( u < N) && (v<M))
		{
			if(arr[u][v]=='*')
				cnt[id_cnt]++;
			else if (id[u][v]==0)
				dfs(u, v, arr, id);
		}
	}
}

int main()

{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	int T;
	T=1;
	for(int tc=1; tc<=T;tc++)
	{
		string inp;
		cin>>inp;
		map<string, int> ma;
		ma["SAT"] = 1;
		ma["SUN"]=7;
		ma["MON"]=6;
		ma["TUE"]=5;
		ma["WED"]=4;
		ma["THU"]=3;
		ma["FRI"]=2;
		cout<<ma[inp]<<"\n";
	}
 
 
 
	return 0;
}
 
 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    int i=0;
    int ans =1;
    while(i!=n){
        if(ans<k){
            ans = ans*2;
        }else{
            ans = ans + k;
        }
        i++;
    }
    cout << ans << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  sort(H.begin(), H.end());
  int ans = 1e9;
  for (int i = 0; i + K - 1 < N; i++) {
    ans = min(ans, H.at(i + K - 1) - H.at(i));
  }
  cout << ans << "\n";
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void doIt() {
		int n = sc.nextInt();
		if(n == 1) {
			System.out.println("Hello World");
		}
		else {
			System.out.println(sc.nextInt() + sc.nextInt());
		}
	}
	Main(){doIt();}
	public static void main(String[] args) {
		new Main();
	}

}



Measured memory_bytes: 23252
n = int(input())
w_list = [int(w) for w in input().split()]
ans = 100000000

for i in range(1, n+1):
  s1 = w_list[:i]
  s2 = w_list[i:]
  ans = min(ans, abs(sum(s1)-sum(s2)))

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

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

    if (x == 2) {
        cout << 2 << endl;
        return 0;
    }

    x--;
    while (1) {
        x++;
        if (x % 2 == 0) {
            continue;
        }
        bool prime = true;
        for (int i = 2; i < x; ++i) {
            if (x % i == 0) {
                prime = false;
                break;
            }
        }
        if (prime) {
            cout << x << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
ll mod = 1000000007;
ll modpow(ll a, int p) {
    if (p == 0)
        return 1;
    if (p & 1) {
        return a * modpow(a, p - 1) % mod;
    }
    ll half = modpow(a, p / 2);
    return half * half % mod;
}
ll calcComb(int a, int b) {
	if (b > a - b)
		return calcComb(a, a - b);
	ll ansMul = 1, ansDiv = 1;
	rep(i, 0, b) {
		ansMul *= (a - i);
		ansDiv *= (i + 1);
		ansMul %= mod;
		ansDiv %= mod;
	}
	return ansMul * modpow(ansDiv, mod - 2) % mod;
}
void solve() {
	var(int, n, m);
	int MNokori = m;
	ll ans = 1;
	for (int i = 2; i * i <= MNokori; ++i) {
		if (MNokori % i == 0) {
			int cnt= 0;
			while (MNokori % i == 0) {
				++cnt;
				MNokori /= i;
			}
			ans *= calcComb(n + cnt - 1, n - 1);
			ans %= mod;
		}
	}
	if (MNokori != 1) {
		ans = ans * n % mod;
	}
	print(ans);
}
int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <cassert>
#include <string.h>
#include <tuple>

using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)
#define  rrep(i,n) for(int i=n-1;i>=0;i--)///n-1番目からn回
#define  REP(i,a,b) for(int i=a;i<=b;i++) ///a番目からb回
#define  RREP(i,a,b) for(int i=a;i<b;i--)
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pair_t;
#define MOD 1000003

//int arr[N]
////sort(arr,arr +N)

//vector <int> hoge
////sort(hoge.begin(),hoge.end());
///*min_element(hoge.begin(),hoge.end();　最小値　　　最大値はmax_element();
///(10-(n%10))%10  10-(1桁目)取得 12->8 20->0

#define Ru(n)  ( ((n)+9)/10*10  ) //切りあげ
#define Rd(n)  ( ((n)-10)/10*10 +10 )	切り捨て


int gcd(int a,int b);
size_t length(const std::string& str) {
	return str.length();
}
bool comp(const pair_t &a, const pair_t &b) {
	return a.first < b.first;
}

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





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


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+10;
int n,cnt,p[N],vis[N];
ll a[510][510];
const int dx[]={0,0,1,-1};
const int dy[]={-1,1,0,0};
ll _lcm(ll x, ll y) {
	if (!y) return x;
	return x/gcd(x,y)*y;
}
int main() {
	REP(i,2,N-1) if (!vis[i]) for (int j=2*i; j<N; j+=i) vis[j] = 1;
	REP(i,2,N-1) if (!vis[i]) p[++cnt] = i;
	cin>>n;
	if (n==2) return puts("4 7\n23 10"),0;
	REP(i,1,n) REP(j,1,n) if (i+j&1) a[i][j] = p[(i+j)/2];
	REP(i,1,n) REP(j,1,n) if (i+j&1) a[i][j] *= p[(i-j+n-1)/2+n];
	REP(i,1,n) REP(j,1,n) if (!a[i][j]) {
		ll x = 1;
		REP(d,0,3) {
			int ii=i+dx[d],jj=j+dy[d];
			x = _lcm(x,a[ii][jj]);
		}
		a[i][j] = x+1;
	}
	REP(i,1,n) {
		REP(j,1,n) cout<<a[i][j]<<' ';hr;
	}
}








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


def solve(sx: int, sy: int, tx: int, ty: int):

    dirc = ["U", "D", "L", "R"]
    ans = []
    # 1
    if sx > tx:
        dirc[2] = "R"
        dirc[3] = "L"
    if sy > ty:
        dirc[0] = "D"
        dirc[1] = "U"

    ans += [dirc[3]]*(tx-sx)
    ans += [dirc[0]]*(ty-sy)

    ans += [dirc[2]]*(tx-sx)
    ans += [dirc[1]]*(ty-sy)

    ans += [dirc[1]]
    ans += [dirc[3]]*(tx-sx+1)
    ans += [dirc[0]]*(ty-sy+1)
    ans += [dirc[2]]

    ans += [dirc[0]]
    ans += [dirc[2]]*(tx-sx+1)
    ans += [dirc[1]]*(ty-sy+1)
    ans += [dirc[3]]

    print("".join(ans))

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    sx = int(next(tokens))  # type: int
    sy = int(next(tokens))  # type: int
    tx = int(next(tokens))  # type: int
    ty = int(next(tokens))  # type: int
    solve(sx, sy, tx, ty)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, d;
    cin >> n >> d;

    vvll x(n, vll(d));
    REP(i, n){
        REP(j, d){
            cin >> x[i][j];
        }
    }
    ll res = 0;
    REP(i, n){
        REP(j, n){
            if(j <= i) continue;
            ll tmp = 0;
            REP(k, d){
                tmp += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            ll xxx = sqrt(tmp);
            if(xxx * xxx == tmp) res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
as = gets.split.map(&:to_i)

tmp = []
as.each.with_index(1) do |a,i|
  tmp << a - i
end

tmp.sort!

b = tmp[tmp.size/2]

ans = 0
tmp.each do |t|
  ans += (t - b).abs
end
puts ans


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

int main() {

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

  sort(a, a + N);
  int alice = 0, bob = 0;
  for (int i = N - 1; i >= 0;i = i - 2)
  {
    alice += a[i];
  }
  for (int i = N - 2; i >= 0;i = i - 2)
  {
    bob += a[i];
  }

  cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*------------------------------------------------------------------------*/

void solve();

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

    solve();
}
void solve() {
    ll n, m;
    std::cin >> n >> m;

    vvll island(n);
    for (ll i = 0; i < m; i++) {
        ll a, b; std::cin >> a >> b;
        a--, b--;
        island[a].push_back(b);
        island[b].push_back(a);
    }

    auto bfs = [&]() -> ll {
        vll dist(n, -1); dist[0] = 0;
        std::queue<ll> que; que.push(0);

        while (!que.empty()) {
            ll cur = que.front(); que.pop();
            for (ll next : island[cur])
                if (dist[next] == -1) {
                    dist[next] = dist[cur] + 1;
                    que.push(next);
                }
        }

        return dist[n - 1];
    };

    std::cout << (bfs() == 2 ? "POSSIBLE" : "IMPOSSIBLE") << '\n';
}


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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	if (h2 >= h1) {
		int sum = (h2 - h1) * 60;
		if (h2 > h1) {
			sum -= m1;
			sum += m2;
		} else {
			sum += m2 - m1;
		}
		cout << sum - k << endl;
	} else {
		int sum = 0;
		sum += (24 - h1) * 60;
		sum += h2 * 60;
		sum -= m1;
		sum += m2;
		cout << sum - k << endl;
	}
	return 0;
}


Measured memory_bytes: 3640
court = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(n):
  b,f,r,v = map(int, input().split())
  court[b-1][f-1][r-1] += v
for i in range(4):
  for j in range(3):
    print(" "+" ".join(map(str, court[i][j])))
  if i < 3:
    print("#"*20)


Measured memory_bytes: 5608
#include<iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;


int main()
{
    string n;
    long long sum=0;
    cin >> n;

    for (int i = 0; i < (int)n.size(); ++i) {
        sum += (int)(n[i] - '0');
    }

    if (sum % 9 == 0) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    return 0;
}



Measured memory_bytes: 3676
def nbase(value,n):
    nbasevalue = 0
    digit = 0
    while value > 0:
        nbasevalue += (value%n)*(10**digit)
        value //= n
        digit += 1
    return nbasevalue

N,K = map(int,input().split())

ans = nbase(N,K)
print(len(str(ans)))



Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int[] x = new int[5];
    for(int i=0; i<5; i++) {
      x[i] = Integer.parseInt(str[i]);
      if(x[i]==0){
        System.out.println(i+1);
        break;
      }
    }
  }
}

Measured memory_bytes: 32504
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
int n;
int a , b;
vector < int > v[N];
int dfs(int node , int parent){
    int mask1 = 0;
    int mask2 = 0;
    for(int next : v[node]){
        if(next != parent){
            int val = dfs(next , node);
            mask2 |= val & mask1;
            mask1 |= val;
        }
    }
    int mn = 0;
    for(int i = 0 ; i < 20 ; ++i){
        if((mask2 >> i) & 1){
            mn = i;
        }
    }
    for(int i = mn ; i < 20 ; ++i){
        if(!((mask1 >> i) & 1)){
            mask1 |= 1 << i;
            mask1 &= ~((1 << i) - 1);
            break;
        }
    }
    return mask1;
}
int main(){
    scanf("%d" , &n);
    for(int i = 1 ; i < n ; ++i){
        scanf("%d %d" , &a , &b);
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    int ans = dfs(1 , 0);
    for(int i = 19 ; ; --i){
        if((ans >> i) & 1){
            printf("%d\n" , i);
            break;
        }
    }
}

Measured memory_bytes: 10240
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		Map<Character,Integer> alphabet = new TreeMap<Character,Integer>();
		for(char x = 'a'; x <= 'z'; x++) {
			alphabet.put(x,0);
		}
		for(int i = 0; i < w.length(); i++) {
			char temp = w.charAt(i);
			int num = alphabet.get(temp)+1;
			alphabet.put(temp,num);
		}
		for(char i:alphabet.keySet()){
			if(alphabet.get(i)%2!=0) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


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

#define SZ(c) int(c.size())
#define all(c) c.begin(), c.end()
#define pb  push_back
#define clr(a, n) memset(a, n, sizeof a)

const int mod = 1e9+7;

typedef vector<int> vi;
typedef long long ll;

int main() {

	string s;
	cin >> s;
	for (int i = 0; i < SZ(s); ++i) {
		cout << 'x';
	}

	return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

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

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

int64 N, M;
vector<int64> D;
vector<PLL> G[112345];
vector<PII> es;
vector<int64> col;
vector<int64> cost;

void dfs(int64 v, int64 p) {
  for (auto &e : G[v]) {
    if (col[e.fs] != -1 || cost[e.sc] != -1) continue;
    if (D[e.fs] < D[v]) {
      cost[e.sc] = INF;
      continue;
    } else {
//      cout << v << " " << "(" << e.fs << " " << e.sc << "): " << D[e.fs] << endl;
      cost[e.sc] = D[e.fs];
      col[e.fs] = 1-col[v];
      dfs(e.fs, v);
    }
  }
}

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

	cin >> N >> M;
	D = vector<int64>(N);
	es.resize(M);
	col.resize(N, -1);
	cost.resize(M, -1);
	REP(i, N) cin >> D[i];
	REP(i, M) {
	  cin >> es[i].fs >> es[i].sc; es[i].fs--; es[i].sc--;
	  G[es[i].fs].emplace_back(es[i].sc, i);
	  G[es[i].sc].emplace_back(es[i].fs, i);
	}
	REP(i, M) {
	  if (col[es[i].fs] == -1 && col[es[i].sc] == -1 && D[es[i].fs] == D[es[i].sc]) {
	    cost[i] = D[es[i].fs];
	    col[es[i].fs] = 0;
	    col[es[i].sc] = 1;
	    dfs(es[i].fs, es[i].sc);
	    dfs(es[i].sc, es[i].fs);
	  }
	}
	vector<int64> check(N, INF_LL);
	REP(i, M) {
//	  cout << es[i].fs << " " << es[i].sc << "---" << cost[i] << endl;
    if (cost[i] == -1) cost[i] = INF;
	  if (col[es[i].fs] == col[es[i].sc]) continue;
	  chmin(check[es[i].fs], cost[i]);
	  chmin(check[es[i].sc], cost[i]);
	}
	REP(i, N) {
	  if (D[i] != check[i] || col[i] == -1) {
	    cout << -1 << endl;
	    return 0;
	  }
	}
	REP(i, N) {
	  if (col[i]) cout << 'B';
	  else cout << 'W';
	}
	cout << endl;
	REP(i, M) {
	  cout << cost[i] << endl;
	}
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);

		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());

		if((a>c && c>b) || (a<c && c<b)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 23508
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
    long long ai, ao, at, aj, al, as, az;
    cin >> ai >> ao >> at >> aj >> al >> as >> az;

    long long cnt = 0;
    int num = ai % 2 + aj % 2 + al % 2;
    if (num >= 2 && ai > 0 && aj > 0 && al > 0) {
        cnt += 3;
        ai--, aj--, al--;
    }
    cnt += ao + ai / 2 * 2 + aj / 2 * 2 + al / 2 * 2;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
bool isRightTriangle(int a,int b,int c){
    if(pow(a,2)==pow(b,2)+pow(c,2))return true;
    else return false;
}
int main(){
    int N;
    cin>>N;
    int tri[3][N];
    for (size_t i = 0; i < N; i++)
    {
        for (size_t j = 0; j < 3; j++)
        {
            cin>>tri[j][i];
            /* code */
        }
        /* code */
    }
    for (size_t i = 0; i < N; i++)
    {
        if(isRightTriangle(tri[0][i],tri[1][i],tri[2][i])||isRightTriangle(tri[1][i],tri[0][i],tri[2][i])||isRightTriangle(tri[2][i],tri[1][i],tri[0][i])){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
        /* code */
    }
    return 0;
}


Measured memory_bytes: 3116
s=input()
if s[0]!="A":
      print("WA")
      exit()
if s[2:-1].count("C")!=1:
      print("WA")
      exit()

s=list(s)
s[0]="a"
s.remove("C")
if "".join(s).islower():
      print('AC')
else:
      print("WA")

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char ch[501];
int i,j,k,n,ans,a[501],b[501],c[501];
int work(int x){
	int i,j,k;
	for (i=1,k=0;!k&&i<=n;i++)
	 if (a[i]==x) k=1;
	if (!k) return n;
	for (i=1;i<=n;i++) c[i]=a[i];
	for (i=1;;i++){
		for (j=1,k=0;!k&&j<=n-i+1;j++)
		 if (c[j]!=x) k=1;
		if (!k) break;
		for (j=1;j<=n-i;j++)
		 if (c[j]==x||c[j+1]==x) b[j]=x;else b[j]=c[j];
		for (j=1;j<=n-i;j++) c[j]=b[j];
	}
	return i-1;
}
int main(){
	scanf("%s",ch);n=strlen(ch);
	for (i=1;i<=n;i++) a[i]=ch[i-1]-'a'+1;
	for (i=1,ans=n;i<=26;i++) ans=min(ans,work(i));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
n,a,b = map(int, raw_input().split())
s = raw_input()
ab = a+b
A= 0
B = 0
p = []
for c in s:
    if c == "a":
        if A < ab:
            A+=1
            p.append("Yes")
        else:
            p.append("No")
    elif c == "b":
        if A < ab and B < b:
            A +=1
            B+=1
            p.append("Yes")
        else:
            p.append("No")
    else:
        p.append("No")

for pp in p:
    print pp


Measured memory_bytes: 4036
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

int main(){
  int n;
  int l[10]={};
  int s[10]={};
  cin >> n;
  LOOP(i,n){
    cin >> l[i];
    LOOP(j,n){
      if(i==j)continue;
      s[j]+=l[i];
    }
  }
  // LOOP(i,n){
  //   cerr << i << ":" << l[i] << "*" << s[i] << endl;
  // }
  LOOP(i,n){
    if(!(l[i]<s[i])){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#*3 or /2
N = int(input())
a = list(map(int,input().split()))
ans = []
count = 0
for i in range(N):
	while(1):
		if  a[i]%2 == 0:
			a[i] = a[i]/2
			count += 1
		else:
			break

print(count)

Measured memory_bytes: 4532
#include <bits/stdc++.h>
using namespace std;
#define int long long

int G[300001];

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);

    for(int i=0; i<n; ++i) cin >> a[i];
    for(int i=0; i<n; ++i) cin >> b[i];
    for(int i=0; i<n; ++i) cin >> c[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    int ans = 0;
    for(int i=0; i<n; ++i) {
        int v = b[i];
        auto it1 = lower_bound(a.begin(), a.end(), v);
        int idx1 = distance(a.begin(), it1);
        auto it2 = upper_bound(c.begin(), c.end(), v);
        int idx2 = distance(c.begin(), it2);

        ans += (idx1 * (n-idx2));
    }

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



Measured memory_bytes: 2560
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

solve :: [Int] -> [Int] -> Int
solve vs cs = foldr (\(v,c) acc -> if v > c then acc + v - c else acc) 0 $ zip vs cs

main = do
    BC.getLine
    vs <- readInts
    cs <- readInts
    print $ solve vs cs

    


Measured memory_bytes: 380
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long
#define lli long long int

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

int main(){

  int N, a;
  cin >> N;
  int ans = 0;
  vector<int> A1(N);
  vector<int> A2(N);

  for (int i = 0; i < N; i++){
    cin >> a;
    A1.at(i) = a;
  }
  for (int i = 0; i < N; i++){
    cin >> a;
    A2.at(i) = a;
  }

  int x = N-1;

  while (x >= 0) {
    int sum = 0;
    for (int i = 0; i < N; i++) {
      // cout << "i " << i << endl;
      if(i <= x){
        // cout << "i <= x " << A1.at(i) << endl;;
        sum += A1.at(i);
      }
      if (i == x){
        // cout << "i == x " << A2.at(i) <<endl;;
        sum += A2.at(i);
      }
      if (i > x){
        // cout << "i > x " << A2.at(i) <<endl;;
        sum += A2.at(i);
      }
    }
    // cout << "sum "<<sum << endl;
    ans = max(ans, sum);
    x--;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3600
X = int(input())

ans = 1
flag = False

for b in range(2, X):
    if flag:
        break
    p = 2
    while True:
        if b**p > X:
            if p != 2:
                ans = max(ans, b**(p - 1))
            else:
                flag = True
            break
        p += 1
print(ans)


Measured memory_bytes: 2940
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <set>
//#inlcude<stringstream>
#define ll long long
#define MODD 1000000007
using namespace std;
ll arr[1000000]={0};
ll brr[1000000]={0};
int main() {
    //1 12 4 11 14 57 31 671644785
    ll n;cin>>n;
    for(int i=0;i<n;i++){
        ll a, b,sum=0;cin >>a>>b;
        ll mul = a*b;ll c = sqrt(mul);
        ll mi = a,ma=b;
        mi = min(mi,b);ma = max(a,ma);
        if(c*c==mul)c--;
        if(c*(c+1)>=mul)sum--;
        if(c>=mi)sum--;
        sum+=2*c;
        cout<<sum<<endl;
    }
    return 0;
}


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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795

ll no_of_div(ll a)
{
  ll cnt=0,i;
  if (a==2)return 1;
  for(i=2;i*i<a;i++)
  {
if(a%i==0)cnt+=2;
  }
  if(i*i==a)cnt++;
  return cnt;
}

//vl a(1001);

ll powM(ll a,ll b)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }

return ans;
}


bool blah(ll x)
{
  ll a=0;
  while(x)
  {
    x/=10;
    a++;
  }
  return (a&1)?true:false;
}




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

    ll n;cin>>n;
ll cnt=0;
    for(int i=1;i<=n;i++)
    {
      if(blah(i))cnt++;
    }
cout<<cnt<<"\n";



  return 0;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define M 100010

int main(){
    
    ll h1,m1,h2,m2,k;
    cin>>h1>>m1;
    cin>>h2>>m2;
    cin>>k;
    ll ans=0;
    if(h1==h2)ans=m2-m1;
    else {
    	if(m1)ans+=(60-m1),h1++;
    	if(m2)ans+=m2;
    	ans+=60*(h2-h1);
    }
    cout<<max(0ll,ans-k);
    
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;
//typedef pair<double, P> T;

const ll mod = 1000000007;
const ll INF = 100000010000;

ll N, M;
ll p[100010];
string S[100010];
ll pen[100010];
ll a, b;

ll ans;

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

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return x * pow_mod(x, y - 1) % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x)
{
	return pow_mod(x, mod - 2);
}

void init()
{
	cin >> N >> M;
	for (int i = 0; i < M; i++)
	{
		cin >> p[i] >> S[i];
	}
}

void output()
{
	cout << a << ' ' << b << endl;
}



void solve()
{
	for (int i = 0; i < M; i++)
	{
		if (S[i][0] == 'A')
		{
			if (pen[p[i]] >= INF)
			{

			}
			else
			{
				b += pen[p[i]];
				a++;
				pen[p[i]] = INF;
			}
		}
		else
		{
			pen[p[i]]++;
		}
	}
}

int main()
{
	init();

	solve();



	output();
	ll N;
	cin >> N;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
	chutiyaap;
    deque<char>dq;
    string s;
    cin>>s;
    for(auto x:s)	dq.push_back(x);
    int flag=0;
    int q;cin>>q;
    while(q--)
    {
    	int x;cin>>x;
    	if(x==1)
    	{
    		flag^=1;
    	}
    	else
    	{
    		int y;cin>>y;
    		char c;cin>>c;
    		if(flag)
    		{
    			if(y==1)
    			{
    				dq.pb(c);
    			}
    			else dq.push_front(c);
    		}
    		else
    		{
    			if(y==1)dq.push_front(c);
    			else dq.pb(c);
    		}
    	}
    }
    if(flag){
    	while(!dq.empty())
    	{
    		cout<<dq.back();
    		dq.pop_back();
    	}
    }
    else 
    {
    	while(!dq.empty())
    	{
    	cout<<dq.front();
    	dq.pop_front();
    }
    }
}

Measured memory_bytes: 976
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int count = 0;
		for(char c : s.toCharArray()) {
			if(c == '1') {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23636
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

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

void solve() {
  int n; cin >> n;
  vector<ll> sums(n);
  ll sum = 0, ans = __INT_MAX__;
  rep(i, n) {
    ll a; cin >> a;
    sum += a;
    sums[i] = sum;
  }
  for (int i = 0; i < n - 1; i++) {
    ans = min(ans, abs(sums[n - 1] - sums[i] * 2));
  }
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

// 桁、N未満か、k
ll dp[110][2][5];

int main () {
    string x;
    int K, n;
    cin >> x >> K;
    n = x.size();
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    rep(i, n) {
        int D = x[i] - '0';
        rep(j, 2) rep(k, 4) rep(d, (j ? 10 : D+1)) {
            dp[i+1][j || (d < D)][d != 0 ? k+1 : k] += dp[i][j][k];
        }
    }
    cout << dp[n][0][K] + dp[n][1][K] << endl;
}


Measured memory_bytes: 256