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

void print_vector(const vector<int>& v) {
    for (int x : v) {
        cout << x << " ";
    }
    cout << endl;
}

int H, W, K;
string A[10];

int check(const vector<int>& pivots) {
    // cout << "pivots: ";
    // print_vector(pivots);

    int cut_cnt = 0;
    int n_block = pivots.size() - 1;
    auto val = vector<int>(n_block, 0);

    for (int c = 0; c < W; c++) {
        // cout << "col " << c << ":" << endl;
        vector<int> add(n_block, 0);
        for (int block_id = 0; block_id < n_block; block_id++) {
            int block_start = pivots[block_id];
            int block_end = pivots[block_id + 1];
            // cout << "block " << block_start << "," << block_end << endl;
            for (int r = block_start; r < block_end; r++) {
                add[block_id] += A[r][c] - '0';
            }
        }

        // cout << "val:";
        // print_vector(val);
        // cout << "add:";
        // print_vector(add);

        for (int block_id = 0; block_id < n_block; block_id++) {
            if (add[block_id] > K) {
                // cout << "impossible" << endl;
                return H * W + 100;
            }
        }

        bool cut = false;
        for (int block_id = 0; block_id < n_block; block_id++) {
            if (val[block_id] + add[block_id] > K) {
                cut = true;
                cut_cnt++;
                break;
            }
        }

        for (int block_id = 0; block_id < n_block; block_id++) {
            if (cut) {
                val[block_id] = add[block_id];
            }
            else {
                val[block_id] = val[block_id] + add[block_id];
            }
        }
    }
    // cout << "cut_cnt:" << cut_cnt << endl;

    return cut_cnt + n_block - 1;
}

int solve() {
    int ans = H * W + 100;
    for (int mask = 0; mask < (1 << (H + 1)); mask++) {
        if ((mask & (1 << 0)) == 0) continue;
        if ((mask & (1 << H)) == 0) continue;
        auto pivots = vector<int>();
        for (int r = 0; r <= H; r++) {
            if (mask & (1 << r)) {
                pivots.push_back(r);
            }
        }

        ans = min(ans, check(pivots));
    }

    return ans;
}

int main() {
    ios::sync_with_stdio(false);

    cin >> H >> W >> K;
    for (int i = 0; i < H; i++) {
        cin >> A[i];
    }

    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 256
/// [Amberjack] CUT BEGIN
#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> vl;

typedef int _loop_int;
#define __GET_REP_MACRO(_1,_2,_3,NAME,...) NAME
#define __REP0(i,n) for(_loop_int i=0;i<(n);++i)
#define __REP1(i,a,b) for(_loop_int i=(a);i<(b);++i)
#define __REPR0(i,n) for(_loop_int i=(n)-1;i>=0;--i)
#define __REPR1(i,a,b) for(_loop_int i=(b)-1;i>=(a);--i)
#define REP(...) __GET_REP_MACRO(__VA_ARGS__,__REP1,__REP0)(__VA_ARGS__)
#define REPR(...) __GET_REP_MACRO(__VA_ARGS__,__REPR1,__REPR0)(__VA_ARGS__)

#ifdef BURI
#define __DEBUG0() "Hello"
#define __DEBUG1(x) #x"("<<(x)<<")"
#define __DEBUG2(x,...) #x"("<<(x)<<"), " __DEBUG1(__VA_ARGS__)
#define __DEBUG3(x,...) #x"("<<(x)<<"), " __DEBUG2(__VA_ARGS__)
#define __DEBUG4(x,...) #x"("<<(x)<<"), " __DEBUG3(__VA_ARGS__)
#define __DEBUG5(x,...) #x"("<<(x)<<"), " __DEBUG4(__VA_ARGS__)
#define __GET_DEBUG_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define __DEBUG(...) __GET_DEBUG_MACRO(__VA_ARGS__,__DEBUG5,__DEBUG4,__DEBUG3,__DEBUG2,__DEBUG1,__DEBUG0)(__VA_ARGS__)
#define DEBUG(...) cerr<<__DEBUG(__VA_ARGS__)<<endl
#else
#define DEBUG(...)
#endif

#define gc getchar_unlocked
inline void getll(ll &x){
  int sgn=1;x=0;
  char c=gc();
  while(c!='-'&&(c<'0'||c>'9'))c=gc();
  if(c=='-') sgn=-1; else x=c-'0';
  c=gc();
  while('0'<=c&&c<='9'){
    x*=10;
    x+=c-'0';
    c=gc();
  }
  x*=sgn;
}
inline void read(ll &x){getll(x);}
inline void read(int &x){ll y;getll(y);x=y;}
inline void read(float &x){scanf("%f",&x);}
inline void read(double &x){scanf("%lf",&x);}
inline void read(long double &x){scanf("%Lf",&x);}
inline void read(char *s){scanf("%s",s);}
// inline void read(char *s){char *t=s;char c;while((c=gc())==' '||c=='\n');while(c!=' '&&c!='\n'){*t++=c;c=gc();}}
inline void read(string &s){int len=s.size();char *buf=(char*)malloc(len*sizeof(char));scanf("%s",buf);s=string(buf);free(buf);}
inline void read(char &c){char *buf=(char*)malloc(5*sizeof(char));scanf("%s",buf);c=buf[0];free(buf);}
inline void read(){}
template<typename S,typename ...T>
inline void read(S& first, T&... rest){
  read(first);
  read(rest...);
}
/// [/Amberjack] CUT END

char s[15];
int main(){
  read(s);
  #define pc(c) putchar_unlocked(c)
  pc(s[0]);
  pc(s[1]);
  pc(s[2]);
  pc(s[3]);
  pc(' ');
  pc(s[4]);
  pc(s[5]);
  pc(s[6]);
  pc(s[7]);
  pc(s[8]);
  pc(s[9]);
  pc(s[10]);
  pc(s[11]);
  pc('\n');
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    int r,d,x;
    cin >> r >> d >> x;
    rep(i,10){
        x = r*x - d;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from math import log2
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))

k-=1

m=int(log2(k)) if 1<k else 1
nxt=[[0]*n for _ in range(m+1)]
point=[[0]*n for _ in range(m+1)]
for i in range(n):
  p[i]-=1
  nxt[0][i]=p[i]
  point[0][i]=c[p[i]]
for j in range(m):
  for i in range(n):
    nxt[j+1][i]=nxt[j][nxt[j][i]]
    point[j+1][i]=point[j][i]+point[j][nxt[j][i]]
min_nk=min(n,k)
ans=-10**18
for s in range(n):
  pla=p[s]
  cur=c[pla]
  if ans<cur:
    ans=cur
  for _ in range(min_nk):
    pla=p[pla]
    cur+=c[pla]
    if ans<cur:
      ans=cur
  if n<k:
    pla=p[s]
    cur=c[pla]
    for i in range(m+1):
      if (k-n)&(1<<i):
        cur+=point[i][pla]
        pla=nxt[i][pla]
    res=cur
    for _ in range(n):
      pla=p[pla]
      cur+=c[pla]
      if res<cur:
        res=cur
    if ans<res:
      ans=res
print(ans)

Measured memory_bytes: 71844
import math
from fractions import Fraction
N, K = map(int, input().split())

p = sum(Fraction(1, 2**math.ceil(math.log2(K / n))) for n in range(1, min(N, K - 1) + 1)) / N
p += max(0, Fraction(N - K + 1, N))

print(float(p))

Measured memory_bytes: 5432
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl


int main(){
  int a, b;
  cin >> a >> b;
  if(a > 8 || b > 8) cout <<  ":(" << endl;
  else cout << "Yay!" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>

int main() {
    using Weight = std::uint64_t;
    using Value = int;

    auto n = 0;
    auto max_weight = Weight(0);

    std::cin >> n >> max_weight;

    auto items = std::vector<std::pair<Weight, Value>>();
    for (auto i_ = 0; i_ < n; ++i_) {
        auto w = 0;
        auto v = 0;
        std::cin >> w >> v;
        items.emplace_back(w, v);
    }

    const auto max_available_value = 100 * 1000;
    auto memo = std::vector<Weight>(max_available_value + 1, max_weight + 1);
    memo[0] = Weight(0);

    auto max_value = Value(0);
    for (const auto& item : items) {
        const auto w = item.first;
        const auto v = item.second;

        for (auto i = max_available_value - v; i >= 0; --i) {
            const auto sum_w = memo[i] + w;
            const auto sum_v = v + i;
            if (sum_w < memo[sum_v]) {
                memo[sum_v] = sum_w;

                if (sum_v > max_value) max_value = sum_v;
            }
        }
    }

    std::cout << max_value << std::endl;
    return 0;
}

Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 競プロ_Csharp {
    class Program {
        static void Main(string[] args) {

            int[] input = NextInts();
            int w = input[0], h = input[1], x = input[2], y = input[3], r = input[4];

            string ans = "Yes";
            if (x - r < 0 || x + r > w) ans = "No";
            if (y - r < 0 || y + r > h) ans = "No";

            Println(ans);

        }

        public static void Println (Object o) {
            Console.WriteLine(o);
        }

        public static string NextString() {
            return Console.ReadLine();
        }

        public static int NextInt () {
            return int.Parse(Console.ReadLine());
        }

        public static int[] NextInts () {
            string[] a = Console.ReadLine().Split();
            int[] b = new int[a.Length];
            for (int i = 0; i < a.Length; i++) {
                b[i] = int.Parse(a[i]);
            }
            return b;
        }

    }
}



Measured memory_bytes: 17912
#include <stdio.h>


int main (void)
{
    
    int X,N,p[100],cnt,i,j;
    scanf("%d",&X);
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d",&p[i]);
    }
    j=0;
    while(1)
    {
        cnt=0;
        for(i=0;i<N;i++)
        {
            if(X-j==p[i])
            {
                break;
            }
            cnt++;
        }
        if(cnt==N){
            printf("%d\n",X-j);
            break;
        }
        cnt=0;
        for(i=0;i<N;i++)
        {
            if(X+j==p[i])
            {
                break;
            }
            cnt++;
        }
        if(cnt==N){
            printf("%d\n",X+j);
            break;
        }
        j++;
    }
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e+9;
#define rep(i, n) for(int i = 0; i < n;i++)
#define REP(i, n) for(int i = 0; i <= n;i++)

int main(){
    ll n, m;
    cin >> n>>m;
    priority_queue<ll> sc;
    rep(i,n){
        ll a;
        cin >> a;
        sc.push(a);
    }
    rep(i,m){
        ll x=sc.top();
        sc.pop();
        x /= 2;
        sc.push(x);
    }
    ll ans = 0;
    rep(i,n){
        ll j=sc.top();
        ans+=j;
        sc.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<algorithm>

using namespace std;

int main() {
	int N;
	int H[200];
	int count = 0;//見れる山カウント
	int max_height=0;
	int height = 0;

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

	for (int i = 0; i < N; ++i) {
		if (i == 0) {
			max_height = H[i];
				++count;
		}
		else if (max_height <= H[i]) {
			max_height = H[i];
			++count;
		}
	}




	cout << count;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
////////////////////////////////////////////////
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
const ll MOD = 1000000007;  // 1e9+7
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll a = 1; a * a <= n; a++) {
    if (n % a == 0) {
      ll m = n / a;
      m--;
      if (a <= m - 1) {
        ans += m;
      }
    }
  }
  cout << ans << endl;
}
//////////////////////////////////////////////


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

sum_A = sum(A)
memo = [0] * 100001
for a in A:
    memo[a] += 1

for _ in range(Q):
    B, C = map(int, input().split())
    sum_A += (C - B) * memo[B]
    memo[C] += memo[B]
    memo[B] = 0
    print(sum_A)



Measured memory_bytes: 20392
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main(){
	IOS;
	int a, b, c, d;
	cin >> a >> b >> c >> d ;

	int c_start = a + c - (a % c);
	c_start /= c;
	if(a % c == 0)
		c_start--;
	int c_end = b/c;

	int d_start = a + d - (a% d);
	d_start /= d;
	if(a % d == 0)
		d_start--;
	int d_end = b/d;

	int l = (c*d)/__gcd(c, d);

	int l_start = a + l - (a % l);
	l_start = l_start/l;
	if(a % l == 0)
		l_start--;
	int l_end = b/l;

	int total_num = b - a + 1 - (c_end - c_start + 1) - (d_end - d_start + 1 ) + l_end - l_start + 1;

	cout << total_num << endl; 



	return 0;
}

Measured memory_bytes: 256
N = int(input())
C = []
V = []
i = 0
X_Y = 0
for x in input().split():
  x = int(x)
  V.append(x)
for x in input().split():
  x = int(x)
  C.append(x)
  if V[i] > C[i]:
    X_Y = X_Y + V[i] - C[i]
  i = i + 1

print(X_Y)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s;
  cin >> s;
  
  if(s[0] == s[1] && s[1] == s[2])
      cout << "No" << "\n";
  else
      cout << "Yes" << "\n";    
  return 0;
}


Measured memory_bytes: 256
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;
const ll mod=1000*1000*1000+7;

int n;

pll tab[nax];

ll wyn;

ll los[nax];

ll sum=0;

int ile[nax];
int zap[nax][2];

int num(int v)
{
	return zap[v][0]+2*zap[v][1];
}

int gdz[nax][2];

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
	{
		los[i]=rand()%mod;
		los[i]*=mod;
		los[i]+=mod;
		//~ mod[i]%=mod;
	}
	ll w1=0;
	ll w2=0;
	for (int i=1; i<=n; i++)
		scanf("%lld%lld", &tab[i].first, &tab[i].second);
	vector <pair<ll,int>> pom;
	for (int i=1; i<=n; i++)
	{
		w1+=tab[i].first;
		w2+=tab[i].second;
		pom.push_back({tab[i].first, i});
		pom.push_back({tab[i].second, -i});
	}
	wyn=min(w1, w2);
	sort(pom.begin(), pom.end());
	for (int i=0; i<2*n; i++)
	{
		if (pom[i].second>0)
		{
			gdz[pom[i].second][0]=i;
		}
		else
		{
			gdz[-pom[i].second][1]=i;
		}
	}
	for (int i=0; i<n; i++)
		sum+=pom[i].first;
	for (int i=1; i<=n; i++)
	{
		if (gdz[i][0]<n && gdz[i][1]<n)
		{
			wyn=sum;
			break;
		}
	}
	if (wyn==sum)
	{
		printf("%lld\n", wyn);
		return 0;
	}
	for (int i=1; i<=n; i++)
	{
		if (gdz[i][1]<n)
		{
			swap(tab[i].first, tab[i].second);
		}
		for (int j=n-1; j>=0 && n-j<=3; j--)
		{
			if (abs(pom[j].second)!=i)
			{
				wyn=min(wyn, sum+tab[i].second-pom[j].first);
			}
		}
	}
	printf("%lld\n", wyn);
	return 0;
}


Measured memory_bytes: 12528
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ll a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll k;
    cin>>k;
    cout<<a[k-1]<<"\n";
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int K; cin >> K;
    vector<int> d(K, INF);
    queue<int> que;
    que.push(1);
    d[1] = 1;

    int j = 1;
    while(true){
        j = (j * 10) % K;
        if(d[j] < INF){
            break;
        }else{
            d[j] = d[1];
            que.push(j);
        }
    }

    while(!que.empty()){
        int i = que.front(); que.pop();
        if(i == 0) break;
        j = (i + 1) % K;
        if(d[j] < INF) continue;
        d[j] = d[i] + 1;
        que.push(j);
        while(true){
            j = (j * 10) % K;
            if(d[j] < INF){
                break;
            }else{
                d[j] = d[i] + 1;
                que.push(j);
            }
        }
    }

    cout << d[0];
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
	"math"
)

func taxRate(n int) (int, string) {
	tax := 1.08
	tmp := float64(n) / tax

	ans := math.Trunc(tmp)

	if int(ans*tax) == n {
		return int(ans), ""
	}
	if int((ans+1)*tax) == n {
		return int(ans + 1), ""
	}
	return 0, ":("
}

func main() {
	var n int
	fmt.Scan(&n)
	c, err := taxRate(n)
	if err != "" {
		fmt.Println(err)
	} else {
		fmt.Println(c)
	}
}


Measured memory_bytes: 512
#include<stdio.h>
#include<bits/stdc++.h>
#define mod 1000000007
#define maxn 4000095
using namespace std;
int f[2005][2005],fac[maxn],inv[maxn];
int add(int a,int b){a+=b; return a>=mod?a-mod:a;}
int ksm(int a,int b)
{
	int s=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1) s=1ll*s*a%mod;
	return s;
}
int n,k;
void Pre()
{
	fac[0]=1;
	for(int i=1;i<maxn;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[maxn-1]=ksm(fac[maxn-1],mod-2);
	for(int i=maxn-2;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}
int C(int n,int m){return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
	Pre();
	scanf("%d%d",&n,&k);
	if(k==1) return puts("1"),0;
	f[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			f[i][j]=f[i-1][j];
			if(j) f[i][j]=add(f[i][j],1ll*C(n*k-i-(j-1)*(k-1)-1,k-2)*(n-j+1)%mod*f[i][j-1]%mod);
		}
	}
	printf("%d\n",f[n][n]);
	return 0;
}


Measured memory_bytes: 47104
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int tate = int.Parse(s[0]);
            int yoko = int.Parse(s[1]);

            int area = tate * yoko;
            int rect = (tate + yoko )* 2;

            Console.WriteLine(area + " "+rect);

            //int n = int.Parse(s);

            //n = (int)Math.Pow(n, 3);

            //Console.WriteLine(n);
        }
    }
}

Measured memory_bytes: 19936
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = I()
print(A[k - 1])


Measured memory_bytes: 39536
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

ll powl(ll a, ll b){
    if(b==0) return 1;
    if(b==1) return a;
    if(b%2==0) return powl(a,b/2)*powl(a,b/2);
    else return powl(a,b-1)*a;
}

int main(){
    ll n; cin >> n;
    string ans="";
    ll num=1;
    ll tn=n;
    ll times=0;
    while(tn>0){
        times++;
        tn-=powl(26,times);
    }

    ll now=0;
    while(times>0){
        ll tmp=n%26;
        if(tmp==0) tmp=26;
        n-=tmp;
        tmp--;
        ans+=tmp+'a';
        n/=26;
        times--;
    }
    reverse(all(ans));
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <memory>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable, numberOFbegin, numberOFend) for(long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable, numberOFbegin, numberOFend) for(long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable, numberOFend) for(long long int LoopVariable = 0; (LoopVariable) < (numberOFend); LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max() - 5;
constexpr long long int inf = numeric_limits<int>::max() - 5;
constexpr long long int mod = 1000000007;

llint f(llint k,llint x){
    return k < 0 ? 0 : 1+k / x;
}

int main() {
    llint a,b,x;
    cin >> a >> b >> x;
    cout << f(b, x) - f(a-1, x) << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;

import com.sun.org.apache.xalan.internal.xsltc.compiler.Pattern;

import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final char[] chs = sc.next().toCharArray();
			
			int fst_0_answer = 0, fst_1_answer = 0;
			for(int i = 0; i < chs.length; i++) {
				if(i % 2 == 0) {
					if(chs[i] == '0') { fst_1_answer += 1; }
					if(chs[i] == '1') { fst_0_answer += 1; }

				}else {
					if(chs[i] == '0') { fst_0_answer += 1; }
					if(chs[i] == '1') { fst_1_answer += 1; }
				}
			}
			
			System.out.println(Math.min(fst_0_answer, fst_1_answer));
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 24788
def solve(n):
    events = []
    for _ in range(n):
        a, b = input().split()
        events.append((a, 1))
        events.append((b, -1))
    events.append(('99:99:99', 0))
    events.sort(key=lambda event: event[0])
    ans = 0
    tmp = 0
    prev = None
    for e, d in events:
        if prev != e:
            ans = max(ans, tmp)
        tmp += d
        prev = e
    print(ans)

while True:
    n = int(input())
    if n == 0:
        break
    solve(n)


Measured memory_bytes: 8532
# -*- coding: utf-8 -*-

import sys
import math

debug = False

def log(text):
    if debug:
        print(text)


def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
    
    k = int(lines[0])

    return (k, )


def solve(k):

    nums = [str(e) for e in range(1, 10)]

    def find(found):
        new_found = []
        for f in found:
            last_num = int(f[-1])

            if last_num == 0:
                new_found.append(f + str(last_num ))
                new_found.append(f + str(last_num + 1))
            elif 1 <= last_num and last_num <= 8:
                new_found.append(f + str(last_num - 1))
                new_found.append(f + str(last_num ))
                new_found.append(f + str(last_num + 1))
            elif last_num == 9:
                new_found.append(f + str(last_num - 1))
                new_found.append(f + str(last_num ))
        
        
        cnt = len(found) + len(new_found)
        if cnt < k:
            total_found = found + find(new_found)
        else:
            total_found = found + new_found
            
        return total_found

    total_found = find(nums)
    total_found_as_int = [int(e) for e in total_found]
    total_found_as_int.sort()

    result = total_found_as_int[k-1]
    
    return result

def main():
    # 出力
    new_found = solve(*parse_input())
    if isinstance(new_found, list):
        for r in new_found:
            print("%s" % r, sep='')
    else:
        print("%s" % new_found, sep='')

if __name__ == '__main__':

    main()

Measured memory_bytes: 26752
(cs, es, ds) = (0, 0, 0)
while True:
  (a, b, c) = map(int, raw_input().split())

  [a, b, c] = sorted([a, b, c])

  if a + b <= c:
    print cs + es + ds, cs, es, ds
    break

  if a * a + b * b == c * c:
    cs += 1
  elif a * a + b * b < c * c:
    ds += 1
  else:
    es += 1

Measured memory_bytes: 4232
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;

int main(void) {
	string s, t;
	cin >> s;
	for (int i = 0;i < s.length();i++) {
		if (s[i] == 'A')t += "T";
		if (s[i] == 'T')t += "A";
		if (s[i] == 'C')t += "G";
		if (s[i] == 'G')t += "C";
	}
	cout << t << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        System.out.println((a+b) * h / 2);
    }
    
}

Measured memory_bytes: 25044
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#ifndef NULL
#define NULL 0
#endif
using namespace std;

const int MAXN = 50000 + 10;
const double pi = acos(-1.0);
const double inf = 1e100;
const double eps = 1e-10;

inline double read() //浮点型快读
{
    double num;
    char in;
    double Dec = 0.1;
    bool IsN = false, IsD = false;
    in = getchar();
    while (in != '-' && in != '.' && (in < '0' || in > '9'))
        in = getchar();
    if (in == '-') {
        IsN = true;
        num = 0;
    } else if (in == '.') {
        IsD = true;
        num = 0;
    } else
        num = in - '0';
    if (!IsD) {
        while (in = getchar(), in >= '0' && in <= '9') {
            num *= 10;
            num += in - '0';
        }
    }
    if (in != '.') {
        if (IsN)
            num = -num;
        return num;
    } else {
        while (in = getchar(), in >= '0' && in <= '9') {
            num += Dec * (in - '0');
            Dec *= 0.1;
        }
    }
    if (IsN)
        num = -num;
    return num;
}

int sgn(double d)
{
    if (fabs(d) < eps)
        return 0;
    if (d > 0)
        return 1;
    return -1;
}
int dcmp(double x, double y)
{
    if (fabs(x - y) < eps)
        return 1;
    if (x > y)
        return 0;
    return -1;
}

struct vec{
    double x,y;
    vec(double x,double y) {
        this->x=x;
        this->y=y;
    }
    vec(){}
    vec operator *(const vec& i_T)const{
        return vec(x*i_T.x,y*i_T.y);
    }
    vec operator *(double u)const{
        return vec(x*u,y*u);
    }
    vec operator /(double u)const{
        return vec(x/u,y/u);
    }
    vec operator +(const vec& i_T){
        return vec(x+i_T.x,y+i_T.y);
    }
    vec operator -(const vec& i_T){
        return vec(x-i_T.x,y-i_T.y);
    }
}p[MAXN];
double chaji(vec A, vec B)
{
    return A.x * B.y - A.y * B.x; // 正为A->B左旋
}
double dianji(vec A,vec B)
{
    return A.x*B.x+A.y*B.y;
}
double xiangliang(vec a, vec b, vec c) // 祖父点a,父点b,新增儿子点c
{
    vec A = b-a; // 向量ab
    vec B = c-a; // 向量ac
    return chaji(A, B);
}
double changdu(vec a) //长度
{
    return sqrt(a.x*a.x+a.y*a.y);
}
vec touying(vec a,vec b,vec c) //c投影在ab上的位置
{
    vec A=b-a;
    vec B=c-a;
    double La=changdu(A);
    double Lc=dianji(A,B)/(La*La);
    return vec(Lc*A.x,Lc*A.y)+a;
}
vec fanshe(vec a,vec b,vec c)   //求c关于ab的对称点c'
{
    vec A=touying(a,b,c);
    return (A-c)*2.0+c;
}
vec xiangjiao(vec a,vec b,vec c,vec d); //两直线是否相交
vec zhixian_jiaodian(vec a,vec b,vec c,vec d);   //两直线交点
int main()
{
    int n;
    vec p1,p2;
    cin>>p1.x>>p1.y>>p2.x>>p2.y>>n;
    for(int i=0;i<n;i++)
        cin>>p[i].x>>p[i].y;
    for(int i=0;i<n;i++){
        vec point=fanshe(p1,p2,p[i]);
        printf("%.8f %.8f\n",point.x+eps,point.y+eps);
    }
    return 0;
}


Measured memory_bytes: 3232
#include "bits/stdc++.h"
using namespace std;
int main(){
 int N;
 cin >> N;
 vector<int> list(N+1,0);

 for(int x= 1 ; x<N;x++){
 	int input;
 	cin >> input;
 	list[input]++;
 }
 for(int x = 1;x<=N;x++){
 	cout << list[x] << endl;
 	 }

}
	


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

using namespace std;

int main()
{
    int H,W;
    cin >> H >> W;
    char a[100][100];
    bool isSharpRow[100];
    bool isSharpCol[100];

    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            cin >> a[i][j];
            if(a[i][j] == '#'){
                isSharpRow[i] = true;
                isSharpCol[j] = true;
            }
        }
    }

    for(int i = 0; i < H; ++i){
        if(isSharpRow[i] == false) continue;
        for(int j = 0; j < W; ++j){
            if(isSharpCol[j] == true) cout << a[i][j];
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int n;
  cin >> n;
  string w[n];
  for (size_t i = 0; i < n; i++) {
    cin >> w[i];
  }
  for (size_t i = 1; i < n; i++) {
    if(w[i-1].back() != w[i].front()) {
      cout << "No" << endl;
      return 0;
    } else {
      for (size_t j = 0; j < i; j++) {
        if(w[j] == w[i]) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
}


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

int main(){
    int n;
    cin>>n;
    stack<int> a,b;
    for(int i=0;i<n;i++){
        int t; cin>>t;
        a.push(t);
        swap(a,b);
    }
    while(!b.empty()){
        int t=b.top();
        b.pop();
        cout<<t<<endl;
    }
    while(!a.empty()){
        int t=a.top();
        a.pop();
        b.push(t);
    }
    while(!b.empty()){
        int t=b.top();
        b.pop();
        cout<<t<<endl;
    }
}

Measured memory_bytes: 2944
n = int(input())
b = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

s = 0
for i in range(n):
	if a[i] <= b[i]:
		s += a[i]
		b[i] -= a[i]
	else:
		s += b[i]
		a[i] -= b[i]
		b[i] = 0
		if a[i] <= b[i + 1]:
			s += a[i]
			b[i + 1] -= a[i]
		else:
			s += b[i + 1]
			b[i + 1] = 0
print(s)


Measured memory_bytes: 19156
#include<stdio.h>

int main(){
	
	int N,a[100010],i,botan=1,ans=0;
	scanf("%d",&N);
	
	for(i=1;i<=N;i++){
		scanf("%d",&a[i]);
	}
	
	for(i=1;i<=N;i++){
		botan=a[botan];
		ans++;
		
		if(botan==2){
			printf("\n%d\n",ans);
			return 0;
		}
	}
	
	printf("\n-1\n");
	
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int n;
    cin>>n;
    map<int,int> ext;
    int ok=1;
    for(int i=0;i<n;i++)
    {
        int tmp;
        cin>>tmp;
        if(ext[tmp]) ok=0;
        ext[tmp]=1;
    }
    if(ok) cout<<"YES\n";
    else cout<<"NO\n";
}

Measured memory_bytes: 9600
def prim(n):
    inf=float("inf")
    D=[inf for i in range(n)]
    P=[0 for i in range(n)]
    M=[[inf for i in range(n)] for j in range(n)]
    color=["white" for i in range(n)]

    P[0]=-1
    D[0]=0

    for i in range(n):
        for j,num in enumerate(list(map(int,input().split()))):
            if num!=-1:
                M[i][j]=num

    while 1:
        cost,point=inf,0
        for i in range(n):
            if color[i]!="black" and D[i]<cost:
                cost=D[i]
                point=i

        if cost==inf:break

        color[point]="black"

        for i in range(n):
            if color[i]!="black" and M[point][i]!=inf:
                if M[point][i]<D[i]:
                    D[i]=M[point][i]
                    P[i]=point
                    color[i]="gray"

    return D


print(sum(prim(int(input()))))


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

/** defines and macros */
#define ll long long
#define ull unsigned long long
#define loop(n) for(int i = 0; i < n; i++)
#define loop1(n) for(int i = 1; i <= n; i++)
#define all(v) (v.begin(), v.end())
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vvi vector<vi>
#define vvpii vector<vii>
#define PB push_back

#define fw(fileName) freopen(fileName, "w", stdout)
#define fr(fileName) freopen(fileName, "r", stdin)
#define fc(stream) fclose(stream);

#define faster_IO_stream ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

/*To compile and run

	g++ -o main main.cpp && ./main

*/

/*
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣀⣤⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣷⣶⣤⣀⡀⠄⠄⠄⠄⠄⣰⣷⡀⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⣀⣀⣀⠄⠄⠄⠄⠄⣠⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣄⠄⠄⢠⣿⣿⣷⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠤⠒⠛⠛⠛⠛⠻⠷⣦⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⣿⣿⣿⠟⠁⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⢀⣤⣤⣶⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣡⡤⠐⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⢀⣶⣿⣿⠿⢛⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠁⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⢠⣿⠟⠉⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠘⠁⠄⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠻⣿⣿⣿⣿⣿⣿⣿⡛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⣾⣿⡿⣽⡿⢹⣿⣿⣟⣿⢻⠇⢀⢹⣿⢿⣿⣿⣿⣿⣿⣦⣙⢿⣿⢷⣈⠻⢿⣟⢿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⢿⡿⠁⡿⠁⢸⣿⣿⢹⡇⢸⠄⠈⠄⠻⣏⠻⣿⡿⣿⣿⣿⣌⠛⢿⡌⠙⢧⣀⠙⢳⡹⢻⣿⣿⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠘⡇⠄⡇⢠⣼⣿⣿⠈⡇⠘⠤⠤⠤⠤⢜⣢⣘⡻⢮⡛⢿⣿⣷⣬⡤⠤⠤⠤⠥⠤⠥⢬⣿⣧⡄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠁⠄⠄⠘⢿⡏⠛⠄⠄⠄⠄⠄⠄⠄⠄⠄⠙⣿⣿⣿⡿⠋⠉⠛⠉⠄⠄⠄⠄⠄⠄⠄⢹⡿⠃⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⡟⠁⠈⢳⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠱⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⡜⠁⠄⠄⠈⢇⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⡇⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠑⠦⢄⣀⣀⣀⣀⣀⠴⠊⠄⠄⠄⠄⠄⠄⠑⠤⢀⣀⣀⣀⡀⠠⠔⠋⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣶⣦⣄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣤⣶⣆⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⣿⣿⣿⣿⣶⣄⣀⣀⣀⣀⣤⣾⣿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸⣿⣿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣿⣿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⣿⣿⣿⣿⠟⠁⠄⠄⠄⠄⠙⢿⣿⣿⣿⡟⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠘⠟⠋⠁⠄⠄⠄⠄⠄⠄⠄⠄⠉⠛⠿⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
 */

int main() {
	faster_IO_stream

	int n;
	cin >> n;
	vi ns(n);

 	loop(n) cin >> ns[i];

 	ull res = 0;
 	for(int i = 1; i < n; i++) if(ns[i] < ns[i - 1]) {
 		res += ns[i - 1] - ns[i]; ns[i] = ns[i - 1];
 	}

 	cout << res << endl;

	return 0;
}


Measured memory_bytes: 3892
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
    }
    let mut digit = 0;
    let mut n_ = n.clone();
    let mut ans = 0;
    while n_ > 0 {
        n_ /= 10;
        digit += 1;
    }
    if digit <= 2 {
        ans += 9;
        if digit == 1 {
            ans -= 9 - n;
        }
    } else if digit <= 4 {
        ans += 900 + 9;
        if digit == 3 {
            ans -= 899 - (n - 100);
        }
    } else if digit <= 6 {
        ans += 90000 + 900 + 9;
        if digit == 5 {
            ans -= 89999 - (n - 10000);
        }
    }

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


Measured memory_bytes: 4352
import math
N = int(input())

def is_prime(p):
	if (p == 1): return false
	for i in range(2, int(math.sqrt(p))+1):
		if (p%i == 0): return False
	return True


c = 0

for i in range(6, 55556, 5):
	if (is_prime(i)):
		c += 1
		if (c != N):
			print(i, end=' ')
		else:
			print(i)
			exit()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
char s[57];
int main(){
    int n,k;
    cin>>n>>k;
    cin>>s+1;
    for(int i=1;i<=n;++i){
        if(i==k){
            if(s[i]=='A')
                s[i]='a';
            else if(s[i]=='B')
                s[i]='b';
            else if(s[i]=='C')
                s[i]='c';
        }
    }
    cout<<s+1;
    return 0;
}



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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> result(N, 0);
  
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    result.at(a-1)++;
    result.at(b-1)++;
  }

  for (int i = 0; i < N; i++) {
    cout << result.at(i) << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;
typedef pair<double,P> PP;

double D(P a,P b){return sqrt((a.F-b.F)*(a.F-b.F)+(a.S-b.S)*(a.S-b.S));}
int p[10001],r[10001];
void init(){for(int i=0;i<10001;i++)p[i]=i,r[i]=0;}
int find(int x){return (p[x]==x)?x:(p[x]=find(p[x]));}
void unite(int x,int y) {
  x=find(x),y=find(y);
  if(x==y)return;
  if(r[x]<r[y])p[x]=y;
  else{p[y]=x;if(r[x]==r[y])r[x]++;}
}
bool same(int x,int y){return find(x)==find(y);}

int main() {
  int n,m;
  cin >> n >> m;
  P a[n];
  for(int i=0;i<n;i++) cin >> a[i].F >> a[i].S;
  priority_queue<PP> que;
  double sum=0;
  for(int i=0;i<m;i++) {
    int x,y;
    cin >> x >> y;
    x--,y--;
    sum+=D(a[x],a[y]);
    que.push(PP(D(a[x],a[y]),P(x,y)));
  }
  init();
  double ans=0;
  while(!que.empty()) {
    PP p=que.top();que.pop();
    int x=p.S.F,y=p.S.S;
    double d=p.F;
    if(same(x,y)) continue;
    unite(x,y);
    ans+=d;
  }
  printf("%.10f\n",sum-ans);
  return 0;
}


Measured memory_bytes: 1860
//*******Abhijit Burman***********//
//Jalpaiguri Government Engineering College//

#include<bits/stdc++.h>
using namespace std;
#define ll long long int

#define pb push_back
#define mk make_pair
#define MAXX (1000000000000000000+7)
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
string temp=" ";
ll dp[3010][3010];
string s,tt,ans="";
ll ii,jj;
//vector<ll> dp(100000100,110);
ll LCS(ll i, ll j)
{

    if(i>ii || j>jj)
    {
        return 0;
    }
   else
    {
        //cout<<i<<" "<<j<<endl;
        if(dp[i][j]!=-1)
        {
            //cout<<"Hello"<<i<<" "<<j<<endl;
            return dp[i][j];
        }
        else
        {

            if(s[i]==tt[j])
            {

                dp[i][j] = 1+LCS(i+1,j+1);
                return dp[i][j];
            }
            else
            {
                dp[i][j] = max(LCS(i+1,j),LCS(i,j+1));
                return dp[i][j];
            }

        }
    }

}
void cal(ll i, ll j)
{
    if(i>ii || j>jj)
    {
        cout<<ans<<endl;
    }
    else
    {
        if(s[i]==tt[j])
        {
            ans+=s[i];
            cal(i+1,j+1);
        }
        else
        {
            if(dp[i][j] == dp[i+1][j])
            {
                cal(i+1,j);
            }
            else
            {
                cal(i,j+1);
            }
        }
    }
}
int main( )
{
    fio;

	cin>>s>>tt;
	 ii=s.size()-1;
	 jj=tt.size()-1;
	 memset(dp,-1,sizeof(dp));

//	ll jj;
    //cout<<v.size()<<endl;
    LCS(0,0);
    //ll maxi = 0;
    cal(0,0);
    //cout<<endl;

    return 0;
}




Measured memory_bytes: 71296
import java.util.*;
import java.math.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int temp = 0;
    //int[] arr = {111,222,333,444,555,666,777,888,999};
    if(N<=111) System.out.println("111");
    if(N>111 && N<=222) System.out.println("222");
    if(N>222 && N<=333) System.out.println("333");
    if(N>333 && N<=444) System.out.println("444");
    if(N>444 && N<=555) System.out.println("555");
    if(N>555 && N<=666) System.out.println("666");
    if(N>666 && N<=777) System.out.println("777");
    if(N>777 && N<=888) System.out.println("888");
    if(N>888 && N<=999) System.out.println("999");
    
    }
  }


Measured memory_bytes: 23764