akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();
        int k = sc.NextInt();

        long sum = 0;
        var p = Math.Min(a, k);
        sum += p;
        k -= p;
        p = Math.Min(b, k);
        k -= p;
        p = Math.Min(c, k);
        sum -= p;
        Console.WriteLine(sum);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27484
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  string S;
  cin>>S;
  cout<<(S=="ABC"?"ARC":"ABC")<<endl;
  return 0;
}


Measured memory_bytes: 3628
def main():
    n, x, y = map(int, input().split())
    x -= 1
    y-= 1
    ans = [0]*n
    
    for i in range(n):
        for j in range(i+ 1, n):
            d = min(j-i, abs(j-y) + abs(x-i) + 1, abs(j-x) + abs(y-i) + 1)
            ans[d] += 1

    for i in range(1, n):
        print(ans[i])

if __name__ == "__main__":
    main()

Measured memory_bytes: 9288
#include <stdio.h>

#define SIZE 2000000

int main() {
  int A[SIZE];
  int H=0;
  int i, l, largest, tmp, n;
  char com[21], buf[20];
  buf[19]='\0';
  char *p,*c1,*c2;
  c1 = com+1;
  c2 = com+2;
  do {
    fgets(com, 20, stdin);
    if (*com == 'i') {
      n = 0;
      p = com+7;
      while (*p!='\n') {
        n = n*10+*p-'0';
        p++;
      }
      A[++H] = n;
      for (i=H; i>1 && A[i>>1]<A[i];i>>=1) {
        tmp = A[i>>1];
        A[i>>1] = A[i];
        A[i] = tmp;
      }

    } else if (*c1=='x') { // extract
      n = A[1];
      for (i=18; n>0; n/=10) buf[i--]=(n%10)+'0';
      puts(buf+i+1);
      A[1] = A[H];
      i = 1;
      while (1) {
        l = i<<1;
        if (l < H && A[l] > A[i])        largest = l;
        else         largest = i;
        if (l+1 < H && A[l+1] > A[largest])  largest = l+1;
        if (largest == i) break;
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        i = largest;
      }
      H--;
    }
  } while (*c2!='d');
  return 0;
}


Measured memory_bytes: 5468
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ii pair<int,int>
#define setin set.insert
using namespace std;

void solve()
{
    int a;
    cin >> a;
    ll c=a+(a*a)+(a*a*a);
    cout << c << endl;
}

int main()
{

    solve();

    return 0;
}


Measured memory_bytes: 3552
#include<stdio.h>

int main(){
 int i,j,k,n,m,l;
 long long C[100][100]={},A[100][100]={},B[100][100]={};
 scanf("%d %d %d", &n, &m, &l);
 for(i=0; i<n; i++){
  for(j=0; j<m; j++){
   scanf("%d", &A[i][j]);
  }
 }
 for(i=0; i<m; i++){
  for(j=0; j<l; j++){
   scanf("%d", &B[i][j]);
  }
 }
 for(i=0; i<n; i++){
  for(j=0; j<l; j++){
   for(k=0; k<m; k++){
    C[i][j]+=A[i][k]*B[k][j];
   }
   if(j!=l-1){printf("%lld ",C[i][j]);}
   else{printf("%lld\n", C[i][j]);}
  }
 }
 return 0;
}

Measured memory_bytes: 844
#include <bits/stdc++.h>
using namespace std;
int INF = 2147483647;
template <typename T>
struct range_update_range_min{
	int N;
	vector<T> ST;
	vector<T> lazy;
	range_update_range_min(int n){
		N = 1;
		while (N < n){
			N *= 2;
		}
		ST = vector<T>(N * 2 - 1, INF);
		lazy = vector<T>(N * 2 - 1, -1);
	}
	range_update_range_min(vector<T> A){
		int n = A.size();
		N = 1;
		while (N < n){
			N *= 2;
		}
		ST = vector<T>(N * 2 - 1, INF);
		lazy = vector<T>(N * 2 - 1, -1);
		for (int i = 0; i < n; i++){
			ST[N - 1 + i] = A[i];
		}
		for (int i = N - 2; i >= 0; i--){
			ST[i] = min(ST[i * 2 + 1], ST[i * 2 + 2]);
		}
	}
	void eval(int i){
		if (lazy[i] != -1){
			if (i < N - 1){
				lazy[i * 2 + 1] = lazy[i];
				lazy[i * 2 + 2] = lazy[i];
			}
			ST[i] = lazy[i];
			lazy[i] = -1;
		}
	}
	void range_update(int L, int R, T x, int i, int l, int r){
		eval(i);
		if (R <= l || r <= L){
			return;
		} else if (L <= l && r <= R){
			lazy[i] = x;
			eval(i);
		} else {
			int m = (l + r) / 2;
			range_update(L, R, x, i * 2 + 1, l, m);
			range_update(L, R, x, i * 2 + 2, m, r);
			ST[i] = min(ST[i * 2 + 1], ST[i * 2 + 2]);
		}
	}
	void range_update(int L, int R, T x){
		return range_update(L, R, x, 0, 0, N);
	}
	T range_min(int L, int R, int i, int l, int r){
		eval(i);
		if (R <= l || r <= L){
			return INF;
		} else if (L <= l && r <= R){
			return ST[i];
		} else {
			int m = (l + r) / 2;
			return min(range_min(L, R, i * 2 + 1, l, m), range_min(L, R, i * 2 + 2, m, r));
		}
	}
	T range_min(int L, int R){
		return range_min(L, R, 0, 0, N);
	}
};
int main(){
  int n, q;
  cin >> n >> q;
  range_update_range_min<int> a(n);
  for (int i = 0; i < q; i++){
    int T;
    cin >> T;
    if (T == 0){
      int s, t, x;
      cin >> s >> t >> x;
      a.range_update(s, t + 1, x);
    }
    if (T == 1){
      int s, t;
      cin >> s >> t;
      cout << a.range_min(s, t + 1) << endl;
    }
  }
}


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

using namespace std;

const int N = 1e5;
int dp[N + 10];
int h[N + 10];

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

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

    for(int i = 1; i < n; i++)
    {
        int mini = 1e9;
        for(int j = i - 1; j >= max(0, i - k); j--)
            mini = min(mini, dp[j] + abs(h[i] - h[j]));
        dp[i] = mini;
    }
    cout << dp[n - 1];
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
using namespace std;
int N;

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

    cin >> N;
    vector<pair <int, int> > red(N);
    vector<pair <int, int> > blue(N);
    rep(i, N) cin >> red[i].first >> red[i].second;
    rep(i, N) cin >> blue[i].first >> blue[i].second;

    sort(red.begin(), red.end());
    sort(blue.begin(), blue.end());
    int cnt= 0;
    rep(i,N){
        int selected_idx = -1;
        bool flag = false;
        rep(j,N){
            if((red[j].first < blue[i].first) &(red[j].second < blue[i].second)){
                if (selected_idx  < 0){
                    selected_idx= j;
                    flag = true;
                    continue;
                }
                if (red[selected_idx].second < red[j].second) selected_idx = j;
            }
        }
        if(flag){
            red[selected_idx].first = 300;
            red[selected_idx].second = 300;
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

struct mint {
	ll x;
	mint() :x(0) {}
	mint(ll x) :x((x% mod + mod) % mod) {}
	// mint(ll x):x(x){}
	mint& fix() { x = (x % mod + mod) % mod; return *this; }
	mint operator-() const { return mint(0) - *this; }
	mint operator~() const { return mint(1) / *this; }
	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) { (x *= a.pow(mod - 2).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 operator/(const mint& a)const { return mint(*this) /= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint res = pow(t / 2);
		res *= res;
		return (t & 1) ? res * x : res;
	}
	mint inv() const {
		return pow(mod - 2);
	}
	bool operator<(const mint& a)const { return x < a.x; }
	bool operator==(const mint& a)const { return x == a.x; }
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; i--) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	combination c(n);
    mint ans = 0;
	rep(i, min(k, n - 1) + 1) {
		ans += c(n, i) * c(n - 1, n - i - 1);
	}
	cout << ans.x << endl;

	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
    int main(){
        // Your code here!
        string S;
            cin>>S;
        if(S.at(0)==S.at(1)&&S.at(0)==S.at(2)){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    return 0;}


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


def read():
    S = input().strip()
    T = input().strip()
    return S, T


def solve(S, T):
    s = ''.join(sorted(S))
    t = ''.join(reversed(sorted(T)))
    return "Yes" if s < t else "No"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
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;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

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

    ll n, k;
    string s;
    cin >> n >> k >> s;

    ll ans = 0;

    ll lef = 0;
    ll rig = 0;

    ll sum = 0;
    ll tmp = k;
    while(lef<n){
        if(rig<n && tmp>0 && s[rig]=='0'){
            tmp--;
            while(rig<n && s[rig]=='0'){
                sum++;
                rig++;
                ans = max(ans,sum);
            }
        }
        else if(rig<n && s[rig]=='1'){
            rig++;
            sum++;
            ans = max(ans,sum);
        }
        else if(s[lef]=='0'){
            tmp++;
            while(lef<n && s[lef]=='0'){
                lef++;
                sum--;
            }
        }
        else if(s[lef]=='1'){
            lef++;
            sum--;
        }

        if(lef==rig){
            lef++;
            rig++;
            sum = 0;
            tmp = k;
        }
    }

    cout << ans <<endl;


    
    return 0;
}



Measured memory_bytes: 3684
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	// input = input.split("\n");
	ans = 0
	input = input.trim().split("");
	input.forEach(function(i) {
    if (i === '-') {
      ans--
		} else {
			ans++
		}
	})

	//出力
	console.log(ans+ ""+ '\n')
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define bzero(p, n) memset(p, 0, n)
#define all(a) begin(a),end(a)

template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}

#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    int n;
    cin >> n;

    int c[100000+1][2]; bzero(c, sizeof c);

    int v;
    rep(i, n) {
        cin >> v;
        c[v][i%2]++;
        // chmax(c_max[i%2], c[v]);
    }
    vector<pair<int, int>> counter[2];
    rep(i, 2) {
        rep1(v, countof(c)) {
            if (c[v][i]) {
                counter[i%2].push_back(make_pair(c[v][i], v));
            }
        }
    }
    rep(i, 2) sort(all(counter[i]), greater<pair<int,int>>());

    int ans;
    if (counter[0][0].second != counter[1][0].second) {
        // cout << FMT2(counter[0][0].second,counter[1][0].second) << endl;
        ans = n - (counter[0][0].first + counter[1][0].first);
    } else {
        int a, b;
        a = counter[0][0].first + (counter[1].size() >= 2 ? counter[1][1].first : 0);
        b = counter[1][0].first + (counter[0].size() >= 2 ? counter[0][1].first : 0);
        // cout << FMT2(a,b) << endl;
        ans = n - max(a, b);
    }

    cout << ans << endl;
}


Measured memory_bytes: 2168
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, M;
  cin >> N >> M;
  vector<P> job;
  rep(i, N){
    ll a, b;
    cin >> a>> b;
    job.push_back({a, b});
  }

  sort(ALL(job), [](P a, P b){return a.first < b.first;});

  ll ans = 0;
  ll curind = 0;
  priority_queue<ll> cand;
  rep(i, M){
    if(curind<N){
      while(job[curind].first <= i+1){
        cand.push(job[curind].second);
        curind++;
        if(curind==N) break;
      }
    }
    if(cand.size()>0){
      ans += cand.top();
      cand.pop();
    }
  }

  cout << ans ;
  
  return 0;
}


Measured memory_bytes: 2548
#include<cstdio>
#include<algorithm>
using namespace std;
int n, t, mx;
int main()
{
	scanf("%d%d",&n, &t);
    for(int i = 1; i <= t; ++i)
    {
        int x;
        scanf("%d",&x);
        mx = max(mx, x);
    }
    printf("%d",max(mx - 1 - (n - mx), 0));
} 

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
int a, b;
cin >> a >> b;

if(a <= b) print(a);
else print(a - 1);
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int n, p;
int a[20010], b[20010];

int main() {
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &p);
        a[i] = 30000 * i;
        b[i] += 30000 * (n - i);
        b[p] += i;
    }
    for (int i = 1; i <= n; i++) {
        printf("%d ", a[i]);
    }
    printf("\n");
    for (int i = 1; i <= n; i++) {
        printf("%d ", b[i]);
    }
    printf("\n");
}

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

int main() {
  int day;
  cin >> day;
  string word;
  word = "Christmas";
  
  if (day == 25) {
  	cout << word << endl;
  }
  else if (day == 24) {
    cout << word << " Eve" << endl;
  }
  else if (day == 23) {
    cout << word << " Eve Eve" << endl;
  }
  else {
    cout << word << " Eve Eve Eve" << endl;
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, m, d; cin >> n >> m >> d;
	ll ps;
	if(d == 0) ps = n;
	else ps = 2ll * (n - d);
	
	double sum = 0;
	rep(i, m - 1) sum += ps;
	printf("%.20f\n", sum / n / n);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  #define int long
  int N;cin>>N;
  vector<int>A(3*N);for(int i=0;i<3*N;i++)cin>>A[i];
  vector<int>Lmax(N+1,0),Rmin(N+1,0);//真ん中のどこかで切った時の最大と最小
  priority_queue<int,vector<int>,greater<int> >L;
  priority_queue<int>R;
  
  
  for(int i=0;i<N;i++){
    Lmax[0]+=A[i];Rmin[N]+=A[3*N-1-i];
    L.push(A[i]);
    R.push(A[3*N-1-i]);
  }
  
  for(int i=0;i<N;i++){
    int lt=L.top();
    if(A[N+i]>lt){L.pop();L.push(A[N+i]);Lmax[i+1]=Lmax[i]+A[N+i]-lt;}
    else Lmax[i+1]=Lmax[i];
    
    int rt=R.top();
    if(A[2*N-i-1]<rt){R.pop();R.push(A[2*N-i-1]);Rmin[N-i-1]=Rmin[N-i]+A[2*N-i-1]-rt;}
    else Rmin[N-i-1]=Rmin[N-i];
  }
  int ans=LONG_MIN;
  for(int i=0;i<N+1;i++){
    ans=max(ans,Lmax[i]-Rmin[i]);
  }
  cout<<ans;
}





Measured memory_bytes: 5996
#include<iostream>
#include<algorithm>
using namespace std;
int n, c[100][100], len;
void solve(int len, int a, int b) {
	int ans;
	ans = min(a, min(b, min(len - a+1, len - b+1)));
	ans = ans % 3;
	if (ans == 0) ans = 3;
	cout << ans << endl;
}
int main() {
	int i;
	cin >> len >> n;
	for (i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		solve(len, a, b);
	}
	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
template <int MOD=1000000007>
struct Modular {
  int value;
  static const int MOD_value = MOD;

  Modular(long long v = 0) { value = v % MOD; if (value < 0) value += MOD;}
  Modular(long long a, long long b) : value(0){ *this += a; *this /= b;}

  Modular& operator+=(Modular const& b) {value += b.value; if (value >= MOD) value -= MOD; return *this;}
  Modular& operator-=(Modular const& b) {value -= b.value; if (value < 0) value += MOD;return *this;}
  Modular& operator*=(Modular const& b) {value = (long long)value * b.value % MOD;return *this;}

  friend Modular mexp(Modular a, long long e) {
    Modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
    return res;
  }
  friend Modular inverse(Modular a) { return mexp(a, MOD - 2); }

  Modular& operator/=(Modular const& b) { return *this *= inverse(b); }
  friend Modular operator+(Modular a, Modular const b) { return a += b; }
  friend Modular operator-(Modular a, Modular const b) { return a -= b; }
  friend Modular operator-(Modular const a) { return 0 - a; }
  friend Modular operator*(Modular a, Modular const b) { return a *= b; }
  friend Modular operator/(Modular a, Modular const b) { return a /= b; }
  friend std::ostream& operator<<(std::ostream& os, Modular const& a) {return os << a.value;}
  friend bool operator==(Modular const& a, Modular const& b) {return a.value == b.value;}
  friend bool operator!=(Modular const& a, Modular const& b) {return a.value != b.value;}
};
int main() {

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

  int n;
  cin >> n;

  map<int, int> m;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;

    a[i] = x;
    for (int j = 2; j <= sqrt(x); ++j) {
      if (x%j)  continue;
      int cnt = 0;
      while (x%j == 0)  cnt++, x /= j;
      m[j] = max(m[j], cnt);
    }
    if (x > 1)  m[x] = max(m[x], 1); 
  }
  Modular<M> l = 1;
  for (auto i : m) {
    Modular<M> c = i.first;
    c = mexp(c, i.second);
    l *= c;
  }

  Modular<M> ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += l / a[i];
  }

  cout << ans << '\n';
}

Measured memory_bytes: 768
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  bool yes = true;
  for(int i=0; i < s.length()-1; i++)
    if(s[i] == s[i+1]){
      yes = false;
      break;
    }
  if(yes)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    int n, min, max, sum, p;
    while (true) {
        cin >> n;
        if (n == 0) {
            break;
        }
        sum = 0;
        for (int i=0; i<n; i++) {
            cin >> p;
            sum += p;
            if (i == 0) {
                min = p;
                max = p;
            }
            min = p<min? p: min;
            max = p>max? p: max;
        }
        cout << (sum-min-max)/(n-2) << endl;
    }
    return 0;
}

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

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9

using namespace std;
typedef long long ll;

int main(){
	ll n, m, ans;
	cin >> n >> m;
	for (ll i=1; i*i<=m && i*n<=m; i++){
		if (m%i==0){
			if ((m/i)*n<=m){
				ans = max(ans, m/i);
			}else{
				ans = max(ans, i);
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    int A, B;
    cin >> A >> B;
    int ans;
    if (A + B >= 24) ans = A + B - 24;
    else ans = A + B;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
    #include <math.h>
    using namespace std;
    int main(){
    	int K, i;
    	cin >> K;
    	long long int A[K], B[K], C[K];
    	for( i=0; i<K; i++ ){
    		cin >> A[i];
    	}
    	if( A[K-1] != 2 ){
    		cout << -1 << endl;
    		return 0;
    	} 
    	B[K-1] = 1;
    	C[K-1] = 1;
    	for( i=K-2;0<=i;i-- ){
    		if( A[i+1]*(C[i+1]+1) <= A[i] ){
    			cout << -1 << endl;
    			return 0;
    		}
    		B[i] = (A[i+1]*B[i+1])/A[i];
    		if( A[i]*B[i] != A[i+1]*B[i+1] ){
    			B[i]++;
    		}
    		C[i] = (A[i+1]*C[i+1]+A[i+1]-1)/A[i];
			if( B[i] > C[i] ){
    			cout << -1 << endl;
    			return 0;
            }
    	}
    	/*
    	xianshi xianzai de qingkuang
    	for( i=0; i<K; i++ ){
    		cout << i << ": " << B[i] << " und " << C[i] << "\n";
    	}
    	*/
    	cout << A[0] * B[0] << endl;
    	cout << A[0] * (C[0]+1) - 1 << endl;
    	return 0;
    }

Measured memory_bytes: 2560
#include<stdio.h>

long long sums[1000000];

int main(){
		int n,i,k,j,c=0;
		long long ans,x,a[1000];
		scanf("%d%d",&n,&k);
		for(i=0;i<n;i++)scanf("%lld",&a[i]);
		for(i=0;i<n;i++){
				for(j=i;j<n;j++){
						if(j>i)sums[c]=sums[c-1]+a[j];
						else sums[c]=a[j];
						c++;
				}
		}
		int t;
		x=0;
		long long ki=1;
		for(i=0;i<40;i++)ki*=2;
		for(t=0;t<41;t++){
						int co=0;
						for(i=0;i<c;i++){
								if(((x+ki)&sums[i])==(x+ki))co++;
						}
						if(co>=k)x+=ki;
				ki/=2;
		}
		printf("%lld\n",x);
		return 0;
}


Measured memory_bytes: 4224
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var a     = int.Parse(spl[0]);
        var b     = int.Parse(spl[1]);

        return Lcm(a, b);
    }

    static long Gcd(long m, long n) {
        //ユークリッド互除法
        if (m < n) {var t=m; m=n; n=t;}

        while (true) {
            var mod = m % n;
            if (mod == 0) return n;
            m = n;
            n = mod;
        }
    }
    static long Lcm(long m, long n){
        var gcd = Gcd(m,n);
        return (m*n)/gcd;
    }
}


Measured memory_bytes: 11092
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type rec struct {
	v, idx int
}
type recs []rec

func (r recs) Len() int {
	return len(r)
}
func (r recs) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

type byIdx struct {
	recs
}
type byValue struct {
	recs
}

func (b byIdx) Less(i, j int) bool {
	return b.recs[i].idx < b.recs[j].idx
}
func (b byValue) Less(i, j int) bool {
	return b.recs[i].v < b.recs[j].v
}

func main() {
	var N int
	fmt.Scan(&N)
	X := make([]rec, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := range X {
		sc.Scan()
		X[i].v, _ = strconv.Atoi(sc.Text())
		X[i].idx = i
	}
	sort.Sort(byValue{X})
	m1 := X[len(X)/2-1].v
	m2 := X[len(X)/2].v
	sort.Sort(byIdx{X})
	for i := 0; i < len(X); i++ {
		if X[i].v <= m1 {
			fmt.Println(m2)
		} else {
			fmt.Println(m1)
		}
	}
}


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

using ll = long long;

int main() {
	string code = "CODEFESTIVAL2016";
	string s;
	cin >> s;

	int cnt = 0;
	for (int i = 0; i < 16; i++) {
		if (s[i] != code[i]) {
			cnt++;
		}
	}
	
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int A = sc.nextInt();
	int B = sc.nextInt();
	int C = sc.nextInt();

	if(A+B>=C){
	    System.out.println("Yes");
	} else {
	    System.out.println("No");
	}
    }
}
	


Measured memory_bytes: 21460
def solve():
    S = input()
    T = input()
    N = len(S)
    M = 2 * N
    S += S
    nxt = [[M] * 26 for i in range(M + 1)]
    for i in range(M - 1, -1, -1):
        for j in range(26):
            nxt[i][j] = nxt[i + 1][j]
        nxt[i][ord(S[i]) - ord('a')] = i
    ans = -1
    for c in T:
        i = ans % N
        pos = ord(c) - ord('a')
        if nxt[i + 1][pos] == M:
            return -1
        ans += nxt[i + 1][pos] - i
    return ans + 1

print(solve())


Measured memory_bytes: 132892
H, W = map(int, input().split())		# 5 7

M=[]
A=[0]*(W+1)
M.append(A)

for i in range(H):
	A=list( map(int, input().split()) )
	A=list(map(lambda x: x % 2, A))
	A=[0]+A
	M.append(A)

#print(M)

ANS=[]
A=[]
x=0
i=0
for h in range(1,H+1):
	x=0
	i=0
	for w in range(1,W+1):
		ans = "{} {} {} {}".format(h, w-1, h, w)
		i = M[h][w]
#		print("x,i={},{} ans={}".format(x,i,ans))
		
		#if (x==0)and(i==0): 
			
		if (x==1)and(i==0):
#			print("x,i={},{} ans={}".format(x,i,ans))
			A.append(ans)
			x=M[h][w-1]=0
			i=M[h][w]=1
		#elif (x==0)and(i==1): 
		elif (x==1)and(i==1):
#			print("x,i={},{} ans={}".format(x,i,ans))
			A.append(ans)
			for a in A:
				ANS.append(a)
			A=[]
			x=M[h][w-1]=0
			i=M[h][w]=0
			
		x = i

#print("A=>",A)
#print("M=>",M)
#print("ANS=>",ANS)

w=W
x=0
i=0
for h in range(1, H+1):
	ans = "{} {} {} {}".format(h-1, w, h, w)
	i=M[h][w]

	if (x==1)and(i==0):
		A.append(ans)
		x=M[h-1][w]=0
		i=M[h][w]=1
	
	elif (x==1)and(i==1):
		A.append(ans)
		for a in A:
			ANS.append(a)
		A=[]
		x=M[h-1][w]=0
		i=M[h][w]=0
	x = i

#print("A=>",A)
#print("M=>",M)
#print("ANS=>",ANS)

print(len(ANS))
for a in ANS:
	print(a)

Measured memory_bytes: 16060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const int N = 1<<17;
const ll INF= 1LL<<62;

class RMQ{
public:
  ll n,dat[2*N-1];
  RMQ(){
    n=N;
    for(int i=0;i<n;i++) dat[i]=INF;
  }
  
  void update(int k,ll a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
  }
  
  ll query(int a,int b,int k=0,int l=0,int r=N){
    if(r<=a||b<=l)return INF;
    if(a<=l&&r<=b)return dat[k];
    ll vl=query(a,b,k*2+1,l,(l+r)/2);
    ll vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
};


ll n,A,B;
vector<ll> num;
ll mem[N][2],used[N][2];
RMQ T;
int dfs(int pos,int flg){
  if(used[pos][flg]++)return mem[pos][flg];
  ll nx=pos+1,&res=mem[pos][flg]=0;
  if(flg==0){
    nx =lower_bound(num.begin()+pos+1,num.end(),num[pos]+A)-num.begin();
    if(nx-pos>1&&T.query(pos+1,nx-1)<B)return 0;
    if(nx>=n) return res=1;
    if(nx+1<n&&pos+1!=nx&&(num[nx+1]-num[nx-1])<B)return res=0;
    if(nx==pos+1||num[nx]-num[nx-1]>=B) res=(res+dfs(nx,1))%mod;
    res=(res+dfs(nx,0))%mod;
    return res;
  }

  else{
    if(nx<n&&(num[nx]-num[pos])>=B)res=(res+dfs(nx,1))%mod;
    if(nx+1>=n||num[nx+1]-num[nx-1]>=B)res=(res+dfs(nx,0))%mod;
    return res;
  }
}

int main(){
  cin>>n>>A>>B;
  if(A<B) swap(A,B);
  num.resize(n+1);
  for(int i=0;i<n;i++)cin>>num[i];
  num[n]=2*(1e18);
  for(int i=0;i<n;i++)T.update(i,num[i+1]-num[i]);
  ll ans=dfs(0,0)+dfs(0,1);
  cout<<ans%mod<<endl;
  return 0;
}


Measured memory_bytes: 15360
r, c = gets.split.map(&:to_i)

spreadsheet = []
i = 0
while true do
   if i == r
      break
   end
   spreadsheet << gets.split.map(&:to_i)
   i += 1
end

spreadsheet.each do |line|
   sum = 0
   line.each do |val|
      sum += val
   end
   line << sum
end

new_line = []
c = c + 1
c.times do |i|
   new_sum = 0
   r.times do |j|
      new_sum += spreadsheet[j][i]
   end
   new_line << new_sum
end
spreadsheet << new_line

spreadsheet.each do |spread|
   spread.each_with_index do |num, idx|
      if idx == (c - 1)
         print "#{num}"
      else
         print "#{num} "
      end
   end
   puts
end

Measured memory_bytes: 8948
#include<iostream>

using namespace std;

int main(void){
    int N;
    cin >> N;
    int ans = 0;
    for(int i=0;i<N;i++){
        int l, r;
        cin >> l >> r;
        ans += r-l+1;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int l = s.size();
  
  cout << s.at(0) << l-2 << s.at(l-1) << endl;
  //string ans = s.at(0) + static_cast<string>(l - 2) + s.at(l-1);
  //cout << ans << endl;
}

Measured memory_bytes: 256
import collections
n=int(input())
a=list(map(int,input().split()))

b=[]
for i in range(n):
    b.append(a[i]-i)

c = collections.Counter(b)

m=0
for i in range(n):
    m+=c[-(i+a[i])]
    c[a[i]-i]-=1
print(m)


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

int main() {
	string a,b,c;
	cin >> a >> b >> c;
	string k = "NO";
	if(a.at(a.size()-1) == b.at(0) && 
	   b.at(b.size()-1) == c.at(0))
	{
		k = "YES";
	}
    cout << k << endl;
}


Measured memory_bytes: 256
import heapq
N, M = map(int, input().split())

jobs = []
available = []
for _ in range(N):
    temp = tuple(map(int, input().split()))
    jobs.append(temp)

heapq.heapify(jobs)
ans = 0
for i in range(1, M+1):
    while(len(jobs)):
        a, b = heapq.heappop(jobs)
        if a == i:
            heapq.heappush(available, -b)
        else:
            heapq.heappush(jobs, (a, b))
            break
    if len(available):
        val = heapq.heappop(available)
        ans += -val

print(ans)

Measured memory_bytes: 16928
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = 0;
        for (int i = 0; i < 3; i++)
            s += sc.nextInt();
        if (s == 17)    System.out.println("YES");
        else System.out.println("NO");
    }
}


Measured memory_bytes: 9420
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
const int mod = 1e9 + 7;
const int N = 1 << 20;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, k;
    cin >> n >> k;
    if (k == 1) {
        cout << 0;
    } else {
        cout << n - k;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.La;
		var n=sc.I;
		while(s[0]>=s[1]){
			s[1]*=2;
			n--;
		}
		while(s[1]>=s[2]){
			s[2]*=2;
			n--;
		}
		Console.WriteLine("{0}",n>=0?"Yes":"No");
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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


int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if (a+b+c > 21){
    cout << "bust";
    return 0;
  }
  cout << "win";
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

struct Rectangle {
	int h;
	int p;  // position from left
};

int max_area_of_histgram(int n, vector<int>& height) {
	stack<Rectangle> S;

	/*  initialize  */
	int maxv = 0;

	for (int i = 0; i <= n; i++) {
		Rectangle rect;
		rect.h = height[i];
		rect.p = i;

		if (S.empty()) {
			S.push(rect);
		}
		else if (S.top().h < rect.h) {
			S.push(rect);
		}
		else if (S.top().h > rect.h) {
			int now = i;
			while (!(S.empty()) && (S.top().h >= rect.h)) {
				Rectangle pre_rect = S.top(); S.pop();
				maxv = max(maxv, pre_rect.h * (i - pre_rect.p));
				now = pre_rect.p;
			}
			rect.p = now;
			S.push(rect);
		}
	}
	return maxv;
}

int get_Largest_Rectangle(int H, int W, vector<vector<int>>& dp) {
	for (int h = 1; h < H; h++) {
		for (int w = 0; w < W; w++) {
			if (dp[h][w] == 0) continue;
			dp[h][w] = dp[h - 1][w] + 1;
		}
	}

	int maxv = 0;
	for (int h = 0; h < H; h++) {
		maxv = max(maxv, max_area_of_histgram(W, dp[h]));
	}
	return maxv;
}
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int H, W; cin >> H >> W;
	vector<vector<int>> c(H + 1, vector<int>(W + 1, 0)), dp(H + 1, vector<int>(W + 1, 0));

	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			cin >> c[h][w];
			if (c[h][w] == 0) { dp[h][w] = 1; }
			else { dp[h][w] = 0; }
		}
	}
	cout << get_Largest_Rectangle(H, W, dp) << endl;
	return 0;
}

Measured memory_bytes: 18244
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

int k;

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);
    scanf("%d",&k);

    int now=0;

    for(int i=1;i<=1000000;++i){
        now=(now*10+7)%k;
        if(now==0){
            printf("%d\n",i);
            return 0;
        }
    }

    puts("-1");


    return 0;
}

Measured memory_bytes: 3800
#include<stdio.h>
int main(){
	int a,b,c,d,e,f,g[500];
	scanf("%d",&a);
	if(a<3600){
	b=0;
	}else{b=a/3600;}
	c=a/60;
	while(1){
		if(c>=60){
			c-=60;
		}
		if(c<60){
			break;
		}
	}
	while(1){
		if(a>=60){
			a-=60;
		}
		if(a<60){
			break;
		}
	}


	printf("%d:%d:%d\n",b,c,a);
	
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m,in1,in2;
	cin>>n>>m;
	vvi v(n);
	rep(i,m){
		cin>>in1>>in2;
		v[in1-1].push_back(in2-1);
		v[in2-1].push_back(in1-1);
	}
	int ans=0;
	vi ta(n,0);
	rep(i,n){
		if(ta[i]==0){
			ll ang=0,dev=0;
			ta[i]=-1;ang++;
			queue<int> q;
			q.push(i);
			while(!q.empty()){
				int t=q.front();q.pop();
				rep(j,v[t].size()){
					if(ta[t]==ta[v[t][j]]){
						cout<<n*(n-1)/2-m<<endl;
						return 0;
					}
					else if(ta[v[t][j]]==0){
						ta[v[t][j]]=-ta[t];
						(ta[v[t][j]]==1?dev++:ang++);
						q.push(v[t][j]);
					}
				}
			}
			cout<<dev*ang-m<<endl;
		}
	}

}


Measured memory_bytes: 6272
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		long count = 1000000000000001l;

		long n = nl() - 1l;
		String ans = "";
		while (true) {

			if (n / 26l == 0) {
				char tmp = (char) ('a' + (char) (n % 26l));
				ans += tmp;
				break;
			} else {
				char tmp = (char) ('a' + (char) (n % 26l));
				ans += tmp;
				n /= 26l;
			}
			n--;

		}

		StringBuilder sb = new StringBuilder(ans);
		System.out.println(sb.reverse());

	}

	/*
	 * 以下メソッド集
	 */
	static int[] sort(int[] n) {
		Arrays.sort(n);
		return n;
	}

	static long[] sort(long[] n) {
		Arrays.sort(n);
		return n;
	}

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int account(String str) {
		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static double min(double d, double e) {
		return Math.min(d, e);
	}

	static int min(int a, int b) {
		return (int) Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 39444
#include<bits/stdc++.h>
using namespace std;
map<string,int> a;
#define ll long long
int main()
{
	int n,num=0;
	string s;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(a[s]==0)
		{
		    num++;
			a[s]++;	
		} 
		else
		a[s]++;
	}
	cout<<num;
    return 0;
}


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

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1e18 + 10;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }

bool judge(vector<ll>& v){
    bool fg = true;
    if(v.size()%2==0){
        int num = 1;
        rep(i, v.size()){
            if(v[i] != num)fg = false;
            if(i%2==1)num +=2;
        }
    }else{
        if(v[0]!=0)fg=false;
        int num = 2;
        rept(i, 1, v.size()){
            if(v[i] != num)fg = false;
            if(i%2==0)num += 2;
        }
    }
    return fg;
}
ll modpow(ll num, int a){
    if(a==0)return 1;
    ll res = 1;
    rep(i, a){
        res = res * num % MOD;
    }
    return res;
}

int main(){ 
    int n; cin >> n;
    vector<ll> A(n); rep(i, n) cin >> A[i];
    sort(all(A));
    if(!judge(A))cout << 0 << ln;
    else{
        cout << modpow(2, n/2) << ln;
    }
}

Measured memory_bytes: 1024