akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const ll MOD = 1000000007;
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; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }
template<int mod>
struct ModInt {
    using ll = long long; ll x;
    ModInt() : x(0) {}
    ModInt(int y) : x(y >= 0 ? ll(y % mod) : (ll)((mod - (-y) % mod))) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
    ModInt &operator+=(const ModInt &rhs) { if((x += rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &rhs) { if((x += mod - rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &rhs) { x = x * rhs.x % mod; return *this; }
    ModInt &operator/=(const ModInt &rhs) { *this *= rhs.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(const ModInt &rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(const ModInt &rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(const ModInt &rhs) const { return ModInt(*this) /= rhs; }
    ModInt operator==(const ModInt &rhs) const { return x == rhs.x; }
    ModInt operator!=(const ModInt &rhs) const { return x != rhs.x; }
    friend ostream &operator<<(ostream &os, const ModInt &rhs) { return os << rhs.x; }
    friend istream &operator>>(istream &is, ModInt &rhs) { ll t; is >> t; rhs = ModInt<mod> (t); return (is); }
private:
    ModInt inverse() const { ll a = x, u = 1LL, v = 0LL, t, b = (ll)mod; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return  ModInt(u); }
};
using mint = ModInt<MOD>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> X(N);
    for(auto &&x : X) cin >> x;
    ll ans = 0;
    for(int i = 1; i < N; ++i){
        ans += (ll)min((X[i]-X[i-1])*A, B);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int d;
	cin>>d;
	string h="Christmas";
	for(int i=25;i>d;i--){
		h+=" Eve";
	}
	cout<<h<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define sf scanf
#define pf printf
using namespace std;
#define ll long long
const int N=1e5+9;
const ll mod=1e9+7;
ll dp[3009][3009],n;
ll f(ll i,ll sum)
{
    if(i==0 || sum==n) return 1LL;
    if(i<3LL || i>n) return 0LL;
    ll &ans=dp[i][sum];
    if(ans != -1) return ans;
    ans = 0LL;
    for(ll k=3;k<=n;k++) {
        ans = (ans%mod + f(i-k,sum+k))%mod;
    }
    return ans;
}
void slv()
{
    memset(dp,-1,sizeof dp);
    cin >> n;
    cout<<f(n,0)<<endl;
}
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int t;
    t=1;
    while (t--)
    {
        slv();
    }
    return 0;
}


Measured memory_bytes: 74352
#include <bits/stdc++.h>
#define fo(i,a) for(i = 0;i < a;i++)
using namespace std;
int kansu(int a,int b) ;
int main(void)
{
	int n,o[9]={0},t=0,i;
	
	cin >> n ;
	while(n != 0){
		fo(i,9) cin >> o[i] ;
		t = accumulate(o,o + 9,0) ;
		cout << n - t << endl ;
		cin >> n ;
	}
	
	return 0 ;
}



Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 998244353;

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

    vector<ll> v(n);

    rep(i, n) {
        int d;
        cin >> d;
        if(i == 0 && d != 0) {
            cout << 0 << endl;
            return 0;
        }
        v[d]++;
    }

    if(v[0] != 1) {
        cout << 0 << endl;
        return 0;
    }

    rep(i, n-1) {
        if(v[i] == 0 && v[i+1] > 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans = 1LL;
    rep(i, n-1) {

        if(v[i] == 0) {
            break;
        }

        ll pow = 1LL;

        rep(j, v[i+1]) {
            pow *= v[i];
            pow %= mod;
        }

        ans *= pow;
        ans %= mod;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import math
from collections import deque

n = int(input())
ans = 0.0
town = []
length = [[0 for i in range(n)]for j in range(n)]
temp = []

for i in range(n):
    x, y = map(int, input().split())
    town.append([x, y])

for i in range(n):
    for j in range(n):
        if i == j:
            continue
        else:
            length[i][j] = math.sqrt(((town[i][0] - town[j][0]) ** 2) + ((town[i][1] - town[j][1]) ** 2))

queue = deque()

for i in range(n):
    queue.append([[i], 0.0])

while len(queue) != 0:
    left = queue.popleft()
    visited = left[0]
    now_length = left[1]
    for i in range(n):
        if i in visited:
            continue
        else:
            now_length = now_length + length[visited[len(visited) - 1]][i]
            for j in visited:
                temp.append(j)
            temp.append(i)
            if len(temp) == n:
                ans += now_length
            else:
                queue.append([temp, now_length])
            temp = []
            now_length = left[1]

print(ans / math.factorial(n))


Measured memory_bytes: 14196
import sys

data = sys.stdin.readline().rstrip()
data = data.split(" ")

stack = []

def get_num(stack):
  b = stack.pop()
  a = stack.pop()
  return a,b

for x in data:
  if x == "+":
    a,b = get_num(stack)
    stack.append(int(a) + int(b))
  elif x == "-":
    a,b = get_num(stack)
    stack.append(int(a) - int(b))
  elif x == "*":
    a,b = get_num(stack)
    stack.append(int(a) * int(b))
  else:
    stack.append(int(x))
print(stack.pop())





Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long int ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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;}

int main(){
    ll n, m;
    cin >> n >> m;
    if(n%2 == 1){
        rep(i, m){
          cout << 1+i << " " << n-i << endl;  
        }
    }
    else {
        ll i = -1;
        ll cnt = 0;
        ll k = 0;
        bool flag = true;
        while(cnt != m){
            i++;
            if(n-2*i-1 <= n/2 && flag){
                //cout << n/2 << endl;
                k++;
                flag = false;
                continue;
            }
            cout << 1+i-k << " " << n-i << endl;
            cnt++;
        }
    }
    return 0;
}

Measured memory_bytes: 3572
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    H,W = LMIIS()
    if H == 1 or W == 1:
        print(1)
    elif H % 2 == 1 and W % 2 == 1:
        print(W//2*H + H//2+1)
    else:
        print(W*H//2)
    
        


    

if __name__ == '__main__':
    main()

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);
const long long MOD = 1000000007;

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll a, b;
    ll p[200010];
    string s;

    cin >> a >> b;

    cout << a*b << endl;
    return 0;
}

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

#define FOR(x,y,z) for(int x=y,x##_=z;x<=x##_;++x)
#define DOR(x,y,z) for(int x=y,x##_=z;x>=x##_;--x)
#define FOR_(x,y,z,s) for(int x=y,x##_=z;x<=x##_;x+=s)
#define FOR__(x,y,z) for(int x=y,x##_=z;x<=x##_;x<<=1)
#define EOR(x,y) for(int x##_=head[x],y=edge[x##_].e;x##_;y=edge[x##_=edge[x##_].to].e)
#define EGOR(x,y,z) for(int x##_=head[x],y=edge[x##_].e,z=edge[x##_].c;x##_;y=edge[x##_=edge[x##_].to].e,z=edge[x##_].c)

#define clr(x,y) memset(x,y,sizeof(x))
#define szf(x) sizeof(x)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)

#define read2(x,y) read(x),read(y)
#define read3(x,y,z) read(x),read(y),read(z)
#define read4(x,y,z,w) read3(x,y,z),read(w)
#define reads(str) sf("%s",str)

#define ts (*this)
#define sf scanf
#define pf printf

#define ll long long
#define ull unsigned long long
#define db double
#define ct clock_t
#define ck() clock()
#define rd rand()
#define rmx RAND_MAX
#define RD T*(rd*2-rmx)


using namespace std;

template<class T>bool tomin(T &x,T y){return x>y?x=y,1:0;}
template<class T>bool tomax(T &x,T y){return x<y?x=y,1:0;}
template<class T>void read(T &x){
	char c;
	x=0;
	int f=1;
	while(c=getchar(),c<'0'||c>'9')if(c=='-')f=-1;
	do x=(x<<3)+(x<<1)+(c^48);
	while(c=getchar(),c>='0'&&c<='9');
	x*=f;
}

const db Pi=acos(-1);
const int maxn=1e5+5;
const int P=1e9+7;
int n,m;
struct Edge{
	int e,to;
}edge[maxn<<1];
int head[maxn],tot;
void Add(int x,int y){
	edge[++tot]=(Edge){y,head[x]};
	head[x]=tot;
}
ll fact[maxn],inv[maxn],finv[maxn];
void Init(){
	fact[0]=finv[0]=inv[1]=1;
	FOR(i,1,m)fact[i]=fact[i-1]*i%P;
	FOR(i,2,m)inv[i]=P-P/i*inv[P%i]%P;
	FOR(i,1,m)finv[i]=finv[i-1]*inv[i]%P;
	// FOR(i,1,m)pf("%lld ",fact[i]);puts("");
}
ll Com(int x,int y){
	// pf("Com %d %d %lld\n",x,y,fact[y]*finv[y-x]%P);
	if(x>y){
		puts("0");
		exit(0);
	}
	return fact[y]*finv[y-x]%P;
}
ll ans;
void dfs(int u,int f){
	int son=0;
	EOR(u,v)if(v!=f){
		son++;
		dfs(v,u);
	}
	ans=ans*Com(son,m-2+(u==1))%P;
}
int main(){
	srand(time(NULL));
	read2(n,m);
	Init();
	int x,y;
	FOR(i,2,n){
		read2(x,y);
		Add(x,y);
		Add(y,x);
	}
	ans=m;
	dfs(1,0);
	pf("%lld",ans);
	return 0;
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
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; }

int main () {
  int n = in();
  rep(i,n) {
    rep(j,n) {
      if (4*i+7*j==n) {
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
using namespace std;
int main(){
	int ans=0,i=0;
	char str[1000];
	scanf("%s",&str);
	while(true){
		if(str[i]=='\0') break;
		if(str[i]=='2') ans++;
		i++;
	}
	printf("%d",ans);
}

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

int main() {
    int n;
    cin >> n;
    int ans = 0;
    int hmax = 0;
    int h;
    for(int i=0; i<n; i++){
        cin >> h;
        if(h >= hmax){
            ans++;
            hmax = h;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 100005;
int pri[5005],cnt,n;
bool notpri[MAXN];
inline void init()
{
	for(int i=2;i<=2300;++i){
		if(!notpri[i])pri[++cnt]=i;
		for(int j=1;j<=cnt && pri[j]*i<=2300;++j){
			notpri[pri[j]*i]=true;
			if(i%pri[j]==0)break;
		}
	}
}
typedef long long ll;
ll a[MAXN],val[MAXN],rev[MAXN];
inline ll pow(ll x,int k)
{
	if(k==0)return 1;
	else if(k==1)return x;
	else if(k==2)return x*x;
}
int ans=0;
map<ll,int>size;
map<ll,bool>used;
int cnt1=0;
int main()
{
	init();
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%lld",a+i);
		val[i]=rev[i]=1;
		for(int j=1;j<=cnt;++j){
			if(a[i]%pri[j])continue;
			int t=0;
			while(a[i]%pri[j]==0){
				++t;
				a[i]/=pri[j];
			}
			t%=3;
			val[i]*=pow(pri[j],t);
			rev[i]*=pow(pri[j],(3-t)%3);
		}		
		if(a[i]!=1){
			ll t;
			if(pow(t=(ll)sqrt(a[i]),2)==a[i]){
				val[i]*=a[i];
				rev[i]*=t;
			}else{
				val[i]*=a[i];
				rev[i]*=a[i]*a[i];
			}		
		}
		size[val[i]]+=1;
	}	
	for(int i=1;i<=n;++i){
		if(!used[val[i]]){
			used[val[i]]=1;
			used[rev[i]]=1;
			if(val[i]!=rev[i])ans+=max(size[val[i]],size[rev[i]]);
			else ++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 27392
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>
 
#define mp make_pair
#define pb push_back
 
 
typedef long long ll;
typedef long double ld;
 
using namespace std;
 
ll n, d, x;
ld dp[220000];
 
int main() {
	cin >> n >> d >> x;
	dp[0] = 0;
	for (int i = 1; i <= n; ++i)
		dp[i] = dp[i - 1] + 1.0 / (2 * i);
	ld ans = 0;
	ld now = 0;
	for (int i = 0; i < n; ++i) {
		now += dp[i];
		ans += (d + 2.0 * i * x) * (1 + now / (i + 1)) / 2.0;
		ans += (d + 2.0 * i * x + x) * (now / (i + 1)) / 2.0;
	}
	now = 0;
	for (int i = n - 1; i >= 0; --i) {
		now += dp[n - 1 - i];
		ans += (d + 2.0 * i * x + x) * (1 + now / (n - i)) / 2.0;
		ans += (d + 2.0 * i * x) * (now / (n - i)) / 2.0;
	}
	cout.setf(ios::fixed);
	cout.precision(10);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
 
///******************************** C o n t a i n e r ********************************///
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;
 
///*********************************** C o n s t ***********************************///
 
int const N=1e6+3;
const double PI = acos(-1);
 
///********************************** M a r c o ***********************************///
 
#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)
 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
 
///*********************************** F u n c t i o n ***********************************///
 
///ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
///bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0n%(i+2)==0)return false;}return true;}
 
///************************************************ C o d e ************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///
 
 
 
void _case()
{
    ll n,s=0,k,i;
  	cin>>n>>k;
  k--;
  ll a[n];
  	forn(i,n) cin>>a[i];
  	sort(a,a+n);
  for(i=0;i<=k;i++) s+=a[i];
  cout<<s el;
 
}
 
main()
{
///    test
///    while(1)
        _case();
 
}
 
 
///Thank you.
 
 
///Brainless_Loco Terminates Here!

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

int main(){
	int a[5];
	int b=0;
	for(int i=0;i<5;i++){
		cin>>a[i];
		if(a[i]==0){
			b=i+1;
		}
	}
	cout<<b<<endl;
}


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

int findNumber(string s) {
	int tmp = 0, res = 0;
	for (int i = 0; i < s.size(); i++) {
		if (0 <= s[i] - '0' && s[i] - '0' < 10) {
			tmp *= 10;
			tmp += s[i] - '0';
		} else {
			res += tmp;
			tmp = 0;
		}
	}
	return res + tmp;
}

int main() {
	string s;
	int sum = 0;
	while (cin >> s) {
		sum += findNumber(s);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
const int LIM = 1e5;

int N, K;
int h[LIM];

int main(){
    cin >> N >> K;
    for(int i=0; i<N; i++) cin >> h[i];
    sort(h, h+N);

    int ans = 1e9;
    for(int i=0; i<N-K+1; i++){
        ans = min(ans, h[i+K-1] - h[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

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

    vector<int> H(N);
    vector<int> I(N);

    int counter = 0;

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

    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j <= i; ++j)
        {
            if (H[i] < H[j])
                I[i] = 1;
        }
        counter = counter + I[i];
    }

    cout << N - counter << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

void dfs(int d, ll  now, vector<ll> &lun){
    lun.push_back(now);

    if(d == 10) return;

    for(int i = -1; i <= 1; i++){
        int add = now%10 + i;
        if(add >= 0 && add <= 9) dfs(d+1, now*10 + add, lun);
    }
}

int main() {
    int k;
    cin >> k;
    vector<ll> lun;
    rep(i,9) dfs(1,i+1,lun);
    sort(all(lun));
    dunk(lun[k-1]);
    return 0;
}

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

using namespace std;

#define PI (3.14159265358979323846)
#define MP make_pair
#define n1 first
#define n2 second
#define ALL(x) (x).begin(), (x).end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MS multiset
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define SZ(x) ((int)x.size())

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

const db eps = 0.00001;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 750555;
const int M = 1125;

ll powmod(ll n, ll k, ll m){
    if (k == 0) return 1;
    ll x = powmod(n, k/2, m) % m;
    x = x * x % m;
    if (k % 2) x = x * n % m;
    return x % m;
}

void solve() {
    int k;
    cin >> k;

    ll x = 0;
    for (int i = 1; i <= k+10; i++){
        x += 7 * powmod(10, i-1, k);
        x %= k;
        if (x == 0){
            cout << i;
            return;
        }
    }

    cout << -1;

}

int main() {
    ios_base::sync_with_stdio(false);

#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int ans = n*800 - (n/15)*200;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}

ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p&1)    res = (res * x)%m;
        x = (x * x)%m;
        p >>= 1;
    }
    return res;
}
long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}

const int N = 1e6 + 5, MX = 1e9;

int main(){
    int a = D(), b = D();
    int turn = 1;
    for(int i = 0; i < 16; ++i){
        if(turn)
            --a;
        else
            --b;
        turn ^= 1;
    }
    if(a > 0 ||  b > 0)
        printf(":(");
    else
        printf("Yay!");
    return 0;
}


Measured memory_bytes: 256
D,G = map(int,input().split())
cnts = []
points = []
for i in range(1,D + 1):
        p,c = map(int,input().split())
        points.append([p, i * 100, i * 100 * p + c, c])

for i in range(1 << D):
        point = 0
        cnt = 0
        not_used = [_ for _ in range(D)]
        for j in range(D):
                if 1 << j & i:
                        many,one,all,bounsu = points[j]
                        cnt += many
                        point += all
                        not_used.remove(j)
        if point < G:
                biggest = points[not_used[len(not_used) - 1]]
                if biggest[2] < G - point:
                        continue
                cnt += (G - point) // biggest[1]
                if (G - point) % biggest[1] != 0:
                        cnt += 1
        cnts.append(cnt)
print(min(cnts))

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

using namespace std;

int a, b, c;

int main(){
	cin >> a >> b >> c;
	if(a == b && a != c ||
	   b == c && c != a ||
	   c == a && a != b) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

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

  // 1はマスト
  vector<int> ans{1};
  FOR(i,2,(int)sqrt(X)+1) {
    int tmp = 1;
    while (pow(i,tmp+1)<=X) {
      tmp++;
      ans.push_back(pow(i,tmp));
    }
  }
  sort(ALL(ans),greater<int>());
  OUT(ans[0]);

  return 0;
}

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

int main(){
  int a, b, c; cin >> a >> b >> c;
  if((a==b&&b!=c)||(b==c&&c!=a)||(c==a&&a!=b))
    cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

const int INF = INT_MAX/2;
int N, X, Y;
int A[2010];
int memo[2010][2];

int game(int id, int turn, int x, int y) {
  if (id == N) return abs(x-y);
  if (memo[id][turn] >= 0) return memo[id][turn];
  int res;
  if (turn == 0) {
    res = -1;
    for (int i = id; i < N; i++) {
      res = max(res, game(i+1, !turn, A[i], y));
    }
  } else {
    res = INF;
    for (int i = id; i < N; i++) {
      res = min(res, game(i+1, !turn, x, A[i]));
    }
  }
  return memo[id][turn] = res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> X >> Y;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  fill_n((int*)memo, 2010*2, -1);
  cout << game(0, 0, X, Y) << endl;

  return 0;
}

Measured memory_bytes: 384
#coding: utf-8
N = int(input())
A = list(map(int, input().split()))
dp = [[0, 0] for i in range(N+1)]
dp[0][1] = -10**10
for i in range(N):
	dp[i+1][0] = max(dp[i][0] + A[i], dp[i][1] - A[i])
	dp[i+1][1] = max(dp[i][0] - A[i], dp[i][1] + A[i])
print(dp[N][0])

Measured memory_bytes: 25588
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		StringBuilder sb1 = new StringBuilder();
		StringBuilder sb2 = new StringBuilder();
		int cnt1 = 0;
		int cnt2 = 0;
		int len = s.length();
		for (int i = 0; i < len; i++) {
			if (i % 2 == 0) {
				if (s.charAt(i) == '0') {
					cnt2++;
				} else {
					cnt1++;
				}
			} else if (i % 2 != 0) {
				if (s.charAt(i) == '0') {
					cnt1++;
				} else {
					cnt2++;
				}
				
			}
		}
		
		int ans = Math.min(cnt1, cnt2);
		System.out.println(ans);

	}
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  int n; cin >> n;
  vi a(n);
  int x = 0;
  REP(i, n) {
    cin >> a[i];
    x ^= a[i];
  }

  REP(i, n) {
    cout << (x ^ a[i]);
    if(i == n-1) cout << endl;
    else cout << " ";
  }

}








Measured memory_bytes: 3920
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  vector<ll> a(n); cin >> a;
  ll sum = 0, cur = 0;
  rep(i, n) sum += a[i];
  ll ans = linf;
  rep(i, n) {
    cur += a[i];
    if (i < n-1) {
      chmin(ans, abs(cur - (sum-cur)));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,q;
    string s;
    cin >> n >> q;
    cin >> s;
    vector<int> t(n+1,0);
    for(int i=0;i<n;i++){
        if(i+1 < n and s[i]=='A' and s[i+1]=='C'){
            t[i+1] = t[i] + 1;
        }else{
        	 t[i+1] = t[i];
        }
    }
    for(int j=0;j<q;j++){
        int l,r;
        cin >> l >> r;
        l--;
        r--;
        cout << t[r] - t[l] << "\n";
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,cnt=0,c[201];
	cin>>a>>b;
	for (int i=0;i<a+b;i++)
		if (i<a)
			c[i]=0;
		else
			c[i]=1;
	for (int i=0;i<a+b;i++)
		for (int n=i+1;n<a+b;n++)
			if (c[i]+c[n]==0||c[i]+c[n]==2)
				cnt++;
	cout<<cnt;
	return 0;
}


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

int HelloWorld(){
	cout << "Hello World" << endl;
	return 0;
}

int XCubic(){
	int x;
	cin >> x;
	if (1 <= x && x <= 100){
		x = x*x*x;
		cout << x << endl;
		return 0;
	}
	return 1;
}

int Rectangle(){
	int a, b, area, perimeter;

	cin >> a >>b;
	if (1 <= a && b <= 100){
		area = a*b;
		perimeter = (a + b) * 2;
		cout << area << " " << perimeter << endl;
		return 0;
	}
	return 1;
}

int Watch(){
	int S;
	cin >> S;
	
	
	int D = 60;
	int s = S%D;
	int m = (S / D) % D;
	int h = (S / D) / D;
	if (0 <= S && S <= 86400){
		printf("%u:%u:%u\n", h, m, s);
		return 0;
	}
	
	return 1;
}

int SmallLargeOrEqual(){
	int a, b;
	cin >> a >> b;
	if (!(a <= a && b <= 1000)) return 1;
	if (a < b)		cout << "a < b" << endl;
	else if (a > b) cout << "a > b" << endl;
	else			cout << "a == b" << endl;
	return 0;
}


int main(){
	//HelloWorld();
	//XCubic();
	//Rectangle();
	//Watch();
	SmallLargeOrEqual();
	return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main(){
  cin.tie(nullptr);ios::sync_with_stdio(false);
  string s;cin >> s;
  int n = s.size(),i;
  if(n == 2){
    printf(s[0] == s[1] ? "1 2\n":"-1 -1\n");
    return 0;
  }
  for(i=0;i<n-2;i++){
    if(s[i] == s[i+1] || s[i] == s[i+2] || s[i+1] == s[i+2]){
      printf("%d %d\n",i+1,i+3);
      return 0;
    }
  }
  printf("-1 -1\n");
}

Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;
int main(){
  int n;
  while(cin >> n, n!=0){
    int posx = 10,posy = 10;
    vector<int> tx,ty;
    for(int i=0;i<n;i++){
      int x,y;
      cin >> x >> y;
      tx.push_back(x);
      ty.push_back(y);
    }
    int m;
    cin >> m;
    int movex[m],movey[m];
    string c;
    int l;
    for(int i=0; i<m;i++){
      cin >> c >> l;
      if(c == "N"){
	movex[i] = 0;
	movey[i] = l;	    
      }else if(c == "E"){
	movex[i] = l;
	movey[i] = 0;
      }else if(c == "S"){
	movex[i] = 0;
	movey[i] = -1*l;
      }else if(c == "W"){
	movex[i] = -1*l;
	movey[i] = 0;
      }
      for(int j=0;j<tx.size();j++){
	if(tx[j] >= posx && tx[j] <= posx + movex[i] && ty[j] >= posy && ty[j] <=posy + movey[i]){
	  n--;
	  vector<int>::iterator del;
	  del = tx.begin()+j;
	  tx.erase(del);
	  del = ty.begin()+j;
	  ty.erase(del);
	  j--;
	}else if(tx[j] <= posx && tx[j] >= posx + movex[i] && ty[j] <= posy && ty[j] >=posy + movey[i]){
	  n--;
	  vector<int>::iterator del;
	  del = tx.begin()+j;
	  tx.erase(del);
	  del = ty.begin()+j;
	  ty.erase(del);
	  j--;
	}
      }
      posx += movex[i];
      posy += movey[i];
    }
    if(tx.size() == 0){
      cout << "Yes" <<endl;
    }else{
      cout << "No" <<endl;
    } 
  }		  
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int mod=1e9+7;
const int INF=1001001001;

int main() {
  int64_t N,K;
  cin>>N>>K;
  vector<int64_t>P(N),C(N);
  for(int i=0;i<N;i++){
    cin>>P[i];
    P[i]--;
  }
  for(int i=0;i<N;i++){
    cin>>C[i];
  }
  int64_t ans=-1e18-10;
  for(int s=0;s<N;s++){
    vector<int>q;
    vector<int>num(N,-1);
    int d=P[s];
    int64_t roopsum=0;
    while(num[d]==-1){
      num[d]=q.size();
      q.push_back(d);
      roopsum+=C[d];
      d=P[d];
    }
    int Q=q.size();
    int roop=Q-num[d];
    if(Q>K){
      int64_t cost=0;
      for(int i=0;i<K;i++){
        cost+=C[q[i]];
        chmax(ans,cost);
      }
    }
    else if(roopsum<=0){
      int64_t cost=0;
      for(int i=0;i<Q;i++){
        cost+=C[q[i]];
        chmax(ans,cost);
      }
    }
    else{
      int64_t cost=0;
      for(int i=0;i<Q;i++){
        cost+=C[q[i]];
        chmax(ans,cost+(K-(i+1))/roop*roopsum);
      }
    }
  }
  cout<<ans<<endl;
  return 0;  
}

Measured memory_bytes: 3748
n = int(input())
a = map(int, input().split())
ans_lst = []
for ai in a:
    if len(ans_lst) == 0 and ai == 1:
        ans_lst.append(1)
    elif len(ans_lst) > 0 and ans_lst[-1] == ai - 1:
        ans_lst.append(ai)
if len(ans_lst) == 0:
    print(-1)
else:
    print(n - len(ans_lst))

Measured memory_bytes: 25724
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 r          PIC 9(10).
01 ans        PIC 9(19).
01 zs         PIC Z(18)9.

PROCEDURE DIVISION.
  ACCEPT r.
  COMPUTE ans = r ** 2.
  MOVE ans TO zs.
  DISPLAY FUNCTION TRIM(zs).
  STOP RUN.


Measured memory_bytes: 3908
// author: Wenxing Mei
//   date: 2018-06-11 16:52
//     ac: 2018-06-11 16:52
#include <bits/stdc++.h>
using namespace std;

int dp[100001];
int main() {
#ifdef LOCAL
    freopen("in", "r", stdin);
#endif
    memset(dp, 0x3f3f3f3f, sizeof(dp));
    dp[0] = 0;

    for (int i = 1; i <= 100000; ++i) {
        dp[i] = min(dp[i], dp[i - 1] + 1);
        for (int j = 6; j <= 100000 && j <= i; j *= 6) dp[i] = min(dp[i], dp[i - j] + 1);
        for (int j = 9; j <= 100000 && j <= i; j *= 9) dp[i] = min(dp[i], dp[i - j] + 1);
    }

    int n;
    cin >> n;
    printf("%d\n", dp[n]);
    return 0;
}

Measured memory_bytes: 640
import sys


def resolve(in_):
    H, W, K = map(int, next(in_).split())
    # n_choco = ord(b'0')
    w_choco = ord(b'1')
    S = [[1 if v == w_choco else 0 for v in line.strip()] for line in in_]
    # print(f'{H=} {W=} {K=}')
    # print(S)

    ans = 10000  # > (Hmax - 1) * (Wmax - 1)
    choco = [0] * H
    choco_temp = [0] * H
    for v in range(2 ** (H - 1)):
        # print(f'{v:04b}')
        ans_temp = sum(1 if v & (0b01 << i) else 0 for i in range(H - 1))
        for w in range(W):
            index = 0
            for h in range(H):
                choco_temp[index] += S[h][w]
                if v & (0b01 << h):
                    index += 1
            # print(f'b {choco=} {choco_temp=} {ans_temp=}')
            if all(a + b <= K for a, b in zip(choco, choco_temp[:index + 1])):
                # for i in range(len(choco)):
                for i in range(index + 1):
                    choco[i] += choco_temp[i]
                    choco_temp[i] = 0
            elif max(choco_temp) > K:
                ans_temp = 10000
                break
            else:
                # for i in range(len(choco)):
                for i in range(index + 1):
                    choco[i] = choco_temp[i]
                    choco_temp[i] = 0
                ans_temp += 1
            if ans_temp >= ans:
                break
            # print(f'a {choco=} {choco_temp=} {ans_temp=}')
        # print(f'{v:09b} {choco=} {ans_temp=}')
        ans = min(ans, ans_temp)
        for i in range(len(choco)):
            choco[i] = 0
            choco_temp[i] = 0
  
    return ans


def main():
    ans = resolve(sys.stdin.buffer)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9340
#include <stdio.h>
int main() {
    double a, b, c, d, e, f;
    double x, y;
    while(scanf(" %lf %lf %lf %lf %lf %lf",
                &a, &b, &c, &d, &e, &f) != EOF) {
        x = (e * c - b * f) / (a * e - b * d);
        y = (a * f - c * d) / (a * e - b * d);
        if (x == -0.0)
            x = 0.0;
        if (y == -0.0)
            y = 0.0;
        printf("%.3lf %.3lf\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 652
H,W=[int(s) for s in input().split()]
maze=[input() for _ in range(H)]
 
edge=[set() for _ in range(H*W)]
n=0
numcount=0
for h in range(H):
  for w in range(W):
    if maze[h][w]=='#':
      numcount+=1
      n+=1
      continue
    if h>0 and maze[h-1][w]=='.':
      edge[n].add(n-W)
    if h<H-1 and maze[h+1][w]=='.':
      edge[n].add(n+W)
    if w>0 and maze[h][w-1]=='.':
      edge[n].add(n-1)
    if w<W-1 and maze[h][w+1]=='.':
      edge[n].add(n+1)
    n+=1

def dfs(start):
  reach=[start]
  distance=[-1 for _ in range(H*W)]
  distance[n]=0
  while reach:
    _from=reach.pop(0)
    for _to in edge[_from]:
      if not(_to in reach) and distance[_to]==-1:
        reach.append(_to)
        distance[_to]=distance[_from]+1
  return(max(distance))
 
n=0
ans=set()
for h in range(H):
  for w in range(W):
    if maze[h][w]=='.':
      ans.add(dfs(n))
    n+=1
print(max(ans))

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

int main() {

    int N;
    cin >> N;

    vector<int> a(N);
    rep(i,N) cin >> a[i];

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    int alice = 0;
    int bob = 0;

    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) alice += a[i];
        else bob += a[i];
    }

    cout << alice - bob << endl;
    return 0;
}

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

char m[2001][2001];
int d[2001][2001];

int main(){
    int H,W;
    cin>>H>>W;
    
    for(int i=0;i<2001;i++){
        if(i<H){
            string S;
            cin>>S;
            for(int j=0;j<2001;j++){
                if(j<W) m[i][j]=S.at(j);
                else m[i][j]='#';
            }
        }

        else{
            for(int j=0;j<2001;j++) m[i][j]='#';
        }

    }

    for(int i=0;i<2001;i++){
        for(int j=0;j<2001;j++){
            if(m[i][j]=='.'){
                int k=0;
                while(m[i][j+k]=='.' && j+k<2001) k++;
                for(int p=0;p<k;p++) d[i][j+p]+=k;
                j+=k;
            }
        }
    }

    for(int i=0;i<2001;i++){
        for(int j=0;j<2001;j++){
            if(m[j][i]=='.'){
                int k=0;
                while(m[j+k][i]=='.' && j+k<2001) k++;
                for(int p=0;p<k;p++) d[j+p][i]+=k;
                j+=k;
            }
        }
    }

    int max=0;
    for(int i=0;i<2001;i++){
        for(int j=0;j<2001;j++){
            if(max<d[i][j]) max=d[i][j];
        }
    }

    cout<<max-1<<endl;
}

Measured memory_bytes: 19840
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1061109567;
const double EPS = 1e-10;
int main(){
    int X;
    cin>>X;
    int K=1;
    while((X*K)%360!=0){
        K++;
    }
    cout<<K<<endl;
    return 0;
}


Measured memory_bytes: 3628
# coding: utf-8
# Your code here!

while True:
   s = input()
   if s == "END OF INPUT": break
   
   s += " " #文字列の文末にスペースを加える
   #print(s)
   
   c = 0
   for i in range(len(s)):
      #print(s[i])
      if s[i] == ' ':
         print(c, end = "")
         c = 0
         continue
      c += 1
   print("")



Measured memory_bytes: 5556
#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 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=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vector<P> g(n);
	rep(i,n){
		cin>>g[i].fi>>g[i].se;
	}
	sort(begin(g),end(g));
	ll ans=0;
	rep(i,n){
		if(m>=g[i].se){
			ans+=g[i].fi*g[i].se;
			m-=g[i].se;
		}else{
			ans+=g[i].fi*m;
			break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n,k;cin>>n>>k;
    vector<int> cnt(n,0);
    rep(i,k){
        int d;cin>>d;
        rep(j,d){
            int x;cin>>x;x--;
            cnt[x]++;
        }
    }

    int ans=0;
    rep(i,n) if(cnt[i]==0) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3652
S0=input()
N=E=W=S=False
for i in range(len(S0)):
    if S0[i]=='N':
        N=True
    elif S0[i]=='E':
        E=True
    elif S0[i]=='W':
        W=True
    else:
        S=True

if ((N and S) or (not N and not S)) and ((E and W)or(not E and not W)):
    print ("Yes")
else:
    print("No")


Measured memory_bytes: 3064