akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////
#define R(i,n) for(int i=0;i<(n);++i)
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N;
	cin >> N;
	vector<int> dp(N + 1, INF);
	dp[0] = 0;
	for (int i = 0; i < N; ++i) {
		if (dp[i] == INF)continue;
		chmin(dp[i + 1],dp[i]+1);
		LL now = 6;
		for (int j = 1; i + now <= N;now*=6,++j) {
			chmin(dp[i + now], dp[i]+1);
		}
		now = 9;
		for (int j=1; i+now <= N; now *= 9,++j) {
			chmin(dp[i + now],dp[i]+1);
		}
	}
	cout << dp[N] << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>

//     MLE,TLE魔
//↓↓↓↓↓↓↓↓↓↓↓↓
#define int long long
//↑↑↑↑↑↑↑↑↑↑↑↑
//     MLE,TLE魔
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 5000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
struct edge { int to, cost; };
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i*i <= x; i++) {
		while (x%i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
/*--------Library Zone!--------*/

int n, a[100005];
prique(int)que;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		que.push(a[i]);
	}
	while (que.size() > 1) {
		int b = que.top(); que.pop();
		int c = que.top(); que.pop();
		que.push(b);
		if (c%b)que.push(c%b);
	}
	cout << que.top() << endl;
	endre;
}

Measured memory_bytes: 1912
class Main{
    public static void main(String[] a){
       
        for(int i = 1; i <= 9; i++){
            int k = 0;
            for(int j = 1; j <= 9; j++){
                k = i * j;
                System.out.println(i + "x" + j + "=" + k);
            }
        }
    }
}


Measured memory_bytes: 24308
from collections import deque


def bfs(u):
    queue = deque([u])
    d = [None] * N  # uからの距離の初期化
    d[u] = 0  # 自分との距離は0
    ans = [0] * N
    while queue:
        v = queue.popleft()
        for i in g[v]:

            if d[i] is None:
                d[i] = d[v] + 1
                queue.append(i)
                ans[i] = v + 1
    return ans

N, M = map(int, input().split())
g = [[] for _ in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

ans = bfs(0)
if 0 in ans[1:]:
    print('No')
else:
    print('Yes')
    for i in ans[1:]:
        print(i)


Measured memory_bytes: 37408
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
i = int(input())

print(s[i-1])

Measured memory_bytes: 38704
unittest
{
	assert( [ "red blue", "3 4", "red" ].parse.expand.solve == "2 4" );
	assert( [ "red blue", "5 5", "blue" ].parse.expand.solve == "5 4" );
}



import core.bitop;
import std.algorithm;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto st = input.front.split.to!( dchar[][] );
	input.popFront;
	auto ab = input.front.split.to!( long[] );
	input.popFront;
	auto u = input.front.to!( dchar[] );
	return tuple( st[ 0 ], st[ 1 ], ab[ 0 ], ab[ 1 ], u );
}

auto solve( dchar[] s, dchar[] t, long a, long b, dchar[] u )
{
	if( s == u ) a--;
	if( t == u ) b--;
	return format( "%s %s", a, b );
}


Measured memory_bytes: 256
#include<stdio.h>

int a = 0;
int max = 0;
int min = 0;
int sc();

int main(int argc, char const *argv[]){
    int k = 0;

    scanf("%d", &a);
    max = a;
    min = a;

    sc();
    sc();
    sc();
    sc();

    scanf("%d", &k);
    if (max - min <= k) {
        printf("Yay!\n");
    }else
    {
        printf(":(\n");
    }  
}

int sc(){
    scanf("%d", &a);
    if (a > max) {
        max = a;
    }else if (a < min) {
        min = a;
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define yes { cout << "YES" << endl; exit(0); }
#define no { cout << "NO" << endl; exit(0); }
#define impossible { cout << "-1" << endl; exit(0); }

using namespace std;

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

const int Nmax = 2005;

char edge[Nmax][Nmax];
vector<int> v[Nmax];

int n;
int d[Nmax];

int distt(int root)
{
    queue<int> q;
    int i;

    q.push(root);
    d[root] = 0;

    for(i=1; i<=n; ++i)
        if(i != root) d[i] = 1e9;

    int nr = 0;
    while(q.size())
    {
        int node = q.front(); q.pop();
        nr = max(nr, d[node]);

        for(auto it : v[node])
            if(d[it] > d[node] + 1)
            {
                d[it] = d[node] + 1;
                q.push(it);
            }
    }

    for(i=1; i<=n; ++i)
        for(auto it : v[i])
            if(d[it] % 2 == d[i] % 2) impossible;

    return nr + 1;
}

int main()
{
  //  freopen("input", "r", stdin);
    // freopen("output", "w", stdout);
    cin.sync_with_stdio(false); cin.tie(0);

    cin >> n;

    int i, j;
    for(i=1; i<=n; ++i)
        cin >> (edge[i] + 1);

    for(i=1; i<=n; ++i)
        for(j=i+1; j<=n; ++j)
            if(edge[i][j] == '1')
            {
                v[i].push_back(j);
                v[j].push_back(i);
            }

    int ans = 0;
    for(i=1; i<=n; ++i)
        ans = max(ans, distt(i));

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int n,ans[(1<<17)];
void solve(int a,int b,int l,int r,vector<int> v)
{
	ans[l]=a;
	ans[r]=b;
	if (l+1==r)
	return;
	int b1=-1,b2,mid=(l+r)/2;
	for (int i=0;i<n;i++)
	{
		if (!v[i])
		continue;
		if (b1==-1 && (a&(1<<i))!=(b&(1<<i)))
		b1=i;
		else
		b2=i;
	}
	if (a&(1<<b1))
	{
		for (int i=l;i<=mid;i++)
		ans[i]|=(1<<b1);
	}
	else
	{
		for (int i=mid+1;i<=r;i++)
		ans[i]|=(1<<b1);
	}
	v[b1]=0;
	solve(a,(b^(1<<b1)^(1<<b2)),l,mid,v);
	solve((b^(1<<b2)),b,mid+1,r,v);
}
int main()
{
	int a,b;
	scanf("%d%d%d",&n,&a,&b);
	if (__builtin_popcount(a)%2==__builtin_popcount(b)%2)
	{
		printf("NO");
		return 0;
	}
	vector<int> v(n,1);
	solve(a,b,0,(1<<n)-1,v);
	printf("YES\n");
	for (int i=0;i<(1<<n);i++)
	printf("%d ",ans[i]);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<__uint128_t> v;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
  }
  sort(ALLOF(v));

  __uint128_t ret = 1;
  rep(i,N){
    ret *= v[i];

    if(ret > 1000000000000000000LL){
      cout << -1 << endl;
      return 0;
    }
  }

  cout << (ll)ret << endl;
  
  return 0;
}



Measured memory_bytes: 5368
a = sorted(map(int, input().split()))
b, c = a[2] - a[1], a[2] - a[0]

あ = b // 2 + c // 2
ばいく = b % 2 + c % 2
if ばいく == 1:
    あ += 2
elif ばいく == 2:
    あ += 1
print(あ)


Measured memory_bytes: 9200
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        boolean[] used = new boolean[26];
        for (char c : scanner.next().toCharArray()) {
            if (used[c - 'a']) {
                System.out.println("no");
                return;
            }
            used[c - 'a'] = true;
        }
        System.out.println("yes");
    }
}

Measured memory_bytes: 23636
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
#define N (1000000000+7)
int num[101] = { 0 };
int main(void) {
	int a, b, c, sum = 0;
	cin >> a >> b >> c;
	num[a] = 1;
	num[b] = 1;
	num[c] = 1;
	for (int i = 1;i < 101;i++)sum += num[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;

ll mabs(ll a) {
  return a > 0 ? a : -a;
}

int main(void) {
  ll i, j, k, n, ans = 0, cnt = 0, now;
  scanf("%lld", &n);
  bool flg[n];
  pair<ll, ll> p[n];
  for(i = 0; i < n; ++i) 
    scanf("%lld", &p[i].first), p[i].second = i;
  sort(p, p + n);
  for(i = 0; i < n; ++i) ans += mabs(p[i].second - i) * p[i].first;
  ll dp[n][n], sum[n][n];
  for(k = 0; k < n; ++k) {
    now = 0;
    for(i = 0; i < n; ++i) {
      sum[i][k] = now + (mabs(k - p[i].second) - mabs(i + k - p[i].second)) * p[i].first;
      if(i + k < p[i].second) now -= p[i].first;
      else now += p[i].first;
    }
  }
  for(j = 0; j < n; ++j) dp[n - 1][j] = dp[j][0] = 0;
  for(k = n - 1; k; --k) {
    for(i = 0; i < n - k; ++i) {
      if(dp[k - 1][i] < dp[k][i]) dp[k - 1][i] = dp[k][i];
      dp[k - 1][i + 1] = dp[k][i] + sum[k][i];
    }
  }
  now = 0;
  for(i = 0; i < n; ++i) if(dp[0][i] > now) now = dp[0][i];
  printf("%lld", ans + now);
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline void fastio () {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
}

#define whats(x) cerr << #x << " = " << (x) << "\n"; 

using LL = long long;
using LD = long double;

const LL INF = LLONG_MAX;
const LL MOD = 998244353;
const LL N = 2e5+1;

int main() {
	fastio();

	string t;
	cin >> t;

	for (auto &e : t) {
		if (e == '?') e='D';
	}

	cout << t << "\n";
}

Measured memory_bytes: 3772
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

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

    int n; cin >> n;
    ll cnt[5]; rep(i,5) cnt[i]=0LL;
    rep(i,n){
        string s; cin >> s;
        if(s[0] == 'M') cnt[0]++;
        else if(s[0] == 'A') cnt[1]++;
        else if(s[0] == 'R') cnt[2]++;
        else if(s[0] == 'C') cnt[3]++;
        else if(s[0] == 'H') cnt[4]++;
    }

    ll ans =0LL;
    rep(i,5) for(int j=i+1; j<5; ++j) for(int k=j+1;k<5;++k){
        ans+=cnt[i]*cnt[j]*cnt[k];
    }

    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/*	#include <boost/math/common_factor.hpp>  boost::math::lcm(10,20) ---> use it to find lcm.*/
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
// #define int long long 
#define PI pair<int , int >
#define mpr make_pair
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define debug() cout << "Hi" << endl	// write debug(); in main()
#define FO(i,a,b) for(int i = (int)a;i < (int)b;++i)
#define FE(i,a,b) for(int i = (int)a;i <= (int)b;++i)
const int MOD = 1e9+7;
const int MAXN = 1e5+3;
const int inf = 2e9;
int max(int a,int b){	if(a > b)return a; else return b; }
int min(int a, int b){	if(a < b)return a; else return b; }
bool cmp(PI p1,PI p2){
	if(p1.ff < p2.ff)return true;
	else if(p1.ff == p2.ff){
		if(p1.ss < p2.ss)return true;		// You should not be writing p1.ss <= p2.ss !!!
		return false;
	}
	return false;
}
/*		1. Take all the inputs
		4. Whenever you do multiplication and division in the same line, beware.
*/
void solve(){
	//debug();
	// int main  or  int32_t main ...
	int a,b,c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b << endl;
}
/*	memset() can be used to set all values as 0 or -1 for integer data types.*/

int main(){
	IO;
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//#endif // ONLINE_JUDGE
	// std::cout << std::setprecision(12); std::cout << std::fixed;
	int t;
	// cin >> t;
	t = 1;
	while(t--){
		solve();
	}
	return 0;
}


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

using namespace std;
using ll = long long;

ll N, K;
ll A[100010];
ll freq[2][51];
ll dp[51][2];

ll rec(int pos, int under){
    if(pos == -1){
        return 0;
    }
    if(dp[pos][under] >= 0) return dp[pos][under];
    ll res = 0;
    // zero
    {
        int nunder = under;
        if(under == 0){
            nunder = (K>> pos) & 1;
        }
        res = max(res, rec(pos - 1, nunder) + (1LL << pos) * freq[1][pos]);
    }
    // one
    if((((K >> pos) & 1) && under == 0) || under == 1){
        res = max(res, rec(pos - 1, under) + (1LL << pos) * freq[0][pos]);
    }
    return dp[pos][under] = res;
}

int main(){

    memset(dp, -1, sizeof(dp));
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 50; j++){
            freq[(A[i] >> j) & 1][j]++;
        }
    }

    cout << rec(50, 0) << endl;
    

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  string s;
  cin >> s;
  string ans;
  rep(i, s.size())
  {
    if (s[i] != 'B')
      ans += s[i];
    else
    {
      if (ans.size() > 0)
      {
        ans.erase(ans.end() - 1);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REP1(i,n) for(int i=1; i<=(int)(n); i++)
#define SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
using namespace std;

int main() {
  long long A,B,K;
  cin>>A>>B>>K;
  REP(i,K) {
    if(i % 2 == 0) {
      A = A / 2;
      B += A;
      // cerr<<A<<" "<<B<<endl;
    } else {
      B = B / 2;
      A += B;
      // cerr<<A<<" "<<B<<endl;
    }
  }

  cout<<A<<" "<<B<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
    using namespace std;
    #define ll  long long
    #define rep(i,n) for(ll i=0;i<n;i++)
    #define pb push_back
    #define in insert
    #define test   ll t;cin>>t;while(t--)
    #define bs  binary_search
    #define rep1(x,n) for(ll x=n-1;x>=0;x--) 
    
    #define SORT(x) sort(x.begin(),x.end())
    #define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
    #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
    #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
    #define All(x) (x).begin(),(x).end()
    #define rAll(x) (x).rbegin(),(x).rend()
    #define db  double
    #define sc scanf
    #define pf printf
    const ll MAX=1e8;
    //ll d[MAX],h[MAX];
    const double pi=3.14159265358979323846;
    const ll M=2e18 +7;
    ll gcd(ll x,ll y){
    	if(x==0)return y;
    	else return gcd(y%x,x);
    }
    ll lcm(ll x,ll y){
    	return (x*y)/gcd(x,y);
    }
   
      bool isPrime(ll n) 
{  
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6){ 
        if (n % i == 0 || n % (i + 2) == 0){ 
            return false; 
        }
    }
    return true; 
} 
bool pdrome(string s){
    ll n = s.length();
    for(ll i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1]){
            return false;
        }
    }
    return true;
}
ll mindig(ll x){
    ll ans = 9;
    ll t = x;
    while(x){
        ans = min(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
ll maxdig(ll x){
    ll ans = 0;
    ll t = x;
    while(x){
        ans = max(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
ll modpow(ll x,ll n,ll M){
	if(n==0)return 1%M;
	ll u=modpow(x,n/2,M);
	u=(u*u)%M;
	if(n%2==1)u=(u*x)%M;
	return u;

}
ll sum(ll a) {
    ll result = 0;
    while (a > 0) {
        result += a % 10;
        a /= 10;
    }
    return result;
}
ll digits(long long n) 
{ 
    return floor(log10(n) + 1); 
}                                  

    int main() {
    	ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    	int l,r,d;
    	cin>>l>>r>>d;
    	int ans=0;
    	for(int x=l;x<=r;x++){
    		if(x%d==0){
    			ans++;
    		}
    		
    	}
    	cout<<ans;
    return 0;
}
    


Measured memory_bytes: 3612
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
using namespace std;


class Dice {
public:
    int num[6] = { 0,0,0,0,0,0 };
    void setnum(int*);
    void roll(char);
};

void Dice::setnum(int* a) {
    for(int i=0;i<6;i++){
        num[i] = a[i];
    }
}

void Dice::roll(char c) {
    switch
        (c) {
        int tmp;
    case'N':
        tmp = num[0];
        num[0] = num[1];
        num[1] = num[5];
        num[5] = num[4];
        num[4] = tmp;
        break;
    case'S':
        tmp = num[0];
        num[0] = num[4];
        num[4] = num[5];
        num[5] = num[1];
        num[1] = tmp;
        break;
    case'E':
        tmp = num[0];
        num[0] = num[3];
        num[3] = num[5];
        num[5] = num[2];
        num[2] = tmp;
        break;
    case'W':
        tmp = num[0];
        num[0] = num[2];
        num[2] = num[5];
        num[5] = num[3];
        num[3] = tmp;
        break;
    }
}

bool same(Dice dice1, Dice dice2) {
    int flag=1;
    for (int i = 0; i < 6; i++) {
        if (dice1.num[i] != dice2.num[i]) flag = 0;
    }
    if (flag) return true;
    else return false;
}

bool ans_check(Dice dice1, Dice dice2) {
    bool flag=false;
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            if (same(dice1, dice2)) {
                flag = true;
                break;
            }
            dice1.roll('N');
        }
        dice1.roll('E');
    }
    dice1.roll('N');
    dice1.roll('W');
    for (int i = 0; i < 4; i++) {
        if (same(dice1, dice2)) {
            flag = true;
            break;
        }
        dice1.roll('N');
    }
    dice1.roll('E');
    dice1.roll('S');
    dice1.roll('S');
    dice1.roll('W');
    for (int i = 0; i < 4; i++) {
        if (same(dice1, dice2)) {
            flag = true;
            break;
        }
        dice1.roll('N');
    }
    if (flag) return true;
    else return false;
}

int main() {
    int n, flag = 0;
    Dice dice[100];

    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 6; j++) {
            int dice_num;
            cin >> dice_num;
            dice[i].num[j] = dice_num;
        }
    }
    
    for (int i = 0; i < n-1; i++) {
        for (int j = i+1; j < n; j++) {
            if (ans_check(dice[i], dice[j])) {
                flag+=1;
                break;
            }
        }
    }

    if (flag==0)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
#define ordered_set tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>

const int N=1e+6+5;
long long prime[N],a[N]; 
unordered_map<long long int, long long int> max_map; 
long long int M=1e+9+7;
long long int power(long long int x, long long int n)
{
    if (n == 0)
        return (long long)1;
    else if (n % 2 == 0) //n is even
        return power((x * x) % M, n / 2);
    else //n is odd
        return (x * power((x * x) % M, (n - 1) / 2)) % M;
}
long long int cans(long long int p, long long int q)
{
    return ((p * power(q, M - 2)) % M + M) % M;
}
void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (int i = 2; i < N; i++) { 
        if (prime[i] == 0) { 
            for (int j = i * 2; j < N; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
} 

long long int lcmModuloM(int n) 
{ 
  
    for (int i = 1; i <= n; i++) { 
        int num = a[i]; 
        unordered_map<long long int,long long  int> temp; 
        while (num > 1) { 
  
            int factor = prime[num]; 
            temp[factor]++; 
            num /= factor; 
        } 
  
        for (auto it : temp) { 
            max_map[it.first] = max(max_map[it.first], it.second); 
        } 
    } 
  
    long long int ans = 1; 
  
    for (auto it : max_map) { 
          ans = (ans * power(it.first, it.second)) % M; 
    } 
  
    return ans; 
} 
int main()
{
    int n;
    cin>>n;
    sieve();
    long long int lc=1,ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    lc=lcmModuloM(n);
    for(int i=1;i<=n;i++)
    {
        ans=(ans+(lc*cans(1,a[i]))%M)%M;
    }
    cout<<ans;
}

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

string S;
vector<ll> range;
ll N;
ll sum = 0;

ll sumN(ll N){
  return N * (N+1) / 2;
}

int main(){
  cin >> S;
  N = S.size();

  ll i = 0;
  while(i < N){
    ll j = 0; ll jj = abs(j);
    while(S[i+abs(j)] == S[i] && i + abs(j) < N){
      if(S[i+abs(j)] == '>') j++;
      else if(S[i+abs(j)] == '<') j--;
    }
    range.push_back(j);
    i += abs(j);
  }

  int len = range.size();
  int head = 0; int tale = len;
  if(range[0] > 0){ sum += sumN(range[0]); head++;}  //範囲縮小
  if(range[len-1] < 0){ sum += sumN(abs(range[len-1])); tale--;}  //範囲縮小

  for(int i = head; i < tale;){
    sum += sumN(max(abs(range[i]), abs(range[i+1])));
    //cout << max(abs(range[i]), abs(range[i+1])) << endl;
    sum += sumN(min(abs(range[i]), abs(range[i+1]))-1);
    //cout << min(abs(range[i]), abs(range[i+1])) << endl;
    i += 2;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3068
#include<stdio.h>
char v[5]={'a','i','u','e','o'};
int main(void)
{
  char c;
  scanf("%c",&c);
  int count=0;
  for(int i=0;i<5;i++){
    if(c!=v[i]){
      count++;
    }
  }
  if(count==5){
    puts("consonant");
  }else{
    puts("vowel");
  }
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

int main(int argc, char** argv){
	unsigned char word[201],tmp[201];
	int m,h,len;

	for(;;){
		// Input Word
		scanf("%200s",word);
		len = strlen(word);
		// Check Finish
		if( word[0] == '-' ){
			break;
		}
		// Input M
		scanf("%d",&m);
		// Input H & Shuffle
		while( m-- > 0 ){
			scanf("%d",&h);
			memcpy( tmp, word, h );
			memmove( word, word+h, len-h);
			memcpy( word+len-h, tmp, h);
		}
		// Output
		printf("%s\n",word);
	}

	return 0;
}

Measured memory_bytes: 616
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int[] k = new int[w];
		for(int i = 0; i < w; i++){
			k[i] = i+1;
		}
		int n = sc.nextInt();
		for(int i = 0; i < n; i++){
			String s = sc.next();
			int h = 0;
			for(h = 0; h < s.length(); h++){
				if(s.charAt(h) == ','){
					break;
				}
			}
			int a = Integer.parseInt(s.substring(0,h));
			int b = Integer.parseInt(s.substring(h+1,s.length()));
			//swap(k[a-1], k[b-1]);
			int c = k[a-1];
			k[a-1] = k[b-1];
			k[b-1] = c;
		}
		for(int i = 0; i < w; i++){
			System.out.println(k[i]);
		}
	}
}

Measured memory_bytes: 25940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=20,V=(1<<16)+10,inf=(ll)1e18;
ll n,ans,sx;
ll a[N],dp[N][N][V],f1[V],f2[V];
bool vis[N][N][V];
ll qry(ll l,ll r,ll s)
{
	if(r-l==1) return 0;
	if(r-l==2) return (f1[s]+f2[s])*a[l+1];
	if(vis[l][r][s]) return dp[l][r][s];
	ll i,ret=inf;
	vis[l][r][s]=1;
	for(i=l+1;i<r;i++)
	{
		ret=min(ret,qry(l,i,s<<1)+qry(i,r,(s<<1)+1)+(f1[s]+f2[s])*a[i]);
	}
	return dp[l][r][s]=ret;
}
int main()
{
	ll i;
	cin>>n;
	for(i=1;i<=n;i++) cin>>a[i];
	ans=a[1]+a[n];
	if(n>=3) 
	{
		sx=(1<<(n-2));
		f1[1]=1;f2[1]=1;
		for(i=1;i<(sx>>1);i++)
		{
			f1[i<<1]=f1[i];f2[i<<1]=f1[i]+f2[i];
			f1[(i<<1)|1]=f1[i]+f2[i];f2[(i<<1)|1]=f2[i];
		}
		ans+=qry(1,n,1);
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 102656
def main():
    L, R = map(int, input().split())
    check_point = 2019
    num_2019 = 0
    while check_point <= R:
        if check_point >= L and check_point <= R:
            num_2019 += 1
        check_point += 2019

    if num_2019 >= 1:
        print(0)
        return
 
    min_mod = 2018
    for i in range(L, R):
        for j in range(i+1, R+1):
            min_mod = min((i*j) % 2019, min_mod)
    print(min_mod)
    

if __name__ == '__main__':
    main()


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

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

int main() {
    int n;
    cin >> n;
    vector<P> v(n);
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        v[i] = P(a,i);
    }
    sort(v.begin(),v.end());
    int ans = 0;
    for(int i=0;i<n;i++){
        if(i%2 != v[i].second%2) ans++;
    }
    ans /= 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sstream>

using namespace std;

int main(){
    unsigned int N, X, temp, D, count;
    cin >> N >> X;
    D = 0, count = 1;
    for(int i = 0; i < N; i++){
        cin >> temp;
        D += temp;
        if(D > X) break;
        count++;
    }

    cout << count << endl;

    return 0;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const ll inf = numeric_limits<ll>::max() / 2;
const ll mod = 1e9+7;

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

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

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
  if (a < b) return a = b, true; else return false;
}


void solve(){
  int N;
  cin >> N;

  int h[100000+5];
  rep(i, N) cin >> h[i];

  ll cost[100000+5];
  cost[0] = 0;
  cost[1] = abs(h[0] - h[1]);
  REP(i, 2, N){
    cost[i] = min(cost[i-1] + abs(h[i-1] - h[i]), cost[i-2] + abs(h[i-2] - h[i]));
  }

  cout << cost[N-1] << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define INF 0x3f3f3f3f
#define MAX (1<<20)
#define MOD 1000000007
#define i64 long long
#define all(x) (x).begin() , (x).end()
#define sz(x) (int)(x).size()
#define ii pair<int, int>
#define fs first
#define sc second
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<ii>
#define vvii vector<vii>
#define lsb(x) ((x) & (-x))
#define gcd(x,y) __gcd((x),(y))

using namespace std;

int k;
string s;

int main(){_
    cin >> k >> s;
    for (int i=0; i<min(sz(s),k); ++i){
        cout << s[i];
    }
    if (sz(s)>k) cout << "...";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

class UnionFind {
private:
    vector<long long> par,_size;
public:
    UnionFind(long long n) : par(n+1),_size(n+1,1) {
        iota(par.begin(), par.end(), 0);
    }

    long long root(long long x) {
        if (x == par[x]) return x;
        else return par[x] = root(par[x]);
    }

    bool is_same(long long x, long long y) {
        return root(x) == root(y);
    }

    bool merge(long long x, long long y) {
        x = root(x); y = root(y);
        if (is_same(x,y)) return false;
        if (_size[x] < _size[y]) swap(x,y);
        par[y] = x;
        _size[x] += _size[y];
        return true;
    }

    long long size(long long x) {
        return _size[root(x)];
    }
};

int main() {
    int n,m;
    cin >> n >> m;
    vector g(n+1, vector<int>());

    UnionFind uni(n);
    for (int i=0; i<m; i++) {
        int a,b;
        cin >> a >> b;
        uni.merge(a,b);
    }

    int64 ans = 0;
    for (int i=1; i<=n; i++) {
        ans = max(ans, uni.size(i));
    }

    cout << ans << endl;
}

Measured memory_bytes: 10744
#include <stdio.h>
#include <limits.h>

int max ( int x, int y ) {
  if ( x > y )
    return x;
  else
    return y;
}

int min ( int x, int y ) {
  if ( x > y )
    return y;
  else
    return x;
}

int main ( void ) {

  int n, t, minv;
  int maxv = INT_MIN;
  int R[200000];
  scanf( "%d", &n );
  scanf( "%d", &R[0] );
  minv = R[0];
  for ( t = 1; t < n; t++ ) {
    scanf ( "%d", &R[t] );
    maxv = max ( R[t] - minv, maxv );
    minv = min ( R[t], minv );
  }
  printf ( "%d\n", maxv );
}



Measured memory_bytes: 2536
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int K, T; cin >> K >> T;
VI a(T); rep(i, 0, T) cin >> a[i];
int sum = accumulate(ALL(a), 0);
int ans = 0;
rep(i, 0, T){
    ans += max(0, a[i] - 1 - (sum - a[i]));
}
cout << ans << endl;

}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
while True:
    n,x = map(int, input().split())
    if n == x == 0:
        break
    
    tmp = 0

    for i1 in range(0,n-1):
        for i2 in range(i1, n):
            n3 = x - i1 - i2
            if (n3 != i2)and(i2 != i1)and(0 < i1 < i2 < n3)and(0 < n3 <= n):
                tmp += 1
    
    print(tmp)




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

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		
		double N = sc.nextDouble();
		double M = sc.nextDouble();
		double ans = (1900d * M + 100d * (N - M)) * Math.pow(2, M);
		
		System.out.println((int)ans);
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 22868
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

using int64 = long long;

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

    const int MAXN = 200005;

    static int64 A[MAXN];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    static int64 dp[2][MAXN];
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) dp[1][i] = A[i];

    int64 ans = 0;
    // スライド最大値
    for (int i = 1; i < K; i++) {
        deque<int> dq;
        for (int j = 0; j < N; j++) {
            if (dq.empty() or dp[i & 1][dq.front()] < 0) dp[(i + 1) & 1][j] = -1;
            else {
                dp[(i + 1) & 1][j] = dp[i & 1][dq.front()] + int64(i + 1) * A[j];
            }
            while (!dq.empty() and dp[i & 1][dq.back()] <= dp[i & 1][j]) dq.pop_back();
            dq.push_back(j);

            if (dq.front() == j - M) dq.pop_front();

            if (i == K - 1) ans = max(ans, dp[K & 1][j]);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
 
using namespace std;


void solve(){
	ll n;
	cin>>n;
	ll ans = 1e18;
	for(ll i=1; i*i <= n; i++){
		if(n%i == 0){
			ans = min(ans, n/i + i);
		}
	}
	cout<<ans-2;
}


int main()
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed<<setprecision(12);
	int t =1; //cin>>t;
	for(int i=1; i<=t; i++){
		solve();
		cout<<"\n";
	}
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
//#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;


signed main() {
	int n, m, a;
	while(1){
		cin >> n >> m >> a;
		if(n + m + a == 0) break;
		vector<vector <pii> > d(1001, vector<pii>());
		int h, p, q, MAX = 0;
		rep(i, 0, m){
			cin >> h >> p >> q;
			d[h].push_back(make_pair(p, q));
			MAX = max(MAX, h);
		}
		int now = a;
		repb(i, 1000, 0){
			rep(j, 0, d[i].size()){
				if(d[i][j].first == now){
					now = d[i][j].second;
					break;
				}
				if(d[i][j].second == now){
					now = d[i][j].first;
					break;
				}
			}
			//cout << i << " " << now <<endl;
		}
		cout << now <<endl;
	}
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int v[3];
	for(int i=0;i<3;++i)
		cin>>v[i];
	int k;
	cin>>k;
	int x = 0;
	while(k>0&&x<2)
	{
		if(v[x]>=v[x+1])
			v[x+1] *= 2,k--;
		else x++;
	}
	if(v[0]<v[1]&&v[1]<v[2])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3648
function range(begin, end) {
  return Array.from(Array(end - begin), (e, i) => begin + i);
}

(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift ());
  const p = lines.map(l => l.split(' ')[0]).concat([lines[n-1].split(' ')[1]]).map(Number);

  const m = Array.from(Array(n + 1), () => (Array(n + 1)));
  for (let i = 1; i < n + 1; i++) m[i][i] = 0;

  let i = 0, d = 1;
  for (d = 1; d <= n - 1; d++) {
    for (i = 1; i <= n - d; i++) {
      m[i][i+d] = range(i, i + d).map(
        k => m[i][k] + m[k + 1][i + d] + p[i - 1] * p[k] * p[i + d]
      ).sort((a, b) => a - b)[0];
    }
  }
  console.log(m[1][n]);
})();



Measured memory_bytes: 20492
import math
a,b,h,m=map(int,input().split())
s=math.radians((60*h+m)/2)
l=math.radians(6*m)
d2=(a*math.sin(s)-b*math.sin(l))**2+(a*math.cos(s)-b*math.cos(l))**2
d=math.sqrt(d2)
print(d)

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

int main()
{
	int m,k;
	scanf("%d%d",&m,&k);
	m = (1<<m);
	//printf("%d\n",m);
	if(k>=m){
		printf("-1\n");
	}
	else{
		if(m==2){
			if(k==0){
				printf("0 0 1 1\n");
			}
			else printf("-1\n");
			return 0;
		}
		for(int i=0;i<m;i++){
			if(i!=k)printf("%d ",i);
		}
		printf("%d ",k);
		for(int i=m-1;i>=0;i--){
			if(i!=k)printf("%d ",i);
		}
		printf("%d\n",k);
	}
}


Measured memory_bytes: 1792
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b = list(map(int, input().split()))
# s = input()


a, b = list(map(int, input().split()))

ans = -1
if a > 9 or b > 9:
    ()
else:
    ans = a * b
print(ans)


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

int main() {
    long long n;
    cin >> n;
    cout << n << ": ";

    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0) {
                n /= i;
                cout << i;
                if (n != 1) cout << " ";
            }
        }
    }
    if (n > 1) cout << n;
    cout << endl;
    return 0;
}


Measured memory_bytes: 3084
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ').map(Number);
  buildMaxHeap(arr);
  console.log(arr.reduce((s, e) => s += ' ' + e, ''));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
  let left, right, largest;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left < n && arr[left] > arr[i]) largest = left;
    else largest = i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
}



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

using namespace std;

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

    int n, m;
    cin >> n >> m;

    int asgn, total_asgn = 0;
    for (int i = 0; i < m; i++) {
        cin >> asgn;
        total_asgn += asgn;
    }

    if (n >= total_asgn) {
        cout << n - total_asgn << "\n";
    } else {
        cout << -1 << "\n";
    }

}


Measured memory_bytes: 3644
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U>
inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U>
inline void cmin(T& a, U b) { if (a > b) a = b; }

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} io_setup;

constexpr char el = '\n';
#line 2 "b2.cpp"

bool f(string s) {
  ll a = s[2]-'0';
  ll b = s[3]-'0';
  return (a == 0 and b > 0) or (a == 1 and b <= 2);
}

bool g(string s) {
  ll a = s[0]-'0';
  ll b = s[1]-'0';
  return (a == 0 and b > 0) or (a == 1 and b <= 2);
}

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

  if (f(s) and g(s)) {
    cout << "AMBIGUOUS" << el;
  } else if (f(s)) {
    cout << "YYMM" << el;
  } else if (g(s)) {
    cout << "MMYY" << el;
  } else {
    cout << "NA" << el;
  }

  cout << flush;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int dx = x2 - x1;
    int dy = y2 - y1;

    int x3 = x2 - dy;
    int y3 = y2 + dx;

    int x4 = x1 - dy;
    int y4 = y1 + dx;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;
}


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

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

  if(a == b){
    if(a == c){
      cout<<"1"<<endl;
    }else{
      cout<<"2"<<endl;
    }
  }else if(a == c){
    cout<<"2"<<endl;
  }else if(b == c){
    cout<<"2"<<endl;
  }else{
    cout<<"3"<<endl;
  }
}


Measured memory_bytes: 256
N = int(input())

from collections import deque

q = deque()

q.append('a')

while True:
    str = q.popleft()
    temp_lst = list(str) + [chr(ord('a') + len(set(str)))]
    temp_lst = list(set(temp_lst))
    temp_lst.sort()
    for c in temp_lst:
        q.append(str + c)
    if len(str) < N:
        continue
    elif len(str) == N:
        print(str)
    else:
        break

Measured memory_bytes: 130524
#include<iostream>
 using namespace std ;
 int main()
{
short int c=0,price;
char s[3];

cin>>s;

if(s[0]=='o') ++c;
if(s[1]=='o') ++c;
if(s[2]=='o') ++c;

price=700+c*100;

cout<<price;

}

Measured memory_bytes: 3496
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n, k;
	cin >> n >> k;
	map<int,int> m;
	for(int i = 0; i < k; i++){
		int x;
		cin >> x;
		m[x] = 1;
	}
	int dp[n+1] = {0};
	dp[0] = 1;
	for(int i = 1; i <= n; i++){
		if(m.count(i))
			continue;
		dp[i] = dp[i-1];
		if(i > 1)
			dp[i] += dp[i-2];
		dp[i] %= MOD;
	}
	cout << dp[n];
	

	return 0;
}



Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define INF (1<<29)
using namespace std;
typedef long long ll;
void ans(int i){
      if(i==0)cout<<"Isono-kun"<<endl;
      else if(i==1)cout<<"Nakajima-kun"<<endl;
      else cout<<"Hikiwake-kun"<<endl;
      return;
}
int main(){
      int K;
      string I[100];
      string N[100];
      cin>>K;
      REP(i,K)cin>>I[i];
      REP(i,K)cin>>N[i];
      int Nk=0,Ik=0;
      REP(i,K){
            if(I[i]=="tameru"){
                  Ik=min(5,Ik+1);
                  if(N[i]=="kougekida"){
                        if(Nk==0){
                              ans(0);
                              return 0;
                        }else{
                              ans(1);
                              return 0;
                        }
                        Nk=0;
                  }else if(N[i]=="tameru")Nk=min(5,Nk+1);
            }else if(I[i]=="kougekida"){
                  if(N[i]=="tameru"){
                        if(Ik==0){
                              ans(1);
                              return 0;
                        }
                        ans(0);
                        return 0;
                  }else if(N[i]=="kougekida"){
                        if(Ik>Nk){
                              ans(0);
                              return 0;
                        }else if(Nk>Ik){
                              ans(1);
                              return 0;
                        }
                        Nk=0;
                  }else if(N[i]=="mamoru"){
                        if(Ik==0){
                              ans(1);
                              return 0;
                        }
                        if(Ik==5){
                              ans(0);
                              return 0;
                        }
                  }
                  Ik=0;
            }else{
                  if(N[i]=="tameru")Nk=min(5,Nk+1);
                  if(N[i]=="kougekida"){
                        if(Nk==0){
                              ans(0);
                              return 0;
                        }else if(Nk==5){
                              ans(1);
                              return 0;
                        }
                        Nk=0;
                  }
            }
      }
      ans(2);
}

Measured memory_bytes: 1220
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
ll dp[2][4];
int now = 0;
int t[3];
ll p2[32];
bool use[100010];
int arr[256];
void Sequence() {

	int n;
	cin >> n;
	string t[51];
	for (size_t i = 0; i < n; i++)
	{
		cin >> t[i];
		sort(t[i].begin(),t[i].end());
	}

	for (int i = 'a'; i <= 'z'; i++)
	{
		arr[i] = 100;
	}
	for (size_t i = 0; i < n; i++)
	{
		int ta[256];
		fill(ta, ta + 256, 0);
		for (size_t j = 0; j < t[i].size(); j++)
		{
			ta[t[i][j]]++;
		}

		for (int j = 'a'; j <= 'z'; j++)
		{
			arr[j] = min(arr[j], ta[j]);
		}
	}
	string res = "";
	for (char i = 'a'; i <= 'z'; i++)
	{
		for (size_t j = 0; j < arr[i]; j++)
		{
			res += i;
		}
	}
	cout << res << endl;
}
int main() {
	Sequence();
	return 0;
}



Measured memory_bytes: 256