akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int f[100001],a[100001]={1};
int main()
{
	int n,i,j,count=1;
	scanf("%d",&n);
	for(i=1;pow(6,i)<=n;i++)
	{
		a[count++]=pow(6,i);
	}
	for(i=1;pow(9,i)<=n;i++)
	{
		a[count++]=pow(9,i);
	}
	sort(a,a+count);
	memset(f,1,sizeof(f));
	f[0]=0;
	f[1]=1;
	for(i=2;i<=n;i++)
	{
		for(j=0;j<count&&i-a[j]>=0;j++)
		{
			f[i]=min(f[i],f[i-a[j]]+1);
		}
	}
	printf("%d",f[n]);
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int n;
    int x = (int)pow(2, 10)-1;
    scanf("%d", &n);
    int f[n][10];
    rep(i, 0, n){
        rep(j, 0, 10){
            scanf("%d", &f[i][j]);
        }
    }
    int p[n][11];
    rep(i, 0, n){
        rep(j, 0, 11){
            scanf("%d", &p[i][j]);
        }
    }
    int ans = INT_MIN;
    revrep(i, x, 0){
        int buf = 0;
        rep(j, 0, n){
            int cnt = 0;
            rep(k, 0, 10){
                int y = 1<<k;
                if(f[j][k] && y&i){
                    cnt++;
                }
            }
            buf += p[j][cnt];
        }
        if(buf > ans){
            ans = buf;
        }
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define vec vector
#define fi first
#define se second
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define cout(a) cout << a << " "
#define vcout(v) rep(i,v.size()) cout(v[i]); cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
#define bit(x) (1ll<<(x))

int main(){
	ll n,m;
	cin >> n >> m;
	vec<P> ab;
	rep(i,n){
		ll a,b;
		cin >> a >> b;
		ab.push_back(make_pair(a,b));
	}
	
	sort(ab.begin(), ab.end(), [&](P aa, P bb){return aa.fi < bb.fi;});
	
	ll res = 0;
	
	rep(i,ab.size()){
		ll a = ab[i].fi;
		ll b = ab[i].se;
		if(b <= m){
			res += a*b;
			m -= b;
		}
		else{
			res += (m)*a;
			break;
		}
		
		if(m<=0) break;
	}
	
	cout(res);
	return 0;
}


Measured memory_bytes: 2420
import java.util.*

fun f(n: Int): Pair<Int, Int> {
    if (n < 10) {
        return Pair(0, 0)
    }
    val s = n.toString()

    var mn = 1e8.toInt()
    var mx = 0

    for (i in 0 until s.length - 1) {
        val t = s.substring(0, i) + (s[i].toInt() + s[i + 1].toInt() - 2 * '0'.toInt()).toString() + s.substring(i + 2)

        val r = f(t.toInt())
        mn = Math.min(mn, r.first + 1)
        mx = Math.min(mn, r.second + 1)
    }

    return Pair(mn, mx)
}

fun update(p: TreeMap<Long, Long>): Triple<TreeMap<Long, Long>, Long, Boolean> {
    var cnt = 0L
    var updated = false
    val res = TreeMap<Long, Long>()

    for (e in p) {
        val pair = Pair(e.key, e.value)
        if (pair.second > 1) {
            cnt += pair.second / 2
            val a = pair.first * 2

            res[a % 10] = (res[a % 10] ?: 0L) + pair.second / 2

            if (a >= 10) {
                res[a / 10] = (res[a / 10] ?: 0L) + pair.second / 2
            }

            if (pair.second % 2 == 1L) {
                res[pair.first] = (res[pair.first] ?: 0L) + 1
            }
            updated = true
        } else {
            val v = res.get(pair.first)
            res[pair.first] = v?.plus(pair.second) ?: pair.second
        }
    }

    return Triple(res, cnt, updated)
}

fun main(args: Array<String>) {
//    var q = true
//    for (i in 1..1000000) {
//        val r = f(i)
//        val s = f(String(i.toString().toCharArray().sortedDescending().toCharArray()).toInt())
////        println("$i ${r.first} ${r.second}")
//        q = q && r.first == r.second && r.first == s.first && r.second == s.second
//        if (r.first != r.second || r.first != s.first || r.second != s.second) {
//            println("$i $r $s")
//        }
//    }
//    println(q)

//    for (i in 1 .. 1000) {
//        val r = f(i)
//        val p = TreeMap<Long, Long>()
//        for (c in i.toString()) {
//            val a = c.toLong() - '0'.toLong()
//            p[a] = (p[a] ?: 0L) + 1
//        }
//        val res = solve(p)
//
//        if (r.first.toLong() != res) {
//            println("$i $res ${r.first}")
//        }
//    }

    val M = readLine()!!.toInt()

    var p = TreeMap<Long, Long>()

    for(i in 1 .. M) {
        val (d, c) = readLine()!!.split(" ").map{it.toLong()}
        p[d] = (p[d] ?: 0L) + c
    }

    println(solve(p))
}

fun solve(p: TreeMap<Long, Long>): Long {
    var p1 = p
    var res = 0L

    do {
        val (q, s, f) = update(p1)
        res += s
        p1 = q
    } while (f)

    val s = p1.map { if (it.value > 0) it.key.toString() else "" }.joinToString("")
    var t = String(s.toCharArray().sortedDescending().toCharArray())

    while (t.length > 1) {
        res++
        t = (t[0].toInt() + t[1].toInt() - 2 * '0'.toInt()).toString() + t.substring(2)
    }

    return Math.max(res, 1)
}


Measured memory_bytes: 70972
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    llong n;
    llong max;

    signed call_of_Cthulhu( signed datum ) {

        read n;
        for ( llong i = n; i > std::max(0ll, n-100000); i-- ) {
            llong I = i;
            llong tmp = 0;
            while ( I ) {
                tmp += I%10;
                I /= 10;
            }
            chmax(max, tmp);
        }
        String s = std::to_string(n);
        chmax(max, (s.size()-1)*9 + s[0]-'1');
        echo max fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include<iostream>

int main(){
  int N, K, X, Y;
  std::cin >> N >> K >> X >> Y;
  int sum = 0;
  for(int i = 0; i < N; i++){
    if(i < K) sum += X;
    else sum += Y;
  }
  std::cout << sum << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n;
  int64_t a,b;
  cin>>n>>a>>b;
  int64_t c=a+b;
  int64_t ans=a*(n/c);
  ans+=min(n%c,a);
  cout<<ans<<endl;
  return 0;
}
  

Measured memory_bytes: 3628
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
    long long minu(long long a, long long b){
        return mod(mod(a)-mod(b));
    }
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
    
    vector<int>dirX={-1,0,1};
    vector<int>dirY={-1,0,1};
 
 
    void solve(){
        ll n;
        cin>>n;
        if(n==1){
            cout<<0;
            return;
        }
        if(n==2){
            cout<<2;
            return;
        }
        ll ans=minu(add(modPow(10LL,n),modPow(8LL,n)),mul(2LL,modPow(9LL,n)));
        cout<<ans;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
        //    cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }


Measured memory_bytes: 3668
/*
 *  Lang    : C++
 *  Author  : little_angel
 */

#include <bits/stdc++.h>

using namespace std;
#define int long long
#define ld long double
const int inf = 9e18L;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t;
    cin >> t;
    while (t--) {
        int n, a, b, c, d;
        cin >> n >> a >> b >> c >> d;
        vector<tuple<int, int>> op = {
                {2, a},
                {3, b},
                {5, c}
        };

        unordered_map<int, int> dp;
        dp[0] = 0;
        dp[1] = d;
        function<int(int)> dfs = [&](int x) -> int {
            if (dp.find(x) != dp.end())return dp[x];
            int ans = inf;
            if ((ld) d * (ld) x < ans) ans = d * x;
            for (auto &i:op) {
                int num, cost;
                tie(num, cost) = i;
                ans = min(ans, dfs(x / num) + cost + d * (x % num));
                if (x % num)ans = min(ans, dfs(x / num + 1) + cost + d * (num - x % num));
            }
            return dp[x] = ans;
        };

        cout << dfs(n) << endl;
    }
}

Measured memory_bytes: 4092
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;
const int WH_MAX = 30;
int field[2 * WH_MAX - 1][WH_MAX * 2 - 1];
int w, h;
int visited[2 * WH_MAX - 1][WH_MAX * 2 - 1];
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int solve() {
	queue<pair<int, int> > que;
	memset(visited, 0, sizeof(visited));
	que.push(make_pair(0, 0));
	visited[0][0] = 1;
	while (!que.empty()) {
		pair<int, int> current = que.front();
		que.pop();
		const int x = current.first;
		const int y = current.second;
		for (int i = 0; i < 4; i++) {
			const int nextX = x + dx[i] * 2;
			const int nextY = y + dy[i] * 2;
			if (0 <= nextX && nextX < w * 2 - 1 && 0 <= nextY && nextY < h * 2 - 1
					&& !field[y + dy[i]][x + dx[i]] && !visited[nextY][nextX]) {
				que.push(make_pair(nextX, nextY));
				visited[nextY][nextX] = visited[y][x] + 1;
			}
		}
	}
	return visited[h * 2 - 2][w * 2 - 2];
}

int main () {
	while (cin >> w >> h, w || h) {
		memset(field, 0, sizeof(field));
		for (int i = 0; i < h * 2 - 1; i++) {
			for (int j = 0; j < w - (i + 1) % 2; j++) {
				cin >> field[i][j * 2 + (i + 1) % 2];
			}
		}
		cout << solve() << endl;
	}
	return 0;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static llong MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

map<llong, llong> M;

template<typename T> void factorization(T p) {
    llong i = 2;
    while (i * i <= p) {
        if (p % i == 0) {
            ++M[i];
            p /= i;
        } else {
            ++i;
        }
    }

    if (p != 1) ++M[p];
}

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    llong n;
    cin >> n;
    for (int i = n; i > 0; --i) {
        factorization(i);
    }
    
    llong ans = 1;
    for (map<llong, llong>::iterator itr = M.begin(); itr != M.end(); ++itr) {
        ans *= (1 + itr->second);
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    vector<int> xs;
    int temp;
    for(auto i=0;i<5;i++){
        cin >> temp;
        xs.push_back(temp);
    }
    for(auto i=0;i<5;i++){
        if(xs.at(i)==0) cout << i+1 << endl;
    }
}


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

int main() {
	string S; cin >> S;
	map<char, int> mp;
	for(char c: S) mp[c]++;
	for(auto p: mp) {
		int v = p.two;
		if(v % 2 == 1) return puts("No") < 0;
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

import "strings"

func main() {
	for {
		var H, W int
		fmt.Scan(&H, &W)
		if H == 0 {
			break
		}
		for i := 1; i <= H; i++ {
			if i == 1 || i == H {
				fmt.Println(strings.Repeat("#", W))
			} else {
				fmt.Println("#" + strings.Repeat(".", W-2) + "#")
			}
		}
		fmt.Println()
	}
}



Measured memory_bytes: 1272
#include<iostream>
#include<vector>
#include<array>
#include<algorithm>
#include <random>
std::random_device seed_gen;
std::mt19937 engine(seed_gen());
std::uniform_int_distribution<> dD {0, 364};

int const INF = 1e9;
int const M = 9000;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int D; std::cin >> D;
  int c[26];
  for(int& ci: c) std::cin >> ci;
  std::vector<std::array<int,26>> s(D);
  for(int d = 0; d < D; ++d) {
    for(int& si: s[d]) std::cin >> si;
  }
  
  // greedy
  std::vector<int> t(D);
  int ans = 0;
  int last[26];
  std::fill_n(last, 26, -1);
  for(int d = 0; d < D; ++d) {
    int ma = -INF;
    t[d] = 0;
    for(int T = 1; T <= 26; ++T) {
      int cur = s[d][T-1];
      int sv = last[T-1];
      last[T-1] = d;
      for(int cx = 0; cx < 26; ++cx) {
        cur -= (d-last[cx])*c[cx];
      }
      last[T-1] = sv;
      if(cur > ma) { ma = cur; t[d] = T; }
    }
    ans += ma;
    last[t[d]-1] = d;
  }
  
  auto score = [&]()->int {
    int ans = 0;
    int last[26];
    std::fill_n(last, 26, -1);
    for(int d = 0; d < D; ++d) {
      ans += s[d][t[d]-1];
      last[t[d]-1] = d;
      for(int cx = 0; cx < 26; ++cx) {
        ans -= (d-last[cx])*c[cx];
      }
    }
    return ans;
  };
  
  // modify
  for(int m = 0; m < M; ++m) {
    int d = dD(engine);
    int sv = t[d], tx = 0;
    for(int T = 1; T <= 26; ++T) if(T != sv) {
      t[d] = T;
      int new_ans = score();
      if(new_ans > ans) { ans = new_ans; tx = T; }
    }
    if(tx == 0) t[d] = sv;
    else t[d] = tx;
  }
  for(int ti: t) std::cout << ti << "\n";
  
  return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define vll vector< ll >
//#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<int,int>
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//#define int unsigned long long
//#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long  
#define int long long
using namespace std;
//using ll = unsigned long long;
ll md=MD;
//ll M=1073741824;
ll M=998244353;
//ll exp(ll a,ll b){ll r=1;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(int a,int b){if(a<b)return a; return b;}
ll Max(int a,int b){if(a>b)return a; return b;}
ll power(ll a,ll b){ll ans=1;while(b>0){if(b&1)ans=(ans*a)%M;a=(a*a)%M;b=b>>1;}return ans;}
const int INF=1000000000000000000;


int32_t main()
{
	IOS;
	int t;
//	cin>>t;
	t=1;
	while(t--)
	{
		 int n,k;
		 cin>>n>>k;
		 vector<int> a(n);
		 for(int i=0;i<n;++i)cin>>a[i];
		 sort(all(a));
		 int sum=0;
		 for(int i=0;i<k;++i)sum+=a[i];
		 cout<<sum<<"\n";	
	}
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)


int main() {
    int k,n;
    cin>>k>>n;
    int a[n],b[n];
    rep(i,n) cin>>a[i];

    rep(i,n-1) b[i] = a[i+1] - a[i];
    b[n-1] = k - a[n-1] + a[0];

    int m = 0;
    rep(i,n){
        if(b[i]>m) m = b[i];
    }

    cout<<k-m<<endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

    static int[][] aa;
    static int maxx(int ind,LinkedList<Integer>[] linkedLists,int flag){
        if(aa[ind][flag]!=-1){
            return aa[ind][flag];
        }
        if(flag==0){
            int maxs=0;
            for(int j=1;j<linkedLists.length;j++){
                maxs=Math.max(maxs,maxx(j,linkedLists,1));
            }
            return aa[ind][flag]=maxs;
        }
        else{
            int maxs=0;
            for(Integer i:linkedLists[ind]){
                maxs=Math.max(maxs,maxx(i,linkedLists,1)+1);
            }
            return aa[ind][flag]=maxs;
        }

    }


    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n= scanner.nextInt();
        int m= scanner.nextInt();
        LinkedList<Integer>[] linkedLists=new LinkedList[n+1];
        for(int j=0;j<=n;j++){
            linkedLists[j]=new LinkedList<>();
        }
        for(int j=0;j<m;j++){
            linkedLists[scanner.nextInt()].add(scanner.nextInt());
        }
        aa=new int[n+1][2];
        for(int j=0;j<=n;j++){
            for(int i=0;i<2;i++){
                aa[j][i]=-1;
            }
        }
        System.out.println(maxx(1,linkedLists,0));
    }

}


Measured memory_bytes: 102496
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 20001
struct faner {
    int w, s, v;
} a[1010];
ll f[N], ans;
bool cmp(faner a1, faner b1) { return a1.s + a1.w < b1.s + b1.w; }
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d%d%d", &a[i].w, &a[i].s, &a[i].v);
    sort(a + 1, a + n + 1, cmp);
    for (int i = 1; i <= n; i++)
        for (int j = N; j >= a[i].w; j--)
            if (a[i].s + a[i].w >= j) f[j] = max(f[j], f[j - a[i].w] + a[i].v);
    for (int i = 1; i < N; i++) ans = max(ans, f[i]);
    printf("%lld\n", ans);
    return 0;
}

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

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }
  
  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  
  for(i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }
  
  for(j=1;j<=n;j++){   
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 9568
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    double r = sc.nextDouble();
    double pi = Math.PI;
    double area = r*r*pi;
    double length = r*2*pi;

    System.out.printf("%f %f",area, length);
    sc.close();
}
}


Measured memory_bytes: 28108
(let ((n (read))
    (k (read))
    (ans 0))

    (if (= k 0)
        (setq ans (* n n))
        (loop for b from (+ k 1) to n do
            (progn
                (incf ans (* (floor (/ n b)) (- b k)))
                (if (>= (rem n b) k)
                    (incf ans (- (rem n b) k -1))
                )
            )
        )
    )
    (princ ans)
)

Measured memory_bytes: 30508
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
using namespace std;
const int maxn=5010;

int n,a[maxn];
long long A,B,f[maxn][maxn];

int main()
{
	scanf("%d%lld%lld",&n,&A,&B);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<=n;j++)
		{
			f[i][j]=100000000000000;
		}
	}
	f[0][0]=0;
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<=n;j++)
		{
			int C=0;
			if (a[i]>j) C=A;
			else C=B;
			f[i][j]=min(f[i][j],f[i-1][j]+C);
			if (a[i]>j)
			{
				f[i][a[i]]=min(f[i][a[i]],f[i-1][j]);
			}
		} 
	}
	long long ans=10000000000000;
	for (int i=1;i<=n;i++)
	{
		ans=min(ans,f[n][i]);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 199428
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a)

template<typename T>
void vdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        if(i==size-1){
            cout << da[i] << endl;
        }
        else{
            cout << da[i] << ' ';
        }
    }
}
template<typename T>
void vvdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        vdeb(da[i]);
    }
}

struct UnionFind{
    int size;
    vector<int> par;
    vector<int> rank;
    UnionFind(int x){
        size=x;
        par=vector<int> (x);
        rank=vector<int> (x,1);
        for (int i=0;i<x;i++){
            par[i]=i;
        }
    }
    int root(int x){
        if(par[x]==x){
            return x;
        }
        else{
            return par[x]=root(par[x]);
        }
    }
    void unite(int x,int y){
        x=root(x);y=root(y);
        if(x==y){
            return;
        }
        if(rank[x]<rank[y]){
            par[x]=y;
        }
        else{
            par[y]=x;
        }
        if(rank[x]==rank[y]){
            rank[x]++;
        }
    }
    bool check(int x,int y){
        return root(x)==root(y);
    }
    void initialize(){
        for (int i=0;i<size;i++){
            par[i]=i;
            rank[i]=1;
        }
    }
};

int main(){
	int n;cin >> n;
	string s, t;
	cin >> s >> t;
	rip(i,n,0){
		printf("%c%c",s[i],t[i]);
	}
	printf("\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    int A,B,C; cin >> A >> B >> C;
    if(A<=C && C <= B) pr("Yes");
    else pr("No");
    
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> a(M), b(M), c(N+1, 0);
    rep(i,M){
        cin >> a[i] >> b[i];
        c[a[i]]++;
        c[b[i]]++;
    }
    rep(i,N+1){
        if(c[i] % 2 == 1){
            cout << "NO" <<endl;
            return 0;
        }
    }
    cout << "YES" << endl;

}


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

class Program
{
    static void Main(string[] args)
    {
        char[] s = Console.ReadLine().ToCharArray();
        char[] disS = s.Distinct().ToArray();
        bool flag = false;
        if (disS.Length % 2 == 0)
        {
            if ((disS.Contains('N') && disS.Contains('S')) || (disS.Contains('E') && disS.Contains('W')))
            {
                flag = true;
            }
        }
        Console.WriteLine(flag ? "Yes" : "No");
    }
}


Measured memory_bytes: 13152
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
int N; 
cin >> N; 
int F[150][15], P[150][15]; 
for(int i = 0; i < N; i++){
 for(int j = 0; j < 10; j++){
cin >> F[i][j];
 }
}
for(int i = 0; i < N; i++){
 for(int j = 0; j <= 10; j++){
cin >> P[i][j];
 }
}

int y = -1000000000; 
for (int bit = 1; bit < (1<<10); ++bit){
    int benefit = 0; 
for(int i = 0; i < N; i++){
  int count = 0; //店iとjoisinoの重複個数
 for (int j = 0; j < 10; j++) {
if ((bit / (1<<j)) % 2 == 1) {count += F[i][9-j];
                             }
 }
   benefit += P[i][count]; //店iについての利益を加算
}
   y = max(y, benefit); 
}
cout << y << endl; 
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val a: Int = sc.nextLine.toInt
    val b: Int = sc.nextLine.toInt
    val c: Int = sc.nextLine.toInt
    val x: Int = sc.nextLine.toInt
    val combination = for {av <- 0 to a; bv <- 0 to b; cv <- 0 to c} yield (av, bv, cv)
    println(combination.map(comb => comb._1 * 500 + comb._2 * 100 + comb._3 * 50).count(_ == x))
  }
}


Measured memory_bytes: 42044
n,c,k=map(int,input().split())
tl=[int(input()) for i in range(n)]
tl.sort()
bef=tl[0]
people=1
bus_count=1
for i in range(n-1):
  if people<c and tl[i+1]-bef<=k:
    people+=1
    #print("ok")
    #print(people)
    #print(bef)
  else:
    bus_count+=1;bef=tl[i+1];people=1
    #print(i)
    #print("---")
print(bus_count)

Measured memory_bytes: 7384
X = input()
tcnt = 0
scnt = 0
ans = 0
for i in range(0, len(X)):
    #print(i, scnt, tcnt)
    if X[i] == "S":
        scnt += 1
    elif scnt > tcnt and X[i] == "T":
        tcnt += 1
    else:
        tcnt = 0
        scnt = 0
    if scnt >= tcnt:
        ans += tcnt * 2
        scnt -= tcnt
        tcnt = 0

print(len(X) - ans)


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

long sum = 0;

long calculate (string number, int mask) {
    vector<long> numbers;
    int bit_flag;
    string buff;
    for (int i = 0; i < number.length(); i++) {
        buff.push_back(number[i]);
        if (i == (number.length() - 1)) {
            continue;
        }
        bit_flag = (1 << i);
        if ((mask & bit_flag) != 0) {
            numbers.push_back(stol(buff));
            buff = "";
        }
    }
    numbers.push_back(stol(buff));
    return accumulate(numbers.begin(), numbers.end(), 0L);
}

int main() {
    string number;
    cin >> number;
    for(int i = 0; i < (1 << (number.length() - 1)); i++) {
        sum += calculate(number, i);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  int a,b;
  cin>>a>>b;
  string ans="No";
  if(a==b){
    ans="Yes";
  }
  cout<<ans<<endl;
}


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

int main()
{
    int h,w;
    int x,y;
    cin >> h >> w;

while(h != 0 && w != 0)
{
    for (x = 0; x < h; x++)
    {
        for (y = 0; y < w; y++)
        {
            if (y == 0 || y == w-1 || x == 0 || x == h-1)
            {
                cout << "#";
            }
            else
            {
                cout << ".";
            }
        }
        cout << endl;
    }
    cout << endl;
    cin >> h >> w;
}
    return 0;
}


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

int main(){
    int H, W; cin >> H >> W;
    char pic[H][W];
    rep(i,H){
        rep(j,W){
            cin>>pic[i][j];
        }
    }
    rep(i,W+2)cout<<'#';
    cout<<'\n';
    rep(i,H){
        cout<<'#';
        rep(j,W){
            cout<<pic[i][j];
        }
        cout<< '#' << endl;
    }
    rep(i,W+2)cout<<'#';
    cout << '\n';
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main( void ){
  
  int a, b;
  cin >> a >> b;
  
  if( (a+b) % 2 == 0 ){
    cout << (a+b)/2 << endl;
  }else{
    cout << (a+b)/2 + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,j,k=0,N;
  scanf("%d",&N);
  int A[N];
  for(i=0;i<N;i++)
    scanf("%d ",&A[i]);
  
  for(i=0;i<N-2;i++){
    if(A[i] < A[i+1]){
      if(A[i+1] < A[i+2])
        k++;
    }
    if(A[i] > A[i+1]){
      if(A[i+1] > A[i+2])
        k++;
    }
  }
  printf("%d\n",k);
  return 0;
}



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

int dp[1<<26];
int main(){
	string s;cin>>s;
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	int h=0;
	rep(i,s.size()){
		h^=1<<(s[i]-'a');
		int Min=dp[h]+1;
		rep(j,26){
			dp[h]=min(dp[h],dp[h^(1<<j)]+1);
			Min=min(Min,dp[h^(1<<j)]+1);
		}
		if(i==s.size()-1){
			printf("%d\n",Min);
		}
	}
}

Measured memory_bytes: 262788
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef pair<int,int> pii;
const int MN = 1e5+5;
int N,X,L,D[MN],ans;
pii P[MN];
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> N;
    for(int i=1; i<=N; i++){
        cin >> X >> L;
        P[i].va = X+L;
        P[i].vb = X-L;
    }
    sort(P+1,P+N+1);
    int pos = -1e9;
    for(int i=1; i<=N; i++){
        if(pos>P[i].vb) continue;
        pos = P[i].va;
        ans++;
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<LL, LL> pii;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    LL ans = 0;
    for (LL i = 1 ; i <= n ; i++)
        ans += i * (n - i + 1);
    vector<pii> edges(n - 1);
    for (auto &e : edges) {
        cin >> e.F >> e.S;
        if (e.F > e.S)
            swap(e.F, e.S);
        ans -= e.F * (n - e.S + 1);
    }
    cout << ans << '\n';
}

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

int main()
{
    int x[3];
    int min = 2000000000, max = -2000000000;

    for( int i = 0; i < 3; i++ )
    {
        cin >> x[i];
        if( min > x[i] )
            min = x[i];
        if( max < x[i] )
            max = x[i];
    }

    cout << min << " " << max << endl;

    return 0;
}


Measured memory_bytes: 3060
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A, B;
  tools::read(A, N);
  tools::read(B, N);

  std::vector<i64> diffs;
  diffs.reserve(N);
  for (i64 i = 0; i < N; ++i) {
    diffs.push_back(A[i] - B[i]);
  }

  std::vector<i64> riches, poors;
  for (const i64& diff : diffs) {
    if (diff > 0) {
      riches.push_back(diff);
    } else if (diff < 0) {
      poors.push_back(-diff);
    }
  }

  std::sort(riches.begin(), riches.end(), std::greater<i64>());
  std::vector<i64> riches_sum({0});
  riches_sum.reserve(riches.size() + 1);
  std::partial_sum(riches.begin(), riches.end(), std::back_inserter(riches_sum));

  const i64 lack = std::accumulate(poors.begin(), poors.end(), static_cast<i64>(0));

  const auto it = std::lower_bound(riches_sum.begin(), riches_sum.end(), lack);
  if (it == riches_sum.end()) {
    std::cout << -1 << std::endl;
  } else {
    std::cout << std::distance(riches_sum.begin(), it) + poors.size() << std::endl;
  }

  return 0;
}

Measured memory_bytes: 3956
import sys
n, m = map(int, input().split())
bf = -1
way = [-1] * (n+1)
way[0] = 1
way[1] = 1
mod = 10 ** 9 + 7
for i in range(m):
    tmp = int(input())
    if bf + 1 == tmp:
        print(0)
        sys.exit()
    bf = tmp
    way[tmp] = 0
for i in range(2, n+1):
    if way[i] == -1:
        way[i] = way[i-2] + way[i-1]
print(way[n] % mod)


Measured memory_bytes: 460020
import java.io.*;
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main
{
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		String []s=br.readLine().split(" ");
		int a[]=new int[N];
		int k=1,c=0;
				
		for(int i=0;i<N;i++)
			a[i]=Integer.parseInt(s[i]);
			
		for(int i=0;i<N;i++)
		{
			if(a[i]==k)
			{
				++k;
				++c;
			}
		}
		
		if(c==0)
			out.println(-1);
		else
			out.println(N-c);
	}
}




Measured memory_bytes: 49864
abc = gets
abc = abc.split(' ')
a = abc[0].to_i
b = abc[1].to_i
c = abc[2].to_i

k = gets.to_i

def yn(a,b,c)
    if a < b and b < c then
        return true
    else
        return false
    end
end

def twice(a,b,c,k)
    if k==0
        return yn(a,b,c)
    end

    return true if twice(2*a, b, c, k-1)
    return true if twice(a, 2*b, c, k-1)
    return true if twice(a, b, 2*c, k-1)
    return false
end

if twice(a,b,c,k) then
    print('Yes')
else
    print('No')
end

Measured memory_bytes: 14148
#include "bits/stdc++.h"
#define _CRT_SECURE_NO_WARNINGS
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define Pi pair<int,int>
#define IINF 1e9
#define LINF 1e18
#define vi vector<int>
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 0, 1,0,-1 };
int dy[] = { 1, 0,-1,0 };
int dx8[] = { -1,-1,-1,0,0,1,1,1 };
int dy8[] = { -1,0,1,-1,1,-1,0,1 };

unsigned long long sttoi(std::string str) {
	unsigned long long ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

ull gcd(ull a, ull b) {
	if (b > a)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a%b);
}

int comb(int n, int k) {
	int ans = 1;
	for (int i = 0; i < min(k, n - k); i++) {
		ans *= n - i;
		ans /= i + 1;
	}
	return ans;
}

ll mod_pow(ll n, ll p, ll mod) {
	if (p == 0) return 1 % mod;
	if (p < 2) {
		return n % mod;
	}
	else {
		ll d = 2, value = (n%mod)*(n%mod) % mod;
		while (d * 2 < p) { d *= 2;	value *= value;	value %= mod; }
		value %= mod;
		return ((value%mod) * (mod_pow(n, p - d, mod) % mod)) % mod;
	}
}

bool isPrime(int n) {
	if (n <= 1)return false;
	if (n == 2)return true;
	if (n % 2 == 0)return false;
	for (int i = 3; i*i <= n; i += 2) {
		if (n%i == 0)return false;
	}
	return true;
}

void solve() {
	int n;
	cin >> n;
	map<int,int> usagi;
	rep(i, n) {
		int a;
		cin >> a;
		usagi[i + 1] = a;
	}
	int count = 0;
	REP(i, 1, n+1) {
		if (usagi[usagi[i]] == i)count++;
	}
	P(count/2);
}

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

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

vector<int> seq[55];
map<string,int> str2idx;

string bnf[55];
string AGCT="ATGC";

void func(int i,int n){
	stringstream ss(bnf[i]);
	string tmp;
	
	ss >> tmp;
	tmp = tmp.substr(0,tmp.size()-1);
	str2idx[tmp] = i;

	while(ss >> tmp){
		if(tmp[0]=='['){
			tmp = tmp.substr(1,tmp.size()-2);
			int val = 0;
			for(auto &mark:tmp) rep(j,4) if(mark == AGCT[j]) val |= (1<<j);
			seq[i].push_back(val);
		}else{
			const int idx = str2idx[tmp];
			seq[i].insert(end(seq[i]),begin(seq[idx]),end(seq[idx]));
		}

		if(seq[i].size()>n) break;
		if(ss.eof()) break;
	}
}

const ll mod = 1000000007LL;
ll dp[55][55][55][55];

int main(void){
	int nATGC[4];
	rep(i,4) cin >> nATGC[i];
	const int total = accumulate(nATGC,nATGC+4,0);


	int m;
	cin >> m;

	cin.ignore();
	rep(i,m) getline(cin,bnf[i]);
	rrep(i,m) func(i,total);

	dp[0][0][0][0]=1LL;

	if(total != int(seq[0].size())){
		cout << 0 << endl;
		return 0;
	}

	rep(i,total)rep(na,nATGC[0]+1)rep(nt,nATGC[1]+1)rep(ng,nATGC[2]+1){
		const int nc = i - na - nt - ng;
		if(nc < 0 or nATGC[3] < nc) continue;

		dp[na][nt][ng][nc] %= mod;

		if(na < nATGC[0] and seq[0][i]&1){
			dp[na+1][nt][ng][nc] += dp[na][nt][ng][nc];
			dp[na+1][nt][ng][nc] %= mod;
		}

		if(nt < nATGC[1] and seq[0][i]&2){
			dp[na][nt+1][ng][nc] += dp[na][nt][ng][nc];
			dp[na][nt+1][ng][nc] %= mod;
		}
		
		if(ng < nATGC[2] and seq[0][i]&4){
			dp[na][nt][ng+1][nc] += dp[na][nt][ng][nc];
			dp[na][nt][ng+1][nc] %= mod;
		}

		if(nc < nATGC[3] and seq[0][i]&8){
			dp[na][nt][ng][nc+1] += dp[na][nt][ng][nc];
			dp[na][nt][ng][nc+1] %= mod;
		}
	}

	cout << dp[nATGC[0]][nATGC[1]][nATGC[2]][nATGC[3]] << endl;

	return 0;
}

Measured memory_bytes: 62256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(v) (ll((v).size()))
#define forn(i,n) for(ll i=0;i<(n);i++)
#define forr(i,n) for(ll i=(n)-1;i>=0;i--)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))

const ll N=17;
const ll K = 1<<N;
const ll mod =1e9+7;
const ll inf = 1e15;
ll a[N][N],cost[K],dp[K],n;
vector<ll> rem;

void add_self(ll &a, ll b){a+=b;if(a>=mod)a-=mod;}
void sub_self(ll &a, ll b){a-=b;if(a<0)a+=mod;}

void update(ll i, ll mask, ll val, ll gr)
{
	if(i==sz(rem)){dp[mask]=max(dp[mask],val+cost[gr]);return;}

	update(i+1,mask,val,gr);
	update(i+1,mask^(1<<rem[i]),val,gr^(1<<rem[i]));
}

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

	cin>>n;ll k=1<<n;
	forn(i,n)forn(j,n)cin>>a[i][j];
	forn(i,k)dp[i]=-inf;

	for(int mask=0;mask<k;mask++)
	{
		ll sum=0;
		forn(i,n)forn(j,i)if(mask&(1<<i))if(mask&(1<<j))sum+=a[i][j];
		cost[mask]=sum;
	}


	dp[0]=0;
	ll d=1;
	for(int mask=0;mask<k;mask++)
	{
		rem.clear();
		forn(i,n)if(!(mask&(1<<i)))rem.pb(i);
		update(0,mask,dp[mask],0);
	}
	cout<<dp[k-1]<<endl;

}


Measured memory_bytes: 1280
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void shortestPath(const vector<vector<int> >& edges, int start, vector<int>& dist)
{
    dist.assign(edges.size(), -1);
    dist[start] = 0;
    queue<int> q;
    q.push(start);

    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(unsigned i=0; i<edges[v].size(); ++i){
            int u = edges[v][i];
            if(dist[u] == -1){
                dist[u] = dist[v] + 1;
                q.push(u);
            }
        }
    }
}

void shortestPath(const vector<vector<int> >& edges, vector<vector<int> >& dist)
{
    dist.resize(edges.size());
    for(unsigned i=0; i<edges.size(); ++i)
        shortestPath(edges, i, dist[i]);
}


int main()
{
    int n;
    cin >> n;
    vector<vector<int> > edges(n+1);
    for(int i=0; i<n; ++i){
        int r, k;
        cin >> r >> k;
        edges[r].resize(k);
        for(int j=0; j<k; ++j)
            cin >> edges[r][j];
    }
    vector<vector<int> > dist;
    shortestPath(edges, dist);

    int p;
    cin >> p;
    for(int i=0; i<p; ++i){
        int s, d, v;
        cin >> s >> d >> v;
        int num = dist[s][d];
        if(num == -1 || num >= v)
            cout << "NA" << endl;
        else
            cout << (num+1) << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
int main() {
    int n,m,R;
    cin>>n>>m>>R;
    vector<int> r(R);
    for(int i=0; i<R; i++) cin>>r[i];
    vector<int> a(m),b(m),c(m);
    for(int i=0; i<m; i++) cin>>a[i]>>b[i]>>c[i];
    vector<vector<ll>> dist(n,vector<ll>(n));
    vector<vector<ll>> next(n,vector<ll>(n));
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            dist[i][j]=1e9;
        }
    }
    for(int i=0; i<m; i++){
        dist[a[i]-1][b[i]-1]=c[i];
        dist[b[i]-1][a[i]-1]=c[i];
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            next[i][j] = j;
        } 
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            for(int k=0; k<n; k++){
                if(dist[j][i]+dist[i][k]<dist[j][k]){
                    dist[j][k]=dist[j][i]+dist[i][k];
                    next[j][k]=next[j][i];
                }
            }
        }
    }
    for(int i=0; i<R; i++) r[i]--;
    sort(r.begin(),r.end());
    ll ans=1e9;
    do{
        ll tmp=0;
        for(int i=0; i<R-1; i++){
            tmp+=dist[r[i]][r[i+1]];
        }
        ans=min(ans,tmp);
    }while(next_permutation(r.begin(),r.end()));
    cout<<ans<<endl;
}


Measured memory_bytes: 1152
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long int

int n, a[200002], f[200002], b[200002];
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 1 ; i <= n ; i ++){
		cin >> a[i];
		f[i] = max(f[i - 1], a[i]);
	}
	for(int i = n ; i >= 1 ; i --)
		b[i] = max(b[i + 1], a[i]);
	for(int i = 1 ; i <= n ; i ++)
		cout << max(f[i - 1], b[i + 1]) << endl;
}

Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>
#include <map>
#include <time.h>
#include <iomanip>
#include <bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
    int n;
    string s;
    cin >> n >> s;

    rep(i, 0, s.length()) {
        int num = (int)s[i] + n;
        if(num >= 65 + 26) num -= 26;
        s[i] = (char)num;
    }
    cout << s << endl;
}


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

int main(){
  uint32_t K, N;
  cin >> K >> N;
  
  uint32_t A[N];
  uint32_t len_max = 0;
  pair<uint32_t, uint32_t> maxLenIndex;
  for( uint32_t i = 0; i < N; ++i ){
    cin >> A[i];
    if( i == 0 ){
      continue;
    }
    uint32_t len = A[i] - A[i-1];
    if( len_max < len ){
      len_max = len;
      maxLenIndex = {i-1, i};
    }
  }

  // i=0,i=N-1の間がもっとも長いか確認
  if( A[0] + K - A[N-1] > len_max ){
    len_max = A[0] + K - A[N-1];
    maxLenIndex = {N-1, 0};
  }

  uint32_t total = 0;
  if( maxLenIndex.first < maxLenIndex.second ){
    total = A[maxLenIndex.first] + K - A[maxLenIndex.second];
  }else{
    total = A[maxLenIndex.first] - A[maxLenIndex.second];
  }

  cout << total << endl;
  
}

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

int main(){
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A[i];
    }

    ll M;
    cin >> M;

    vector<ll> B(M);
    FOR(i, 0, M){
        cin >> B[i];
    }

    p(includes(ALL(A), ALL(B)));

    return 0;
}


Measured memory_bytes: 6008
a, b, k = map(int, input().split())

n_takahashi = a
n_aoki = b

cookies_to_eat = k
if n_takahashi > cookies_to_eat:
    n_takahashi = n_takahashi - cookies_to_eat
    cookies_to_eat = 0
else:
    cookies_to_eat = cookies_to_eat - n_takahashi
    n_takahashi = 0

if n_aoki > cookies_to_eat:
    n_aoki = n_aoki - cookies_to_eat
    cookies_to_eat = 0
else:
    cookies_to_eat = cookies_to_eat - n_aoki
    n_aoki = 0

print('{} {}'.format(n_takahashi, n_aoki))



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int maxn = 1000100;
const int base = 1e9+7;

int n,k;
string t;
vector<string> st;

int main() {
   // freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>t; n = t.length();
    cin>>k;
    for (int i=0;i<n;i++) {
        string tmp = "";
        for (int j=i;j<min(n,i+6);j++) {
            tmp.push_back(t[j]);
            st.push_back(tmp);
        }
    }
    sort(st.begin(),st.end());
    st.erase(unique(st.begin(),st.end()), st.end());
    cout<<st[k-1];
}



Measured memory_bytes: 1916