akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=(1<<10);i>0;i/=2){
		if(i<=n){
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF=1e18,MOD=1e9+7;
ll GCD(ll a,ll b){
    ll hoge;
    do{
        hoge=a%b;
        a=b;b=hoge;
    }while(b!=0);
    return a;
}
ll LCM(ll a,ll b){
    return max(a,b)/GCD(a,b)*min(a,b);
}
int main(){
    ll n;
  cin>>n;
    vector<ll>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=1;i<n;i++)a[i]=LCM(a[i],a[i-1]);
	cout<<a[n-1]<<endl;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b,c,x,y; cin>>a>>b>>c>>x>>y;
  ll ans=a*x+b*y;
  chmin(ans,max(x,y)*c*2);
  if(x>y) swap(a,b), swap(x,y);
  chmin(ans,x*c*2+(y-x)*b);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>


int main(){
	int x;
	scanf("%d",&x);
	long long int sum = 0;
	for(int i = 1;i<=x;i++){
		if ( i % 3 !=0 && i % 5 !=0 && i % 15 !=0) sum+=i;
		
	}
	printf("%lld\n",sum);
	
	
	
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int cnt[26];
int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	string s;
	cin >> s;
	for (char c : s) {
		cnt[c - 'a']++;
	}
	int n = s.length();
	ll res = 1LL * n * (n - 1) / 2;
	for (int i = 0; i < 26; i++) {
		int x = cnt[i];
		res -= 1LL * x * (x - 1) / 2;
	}
	cout << res + 1 << endl;
}



Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

const int MAX_DIFF = (80 + 80) * 80;

vector<vector<int>> A;
vector<vector<int>> B;

vector<vector<vector<bool>>> dp;

void solve(const int H, const int W) {
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            const int diff = abs(A[i][j] - B[i][j]);
            // up
            {
                const vector<bool> &xs = dp[i - 1][j];
                for (int k = 0; k < (int) xs.size(); k++) {
                    if (xs[k]) {
                        dp[i][j][abs(k + diff)] = true;
                        dp[i][j][abs(k - diff)] = true;
                    }
                }
            }

            // left
            {
                const vector<bool> &xs = dp[i][j - 1];
                for (int k = 0; k < (int) xs.size(); k++) {
                    if (xs[k]) {
                        dp[i][j][abs(k + diff)] = true;
                        dp[i][j][abs(k - diff)] = true;
                    }
                }
            }
        }
    }
}

int main(void) {
    int H, W;
    cin >> H >> W;

    A.resize(H + 1, vector<int>(W + 1, 0));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int x;
            cin >> x;
            A[i + 1][j + 1] = x;
        }
    }

    B.resize(H + 1, vector<int>(W + 1, 0));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int x;
            cin >> x;
            B[i + 1][j + 1] = x;
        }
    }

    dp.resize(H + 2);
    for (int i = 0; i < H + 2; i++) {
        dp[i].resize(W + 2);
        for (int j = 0; j < W + 2; j++) {
            dp[i][j].resize(MAX_DIFF + 1, false);
        }
    }

    dp[0][0][0] = true;
    dp[1][0][0] = true;
    dp[0][1][0] = true;
    solve(H, W);

    for (int i = 0; i < (int) dp[H][W].size(); i++) {
        if (dp[H][W][i]) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define inf 10e7

int main(void) {
  int n, m, i, j, k;
  scanf("%d%d", &n, &m);
  int num = 1 << m;
  int *dp, f[n], numt[m], *sum, ssum[n][m];
  dp = (int*)malloc(sizeof(int) * num);
  sum = (int*)malloc(sizeof(int) * num);
  rep(i, m) {
    numt[i] = 0;
    rep(j, n) ssum[j][i] = 0;
  }
  rep(i, n) {
    scanf("%d", &f[i]);
    f[i]--;
    numt[f[i]]++;
    if(!i) ssum[i][f[i]] = 1;
    else {
      rep(j, m) ssum[i][j] = ssum[i - 1][j];
      ssum[i][f[i]]++;
    }
  }
  rep(i, num) sum[i] = 0, dp[i] = inf;
  rep(i, num) rep(j, m) {
    if(i & (1 << j)) sum[i] += numt[j];
  }
  dp[0] = 0;
  rep(i, num) {
    rep(j, m) {
      if(i){
        if(dp[i | (1 << j)] > dp[i] - ssum[sum[i | (1 << j)] - 1][j] + ssum[sum[i] - 1][j] + numt[j]) dp[i | (1 << j)] = dp[i] - ssum[sum[i | (1 << j)] - 1][j] + ssum[sum[i] - 1][j] + numt[j];
      } else {
        if(dp[i | (1 << j)] > dp[i] - ssum[sum[i | (1 << j)] - 1][j] + numt[j]) dp[i | (1 << j)] = dp[i] - ssum[sum[i | (1 << j)] - 1][j] + numt[j];
      }
    }
  }
  /*rep(i, n) {
    rep(j, m)printf("%d ", ssum[i][j]);
    printf("\n");
  }
  rep(i, m) printf("%d ", numt[i]);
  printf("\n");
  rep(i, num) printf("%d ", sum[i]);
  printf("\n");
  rep(i, num) printf("%d ", dp[i]);
  printf("\n");*/
  printf("%d\n", dp[num - 1]);
  free(dp);
  free(sum);
  return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  if (A <= 5)
    cout << 0 << endl;
  else if (A <= 12)
    cout << B / 2 << endl;
  else
    cout << B << endl;
}

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

int cal_num (vector<int> a, string &c, int m) {
  char x = c.at(m);

  if ( m == 2) {
    if( x == '1') return a.at(2) + a.at(3);
    return a.at(2) - a.at(3);
  }
  
  int s;
  if(x == '1') s = a.at(m) + a.at(m+1);
  else s = a.at(m) - a.at(m+1);
  a.at(m+1) = s;
  return cal_num ( a, c, m + 1);
}

int main() {
  int c = 7 + 1; 
  
  vector<string> cal(c);
  
  for(int i=0; i<c; i++) {
    stringstream ss;
    ss << bitset<3>(i);
    cal.at(i) = ss.str();
  }
  
  int N;
  cin >> N;
  vector<int> num(4);
  int j = 3;
  for(int i=N; i>0; i/=10) {
    num.at(j) = i%10;
    j--;
  }
  
  int A;
  for (int i=0; i<9; i++){
    A = cal_num( num, cal.at(i), 0);
    if( A == 7) {
      A = i;
      break;
    } 
  }
  for (int i=0; i<3; i++){
    string s;
    if ( cal.at(A).at(i) == '1') s = "+";
    else s = "-";
    cout << num.at(i) << s;
  }
  cout << num.at(3) << "=7" << endl;
}


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

template < int MOD >
class modint{

public:
  long long val;
  constexpr modint(const long long v = 0) noexcept : val(v % MOD) {
     if (val < 0) val += MOD;
  }
  constexpr modint operator -() const noexcept { return modint(-val); };
  constexpr modint operator +(const modint r) const noexcept { return modint(*this) += r; }
  constexpr modint operator -(const modint r) const noexcept { return modint(*this) -= r; }
  constexpr modint operator *(const modint r) const noexcept { return modint(*this) *= r; }
  constexpr modint operator /(const modint r) const noexcept { return modint(*this) /= r; }

  constexpr modint& operator +=(const modint& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr modint& operator -=(const modint& r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr modint& operator *=(const modint& r) noexcept {
    (val *= r.val) %= MOD;
    return *this;
  }

  constexpr modint& operator /= (const modint& r) noexcept {
      return (*this) *= r.inv();
  }

  modint mpow (const long long n) const noexcept {
      if (!n) return 1;
      modint a = mpow(n >> 1);
      a *= a;
      if (n & 1) a *= *this;
      return a;
  }
  // for prime mod
  modint inv() const noexcept {
    return mpow(MOD-2);
  }

  friend constexpr ostream& operator <<(ostream &os, const modint<MOD>& x) noexcept {
    return os << x.val;
  }
    friend constexpr modint<MOD> modpow(const modint<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
const int MOD = 1000000007;
using mint = modint<MOD>;
// ------------------------

mint COM(long long n, long long k){
    mint res = 1;
    for (long long i = 0; i < k; ++i){
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}


void solve() {
    long long n, a, b; cin >> n >> a >> b;
    mint res = modpow(mint(2), n);
    // mint res = mint(2).mpow(n);
    res -= COM(n, a) + COM(n, b) + 1;
    cout << res << "\n";
}

signed main() {
    cin.tie(nullptr); 
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

int main(){
    string S;
    cin >> S;

    if(S[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }

    int count_large_C = 0;
    int target_i = 0;
    for(int i=2; i<S.size()-1; i++){
        if(S[i] == 'C'){
            count_large_C += 1;
            target_i = i;
        }
    }
    if(count_large_C != 1){
        cout << "WA" << endl;
        return 0;
    }

    for(int i=1; i<S.size(); i++){
        if(i==target_i){continue;}

        if(S[i] >= 'a' && S[i] <= 'z'){
            continue;
        }else{
            cout << "WA" << endl;
            return 0;
        }
    }

    cout << "AC" << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

string cube;


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

    cin >> cube;

    ll ans = 0;
    rep(i, cube.size()){
        if(cube[i] == '0') ans --;
        else ans ++;
    }

    cout << cube.size() - abs(ans) << endl;

	//cout << fixed << setprecision(16) << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 4296
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007 
using namespace std;
void solve(){
   ll n,k;
   cin>>n>>k;
   ll a[n+1];
   for(ll i=1;i<=n;i++){
      cin>>a[i];
   }
   ll dp[n+2];
   dp[1]=0;
   for(ll i=2;i<=n;i++){
       ll minm=INT_MAX;
       for(ll j=1;j<=k;j++){
          if(i-j>=1){
             ll op=dp[i-j]+abs(a[i]-a[i-j]);
             minm=min(minm,op);
           }
           else{
            break;
           }
       }
       dp[i]=minm;     }
   cout<<dp[n]<<endl;

}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 5204
#include<bits/stdc++.h>
using namespace std;
#define RI register int
typedef double db;
int n;db d,x,ans;
int main()
{
	scanf("%d%lf%lf",&n,&d,&x);
	db nn=n+n;
	for(RI i=n;i>=1;--i) {
		ans+=d+(nn-1)/2*x;
		db dd=d+(2*d+5*x)/nn;
		db xx=x+4*x/nn;
		x=xx,d=dd,nn-=2;
	}
	printf("%.10lf\n",ans);
	return 0;
}

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

int gcd(int a, int b)
{
    if (a > b) {
        return gcd(b, a);
    }

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

int main()
{
    int a, b;
    while (cin >> a >> b) {
        int gcd_thereof = gcd(a, b);

        cout << gcd_thereof << " ";

        a /= gcd_thereof;
        b /= gcd_thereof;

        cout << a * b * gcd_thereof << endl;
    }
}

Measured memory_bytes: 1160
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on
void main()
{
    auto input = stdin.byLine.map!split.joiner;

    long L;
    L = input.front.to!long;
    input.popFront;

    long R;
    R = input.front.to!long;
    input.popFront;

    long d;
    d = input.front.to!long;
    input.popFront;

    solve(L, R, d);
}

void solve(long L, long R, long d)
{
    writeln(R / d - (L - 1) / d);
}


Measured memory_bytes: 3748
import collections
n=int(input())
d=list(map(int, input().split()))
num=collections.Counter(d)
"""d=sorted(list(map(int, input().split())))
num=[0]*(max(d)+1)
num_=0
count=0
j=0
for i in range(len(d)):
    if d[i]==j:
        num[j]+=1
    elif d[i]==j+1:
        num[j+1]+=1
        j+=1
    else:
        j+=1"""
#print(num)
ans=1
for i in range(1, max(d)+1):
    #print(num[i-1]**num[i])
    #ans = ans * pow(num[i-1], num[i], 998244353)%998244353
    ans*=num[i-1]**num[i]

if d[0]!=0 or d.count(0)!=1:
    print(0)
else:
    print(ans%998244353)


Measured memory_bytes: 62004
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;
#define mod 1000000007
int main(){
    int n,m;
    cin >> n >> m;
    vector<ll>x(n),y(m);
    ll xx = 0;
    ll yy = 0;
    rep(i,n){
        cin >> x[i];
        xx+=x[i]*i-x[i]*(n-1-i)%mod;
        xx%=mod;
    }
    rep(i,m){
        cin >> y[i];
        yy+=y[i]*i-y[i]*(m-1-i)%mod;
        yy%=mod;
    }
    cout << xx*yy%mod << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  vector<string> data(a);
  for(int i = 0;i < a;i++){
    cin >> data[i];
  }
  
  vector<bool> as(a,false);
  vector<bool> bs(b,false);  
  for(int i = 0;i < a;i++){
    for(int j = 0;j < b;j++){
      if(data[i][j] == '#'){
        as[i] = true;
        bs[j] = true;
      }
    }
  }
  
  for(int i = 0;i < a;i++){
    if(as[i]){
      for(int j = 0;j < b;j++){
        if(bs[j]){
          cout << data[i][j];
        }
      }
      cout << endl;
    }
  }
  
}
  

Measured memory_bytes: 3636
while True:
    h,w = map(int,input().split())
    if h == 0 and w == 0:
        break
    else:
        for t in range(h):
            if t % 2 == 0:
                for y in range(w):
                    if y % 2 == 1:
                        print(".",end="")
                    else:
                        print("#",end="")
                print()
            else:
                for y in range(w):
                    if y % 2 == 0:
                        print(".",end="")
                    else:
                        print("#",end="")
                print()
        print()


Measured memory_bytes: 7004
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define SET(A,VAL) memset(A, VAL, sizeof(A))
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int MAX = 1e6+8;
const int sz = 1e5+5;
void f_io(){
    IOS;
}
int32_t main(){
    f_io();
    int t = 1;
    //cin>>t;
    while(t--){
        int k,s; cin>>k>>s;
        int ans = 0;
        rep(i,0,k+1)rep(j,0,k+1){
            int temp = s - (i+j);
            if(temp >=0 && temp <=k) ans++;
        }
        cout<<ans<<endl;

    }
}

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

if n % 2 == 0:
    for i in range(n-1, 0, -2):
        print(a[i], end=' ')
    for i in range(0, n-1, 2):
        print(a[i], end=' ')
else:
    for i in range(n - 1, -1, -2):
        print(a[i], end=' ')
    for i in range(1, n - 1, 2):
        print(a[i], end=' ')

Measured memory_bytes: 96084
#include<stdio.h>
int main(){
	int x=0,j=0;
	char k[1000];
	while(1){
		scanf("%c",&k[j]);
	//	printf("%d %c\n",j,k[j]);
		if(k[0]=='0'){
			break;
		}
		
		if(k[j]=='\n'){
			printf("%d\n",x);
			j=0;
			x=0;
		}
		else{
			x=x+(k[j]-'0');
			j++;
		}
		
	}
	return 0;
}

Measured memory_bytes: 536
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] coordinates = new int[n];
    int max = 1;
    int min = 100;
    for(int i = 0; i < n; i++){
      coordinates[i] = sc.nextInt();
      max = Math.max(max, coordinates[i]);
      min = Math.min(min, coordinates[i]);
    }
    int energy = 250000;
    for(int i = min; i <= max; i++){
      int eachCase = 0;
      for(int j = 0; j < n; j++){
        eachCase += (i - coordinates[j]) * (i - coordinates[j]);
      }
      energy = Math.min(energy,eachCase);
    }
    System.out.println(energy);
  }
}

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

int main(){
        int array[3];
        cin >> array[0] >> array[1] >> array[2];
        sort(array,  array + 3);
        cout << array[0] << " " << array[1] << " " << array[2] << endl;
        return 0;
}



Measured memory_bytes: 3160
fun main(args: Array<String>) {
        val (aStart, aSpeed) = readLine()!!.split(' ').map{it.toInt()}
        val (bStart, bSpeed) = readLine()!!.split(' ').map{it.toInt()}
        val time = readLine()!!.toInt()

        if(aSpeed < bSpeed) {
            println("NO")
            return
        }

        if(aStart < bStart) {

            val aPosition = aStart + (aSpeed * time)
            val bPosition = bStart + (bSpeed * time)

            if(aPosition - bPosition >= 0) {
                println("YES")
            } else {
                println("NO")
            }
        } else {
                val aPosition = aStart - (aSpeed * time)
                val bPosition = bStart - (bSpeed * time)

                if(aPosition - bPosition <= 0) {
                    println("YES")
                } else {
                    println("NO")
                }
        }
    }

Measured memory_bytes: 36344
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007;
#define MOD2 998244353;
#define INF ((1<<30)-1);
#define LINF (1LL<<60);
#define EPS (1e-10);
typedef long long Int;
typedef pair<Int, Int> P;

Int n;
int a[220000];

int main() {
    cin >> n;
    map<int, Int> cnt;
    for (int i = 2; i <= n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << cnt[i];
        if (i <= n-1) cout << " ";
    }
    cout << endl;
}

Measured memory_bytes: 16860
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back
 
void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}
 
typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main(void)
{
    int n;
    cin >> n;
    vector<int> p(10);
    for (int i = 0; i < n; i++ ){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());
    int sum = 0;
    sum += p[0] / 2;
    for (int i = 1; i < n; i++ ){
        sum += p[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
main(){
  int count[4][3][10], b,f,r,v,n;
  cin >> n ;
  for( int i=0;i<4;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<10;k++){
	count[i][j][k]=0;
      }
    }
  }
  for( int i=0; i<n ; i++){
    cin >> b >> f >> r >> v ;
    count[b-1][f-1][r-1] += v;
  }
  for(b=0;b<4;b++){
    for(f=0;f<3;f++){
      for(r=0;r<10;r++){
	cout << " "  << count[b][f][r];
      }
      cout << "\n";
    }
    if(b==3)break;
    cout << "####################\n" ;
  }
}    

Measured memory_bytes: 1168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC140
{
    class C
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] B = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int[] A = new int[N];
            A[0] = B[0];
            A[N - 1] = B[N - 2];
            for (int i = 0; i < N - 2; i++)
            {
                A[i + 1] = Math.Min(B[i], B[i + 1]);
            }
            Console.WriteLine(A.Sum());
        }
    }
}


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

int     main() {
        int N;
        cin >>N;
        vector<long> A(N, 0);
        for (int i=0; i<N; i++) cin >>A.at(i);
        int l=0;
        long AA=A.at(0);
        long S=1;
        for (int r=1; r<A.size(); r++) {
                if (0!=(AA&A.at(r))) {
                        do {
                                AA ^=A.at(l);
                                l++;
                        } while (0 != (AA&A.at(r)));
                }
                AA|=A.at(r);
                S += r-l+1;
        }
        cout <<S <<endl;
        return 0;
};

Measured memory_bytes: 1792
from math import ceil
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
Asum = sum(A)
ans = 10**10
x = 0
for i in range(N-1):
    x+=A[i]
    ans = min(ans, abs(Asum-2*x))
print(ans)

Measured memory_bytes: 23800
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

using namespace std;
typedef long long li;
typedef pair <li, li> pi;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main() {
    int n;
    cin >> n;
    vector<string> ss(n);
    rep(i, n) {
        cin >> ss[i];
    }

    vector<int> mc(26, 114514);
    for (string s : ss) {
        vector<int> cnt(26, 0);
        for (char c : s) {
            cnt[c - 'a']++;
        }
        rep(i, 26) {
            mc[i] = min(mc[i], cnt[i]);
        }
    }

    rep(i, 26) {
        rep(j, mc[i]) {
            cout << (char)('a' + i);
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
 
      Scanner sc = new Scanner(System.in);
      
      if(sc.nextInt() == 1) {
        System.out.println("Hello World");
      } else {
        System.out.println(sc.nextInt() + sc.nextInt());
      }
    }
}


Measured memory_bytes: 20820
package main

import (
  "fmt"
  "strings"
)

var n, k int
var s, ans string

func main() {
  fmt.Scanf("%d%d", &n, &k)
  fmt.Scanf("%s", &s)
  k--
  for i, ch := range s {
    if i == k {
      ans += strings.ToLower(string(ch))
    } else {
      ans += string(ch)
    }
  }
  fmt.Println(ans)
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    int n,X,y,r,s,t,total_point;
    scanf("%d",&X);
    n=X/500;
    y=n*1000;
    r=X%500;
    s=r/5;
    t=s*5;
    total_point=(y+t);
    printf("%d\n",total_point);
}

Measured memory_bytes: 1720
#include <stdio.h>

#define abs(a) (( (a) > 0) ? (a) : -(a))

int main() {
    int n;
    int k;

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

    S[0] = 0;
    S[1] = abs(h[1] - h[0]);
  	for (int i = 2; i < n; i++) {
        int min = -1;
        int current;
        for (int j = 1; j <= k && (i - j) >= 0; j++) {
            current = abs(h[i] - h[i - j]) + S[i - j];
            if (current < min || min == -1)
                min = current;
        }
        S[i] = min;
    }

    printf("%d\n", S[n-1]);
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
using namespace std;
int main(){
    int m, f, r;
    while(1){
        cin >> m >> f >> r;
        if(m==-1 && f == -1 && r == -1) break;
        int total_score = m + f;
        if(m == -1 || f == -1) cout << 'F' << endl;
        else if(total_score >= 80) cout << 'A' << endl;
        else if(total_score >=65) cout << 'B' << endl;
        else if(total_score >= 50 || (total_score >= 30 && r >= 50) ) cout << 'C' << endl;
        else if(total_score >= 30) cout << 'D' << endl;
        else if(total_score < 30) cout << 'F' << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>

int main()
{
    int a, b, c;
    
    scanf("%d %d %d", &a, &b, &c);
    
//    printf("a=%d, b=%d, c=%d\n", a, b, c);
    
    if ( (a + b) == c || (a + c) == b || (b + c) == a)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define size1 3
#define start  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

int a[100005][size1];
int dp[100005][size1];

int solve(int a[][size1],int column,int row,int n )
{

    if(dp[row][column]!=-0)
    {
        return dp[row][column];
    }

    if(row==n)
    {
        return 0;
    }
    int x = solve(a,(column+1)%3,row+1,n);
    int y=solve(a,(column+2)%3,row+1,n);
    int value= max(x,y)+a[row][column];
    dp[row][column]=value;
    return value;
}
int main()
{
    int n;
    cin>>n;
   for(int i=0;i<n;i++)
   {
       for(int j=0;j<3;j++)
       {
           cin>>a[i][j];
       }
   }
   //memset(dp,sizeof(dp),-1);
    int x,y,z;
    x=solve(a,0,0,n);
     y=solve(a,1,0,n);
     z=solve(a,2,0,n);
    int ans=max(z,max(x,y));
    cout<<ans<<endl;


}


Measured memory_bytes: 10368
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Control.Monad               (replicateM)
import           Control.Monad.ST            (ST)
import           Data.Bits                   (shiftR)
import qualified Data.ByteString.Char8       as BC
import           Data.Maybe                  (fromJust)
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

type Vec = V.Vector Int

main :: IO ()
main = do
  n <- readLn
  as <- getInts
  bs <- getInts
  cs <- getInts
  print $ solve n as bs cs

solve :: Int -> [Int] -> [Int] -> [Int] -> Int
solve n as bs cs = solve' (sort' (V.fromList as)) bs (sort' (V.fromList cs))

solve' :: Vec -> [Int] -> Vec -> Int
solve' va bs vc = sum $ map countAlter bs where
  countAlter b = countLower va b * countUpper vc b

-- v is sorted vector
binarySearch :: (Int -> Bool) -> Vec -> Int
binarySearch p v = go 0 $ V.length v where
  go l u
    | l >= u = l
    | otherwise = if p $ v V.! m then go l m else go (m + 1) u where
        m = ((u - l) `shiftR` 1) + l

countLower :: Vec -> Int -> Int
countLower v x = binarySearch (>= x) v

countUpper :: Vec -> Int -> Int
countUpper v x = V.length v - binarySearch (> x) v

sort' :: Vec -> Vec
sort' = V.modify (\v -> quicksort v 0 (VM.length v))

-- https://github.com/as-capabl/haskell-qsort-pfm/blob/master/src/UV.hs
quicksort :: VM.STVector s Int -> Int -> Int -> ST s ()
quicksort work iStart iEnd
    | iEnd - iStart <= 1 = return ()
    | otherwise =
      do
        pivot <- VM.unsafeRead work (((iEnd - iStart) `shiftR` 1) + iStart)
        med <- divide pivot iStart (iEnd - 1)
        quicksort work iStart med
        quicksort work med iEnd
  where
    divide pivot iS' iE'
        | iS' > iE' = return iS'
        | otherwise =
          do
            lower <- shrinkLower pivot iS' iE'
            higher <- shrinkHigher pivot lower iE'
            if lower >= higher
              then do
                return lower
              else do
                swapWork lower higher
                divide pivot (lower + 1) (higher - 1)

    shrinkLower pivot iS' iE'
        | iS' > iE' = return iS'
        | otherwise =
          do
            x <- VM.unsafeRead work iS'
            if x >= pivot
              then
                return iS'
              else
                shrinkLower pivot (iS' + 1) iE'

    shrinkHigher pivot iS' iE'
        | iS' > iE' = return iE'
        | otherwise =
          do
            x <- VM.unsafeRead work iE'
            if x <= pivot
              then
                return iE'
              else
                shrinkHigher pivot iS' (iE' - 1)

    swapWork i j = VM.unsafeSwap work i j

readInts :: BC.ByteString -> [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words

getInts :: IO [Int]
getInts = readInts <$> BC.getLine


Measured memory_bytes: 13692
import sys

sys.setrecursionlimit(10 ** 6)


def input(): return sys.stdin.readline().rstrip()

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

for cx in range(0, 101):
    for cy in range(0, 101):
        H = [1, float('inf')]
        ok = True
        for x, y, h in points:
            # max(H - abs(cx - x) - abs(cy - y), 0) = h
            if h == 0:
                v = abs(cx - x) + abs(cy - y)
                if v < H[0]:
                    ok = False
                H[1] = v
            else:
                v = h + abs(cx - x) + abs(cy - y)
                if not H[0] <= v <= H[1]:
                    ok = False
                H[0] = H[1] = v
        if ok:
            print(cx, cy, H[0])
            exit()




    

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

using namespace std;

int main()
{
	int N,M;
	string s[100],t[100];

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s[i];
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> t[i];
	}

	int max_yen=0;
	for (int i = 0; i < N; i++) {
		int s_count=0, t_count=0;
		for (int j = 0; j < N; j++) {
			if (s[j] == s[i]) {
				s_count++;
			}
		}
		for (int j = 0; j < M; j++) {
			if (t[j] == s[i]) {
				t_count++;
			}
		}

		if (s_count - t_count > max_yen) {
			max_yen = s_count - t_count;
		}
	}

	cout << max_yen << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n)
    {
        cin >> p[i];
    }
    int res = 0;
    sort(p.begin(), p.end());
    rep(i, k)
    {
        res += p[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void solve();

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

template <class _Ty> class PermComb
{
protected:

	_Ty _maxNum = 0;
	_Ty _use_mod = 0;
	_Ty* _fact = 0;
	_Ty* _inv = 0;
	_Ty* _finv = 0;

	PermComb() {}

public:
	PermComb(_Ty maxNum, _Ty use_mod = 0) {
		_maxNum = maxNum;
		_use_mod = use_mod;
		_fact = new _Ty[(unsigned int)maxNum + 1];
		_fact[0] = _fact[1] = 1;

		if (_use_mod) {
			_inv = new _Ty[(unsigned int)maxNum + 1];
			_finv = new _Ty[(unsigned int)maxNum + 1];
			_inv[0] = _inv[1] = 1;
			_finv[0] = _finv[1] = 1;
		}

		for (_Ty i = 2; i <= maxNum; i++) {
			_fact[i] = _fact[i - 1] * i;
			if (_use_mod) {
				_fact[i] %= _use_mod;
				_inv[i] = _use_mod - _inv[_use_mod % i] * (_use_mod / i) % _use_mod;
				_finv[i] = _finv[i - 1] * _inv[i] % _use_mod;
			}
		}
	}

	//	get permutation value
	virtual _Ty nPk(int n, int k) {
		if ((k > _maxNum) || (n > _maxNum) || (k > n) || (k < 0) || (n < 0)) {
			return 0;
		}
		return(_fact[n] / _fact[n - k]);
	}

	//	get combination value
	virtual _Ty nCk(int n, int k) {
		_Ty ans = 0;
		if ((k > _maxNum) || (n > _maxNum) || (k > n) || (k < 0) || (n < 0)) {
			ans = 0;
		}
		else if (_use_mod == 0) {
			ans = nPk(n, k);
			ans /= _fact[k];
		}
		else {
			ans = _fact[n] * (_finv[k] * _finv[n - k] % _use_mod) % _use_mod;
		}
		return ans;
	}

	//	destructor
	~PermComb() {
		delete[] _fact;
		delete[] _inv;
		delete[] _finv;
	}
};

static void solve()
{
	int N, K;
	getint(N, K);
	
	std::vector<LLONG> ai(N);
	for (int i = 0; i < N; i++) {
		getint(ai[i]);
	}

	std::sort(ai.begin(), ai.end());
	PermComb <LLONG> pc(N, MOD_NUM);

	LLONG sumMax = 0;
	for (int i = K - 1; i < N; i++) {
		sumMax = (sumMax + ai[i] * pc.nCk(i, K - 1)) % MOD_NUM;
	}
	LLONG sumMin = 0;
	for (int i = 0; i < N - K + 1; i++) {
		sumMin = (sumMin + ai[i] * pc.nCk(N - i - 1, K - 1)) % MOD_NUM;
	}

	LLONG ans = (sumMax - sumMin + MOD_NUM) % MOD_NUM;
	printf("%lld\n", ans);
}


Measured memory_bytes: 6320
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX 256
int main(){
    int side1[1000],side2[1000],side3[1000];
    int i,j,num;
    char str[MAX], *tp;

    i = 0;
    /* input */
    while (fgets(str,MAX,stdin) != NULL)
    {
        if (i == 0)
        {
            num = atoi(str);
            i++;
        }
        else
        {
            tp = strtok(str, " ");
            side1[i] = atoi(tp);
            tp = strtok(NULL, " ");
            side2[i] = atoi(tp);
            tp = strtok(NULL, "\n");
            side3[i] = atoi(tp);
            i++;
        }
    }

    /* output */
    for(i = 1; i <= num; i++)
    {
        if (side1[i] <= side2[i])
        {
            if (side2[i] <= side3[i])
            {
                if (pow(side3[i],2.0) == pow(side1[i],2.0) + pow(side2[i],2.0))
                {
                    printf("YES\n");
                }
                else
                {
                    printf("NO\n");
                }
            }
            else
            {
                if (pow(side2[i],2.0) == pow(side1[i],2.0) + pow(side3[i],2.0))
                {
                    printf("YES\n");
                }
                else
                {
                    printf("NO\n");
                }
            }
        }
        else
        {
            if (side1[i] <= side3[i])
            {
                if (pow(side3[i],2.0) == pow(side1[i],2.0) + pow(side2[i],2.0))
                {
                    printf("YES\n");
                }
                else
                {
                    printf("NO\n");
                }
            }
            else
            {
                if (pow(side1[i],2.0) == pow(side2[i],2.0) + pow(side3[i],2.0))
                {
                    printf("YES\n");
                }
                else
                {
                    printf("NO\n");
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define fname "D"
#define bug(x) cerr << (#x) << " = " << (x) << endl
#define ll long long
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define ARR0(a, n) {cerr <<(#a)<< ": ["; REP0(i, n) cerr<< ' ' << a[i] <<','; cerr<<']'<<endl;}
#define ARR1(a, n) {cerr <<(#a)<< ": ["; REP1(i, n) cerr<< ' ' << a[i] <<','; cerr<<']'<<endl;}
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define LB lower_bound
#define UB upper_bound
#define X first
#define Y second

using namespace std;
template<typename T, typename V>
inline void bugp(const pair<T, V> &x) {cerr << '{' << x.X << ", " << x.Y << '}' << endl;}
template<typename T, typename U, typename V>
inline void bugpp(const pair<T, pair<U, V> > &x) {cerr << '{' << x.X << ", {" << x.Y.X << ", " << x.Y.Y << "}}" << endl;}
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ll, int> li;
typedef pair<ll, ii> lii;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int H = 1001, W = 1001, INF = 1000000000;
int h, w, d[H][W], dx[] = {-2, -1, 0, 1, 2}, dy[] = {-2, -1, 0, 1, 2};
ii s, t;
char C[H][W];

int main()
{
    //freopen("input.txt", "r", stdin);
	ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> h >> w >> s.X >> s.Y >> t.X >> t.Y;
    REP1(i, h) REP1(j, w) cin >> C[i][j];
    deque<ii> dq;
    dq.pb(s);
    fill(&d[0][0], &d[0][0] + sizeof(d)/sizeof(int), INF);
    d[s.X][s.Y] = 0;
    ii u;
    int a, b;
    while(dq.size()) {
        u = dq.front();
        dq.popf();
        if(u == t) break;
        REP0(x, 5) {
            REP0(y, 5) {
                a = u.X + dx[x];
                b = u.Y + dy[y];
                if(a >= 1 && a <= h && b >= 1 && b <= w && C[a][b] == '.') {
                    if(abs(u.X - a) + abs(u.Y - b) == 1) { // adjacent
                        if(d[a][b] > d[u.X][u.Y]) {
                            d[a][b] = d[u.X][u.Y];
                            dq.pf({a, b});
                        }
                    }
                    else if(d[a][b] > d[u.X][u.Y] + 1) {
                        d[a][b] = d[u.X][u.Y] + 1;
                        dq.pb({a, b});
                    }
                }
            }
        }
    }
    int res = d[t.X][t.Y];
    if(res == INF) cout << -1;
    else cout << res;
	return 0;
}


Measured memory_bytes: 8616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[200010],vis[200010];
vector<int>v;
int main(){
    char a,b;
    cin>>a>>b;
    if(a=='H')
    {
        if(b=='H')cout<<'H';
        if(b=='D')cout<<'D';
    }
    else 
    {
        if(b=='H')cout<<'D';
        if(b=='D')cout<<'H';
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(void)
{
	int n,k,m,dat[10001],prev[10001],next[10001];
	int i,j,cnt,x;
	while(1)	{
		scanf("%d %d %d",&n,&k,&m);
		if (n==0 && k==0 && m==0)	break;
		for(i=1;i<=n;i++)	{
			dat[i]=i;
			next[i]=i+1;
			prev[i]=i-1;
		}
		next[n]=1;
		prev[1]=n;
		cnt=n;
		next[prev[m]]=next[m];
		prev[next[m]]=prev[m];
		cnt--;
		if(cnt==1)	{
			printf("%d\n",next[m]);
		}
		else {
			x=m;
			while(cnt>1)	{
				for(i=0;i<k;i++)	{
					x=next[x];
				}
				next[prev[x]]=next[x];
				prev[next[x]]=prev[x];
				cnt--;
			}
			printf("%d\n",next[x]);
		}
	}
	return 0;
}


Measured memory_bytes: 1104
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll dp[100010];
ll f(ll n){
	if(dp[n])return dp[n];
	if(n==0)return 0;
	ll t6=1;
	while(t6*6<=n)t6*=6;
	ll t9=1;
	while(t9*9<=n)t9*=9;
	return dp[n]=min(n,min(f(n-t6)+1,f(n-t9)+1));
}
int main(){
	ll n;
	scanf("%lld",&n);
	printf("%lld\n",f(n));
}

Measured memory_bytes: 384
using namespace std;
#include <iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<cmath>
//#define MAX 100
//int p[MAX][MAX];
//int N;
//int M;
int main() {
    double input;
    cin >> input;
    if (input < 3) {
        double ans = 0.0;
        double tmp;
        tmp = input;
        ans = (tmp/3) *(tmp/3) * (tmp/3);
        cout << ans << endl;
    } else {
        long long ans = 0;
        
        ans = (input/3) *((input/3)) * (input/3);
        
        string aaa = to_string(ans)+".000000000000";
        cout << aaa << endl;
    }
}


Measured memory_bytes: 256
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 t = sc.nextInt();
        System.out.println((int)((t + 0.5) / a) * b);
    }
}


Measured memory_bytes: 22612
#include <iostream>
#include <vector>

using namespace std;

int main() {
    while(true) {
        int N, P;
        cin >> N >> P;
        if(!N && !P) break;

        vector<int> v(N, 0);
        int cup = P;
        int pos = 0;
        int winner = 0;
        while(true) {
            if(cup > 0) {
                v[pos] += 1;
                cup -= 1;
                if(cup == 0) {
                    bool win = true;
                    for(int i = 0; i < N; ++i)
                        if(i != pos && v[i]) win = false;
                    if(win) {
                        winner = pos;
                        break;
                    }
                }
            }
            else {
                cup = v[pos];
                v[pos] = 0;
            }
            pos = (pos+1) % N;
        }

        cout << winner << endl;
    }
    return 0;
}

Measured memory_bytes: 904
num = str(input())
a = int(num[0])
b = int(num[1])
c = int(num[2])
d = int(num[3])

op = [[1, -1],[1, -1],[1, -1]]
dic = {0:"+",1:"-"}

for i in range(2):
  for j in range(2):
    for k in range(2):
      ans = a + op[0][i] * b + op[1][j] * c + op[2][k] *d
      if ans == 7:
        fml = str(a) + dic[i] + str(b) + dic[j] + str(c) + dic[k] + str(d) +"=7"
        print(fml)
        exit()

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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll A, B;
    cin >> A >> B;

    ll m = max(A, B);

    if(m-1 >= min(A, B))
    {
        cout << 2*m-1 << endl;
    }

    else
    {
        cout << A+B << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a;
	cin>>b;
	if(a==b)
	cout<<"a == b"<<endl;
	else if(a > b)
	cout<<"a > b"<<endl;
	else
	cout<<"a < b"<<endl;
	return 0;
}

Measured memory_bytes: 3092