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

#define ll long long
#define pb push_back
#define bit(a , b) (((a)>>(b))&1)

const int maxb = 19;
const int N = (1 << maxb);
const int maxn = N + 20;
const int mod = 924844033;

int bpw(int a , int b)
{
	if(!b)
		return 1;
	int x = bpw(a , b / 2);

	x = 1LL * x * x % mod;
	if(b&1)
		x = 1LL * x * a % mod;

	return x;
}

void rev(int* a)
{
	for(int i = 0; i < N; i++)
	{
		int k = 0;
		for(int j = 0; j < maxb; j++)
			if(bit(i , j))
				k |= 1 << (maxb - 1 - j);

		if(i < k)
			swap(a[i] , a[k]);
	}
}

void mul(int* a , int val)
{
	rev(a);

	for(int len = 2; len <= N; len *= 2)
	{
		int wn = bpw(5 , (mod - 1) / len);
		if(val == -1)
			wn = bpw(wn , mod - 2);
		for(int i = 0; i < N; i += len)
		{
			int nxt = len / 2 , pw = 1;
			for(int j = 0; j < nxt; j++)
			{
				int x = a[i + j] , y = a[i + j + nxt];
				a[i + j] = (x + 1LL * pw * y) % mod;
				a[i + j + nxt] = (x - 1LL * pw * y % mod + mod) % mod;
				pw = 1LL * pw * wn % mod;
			}
		}
	}

	if(val == -1)
	{
		int inv = bpw(N , mod - 2);
		for(int i = 0; i < N; i++)
			a[i] = 1LL * a[i] * inv % mod;
	}
}

vector<int> adj[maxn];

int t[maxn] , sz[maxn] , n , fac[maxn] , caf[maxn] , a[maxn] , b[maxn] , c[maxn];

void dfs(int v , int p = -1)
{
	sz[v] = 1;
	for(auto u : adj[v])
		if(u != p)
		{
			dfs(u , v);
			sz[v] += sz[u];
			t[sz[u]]++;
		}

	t[n - sz[v]]++;
}

int ch(int s , int r)
{
	return 1LL * fac[s] * caf[r] % mod * caf[s - r] % mod;
}

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

	fac[0] = 1;
	for(int i = 1; i < maxn; i++)
		fac[i] = 1LL * fac[i - 1] * i % mod;
	
	caf[maxn - 1] = bpw(fac[maxn - 1] , mod - 2);
	for(int i = maxn - 1; i > 0; i--)
		caf[i - 1] = 1LL * caf[i] * i % mod;

	cin >> n;
	for(int i = 0; i < n - 1; i++)
	{
		int a , b;
		cin >> a >> b;
		a-- , b--;

		adj[a].pb(b);
		adj[b].pb(a);
	}

	dfs(0);
	for(int i = 0; i <= n; i++)
	{
		a[i] = 1LL * t[i] * fac[i] % mod;
		b[n - i] = caf[i];
	}

	mul(a , 1);
	mul(b , 1);
	for(int i = 0; i < N; i++)
		a[i] = 1LL * a[i] * b[i] % mod;
	mul(a , -1);

	for(int i = 1; i <= n; i++)
	{
		c[i] = 1LL * a[i + n] * caf[i] % mod;
		c[i] = (1LL * n * ch(n , i) - c[i] + mod) % mod;
		cout << c[i] << endl;
	}
}








Measured memory_bytes: 44416
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;

int main() {
  // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  long long x;
  cin >> x;
  long long res = 0;

  for (long long i = 100; i < x;) {
    i += i / 100;
    ++res;
  }

  cout << res << endl;

  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N, X;
    cin >> N >> X;
    vector<ll> S(N);
    REP(i, N) cin >> S[i];

    sort(S.rbegin(), S.rend());
    ll ma = 101010;
    ll dp[205][ma];
    REP(i, 205)REP(j, ma) dp[i][j] = 0;
    dp[0][X] = 1;
    REP(i, N){
    	REP(j, ma){
    		dp[i+1][j%S[i]] += dp[i][j];
    		dp[i+1][j%S[i]] %= mod;
    		dp[i+1][j] += (dp[i][j] * (N-i-1) % mod);
    		dp[i+1][j] %= mod;
    	}
    }
    ll res = 0;
    REP(j, ma){
    	res += (j*dp[N][j]%mod);
    	res %= mod;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 162048
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int x = a + b;
	int y = a - b;
	int z = a * b;
	cout << max(x, max(y, z)) << endl;
}

Measured memory_bytes: 256
from collections import defaultdict

H, W, M = map(int, input().split())

h = [-1]
w = [-1]
hw_dict = defaultdict(int)

for _ in range(M):
    hi, wi = map(int, input().split())
    h.append(hi)
    w.append(wi)
    hw_dict[(hi, wi)] = 1

h_cnt = [0] * (H + 1)
w_cnt = [0] * (W + 1)

for i in range(1, M + 1):
    h_cnt[h[i]] += 1
    w_cnt[w[i]] += 1

h_max = max(h_cnt)
w_max = max(w_cnt)

h_max_idx = []
w_max_idx = []

for i in range(1, H + 1):
    if h_cnt[i] == h_max:
        h_max_idx.append(i)

for i in range(1, W + 1):
    if w_cnt[i] == w_max:
        w_max_idx.append(i)

ans = 0

for i in h_max_idx:
    for j in w_max_idx:
        if hw_dict[(i, j)] == 0:
            print(h_max + w_max)
            exit()

print(h_max + w_max - 1)


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

using namespace std;

int main(){
  string s; cin >> s;
  if(s[1] != s[0] && s[1] != s[2] && s[2] != s[0]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int x,y;
    cin>>x>>y;
    if(abs(x-y)<=1){
        cout<<"Brown"<<endl;
    }
    else{
        cout<<"Alice"<<endl;
    }

    
}

Measured memory_bytes: 256
//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef unsigned long long ull;
#define MX 1000000000
#define endl '\n'
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr first
#define sc second
#define MOD 1000000007

int main()
{
    int n, k;
    cin >> n >> k;
    ll a[n+3];
    a[0] = 1;
    a[1] = 1;
    for(int i = 2; i < n+2; i++)
    {
        cin >> a[i];
    }
    for(int i = k+2; i < n+2; i++)
    {
        if(a[i] > a[i-k])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}


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

int main() {
	int a[4] = { 0 };
	for (int i = 0; i < 4;i++) {
		char te;
		cin >> te;
		a[i] = te - '0';
	}
	for (int i = 0; i < 2;i++) {
		for (int j = 0; j < 2;j++) {
			for (int k = 0; k < 2; k++) {
				int wa = a[0];
				wa += (i ? 1 : -1)*a[1];
				wa += (j ? 1 : -1)*a[2];
				wa += (k ? 1 : -1)*a[3];
				if (wa == 7) {
					cout << a[0] << (i ? '+' : '-') << a[1] << (j ? '+' : '-') << a[2] << (k ? '+' : '-') << a[3] << "=7" << endl;
					return 0;
				}
			}
		}
	}
}

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

void bnf(bool);
void If(bool);

string grid[N],s;
int h,w,p,y,x,dir,cnt,ans;
bool used[M][N][N][4];

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

bool get_if(){
  bool res=false;

  if(s[p]=='~')res=!res,p++;
  
  if(s[p]=='N'&&dir==0)res=!res;
  
  if(s[p]=='E'&&dir==1)res=!res;
  
  if(s[p]=='S'&&dir==2)res=!res;
  
  if(s[p]=='W'&&dir==3)res=!res;
  
  if(s[p]=='C'&&grid[y+dy[dir]][x+dx[dir]]=='#')res=!res;
  
  if(s[p]=='T')res=!res;
  
  p++;
  return res;
}

void move_ai(bool flag){
  
  if(flag){
    cnt++;

    if(s[p]=='^'){
      int ny=y+dy[dir],nx=x+dx[dir];
      if(grid[ny][nx]!='#')y=ny,x=nx;
    }
    
    if(s[p]=='v'){
      int ny=y-dy[dir],nx=x-dx[dir];
      if(grid[ny][nx]!='#')y=ny,x=nx;
    }
    
    if(s[p]=='<')dir=(dir+3)%4;
    
    if(s[p]=='>')dir=(dir+1)%4;
    
  }
  
  p++;
  
  if(!ans&&grid[y][x]=='g')ans=cnt;
}

void While(bool flag){
  int prev=++p;

  while(1){
    bool r=get_if();
    
    while(s[p]!='}'){
      if(s[p]=='{') While(flag&r);
      else if(s[p]=='[') If(flag&r);
      else move_ai(flag&r);
    }

    int temp=p;
    p=prev;
    
    int r1=get_if();

    if(!r1||!r||!flag){
      p=temp;
      break;
    }
    
    if(used[p][y][x][dir]){
      cout<<(ans?ans:-1)<<endl;
      exit(0);
    }
    used[p][y][x][dir]=true;

    p=prev;
  }
  
  p++;
}

void If(bool flag){
  p++;

  bool r=get_if();
  
  while(s[p]!=']'){
    if(s[p]=='{') While(flag&r);
    else if(s[p]=='[') If(flag&r);
    else move_ai(flag&r);
  }
  
  p++;
}
 
void bnf(bool flag){
  
  while(s[p]!='x'){
    
    if(s[p]=='{') While(flag);
    else if(s[p]=='[') If(flag);
    else move_ai(flag);
    
  }
  
}

int main(){
  
  cin>>h>>w;
  
  for(int i=0;i<h;i++){
    cin>>grid[i];
    
    for(int j=0;j<w;j++)
      if(grid[i][j]=='s')y=i,x=j;
     
  }
  
  cin>>s;  s+='x';
  
  bnf(true);
  
  cout<<(ans?ans:-1)<<endl;
  return 0;
}

Measured memory_bytes: 4072
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define N 200010
//#define M 61
//#define MOD 100003
//vector <pair<int,int> > edge[M];
//int d[N][N];
//priority_queue <pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >q;
//queue <int> q;
//ll cnte[N];
//int ans=0;
//vector <int> edge[N];
int a[N];
int b[N];
int n,k;

void func(int a[],int b[]) 
{
	for (int i=1;i<=n;i++)
		a[i]=b[i]+a[i-1];
}

bool judge(int a[])
{
	for (int i=1;i<=n;i++)
		if (a[i]!=n)
			return false;
	return true;
}
/*
void outb(int b[])
{
	cout<<"b: ";
//	cout<<"n:"<<n<<endl;
	for (int i=1;i<=n;i++)
		cout<<b[i]<<" ";
	cout<<endl;
}
*/
/*
void outa(int a[])
{
	cout<<"a: ";
	for (int i=1;i<=n;i++)
		cout<<a[i]<<" ";
	cout<<endl;
}
*/

void solve()
{
	cin>>n>>k;
	for (int i=1;i<=n;i++)
		cin>>a[i];
	for (int i=1;i<=k;i++)
	{
		memset(b,0,sizeof(b));
		for (int j=1;j<=n;j++)
		{
			int l=max(1,j-a[j]);
			int r=min(n,j+a[j]);
			b[l]++;
			b[r+1]--;
		//	outb(b);
		//	outa(a);
		}
		func(a,b);
		if (judge(a))
			break;
	}
	for (int i=1;i<=n;i++)
		cout<<a[i]<<" ";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	int t;
//	cin>>t;
//	while (t--)
		solve();
	return 0;
} 

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

int main(void){
    int D,N;
    cin>>D>>N;
    long long ans;
    if(N!=100){
        ans=N*pow(100,D);
    }else{
        ans=pow(100,D+1)+pow(100,D);
    }
    cout<<ans<<endl;
    return 0;
}



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

#define rep(i, n) for(int i=1; i<=(n); ++i)
#define ll long long

int findCycle(std::vector<int> a) {
    int n=a.size(), ans, next=1;
    std::vector<bool> visit(n, false);
    rep(i, n) {
        if (visit[next]) {
            ans = next;
            break;
        }
        visit[next] = true;
        next = a[next];
    }
    return ans;
}

int naiveTrace(std::vector<int> a, int start, int move) {
    int town=start;
    rep(i, move) town = a[town];
    return town;
}


int main() {
    ll n, k, ans=0;
    std::cin >> n >> k;
    std::vector<int> a(n+1);
    rep(i, n) std::cin >> a[i];

    if (n >= k) {
        ans = naiveTrace(a, 1, k);
        std::cout << ans << std::endl;
        return 0;
    }
    
    int town=findCycle(a);
    int current=1;
    while (current != town) {
        current = a[current];
        ++ans;
    }
    int cycle_size=0, next=town;
    do {
        next=a[next];
        ++cycle_size;
    } while (town != next);
    int rest=(k-ans)%cycle_size;

    ans = naiveTrace(a, town, rest);
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 4832
#include <stdio.h>          // printf(), scanf()

#define MAX_M 1400
#define max(a, b) ((a) > (b) ? (a) : (b))

int G[MAX_M][MAX_M];
int dp[MAX_M][MAX_M];
int H, W;

int
getLargestSquare()
{
	int i, j;
	int s, t;

	int maxWidth = 0;
	for (i = 0; i < H; ++i)
	{
		for (j = 0; j < W; ++j)
		{
			dp[i][j] = (G[i][j] + 1) % 2;
			maxWidth |= dp[i][j];
		}
	}

	for (i = 1; i < H; ++i)
	{
		for (j = 1; j < W; ++j)
		{
			if (G[i][j])
				dp[i][j] = 0;
			else
			{
				t = dp[i - 1][j - 1];
				s = dp[i - 1][j];
				if (s < t)
					t = s;

				s = dp[i][j - 1];
				if (s < t)
					t = s;

				dp[i][j] = t + 1;
				maxWidth = max(maxWidth, dp[i][j]);
			}
		}
	}

	return maxWidth * maxWidth;
}

int
main(int argc, char** argv)
{
	int c;
	int i, j;

	scanf("%d %d", &H, &W);
	c = getchar();
	for (i = 0; i < H; ++i)
	{
		for (j = 0; j < W; ++j)
		{
			while (c == ' ' || c == '\n')
				c = getchar();

			G[i][j] = c != '0' ? 1 : 0;
			c = getchar();
		}
	}

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

Measured memory_bytes: 15908
//	Totally unrelated and not AT ALL stolen from hohohaha's, generic_placeholder_name's or katoriyuu's template
#include <bits/stdc++.h>

using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("avx")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define rep(i,s,end) for(int i = (s); i <  (end); ++i)
#define rep0(i, end) for(int i =   0; i <= (end); ++i)
#define rep1(i, end) for(int i =   1; i <= (end); ++i)
#define lb lower_bound
#define ub upper_bound

#define vt vector
#define endl "\n"

#define fileopen(filename, in_type, out_type) if (fopen(filename in_type, "r")) {freopen(filename in_type, "r", stdin);freopen(filename out_type, "w", stdout);}
#define local_input(x) if (x && fopen("input.txt","r")) freopen("input.txt","r",stdin);
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fscan(x)   scanf("%d",  &x)
#define fscandb(x) scanf("%lf", &x)
#define fscanll(x) scanf("%lld",&x)
//	Until next time, remember:
//			You are closer than you think.
//						_Dan Lok_

#define db double
#define ll long long
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define pi 3.1415926535897932	//faster than pi = acos(-1); but sometimes doesn't work?
//	srand(chrono::steady_clock::now().time_since_epoch().count());
//	freopen("input.txt","r",stdin);

#define lnode id<<1
#define rnode id<<1|1
#define mn 200007
string s;
int nx[26];
int dp[mn];
int after[mn], afterc[mn];
signed main()
{
	// fastio;
	cin >> s; fill(nx, end(nx),s.length());
	for(int i = s.length()-1, nchar = 0; i > -1; nx[s[i]-'a'] = i,--i, nchar = 0){
		for(int j = 0; j < 26; ++j) 
			if(dp[nx[nchar]] > dp[nx[j]]) nchar = j;
		dp[i] = dp[nx[nchar]]+1, after[i] = nx[afterc[i] = nchar];
	}
	int st = -1;
	rep(i,0,26) if(nx[i] != s.length()){
		if(st == -1 || dp[nx[i]] < dp[st]) st = nx[i];
	} else {
		cout << char(i+'a'); return 0;
	}
	cout << s[st];
	while(after[st] < s.length()) cout << s[st = after[st]]; 
	cout << char(afterc[st]+'a') << endl;
	// rep(i,0,s.length()) cerr << dp[i] << ' '; cerr << endl;
	// rep(i,0,s.length()) cerr << after[i] << ' '; cerr << endl;
	return 0;
}
// with the aura of Dora, AC!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Why is there a one in my row of exclamation marks?



Measured memory_bytes: 6048
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
using namespace std;

#define ll long long
#define VEC2(type, name, dim0, dim1, init_val) vector<vector<type>> name(dim0, vector<type>(dim1, init_val))
#define IN(type, name) type name; cin >> name
#define IN_V(type, name, size) vector<type> name(size); for(auto& x: name) cin >> x
#define IN_VPair(type1, type2, name, size) vector<pair<type1, type2>> name(size); for(auto& x: name) cin >> x.first >> x.second
#define IN_VW(type, name, size) vector<type> name(size); for(auto& x: name)

#define REP(name, start, end) for(ll name = (start); (name) < (end); ++(name))
#define REPR(name, end, start) for(ll name = (start - 1); (name) >= (end); --(name))
#define ALL(iterable) (iterable).begin(), (iterable).end()

template<typename _T> void OutIter(_T beg, _T end, string separator = " ", bool eol = true) {
	cout << *beg;
	for (auto it = beg + 1; it != end; ++it) {
		cout << separator << *it;
	}
	if(eol)cout << endl;
}

int main()
{
	cout << fixed << setprecision(6);
	IN(ll, n);
	IN_V(ll, als, n);
	IN_V(ll, bls, n);
	IN_V(ll, cls, n - 1);

	ll s = 0;
	REP(i, 0, n) {
		s += bls[als[i] - 1];
		if (i > 0 && als[i] - 1 == als[i - 1])s += cls[als[i - 1] - 1];
	}

	cout << s << endl;
	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    long double a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    long double res = 0, r1 = 0, r2 = 0;
    for (long double i = 0; i <= f; i += 100.0 * a) {
        for (long double j = 0; j <= f; j += 100.0 * b) {
            for (long double x = 0; x <= f; x += c) {
                for (long double y = 0; y <= f; y += d) {
                    if (1.0 * (i + j) >= 100.0 * (x + y) / e && i + j + x + y <= f) {
                        if (1.0 * (x + y) / (i + j + x + y) >= res) {
                            res = 1.0 * (x + y) / (i + j + x + y);
                            r1 = i + j + x + y;
                            r2 = x + y;
                        }
                    }
                }
            }
        }
    }
    cout << (int)(r1) << " " << (int)(r2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

int32_t main()
{
    int n,k;cin>>n>>k;

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

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

    for(int i=0;i<n;i++){
        for(int j=i+1;j<=(i+k);j++){
            if(j<n){
                int val=dp[i]+abs(arr[j]-arr[i]);
                dp[j]=min(dp[j],val);
            }
        }
    }

    cout<<dp[n-1]<<endl;


    return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
ll dp[3001][3001];
int ar[3001];
int n;
ll x = 0, y = 0, fl = 0;
ll count(int i, int j)
{
	if(i==j)
		return dp[i][j] = ar[i];
	if(i==j-1)
		return dp[i][j] = max(ar[i],ar[j]);
	if(dp[i][j]!=0)
		return dp[i][j];
	fl++;
	fl %= 2;
	ll l1, l2, l3, ans;
	l1 = count(i+2,j);
	l2 = count(i,j-2);
	l3 = count(i+1,j-1);
	l1 = min(l1,l3);
	l2 = min(l2,l3);
	// ans = (l1+ar[i],l2+ar[j]);
	ans = max(l1+ar[i],l2+ar[j]);
	// ans = max(ans,ar[i]+l3);
	// ans = max(ans,ar[j]+l3);
	if(fl)
		x+=ans;
	else
		y+=ans;
	return	dp[i][j] = ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	cin>>n;
    	ll sum=0;
    	for(int i=0;i<n;i++)
    	{
    		cin>>ar[i];
    		// ar.pb(a);
    		sum += ar[i];
    	}
    	ll ans = count(0,n-1);
    	cout<<2*ans-sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 70144
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		List<Integer> costs = new ArrayList<>();
		List<Integer> times = new ArrayList<>();
		List<Integer> tmpCosts = new ArrayList<>();
		for(int a = 0 ; a < N ; a++){
			costs.add(sc.nextInt());
			times.add(sc.nextInt());
		}
		sc.close();
		for(int b = 0 ; b < N ; b++){
			if(times.get(b) <= T){
				tmpCosts.add(costs.get(b));
			}
		}
		if(tmpCosts.isEmpty()){
			System.out.println("TLE");
		}else{		
			Collections.sort(tmpCosts);
			System.out.println(tmpCosts.get(0));
		}
	 }
}

Measured memory_bytes: 22612
N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]

s = 0
m = float('inf')
for i, (A, B) in enumerate(AB) :
    s += A
    if A > B :
        m = min(m, B)

if m == float('inf') :
    print(0)
else :
    print(s - m)

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

using namespace std;

const int INF = 1e9 + 9;
const int MAX = 2e5 + 3;

void dfs(int node, int parent, vector<int>& a, vector<vector<int>>& to, vector<int>& dp, vector<int>& lenLIS){
  int ok = MAX, ng = -1;
  while(ok - ng > 1){
    int mid = (ok + ng) >> 1;
    (dp[mid] >= a[node] ? ok : ng) = mid;
  }
  
  int ch_idx = ok;
  int org_val = dp[ch_idx];
  dp[ch_idx] = a[node];
  
  ok = 0, ng = MAX;
  while(ng - ok > 1){
    int mid = (ok + ng) >> 1;
    (dp[mid] < INF ? ok : ng) = mid;
  }
  lenLIS[node] = ok + 1;
  
  for(int next : to[node]){
    if(next == parent) continue;
    
    dfs(next, node, a, to, dp, lenLIS);
  }
  
  dp[ch_idx] = org_val;
}

int main(){
  int N;
  scanf("%d", &N);
  
  vector<int> a(N);
  for(int i = 0; i < N; i++) cin >> a[i];
  
  vector<vector<int>> to(N);
  for(int i = 0; i < N - 1; i++){
    int u, v;
    scanf("%d%d", &u, &v);
    --u; --v;
    
    to[u].push_back(v);
    to[v].push_back(u);
  }
  
  vector<int> lenLIS(N), dp(MAX, INF);
  
  dfs(0, -1, a, to, dp, lenLIS);
  
  for(int i = 0; i < N; i++){
    printf("%d\n", lenLIS[i]);
  }
  
  return 0;
}

Measured memory_bytes: 33932
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int a, b;
	cin >> a >> b;

	if( b!=1) cout << (b - 2) / (a - 1) + 1 << "\n";
	else cout << "0\n";

	return 0;
}

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

int main()
{

    int N, minv = 2001, maxv = 0, h;
    std::scanf("%d", &N);
    for (int i = 0; i < N; i ++) {
        std::scanf("%d", &h);
        minv = std::min(minv, h), maxv = std::max(maxv, h);
    }
    ((maxv - minv) % 2 == 0) ? std::printf("%d\n", (maxv-minv)/2) : std::printf("%d\n", (maxv-minv)/2+1);

    return 0;
}



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

int nC2(int n){
    if(n == 0 || n == 1){
        return 0;
    }else{
        return n * (n - 1) / 2;
    }
}

int main(){ 
    int n, m;
    cin >> n >> m;
    int ans = 0;
    
 
    ans = nC2(n) + nC2(m);
    
    cout << ans << endl;
    
    
}
        


Measured memory_bytes: 256
# 2019-11-18 23:58:23(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n, *a = [int(x) for x in sys.stdin.read().split()]
    a = list(enumerate(a, 1))
    a.sort(key=lambda x: x[1])
    for i in a:
        print(i[0], end=' ')

if __name__ == "__main__":
    main()


Measured memory_bytes: 18668
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("in", "r", stdin),freopen("out", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
vi G[N], Ginv[N], TopSort, vis(N, -1), dis(N, 0);
void dfs(int u){
    vis[u] = 1;
    for(auto v : G[u])
        if(vis[v] == -1)
            dfs(v);
    TopSort.pb(u);
}
int n, m;
int main(){
    //FL;
    FIN;
    int u, v;
    cin >> n >> m;
    w(m){
        cin >> u >> v;
        u--;
        v--;
        G[u].pb(v);
        Ginv[v].pb(u);
    }
    fore(i, 0, n){
        if(vis[i] == -1)
            dfs(i);
    }
    fore(i, 0, sz(TopSort)){
        int u = TopSort[i];
        fore(j, 0, sz(Ginv[u])){
            int v = Ginv[u][j];
            dis[v] = max(dis[v], dis[u] + 1);
        }
    }
    cout << *max_element(all(dis)) << '\n';
    EjecuteTime;
    return 0;
}       

Measured memory_bytes: 17576
#include <stdio.h>

int main(){
	int i = 0, j, k, n, array[100];

	scanf("%d", &n);
	while(i < n)  scanf("%d", &array[i++]);  
	for(i = 0; i < n; i++){
		j = i;
		while(j > 0 && array[j] < array[j-1]){
			k = array[j];
			array[j] = array[j-1];
			array[j-1] = k;
			j--;
		}
		for(j = 0; printf("%d", array[j]), j < n-1; j++)  printf(" ");
		printf("\n");
	}
	
	return 0;
}

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

int main()
{
    int n,i;
    cin>>n;
    long long l[n];
    for(i=0;i<n;i++) cin>>l[i];
    sort(l,l+n);
    long long ans=0,x=0,y=0;
    for(i=n-1;i>0;)
    {
        if(x!=0 && y!=0) break;
        else if(x==0 && l[i]==l[i-1]) {
                x=l[i];
                i=i-2;
        }
        else if(x!=0 && l[i]==l[i-1]) {
                y=l[i];
                i=i-2;
        }
        else i--;
    }
    ans=x*y;
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 1024
K, N = [int(x) for x in input().split(' ')]
A = [int(x) for x in input().split(' ')]

def pairwise_distance(a, b, K):
  return b - a 
  
memo = {frozenset({i, i+1}): pairwise_distance(A[i], A[i+1], K) 
        for i in range(0, len(A) - 1)}

last_pair_distance = K - pairwise_distance(A[0], A[len(A) - 1], K)
if last_pair_distance > K / 2:
  memo[frozenset({0, len(A) - 1})] = K - last_pair_distance
else:
  memo[frozenset({0, len(A) - 1})] = last_pair_distance

min_dist = K - max(memo.values())
print(min_dist)

Measured memory_bytes: 84008
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    double a,b,c,d=0,e=0;
    string s;
    cin>>s;
    if(s[0]=='S'){cout<<"Cloudy";}
    if(s[0]=='C'){cout<<"Rainy";}
    if(s[0]=='R'){cout<<"Sunny";}
    return 0;
}


Measured memory_bytes: 3564
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N, K;
  invec<ll> p(N);
  
  bst::sort(p);
  


  return accumulate(p.begin(), p.begin() + K, 0);
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 typedef long long ll;
 
int main() {
char c[222];
scanf("%s", c);
int n=strlen(c);
for(int i = n-2;i;i-=2){
if(strncmp(c, c+i/2, i/2)==0){
    printf("%d\n",i);
    return 0;
}

}

return 0;
}

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


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

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

using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
const ll mod = 1e9 + 9;
const ll maxn = 2e5 + 10;
signed main(){
    _rep(i, 1, 5){
        int x;
        cin >> x;
        if(x == 0){
            cout << i << endl;
            break;
        }
    }
}

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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define str string
#define s_vec(data,name,vertical,horizontal) vector<vector<(data)>> (name)((vertical),vector<(data)>((horizontal)));




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

    double a;
    double b;
    if(n%2==0){
        cout<<"0.5"<<endl;
    }else{
        a = floor(n/2);
        b = 1 - (a/n);
        cout<<b<<endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC136B
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = CIN.Long();

            long ans = 0;
            for (int i = 1; i <= N; i++)
            {
                if (i.ToString().Length % 2 == 1)
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 13140
from collections import deque
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]

graph = [[] for i in range(N+1)]
for i,j in AB:
    graph[i].append(j)
    graph[j].append(i)
    
r = [-1 for i in range(N+1)] 
Q = deque([1])
r[1] = 0
while Q:
    x = Q.popleft()
    for to in graph[x]:
        if r[to] == -1:
            r[to] = x 
            Q.append(to)

print("Yes")
for i in r[2:]:
    print(i)

Measured memory_bytes: 58672
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

template <class T>
class cumulativeSum
{
    int ny, nx;
    vector<vector<T> > sum;
public:
    cumulativeSum(const vector<vector<T> >& a)
    {
        ny = a.size();
        nx = a[0].size();
        sum.assign(ny+1, vector<T>(nx+1, 0));
        for(int i=0; i<ny; ++i){
            for(int j=0; j<nx; ++j){
                sum[i+1][j+1] = a[i][j] + sum[i][j+1] + sum[i+1][j] - sum[i][j];
            }
        }
    }
    T getSum(int y1, int x1, int y2, int x2)
    {
        if(y1 > y2 || x1 > x2)
            return 0;
        y1 = max(y1, 0);
        x1 = max(x1, 0);
        y2 = min(y2, ny-1);
        x2 = min(x2, nx-1);
        return sum[y2+1][x2+1] - sum[y1][x2+1] - sum[y2+1][x1] + sum[y1][x1];
    }
};

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

    vector<int> y(n), x(n);
    map<int, int> yIndex, xIndex;
    yIndex[-1];
    xIndex[-1];
    yIndex[INT_MAX/2];
    xIndex[INT_MAX/2];
    for(int i=0; i<n; ++i){
        cin >> x[i] >> y[i];
        yIndex[y[i]];
        xIndex[x[i]];
    }

    int h = 0;
    for(map<int, int>::iterator it=yIndex.begin(); it!=yIndex.end(); ++it){
        it->second = h;
        ++ h;
    }
    int w = 0;
    for(map<int, int>::iterator it=xIndex.begin(); it!=xIndex.end(); ++it){
        it->second = w;
        ++ w;
    }

    vector<vector<int> > treasure(h, vector<int>(w, 0));
    for(int i=0; i<n; ++i){
        int y2 = yIndex[y[i]];
        int x2 = xIndex[x[i]];
        ++ treasure[y2][x2];
    }
    cumulativeSum<int> cs(treasure);

    for(int i=0; i<m; ++i){
        int y1, x1, y2, x2;
        cin >> x1 >> y1 >> x2 >> y2;
        y1 = yIndex.lower_bound(y1)->second;
        x1 = xIndex.lower_bound(x1)->second;
        y2 = (--yIndex.upper_bound(y2))->second;
        x2 = (--xIndex.upper_bound(x2))->second;
        cout << cs.getSum(y1, x1, y2, x2) << endl;
    }

    return 0;
}

Measured memory_bytes: 197420
N = gets.to_i
a = gets.chomp.split.map(&:to_i)

stick = Hash.new(0)
l = []

a.each do |i|
  stick[i] += 1

  if stick[i] % 2 == 0
    l << i
  end
end

if l.size < 2
  puts 0
else
  puts l.sort.reverse[0..1].inject(:*)
end


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

int main(){
	int N;
	string A,B;
	string C="";
	cin >> N >> A >> B;
	
	for (int i = 0; i < N; i++) {
		C += (A.substr(i,1) + B.substr(i,1));
	}
	cout << C;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int min(int a,int b)
{
  if(a<b)
    return a;
  return b;
}
int main()
{
  int n,s=0;
  cin>>n;
  int b[n];
  for(int i=1;i<n;i++)
    cin>>b[i];
  int a[n+1]={0};
  a[1]=b[1];
  s+=a[1];
  for(int i=2;i<n;i++)
  {
    a[i]=min(b[i-1],b[i]);
    s+=a[i];
  }
  a[n]=b[n-1];
  s+=a[n];
  cout<<s;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;

int main(){
	int w,a,b;
	cin >> w >> a >> b;
	if(b < a) swap(a,b);
	cout << max(0, b-a-w) << endl;
}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;

  int x = 0;
  int mx = 0;
  rep(i, S.size()) {
    if (S[i] == 'I') x++;
    else x--;

    if (mx < x) mx = x;
  }

  cout << mx << endl;

  return 0;
}


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

string s;
string t;
ll ans=0                ;
cin >> s;
cin >> t;

for(i,s.size())
{

if(s[i]!=t[i]) ans++;


}

cout << ans <<endl;


return 0;
}


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

public class Main
{
    static class Reader {
		BufferedReader br;
		StringTokenizer st;
 
		public Reader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
 
	}
    static class Ele implements Comparable<Ele> 
    {  
        public int x,y;  
        Ele(int x,int y) 
        {  
            this.x=x;this.y=y; 
        }  
        public int compareTo(Ele ob) {  
        if(ob.x!=x)return x-ob.x;
        return this.y-ob.y;  
        }   
    }
    int a[][];int b[][];
    
    long gcd(long a,long b)
    {
        long min=Math.min(a,b);
        long max=Math.max(a,b);
        while (max%min!=0)
        {
            a=max%min;
            max=min;min=a;
        }
        return min;
    }
	public static void main(String[] args) throws IOException 
	{
		Reader sc=new Reader();Main G=new Main();
		PrintWriter o = new PrintWriter(System.out);
		int t=1;//t=sc.nextInt();
		int x,x0,x1,x2;int y,y0,y1,y2;int s,s0,s1,s2;
		int n,m;int a[],b[],in[],in1[];
		long k,l;boolean b1,b2;String ss1[],ss;
		//long l;long a[]; 
		ArrayList<ArrayList<Integer>> ll=new ArrayList<>();
		ArrayList<Integer> a1=new ArrayList<>();
		ArrayList<Integer> a2=new ArrayList<>();
		ArrayList<Integer> a3=new ArrayList<>();
		ArrayDeque<Integer> deq=new ArrayDeque<>();
		TreeSet<Integer> h0=new TreeSet<>();
		TreeSet<Integer> h1=new TreeSet<>();
		HashMap<Integer,Integer> h=new HashMap<>();
		try{
		while (t-->0)
		{
		    n=sc.nextInt();
		    
		    if (n==1)
		    o.println(0);
		    else o.println(1);
		    //o.println(h);
		    //o.println(x2);
		    //o.println();
		    h0.clear();ll.clear();a1.clear();a2.clear();h1.clear();
		}
		}
		catch (Throwable e)
		{
		    e.printStackTrace();
		}
		//o.println("HI");
		
        o.flush();
        o.close();
	}
} 

Measured memory_bytes: 32964
// DisjointSet class について
// 今回、rankの情報については、親が保持していればそれで十分
// (経路圧縮のために用いる情報のため)
#include <bits/stdc++.h>
using namespace std;

#define REP(i, start, count) for (int i = (start); i < (int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

class DisjointSet {
public:
    veci rank, p;

    DisjointSet() = default;
    DisjointSet(int size) {
        rank.resize(size, 0);
        p.resize(size, 0);
        for (int i = 0; i < size; i++) makeSet(i);
    }

    // 木の初期化
    void makeSet(int x) {
        p[x] = x; // 自分だけが所属する
        rank[x] = 0; // 自分以外いないのでrankも0
    }

    // xとyが同じ集合に属しているか
    bool same(int x, int y) {
        return findSet(x) == findSet(y);
    }

    // xとyの所属する集合を結合する
    void unite(int x, int y) {
        link(findSet(x), findSet(y));
    }

    // 低い方の木に結合する
    void link(int x, int y) {
        if (rank[x] > rank[y]) {
            p[y] = x;
        }
        else {
            p[x] = y;
            // 同じ高さの場合は結合後1ランク高くなる
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
    }

    // xが所属している集合の代表を返す
    int findSet(int x) {
        if (x != p[x]) {
            // 親が見つかるまで遡っていく
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};

int main(void)
{
    int n, a, b, q;
    int t;

    cin >> n >> q;
    DisjointSet ds = DisjointSet(n);

    for ( int i = 0; i < q; ++i) {
        cin >> t >> a >> b;
        if (t == 0) ds.unite(a, b);
        else if (t == 1) {
            if ( ds.same(a, b) ) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3184
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;
int main(){
  int N, K;
  string S;
  cin >> N >> K >> S;

  vector<int> last;

  last.push_back(0);
  int i=0;
  while(i<N-1){
    if(S[i]!=S[i+1]){
      last.push_back(i+1);
    }
    i++;
  }
  last.push_back(N);

  int len = last.size();
  /*for(int i=0;i<len;i++) cout << last[i] << " ";
  cout <<endl;*/

  int ans = 0;

  if(S[0]=='1'){
    for(int i=0;2*i+1<len+1;i++){
      int a = max(0,2*i-2*K);
      int b = min(len-1, 2*i+1);
      ans = max(ans, last[b]-last[a]);
      //cout << ans <<endl;
    }
  }else{
    for(int i=0;2*i<len+1;i++){
      int a = max(0,2*i-2*K-1);
      int b = min(len-1, 2*i);
      ans = max(ans, last[b]-last[a]);
    }
  }
  cout << ans <<endl;

  return 0;
}

Measured memory_bytes: 1020
class BIT:
    '''https://tjkendev.github.io/procon-library/python/range_query/bit.html'''
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def query(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)
      
N,Q=map(int,input().split())
*A,=map(int,input().split())
bit = BIT(N)
for i in range(N):
  bit.add(i+1,A[i])
for i in range(Q):
  q,a,b = map(int,input().split())
  if q:
    print(bit.query(a,b))
  else:
    bit.add(a+1,b)

Measured memory_bytes: 149696
def check(X):
    if X < 0 or X % 5 != 0:
        return False
    else:
        flag = False
        for i in range((X//105)+1):
            if (X - i*105) % 100 == 0:
                flag = True
                break
        return flag
X = int(input()) 
for i in range(5**4):
    i_tmp = i
    buylist = [0]*4
    for j in range(len(buylist)):
        buylist[j] = i_tmp % 5
        i_tmp = i_tmp // 5
    buytmp = 101*buylist[0]+102*buylist[1]+103*buylist[2]+104*buylist[3]
    if check(X - buytmp) == True:
        flag = True
        break
    else:
        flag = False
if flag:
    print(1)
else:
    print(0)

Measured memory_bytes: 3064
n = gets.chop.to_i
s = []
n.times do
  s << gets.chop.to_i
end

sum_s = s.inject(:+)

if sum_s % 10 == 0
  s.sort!
  s.each do |value|
    if value % 10 != 0
      p sum_s-value
      exit
    end
  end
  p 0
else
  p sum_s
end



Measured memory_bytes: 1788
import java.util.Scanner;

/*
問題文

*/

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long m = sc.nextInt();

        long count = 0;
        for (int i = 0; i < m; i++) {
            count += sc.nextInt();
        }

        if (n >= count ) {
            System.out.println(n - count);
        } else {
            System.out.println("-1");
        }
    }
}

Measured memory_bytes: 46540
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
    cin >> n;
    int64_t a,b,c;
    a=2;
    b=1;
    for(int i=0;i<n-1;i++){
    	c=a+b;
        a=b;
        b=c;
    }
    cout << b <<endl;
}

Measured memory_bytes: 3636
#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;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 ll long long

int main(){
	ll a, b;
	cin >> a >> b;
	if (b%a == 0){cout << a + b << endl;}
	else {cout << b - a << endl;}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
 
void solve(){
	cin >> n;
	int ans = 0;
	for(int i =1;i<=n;i++){
		cin >> x;
		if(i&1 && x&1){
			ans++;
		}
	}	
	cout << ans;
 
}
 
int main(){

	t=1;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3620