akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <map>
//#include <set>
//#include <list>
//#include <cmath>
//#include <ctime>
//#include <deque>
//#include <queue>
//#include <stack>
//#include <string>
//#include <bitset>
//#include <cstdio>
//#include <limits>
//#include <vector>
//#include <climits>
//#include <cstring>
//#include <cstdlib>
//#include <fstream>
//#include <numeric>
//#include <sstream>
//#include <iomanip>
//#include <iostream>
//#include <algorithm>
//#include <unordered_map>

using namespace std;

#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.141592653589793238462643383279502884
#define MAX 1000100
#define mod 1000000007
#define EPS 1E-9
#define int long long
#define endl "\n"

int fix(int cur, int m)
{
    return ((cur%m) + m) % m;
}

int fast_power(int x, int y,int m)
{
    if (y == 0)
        return 1;
    int temp = fast_power(x, y / 2, m) ;
    temp = (temp*temp)% m;
    if (y % 2 != 0)
        temp = (temp*x)% m;
    return temp;

}


int32_t main()
{
    //freopen("D:/Important Files/Cocktail/SOLVE/TestLib/testcases/input/input11.txt", "r", stdin);
   // freopen("D:/Important Files/Cocktail/SOLVE/TestLib/testcases/output/output11.txt", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.tie(0);

    int n;
    string s;
    cin >> n;
    map<string,int>mp;
    int mx=INT_MIN;
    for(int i=0;i<n;i++)
    {
        cin >> s;
        mp[s]++;
        mx=max(mx,mp[s]);
    }
    set<string>st;
    map<string,int>::iterator itr;
    for(itr=mp.begin();itr!=mp.end();itr++)
    {
        if(itr->second == mx)
        {
            st.insert(itr->first);
        }
    }
    set<string>::iterator it=st.begin();
    for(;it!=st.end();it++)
    {
        cout << *it << endl;
    }

    return 0;
}


Measured memory_bytes: 33280
import sys


def main():
    s = sorted(input())
    t = sorted(input())[::-1]

    for i, j in zip(s, t):
        if i == j:
            continue
        else:
            if ord(i) > ord(j):
                print('No')
                sys.exit(0)
            else:
                print('Yes')
                sys.exit(0)

    if len(s) < len(t):
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<math.h>
#include<map>
#include <unordered_map> 
#include<vector>
#include<queue>
#include<set>
#include <bits/stdc++.h> 
#include<string>
#define N 2005
#define K 200005
#define MOD 1e9+7
#define ll long long int
using namespace std;

int main(){
	ll n,k;
	cin>>n>>k;
	ll dp[k+1] = {0};
	dp[0] = 1;
	ll x;
	for(ll i=0;i<n;i++){	//implicitly keeps track of the number of the ppl who are there
		cin>>x;
		vector<int> fake(k+1);
		for(ll candies = k;candies>=0;candies--){
		    ll left = candies +1;
		    ll r = min(candies+x,k);
		    ll temp = dp[candies];
		    
		    if(left<=r ){
		    	fake[left] += temp;
		    	if(fake[left] >MOD)
		    	    fake[left] -=MOD;
		    	if(r<k)
		    	    fake[r+1] += -1*temp;
		    	if(fake[r+1] <0)
		    	    fake[r+1]+=MOD;
		    }
			/*for(lli =l;i <=r;i++){//adding a fixed value to some terms; which is dp[candies] and this value never gets changed as to change dp[candies] last should be ==0 which is not the case
				dp[i] +=dp[candies];
				if(dp[i] >=MOD)
					dp[i] -=MOD;
			}*/
		}
		ll prefix = 0;
		for(ll i=0;i<=k;i++){
			prefix+=fake[i];
			if(prefix >= MOD)
			    prefix-=MOD;
			dp[i]+=prefix;
			if(dp[i] >= MOD)
			    dp[i]-=MOD;
		}
	}
	/*
	cout<<dp[0]<<endl;
	cout<<dp[1]<<endl;
	cout<<dp[2]<<endl;
	cout<<dp[3]<<endl;
	cout<<dp[4]<<endl;
	*/
	cout<<dp[k];
}	


Measured memory_bytes: 1532
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;

#define LOCAL  1
#define UPLOAD 2

#define ll long long
const long long INF = 1LL << 60;

template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';

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 gcd(ll x,ll y){return y?gcd(y,x%y):x;}

const long long mod=1e9+7;
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
 
  ll N = input();
  vector<ll> a, b, c;
  for(int i=0;i<N;i++){
    a.push_back(input());
    b.push_back(input());
    c.push_back(input());
  }

  vector<vector<ll>> dp(N+1, vector<ll>(3, 0));
  dp[0][0] = 0;
  dp[0][1] = 0;
  dp[0][2] = 0;

  for(int i=0;i<N;i++){
    chmax(dp[i+1][0], max(dp[i][1], dp[i][2]) + a[i]);
    chmax(dp[i+1][1], max(dp[i][0], dp[i][2]) + b[i]);
    chmax(dp[i+1][2], max(dp[i][0], dp[i][1]) + c[i]);
  }

  output(max(max(dp[N][0], dp[N][1]), dp[N][2]));


  return 0;
}

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

using namespace std;

#define int long long 
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;

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

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    int x[100], y[100], h[100];
    int N;
    cin >> N;
    int tag;
    for(int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0) tag = i;
    }
    for(int i = 0; i <= 100; ++i) for(int j = 0; j <= 100; ++j) {
        int Hmax = h[tag] + abs(x[tag] - i) + abs(y[tag] - j);
        bool success = true;
        for(int n = 0; n < N; ++n) {
            int H = max(Hmax - abs(x[n] - i) - abs(y[n] - j), 0LL);
            if(H != h[n]) {
                success = false;
                break;
            }
        }
        if(success) {
            cout << i << " " << j << " " << Hmax << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
class Cube{
    public:
    int f[6];
    Cube (){}
    void roll_z(){roll(1,2,4,3);}
    void roll_y(){roll(0,2,5,3);}
    void roll_x(){roll(0,1,5,4);}
    void roll(int i,int j,int k,int l){
        int t=f[i];f[i]=f[j];f[j]=f[k];f[k]=f[l];f[l]=t;
    }
};
bool eq(Cube c1,Cube c2){
    for(int i=0;i<6;i++){
        if(c1.f[i]!=c2.f[i])return false;
    }
    return true;
}

bool equal(Cube c1,Cube c2){
    for(int i=0;i<6;i++){
        for(int j=0;j<6;j++){
            if(eq(c1,c2))return true;
            c1.roll_z();
        }
        if(i%2==0)c1.roll_y();
        else c1.roll_x();
    }
    return false;
}

Cube C[100];
int n;
bool check(){
    for(int i=0;i<n-1;i++)
        for(int j=i+1;j<n;j++)if(equal(C[i],C[j]))return false;
    return true;
}
int main(){
    cin>>n;
    for(int j=0;j<n;j++){
        for(int i=0;i<6;i++)cin>>C[j].f[i];
    }
    if(check())cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3104
/*
  Contest 067
  A - Sharing Cookies
  Rakesh Kumar --> 01/09/2020
 */

#include <bits/stdc++.h>

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

    int a = 0, b = 0;
    std::cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
        std::cout << "Possible" << std::endl;
    else
        std::cout << "Impossible" << std::endl;

    return 0;
}


Measured memory_bytes: 3476
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    long double p[n+1];
    p[0]=0.0;
    for(int i=1;i<=n;i++){
        cin>>p[i];
    }
    vector<vector<long double>> dp(n+1,vector<long double> (n+1,0.0));
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(j==0){
                dp[i][0]=dp[i-1][0]*(1.0-p[i]);
            }
            else{
                dp[i][j]=dp[i-1][j]*(1.0-p[i])+dp[i-1][j-1]*p[i];
            }
        }
    }
    long double ans=0.0;
    for(int j=(n+1)/2;j<=n;j++){
        ans+=dp[n][j];
    }
    cout<<setprecision(10)<<ans;
    return 0;
}

Measured memory_bytes: 141056
"""
https://www.planeta.tokyo/entry/5195/
"""
def cmb(n, r, p=10**9+7):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10**9+7
n = 2*10**5+1  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, n + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


N,k = map(int,input().split())

##移動が起きたとして,部屋にいる人数は高々min(N,k)人である

ans = 0
mod = 10**9 + 7
for i in range(1,min(N,k)+1):
    ans += cmb(N,i)*cmb(N-1,i)

print(ans%mod+1)

Measured memory_bytes: 29088
#include <stdlib.h>

int main()
{
	int W, H;
	int x, y, r;

	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
	W -= r, H -= r;
	if (r <= x && x <= W && r <= y && y <= H) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 2104
// inputに入力データ全体が入る
function Main(input) {
	input = input.split("\n");
	tmp = input[0].split(" ");

	var n = parseInt(tmp[0], 10);
	var x = parseInt(tmp[1], 10);
	var y = parseInt(tmp[2], 10);
	var max = Math.min(x, y);
	var min = (x + y) -n;
	if(min < 0) {
		min = 0;
	}
	//出力
	console.log('%d %d',max,min);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;

int main() {
  int a, b;
  cin >> a >> b;
  if (b % a == 0) cout << a + b << endl;
  else cout << b - a << endl;
}



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

int main(int argc, const char * argv[]) {
    long long num[5] = {};
    long long ans = 0;
    int n;
    string name;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> name;
        switch (name[0]) {
            case 'M':
                num[0]++;
                break;
            case 'A':
                num[1]++;
                break;
            case 'R':
                num[2]++;
                break;
            case 'C':
                num[3]++;
                break;
            case 'H':
                num[4]++;
                break;
            default:
                break;
        }
    }
    ans += num[0] * num[1] * num[2];
    ans += num[0] * num[1] * num[3];
    ans += num[0] * num[1] * num[4];
    ans += num[0] * num[2] * num[3];
    ans += num[0] * num[2] * num[4];
    ans += num[0] * num[3] * num[4];
    ans += num[1] * num[2] * num[3];
    ans += num[1] * num[2] * num[4];
    ans += num[1] * num[3] * num[4];
    ans += num[2] * num[3] * num[4];
    
    cout << ans;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=15;
char s[maxn][maxn];
int t[maxn][30],mp[maxn][maxn],n,m,vis[maxn],vis1[maxn];
int a[maxn];
inline bool check(int x,int y){
	REP(i,1,n) if(s[a[i]][x]!=s[a[n-i+1]][y]) return 0;
	return 1;
}
void dfs2(int x){
	if(x>m/2){
		REP(i,1,m) if(!vis1[i]) if(!check(i,i)) return;
		printf("YES\n");
		exit(0);
	}
	REP(i,1,m) if(!vis1[i]) REP(j,i+1,m) if(!vis1[j]) if(check(i,j)){
		vis1[i]=vis1[j]=1;
		dfs2(x+1);
		vis1[i]=vis1[j]=0;
	}
}
void dfs1(int x){
	if(x>n/2){
		REP(i,1,n) if(!vis[i]) a[x]=i;
		dfs2(1);
		return;
	}
	REP(i,1,n) if(!vis[i]) REP(j,i+1,n) if(!vis[j] && mp[i][j]){
		vis[i]=vis[j]=1;
		a[x]=i,a[n-x+1]=j;
		dfs1(x+1);
		vis[i]=vis[j]=0;
	}
}
int main(){
	n=read(),m=read();
	REP(i,1,n) scanf("%s",s[i]+1);
	REP(i,1,n) REP(j,1,m) t[i][s[i][j]-'a']++;
	REP(i,1,n) REP(j,i+1,n){
		mp[i][j]=1;
		REP(k,0,25) mp[i][j]&=(t[i][k]==t[j][k]);
	}
	dfs1(1);
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c;

    cin >> a >> b >> c;
    if (a == 5 && b == 5 && c == 7 ||
        a == 5 && b == 7 && c == 5 ||
        a == 7 && b == 5 && c == 5)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

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

//#define DEBUG 1
#define TRAIN_NUMBER 30
 
int push(int array[TRAIN_NUMBER], int num, int count);
int pop(int array[TRAIN_NUMBER], int ans[TRAIN_NUMBER], int count, int *ans_c);

main()
{
	int train[TRAIN_NUMBER];
	int ans[TRAIN_NUMBER];
	int count = 0;
	int ans_c = 0;
	int input;
	int i;
	
	for(i = 0; i < TRAIN_NUMBER; i++)
	{
		train[i] = '\0';
		ans[i] = '\0';
	}	
	while (scanf("%d", &input) != EOF)
	{	
		
		if(input != 0)
		{
			count = push(train, input, count);
		}
		else
		{
			count = pop(train, ans, count, &ans_c);
		}
	}
	
	for(i = 0; i < ans_c; i++)
	{
		printf("%d\n",ans[i]);
	}

	return 0;
}

int push(int array[TRAIN_NUMBER], int num, int count)
{
	
	array[count] = num;
#ifdef DEBUG
	printf("array: %d\n", count);
#endif
	return ++count;
	
}

int pop(int array[TRAIN_NUMBER], int ans[TRAIN_NUMBER], int count, int *ans_c)
{
	count--;
	ans[*ans_c] = array[count];
	*ans_c = *ans_c + 1;
	return count;

}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

vector<int>z_algorithm(const string &s){
	vector<int>prefix(s.size());
	for(int i=1,j=0;i<s.size();++i){
		if(i+prefix[i-j]<j+prefix[j]){
			prefix[i]=prefix[i-j];
		}
		else {
			int k=max(0,j+prefix[j]-i);
			while(i+k<s.size()&&s[k]==s[i+k])++k;
			prefix[i]=k;
			j=i;
		}
	}
	prefix[0]=(int)s.size();
	return prefix;
}
void solve(){
	int n;
	string s;
	cin>>n>>s;
	int ans=0;
	rep(i,n){
		string t=s.substr(i,n-i);
		vector<int>prefix=z_algorithm(t);
		rep(j,n-i){
			ans=max(ans,min(prefix[j],j));
			//l1+len<=l2よりl1=i,len=prefix[j],l2=i+j,よってprefix[j]<=j
		}
	}
	cout<<ans<<endl;
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,m,day=0,sw=0;
  cin>>n>>m;
  for(int i=1;i<=m;i++){
    int am;
    cin>>am;
    day+=am;
    if(day<=n){
      continue;
    }
    else{
      cout<<"-1"<<endl;
      sw=1;
      break;
    }
  }
  if(sw==0){
    cout<<n-day<<endl;
  }
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int m=1e9+7;
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    fastio
    int n;
    cin>>n;
    cout<<pow(n,1)+pow(n,2)+pow(n,3);
	return 0;
}

Measured memory_bytes: 4236
import re
from collections import deque

N,K = list(map(int, input().split()))
S = input()

token = re.findall(r'(L+|R+)', S)

def flip(s):
    if s[0] == 'R':
        return 'L'*len(s)
    else:
        return 'R'*len(s)
    
even = False
flipped_token = deque([])

flip_count = 0
for s in token:
    if flip_count >= K:
        flipped_token.append(s)
    else:
        if even:
            s = flip(s)
            flip_count += 1
            flipped_token.append(s)
            even = False
        else:
            flipped_token.append(s)
            even = True

flipped_S = ''.join(flipped_token)
        
token = re.findall(r'(L+|R+)', flipped_S)

happy_count = 0

for s in token:
    l = len(s)
    happy_count += l-1

print(happy_count)


Measured memory_bytes: 67164
from itertools import permutations

A = [int(input()) for _ in range(5)]

MIN=10**9
for p in permutations(A):
  SUM=0
  for i in range(5):
    if i < 4:
      SUM += (p[i]+10-1)//10*10
    if i == 4:
      SUM += p[i]
  if SUM < MIN:
    MIN = SUM
    
print(MIN)

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

typedef long long LL;
typedef pair<LL,int> pli;

const int N = 1e5;

int n;
pli P[N+5];

int find_par(int x, int *par){
	if(par[x] == x) return x;
	return par[x] = find_par(par[x],par);
}

int L[N+5],R[N+5];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&P[i].first);
	for(int i=1;i<=n;i++) P[i].second = i, L[i] = i, R[i] = i;
//	L[n+1] = R[n+1] = n+1;
	sort(P+1,P+n+1);
	LL ans = 0LL;
	for(int ii=1;ii<=n;ii++){
		int i = P[ii].second;
		L[i] = L[i-1];
		R[i] = R[i+1];
		int kanan = find_par(i,R);
		int kiri = find_par(i,L);
		int kanan2 = find_par((kanan==0)?0:kanan+1,R);
		int kiri2 = find_par((kiri==0)?0:kiri-1,L);
//		cout << kiri2 << " , " << kiri << " DAN " << kanan << " , " << kanan2 << endl;
		if(kanan == 0) kanan = n+1;
		if(kanan2 == 0) kanan2 = n+1;
		LL tmp = (kanan2-kanan)*(i-kiri);
		tmp+= (kiri-kiri2)*(kanan-i);
		ans+=tmp*(LL)ii;
//		cout << tmp << " " << ii << endl;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define SC scanf
#define PR printf
#define pb push_back
#define mp make_pair
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define db double
#define ldb long double
#define uint unsigned
#define ll long long
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef pair<pii,pii> ppp;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef map<int,int> mii;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const int xx[4]={1,-1,0,0};
const int yy[4]={0,0,1,-1};
int inline nextin(){
	int t;
	if(scanf("%d",&t)!=1)exit(0);
	return t;
}
int inline in(){
	int x=0,c;
	for(;(uint)((c=getchar())-'0')>=10;){
		if(c=='-')return -in();
		if(!~c)throw ~0;
	}
	do{
		x=(x<<3)+(x<<1)+(c-'0');
	}while((uint)((c=getchar())-'0')<10);
	return x;
}
string a[105];
int main(){
    cin.sync_with_stdio(false);cin.tie(0);
	int N,L;
	cin>>N>>L;
	rep(i,N)cin>>a[i];
	sort(a,a+N);
	rep(i,N)cout<<a[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
#include<numeric>
using namespace std;
typedef long long ll;
//ll mod = 1e9+7;
ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    vector<ll> a_accum(n);
    rep(i, n) {
        if ( i == 0 ) {
            a_accum[0] = a[0];
        }
        else {
            a_accum[i] = a[i] + a_accum[i-1];
        }
    }
    vector<pair<ll, int>> vbc(m);
    rep(i, m) {
        int b;
        ll c;
        cin >> b >> c;
        vbc[i] = make_pair(c, b);
    }
    sort(vbc.begin(), vbc.end());
    reverse(vbc.begin(), vbc.end());
    ll ans = 0;
    int replace_idx = 0;
    rep(i, m) {
        int itr = distance(a.begin(), lower_bound(a.begin(), a.end(), vbc[i].first));
        int num_sel = min(max(0, itr - replace_idx), vbc[i].second);
        if ( num_sel > 0 ) {
            ans += num_sel * vbc[i].first;
        }
        replace_idx += num_sel;
    }
    if ( replace_idx < 1 ) {
        cout << a_accum[n-1] << endl;
    }
    else {
        cout << ans + a_accum[n-1] - a_accum[replace_idx-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3328
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define N  100005
ll n;
double p[N],dp[3000][3000];

int main()
{
	ios
	ll n,i,j,cnt;
	cin>>n;
	double p[n+1];
	for(i=1;i<=n;i++)
		cin>>p[i];
	dp[0][0]=1;
	for(i=1;i<=n;i++)
		dp[0][i]=(dp[0][i-1]*(1.0-p[i]));
	for(cnt=1;cnt<=n;cnt++){
		for(i=1;i<=n;i++){
			dp[cnt][i]=p[i]*dp[cnt-1][i-1]+(1-p[i])*dp[cnt][i-1];
		}
	}
	double ans=0.0;
	for(i=n/2+1;i<=n;i++)
		ans+=dp[i][n];
	cout<<setprecision(12)<<ans;
	return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int g[100][100];
int n;

bool used[100];
int ans;
void dfs(int now) {
  if (now == n) {
    int tmp = 0;
    REP(i,n) {
      if (!used[i]) continue;
      int mi = INF;
      REP(j,n) {
        if (!used[j] || i==j) continue;
        mi = min(mi, g[i][j]);
      }
      if (mi!=INF)
        tmp += mi;
    }
    ans = max(ans, tmp);
    return;
  }
  bool f = 1;
  REP(i,now) {
    if (used[i] && g[now][i]==0) {
      f = 0;
      break;
    }
  }
  if (f) {
    used[now] = 1;
    dfs(now+1);
    used[now] = 0;
  }
  dfs(now+1);
}

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

  REP(i,m) {
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    g[a][b] = c;
    g[b][a] = c;
  }
  dfs(0);
  cout << ans << endl;
}

Measured memory_bytes: 0
#include <iostream>

long long int arr[100010];

int main(){
    int n;
    long long int sum = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        long long int a;
        scanf("%lld", &a);
        sum += a;
        arr[a]++;
    }
    int q;
    scanf("%d", &q);
    for (int i = 0; i < q; i++)
    {
        long long int b, c;
        scanf("%lld %lld", &b, &c);
        sum += arr[b] * (c - b);
        arr[c] += arr[b];
        arr[b] = 0;
        printf("%lld\n", sum);
    }
}

Measured memory_bytes: 4500
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main()
{
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 cout.tie(NULL);
	 int n;
	 cin>>n;
	 string s;
	 cin>>s;
	 char str[n];
	 set<int>p[26];
	 for(int i=0;i<n;i++)
	 {
	 	str[i]=s[i];
	 	p[str[i]-'a'].emplace(i);
	 }
	 int q;
	 cin>>q;
	 while(q--)
	 {
	 	   int type;
	 	   cin>>type;
	 	   if(type==1)
	 	   {
	 	   	     int pos;
	 	   	     char c;
	 	   	     cin>>pos>>c;
	 	   	     pos--;
	 	   	     p[str[pos]-'a'].erase(pos);
	 	   	     p[c-'a'].emplace(pos);
	 	   	     str[pos]=c;
	 	   }
	 	   else
	 	   {
	 	   	    int l,r;
	 	   	    cin>>l>>r;
	 	   	    l--;
	 	   	    r--;
	 	   	    int res=0;
	 	   	    for(int i=0;i<26;i++)
	 	   	    {
	 	   	    	   auto it=p[i].lower_bound(l);
	 	   	    	   if(it!=p[i].end())
	 	   	    	   res+=(*it)<=r;
	 	   	    }
	 	   	    cout<<res<<endl;
	 	   }
	 }


}

Measured memory_bytes: 26780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 40;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int H,W; cin >> H >> W;
    if(H%3==0 || W%3==0) cout << 0 << endl;
    else{
        int h = H/3;
        int w = W/3;
        int c1 = max(h*W,max((H-h)*(W/2),(H-h)*(W-W/2)))
            -min(h*W,min((H-h)*(W/2),(H-h)*(W-W/2)));
        int c2 = max(w*H,max((W-w)*(H/2),(W-w)*(H-H/2)))
            -min(w*H,min((W-w)*(H/2),(W-w)*(H-H/2)));
        int c3 = H;
        int c4 = W;
        int c5 = max((h+1)*W,max((H-h-1)*(W/2),(H-h-1)*(W-W/2)))
            -min((h+1)*W,min((H-h-1)*(W/2),(H-h-1)*(W-W/2)));
        int c6 = max((w+1)*H,max((W-w-1)*(H/2),(W-w-1)*(H-H/2)))
            -min((w+1)*H,min((W-w-1)*(H/2),(W-w-1)*(H-H/2)));
        cout << min(min(min(c1,min(c2,min(c3,c4))),c5),c6) << endl;

    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N, K; cin >> N >> K;
	vector<ll> A(N);
	ll mx = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		mx = max(mx, A[i]);
	}

	if (K == 0)cout << mx << endl;
	else {
		ll L = 1, R = 1e10;
		while (L < R) {
			ll mid = (L + R) / 2, cnt = 0;
			for (int i = 0; i < N; i++) {
				cnt += (A[i] / mid);
				if (A[i] % mid == 0)cnt--;
			}
			if (cnt > K)L = mid + 1;
			else R = mid;
			//cout << "L=" << L << " R=" << R << endl;
		}
		cout << R << endl;
	}
}


Measured memory_bytes: 4796
import sys
L, A, B, M = map(int, input().split())
mod = M
sys.setrecursionlimit(pow(10, 8))

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, (y-1)//2)**2 * x % mod
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
def modinv(a):
    b, u, v = mod, 1, 0
    while b:
        t = a//b
        a, u = a-t*b, u-t*v
        a, b, u, v = b, a, v, u
    u %= mod
    return u
def div(a, b):
    return a * modinv(b) % mod

def G(n, i):
    if n == 1:
        return 1
    tn = n//2
    return (G(tn, i) * (1 + power(10, tn*i)) %mod + (n%2)*power(10, (n-1)*i)) % mod

def G2(n, i):
    if n ==0 :
        return 0
    if n == 1:
        return power(10, i) % mod
    tn = n//2
    X = G2(tn, i)
    I = power(10, tn*i)
    Y = (X*(I+1)%mod + mul(mul(tn, I), (G(tn+1, i)-1))%mod) %mod
    Y = Y + mul(n%2, mul(n, power(10, n*i)))
    return Y%mod


def f(a, b, n, i):
    if n == 0:
        return 0
    r = power(10, i)
    P = power(r,n)
    #aa = mul(a, div(P-1, r-1))
    aa = mul(a, G(n, i))
    bb2 = mul(b, div(r-n*P + (n-1)*P*r, mul(1-r, 1-r)))
    bb = mul(b, G2(n-1, i))
    #print(n-1, i, div(r-n*P + (n-1)*P*r, mul(1-r, 1-r)), G2(n-1, i))
    #print(bb, bb2)
    return (aa - bb) % mod

sl = A + (L-1) * B
t = 10
k = 0
ts = 0
ks = []
mk = 18
for i in range(mk):
    k = max(min((t-1),sl)-(A-B), 0) // B - ts
    #print(t, min(t, sl) - (A-B), -(-((min(t, sl) - (A-B))//B)))
    #k = -(-(min(t, sl) - (A-B)) // B) - 1 - ts
    ts += k
    ks.append(k)
    t *= 10
ti = 0
ti2 = 0
b = B
R = 0
for i in range(mk):
    i = mk - i
    n = ks[i-1]
    a = sl - ti2*b
    if n:
        R = (R + (f(a, b, n, i))*power(10, ti)) % mod
#        print(a, f(a,b,r,n))
#    print(a, b, r, n, R, ti)

    ti += i*n
    ti2 += n
print(R)
#$print(ks)


Measured memory_bytes: 110556
#include<iostream>
#include<algorithm>
#include<queue>
#include<tuple>
#include<cmath>

using namespace std;

typedef long long ll;
typedef tuple<int, int, int> T3;

const int vx[4] = { 0,1,0,-1 }, vy[4] = { 1, 0,-1,0 };

int H, W, K;
int field[800 + 10][800 + 10];
bool visited[800 + 10][800 + 10];

int nearest(int x, int y) {
	int ret = H * W;
	ret = min(ret, (int)ceil((double)x / K));
	ret = min(ret, (int)ceil((double)y / K));
	ret = min(ret, (int)ceil((double)(H - 1 - x) / K));
	ret = min(ret, (int)ceil((double)(W - 1 - y) / K));
	return ret;
}

int main() {
	cin >> H >> W >> K;
	int sx = 0, sy = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char c;
			cin >> c;
			if (c == '.')field[i][j] = 0;
			else if (c == '#')field[i][j] = 1;
			else field[i][j] = 2, sx = i, sy = j;
		}
	}

	int ans = H * W;
	queue<T3> q;
	q.push(make_tuple(sx, sy, 0));
	visited[sx][sy] = true;
	while (q.size()) {
		int x = get<0>(q.front()), y = get<1>(q.front()), length = get<2>(q.front());
		q.pop();

		if (x == 0 || y == 0 || x == H - 1 || y == W - 1)ans = min(ans, 1);
		else ans = min(ans, 1 + nearest(x, y));

		if (length == K)continue;

		for (int i = 0; i < 4; i++) {
			int nx = x + vx[i], ny = y + vy[i];
			if (nx < 0 || ny < 0 || nx >= H || ny >= W)continue;
			if (field[nx][ny] == 1 || visited[nx][ny])continue;
			visited[nx][ny] = true;
			q.push(make_tuple(nx, ny, length + 1));
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;

#define M 1777771

class Dictionary{
    private:
        vector<string> data;
        map<int, string> m;
    public:
        void insert(string str);
        void hash_Insert(string str);
        bool find(string str);
        bool hash_Find(string str);
        int get_Kay(string str);
        int hash_1(int kay);
        int hash_2(int kay);
};

int Dictionary::hash_1(int kay){ return kay%M; }
int Dictionary::hash_2(int kay){ return 1+(kay%(M-1)); }

int Dictionary::get_Kay(string str){
    int k = 0;
    REP(i, (int)str.length()){
        k += (int)str[i] * pow(5, i);
    }
    return k;
}

void Dictionary::insert(string str){
    if (!Dictionary::find(str)) data.PB(str);
}
void Dictionary::hash_Insert(string str){
    int i = 0;
    int hashed_Kay;
    int kay = get_Kay(str);
    while(true){
        hashed_Kay = hash_1(kay) + i*hash_2(kay);
        if(m[hashed_Kay] == "" or m[hashed_Kay] == str) break;
        i++;
    }
    m[hashed_Kay] = str;
}

bool Dictionary::find(string str){
    if(std::find(ALL(data), str) != data.end()) return true;
    else return false;
}
bool Dictionary::hash_Find(string str){
    int i = 0;
    int hashed_Kay;
    int kay = get_Kay(str);
    while(true){
        hashed_Kay = hash_1(kay) + i*hash_2(kay);
        if(m[hashed_Kay] == str) return true;
        else if(m[hashed_Kay].length() == 0) return false;
        i++;
    }
}

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

    int n;
    cin >> n;

    string op, word;
    Dictionary dic;

    REP(_, n){
        cin >> op >> word; 
        if (op[0] == 'i') dic.hash_Insert(word);
        else if(dic.hash_Find(word)) cout << "yes" << "\n";
        else cout << "no" << "\n";
    }  
}


Measured memory_bytes: 41280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int dp[100010];

int main() {
    dp[0] = 0;
    for(int i = 1; i <= 100000; i++){
        dp[i] = INF;
        int power = 1;
        while(power <= i){
            dp[i] = min(dp[i],dp[i-power]+1);
            power *= 6;
        }
        power = 1;
        while(power <= i){
            dp[i] = min(dp[i],dp[i-power]+1);
            power *= 9;
        }
    }
    int n; cin >> n;
    cout << dp[n] << endl;

    return 0;
}

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

const int N=3e3+100;
int n,a[N],f[N];
int head[N],ce;
struct edge{int to,nxt;} e[N<<1];

void lnk(int a,int b) {e[++ce]=(edge){b,head[a]}, head[a]=ce;}

void dfs(int u,int lst)
{
	f[u]=0;
	for(int i=head[u];i;i=e[i].nxt)
	{
		int v=e[i].to;
		if(v == lst) continue;dfs(v,u);
		if(!f[v] && a[u]>a[v]) f[u]=1;
	}
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	for(int i=1,u,v;i<n;++i)
		scanf("%d%d",&u,&v), lnk(u,v), lnk(v,u);
	for(int i=1;i<=n;++i)
	{
		dfs(i,0);
		if(f[i]) printf("%d ",i);
	}
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;

  if(a >= 13) {
    cout << b << endl;
  }else if(a >= 6 && a <= 13) {
    cout << b/2 << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 3568
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
vector<string> v;
int main()
{
	string s;cin>>s;
	int k,n=s.size();cin>>k;
	rep(i,n) REP(j,1,k+1){
		if(i+j<=n) v.pb(s.substr(i,j));
	}
	sort(All(v));
	v.erase(unique(All(v)),v.end());
	//rep(i,v.size()) cout<<v[i]<<endl;
	cout<<v[k-1]<<endl;
}


Measured memory_bytes: 1660
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from itertools import groupby

    N = int(readline())
    S = input()
    ans = 0
    for g in groupby(S):
        ans += 1

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 69072
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

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

ll Pow(ll n, ll k) {
	ll ans = 1, a = n % MOD;
	while (k > 0) {
		if (k & 1) {
			ans *= a;
			ans %= MOD;
		}
		a *= a;
		a %= MOD;
		k >>= 1;
	}
	return ans;
}

ll Inverse(ll a) {
	return Pow(a, MOD - 2);
}

//nCaを計算、a < 0 の時 0
ll Combi(ll n, ll a, vector<ll> & k) {
	a = min(a, n - a);
	if (a < 0)
		return 0;
	if (a == 0)
		return 1ll;
	ll ans = k[n] * Inverse(k[a]) % MOD;
	return ans * Inverse(k[n - a]) % MOD;
}

// d[n] = n! の配列初期化
void Ini_fact(vector<ll> & d) {
	d[1] = 1;
	for (ll i = 2; i < d.size(); i++)
		d[i] = d[i - 1] * i % MOD;
	return;
}

int main(void) {
	int num, i;
	ll ans = 0;
	cin >> num;
	vector<ll> kai(num);
	Ini_fact(kai);
	for (i = 1; 3 * i <= num; i++) {
		ll n = num - 3 * i;
		ll k = i - 1;
		ans += Combi(n + k, k, kai);
		ans %= MOD;
	}
	cout << ans << "\n";
	return 0;
}

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

string intTostring(int num){
  stringstream ss;
  ss<<num;
  return ss.str();
}

int mcxiToint(string str){
  int num=0;
  int loop=0;
  for(int i=(int)str.size()-1;i>=0;i--){
    if(str[i]=='i') loop=1;
    if(str[i]=='x') loop=10;
    if(str[i]=='c') loop=100;
    if(str[i]=='m') loop=1000;
    num+=loop;
    if('2'<=str[i] && str[i] <= '9'){
      num+=loop*(str[i]-'2');
    }
  }
  return num;
}

string intTomcxi(int num){
  string str="";
  if(num>=2000){
    str+=intTostring(num/1000)+"m";
    num=num%1000;
  }else if(num >=1000){
    str+="m";
    num=num%1000;
  }
  if(num>=200){
    str+=intTostring(num/100)+"c";
    num=num%100;
  }else if(num >=100){
    str+="c";
    num=num%100;
  }
  if(num>=20){
    str+=intTostring(num/10)+"x";
    num=num%10;
  }else if(num >=10){
    str+="x";
    num=num%10;
  }
  if(num>=2){
    str+=intTostring(num)+"i";
  }else if(num >=1){
    str+="i";
  }
  return str;

}

int main(){
  int n;
  cin>>n;
  while(n--){
    string s1,s2;
    cin>>s1>>s2;
    //    cout<<mcxiToint(s1)<<" "<<mcxiToint(s2)<<endl;
    cout<<intTomcxi(mcxiToint(s1)+mcxiToint(s2))<<endl;
  }
  return 0;
}

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

int main()
{
	int n;
	int v[101];
	long m[100][100];
	const long nil = 999999999;

	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> v[i] >> v[i + 1];

	for (int i = 0; i < 100; i++)
		for (int j = 0; j < 100; j++)
			if (i == j)
				m[i][j] = 0;
			else
				m[i][j] = nil;
	
	for(int i = n - 2; i > -1; i--)
		for(int j = i + 1; j < n; j++)
			for (int k = i; k < n; k++)
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + v[i] * v[k + 1] * v[j + 1]);

	cout << m[0][n - 1] << endl;

	return 0;
}


Measured memory_bytes: 3188
# C - Colorful Leaderboard
N = int(input())
a = list(map(int, input().split()))

lst = [0,0,0,0,0,0,0,0,0]

for i in range(N):
	for j in range(1,9):
		if a[i] < 400*j:
			lst[j-1] = 1
			break
	else:
		lst[8] += 1

if sum(lst[0:8]) == 0:
    min = 1
else:
    min = sum(lst[0:8])
max = sum(lst)

print(min,max)


Measured memory_bytes: 9140
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 105
#define MAXV 100005
#define INF 1000000000000000000LL
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll n,W,w[MAXN],v[MAXN];
ll dp[MAXN][MAXV];
int main()
{
    scanf("%lld%lld",&n,&W);
    ll s=0;
    for(ll i=1;i<=n;i++) 
    {
        scanf("%lld%lld",&w[i],&v[i]);
        s+=v[i];
    }
    for(ll i=0;i<=n;i++)
        for(ll j=0;j<=s;j++)
            dp[i][j]=INF;
    dp[0][0]=0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<=s;j++)
        {
            if(j<v[i]) dp[i][j]=dp[i-1][j];
            else dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
        }
    }
    for(ll j=s;j>=0;j--) if(dp[n][j]<=W) {printf("%lld\n",j); return 0;}
    return 0;
}



Measured memory_bytes: 80128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		String s = scan.next();

		int num = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '+') {
				num++;
			} else {
				num--;
			}
		}
		System.out.println(num);
	}

}


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

#define mp make_pair
#define pb push_back
#define repm(i, n, m)  for(int i = n; i < m; ++i)
#define Repm(i, n, m)  for(int i = n; i <= m; ++i)
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repn(i, n) repm(i, 1, n)
#define mod 1000000000+7

int culc(int n){
    int count = 0;
    while (n > 0){
        n/=10;
        count++;
    }
    return count;
}

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

    int ans = 0;
    Repm(i, 1, n){
        if(culc(i) % 2 == 1)    ans++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] a) {
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),i;
		long f=1;
		for(i=1;i<=n;i++)
			f=f*i;
		System.out.println(f);
	}
}

Measured memory_bytes: 12000
import sys
import socket

if socket.gethostname() == 'N551J':
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    if read_str().startswith('YAKI'):
        return 'Yes'
    return 'No'

def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


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

using namespace std;

#define int long long
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

#define PII pair<int, int>

#define ALL(v) v.begin(), v.end()

#ifdef DBG
#define _log(item) cout << #item << " = " << item << endl
#define _loga(array, val) cout << #array << "[" << val << "] = " << array[val] << endl
#else
#define _log(item)
#define _loga(array, val)
#endif

inline int gcd(int number1, int number2)
{
    int m = number1;
    int n = number2;
    if (number2 > number1) {
        m = number2;
        n = number1;
    }
    while (m != n) {
        int temp = n;
        n = m - n;
        m = temp;
    }
    return m;
}
inline int lcm(int number1, int number2)
{
    return number1 * number2 / gcd(number1, number2);
}

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



signed main()
{
    int sx, sy;
    int tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int m = tx - sx;
    int n = ty - sy;

    rep(i, m){
        cout << "R";
    }
    rep(i, n + 1){
        cout << "U";
    }
    rep(i, m + 1){
        cout << "L";
    }
    rep(i, n + 1){
        cout << "D";
    }
    cout << "R";
    cout << "D";
    rep(i, m + 1){
        cout << "R";
    }
    rep(i, n + 1){
        cout << "U";
    }
    rep(i, m + 1){
        cout << "L";
    }
    rep(i, n){
        cout << "D";
    }

    cout << endl;
}


Measured memory_bytes: 256
N = int(input())
job = []
for i in range(N):
    a, b = map(int, input().split())
    job.append([a, b])
#print(job)
job.sort(key=lambda x: x[1])
#print(job)
for i in range(1, N):
    job[i][0] += job[i - 1][0]
for i in range(N):
    if job[i][0] > job[i][1]:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 114036
from math import factorial


def solve(n, m):
    d = abs(n - m)
    if d > 1:
        return 0

    DIV = int(1e9 + 7)
    if d == 1:
        l = min(n, m)
        f = factorial(l) % DIV
        return f ** 2 * (l + 1) % DIV
    f = factorial(n) % DIV
    return f ** 2 * 2 % DIV


n, m = map(int, input().split())
print(solve(n, m))


Measured memory_bytes: 4088
N, M, Q = map(int, input().split())
a = [0] * Q
b = [0] * Q
c = [0] * Q
d = [0] * Q
for i in range(Q):
    a[i], b[i], c[i], d[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1


def score(A):
    tmp = 0
    for ai, bi, ci, di in zip(a, b, c, d):
        if A[bi] - A[ai] == ci:
            tmp += di
    return tmp


def dfs(A):
    if len(A) == N:
        return score(A)
    res = 0
    prev_last = A[-1] if len(A) > 0 else 0
    for v in range(prev_last, M):
        A.append(v)
        res = max(res, dfs(A))
        A.pop()
    return res

print(dfs([]))

Measured memory_bytes: 9172
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	int n, m;
	cin>>n>>m;
	rep(i, n /2+1) {
		if(i != 0) cout<<" ";
		cout<<0;
	}
	for(int i = n / 2+1; i < n; i++) cout<<" "<<m;
	cout<<endl;
}

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

class D {
    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int K = sc.nextInt();
        final int[] p = new int[N];
        Arrays.setAll(p, i -> sc.nextInt());
        final double[] e = new double[N];
        Arrays.setAll(e, i -> .5 * p[i] * (p[i] + 1) / p[i]);
        double sum = 0;
        for(int i = 0; i < K; i++)
            sum += e[i];
        double max = sum;
        for(int i = K; i < N; i++) {
            sum -= e[i - K];
            sum += e[i];
            max = Math.max(max, sum);
        }
        System.out.println(max);
    }
}
public class Main {
    public static void main(String... args) {
        D.main();
    }
}


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

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> s(100001, 0);
    for(int i=0; i<n; i++){
        int a, b;
        cin >> a >> b;
        s[a] += b;
    }
    int ans = 0;
    for(int i=1; i<100001; i++){
        if(k<=s[i]){
            ans = i;
            break;
        }
        k -= s[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int H = sc.nextInt();
      int W = sc.nextInt();
      int h = sc.nextInt();
      int w = sc.nextInt();

      int all = H*W;

      if(all-(h*W+(H-h)*w)<=0){
        System.out.println(0);
        System.exit(0);
      }
      System.out.println(all-(h*W+(H-h)*w));
  }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
bool tate[110],yoko[110];
int main() {
  ll h,w;
  cin>>h>>w;
  char c[110][110];
  for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>c[i][j];
  for(int i=0;i<h;i++){
    bool f=1;
    for(int j=0;j<w;j++){
      if(c[i][j]=='#')f=0;
    }
    if(f)yoko[i]=1;
  }
  for(int i=0;i<w;i++){
    bool f=1;
    for(int j=0;j<h;j++){
      if(c[j][i]=='#')f=0;
    }
    if(f)tate[i]=1;
  }
  for(int i=0;i<h;i++){
    if(yoko[i])continue;
    for(int j=0;j<w;j++){
    if(tate[j])continue;
    cout<<c[i][j];
    }
    cout<<endl;
  }
	return 0;
}


Measured memory_bytes: 256
import sys,math
def input():
    return sys.stdin.readline()[:-1]


a,b,x = map(int,input().split(' '))

t = x/(a**2)
half = b/2
if t<half:
    a_2 = ((x/a)/b)*2
    b_2 = b
else:
    a_2 = a
    b_2 = (b-t)*2
c = (a_2**2+b_2**2)**0.5
cos1 = ((a_2**2)+(c**2)-(b_2**2))/(2*a_2*c)
print(math.degrees(math.acos(cos1)))

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

int main()
{
    int a, b;
    cin >> a >> b;

    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
    {
        cout << "Possible" << endl;
    }
    else
    {
        cout << "Impossible" << endl;
    }
    
}

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

long long factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1) % 1000000007;
    } else {
        return 1;
    }
}

int main(){
  long long N, M;
  cin >> N >> M;
  if (N < M) swap(N, M);
  if(N-1 > M){
    cout << 0 << endl;
    return 0;
  }

  if(N-1 == M){
    cout << factorial(N)*factorial(M) % 1000000007 << endl;
  } else if(N==M){
    cout << (factorial(N)*factorial(M) % 1000000007)*2% 1000000007 << endl;
  }
}


Measured memory_bytes: 1792