akhauriyash/Code-Regression huggingface dataset:
/*||>>>> Praveen Ojha <<<<>>>> 10 June 2019 <<<<>>>> 00:55:52 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf 1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int maxn=100005;
vi brk(maxn);
int n,m,x;
int dp[maxn];
int solve(int ind){
	if(ind>n)
		return 0;
	if(brk[ind])
		return 0;
	if(ind==n)
		return 1;
	if(dp[ind]!=-1)
		return dp[ind];
	return dp[ind]=(solve(ind+1)+solve(ind+2))%mod;
}
int32_t main(){__
	memset(dp,-1,sizeof dp);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>x;
		brk[x]=1;
	}
	cout<<solve(0)<<"\n";
return 0;
}

Measured memory_bytes: 4992
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
class DIJ{
	public:
	struct edge{
		int to,cost;
	};
	int n,m;
	ll MOD=1000000007;
	vvi d,co;//distance
	DIJ(int N,int M){
		n=N;
		m=M;
	}
	void dij(int sx,int sy,int gx,int gy){
		d=vvi(n,vi(m,inf));
		co=vvi(n,vi(m));
		co[sx][sy]=1;
		d[sx][sy]=0;
		priority_queue<tp>q;
		q.push(tp(0,sx,sy));
		while(!q.empty()){
			int cost,x,y;
			tie(cost,x,y)=q.top();
			cost*=-1;
//			cout<<x<<" "<<y<<" "<<cost<<endl;
			q.pop();
			if(cost>d[x][y])continue;
			rep(i,8){
				int nx=x;
				int ny=y;
				if(i<4){
					nx+=dx[i];
					ny+=dy[i];
				}else if(i==5)nx=0;
				else if(i==6)ny=0;
				else if(i==7)nx=n-1;
				else if(i==4)ny=m-1;
				if(nx<0||ny<0||nx>=n||ny>=m)continue;
				int nowcost=cost+1;
//				cout<<nx<<" "<<ny<<" "<<nowcost<<endl;
				if(nowcost<d[nx][ny]){
					d[nx][ny]=nowcost;
					q.push(tp(-d[nx][ny],nx,ny));
					co[nx][ny]=co[x][y];
				}else if(nowcost==d[nx][ny]){
					(co[nx][ny]+=co[x][y])%=MOD;
				}
			}
		}
		cout<<d[gx][gy]<<" "<<co[gx][gy]<<endl;
	}
};
int main(){
	int n,m,a,b,c,d;
	cin>>n>>m>>a>>b>>c>>d;
	DIJ dij(n,m);
	dij.dij(a,b,c,d);
}










Measured memory_bytes: 4360
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 3005, MOD = 1000000007;
typedef long long i64;
i64 f[2][MAX_N];
int L[MAX_N], R[MAX_N], C[MAX_N][MAX_N];
char s[MAX_N];

int main() {
  int N, M;
  
  scanf("%d%d", &N, &M);
  scanf("%s", s + 1);
  
  for (int i = 1; i <= M; ++i) {
    scanf("%d%d", &L[i], &R[i]);
    if (R[i] <= R[i - 1]) i--, M--;
  }
  
  for (int i = 0; i <= N; ++i) {
    C[i][0] = 1;
    for (int j = 1; j <= i; ++j)
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
  }
  
  int o = 0, p;
  R[0] = L[1] - 1, f[0][0] = 1, L[M + 1] = N + 1;
  
  for (int i = 1; i <= M; ++i) {
    p = o, o ^= 1;
    memset(f[o], 0, sizeof f[o]);
    int num = 0;
    for (int j = R[i - 1] + 1; j <= R[i]; ++j)
      if (s[j] == '1') num++;
    
    int temp1 = R[i - 1] - L[i] + 1, temp2 = max(R[i] - L[i + 1] + 1, 0);
    
    for (int k1 = 0; k1 <= temp1; ++k1) {
      int num1 = num + k1, num0 = R[i] - L[i] + 1 - num1;
      for (int k2 = 0; k2 <= temp2; ++k2) {
	int rest1 = num1 - k2, rest0 = num0 - temp2 + k2;
	if (rest1 < 0 || rest0 < 0) continue;
	f[o][k2] = (f[o][k2] + C[rest1 + rest0][rest1] * f[p][k1] % MOD) % MOD;
      }
    }
    if (R[i] < L[i + 1] - 1) R[i] = L[i + 1] - 1;
  }

  printf("%lld\n", f[o][0]);
  
  return 0;
}


Measured memory_bytes: 34176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
int x[maxn], y[maxn], n;
ll cal(ll x) {
	return x * (x + 1) / 2;
}
int main() {
	scanf("%d",&n);
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		scanf("%d%d",&x[i],&y[i]);
		if (x[i] > y[i]) swap(x[i],y[i]);
		ans += cal(i);
		ans -= 1ll * x[i] * (n - y[i] + 1);
	}
	printf("%lld\n",ans + cal(n));
	return 0;
}

Measured memory_bytes: 5392
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

int main(){
    ios;
    INT(h, w, n);
    V<pair<int,int>> vec(n);
    REP(i, n){
        ll x, y; cin >> x >> y;
        vec[i] = {x, y};
    }
    sort(all(vec));
    ll cnt = 0;
    REP(i, n){
        fin(vec[i].first > vec[i].second + cnt, vec[i].first - 1);
        if(vec[i].first == vec[i].second + cnt) cnt++;
    }
    print(h);
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

ll keta(ll x){
    ll cnt=0;
    ll c=x;
    while(c>0){
        cnt++;
        c/=10;
    }
    return cnt;
}
ll f(ll x,ll y){
    return max(keta(x),keta(y));
}

int main(){
    ll n;cin >>n;
    ll ans=INF;
    for (ll i = 1; i*i<=n; ++i) {
        if(n%i==0){
            ans=min(ans,f(i,n/i));
        }
    }
    cout <<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
a=0;b=0;c=0
while n = gets do
    n=n.to_i
    if a<n then
        c=b;b=a;a=n
    elsif b<n then
        c=b;b=n
    elsif c<n then
        c=n
    end
end
#print(a," ",b," ",c)
puts a;puts b;puts c

Measured memory_bytes: 6088
#include "bits/stdc++.h"
using namespace std;

int a,b,c;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>a>>b>>c;
	int d=b/a;
	if(d>=c)
		cout<<c;
	else
		cout<<d;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

struct Edge { int from, to; };
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &g, int from, int to) {
	g[from].push_back(Edge{ from, to });
}

void dfs(const Graph& g, int v, vector<bool>& used, vi& vs)
{
	used[v] = true;
	for (auto i : g[v])
	{
		if (!used[i.to]) dfs(g, i.to, used, vs);
	}
	vs.push_back(v);
}

void rdfs(const Graph& rg, int v, vector<bool>& used, int k, vi& cmp)
{
	used[v] = true;
	cmp[v] = k;
	for (auto i : rg[v])
	{
		if (!used[i.to]) rdfs(rg, i.to, used, k, cmp);
	}
}

int strongly_connected_component(Graph graph, vi& cmp)
{
	int V = graph.size();
	Graph g(V), rg(V);
	vector<bool> used(V);
	vi vs;
	cmp.resize(V);
	REP(i, V)
	{
		for (auto e : graph[i])
		{
			add_edge(g, i, e.to);
			add_edge(rg, e.to, i);
		}
	}
	REP(i, V)
	{
		if (!used[i]) dfs(g, i, used, vs);
	}
	used = vector<bool>(V);
	reverse(ALL(vs));
	int k = 0;
	for (auto i : vs)
	{
		if (!used[i]) rdfs(rg, i, used, k++, cmp);
	}
	return k;
}

Graph buildGraph(const Graph& g, const vi& cmp, int K)
{
	int V = g.size();
	vector<set<int>> s(K);
	Graph res(K);
	REP(i, V)
	{
		for (auto e : g[i]) s[cmp[i]].insert(cmp[e.to]);
	}
	REP(i, K)
	{
		for (auto j : s[i]) if (i != j) add_edge(res, i, j);
	}
	return res;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n;
	while (cin >> n, n)
	{
		vector<ld> p(n);
		Graph g(n);
		REP(i, n)
		{
			cin >> p[i];
			int m; cin >> m;
			REP(j, m)
			{
				int a; cin >> a; a--;
				add_edge(g, i, a);
			}
		}
		vi cmp;
		int k = strongly_connected_component(g, cmp);
		Graph dag = buildGraph(g, cmp, k);
		set<int> src;
		REP(i, k) src.insert(i);
		REP(i, k)
		{
			for (auto e : dag[i])
			{
				int u = e.to;
				if (src.count(u)) src.erase(u);
			}
		}
		ld ans = 1.0;
		REP(i, k)
		{
			if (src.count(i))
			{
				ld tmp = 1.0;
				REP(j, n)
				{
					if (cmp[j] == i)
					{
						tmp *= p[j];
					}
				}
				ans *= 1 - tmp;
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3492
#include <iostream>
#include <vector>
#include <deque>
using namespace std;
typedef long long ll;

class BIT{
private:
    vector<ll> bit;
    int n;
public:
    BIT(){};
    BIT(int N){
        init(N);
    }
    void init(int N){
        n = N;
        bit.clear();
        bit.resize(N+1,0);
    }
    ll sum(int i){
        ll s = 0;
        while(i>0){
            s += bit[i];
            i -= i&-i;
        }
        return s;
    }
    ll sum_range(int l,int r){
        if(l>r) return 0;
        return (sum(r)-sum(l-1));
    }
    void add(int i,ll x){
        while(i<=n){
            bit[i] += x;
            i += i&-i;
        }
    }
    ll sum0(int i){
        return sum(i);
    }
    void add0(int i,ll x){
        add(i,x);
    }
};

int main(){
    ll N;
    ll ma = 100000;
    cin >> N;
    vector<vector<ll>> v(ma+1);
    BIT bit(N);
    for(int i=1;i<=N;i++){
        ll a;
        cin >> a;
        v[a].push_back(i);
    }
    ll ans = 0;
    for(int i=1;i<=ma;i++){
        if(v[i].empty()) continue;
        int n = v[i].size();
        vector<ll> L(n+2,0),R(n+2,0);
        for(auto x:v[i]) bit.add(x,1);
        for(ll j=1;j<=n;j++){
            ll id = v[i][j-1];
            L[j] = L[j-1]+(id-1-bit.sum_range(1,id-1));
        }
        for(ll j=n;j>=1;j--){
            ll id = v[i][j-1];
            R[j] = R[j+1]+(N-id)-bit.sum_range(id+1,N);
        }
        ll c = 1e18;
        for(int j=0;j<=n;j++) c = min(c,L[j]+R[j+1]);
        ans += c;
    }
    cout << ans << endl;
}


Measured memory_bytes: 9072
#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 ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

ull func(ull n){
    if(n == 1) return 1;
    return 2 * func(n/2) + 1;
}

int main()
{
    ull n, cnt=0;
    cin >> n;
    cnt = sqrt(n);
    cout << func(n) << endl;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int c = Integer.parseInt(sc.next());
    boolean flag=true;
    for (int i = 0; i <=b; i++) {
        if((a*i)%b==c){
        flag=true;
        break;
        }else{
        flag=false;
        }
    }
    if(flag){
        out.println("YES");
    }else{
        out.println("NO");   
    }
}
}

Measured memory_bytes: 23892
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
fn main() {
    let (n, a, b) = read_three::<i32>();
    let mut s: String = read();
    let mut v: Vec<bool> = Vec::new();
    let mut inners = 0;
    let mut outers = 0;
    for i in s.chars() {
        if i == 'a' {
            if inners + outers < a + b {
                v.push(true);
                inners += 1;
            } else {
                v.push(false);
            }
        } else if i == 'b' {
            if inners + outers < a + b && outers < b {
                v.push(true);
                outers += 1;
            } else {
                v.push(false);
            }
        } else {
            v.push(false);
        } 
    }
    for i in v.iter() {
        if *i {
            println!("Yes");
        }  else {
            println!("No");
        }
    }
}

Measured memory_bytes: 4732
N, A , B = map(int,input().split())
s = 0
ans = 0
for i in range(N + 1):
    if i < 10:
        ans = i
        if ans >= A and ans <= B:
            s += i
    elif i < 100:
        ans =  i // 10 + i % 10
        if ans >= A and ans <= B:
            s += i
    elif i < 1000:
        ans = i // 10
        ans = ans // 10 + ans % 10 + i % 10
        if ans >= A and ans <= B:
            s += i
    elif i < 10000:
        ans = i//10
        ans = i % 10 + ans % 10 + ans // 10 % 10 + i // 1000
        if ans >= A and ans <= B:
            s += i
    else:
        ans = 1
        if ans >= A and ans <= B:
            s += i
print(s)


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for(int i = 0; i < m; ++i){
        int x, y, z;
        cin >> x >> y >> z;
        --x; --y;
        uf.unionSet(x, y);
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        if(uf.data[i] < 0) ++ans;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x%p;
		x = x * x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n, x;
signed main() {
	while (cin >> n >> x && (n | x)) {
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				if (x - j - i > j&&x - j - i <= n) {
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3088
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();//Aの長さ
		int m=sc.nextInt();//Aの最大値
		int q=sc.nextInt();//abcdの長さ
		
		int[]a=new int[q];
		int[]b=new int[q];
		int[]c=new int[q];
		int[]d=new int[q];
		
		for(int i=0;i<q;i++){
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
			c[i]=sc.nextInt();
			d[i]=sc.nextInt();
		}
		
		int[]k=new int[n];
		
		/*if(q==1)System.out.println(d[0]);
		else */System.out.println(dfs(k, 0, 1,a,b,c,d,0,m));
		
	}
	
	static int dfs(int[] k, int index, int start,int[] a,int[] b,int[]c, int[]d, int max, int m){
		if(index==k.length){
			int tmp=0;
			for(int i=0;i<a.length;i++){
				if(k[b[i]-1]-k[a[i]-1]==c[i])tmp+=d[i];
			}
			
			if(tmp>max)max=tmp;
			
			return max;
		}
		
		for(int i=index;i<k.length;i++){
			
			for(int j=start;j<=m;j++){
				//System.out.print(index);
				k[index]=j;start=j;
				max=Math.max(dfs(k, index+1, start,a,b,c,d,max, m),max);
				
			}
		}
		return max;
		
		
	}
	
}


Measured memory_bytes: 37848
#include <bits/stdc++.h>
using namespace std;
vector<int>v[100005],g[100005];
long long dp[100005];
/*void dfs(int s,int len,int par)
{
    int i;
    if(dist[s]>len)
    {
        return ;
    }

    dist[s]=len;
    for(i=0;i<g[s].size();i++)
    {
        if(g[s][i]!=par)
        {
            dfs(g[s][i],len+1,s);
        }
    }
}*/
long long int dfs(int s)
{
    int i;
    if(dp[s]>=0)
    {
        return dp[s];
    }
    if(v[s].size()==0)
    {
        return dp[s]=0;
    }
    for(i=0;i<v[s].size();i++)
    {
        dp[s]=max(dp[s],dfs(v[s][i])+1);
    }
    return dp[s];
}
int main()
{
    int n,m;
    cin>>n>>m;
    int i;
    for(i=1;i<=n;i++)
    {
        dp[i]=-1;
    }
    int a,b;
    for(i=0;i<m;i++)
    {
        cin>>a>>b;
        v[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int>ans;
    for(i=1;i<=n;i++)
    {
        dfs(i);
    }
    /*for(i=0;i<ans.size();i++)
    {
        cout<<ans[i]<<" ";
    }
    cout<<endl;*/
    long long ans1=0;
    for(i=1;i<=n;i++)
    {
        if(dp[i]!=1e18)
        {
            ans1=max(ans1,dp[i]);
        }
    }
    cout<<ans1<<endl;

}


Measured memory_bytes: 13952
import java.util.Scanner;

public class Main {

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

        int i = 0;
        while(true) {
            i++;
            int n = scanner.nextInt();
            if (n == 0) break;
            System.out.printf("Case %d: %d\n", i, n);
        }
        scanner.close();
    }
}



Measured memory_bytes: 62032
def calc_happiness(h):
    n = len(h)

    states = [[None, None, None] for i in range(n)]
    states[0] = h[0]
    for i in range(1, n):
        states[i][0] = h[i][0] + max(states[i-1][1], states[i-1][2])
        states[i][1] = h[i][1] + max(states[i-1][0], states[i-1][2])
        states[i][2] = h[i][2] + max(states[i-1][0], states[i-1][1])
    return max(states[n-1][0], states[n-1][1], states[n-1][2])

if __name__ == "__main__":
    n = int(input())
    h = [[]] * n
    for day in range(n):
        h[day] = list(map(int, input().split(" ")))
    res = calc_happiness(h)
    print(res)

Measured memory_bytes: 47288
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MAXN = 3e5 + 123;
const ld EPS = 1e-12;
const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

ll n, k, ans, a[MAXN], pref[MAXN], suff[MAXN], pref_sum[MAXN];

void solve(){
	cin >> n >> k;

	for(int i = 1; i <= n; ++i){
		cin >> a[i];
		pref[i] = pref[i - 1] + (a[i] > 0) * a[i];
		pref_sum[i] = pref_sum[i - 1] + a[i];
	}

	for(int i = n; i >= 1; --i){
		suff[i] = suff[i + 1] + (a[i] > 0) * a[i];
	}

	for(int i = 1; i + k - 1 <= n; ++i){
		ans = max(max(pref_sum[i + k - 1] - pref_sum[i - 1], 0ll) + pref[i - 1] + suff[i + k], ans);
	}

	cout << ans;
}

int main(){

	faster();
 
	int T = 1;
	// cin >> T;
	
	while(T--){
		solve();
	}
 
	return 0;
}

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

ll f(ll x) {
    if (x % 4 == 0) return x;
    if (x % 4 == 1) return 1;
    if (x % 4 == 2) return x + 1;
    return 0;
}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << (f(b) ^ f(a - 1)) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
S=list(input())
A=int(S[0])
B=int(S[1])
C=int(S[2])
D=int(S[3])
if A+B+C+D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+"+"+B+"+"+C+"+"+D+"=7")
  sys.exit()
elif A+B+C-D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+"+"+B+"+"+C+"-"+D+"=7")
  sys.exit()
elif A+B-C+D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+"+"+B+"-"+C+"+"+D+"=7")
  sys.exit()
elif A-B+C+D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+"-"+B+"+"+C+"+"+D+"=7")
  sys.exit()
elif A+B-C-D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+"+"+B+"-"+C+"-"+D+"=7")
  sys.exit()
elif A-B-C+D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+"-"+B+"-"+C+"+"+D+"=7")
  sys.exit()
elif A-B+C-D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+"-"+B+"+"+C+"-"+D+"=7")
  sys.exit()
elif A-B-C-D==7:
  A=str(A)
  B=str(B)
  C=str(C)
  D=str(D)
  print(A+"-"+B+"-"+C+"-"+D+"=7")
  sys.exit()

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

int dp[400];
int n,s,l,p,w,ans[400];

int main(){

  for(int i = 0; i < 400;i++){
    dp[i] = -1;
  }
  dp[0] = 0;

  cin >> n;
  for(int i = 0; i < n;i++){
    cin >> s >> l >> p;
    for(int j = s; j <= l ;j++){ 
      if(dp[j] < p){
	dp[j] = p;
      }
    }
  }

  for(int i = 1; i < 400;i++){
    int max = -1;
    for(int j = 0; j <= (i)/2; j++){
      if(dp[j] != -1 && dp[i-j] != -1){
	if(max < dp[j] + dp[i-j]) max =  dp[j] + dp[i-j];
      } 
       }
    dp[i] = max;
  }

  for(int i = 0; i < 393 ;i++){
    //     cout << dp[i] << " ";
  }
  //   cout << endl;



  int m;
  cin >> m;
  vector<int> ans;
  int f = 0;
  for(int i = 0; i < m;i++){
    cin >> w;
    if(dp[w] == -1){
      cout << "-1\n";
      return 0;
    }
    else{
      ans.push_back(dp[w]); 
    }
  }

  if(f != 1){
    for(int i = 0; i < ans.size() ;i++){
      cout << ans[i] << endl;
    }
  }
  return 0;
}

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

int main(){
    int N,M; cin >> N >> M;
    int a[N];
    priority_queue<int> que;
    for(int i=0;i<N;i++){
        cin >> a[i];
        que.push(a[i]);
    }
    for(int i=0;i<M;i++){
        int p=que.top(); que.pop();
        p/=2;
        que.push(p);
    }
    long long ans=0;
    while(!que.empty()){
        int p=que.top();que.pop();
        ans+=p;
    }
    cout << ans << endl;
    


}

Measured memory_bytes: 1148
n=int(input())
vi=[]
for i in map(int,input().split()):
    vi.append(i)
#print(hi)
vi.sort(reverse=True)

r=0.5
vsum=vi[0]*r

ri=0.5
for i in range(n-1):
    ri=ri*r
    vsum=vsum+vi[i+1]*ri
vsum=vsum+vi[i+1]*ri

print(vsum)

Measured memory_bytes: 3064
<?php
fscanf(STDIN, '%s', $S);
$a = str_split($S);
$ans = 0;
$c1 = 0;
$c2 = count($a) - 1;
while ($c1 < $c2) {
    if ($a[$c1] === $a[$c2]) {
        $c1++;
        $c2--;
    } else {
        if ($a[$c1] === 'x') {
            $c1++;
            $ans++;
        } else if ($a[$c2] === 'x') {
            $c2--;
            $ans++;
        } else {
            $ans = -1;
            break;
        }
    }
}
echo $ans;


Measured memory_bytes: 10744
// Debug : debug template
// Number : number theory 

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define pi pair<int,int>
#define IOS ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);

const int inf = 0x3f3f3f3f;
const ll INF = 0xFFFFFFFFFFFFFFFL;

typedef tree<int,null_type, /*greater<int>,*/
less<int>,rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// find_by_order() and order_of_key() returns pointers
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)

void solve(){
	// your main solution for each testcase
	int n,t;
	cin >> n >> t;
	set<int> st;
	for(int i=0;i<n;i++){
		int x, y;
		cin >> x >> y;
		if(y<=t)
			st.insert(x);
	}
	if(st.empty()==true)
		cout << "TLE\n";
	else 
		cout << *st.begin() << '\n';
}

int main(){
	IOS;
	int test=1;
	// cin >> test;
	while(test--)
		solve();

	return 0;
}


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

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int Q = sc.nextInt();
		int[] s = new int[100010];
		for(int i = 3; i < 100000; i = i + 2) {
			boolean flag1 = prime(i);
			boolean flag2 = prime((i + 1) / 2);
			if (flag1 && flag2) {
				s[i] += s[i - 2] + 1;
			} else {
				s[i] = s[i - 2];
			}
		}
		for(int i = 0; i < Q; i++) {
			int left = sc.nextInt() - 2;
			if (left < 0) left = 0;
			int right = sc.nextInt();
			//out.println("right" + s[right] + " left" + s[left - 1]);
			out.println(s[right] - s[left ]);
		}		
		
		out.close();
	}

	static boolean prime(int n) {
		boolean flag = true;
		int max = (int)Math.sqrt(n);
		for (int i = 2; i <= max; i++) {
			if (n % i == 0) {
				flag = false;
				break;
			}
		}
		if (n == 1) flag = false;
		return flag;
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}



Measured memory_bytes: 28296
N = int(input())
A = list(map(int, input().split()))
def pow2(a):
    return 1<<min(a, 63)
ans = 0
Cap = []
c = 1
for d, a in enumerate(A):
    Cap.append(c)
    c -= a
    if c < 0:
        print(-1)
        exit()
    c *= 2
    if c >= 1<<63:
        c = 1<<63
siz = 0
#print(Cap)
for d, a, cap in zip(range(N, -1, -1), A[::-1], Cap[::-1]):
    #print(d, a, cap)
    siz = min(siz+a, cap)
    ans += siz
    #print(siz)
print(ans)






Measured memory_bytes: 20152
#include<iostream>

int main()
{
    int N;
    std::cin >> N;
    if (N == 1){
        std::cout << "Hello World" << std::endl;
        return 0;
    }

    int A, B;
    std::cin >> A ;
    std::cin >> B;
    std::cout << A + B << std::endl;
    return 0;
}

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


   // int mokemoke,hogehoge;
   // std::cin >> mokemoke >> hogehoge;
   // std::cout << mokemoke << hogehoge << std::endl;

int main(){

    int a,b,h,c;
    std::cin >> a >> b >> h;
    c = a + b;

    std::cout << c * h / 2 << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}

using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n,m,R;
  cin>>n>>m>>R;
  vector<int> r(R);
  REP(i,R){
    cin>>r[i];
    r[i]--;
  }
  sort(r.begin(), r.end());
  
  vector<vector<long long>> dist(n, vector<long long>(n, INF));
  REP(i,n){
    dist[i][i] = 0;
  }
  int a,b;
  long long c;
  REP(i,m){
    cin>>a>>b>>c;
    a--;b--;
    dist[a][b] = dist[b][a] =  c;
  }
  
  REP(k,n){
    REP(i,n){
      REP(j,n){
        dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
      }
    }
  }
  
  long long ans = INF;
  long long temp;
  do{
    temp = 0;
    REP(i,R-1){
      temp += dist[r[i]][r[i+1]];
    }
    ans = min(ans, temp);
  }while(next_permutation(r.begin(), r.end()));
  cout<<ans<<endl;
  return 0;
}


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

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef unsigned long long ULL;
 
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)a.size()
#define f first
#define s second
#define FILL(a, b) memset(a, b, sizeof(a))
 
const int MAX = 400*1000+5;
const int INF = 1000*1000*1000 + 7;
const LL LINF = 1LL*INF*INF;
const int MOD = INF;
const double PI = acos(-1.);
const int MAXN = 10*100007;
const double EPS = 1e-6;
 
mt19937 rnd(time(0));


int main()
{
	ios_base::sync_with_stdio(0);
	LL x, y;
	cin >> x >> y;
	if (abs(x - y) <= 1)
	{
		cout << "Brown\n";
	}
	else
	{
		cout << "Alice\n";
	}

	return 0;
}

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

int main()
{
  string str; cin>>str;
  bool n=false,w=false,s=false,e=false;
  for (auto c:str) {
    if (c=='N') n=true;
    if (c=='W') w=true;
    if (c=='S') s=true;
    if (c=='E') e=true;
  }
  if (!(n^s) && !(e^w)) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
#define INF 1000000001

vector<int> a(3);


int main(void){
    // a[0] = 100;
    // a[2] = 2;
    // fill(a,a+3,100);
    // cout << count(a,a+3,100) << endl;
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(),a.end());
    // cout << a[0] << a[1] << a[2];
    
    int ans = 0;
    //全て偶数or奇数
    if (a[0]%2 == a[1]%2 &&  a[1]%2 == a[2]%2) {
        ans += (a[2]-a[0])/2 + (a[2]-a[1])/2;
        cout << ans << endl;
    }
    else{
        if (a[0]%2 == a[1]%2 &&  a[1]%2 != a[2]%2) {
            a[0]++,a[1]++;
        }
        if (a[1]%2 == a[2]%2 &&  a[2]%2 != a[0]%2) {
            a[1]++,a[2]++;
        }
        if (a[2]%2 == a[0]%2 &&  a[0]%2 != a[1]%2) {
            a[2]++,a[0]++;
        }
        
        ans += (a[2]-a[0])/2 + (a[2]-a[1])/2;
        cout << ans + 1 << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll A,B,C,D;
  cin>>A>>B>>C>>D;
  cout<<max({A*C,A*D,B*C,B*D})<<endl;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint a(n);
  rep(i, n) cin >> a[i];
  int m;
  cin >> m;
  vint b(m);
  rep(i, m) cin >> b[i];
  vint res;
  set_symmetric_difference(all(a), all(b), inserter(res, res.end()));
  for(int x : res) cout << x << endl;

  return 0;
}



Measured memory_bytes: 10212
// stay fuckin hard -- Abhinav -IIITA
#include<bits/stdc++.h>
#define int long long
#define ld long double
using namespace std;
int mod=1e9+7;
ld pi=3.1415926535;
int fun(int a,int b){
	int r=1;
	while(b>0){
		if(b&1){
			r*=a;
			r%=mod;
		}
		b/=2;
		a*=a; a%=mod;
	}
	return r;
}
int32_t main(){
	int n,k; cin>>n>>k;
	int ans=0;
	int dp[k+1]={0};
	for(int i=k;i>0;--i){
		dp[i]=fun((k/i),n);
		for(int ii=2*i;ii<=k;ii+=i){
			dp[i]-=dp[ii]; dp[i]+=mod; dp[i]%=mod;
		}
		dp[i]+=mod; dp[i]%=mod;
		ans+=(i*dp[i])%mod; ans+=mod; ans%=mod;
	}
	cout<<ans;
	return 0;
}


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

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

    vector<int> vecA(n);
    for(int i=0; i<n; i++)  cin >> vecA.at(i);

    double sum = 0;
    for(int i=0; i<n; i++)
        sum += 1.0f/vecA[i];

    double ans;
    ans = 1/sum;
    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int w=0,r=0;
    for(int i=0;i<n;i++)if(s[i]=='R')r++;
    if(r==0){
        cout<<"0"<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        if(s[i]=='R')r--;
        else w++;
        if(w==r){
            cout<<w<<endl;
            return 0;
        }
    }
}

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

int main()
{
    char A,B,C,D,E,F;
    A='10';
    B='11';
    C='12';
    D='13';
    E='14';
    F='15';
    char x,y;
    cin>>x>>y;
    if(x>y)
    {
        cout<< ">\n";

    }
    else if(x<y)
        {
        cout<< "<\n";

    }
    else
        {
        cout<< "=\n";

    }
    return 0;
}


Measured memory_bytes: 256
# 配るDP
H, W = map(int, input().split())
a = [input() for _ in range(H)]

dp = [[0] * W for _ in range(H)]
dp[0][0] = 1
for h in range(H - 1):
  for w in range(W - 1):
    if a[h][w] == '#':
      continue
    if a[h][w + 1] != '#':
      dp[h][w + 1] = (dp[h][w + 1] + dp[h][w]) % 1000000007
    if a[h + 1][w] != '#':
      dp[h + 1][w] = (dp[h + 1][w] + dp[h][w]) % 1000000007
  if a[h][W - 1] == '#':
    continue
  if a[h + 1][W - 1] != '#':
    dp[h + 1][W - 1] = (dp[h + 1][W - 1] + dp[h][W - 1]) % 1000000007
for w in range(W - 1):
  if a[H - 1][w] == '#':
    continue
  if a[H - 1][w + 1] != '#':
    dp[H - 1][w + 1] = (dp[H - 1][w + 1] + dp[H - 1][w]) % 1000000007

print(dp[H - 1][W - 1])


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

int main () {
  long long N;
  cin >> N;
  int ans1 = 0;
  int ans2 = 0;
  for (int i = 0; i < 5000000; i++){
    for (int j = i-1; (i*i*i*i*i)-(j*j*j*j*j) > 0; j--){
      long long num = (i*i*i*i*i)-(j*j*j*j*j);
      if (num == N) {
        ans1 = i;
        ans2 = j;
        break;
      }
    }
  }
  cout << ans1 << " " << ans2 << endl;
}


Measured memory_bytes: 3604
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.close();
        for (int i = 0; i <= 9; ++i) {
            if (N <= 111 * i) {
                System.out.print(111 * i);
                break;
            }
        }
    }
}

Measured memory_bytes: 23252
N = int(input())
ans = ""
al = "zabcdefghijklmnopqrstuvwxy"
while(N>26):
    x = N%26
    ans += al[N%26]
    N = N // 26
    if x == 0:
        N -= 1
ans += al[N%26]
ans = ans[::-1]
print(ans)


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

int permutation(int x, int y, int z){
  if(x == y && y == z){
    return 1;
  }else if(x != y && y != z && z != x){
    return 6;
  }else{
    return 3;
  }
}

int main(){
  int N;
  cin >> N;
  for(int i = 1; i < N+1; i++){
    int count = 0;
    if(i < 6){
      cout << count << endl;
      continue;
    }
    int rn = floor(sqrt(i));
    for(int x = 1; x <= rn; x++){
      for(int y = x; y <= rn; y++){
        for(int z = y; z <= rn; z++){
          if(pow(x+y,2)+pow(y+z,2)+pow(z+x,2) == 2*i){
            count += permutation(x,y,z);
          }
        }
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 3564
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int fie[20][20];
int main(){
    int N;
    cin>>N;
    for(int i=0;i<20;i++){
        for(int j=0;j<20;j++)fie[i][j]=10;
    }
    int ans=0;
    for(int i=1;i<=N;i++){
        int A;
        cin>>A;
        for(int j=0;j<A;j++){
            int x,y;
            cin>>x>>y;
            fie[i][x]=y;

        }
    }
    for(int i=0;i<(1<<N);i++){
        int flg=1;
        int karians=0;
        for(int j=1;j<=N;j++){
            if(i&(1<<(j-1))){
                karians++;
                for(int k=0;k<20;k++){
                    if(fie[j][k]!=10){
                        //printf("[%d][%d][%d][%d][%d]\n",i,j,k,fie[j][k],(int)(i&(1<<(k-1))));
                        if((fie[j][k]==0)&&((int)(i&(1<<(k-1))))!=0)flg=0;
                        if((fie[j][k]!=0)&&((int)(i&(1<<(k-1))))==0){
                                //puts("hoge");
                                flg=0;
                        }
                    }
                }
            }
        }

        if(flg){
            //printf("===========[%d][%d]\n",i,karians);
            ans=max(ans,karians);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3628