akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;
#define int long long
const long long mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)

signed main() {
	int a[5];
	rep(i, 3)cin >> a[i];
	sort(a, a + 3);
	int ans = 0;
	while (a[1] >= a[0] + 2) {
		a[0] += 2;
		ans++;
	}
	while (a[2] >= a[1] + 2) {
		a[1] += 2;
		ans++;
	}
	while (a[2] >= a[0] + 2) {
		a[0] += 2;
		ans++;
	}
	if (a[0] == a[1] && a[1] == a[2]) {
		cout << ans << endl;
	}
	else {
		sort(a, a + 3);
		if (a[0] == a[1])ans++;
		else ans += 2;
		cout << ans << endl;
	}
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#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()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	string s,t[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
	cin >> s;
	for(int i = 0; i < 7; i++){
		if(s == t[i]){
			if(i == 0) cout << 7 << endl;
			else cout << 7-i << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <stdio.h>
#include <unistd.h>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl
#define PI 3.14159265359

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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() {
  int n;
  cin >> n;

  vector<int> v((n + 1) / 2);
  int flag = 0;
  rep (i, n) {
    int a;
    cin >> a;
    a /= 2;
    if (a >= (n + 1) / 2) {
      flag = 1;
    }
    v[a]++;
    if (v[a] > 2) flag = 1;
  }
  if (n % 2 != 0 && v[0] != 1) {
    flag = 1;
  }
  if (flag == 1) {
    P(0);
  } else {
    int count = 0;
    rep (i, v.size()) {
      if (v[i] == 2) count++;
    }
    ll ans = 1;
    rep (i, count) {
      ans = (ans * 2) % mod;
    }
    P(ans);
  }

  return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>//accumulateを使うためにインクルード

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    int ans = (a+b);
    if(ans >= 24) ans -= 24;
    cout << ans << endl;
    
    return 0;
}

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

int main(){
	int d;
	cin>>d;
	while(d>0){
		int num[3];
		for(int i = 0 ; i < 3 ; i++ )
		{
			cin>>num[i];
		}
		for(int i = 0 ; i < 3 ; i++)
		{
			for(int j = i+1; j < 3 ; j++)
			{
				if( num[i] > num[j] )
				{
					int q = num[i];
					num[i] = num[j];
					num[j] = q;
				}
			}
		}
		if( num[2]*num[2] - num[1]*num[1] == num[0]*num[0] )
		{
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
		d--;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
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()
{
  int a, b, c ;
  cin >> a >> b >> c ;
  
  if(min(a,b)<=c && c<=max(a,b)){
    cout <<"Yes"<<endl ;
  }
  else{
    cout <<"No"<<endl ;
  }


  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++)
typedef long long ll;

int top;
int S[1000];

void push(int x){
    S[++top] = x;
}

int pop(){
    top--;
    return S[top + 1];
}

int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int a,b;
    top = 0;
    char s[100];

    while( scanf("%s", s) != EOF ){
        if ( s[0] == '+' ){
            a = pop();
            b = pop();
            push(a + b);
        } else if(s[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        } else if ( s[0] == '*' ){
            a = pop();
            b = pop();
            push(a * b);
        } else {
            push(atoi(s));
        }
    }
    printf("%d\n", pop());
    return 0;
}



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

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, 0, h) cin >> s[i];
    rep(i, 0, h) rep(j, 0, 2) cout << s[i] << endl;
    return 0;
}


Measured memory_bytes: 3620
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	numberToHeight := make([]int, N)

	z := make(map[int][]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&numberToHeight[i])
		z[i-numberToHeight[i]] = append(z[i-numberToHeight[i]], i)
	}

	ret := 0
	for i := 0; i < N; i++ {
		hi := numberToHeight[i]
		ret += len(z[hi+i])
	}
	fmt.Println(ret)
}


Measured memory_bytes: 25120
using System;
class P
{
    static void Main()
    {
        string a = Console.ReadLine();
        string color = Console.ReadLine();
        char c = color[0];
        int count = 1;
        for (int i = 1; i < color.Length; i++)
        {
            if (c != color[i])
            {
                c = color[i];
                count++;
            }
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define fastio  cin.sync_with_stdio(0); cin.tie(0);cin.exceptions(cin.failbit);
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
  
    fastio;
    int T=1;
    // cin>>T;
    while(T--){
        int x,n;cin>>x>>n;
        map<int,int> ma;
        rep(i,n){
            int x;cin>>x;ma[x]=1;
        }
        int i=0;
        while(1){
            if(ma.find(x-i)==ma.end()){
                cout<<x-i;return 0;
            }
            if(ma.find(x+i)==ma.end()){
                cout<<x+i;return 0;
            }
            i++;
        }
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 3644
n,m=map(int,input().split())
s=input()
ACsuu=[0 for i in range(n)]
for i in range(1,n):
  ACsuu[i]=ACsuu[i-1]+(1 if s[i-1:i+1]=="AC" else 0)
for i in range(m):
  a,b=map(int,input().split())
  print(ACsuu[b-1]-ACsuu[a-1])


Measured memory_bytes: 7772
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <tuple>
 
using namespace std;
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(n, a) for(int i = 0; i < n; i++) cout << a[i] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "YES" : "NO")
#define mod(a, b) (b + (a % b)) % b
#define MOD (int)1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

void add_self (int& a, int b){ a += b; if (a >= MOD) a -= MOD; }
//-------------------------------------------------------------------------------------------------------//

void solve(){
    string s;
    cin >> s;
    bool ok = false;
    for(int i = 0; i < 3; i++){
        if(s[i] == s[i + 1]) ok = true;
    }
    cout << (ok ? "Bad" : "Good");
}
 
int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}


Measured memory_bytes: 256
use std::collections::BTreeMap;
use whiteread::parse_line;

fn main() {
    let _n: usize = parse_line().unwrap();
    let d: Vec<u32> = parse_line().unwrap();
    let _m: usize = parse_line().unwrap();
    let t: Vec<u32> = parse_line().unwrap();
    let mut dmap: BTreeMap<u32, u32> = BTreeMap::new();
    let mut tmap: BTreeMap<u32, u32> = BTreeMap::new();
    let mut ans = "YES";

    for &di in &d {
        dmap.entry(di).and_modify(|x| *x += 1).or_insert(1);
    }
    for &ti in &t {
        tmap.entry(ti).and_modify(|x| *x += 1).or_insert(1);
    }
    for (tk, tv) in tmap.iter() {
        if let Some(dv) = dmap.get(tk) {
            if dv < tv {
                ans = "NO";
                break;
            }
        } else {
            ans = "NO";
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 10200
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    sort(a.begin(),a.end());
    string t;
    cin>>t;
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if( a < t ) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  ll n, k;
  cin >> n >> k;
  vector<int> v(n);
  rep(i, 0, n) cin >> v[i];

  vector<int> nums(n + 1, -1);
  vector<int> finished(n + 1, -1);

  int num = 1, now = 1, d = 0;
  while (finished[now] == -1) {
    nums[num] = now;
    finished[now] = num;
    now = v[d];
    d = v[d] - 1;
    num++;
  }

  if (k < num - 1)
    cout << nums[k + 1] << endl;
  else {
    k -= finished[now] - 1;
    int c = num - finished[now];
    int t = k % c;
    cout << nums[finished[now] + t] << endl;
  }
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(i, v) for(auto i =  v.begin(); i !=  v.end(); ++i)
#define RFOR(i, v) for(auto i = v.rbegin(); i != v.rend(); ++i)

template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T> ostream & operator<<(ostream & os, const vector<T> & v) {
	os << "[";
	FOR(it, v) {
		if(it != v.begin()) { os << ", "; }
		os << *it;
	}
	os << "]";
	return os;
}
template<typename F, typename S> ostream & operator<<(ostream & os, const pair<F, S> & p) {
	os << "<" << p.FI << ", " << p.SE << ">";
	return os;
}

// ---- ----

int n, m;
vector<pair<int, int>> vec[100001];

const int BS = 1 << 17;
struct BIT {
	int tree[BS];
	int bit(int p, int v) { return bit2(p + BS, v); }
	int bit2(int p, int v) {
		if(p == 1) { return 0; }
		
		if(p % 2 == 0) { tree[p / 2] += v; }
		int w = bit2(p / 2, v);
		if(p % 2 != 0) { w += tree[p / 2]; }
		return w;
	}
};

BIT bl, br;

int main() {
	cin >> n >> m;
	inc(i, n) {
		int l, r;
		cin >> l >> r;
		vec[r - l + 1].EB(l, r + 1);
	}
	
	int a = n;
	inc1(d, m) {
		int k = d, b = 0;
		while(k <= m) {
			b += bl.bit(k + 1, 0) - br.bit(k + 1, 0);
			k += d;
		}
		
		cout << a + b << "\n";
		//cout << a + b << " = " << a << " + " <<  b << "\n";
		
		inc(i, vec[d].size()) {
			bl.bit(vec[d][i].FI, 1);
			br.bit(vec[d][i].SE, 1);
			a--;
		}
	}
	
	return 0;
}


Measured memory_bytes: 8448
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Aeroui
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();

            out.println((a + b) >= 10 ? "error" : (a + b));
        }

    }
}



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

int act[100000][3];

int happy_dp[100000][3];

void happy(int n)
{
	happy_dp[0][0] = act[0][0];
	happy_dp[0][1] = act[0][1];
	happy_dp[0][2] = act[0][2];

	for(int i = 1; i < n; i++)
	{
		happy_dp[i][0] = max(happy_dp[i-1][1] + act[i][0], happy_dp[i-1][2] + act[i][0]);
		happy_dp[i][1] = max(happy_dp[i-1][0] + act[i][1], happy_dp[i-1][2] + act[i][1]);
		happy_dp[i][2] = max(happy_dp[i-1][0] + act[i][2], happy_dp[i-1][1] + act[i][2]);
	}

	int max_happ = max(happy_dp[n-1][0], happy_dp[n-1][1]);
	max_happ = max(max_happ, happy_dp[n-1][2]);

	cout << max_happ << endl;

}

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

	for(int i = 0; i < n; i++)
		cin >> act[i][0] >> act[i][1] >> act[i][2];

	happy(n);
	return 0;
}


Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int main(void)
{
	int result[10000], step[10000];
	int suffix = 0;

	while (1) {
		long long x, y;

		scanf("%lld", &x);
		scanf("%lld", &y);

		if (x == 0 && y == 0) {
			break;
		}

		if (x < y) {
			int temp = x;
			x = y;
			y = temp;
		}


		long long value = 1;
		int count = 0;

		while (1) {
			count++;
			value = x % y;

			if (value == 0) {
				result[suffix] = y;
				step[suffix] = count;
				suffix++;
				break;
			}

			x = y;
			y = value;
		}
	}

	for (int i = 0; i < suffix; i++) {
		printf("%d %d\n", result[i], step[i]);
	}

	return 0;
}

Measured memory_bytes: 1048
from operator import itemgetter
n = int(input())
ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))

ab.sort(key=itemgetter(0))
ans = ab[0][0]-1 + ab[-1][1] + (ab[-1][0] - ab[0][0] + 1)
print(ans)

Measured memory_bytes: 29096
import math
import fractions
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

#a = list(map(int, input().split()))

#################################################
#################################################
#################################################
#################################################



ss = input()
n = len(ss)
s=[]
for i in range(n):
    s.append(int(ss[i]))

ans = 0
for i in range(2**(n-1)):
    d=[[]]
    bit = ValueToBits(i,n-1)
    for j in range(n-1):
        d[-1].append(s[j])
        if(bit[j]==1):
            d.append([])
    d[-1].append(s[n-1])
    #print(d)
    
    for j in d:
        for k in range(len(j)):
            ans += 10**(len(j)-1-k) * j[k]

            



print(ans)

















































Measured memory_bytes: 69100
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P	  = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	int a, b;
	cin >> a >> b;
	dump(max(a - 2 * b, 0));
	return 0;
}

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

using namespace std;

int main(){
  int x;
  int y;
  bool flag=false;
  cin >> x >> y;
  for(int i=0;i<=x;i++){
    int j=x-i;
    int ans = i*2 + j*4;
    if(ans == y){
      flag = true;
      break;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>

bool all_different(const std::string& s) {
    constexpr size_t len = ('z' - 'a') + 1;
    int ss[('z' - 'a') + 1];

    for( size_t i = 0; i < len; ++i ) {
        ss[ i ] = 0;
    }

    for( size_t i = 0; i < s.size(); ++i ) {
        ss[ s[i] - 'a' ] += 1;
    }

    for( size_t i = 0; i < len; ++i ) {
        if( 2 <= ss[ i ] ) return false;
    }
    return true;
}

int main( void ) {

    std::string s;

    std::cin >> s;

    if( all_different( s ) ) {
        std::cout << "yes" << std::endl;
    } else {
        std::cout << "no" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

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

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

  string aa, bb = "";

  rep(i,b) aa += to_string(a);
  rep(i,a) bb += to_string(b);

  if (aa > bb) {
    cout << bb << endl;
  } else {
    cout << aa << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  string s; cin >> s;
  int n=s.length();
  int first,last;
  for(int i=0;i<n;i++){
    if(s[i]=='A'){first=i;break;}
  }
  for(int i=n-1;0<i;i--){
    if(s[i]=='Z'){last=i;break;}
  }
  cout << last-first+1 << endl;
}

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

const int INF=1e18;

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

    int negativeCnt=0;
    for(int i=0;i<N;i++){
        if(a[i]<0){
            negativeCnt++;
            a[i]*=-1;
        }
    }

    sort(a.begin(),a.end());
    if(negativeCnt%2==1) a[0]*=-1;

    int ans=0;
    for(int i=0;i<N;i++){
        ans+=a[i];
    }
    cout<<ans<<endl;
}


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

const lli INF = 1LL<<60;
const lli MAXH = 101;
const lli MAXW = 101;
const string D = "ESWN";
const lli di[4] = {0,1,0,-1};
const lli dj[4] = {1,0,-1,0};

lli H, W, L;
char G[MAXH][MAXW];
lli cost[MAXH][MAXW][4];

int main() {
  while(cin >> H >> W >> L && (H|W|L)) {
    lli pi, pj, d;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        cin >> G[i][j];
        lli f = D.find(G[i][j]);
        if(f != string::npos) {
          pi = i;
          pj = j;
          d = f;
        }
      }
    }
    fill(cost[0][0], cost[MAXH][0], INF);
    cost[pi][pj][d] = L;
    bool flag = false;
    while(L--) {
      for(lli k = 0; k < 4; ++k) {
        lli nd = (d + k) % 4;
        lli ni = pi + di[nd];
        lli nj = pj + dj[nd];
        if(ni < 0 || ni >= H) continue;
        if(nj < 0 || nj >= W) continue;
        if(G[ni][nj] == '#') continue;
        if(!flag) {
          if(cost[ni][nj][nd] != INF) {
            L %= (cost[ni][nj][nd] - L);
            flag = true;
          } else {
            cost[ni][nj][nd] = L;
          }
        }
        pi = ni;
        pj = nj;
        d = nd;
        break;
      }
    }
    cout << pi+1 << " " << pj+1 << " " << D[d] << endl;
  }
  return 0;
}

Measured memory_bytes: 1524
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

array<int, 3> v{};
using state = string::const_iterator;
ll op1(state &cur, int depth);
ll number(state &cur);
ll factor(state &cur);
ll number(state &cur){
    ll ans = *cur - '0';
    while(isdigit(*++cur)) ans = ans*10+(*cur-'0');
    return ans;
}

ll factor(state &cur){
    if(isdigit(*cur)) return number(cur);
    cur++;
    ll ans = op1(cur, 1);
    cur++;
    return ans;
}

ll op1(state &cur, int depth) {
    if(depth == 4) return factor(cur);
    ll ans = op1(cur, depth+1);
    while(true){

        if(v[0] == depth && *cur == '+'){
            cur++;
            ans += op1(cur, depth+1);
        }else if(v[1] == depth && *cur == '-'){
            cur++;

            ans -= op1(cur, depth+1);
        }else if(v[2] == depth && *cur == '*'){
            cur++;
            ans *= op1(cur, depth+1);
        }else break;
    }
    return ans;
}


ll expr(state &cur){
    return op1(cur, 1);
}

int main() {
    string s;
    cin >> s;
    ll ans = INT64_MIN;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                v = {i+1, j+1, k+1};
                state cur = s.begin();
                ans = max(ans, expr(cur));
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


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

int main() {
	int n, cnt = 0,a,b;
	cin>>n;
	for(int i = 0;i<n;i++) {
		cin>>a>>b;
		cnt+= b-a+1;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Math;

class Program
{
    static void Main()
    {
        var (A, B, K) = ReadLine().Split(' ').Select(int.Parse).ToArray();

        var ab = Range(A, K).Where(x => x <= B).Concat(Range(B - K + 1, K).Where(x => x >= A)).Distinct();

        foreach (var ans in ab)
            WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


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

main(){
    int n, p,maxp, maxv, d1, d2;
    while(1){
	cin >> n;
	if ( n == 0 ) break;
	assert( 1 <= n && n <= 10000 );
	maxv = -1;
	for ( int i = 0; i < n; i++ ){
	    cin >> p >> d1 >> d2;
	    assert(1 <= p && p <= 10000 );
	    assert(0 <= d1 && 1 <= 5000 );
	    assert(0 <= d2 && 2 <= 5000 );
	    assert( maxv != d1 + d2 );
	    if ( maxv < d1 + d2 ){
		maxp = p;
		maxv = d1 + d2;
	    }
	}
	cout << maxp << " " << maxv << endl;

    }
}

Measured memory_bytes: 868
#include<bits/stdc++.h>
using namespace std;
#define N 1111116

int n,a[N],d[N];
queue<int> q;
vector<int> f[N];

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();
	for (int i=2;i<=n;i++) a[i]=read(),d[a[i]]++;
	for (int i=1;i<=n;i++) if (!d[i]) q.push(i);
	while (!q.empty()){
		int t=q.front(),ans=0;q.pop();
		sort(f[t].begin(),f[t].end());
		for (int i=0;i<(int)f[t].size();i++)
			ans=max(ans,f[t][i]+(int)f[t].size()-i);
		f[a[t]].push_back(ans);
		if (--d[a[t]]==0) q.push(a[t]);
	}
	printf("%d\n",f[0][0]);
	return 0;
}

Measured memory_bytes: 34048
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (i == 0 || i == H - 1) {
                        System.out.print("#");
                    } else if (j == 0 || j == W - 1) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
}



Measured memory_bytes: 37724
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

const double PI = acos(-1.0);

signed main(){
	double a, b, x, ans;
	cin >> a >> b >> x;
	if(x >= a * a * b / 2.0){
		ans = atan(pow(a, 3) / (2.0 * (a * a * b - x)));
	}else{
		ans = atan((2.0 * x) / (a * b * b));
	}
	printf("%.10f\n", 90.0 - ans / PI * 180);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

typedef long double ld;

const int N = 1007;

int a[10][N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char c;
      cin >> c;
      a[i][j] = (c == '1');
    }
  }
  int ans = 1e9 + 7;
  for (int msk = 0; msk < (1 << (n - 1)); msk++) {
    vector <vector <int> > pos;
    vector <int> cur;
    for (int i = 0; i < n; i++) {
      cur.push_back(i);
      if (msk >> i & 1) {
        pos.push_back(cur);
        cur.clear();
      }
    }
    pos.push_back(cur);
    vector <int> sum(n + 1, 0);
    bool imp = false;
    for (int j = 0; j < m; j++) {
      for (int it = 0; it < pos.size(); it++) {
        int x = 0;
        for (int y : pos[it]) {
          x += a[y][j];
        }
        if (x > k) {
          imp = true;
          break;
        }
      }
    }
    if (imp) continue;
    int need = 0;
    for (int j = 0; j < m; j++) {
      bool bruh = false;
      for (int it = 0; it < pos.size(); it++) {
        for (int x : pos[it]) {
          sum[it] += a[x][j];
          if (sum[it] > k) {
            bruh = true;
            break;
          }
          if (bruh) break;
        }
        if (bruh) break;
      }
      if (bruh) {
        need++;
        for (int i = 0; i < pos.size(); i++) {
          sum[i] = 0;
          for (int x : pos[i]) { 
            sum[i] += a[x][j];
          }
        }
      }
    }
    int bitcnt = __builtin_popcount(msk);
    ans = min(ans, need + bitcnt);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(abs(c-b)-a>0)
    cout<<abs(c-b)-a;
  else
    cout<<0;
}

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

int	main() {
  // input
    int bingo[3][3];
    bool check[3][3];
    for (int i=0;i<3;i++) {
    	for (int j=0;j<3;j++) cin >> bingo[i][j];
    }
  	for (int i=0;i<3;i++) {
    	for (int j=0;j<3;j++) check[i][j] = false;
    }
  
  	int n;
  	cin >> n;
  	int nb;
  	for (int x=0;x<n;x++) {
   		cin >> nb;
      	for (int i=0;i<3;i++) {
        	for (int j=0;j<3;j++) {
            	if (bingo[i][j] == nb) check[i][j] = true;
            }
        }
    }
  	
  	bool flag;
  	for (int i=0;i<3;i++){
      	flag = true;
    	for (int j=0;j<3;j++) {
        	if (!check[i][j]) flag = false;
        }
      	if (flag) {
            cout << "Yes" << endl;
            return (0);
        }
    }
  	
  	for (int i=0;i<3;i++){
      	flag = true;
    	for (int j=0;j<3;j++) {
        	if (!check[j][i]) flag = false;
        }
      	if (flag) {
            cout << "Yes" << endl;
            return (0);
        }
    }  
    flag = true;
  	for (int i=0;i<3;i++){
        if (!check[i][i]) flag = false;
    }
    if (flag) {
        cout << "Yes" << endl;
        return (0);
    }
    flag = true;
  	for (int i=0;i<3;i++){
        if (!check[i][2-i]) flag = false;
    }
    if (flag) {
         cout << "Yes" << endl;
         return (0);
    }  	
  
  	cout << "No" << endl;
 	
    
  		

}

Measured memory_bytes: 256
nd = input('')
n = int(nd.split()[0])
d = int(nd.split()[1])

d1=d**2
cnt=0
for i in range(n):
    xy=input('')
    x = int(xy.split()[0])
    y = int(xy.split()[1])
    d2 = x**2+y**2
    if d1 >=d2:
        cnt+=1
print(cnt)


Measured memory_bytes: 9196
x=int(input())
for p in range(1,int(x**0.5)+1):
    if x%p==0:
        q=x//p
        for a in range(int(x**0.5)+1):
            b=a-p
            if a**4+a**3*b+a**2*b**2+a*b**3+b**4==q:
                print(a,b)
                exit()

Measured memory_bytes: 67996
#include <iostream>
#include <vector>
using namespace std;
long long md=1000000007;
int main() {
	int n;
	int m;
	cin >> n >> m;
	vector <int> a(n+1,0);
	for (int i=0; i<m; i++){
		int x;
		cin >> x;
		a[x]=-1;
	}
	vector <long long> dp(n+1);
	dp[0]=1;
	if (a[1]==-1) dp[1]=0;
	else dp[1]=1;
	for (int i=2; i<=n; i++){
		if (a[i]==-1) {
			dp[i]=0;
		}
		else {
			dp[i]=(dp[i-1]+dp[i-2])%md;
		}
	}
	cout << dp[n];
	return 0;
}

Measured memory_bytes: 1408
my @data =<STDIN>;
my @num = split(/ /, $data[0]);

# 学生数
my $student_num = $num[0];
my @student_x;
my @student_y;
# チェックポイント数
my $checkpoint_num = $num[1];
my @checkpint_x;
my @checkpint_y;

for(my $i=0;$i < $student_num; $i++) {
	@tmp = split(/ /, $data[1+$i]);
	push(@student_x, $tmp[0]);
	chomp $tmp[1];
	push(@student_y, $tmp[1]);
}
for(my $j=0;$j < $checkpoint_num; $j++) {
	@tmp = split(/ /, $data[$j+$student_num+1]);
	push(@checkpint_x, $tmp[0]);
	chomp $tmp[1];
	push(@checkpint_y, $tmp[1]);
}

for(my $i;$i < $student_num; $i++) {
	my $selectCheckpoint = 1;
	my $max= calcDistance($student_x[$i], $student_y[$i], $checkpint_x[0], $checkpint_y[0]);
	for($j=1;$j < $checkpoint_num; $j++) {
		my $calcResult = calcDistance($student_x[$i], $student_y[$i], $checkpint_x[$j], $checkpint_y[$j]);

		if($max > $calcResult) {
			$max = $calcResult;
			$selectCheckpoint = $j+1;
		}
	}
	print $selectCheckpoint, "\n";
}

sub calcDistance {
	($x1, $y1, $x2, $y2) = @_;
	return abs($x1-$x2) + abs($y1-$y2);
}


Measured memory_bytes: 512
import java.util.Scanner; 
class Main {
   public static void main(String[] args){
     Scanner scan = new Scanner(System.in);
     int x = scan.nextInt();
     int y = scan.nextInt();
     int area = x * y;
     int perimeter =(2 * x) + (2 * y);
     System.out.println(area + " " + perimeter);
  }
}


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

int main() {
    string s;
    ll k;
    cin>>s>>k;
    for (int i=0; i<min(k,(ll)s.size()); i++) {
        if (s[i]!='1') {
            cout<<s[i]<<endl;
            return 0;
        }
    }
    cout<<1<<endl;
}


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

int main(){
	int a,b;
	cin >> a >> b;
	cout << "a ";
	if(a<b) cout << "< ";
	if(a==b) cout << "== ";
	if(a>b) cout << "> ";
	cout << "b" << endl;
	
	
	return 0;
}


Measured memory_bytes: 3116
// 2019/06/19
// AtCoder Beginner Contest 101 - B

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, w, ksum;
    string ans;
    cin >> n;
    w = n;
    ksum = 0;
    while(w > 0){
        ksum = ksum + (w % 10);
        w = w / 10;
    }
    if(n % ksum == 0){
        ans = "Yes";
    } else {
        ans = "No";
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

vector<int64_t> divisor(int64_t n) {
  vector<int64_t> ret;
  for (int64_t i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int64_t> A(N);
  vector<vector<int64_t>> B(N);
  unordered_map<int64_t, int> Amap;
  rep(i, N) {
    cin >> A[i];
    B[i] = divisor(A[i]);
    Amap[A[i]]++;
  }

  int answer = 0;
  for (int i = 0; i < N; ++i) {
    bool flag = true;
    for (auto n : B[i]) {
      if (Amap.count(n)) {
        if (n == A[i] && Amap[n] == 1) {
          continue;
        }
        flag = false;
        break;
      }
    }
    if (flag) ++answer;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 112320
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/24 11:18:40 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>
// #include <boost/multi_array.hpp>
// #include <boost/optional.hpp>
// #include <boost/range/irange.hpp>
// #include <boost/range/algorithm.hpp>
// #include <boost/range/adaptors.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/algorithm/string/classification.hpp> // is_any_of
// #include <boost/algorithm/string/split.hpp>
// #include <boost/algorithm/string/join.hpp>
// #include <boost/algorithm/string/replace.hpp>
// #include <boost/math/tools/minima.hpp>

#define MOD 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

// namespace adaptor = boost::adaptors;
using namespace std;
// using boost::math::tools::brent_find_minima;
// using boost::irange;
// using boost::algorithm::join;
// using boost::algorithm::split;
// using boost::algorithm::replace_all;
// using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	ll	n, c, k;
	cin >> n >> c >> k;

	vector<ll>	V(n);
	rep(i, n)
		cin >> V.at(i);
	sort(V.begin(), V.end());
	ll	bus;
	bus = 0;
	int i = 0;
	while (i < n)
	{
		bus++;
		int	cnt;
		cnt = 0;
		ll limit;
		limit = V.at(i) + k;
		while (i < n - 1 && cnt < c - 1 && V.at(i + 1) <= limit )
		{
			cnt++;
			i++;
		}
		i++;
	}
	cout << bus << endl;
}
// END

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


Measured memory_bytes: 1024
n,m = map(int, input().split())

ans = 0
if n == 1:
    if m == 1:
        ans = 1
    elif m == 2:
        ans = 0
    else:
        ans = m - 2

if n == 2:
    ans = 0

if n > 2:
    if m == 1:
        ans = n-2
    elif m == 2:
        ans = 0
    else:
        ans = (n-2)*(m-2)
    



print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<62;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){
    ll X, t; cin >> X >> t;

    cout << max(X-t,0LL) << endl;
   
}

Measured memory_bytes: 3556
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] dat = br.readLine().split(" ");
		int r = Integer.parseInt(dat[0]);
		int c = Integer.parseInt(dat[1]);
		StringBuilder out=new StringBuilder();
		int g,p,gg=0;
		String str;
		int[] SumC=new int[c];
		for (int i=0;i<r;i++){
			str =br.readLine();
			dat = str.split(" ");
			g=0;
			for (int j=0;j<c;j++){
				p=Integer.parseInt(dat[j]);
				g += p;
				SumC[j] += p;
			}
			gg+=g;
			out.append(str+" "+g+"\n");
		}
		for (int j=0;j<c;j++) out.append(SumC[j]+" ");
		out.append(gg);
		System.out.println(out);
	}
}

Measured memory_bytes: 25344
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] a = new int[n];
		int odd=0;
		int even=0;
		for (i = 0; i < a.length; i++) {
			a[i] = parseInt(sc.next());
			if(a[i]%2==0) {
				even++;
			} else {
				odd++;
			}
		}
		sc.close();
		boolean f=false;
		if(odd%2==1) {
			f=false;
		} else {
			f=true;
		}
		out.println(f?"YES":"NO");
	}
}


Measured memory_bytes: 50944
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main{
 public static void main(String[] args){
  Scanner s = new Scanner(System.in);
   int k = s.nextInt();
   s.nextLine();
   String inp = s.nextLine();
   int rep = s.nextInt();
   char txt = inp.charAt(rep-1);
   String res = "";
   
   for(int i=0; i<k; i++){
   if(inp.charAt(i) != txt){
   res = res +'*' ;
   }
     else{
     res = res + txt;
     }
   }
   
   System.out.print(res);
 }
}

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

int main(){
    int k,a,b;
    cin >> k>> a >> b;
    bool can = false;
    for(int idx=a;idx<=b;idx++){
        if(idx%k == 0) can = true;
    }
    cout << (can ? "OK" : "NG") << endl;
}


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

int main() {
	int h,w;
	int dx[4] = {1, -1, 0, 0};
	int dy[4] = {0, 0, 1, -1};
	cin >> h >> w;
	char grid[20][20];
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cin >> grid[i][j];
		}
	}
	long long ans = 0;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(grid[i][j] == '#'){
				continue;
			}else{
				long long board[20][20];
				for(int ii=0; ii<h; ii++){
					for(int jj=0; jj<w; jj++){
						board[ii][jj] = -1;
					}
				}

				board[i][j] = 0;
				queue<int> queueX;
				queue<int> queueY;
				queueX.push(j);
				queueY.push(i);

				while(queueX.size() > 0){
					int x = queueX.front();
					int y = queueY.front();
					queueX.pop();
					queueY.pop();
					for(int ii=0; ii<4; ii++){
						int nextX =x + dx[ii];
						int nextY =y + dy[ii];

						if(0<=nextX && nextX<w && 0<=nextY && nextY<h && board[nextY][nextX] == -1 && grid[nextY][nextX] == '.'){
							board[nextY][nextX] = board[y][x] + 1;
							queueX.push(nextX);
							queueY.push(nextY);
						}
					}
				}
				long long tmp = 0;
				for(int ii=0; ii<h; ii++){
					for(int jj=0; jj<w; jj++){
						tmp = max(tmp, board[ii][jj]);
					}
				}
				ans = max(ans, tmp);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const ll INF = 1e18+1;

/*
各クエリqに対してできればO(100)以内に収めた回答をしたい

各マスに対して＋Dされたときの移動先を記録しておく

逆に、値xを添え字として座標を値とした配列作るかー

*/

int H, W, D, Q;
int A[300][300];

int main() {
    cin >> H >> W >> D;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) cin >> A[i][j];
    }
    cin >> Q; vector<int> L(Q), R(Q);
    for (int i = 0; i < Q; i++) cin >> L[i] >> R[i];

    vector<pair<int, int> > P(H*W+1);
    vector<ll> S(H*W+1,0);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            P[A[i][j]] = make_pair(i+1,j+1);
        }
    }
    for (int r = 0; r < D; r++) {
        for (int k = r; k < H*W+1; k += D) {
            if (k < r + D) {
                S[k] = 0;
                continue;
            }
            S[k] = S[k-D] 
                 + abs(P[k].first-P[k-D].first) 
                 + abs(P[k].second-P[k-D].second);
        }
    }

    for (int q = 0; q < Q; q++) {
        ll res = S[R[q]] - S[L[q]];
        cout << res << endl;
    }



}



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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = new PrintStream(System.out);
        int A, B, C, D;

        A = sc.nextInt();
        B = sc.nextInt();
        C = sc.nextInt();
        D = sc.nextInt();

        if(A*B > C*D) {
            out.println(A*B);
        } else {
            out.println(C*D);
        }

        sc.close();
    }
}

Measured memory_bytes: 21716