akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MIN -10000
#define N 3

int main(){
    string str;
    cin >> str;
    int atod[N+1];
    for(int i=0;i<N+1;i++) atod[i] = str[i]-'0';
    char op[N];
    int sum;
    for(int bit=0;bit<(1<<N);bit++){
        sum = atod[0];
        for(int i=0;i<N;i++){
            if(bit>>i & 1){
                sum -= atod[i+1];
                op[i] = '-' ;
            }
            else{
                sum += atod[i+1];
                op[i] = '+';
            }
        }
        if(sum == 7){
            printf("%d%c%d%c%d%c%d=7",
                atod[0],op[0],
                atod[1],op[1],
                atod[2],op[2],
                atod[3]
            );
            return 0;
        }
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int a[1100];
int main()
{
	int n,m;
	int ans=0;
	scanf("%d%d",&n,&m);
	for(int i = 1; i <= n; ++i) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i = 1; i <= m; ++i) ans += a[i];
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define loop(i, sta, end, inc) for(int i = sta; i <= end; i += inc)
#define itr(it, l)             for(auto it = l.begin(); it != l.end(); it ++)
#define in(a, b, c)            assert( b <= a && a <= c)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define what_is(x) cerr<<#x<<" ="<<x<<" ";
#define error(args...)  { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define LINT_MAX  9223372036854775807
#define LINT_MIN -9223372036854775808
#define EPS 1e-9
#define MOD 1000000007
#define DEBUG 0

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
void err(istream_iterator<string> it) { cerr<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    if(DEBUG == 0)return;
	cerr << *it << " = " << a <<" ";
	err(++it, args...);
}


double p[3000];
double dp[3000][3000];
int main(){
   // freopen("test.txt", "r", stdin);
    int n;cin>>n;
    forn(i,n)cin>>p[i];
    dp[0][0]=1-p[0];
    dp[0][1]=p[0];
    forn1(i,n-1){
    	forn(j,n+1){
    		if(j==0)dp[i][j]=dp[i-1][j]*(1-p[i]);
    		else dp[i][j]=dp[i-1][j-1]*(p[i])+dp[i-1][j]*(1-p[i]);
    	}
    }
    double ans=0;
    
    for(int i=(n/2)+1;i<=n;i++){
    	ans+=dp[n-1][i];
    }
    cout<<setprecision(12)<<ans<<endl;

    return 0;
}



Measured memory_bytes: 70528
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0) {if(a<b) swap(a,b); a = a%b;} return max(a,b);
}


int main(){
  int m1, d1,m2,d2;
  cin>>m1>>d1>>m2>>d2;
  if(m1==m2) cout << 0 << endl;
  else cout << 1 << endl;


  return 0;
}

Measured memory_bytes: 256
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())),reverse=True)
q=sorted(list(map(int,input().split())),reverse=True)
r=list(map(int,input().split()))

p=p[:x]
q=q[:y]
print(sum(sorted(p+q+r,reverse=True)[:x+y]))


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

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

  cout << ((n * (n - 1)) + (m * (m - 1))) / 2 << endl;

  return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
char s[N], rs[N];
set<int> sls[N];
vector<int> sl[N];
int a[N];
void my_merge(set<int> &a, set<int> &b) {
	if (b.size() < a.size()) {
		for (int i : b) a.insert(i);
	}
	else {
		for (int i : a) b.insert(i);
		a.swap(b);
	}
}
int main() {
	scanf("%s", s);
	int m = (int) strlen(s);
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) {
		int l, r;
		scanf("%d%d", &l, &r); -- l, -- r;
		if (l <= (m - 1) / 2 && r >= m / 2) {
			int dl = (m - 1) / 2 - l;
			int dr = r - m / 2;
			if (dl == dr) continue;
			if (dl < dr) {
				l = m / 2 + dl + 1;
			}
			else {
				r = (m - 1) / 2 - dr - 1;
			}
			assert(l <= r && (r <= (m - 1) / 2 || l >= m / 2));
		}
		if (r <= (m - 1) / 2) {
			sls[l].insert(r);
		}
		else {
			sls[m - 1 - r].insert(m - 1 - l);
		}
	}
	for (int i = 0; i <= (m - 1) / 2; ++ i) {
		//sort(sl[i].begin(), sl[i].end());
		while (sls[i].size() && *(sls[i].begin()) < i) {
			sls[i].erase(sls[i].begin());
		}
		if (sls[i].size()) {
			sl[i].push_back(*(sls[i].begin()));
			my_merge(sls[sl[i].back() + 1], sls[i]);
		}
	}
	for (int i = 0; i < m; ++ i) rs[m - i - 1] = s[i];
	int res = 0, gg = 0;
	for (int i = 0; i <= (m - 1) / 2; ++ i) {
		res += a[i];
		s[i] = (s[i] - 'a' + res) % 26 + 'a';
		if (sl[i].size()) {
			int delta = (26 + (rs[i] - 'a') - (s[i] - 'a')) % 26;
			s[i] = (s[i] - 'a' + delta) % 26 + 'a';
			assert(s[i] == rs[i]);
			res += delta;
			a[sl[i][0] + 1] -= delta;
		}
		if (s[i] != rs[i]) { gg = 1; break; }
	}
	puts(gg ? "NO" : "YES");
}



Measured memory_bytes: 16512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll a, b;
  cin >> a >> b;
  if (a+b == 15) cout << '+' << endl;
  else if (a*b == 15) cout << '*' << endl;
  else cout << 'x' << endl;
}

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

// こんなの思いつかない
int main(){
    int n;
    cin >> n;

    int k;
    for(k = 1; k*(k-1) <= 2*n; k++){
        if(k*(k-1) == 2*n)    break;
    }

    if(k*(k-1) != 2*n){
        cout << "No" << endl;
        return 0;
    }

    int now = 1;
    vector<vector<int>> v(1000, vector<int>(1000, 0));
    for(int i = 0; now <= n; i++){
        for(int j = 0; j <= i; j++){
            v[i][j] = now++;
        }
    }

    vector<int> ans[k];
    for(int i = 0; i < k-1; i++)  ans[0].push_back(v[i][i]);
    for(int i = 1; i < k; i++){
        int ni = i-1, nj = 0;
        while(nj < ni)  ans[i].push_back(v[ni][nj]), nj++;
        while(ni < k-1) ans[i].push_back(v[ni][nj]), ni++;
    }

    cout << "Yes" << endl;
    cout << k << endl;
    for(int i = 0; i < k; i++){
        cout << k-1;
        for(int j = 0; j < k-1; j++)    cout << " " << ans[i][j];
        cout << endl;
    }
    return 0;
}

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

int main() {
	int H, W;


	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0)	break;

		for (int i = 0; i < H; i++) {
			if (i == 0 || i == H-1) {
				for (int j = 0; j < W; j++)	cout << '#';
			}
			else {
				for (int j = 0; j < W; j++) {
					if (j == 0 || j == W - 1)	cout << '#';
					else cout << '.';
				}
			}
			cout << endl;
		}
		cout << endl; //??????
	}

	return 0;

}

Measured memory_bytes: 1152
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int d, n, m, x, y, z, p[50], q[50]; string s;
int main() {
	cin >> d >> n;
	for(int i = 0; i < n; i++) {
		cin >> s >> z;
		if(s == "D") p[x++] = -z;
	}
	sort(p, p + x);
	cin >> m;
	for(int i = 0; i < m; i++) {
		cin >> s >> z;
		if(s == "DD") q[y++] = -z;
	}
	sort(q, q + y);
	int ret = 0;
	for(int i = 0; i <= x; i++) {
		for(int j = 0; j <= y; j++) {
			if(i + 2 * j <= d) {
				int sum = 0;
				for(int k = 0; k < i; k++) sum -= p[k];
				for(int k = 0; k < j; k++) sum -= q[k];
				ret = max(ret, sum);
			}
		}
	}
	cout << ret << endl;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
	int main(){
        int t,n,k,c=0,m=INT_MIN;
        cin>>t;
        while(t--){
            cin>>n>>k;
            if(n!=k){
                m=max(c,m);
                c=0;
            }else{
                c++;
            }
        }
        m=max(c,m);
        if(m<3){cout<<"No"<<endl;}
        else{cout<<"Yes"<<endl;}
	}


Measured memory_bytes: 3624
#include <stdio.h>
int main(){
  long x,i=0;
  scanf("%ld",&x);
  if(x%11==0) i=x/11*2;
  else if(x%11>6) i=x/11*2+2;
  else i=x/11*2+1;
  printf("%ld\n",i);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b/a, c) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC124_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var ans1 = S.Length;
            var ans2 = S.Length;
            for (int i = 0; i < S.Length; i++)
            {
                if (i % 2 == 0 && S[i] == '1' || i % 2 == 1 && S[i] == '0') ans1--;
                if (i % 2 == 1 && S[i] == '1' || i % 2 == 0 && S[i] == '0') ans2--;
            }
            Console.WriteLine(Math.Min(ans1, ans2));
        }
    }
}


Measured memory_bytes: 13140
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

unsigned gcd(unsigned a, unsigned b)
{

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

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

	string S;
	cin >> S;
	
	int num_0 = 0;
	int num_1 = 0;

	for (unsigned i = 0; i < S.size(); ++i)
	{
		if (S[i] == '0')
		{
			++num_0;
		}
		else if (S[i] == '1')
		{
			++num_1;
		}
	}

	cout << min(num_0, num_1) * 2;

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll w[101],u[101];
ll dp[101][100001]={};
int main() {

	int n,W;

	cin>>n>>W;
	rep(i,n){
		cin>>w[i+1]>>u[i+1];
	}
	for(int i=1; i<100001; i++){
		for(int j=0; j<101; j++){
			dp[j][i]=1000000001;
		}
	}
	for(int i=1; i<100001; i++){
		for(int j=1; j<n+1; j++){
			if(i>=u[j])dp[j][i]=min(dp[j-1][i],dp[j-1][i-u[j]]+w[j]);
			else dp[j][i]=dp[j-1][i];
		}
	}
	for(int i=100000; i>=1; i--){
		if(dp[n][i]<=W){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

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

using bint = boost::multiprecision::cpp_int;

constexpr int MOD = 1e9 + 7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

bool isOK(int mid, int k, vector<int>& v) {
    int cnt = 0;
    for (int it : v) cnt += (it - 1) / mid;
    return cnt <= k;
}

struct BIT {
    vector<int> data;

    BIT(int sz) {
        data.resize(sz+1, 0);
    }

    int sum(int k) {
        int ret = 0;
        for (++k; k > 0; k -= k & -k) ret += data[k];
        return ret;
    }

    void add(int k, int x) {
        for (++k; k < data.size(); k += k & -k) data[k] += x;
    }
};

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    rep(i, n) cin >> c[i];
    vector<pair<P, int>> vec(q);
    rep(i, q) {
        cin >> vec[i].first.first >> vec[i].first.second;
        vec[i].second = i;
    }
    sort(vec.begin(), vec.end(), [](pair<P, int>& a, pair<P, int>& b) { return a.first.second < b.first.second; });
    vector<int> last(n,0);
    vector<int> ans(q);
    BIT tree(n+1);
    int cnt=0;
    rep(i,q){
        auto [p,idx]=vec[i];
        while(cnt<p.second){
            if(last[c[cnt]-1])tree.add(last[c[cnt]-1],-1);
            last[c[cnt]-1]=cnt+1;
            tree.add(last[c[cnt]-1],1);
            cnt++;
        }
        ans[idx]=tree.sum(p.second);
        if(p.first-1)ans[idx]-=tree.sum(p.first-1);
    }
    rep(i,q)cout<<ans[i]<<endl;
}


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

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    int num = 100*r + 10*g + b;

    if (num%4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

using namespace std;

int strToNum(char c)
{
  string str = "abcdefghijklmnopqrstuvwxyz";
  for(int i = 0; i < str.size(); i++){
    if(c == str[i]){
      return i;
    }
  }
}

int main(void)
{
  string S, T;
  cin >> S;
  cin >> T;

  int Sflag[26];
  int Tflag[26];

  for(int i = 0; i < 26; i++){
    Sflag[i] = -1;
    Tflag[i] = -1;
  }


  vector<int> S2(S.size());
  vector<int> T2(T.size());

  int num = 0;
  for(int i = 0; i < S.size(); i++){
    if(Sflag[strToNum(S[i])] < 0){
      Sflag[strToNum(S[i])] = num;
    }
    S2[i] = Sflag[strToNum(S[i])];

    if(Tflag[strToNum(T[i])] < 0){
      Tflag[strToNum(T[i])] = num;
    }
    T2[i] = Tflag[strToNum(T[i])];
    num++;
  }

  for(int i = 0; i < S.size(); i++){
    if(S2[i] != T2[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 2440
#include<iostream>

using namespace std;

int main(){

	int H,W;
	bool flag= true;
	cin>>H>>W;
	if(H==0&&W==0){
			flag = false;
		}
	while(flag==true){
		for(int i=0;i<H;++i){
			for(int j=0;j<W;++j){
				cout<<"#";
			}
			cout<<endl;
		}
		cin>>H>>W;
		if(H==0&&W==0){
			flag = false;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define in(s) ll s; cin>>s
#define pr(r) cout<<r<<endl
#define prr(m,n) cout<<m<<" "<<n<<endl
#define prarr(a,i,n) fab(j,i,n) cout<<a[j]<<" "
#define wh(t) ll t; cin>>t; while(t--)
#define sz(u) u.size()
#define all(v) v.begin(),v.end()
#define arr(a,n) ll a[n]; fab(i,0,n) cin>>a[i]
#define showdp(d,n,m) fab(i,0,n){ fab(j,0,m) if(d[i][j]==-1 || d[i][j]>9) cout<<d[i][j]<<" "; else cout<<" "<<d[i][j]<<" "; cout<<endl; }
#define prs(u) cout<<u<<" "
#define fab(i,a,b) for(ll i=a;i<b;i++)
#define fba(i,b,a) for(ll i=b;i>=a;i--)
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MX 1000000007
#define MAX 10000007
#define endl "\n"
#define ll long long int
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define pl pair<ll,ll>
#define pll pair<ll,pl>
#define vvl vector<vl>
#define mxe(x,n) *max_element(x,x+n)
#define mne(x,n) *min_element(x,x+n)
#define mp make_pair
#define pb push_back
#define fs first
#define sd second
#define fr front()
#define bk back()
#define rr return
#define N 300005
#define inf 1e18+7
 
bool rsort1(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.first > b.first);}
bool rsort2(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.second>b.second);}
bool sort2(const pair<ll,ll> &a,const pair<ll,ll> &b){ return (a.second < b.second);}
 
bool isPrime(ll p)
{
    for(ll i=2;i*i<=p;i++)
        if(p%i==0)
            rr false;
    rr true;
}
 
void sieve(ll n,vl &v)
{
    v.pb(2);
    bool prime[n+1];
    memset(prime,true,sizeof(prime));
    for(ll i=3;i*i<=n;i+=2)
        if(prime[i])
            for(ll j=i;j*i<=n;j+=2)
                prime[j*i]=false;
        
    for(ll i=3;i<=n;i+=2)
        if(prime[i])
            v.pb(i);
}

ll phi(ll n)
{
    ll result=n;
    for(ll p=2;p*p<=n;p++)
    {
        if(n%p==0)
        {
            while(n%p==0)
                n/=p;
            result-=result/p;
        }
    }

    if(n>1)
        result-=result/n;
    return result;
}


int main()
{
	sup;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
    #endif*/
	
    char c;
    cin>>c;
    pr(char(c+1));
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
  int n,a=0,b=0,ab=0,o=0;
  char type[3];
  while(scanf("%d,%s",&n,type)!=EOF){
    if(strcmp(type,"A")==0)
      a++;
    else if(strcmp(type,"B")==0)
      b++;
    else if(strcmp(type,"AB")==0)
      ab++;
    else
      o++;
  }
  printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
  return 0;
}

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

int main(void){
  int n,q; cin >> n >> q;
  string s; cin >> s;
  int l[q],r[q];
  rep(i,q){
    cin >> l[i] >> r[i];
  }
  ll sum[n];
  sum[0] = 0;
  for(int i = 1; i < n; i++){
    if(s.at(i) == 'C' && s.at(i-1) == 'A'){
      sum[i] = sum[i-1] + 1;
    }
    else sum[i] = sum[i-1];
  }
  rep(i,q){
    cout << sum[r[i]-1] -sum[l[i]-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 2560
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


int main()
{
    
    int N;
    cin >> N;
    int G = 0, L = pow(10,9);
    int tmp;
    for(int i=0;i<N;i++)
    {
        cin >> tmp;
        G = max(G, tmp);
        L = min(L, tmp);
    }
    
    cout << G - L << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
@h,@w,k = gets.chomp.split.map(&:to_i)
@s = @h.times.map{gets.chomp.chars}
empty_array = []
cnt = 1
def mark_num(i,j,n)
  if @s[i][j] != "." || j < 0 || j > @w - 1
    return
  else
    @s[i][j] = n
    mark_num(i,j - 1,n)
    mark_num(i,j + 1,n)
  end
end

def search_num_up(i)
  if i < 0 || i > @h - 1
    return 
  elsif @s[i][0] == "."
    search_num_up(i+1)
  else
    @num_array << i
  end
end

def search_num_down(i)
  if i < 0 || i > @h - 1
    return 
  elsif @s[i][0] == "."
    search_num_down(i-1)
  else
    @num_array << i
  end
end

(0..@h-1).each do |i|
  empty_flag = true
  (0..@w-1).each do|j|
    if @s[i][j] == "#"
      empty_flag = false
      @s[i][j] = cnt
      mark_num(i,j + 1,cnt)
      mark_num(i,j - 1,cnt)
      cnt += 1
    end
  end
  if empty_flag
    empty_array << i
  end
end

empty_array.each do |k|
  @num_array = []
  search_num_up(k)
  search_num_down(k)
  (0..@w-1).each do |l|
    @s[k][l] = @s[@num_array.min][l]
  end
end

@s.each do |c|
  puts c.join(" ")
end

  

Measured memory_bytes: 10108
abList = []
for i in range(3):
    ab = [int(i) for i in input().split()]
    abList.append(ab)

visited = {}
for ab in abList:
    for i in ab:
        if i in visited:
            visited[i] += 1
        else:
            visited[i] = 1

ans = "YES"
for city in visited:
    if visited[city] == 0 or visited[city] > 2:
        ans = "NO"


print(ans)


Measured memory_bytes: 3060
import math
n = int(input())
n_p = 0
for i in range(n):
    a = int(input())
    if a == 2:
        n_p += 1
        continue
    elif a % 2 == 0:
        continue
    else:
        j = 3
        while j <= math.sqrt(a):
            if a%j == 0:
                break
            j += 2
        else:
            n_p += 1
print(n_p)

Measured memory_bytes: 7784
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <queue>

#define mod 1000000007
#define MAX_N 100

using namespace std;

int A[MAX_N + 1];

int main()
{
    int N, i, counter;

    scanf("%d", &N);
    counter = 0;
    for(i = 1; i <= N; ++i){
        scanf("%d", &A[i]);
        if(i % 2 && A[i] % 2)
            ++counter;
    }
    printf("%d", counter);

    return 0;
}


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

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

    vector<int> snuke(n, 1);
    for(int i=0; i<k; i++){
        int d;
        cin >> d;
        for(int j=0; j<d; j++){
            int a;
            cin >> a;
            a -= 1;
            snuke[a] = 0;
        }
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        ans += snuke[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

typedef long long ll;
typedef double db;

const ll N = 2e5 + 10;

ll a[N], q[N];
ll n, k;

int main() {
	cin >> n >> k;
	for (ll i = 1; i <= n; i++) cin >> a[i];

	for (ll j = 1; j <= k; j++) {
		memset(q, 0, sizeof q);
		for (ll i = 1; i <= n; i++) {
			q[max(1 * 1ll, i - a[i])]++;
			q[min(n + 1, i + a[i] + 1)]--;
		}

		bool flag = true; ll sum = 0;
		for (ll i = 1; i <= n; i++) {

			a[i] = sum += q[i];

			if (a[i] < n) {
				flag = false;
			}
		}

		if (flag) break;
	}

	for (ll i = 1; i <= n; i++) cout << a[i] << " ";
	cout << endl;

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0;n > i;i++)
    cin >> a[i];
  for (int i = n - 1;i >= 0;i--) {
    if (a[i] < a[i-1] && a[i] == a[i-1] - 1)
      a[i-1]--;
    else if (a[i] < a[i-1] && a[i] != a[i-1] -1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
      

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define RI register int
#define Cannot puts("No"), exit(0);
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 1e5 + 5;
struct Edges { int to, next; } e[MAXN * 2];
int head[MAXN], tot;
int l[MAXN], r[MAXN], a[MAXN], vis[MAXN];

inline void addedge(int from, int to) {
  e[++tot] = (Edges){to, head[from]};
  head[from] = tot;
  e[++tot] = (Edges){from, head[to]};
  head[to] = tot;
}

void Put(int now, int fa, int num) {
  vis[now] = 1;
  ++l[now], --r[now];
  if (!((l[now] & 1) ^ (num & 1)) && !(l[now] < -9e5)) Cannot;
  if (r[now] == num - 1) a[now] = r[now];
  else a[now] = num + 1;
  for (RI i = head[now]; i; i = e[i].next)
    if (e[i].to != fa && !vis[e[i].to])
      Put(e[i].to, now, a[now]);
}

void Dfs(int now, int fa) {
  if (vis[now]) l[now] = r[now] = a[now];
  else l[now] = -1e6, r[now] = 1e6;
  for (RI i = head[now]; i; i = e[i].next)
    if (e[i].to != fa) {
      Dfs(e[i].to, now);
      l[now] = max(l[now], l[e[i].to]);
      r[now] = min(r[now], r[e[i].to]);
    }
  if (l[now] > r[now]) Cannot;
  if (vis[now]) {
    if (l[now] > a[now] || r[now] < a[now]) Cannot;
    if ((a[now] & 1) ^ (l[now] & 1)) Cannot;
    l[now] = r[now] = a[now];
    for (RI i = head[now]; i; i = e[i].next)
      if (e[i].to != fa && !vis[e[i].to])
        Put(e[i].to, now, a[now]);
  }
  --l[now], ++r[now];
}

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n; read(n);
  for (RI i = 1, x, y; i < n; ++i)
    read(x), read(y), addedge(x, y);
  int k; read(k);
  int rt;
  for (RI i = 1, x; i <= k; ++i) {
    read(x), read(a[x]), vis[x] = 1;
    if (i == 1) rt = x;
  }
  Dfs(rt, 0);
  puts("Yes");
  for (RI i = 1; i <= n; ++i)
    printf("%d\n", a[i]);
  
  return 0;
}

// created by Daniel yuan


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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);


void solve()
{
    int n;
    cin >> n;
    ll luca[87];
    luca[0]=2ll;
    luca[1]=1ll;
    for(int i = 2 ; i<= 86; i++) luca[i] = luca[i-1]+luca[i-2];
    cout << luca[n] << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define Fordown(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
 int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}

const int N = 100100;
int a[N], b[N], c[N];
long long ans = 0;
long long sum[N];
int main () {
#ifdef zjp_shadow
	freopen ("C.in", "r", stdin);
	freopen ("C.out", "w", stdout);
#endif
	int n = read();
	For (i, 1, n) 
		a[i] = read();
	sort (a + 1, a + 1 + n);

	For (i, 1, n) 
		b[i] = read();
	sort (b + 1, b + 1 + n);

	For (i, 1, n) {
		int pos = lower_bound(a + 1, a + 1 + n, b[i]) - a - 1;
		if (pos > n) pos = n;
		sum[i] = sum[i - 1] + pos;
	}

	For (i, 1, n) {
		c[i] = read();
		int pos = lower_bound(b + 1, b + 1 + n, c[i]) - b - 1;
		if (pos > n) pos = n;
		ans += sum[pos];
	}
	printf ("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

///////////////////////////////////////////////////////////////////////////

int main(){
	string s;
	cin >> s;
	int l = 0,r = sz(s)-1;

	rep(i,0,sz(s)){
	    if(s[i] == 'A'){
	        l = i;
	        break;
	    }
	}
	rep(i,0,sz(s)){
        if(s[sz(s)-1-i] == 'Z'){
            r = sz(s)-1-i;
            break;
        }
	}
	P(r-l+1);
	return  0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;
int main(){
    int N;
    cin >> N;
    int a=N%10;
    int c=N/100;
    int b=(N-c*100)/10;
    if(a==7 || b==7 || c==7) cout << "Yes";
    else cout << "No" << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

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

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n=n>>1;
    }
    return result;
}



int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    ll a,b,ans;
    double c;
    cin>>a>>c;
    b=c*100 + 0.5;
    ans=(a*b)/100;
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <math.h>
using namespace std;
int main() {
  int d, n;
  int count;
  int ans = 0;
  cin >> d >> n;
  count = pow(100, d);
  for(int i = 0; i < n; i++) {
    ans += count;
  }
  if(n == 100)
   ans += count;
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
int main(){
    vector<int> a;
    int n = 1;
    a.pb(0);
    vector<int> b;
    int m = 1;
    b.pb(0);
    while(n * (n + 1) * (n + 2) / 6 < 1000000){
        a.pb(n * (n + 1) * (n + 2) / 6);
        if (((n * (n + 1) * (n + 2) / 6) % 2 )== 1){
            b.pb(n * (n + 1) * (n + 2) / 6);
            m++;
        }
        n++;
    }
    vector<int> dp(1000001,6);
    dp[0] = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= 1000000; j++) {
            if (j - a[i] >= 0){
                dp[j] = min(dp[j],dp[j - a[i]] + 1);
            }
        }
    }

    vector<int> dp2(1000001,INF);
    dp2[0] = 0;
    for(int i = 1; i < m; i++) {
        for(int j = 1; j <= 1000000; j++) {
            if (j - b[i] >= 0){
                dp2[j] = min(dp2[j],dp2[j - b[i]] + 1);
            }
        }
    }

    while(1){
        int x;cin>>x;
        if(x == 0){
            break;
        }
        cout << dp[x] << ' ' << dp2[x] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 10612
#include<iostream>

using namespace std;
#define int long long
const int mod=1e9+7;

signed main(){

   int N;
   cin>> N;
   int T[N], A[N];
   for(int i=0; i<N; i++) cin>> T[i];
   for(int i=0; i<N; i++) cin>> A[i];

   int s=1;
   int l=0;
   for(int i=1; i<N; i++){
      if(T[i-1]!=T[i]) l=i;
   }
   int r=N-1;
   for(int i=N-2; i>=0; i--){
      if(A[i]!=A[i+1]) r=i;
   }
   if((l>r)||T[N-1]!=A[0]){
      cout<< 0<< endl;
      return 0;
   }
   for(int i=1; i<=l; i++){
      if(T[i-1]==T[i]) (s*=T[i-1])%=mod;
   }
   for(int i=N-2; i>l; i--){
      if(A[i]==A[i+1]) (s*=A[i+1])%=mod;
   }

   cout<< s<< endl;

   return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long dp[200006][20];
long long a[200006];
long long n;
long long mae;
long long ans;
long long tugi[200006];
long long flag;
int main()
{
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)
	{
		rep(j,20)
		{
			dp[i][j]=a[i]%2;
			a[i]/=2;
		}
	}
	rep(i,n)
	{
		tugi[i]=n;
	}
	rep(j,20)
	{
		flag=0;
		rep(i,n)
		{
			if(dp[i][j]==1)
			{
				if(flag==0)
				{
					mae=i;
					flag=1;
				}
				else
				{
					if(tugi[mae]>i)
					{
						tugi[mae]=i;
					}
					mae=i;
				}
			}
		}
	}
	for(long long i=n-1;i>=1;i--)
	{
		if(tugi[i-1]>tugi[i])tugi[i-1]=tugi[i];
	}
	for(long long now=0;now<n;now++)
	{
		ans+=(tugi[now]-now);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 34560
#include <iostream>
#include <cstdlib>
#include <vector>

using namespace std;

int main()
{
    int d;  cin >> d;
    if (d == 25){
        cout << "Christmas";
    }else if(d == 24){
        cout << "Christmas Eve";
    }else if(d == 23){
        cout << "Christmas Eve Eve";
    }else{
        cout << "Christmas Eve Eve Eve";
    }
    cout << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
using namespace std;

using ll = long long;
int main() {
	int n;
	cin >> n;
	vector<ll> A(n);
	ll high = 0;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		high += A[i];
	}
	ll low = -1;
	while (high - low > 1) {
		ll H = high;
		ll mean = (low + high) / 2;
		for (ll M = max(low, mean - n); M <= mean; M++) {
			vector<ll> B(A);
			for (int i = 0; i < n; i++) {
				B[i] += M;
			}
			ll k = 0;
			for (int i = 0; i < n; i++) {
				if (B[i] > n - 1) {
					k += (B[i] - n + 1) / (n + 1);
					if ((B[i] - n + 1) % (n + 1) != 0) {
						k++;
					}
				}
			}
			if (k <= M) {
				high = M;
				break;
			}
		}
		if (high == H) {
			low = mean;
		}
	}
	cout << high <<endl;
}


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

int main() {
  int N;
  cin >> N;
  
  int a;
  if( N == 1){
    a = 1;
  }else if(N>=2 && N<4){
    a = 2;
  }else if(N >=4 && N<8){
    a = 4;
  }else if(N >=8 && N <16){
    a = 8;
  }else if(N >= 16 && N < 32){
    a = 16;
  }else if(N >= 32 && N < 64){
    a = 32;
  }else if(N >= 64){
    a = 64;
  }
  cout << a << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if (a == b) {
            while (b-- > 0) {
            System.out.print(a);
            }
            System.out.println();
            return;
        }
        
        if (a < b) {
            while (b-- > 0) {
            System.out.print(a);
            }
            System.out.println();
            return;
        } else {
            while (a-- > 0) {
            System.out.print(b);
            }
            System.out.println();
            return;
            
        }
        
        // String stra = "";
        // for (int i = 0; i < Integer.parseInt(b); i++) {
        //     stra += "" + a;
        // }
        // String strb = "";
        // for (int i = 0; i < Integer.parseInt(a); i++) {
        //     strb += "" + b;
        // }
        // if (stra < strb) {
        //     System.out.println(stra);
        // } else {
        //     System.out.println(strb);
        // }
    }
}


Measured memory_bytes: 23636
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");

		long X =  Long.parseLong(Ws[0]);
		long Y =  Long.parseLong(Ws[1]);


		long ans = 0;
		for(long i=X;i<=Y;i+=i){
			ans++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    ll ans = 0;
    rep(i, n) {
        ll before = i - k;
        if (before < 0) {
            if (t[i] == 'r') ans += p;
            else if (t[i] == 's') ans += r;
            else if (t[i] == 'p') ans += s;
        }
        else {
            if (t[i] != t[before]) {
                if (t[i] == 'r') ans += p;
                else if (t[i] == 's') ans += r;
                else if (t[i] == 'p') ans += s;
            }
            else {
                t[i] = '*';
            }
        }
        // printf("i=%lld, ans=%lld\n", i, ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
import fractions
from functools import reduce

n = int(input())
a = list(map(int, input().split()))
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
m = lcm(*a)

ans = 0

for i in range(n):
    ans += (m - 1) % a[i]
print(int(ans))

Measured memory_bytes: 5368
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<math.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if((a==1 && b==2)|| (a==2 && b==1))
        printf("3");
        if((a==1 && b==3) || (a==3 && b==1))
        printf("2");
            if((a==2 && b==3) || (a==3 && b==2))
        printf("1");
    return 0;
}




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

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

  int W, A, B;
  cin >> W >> A >> B;
  if(A >= B) swap(A, B);
  cout << max(0, B - W - A) << endl;

}

Measured memory_bytes: 256
/*
  A - Tak and Hotels (ABC Edit)
  Contest 044
  Rakesh Kumar --> 02/08/2020
 */

#include <bits/stdc++.h>

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

    int n = 0, k = 0, x = 0, y = 0;
    std::cin >> n >> k >> x >> y;
    int total = 0;
    for (int i = 0; i < std::min(n, k); ++i)
        total += x;
    for (int i = 0; i < std::max(0, n - k); ++i) {
        total += y;
    }
    std::cout << total << std::endl;

    return 0;
}


Measured memory_bytes: 3528
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		sc.nextLine();

		for (int i=0; i < N; i++) {
			String n = sc.next();
			String m = sc.next();
//			System.out.println(n + "#" + m);
			System.out.println(calc(n, m));
		}
	}

	public static String calc(String n, String m) {
		if (n.length() > 80 || m.length() > 80) return "overflow";

		char[] cn = n.toCharArray();
//		char[] cm = n.toCharArray(); miss!
		char[] cm = m.toCharArray();

		if (cn.length < cm.length) {
			char[] temp = cn;
			cn = cm;
			cm = temp;
		}
//		System.out.println(Arrays.toString(cn));
//		System.out.println(Arrays.toString(cm));
		int nlen = cn.length;
		int mlen = cm.length;
		// nlen >= mlen
		byte[] ans = new byte[nlen];

		byte carry = 0; // kuriagari
		for (int i=nlen-1, j=mlen-1; 0 <= j; ) {
			if (cn[i] - '0' + cm[j] - '0' + carry > 9) {
				ans[i] = (byte) (cn[i] - '0' + cm[j] - '0' + carry - 10);
//				System.out.println(ans[i]);
				carry = 1;
			} else {
				ans[i] =  (byte) (cn[i] - '0' + cm[j] - '0' + carry);
				carry = 0;
			}
			j--;
			i--;
		}
		// x+mlen = nlen
		for (int i = nlen - mlen - 1; 0 <= i; i--) {
			if (cn[i] - '0' + carry > 9) {
				ans[i] = 0;
				carry = 1;
			} else {
				ans[i] = (byte) (cn[i] - '0' + carry);
				carry = 0;
			}
		}

		if (nlen == 80 && carry == 1) return "overflow";

		StringBuilder ansstr = new StringBuilder();
		if (carry == 1) ansstr.append(1);
		for (int i=0; i < ans.length; i++) {
			ansstr.append(ans[i]);
		}
		return ansstr.toString();
	}
}

Measured memory_bytes: 26268
//Matrix-like Computation
#include<bits/stdc++.h>
using namespace std;

vector<vector<int> > v;

int main(){
  int n;
  while(true){
    cin>>n;
    if(n==0)break;
    v.clear();
    for(int i=0; i<n; i++){
      vector<int> tmp;
      for(int j=0; j<n; j++){
        int c;
        cin>>c;
        tmp.push_back(c);
      }
      v.push_back(tmp);
    }
    //行方向
    for(int i=0; i<n; i++){
      int sum=0;
      for(int j=0; j<n; j++)sum+=v[i][j];
      v[i].push_back(sum);
    }
    //列方向
    vector<int> tmp;
    for(int j=0; j<n; j++){
      int sum=0;
      for(int i=0; i<n; i++)sum+=v[i][j];
      tmp.push_back(sum);
    }
    int sum=0;
    for(int i=0; i<n; i++)sum+=tmp[i];
    tmp.push_back(sum);
    v.push_back(tmp);
    for(int i=0; i<=n; i++){
      for(int j=0; j<=n; j++){
        printf("%5d", v[i][j]);
      }
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <cctype>
#include <algorithm>
#include <math.h>
#include <iomanip>

using namespace std;

int main(){
  string s;
  cin >> s;
  if(s == "SUN"){
    cout << '7';
  }else if(s == "MON"){
    cout << '6';
  }else if(s == "TUE"){
    cout << '5';
  }else if(s == "WED"){
    cout << '4';
  }else if(s == "THU"){
    cout << '3';
  }else if(s == "FRI"){
    cout << '2';
  }else if(s == "SAT"){
    cout << '1';
  }
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

N = int(input())

A = list(map(int, input().split()))

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

gcd_left = []
tmp = A[0]
for i in range(N):
    tmp = gcd(tmp, A[i])
    gcd_left.append(tmp)

gcd_right = []
tmp = A[-1]
for i in range(N-1, -1, -1):
    tmp = gcd(tmp, A[i])
    gcd_right.append(tmp)
ans = 0
for i in range(len(A)):
    if i == 0:
        ans = max(ans, gcd_right[-2])
    elif i == len(A) - 1:
        ans = max(ans, gcd_left[-2])
    else:
        ans = max(ans, gcd(gcd_left[i-1], gcd_right[N-i-2]))

print(ans)

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

int main() {
    string a, b, c;
    int ai=0, bi=0, ci=0;
    char n, ans;
    cin >> a >> b >> c;
    n = a[ai];
    ai++;
    while (true) {
        if (n == 'a') {
            if (ai == a.size()) {
                ans = 'A';
                break;
            }
            n = a[ai];
            ai++;
        } else if (n == 'b') {
            if (bi == b.size()) {
                ans = 'B';
                break;
            }
            n = b[bi];
            bi++;
        } else if (n == 'c') {
            if (ci == c.size()) {
                ans = 'C';
                break;
            }
            n = c[ci];
            ci++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main() {
  int N;
  string S;
  cin >> N >> S;
  bool valid = false;
  if (N % 2 == 0) {
    int len = N / 2;
    string T1 = S.substr(0, len);
    string T2 = S.substr(len);
    valid = T1 == T2;
  }
  if (valid) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<climits>
#include<string>
using namespace std;
#define lli long long int
#define f first
#define s second
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define pr(n) printf("%d",n);
#define prl(n) printf("%lld",n);
#define nl printf("\n");
#define all(c) (c).begin(), (c).end()
#define sz(a) int((a).size())
#define FN(i,n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++))
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
			cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
			const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
void optimizeIO()
{
	        ios_base:: sync_with_stdio(false);
		        cin.tie(NULL);
}

int main()
{
	int n;
	cin >> n;
	int arr[111111][3];
	int ans[111111];
	for(int i=1;i<=n;i++){
		cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
	}

	int x,y,z;
	x = 0;
	y = 0;
	z = 0;
	for(int i=1;i<=n;i++){
		int x1,y1,z1;
		x1 = x;
		y1 = y;
		z1 = z;
		x = arr[i][0] + max(y1,z1);
		y = arr[i][1] + max(x1,z1);
		z = arr[i][2] + max(y1,x1);
		ans[i] = max(x, max(y,z));
	}
	cout << ans[n];
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main(void)
{
    int n;
    ll counter = 0;
    scanf("%d", &n);
    vector<ll> A(n);
    for (int i = 0; i < n; i++)
        cin >> A[i];
    for (int i = 0; i < n - 1; i++)
    {
        if (A[i] > A[i + 1])
        {
            counter += A[i] - A[i + 1];
            A[i + 1] += (A[i] - A[i + 1]);
        }
    }
    printf("%lld\n", counter);
    return 0;
}

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

int main(){
  int n; cin >> n;
  int a[n], b[n];
  priority_queue<P> pq;
  rep(i, n){
    cin >> a[i] >> b[i];
    pq.push(make_pair(a[i] + b[i], i));
  }
  ll as = 0, bs = 0;
  int cnt = 0;
  while(pq.size() > 0){
    if(cnt % 2 == 0) as += a[pq.top().second];
    else bs += b[pq.top().second];
    cnt++;
    pq.pop();
  }
  cout << as - bs << endl;
  return 0;
}


Measured memory_bytes: 5092
import math
n,d = map(int,input().split())
dli = [[] for _ in range(n)]
for i in range(n):
    x = list(map(int,input().split()))
    dli[i] = x
#dli[0][0] - dli[1][0] + dli[0][1] - dli[1][1]

#(abs(dli[i][d] - dli[i+1][d]))**2 + dli[i][d] -
#
# dli[0][0] - dli[1][0] + dli[0][1] - dli[1][1]
#dli[0][0] - dli[2][0]
#dli[0][0] - dli[3][0]
cnt = 0
for i in range(n):
    for j in range(i+1,n,1):
        res = 0
        for k in range(d):
            res += abs(dli[i][k] - dli[j][k])**2
        if math.sqrt(res).is_integer():
            cnt+=1

print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include<algorithm>
#include<climits>
using namespace std;
int main(void){
    int n,a,ans=INT_MAX;
    cin>>n;
    for(int i=0; i<n;i++){
        int crack_Coount=0;
        cin>>a;
        while(a%2==0){
            crack_Coount++;
            a/=2;
        }
        ans=min(ans,crack_Coount);
    }
cout<<ans<<endl;
    
    }

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

int main(){
    int a[10],x,n=3;
    for (int i=1;i<=n;i++){
        cin>>a[i];
    }
    
    sort(a+1,a+1+n);
    

    x=a[3]*10+a[2];
    cout<<a[1]+x;
}

Measured memory_bytes: 256