akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 1e9 + 7;

const ll N = 2e6 + 10;
ll fact[N];

void prefact() {
    fact[0] = 1;
    for(ll i = 1; i < N; i++) {
        fact[i] = (i * fact[i - 1]) % mod;
    }
}

ll powmod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if(p & 1) {res = (res * a) % mod;}
        p /= 2;
        a = (a * a) % mod;
    }
    return res;
}

ll modinv(ll a) {
    return powmod(a, mod - 2);
}

ll ncr(ll n, ll r) {
    if(!r) return 1;
    return (fact[n] * (modinv(fact[r]) * modinv(fact[n - r]) % mod)) % mod;
}

void solve() {
    prefact();
    ll k;
    string s;
    cin >> k;
    cin >> s;
    ll ans = 0, n = s.size();
    for(ll i = 0; i <= k; i++) {
        ans = (ans + (ncr(n + i - 1, n - 1) * ((powmod(25, i) * powmod(26, k - i)) % mod) % mod)) % mod;
    }
    cout << ans;
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 19868
s=int(input())
a=[]
a.append(s)
for i in range(10**6):
    if s%2==0:
        s//=2
        if s in a:
            print(i+2)
            break
        else:
            a.append(s)
    else:
        s=3*s+1
        if s in a:
            print(i+2)
            break
        else:
            a.append(s)
            

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

using namespace std;


class Solution{

public:
    bool isBeautiful(const string& s){

        vector<int> freq(26, 0);
        for(char c: s) freq[c - 'a'] ++;

        for(int e: freq) if(e % 2) return false;
        return true;
    }
};

int main() {

    string s;
    cin >> s;
    printf("%s\n", Solution().isBeautiful(s) ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define cY cout << "Yes" << endl;
#define cN cout << "No" << endl;

int main() {
  int h,w,n;
  cin >> h >> w >> n;
  int cnt = 0;
  while(n>0){
    n -= max(h,w);
    cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;

string S;


int main(void) {

	int A, B, X[100000], ans = 0, tmp[3];
	
	cin >> A >> B;

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

	for (int i = 0; i <= A - B; i++) {
		tmp[0] = abs(X[i] - X[i + B - 1]);
		tmp[1] = tmp[0] + abs(X[i]);
		tmp[2] = tmp[0] + abs(X[i + B - 1]);
		if (tmp[1] < tmp[2]) {
			tmp[0] = tmp[1];
		}
		else {
			tmp[0] = tmp[2];
		}
		
		if (tmp[0] < ans) {
			ans = tmp[0];
		}
		if (i == 0) {
			ans = tmp[0];
		}
	}
	
	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 640
from collections import deque

H, W = map(int, input().split())
X = [[[0, 1][a=="#"] for a in input()] for i in range(H)]

ch = [[0] * W for _ in range(H)]
move = [[-1,0], [1,0], [0,-1], [0,1]]
ans = 0
for i in range(H):
    for j in range(W):
        if ch[i][j]:
            continue
            
        ch[i][j] = 1
        q = deque([[i,j]])
        a = [0, 0]
        while q:
            t = q.popleft()
            x = t[0]
            y = t[1]
            ch[x][y] = 1
            a[(x+y)%2] += 1
            for m in move:
                nx = x + m[0]
                ny = y + m[1]
                if nx >= 0 and nx < H and ny >= 0 and ny < W and X[x][y] != X[nx][ny]:
                    if ch[nx][ny] == 0:
                        q.append([nx,ny])
                        ch[nx][ny] = 1
        ans += a[0] * a[1]

print(ans)


Measured memory_bytes: 5996
#include<iostream>
#include<cstdio>
#include<map>
#include<sstream>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    string s;
    int num[30]={0};
    cin >> s;
    int l = s.length();
    for(int i = 0; i < l; i ++)
    {
        num[s[i]-'a']++;
    }
    bool p = true;
    for(int i = 0; i < 30; i ++)
    {
        if(num[i]%2!=0)p = false;
    }
    if(p)cout << "Yes" << endl;
    else cout << "No" <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll n;

ll gcd(ll n, ll m){
    if(n<m)return gcd(m,n);
    ll r;
    while(r=n%m){
        n=m;
        m=r;
    }
    return m;
}

int main(void) {
    cin >> n;
    ll res;
    cin >> res;
    rep(i,n-1){
        ll t;
        cin >> t;
        res=gcd(res,t);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 764
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
  int K, X;
  cin >> K >> X;
  int xmin = max(X+1-K,-1000000);
  int xmax = min(X-1+K,1000000);
  ll i = xmin;
  while(i <= xmax) {
  	cout << i << " ";
    i++;
  }
  cout << endl;
  return 0;
}

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

long long int n,i,ans,d,sq,x;

signed main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;ans=2;
	if (n==2) 
	{
		cout<<1;return 0;
	}
	sq=trunc(sqrt(n));
	for (i=2;i<sq+1;i++) if (n%i==0)
	{
		x=n;
		while (x%i==0) x=x/i;
		if ((x-1)%i==0) ans++;
		x=n;
		while (x%(n/i)==0) x=x/(n/i);
		if ((x-1)%(n/i)==0 && i!=n/i) ans++;
	}
	n--;sq=trunc(sqrt(n));
	for (i=2;i<sq+1;i++) if (n%i==0)
	{
		ans=ans+2;
		if (i==n/i) ans--;
	}
	cout<<ans;
}


Measured memory_bytes: 3700
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

const int MAX_V = 105;
int d[MAX_V][MAX_V];

struct Road {
  int from;
  int to;
  int cost;
};
vector<Road> roads;

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

  int n, m;
  cin >> n >> m;

  rep(i, n) rep(j, n) {
    d[i][j] = INF;
  }

  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
    roads.push_back(Road({a, b, c}));
  }

  rep(k, n) rep(i, n) rep(j, n) {
    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  }

  int cnt = 0;
  for(Road r : roads) {
    if(d[r.from][r.to] != r.cost) {
      cnt++;
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

/***************************/
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll> > vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

ll m;
ll d[200020],c[200020];
ll sum,dig;
void input(){
	cin >> m;
	rep(i,m)cin >> d[i] >> c[i];
}
void calc(){
	sum = dig = 0;
	rep(i,m){
		sum += d[i]*c[i];
		dig += c[i];
	}
}
void solve(){
	cout << (dig - 1) + (sum - 1) / 9 << endl;
}

int main(){
	input();
	calc();
	solve();
}

//./oj.py --onlinejudgename [contest_id] problem_id [options...]



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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define int long long
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n, m;
int p[100000 + 5];
int s[100000 + 5][25];
int cnt[25];
int dp[1<<21];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, n) cin >> p[i];
    rep(i, n) cnt[p[i] - 1] += 1;
    rep(i, n) s[i + 1][p[i] - 1] += 1;
    rep(i, n)rep(j, m) s[i + 1][j] += s[i][j];
    fill(dp, dp + (1<<m) + 1, 1e9);
    dp[0] = 0;
    rep(i, 1<<m) {
        rep(j, m) {
            if (i>>j & 1) {
                int l = 0;
                int r = 0;
                rep(k, m) {
                    if (k == j) r = cnt[k];
                    else if (i>>k & 1) l += cnt[k];
                }
                r += l;
                int change = (r - l) - (s[r][j] - s[l][j]);
                dp[i] = min(dp[i], dp[i ^ (1<<j)] + change);
            }
        }
    }
    cout << dp[(1<<m) - 1] << endl;
}

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

int main (){
    string a;cin>>a;
    int len=a.length();
    int x=0,y=0;
    for(int i=0;i<len;i++)
        if(a[i]=='+') x++;
    else y++;
    cout<<x-y<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

const int INF = 1e9;

int main() {
    ios::sync_with_stdio(false);
    vector<int> v;
    PUSH(3,v);
    sort(ALL(v));
    if (v[0] + v[1] == v[2]) {
        print("Yes");
    }else {
        print("No");
    }
    return 0;
}

Measured memory_bytes: 764
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());

            var list = new List<int> { 1, 2, 3 };
            list.Remove(A);
            list.Remove(B);

            Console.WriteLine(list.First());
        }
    }
}


Measured memory_bytes: 11220
import sys
input = sys.stdin.readline

def main():
	n = int(input().strip())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	s = 0
	for i in range(n):
		l = min(a[i], b[i])
		a[i] -= l
		b[i] -= l
		r = min(a[i+1], b[i])
		a[i+1] -= r
		b[i] -= r
		s += l + r
	print(s)

if __name__ == '__main__':
	main()


Measured memory_bytes: 76416
#include <cstdio>
#include <cstring>

const int MAX_N = 55;

int has_edge[MAX_N][MAX_N], a[MAX_N], b[MAX_N], visited[MAX_N];

void delete_edge(int u, int v)
{
    has_edge[u][v] = has_edge[v][u] = false;
}

void create_edge(int u, int v)
{
    has_edge[u][v] = has_edge[v][u] = true;
}


void dfs(int v)
{
    visited[v] = true;

    for(int child = 1; child <= MAX_N; child++)
    {
        if(has_edge[v][child] && !visited[child])
            dfs(child);
    }
}

int main()
{
    int no_of_vertices, no_of_edges;
    scanf("%d %d", &no_of_vertices, &no_of_edges);

    memset(has_edge, false, sizeof(has_edge));

    for(int i = 1; i <= no_of_edges; i++)
    {
        scanf("%d %d", &a[i], &b[i]);

        create_edge(a[i], b[i]);
    }

    int no_of_bridges = 0;
    for(int i = 1; i <= no_of_edges; i++)
    {
        delete_edge(a[i], b[i]);

        memset(visited, false, sizeof(visited));

        dfs(1);

        int is_bridge = false;
        for(int v = 1; v <= no_of_vertices; v++) //Checking if some vertex is not reachable if this bridge is deleted
            if(!visited[v])
                is_bridge = true;

        no_of_bridges += (is_bridge == true);

        create_edge(a[i], b[i]);
    }

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


Measured memory_bytes: 128
#include <cctype>
#include <cstdio>
#include <iostream>
using namespace std;

int main(int argc, char const *argv[]) {
    char ch;

    while (true) {
        scanf("%c", &ch);
        if (ch == '\n') {
            printf("\n");
            break;
        }

        if (isalpha(ch)) {
            if (islower(ch)) {
                printf("%c", toupper(ch));
            } else {
                printf("%c", tolower(ch));
            }
        } else {
            printf("%c", ch);
        }
    }

    return 0;
}



Measured memory_bytes: 3124
#include<stdio.h>
#include<math.h>
double stdev(int s[], int n){
    int sum = 0;
    for (int i = 0;i<n;i++){
        sum=sum+s[i];
    }
    double m=(double)sum/n;
    
    double sum2 =0;
    for (int i=0;i<n;i++){
       sum2=sum2+ pow(s[i]-m,2);
    }
    double v=sum2/n;
    return sqrt(v);
}
int main(){
    int n,s[1000];
    do{
        scanf("%d",&n);
        if (n>0){
            for(int i =0; i<n;i++){
                scanf("%d",&s[i]);
            }
            double sd = stdev(s,n);
            printf("%.6lf\n",sd);
        }
    }while(n>0);
    return 0;
}


Measured memory_bytes: 2040
/* Ajay Jadhav */
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

const int N=1e6;
int a[N+5];
int present[N+5];
void solve()
{
    int n;
    cin>>n;
    int nums[n];
    int lim=0;
    int one=0;
  	rep(i,0,n) 
    {
        cin>>nums[i];
        if(nums[i]==1) one++;
      	present[nums[i]]=true;
        lim=max(lim,nums[i]);
    }
  	if(one>0)
    {
        if(one==1)
       		cout<<1;
        else
          	cout<<0;
      	return;
    }
    rep(i,0,n)
    {
        int key=nums[i];
        for(int j=key;j<=lim;j+=key)
            a[j]++;
    }
    int c=0;
    for(int i=1;i<=lim;i++)
    {
        if(present[i] and a[i]==1)
            c++;
    }
    cout<<c;
}
 
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 12116
# coding=utf-8
import re

n = input()
l = len(n)-1

def f(s):
    return sum(map(int, list(s)))

if l==0:
    print(n)
elif re.search("^9+$", n)!=None:
    print(9*(l+1))
else:
    r = max(f(n), 9*l + (int(n[0])-1))
    print(r)


Measured memory_bytes: 3188
N, M = map(int, input().split())
gate = [0] * N
maxL, minR = 0, N
for i in range(M):
    L, R = map(int, input().split())
    maxL = max(maxL, L-1)
    minR = min(minR, R-1)

count = minR - maxL + 1
if count >= 0:
    print(count)
else:
    print(0)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 11;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int n, m, b[MAXN], c[MAXN];
vector<int> a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m;
    FOR(i,1,m) {
        int k, x;
        cin >> k;
        while (k--) {
            cin >> x;
            a[i].emplace_back(x);
        }
    }
    FOR(i,1,m) cin >> b[i];
    int res = 0;
    FOR(mask,0,(1<<n)-1) {
        FOR(i,1,m) c[i] = b[i];
        FOR(i,1,m) {
            FOR(j,0,SZ(a[i])-1) {
                int k = a[i][j];
                if (mask & (1<<(k-1))) {
                    c[i] = (c[i] + 1) % 2;
                }
            }
        }
        bool co = true;
        FOR(i,1,m) 
            if (c[i]) co = false;
        res += co;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin >> n;
    rep(i, n) {
        char c;
        cin >> c;
        if (c == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    c = S()
    print(chr(ord(c) + 1))

main()



Measured memory_bytes: 7848
N,K = map(int,input().split())

if N > K:
    amari  = N % K
    amari_h = abs(amari - K)

    if amari <= amari_h:
        print(amari)
    else:
        print(amari_h)
if N <= K:
    sub = abs(N - K)
    if N <= sub:
        print(N)
    else:
        print(sub)

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

int n,a[100001], dp[100001];

int cal(int idx)
{
    if (idx==n) return 0;
    if (idx>n) return 1e9;
    if (dp[idx]!=-1) return dp[idx];
    dp[idx]=0;

    dp[idx]=min( cal(idx+1)+abs(a[idx]-a[idx+1]), cal(idx+2)+abs(a[idx]-a[idx+2]) );
    return dp[idx];
}

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

    for (int i=0;i<=n;i++) dp[i]=-1;
    cout<<cal(1);
}


Measured memory_bytes: 2560
#include <stdio.h>

int main() {

    int n, k, p;
    scanf("%d %d", &n, &k);
    int arr[n];

    for (int k = 0; k < n; k++) {
        scanf("%d", &p);
        arr[k] = p;
    }

    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            //printf("%d %d\n", arr[i], arr[j]);
            if (arr[i] > arr[j]) {
                int temp = arr[j];
                arr[j] = arr[i];
                arr[i] = temp;
            }
        }
    }

    int mysum = 0;
    for (int l = 0; l <= k - 1; l++) {
        mysum += arr[l];
    }
    printf("%d", mysum);

    return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define mp make_pair
using namespace std;

void solve(int test){
	int n;
	cin>>n;
	int a[3*n];
	for (int i = 0; i < 3*n; ++i)
	{
		cin>>a[i];
	}
	//ll hi = 0, lo = 0;
	ll cumhi[n+1]={0},cumlo[n+1]={0};
	priority_queue <int> lo;
	priority_queue <int, vector<int>, greater<int>> hi;
	for (int i = 0; i < n; ++i)
	{
		cumhi[0] += a[i];
		cumlo[0] += a[3*n - 1 - i];
		hi.push(a[i]);
		lo.push(a[3*n-1-i]);
	}
	for (int i = n; i < 2*n; ++i)
	{
		if (a[i]>hi.top())
		{
			cumhi[i-n+1] = cumhi[i-n] + a[i] - hi.top();
			hi.push(a[i]);
			hi.pop();
		}
		else{
			cumhi[i-n+1] = cumhi[i-n];
		}
	}
	for (int i = 2*n - 1; i >= n; --i)
	{
		if (a[i]<lo.top())
		{
			cumlo[2*n - i] = cumlo[2*n - i - 1] + a[i] - lo.top();
			lo.push(a[i]);
			lo.pop();
		}
		else{
			cumlo[2*n - i] = cumlo[2*n - i - 1];
		}
	}
	ll m = -1e15;
	for (int i = 0; i < n+1; ++i)
	{
		m = max(m, cumhi[i] - cumlo[n - i]);
	}
	cout<<m<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll t=1,k;
	//cin>>t;
	k = t;
	while(t--){
		solve(k-t);
	}
	return 0;
}

Measured memory_bytes: 7084
import scala.io.StdIn.readInt

object Main {
  def getQ(n:Int,b:List[Int]):String = {
    if(n/4==0) ((n%4)::b).mkString
    else getQ(n/4,(n%4)::b)
  }

  def main(args:Array[String]) = {
    var n = -1
    while({n=readInt;n} != -1) {
      println(getQ(n,Nil))
    }
  }

}

Measured memory_bytes: 44628
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int time = sc.nextInt();
        String n = Integer.toString(time);
        String str[] = n.split("");
        String s = str[0];
        for(int i=1; i<str.length; i++){
            str[i] = str[0];
            s += str[i];
        }
        int x = Integer.parseInt(s);
        if(x >= time) System.out.println(x);
        else{
            int a = Integer.parseInt(str[0]) +1;
            for(int i=0; i<str.length; i++){
                System.out.print(a);
            }
        }
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    string s;
    cin >> s;
    ll n=s.size() ,ans=0;
    rep(i,n-1) ans += s[i]!=s[i+1];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

int n,m,a[2505],dp[5005][10005],s[5005][10005];
int main(){
	scanf("%*d%d%d",&n,&m);
	int i,j,k;
	for (i=0; i<=m*2; i++)
		for (j=0; j<=10000; j++){
			if (i && j){
				k=max(0,j-1-(i-(i+1)%2));
			//	for (k=j-1; k>=0 && j-k-1<=i-((i+1)%2); k--) dp[i][j]=(dp[i][j]+dp[i-1][k])%mod;
				if (k) dp[i][j]=(s[i-1][j-1]-s[i-1][k-1]+mod)%mod; else dp[i][j]=s[i-1][j-1];
			}
			if (j<=i) dp[i][j]=(dp[i][j]+1)%mod;
			if (!j) s[i][j]=dp[i][j]; else s[i][j]=(s[i][j-1]+dp[i][j])%mod;
		}
	for (i=1; i<=n; i++) scanf("%d",&a[i]);
	int ans=1;
	for (i=1,m=m*2-1; i<n && ans; i++,m-=2)
		ans=(m<0)?0:(long long)ans*dp[m][a[i+1]-a[i]-1]%mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 391424
#include <iostream>
#include <algorithm>

using namespace std;

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

int n;
int r[1010];
int w[1010];

bool dp[1010][1010];

int main(void){
	while(cin >> n,n){
		rep(i,1010)rep(j,1010) dp[i][j]=false;
		rep(i,n) cin >> r[i] >> w[i];
		int rmax=0,rother=0,rindex=-1;
		rep(i,n){
			if(r[i] > rmax){
				rmax=r[i];
				rindex=i;
			}
			rother+=r[i];
		}
		rother-=rmax;
		int ans=0;
		if(rother>=rmax){
			rep(i,n) ans+=r[i]+w[i];
		}else{
			int rem=rmax-rother;
			dp[0][0]=true;;
			rep(i,n)rep(j,rem+1){
				if(dp[i][j]==false) 
					continue;
				dp[i+1][j]=true;
				if(i!=rindex&&j+w[i]<=rem)
					dp[i+1][j+w[i]]=true;
			}
			int wsum=0;
			rep(i,n) wsum+=w[i];

			int res=0;
			rep(i,rem+1){
				if(dp[n][i]) res=i;
			}
			ans=2*rmax+(wsum-res);
		}
		cout << ans << endl;
	}
	return 0;
}

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

bool chk(int x){
	for(int i=2; i<=sqrt(x); i++){
		if(x%i==0) return false;
	}
	return true;
}

int main(){
	int X;
	cin >> X;
	for(int i=X; i<=1000000; i++){
		if(chk(i)){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+10;
const int INF=0x3f3f3f3f;
int n,k,tot,a[N],pos[N],deg[N],ans[N];
set<int> L,R;
vector<int> G[N];

priority_queue<int> q;
void toposort() {
	for (int i=1;i<=n;i++)
		if (deg[i]==0) q.push(-i);
	while (!q.empty()) {
		int x=-q.top(); q.pop();
		a[++tot]=x;
		for (int i=0;i<G[x].size();i++) {
			int y=G[x][i];
			if (--deg[y]==0) q.push(-y);
		}
	}	
}

int Min[N<<2];
void build(int rt,int l,int r) {
	Min[rt]=INF;
	if (l==r) return;
	int mid=l+r>>1;
	build(rt<<1,l,mid); build(rt<<1|1,mid+1,r);
}

void update(int rt,int l,int r,int q,int v) {
	if (l==r) { Min[rt]=min(Min[rt],v); return; }
	int mid=l+r>>1;
	if (q<=mid) update(rt<<1,l,mid,q,v);
	if (q>mid) update(rt<<1|1,mid+1,r,q,v); 
	Min[rt]=min(Min[rt<<1],Min[rt<<1|1]);
}

int query(int rt,int l,int r,int ql,int qr) {
	if (ql<=l && r<=qr) return Min[rt];
	int mid=l+r>>1;
	int ret=INF;
	if (ql<=mid) ret=min(ret,query(rt<<1,l,mid,ql,qr));
	if (qr>mid) ret=min(ret,query(rt<<1|1,mid+1,r,ql,qr));
	return ret; 
}

int main()
{
	cin>>n>>k;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) pos[a[i]]=i;
	
	build(1,1,n);
	for (int i=n;i;i--) {
		int t1=query(1,1,n,max(1,pos[i]-k+1),pos[i]);
		if (t1<=n) G[pos[i]].push_back(pos[t1]),deg[pos[t1]]++;
		int t2=query(1,1,n,pos[i],min(n,pos[i]+k-1));
		if (t2<=n) G[pos[i]].push_back(pos[t2]),deg[pos[t2]]++;
		update(1,1,n,pos[i],i);
	}
	
	toposort();
	for (int i=1;i<=n;i++) ans[a[i]]=i;
	for (int i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 46592
# -*- coding: utf-8 -*-
"""
Calorie Counting
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0239

"""
import sys


def solve(foods, limit):
    ans = []
    for s, p, q, r in foods:
        total_calorie = p*4 + q*9 + r*4
        if all([x <= y for x, y in zip([p, q, r, total_calorie], limit)]):
            ans.append(s)
    return ans if ans else ['NA']


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break
        foods = [list(map(int, input().split())) for _ in range(n)]
        limit = list(map(int, input().split()))
        ans = solve(foods, limit)
        print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 5984
_x, _y, _z, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)
cs = gets.split.map(&:to_i)
combi = []
as.each do |a|
  bs.each do |b|
    combi << a + b
  end
end
trio = []
combi.sort!.reverse!
combi[0...k].each do |ab|
  cs.each do |c|
    trio << ab+c
  end
end
trio.sort!.reverse!
trio[0...k].each do |sum|
  puts sum
end


Measured memory_bytes: 70028
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {
        var str = Console.ReadLine().SplittedStringToList();
        if (str[1] == "+")
            Console.WriteLine(str[0].ToInt32() + str[2].ToInt32());
        else
            Console.WriteLine(str[0].ToInt32() - str[2].ToInt32());
    }


    public class Edge
    {
        public int From;
        public int To;
        public int Cost;
    }

    public static List<KeyValuePair<int,int>> GetShortestPathes(int s, IEnumerable<Edge> edges, int vertices)
    {
        var ls = new KeyValuePair<int, int>[vertices];

        return ls.ToList();
    }


    #region ライブラリ

    #region 文字列処理

    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();

    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    #endregion
    #region DeepClone
    public static T DeepClone<T>(this T src)
    {
        using (var memoryStream = new MemoryStream())
        {
            var binaryFormatter
              = new BinaryFormatter();
            binaryFormatter.Serialize(memoryStream, src);
            memoryStream.Seek(0, SeekOrigin.Begin);
            return (T)binaryFormatter.Deserialize(memoryStream);
        }
    }
    #endregion

    public static int Gcd(int a,int b)
    {
        if (b == 0)
            return a;
        return Gcd(b, a % b);
    }
    public static BigInteger Gcd(BigInteger a, BigInteger b)
    {
        if (b == 0)
            return a;
        return Gcd(b, a % b);
    }


    public static BigInteger Factorial(int n)
    {
        var dp = new BigInteger[n];
        dp[0] = 1;
        for (int i = 1; i < n; i++)
        {
            dp[i] = dp[i - 1] * (i + 1);
        }
        return dp[n - 1];
    }

    public static List<int> PrimeFactorize(int n)
    {
        var bases = n;
        var num = (int)Math.Pow(n, 0.5);
        var ls = new List<int>();
        for (int i = 2; i <= num; i++)
        {
            if (n % i == 0)
            {
                n = n / i;
                ls.Add(i);
                i--;
                continue;
            }
        }
        var nnn = 1;
        foreach (var item in ls)
        {
            nnn = nnn * item;
        }
        if (nnn != bases)
            ls.Add(n);
        return ls;
    }

    #endregion

}


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

using namespace std;

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
long long l[N], r[N];

bool read() {
    if (!(cin >> n))
        return false;

    for (int i = 0; i < n; ++i)
        cin >> l[i] >> r[i];

    return true;
}

long long calc(
        set< pair<long long, int> >& L,
        set< pair<long long, int> >& R,
        long long pos, int turn) {
    auto res = 0ll;

    for (; ; turn ^= 1) {
        auto i = 0;

        if (turn == 0) {
            if (R.empty() || R.begin()->first >= pos)
                return res + abs(pos);

            res += pos - R.begin()->first;
            pos = R.begin()->first;
            i = R.begin()->second;
        } else {
            if (L.empty() || L.rbegin()->first <= pos)
                return res + abs(pos);

            res += L.rbegin()->first - pos;
            pos = L.rbegin()->first;
            i = L.rbegin()->second;
        }
        
        R.erase(make_pair(r[i], i));
        L.erase(make_pair(l[i], i));
    }

    return res + abs(pos);
}

void solve() {
    set< pair<long long, int> > L, R;

    auto dist = [](long long l, long long r) {
        return l > 0 ? l : (r < 0 ? r : 0);
    };

    for (int i = 0; i < n; ++i) {
        L.insert(make_pair(l[i], i));
        R.insert(make_pair(r[i], i));
    }

    auto i = L.rbegin()->second;
    L.erase(make_pair(l[i], i));
    R.erase(make_pair(r[i], i));
    auto pos = dist(l[i], r[i]);
    auto ans = abs(pos) + calc(L, R, pos, 0);

    L.clear();
    R.clear();

    for (int i = 0; i < n; ++i) {
        L.insert(make_pair(l[i], i));
        R.insert(make_pair(r[i], i));
    }

    i = R.begin()->second;
    L.erase(make_pair(l[i], i));
    R.erase(make_pair(r[i], i));
    pos = dist(l[i], r[i]);
    ans = max(ans, abs(pos) + calc(L, R, pos, 1));
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 14336
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();

    println!("{}", if a >= 13 {
        b
    }
    else if a <= 5{
        0
    }
    else {
        b/2
    });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

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

ll lcm(ll a, ll b) {
    return a * (b / gcd(a, b));
}

int main(void)
{
    ll a,b;
    cin >> a >> b;
    ll c,d;
    cin >> c >> d;
    auto f = [c,d](ll n){
        return (n / c) + (n / d) - (n / lcm(c,d));
    };

    pr((b-a+1) - (f(b) - f(a-1)));
}

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

int main(){
	string S;
	cin>>S;
	int ans=0;
	int tmp=0;
	for(int i=0;i<S.length();++i){
		if((S[i]=='A') || (S[i]=='G') || (S[i]=='T') || (S[i]=='C')){
			tmp++;
		}
		else if(ans<tmp){
			ans=tmp;
			tmp=0;
		}
		else{ 
			tmp=0;
		}
		if(ans<tmp)ans=tmp;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
n,p=map(int,input().split())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

arr=factorization(p)

ans=1
for i in range(len(arr)):
    if arr[i][1]//n!=0:
        ans*=arr[i][0]**(arr[i][1]//n)

if p==1:
    ans=1
elif n==1:
    ans=p


print(ans)

Measured memory_bytes: 9404
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
    static void solve(){//Here is the main function
      ArrayList<Integer> one = nextIntArray();
      int W = one.get(0);
      int A = one.get(1);
      int B = one.get(2);
      if(A + W < B){
        myout(B - (A + W));
      }else if(A > B + W){
        myout(A - (B + W));
      }else{
        myout(0);
      }
	}
	//Method addition frame start


  
	//Method addition frame end
}


Measured memory_bytes: 32748
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>

#define MAX_N 2000

typedef long long ll;

using namespace std;

int L[MAX_N];

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> L[i];
  }
  sort(L, L + N);
  ll res = 0;
  for (int i = 0; i < N - 1; ++i) {
    for (int j = i + 1; j < N; ++j) {
      int left = j + 1;
      int right = lower_bound(L, L + N, L[i] + L[j]) - L;
      res += right - left;
    }
  }
  printf("%lld\n", res);
}

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

bool less_than(int x_num, int x_denom, int y_num, int y_denom) {
    return x_num * y_denom < y_num * x_denom;
}

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    pair<int, int> ans = make_pair(0, 1);
    int ansS = 0;
    int ansW = 100 * a;
    
    for (int i = 0; 100 * a * i <= f; i++)
    {
        for (int j = 0; 100 * b * j <= f; j++)
        {
            int sumW = 100 * a * i + 100 * b * j;

            if (sumW > f) break;

            int maxS = sumW / 100 * e;

            for (int k = 0; c * k <= f; k++)
            {
                if (maxS < c * k) break;

                int l = min(maxS - c * k, f - sumW - c * k) / d;

                int sumS = c * k + d * l;

                if (sumW + sumS <= 0 || sumW + sumS > f) continue;
                
                if (less_than(ans.first, ans.second, 100 * sumS, sumW + sumS)) {
                    ans.first = 100 * sumS;
                    ans.second = sumW + sumS;
                    ansW = sumW;
                    ansS = sumS;
                }
            }
        }
    }
    
    printf("%d %d\n", ansW + ansS, ansS);
}

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

struct proc {
	char name[100];
	int t;
};

#define QLEN	100000
struct proc procs[QLEN];
int head, tail;

bool isFull(void)
{
	return head == ((tail + 1) % QLEN);
}

bool enqueue(struct proc p)
{
	if (isFull()) {
		cout << "Error: queue is full" << endl;
		return false;
	}
	procs[tail] = p;
	tail = (tail + 1) % QLEN;;
	return true;
}

struct proc dequeue(void)
{
	if (head == tail) {
		cout << "Error: queue is empty" << endl;
		exit(1);
	}
	struct proc p = procs[head];
	head = (head + 1) % QLEN;
	return p;
}

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

	rep(i, n) scanf("%s %d", procs[i].name, &procs[i].t);
	head = 0; tail = n;

	int elaps = 0, c;
	while (head != tail) {
		struct proc p = dequeue();
		c = min(q, p.t);
		p.t -= c;
		elaps += c;
		if (p.t > 0)
			enqueue(p);
		else
			printf("%s %d\n", p.name, elaps);
	}
}



Measured memory_bytes: 13288
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
	}
	
	mod& operator=(const ll & tx) {
		x = tx;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return (x + m2.x) % MOD;
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return (x - m2.x + MOD) % MOD;
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return (x * m2.x) % MOD;
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return mod(((*this).x * (*this).inv().x) % MOD);
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}

/* TEMPLATE ENDS HERE */

#define MAXN (1 << 20)

int p[MAXN];

bool prime(ll x) {
/*	if (x < MAXN) {
		return p[x];
	}*/
	for (ll i = 2; i * i <= x; i++) {
		if (x % i == 0) {
			return false;
		}
	}
	return true;
}

set<ll> ans;
ll a, b;

void check(ll x) {
	if (!x) {
		return;
	}
	if (!(a % x == 0) || !(b % x == 0)) {
		return;
	}
	if (!prime(x)) {
		return;
	}
	ans.insert(x);
}

int main() {
	cin >> a >> b;
/*	for (int i = 1; i < MAXN; i++) {
		p[i] = 1;
	}
	if (a > b) {
		swap(a, b);
	}
	for (int i = 2; i < MAXN; i++) {
		if (p[i]) {
			for (int j = 2 * i; j < MAXN; j += i) {
				p[j] = 0;
			}
		}
	}*/
	for (int i = 1; i < MAXN; i++) {
		check(i);
		check(a / i);
		check(b / i);
	}
	cout << ans.size() << endl;
	return 0;
}


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

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

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

#define PUTS(x) cout << (x) << endl;

const LL INF = 1e13;
// dp[i][j] : i番目までの品物を使ったときの、価値の総和がjである重さの総和の最小値
LL dp[101][100005] = {{0}};
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL N,W;
    cin>>N>>W;
    vector<PLL> item(N);
    REP(i,N){
        LL w,v;
        cin>>w>>v;
        item[i] = MP(w,v);
    }

    REP(i,101)REP(j,100005)dp[i][j] = INF;
    dp[0][0] = 0;
    dp[0][item[0].second] = item[0].first;
    REP(i,N-1){
        REP(j,100005)if(dp[i][j] != INF){
            // 入れない
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);

            // 入れる
            LL w = dp[i][j] + item[i+1].first;
            if(w > W)continue;
            LL v = j + item[i+1].second;
            dp[i+1][v] = min(dp[i+1][v], w);
        }
    }

    LL ans = 0;
    REP(i,100005){
        if(dp[N-1][i] != INF)ans = i;
    }
    PUTS(ans);
}

Measured memory_bytes: 79232