akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> // {{{

#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define let const auto
#define USE_T template <typename T>
#define USE_Ti template <typename T = int>
#define USE_TU template <typename T, typename U>

USE_Ti using duo = std::pair<T, T>;
USE_Ti using vec = std::vector<T>;
using ll = long long;
// clang-format off
USE_TU inline bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE_TU inline bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE_Ti inline T in(){T x;std::cin>>x;return x;}
USE_Ti inline vec<T> in(int n){vec<T> v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE_T inline void in(T*x,int n){rep(i,n)x[i]=in<T>();}
struct IoSetup {
  IoSetup(){
    using namespace std;
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<setprecision(10);
    cerr<<setprecision(10);
  }
} iosetup;
// clang-format on
// }}}
using namespace std;
const int inf = 1001001001;
const ll infll = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

int C[] = {1, 5, 10, 50, 100, 500};

signed main() {
  auto c = in(6);
  int s = 0;
  REP(i, 6) s += c[i] * C[i];
  cout << (s >= 1000) << endl;
  return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

void search(int c, vector<int> *lst, bool *v){
  
  for (int i = 0; i < (lst + c)->size(); i++) {
    
    if (v[(*(lst + c))[i]] == false) {
      v[(*(lst + c))[i]] = true;
      search((*(lst + c))[i], lst, v);
    }
  }
  return;
}

int main(void) {
  int n, m, count;
  vector<int> *lst;
  bool *visited;
  
  cin >> n >> m;
  visited = new bool[n+1];
  lst = new vector<int>[n+1];
  
  for (int i = 0; i < m; i++) {
    int u, v, z;
      
    cin >> u >> v >> z;
    lst[u].push_back(v);
    lst[v].push_back(u);
  }
  
  for (int i = 1; i < n + 1; i++) {
    if (visited[i] == false) {
      count++;
      visited[i] = true;
      search(i, lst, visited);
    }
  }
  
    
  cout << count << endl;
  
  return 0;
}
  

Measured memory_bytes: 10496
n, y = map(int, input().split())

total = 0
sen = -1
gosen = -1
ichiman = -1

for a in range(n+1):
  for b in range(n+1-a):
    total = a*1000 + b*5000 + (n-a-b)*10000
    if(total==y):
      sen = a
      gosen = b
      ichiman = n-a-b
      
print(ichiman,gosen,sen)

Measured memory_bytes: 9080
#include <stdio.h>
#include <stdlib.h>

long long a[100001];
int N;

long long int solve(int parity) {
  long long ret = 0, sum = 0;
  
  for (int i = 0; i < N; i++) {
    long long tmp = sum + a[i];
    long long to_add = a[i];
    if (sum + a[i] >= 0 && parity == 1) {
      to_add = -1 - sum;
    } else if (sum + a[i] <= 0 && parity == -1) {
      to_add = 1 - sum;
    }

    sum += to_add;
    ret += llabs(a[i] - to_add);
    parity *= -1;
  }

  return ret;
}

int main() {
  long long ret, tmp;
  scanf("%d", &N);
  
  for (int i = 0; i < N; i++) {
    scanf("%lld", a + i);
  }

  ret = solve(1);
  tmp = solve(-1);
  if (ret > tmp) ret = tmp;
  printf("%lld\n", ret);
  
  return 0;
}


Measured memory_bytes: 896
#include<iostream>
using namespace std;
long A,B,N;
main()
{
	cin>>A>>B>>N;
	if(B==1)
	{
		cout<<0<<endl;
		return 0;
	}
	long X=N>=B?N/B*B-1:N;
	cout<<A*X/B-A*(X/B)<<endl;
}


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

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

int32_t main(){
	NINJA;

	int n; cin >> n;
	vii a;

	for(int i=2;i*i<=n;i++){
		int x = 0;
		while(n%i==0){
			n /= i;
			++x;
		}
		a.pb({i,x});
	}
	if(n!=1) a.pb({n,1});

	int ans = 0;

	for(auto i : a){
		int s = i.S;
		int j = 1;
		while(j<=s){
			s-=j;
			j++;
			++ans;
		}
	}

	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 19708
#include <bits/stdc++.h>
using namespace std;
// https://atcoder.jp/contests/abc093/tasks/abc093_b

int main() {
  int A, B, K;
  cin >> A >> B >> K;

  for (int i = A; i <= min(B, A + K - 1); i++) cout << i << endl;
  for (int i = max(B - K + 1, A + K); i <= B; i++) cout << i << endl; 
}

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

void fnInput(vector<string>& rvsStr)
{
  int nStrSiz;
  cin >> nStrSiz;
  rvsStr.resize(nStrSiz);

  for (string& rsStr : rvsStr)
    cin >> rsStr;
}
  
int64_t fnAnagramCnt(const vector<string>& cnrvsStr)
{
  vector<string> vsSortStr(cnrvsStr);

  for (string& rsSortStr : vsSortStr)
    sort(begin(rsSortStr), end(rsSortStr));

  int64_t nAnagramCnt = 0;
  map<string, int> mpSortStr;

  for (string sSortStr : vsSortStr)
  {
    nAnagramCnt += mpSortStr[ sSortStr ];
    mpSortStr[ sSortStr ]++;
  }
  return nAnagramCnt;
}
  
int main()
{
  vector<string> vsStr;

  fnInput(vsStr);
  cout << fnAnagramCnt(vsStr) << endl;

  return 0;
}

Measured memory_bytes: 23680
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vec<int, 2> G(N);
    for (int i = 0; i < N - 1; i++) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    vector<ll> C(N);
    for (ll& x : C) cin >> x;
    sort(C.begin(), C.end());
    vector<int> deg(N, 0);
    for (int v = 0; v < N; v++) {
      for (int u : G[v]) {
        ++deg[u];
      }
    }
    queue<int> pq;
    for (int v = 0; v < N; v++) {
      if (deg[v] == 1) {
        pq.push(v);
      }
    }
    int p = 0;
    vector<ll> cost(N);
    while (!pq.empty()) {
      int v = pq.front();
      pq.pop();
      cost[v] = C[p++];
      for (int u : G[v]) {
        --deg[u];
        if (deg[u] == 1) {
          pq.push(u);
        }
      }
    }
    ll M = 0;
    for (int v = 0; v < N; v++) {
      for (int u : G[v]) {
        M += min(cost[v], cost[u]);
      }
    }
    M /= 2;
    cout << M << endl;
    for (int v = 0; v < N; v++) cout << cost[v] << " ";
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}

#define rank Asdfiasofsad
class UF{
public:
  int V;
  vector<int> par,rank,base;
  UF(){}
  UF(int V):V(V),par(V),rank(V,0),base(V,0){for(int i=0;i<V;i++)par[i]=i;}
  
  int find(int x){
    assert(x < V);
    if(par[x]==x)return x;
    return par[x]=find(par[x]);
  }
  
  void unite(int x,int y){
    x=find(x), y=find(y);
    if(x==y)return;
    if(rank[x]<rank[y])par[x]=y, base[y] |= base[x];
    else{
      par[y]=x;
      base[x] |= base[y];
      if(rank[x]==rank[y])rank[x]++;
    }
  }

  bool same(int x,int y){return find(x)==find(y);}
};

int n,k,t;
typedef pair<int,int> P;
typedef pair<int,P> PP;
vector<int>  T;
vector<PP> edge;

int solve(){
  sort(edge.begin(),edge.end());
  int sum = 0;
  for(int i=0;i<n-1;i++) sum += -edge[i].first;
  UF uf(n);
  for(int i=0;i<t;i++) uf.base[T[i]] = 1;
  
  int numBase = t,numNode = n;
  for(int i=0;i<n-1;i++){
    int a = edge[i].second.first;
    int b = edge[i].second.second;
    int c = -edge[i].first;
    a = uf.find(a);
    b = uf.find(b);
    if(uf.same(a,b)) continue;
    if(numBase == k+1 && uf.base[a] && uf.base[b]) continue;
    if(numNode == k+1) continue;
    if(uf.base[a] && uf.base[b]) numBase--;
    numNode--;
    sum -= c;
    uf.unite(a,b);
  }
  return sum;
}

signed main(){
  int numCase = 0;
  while(1){
    cin>>n>>t>>k;
    if(n == 0 && k == 0 && t == 0) break;
    cout<<"Case "<<++numCase<<": ";
    
    edge.resize(n-1);
    for(int i=0;i<n-1;i++){
      int a,b,c;
      cin>>a>>b>>c; a--,b--;
      edge[i] = PP(-c,P(a,b));
    }
    
    T.resize(t);
    for(int i=0;i<t;i++) cin>>T[i],T[i]--;
   
    cout<<solve()<<endl; 
  }



  return 0;
}

Measured memory_bytes: 3520
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
	int R[MAX], n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> R[i];

	int maxv = -2000000000; //十分小さい値
	int minv = R[0];

	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;
	return 0;
}


Measured memory_bytes: 3872
#include <bits/stdc++.h>
#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=998244353;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	int h,w;
	cin>>h>>w;
	if(h==1||w==1)cout<<1<<endl;
	else cout<<(h*w+1)/2<<endl;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

// long version
long long int GCD(long long int x, long long int y){
    if(x>y){
        long long int swap = x;
        x = y;
        y = swap;
    }
    while(true){
        if(y%x==0){
            return x;
        }else{
            long long int amari = y%x;
            y = x;
            x = amari;
        }
    }
}

int main() {
    ll n;
    cin >> n;
    ll a[n], b[n];
    ll zerozero = 0;
    ll azero = 0;
    ll bzero = 0;
    map<P,ll> mp;
    rep(i,n){
        cin >> a[i] >> b[i];

        if(a[i] == 0 && b[i] == 0){
            zerozero++;
            continue;
        }
        if(a[i] == 0){
            azero++;
            continue;
        }
        if(b[i] == 0){
            bzero++;
            continue;
        }


        ll g = GCD(abs(a[i]),abs(b[i]));
        a[i] /= g, b[i] /= g;

        if(a[i] < 0 && b[i] < 0){
            a[i] = abs(a[i]);
            b[i] = abs(b[i]);
        }

        if(a[i] >= 0 && b[i] < 0){
            a[i] *= -1;
            b[i] *= -1;
        }

        mp[P(a[i],b[i])]++;

    }

    ll ans = 1;

    int m = mp.size();
    int now = 0;
    P p[m];
    ll cnt[m];

    map<P,int> mmp;

    for(auto pp : mp){
        p[now] = pp.first;
        cnt[now] = pp.second;
        mmp[pp.first] = now;
        now++;
    }

    /*
    cout << endl;
    rep(i,m){
        cout << p[i].first << ' ' << p[i].second << endl;
    }
    cout << endl;
    */

    int f[m] = {};

    ll MOD = 1e9+7;
    ll two[MAX_N];
    two[0] = 1;
    srep(i,1,MAX_N) two[i] = two[i-1] * 2 % MOD;

    rep(i,m){
        if(f[i])continue;
        f[i] = 1;
        int j = -1;
        if(p[i].first > 0){
            if(mmp.find(P(-p[i].second,p[i].first)) != mmp.end()){
                j = mmp[P(-p[i].second,p[i].first)];
            }
            
        }else{
            if(mmp.find(P(p[i].second,-p[i].first)) != mmp.end()){
                j = mmp[P(p[i].second,-p[i].first)];
            }
            
        }

        // cout << i << ' ' << j << endl;
        
        ll alp = cnt[i], bet = 0;
        if(j == -1){
            ;
        }else{
            bet = cnt[j];
            f[j] = 1;
        }
        // cout << alp << bet << endl;
        ll val = (two[alp] + two[bet] - 1) % MOD;
        //cout << i << ' ' << j << ' ' << val << endl;
        ans = ans * val % MOD;
    }

    ll val = (two[azero] + two[bzero] - 1) % MOD;
    ans = ans * val % MOD;

    ans = (ans + zerozero) % MOD;

    ans = (ans + MOD - 1 ) % MOD;

    cout << ans << endl;
    return 0;

}




Measured memory_bytes: 38748
#include <bits/stdc++.h>
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
/* cpp template {{{*/
using namespace std;

#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()

typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
/* }}} */
/* 定数 {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */

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

  vi a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(ALL(a));
  a.erase(unique(ALL(a)), a.end());

  cout << a.size() << endl;


}



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

int main(){
    int N;
    float T,A;
    cin >> N;
    cin >> T >> A;
    vector<float> H(N);

    float diff = 10000;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        /* code */
        cin >> H[i];
        H[i] = T - (H[i] * 0.006);  
        if(diff > abs(A - H[i])){
            diff = abs(A - H[i]);
            ans = i + 1;
        }
    }
    cout << ans << endl;
    

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
 
public class Main {
	
	public static void main(String[] args) {
		FastReader scan = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		Task solver = new Task();
		int t = 1;
		while(t-->0) solver.solve(1, scan, out);
		out.close();
	}
	
	static class Task {
		
		public void solve(int testNumber, FastReader scan, PrintWriter out) {
			long total = 0;
			int n = scan.nextInt(), m = scan.nextInt();
			PriorityQueue<Long> q = new PriorityQueue<>(Collections.reverseOrder());
			for(int i = 0; i < n; i++) q.add(scan.nextLong());
			for(int i = 0; i < m; i++) {
				long g = q.poll();
				q.add(g/2);
			}
			for(long x : q) total += x;
			out.println(total);
		}
	}
	
	static void shuffle(int[] a) {
		Random get = new Random();
		for(int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	
	static void shuffle(long[] a) {
		Random get = new Random();
		for(int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	
 
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}
 
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
 
}

Measured memory_bytes: 45780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

ll a, b, x;

int main(void){
	
	scanf("%lld %lld %lld", &a, &b, &x);
	
	if(a == 0) printf("%lld\n", (b / x) + 1);
	else printf("%lld\n", (b / x) - ((a % x) ? a / x : (a / x) - 1));
	
    return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var l = new List<long>();
		l.Add(A * C);
		l.Add(B * C);
		l.Add(A * D);
		l.Add(B * D);
		if(A <= 0 && 0 <= B){
			l.Add(0);
		}
		if(C <= 0 && 0 <= D){
			l.Add(0);
		}
		Console.WriteLine(l.Max());
	}
	long A,B,C,D;
	public Sol(){
		var d = rla();
		A = d[0]; B = d[1]; C = d[2]; D = d[3];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 28332
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(int)n;i++)
using namespace std;
int main(){
  //一致させることができるか
  int b=0;
  string s, s1, t, min_s;
  cin >> s >> t;
  s1=s;
  rep(i, s.size()-t.size()+1){
    int k=0;
    for(int j=i;j<i+t.size(); j++){
      if(s.at(j)==t.at(j-i)) continue;
      else if(s.at(j)=='?') s.at(j)=t.at(j-i);
      else {
        k=1;
        break;
      }
    }
    if(k!=1){
      for(int j=0;j<s.size();j++){
      if(s.at(j)=='?') s.at(j)='a';
      }
    }
    else if(k==1) {
      s=s1;
      continue;
    }
    if(b==0) b=1;
    else b=2;
      
    if(b==1) {
      min_s=s;
      //cout << min_s << endl;
    }
    else {
      if(s<min_s) min_s=s;
    }
    //if(i==2) cout << min_s << endl;
    s=s1;
    //cout << min_s << endl;
  }
  if(b==0) cout << "UNRESTORABLE" << endl;
  else cout << min_s << endl;
  //cout <<  << endl;
}


    
    

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll x, t;
    cin >> x >> t;
    cout << max(x - t, 0LL) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
using namespace std;

typedef unsigned long long ull;

const int thr = 1;

map<ull,int> memo;

vector<ull> tbl;

void maketbl(ull s, int t, int u){
	if(t == 0){
		tbl.push_back(s);
	}
	for(u = min(t, u); u >= 1; --u){
		maketbl(s + (1ull << ((u - 1) * 8)), t - u, u);
	}
}

int dfs2(ull, int, int);

int dfs1(ull s){
	if(s < 10){ return 0; }
	if(memo.count(s)){
		return memo[s];
	}
	int k;
	for(k = 8; !(s >> ((k - 1) * 8)); --k);

	int res = 0;
	if(k <= thr){
		ull r = s;
		for(size_t i = 0; i < tbl.size(); ){
			ull p = r;
			bool ok = true;
			for(int j = thr; j >= 1; --j){
				if((p >> ((j - 1) * 8) & 0xff) >= (tbl[i] >> ((j - 1) * 8) & 0xff)){
					p -= tbl[i] & (0xffull << ((j - 1) * 8));
				}
				else{
					ok = false;
				}
			}
			if(ok){
				r = p;
				++res;
			}
			else{
				++i;
			}
		}
	}
	else{
		int a = dfs2(s - (1ull << ((k - 1) * 8)), 10 - k, k);
		int b = dfs1(s & ((1ull << ((k - 1) * 8)) - 1));
		res = max(a, b);
	}
	
	memo[s] = res;
	return res;
}

int dfs2(ull s, int t, int u){
	if(s >> ((t - 1) * 8) & 0xff){
		return dfs1(s - (1ull << ((t - 1) * 8))) + 1;
	}
	if(t == 1){
		return 0;
	}
	if(t == 2){
		if((s & 0xff) >= 2){
			return dfs1(s - 2) + 1;
		}
		return 0;
	}
	if(t == 3){
		if(s & 0xff && s & 0xff00){
			return dfs1(s - 0x101) + 1;
		}
		if((s & 0xff) >= 3){
			return dfs1(s - 3) + 1;
		}
		return 0;
	}
	
	int res = 0;
	for(u = min(t, u); u >= 1; --u){
		if(s >> ((u - 1) * 8) & 0xff){
			int a = dfs2(s - (1ull << ((u - 1) * 8)), t - u, u);
			res = max(res, a);
		}
	}
	return res;
}

int main(){
	maketbl(0, 10, thr);
	sort(tbl.begin(), tbl.end(), greater<ull>());

	int n, x;
	while(scanf("%d", &n), n){
		int cnt[10] = {};
		for(int i = 0; i < n; ++i){
			scanf("%d", &x);
			++cnt[x];
		}
		
		int ans = 0;
		for(int i = 1; i <= 4; ++i){
			x = min(cnt[i], cnt[10 - i]);
			ans += x;
			cnt[i] -= x;
			cnt[10 - i] -= x;
		}
		
		ans += cnt[5] / 2;
		cnt[5] &= 1;
		
		ull s = 0;
		for(int i = 1; i <= 8; ++i){
			s |= (ull)cnt[i] << ((i - 1) * 8);
		}
		
		memo.clear();
		ans += dfs1(s);
		printf("%d\n", ans);
	}
}

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

N = int(input())
l = list(map(int, input().split()))

s = max(l) - min(l)
if s == 1:
   print("1")
else:
   if s % 2 == 0:
      print(int(s / 2))
   else:
      print(int(s / 2) + 1)



Measured memory_bytes: 5616
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(int i = (int)(b); i < (int)(e); ++i)
#define RFOR(i, b, e) for(int i = (int)(e-1); i >= 0; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>
#define ALL(x) (x).begin(),(x).end()
#define PAIR pair<int,int>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;

using namespace std;

int main() {
	VI v(3);
	REP(i, 3) { cin >> v[i]; }

	sort(ALL(v));
	
	cout << v[0] + v[1] + 10 * v[2] << endl;
}

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

int main(){
  int n, k, c;
  cin>>n>>k>>c;
  string s;
  cin>>s;
  
  if(n==1){
    cout<<1<<endl;
    return 0;
  }
  
  int dpl[n], dpr[n];
  
  dpl[0] = s[0] == 'o';
  for(int i = 1; i < n; ++i){
    dpl[i] = dpl[i-1];
    if(s[i] == 'o' && i-c-1 >= 0){
      dpl[i] = max(dpl[i], 1+dpl[i-c-1]);
    }
    else if(s[i] == 'o')dpl[i] = max(dpl[i], 1);
  }
  
  dpr[n-1] = s[n-1] == 'o';
  for(int i = n-2; i >= 0; --i){
    dpr[i] = dpr[i+1];
    if(s[i] == 'o' && i+c+1 < n){
      dpr[i] = max(dpr[i], 1+dpr[i+c+1]);
    }
    else if(s[i] == 'o')dpr[i] = max(dpr[i], 1);
  }
  
  //assert(k == dpl[n-1] && dpr[0] == k);
  
  if(n>1 && dpr[1] < k)cout<<1<<'\n';
  
  for(int i=1; i<n-1; ++i){
    if(dpl[i-1] + dpr[i+1] < k){
      cout<<i+1<<'\n';
    }
  }
  
  if(n>1 && dpl[n-2]<k)cout<<n<<'\n';
  
}

Measured memory_bytes: 3332
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<queue>
using namespace std;
int n,m;
int col,color[10001],tot;
int shuchu[101][101];
int main()
{
	cin>>n>>m;
	cin>>col;
	for(int i=1;i<=col;i++)
	{
		int times;
		cin>>times;
		for(int j=1;j<=times;j++)
		{
			color[tot+j]=i;
		}
		tot+=times;
	}
	int k=0;
	for(int i=1;i<=n;i++)
	{
		if(i&1){
			for(int j=1;j<=m;j++){
				shuchu[i][j]=color[++k];
			}
		}
		else{
			for(int j=m;j>=1;j--){
				shuchu[i][j]=color[++k];
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)cout<<shuchu[i][j]<<" ";
		cout<<endl;
	}
	return 0;
 }


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

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define DEC(i, s) for (int i = (s); i >= 0; i--)

#define SIZE(v) (int)((v).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define FIND(m, w) ((m).find(w) != (m).end())

int n, m;
int taro[200];
int hanako[200];

int main() {
  while (scanf("%d %d", &n, &m), n|m) {
    int tsum = 0;
    int hsum = 0;
    REP(i, n) { scanf("%d", &taro[i]); tsum += taro[i]; }
    REP(i, m) { scanf("%d", &hanako[i]); hsum += hanako[i]; }
    REP(i, n) REP(j, m) {
      if (tsum - taro[i] + hanako[j] == hsum - hanako[j] + taro[i]) {
        printf("%d %d\n", taro[i], hanako[j]);
        goto next;
      }
    }
    puts("-1");
next:;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  set<int>S;
  int a=0;
  for(int i=0;i<N;i++){
  int x;
    cin>>x;
    if(1<=x && x<=399)
      S.insert(1);
    else if(x<=799)
    S.insert(2);
    else if(x<=1199)
      S.insert(3);
    else if(x<=1599)
      S.insert(4);
    else if(x<=1999)
      S.insert(5);
    else if(x<=2399)
      S.insert(6);
    else if(x<=2799)
      S.insert(7);
    else if(x<=3199)
      S.insert(8);
    else 
      a++;
  
  
  } int n=S.size();
  int Min=max(n,1);
  
  int Max=n+a;
  cout<<Min<<" "<<Max<<endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    char X, Y;
    cin >> X >> Y;
    
    int x,y;
    if (X == 'A'){
        x = 1;    
    }
    else if (X == 'B'){
        x = 2;
    }
    else if (X == 'C'){
        x = 3;
    }
    else if (X == 'D'){
        x = 4;
    }
    else if (X == 'E'){
        x = 5;
    }
    else if (X == 'F'){
        x = 6;
    }

    if (Y == 'A'){
        y = 1;    
    }
    else if (Y == 'B'){
        y = 2;
    }
    else if (Y == 'C'){
        y = 3;
    }
    else if (Y == 'D'){
        y = 4;
    }
    else if (Y == 'E'){
        y = 5;
    }
    else if (Y == 'F'){
        y = 6;
    }

    if (x == y){
        cout << '=' << endl;
    }
    else if (x < y){
        cout << '<' << endl;
    }
    else {
        cout << '>' << endl;
    }
}

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = False
show_flg = True


def main():
    X, Y = MI()
    tmp = math.log2(Y) - math.log2(X)
    # print(X * 2 ** (int(tmp) + 1))
    if X * 2 ** (int(tmp) + 1) <= Y:
        print(int(tmp) + 2)
        return
    elif X * 2 ** int(tmp) <= Y:
        print(int(tmp) + 1)
        return
    elif X * 2 ** (int(tmp)-1) <= Y:
        print(int(tmp))
        return

    print(-1)

    return

    ans = 0
    c = X
    while c <= Y:
        c = c * 2
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
#include <iostream>
     
    using namespace std;
     
    long Gcd(long m, long n) {
      long temp = 0;
      while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
      }
      return n;
    }
     
    long Lcm(long m, long n) {
      return m * n / Gcd(m,n); 
    }
     
    int main() {
      long A, B, C, D;
      cin >> A >> B >> C >> D;
      long div_c = B / C;
      long div_c_out = (A-1) / C;
      div_c -= div_c_out;
     
      long div_d = B / D;
      long div_d_out = (A-1) / D;
      div_d -= div_d_out;
     
      long lcm = Lcm(C, D);
      long div_cd = B /lcm;
      long div_cd_out = (A - 1) / lcm;
      div_cd -= div_cd_out;
      
      long res = B - A + 1 - (div_c - div_cd + div_d);
      
      cout << res << endl;
     
      return 0;
    }

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

public class Main {

	int INF = 1 << 24;

	public class Point3D{
		double x,y,z;
		public Point3D(double x, double y, double z) {
			this.x = x;this.y = y;this.z = z;
		}

		private double distance(Point3D p) {
			double x = this.x - p.x;
			double y = this.y - p.y;
			double z = this.z - p.z;
			double dissq = x * x + y*y + z*z;
			return Math.sqrt(dissq);
		}
	}

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			double [] rlist = new double[n];
			Point3D [] plist = new Point3D[n];
			for(int i = 0; i < n; i++){
				double x = sc.nextDouble();
				double y = sc.nextDouble();
				double z = sc.nextDouble();
				rlist[i] = sc.nextDouble();
				plist[i] = new Point3D(x,y,z);
			}

			double [][] pass = new double[n][n];
			for(int i = 0; i < n; i++){
				for(int j = i + 1; j < n; j++){
					double distance = plist[i].distance(plist[j]);
					double rDistance = rlist[i] + rlist[j];
					double value = Math.max(0.0, distance - rDistance);
					pass[i][j] = value;
					pass[j][i] = value;
				}
			}

			double res = mst(pass);
			System.out.printf("%.3f\n",res);
		}
	}

	private double mst(double[][] pass) {
		int n = pass.length;
		double [] mincost = new double[n];
		boolean [] isused = new boolean[n];
		Arrays.fill(mincost, INF);

		mincost[0] = 0.0;
		double res = 0.0;
		while(true){
			int v = -1;
			for(int i = 0; i < n; i++){
				if(! isused[i] &&( v == -1 || mincost[i] < mincost[v])){
					v = i;
				}
			}
			if(v == -1) break;
			isused[v] = true;
			res += mincost[v];
			for(int i = 0; i < n; i++){
				mincost[i] = Math.min(mincost[i], pass[v][i]);
			}
		}
		return res;
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 13000
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    dp = [[0] * 4 for i in range(N)]

    dp[0][0] = A[0]
    dp[0][1] = -float('inf')
    dp[0][2] = -float('inf')
    dp[0][3] = -A[0]

    for i in range(1, N):
        a = A[i]
        dp[i][0] = max(dp[i-1][0] + a, dp[i-1][1] + a)
        dp[i][1] = max(dp[i-1][2] - a, dp[i-1][3] - a)
        dp[i][2] = max(dp[i-1][2] + a, dp[i-1][3] + a)
        dp[i][3] = max(dp[i-1][0] - a, dp[i-1][1] - a)
    print(max(dp[-1][:2]))


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

int main(){
  int n;
  cin >>n;
  vector<int> P(n);
  for(int i=0;i<n;i++){
    cin >>P.at(i);
  }
  int count =0;
  for(int i=1;i<n-1;i++){
    if((P.at(i)>P.at(i-1)&P.at(i)<P.at(i+1))||(P.at(i)<P.at(i-1)&P.at(i)>P.at(i+1))){
      count ++;
    }
  }
  cout <<count<<endl;
}

    

Measured memory_bytes: 256
#include <stdio.h>
#define max 2000000

void CountingS(int *,int *, int);


int n=0;
int C[max];

int main(){
  int i=0;
  scanf("%d",&n);
  int A[n+1];
  int B[n+1];
  for(i=0;i<n;i++){
    scanf("%d",&A[i+1]);
  }
  
  CountingS(A,B,n);
  
  for(i=1;i<n+1;i++){
    if(i==1)printf("%d",B[i]);
    else printf(" %d",B[i]);
  }
  printf("\n");

  return 0;
}

void CountingS(int *A,int *B,int k){
  int i=0;
  int j=0;
  for(i=0;i<=max;i++)C[i]=0;
  for(j=0;j<k;j++){
    C[A[j+1]]++;
  }
  for(i=1;i<=max;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=1;j<=k;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
}



Measured memory_bytes: 25220
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    ll k;
    cin >> s >> k;

    ll m = s.size() - 1;
    REP(i, s.size())if(s[i] != '1') {
        m = i;
        break;
    }
    cout << (k <= m ? '1' : s[m]) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,K;
  cin>>N>>K;
  vector<int>A={};
  for(int i=0;i<K;i++)
    A.push_back(-1000000000);
  for(int i=0;i<N;i++){
  int x;
    cin>>x;
    A.push_back(x);
  
  }for(int i=0;i<K;i++)
    A.push_back(1000000000);
  auto itr=lower_bound(A.begin(),A.end(),0);
  int k=distance(A.begin(),itr);
  int ans;
  if(*itr!=0){
    ans=min(abs(A.at(k-K)),A.at(k+K-1));
    for(int i=0;i<=K-2;i++){
      int a=A.at(k+i); int b=abs(A.at(k-K+1+i));
      int Min=a+b+min(a,b);
      if(Min<ans)
        ans=Min;
    }cout<<ans<<endl;
}else{
ans=abs(A.at(k-K+1));
    for(int i=0;i<K;i++){
    int a=abs(A.at(k-K+i+1));
      int b=A.at(k+i);
      int Min=a+b+min(a,b);
      if(Min<ans)
        ans=Min;
    } cout<<ans<<endl;

}
   return 0;
}

Measured memory_bytes: 2420
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===

def main():
    h, w = ns()
    table = [list(input()) for _ in range(h)]
    not_visited = [[True for _ in range(w)] for __ in range(h)]
    dist = [[INF for _ in range(w)] for __ in range(h)]

    que = collections.deque()
    for hi in range(h):
        for wi in range(w):
            if table[hi][wi] == "#":
                not_visited[hi][wi] = False
                dist[hi][wi] = 0
                que.append([hi, wi])

    nxt = [[0, 1], [0, -1], [1, 0], [-1, 0]]
    cnt = -1
    ans = 0
    while len(que):
        cnt += 1
        for i in range(len(que)):
            hi, wi = que.popleft()
            for yi, xi in nxt:
                th = hi + yi
                tw = wi + xi
                if -1 < th < h and -1 < tw < w:
                    if not_visited[th][tw]:
                        not_visited[th][tw] = False
                        dist[th][tw] = min(dist[th][tw], dist[hi][wi] + 1)
                        que.append([th, tw])

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 224616
def main():
  n = int(input())

  mod = 26

  n2 = n
  i = 0
  while n > 0:
    i += 1
    n2 = n
    n -= mod
    if n <= 0:
      break

    mod *= 26

  n = n2 - 1
  arr = []
  while n > 0:
    arr.append(n % 26)
    n //= 26


  arr.extend([0 for _ in range(i - len(arr))])
  arr.reverse()


  ref = ("a", "b", "c", "d", "e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z")

  print("".join([ref[a] for a in arr]))


main()


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

using namespace std;

using ll = long long;


int main(){
    ll n;
    cin >> n;
    ll arr[n];
    for(ll i = 0; i < n; ++i){
        cin >> arr[i];
    }
    sort(arr, arr + n, greater<ll>());
    ll ans = 0;
    for(ll i = 1; i < n; ++i){
        ans += arr[i / 2];
    }
    cout << ans;

    return 0;

}


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

using namespace std;

using int64 = long long;


int main()
{
  string S, T;

  cin >> S;
  cin >> T;

  string x = "~";
  for(int i = 0; i <= (int) S.size() - (int) T.size(); i++) {
    bool match = true;
    for(int j = 0; j < T.size(); j++) {
      match &= S[i + j] == '?' || S[i + j] == T[j];
    }

    if(match) {
      string Q = S;
      for(int j = 0; j < T.size(); j++) Q[i + j] = T[j];
      for(int j = 0; j < Q.size(); j++) if(Q[j] == '?') Q[j] = 'a';
      x = min(x, Q);
    }
  }

  if(x == "~") x = "UNRESTORABLE";
  cout << x << endl;
}

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

using namespace std;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  string s;
  cin >> s;

  int sum = 0;
  for (int i = 1; i < n; ++i) {
    if (s[i] == s[i - 1]) sum++;
  }

  cout << min(sum + 2 * k, n - 1) << endl;
  return 0;
}



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

using namespace std;

int main()
{
    long long n, m, a, sum[100010], cnt=1, vp, ans=0;
    cin>>n>>m;
    sum[0]=0;
    for (int i=1; i<=n; i++)
    {
        cin>>a;
        sum[i]=sum[i-1]+a;
    }
    for (int i=0; i<=n; i++) sum[i]%=m;
    sort(sum, sum+n+1);
    vp=sum[0];
    for (int i=1; i<=n; i++)
    {
        if (vp!=sum[i])
        {
            ans+=cnt*(cnt-1)/2;
            vp=sum[i];
            cnt=1;
        }
        else cnt++;
    }
    ans+=cnt*(cnt-1)/2;
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n;
int dp[100005][4];
int arr[100005][4];
int rec(int x, int y){
	if(x == n)return 0;
	if(dp[x][y] != -1)return dp[x][y];
	int ret = -1000000005;
	for(int i = 0; i < 3; i++){
		if(i == y)continue;
		ret = max(ret, arr[x][i] + rec(x+1, i));
	}
	return dp[x][y] = ret;
}
int main(){
	cin >> n;
	for(int i = 0; i <= 100000; i++)dp[i][0] = -1, dp[i][1] = -1, dp[i][2] = -1, dp[i][3] = -1;
	for(int i = 0; i < n; i++)cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
	cout << rec(0,3);
}

Measured memory_bytes: 11136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] gr = new int[N];
		int[][] vec = new int[N][4];
		for (int i = 0; i < M; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			if (gr[a] < 4) {
				vec[a][gr[a]] = b;
			}
			if (gr[b] < 4) {
				vec[b][gr[b]] = a;
			}
			gr[a]++;
			gr[b]++;
		}
		boolean can = true;
		int six = 0, four = 0, lastFour = -1;
		for (int i = 0; i < N; i++) {
			if (gr[i] % 2 != 0) can = false;
			if (gr[i] >= 6) six++;
			else if (gr[i] == 4) {
				four++;
				lastFour = i;
			}
		}
		if (can) {
			if (six == 0 && four < 2) can = false;
			if (six == 0 && four == 2) {
				can = false;
				for (int i = 0; i < 4; i++) {
					int prev = lastFour;
					int next = vec[lastFour][i];
					while (next != lastFour && gr[next] == 2) {
						int tmp = next;
						next = vec[next][0] + vec[next][1] - prev;
						prev = tmp;
					}
					if (next == lastFour) {
						can = true;
						break;
					}
				}
			}
		}
		out.println(can ? "Yes" : "No");
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 46324
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void rd(string &x){
  char *buf = (char *)wmem;
  rd(buf);
  x = buf;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
inline void wt_L(string &x){
  int i=0;
  for(i=0;x[i]!='\0';i++){
    putchar_unlocked(x[i]);
  }
}
string S;
string w[3];
int main(){
  int i;
  wmem = memarr;
  w[0] = "Sunny";
  w[1] = "Cloudy";
  w[2] = "Rainy";
  rd(S);
  for(i=0;i<(3);i++){
    if(S==w[i]){
      wt_L(w[(i+1)%3]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20190914-1

// --- original code ---
// string S;
// string w[3];
// {
//   w[0] = "Sunny";
//   w[1] = "Cloudy";
//   w[2] = "Rainy";
//   rd(S);
//   rep(i,3) if(S==w[i]) wt(w[(i+1)%3]);
// }


Measured memory_bytes: 256
import math

def distance(x,y):
    sum = 0
    for i in range(d):
        sum += (x[i] - y[i]) ** 2
    return math.sqrt(sum)

n, d = list(map(int, input().split()))
x = []
memoize = []
count = 0

for i in range(n):
    x.append(list(map(int, input().split())))

for i in range(n):
    for j in range(n):
        if i == j or ((i,j) in memoize) or ((j, i) in memoize):
            continue

        if float.is_integer(distance(x[i], x[j])):
            count += 1

count = count // 2
print(count)


Measured memory_bytes: 3064
#include <stdio.h>

/*
中心の座標をそれぞれ求める
*/
int getCenterX( int boardSize );
int getCenterY( int boardSize );

/*
x,yの色を取得する
*/
int getLostColor( int x, int y, int boardSize );

int main( void )
{
	int boardSize;
	int numOfLost;
	int x;
	int y;
	int i;
	
	while( scanf( "%d", &boardSize ) != EOF )
	{
		scanf( "%d", &numOfLost );
		for( i = 0; i < numOfLost; i++ )
		{
			scanf( "%d %d", &x, &y );
			printf( "%d\n", getLostColor( x, y, boardSize ) );
		}
	}
	
	return (0);
}

int getLostColor( int x, int y, int boardSize )
{
	int centerX;
	int centerY;
	
	
	//中心のX,Y座標を求める
	centerX = getCenterX( boardSize );
	centerY = getCenterY( boardSize );
	
	if( x <= centerX && y <= centerY )
	{
		if( x <= y )
		{
			return ( (x - 1) % 3 + 1 );
		}
		else
		{
			return ( (y - 1) % 3 + 1 );
		}
	}
	else if( x <= centerX && y > centerY )
	{
		y = boardSize - y + 1;
		if( x <= y )
		{
			return ( (x - 1) % 3 + 1 );
		}
		else
		{
			return ( (y - 1) % 3 + 1 );
		}
	}
	else if( x >= centerX && y < centerY )
	{
		x = boardSize - x + 1;
		if( x <= y )
		{
			return ( (x - 1) % 3 + 1 );
		}
		else
		{
			return ( (y - 1) % 3 + 1 );
		}
	}
	else
	{
		x = boardSize - x + 1;
		y = boardSize - y + 1;
		if( x <= y )
		{
			return ( (x - 1) % 3 + 1 );
		}
		else
		{
			return ( (y - 1) % 3 + 1 );
		}
	}
}

int getCenterX( int boardSize )
{
	int centerX = ( boardSize + 1 ) / 2;
	return ( centerX );
}

int getCenterY( int boardSize )
{
	int centerY = (boardSize + 1) / 2;
	return ( centerY );
}

Measured memory_bytes: 596
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;

int main()
{
	double a,b;
	double size=3.305785;
	double ans;
	cin>>a>>b;
	ans=a*b/size;
	printf("%.6lf\n",ans);
	return 0;
}

Measured memory_bytes: 1236