akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int wf[100][100];
	int n,m,g1,g2,s,a,b,c;
	while(cin >> n >> m >> s >> g1 >> g2,n){
		int ret = (1<<21);
		s--;g1--;g2--;
		rep(i,100)rep(j,100)wf[i][j]=(1<<26);
		rep(i,100)wf[i][i]=0;
		rep(i,m){
			cin >> a >> b >> c;
			a--;b--;
			wf[a][b] = c;
		}
		
		rep(k,n)rep(i,n)rep(j,n)
			wf[i][j] = min(wf[i][j],wf[i][k]+wf[k][j]);
			
		rep(j,n)
			ret = min(ret,wf[s][j]+wf[j][g1]+wf[j][g2]);

		cout << ret << endl;
	}
}

Measured memory_bytes: 904
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        char[] s = (sc.next()).toCharArray();
        char[] t = (sc.next()).toCharArray();

        Arrays.sort(s);
        Arrays.sort(t);

        boolean isAns = false;
        for (int i = 0; i < s.length; i++) {
            if (i >= t.length)
                break;
            int tNum = t.length - i - 1;
            if (s[i] < t[tNum]) {
                isAns = true;
                break;
            }
        }

        if (s[s.length-1] == t[0] && s.length < t.length)
            isAns = true;

        System.out.println(isAns ? "Yes" : "No");
    }
}


Measured memory_bytes: 23124
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return read.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtype!real;

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	long m = rlong;
	long k = rlong;
	
	long n = 1L << m;
	
	if(n <= k){
		"-1".writeln;
		return;
	}
	if(m == 1 && k == 1){
		"-1".writeln;
		return;
	}
	if(m == 1 && k == 0){
		"0 0 1 1".writeln;
		return;
	}
	
	long[] ans;
	foreach(i; 0 .. n) if(i != k) ans ~= i;
	ans ~= k;
	foreach_reverse(i; 0 .. n) if(i != k) ans ~= i;
	ans ~= k;
	
	ans.map!(to!string).array.join(" ").writeln;
}


Measured memory_bytes: 17660
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <unordered_map>
#include <iterator>
#include <functional>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const ll INF = 1ll<<50;
const double EPS = 1e-8;
const int MOD = 1000000007;

int n, m, x;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin >> m >> x;
	n = 200010;
	vector<pii> e(m);
	REP(i, m) cin >> e[i].first >> e[i].second;
	priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
	vector<ll> dist(n, INF);
	pq.emplace(0, 0);
	dist[0] = 0;
	while(!pq.empty()){
		int u; ll c;
		tie(u, c) = pq.top(); pq.pop();
		if(dist[u] < c) continue;
		FOR(it, e)for(int d=-1;d<=1;d+=2){
			int v = u + it->first*d;
			if(v<0 || n<=v) continue;
			if(chmin(dist[v], c + it->second)) pq.emplace(v, c + it->second);
		}
	}
	printf("%lld\n", dist[x] < INF ? dist[x] : -1);
	return 0;
}


Measured memory_bytes: 37208
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int pow_mod(int a, int p){
  int digit=0;
  int ans=1;
  int temp=a;

  while(p >= (1<<digit)){
    if(p&(1<<digit)){
      ans=(long)ans*temp%mod;
    }
    temp=(long)temp*temp%mod;
    digit++;
  }
  return ans;
}

int combination(int n, int r, int *factorial, int *factorial_p){
  int ans=((long)factorial[n]*factorial_p[n-r]%mod)*factorial_p[r]%mod;
  return ans;
}

int main(){
  char buf[1024];
  int N, K;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %d", &N, &K);

  int *factorial=(int *)malloc(sizeof(int)*(N+1));
  factorial[0]=1;
  srep(i,1,N+1){
    factorial[i]=(long)factorial[i-1]*i%mod;
  }

  int *factorial_p=(int *)malloc(sizeof(int)*(N+1));
  rep(i,N+1){
    factorial_p[i]=pow_mod(factorial[i], mod-2);
  }

  srep(i,1,K+1){
    if(N-K+1<i){
      printf("%d\n", 0);
    }
    else{
      int ans=(long)combination(K-1, i-1, factorial, factorial_p)*combination(N-K+1, i, factorial, factorial_p)%mod;
      printf("%d\n", ans);
    }
  }



  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 + 7 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
void solve(){
   int n , k ;
   cin >> n >> k ;
   vector < ll > a(n) ;
   for( int i = 0 ; i < n ; i++) cin >> a[i] ;
   vector < ld > b(n);
   for( int i = 0 ; i < n ; i++) b[i] = log(a[i]) ;
   vector < ld > ans ;
   ld s = 0 ;
   for( int i = 0 ; i < k ; i++) s += b[i] ;
   ans.push_back(s);
   for( int i = k ; i < n ; i++){
        s+=b[i] ;
        s-=b[i-k];
        ans.push_back(s);
   }
   for( int i = 1 ; i < ans.size() ; i++){
        if(ans[i]<=ans[i-1]){
            cout << "No\n";
        }
        else{
            cout << "Yes\n";
        }
   }
   //cout << "Yes" ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1 ;
    //cin >> t ;
    while(t--){
        solve( );
    }
}


Measured memory_bytes: 12344
// Lec11-B Dice II
#include<iostream>
class Dice{
public:
  int d[6], tmp;
  Dice(int *in){
    for(int i=0; i<6; i++) d[i] = in[i];
  }
  int question(int top, int front){
    int tmp;
    while(!(top==d[0] && front==d[1])){
      if(top == d[0]){ tmp=d[1];d[1]=d[2];d[2]=d[4];d[4]=d[3];d[3]=tmp; }
      else if(front == d[1]){ tmp=d[0];d[0]=d[2];d[2]=d[5];d[5]=d[3];d[3]=tmp; }
      else{ tmp=d[0];d[0]=d[1];d[1]=d[5];d[5]=d[4];d[4]=tmp; }
    }
    return d[2];
  }
};
int main(){
  int in1[6], n, top, front;
  for(int i=0; i<6; i++) std::cin >> in1[i];
  std::cin >> n;
  Dice sample(in1);
  for(int i=0; i<n; i++){
    std::cin >> top >> front;
    std::cout << sample.question(top, front) << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[50],i,j,f=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        if(a[i]!=i+1)
        {
            for(j=i+1;j<n;j++)
            {
                if(a[j] == i+1)
                {
                    swap(a[i],a[j]);

                    break;
                }
            }

            break;
        }
    }

    for(i=0;i<n;i++)
    {
        if(a[i] != i+1)
        {
            printf("NO\n");
            f++;
            break;
        }
    }

    if(f==0) printf("YES\n");
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n;
ll a[300000];
ll l[300000];
int main(){
	cin >> n;
	REP(i,n) {
		cin >> a[i];
	}

	REP(i,n) {
		if(a[i] > i) {
			cout << -1 << endl;
			return 0;
		}
	}

	REP(i,n) {
		l[i] = -1;
	}
	REP(i,n-1) {
		if(a[i + 1] - a[i] > 1) {
			cout << -1 << endl;
			return 0;
		}
	}

	REP(i,n) {
		l[i - a[i]] = max(l[i - a[i]],(ll)i);
	}

	ll sum = 0;

	REP(i,n) {
		if(l[i] >= 0) {
			sum += l[i] - i;
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3840
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int leng(char *a){
    int n=0;
    for(int i=0; 1; i++){
        if(a[i] == '\0') break;
        n++;
    }
    return n;
}
int main(void){
    int n, i, j, flag = 0;
    scanf("%d", &n);
    char w[n][11];
    for(i=0; i<n; i++){
        scanf("%s", w[i]);
    }
    for(i=1; i<n; i++){
        if(w[i-1][leng(w[i-1])-1] != w[i][0]) flag += 100;
        for(j=0; j<i; j++){
            if(strcmp(w[j], w[i]) == 0) flag += 1;
        }
    }
    if(flag == 0) printf("Yes");
    else printf("No");
/*    for(i=0; i<n; i++){
        printf("%s %d\n", w[i], leng(w[i]));
    }*/

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=5005,INF=1<<30;

ll dp[MAX][MAX];

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}

ll sum[MAX];
ll naname[MAX][MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,A,B;cin>>N>>A>>B;
    if(A>B) swap(A,B);
    if(A==1){
        cout<<rui(2,N)<<endl;
        return 0;
    }
    dp[0][0]=1;
    sum[0]=1;
    naname[0][0]=1;
    
    for(int i=1;i<=N;i++){
        for(int j=0;j<B;j++){
            if(j) dp[i][j]+=dp[i-1][j-1];
            
            if(j==1){
                if(i-2>=0) dp[i][j]+=sum[i-2];
                if(i-(A+1)>=0) dp[i][j]+=mod-sum[i-(A+1)];
            }
            
            if(i-(A+1)>=0&&j-(A+1)>=0) dp[i][j]+=naname[i-(A+1)][j-(A+1)];
            
            while(dp[i][j]>=mod) dp[i][j]-=mod;
        }
        
        ll S=0;
        for(int l=0;l<=B-1;l++){
            S+=dp[i][l];
        }
        S%=mod;
        sum[i]=sum[i-1]+S;
        if(sum[i]>=mod) sum[i]-=mod;
        
        naname[i][0]=dp[i][0];
        for(int j=1;j<=N;j++){
            naname[i][j]=naname[i-1][j-1]+dp[i][j];
            if(naname[i][j]>=mod) naname[i][j]-=mod;
        }
    }
    
    ll ans=0;
    
    for(int i=1;i<N;i++){
        for(int j=1;j<B;j++){
            if(N-i<A||j+N-i<B){
                ans+=dp[i][j];
            }
        }
    }
    
    for(int j=0;j<B;j++){
        ans+=dp[N][j];
    }
    
    ans%=mod;
    
    cout<<(mod+rui(2,N)-ans)%mod<<endl;
}


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

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

int a[N + 10][N + 10],h,w;
string s;

int main()
{
	/*freopen("F:\\rush.txt", "r", stdin);*/
	cin >> h >> w;
	for (int i = 1; i <= h; i++)
	{
		cin >> s;
		for (int j = 1; j <= w; j++)
		{
			if (s[j - 1] == '#')
				a[i][j] = 1;
			else
				a[i][j] = 0;
		}
	}
	for (int i = 1;i <= h;i++)
		for (int j = 1; j <= w; j++)
		{
			if (a[i][j] == 1)
				putchar('#');
			else
			{
				int num = 0;
				for (int k = 0; k < 8; k++)
				{
					int tx = i + dx[k];
					int ty = j + dy[k];
					num += a[tx][ty];
				}
				printf("%d", num);
			}
			if (j == w)
				puts("");
		}
	return 0;
}

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

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=1000000007LL;
const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};




int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll q;cin>>q;
  vl b(q),c(q);
  rep(i,q)cin>>b[i]>>c[i];
  map<ll,ll>M;
  rep(i,n)M[a[i]]++;
  ll sum=0;
  rep(i,n)sum+=a[i];
  rep(i,q){
    sum+=M[b[i]]*(c[i]-b[i]);
    cout<<sum<<endl;
    M[c[i]]+=M[b[i]];
    M[b[i]]=0;
  }
}

Measured memory_bytes: 11560
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
#define dbg(vec) for (size_t _ = 0; _ < vec.size(); ++_){std::cerr << #vec << "[" << _ << "] : " << vec[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;  // 1.073741823e9
const int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
const int MOD = 1000000007;

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

  int n; cin >> n;
  vector<int> h(n); rep(i,n) cin >> h[i];

  int beg = 0;
  int mx = -1;

  while (beg < n) {
    int end = beg;
    while (end + 1 < n && h[end + 1] <= h[end]) {
      ++end;
    }
    int len = end - beg + 1;
    chmax(mx, len);
    beg = end + 1;
  }

  print(mx - 1);

  return 0;
}

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

using namespace std;


#define modulo 1000000007

int min(int x, int y)
{
	return x<y?x:y;
}
int abs(int x)
{
	return x>=0?x:(-1*x);
}
int main()
{
	int n, k, arr[100005];
	cin>>n;
	cin>>k;
	int memo[100005];
	for (int i = 0; i < n; ++i)
	{
		cin>>arr[i];
	}
	memo[0] = 0;
	memo[1] = abs(arr[0] - arr[1]);
	// memo[2] = abs(arr[0] - arr[2]);
	for (int i = 2; i < n; ++i)
	{
		int minim = memo[i-1] + abs(arr[i-1] - arr[i]);
		int sel = i-1;
		for (int j = 2; j <= k && j <= i; ++j)
		{
			minim = min(minim, memo[i-j] + abs(arr[i-j] - arr[i]));
			sel = i-j;
		}
		memo[i] = minim;
	}
	cout<<memo[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long       ll;
#define PI                acos(-1)
#define pb                push_back
#define mp                make_pair
#define mt                make_tuple
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define fore(i,b,e)		  for(int i=(int)b;i<(int)e;++i)
#define forr(i,b,e)		  for(int i=(int)b;i<(int)e;++i)
#define deb(x)			  cerr << "# " << (#x) << " = " << (x) << endl;
#define sz(x)             (int)x.size()
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;

typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const int INF = 1234567890;

int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    int x;
    cin >> x;
    cout << (x^1) << '\n';
    return 0;
}
// Dinosaurs are cool!

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define inf 1000000100

int main()
{
    int n;
    cin >> n;
    map<char ,int> mp;
    while(n--)
    {
        string str;
        cin >> str;
        vi alpha(26);
        for(int i = 0; str[i]; i++)
        {
            alpha[str[i] - 'a']++;
        }
        for(int i = 0; i < 26; i++)
        {
            if(mp.count((char)('a'+i)))
            {
                mp[(char)('a'+i)] = min(mp[(char)('a'+i)], alpha[i]);
            }
            else
            {
                mp[(char)('a'+i)] = alpha[i];
            }
        }

    }
    
        for(int i = 0; i < 26; i++)
        {
            if(mp.count((char)('a'+i)))
            {
                for(int j = 0; j < mp[(char)('a'+i)]; j++)
                {
                    cout << (char)('a'+i);
                }
            }
        }
        cout << endl;


}


Measured memory_bytes: 256
using System;
using static System.Math;

class Program
{
    static int n, k;
    static int[] a;
    static bool[,] dp;
    static int before = 0;

    static void Main()
    {
        string[] s = Console.ReadLine().Split();
        n = int.Parse(s[0]);
        k = int.Parse(s[1]);
        a = new int[n];
        s = Console.ReadLine().Split();
        for (int i = 0; i < n; i++) a[i] = int.Parse(s[i]);
        Array.Sort(a);
        dp = new bool[n + 1, k];
        dp[0, 0] = true;
        if (Need(0))
        {
            Console.WriteLine(0);
            return;
        }
        int l = -1;
        int r = n;
        while (r - l > 1)
        {
            int m = l + (r - l) / 2;
            if (Need(m))
            {
                r = m;
                continue;
            }
            l = m;
        }
        Console.WriteLine(r);
    }

    static bool Need(int x)
    {
        if (x == n) return true;
        if (x == -1) return false;
        for (int i = Min(before, x) + 1; i <= n; i++)
        {
            for (long j = 0; j < k; j++)
            {
                if (j >= a[i - 1] && i - 1 != x)
                    dp[i, j] = dp[i - 1, j] || dp[i - 1, j - a[i - 1]];
                else
                    dp[i, j] = dp[i - 1, j];
            }
        }
        bool f = false;
        for (long j = Max(0, k - a[x]); j < k; j++)
            f = f || dp[n, j];
        before = x;
        return f;
    }
}


Measured memory_bytes: 35796
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    ll ans = LINF;
    for(int i=0;i<=1000000;i++){
        ans = min(ans,(ll)i*2*c+max(0,x-i)*a+max(0,y-i)*b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define lld long double
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 1001000;
string T;
int P[N],W[N],nP[N],nW[N],n,tag[N],D[N];
void solve(int n){
	int siz=pow(3,n-1)+0.5;
	for(int i=0;i<3;i++)
		for(int j=0;j<siz;j++)
			D[i*siz+j]=i,tag[i*siz+j]=0;
	int Tag=0;
	auto upd =[&](int x){
		if(tag[x]!=Tag&&D[x]) D[x]=3-D[x];
		tag[x]=Tag;
	};
	for(int i=0;i<T.size();i++){
		for(int j=0;j<3;j++){
			int w=j*siz+W[i];
			upd(w);
			if(D[w]==2) nW[i]=w;
		}
		if(T[i]=='S') Tag^=1;
		else{
			for(int j=0;j<3;j++){
				int w=j*siz+W[i];
				D[w]=(D[w]+1)%3;
			}
		}
	}
	for(int i=0;i<3;i++)
		for(int j=0;j<siz;j++){
			upd(i*siz+j);
			nP[i*siz+j]=D[i*siz+j]*siz+P[j];
		}
	memcpy(P,nP,sizeof(P));
	memcpy(W,nW,sizeof(W));
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>T;
	for(int i=1;i<=n;i++) solve(i);
	int siz=pow(3,n)+0.5;
	for(int i=0;i<siz;i++) cout<<P[i]<<' ';
	cout<<'\n';
	return 0;
}



Measured memory_bytes: 19172
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)] 
mod = 10**9 + 7
X = [1 for _ in range(N+1)]
for i in a:
  X[i] = 0
for j in range(2,N+1):
  if X[j]:
    X[j] = X[j-1] + X[j-2]
ans = X[N] % mod
print(ans)

Measured memory_bytes: 460056
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int m,d;
int main(){
	m=read(),d=read();
	int ans=0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=d;j++){
			if(j>=10){
				int alfa=j/10,beta=j%10;
				if(alfa<2||beta<2)continue;
				if(alfa*beta==i){
					ans++;
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

typedef long long ll;

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

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

const char nl = '\n';

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	// freopen("input.in", "r", stdin);
	// freopen("input.out", "w", stdout);
    int k; cin >> k;
    if (k % 2 == 0 || k % 5 == 0) cout << -1 << nl;
    else {
	int ans = 1;
	int x = 7;
	while (x % k != 0) {
	    x *= 10; x += 7;
	    x %= k;
	    ans++;
	}
	cout << ans << nl;
    }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
bool is_prime(lli x) {
  for(lli i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}
int main() {
  lli A,B,C=INF,D=0,E=0,F=0,G=0,H=0,N,M;
  cin >> N;
  vector<int>P(N,0);
  rep(i,0,N){
    cin >> P[i];
    D+=P[i];
  }
  rep(i,0,N){
    A=D-N*P[i];
    if(A<0)A*=-1;
    C=min(A,C);
  }
  rep(i,0,N){
    A=D-N*P[i];
    if(A<0)A*=-1;
    if(A==C){
      Out(i);
      break;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


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

    string ans = "No";
    if (s[2]==s[3] && s[4]==s[5]) ans = "Yes";
    
    
    
    cout << ans << endl;
    return 0;
}


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

constexpr int64_t mod = 1000000007;

void dfs(const vector<vector<int>> &to,
            vector<int64_t> &dp_black,
            vector<int64_t> &dp_white,
            int index) {
  if (dp_black.at(index) != -1) return;
  dp_black.at(index) = 1;
  dp_white.at(index) = 1;
  for (auto next : to.at(index)) {
    if (dp_black.at(next) != -1) continue;
    dfs(to, dp_black, dp_white, next);
    (dp_black.at(index) *= dp_white.at(next)) %= mod;
    (dp_white.at(index) *= dp_black.at(next) + dp_white.at(next)) %= mod;
  }
}

int main() {
  int n;
  cin >> n;
  vector<vector<int>> to(n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    to.at(x).push_back(y);
    to.at(y).push_back(x);
  }
  vector<int64_t> dp_black(n, -1), dp_white(n, -1);
  dfs(to, dp_black, dp_white, 0);
  cout << (dp_black.at(0) + dp_white.at(0)) % mod << endl;
}


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

using namespace std;

int main() {
	char tmp[100];
	stack<int> st;
	while (cin >> tmp) {
		if (tmp[0] == '+') {
			int b = st.top();
			st.pop();
			int a = st.top();
			st.pop();
			st.push(a + b);
		}else if (tmp[0] == '-') {
			int b = st.top();
			st.pop();
			int a = st.top();
			st.pop();
			st.push(a - b);
		} else if (tmp[0] == '*') {
			int b = st.top();
			st.pop();
			int a = st.top();
			st.pop();
			st.push(a * b);
		} else st.push(atoi(tmp));
	}

	cout << st.top() << endl;

	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int dp[100005], cont = 0;
int f(int u, vector<vector<int>>&lad){
	if(dp[u]) return dp[u];
	dp[u] = 1;
	for(auto x: lad[u])
		dp[u] = max(dp[u], f(x, lad) + 1);
	
	return dp[u];
}
int main() {
	int n, m, u , v;
	cin >> n >> m;
	vector<vector<int>>lad(n);
	for(int i=0;i<m;i++){
		cin >> u >> v;
		u--, v--;
		lad[u].push_back(v);
	}
	memset(dp, 0 , sizeof(dp));
	int ans = f(0, lad);
	for(int i=1;i<n;i++)
		ans = max(ans,f(i, lad));
	cout << ans - 1;
	return 0;
}

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

a_list = [1, a]
c = 2
while c <= a**0.5:
    if a%c == 0:
        a_list.append(a//c)
        a_list.append(c)
    c += 1
        
b_list = [1, b]
d = 2
while d <= b**0.5:
    if b%d == 0:
        b_list.append(b//d)
        b_list.append(d)
    d += 1
        
a_set = set(a_list)
b_set = set(b_list)
ans_list = list(a_set & b_set)

def prime(n):
    i = 2
    jud = 0
    while i <= n**0.5:
        if n%i == 0:
            jud = 1
            break
        i += 1
    return jud

ans = 0
for i in range(len(ans_list)):
    if prime(ans_list[i]) == 0:
        ans += 1
        
print(ans)

Measured memory_bytes: 5192
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
// #include <fstream>
#define typeof(x) __typeof__(x)
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SIZE(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (int)(UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cost;
};

const int INF = 1e18;
const int MOD = 1e9+7;

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


signed main()
{
  // string filename; cin >> filename;
  // ifstream in(filename);
  // cin.rdbuf(in.rdbuf());

  int N; cin >> N;
  vector<int> a(N);
  rep(i, 0, N) {
    cin >> a[i];
  }
  SORT(a);

  int sum = 0;
  rrep(i, 0, N) {
    int num = (a[i] - a[0]) / (N+1);
    sum += num;
    a[i] -= num * (N+1);
  }
  rep(i, 0, N) {
    a[i] += sum;
  }
  SORT(a);

  if (a[0] > N-1) {
    sum += N * (a[0] - (N-1));
    rrep(i, 0, N) {
      a[i] -= a[0] - (N-1);
    }
  }


  while (true) {
    RSORT(a);
    if (a[0] <= N-1) {
      break;
    }

    a[0] -= (N+1);
    rep(i, 0, N) {
      a[i] += 1;
    }
    sum++;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }


int main(){
    int n; cin >> n;
    vector<int> H(n); rep(i, n) cin >> H[i];
    int cnt = 0;

    for(int i=100; i>0; i--){
        bool water = false;
        for(int j=0; j<n; j++){
            if(!water && H[j] == i){
                water = true;
                cnt++;
                H[j]--;
            }else if(water && H[j] == i) H[j]--;
            else if(water && H[j] != i){
                water = false;
            }
        }
    }
    cout << cnt << ln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.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));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int nxt[60][10][10];
ll cnt[60][10][10];

int calc(int a, int b){
	if(a == 0 and b == 0) return 0;
	int ret = (a + b) % 9;
	if(ret == 0) ret = 9;
	return ret;
}

int main(void){
	rep(d, 10){
		rep(a, 10){
			nxt[0][d][a] = calc(a, d);
			cnt[0][d][a] = (a + d) >= 10 ? 2 : 1;
		}
	}

	rep(d, 10){ 
		rep(k, 1, 60){
			rep(a, 10) {
				nxt[k][d][a] = nxt[k - 1][d][nxt[k - 1][d][a]];
				cnt[k][d][a] = cnt[k - 1][d][a] + cnt[k - 1][d][nxt[k - 1][d][a]];
			}
		}
	}

	int cur = 0;
	ll ans = 0LL;


	int m;
	cin >> m;

	vector<int> d(m);
	vector<ll> c(m);

	rep(i, m) cin >> d[i] >> c[i];


	rep(i, m){
		rrep(k, 60){
			if((c[i] >> k) & 1){
				ans += cnt[k][d[i]][cur];
				cur = nxt[k][d[i]][cur];
			}
		}
	}

	cout << ans - 1 << endl;

	return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n,m,p,q,r,x,y;
	vector<int>::iterator itx,ity,it;
	for(;cin>>n>>m>>p>>q>>r;cout<<x<<endl){
		vector<int> v1,v2;
		v1.push_back(0);
		for(v1.push_back(r);m--;v2.clear()){
			cin>>x>>y;
			itx=upper_bound(v1.begin(),v1.end(),x);
			ity=upper_bound(v1.begin(),v1.end(),y);
			
			if( ity-v1.begin()+1 & 1 )v2.push_back(0);
			v2.push_back(0);
//			v2.insert(v2.end(),ity-v1.begin()&1?1:2,0);
			for(it=ity;it!=v1.end();++it)
				v2.push_back(*it - y);
			
			if(v1.end()-itx & 1)v2.push_back(n-y);
			for(it=itx;it!=ity;++it)
				v2.push_back(*it-x+n-y);
			
			it = v1.begin();
			if(ity-v1.begin() & 1)++it;
			if(!it[1])it+=2;
			if(*it+n-x==v2.back()){++it;v2.pop_back();}
			for(;it!=itx;++it)
				v2.push_back(*it+n-x);
			
			v1.swap(v2);
		}
		v1.insert( upper_bound(v1.begin(),v1.end(),p-1), 2, p-1);
		v1.insert( lower_bound(v1.begin(),v1.end(),q), q );
		v1.push_back(n);
		it = upper_bound(v1.begin(),v1.end(),p-1);
		if(it-v1.begin() & 1) --it;
		for(x=0;*it<q;++it){
			m=*it;++it;
			x+=*it-m;
		}
	}
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final String s = scanner.next();
        if(s.contains("7")){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35688
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int MAXN = 3000000;
int f(int a, int b){
  if(a>b)return a-b;
  else if(a<b) return b- a;
  else return a;
}
int main(){
  int n;
  int A[MAXN+10];    
  while(cin>>n){
    int total = (1<<n);
    int sum = 0;
    for(int i=0; i<total; i++){
      scanf("%d",&A[i]);
    }
    int *q = A; 
    while(total > 1){
      int *p = new int[total/2+1];
      for(int i=0; i<total; i+=2){
        p[i/2] = f(q[i+1],q[i]);
        //cout<<p[i/2]<<" ";
      }
      //cout<<endl;
      total = (total >> 1);      
      q = new int[total+1];      
      for(int i=0;i<total; i++)q[i] = p[i];
      delete[] p;      
      //cout<<"q: ";
      //for(int i=0; i<total; i++){
      //cout<< q[i]<<" ";
      //}
      //cout<<endl;
    }
    cout<<q[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 2428
package main

import (
  "bufio"
  "container/list"
  "fmt"
  "os"
  "strconv"
  "strings"
)

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,100)}
  n := input.NextInt()
  a := input.NextIntArray()
  tree := make([][]int,n)
  for i:=0;i<n-1;i++ {
    x,y := input.NextInts()
    tree[x-1] = append(tree[x-1],y-1)
    tree[y-1] = append(tree[y-1],x-1)
  }
  order := order_from_leaf(tree)
  for _,node := range order {
    if len(tree[node.id]) == 1 { continue }
    s := int64(0)
    m := int64(-1)
    for _,nxt := range tree[node.id] {
      if nxt == node.par { continue }
      s += a[nxt]
      if m < a[nxt] { m = a[nxt] }
    }
    p := s/2
    if m > s-m { p = s-m }
    if a[node.id] < s-p || s < a[node.id] { fmt.Println("NO");return }
    a[node.id] = 2*a[node.id]-s
  }
  if len(tree[0]) == 1 && a[0] == a[tree[0][0]] ||
  len(tree[0]) > 1 && a[0] == 0 {
    fmt.Println("YES");return
  }
  fmt.Println("NO")
}

type Node struct { par,id int }
func order_from_leaf(tree [][]int) []Node {
  n := len(tree)
  order := make([]Node,n)
  q := list.New()
  q.PushBack(Node{-1,0})
  i := n-1
  for q.Len() > 0 {
    p := q.Remove(q.Front()).(Node)
    order[i] = p
    i--
    for _,e := range tree[p.id] {
      if e == p.par { continue }
      q.PushBack(Node{p.id,e})
    }
  }
  return order
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInt() int {
  n,_ := strconv.Atoi(i.NextLine())
  return n
}
func(i *Input) NextInts() (int,int) {
  s := strings.Fields(i.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}
func(i *Input) NextIntArray() []int64 {
  s := strings.Fields(i.NextLine())
  a := make([]int64,len(s))
  for i:=0;i<len(s);i++ { a[i],_ = strconv.ParseInt(s[i],10,64) }
  return a
}

Measured memory_bytes: 14720
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

//using edge = struct{ll from, to;};

int main(){
    ll N; cin >> N;
    vl p(N); REP(i, N) {cin >> p[i]; p[i]--;};
    vl a(N), b(N); ll m = 2*N+1;
    REP(i, N){
        a[i] = 1+m*i; b[i] = 1+m*(N-i-1);
    }
    REP(i, N){
        b[p[i]] += i;
    }
    REP(i, N) cout << a[i] << " ";
    cout << endl;
    REP(i, N) cout << b[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 1152
def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = A[left:mid]
    R = A[mid:right]
    L.append(10 ** 9)
    R.append(10 ** 9)
    i = 0
    j = 0
    global count
    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = int((left + right)/2)
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

n = int(input())
A = list(map(int, input().split()))
count = 0
mergeSort(A, 0, n)

print(*A)
print(count)


Measured memory_bytes: 61648
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb emplace_back
#define mp make_pair
#define MOD 1000000007
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL))
int main()
{
     ll n;
     cin>>n;
     ll a[n];
     for(ll i=0;i<n;i++)   cin>>a[i];
     ll ans = 0;
     for(ll i=0;i<n;i++)
     {
         for(ll j=i+1;j<n;j++)
         {
             ans += a[i]*a[j];
         }
     }
     cout<<ans;
}

Measured memory_bytes: 256
import heapq

def dijkstra(s):
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * 10 # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for d, u in e[v]:
            tmp = d + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                heapq.heappush(hq, (tmp, u))
    return cost

h,w = map(int,input().split())
e = [[] for _ in range(10)]
for i in range(10):
    alist = list(map(int,input().split()))
    for j in range(10):
        if i != j:
            e[i].append((alist[j], j))


l = []
for i in range(h):
    for a in list(map(int,input().split())):
        if a != -1:
            l.append(a)

ans = 0
for i in l:
    ans += dijkstra(i)[1]
print(ans)

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

int main()
{
	int n;
	int sum = 0;
	cin >> n;
	vector<string> a(n);
    for (int i = 0; i< n; i++){
      cin>> a.at(i);
    }
	sort(a.begin(), a.end());
	for (int i = 0; i < n-1; i++) {
		if (a.at(i) != a.at(i + 1)) {
			sum += 1;
		}
	}
	cout << sum + 1 << endl;
}


Measured memory_bytes: 9600
let cnt = ref 0

let merge a l m r =
  let ni = m - l in
  let nj = r - m in
  let init_ary n p =
    Array.init (n + 1) (fun i -> if i = n then max_int else a.(p + i))
  in
  let ai = init_ary ni l in
  let aj = init_ary nj m in
  let rec doit i j k =
    if k < r then begin
      if ai.(i) <= aj.(j) then (a.(k) <- ai.(i); doit (i + 1) j (k + 1))
      else (a.(k) <- aj.(j); cnt := !cnt + (ni - i); doit i (j + 1) (k + 1))
    end
  in
  doit 0 0 l

let rec merge_sort a l r =
  if (l + 1) < r then begin
    let m = (l + r) / 2 in
    merge_sort a l m;
    merge_sort a m r;
    merge a l m r
  end

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  merge_sort a 0 n;
  Printf.printf "%d\n" !cnt

Measured memory_bytes: 10568
#include <stdio.h>

int main(void){
	int h, w;
	char c[101][101];

	scanf("%d%d", &h, &w);
	for(int i=0; i < h; i++) {
		scanf("%s", &c[i]);
	}

	for(int i=0; i < 2*h; i++) {
		printf("%s\n", c[i/2]);
	}

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;

vector<vector<int>>graph(200005);
vector<int>ans;

void dfs(int v,int p){
	for(int u=0;u<graph[v].size();u++){
		if(graph[v][u]==p)continue;
		ans[graph[v][u]]+=ans[v];
		dfs(graph[v][u],v);
	}
}

int main(){
	int n,q;
	cin>>n>>q;
	vector<int>a(n),b(n),p(q),x(q);
	ans.resize(n);
	for(int i=0;i<n-1;i++){
		cin>>a[i]>>b[i];
		a[i]--,b[i]--;
		graph[a[i]].push_back(b[i]);
		graph[b[i]].push_back(a[i]);
	}
	for(int i=0;i<q;i++){
		cin>>p[i]>>x[i];
		p[i]--;
		ans[p[i]]+=x[i];
	}
	dfs(0,-1);
	for(int i=0;i<n;i++)cout<<ans[i]<<endl;
	return 0;
}


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

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

    int n;
    while (cin >> n, n) {
        int m; string s;
        cin >> m >> s;

        int c = 0, res = 0;
        for (int i=0; i<m; ++i) {
            if (s[i] == 'I') {
                if (i == 0 || s[i-1] != 'O') {
                    c = 1;
                } else {
                    c ++;
                    if (n < c) res ++;
                }
            } else {
                if (i == 0 || s[i-1] != 'I') {
                    c = 0;
                }
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 2772
n=int(input())
s=[0 for i in range(n)]
alp_count=[51 for i in range(26)]

ans=""

for i in range(n):
    s[i]=input()
    for j in range(26):
        alp_count[j]=min(alp_count[j], s[i].count(chr(97+j)))

for i in range(26):
    ans=ans+alp_count[i]*(chr(97+i))

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<vector>
#include<iostream>
#include<map>

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

std::map<ll, ll> PrimeFactor(ll n){
    std::map<ll, ll> answer;
    for(ll i=2;i*i<=n;i++){
        while(n%i==0){
            answer[i]++;
            n /= i;
        }
    }
    if(n!=1)answer[n]=1;
    return answer;
}

ll EulersPhiFunction(ll n){  //n について、1 から n までの自然数のうち n と互いに素なものの個数
    ll num = n;
    auto primes = PrimeFactor(n);
    for(auto i:primes){
        num *= i.first-1;
        num /= i.first;
    }
    return num;
}

int main(){
    ll n;
    cin >> n;
    cout << EulersPhiFunction(n) << endl;
}


Measured memory_bytes: 3124
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        double x1,x2,y1,y2;
        x1 = input.nextDouble();
        y1 = input.nextDouble();
        x2 = input.nextDouble();
        y2 = input.nextDouble();
        double ans;
        ans = Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2));
        System.out.println(ans);

    }
}


Measured memory_bytes: 28168
using System;

class C{
  public static void Main(){
	int[] Ar = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    int A = Ar[0], B = Ar[1], H = Ar[2], M = Ar[3];
    double shortr = 30 * H;
    shortr += M * 0.5;
    double longr = 6 * M;
    double abs = Math.Abs(longr - shortr);
    double min = Math.Min(abs, 360 - abs);
    double aji = (A * A) + (B * B);
    decimal minus = ((decimal)Math.Cos(min * (Math.PI / 180))* 2 * B * A);
    double ans = Math.Sqrt(aji - (double)minus);
    Console.WriteLine(ans);
  }
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

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

	cout<< (ll)n*(n-1)/2 <<endl;
	
	return 0;
}


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

int main(){
    int x;
    cin>>x;
    long long int ans=0;
    if(x==1){
        cout<<1<<endl;
        return 0;
    }
    for(int i=1;i<=35;i++){
        for(int j=2;j<20;j++){
            long long int now=pow(i,j);
            if(pow(i,j)<=x)ans=max(ans,now);

        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512