akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, d float64
	fmt.Scan(&a, &b, &c, &d)
	if math.Abs(c-a) <= d || (math.Abs(c-b) <= d && math.Abs(b-a) <= d) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

int main() {
	string S;
	long long int ans = 0;
	long long int cnt_b = 0;
	cin >> S;

	for (char c: S) {
		if (c == 'B')
			cnt_b++;
		else
			ans += cnt_b; 
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

enum FACE { TOP = 0, SOUTH = 1, EAST = 2, WEST = 3, NORTH = 4, BOTTOM = 5};
class Dice {
 public:
  Dice(int top, int south, int east, int west, int north, int bot) {
    id[TOP] = top;
    id[SOUTH] = south;
    id[EAST] = east;
    id[WEST] = west;
    id[NORTH] = north;
    id[BOTTOM] = bot;
  }
  Dice(vector<int> fs) {
    assert((int)fs.size() == 6);
    for (int i = 0; i < 6; i++) {
      id[i] = fs[i];
    }
  }
  int& operator[](FACE f) { return id[f]; }
  const int& operator[](FACE f) const { return id[f]; }
  bool operator==(const Dice& b) const {
    const Dice& a = *this;
    return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] && a[SOUTH] == b[SOUTH] &&
           a[NORTH] == b[NORTH] && a[WEST] == b[WEST] && a[EAST] == b[EAST];
  }
  // TOP -> SOUTH
  void roll_x() { roll(TOP, NORTH, BOTTOM, SOUTH); }
  // TOP -> EAST
  void roll_y() { roll(TOP, WEST, BOTTOM, EAST); }
  // SOUTH -> WEST
  void roll_z() { roll(SOUTH, EAST, NORTH, WEST); }
  vector<Dice> all_rolls() {
    vector<Dice> ret;
    for (int k = 0; k < 6; (k & 1 ? roll_y() : roll_x()), ++k)
      for (int i = 0; i < 4; roll_z(), ++i) ret.push_back(*this);
    return ret;
  }
  bool equivalent_to(const Dice& di) {
    for (int k = 0; k < 6; (k & 1 ? roll_y() : roll_x()), ++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        if (*this == di) return true;
    return false;
  }

 private:
  void roll(FACE a, FACE b, FACE c, FACE d) {
    auto tmp = id[a];
    id[a] = id[b];
    id[b] = id[c];
    id[c] = id[d];
    id[d] = tmp;
  }
  int id[6];
};

int main() {
  vector<int> v1(6), v2(6);
  for (int i = 0; i < 6; i++) cin >> v1[i];
  for (int i = 0; i < 6; i++) cin >> v2[i];
  auto dc1 = Dice(v1);
  auto dc2 = Dice(v2);
  cout << (dc1.equivalent_to(dc2) ? "Yes" : "No") << endl;
}



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

using namespace std;

int main(){
	int N, M, C, total, count = 0;
	int A[20][20];
	int B[20];
	cin >> N >> M >> C;
	for(int i = 0; i < M; i++){
		cin >> B[i];
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			cin >> A[i][j];
		}
	}	
	for(int i = 0; i < N; i++){
		total = 0;
		for(int j = 0; j < M; j++){
			total += A[i][j] * B[j];
		}
		if(total + C > 0) count++;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll N,W[300001],E[300001],ans=3000000;
string S;

int main(void){
    cin >> N >> S;
    W[0]=0;E[0]=0;
    for(ll i=1;i<=N;i++){
        W[i] =W[i-1]+(S[i-1]=='W');
        E[i]= E[i-1]+(S[i-1]=='E');
    }
    for(ll i=1;i<=N;i++)ans = min(ans,W[i-1]+E[N]-E[i]);
    //rep(i,N)cout << W[i] << " " << E[i] << endl;
    cout << ans << endl;
}


Measured memory_bytes: 5380
a,v=map(int, input().split()) 
b,w=map(int, input().split()) 
t = int(input())
dis=abs(a-b)
if(a==b):
    print('YES')
elif(v<=w):
    print('NO')
else:
    vel=v-w
    if(dis>vel*t):
        print('NO')
    else:
        print('YES')


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

int a[100+1];
int main(){
	int n,s=0;
	cin>>n;
	for(int i=1; i<=n; i++){
		int x;
		cin>>x;
		a[x]=1;
	}
	for(int i=1; i<=100; i++){
		s+=a[i];
	}
	cout<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 256
//@formatter:off
#include<bits/stdc++.h>
#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 rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?"":","); return os<<']'; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vi a(n), b(n);
    cin >> a >> b;
    queue<int> q;
    vb same(n);
    rep(i, n) {
        same[i] = (a[i] == b[i]);
    }
    auto push = [&](int i) {
        int sum = b[(i - 1 + n) % n] + b[(i + 1) % n];
        if (sum < b[i] and !same[i]) q.push(i);
    };
    rep(i, n) push(i);
    ll ans = 0;
    while (q.size()) {
        int i = q.front();
        q.pop();
        int sum = b[(i - 1 + n) % n] + b[(i + 1) % n];
        if (sum >= a[i]) {
            ans += b[i] / sum;
            b[i] %= sum;
            if (b[i] == 0) {
                b[i] = sum;
                ans--;
            }
            if (b[i] < a[i]) {
                cout << -1 << endl;
                return 0;
            }
        } else {
            int d = b[i] - a[i];
            if (d % sum != 0) {
                cout << -1 << endl;
                return 0;
            }
            ans += d / sum;
            b[i] = a[i];
            same[i] = true;
        }
        push((i - 1 + n) % n);
        push((i + 1) % n);
    }
    if (a == b) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;
int dp[100010] = {};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    rep(i, 0, n + 1) dp[i] = INF;
    dp[0] = 0;
    vector<int> d;
    d.push_back(1);
    for(int i = 6; i <= n; i *= 6){
        d.push_back(i);
    }
    for(int i = 9; i <= n; i *= 9){
        d.push_back(i);
    }
    rep(i, 0, d.size()){
        rep(j, 0, n + 1){
            if(j + d[i] > n) break;
            chmin(dp[j + d[i]], dp[j] + 1);
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
    int n;
    while(cin >> n && n!=0){
        int sum=0;
        for(int i=0;i<n/4;++i){
            int a;
            cin >> a;
            sum+=a;
        }
        cout << sum <<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */
ll bpow(ll a , ll b){
  if (b == 0) return 1;
  ll ret;
  if (b%2 == 0){
    ll  t = bpow(a, b/2);
    ret = t*t;
  }else{
    ll t = bpow(a, (b-1)/2);
    ret = a*t*t;
  }
  return ret;
}

int main() {
  vector<ll> a(3);
  REP(i, 3) cin >> a[i];
  sort(ALL(a));
  ll k; cin >> k;
  cout << a[0] + a[1] + a[2] * bpow(2, k) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var len = str.Length / 2;
            var head = str.Substring(0, len);
            var tail = new string(str.Reverse().Take(len).ToArray());

            var cnt = 0;
            for (var i = 0; i < len; i++)
            {
                if (head[i] != tail[i]) cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 26744
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int n,m; cin>>n>>m;
  int ans=0;
  if(n>1){
    ans+=n*(n-1)/2;
  }
  if(m>1){
    ans+=m*(m-1)/2;
  }
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

signed main(){
    
    int n; cin >> n;
    string s; cin >> s;
    int G[10][10] = {};
    for(int i = 1; i < n; i++){
        int cur = (int)(s[i - 1] - '0');
        int nxt = (int)(s[i] - '0');
        G[cur][nxt]++;
    }
    
    vector<int> vec(9);
    for(int i = 0; i < 9; i++) vec[i] = i + 1;
    int ans = INF;
    vector<int> ansV(9);
    
    do{
        int phone[3][3];
        for(int j = 0; j < 3; j++){
            for(int i = 0; i < 3; i++){
                phone[i][j] = vec[3 * j + i];
            }
        }

        int cost = 0;
        for(int ci = 0; ci < 3; ci++){
            for(int cj = 0; cj < 3; cj++){
                for(int ni = 0; ni < 3; ni++){
                    for(int nj = 0; nj < 3; nj++){
                        int cur = phone[ci][cj];
                        int nxt = phone[ni][nj];
                        int dis = (int)abs(ci - ni) + (int)abs(cj - nj);
                        cost += G[cur][nxt] * dis;
                    }
                }
            }
        }

        if(cost < ans){
            ans = cost;
            ansV = vec;
        }

    }while(next_permutation(vec.begin(), vec.end()));
    
    for(int j = 0; j < 3; j++){
        for(int i = 0; i < 3; i++){
            cout << ansV[3 * j + i];
        }
        cout << endl;
    }
    return 0;
}


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

int main(){
  string N;
  cin >> N;
  int b=N.size();
  vector<int> vec(b,0);
  int cnt=0,cnt1=0,cnt2=0;
  
  cnt=0;cnt1=0;cnt2=0;
  for(int i=0;i<b;i++){
    if(N[i]=='R'){
      cnt++;
      if(cnt%2==0){
        cnt1++;
      }
      else{
        cnt2++;
      }
    }
    else{
      cnt=0;
      if(N[i-1]=='R'){
        vec[i]+=cnt1;
        vec[i-1]+=cnt2;
        cnt1=0;
        cnt2=0;
      }
    }
  }
  
  reverse(N.begin(),N.end());
  for(int i=0;i<b;i++){
    if(N[i]=='L'){
      cnt++;
      if(cnt%2==0){
        cnt1++;
      }
      else{
        cnt2++;
      }
    }
    else{
      cnt=0;
      if(N[i-1]=='L'){
        vec[b-i-1]+=cnt1;
        vec[b-i]+=cnt2;
        cnt1=0;
        cnt2=0;
      }
    }
  }
  for(int i=0;i<b;i++){
    cout << vec[i] << ' ';
  }
}


  

Measured memory_bytes: 3844
<?php
// $s = trim(fgets(STDIN));

$input = explode(' ', trim(fgets(STDIN)));
$H = (int)$input[0];
$W = (int)$input[1];
$input = explode(' ', trim(fgets(STDIN)));
$h = (int)$input[0];
$w = (int)$input[1];

echo $H*$W - ($h * $W) - ($w * $H) + ($h*$w);

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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 long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int n, A, B, C;
vector<int> l;

int rec(int i, int a, int b, int c)
{
    if (i == n)
    {
        if (!a || !b || !c) return MOD;
        return abs(a - A) + abs(b - B) + abs(c - C);
    }

    int ans = rec(i + 1, a, b, c);

    chmin(ans, rec(i + 1, a + l[i], b, c) + (a ? 10 : 0));
    chmin(ans, rec(i + 1, a, b + l[i], c) + (b ? 10 : 0));
    chmin(ans, rec(i + 1, a, b, c + l[i]) + (c ? 10 : 0));

    return ans;
}

int main()
{
    cin >> n >> A >> B >> C;
    l.resize(n);
    rep(i, n) cin >> l[i];

    cout << rec(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
k,x=map(int, input().split())

for i in range(-k+1,k):
  if(x+i==-1000000) and (x+i-1<-1000000):
    print(x+i,end=" ")
  elif (x+i==1000000) and (x+i+1>-1000000):
    print(x+i,end=" ")
  elif(-1000000<x+i<1000000):
    print(x+i,end=" ")


Measured memory_bytes: 3060
n = int(input())
s = [input() for i in range(n)]

from collections import Counter
c = Counter(s).most_common()
l =[c[0][0]]
for i in range(1,len(c)):
    if c[i][1]==c[0][1]:
        l.append(c[i][0])
l = sorted(l)
for j in range(len(l)):
    print(l[j])

Measured memory_bytes: 45068
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0;i < s.length();++i){
		string a,b;
		for(int q = 0;q <= i;++q){
			a.push_back(s[q]);
		}
		for(int q = i+1;q < s.length();++q){
			b.push_back(s[q]);
		}
		int cnt[2][27] = {};
		for(int i = 0;i < a.length();++i){
			cnt[0][a[i] - 'a']++;
		}
		for(int i = 0;i < b.length();++i){
			cnt[1][b[i] - 'a']++;
		}
		int pre_ans = 0;
		for(int i = 0;i < 27;++i){
			if(cnt[0][i] != 0&&cnt[1][i] != 0){
				pre_ans++;
			}
		}
		ans = max(ans,pre_ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pair<int,int>>

int main(){
    ios::sync_with_stdio(0);
    ll n;
    cin >> n;
    if (n%2==1){
        cout << 0;
        return 0;
    }
    n /= 2;
    n -= n%5;
    ll ans = n/5, b = 5;
    while(true){
        b *= 5;
        if (b > n)
            break;
        ans += (n/b);
    }

    cout << ans;
    return 0;
}


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

using namespace std;

int main(){
	int a,b,c,d,e,f,g,h,sum=0,suma=0;
	cin >> a>>b>>c>>d>>e>>f>>g>>h;
	if(a/10>0)sum+=(a/10)*g;
	if(b/20>0)sum+=(b/20)*h;
	if(c/10>0)suma+=(c/10)*g;
	if(d/20>0)suma+=(d/20)*h;

	sum+=(a*e)+(b*f);
	suma+=(c*e)+(d*f);

	if(sum>suma)cout<<"hiroshi"<<endl;
	else if(sum<suma)cout<<"kenjiro"<<endl;
	else cout<<"even"<<endl;
	return 0;
}


Measured memory_bytes: 3136
/// 25-01-2018
/// MD:NUR ALAM
/// Eastern University of Bangladesh

#include "bits/stdc++.h"

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = (a); i < (b); ++i)
#define fo(i, a, b) for (int i = (a); i <(b); ++i)
#define fors(i, s) for (int i = 0; s[i]; ++i)
#define rs(x) scanf("%s", (x))
#define mp make_pair
#define pb push_back
#define mso(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define len(X) strlen(x)

using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef long double lu;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpll;
typedef pair<int,int> Pll;
typedef map<string,int>msi;
typedef set<int>se;

template<class t> void _r(t &x) { cin >> x; }
void _r(int &x) { scanf("%d", &x); }
void _r(int64_t &x) { scanf("%lld", &x); }
void _r(double &x) { scanf("%lf", &x); }
void _r(char &x) { scanf(" %c", &x); }
void _r(char *x) { scanf("%s", x); }
void r() {}
template<class t, class... u> void r(t &head, u &... tail) { _r(head); r(tail...); }
template<class t> void _w(const t &x) { cout << x; }
void _w(const int &x) { printf("%d", x); }
void _w(const int64_t &x) { printf("%lld", x); }
void _w(const double &x) { printf("%.16f", x); }
void _w(const char &x) { putchar(x); }
void _w(const char *x) { printf("%s", x); }
template<class t,class u> void _w(const pair<t,u> &x) {_w(x.f); putchar(' '); _w(x.s);}
void w() {}
template<class t, class... u> void w(const t &head, const u &... tail) { _w(head); putchar(sizeof...(tail) ? ' ' : '\n'); w(tail...); }
template<class t, class... u> void debug(const t &head, const u &... tail) {
#ifdef HOME
#endif
}

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


int main()
{
   ll a,b,c,d,x=0,y=0;
   r(a,b,c,d);
   x=a+b;
   y=c+d;
   if(x>y) w("Left");
   else if(x<y) w("Right");
   else w("Balanced");
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int K;
    cin >> K;
    int T;
    cin >> T;
    int a[T];
    for (int i=0;i<T;i++){
        cin >> a[i];
    }
    sort(a,a+T);
    vector<int> seq(K,-1);
    
    int sum = -1;
    for (int i=0;i<a[T-1];i++){
        sum++;
        seq[i] = T-1;
    }
    for (int i=T-2; i>=0; i--){
        for (int t=0;t<a[i];t++){
            bool insert_flag = false;
            int insert_idx = 0;
            for (int j=sum;j>0;j--){
                if ( i!=seq[j] && i!=seq[j-1]){
                    insert_idx = j;
                    if (seq[j]==seq[j-1]){
                        seq.insert(seq.begin()+j,i);
                        insert_flag = true;
                        break;
                    }
                }
            } 
            if (!(insert_flag)) seq.insert(seq.begin()+insert_idx,i);
            sum++;
        }
    }

    int count = 0;
    for(int i=1;i<K;i++){
        if (seq[i]==seq[i-1]) count++;
    }
    cout << count << endl;
    
    //for (int i=0;i<K;i++){
    //    cout << seq[i];
    //}
    //cout << endl;



}


Measured memory_bytes: 384
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
  A[i]-= i+1
A.sort()
total = sum(A)
mean1 = total//N
mean2 = total//N + 1
med1 = A[N//2]
#med2 = A[N//2+1]
ans1 = 0
ans2 = 0
ans3 = 0
ans4 = 0 
for a in A:
  ans1+=abs(a-mean1)
  ans2+=abs(a-mean2)
  ans3+=abs(a-med1)
  #ans4+=abs(a-med2)
print(min([ans1,ans2,ans3]))

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

int main(){
  char l[10][6]={{}, {".,!? "}, {"abc"}, {"def"}, {"ghi"}, {"jkl"}, {"mno"}, {"pqrs"}, {"tuv"}, {"wxyz"}};
  //char **l={{}, {".,!? "}, {"abc"}, {"def"}, {"ghi"}, {"jkl"}, {"mno"}, {"pqrs"}, {"tuv"}, {"wxyz"}};
  int n;
  cin >> n;
  for(int k=0;k<n;k++){
    char c[1025];
    cin >> c;
    int size=0;
    for(int i=0;i<1025;i++){
      if(c[i]=='\0'||c[i]=='\n'){
        break;
      }
      size++;
    }

    int count=0;
    for(int i=0;i<size;i++){
      if(c[i]=='0'){
        if(i!=0){
          int num = (int)(c[i-1]-'0');
          int s=0;
          for(int j=0;j<7;j++){
            if(l[num][j]=='\0'){
              s=j;
              break;
            }
          }
          if(c[i]!=c[i-1])
            cout << l[num][(count-1)%s];
          count=0;
        }
      }else{
        count++;
      }
    }


    /*for(int i=1;i<size;i++){
      if(c[i-1]=='0'&&c[i]=='0') continue;
      else if(c[i-1]!='0'&&(c[i-1]==c[i]||c[i]!='0')){
      count++;
      }else if(c[i]=='0'){
      int s=0;
      int num = (int)(c[i-1]-'0');
      if(num==0) continue;
      for(int j=0;j<7;j++){
      if(l[num][j]=='\0'){
      s=j+1;
      break;
      }
      }
    //int num = static_const<int>(c[i-1]);
    if(s!=0)cout << l[num][count%s];
    count=0;
    }
    if(i==size-1) cout << endl;
    }*/

    cout << endl;
    for(int i=0;i<1025;i++){
      c[i]='\0';
    }
  }
  return 0;
}

Measured memory_bytes: 1156
#include<cstdio>
#include<algorithm>
//dp[i]=i個のどんぐりを使って取引所A→Bを使ったあとのどんぐりの個数の最大値
long long dp[5001];
//dp2[i]=i個のどんぐりを使って取引所B→Aを使ったあとのどんぐりの個数の最大値
long long dp2[5000*5000+1];
int main(){
    long long n,a[3],b[3];
    scanf("%lld",&n);
    for(int i=0;i<3;i++)scanf("%lld",&a[i]);
    for(int i=0;i<3;i++)scanf("%lld",&b[i]);
    dp[0]=0;
    for(int i=1;i<=n;i++){
        dp[i]=dp[i-1]+1;
        for(int j=0;j<3;j++){
            if(a[j]<=i)dp[i]=std::max(dp[i],dp[i-a[j]]+b[j]);
        }
    }
    dp2[0]=0;
    for(int i=1;i<=dp[n];i++){
        dp2[i]=dp2[i-1]+1;
        for(int j=0;j<3;j++){
            if(b[j]<=i)dp2[i]=std::max(dp2[i],dp2[i-b[j]]+a[j]);
        }
    }
    printf("%lld\n",dp2[dp[n]]);
    return 0;
}

Measured memory_bytes: 195456
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String convertString = sc.nextLine();
		String matchString = sc.nextLine();
		char[] convertChar = convertString.toCharArray();
		String okay = "No";
		for(int i = 0; i< convertChar.length ; i++) {
			char sorttemp = convertChar[convertChar.length-1]; 
			for(int j = convertChar.length -1; j >= 1  ; j--) {
				convertChar[j] = convertChar[j-1]; 
			}
			convertChar[0] = sorttemp;
			String convertedString = String.valueOf(convertChar);
			if(convertedString.equals(matchString)) {
				okay = "Yes";
			}
		}
		System.out.println(okay);
	}

}


Measured memory_bytes: 25172
/******************************\
*  Everyone has a different way of thinking, so God Created us
Hope You Respect My Way..,Thank You ):  *
*                            *
*   Created by : Murad   *
\******************************/
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define MP make_pair
#define ff first
#define ss second
#define INF 2147483647
#define _INF -2147483647
#define pq priority_queue
#define MM multimap
#define PB push_back
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
LL MMIN(LL a, LL b)
{
	if (a <= b)
		return a;
	else
		return b;
}
LL MMAX(LL a, LL b) {
	if (a >= b)
		return a;
	else
		return b;
}
int main()
{
	int n, k;
	cin >> n >> k;
	string ans = "";
	vector<string>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++)ans += a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
#define dump(x)  cout << " "<< #x << " = " << (x) << endl;
typedef long long ll;
typedef complex<int> P;
const double EPS = 1e-10;
const double PI  = acos(-1.0);


const int MAXN = 1e6;
int ans[MAXN], ans2[MAXN];

vector<int> v, v2;
void f(vector<int> &v, int ans[]){
	for(int i=0;i<MAXN;i++){
		ans[i] = i;
	}
	for(int i=1;i<v.size();i++){
		for(int j=v[i];j<MAXN;j++){
			ans[j] = min(ans[j], ans[j - v[i]] + 1);
		}
	}
	return;
}
void ini(){
	for(int i=1;i<MAXN;i++){
		int a = i * (i+1) * (i+2) / 6;
		if(a > MAXN) break;
		v.pb(a);
		if(a%2) v2.pb(a);
	}
	f(v, ans);
	f(v2, ans2);
	return;
}

bool solve(int n){
	
	cout<< ans[n]<< " "<< ans2[n]<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	ini();
	int n;
	while(cin>> n, n) solve(n);
	return 0;
}

 

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

ll cnt[26] = {0,};

int main() {
    string a;
    cin >> a;
    ll ans = (a.size() * (a.size()-1))/2 + 1;
    for(int i = 0; i < a.size(); i++){
        cnt[a[i]-97]++;
    }
    for(int i = 0; i < 26; i++){
        ans -= cnt[i]>1 ? (cnt[i]*(cnt[i]-1))/2 : 0LL;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

int main()
{
	string str;
	int n, a, b;
	cin >> n >> a >> b;

	int c = a + b;

	char x;

	for (int i = 0; i < n; i++)
	{
		cin >> x;

		if ((x == 'a') && (c > 0))
		{
				cout << "Yes" << endl;
				if (a > 0)
					a--;
				else if (b > 0)
					b--;
		}
		else if ((x == 'b') && (b > 0))
		{	
			cout << "Yes" << endl;
			b--;
		}
		else
		{
			cout << "No" << endl;
		}
		c = a + b;
	
	}


	//cout << cnt << endl;

	//		sort(c, c + n, greater<int>()); //降順ソート

	return 0;
}

Measured memory_bytes: 640
import sys
s=input()
n=len(s)
p=[0 for _ in range(n)]

for i in range(n):
    if s[i]=="L": p[i]=p[i-1]-1 if s[i-1]=="L" else -1
for i in range(n-1,-1,-1):
    if s[i]=="R": p[i]=p[i+1]+1 if s[i+1]=="R" else 1

ans=[0]*n
for i in range(n):
    if p[i]>0:
        ans[i+(p[i]//2)*2]+=1
    else:
        if p[i]%2==0: ans[i+p[i]]+=1
        else: ans[i+p[i]+1]+=1
print(*ans)

Measured memory_bytes: 49280
import java.util.*;

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

        int n = sc.nextInt();
        int l = sc.nextInt();

        int sum = 0;

        for(int i = 0; i < n; i++){
            sum += l + i;
        }

        if(n + l <= 0){
            System.out.println(sum - (n + l - 1));
        }else if(l < 0){
            System.out.println(sum);
        }else{
            System.out.println(sum - l);
        }

    }
}


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

#define MAX 100005
#define NIL -1

struct Node{
    int p, l, r;
};

Node T[MAX];
int n, D[MAX];

void print(int u){
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if(T[u].p == NIL)       cout << "root";
    else if(T[u].l == NIL)  cout << "leaf";
    else                    cout << "internal node";
    cout << ", ";

    cout << "[";

    int c;
    for(int i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
        if(i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

int rec(int u, int p){
    D[u] = p;
    if(T[u].l != NIL)   rec(T[u].l, p+1);
    if(T[u].r != NIL)   rec(T[u].r, p);
}

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        T[i].p = T[i].l = T[i].r = NIL;
    }

    for(int i = 0; i < n; i++){
        int v, d, c, l;
        cin >> v >> d;
        for(int j = 0; j < d; j++){
            cin >> c;
            if(j == 0){
                T[v].l = c;
            }else{
                T[l].r = c;
            }
            l = c;
            T[c].p = v;
        }
    }

    int r;
    for(int i = 0; i < n; i++){
        if(T[i].p == NIL)   r = i;
    }

    rec(r, 0);

    for(int i = 0; i < n; i++){
        print(i);
    }

    return 0;
}


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

int main(){
  int n;cin>>n;
  string s;cin>>s;
  int k;cin>>k;
  char l = s[k-1];
  fol(i,n){
    if(s[i]!=l){
      s[i]='*';
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int n,m,a[202],b[202];
int main() {
  int i,j,l,o;
  scanf("%d%d",&n,&m);
  for(i=0;i<2*n;++i) a[i] = i+1;
  for(l=0;l<m;++l) {
    scanf("%d",&o);
    if (o) {
      for(i=0;i<2*n-o;++i) b[i] = a[i+o];
      for(i=0;i<o;++i) b[i+2*n-o] = a[i];
    } else {
      for(i=0;i<n;++i) {
        b[2*i] = a[i];
        b[2*i+1] = a[i+n];
      }
    }
    for(i=0;i<2*n;++i) a[i] = b[i];
  }
  for(i=0;i<2*n;++i) printf("%d\n", a[i]);
  return 0;
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;

int main(){

	int n, m;
	int in,out;
	int max;

	cin >> n >> m;

	max = m;
	for (int i = 0; i < n; i++){
		cin >> in >> out;
		m = m + in - out;
		if (m < 0) max = -1;
		if (m>max&&max!=-1) max = m;
	}

	if (max == -1) max = 0;
	cout << max << endl;

	return 0;
}

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

typedef long long ll;

int main(){

    int n,k,x,y;
    cin >> n >> k >> x >> y;
    
    int ans = 0;
    if( n > k ) {
	ans = k*x + (n-k)*y;
    }
    else{
	ans = n*x;
    }
	
    cout << ans << endl;
    

}


Measured memory_bytes: 256
#include<cstdio>

int main(){
	int x,y;
	scanf("%d%d",&x,&y);
	int ok = 0;
	for(int i = 0; i <= x; i++){
		int cnt = 2*i+(x-i)*4;
		if(cnt==y) ok = 1;
	}
	if(ok) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main(){
	int n,m;
	int a,b;
	int x[55];
	int i=0;
	for(i=0;i<55;i++){
		x[i]=0;
	}
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>a>>b;
		x[a]++;
		x[b]++;
	}
	for(i=1;i<n+1;i++){
		cout<<x[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
vector<ll> memo(1e5+5, -1);
ll dp(vector<int> &v, int i){
	if(i == v.size()-1)
		return 0;
	if(memo[i] != -1)
		return memo[i];
	if(i < v.size()-2)
		memo[i] = min(abs(v[i]-v[i+2]) + dp(v, i+2), abs(v[i]-v[i+1]) + dp(v, i+1));
	else
		memo[i] = abs(v[i]-v[i+1]) + dp(v, i+1);
	return memo[i];
}
signed main() { 
	cin.tie(0);
	cin.sync_with_stdio();
	int n; 
	cin>>n;
	vector<int> v(n);
	for(int &i : v)
		cin>>i;
	cout<<dp(v, 0);
}


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

int main() {
  int x,y,z;
  while(1){
    cin >> x >> y;
    if(x==0 && y==0)
      break;
    z=0;
    for(int i=1; i<=x; i++){
      for(int j=1; j<=x; j++){
        for(int k=1; k<=x; k++){
          if(i!=j && j!=k && k!=i){
            if(i+j+k==y){
              z++;
            }
          }
        }
      }
    }
    cout << z/6 << endl;
  }
}



Measured memory_bytes: 3064
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
    int n,i,j,x;
    long long int ans=0,a[200014],b[200014];
    b[0]=0;
    cin >> n;
    long long int MOD=1000000007;
    
    for(i=0;i<n;i++)
    {
        cin >> a[i];
    }
    for(i=1;i<n+1;i++)
    {
        b[i]=a[i-1]+b[i-1];
        b[i]=b[i]%MOD;
    }
    for(i=0;i<n;i++)
    {
        
        ans+=a[i]*(b[n]-b[i+1]+MOD)%MOD;
        ans=ans%MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6708
#include <bits/stdc++.h>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;

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

int factorization(int n){
    int fac_ans = 1.0;
    for(int i=1;i<=n;i++) fac_ans *= i;
    return fac_ans;
}

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define repr1(i, n) for (int i = n; i > 0; i--)
#define FOR(i, j, n) for (int i = j; i < n; i++)

typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 100000000;


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

    string alp = "zabcdefghijklmnopqrstuvwxy";
    string ans="";

    int64_t l=n,cnt=0;
    while(cnt<=100){
        if(l<=26){
            ans[cnt] = alp[l%26];
            cnt++;
            break;
        }
        ans[cnt]= alp[l%26];
        if(l%26==0){
            l = l/26 - 1;
        }else{
            l /= 26;
        }
        cnt++;
    }
    repr(i,cnt){
        cout << ans[i];
    }
    cout << endl;
}


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

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

    if (n % 2) // odd
    {
        cout << 0 << endl;
    }
    else
    {
        long long div = 10, ans = 0;
        while (n / div > 0)
        {
            ans += n / div;
            div *= 5;
        }
        cout << ans << endl;
    }    
}

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

using namespace std;

const int NMAX=200*1000;
int occurences[NMAX],n,k,a,different=0,m=0;
pair<int,int> nb[NMAX];

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

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

    for(int i=0;i<NMAX;i++){
        if(occurences[i]!=0){
            different++;
            nb[m]=make_pair(occurences[i],i);
            m++;
        }
    }

    sort(nb,nb+m);
    int i=0,total;
    while(different>k){
        total+=nb[i].first;
        different--;
        i++;
    }
    cout << total << endl;
}

Measured memory_bytes: 2560
n, k = map(int, input().split())
a = list(map(int, input().split()))

start = a.index(1) + 1
left = (start - 1) // (k - 1) + 1
new_start = (k - 1) * left + 1
right = (n - new_start - 1) // (k - 1) + 1
count = left + right
print(count)

Measured memory_bytes: 13880
# include <stdio.h>

int bubbleSort(int *A, int N) {
    int flag = 1, count=0, i=0;
    while(flag) {
        flag = 0;
        for (int j=N-1; j>i; j--) {
            if (A[j] < A[j-1]) {
                int tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                count++;
                flag = 1;
            }
        }
        i++;
    }
    return count;
}

void outputArray(int *A, int N) {
    printf("%d", A[0]);
    for (int i=1; i<N; i++) {
        printf(" %d", A[i]);
    }
    printf("\n");
}

int main() {
    int n;
    scanf("%d", &n);
    
    int a[n];
    for (int i=0; i<n; i++) scanf("%d", &a[i]);
    
    int count = bubbleSort(a, n);
    outputArray(a, n);
    printf("%d\n", count);
    
    return 0;
}


Measured memory_bytes: 2732
import java.util.Scanner;

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

	int N = sc.nextInt();
	char c[] = (sc.next()).toCharArray();

	char ABC[] = {'A', 'B', 'C'};
	int count = 0;
	int j = 0;
	for (int i = 0; i < N; i++) {
	    if (c[i] == ABC[j]) {
		j++;
	    } else {
		if (c[i] == 'A') {
		    j = 1;
		} else {
		    j = 0;
		}
	    }

	    if (j == 3) {
		j = 0;
		count++;
	    }
	}

	System.out.println(count);
    }
}

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

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

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

int main() {
  int R, G, B, N;
  ll ans = 0;
  cin >> R >> G >> B >> N;
  for (int r = 0; r * R <= N; r++){
    for (int g = 0; r * R + g * G <= N; g++){
      if((N - (r * R + g * G)) % B == 0)ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll x;
  cin >> x;
  cout << x/11*2 + (x%11+5)/6 << newl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    map<int, int> ans;
    
    for(int i = 0; i < N; i++){
        ans[i] = 0;
    }

    for(int i = 0; i < N-1; i++){
        int A;
        cin >> A;
        A--;
        ans[A]++;
    }
    
    for(auto A : ans){
        auto value = A.second;
        cout << value << endl;
    }
    
    
    
}


Measured memory_bytes: 12540
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

signed main(void) {
  int i,j,bit;
  string s;
  cin>>s;
  if(s.size()==1){
    cout<<s<<endl;
    return 0;
  }
  int n=s.size()-1;
  ll ans=0;
  rep(bit,1<<n){//+の位置
    int tmp=s[0]-'0';
    rep(j,n)
      if((bit&(1<<j))!=0)//+
	ans+=tmp,tmp=s[j+1]-'0';
      else
	tmp*=10,tmp+=s[j+1]-'0';
    ans+=tmp;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
a = 1
MOD = 10**9+7
cnt = 10**9
l = 0
for i in A:
  i = i//2
  a = lcm(a,i)
for i in A:
  cnt1=0
  b=i//2
  if b%2==0:
    while b%2==0:
      b=b/2
      cnt1+=1
  if cnt==10**9:
    cnt=cnt1
  elif cnt!=cnt1:
    print(0)
    exit()
print((M//a+2-1)//2)


Measured memory_bytes: 89580
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

int
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && a == c) cout << "Yes" << endl;
  else cout << "No" << endl;

  
    
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int min1(int [],int);
int max1(int [],int);
long int sum1(int [],int);
int min1(int w[],int x){
    int y=w[0];
    if(x>1){
        for(int z=1;z<x;z++){
            if(y>w[z]){
                y=w[z];
            }
        }
    }
    return y;
}
int max1(int b[],int c){
    int d=b[0];
    if(c>1){
        for(int e=1;e<c;e++){
            if(d<b[e]){
                d=b[e];
                }
        }
    }
    return d;
}
long int sum1(int f[],int g){
    long int h=f[0];
    if(g>1){
        for(int i=1;i<g;i++){
            h+=f[i];
        }
    }
    return h;
}
int main(void){
    int n,m,min,max;
    long int sum;
    scanf("%d",&n);
    int a[n];
    scanf("%d",&a[0]);
    if(n>1){
        for(m=1;m<n;m++){
            scanf(" %d",&a[m]);
        }
    }
    min=min1(a,n);
    max=max1(a,n);
    sum=sum1(a,n);
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}


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

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

    int N, K;
    cin >> N >> K;
    int cnt = 0;
    while (N > 0) {
        N /= K;
        cnt++;
    }
    cout << cnt << '\n';

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# モジュールのインポート
import math

# 標準入力を取得
A, B, C = list(map(int, input().split()))
K = int(input())

# 求解処理
ans = str()
k_b = 0
if A >= B:
    k_b = int(math.log(A / B) / math.log(2)) + 1
if k_b > K:
    ans = "No"
else:
    if 2**(K - k_b) * C > 2**k_b * B:
        ans = "Yes"
    else:
        ans = "No"

# 結果出力
print(ans)


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 998244353;

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

struct mint
{
  ll x; // typedef long long ll;
  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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= 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
  {
    mint res(*this);
    return res /= a;
  }
};

bool check(vector<P> s) {
  int h = 0;
  for(auto p : s) {
    int b = h+p.first;
    if(b < 0) return false;
    h += p.second;
  }
  return true;
}
int main()
{
  int n, k;
  ll s;
  cin >> n >> k >> s;
  vector<ll> a(n, 1);
  rep(i, k) a[i] = s;
  if(s < 1000000000ll) {
    for(int i = k; i < n; ++i) a[i] = s+1;
  }
  else {
    for(int i = k; i < n; ++i) a[i] = s-1;
  }
  rep(i, n) cout << a[i] << " ";
  cout << endl;
}

Measured memory_bytes: 2048
#include <stdio.h>
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if(a>b){
        printf("a > b\n");
    }else if(a<b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2096
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        a: [[i64; n]; n],
    }
    let mut gain = vec![0; 1 << n];
    for bits in 0 .. 1 << n {
        let mut sum = 0;
        for i in 0 .. n {
            if (bits & 1 << i) == 0 { continue; }
            for j in 0 .. i {
                if (bits & 1 << j) == 0 { continue; }
                sum += a[i][j];
            }
        }
        gain[bits] = sum;
    }
    let mut dp = vec![-1 << 60; 1 << n];
    dp[0] = 0;
    for bits in 0 .. 1 << n {
        for sub in 0 .. bits {
            if (sub & bits) != sub { continue; }
            dp[bits] = max(dp[bits], dp[sub] + gain[bits - sub]);
        }
    }
    puts!("{}\n", dp[(1 << n) - 1]);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572