akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <vector>
#include <string.h>
#include <algorithm>
using namespace std;

#define N 110000

vector<int> vec[N];
int order[N];
int a[N], pa[N];

void init(int n) {
    memset(order, 0, sizeof(order));
    for (int i = 1; i <= n; ++i) {
        pa[i] = i;
        vec[i].clear();
        vec[i].push_back(a[i]);
    }
}

int findset(int x) {
    return x == pa[x] ? pa[x] : pa[x] = findset(pa[x]);
}

int main() {
    int n, m;
    while (scanf("%d%d", &n, &m) == 2) {
        for (int i = 1; i <= n; ++i) scanf("%d",&a[i]);
        init(n);
        while (m--) {
            int u, v;
            scanf("%d%d",&u, &v);
            int x = findset(u);
            int y = findset(v);
            if (x != y) {

                if (vec[x].size() <= vec[y].size()) {
                    pa[x] = y;
                    for (int i = 0; i < vec[x].size(); ++i) {
                        vec[y].push_back(vec[x][i]);
                    }
                } else {
                    pa[y] = x;
                    for (int i = 0; i < vec[y].size(); ++i) {
                        vec[x].push_back(vec[y][i]);
                    }
                }

            }
        }
        int cnt = 0;
        for (int i = 1; i <= n; ++i) {
            int x = findset(i);
            if (!order[x]) { sort(vec[x].begin(), vec[x].end()); order[x] = 1; }
            int p = lower_bound(vec[x].begin(), vec[x].end(), i) - vec[x].begin();
            if (vec[x][p] == i) cnt++;
        }
        printf("%d\n",cnt);

    }
    return 0;
}


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

int main() {
	char c;
	while (true) {
		scanf("%c", &c);
		if (c == '\n') {
			cout << endl;
			break;
		}
		if (isupper(c)) {
			c = tolower(c);
			cout << c;
		}
		else if (islower(c)) {
			c = toupper(c);
			cout << (c);
		}
		else
			cout << c;
	}
	return 0;
}

Measured memory_bytes: 3220
n, m = map(int, input().split())
a = [ int(x) for x in input().split() ]

# mod をとった累積和をとる
for k, v in enumerate(a):
    if k != 0:
        a[k] += a[k-1]
    a[k] %= m

ans = 0
dic = {}

for aa in a:
    dic[aa] = (dic.get(aa, 0) + 1)

    if aa == 0:
        ans += dic[aa]
    else:
        ans += dic[aa] - 1

print(ans)


Measured memory_bytes: 14252
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

ll x[1010], y[1010];
char ch[2][2]={'L','D','U','R'};

int
main(void){  
  ios::sync_with_stdio(false); 
  int n;
  cin >> n;
  REP(i, n){
    cin >> x[i] >> y[i];
  }
  
  int p = (abs(x[0]) + abs(y[0])) % 2;
  FOR(i, 1, n){
    if((abs(x[i]) + abs(y[i]) )%2 != p) {cout << "-1" << endl; return 0;}
  }

  int m = 31 + (p ? 0 : 1);
  cout << m << endl;
  REP(i, m) printf("%d%c", i == 31 ? 1 : 1 << i, i + 1 == m ? '\n' : ' ');
  if(!p) {
    REP(i, n) {
      x[i]--;
    }
  }
  REP(i, n){
    int u = x[i] + y[i], v = x[i] - y[i];
    REP(j, 31) {
      putchar(ch[((u - 1) / 2 + (1 << 30)) >> j & 1][((v - 1) / 2 + (1 << 30)) >> j & 1]);
    }
    if(!p) {
      putchar('R');
    }
    puts("");
  }
    
  return 0;
}


Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
const int mxw=1e5+5;
const int mxn=(1<<18)+10;
const int magic=(1<<9);
int v[mxn],w[mxn];
int dp[magic][mxw];
int ses(int x,int l)
{
    if(x<magic)return dp[x][l];
    vector<pi>vec;
    while(x>=magic)
    {
        vec.pb(mp(w[x],v[x]));
        x>>=1;
    }
    int sz=vec.size();
    int ret=0;
    int tmp=(1<<sz);
    for(int msk=0;msk<tmp;msk++)
    {
         int sw=0,sv=0;
         for(int j=0;j<sz;j++)
         {
             if((msk>>j) & 1)
             {
                 sw+=vec[j].fi;
                 sv+=vec[j].si;
             }
         }
         if(sw<=l)
         {
             ret=max(ret,sv+dp[x][l-sw]);
         }
    }

    return ret;
}
 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,n)
    {
        cin>>v[i]>>w[i];
    }
    for(int i=1;i<magic && i<=n;i++)
    {
        for(int j=1;j<mxw;j++)
        {
            dp[i][j]=dp[i>>1][j];
            if(w[i]<=j)
            {
                dp[i][j]=max(dp[i][j],v[i]+dp[i>>1][j-w[i]]);
            }
        }
    }
    int q;
    cin>>q;
    while(q--)
    {
        int x,l;
        cin>>x>>l;
        cout<<ses(x,l)<<"\n";
    }
    return 0;

}




































Measured memory_bytes: 406904
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
int n;
ll H[555];
int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++) scanf("%lld",&H[i]);
  sort(H,H+n);
  ll mi=0;
  ll res=1;
  for(int i=n-1,j=1;i>-1;i--,j++){
    if(H[i]-mi<=0) break;
    res+=(H[i]-mi);
    if(j%4==0) mi++;
  }
  printf("%lld\n",res);
}

Measured memory_bytes: 1048
#include<bits/stdc++.h>
#define rint register int 
#define ll long long 
#define mk make_pair
#define pa pair<int,int>
#define pb push_back
using namespace std;
int N,M,L[201010],R[201000];
int Max[2010000],tag[2010000];
vector<int> vec[1010000];
inline void Pushdown(int now) {
	if(tag[now]){
		Max[now<<1]+=tag[now];
		Max[now<<1|1]+=tag[now];
		tag[now<<1]+=tag[now];
		tag[now<<1|1]+=tag[now];
		tag[now]=0;
		return ; 
	}
} 
inline void Update(int now) {
	Max[now]=max(Max[now<<1],Max[now<<1|1]);
}
inline void Build(int now,int l,int r) {
	if(l==r) {Max[now]=-l;return ;}
	int mid=(l+r)>>1;
	Build(now<<1,l,mid);
	Build(now<<1|1,mid+1,r);
	Update(now);
}
inline void Modify(int now,int l,int r,int x,int y,int d){
	x=max(0,x);y=min(M,y);//if(x>y) return ;
	if(x<=l&&r<=y){tag[now]+=d;Max[now]+=d;return ;}
	int mid=(l+r)>>1;Pushdown(now);
	if(x<=mid) Modify(now<<1,l,mid,x,y,d);
	if(y>mid) Modify(now<<1|1,mid+1,r,x,y,d);
	Update(now); 
}
inline int Qry(int now,int l,int r,int x,int y){
	x=max(0,x);y=min(M,y);//if(x>y) return 0;
	if(x<=l&&r<=y) return Max[now];
	int res=0,mid=(l+r)>>1;Pushdown(now);
	if(x<=mid) res=max(res,Qry(now<<1,l,mid,x,y));
	if(y>mid) res=max(res,Qry(now<<1|1,mid+1,r,x,y));
	Update(now);
	return res; 
} 
int main() {
	cin>>N>>M;
	for(rint i=1;i<=N;++i) cin>>L[i]>>R[i],vec[R[i]].pb(L[i]);
	Build(1,0,M);
	int ans=0;ans=max(N-M,ans);
	for(rint i=M+1;i>=1;--i) {
		int SZ=vec[i].size();
		if(i<=M&&i>=1) {
			Modify(1,0,M,0,M,-1);
		}
		for(rint j=0;j<SZ;++j){
			int l=vec[i][j];
			Modify(1,0,M,l,M,1);
		}
		ans=max(ans,Qry(1,0,M,0,i-1));
	}cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 36448
news = str(input())
news = list(news)
cn = news.count('N')
ce = news.count('E')
cw = news.count('W')
cs = news.count('S')
if cn > 0 and ce > 0 and cw > 0 and cs > 0 :
  print("Yes")
elif cn == cs == 0:
  if cw > 0 and ce > 0:
    print("Yes")
  else:
    print("No")
elif cw == ce == 0:
  if cn > 0 and cs > 0:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()


void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

//ifstream &cin
void solve(){

}

int main() {
    fastik();
    //ifstream cin("input.txt");
    /*ll t = 1;
    cin >> t;
    while(t--){
       solve();
    }*/
    ll n,l;cin>>n>>l;
    vll a(n);
    ll mn = ll(2e9);
    ll ans = 0;
    ll dec = 1;
    forn(i,n){
        a[i] = l + i;
        ans += a[i];
        if(a[i] > 0){
            dec = -1;
        }
    }
    if(dec == 1){
        mn = ll(-2e9);
    }
    forn(i,n){
        if(dec == 1){
            mn = max(a[i],mn);
        }else{
            mn = min(a[i],mn);
            mn = max(mn,ll(0));
        }
    }
    //cout << ans<<"\n";
    //forn(i,n) cout<<a[i]<<" ";
    //cout << "\n";
    cout << ans - mn;


}

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

#define     ll     long long int

int main( )
{
    char a, b;
    cin >> a >> b;
    if (a == 'H') {
        cout << b << '\n';
    }
    else {
        if (b == 'H') {
            cout << "D\n";
        }
        else {
            cout << "H\n";
        }
    }
    return 0;
}


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


using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
int cnt = 0;

int main(){
    int n;
    vector<int> vec;
    int mina;
    int maxa;
    int d=0;
    cin >> n;
    rep(i,n){
        cin >> d;
        vec.push_back(d);
    }
    
    sort(vec.begin(),vec.end());
    
    for(int c=0; c<n; c++){
        for(int b=(c+1); b<n; b++){
            mina = vec[b] - vec[c];
            maxa = vec[b] + vec[c];
            for(int a=(b+1); a<n; a++){
                if(maxa <= vec[a]){
                    continue;
                }
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


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

#define SZ(x) (int)((x).size())
#define xx first
#define yy second
#define pii pair<int, int>



void solve() {
    int d, t, s;
    cin >> d >> t >> s;
    cout << (d <= s * t ? "Yes" : "No") << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 605;
const int P = 1e9 + 7;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int s[MAXN], home[MAXN], dp[MAXN][MAXN];
int n, m, p[MAXN], fac[MAXN];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int main() {
	read(n), read(m), fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = fac[i - 1] * (2ll * i - 1) % P;
	for (int i = 1; i <= m; i++) {
		int x, y; read(x), read(y);
		home[x] = home[x + n * 2] = i;
		home[y] = home[y + n * 2] = i;
	}
	int ans = 0;
	for (int i = 1; i <= n * 2 - 1; i++) {
		static bool col[MAXN]; int cnt = 0, empty = 0;
		memset(col, false, sizeof(col));
		for (int j = i; j <= n * 2 - 1; j++) {
			if (home[j]) {
				cnt -= col[home[j]];
				col[home[j]] ^= true;
				cnt += col[home[j]];
			} else empty += 1;
			if (cnt == 0 && empty % 2 == 0) {
				dp[i][j] = fac[empty / 2];
				for (int k = i, cmt = 0; k <= j - 1; k++) {
					cmt += !home[k];
					if (cmt % 2 == 0) update(dp[i][j], P - 1ll * dp[i][k] * fac[empty / 2 - cmt / 2] % P);
				}
				update(ans, 1ll * dp[i][j] * fac[n - m - empty / 2] % P);
			}
		}
	}
	update(ans, fac[n - m]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1664
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  rep(i, N) {
    cin >> a[i];
  }

  vector<vector<bool>> L(N + 1, vector<bool>(K + 1, false));
  L[0][0] = true;
  rep(i, N) {
    rep(j, K + 1) {
      if (!L[i][j])
        continue;

      L[i + 1][j] = true;
      if (j + a[i] <= K)
        L[i + 1][j + a[i]] = true;
    }
  }

  vector<vector<bool>> R(N + 1, vector<bool>(K + 1, false));
  R[N][0] = true;
  repr(i, N, 1) {
    rep(j, K + 1) {
      if (!R[i][j])
        continue;

      R[i - 1][j] = true;
      if (j + a[i - 1] <= K)
        R[i - 1][j + a[i - 1]] = true;
    }
  }

  int ans = 0;
  rep(i, N) {
    vector<int> l, r;
    repp(j, 0, K) {
      if (L[i][j])
        l.pb(j);
      if (R[i + 1][j])
        r.pb(j);
    }

    bool need = false;
    for (int ll : l) {
      auto itl = lower_bound(all(r), K - a[i] - ll);
      auto itr = lower_bound(all(r), K - ll);
      if (itl != itr) {
        need = true;
        break;
      }
    }

    if (!need)
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 7180
#include <bits/stdc++.h>
using namespace std;
#define lli long long int 
#define MOD 1000000007
#define f(i,a,n) for(lli i = a; i < n; i++)
#define pb push_back
#define mp make_pair

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

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
lli t=1;
// cin>>t;
while(t--)
{
	string s;
	cin>>s;
	lli n=s.length();
	string s1;
	lli ans=0;
	if(n<3)
		cout<<ans;
	else
	{
		f(i,0,n)
		{
			if(i<n-1 && s[i]=='B' && s[i+1]=='C')
			{
				s1.pb('D');
				i++;
				// cout<<s<<endl;
			}
			else
				s1.pb(s[i]);
		}
		// cout<<s1;
		lli countA=0;
		f(i,0,s1.length())
		{
			if(s1[i]=='A')
			{
				countA++;
			}
			else if(s1[i]=='D')
			{
				ans+=countA;
			}
			else
				countA=0;
		}
		cout<<ans;
	}
}
return 0;
}

Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 40005
#define MAX_L 100005
int N;
int A[MAX_N],B[MAX_N];
int a[MAX_L],b[MAX_L];
int c[MAX_L];

int main(){
  while(1){
    scanf("%d",&N);
    if(N==0)break;
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));

    for(int i=0;i<N;i++){
      scanf("%d",&A[i]);
      a[A[i]]++;
      c[A[i]]++;
    }

    for(int i=0;i<N;i++){
      scanf("%d",&B[i]);
      b[B[i]]++;
      c[B[i]]++;
    }

    for(int i=1;i<MAX_L;i++){
      c[i]+=c[i-1];
    }
    /*
    for(int i=0;i<=11;i++){ printf("%3d",a[i]); } cout<<endl;
    for(int i=0;i<=11;i++){ printf("%3d",b[i]); } cout<<endl;
    for(int i=0;i<=11;i++){ printf("%3d",c[i]); } cout<<endl;
    */

    int ans=1e9,sumA=0,sumB=0;
    int cntA=0,cntB=0;

    for(int i=MAX_L-1;i;i--){
      cntA+=a[i];cntB+=b[i];
      if(a[i]==b[i])continue;
      if(a[i]>b[i]){
	int dA=(a[i]-b[i]);
	int k=min(dA,sumB);
	dA-=k;sumB-=k;
	sumA+=dA;
      }else if(a[i]<b[i]){
	sumB+=(b[i]-a[i]);
      }
      
      //      cout<<i<<' '<<cntA<<' '<<cntB<<' '<<sumA<<' '<<sumB<<endl;
      int X=max(cntA,cntB);
      if(X/2 < sumA){
	int xx=X;
	while((xx-1)/2<(sumA-1) &&xx>1&&sumA>1){
	  xx--;
	  sumA--;
	  //	  cout<<xx<<' '<<sumA<<' '<<'!'<<endl;
	}
	ans=min(ans,xx);
	break;
      }
    }
    if(ans==1e9||ans==N)printf("NA\n");
    else printf("%d\n",ans);
  }

  return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b,c;cin>>a>>b>>c;
  cout<<c<<" "<<a<<" "<<b<<endl;
    return 0;
}


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

typedef long long ll;

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;

string bata(ll n) {
	string s = "";
	while(n) {
		int r = n%26;
		n /= 26;
		if(r==0) s += 'z', n--;
		else s += (char)(r+'a'-1);
	}
	reverse(ALL(s));
	return s;
}
void solve() {
	ll n;
	cin >> n;

	cout << bata(n);
}

int32_t main() {_
	
#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
		solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}



Measured memory_bytes: 3844
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func bubleSort(a []int, n int) {
	flag := 1
	count := 0
	for {
		flag = 0
		for j := n - 1; j > 0; j-- {
			if a[j] < a[j-1] {
				var v int
				v = a[j]
				a[j] = a[j-1]
				a[j-1] = v
				flag = 1
				count++
			}
		}
		if flag == 0 {
			break
		}
	}
	for i := 0; i < n; i++ {
		if i == n-1 {
			fmt.Printf("%d", a[i])
			fmt.Print("\n")
		} else {
			fmt.Printf("%d ", a[i])
		}
	}
	fmt.Println(count)
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	bubleSort(a, n)
}



Measured memory_bytes: 1104
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef  long long  ll;
const int maxn = 2e5 + 5;
int n, q;
ll a, t[maxn], ans[maxn];
vector<ll> v;
int main() {
    scanf("%d %d",&n,&q);
    v.push_back(n);//!!!
    for (int i=0; i<q; i++) {
        scanf("%lld",&a);
        while (v.size() && v.back() >= a)
            v.pop_back();
        v.push_back(a);
    }
    //for (int i=0; i<v.size(); i++) cout<<v[i]<<"  ";
    t[v.size() - 1] = 1;
    for (int i=v.size()-1; i>=0; i--) {
        ll k = v[i];
        //cout<<endl<<i<<" : \n";
        while (k > v[0]) {
            int j = lower_bound(v.begin(), v.end(), k) - (v.begin() + 1);
            t[j] += k / v[j] * t[i];
            //cout<<k<<" "<<j<<" : "<<v[j]<<" "<<t[j]<<" "<<t[i]<<endl;
            k %= v[j];
        }
        ans[k] += t[i];
    }
    for (int i=n-1; i>=1; i--) ans[i] += ans[i+1];
    for (int i=1; i<=n; i++)
        printf("%lld\n", ans[i]);
    return 0;
}

Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000

double dis(int i, int j, int E){
    double ans = i*i + j*j;
    ans = pow(ans, 0.5);
    if((double)E - ans > 0) return (double)E - ans;
    else return ans - (double)E;
}

int main(void){
    int D; int E;
    while(1){ 
        cin >> D >> E;
        if(D == 0) break;
        double ans = INF;
        for(int i = 0; i <= D; i++){
            ans = min(ans, dis(i, -i + D, E));
        }
        cout << ans << endl;
    }

    return 0;
}

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

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

/********
*	?????????????´¢
*********/	

/*********??¢?????´?????????
*	(1)
*	(2)????????°?????????????????????????????????0????????????
*********/

int main(void)
{
	char word	 [10]	={0};
	char sentence[1000]	={0};
	int i, j;		//
	int length_w ;
	int length_T ;
	int count = 0;
	int sa 	  = 0;

	std::cin >> word ;
	length_w = strlen(word);
	
	while (scanf("%s",sentence) != EOF) {
		sa = 0;
//		std::cin >> sentence;
		length_T = strlen(sentence);
		
		
		if (length_w == length_T){
			//??????W???????????¨??????T????????????????????????????????¨???
			j=0;
			for(i= 0 ; i<	length_w; i++ ){
				sa = word[i] - sentence[i];
				
				if(32 <= sa && sa <= 59){
					 sa = sa-32; 
				}
				if(sa == 0){
					j ++; 	
					if(j==length_w ){
						count++;
					}
				} else {
				//?????????????????????
				}
			}
		}else {
		//?????????????????????
		}
		
	}
	
	std::cout << count << std::endl; 
    return 0;

}

Measured memory_bytes: 1176
<?php

fscanf(STDIN, "%d", $N);
$input = explode(" ", trim(fgets(STDIN)));

sort($input);

$arg=[];
$min=0;
for ($i=1; $i < $N; $i++) { 
	$arg[$i] = $input[$i] - $input[$i-1];
}

sort($arg);

foreach ($arg as $key => $value) {
	if ($value>0) {
		$min = $value;
		break;
	}
}

if ($input[0]>$min) {
	$nex = $input[0]-$min;
}else{
	$nex = $min-$input[0];
}

function sol($input,$min){
	$newmin=$min;
	foreach ($input as $key => $value) {
		$nowmin = $value % $min;
		if ($nowmin < $min && $nowmin != 0) {
			$newmin = $nowmin;
		}
	}
	if ($newmin != $min) {
		return sol($input,$newmin);
	}else{
		return $min;
	}
}


if ($min==0) {
	echo $input[0];
}else{
	$min = sol($input,$min);
	echo $input[0]>$min?$min:$input[0];
}


Measured memory_bytes: 18932
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

int main() {
  int r, d, x;
  cin >> r >> d >> x;
  for (int i = 0; i < 10; i ++) {
    int nx = r * x - d;
    cout << nx << endl;
    x = nx;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;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();}
	return x*f;
}
int stack[20];
inline void write(LL x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(LL x){write(x);putchar('\n');}
const int MAXN=2005;
const LL mod=1e9+7;
int n,K;
LL inv[MAXN*MAXN],pre[MAXN*MAXN];
LL pow_mod(LL a,LL b)
{
	LL ret=1;
	while(b)
	{
		if(b&1)ret=ret*a%mod;
		a=a*a%mod;b>>=1;
	}
	return ret;
}

LL f[MAXN][MAXN];
LL C(int n,int m){return pre[n]*inv[m]%mod*inv[n-m]%mod;}
void ad(LL &x,LL y){x+=y;if(x>=mod)x-=mod;}
int main()
{
	n=read();K=read();
	if(K==1)return puts("1"),0;
	pre[0]=1;for(int i=1;i<MAXN*MAXN;i++)pre[i]=pre[i-1]*i%mod;
	inv[MAXN*MAXN-1]=pow_mod(pre[MAXN*MAXN-1],mod-2);
	for(int i=MAXN*MAXN-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
	f[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=i;j++)
		{
			if(i-1>=j)ad(f[i][j],f[i-1][j]);
			ad(f[i][j],f[i][j-1]*C(n*K-(K-1)*(j-1)-i-1,K-2)%mod);
		}
	f[n][n]=f[n][n]*pre[n]%mod;
	pr2(f[n][n]);
	return 0;
}


Measured memory_bytes: 92928
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=2e5+7,M=N<<1;
const int mod=inf;

int f[N][3],pw2[N];
int v[N],nxt[N];
int p[N],dep[N],head[N],up[N],from[N];
int q[N],st,ed;
priority_queue<pii,vector<pii>,less<pii> > pq;
bool inq[N];
int n,ans;

il void dfs(const int &u){
	if(u){
		dep[u]=dep[p[u]]+1;
		up[u]=(nxt[head[p[u]]]?u:up[p[u]]);
	}
	for(int e=head[u];e;e=nxt[e]){
		dfs(v[e]);
	}
}

il int top(const int &u){
	return up[u]==u?u:up[u]=top(up[u]);
}

il void inc(int &x,const int &y){
	x+=y;
	if(x>=mod) x-=mod;
}

il void upd(int v,int u){
	if(!inq[v]) f[v][0]=1,f[v][1]=f[v][2]=0;
	ll cnt0=f[u][0]+f[u][2],cnt1=f[u][1];
	f[v][2]=((cnt0+cnt1)*f[v][2]+cnt1*f[v][1])%mod;
	f[v][1]=(cnt0*f[v][1]+cnt1*f[v][0])%mod;
	f[v][0]=(cnt0*f[v][0])%mod;
}

int main(){
//	fileio("test");
	scanf("%d",&n);
	pw2[0]=1;
	rep(i,1,n+1){
		pw2[i]=pw2[i-1]<<1;
		if(pw2[i]>=mod) pw2[i]-=mod;
	}
	rep(i,1,n){
		scanf("%d",p+i);
		v[i]=i,nxt[i]=head[p[i]],head[p[i]]=i;
	}
	dfs(0);
//	rep(i,1,n) cerr<<i<<" "<<up[i]<<endl;
	for(st=0,ed=0,q[ed]=0;st<=ed;){
		int cur=dep[q[st]],cnt=0;
		for(;st<=ed&&dep[q[st]]==cur;++st){
			int u=q[st];
			++cnt;
			f[u][0]=f[u][1]=1,f[u][2]=0;
			pq.push(mp(dep[u],u));
			inq[u]=true;
			for(int e=head[u];e;e=nxt[e]) q[++ed]=v[e];
			for(u=top(u);u;u=top(p[u])){
				if(from[p[u]]!=u) from[p[u]]=(!from[p[u]]?u:-1);
			}
		}
		while(!pq.empty()){
			pii tmp=pq.top();pq.pop();
			int u=tmp.Y,v=p[top(u)];
			inq[u]=false;
			if(from[u]>0) up[from[u]]=u;
			from[u]=0;
			if(!u){
				inc(ans,1ll*f[u][1]*pw2[n+1-cnt]%mod);
				break;
			}
			upd(v,u);
			if(!inq[v]){
				pq.push(mp(dep[v],v));
				inq[v]=true;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 11904
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;


int main(void) {
    int n, k, i, j;
    ll a[1003] = {}, ans = 0;
    vector<ll> lv;

    cin >> n >> k;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
    }

    for (i = 1; i <= n; i++) {
        a[i] += a[i - 1];
    }

    for (i = 0; i < n; i++) for (j = i + 1; j <= n; j++) {
        lv.push_back(a[j] - a[i]);
    }

    sort(lv.begin(), lv.end(), greater<ll>());

    while (lv.size() >= k) {

        int t1, t2, mt;
        ll m1, m2, r;
        vector<ll> y;

        m1 = lv[0];
        m2 = lv[k - 1];

        if (m1 <= 1) {
            if (m2 == 1) ans++;
            break;
        }

        t1 = t2 = 0;
        while (m1 > 1) {
            m1 /= 2;
            t1++;
        }
        while (m2 > 1) {
            m2 /= 2;
            t2++;
        }

        mt = max(t1, t2);

        r = 1;
        for (i = 0; i < mt; i++) {
            r *= 2;
        }

        if (t1 == t2) {
            ans += r;
            for (i = 0; i < lv.size(); i++) {
                if (lv[i] < r) break;
                y.push_back(lv[i] - r);
            }
        }
        else {
            for (i = 0; i < lv.size(); i++) {
                if (lv[i] != r) y.push_back(lv[i] % r);
            }
        }

        lv = y;

        sort(lv.begin(), lv.end(), greater<ll>());

    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 6384
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const int MaxN = 100 + 5, MaxK = 100000 + 5;

int N, K;
int A[MaxN];
bool dp[MaxK];

void init() {
  scanf("%d %d", &N, &K);
  for (int i = 1; i <= N; ++i)
    scanf("%d", &A[i]);
}

void solve() {
  for (int i = 1; i <= K; ++i) {
    for (int j = 1; j <= N; ++j)
      if (i - A[j] >= 0) if (dp[i - A[j]] == false) dp[i] = true;
  }

  if (dp[K] == true) puts("First");
  else puts("Second");
}

int main() {
  init();
  solve();
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iomanip>

using namespace std;

typedef long long LL;

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

int n, m, k;

void solve() {
	int ans = 1;
	for (int i = 2; i <= n; i++) {
		int pos = (k - 1 + i) % i + 1;
		ans = (ans + pos - 1) % i + 1;
	}
	ans = ((ans + m - 1 - k) % n + n) % n + 1;
	printf("%d\n", ans);
}

int main() {
	while (scanf("%d%d%d", &n, &k, &m) && (n||m||k))
		solve();

}

Measured memory_bytes: 1188
import sys

N, Y = [int(x) for x in sys.stdin.readline().strip().split()]

a = Y // 10000
b = (Y - a * 10000) // 5000
c = (Y - a * 10000 - b * 5000) // 1000

while 1:
    t = a + b + c
    if N >= t + 9 and a > 0:
        a -= 1
        c += 10
        continue
    if N >= t + 4 and b > 0:
        b -= 1
        c += 5
        continue
    if N > t and a > 0:
        a -= 1
        b += 2
        continue
    break

if a + b + c != N or a < 0 or b < 0 or c < 0:
    print("-1 -1 -1")
else:
    print(a, b, c)
    #print(a + b + c)
    #print(a*10000+b*5000+c*1000)


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

using namespace std;

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

    if(S.size() >= T.size()){
        for(int i=0; i<=S.size() - T.size(); i++){
            // S?????¨????????????????????????i????????????T????????????????????????????????????
            if(T == S.substr(i, T.size())){
                cout << i << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3224
#include<iostream>

void swap(int *a, int *b) {
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}


void sort(int *a, int *b, int *c) {
  int temp;
  if (*a > *b) {
    swap(a, b);
  }
  if (*a > *c) {
    swap(a, c);
  }
  if (*b > *c) {
    swap(b, c);
  }
}


int main() {
  int a, b, c;
  char delimiter = ' ';

  std::cin >> a >> b >> c;
  sort(&a, &b, &c);
  std::cout << a << delimiter << b << delimiter << c << std::endl;

  return 0;
}



Measured memory_bytes: 3104
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()


ok = [True] * N
d = {"r": P, "s": R, "p": S}
ans = 0
for i in range(N):
    if i >= K and T[i - K] == T[i] and ok[i - K]:
        ok[i] = False
    if ok[i]:
        ans += d[T[i]]
print(ans)


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

int main(){
    string s;
    cin >> s;
    
    long long ans = 0, count_a = 0;
    int len = s.length();
    rep(i, len){
        if(s.at(i) == 'A') count_a++;
        if(s.at(i) == 'B' && i != len-1){
            if(s.at(i+1) == 'C'){
                ans += count_a;
                i++;
            }
            else{
                count_a = 0;
            }
        }
        else if(s.at(i) == 'C') count_a = 0;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import sys

n = int(sys.stdin.readline().strip())
data = sys.stdin.readline().strip().split(' ')

min = None
max = None
sum = 0

for i in range(n):
    num = int(data[i])
    if max is None or num > max:
        max = num

    if min is None or num < min:
        min = num

    sum += num

print('%d %d %d' % (min, max, sum))

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

int main(){
  int n;
  cin>>n;
  char s[n][n],t[n][n];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>s[i][j];
    }
  }
  int ans=0;
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        t[i][j]=s[i][(j+k)%n];
      }
    }
    bool flag=1;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(t[i][j]!=t[j][i]){
          flag=0;
        }
      }
    }
    if(flag) ans+=n;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<ctime>
    #include<cctype>
    #include<algorithm>
    #include<cstring>
    #include<iomanip>
    #include<queue>
    #include<map>
    #include<set>
    #include<bitset>
    #include<stack>
    #include<vector>
    #include<cmath>
    #define ld long double
    //This code is written by Itst
    using namespace std;
     
    inline int read(){
        int a = 0;
        char c = getchar();
        bool f = 0;
        while(!isdigit(c) && c != EOF){
            if(c == '-')
                f = 1;
            c = getchar();
        }
        if(c == EOF)
            exit(0);
        while(isdigit(c)){
            a = a * 10 + c - 48;
            c = getchar();
        }
        return f ? -a : a;
    }
     
    const int MOD = 1e9 + 7 , inv2 = 5e8 + 4;
    long long dp[3007][3007];
    int num[3007] , N , M;
     
    int main(){
        N = read();
        M = read();
        for(int i = 1 ; i <= N ; ++i)
            num[i] = read();
        for(int i = 1 ; i <= N ; ++i)
            for(int j = i - 1 ; j ; --j){
                dp[i][j] = num[i] > num[j];
                dp[j][i] = num[j] > num[i];
            }
        for(int i = 1 ; i <= M ; ++i){
            int a = read() , b = read();
            for(int j = 1 ; j <= N ; ++j)
                if(j != a && j != b){
                    dp[j][a] = dp[j][b] = (dp[j][a] + dp[j][b]) * inv2 % MOD;
                    dp[a][j] = dp[b][j] = (dp[a][j] + dp[b][j]) * inv2 % MOD;
                }
            dp[a][b] = dp[b][a] = (dp[a][b] + dp[b][a]) * inv2 % MOD;
        }
        long long sum = 0;
        for(int i = 1 ; i <= N ; ++i)
            for(int j = i - 1 ; j ; --j)
                sum = (sum + dp[j][i]) % MOD;
      	for(int i = 1 ; i <= M ; ++i)
          sum = sum * 2 % MOD;
        cout << sum;
        return 0;
    }

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

typedef pair<int, int> P;

int main(){
  int N, M;
  cin >> N >> M;
  vector<P> a;
  for(int i=0; i<M; i++){
    int A,B; cin >> A >> B;
    a.push_back(make_pair(B,A));
  }
  sort(a.begin(), a.end());
  int ans = 0;
  int last = 0;
  
  for(int i=0; i<M; i++){
    if(last<a[i].second){
      ans+=1;
      last=a[i].first-1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 998244353;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

long long maximum;
vector<long long> fct(0),invfct(0);

long long modpow(long long a,long long n, long long mod){
    long long res = 1;
    while(n>0){
        if ( n & 1 ) res = (res * a) % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}

void fct_input(long long maximum,long long mod){
    fct.resize(maximum+1,-1);
    fct.at(0) = 1;
    fct.at(1) = 1;
    long long x = 1;
    for(long long i=2;i<=maximum;i++){
        x = x * i % mod;
        fct.at(i) = x;
    }
 }

void invfct_input(long long maximum,long long mod){
    invfct.resize(maximum+1,-1);
    invfct.at(0) = 1;
    invfct.at(1) = 1;
    long long x = 1;
    for(long long i=2;i<=maximum;i++){
        x = x * i % mod;
        invfct.at(i) = modpow(x,mod - 2,mod);
    }
}

ll nck(ll n,ll k){
    return ((invfct.at(k) * invfct.at(n-k) % mod) * fct.at(n) ) % mod;
}

int main(){
    ll n ,m,k; cin >> n >> m >> k;
    fct_input(n,mod);
    invfct_input(n,mod);

    ll ans = 0;

    for(int i=0;i<=k;i++){
        ll adding = 1;
        adding = (adding * nck(n-1,i))%mod;
        adding = (adding * m)%mod;
        adding = (adding * modpow(m-1,n-1-i,mod))%mod;
        ans = (ans+adding)%mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6360
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  int N;
  P a[100000];
  cin >> N;
  rep(i, N) {
    int temp;
    cin >> temp;
    a[i].first = temp;
    a[i].second = i+1;
  }

  sort(a, a+N);

  rep(i, N) {
    cout << a[i].second;
    if(i != N-1) cout << " ";
    else cout << endl;
  }

  return 0;
}

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    VI av(n);
    REP(i, n) cin >> av[i];
    vector<bool> dp(k + 1, false);
    FOR(i, 1, k)for(auto a : av)if(i - a >= 0) dp[i] = dp[i] | !dp[i - a];
    cout << (dp[k] ? "First" : "Second") << ln;
    return 0;
}


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

int main(){
  long long X,K,D,ans,t1,t2;
  cin >> X >> K >> D;
  X = abs(X);
  if(X/D >= K) ans = X - D*K;
  else{
    t1 = X - (X/D)*D;
    t2 = X - (X/D+1)*D;
    if( (K - X/D)%2 == 0) ans = t1;
    else ans = t2;
  }
  cout << abs(ans);
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;
int c[26],s[400][30];
int main(){
    int i,j,d; cin >> d;
    for(i=0;i<26;i++){
        cin >> c[i];
    }
    for(i=0;i<d;i++){
        for(j=0;j<26;j++){
            cin >> s[i][j];
        }
    }
    for(i=0;i<d;i++){
        cout << i%26 + 1 << endl;
    }
}

Measured memory_bytes: 3716
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, k: usize);
    let mut ok = vec![false; n];
    for _ in 0..k {
        parse!(it, d: usize, a: [usize; d]);
        for ai in a {
            ok[ai - 1] = true;
        }
    }
    let s = ok.iter().filter(|&&x| x == false).count();
    println!("{}", s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2160
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
using namespace std;

int main()
{
	long long x;
	cin >> x;
	int sum = 0;
	int i = 1;
	int ans = 0;
	while (true) {
		sum += i;
		ans++;
		if (sum >= x) break;
		i++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//noob
#include<bits/stdc++.h>
using namespace std;
#define fori(x) for(int i=0;i<x;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long int 
#define ld long double
#define ull unsigned long long int
#define pi acos(-1)
#define test() int T,t=1;cin>>T;
typedef vector<int> VI;
typedef pair<int,int> PII;


void solve()
{
   //freopen("input.txt","r",stdin);
	int n,x,t;cin>>n>>x>>t;
	if(n>x){
		if(n%x) cout<<((n/x)+1)*t<<endl;
		else cout<<(n/x)*t<<endl;
	}
	else if(n<=x){
		cout<<t<<endl;
	}

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

solve();


	return 0;
}

Measured memory_bytes: 3708
using System;
using System.Linq;

namespace Csharp
{
    class Program
    {

        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            int ans = 0;
            for(int i = 0; i < S.Length; i++)
            {
                if (S[i] != T[i])
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }



    }
}


Measured memory_bytes: 27272
import scala.annotation.tailrec
import scala.collection.mutable
import scala.io.StdIn._
object Main extends App{
  solve()
  @tailrec def solve(): Unit = {
    val n = readInt()
    if (n == 0) {
      return
    }
    val Array(h, w) = readLine.trim.split(' ').map(_.toInt)
    val pages = List.tabulate(n){_ ⇒
      val Array(title, b) = readLine.trim.split(' ')
      val buttons = List.tabulate(b.toInt){_ ⇒
        val Array(left, up, right, botton, label) = readLine.trim.split(' ')
        Button(label, left.toInt, up.toInt, right.toInt, botton.toInt)
      }
      title → new Page(title, buttons)
    }
    var browser = new Browser(pages.toMap, pages.head._2)
    val click = """click (\d+) (\d+)""".r
    for (_ ← 0 until readInt) {
      readLine.trim match {
        case "back" ⇒ browser = browser.back
        case "forward" ⇒ browser = browser.forward
        case "show" ⇒ println(browser.show)
        case click(x, y) ⇒ browser = browser.click(Point(x.toInt, y.toInt))
        case _ ⇒ ???
      }
    }
    solve()
  }
  class Browser(private val pages: String ⇒ Page, private val history: History) {
    def this(pages: String ⇒ Page, top: Page){
      this(pages, new History(top))
    }
    def click(point: Point): Browser = {
      history.current.click(point) match {
        case None ⇒ this
        case Some(next) ⇒ new Browser(pages, history.move(pages(next)))
      }
    }
    def back: Browser = new Browser(pages, history.movePrev)
    def forward: Browser = new Browser(pages, history.moveNext)
    def show: String = history.current.title
  }
  case class Point(x: Int, y: Int)
  case class Button(label: String, left: Int, up: Int, right: Int, bottom: Int) {
    def isPushed(point: Point): Boolean = (left to right).contains(point.x) && (up to bottom).contains(point.y)
  }
  class Page(val title: String, val button: List[Button]) {
    def click(point: Point): Option[String] = {
      button.find(_.isPushed(point)).map(_.label)
    }
  }
  case class History(prev: List[Page], current: Page, next: List[Page]) {
    def this(current: Page) {
      this(Nil, current, Nil)
    }
    def movePrev: History = {
      prev match {
        case Nil ⇒ this
        case h::t ⇒ History(t, h, current::next)
      }
    }
    def moveNext: History = {
      next match {
        case Nil ⇒ this
        case h::t ⇒ History(current::prev, h, t)
      }
    }
    def move(page: Page): History = History(current::prev, page, Nil)
  }
}


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

using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int> pii32;
typedef pair<int64,int64> pii64;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int maxn = 1e5+10;
const int64 MO = 1e9+7;
const int64 IN = 1e9;

int m, k;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> m >> k;
	if (k > (1 << m) - 1)
		return cout << "-1\n", 0;
	if (k == 1 && m == 1)
		return cout << "-1\n", 0;
	if (m == 1) {
		cout << 0 << " " << 0 << " " << 1 << " " << 1 << "\n";
		return 0;
	}
	for (int i = 0; i < (1 << m); i++)
		if (i != k)
			cout << i << " ";
	cout << k << " ";
	for (int i = (1 << m) - 1; i >= 0; i--)
		if (i != k)
			cout << i << " ";
	cout << k << "\n";
}


Measured memory_bytes: 1920