akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
inline int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int k=1,kk=0;if (c=='-')c=getchar(),k=-1;
	while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return kk*k;
}using namespace std;
void write(int x){if (x<0)putchar('-'),x=-x;if (x/10)write(x/10);putchar(x%10+'0');}
void writeln(int x){write(x);puts("");}
struct lsg{int x,y,z;}f[1000][1000];
int a,b,c[1000][1000],flag[1000][1000],fff[1000][1000],ii,jj,sum;
signed main(){
	a=read();b=read();for (int i=1;i<=a;i++)for (int j=1;j<=b;j++)c[i][j]=read();
	ii=jj=-1;
	for (int i=0;i<=100;i++)
		for (int j=0;j<=100;j++)
			for (int k=0;k<=100;k++){
				int ff=0,fff=0;if (ii==i&&jj==j)continue;
				for (int x=1;x<=a;x++)
					for (int y=1;y<=b;y++)if (c[x][y]>i*x+j*y+k)ff=1;
				if (ff)continue;
				for (int x=1;x<=a;x++)
					for (int y=1;y<=b;y++)
						if (c[x][y]==i*x+j*y+k)f[x][y].x=i,f[x][y].y=j,f[x][y].z=k,flag[x][y]=1,fff=1;
				if (fff)ii=i,jj=j;
			}
	for (int i=1;i<=a;i++)for (int j=1;j<=b;j++)if (!flag[i][j]){puts("Impossible");return 0;}
	puts("Possible");for (int i=1;i<=a;i++)for (int j=1;j<=b;j++)
		if (!fff[f[i][j].x][f[i][j].y])sum++,fff[f[i][j].x][f[i][j].y]=1;
	cout<<300<<' '<<200+sum<<endl;memset(fff,0,sizeof(fff));
	for (int i=1;i<=100;i++)cout<<i<<' '<<i+1<<' '<<'X'<<endl;
	for (int i=1;i<=100;i++)cout<<300-i<<' '<<300-i+1<<' '<<'Y'<<endl;
	for (int i=1;i<=a;i++)for (int j=1;j<=b;j++)
		if (!fff[f[i][j].x][f[i][j].y])
			cout<<f[i][j].x+1<<' '<<300-f[i][j].y<<' '<<f[i][j].z<<endl,fff[f[i][j].x][f[i][j].y]=1;
	cout<<1<<' '<<300<<endl;
}

Measured memory_bytes: 12544
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll>>;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const int INF = 2147483647;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int n;cin >>n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i] ;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    int ans;
    if(n%2==0){
	ans = (b[n/2-1]+b[n/2])-(a[n/2-1]+a[n/2])+1;
    }else{
	ans = (b[n/2]-a[n/2])+1;	
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;

int mat[1005][1005];

struct cet{
    int a, b, c, d;
};

queue <cet> q;

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n, m;
    cin >> n >> m;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            cin >> mat[i][j];
        }
    }
    for(int i=1; i<=n; i++){
        if(i%2){
            for(int j=1; j<m; j++){
                if(mat[i][j]%2){
                    mat[i][j]--;
                    mat[i][j+1]++;
                    q.push({i, j, i, j+1});
                }
            }
            if(i == n) break;
            if(mat[i][m]%2){
                mat[i][m]--;
                mat[i+1][m]++;
                q.push({i, m, i+1, m});
            }
        }
        else{
            for(int j=m; j>1; j--){
                if(mat[i][j]%2){
                    mat[i][j]--;
                    mat[i][j-1]++;
                    q.push({i, j, i, j-1});
                }
            }
            if(i == n) break;
            if(mat[i][1]%2){
                mat[i][1]--;
                mat[i+1][1]++;
                q.push({i, 1, i+1, 1});
            }
        }
    }
    cout << q.size() << "\n";
    while(!q.empty()){
        cout << q.front().a << " " << q.front().b << " " << q.front().c << " " << q.front().d << "\n";
        q.pop();
    }
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    int N = 0;
    cin >> N;
    vector<int> A(N,0);
    vector<int> a(N,0);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    a = A;
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int FA = a.at(0);
    int SA = a.at(1);

    for(int i = 0; i < N; i++) {
        if(A.at(i) == FA) {
            cout << SA << endl;
        } else {
            cout << FA << endl;
        }
    }



    return 0;
}

Measured memory_bytes: 4824
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,c=1,cnt=0,sum=0; cin>>n;
    while(1){
        sum+=c; 
        if(sum>n){
            sum-=c;
            n-=sum;
            break;
        }
        c*=26;
        cnt++;
    }
    stack<char> ans;
    rep(i,cnt){
        ans.push(((26+n)%26)+'a');
        n/=26;
    }
    while(!(ans.empty())){
        cout<<ans.top();
        ans.pop();
    }
    cout<<endl;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

const int64_t MOD = 1000000007;

signed main() {
  int L,R;
  cin >> L >> R;
  
  if(R-L>=3000){
    cout << "0" << endl;
    return 0;
  }
  
  int64_t minMod = 2018;
  for(int64_t i=L;i<R;i++){
    for(int64_t j=i+1;j<=R;j++){
      minMod = min(minMod, (i*j)%2019);
    }
  }
  cout << minMod << endl;
  return 0;
}



Measured memory_bytes: 3676
import java.io.*;

class Main {
  public static void main(String[] args){
    InputStreamReader sr = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(sr);

    try{
      while(true){
        String[] str = br.readLine().split(" ");
        int a = Integer.parseInt(str[0]);
        String op = str[1];
        int b = Integer.parseInt(str[2]);

        switch(op){
          case "+" :  System.out.println(a+b); break;
          case "-" :  System.out.println(a-b); break;
          case "*" :  System.out.println(a*b); break;
          case "/" :  System.out.println(a/b); break;
          case "?" :  break;
        }
        if(op.equals("?")){
          break;
        }
      }
    }
    catch(IOException e) {
      e.printStackTrace();
    }
  }
}

Measured memory_bytes: 24528
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i,n) for (int i=1;i<=n;i++)
bool d[10];
int n,k;
inline bool check(int x){
	while (x){
		if (d[x%10]) return 0;
		x/=10;
	}
	return 1;
}
int main()
{
	cin>>n>>k;
	for (int i=1;i<=k;i++){
		int x;
		cin>>x;
		d[x]=1;
	}
	n--;
	while (1){
		n++;
		if (check(n)) break;
	}
	cout<<n;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> pii;
typedef long long ll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;
const ll MOD=1e9+7;
struct edge{
    int to;
    int cost;
};
int main(){
    int N,C;cin>>N>>C;
    vector<pii> ch(N);
    for(int i=0;i<N;++i){
        int s,t,c;cin>>s>>t>>c;s--;t--;
        ch[i]=pii(c,ii(s,t));
    }
    sort(ch.begin(),ch.end());
    vector<int> S(1e5+1,0);
    for(int i=0;i<N;++i){
        int c=ch[i].first;
        int s=ch[i].second.first;
        int t=ch[i].second.second;
        if(!(i>0&&c==ch[i-1].first&&ch[i-1].second.second==s)){
            S[s]++;
        }
        if(!(i<N-1&&c==ch[i+1].first&&t==ch[i+1].second.first)){
            S[t+1]--;
        }
    }
    int mx=S[0];
    for(int i=1;i<=1e5;++i){
        S[i]+=S[i-1];
        mx=max(mx,S[i]);
    }
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 4840
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
ll dp[1024][100005];
void solve()
{
    ll n;
    cin>>n;
    ll wt[n+1];
    ll val[n+1];
    for(int i=1;i<=n;i++)
        cin>>val[i]>>wt[i];
    ll q;
    cin>>q;
    for(int i=1;i<min(n+1,(ll)1024);i++)
    {
        if(i==1)
        {
            for(int j=wt[i];j<=100000;j++)
                dp[i][j]=val[i];
            continue;
        }
        int par=i/2;
        for(int j=1;j<=100000;j++)
        {
            if(wt[i]>j)
                dp[i][j]=dp[par][j];
            else
                dp[i][j]=max(dp[par][j],dp[par][j-wt[i]]+val[i]);
        }
    }
    while(q--)
    {
        ll v,W;
        cin>>v>>W;
        if(v<1024)
        {
            cout<<dp[v][W]<<'\n';
            continue;
        }
        vi anc;
        while(v>=1024)
        {
            anc.pb(v);
            v/=2;
        }
        int res=anc.size();
        ll ans=0;
        for(int i=0;i<(1<<res);i++)
        {
            int sumval=0,sumwt=0;
            for(int j=0;j<res;j++)
            {
                if((i&(1LL<<j))!=0)
                {
                    sumval+=val[anc[j]];
                    sumwt+=wt[anc[j]];
                }
            }
            if(sumwt>W)
                continue;
            ans=max(ans,sumval+dp[v][W-sumwt]);
        }
        cout<<ans<<'\n';
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 807044
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<array>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


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


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };
int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/
typedef tuple<int,int,int> tpl;


int main() {

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

	int n,k;
	cin >> n >> k;
	int cnt = 0;
	while(n/k){
		n/=k;
		cnt++;
	}
	if(n != 0){
		cnt++;
	}

	cout << cnt << endl;

	return 0;
}






Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

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

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

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


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

  cout << "[";

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

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

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

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

  for(i=0;i<n;i++)print(i);

  return 0;
}



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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts

int main()
{
  int n,k;cin>>n>>k;
  vector<int> v(n);
  int i,j,l;
  rep(i,n)cin>>v[i];
  int ans=0;
  for(i=0;i<=min(n,k);i++)
  {
    for(j=0;j<=min(n-i,k-i);j++)
    {
      int left=k-i-j;
      vector<int> got(0);
      rep(l,i)got.emplace_back(v[l]);
      rep(l,j)got.emplace_back(v[n-1-l]);
      sort(all(got));
      reverse(all(got));
      int kans=0;
      for(l=0;l<i+j-left;l++)kans+=got[l];
      for(l=max(i+j-left,0);l<i+j;l++)
      {
        if(got[l]<0)break;
        kans+=got[l];
      }
      ans=(ans<kans)?kans:ans;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> aup(n),adown(n);
  int i;
  for(i=0;i<n;i++){
    cin >> aup[i];
  }
  for(i=0;i<n;i++){
    cin >> adown[i];
  }
  int upmax = aup[n-1];
  int downmax = adown[n-2];
  for(i=1;i<n;i++){
    if(upmax > downmax){
      upmax = upmax + aup[n-1-i];
    }else{
      upmax = downmax + aup[n-1-i];
    }
    if(i != n-1)
      downmax += adown[n-2-i];
  }
  cout << upmax + adown[n-1] << endl;
}
    
    

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

int main(int argc, char *argv[])
{
	int n;

	cin >> n;

	double s=0.0;
	for (int i=0;i<n;i++)
	{
		double t;
		cin >> t;
		s+=(1/t);
	}
	cout << (1.0/s) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main(){
    int n, y;
    scanf("%d %d", &n, &y);

    int flag;
    flag = 0;

    int xy;
    xy = 10000*n - y;
    if( xy < 0 ){
        printf("-1 -1 -1\n");
        flag = 1;
    }

    for(int a=0; a<=n; a++){
        if(flag==1){break;}
        for( int b=0; b<=n; b++ ){
//            printf("%d %d,", a, b);
            int val;
            val = 9000 * a + 5000 * b;
//            printf("val:%d xy:%d val+n:%d\n", val, xy, val+n*1000);
            if( val==xy and 0<=a+b and a+b<=n){
                printf("%d %d %d\n", n-a-b, b, a);
                flag = 1;
                break;
            }
        }
        if( a==n and flag==0){
            printf("-1 -1 -1\n");
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N=5;
    int m[5];
    int i;
    int min =10;
    int ans =0;
    for(i=0;i<N;i++)
    {
        cin >>m[i];
        if(m[i] % 10 > 0)
        {
            if(m[i]%10 <min)
            {
                min = m[i]% 10;
            }
            
            
        }
        if(m[i]%10 != 0)
        {
        m[i] = m[i] + 10-m[i]%10;
        }
        ans += m[i] ;
    }
    if(min==10)
    {
        min =10;
    }
    cout << ans  -10+min << endl;
    return 0;
    
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize,
        k: u64,
        a: [u64;n],
    }

    let mut ng = 0;
    let mut ok = 1_000_000_001;

    while abs(ok, ng) > 1 {
        let mid = (ok + ng) / 2;

        if calc(&a, mid) <= k {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    println!("{}", ok);
}

fn calc(a: &Vec<u64>, length: u64) -> u64 {
    let mut res = 0;

    for &v in a {
        res += (v + length - 1) / length - 1;
    }

    res
}

fn abs(a: u64, b: u64) -> u64 {
    if a > b {
        a - b
    } else {
        b - a
    }
}


Measured memory_bytes: 5376
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize
    }

    let mut ans = 0;
    let mut start = 1;

    if n > 100000 {
        ans = 1166714;
        start = 100000;
    }
    if n > 200000 {
        ans = 2472071;
        start = 200000;
    }
    if n > 300000 {
        ans = 3829761;
        start = 300000;
    }
    if n > 400000 {
        ans = 5221424;
        start = 400000;
    }
    if n > 500000 {
        ans = 6638407;
        start = 500000;
    }
    if n > 600000 {
        ans = 8075420;
        start = 600000;
    }
    if n > 700000 {
        ans = 9529244;
        start = 700000;
    }
    if n > 800000 {
        ans = 10997400;
        start = 800000;
    }
    if n > 900000 {
        ans = 12478098;
        start = 900000;
    }
    for c in start..n {
        ans += enumerate_divisor(c);
    }

    println!("{}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet
// 約数の列挙
fn enumerate_divisor(n: usize) -> usize {
    let mut i = 1;

    let mut divisors = 0;

    while i * i <= n {
        if n % i == 0 {
            divisors += 1;
            if i != n / i {
                divisors += 1;
            }
        }
        i += 1;
    }

    divisors
}


Measured memory_bytes: 2264
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int[] counts = new int[26];

        while (true) {
            String line = br.readLine();

            if (line == null) {
                break;
            }

            for (int i = 0; i < line.length(); i++) {
                char c = line.charAt(i);
                if (isUppercase(c)) {
                    counts[c - 'A']++;
                } else if (isLowercase(c)) {
                    counts[c - 'a']++;
                }
            }
        }

        for (int i = 0; i < 26; i++) {
            System.out.println((char) (i + 'a') + " : " + counts[i]);
        }
    }

    private static boolean isUppercase(char c) {
        return (c >= 'A' && c <= 'Z');
    }

    private static boolean isLowercase(char c) {
        return (c >= 'a' && c <= 'z');
    }
}


Measured memory_bytes: 24244
import java.util.Scanner;
import java.util.function.IntBinaryOperator;

public class Main {

	static int lastIndexOf(String e, char ch, char ch2) {
		int nest = 0;
		for(int i = e.length()-1; i > 0 ; i--) {
			char c = e.charAt(i);
			if(c == '(') {
				nest++;
			}
			if(c == ')') {
				nest--;
			}
			if((ch == c || c == ch2) && nest == 0) {
				return i;
			}
		}
		return -1;
	}
	
	static int parse(String e) {
		int loc = lastIndexOf(e, '-', '+');
		if(loc != -1) {
			if(e.charAt(loc) == '+') {
				return parse(e.substring(0, loc)) + parse(e.substring(loc+1));				
			}
			return parse(e.substring(0, loc)) - parse(e.substring(loc+1));
		}
		loc = lastIndexOf(e, '/', '*');
		if(loc != -1) {
			if(e.charAt(loc) == '*') {
				return parse(e.substring(0, loc)) * parse(e.substring(loc+1));				
			}
			return parse(e.substring(0, loc)) / parse(e.substring(loc+1));
		}
		if(e.startsWith("(") && e.endsWith(")")) {
			return parse(e.substring(1, e.length()-1));
		}
		return Integer.parseInt(e);
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			for(int i = 0; i < n; i++) {
				String e = sc.next().replace("=", "");
				System.out.println(parse(e));
			}
		}
	}
}



Measured memory_bytes: 25980
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]

def DFS(cnt, a, b, c):
    if cnt == N:
        # print(cnt, a, b, c)
        if a == 0 or b == 0 or c == 0:
            return 10 ** 10
        return abs(A-a) + abs(B-b) + abs(C-c) - 30

    r1 = DFS(cnt+1, a, b, c)
    r2 = DFS(cnt+1, a+l[cnt], b, c) + 10
    r3 = DFS(cnt+1, a, b+l[cnt], c) + 10
    r4 = DFS(cnt+1, a, b, c+l[cnt]) + 10
    return min(r1, r2, r3, r4)

print(DFS(0, 0, 0, 0))

Measured memory_bytes: 3064
#include<iostream>

int main(int argc, char const *argv[]) {

    int N,K;
    std::cin >> N >> K;

    int value = 1;
    for(int times = 0 ; times < N ; times++ ){
        if(value <= K)
            value *= 2;
        else
            value += K;
    }

    std::cout << value << '\n';
    return 0;
}


Measured memory_bytes: 256
# Author: cr4zjh0bp
# Created: Thu Mar  5 09:20:24 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

a, b, c, d = na()

if abs(a - c) <= d:
    print("Yes")
elif abs(a - b) <= d and abs(b - c) <= d:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
    int N,a;
    int flag=0;
    cin>>N;
    while(N--)
    {
        cin>>a;
        if(a%2==0){
            if(a%5!=0&&a%3!=0)
                flag=1;
        }
    }
    
    if(flag==0)
        cout<<"APPROVED";
        else 
            cout<<"DENIED";
    return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int table[10001];
int main() {
  vector<int> prime(10000);
  for (int i=2; i<10000; ++i) prime[i] = i;
  for (int i=2; i*i<10000; ++i)
    if (prime[i])
      for (int j=i*i; j<10000; j+=i)
        prime[j] = 0;
  prime.erase(remove(ALL(prime),0), prime.end());
  REP(i, prime.size()) {
    int sum = 0;
    for (int j=i; j<prime.size(); ++j) {
      sum += prime[j];
      //cout << j << " " << sum << endl;
      if (sum>10000) break;
      table[sum]++;
    }
  }
  int n;
  while(cin >> n,n)
    cout << table[n] << endl;
}

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

const int64_t INT = 1000000007;

int64_t func1(int64_t x, int64_t y) {
  if(y == 0) {
    return 1;
  }
  else if(y % 2 == 0) {
    int64_t a = func1(x, y / 2);
    a = a * a % INT; 
    return a;
  }
  else {
    int64_t a = func1(x, y / 2); 
    a = a * a % INT;
    a = a * x % INT;
    return a;
  }
}

int main() {
  int K;
  string S;
  cin >> K >> S;
  int64_t ans = 0;
  int64_t n = S.size();
  int64_t combination = 1;
  for(int i = 2; i < n; i++) {
    combination = combination * func1(i, INT - 1);
  }
  for(int i = n - 1; i < n + K; i++) {
    int64_t keep = 1;
    keep = (func1(25, i - n + 1) * func1(26, n + K - i - 1)) % INT;
    keep = keep * combination % INT;
    combination = combination * (i + 1) % INT;
    combination = combination * func1(i - n + 2, INT - 2) % INT;
    ans += keep;
    ans %= INT;
  }
  cout << ans << endl;
}


Measured memory_bytes: 5316
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,j=0,f=0,c=0;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++) cin>>a[i];
  while(f==0){
    int x=a[j];
    if(x==0){
      f=-1;
    }else if(x==2){
      c++;
      f=c;
    }else{
      c++;
      a[j]=0;
      j=x-1;
    }
  }
  cout<<f<<endl;
}

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

int main(){
	/*intput*/
	int n;	cin >> n;
	vector<double>v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}
	/*calculaiton*/
	sort(v.begin(), v.end());
	double ans = 0;
	double tmp = v[0];
	for(int i = 1; i < n; i++){
		tmp = (tmp + v[i])/2;
	}
	ans = tmp;
	/*output*/
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#pragma GCC optimize "O3"
#define rep(i,a,n) for(int i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;
 
int main(void){
    int n,a,b; cin >>n >> a >> b;
    cout << min(b,a*n) << "\n";
}

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

h  = list(map(int, input().split()))

ab = {}
for i in range(n):
    ab[i] = []
    
for i in range(m):
    a, b = map(int, input().split())
    ab[a-1].append(b-1)
    
abab = ab.copy()
for key, value in ab.items():
    for v in value:
        abab[v].append(key)

count = 0
for i in range(len(abab)):
    abab[i] = set(abab[i])
    for j in abab[i]:
        if h[i] <= h[j]:
            break
    else:
        count+=1
print(count)

Measured memory_bytes: 65376
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define ll long long
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define deb(x) cout << #x << "=" << x << endl;
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;      

const int N = 1e6+5;
ll arr[N];

void fun() {
    for(int i = 1; i<=N; ++i) {
        for(int j = 1; j*i<=N; ++j) {
            arr[i*j]++;
        }
    }
}

int main() {
    fastio
    ll n;
    cin>>n;
    fun();
    ll ans = 0;
    for(int i = 1; i<n; ++i) {
        ans += arr[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11448
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 10050
#define INF 1e9
 
struct P{
    int dist,cost,v;
    bool operator < (const P &p)const{
	if(dist != p.dist){
	    return dist > p.dist;
	}
	return cost > p.cost;
    }
};
 
int N,M;
vector<P> G[MAX];
 
int dijkstra(){
    int res = 0;
    bool visited[MAX] = {false};
    priority_queue<P> Q;
    Q.push((P){0,0,0});
 
    while(!Q.empty()){
	P p = Q.top(); Q.pop();
	int v = p.v;
	if(visited[v]) continue;
	visited[v] = true;
	res += p.cost;
	for(int i = 0 ; i < (int)G[v].size() ; i++){
	    P e = G[v][i];
	    Q.push((P){p.dist+e.dist,e.cost,e.v});
	}
    }
    return res;
}
 
int main(){
    int u,v,d,c;
    while(cin >> N >> M, N){
	for(int i = 0 ; i < N ; i++){
	    G[i].clear();
	}
	for(int i = 0 ; i < M ; i++){
	    cin >> u >> v >> d >> c;
	    u--; v--;
	    G[u].push_back((P){d,c,v});
	    G[v].push_back((P){d,c,u});
	}
	cout << dijkstra() << endl;
    }
    return 0;
}

Measured memory_bytes: 5372
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes) if b else print(no)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
a,b,c,k=n1()
p0(a+b>=k,min(a,k),a-(k-a-b))

Measured memory_bytes: 9104
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

int climb[200000];
int a[200000];
int b[200000];
int c[200000];

int main(){
	
	int N, M;
	
	cin >> N >> M;
	
	int pre;
	int next;
	
	for(int i = 0; i <= N; i++){
		climb[i] = 0;
	}
	
	cin >> pre;
	
	for(int i = 0; i < M - 1; i++){
		cin >> next;
		if(pre > next){
			climb[next]++;
			climb[pre]--;
		}else{
			climb[pre]++;
			climb[next]--;
		}
		pre = next;
	}
	
	int count = 0;
	long long int ans = 0;
	
	for(int i = 1; i < N; i++){
		count += climb[i];
		long long int a, b, c;
		cin >> a >> b >> c;
		ans += min(a * count, c + b * count);
	}
	
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

void A()
{
    string S;
    cin >> S;
    
    if( S[0] == S[1] && S[1] == S[2] ){
        cout << "No" << endl;
        return;
    }
    
    cout << "Yes" << endl;
}

void B()
{
    
}


int main()
{
    A();
    //B();
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

void countingsort(int [],int);

int main(){
  int A[MAX];
  int n, i, j;

  scanf("%d", &n);


  /* your code */
  for(i=0 ; i<n ; i++)
  {
    scanf("%d",&A[i]);
  }

  countingsort(A,n);

  for(i=0 ; i<n-1 ; i++)
  {
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);

  return 0;
}

void countingsort(int A[],int n)
{
  int i,j,k=0;

  int C[VMAX];
  for(i=0;i<VMAX;i++){
    C[i]=0;
  }
  for(i=0;i<n;i++){
    C[A[i]]++;
  }
  for(i=0;i<VMAX;i++){
    for(j=C[i];j>0;j--){
A[k++]=i;
    }
}
}


Measured memory_bytes: 9556
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } else return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } else return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;

string S;
ll K;

int main() {
	cin >> S >> K;
	
	int lead = -1;
	REP(i, S.size()) {
		if (S[i] != '1') break;
		lead = i;
	}
	
	int ans;
	if (lead != -1 && lead + 1 >= K) ans = 1;
	else ans = S[lead + 1] - '0';
	
	cout << ans << endl;
	
	return 0;
}

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

int main()
{
	long K, X;
	cin >> K >> X;

	int min = X - (K - 1);
	int max = X + (K - 1);
	for (int loop = min; loop <= max; ++loop) {
		cout << loop << ' ';
	}

	return 0;
}


Measured memory_bytes: 3504
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>
#include <cmath>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back
#define UNIQ(a) a.erase(unique(all(a)), end(a))

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}
template<typename T>bool chmin(T&a,T b){return a>b?(a=b,1):0;}
template<typename T>bool chmax(T&a,T b){return a<b?(a=b,1):0;}
int read(){int a;scanf("%lld",&a);return a;}

const double pi = acos(-1);
constexpr int inf = 3*TEN(18) + 10;
constexpr int mod = TEN(9) + 7;

signed main()
{
	string s; cin >> s;
	int n = s.size();
	int g = 0, p = 0;
	rep(i, n) {
		if (s[i] == 'g') g++;
		else p++;

		int a = g - p;
		if (i + a >= n - 1) {
			int ans = 0;
			for (int j = i + 1; j < n; ++j) ans += s[j] == 'g';
			cout << ans << endl;
			return 0;
		}
	}

	cout << 0 << endl;
}



Measured memory_bytes: 3684
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <set>
#include <vector>
using namespace std;
int as[7];
int bs[7];
int m;
int sums[100 * 10 + 1];
void solve(int n, int sum) {
	if (sum > 1000)
		return;
	if (n == m) {
		sums[sum]++;
		return;
	}
	for (int i = 0; i <= bs[n]; i++) {
		solve(n + 1, sum + (i * as[n]));
	}
}

int main() {
	while (cin >> m, m) {
		memset(sums, 0, sizeof(sums));
		for (int i = 0; i < m; i++) {
			cin >> as[i];
			cin >> bs[i];
		}
		solve(0, 0);
		int g;
		cin >> g;
		for (int i = 0; i < g; i++) {
			int ni;
			cin >> ni;
			cout << sums[ni] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Prog
    {
        public static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Prog().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var r = cin.ReadInt;
            var d = cin.ReadInt;
            var x = cin.ReadInt;

            for (int i = 0; i < 10; i++)
            {
                x = r * x - d;
                Console.WriteLine(x);
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } }
    }
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

int m,n_min,n_max, P[210];

int main() {
  while( cin >> m >> n_min >> n_max, m | n_min | n_max ) {
    rep(i,m) cin >> P[i];
    sort(P,P+m,greater<int>());
    int max_diff = -1;
    int n=1;
    --n_min, --n_max;
    REP(i,n_min,n_max+1) {
      int diff = P[i] - P[i+1];
      if( diff >= max_diff ) {
	max_diff = diff;
	n = i+1;
      }
    }
    cout << n << endl;
  }
  return 0;
}

Measured memory_bytes: 1176
#include <stdio.h>

int main(){

 int i, x, y, z;

 for(i = 1; 1; i++){

  scanf("%d%d", &x, &y);

  if(x > y){
    z = x;
    x = y;
    y = z;
  }

 if(x == 0 && y == 0){
 break;
 }

 printf("%d %d\n", x, y);

 }

return 0;

}
     

Measured memory_bytes: 1704
#include <iostream>

using namespace std;

int main(){

  int n,b,f,r,v;
  int t[4][3][10]={0};

  cin >>n;

  for(int i=0; i<n; i++){
    cin>>b>>f>>r>>v;
    t[(b-1)][(f-1)][(r-1)]+=v;
  }

  
  for(int i=0; i<3; i++){
    for(int j=0; j<10; j++){
      cout <<" "<<t[0][i][j];
    }
    cout <<endl;
  }
  cout <<"####################"<<endl;

  for(int i=0; i<3; i++){
    for(int j=0; j<10; j++){
      cout <<" "<<t[1][i][j];
    }
    cout <<endl;
  }
  cout <<"####################"<<endl;

  for(int i=0; i<3; i++){
    for(int j=0; j<10; j++){
      cout <<" "<<t[2][i][j];
    }
    cout <<endl;
  }
  cout <<"####################"<<endl;

  for(int i=0; i<3; i++){
    for(int j=0; j<10; j++){
      cout <<" "<<t[3][i][j];
    }
    cout <<endl;
  }

  
  return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <limits>
#include <cmath>
#include <vector>
using namespace std;
#define ll long long

int main(){
	int X;
	cin >> X;
	ll N=2;
	for(int i=0;i<X;i++){
		N=N+1+N+1;
	}
	cout <<N << endl;;
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define sc second
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define rep1(i, n) repi(i, 1, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define sp(n) cout << fixed << setprecision(n)
#define ma(n, o) map<n, o>
#define pr(n, o) pair<n, o>
#define so(n) sort(n.begin(), n.end())
#pragma endregion
// abs 絶対値, rtsq ルート, pow(a, n) aのn乗

int main() {
  int S, a, b;
  ci(S);
  a = S / 100;
  b = S % 100;
  st ans;
  if(0 < b && b <= 12 && 0 < a && a <= 12) {
    co("AMBIGUOUS");
  }
  else if(0 < b && b <= 12) {
    co("YYMM");
  }
  else if(0 < a && a <= 12) {
    co("MMYY");
  }
  else {
    co("NA");
  }    
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
signed main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	//MessageBox(GetForegroundWindow(),"标题","内容",MB_YESNO);
	string s;
	cin>>s;
	if(s[s.size()-1]=='s'){
		cout<<s<<"es"<<endl;
	}else{
		cout<<s<<"s"<<endl;
	}
	return 0;
}


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

const int MAXN = 100010;
int main() {
	int m, n;
	cin>>n>>m;
	priority_queue<int> good;
	for (int i=0; i<n; i++) {
		int a;
		cin>>a;
		good.push(a);
	}
	while(m--) {
		int t = good.top();
		good.pop();
		good.push(t/2);
	}
	long long ans = 0;
	while (!good.empty()) {
		int t = good.top();
		good.pop();
		ans += (long long)t;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define int long long
#define P(x) {if (debug) cout << x << endl;}
#define H(x) P(#x << ": " << (x))
#define FR(i,a,b) for (int i=(a); i<(b); i++)
#define F(i,n) FR(i,0,n)
#define DR(i,a,b) for (int i=(b); i-->(a);)
#define D(i,n) DR(i,0,n)
#define S(s) (int)(s).size()
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,v)
#define MA(a,v) a = max(a,v)
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
template<class T> ostream &operator<<(ostream &os, V<T> v) {
    F(i,S(v)) os<<(i?" ":"")<<v[i];
    return os;
}
const bool debug = 1;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin>>s;
    int n=S(s),k; cin>>k;
    set<string> subs;
    F(i,n) FR(j,1,6) if (i+j <= n) {
        subs.insert(s.substr(i,j));
    }
    while (k > 1) {
        k--;
        subs.erase(subs.begin());
    }
    cout<<*subs.begin()<<"\n";
}

Measured memory_bytes: 1664
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
  a=list(map(int,input().split()))
  check=0
  for j in range(m):
    check+=a[j]*b[j]
  if check>-c:
    ans+=1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>

using namespace std;

class Cake {
    class Piece {
    public:
        int id = 1, w, d;

        Piece(int w, int d) :
                w(w), d(d) {}

        int area() {
            return w * d;
        }
    };

public:
    unordered_map<int, Piece *> pieces;

    Cake(int w, int d) {
        pieces[1] = new Piece{w, d};
    }

    void cut(int p, int s) {
        Piece *p0 = pieces[p], *p1, *p2;
        int w1, w2, d1, d2;
        //
        s %= p0->w * 2 + p0->d * 2;
        if (s < p0->w) {
            w1 = s;
            w2 = p0->w - s;
            p1 = new Piece{w1, p0->d};
            p2 = new Piece{w2, p0->d};
        } else if (s < p0->w + p0->d) {
            s -= p0->w;
            d1 = s;
            d2 = p0->d - s;
            p1 = new Piece{p0->w, d1};
            p2 = new Piece{p0->w, d2};
        } else if (s < p0->w * 2 + p0->d) {
            s -= p0->w + p0->d;
            w1 = s;
            w2 = p0->w - s;
            p1 = new Piece{w1, p0->d};
            p2 = new Piece{w2, p0->d};
        } else {
            s -= p0->w * 2 + p0->d;
            d1 = s;
            d2 = p0->d - s;
            p1 = new Piece{p0->w, d1};
            p2 = new Piece{p0->w, d2};
        }
        //
        if (p1->area() <= p2->area()) {
            p1->id = pieces.size() + 1;
            p2->id = pieces.size() + 2;
        } else {
            p1->id = pieces.size() + 2;
            p2->id = pieces.size() + 1;
        }
        //
        pieces.erase(p);
        delete p0;

        vector<Piece *> tmp;

        tmp.push_back(p1);
        tmp.push_back(p2);

        for (auto p : pieces) {
            tmp.push_back(p.second);
        }

        sort(tmp.begin(), tmp.end(),
             [](Piece *lhs, Piece *rhs) -> bool {
                 return lhs->id < rhs->id;
             });

        pieces.clear();

        for (int i = 0; i < tmp.size(); i++) {
            tmp[i]->id = i + 1;
            pieces[i + 1] = tmp[i];
        }
    }

};

int main() {
    int n, w, d;
    while (cin >> n >> w >> d) {
        if ((n | w | d) == 0) break;

        Cake cake{w, d};

        int p, s;
        while (n--) {
            cin >> p >> s;
            cake.cut(p, s);
        }

        vector<int> ans;

        for (auto p : cake.pieces) {
            ans.push_back(p.second->area());
        }

        sort(ans.begin(), ans.end());

        cout << ans[0];
        for (int i = 1; i < ans.size(); i++) {
            cout << " " << ans[i];
        }
        cout << endl;
    }
}




Measured memory_bytes: 3296