akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=2050,mod=924844033;

int fac[M],rfac[M],a[M],b[M],n,k,i,s;

int mul(int a,int b)
{
	return a*(ll)b%mod;
}
int ad(int a,int b)
{
	return(a+b)%mod;
}
int de(int a,int b)
{
	return(a-b)%mod;
}

int pow(int a,int b)
{
	int s=1;
	while(b)
	{
		if(b&1)s=mul(s,a);
		a=mul(a,a);
		b>>=1;
	}
	return s;
}
int rev[M],N,iN;
void pre(int n)
{
	int i,k;
	for(N=1,k=0; N<n; N<<=1)k++;
	for(i=0; i<N; i++)rev[i]=(rev[i>>1]>>1)|((i&1)<<(k-1));
	iN=pow(N,mod-2);
}
void ntt(int*a,int on)
{
	int i,j,k,t,w,wn;
	for(i=0; i<N; i++)
	{
		if(i<rev[i])swap(a[i],a[rev[i]]);
	}
	for(i=2; i<=N; i<<=1)
	{
		wn=pow(5,on==1?(mod-1)/i:mod-1-(mod-1)/i);
		for(j=0; j<N; j+=i)
		{
			w=1;
			for(k=0; k<i>>1; k++)
			{
				t=mul(w,a[i/2+j+k]);
				a[i/2+j+k]=de(a[j+k],t);
				a[j+k]=ad(a[j+k],t);
				w=mul(w,wn);
			}
		}
	}
	if(on==-1)
	{
		for(i=0; i<N; i++)a[i]=mul(a[i],iN);
	}
}

int C(int n,int k)
{
	return n<k?0:mul(fac[n],mul(rfac[k],rfac[n-k]));
}

int main()
{
	scanf("%d%d",&n,&k);
	fac[0]=1;
	for(i=1; i<=n; i++)fac[i]=mul(fac[i-1],i);
	rfac[n]=pow(fac[n],mod-2);
	for(i=n; i>0; i--)rfac[i-1]=mul(rfac[i],i);
	pre(n+1);
	for(i=0; i<=n; i++)
	{
		a[i]=C(n/k-i,i);
		b[i]=C(n/k+1-i,i);
	}
	ntt(a,1);
	ntt(b,1);
	for(i=0; i<N; i++)a[i]=mul(pow(a[i],(k-n%k)*2),pow(b[i],n%k*2));
	ntt(a,-1);
	for(i=0; i<=n; i++)(s+=(i&1?-1:1)*mul(fac[n-i],a[i]))%=mod;
	printf("%d",(s+mod)%mod);
} 

Measured memory_bytes: 256
using System;

namespace _048_Class
{
	class Program
	{
		static void Main ( string[] args )
		{
			string[] weightArray = {
									    "",
									    "fly", "fly","fly",
										"bantam","bantam","bantam",
										"feather","feather","feather",
										"light","light","light",
										"light welter","light welter","light welter","light welter",
										"welter","welter","welter","welter","welter",
										"light middle","light middle","light middle","light middle","light middle","light middle",
										"middle","middle","middle","middle","middle","middle",
										"light heavy","light heavy","light heavy","light heavy","light heavy","light heavy","light heavy","light heavy","light heavy","light heavy"
								   };

			string inputStr;

			while ((inputStr = Console.ReadLine ()) != null)
			{
				double inputNum = double.Parse (inputStr);

				if (inputNum <= 48)
				{
					Console.WriteLine ("light fly");
				}
				else if (91 < inputNum)
				{
					Console.WriteLine ("heavy");
				}
				else
				{
					int index = (int) Math.Ceiling (inputNum) - 48;
					Console.WriteLine (weightArray[index]);
				}
			}
		}
	}
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

struct BIT{
	vi buf;
	int s;
	void Init(int n){
		buf.resize(n,0);
		s=n;
	}
	void Add(int i,int v){
		while(i>=0){
			buf[i]+=v;
			i-=(i+1)&(-i-1);
		}
	}
	int Get(int i){
		int ret=0;
		while(i<s){
			ret+=buf[i];
			i+=(i+1)&(-i-1);
		}
		return ret;
	}
};

struct Kyuri{
	struct Query{
		int x,y,i;
	};
	vector<Query> qs;
	void AddPoint(int x,int y){
		qs.PB(Query{x,y,-1});
	}
	void AddAnswer(int x,int y,int i){
		qs.PB(Query{x,y,i});
	}
	void Calc(vi& ans){
		sort(ALL(qs),[&](const Query& lhs,const Query& rhs){
			return lhs.y!=rhs.y?lhs.y<rhs.y:lhs.i<rhs.i;
		});
		map<int,int> crd;
		for(auto q:qs)
			crd[q.x]=0;
		{
			int tmp=0;
			for(auto& kv:crd)
				kv.second=tmp++;
		}
		BIT bit;
		bit.Init(crd.size());
		for(auto q:qs){
			int x=crd[q.x],y=q.y,i=q.i;
			if(i==-1)
				bit.Add(x,1);
			else
				ans[i]+=bit.Get(x);
		}
	}
};

signed main(){
	int n=read(),m=read();
	Kyuri ky;
	REP(i,n){
		int l=read(),r=read();
		ky.AddPoint(l,r);
	}
	FOR(w,1,m+1){
		int p=w;
		for(;p<=m;p+=w)
			ky.AddAnswer(p-w+1,p-1,w-1);
		ky.AddAnswer(p-w+1,inf,w-1);
	}
	vi ans(m,0);
	ky.Calc(ans);
	REP(i,m)
		print(n-ans[i]);
}


Measured memory_bytes: 49508
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 100000000

using namespace std;

int main() {
   int a,b,h;
   cin >> a >> b >> h;
   cout << (a+b)*h/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int t=2;
		if(n==1) cout<<t<<endl;
		else{
			for(int i=2;i<=n;i++){
				t+=i;
			}
			cout<<t<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
using namespace std;

int main(){
    int a;
    cin >> a;
    int b[200];
    b[0]=a;
    for(int i=1;;i++){
        if(b[i-1]%2==0){
            b[i]=b[i-1]/2;
        }else{
            b[i]=3*b[i-1]+1;
        }
        int c=count(b,b+(i+1),b[i]);
        if(c==2){
            cout << i+1;
            break;
        }
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 
  vector <int> a(3);
  for(int &e:a) cin>>e;
  
  sort(a.begin(),a.end());
  
  if(a[0]+a[1] == a[2]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))
#define YES puts("YES")
#define NO puts("NO")
#define Yes puts("Yes")
#define No puts("No")
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end())

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using vstr = std::vector<std::string>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void dfs(int x_remain, int y_remain) {

}

void Main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;

    if (a == 0 && b == 0) {
        rep(i, h) {
            rep(j, w) {
                cout << "0";
            }
            cout << "\n";
        }
        return;
    }

    if (a == 0) {
        int cnt = b;
        rep(i, h) {
            rep(j, w) {
                if (cnt > 0) {
                    cout << "1";
                }
                else {
                    cout << "0";
                }
            }
            cout << "\n";
            if (cnt > 0)--cnt;
        }
        return;
    }

    if (b == 0) {
        rep(i, h) {
            int cnt = a;
            rep(j, w) {
                if (cnt > 0) {
                    cout << "1";
                    --cnt;
                }
                else {
                    cout << "0";
                }
            }
            cout << "\n";
        }
        return;
    }

    vstr ans(h);

    rep(x, w) {
        int x_count = b;
        if (x < a) {
            rep(y, h) {
                if (x_count > 0) {
                    ans[y].push_back('1');
                    --x_count;
                }
                else {
                    ans[y].push_back('0');
                }

            }
        }
        else {
            rep(y, h) {
                if (x_count > 0) {
                    ans[y].push_back('0');
                    --x_count;
                }
                else {
                    ans[y].push_back('1');
                }

            }
        }
    }
    rep(i, h)cout << ans[i] << "\n";


}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool compare( pair<ll,ll> a , pair<ll,ll> b)
{
    return a.second > b.second  ;
}
int main()
{
   ll n,m;
   cin>>n>>m;
   priority_queue<int , vector<int> , greater<int> > q;
   for(int i=0;i<n;i++)
   {
       ll temp;
       cin>>temp;
       q.push( temp  );
   }
   auto* arr = new pair<ll , ll> [m];
   for(int i=0;i<m;i++)
   {
       cin>>arr[i].first >>arr[i].second ;
   }
   sort( arr , arr + m , compare );

   int index = 0;
   while( index < m )
   {
       ll amount = arr[index].first ;
       ll val = arr[index].second;
       if( val > q.top() )
       {
           while( q.top() < val && amount > 0 )
           {
               q.pop();
               q.push(val);
               amount--;
           }
       }
       index++;
   }
   ll sum =0;
   while( !q.empty() )
   {
       sum += q.top();
       q.pop();
   }
   cout<<sum;
}

Measured memory_bytes: 5336
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;
const ll LOG = 20;
str s;
ll n, k;

int main(){
	IOS;
	cin >> n >> k;
	cin >> s;
	if (s[k - 1] == 'A') s[k - 1] = 'a';
	if (s[k - 1] == 'B') s[k - 1] = 'b';
	if (s[k - 1] == 'C') s[k - 1] = 'c';
	cout << s;
	
	
	

	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 256
cp,score = 0,0
for s in input():
    if s == "g":
        if cp > 0:
            score += 1
            cp -= 1
        else:
            cp += 1
    elif s == "p":
        if cp > 0:
            cp -= 1
        else:
            score -= 1
            cp += 1
print(score)

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

int main(){
  int N;
  cin>>N;
  vector<int> d(N);
  for(int &i:d)
    cin>>i;
  sort(d.begin(),d.end());
  cout<<d.at(N/2)-d.at(N/2-1)<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

struct Sieve{
  ll n;
  vector<ll> f, primes;
  Sieve(ll n = 1): n(n), f(n+1, 0){
    f[0] = f[1] = -1;
    for(ll i = 2; i <= n; i++){
      if(f[i]) continue;
      primes.emplace_back(i);
      f[i] = i;
      for(ll j = i*i; j <= n; j += i) if(!f[j]) f[j] = i;
    }
  }
  bool isPrime(const ll x){ return f[x] == x; }
  vector<ll> factorList(ll x){
    vector<ll> res;
    while(x != 1){
      res.emplace_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<pair<ll, ll>> factor(const ll x){
    vector<ll> fl = factorList(x);
    if(fl.size() == 0) return {};
    vector<pair<ll, ll>> res(1, pair<ll, ll>(fl[0], 0));
    for(ll p : fl){
      if(res.back().first == p) res.back().second++;
      else res.emplace_back(pair<ll, ll>(p, 1));
    }
    return res;
  }
};

int main(void){
  ll n;
  cin >> n;
  Sieve s(n);
  ll ans = 0;
  FOR(i, 1, n){
    ll t = n-i;
    auto f = s.factor(t);
    ll a = 1;
    for(auto p : f){
      a *= p.second+1;
    }
    ans += a;
  }
  cout << ans << endl;
  return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int sum = 0;
    rep(i, n) sum ^= a[i];
    rep(i, n) a[i] ^= sum;
    rep(i, n) {
        printf("%d%c", a[i], (i<n-1?' ':'\n'));
    }
    return 0;
}


Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

ll fib(int n){
  if (n<0) return 0;
  if (n==0||n==1) return 1;
  return (fib(n-1)+fib(n-2))%MOD;
}

int main(){
  int H, W, K;cin>>H>>W>>K;

  ll dp[H+1][W];
  memset(dp, 0, sizeof(dp));
  dp[0][0]=1;
  for (int y=1;y<=H;++y){
    for (int x=0;x<W;++x){
      (dp[y][x]+=fib(x-1)*fib(W-1-x)*dp[y-1][x-1])%=MOD;
      (dp[y][x]+=fib(x)*fib(W-1-x)*dp[y-1][x])%=MOD;
      (dp[y][x]+=fib(x)*fib(W-2-x)*dp[y-1][x+1])%=MOD;
    }
  }

  cout << dp[H][K-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define change(x,y) {int t = x; x = y; y = t;}

int uruu(int year);
int ndays(int y1, int m1, int y2, int m2);

int fy = 0;
int ty = 0;
int fd = 0;
int td = 0;
int mon[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
    int y = 0, cnt = 0;
    int fromy, toy;
    int fromm, tom;
    int fromd, tod;
    int days = 0;
    int u = 0;
    
    
    while(~scanf("%d %d %d %d %d %d",&fromy ,&fromm ,&fromd ,&toy ,&tom ,&tod)){
        if (fromy < 0 || fromm < 0 || fromd < 0 || toy < 0 || tom < 0 || tod < 0) {
            break;
        }
        fy = 0;
        ty = 0;
        fd = 0;
        td = 0;
        y = 0;
        cnt = 0;
        days = 0;
        u = 0;
        if (fromy > toy) {
            change(fromy,toy);
            change(fromm,tom);
        }
        for(y = fromy + 1; y < toy; y++) {
            u = uruu(y);
            if(u) {
                cnt++;
            }
        }
        ndays(fromy, fromm, toy, tom);
        days = 365 * (toy - fromy - 1) + cnt + fd + td - fromd + tod;
        printf("%d\n",days);
    }
    return 0;
}

int uruu(int year)
{
    int result = 0;
    
    if (year % 4 == 0) {
        result = 1;
        if (year % 100 == 0 && year % 400 != 0) {
            result = 0;
        }
    }
    return result;
}

int ndays(int y1, int m1, int y2, int m2){
    int i;
    
    if (y1 % 4 == 0) {
        fy = 1;
        if (y1 % 100 == 0 && y1 % 400 != 0) {
            fy = 0;
        }
    }

    for (i = m1; i <= 12 ; i++) {
        if (fy == 1 && i == 2) {
            fd++;
        }
        fd += mon[i];
    }

    if (y2 % 4 == 0) {
        ty = 1;
        if (y2 % 100 == 0 && y2 % 400 != 0) {
            ty = 0;
        }
    }
    
    for (i = m2 - 1; i >= 1 ; i--) {
        if (ty == 1 && i == 2) {
            td++;
        }
        td += mon[i];
    }
    return 0;
}

Measured memory_bytes: 596
#pragma once
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const ll MAX = 210000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string & S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}

void solv() {
	ll n,m;
	cin >> n >> m;
	COMinit();
	map<ll, int> mp;

	while (m % 2 == 0 )
	{
		mp[2]++;
		m /= 2;
	}

	for (ll i = 3; i <= m; i+=2)
	{
		while (m % i == 0)
		{
			mp[i]++;
			m /= i;
		}
	}
	ll res = 1;
	for (auto p : mp)
	{
		ll v = p.second;
		res *= COM(v + (n - 1), (n - 1));
		res %= INF;

	}

	cout << res << endl;
}

int main() {
	//COMinit();
	solv();

	return 0;
}


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

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

    for (int i = 0; i < N; i++) {
        cout << S[i] << T[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;
    vector<vector<int>> graph(N);
    for(int i = 1; i < N; ++i){
        int a;
        cin >> a;
        --a;
        graph[a].emplace_back(i);
    }

    auto dfs = [&](auto&& self, int from = 0) -> int {
        if(!graph[from].size()) return 0;
        vector<int> depth;
        for(int to : graph[from]){
            depth.emplace_back(self(self, to));
        }
        sort(depth.rbegin(), depth.rend());
        for(int i = 0; i < (int)depth.size(); ++i){
            depth[i] += i + 1;
        }
        sort(depth.rbegin(), depth.rend());
        return depth[0];
    };
    cout << dfs(dfs) << endl;
}

Measured memory_bytes: 19388
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

using namespace std;
int n, m;
vector<vector<pair<int, long long>>> p;
vector<long long> x;
set<int> s;

bool dfs(int id, long long pos) {
  if(x[id] != -10000000000 && pos != x[id]) return false;
  if(x[id] != -10000000000) return true;
  x[id] = pos;
  s.insert(id);
  for(int i = 0; i < p[id].size(); i++) {
    if(!dfs(p[id][i].first, pos + p[id][i].second)) return false;
  }
  return true;
}

int main() {
  cin >> n >> m;
  p.resize(n);
  x.resize(n);
  for(int i = 0; i < n; i++) x[i] = -10000000000;
  for(int i = 0; i < m; i++) {
    int l, r;
    long long d;
    cin >> l >> r >> d;
    r--; l--;
    p[l].push_back(make_pair(r, d));
    p[r].push_back(make_pair(l, -d));
  }
  for(int i = 0; i < n; i++) {
    if(x[i] == -10000000000) {
      if(!dfs(i, 0)) {
        cout << "No" << endl;
        return 0;
      }
      vector<long long> y;
      for(auto it = s.begin(); it != s.end(); it++) y.push_back(x[*it]);
      sort(y.begin(), y.end());
      if(y[y.size() - 1] - y[0] > 1000000000) {
        cout << "No" << endl;
        return 0;
      }
      s.clear();
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 21756
#include<stdio.h>

int main(){
	
	int N, K;
	scanf("%d %d", &N, &K);
	int score[N];
	for(int i = 0; i<N; i++){
		scanf("%d", &score[i]);
	}
	for(int i = K; i<N; i++){
		if(score[i-K]<score[i]){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
}

Measured memory_bytes: 2440
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(){

    int N;
    cin >> N;

    map <int, int> M;
    for (int i = 0; i < N; i++){
        int a;
        cin >> a;
        a = a / 400;
        M[a] ++;
    }
    
    int min = 0;
    for (int i = 0; i < 8; i++){
        if (M[i] != 0){
            min ++;
        }
    }


    int count = 0;
    for (int i = 8; i <= 12; i++){
        if (M[i] != 0){
            count += M[i];
        }
    }
    
    int max = min + count;

    if (min == 0){
        min = 1;
    }
    
    
    cout << min << " " << max << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char s[200005];
	scanf("%s", s);
	int n = 0;
	while (s[n] != '\0')
		n++;
	int i;
	int p = 2019;
	int m[200005];
	int k = 10;
	m[n - 1] = s[n - 1] - '0';
	for (i = n - 2; i >= 0; i--)
	{
		m[i] = ((s[i] - '0') * k + m[i + 1]) % p;
		k = 10 * k % p;
	}
	long long int cnt[2020];
	for (i = 0; i < 2020; i++)
		cnt[i] = 0;
	for (i = 0; i < n; i++)
		cnt[m[i]]++;
	cnt[0]++;
	long long int ans = 0;
	for (i = 0; i < 2020; i++)
		ans += cnt[i] * (cnt[i] - 1) / 2;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2700
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.List

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

main :: IO ()
main = do
  getLine
  ds <- sort <$> readIntsLine
  let mid = length ds `div` 2
  let s = last $ take mid ds
  let e = head $ drop mid ds
  print $ max (e - s) 0

Measured memory_bytes: 17788
#include <stdio.h>
#include <string.h>
#define MAX_N 1001
 
int main(void) {
    int num, m, n, i, j;
    int cim1[MAX_N], ci[MAX_N];
    char x[MAX_N], y[MAX_N], xi;
 
    scanf("%d ", &num);
    while (num--) {
        scanf("%s %s ", x, y);
        m = strlen(x);
        n = strlen(y);
 
        for (i = 0; i < n+1; i++) {
            ci[i] = cim1[i] = 0;
        }
        for (i = 1; i < m+1; i++) {
            xi = x[i-1];
            for (j = 1; j < n+1; j++) {
                if (xi == y[j-1]) {
                    ci[j] = cim1[j-1] + 1;
                } else if (cim1[j] >= ci[j-1]) {
                    ci[j] = cim1[j];
                } else {
                    ci[j] = ci[j-1];
                }
            }
            for (j = 1; j < n+1; j++) {
                cim1[j] = ci[j];
            }
        }
        printf("%d\n", cim1[n]);
    }
    return 0;
}

Measured memory_bytes: 612
#include <array>
#include <iostream>

int main() {
  uint32_t N = 0;
  std::array<uint32_t, 100> A;
  std::cin >> N;
  for (size_t i = 0; i < N; i++) std::cin >> A[i];

  uint32_t count = 0, prev_count = 0;
  for (size_t i = 0; i < N - 1; i++) {
    prev_count = count;
    for (size_t j = 0; j < N - 1 - i; j++) {
      if (A[N - 1 - j] < A[N - 2 - j]) {
        uint32_t temp = A[N - 1 - j];
        A[N - 1 - j] = A[N - 2 - j];
        A[N - 2 - j] = temp;
        count++;
      }
    }
    if (prev_count == count) break;
  }

  for (uint32_t i = 0; i < N - 1; i++) std::cout << A[i] << " ";
  std::cout << A[N - 1] << std::endl;
  std::cout << count << std::endl;

  return 0;
}


Measured memory_bytes: 3112
N = int(input())
a = [int(i) for i in input().split()]
a.append(a[N-1]+1)
List = []
counter = 0
series = 0
while counter < N:
  if a[counter +1] == a[counter]:
    series += 1
  else:
    List.append(series)
    series = 0
  counter += 1
List2 = [(i+1)//2 for i in List]
print(sum(List2))


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

bool is_palindrome(string s) {
  string t = s;
  reverse(t.begin(), t.end()); // tを左右逆にする
  return s == t; // 左右逆にしたものと等しければ回文
}

int main() {
  string s;
  cin >> s;
  if (is_palindrome(s) && is_palindrome(s.substr(0, s.size()/2))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
template <class T>
void print(const T &value)
{
	std::cout << value << std::endl;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}

int main()
{
	ll n,a,b;
	cin>>n>>a>>b;
	vector<int>x(n);
	rep(i,n)cin>>x[i];
	ll ans=0;
	FOR(i,1,n){
		ll dis=x[i]-x[i-1];
		ans+=min(dis*a,b);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
from collections import defaultdict
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
n, k, l = map(int, input().split())
ufR, ufT = UnionFind(n), UnionFind(n)
for _ in range(k):
  p, q = map(int, input().split())
  p -= 1
  q -= 1
  ufR.union(p, q)
for _ in range(l):
  r, s = map(int, input().split())
  r -= 1
  s -= 1
  ufT.union(r, s)
d = defaultdict(int)
L = []
for i in range(n):
  a = ufR.find(i)
  b = ufT.find(i)
  d[(a, b)] += 1
  L.append((a, b))
print(*(d[L[i]] for i in range(n)))

Measured memory_bytes: 54428
package main

import "fmt"

func main() {
	var n, k int
	_, _ = fmt.Scan(&n, &k)
	if (n - 1) % (k - 1) == 0 {
		fmt.Println((n - 1) / (k - 1))
	} else {
		fmt.Println((n - 1) / (k - 1) + 1)
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <random>

#define ll long long

using namespace std;

vector<int> dp;

void dfs(vector<vector<int>> &g, vector<bool> &used, int v) {
    used[v] = true;
    for (int next : g[v]) {
        if (used[next]) {
            dp[v] = max(dp[v], dp[next] + 1);
        } else {
          dfs(g, used, next);
          dp[v] = max(dp[v], dp[next] + 1);
        }
    }
}

int main() {
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    int n, m;
    scanf("%d %d", &n, &m);
    vector<vector<int>> g(n + 1);
    for (int i = 1; i <= m; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        g[a].push_back(b);
    }
    dp.resize(n + 1, 0);
    vector<bool> used(n + 1, false);
    for (int i = 1; i <= n; i++) {
        if (!used[i])
            dfs(g, used, i);
    }
    int maxVal = 0;
    for (int i = 1; i <= n; i++)
        maxVal = max(maxVal, dp[i]);
    printf("%d", maxVal);
    return 0;
}


Measured memory_bytes: 9472
// @author: arch_

#include <bits/stdc++.h>
using namespace std;

int w, h, x, y, r;

void solve() {
    int cx[] = {x, x, x - r, x + r};
    int cy[] = {y - r, y + r, y, y};
    for (int i = 0; i < 4; i++)
        if (!(0 <= cx[i] && cx[i] <= w
              && 0 <= cy[i] && cy[i] <= h)) {
            cout << "No\n";
            return;
        }
    cout << "Yes\n";
}

int main(void) {
    cin >> w >> h >> x >> y >> r;
    solve();
    return 0;
}

Measured memory_bytes: 3088
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for C - Attention
	var N int
	fmt.Scanf("%d", &N)

	var S string
	fmt.Scanf("%s", &S)

	Ecount := make([]int, N)
	var temp1 int
	for i := 0; i < N; i++ {
		if S[i] == 'E' {
			temp1++
		}
		Ecount[i] = temp1
	}

	Wcount := make([]int, N)
	var temp2 int
	for i := N - 1; 0 <= i; i-- {
		if S[i] == 'W' {
			temp2++
		}
		Wcount[i] = temp2
	}

	//fmt.Println(Ecount, Wcount)
	var count int
	var min int = N - Wcount[1] - 1
	//fmt.Println(min)
	for i := 1; i < N-1; i++ {
		count = N - Ecount[i-1] - Wcount[i+1] - 1
		//fmt.Println(Ecount[i-1], Wcount[i+1], count)
		if min > count {
			min = count
		}
	}
	min = int(math.Min(float64(min), float64(N-Ecount[N-2]-1)))
	fmt.Println(min)
}


Measured memory_bytes: 8572
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, H, W] = [int(input_raw[0]),int(input_raw[1]),int(input_raw[2])]
    count = 0
    for i in range(N):
        input_raw = read_func().strip().split()
        [A, B] = [int(input_raw[0]),int(input_raw[1])]
        if A >= H and B >= W:
            count += 1

    print count


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        long N = scanner.nextLong();
        long M = scanner.nextLong();
        long ans = solve(N - 1) ^ solve(M);
        System.out.println(ans);
    }

    private static long solve(long n) {
        long res = 0;
        if (n % 2 == 0) {
            res = n;
        }
        if (((n + 1) / 2) % 2 != 0) {
            res++;
        }
        return res;
    }
}

Measured memory_bytes: 23892
import Foundation

let  homeworks = (readLine()!).components(separatedBy: " ").map{Int($0) ?? 0 }
var	 days = Array(repeating: 0, count: homeworks[1])
days = (readLine()!).components(separatedBy: " ").map{Int($0) ?? 0 }
let sum_days = days.reduce(0) {(num1: Int, num2: Int) -> Int in
    return num1 + num2
}

print( homeworks[0] >= sum_days ?   homeworks[0]-sum_days:-1)


Measured memory_bytes: 14384
def main():
    word = list(input())
    operation = int(input())
    cost = {}
    for i in range(26):
        cost[chr(ord("a") + i)] = ord("z") - ord("a") - i + 1
    for i in range(len(word)):
        if cost[word[i]] <= operation and word[i] != "a":
            operation -= cost[word[i]]
            word[i] = "a"
        else:
            continue
    if 0 < operation:
        word[-1] = chr((ord(word[-1]) - ord("a") + operation % 26) % 26 + ord("a"))
    print("".join(word))


if __name__ == '__main__':
    main()



Measured memory_bytes: 4152
#include<iostream>
using namespace std;
int main(){
	int n, x,a,N;
	
	while (1){
		N = 0;
		cin >> n >> x;
		if (n == 0 && x == 0)break;
		for (int i = 1; i < n + 1; i++){
			for (int j = 1; j < n + 1; j++){
				for (int k = 1; k < n + 1; k++){
					a = i + j + k;
					if (i < j&&j < k&&a == x){
						N++;

					}
				}
			}
		}
		cout << N << endl;
	}
	

























	return 0;
}

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

using ll = long long;

const int MAX_N = 100010;

string s[MAX_N];

set<string> recorder, prev_recorder;

string str;

ll pow(ll a, ll b) {
    if (b == 0) return 1;
    else return a * pow(a, b - 1);
}

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

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

    prev_recorder.insert("");

    for (int len = 1; len <= 6; len++) {
        recorder.clear();
        for (int i = 0; i < n; i++) {
            for (int s_i = 0; s_i + len <= s[i].size(); s_i++) {
                recorder.insert(s[i].substr(s_i, len));
            }
        }
        if (recorder.size() != pow(26, len)) {
            for (char alpha = 'a'; alpha <= 'z'; alpha++) {
                for (string str : prev_recorder) {
                    string str2 = alpha + str;
                    if (recorder.find(str2) == recorder.end()) {
                        cout << str2 << endl;
                        return 0;
                    }
                }
            }
        } else {
            prev_recorder = recorder;
        }
    }

    return 0;
}

Measured memory_bytes: 43240
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int Q = Integer.parseInt(sc.next());
        String S = sc.next();
        int[] t = new int[N];
        int l = 0;
        int r = 0;
        int result = 0;
        int count = 0;

        t[0] = 0;
        for (int i = 0; i < N - 1; i++) {
            if (S.substring(i, i + 2).equals("AC")) {
                count++;
            }
            t[i + 1] = count;
        }

        PrintWriter out = new PrintWriter(System.out);
        for (int i = 0; i < Q; i++) {
            l = Integer.parseInt(sc.next());
            r = Integer.parseInt(sc.next());
            result = t[r - 1] - t[l - 1];
            out.println(result);
            out.flush();
        }
        sc.close();
    }
}

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

int main() {
	string s;
	cin >> s;
	int i, a = 0;
	for (i = 0; i < s.length(); i++) {
		if (s[i] == 'o')
			a++;
	}
	if(a + (15 - s.length()) >= 8)
		cout << "YES";
	else
		cout << "NO";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    int N;
    cin >> N;
    vector<string> s(N);
    for (int i = 0; i < N; i++) {
        cin >> s.at(i);
    }
    int M;
    cin >> M;
    vector<string> t(M);
    for (int i = 0; i < M; i++) {
        cin >> t.at(i);
    }
    
    map<string, int> wordcnt;
    for (int i = 0; i < N; i++) {
        wordcnt[s.at(i)]++;
    }
    for (int i = 0; i < M; i++) {
        wordcnt[t.at(i)]--;
    }
    int ans = 0;
    for (auto iter = wordcnt.begin(); iter != wordcnt.end(); iter++) {
        if (ans < iter->second) ans = iter->second;
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 100010
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,ans,mx,mn,l[N],r[N],L,R,suf[N][2],pre[N][2];
struct Seg{
	int l,r;
}a[N];
bool cmp1(Seg a,Seg b){
	return a.l==b.l?a.r<b.r:a.l<b.l;
}
bool cmp2(Seg a,Seg b){
	return a.r==b.r?a.l>b.l:a.r>b.r;
}
void Solve(){
	pre[1][0]=a[1].l,pre[1][1]=a[1].r;
	for(int i=2;i<=n;++i){
		pre[i][0]=max(pre[i-1][0],a[i].l);
		pre[i][1]=min(pre[i-1][1],a[i].r);
	}
	suf[n][0]=a[n].l,suf[n][1]=a[n].r;
	for(int i=n-1;i>=1;--i){
		suf[i][0]=max(suf[i+1][0],a[i].l);
		suf[i][1]=min(suf[i+1][1],a[i].r);
	}
	for(int i=1;i<n;++i){
		ans=max(ans,max(0,pre[i][1]-pre[i][0]+1)+max(0,suf[i+1][1]-suf[i+1][0]+1));
	}
}
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		l[i]=read(),r[i]=read();
	}
	R=*min_element(r+1,r+n+1);
	L=*max_element(l+1,l+n+1);
	for(int i=1;i<=n;++i){
		ans=max(ans,max(0,R-L+1)+r[i]-l[i]+1);
		a[i].l=l[i],a[i].r=r[i];
	}
	sort(a+1,a+n+1,cmp1);
	Solve();
	sort(a+1,a+n+1,cmp2);
	Solve();
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 6860
#include<bits/stdc++.h>
using namespace std;
int n,m;
int k;
int v[105][105];
int main(){
	scanf("%d%d",&n,&m);
	scanf("%d",&k);
	int nx=1,ny=1,f=0;
	for(int i=1,x;i<=k;++i){
		scanf("%d",&x);
		while(x--){
			v[nx][ny]=i;
			if(f)--ny;else ++ny;
			if(ny>m)++nx,f=1,--ny;
			if(!ny)++nx,++ny,f=0;
		}
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			printf("%d ",v[i][j]);
		}putchar('\n');
	}
	return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;




int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	ll n,ans=0,x=0;
	cin>>n;
	string s;
	cin>>s;

	for(auto i: s)
		if(i=='I')
			ans=max(ans,++x);
		else 
			x--;
	cout<<ans<<"\n";


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

const int mod = 1e9 + 7;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int64> a(n);
    for (int i = 0; i < n; ++ i) {
        cin >> a[i];
    }
    int64 ans = 0;
    for (int i = 0; i < 60; ++ i) {
        int cnt0 = 0, cnt1 = 0;
        for (int j = 0; j < n; ++ j) {
            a[j] & 1 ? cnt1 ++ : cnt0 ++;
            a[j] >>= 1;
        }
        ans = (ans + (((1LL << i) % mod * cnt0) % mod * cnt1) % mod) % mod;
    }
    cout << ans;
    
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}

int h,w,k,an;

vector<vii>rows,cols;



void gen(int i,int n,vector<vii>&x,vii cur)
{
  if(i==n)
  {
   
    x.pb(cur);
    return ;
  }

  gen(i+1,n,x,cur);
  cur.pb(i);
  gen(i+1,n,x,cur);

}
void solve()
{
 
 cin >> h >> w >> k;
 
 an = 0;
 vector<vector<char> >mat;
 mat.assign(h,vector<char>(w,'/'));

 forf(i,0,h)
 {
  forf(j,0,w) cin >> mat[i][j];
 }
 
 vii cur;
 gen(0,h,rows,cur);
 gen(0,w,cols,cur);
 

 //cout<<sz(rows)<<" "<<sz(cols)<<"\n";

 forf(i,0,sz(rows))
 {
  forf(j,0,sz(cols))
  {
    vector<vector<char> >temp = mat;
    int cn = 0;

     forf(x,0,h)
     {
      forf(y,0,w)
      if(temp[x][y]=='#')
      {
         int fl=1;
         forf(l,0,sz(rows[i]))
         {
          if(x == rows[i][l]) fl=0;
         }
          forf(l,0,sz(cols[j]))
         {
          if(y == cols[j][l]) fl=0;
         }

         if(fl) cn++;
      }

     }

    if(cn==k) an++;

  }
 }


 cout<<an;
}


int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 3656
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N = int(input())
THS = 55555

sieve = [0]*(THS+1)
prime_list = []
for i in range(2,THS+1):
    if sieve[i] == 0:
        prime_list.append(i)
        j = i
        while j <= THS:
            sieve[j] = 1
            j += i

ans = [[] for _ in range(4)]
for p in prime_list:
    ans[p%5-1].append(p)

for a in ans:
    if len(a) >= N:
        print(*a[:N])
        break

Measured memory_bytes: 21756
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N,c,q=0,z=1e9+7,i;
  cin>>N;
  vector<int> C(N,0);
  for(i=0; i<N; i++){cin>>c, C[i]=c;}
  if(N==1) q=C[0]*2%z;
  else{
    sort(C.begin(), C.end());
    for(i=0; i<N; i++){q+=(N+1-i)*C[i], q%=z;}
    for(i=0; i<2*N-2; i++){q*=2, q%=z;}
  }
  cout<<q<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    int n;
    while(sf("%d",&n)==1)
    {
        ll ara[n+5];
        for(int i=0;i<n;i++)
        {
            sf("%lld",&ara[i]);
        }

        ll psum,nsum,pans,nans;
        psum=nsum=pans=nans=0;
        for(int i=0;i<n;i++)
        {
            //pos-neg
            psum+=ara[i];
            if(i%2==0 && psum<=0)
            {
                pans+=abs(1-psum);
                psum=1;
            }
            else if(i%2==1 && psum>=0) 
            {
                pans+=abs(-1-psum);
                psum=-1;
            }

            //neg-pos
            nsum+=ara[i];
            if(i%2==0 && nsum>=0)
            {
                nans+=abs(-1-nsum);
                nsum=-1;
            }
            else if(i%2==1 && nsum<=0)
            {
                nans+=abs(1-nsum);
                nsum=1;
            }
            //pf("%lld %lld\n",pans,nans);
        }
        pf("%lld\n",min(pans,nans));
    }
    return 0;
}
 









 




























Measured memory_bytes: 1024