akhauriyash/Code-Regression huggingface dataset:
import Control.Applicative

main :: IO ()
main = solve <$> getLine >>= print

solve :: String -> Int
solve = f 1000
  where
    f x s
      | l < 3 = x
      | otherwise = f (min x (abs (y - 753))) (tail s)
      where
        l = length s
        y = read . take 3 $ s


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

using namespace std;

typedef struct node_{
    int id;
    int k;
    vector<node_*> children;
    int depth;
    int parent;
}* node;

void printTree(vector<node> tree, int n){
    for(int i = 0; i < n; i++){
        node nd = tree[i];
        char* kind = new char[15];
        if(nd -> parent == -1){
            strcpy(kind, "root");
        }else if(nd -> k == 0){
            strcpy(kind, "leaf");
        }else{
            strcpy(kind, "internal node");
        }
        printf("node %d: parent = %d, depth = %d, %s, ", nd -> id, nd -> parent, nd -> depth, kind);
        printf("[");
        for(int j = 0; j < nd -> k - 1; j++){
            printf("%d, ", nd -> children[j] -> id);
        }
        if(nd -> k != 0){
            printf("%d", nd -> children[nd -> k - 1] -> id);
        }
        printf("]\n");
    }
}

int main(){
    int n;
    scanf("%d", &n);
    vector<node> tree(n);
    for(int i = 0; i < n; i++){
        node nd = new node_;
        tree[i] = nd;
    }
    vector<int> find_parent(n);
    for(int i = 0; i < n; i++){
        find_parent[i] = 1;
    }
    for(int i = 0; i < n; i++){
        int id, k;
        scanf("%d %d", &id, &k);
        node nd = tree[id];
        nd -> id = id;
        nd -> k = k;
        nd -> parent = -1;
        for(int j = 0; j < k; j++){
            int c;
            scanf("%d", &c);
            nd -> children.push_back(tree[c]);
            find_parent[c] = 0;
        }
    }//各nodeの情報はできた
    int pa = 0;
    int p = find_parent[pa];
    while(p == 0){
        pa++;
        p = find_parent[pa];
    }

    queue<node> Q;
    Q.push(tree[pa]);
    tree[pa] -> depth = 0;
    while(Q.empty() == 0){
        node nd = Q.front();
        Q.pop();
        for(int i = 0; i < nd -> k; i++){
            Q.push(nd -> children[i]);
            nd -> children[i] -> depth = nd -> depth + 1;
            nd -> children[i] -> parent = nd -> id;
        }
    }

    printTree(tree, n);
    return 0;
}


Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
#define int long long

int32_t main()
{
	int k;
	cin>>k;
	int res = 0;
	for(int a = 1;a<=k;a++)
		for(int b = 1;b<=k;b++)
			for(int c = 1; c<=k; c++)
				res+=__gcd(a,__gcd(b,c));
				cout<<res<<endl;

	
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var s = Console.ReadLine();
		var n = s.Length;
		
		var dp = new long[n+1,13];	//keta, 13amari
		dp[0,0] = 1;
		
		for(int i = 0; i < n; i++)
		{
			var d = (int)(s[i] - '0');
			for(int k = 0; k < 13; k++)
			{
				if(s[i] == '?')
				{
					for(int l = 0; l <= 9; l++)
					{
						dp[i + 1, (k * 10 + l) % 13] += dp[i, k];
						dp[i + 1, (k * 10 + l) % 13] %= Giri;
					}
				}
				else
				{
					dp[i + 1, (k * 10 + d) % 13] += dp[i, k];
					dp[i + 1, (k * 10 + d) % 13] %= Giri;
				}
			}
			
		}
		Console.WriteLine(dp[n, 5] % Giri);
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



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

using namespace std;

typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    int res = 0;
    for (ll i = 0; i <= 62; i++) {
        if (n < (1LL << i)) {
            break;
        }
        ++res;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3104
#include <stdio.h>


int main()
{
    char ch,a,e,i,o,u;
    scanf("%c",&ch);

    if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
       {
            printf("vowel");
       }
       else
       {
           printf("consonant");
       }


    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/perl
my ($n,$x) = map { $_ - 0 } split(/\s+/,<STDIN>);
my @l = map { $_ - 0 } split(/\s+/,<STDIN>);

my $c = 1;
my $d = 0;
for(my $i=0;$i<$n;$i++){
  $d += $l[$i];
  last if $d > $x;
  $c ++;
}
print "$c\n";


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

int main() {
    int x; cin >> x;
    vector<int> ok(x + 1);
    ok[1] = 1;
    for (int b = 2; b * b <= x; b++) {
        int beki = b * b;
        while (beki <= x) ok[beki] = beki, beki *= b;
    }
    cout << *max_element(begin(ok), end(ok)) << endl;
    return 0;
}


Measured memory_bytes: 256
/*
 * URL 		: 	
 * DATE		: 
 */

#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;

#define rep(i,a,b)  for(int i=a; i<b; i++)
#define req(i,a,b)  for(int i=b-1; i>=a; i--)
#define trv(it,s)   for(auto it=s.begin(); it!=s.end(); it++)
#define trs(it,s)   for(auto &it : s)

#define endl        '\n'
#define pb          push_back
#define F           first
#define S           second
#define ll          long long
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<vi>
#define mi          map<int,int>
#define umap        unordered_map
#define uset        unordered_set
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define fill(a,x)   memset(a,x,sizeof(a))
#define num1(x)     __builtin_popcount(x)

#define db(a)       cout<<"---DEBUG : "<<a<<"\n"
#define wa(x)       cout << (#x) << " -------- " << (x) << endl
#define line1	    printf("---------------------------------------\n")
#define line2	    printf("_______________________________________\n")

#define mod(x, m)   ((((x)%(m)) + (m)) % (m))

#define MOD         1000000007 
#define PI          2 * acos(0.0)

//#define int 		long long
//#define printf      //

void pmap(auto l){
	trv(itt,l) printf("%d %d\n", itt->fi, itt->se);
	line1;
}

void pvi(vector<int> pvec, string name="") {
	if(name != "") cout<<"Output of "<<name<<" : ";
	for(int i=0;i<pvec.size();i++) cout<<pvec[i]<<" ";
	cout<<endl;
}

int gcd(int n,int m){
	return m==0?n:gcd(m,n%m);
}

ll mpow(ll base, ll power){
	if(power==0) return 1;
	if(power==1) return base;
	ll exp = mpow(base,power/2);
	exp = exp*exp;
	if(power%2==1) exp = exp * base;
	return exp;
}

//___________________________________________________________________________________________________________

vi a;
vi b;

int choose(int ind){

	if(b[ind] != -1) return b[ind];

	int d1 = abs(a[ind] - a[ind-1]);
	int d2 = abs(a[ind] - a[ind-2]);

	b[ind] =  min(choose(ind-1) + d1, choose(ind-2) + d2);
	// wa(ans);

	return b[ind];
}


void solve() {

	int n;
	cin>>n;

	rep(i,0,n){
		int t;
		cin>>t;
		a.pb(t);
		b.pb(-1);
	}

	b[1] = abs(a[1] - a[0]);
	b[2] = abs(a[2] - a[0]);

	cout << choose(n-1) << endl;


}

//___________________________________________________________________________________________________________
int32_t main() {

	ios_base::sync_with_stdio(false); cin.tie(NULL);


	int notc = 1; 
//	cin>>notc;

	while(notc--) {
		solve();
		//printf("========================================================\n");
	}
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin>>a;
    int b[a]={0};
    for(int i=1;i<=a;i++) cin>>b[i];
    for(int i=1;i<=a;i++){
        int v=b[i];
        int j=i-1;
        while(j>=0&&b[j]>v){
            b[j+1]=b[j];
            j--;
            b[j+1]=v;
        }
        for(int j=1;j<=a;j++){
        if(j==a) cout<<b[j]<<endl;
        else cout<<b[j]<<" ";
        }
    }
}



Measured memory_bytes: 3108
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int sum[510][510];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, Q;
    cin >> N >> M >> Q;
    rep(i, M) {
        int l, r;
        cin >> l >> r;
        sum[r][l]++;
    }
    // rep(i, N + 1) {
    //     rep(j, N + 1) {
    //         cout << sum[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;
    rep(i, N) {
        rep(j, N + 1) {
            sum[i + 1][j] += sum[i][j];
        }
    }
    rep(i, N + 1) {
        RREP(j, N, 1) {
            sum[i][j - 1] += sum[i][j];
        }
    }
    // rep(i, N + 1) {
    //     rep(j, N + 1) {
    //         cout << sum[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    while(Q--) {
        int l, r;
        cin >> l >> r;
        cout << sum[r][l] << endl;
    }


    return 0;
}

// |
// |-|
//   |

// |-|-|-|-|
//   |-|-|-|-|-|-|
//             |-|-|-|
// |-------------|
//     |-------------|

//  0 1 2
//0   
//1   1 1
//2     1

//  0 1 2
//0   
//1   1 3
//2     1

//  0 1 2 3 4 5 6 7 8 9 10
//0 0 0
//1 0 0
//2 0 0
//3 0 0
//4 1 1 0 0 0 0 0 0 0 0 0
//5 1 1
//6 1 1
//7 1 1
//8 1 1
//9 1 1
//10



Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

vector<ll> dijkstra(const vector<vector<pair<int,int>>> &graph,int s,vector<ll> &cnt){
    int n=(int)graph.size();
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> pq;
    vector<ll> dist(n,linf);
    dist[s]=0;
    cnt.assign(n,0);
    cnt[s]=1;
    pq.push({0,s});
    while(pq.size()){
        auto p=pq.top();
        pq.pop();
        int v=p.second;
        if(dist[v]<p.first)continue;
        for(auto edge:graph[v]){
            int u=edge.first;
            int w=edge.second;
            if(dist[v]+w<dist[u]){
                dist[u]=dist[v]+w;
                cnt[u]=cnt[v];
                pq.push({dist[u],u});
            }
            else if(dist[v]+w==dist[u]){
                cnt[u]=(cnt[u]+cnt[v])%mod;
            }
        }
    }
    return dist;
}

int main(){
    int n,m,s,t;
    cin>>n>>m>>s>>t;
    --s,--t;
    vector<vector<pair<int,int>>> g(n);
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        c*=2;
        --a,--b;
        g[a].push_back({b,c});
        g[b].push_back({a,c});
    }
    vector<ll> cnt_t,cnt_a;
    vector<ll> d_t=dijkstra(g,s,cnt_t);
    vector<ll> d_a=dijkstra(g,t,cnt_a);
    bool used[n]={};
    queue<int> que;
    que.push(t);
    used[t]=true;
    while(que.size()){
        int v=que.front();
        que.pop();
        for(auto next:g[v]){
            ll w=next.second;
            int u=next.first;
            if(used[u])continue;
            if(d_t[v]==d_t[u]+w){
                used[u]=true;
                que.push(u);
            }
        }
    }
    ll half=d_t[t]/2;
    vector<ll> path;
    rep(i,n){
        if(used[i]&&d_t[i]==half){
            path.push_back((cnt_t[i]*cnt_a[i])%mod);
        }
        rep(j,g[i].size()){
            ll w=g[i][j].second;
            int to=g[i][j].first;
            if(!used[i]||!used[to])continue;
            if(d_t[i]+w!=d_t[to])continue;
            if(d_t[i]<half&&half<d_t[to]){
                path.push_back((cnt_t[i]*cnt_a[to])%mod);
            }
        }
    }
    ll sum=0;
    for(ll e:path){
        sum=(sum+e)%mod;
    }
    ll ans=0;
    for(ll e:path){
        ans=(ans+e*(sum-e))%mod;
    }
    ans=(ans+mod)%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 15060
import itertools as it
n=int(input())
p=tuple(map(int, input().split()))
q=tuple(map(int, input().split()))
dic=[i+1 for i in range(n)]
dic=list(it.permutations(dic,n))
a=dic.index(p)
b=dic.index(q)
print(abs(a-b))

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

typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int n;
    cin >> n;
    map<int,int> mp[2];
    for(int i = 0; i < n; i++){
        int V;
        cin >> V;
        mp[i%2][V]++;
    }

    vector<P> v[2];
    for(int i = 0; i < 2; i++){
        for(auto j: mp[i]){
            v[i].emplace_back(j.second,j.first);
        }
        sort(v[i].rbegin(),v[i].rend());
        v[i].emplace_back(0,-1);
    }
    if(v[0][0].second == v[1][0].second){
        cout << min(n-v[0][0].first-v[1][1].first,n-v[0][1].first-v[1][0].first);
    }else{
        cout << n-v[0][0].first-v[1][0].first << endl;
    }
    return 0;
}

Measured memory_bytes: 6136
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
#define int long long

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e9 + 200, mod = 1e9 + 7;

set <int> S;
vector <int> g;
int a[N], pos[N], f[N];
string ss;

int bin_pow(int x, int y){
	int res = 1;
	while (y){
		if (y & 1) (res *= x) %= mod;
		(x *= x) %= mod;
		y >>= 1;
	}
	return res;
}

int CC(int n, int k){
	if (k > n) return 0;
	return f[n] * bin_pow(f[k], mod - 2) % mod * bin_pow(f[n - k], mod - 2) % mod; 
}

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int l, r;
	for (int i = 1; i <= n + 1; i++){
		int x;
		cin >> x;
		if (pos[x]){
			l = pos[x];
			r = i;
		}
		pos[x] = i;
	}
	f[0] = 1;
	for (int i = 1; i <= n + 1; i++) (f[i] = f[i - 1] * i) %= mod;
	for (int i = 1; i <= n + 1; i++){
		int res = CC(n + 1, i);
		res = (res + mod - CC(n - (r - l), i - 1)) % mod;
		cout << res << "\n";
	}
	
	return 0;
}












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

using namespace std;

#define LL long long
#define Re register
#define U unsigned
#define forn(i,a,b) for(Re int i = a;i <= b;++i)
#define nfor(i,a,b) for(Re int i = a;i >= b;--i)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define pb push_back
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dir[4][2]={1,0,0,1,-1,0,0,-1};

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    string s;
    cin>>s;
    bool f=true;
    for(int i=1;i<=3;i++)
    {
        if(s[i]==s[i-1])
        {
            f=false;
        }
    }
    if(f)
        cout<<"Good";
    else
        cout<<"Bad";
	return 0;
}


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

using namespace std;

struct edge {
    int to;
    int cost;
    edge(int a, int b) : to(a), cost(b) {}
};

vector<vector<edge>> e;
int N;

pair<int, int> dfs(int p, int par = -1)
{
    if (e[p].size() == 1 && par >= 0) return make_pair(0, p);
    pair<int, int> res = make_pair(0, 0);
    for (auto x : e[p]) {
        if (x.to == par) continue;
        auto t = dfs(x.to, p);
        t.first += x.cost;
        res = max(res, t);
    }
    return res;
}

int main()
{
    cin >> N;
    e.resize(N);
    for (int i = 0; i < N-1; i++) {
        int s, t, w;
        cin >> s >> t >> w;
        e[s].emplace_back(t, w);
        e[t].emplace_back(s, w);
    }
    auto res = dfs(0);
    res = dfs(res.second);
    cout << res.first << endl;
}


Measured memory_bytes: 15904
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#define	MOD  1000000007;
#define PI = 3.14159265358979323846;
using namespace std;

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

	int a[100000], b[100000];
	map<long long, long long> mp;
	map<long long, long long>::iterator it;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i] >> b[i];
		mp[a[i]] += b[i];
	}

	long long count = 0;
	for (it = mp.begin(); it != mp.end(); it++) {
		count += it->second;
		if (count >= K) {
			cout << it->first << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int h[N];bool vis[N];
int main(){
	int u,v,n,m,ans=0;scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",h+i);
	for(int i=0;i<m;i++){
		scanf("%d%d",&u,&v);
		if(h[u]<=h[v])vis[u]=1;
		if(h[v]<=h[u])vis[v]=1;
	}
	for(int i=1;i<=n;i++)if(!vis[i])ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 4272
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 200005
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007
#define PI acos(-1.0)
#define eps 1e-9

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    ll a, b;
    cin>>a>>b;
    ll g = __gcd(a, b);
    ll ans = (a * b) / g;
    cout<<ans<<endl;

    //End();
    return 0;
}


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

typedef long long ll;

using namespace std;

ll is(vector<ll> &a, ll m, ll k)
{
	ll count = 0;
	for(ll i = 0; i < a.size(); i++)
	{
		count = count + a[i] / m;
		if(a[i] % m == 0)
			count--;
	}

	if(count > k)
		return 0;
	else if(count == k)
		return 1;
	
	return 2;
}

int main()
{
	ll n, k;
	cin >> n >> k;

	vector<ll> a(n);
	for(ll i = 0; i < n; i++)
		cin >> a[i];

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

	cout.setf(ios::fixed);
	cout << setprecision(0);
	if(!k)
	{
		cout << a[n - 1] << endl;
		return 0;
	}
	else if(k == 1)
	{
		if(n == 1)
			cout << ((ll) round(a[0] / 2)) << endl;
		else
			cout << max((ll)round(a[n - 1] / 2), a[n - 2]) << endl;
	}

	double ans = 0;
	ll l = 1, r = a[n - 1];
	while(l <= r)
	{
		ll m = l + (r - l) / 2;
		ll count = is(a, m, k);
		if(count >= 1)
		{
			ans = m;
			r = m - 1;
		}
		else
		{
			l = m + 1;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 4756
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	x := scanInt()
	y := scanInt()
	a := scanInt()
	b := scanInt()
	c := scanInt()
	p := scanInts(a)
	q := scanInts(b)
	r := scanInts(c)

	d := make(rngs, a+b+c)
	for i := 0; i < a; i++ {
		d[i] = rng{p[i],0}
	}
	for i := 0; i < b; i++ {
		d[i+a] = rng{q[i],1}
	}
	for i := 0; i < c; i++ {
		d[i+a+b] = rng{r[i],2}
	}

	sort.Sort(d)

	ans := 0
	all := x+y
	for i := 0; i < len(d); i++ {
		next := d[i]
		if next.col == 2 {
			all--
			ans+=next.val
		} else if next.col == 1 {
			if y == 0 {
				continue
			}
			y--
			all--
			ans+=next.val
		} else {
			if x == 0 {
				continue
			}
			x--
			all--
			ans+=next.val
		}

		if all == 0 {
			break
		}
	}

	fmt.Fprintln(wr, ans)

}

type rng struct {
	val, col int
}

type rngs []rng

func (a rngs) Len() int           { return len(a) }
func (a rngs) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a rngs) Less(i, j int) bool { return a[i].val > a[j].val }


Measured memory_bytes: 10752
#include <iostream>
#define    N    101
using namespace std;

void swap(int *x, int *y){
	int z = *x;
	*x = *y;
	*y = z;
}

int bubbleSort(int *A, int n){
	int count = 0, flag = 1;
	
	while(flag){
		flag = 0;
		for(int j=n-1;j>0;j--){
			if(A[j] < A[j-1]){
				swap(A[j], A[j-1]);
				count++;
				flag = 1;
			}
		}
	}

	return count;
}

int main(){
	int n, A[N], change;

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

	change = bubbleSort(A, n);
	
	for(int i=0;i<n;i++){
		if(i!=0) cout<<" ";
		cout<<A[i];
	}
	cout<<endl<<change<<endl;

	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


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

    int t=1,te=0;
    // cin>>t;
    while(t--){
        int n;
        cin>>n;
        string s;
        cin>>s;
        int res=0;
        for(int i=0;i+2<(int)s.size();++i){
            if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C')++res;
        }
        printf("%d\n", res);


        //printf("Case %d: ",++te);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
struct poi{
  int X;int Y;int Z;
  bool operator<(const poi&R)const{
    return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
  }
};
/*
ll GCD(ll A,ll B){
  return (B==0)?(A):(GCD(B,A%B));
}
ll LCM(ll A,ll B){
  return A/GCD(A,B)*B;
}
*/
int main(){
  ll H,W,N;
  VP V;
  cin>>H>>W>>N;
  FOR(i,0,N){
    int A,B;
    cin>>A>>B;
    A--;B--;
    FOR(j,0,3){
      FOR(k,0,3){
        if(0<=(A-j)&&(A-j)<H-2&&0<=(B-k)&&(B-k)<W-2){
          V.PB(MA((A-j),(B-k)));
        }
      }
    }
  }
  sort(V.begin(),V.end());
  ll ans[10];
  fill(ans,ans+10,0);
  int now=0;
  while(now<(int)V.size()){
    int c=1;
    while(now<(int)V.size()-1&&V[now]==V[now+1]){
      now++;
      c++;
    }
    now++;
    ans[c]++;
  }
  ans[0]=(H-2)*(W-2);
  FOR(i,1,10){
    ans[0]-=ans[i];
  }
  FOR(i,0,10){
    cout<<ans[i]<<endl;
  }
	return 0;
}

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

#define INPUT freopen("input.txt", "r", stdin);

#define ll long long
#define ld long double

#define len(s) s.size()

#define fl(st, en, in) for (int i = st; i < en; i += in)
#define rfl(st, en, de) for (int i = st; i < en; i -= de)

#define COY cout << "Yes" << endl;
#define CON cout << "No" << endl;

int main()
{
    //INPUT;

    string s;
    cin >> s;

    ll sum = 0;
    fl(0, len(s), 1)
    {
        sum += (s[i] - '0');
    }
    if (sum % 9)
    {
        CON;
    }
    else
    {
        COY;
    }
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    ll a,b,v,w,t;
    cin >> a >> v >> b >> w >> t;

    ll sa = abs(a-b);
    ll sokudo = v-w;
    ll d = sokudo * t;
    if(sa<=d)YES
    NO
	return 0;
}

Measured memory_bytes: 3572
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
td = [tuple(li()) for _ in range(n)]

td.sort(key=lambda x:x[1], reverse=True)

kindset = set()
doublestack = []

ans = 0

for ti, di in td[:k]:
    if ti in kindset:
        doublestack.append((ti,di))
    
    else:
        kindset.add(ti)
        
    ans += di

ans += len(kindset) * len(kindset)
score = ans

# n-k個の要素に対して重複を排して交換
for ti, di in td[k:]:
    if ti in kindset:
        continue
    
    # すべてユニークだったら抜ける
    if len(doublestack) == 0:
        break
    
    #スコア再計算
    old_ti, old_di = doublestack.pop()    
    score = score - old_di + di + 2*len(kindset) + 1
    
    # 更新
    ans = max(ans, score)    
    kindset.add(ti)
    
    
print(ans)

Measured memory_bytes: 22040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

const ll MAX_V = 2510;
const ll MAX_E = 5010;
ll n, m, p;
// 辺from    辺to      辺の距離   最短距離(!=INF:startから到達できる)
ll a[MAX_E], b[MAX_E], c[MAX_E], d[MAX_V];
// startから到達できる負閉路である
bool neg[MAX_V];

// ベルマンフォード法
// 有向グラフの単一始点最短経路を求める O(VE)
// 始点から到達可能な負閉路を検出する O(VE)
void BellmanFord(ll start){
    repr(i, 1, n+1){
        d[i] = INF;
        neg[i] = 0;
    }
    d[start] = 0;
    // 距離の緩和
    rep(i, n){
        rep(j, m){
            ll u = a[j];
            ll v = b[j];
            if(d[u] != INF && d[v] > d[u] + c[j]){
                d[v] = d[u] + c[j];
            }
        }
    }
    // 負閉路検出
    rep(i, n){
        rep(j, m){
            ll u = a[j];
            ll v = b[j];
            // startから到達できる、かつ距離を緩和できる
            if(d[v] != INF && d[v] > d[u] + c[j]){
                d[v] = d[u] + c[j];
                neg[v] = 1;
            }
            // negの伝播
            if(neg[u]) neg[v] = 1;
        }
    }
}

/*
// Verified: ABC137-E Coins Respawn
int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> n >> m >> p;
    rep(i, m){
        cin >> a[i] >> b[i] >> c[i];
        c[i] = -c[i] + p;
    }
    BellmanFord(1);
    if(neg[n]){
        cout << -1 << endl;
    }else{
        cout << max(-d[n], 0ll) << endl;
    }
    return 0;
}
*/

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, m){
        cin >> a[i] >> b[i] >> c[i];
        c[i] = -c[i];
    }
    BellmanFord(1);
    if(neg[n]){
        cout << "inf" << endl;
    }else{
        cout << -d[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
int main() {
    int n, k, q; cin >> n >> k >> q;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    int ans = 1<<30;
    for (int i = 0; i < n; i++) {
        vector<int> ii, tmp;
        ii.push_back(-1);
        for (int j = 0; j < n; j++) if (a[j] < a[i]) ii.push_back(j);
        ii.push_back(n);
        for (int j = 1; j < ii.size(); j++) {
            if (ii[j] - ii[j-1] > k) {
                vector<int> tmp2;
                for (int m = ii[j-1]+1; m < ii[j]; m++)
                    tmp2.push_back(a[m]);
                sort(tmp2.begin(), tmp2.end());
                for (int m = 0; m + k <= tmp2.size(); m++)
                    tmp.push_back(tmp2[m]);
            }
        }
        if (tmp.size() < q) continue;
        sort(tmp.begin(), tmp.end());
        ans = min(ans, tmp[q-1] - tmp[0]);
    }
    cout << ans << endl;
}


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

n = int(input())
nums = []
for i in range(n):
    nums.append(int(input()))
nums.sort()
nums.reverse()
count = len(nums)
for j in range(len(nums) - 1):
    if nums[j] == nums[j+1]:
        count -= 1
print(count)

Measured memory_bytes: 3060
n, m=map(int, input().split(" "))
l=1

A = [ [ int(a) for a in input().split() ] for i in range(n) ]
B = [ [ int(b) for b in input().split() ] for i in range(m) ]
C = [ [ 0 for i in range(l) ] for i in range(n) ]

for i in range(n):
    for j in range(l):
        for jj in range(m):
                 C[i][j] = C[i][j] + A[i][jj] * B[jj][j]

    print(" ".join([str(_) for _ in C[i]]))

Measured memory_bytes: 8080
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,A,B,C;
    cin>>N>>A>>B>>C;
    string s[N];
    rep(i,N) {
        cin >> s[i];
    }
    string ans="Yes";
    char v[N]={};
    rep(i,N){
        if(s[i]=="AB"){
            if(i+1<N &&A==1&&B==1){
                if(s[i+1]=="AC"){
                    v[i]='A';
                A++;
                B--;
                }else if(i+1<N &&s[i+1]=="BC"){
                    v[i]='B';
                A--;
                B++;
                }else {
                    v[i]='A';
                    i++;
                    v[i]='B';
                }
            }
            else if(A>=B) {
                v[i]='B';
                A--;
                B++;
            }else{
                v[i]='A';
                A++;
                B--;
            }
        }
        if(s[i]=="AC"){
            if(i+1<N &&A==1&&C==1){
                if(s[i+1]=="AB"){
                    v[i]='A';
                A++;
                C--;
                }else if(s[i+1]=="BC"){
                    v[i]='C';
                A--;
                C++;
                }else {
                    v[i]='A';
                    i++;
                    v[i]='C';
                }
            }
            else if(A>=C) {
                v[i]='C';
                A--;
                C++;
            }else{
                v[i]='A';
                A++;
                C--;
            }
        }
        if(s[i]=="BC"){
            if(i+1<N &&C==1&&B==1){
                if(i+1<N &&s[i+1]=="AC"){
                    v[i]='C';
                C++;
                B--;
                }else if(i+1<N &&s[i+1]=="AB"){
                    v[i]='B';
                C--;
                B++;
                }else {
                    v[i]='B';
                    i++;
                    if(i==N) break;
                    v[i]='C';
                }
            }
            else if(B>=C) {
                v[i]='C';
                B--;
                C++;
            }else{
                v[i]='B';
                B++;
                C--;
            }
        }
            if(A<0||B<0||C<0) {
                ans="No";
                break;
            }
    }
    if(ans=="No") cout << ans << endl;
    else{
        cout << ans << endl;
        rep(i,N){
            cout << v[i] << endl;
        }
    }





}


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

Measured memory_bytes: 21972
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll INF = numeric_limits<ll>::max()/2;
const ll MOD = 1e9+7;

vector<ll> fact(222222),inv(222222);

// a^b
ll mypow(ll a, ll b) {
    if (b == 0) return 1;
    ll tmp = mypow(a, b / 2);
    if (b % 2) return (((tmp*tmp) % MOD)*a) % MOD;
    else return (tmp*tmp) % MOD;
}

ll comb(ll n, ll r){
    return (((fact[n]*inv[r])%MOD)*inv[n-r])%MOD;
}

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

    ll h,w,a,b;cin>>h>>w>>a>>b;
    fact[0]=1;inv[0]=1;
    for(int i=1;i<=200000;i++){
        fact[i] = fact[i-1]*i;
        fact[i] %= MOD;
        inv[i] = mypow(fact[i],MOD-2);
    }
    ll res=0;
    for(int i=b+1;i<=w;i++){
        res += comb(h+i-a-2,i-1)*comb(w-i+a-1,a-1);
        res %= MOD;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3712
import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;

public class Main {
    static int n;
    static int[] A = new int[50];
    static double th = Math.PI * 60.0 / 180.0;

    public static void main(String[] args) throws IOException{

        //??\???
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */

        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();

        // ??????
       Point P1 = new Point(0, 0);
       Point P2 = new Point(100, 0);
       System.out.printf("%.8f %.8f\n", P1.x, P1.y);
       koch(n, P1, P2);
       System.out.printf("%.8f %.8f\n", P2.x, P2.y);
    }

    public static void koch(int d, Point P1, Point P2){
        if(d == 0) return;

        double x1 = P1.x;
        double y1 = P1.y;
        double x2 = P2.x;
        double y2 = P2.y;

        double sx = (2 * x1 + x2) / 3;
        double sy = (2 * y1 + y2) / 3;
        double tx = (x1 + 2 * x2) / 3;
        double ty = (y1 + 2 * y2) / 3;
        double ux = sx + (tx - sx) * Math.cos(th) - (ty - sy) * Math.sin(th);
        double uy = sy + (tx - sx) * Math.sin(th) + (ty - sy) * Math.cos(th);

        Point S = new Point(sx, sy);
        Point T = new Point(tx, ty);
        Point U = new Point(ux, uy);

        koch(d - 1, P1, S);
        System.out.printf("%.8f %.8f\n", sx, sy);
        koch(d -1, S, U);
        System.out.printf("%.8f %.8f\n", ux, uy);
        koch(d - 1, U, T);
        System.out.printf("%.8f %.8f\n", tx, ty);
        koch(d -1, T, P2);

    }

}

class Point{
    double x;
    double y;

    Point(double a, double b){
        x = a;
        y = b;
    }
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1
#define j0 gray_cat_j0

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 16;
const int INF = 1e9 + 10;
const ll MOD = 998244353;

const int MAXN = 3e2 + 5;

int cnt[MAXN];

ll dp[MAXN][MAXN][MAXN];
ll dp_s[MAXN][MAXN][MAXN];
ll dp_sd[MAXN][MAXN][MAXN];

char s[MAXN];

void solve(){
	int m;
	scanf("%s%d", &s[0], &m);
	int cur = 0, n = strlen(s), top = 0;
	m = min(m, n);
	REP(i, 0, n) {
		if (s[i] == '0') {
			cnt[top++] = cur;
			cur = 0;
		} else {
			cur++;
		}
	}
	if (cur) {
		cnt[top++] = cur;
	}
	n = top;
	dp[n][0][0] = 1;
	REPN(j, 0, m) {
		dp_s[n][j][0] = 1;
	}
	//dp_sd[n][0][0] = 1;
	for(int i = n - 1; i >= 0; i--) {
		REPN(j, 0, m) {
			REPN(k, 0, m) {
				dp[i][j][k] = (dp[i][j][k] + dp_s[i + 1][j][k]) % MOD;
				if (j > cnt[i]) {
					dp[i][j][k] = (dp[i][j][k] + MOD - dp_s[i + 1][j - cnt[i] - 1][k]) % MOD;
				}
				dp[i][j][k] = (dp[i][j][k] + dp_sd[i + 1][j][k]) % MOD;
				
				dp_s[i][j][k] = dp[i][j][k];
				if (j) {
					dp_s[i][j][k] = (dp_s[i][j][k] + dp_s[i][j - 1][k]) % MOD;
				}
			}
		}
		for(int j = m; j >= 0; j--) {
			REPN(k, 1, m) {
				dp_sd[i][j][k] = dp[i][j + 1][k - 1] + dp_sd[i][j + 1][k - 1];
			}
		}
		/*for(int j = m; j >= 0; j--) {
			REPN(k, 0, m) {
				dp_sd[i][j][j + k] = (dp_sd[i][j][j + k] + dp_sd[i][j + 1][j + k]) % MOD;
			}
		}*/
	}
	
	/*for(int i = n; i >= 0; i--) {
		REPN(j, 0, m) {
			REPN(k, 0, m) {
				printf("%d %d %d: %lld %lld %lld\n", i, j, k, dp[i][j][k], dp_s[i][j][k], dp_sd[i][j][k]);
			}
		}
	}*/
	
	ll ans = 0ll;
	REPN(k, 0, m) {
		ans = (ans + dp[0][0][k]) % MOD;
	}
	printf("%lld\n", ans);
}

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 329976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K; cin >> N >> K;
    int ans=0;
    while(N>0){N/=K; ++ans;}
    cout << ans << endl;
}

Measured memory_bytes: 384
/******************************************************************
KMP+思维
 
******************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define maxn 500005
#define mo 1000000007
char s[maxn*4],t[maxn*4];
int nex[maxn*4];
void add(char s[],char s1[],int &l,int l1){
	for(int i=0;i<l1;i++)s[i+l]=s1[i];
	l+=l1;
}
void Next(const char a[],int nex[],int l){
	nex[0]=-1;
	for(int i=0,j=-1;i<l;i++){
		while(j!=-1&&a[i]!=a[j])j=nex[j];
		nex[i+1]=++j;
	}
}
int kmp(const char a[],const char b[],int nex[],int l1,int l2){
	int ans=0;
	for(int i=0,j=0;i<l1;i++){
		while(j==l2||(j!=-1&&a[i]!=b[j]))j=nex[j];
		ans=max(ans,++j);
	}
	return ans;
}
int main(){
	scanf("%s%s",s,t);
	int l=strlen(s),l1=strlen(t),l2=l,l3=l1;
	while(l3<l+l1)add(t,t,l3,l1);
	while(l2<l+l1*2)add(s,s,l2,l);
	Next(t,nex,l3);
	int ans=kmp(s,t,nex,l2,l3);
	if(ans==l3)ans=-1;
	else ans/=l1;
	printf("%d",ans);
	return 0;
} 

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

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

ll monster(ll hp){
    if(hp == 1) return 1;
    else return 2*monster(ceil(hp/2)) + 1;
}

int main(){
    ll h; cin >> h;
    cout << monster(h) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = a; i < b; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;


int main(){
    ll H, W; cin >> H >> W;
    vector<string> S(H);
    rep(i, 0, H) cin >> S[i];

    vector<vector<bool> > visited(H, vector<bool>(W, false));
    ll ans = 0;

    rep(i, 0, H){
        rep(j, 0, W){
            if(!visited[i][j]){
                queue<pair<char, pair<ll,ll> > > Q;
                Q.push(make_pair(S[i][j], make_pair(i,j)));
                visited[i][j] = true;
                ll cnt_b = 0;
                ll cnt_w = 0;
                if(S[i][j] == '#') cnt_b++;
                else cnt_w++;
                while(!Q.empty()){
                    pair<char, P> u = Q.front(); Q.pop();
                    //visited[u.first][u.second ] = true;
                    ll y = u.second.first;
                    ll x = u.second.second;
                    char t = u.first;
                    //cout << y << " " << x << endl;
                    if(y-1 >= 0 && !visited[y-1][x] && t != S[y-1][x]){
                        visited[y-1][x] = true;
                        Q.push(make_pair(S[y-1][x],make_pair(y-1, x) ));
                        if(t == '#') cnt_w++;
                        else cnt_b++;
                    }
                    if(y+1 < H && !visited[y+1][x] && t != S[y+1][x]){
                        visited[y+1][x] = true;
                        Q.push(make_pair(S[y+1][x],make_pair(y+1, x) ));
                        if(t == '#') cnt_w++;
                        else cnt_b++;
                    }
                    if(x-1 >= 0 && !visited[y][x-1] && t != S[y][x-1]){
                        visited[y][x-1] = true;
                        Q.push(make_pair(S[y][x-1],make_pair(y, x-1) ));
                        if(t == '#') cnt_w++;
                        else cnt_b++;
                    }
                    if(x+1 < W && !visited[y][x+1] && t != S[y][x+1]){
                        visited[y][x+1] = true;
                        Q.push(make_pair(S[y][x+1],make_pair(y, x+1) ));
                        if(t == '#') cnt_w++;
                        else cnt_b++;
                    }
                }
                ans += cnt_b * cnt_w;
                //cout << i << " " << j << " " << cnt_b * cnt_w << endl;
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 512
#include<iostream>
using namespace std;;
int main(){
  long long n,a;
cin >> n ;
  long long n1=n;
long long c[8];
  long long b=0;
  long long i=0;
  while(n1 >9){
    i+=n1%10;
    n1=n1/10;
  }
  i+=n1;
if((n%i)==0){
cout <<"Yes";
}
  else
    cout <<"No";
return 0;
}

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

int main() {
  int h, m, s, S;

  cin >> S;
  m = S / 60;
  h = m / 60;
  m = m - h * 60;
  s = S - (h * 60 * 60 + m * 60); 


  cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int X, Y;
bool D[20202];
char str[10101];
vector<int> XM, YM, V;

int main(){
    scanf("%s", str+1);
    scanf("%d %d", &X, &Y);
    int cnt=0, xy=1;
    for (int i=1; str[i]; i++){
        if (str[i] == 'F') cnt++;
        else{
            if (xy == 1) XM.push_back(cnt);
            else YM.push_back(cnt);
            cnt=0, xy = -xy;
        }
    }
    if (xy == 1) XM.push_back(cnt);
    else YM.push_back(cnt);

    int l = XM[0]+10000, r = XM[0]+10000;
    D[XM[0]+10000] = true;
    for (int i=1; i<(int)XM.size(); i++){
        V.clear();
        for (int j=l; j<=r; j++) {
            if (D[j]) V.push_back(j);
            D[j] = false;
        }
        l = 20000, r = 0;
        for (int t : V){
            l = min(l, t-XM[i]);
            r = max(r, t+XM[i]);
            D[t-XM[i]] = D[t+XM[i]] = true;
        }
    }
    if (!D[X+10000]){
        puts("No");
        return 0;
    }

    memset(D, false, sizeof D);
    l = 10000, r = 10000;
    D[10000] = true;
    for (int i=0; i<(int)YM.size(); i++){
        V.clear();
        for (int j=l; j<=r; j++) {
            if (D[j]) V.push_back(j);
            D[j] = false;
        }
        l = 20000, r = 0;
        for (int t : V){
            l = min(l, t-YM[i]);
            r = max(r, t+YM[i]);
            D[t-YM[i]] = D[t+YM[i]] = true;
        }
    }
    if (!D[Y+10000]){
        puts("No");
        return 0;
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 384