akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
int N;
  cin>>N;
int a[N];
int sum=0;
for(int i=0;i<N;i++) {
cin>>a[i];
sum+=a[i];
}
double mean=(double)(sum)/(double)(N);
int int_mean;
  //cout<<mean-(int)(mean)/1<<endl;
if(mean-(int)(mean)/1>=0.5) int_mean=mean/1+1;
else int_mean=mean/1;
  //cout<<int_mean<<endl;
int ans=0;
for(int i=0;i<N;i++){
  ans+=(int_mean-a[i])*(int_mean-a[i]);
}
cout<< ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
string S;
int k[1000000]={0};
int main()
{
    while(cin>>S)
    {  //if(S=="0")return 0;
    int len=S.size();
    int i=0,j;
    int count=0;
    for(j=1;j<len;j++)
     if(S[j]!=S[j-1])
        {
            k[count++]=max(j,len-j);
           // cout<<k[]
        }
     k[count]=len;
    sort(k,k+count+1);
    cout<<k[0]<<endl;
    }
}



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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

template<typename T>
struct BIT{
    int N;
    vector<T> dat;
    BIT(int n) : N(n), dat(n+1,0){ }
    void add(int i, T num){
        for(int x = i+1; x <= N; x += (x & -x)) dat[x] = max(dat[x], num);
    }
    T mx(int i){
        T ret = 0;
        for(int x = i+1; x > 0; x -= (x & -x)) ret = max(ret, dat[x]);
        return ret;
    }
};

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    int n; cin >> n;
    vi H(n), A(n);
    rep(i,n) cin >> H[i];
    rep(i,n) cin >> A[i];
    BIT<ll> bit(200010);
    rep(i,n){
        int h = H[i], a = A[i];
        bit.add(h, bit.mx(h)+a);
    }

    cout << bit.mx(200010) << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k,q; cin>>k>>q;
    vll d(k);
    rep(i,k) cin>>d[i];
    while(q--){
        ll n,x,m; cin>>n>>x>>m; x%=m;
        vll dd(k);
        rep(i,k) dd[i] = (d[i]%m==0)?m:d[i]%m;
        vll sum(k+1);
        rep(i,k) sum[i+1]=sum[i]+dd[i];
        ll tail = x + (n-1)/k*sum[k] + sum[(n-1)%k];
        int ans = (n-1)-tail/m;
        cout<<ans<<endl;
    }
    return 0;
}


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

//using namespace--------------------------------------------------------------------------------------------------------------
using namespace std;

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i, s, n) for(int i = s; i < n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << endl
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define FOREACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#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 SORT(c) sort((c).begin(),(c).end())
#define INF 1 << 25
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define sq(n) (n) * (n)

//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ull;

//const------------------------------------------------------------------------------------------------------------------------
const double EPS = 1e-10;
const double PI = acos( -1.0 );

//global-----------------------------------------------------------------------------------------------------------------------
double a;
double test;

//function---------------------------------------------------------------------------------------------------------------------
int main() {
	while ( scanf( "%lf", &a ) != EOF ) {
		for ( int i = 2;; i++ ) {
			test = ( i * 5 - 5 );
			test /= 4.9;
			test = sqrt( test );
			if ( test * 9.8 >= a ) {
				printf( "%d\n", i );
				break;
			}
		}
	}
	return 0;
}

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

int main(){
	int n,ans=0,cnt=0;
	cin>>n;
	
	int a[n];
	for(int i=0;i<n;i++)  cin>>a[i];
	
	for(int i=0;i<n;i++){
		if(a[i]%2==0){
			ans++;
			if(a[i]%3==0||a[i]%5==0){
				cnt++;
			}
		}
	}
	if(ans==cnt)
		cout<<"APPROVED"<<endl;
	else
		cout<<"DENIED"<<endl;
		
	return 0;
}

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

int main(){
    string n;
    cin >> n;
    int sum = 0;

    for(int i=0; i<n.length(); i++){
        char tmp = n[i];
        sum += atoi(&tmp);
    }

    if(sum % 9==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

vector<int> suffix_array(vector<int>& s) {
    int n = s.size();
    vector<int> p(n), c(n), cnt(n);
    for (int i = 0; i < n; i++) cnt[s[i]]++;
    for (int i = 1; i < n; i++) cnt[i] += cnt[i-1];
    for (int i = 0; i < n; i++) p[--cnt[s[i]]] = i;
    int cl = 0;
    for (int i = 1; i < n; i++) {
        if (s[p[i]] != s[p[i-1]]) cl++;
        c[p[i]] = cl;
    }
    vector<int> pn(n), cn(n);
    for (int h = 0; (1 << h) < n; h++) {
        for (int i = 0; i < n; i++) {
            pn[i] = p[i] - (1 << h);
            if (pn[i] < 0) pn[i] += n;
        }
        fill(cnt.begin(), cnt.end(), 0);
        for (int i = 0; i < n; i++) cnt[c[pn[i]]]++;
        for (int i = 1; i < n; i++) cnt[i] += cnt[i-1];
        for (int i = n - 1; i >= 0; i--) {
            cnt[c[pn[i]]]--;
            p[cnt[c[pn[i]]]] = pn[i];
        }
        cn[p[0]] = 0;
        cl = 0;
        for (int i = 1; i < n; i++) {
            pair<int, int> cur(c[p[i]], c[(p[i] + (1 << h)) % n]);
            pair<int, int> prev(c[p[i-1]], c[(p[i-1] + (1 << h)) % n]);
            if (cur != prev) cl++;
            cn[p[i]] = cl;
        }
        swap(c, cn);
    }
    return p;
}

int bin_search(vector<int>& a, vector<int>& b, vector<int>& sa, bool lower) {
    int n = a.size();
    int lb = -1, ub = n;
    while (ub - lb > 1) {
        int m = (lb + ub) / 2;
        bool flag = false;
        for (int i = 0; i < n; i++) {
            int j = (sa[m] + i) % n;
            if (a[i] < b[j]) {
                ub = m;
                flag = true;
                break;
            }
            if (a[i] > b[j]) {
                lb = m;
                flag = true;
                break;
            }
        }
        if (!flag) {
            if (lower) ub = m;
            else lb = m;
        }
    }
    return ub;
}

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

    int N;
    cin >> N;
    vector<int> a(N), b(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i++) cin >> b[i];
    vector<int> cnt(N);
    for (int i = 0; i < 30; i++) {
        vector<int> c(N), d(N);
        for (int j = 0; j < N; j++) {
            c[j] = a[j] >> i & 1;
            d[j] = b[j] >> i & 1;
        }
        auto sa = suffix_array(d);
        int lb = bin_search(c, d, sa, true);
        int ub = bin_search(c, d, sa, false);
        for (int j = lb; j < ub; j++) cnt[(N - sa[j]) % N]++;

        for (int j = 0; j < N; j++) c[j] = 1 - c[j];
        lb = bin_search(c, d, sa, true);
        ub = bin_search(c, d, sa, false);
        for (int j = lb; j < ub; j++) cnt[(N - sa[j]) % N]++;
    }
    for (int k = 0; k < N; k++) {
        if (cnt[k] == 30) {
            int x = a[k] ^ b[0];
            cout << k << " " << x << "\n";
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>

using namespace std;

#define REP(i,e,s) for(register int i=(e); i<=(s); i++)
#define DREP(i,e,s) for(register int i=(e); i>=(s); i--)
#define ll long long
#define DE(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG(a) DE("DEBUG: %d\n",a)
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
int read() {
	int x=0,f=1,ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int main() {
	char a=getchar();
	printf("%c",a+1);
	return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int a,b;

string itostring(int a){
    stringstream ss;
    string res;
    ss << a;
    ss >> res;
    return res;
}

int main(){
    cin >> a >> b;
    ll ans = 0;
    FOR(i,a,b+1){
        string s = itostring(i);
        string t = s;
        reverse(ALL(s));
        if(s == t)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n; cin >> n;
  vector<int64> a(n);
  rep(i, n) cin >> a[i];

  int right = 0;
  int64 sum = 0;
  int64 ans = 0;

  for (int left = 0; left < n; ++left) {
    // increment right while ok

    while (right < n && sum + a[right] == (sum^a[right])) {
      sum += a[right];
      ++right;
    }
    int len = right - left;

    /**
     *  do something using 'len'(length of section which satisfies condition)
    **/
    ans += len;

    // if right do not move at all, increment it
    if (right == left) {
      ++right;
    } else {
      sum -= a[left];
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main(void)
{
	int n;
	scanf("%d",&n);
	--n;
	
	ll ans = 0;
	for(int i=1; i<=n; ++i)
		ans += n/i;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=305;
int head[maxn],t[maxn*maxn<<1],ne[maxn*maxn<<1],sap[maxn*maxn<<1],m,S,T,d[maxn],num;
int cur[maxn],cnt[maxn],his[maxn],edge[maxn],pre[maxn];
const int inf=1e9;
inline void addedge(int x,int y,int z){
	ne[++num]=head[x];head[x]=num;t[num]=y;sap[num]=z;
	ne[++num]=head[y];head[y]=num;t[num]=x;sap[num]=0;
}
inline int isap(){
	rep(i,1,T)cur[i]=head[i],d[i]=0,cnt[i]=0;
	cnt[0]=T;
	int i=S,aug=inf,ans=0,minnum,jl;
	while(d[S]<T){
		bool flag=0;his[i]=aug;for(int j=cur[i];j!=-1;j=ne[j])if(d[t[j]]+1==d[i]&&sap[j]){
			cur[i]=j;edge[i]=j;pre[t[j]]=i;aug=min(aug,sap[j]);flag=1;i=t[j];
			if(i==T){
				ans+=aug;
				while(i!=S){i=pre[i];sap[edge[i]]-=aug;sap[edge[i]^1]+=aug;}
				aug=inf;
			}break;
		}if(flag)continue;minnum=T;forE(j,i)if(sap[j]&&d[t[j]]<minnum)minnum=d[t[j]],jl=j;
		if(--cnt[d[i]]==0)return ans;cnt[d[i]=minnum+1]++;cur[i]=jl;
		if(i!=S){i=pre[i];aug=his[i];}
	}return ans;
}
bool flag[10000005];
int prime[1000005],n,tot;
inline void prprpr(){
	memset(flag,1,sizeof(flag));
	rep(i,2,10000000){
		if(flag[i])prime[++tot]=i;
		rep(j,1,tot){
			if(i*prime[j]>10000000)break;
			flag[i*prime[j]]=0;
			if(i%prime[j]==0)break;
		}
	}
}
int a[205],b[205],idx;
int p[205],q[205];
int cntp,cntq;
inline void insert(int x){
	if(x&1)
		p[++cntp]=x;
	else
		q[++cntq]=x;
}
inline bool is_prime(int x,int y){	
	if(x<y)swap(x,y);
	return flag[x-y];
}	
int main(){
	prprpr();
	read(n);
	rep(i,1,n)read(a[i]);a[0]=-100;
	rep(i,1,n){
		if(a[i]-1!=a[i-1])b[++idx]=a[i];
		if(a[i]+1!=a[i+1])b[++idx]=a[i]+1;
	}flag[2]=0;flag[1]=0;
	rep(i,1,idx)insert(b[i]);
	S=cntp+cntq+1;T=cntp+cntq+2;
	rep(i,1,T)head[i]=-1;num=1;
	rep(i,1,cntp)addedge(S,i,1);
	rep(i,cntp+1,cntp+cntq)addedge(i,T,1);
	rep(i,1,cntp)rep(j,1,cntq)if(is_prime(p[i],q[j]))
		addedge(i,j+cntp,1);
	printf("%d\n",cntp+cntq-(isap()-(cntp&1)>>1<<1)-(cntp&1));	
	return 0;
}


Measured memory_bytes: 14720
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

int main ()
{
  prep();
  int h, a;
  cin >> h >> a;
  cout << h/a+(h%a != 0);
  return 0; 
}


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

int main() {
    int n, k; cin >> n >> k;
    double ans = 0;
    for (int i=1; i<=n; ++i) {
        double p = 1;
        int now = i;
        while (now < k) {
            now *= 2;
            p /= 2;
        }
        ans += p;
    }
    ans /= n;
    printf("%.15lf\n", ans);
}

Measured memory_bytes: 256
#include<algorithm>
#include<vector>
#include<list>
#include<iostream>
#include<utility>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<iterator>
#include<map>
#include<limits>

const int INF=2147483647;

using namespace std;

int run(vector<int>& vi, int pos){
    int n=vi.size();
    bool inc=false, dec=false;
    int num=vi[pos];
    while(num==vi[pos] && pos<n){
        pos++;
    }
    if(pos==n-1) return -1;
    
    if(vi[pos]<num) dec=true;
    else inc=true;
    
    for(int i=pos+1; i<n; i++){
        if((vi[i]>vi[i-1] && dec)||(vi[i]<vi[i-1]&& inc)) return i;
    }
    return -1;
    
}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    vector<int> vi(n,0);
    for(int i=0; i<n; i++){
        cin>>vi[i];
    }
    int ans=0;
    int pos=0;
    for(int i=0; i!=-1; i=run(vi,i)){
        ans++;
        
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 640
a = int(input())

if 400 <= a <= 599:
    print(8)
elif 600 <= a <= 799:
    print(7)
elif 800 <= a <= 999:
    print(6)
elif 1000 <= a <= 1199:
    print(5)
elif 1200 <= a <= 1399:
    print(4)
elif 1400 <= a <= 1599:
    print(3)
elif 1600 <= a <= 1799:
    print(2)
elif 1800 <= a <= 1999:
    print(1)

Measured memory_bytes: 61736
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define all(v) v.begin(),v.end() 
#define rev(v) v.rbegin(),v.rend()
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define inp 100005
#define en "\n"
using namespace std;
using namespace __gnu_pbds;

signed main() 
{
    ssd
    ll i,j,k,n,wei;
    cin>>n>>wei;
    vector<ll> w(n+5), profit(n+5);
    for(i=1;i<=n;i++)
    {
        cin>>w[i]>>profit[i];
    }
    vector<vector<ll>> dp(n+5,vector<ll> (100005,LLONG_MAX));
    for(i=0;i<=n;i++) dp[i][0] = 0; 

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=100000;j++)
        {
            if(j>=profit[i] && dp[i-1][j-profit[i]] != LLONG_MAX)
            {
                if(w[i]+dp[i-1][j-profit[i]] <= wei) dp[i][j] = min(dp[i-1][j], w[i]+dp[i-1][j-profit[i]]);
                else dp[i][j] = dp[i-1][j]; 
            }
            else dp[i][j] = dp[i-1][j]; 
        }
    }
    for(i=100000;i>=1;i--) if(dp[n][i]!=LLONG_MAX) {cout<<i; return 0;}
    return 0;           
}

Measured memory_bytes: 86300
#include<stdio.h>
#define d long long
d int h,w;
long long int p=1000000007;
char a[1000][1000];
d int m[1000][1000];
d int f(d int i,d int j)
{
    if((i==h-1)&&(j==w-1))
        return 1;
    if(i==h)
        return 0;
    if(j==w)
        return 0;
    if(a[i][j]=='#')
        return 0;
    if(m[i][j]!=-1)
        return m[i][j];
    m[i][j]=f(i+1,j)%p+f(i,j+1)%p;
    return m[i][j];
}
int main()
{
    d int i,j,k;
     scanf("%lld %lld",&h,&w);
     for(i=0;i<h;i++)
        scanf("%s",&a[i]);
     for(i=0;i<h;i++)
     {
         for(j=0;j<w;j++)
            m[i][j]=-1;

     }
     k=f(0,0)%p;
     printf("%lld",k);
    return 0;
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        
        FastScanner sc = new FastScanner();
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        
        if(((a==b)&&(b!=c))||((a==c)&&(b!=c))||((c==b)&&(a!=c))) System.out.println("Yes");
        else System.out.println("No");
        
    }
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) (flag)?1:0
#define yn(f) cout<<(f?"yes":"no")<<endl
#define Yn(f) cout<<(f?"Yes":"No")<<endl
#define YN(f) cout<<(f?"YES":"NO")<<endl
#define COUT(x) cout<<(x)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

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

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  int a,b; cin>>a>>b; Yn(a%500<=b);
}













Measured memory_bytes: 256
import glob

#IS_TEST = 1

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\136\\C'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                self.initialize(path)
                self.resolve()
        except NameError:
            self.resolve()


class C(Common):

    def resolve(self):

        n = int(self.input_data())
        stairs = [int(i) for i in self.input_data().split()]
        now = 0

        for i in range(n):
            if stairs[i] < now:
                print('No')
                exit(0)
            if stairs[i] > now:
                stairs[i] -= 1
                now = stairs[i]

        print('Yes')

solver = C(REL_PATH)
solver.exec_resolve()

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

int X, ans = 1;
int main() {
	cin >> X;

	for (int i = 2; pow(i, 2) <= X; i++) {
		for (int j = pow(i, 2); j <= X; j *= i) {
			ans = max(ans, j);
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int A[4], x1,x2,x3,x4, cnt=1;

	for(int i=0; i<4; i++)
		scanf("%1d", A+i);
	
	for(int i=0; i<3; i++)
	{
		if(A[i]==A[i+1])
		{
			cnt++;
			if(cnt>=3) break;
		}
		else cnt=1;
	}

	if(cnt>=3) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 128
def main():
    N, C, K = map(int, input().split())
    T = list()

    for i in range(N):
        T.append(int(input()))
    T = sorted(T)

    ans = 0
    cap = 0
    t0 = T[0]

    for i in range(N):
        if T[i] <= t0 + K:
            if cap + 1 <= C:
                cap += 1
            else:
                ans += 1
                t0 = T[i]
                cap = 1
            
        else:
            ans += 1
            t0 = T[i]
            cap = 1

    if cap > 0:
            ans += 1

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14132
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	ll N, K;
	cin >> N >> K;
	vector<P> insNo; 
	REP(i, N) {
		P one;
		cin >> one.first >> one.second;
		insNo.emplace_back(one);
	}
	sort(insNo.begin(), insNo.end());

	ll ans = 0;
	ll totalCnt = 0;
	for (auto one : insNo) {
		if (K <= (totalCnt + one.second)) {
			ans = one.first;
			break;
		}
		totalCnt += one.second;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2420
N = int(input())
A = [int(i) for i in input().split()]

# 線形で計算できる
# j > iとしてA[j]+A[i] = j-iよりA[i]+i=j-A[j]
# iとjを分離できたのでjを前に進めていって、計算結果を貯めていけばいい
# 

counter = 0
dic = {}
for j in range(N):
    if j-A[j] in dic:
        counter += dic[j - A[j]]
    if j + A[j] in dic:
        dic[j+A[j]] += 1
    else:
        dic[j+A[j]] = 1
print(counter)


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

int n;
string s, t;

int main() {
  cin >> s >> t;
  n = s.size();
  s += s;
  for(int i = 0; i < n; ++i) {
    bool ch = 1;
    for(int j = 0; j < t.size(); ++j)
      if(t[j] != s[i + j]) ch = 0;
    if(ch) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3208
S = str(input())
mod = 10 ** 9 + 7
L = len(S)
d = "ABC".index
dp = [0 for _ in range(4)]
dp[0] = 1
for i in range(len(S)):
    if S[i] == '?':
        dp = [dp[0]*3, dp[1]*3+dp[0], dp[2]*3+dp[1], dp[3]*3+dp[2]]
        for j in range(4):
            dp[j] %= mod
    else:
        j = d(S[i])
        dp[j+1] += dp[j] % mod

print(dp[-1]%mod)


Measured memory_bytes: 41452
s = input()
max_ind = len(s)-1
count_l = 0
count_r = 0
tmp_ind = 0
last_ind = -1
key_ind = 0
flag = True
text = ""

for i,c in enumerate(s):
    if flag == True:     
        if c == "R":
            count_r+=1
        else:
            flag = False
            key_ind = i
            count_l = 1
    else:
        if c == "L":
            count_l += 1
        else:
            for i in range((key_ind-2)-last_ind):
                text += "0 "
            left = (count_r+1)//2 + count_l//2
            right = count_r//2 + (count_l+1)//2
            text += "{} ".format(left)
            text += "{} ".format(right)
            last_ind = key_ind
            # ここで処理をしてしまう。
            count_r = 1
            flag = True

for i in range((key_ind-2)-last_ind):
    text += "0 "
left = (count_r+1)//2 + count_l//2
right = count_r//2 + (count_l+1)//2
text += "{} ".format(left)
text += "{} ".format(right)

for i in range(max_ind-key_ind):
    text += "0 "


print(text[:-1])


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

int main(){
  int W,a,b; cin >>W >>a >>b;
  int ans=0;
  if (a<b && a+W<b) {
    ans=b-(W+a);
  } else if (a>b && b+W<a) {
    ans=a-(W+b);
  }
  cout <<ans <<endl;
  return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S[i];

    map<char, int> mp;
    string a = "abcdefghijklmnopqrstuvwxyz";
    rep(i, a.size()) mp[a[i]] = 50;

    rep(i, S.size()) {
        map<char, int> mp2;
        string s = S[i];
        rep(j, s.size()) mp2[s[j]]++;
        rep(i, a.size()) chmin(mp[a[i]], mp2[a[i]]);
    }

    string ans = "";
    rep(i, a.size()) rep(j, mp[a[i]]) ans += a[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N];
int col[N];
int dpos[2 * N - 1];
int dneg[2 * N - 1];
bool X[N][N];

void initialize(){
  int i;
  
  for(i=0; i<N; i++){
    row[i] = FREE;
    col[i] = FREE;
  }

  for(i=0; i<2*N-1; i++){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
}

void printBoard(){
  int i,j;

  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      if(X[i][j]){
        if(row[i] != j) return;
      }
    }
  }

  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      printf("%s", ( (row[i] == j) ? "Q" : "."));
    }
    printf("\n");
  }
}

void recursive(int i){
  int j;
  if(i == N){
    printBoard();
    return;
  }

  for(j=0; j<N; j++){
    if(NOT_FREE == col[j] || NOT_FREE == dpos[i+j] || NOT_FREE == dneg[i-j + N-1]) continue;

    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j + N-1] = NOT_FREE;

    recursive(i+1);

    row[i] = col[j] = dpos[i+j] = dneg[i-j + N-1] = FREE;
  }
}

int main(){
  int i,j;
  int k;
  int c;
  int r;
  
  initialize();

  for(i=0; i<N; i++){
    for(j=0; j<N; j++) X[i][j] = false;
  }

  scanf("%d", &k);  

  for(i=0; i<k; i++){
    scanf("%d %d", &r, &c);
    X[r][c] = true;
  }

  recursive(0);

  return 0;
}


Measured memory_bytes: 2112
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
		int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    int oddCount = 0;
    for(int i = 0; i < m; i++)
    {
      if(nums[i] % 2 == 1) oddCount++;
    }

    if(oddCount > 2) Console.WriteLine("Impossible");
    else
    {
      oddCount = 0;
      for(int i = 0; i < m; i++)
      {
        if(nums[i] % 2 == 1)
        {
          if(oddCount == 0)
          {
            int memo = nums[i];
            nums[i] = nums[0];
            nums[0] = memo;
            oddCount++;
          }else
          {
            int memo = nums[i];
            nums[i] = nums[m-1];
            nums[m-1] = memo;
          }
        }
      }

      Console.WriteLine(string.Join(" ", nums));
      nums[0]--;
      if(m > 1) nums[m-1]++;
      if(nums[0] != 0 && m > 1) Console.WriteLine(m);
      else if(nums[0] == 0 && m > 1) Console.WriteLine(m-1);
      else if(nums[0] != 0 && m == 1) Console.WriteLine(m+1);
      else Console.WriteLine(1);
      
      if(nums[0] != 0 && m > 1) Console.WriteLine(string.Join(" ", nums));
      else if(m > 1)
      {
        int[] answers = new int[m-1];
        for(int i = 0; i < m-1; i++) answers[i] = nums[i+1];
        Console.WriteLine(string.Join(" ", answers));
      }else if(nums[0] != 0)
      {
        Console.WriteLine(nums[0] + " " + 1);
      }else
      {
        Console.WriteLine(1);
      }  
    }
	}
}

Measured memory_bytes: 13268
n = int(input())
a = [int(i) for i in input().split()]
b = [0]*(n+1)
l = [i for i in range(n+2)]
r = [i for i in range(n+2)]
ans = 0
for i in range(n): b[a[i]]=i
for i in range(n,0,-1):
	m = b[i]
	x,y = l[m],r[m]
	ans+=i*(m-x+1)*(y-m+1)
	l[y+1],r[x-1] = x,y
print(ans)

Measured memory_bytes: 36752
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
int func(int x){
	if(x%100!=0)return 0;
	else return func(x/100)+1;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int d,n=0;
	scanf("%d%d",&d,&n);
	int cnt = 0;
	for(int x = 1;;x++){
		if(func(x)==d){
			cnt++;
			if(cnt==n){
				cout << x << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int H,W,D,Q,a;
int main(){
    cin>>H>>W>>D;
    int Ax[(H+1)*(W+1)],Ay[(H+1)*(W+1)];
    rep1(i,H) rep1(j,W) cin >> a, Ax[a] = i, Ay[a] = j;
    vector<int> d((H+1)*(W+1));
    rep1(i,H*W){
        if(i <= D) d[i] = 0;
        else d[i] = d[i-D] + abs(Ax[i]-Ax[i-D]) + abs(Ay[i]-Ay[i-D]);
    }
    cin>>Q;
    int L,R;
    rep(i,Q){
        cin>>L>>R;
        pr(d[R]-d[L]);
    }
}

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

struct P {
    int cnt;
    vi c;
};

const int dxdy[] = {1,4,-1,-4};

char G[8][8][8][8][8][8][8][8]; // ?????§ 35

int main() {
    fill_n((char *)G, 8*8*8*8*8*8*8*8, -1);
    G[0][1][2][3][4][5][6][7] = 0;
    queue<P> que;
    vi init(8);
    REP(i, 8) init[i] = i;
    que.push({0, init});
    while (!que.empty()) {
        P p = que.front(); que.pop();
        REP(i, 8) {
            if (p.c[i] != 0) continue;
            REP(j, 4) {
                int xy = i + dxdy[j];
                if (!(i == 3 && xy == 4) && !(i == 4 && xy == 3) && 0 <= xy && xy < 8) {
                    swap(p.c[i], p.c[xy]);
                    if (G[p.c[0]][p.c[1]][p.c[2]][p.c[3]][p.c[4]][p.c[5]][p.c[6]][p.c[7]] == -1) {
                        G[p.c[0]][p.c[1]][p.c[2]][p.c[3]][p.c[4]][p.c[5]][p.c[6]][p.c[7]] = p.cnt+1;
                        que.push({p.cnt+1, p.c});
                    }
                    swap(p.c[i], p.c[xy]);
                }
            }
        }
    }

    int a,b,c,d,e,f,g,h;
    while (cin >>a>>b>>c>>d>>e>>f>>g>>h) {
        printf("%d\n", G[a][b][c][d][e][f][g][h]);
    }
}

Measured memory_bytes: 17744
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,sum=0;
  	cin >> n;
  	for(int i=1;i<n+1;i++)
    {
      for(int j=1;j<n+1;j++)
      {
        for(int k=1;k<n+1;k++)
        {
          sum += gcd(i,gcd(j,k));
        }
      }
    }
  	cout << sum;
}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
res = [-1] * N
for _ in range(M):
  x, t = map(int, input().split())
  x -= 1
  if res[x] != -1 and (res[x] != t):
    print(-1)
    exit(0)
  if x == 0 and (t == 0) and (N > 1):
    print(-1)
    exit(0)
  res[x] = t
if res[0] == -1 and (N > 1): res[0] = 1
if res[0] == -1 and (N == 1): res[0] = 0
for i in range(N):
  if res[i] == -1: res[i] = 0
print("".join(list(map(str, res))))


Measured memory_bytes: 38420
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input, "index" : 0, "max" : input.length,
  "hasNext" : function(){return (this.index < this.max);},
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  }
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  //解説コピペ
  var one = nextIntArray();
  var K = one[0];
  var T = one[1];
  var list = nextIntArray();
  var max = Math.max.apply(null,list);
  var output = Math.max(0,max - 1 - (K - max));
  myout(output);
  
  //maxとそれ以外を交互に並べたときにmaxがあぶれるかどうか
}

Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    // 整数の入力
    int N;
    int C[20],V[20];
    int temp;

    cin >> N;

    for (int i = 0; i < N ; i++){
        cin >> V[i];
    }
    for (int i = 0; i < N ; i++){
        cin >> C[i];
    }
    temp = 0;
    for (int i = 0; i < N ; i++){
        temp = max(0, V[i] - C[i]) + temp;
    }

    cout << temp << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

struct UF {
  vector<int> parent_, rank_;

  UF(int n) : parent_(n + 5), rank_(n + 5, 1) {
    for (int i = 0; i < n + 5; ++i) {
      parent_[i] = i;
    }
  }

  int find_set(int x) {
    if (x != parent_[x]) {
      parent_[x] = find_set(parent_[x]);
    }
    return parent_[x];
  }

  void unite(int x, int y) {
    int a = find_set(x), b = find_set(y);
    if (a == b) { return; }
    if (rank_[a] > rank_[b]) {
      parent_[b] = a;
    }
    else {
      parent_[a] = b;
      if (rank_[a] == rank_[b]) {
        ++rank_[b];
      }
    }
  }

  bool is_connected(int x, int y) {
    return find_set(x) == find_set(y);
  }

};

int main()
{
  int N, K, L; scanf("%d %d %d", &N, &K, &L);
  int a, b;
  UF uf1(N + 3), uf2(N + 3);
  for (int i = 0; i < K; ++i) {
    scanf("%d %d", &a, &b);
    uf1.unite(a, b);
  }

  for (int i = 0; i < L; ++i) {
    scanf("%d %d", &a, &b);
    uf2.unite(a, b);
  }
  vector<pair<int, int>> v;
  for (int i = 1; i <= N; ++i) {
    v.push_back(make_pair(uf1.find_set(i), uf2.find_set(i)));
  }
  sort(v.begin(), v.end());
  for (int i = 1; i <= N; ++i) {
    pair<int, int> p = make_pair(uf1.find_set(i), uf2.find_set(i));
    int ans = distance(lower_bound(v.begin(), v.end(), p),
                       upper_bound(v.begin(), v.end(), p));
    if (i == 1) { printf("%d", ans); }
    else { printf(" %d", ans); }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 5492
#include <bits/stdc++.h>
#define fr first
#define sc second

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int NMAX = 1e5 + 1;

main()
{
    #ifdef HOME
        freopen("input.txt", "r", stdin);
    #else
//        freopen("rod.in", "r", stdin);
//        freopen("rod.out", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> arr(n);
    int cnt[n + 1];
    memset(cnt, 0, sizeof(cnt));
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        if (arr[i] > n) {
            ++ans;
        } else {
            ++cnt[arr[i]];
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (cnt[i] && cnt[i] < i) {
            ans += cnt[i];
        } else if (cnt[i] && cnt[i] > i) {
            ans += cnt[i] - i;
        }
    }
    cout << ans;
}


Measured memory_bytes: 1024
use std::io;
use std::cmp;

fn main() {
    const NMAX: usize = 1000;
    const MMAX: usize = 2000;
    const INF: i64 = std::i64::MAX;

    let mut first = String::new();
    io::stdin().read_line(&mut first);
    let mut fitr = first.split_whitespace();
    let n = fitr.next().unwrap().parse::<usize>().unwrap();
    let m = fitr.next().unwrap().parse::<usize>().unwrap();

    let mut a = [0usize; MMAX];
    let mut b = [0usize; MMAX];
    let mut c = [0i64; MMAX];
    for i in 0..m {
        let mut line = String::new();
        io::stdin().read_line(&mut line);
        let mut itr = line.split_whitespace();
        a[i] = itr.next().unwrap().parse::<usize>().unwrap();
        b[i] = itr.next().unwrap().parse::<usize>().unwrap();
        c[i] = itr.next().unwrap().parse::<i64>().unwrap();
        
        a[i] = a[i] - 1;
        b[i] = b[i] - 1;
        c[i] = -c[i];
    }

    let mut dist = [INF; NMAX];
    dist[0] = 0;

    for _ in 0..(n-1) {
        for i in 0..m {
            match dist[a[i]] {
                INF => continue,
                v => {
                    dist[b[i]] = cmp::min(v + c[i], dist[b[i]])
                }
            }
        }
    }

    let ans = dist[n-1];

    let mut neg = [false; NMAX];
    //find loop
    for _ in 0..n {
        for i in 0..m {
            if dist[a[i]] == INF { continue; }

            if dist[a[i]] + c[i] < dist[b[i]] {
                dist[b[i]] = dist[a[i]] + c[i];
                neg[b[i]] = true;
            }

            if neg[a[i]] == true { neg[b[i]] = true; }
        }
    }

    if neg[n-1] {
        println!("inf");
    } else {
        println!("{}", -ans);
    }
}

Measured memory_bytes: 4352
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val l = sc.nextInt()

  println(abc159c(l))
}

private fun abc159c(l: Int): Double {
  val a = l / 3.0
  val b = l - a - a

  return a * a * b
}

Measured memory_bytes: 29484