akhauriyash/Code-Regression huggingface dataset:
while True:
    n = int(input())
    if not n:
        break

    star = [list(map(float, input().split())) for i in range(n)]
    start = [0.0, 0.0, 0.0]
    move = 0.5


    for _ in range(500):
        for j in range(100):
            tmpmax = 0
            a = 0
            for i in range(n):
                k = (star[i][0] - start[0]) ** 2 + (star[i][1] - start[1]) ** 2 + (star[i][2] - start[2]) ** 2
                if tmpmax < k:
                    tmpmax = k
                    a = i
            start = [start[i] - (start[i] - star[a][i]) * move for i in range(3)]
        move /= 2

    tmpmax = 0
    for i in range(n):
        k = (star[i][0] - start[0]) ** 2 + (star[i][1] - start[1]) ** 2 + (star[i][2] - start[2]) ** 2
        if tmpmax < k:
            tmpmax = k

    print(round(tmpmax ** 0.5, 5))



Measured memory_bytes: 5688
def main():
    cx1, cy1, r1 = map(int, input().split())
    cx2, cy2, r2 = map(int, input().split())
    d = pow((cx2 -cx1)**2 + (cy2 -cy1)**2, 0.5) 

    if d > r1 + r2:
        # 4(not cross)
        print("4")
    elif d == r1 + r2:
        # 3(circumscribed)
        print("3")
    elif abs(r1 - r2) < d and d < r1 + r2:
        # 2(intersec)
        print("2")
    elif d == abs(r1 - r2):
        # 1(inscribed)
        print("1")
    elif d < abs(r1 - r2):
        # 0(includes another)
        print("0")


if __name__=="__main__":
    main()



Measured memory_bytes: 5640
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	int n, m;
	cin >> n >> m;
	vi d(m), dp(n+1, INF);
	REP(i, m) {
		cin >> d[i];
	}
	dp[0] = 0;
	REP(i, m) {
		REP(j, n-d[i]+1) {
			dp[j+d[i]] = min(dp[j+d[i]], dp[j]+1);
		}
	}

	cout << dp[n] << endl;
}

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

using namespace std;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}init;

typedef long long LL;

template<typename T>void chmin(T &a,T b){a=min(a,b);}
template<typename T>void chmax(T &a,T b){a=max(a,b);}
template<typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

int main(){
    int N;cin>>N;
    LL res=0;
    LL min_cost=0;
    for(int i=0;i<N;i++){
        LL A;
        cin>>A;
        LL cnt=A/(min_cost+1);
        if(cnt*(min_cost+1)==A)
            cnt--;
        if(cnt==0)min_cost=max(min_cost,A);
        else{
            res+=cnt;
            min_cost=max(min_cost,1ll);
        }
        //cout<<res<<endl;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
const int N = 100001;

int main(){
    char c;
    cin>>c;
    if(c>='A'&&c<='Z')
        puts("A");
    else
        puts("a");
}



Measured memory_bytes: 3064
N = int(input())
ans = ""
i = 1
while N != 0:
    if N % (2 ** i) == 0:
        ans = "0" + ans
    else:
        ans = "1" + ans
        N -= ((-2) ** (i-1))
    i += 1
if len(ans) > 0:
    print(ans)
else:
    print(0)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int mx = 0, mn = 123;
	REP(i, 5) {
		int a;
		cin >> a;
		mn = min(mn, a);
		mx = max(mx, a);
	}
	int k;
	cin >> k;
	string res = ":(";
	if (mx - mn <= k) res = "Yay!";
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
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;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
int N;
ll L,A[100010] = {};
ll T[100010] = {};

int main(){
	cin >> N >> L;
	priority_queue<P> Q;
	for(int i=1;i<=N;i++){
		cin >> A[i];
		Q.push({A[i],i});
	}
	ll ans = 0;
	while(!Q.empty()){
		P p = Q.top(); Q.pop();
		int id = p.second;
		T[id] = max(T[id-1],T[id+1])+(L-A[id]);
		ans = max(ans,T[id]);
	}
	cout << ans << endl;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n); for(auto&&i:a)cin>>i;
	int mx=*max_element(a.begin(),a.end());
	int mx2=0;
	bool one=true;
	for(auto&&i:a){
		if(!one||i!=mx)mx2=max(mx2,i);
		if(i==mx)one=false;
	}
	for(auto&&i:a){
		if(i!=mx)cout<<mx;
		else cout<<mx2;
		cout<<"\n"s;
	}
}

Measured memory_bytes: 2432
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
using namespace std;


int main() {
  int s;
  cin >> s;
  int one = s / 1000;
  int two = (s / 100) % 10;
  int three = (s / 10) % 10;
  int four = (s % 10);

  int front = one * 10 + two;
  int back = three * 10 + four;

  if ((0 < front && front <= 12) && (12 < back || back == 0))
    cout << "MMYY" << endl;
  else if ((0 < back && back <= 12) && (12 < front || front == 0))
    cout << "YYMM" << endl;
  else if (front == 0 || back == 0 || (front > 12 && back > 12))
    cout << "NA" << endl;
  else
    cout << "AMBIGUOUS" << endl;
}


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

int main(){
    
    ll n; cin >> n;
    ll root = sqrt(n);
    ll res = 1e18;
    for(ll i = 1; i <= root; i++)
        if(n%i == 0)
            res = min(res, i-1 + n/i-1);
    cout << res << endl;
    
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m, n) for(int i = m-1; i < n; i++)
#define INF 2000000000
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
int main(){
    int n;
    int a;
    cin>>n;
    int ans=0;
    REP(i,n){
    cin>>a;
    if(a==ans+1) ans+=1;
    }
    if(ans!=0) cout<<n-ans<<endl;
    else cout<<-1<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <time.h>
#include <iostream>
#include <vector>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>

using namespace std;

string repl( string str, string a, string b ) {
	/*
		str??????a???b??????????????????
	*/
	vector< int > f( str.length(), 0 );
	for( int i = 0; i < (int)str.length(); i++ ) {
		if( str.find(a,i) == i ) {
			f[i] = 1;
			i += a.length() - 1;
			continue;
		}
	}
	string ret;
	for( int i = 0; i < (int)str.length(); i++ ) {
		if( f[i] ) {
			ret += b;
			i += a.length() - 1;
		} else {
			ret += str[i];
		}
	}
	return ret;
}

int solve() {
	int n;
	cin >> n;
	if( n == 0 ) return 1;
	vector< string > a(n), b(n);
	string c,d;
	set< string > st;

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

	cin >> c >> d;
	st.insert(c);


	queue< pair<string,int> > q;
	q.push( pair<string,int>( c, 0 ) );

	int ans = -1;
	while( !q.empty() ) {
		pair<string,int> p = q.front();
		if( p.first == d ) {
			ans = p.second;
			break;
		}
		q.pop();
		for( int i = 0; i < n; i++ ) {
			if( p.first.find( a[i] ) == string::npos ) continue;
			string nstr = repl( p.first, a[i], b[i] );
			int nsec = p.second + 1;
			if( st.find( nstr ) != st.end() ) continue;
			if( nstr.length() > d.length() ) continue;
			st.insert( nstr );
			q.push( pair<string,int>( nstr,nsec ) );
		}
	}

	cout << ans << endl;

	return 0;
}
     
int main(void){
	while(1){
		if( solve() ) break;
	}
    return 0;
}

Measured memory_bytes: 3412
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	string s; 
    cin >> s;
    int n = (int)s.size();
    int k;
    cin >> k;
    static int dp[330][330][330];
    rep(i, 330) {
        rep(j, 330) {
            rep(l, 330) {
                dp[i][j][l] = 0;
            }
        }
    }
    rep(i, n) {
        rep(j, n) {
            rep(l, k + 1) {
                chmax(dp[i + 1][j][l], dp[i][j][l]);
                chmax(dp[i][j + 1][l], dp[i][j][l]);
                chmax(dp[i + 1][j + 1][l + 1], dp[i][j][l] + 1);
                if(i <= n - 1 - j && s[i] == s[n - 1 - j]) {
                    chmax(dp[i + 1][j + 1][l], dp[i][j][l] + 1);
                }
            }
        }
    }
    int ans = 0;
    rep(i, n + 1) {
        rep(l, k + 1) {
            chmax(ans, dp[i][n + 1 - i][l] * 2 - 1);
            chmax(ans, dp[i][n - i][l] * 2);
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

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

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; }

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 998244353;

ll modpow( ll x, ll n ){
    if( n == 0 ){
        return 1;
    }else if( n % 2 == 0 ){
        ll h = modpow( x, n / 2 );
        return h * h % MOD;
    }else{
        return x * modpow( x, n - 1 ) % MOD;
    }
}

ll dp1[310][90010];
ll dp2[310][90010];

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

    int s = 0;
    vector<int> a( N );
    REP( i, N ){
        cin >> a[i];
        s += a[i];
    }

    dp1[0][0] = dp2[0][0] = 1;
    REP( i, N ){
        REP( j, s + 1 ){
            dp1[i + 1][j] += dp1[i][j] * 2;
            dp1[i + 1][j] %= MOD;
            dp2[i + 1][j] += dp2[i][j];
            dp2[i + 1][j] %= MOD;

            if( j - a[i] < 0 ) continue;

            dp1[i + 1][j] += dp1[i][j - a[i]];
            dp1[i + 1][j] %= MOD;
            dp2[i + 1][j] += dp2[i][j - a[i]];
            dp2[i + 1][j] %= MOD;
        }
    }

    ll ans = modpow( 3, N );
    REP( i, s + 1 ){
        if( 2 * i < s ) continue;

        ans -= dp1[N][i] * 3;
        ans %= MOD;
        if( ans < 0 ) ans += MOD;
    }

    if( s % 2 == 0 ){
        ans += dp2[N][s / 2] * 3;
        ans %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 425472
#include<iostream>

using namespace std;

int main()
{
    int a[101][101];

    int n,m;

    cin>>n>>m;

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

    for(int i=0;i<=m;i++)
    {
        a[n][i]=0;
        for(int j=0;j<n;j++)
        {
            a[n][i]+=a[j][i];
        }
    }


    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(j)
            {
                cout<<" ";
            }
            cout<<a[i][j];
        }
        cout<<endl;
    }


    return 0;
}



Measured memory_bytes: 3104
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    string a,b;
    cin >> a >> b;
    //処理
    //出力
    if((a[0]==b[2] && a[1]==b[1]) && a[2]==b[0]) cout << "YES" << ENT;
    else cout << "NO" << ENT;
    return 0;
}

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


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

int main() {
  int n, t, a;
  cin >> n >> t >> a;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  int b = 0;
  for (int i = 1; i < n; ++i) if (abs(t - h[i] * 0.006 - a) < abs(t - h[b] * 0.006 - a)) b = i;
  cout << b+1 << endl;
  return 0;
}

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

int main() {
  int K, N; cin >> K >> N;
  int A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  int max_dist = 0;
  for (int i = 0; i < N; i++) {
    int dist = A[(i+1) % N] - A[i];
    if (dist < 0) dist += K;
    max_dist = max(max_dist, dist);
  }
  cout << K - max_dist << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
const long long INF = 1LL << 62;
int main(){
	int n; cin >> n;
	long long h[n+2] = {};
	for (int i = 1; i < n+1; ++i){
		cin >> h[i];
	}
	long long cost[n+2] = {};
	for (int i = 0; i < n+2; ++i) cost[i] = INF;
		
	cost[1] = 0;

	for (int i = 1; i < n; ++i){
		
		cost[i+1] = min(cost[i+1], abs(h[i+1] - h[i]) + cost[i]);
		
		cost[i+2] = abs(h[i+2] - h[i]) + cost[i];
	}
	cout << cost[n] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#define INF 2100000000

using namespace std;

int main()
{
    int n,minn,maxn,a;
	cin >> n;
	maxn = -INF;
	minn = INF;
	for(int i = 1; i <= n; i++) {
		cin >> a;
		maxn = (a > maxn) ? a : maxn;
		minn = (a < minn) ? a : minn;
	}
	cout << maxn-minn;
    return 0;
}


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

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define NCK_MAX 510000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S secon

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.PB(i);
      if(i * i != n) ret.PB(n / i);
    }
  }
  sort(ALL(ret));
  return (ret);
}

int main(int argc, char const *argv[]) {
  ll n; std::cin >> n;
  std::vector<ll> yakusu = divisor(n);
  ll size = SIZE(yakusu);
  if (size % 2 == 1) std::cout << 2 * yakusu[size/2]  - 2 << '\n';
  else std::cout << yakusu[size/2-1] + yakusu[size/2] - 2 << '\n';
  return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))
from itertools import product, combinations

def main():
    N = int(input())
    adj = [inpl() for _ in range(N)]
    need = [[True]*N for _ in range(N)]
    ok = True
    res = 0
    for k, i, j in product(range(N), repeat=3):
        if adj[i][j] < adj[i][k] + adj[k][j]:
            continue
        elif i == k or j == k:
            continue
        elif adj[i][j] == adj[i][k] + adj[k][j]:
            need[i][j] = False
            need[j][i] = False
        else:
            ok = False
    if ok:
        for i, j in combinations(range(N), 2):
            if need[i][j]:
                res += adj[i][j]
        print(res)
    else:
        print(-1)

main()

Measured memory_bytes: 49372
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2")
#pragma GCC optimize ("trapv")
 
 
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);
//#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define rep(i, a, b) for(lli i = a; i < (b); ++i)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()
#define what_is(x) cerr << #x << " is " << x << endl;
#define wis cout<<endl<<"I already speak english, bitch"<<endl<<endl;
 
typedef long long int lli;
typedef vector<lli> vi;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef pair<ii,lli> iii;
 
#define trace(args...) { string  _s =#args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
void err(istream_iterator<string> it){}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args){
    cout <<  *it  << " : " << a << endl;
    err(++it, args...);
}


const int N=2*1e5+10;
lli pre[N];

bool check1(int i,int j,int k,int n){
	return abs(pre[i]-pre[j+1]-pre[j+1])<=abs(pre[i]-pre[j]-pre[j]);
}
bool check2(int i,int j,int k,int n){
	return abs(pre[n]-pre[k+1]-pre[k+1]+pre[i])<=abs(pre[n]-pre[k]-pre[k]+pre[i]);
}

int main(){
	lli n; cin>>n;
	vi v(n+10);
	rep(i,1,n+1){
		lli foo;
		cin>>foo;
		pre[i]=pre[i-1]+foo;
		//cout<<i<<" -> "<<pre[i]<<endl;
	}//cout<<endl<<endl;
	lli wyn=2e16+100;
	lli j=1,k=3;//suml=0,sumr=0;
	for(int i=2;i<n;i++){
	//	trace(k,n,i,j);
		while(check1(i,j,k,n) and j<i) j++;
		while(check2(i,j,k,n) and k<n)k++;
	//	trace(k,n,i,j);
		lli B=pre[j],C=pre[i]-B,D=pre[k]-pre[i],E=pre[n]-pre[k];
		//wyn=min({wyn,B,C,D,E});
		vi asd={B,C,D,E};
		sort(all(asd));
		wyn=min(wyn,asd[sz(asd)-1]-asd[0]);
		//lli mini=min({B,C,D,E}),maxi=max({B,C,D,E});
	//	wyn=min(wyn,maxi-mini);
	}
	cout<<wyn<<endl;
	return 0;
}

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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int N;
  cin >> N;
  int sn = 0;
  int n = N;
  while(n > 0){
    sn += n % 10;
    n /= 10;
  }
  if(N % sn == 0) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}

Measured memory_bytes: 3632
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

module ModOp = struct
  let prime = 1_000_000_007
  let (-) a b = (a + prime - b) mod prime
  let (+) a b = (a + b) mod prime
  let ( * ) a b = (a * b) mod prime

  let rec pow x n =
    if n = 0 then 1
    else if n mod 2 = 0 then pow (x*x) (n/2)
    else x * pow (x*x) (n/2)
end

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let (s, w) = scan "%d %d" Tuple2.make

let () =
  if w >= s then Printf.printf "unsafe\n"
  else Printf.printf "safe\n"


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

int main(){
  string s;
  cin>>s;
  int m=s.size();
  int ans;
  for(int i=1;i<m;i++){
    string t=s;
    t.erase(m-i,i);
    if(t.size()%2==1) continue;
    int k=t.size();
    string u=t.substr(0,k/2);
    string v=t.substr(k/2,k/2);
    if(u==v){
      ans=k;
      break;
    }
  }
  cout<<ans<<endl;
}

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

bool check(const vector<int> &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (v[i] != 0)
        {
            return true;
        }
    }
    
    return false;
}

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

    vector<int> h(N);
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    
    int ans = 0, left, right, min_h;
    while(check(h))
    {
        for (int i = 0; i < N; i++)
        {
            if (h[i] != 0)
            {
                left = i;
                break;
            }
        }
        
        for (int i = left; i < N; i++)
        {
            if (h[i] == 0)
            {
                right = i;
                break;
            }

            if (i + 1 == N)
            {
                right = N;
            }
        }
        
        min_h = *min_element(h.begin() + left, h.begin() + right);

        for (int i = left; i < right; i++)
        {
            h[i] -= min_h;
        }

        ans += min_h;
    }

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

Measured memory_bytes: 256
// Remember...

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn=2e5+10,mod=1e9+7;
const ll inf=1e18;

int dp[maxn][3];
string s;

bool ok(int st,int x,int y){
    if(x!=y) return 1;
    for(int i=0;i<x;i++)
	if(s[st+i] != s[st+x+i]) return 1;
    return 0;
}

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

    cin>>s;
    int n=sz(s);
    for(int i=0;i<n;i++){
	for(int j=1;j<=3;j++){
	    dp[i+1][j-1]=1;
	    for(int k=1;k<=3;k++){
		if(j+k>i+1) continue;
		if(ok(i+1-j-k,j,k)) dp[i+1][j-1]= max(dp[i+1][j-1], dp[i+1-j][k-1]+1);
			       
	    }
	}
    }   
    return cout<<max(dp[n][0], max(dp[n][1],dp[n][2]) )<<endl,0;
}
// Deathly mistakes:
//  * Read the problem carefully.
//  * Check maxn.
//  * Overflows.


// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


Measured memory_bytes: 2964
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

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

    return 0;
}



Measured memory_bytes: 3968
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()

p = list(map(int, input().split()))

exist = [False] * 102
for pi in p:
  exist[pi] = True
  
minabs = X
ans = 0
for i in range(102):
  if exist[i]:
    continue
  if abs(X-i) < minabs:
    ans = i
    minabs = abs(X-i)
    
print(ans)


Measured memory_bytes: 9192
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){
  char c;
  cin >> c;
  if('A' <= c && c <= 'Z'){
    cout << 'A' << endl;
  }else{
    cout << 'a' << endl;
  }
  return 0;
}


Measured memory_bytes: 3612
n = int(input())
a = list(map(int, input().split()))
s = 0

for i in a:
    if i % 2 == 0:
        if i % 3 == 0:
            pass
        elif i % 5 == 0:
            pass
        else:
            s = 1
            print('DENIED')
            break
if s != 1:
    print('APPROVED')

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>       // printf,scanf
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>  //sort,binarySearch
#include <functional> 
#include <iomanip>    // setprecision
#include <utility>    // c+11 Array
#include <set>
#include <sstream>
#include <map>
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238462643383279
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define pb(x) push_back(x)
#define debug(x) cout << #x << " = " << x << endl;
#define debret(x) debug(x) ; return 0;

using namespace std;

int main(void){

    set<int> st;

    int a,b,c;;
    
    cin >> a >> b >> c;

    st.insert(a);
    st.insert(b);
    st.insert(c);
    
    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s;
    cin >> s;
  	int count=0;
	int flag=0;
    int roopcount=0;
    reverse(s.begin(), s.end()); 
	for(int i = 0; i < s.size(); i++) {
	     if(s.at(i)=='m' && s.at(i+1)=='a' && s.at(i+2)=='e' && s.at(i+3)=='r' && s.at(i+4)=='d'){
          i +=4;
	  count +=1;
	  flag =1;
//	cout << i << endl;
        }  	
        else if(s.at(i)=='r' && s.at(i+1)=='e' && s.at(i+2)=='m' && s.at(i+3)=='a' && s.at(i+4)=='e' && s.at(i+5)=='r' && s.at(i+6)=='d'){
	  i +=6;
	  count +=1;
	  flag =1;
//	cout << i << endl;
	}
	else if(s.at(i)=='e' && s.at(i+1)=='s' && s.at(i+2)=='a' && s.at(i+3)=='r' && s.at(i+4)=='e'){
	  i +=4;
	  count +=1;
	  flag =1;
//	cout << 1000 << endl;
	}
        else if(s.at(i)=='r' && s.at(i+1)=='e' && s.at(i+2)=='s' && s.at(i+3)=='a' && s.at(i+4)=='r' && s.at(i+5)=='e'){
	  i +=5;
	  count +=1;
	  flag =1;
//	cout << i << endl;
	}
	else{
	flag=0;
	i = s.size();
//	cout << i << endl;
	}
//      roopcount++;
}
//	cout << flag << endl;
//	cout << count << endl;
//  	cout << roopcount <<endl;

	if(flag==1) cout << "YES" << endl;
	if(flag==0) cout << "NO"  << endl;
}
	


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mod 1000000007;

using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> v(N);

    for(auto &i : v)
        cin >> i;

    double y = accumulate(v.begin(),v.end(),0.0) / v.size();
    y = round(y);
    int res = 0;
    for(int i = 0 ; i < N; i++)
    {
       res += (v[i]-y) * (v[i]-y);
    }

    cout << res;
}



Measured memory_bytes: 256
#include<stdio.h>
    int main(){
        int A, B, C;
        scanf("%d %d %d", &A, &B, &C);
            //if(B >= A){B = A;}
        int D = C - (A - B);
        if(D>0){printf("%d", D);}
      else{printf("0");}
        return 0;

    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
#define rep(i,n) for(int i = 0;i<n;i++)

int main(){
	int n;
	cin >> n;
	if(n%10 == 2 || n%10 == 4 || n%10 == 5||n%10 == 7||n%10==9)cout << "hon\n";
	else if(n%10 == 3)cout << "bon\n";
	else cout << "pon\n";

	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll a[100005],d[100005];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll N;
    cin>>N;
    ll i;
    for(i=0;i<N;i++)
    {  cin>>a[i]; }
    d[0]=0; d[1]=abs(a[1]-a[0]);
    for(i=2;i<N;i++)
    {  d[i]=min(d[i-2]+abs(a[i]-a[i-2]),d[i-1]+abs(a[i]-a[i-1])); }
    cout<<d[N-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
typedef long long ll;

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

using namespace std;

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

    vector<int> v(n, 0);

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

    for(int p = 0; p <= min(k, n); p++) {
        for(int q = 0; q <= min(k, n) - p; q++) {
            ll sum = 0;
            vector<ll> select;

            for(int i = 0; i < p; i++){
                select.push_back(v[i]);
                sum += v[i];
            }
            for(int i = 0; i < q; i++){
                select.push_back(v[n-1-i]);
                sum += v[n-1-i];
            }

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

            for(int i = 0; i < min(k - p - q, (int)select.size()); i++) {
                if(select[i] < 0) sum += -select[i];
            }
            ans = max(sum, ans);
        }
    }
    cout << ans << endl;
    return 0;
}

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

struct Node {
    int key;
    Node *parent, *right, *left;
    public:
    Node(Node *r, Node *l, Node *p, int k) : right(r), left(l), parent(p), key(k) {};
};

Node *root, *NIL;

void insert(int key) {
    Node *z = new Node(NIL, NIL, NIL, key);
    Node *y = NIL;
    Node *x = root;
    while (x != 0) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        }
        else {
            x = x->right;
        }
    }
    z->parent = y;
    if (y == NIL) {
        root = z;
    }
    else if (z->key < y->key) {
        y->left = z;
    }
    else {
        y->right = z;
    }
    return;
}

Node* find(Node *u,int key){
    while(u != NIL && key != (u->key)){
        if(key < (u->key)) u = u->left;
        else u = u->right;
    }
    return u;
}

void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);
    return;
}

void preorder(Node *u) {
    if (u == NIL)return;
    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
    return;
}

void print(Node *u) {
    inorder(root);
    cout << endl;
    preorder(root);
    cout << endl;
    return;
}

int main() {
    int n,key;
    string order;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> order;
        if (order == "insert") {
            cin >> key;
            insert(key);
        }
        else if (order == "print") {
            print(root);
        }
        else if (order == "find"){
            cin >> key;
            if (find(root, key) != NIL) cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 19960
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

bool issafe(int x,int y,int n,int m){
  return (x>=0 && y>=0 && x<n && y<m);
}
ll lcm(ll a,ll b){
    return (a%hell*modinv(gcd(a,b))%hell)%hell*(b%hell);
}


void solve(){
  int test;
  //cin>>test;
  test=1;
  
  while(test--){
        int n;
        cin>>n;
        
        int a[2*n];
        forn(i,0,2*n)
        cin>>a[i];
        
        sort(a,a+2*n);
        int ans=0;
        
        for(int i=0;i<2*n;i+=2)
        ans+=a[i];
        
        cout<<ans;
  }    
}    

    




///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}


Measured memory_bytes: 256
w1, w2, s1, s2, sp, l = map(int, input().split())
w1 *= 100
w2 *= 100

ws = set()
for i1 in range(l // w1 + 1):
    for i2 in range(l // w2 + 1):
        if i1 * w1 + i2 * w2 <= l:
            ws.add(i1 * w1 + i2 * w2)


ss = set()
for i1 in range((l * sp // 100) // s1 + 1):
    for i2 in range((l * sp // 100) // s2 + 1):
        if i1 * s1 + i2 * s2 <= l * sp / 100:
            ss.add(i1 * s1 + i2 * s2)


maxd, maxws, maxs = 0, 0, 0
for w in ws:
    for s in ss:
        if w + s > l or w == 0 or s > w * sp / 100:
            continue

        d = s / (w + s)
        if d >= maxd:
            maxd = d
            maxws = w + s
            maxs = s

print(maxws, maxs)


Measured memory_bytes: 3188
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <vector>

using namespace std;

using int64 = long long;

bool dp1[5050][5050];
bool dp2[5050][5050];

template<class T> inline void fastin(T &num) {
  T c;
  num = 0;
  c = getchar_unlocked();
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
}

int main() {
  int n, k; fastin(n); fastin(k);
  int a[n];
  for (int i = 0; i < n; ++i) fastin(a[i]);

  dp1[0][0] = 1;

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= k; ++j) {
      if (dp1[i][j]) dp1[i + 1][j] = 1;
      if (j + a[i] > 5000) continue;
      dp1[i + 1][j + a[i]] |= dp1[i][j];
    }
  }

  dp2[0][0] = 1;

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= k; ++j) {
      if(dp2[i][j]) dp2[i + 1][j] = 1;
      if (j + a[n - 1 - i] > 5000) continue;
      dp2[i + 1][j + a[n - 1 - i]] |= dp2[i][j];
    }
  }

  int need = 0;

  for (int i = 1; i <= n; ++i) {
    int target = max(0, k - a[i - 1]);
    for (int j = target; j <= k - 1; ++j) {
      for (int l = 0; l <= j; ++l) {
        if (dp1[i - 1][l] && dp2[n - i][j - l]) {
          ++need;
          j = l = k + 5;
        }
      }
    }
  }

  printf("%d\n", n - need);

  return 0;
}

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

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define Puts(x) puts(x? "Yes":"No")
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

i64 gcd(int n, int m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(int n, int m) {return (n / gcd(n, m) * m);}
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

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

  int n, m;
  string s, t;
  cin >> n >> m;
  cin >> s >> t;

  i64 ans = lcm(n, m);
  map<i64, char> mp;
  rep(i, 0, n) {
    mp[i * ans / n + 1] = s[i];
  }
  rep(i, 0, m) {
    if(mp.count(i * ans / m + 1) && mp[i * ans / m + 1] != t[i]) return cout << -1 << endl, 0;
  }
  cout << ans << endl;
} 


Measured memory_bytes: 6144
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
#include <math.h>

using namespace std;
typedef long long ll;
#define MOD 1000000007

ll dfs(int K, vector<vector<int>> &graph, int now, int from){
	int color_num;
  	if(from == -1) color_num = K-1;
  	else color_num = K-2;
  	if(K < graph[now].size()) return 0;
  	ll rtn = 1;
  	for(auto edge: graph[now]){
      	if(edge == from) continue;
    	rtn *= color_num;
      	rtn %= MOD;
      	color_num--;
    }
	for(auto edge: graph[now]){
      	if(edge == from) continue;
    	rtn *= dfs(K, graph, edge, now); 
      	rtn %= MOD;
    }
  	return rtn;
}

int main(){
	int N, K;
  	cin >> N >> K;
  	vector<vector<int>> graph(N);
  	for(int i = 0; i < N-1; i++){
      	int a,b;
      	cin >> a >> b;
      	a--;
      	b--;
    	graph[a].push_back(b);
      	graph[b].push_back(a);
    }
  	cout << (K*dfs(K, graph, 0, -1))%MOD << endl;
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;


void solve(){
  int a,b;
  cin >> a >> b;
  bool c = 1 <= a && a <= 9 && 1 <= b && b <= 9;
  if(c) cout << a*b << endl;
  else cout << -1 << endl;
}

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int FACE = 6;
int main()
{
    int a[FACE];
    for(int i = 0; i < FACE; i++)
    {
        cin >> a[i];
    }
    string command;
    cin >> command;
    for(int i = 0; i < command.length(); i++)
    {
        int temp;
        switch(command[i])
        {
            case 'N':
                 temp = a[0];
                 a[0] = a[1];
                 a[1] = a[5];
                 a[5] = a[4];
                 a[4] = temp;
                 break;
            case 'E':
                 temp = a[0];
                 a[0] = a[3];
                 a[3] = a[5];
                 a[5] = a[2];
                 a[2] = temp;
                 break;
            case 'W': 
                 temp = a[0];
                 a[0] = a[2];
                 a[2] = a[5];
                 a[5] = a[3];
                 a[3] = temp;
                 break;
            case 'S':
                 temp = a[0];
                 a[0] = a[4];
                 a[4] = a[5];
                 a[5] = a[1];
                 a[1] = temp;
                 break;
        }
    }
    cout << a[0] << endl;
    return 0;
}



Measured memory_bytes: 3212
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int X;
    cin >> X;
	//X>=30の時Yes,そうでない時にNoを出力
  	if(X >= 30){// 出力
    cout << "Yes" << endl;}
  	else{
    cout << "No" << endl;}
    
    return 0;
}

Measured memory_bytes: 3588
import itertools

def judge_prime(n):
    for p in range(2,n):
        if n % p == 0:
            return False
        
    return True


N = int(input())

ans_list = []
number = 2

while(number <= 55555):
    if len(ans_list) < N:
        if judge_prime(number):
            if number % 5 ==1:
                ans_list.append(number)
        number += 1
    else:
        break

print(" ".join(map(str,ans_list)))



Measured memory_bytes: 3060
// Problem: E - Dist Max
// Contest: AtCoder - AtCoder Beginner Contest 178
// URL: https://atcoder.jp/contests/abc178/tasks/abc178_e
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define ll long long int
#define ii int
#define du double
#define jmp "\n"
#define vl vector<ll>
#define vvl vector<vl>
#define pb push_back
#define printv(v)     \
  for (auto x : v)    \
    cout << x << " "; \
  cout << jmp;
#define vi vector<int>
#define vb vector<bool>
#define ump unordered_map
#define SORT(v) sort(v.begin(), v.end())
#define REV(x) reverse(x.begin(), x.end())
#define all(x) x.begin(), x.end()
#define SET(x, a) memset(x, a, sizeof(x))
#define si(x) x.size()
#define ff first
#define ss second
#define iin insert
#define deb(x) cout << "test " << #x << "=" << x << jmp
#define deb2(x, y) cout << "test " << #x << "=" << x << "," << #y << "=" << y << jmp
using namespace std;
const ll nax = 1e5 + 5;
void solve()
{
  ll n, a, b;
  cin >> n;
  vl aa, bb;
  for (ll i = 0; i < n; i++)
    cin >> a >> b, aa.pb(a + b), bb.pb(a - b);
  SORT(aa);
  SORT(bb);
  cout << max(aa[n - 1] - aa[0], bb[n - 1] - bb[0]);
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  //cin >> t;
  while (t--)
    solve();
  return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b;
  cin>>a>>b;
  cout<<((a+b)%24)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#include <assert.h>
#include <numeric>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)3e5
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
vi f(mxn,1);
struct node{
	int x,y;
	void read(){
		cin>>x>>y;
	}bool operator<(const node&a) const{
		if(a.x-x) return x<a.x;
		return y<a.y;
	}
};
ll powe(ll x,ll y=mod-2){
	x%=mod;ll s=1;while(y){
		if(y%2) s=(s*x)%mod;
		y/=2;x=(x*x)%mod;
	}return s;
}ll ncr(int x,int y){
	if(x<1||y<1) return 0;
	int n=x+y-2,r=y-1;
	ll inv=(powe(f[n-r])*powe(f[r]))%mod;
	return (f[n]*inv)%mod;
}
int main(){
	int h,w,i,n,j;cin>>h>>w>>n;vector<node>v(n+1);vi d(n+2,0);
	for(i=1;i<f.size();i++) f[i]=(f[i-1]*i)%mod;
	for(i=1;i<=n;i++) v[i].read();sort(all(v));
	v.eb(node{h,w});
	for(i=1;i<=n+1;i++){
		d[i]=ncr(v[i].x,v[i].y);
		for(j=i-1;j;j--){
			d[i]=(d[i]-d[j]*ncr(v[i].x-v[j].x+1,v[i].y-v[j].y+1)%mod+mod)%mod;
		}
	}cout<<d[n+1]<<endl;
}


Measured memory_bytes: 5808
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a=0,b=0;
	char c[1005];
	gets(c);
	for (int i=0;i<strlen(c);i++){
		if(c[i]=='C') a=1;
		if(c[i]=='F') 
			if(a==1)b=1; 
	}
	if(a==1&&b==1) 
	    cout<<"Yes";
	else 
		cout<<"No";
	return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    ll a[100050];
    vector<ll> comp;
    comp.push_back(0);
    map<ll, ll> mini;
    map<ll, ll> number;
    for(ll i = 1; i <= n; i++){
        cin >> a[i];
        comp.push_back(a[i]);
        number[a[i]]++;
        if(mini[a[i]] == 0){
            mini[a[i]] = i;
        } else {
            mini[a[i]] = min(i, mini[a[i]]);
        }
    }
    sort(comp.begin(), comp.end());
    comp.erase(unique(comp.begin(), comp.end()), comp.end());
    map<ll, ll> mp;
    map<ll, ll> ans;
    ll next = comp.back();
    ll now;
    ll added = 0;
    ll minimum = INF;
    for(int i = comp.size() - 2; i >= 0; i--){
        now = next;
        next = comp[i];
        added += number[now];
        minimum = min(minimum, mini[now]);
        ans[minimum] += added * (now - next);
    }
    for(int i = 1; i <= n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 21364