akhauriyash/Code-Regression huggingface dataset:
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;


int main(){
    string S,ans="";
    cin>>S;
    if(S.size()<26){
    map<char,int> m;
    rep(i,S.size()){
        m[S[i]]++;
    }
    rep(i,26){
        if(m[(char)(i+'a')]==0){
            ans= S+string(1,(char)(i+'a'));
            break;
        }
    }

    }
    else{
        if(S[0]=='z'){
            cout<<-1<<endl;
            return 0;
        }
    vector<int> order(26);
    rep(i,26){
        order[i]=S[i]-'a';
    }
    

    
    next_permutation(order.begin(), order.end());
    rep(i,26){
       
        ans+=string(1,(char)(order[i]+'a'));
        if(S[i]!=(char)(order[i]+'a')){
            break;
        }


    }
    }
    // 答えを出力
    cout << ans << endl;
return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
ll gcd(ll a,ll b){//最大公約数
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){//最小公倍数
	ll g=gcd(a,b);
	return a/g*b;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	ll N,M;
	string S,T;
	cin>>N>>M>>S>>T;
	map<int,char>ST;
	map<int,bool>F;
	ll ans=0;
	ll D=lcm(N,M);

	ST[1]=S[0];
	//cout<<ST[1]<<endl;
	FOR(i,1,N){
		ans+=D/N;
		ST[ans+1]=S[i];
		F[ans+1]=true;
		//cout<<ST[ans+1]<<" "<<ans+1<<endl;
	}
	ll ansa=0;
	if(ST[1]!=T[0]){cout<<-1<<endl; return 0;}
	FOR(i,1,M){
		ansa+=D/M;
		//cout<<ansa<<endl;
		if(ST[ansa+1]!=T[i] && F[ansa+1]){cout<<-1<<endl; return 0;}
	}
	cout<<D<<endl;
	return 0;
}

Measured memory_bytes: 16000
package main

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

type card struct{ number, stock int }
type cards []card

func (c cards) Len() int           { return len(c) }
func (c cards) Swap(i, j int)      { c[i], c[j] = c[j], c[i] }
func (c cards) Less(i, j int) bool { return c[i].number > c[j].number }

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, n)
	sum := 0
	for i := range as {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
		sum += as[i]
	}
	sort.Ints(as)

	cs := cards(make([]card, m))
	for i := range cs {
		sc.Scan()
		cs[i].stock, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		cs[i].number, _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(cs)

	var p int
lb:
	for _, v := range cs {
		for i := 0; i < v.stock; i++ {
			if p >= len(as) || v.number < as[p] {
				break lb
			}
			sum += v.number - as[p]
			p++
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 5120
#include <stdio.h>
int main(){
	int x=0;
	char a[3];
	scanf("%s",&a);
	for (int i = 0; i < 3; ++i)
	{
		if (a[i]=='o')
		{
			x=x+100;
		}
	}
	printf("%d\n",700+x);
}

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

int main()
{
	long long int n, a, b, c, d, e, maxm;

	cin >> n >> a >> b >> c >> d >> e;
	maxm=0;

	maxm=max(maxm, (long long int)(ceil((1.0*n)/a)));
	maxm=max(maxm, (long long int)(ceil((1.0*n)/b)));
	maxm=max(maxm, (long long int)(ceil((1.0*n)/c)));
	maxm=max(maxm, (long long int)(ceil((1.0*n)/d)));
	maxm=max(maxm, (long long int)(ceil((1.0*n)/e)));

	cout << maxm+4 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define mod 1000000007


int main() {
    int N; cin >> N;
    vector<int> A(3*N);
    priority_queue<int ,vector<int>, greater<int>> LN;
    vector<ll> LS(N);
    priority_queue<int> RN;
    vector<ll> RS(N);
    ll lsum = 0;
    ll rsum = 0;
    for(int i=0; i<3*N; i++){
        cin >> A[i];
        if(i<N){
            lsum += A[i];
            LN.push(A[i]);
        }
        if(i>=2*N){
            rsum += A[i];
            RN.push(A[i]);
        }
    }
    
    for(int i=0; i<N; i++){
        LN.push(A[N+i]);
        if(i==0) LS[i] = lsum + A[N+i] - LN.top();
        else LS[i] = LS[i-1] + A[N+i] - LN.top();
        LN.pop();
    }
    
    for(int i=2*N-1; i>=N; i--){
        RN.push(A[i]);
        if(i==2*N-1) RS[2*N-1-i] = rsum + A[i] - RN.top();
        else RS[2*N-1-i] = RS[2*N-2-i] + A[i] - RN.top();
        RN.pop();
    }
    
    
    ll ans = 1LL<<60;
    ans *= -1;
    
    for(int i=N-1; i<2*N; i++){
        if(i==N-1) ans = max(ans, lsum - RS[i]);
        else if(i==2*N-1) ans = max(ans, LS[N-1] - rsum);
        else ans = max(ans, LS[i-N] - RS[2*N-2-i]);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4088
/*
*    AUTHOR:    mkbaloch
*    CREATED:   26.01.2020 17:53:49
*/

#include<bits/stdc++.h>
#define vi vector<int>
#define ll long long
#define pi pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for(int i=a; i<=b; i++)
#define repn(i, n) for(int i=0; i<(int)n; i++)
#define all(x) x.begin(), x.end()

using namespace std;

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

  #ifdef DEBUG
    auto start = chrono::high_resolution_clock::now();
  #endif

  //-------Start-------//
  
  ll h;
	ll monsters = 1;
	cin >> h;
	ll ans = 0;
	while(h != 0){
		ans += monsters;
		h /= 2;
		monsters *= 2;
	}
	cout << ans << endl;

  //-------End---------//

  #ifdef DEBUG
    auto end = chrono::high_resolution_clock::now();
    auto dur = chrono::duration_cast<chrono::microseconds>(end - start);
    cout << "Execution time: " << setprecision(6) << ((long double)dur.count() / 1e6) << " seconds" << endl; 
  #endif

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int D = sc.nextInt();
    	int X = sc.nextInt();
    	int count = 0;
    	for (int i = 0; i < N; i++) {
			int Ai = sc.nextInt();
			int day = 1;
			int eat = 0;
			while (day <= D) {
				eat++;
				day += Ai;
			}
			count += eat;
		}
    	System.out.println(count + X);
    }
}

Measured memory_bytes: 23252
N = gets.to_i
ary = N.times.map{gets.split.map(&:to_s)}
S = []
T = []
ary.each do|s,t|
  S << s
  T << t.to_i
end

X = gets.chomp

if T[S.index(X)+1..N-1] == []
  puts 0
else
  puts T[S.index(X)+1..N-1].inject(:+)
end



  



Measured memory_bytes: 1788
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main() {
	string n;
	cin >> n;
	if (n[0] == n[1] && n[1]== n[2] || n[1] == n[2] && n[2] == n[3]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define LINE cout<<"--------------------------\n";
#define IOS ios::sync_with_stdio(false),cin.tie(0);
using namespace std;
int dx[]={0 , 0 , -1 , 1} , dy[]={1 , -1 , 0 , 0};
signed main(){
	IOS;
	int n , m , k ; cin >> n >> m >> k;
	int x , y , x2 , y2; cin >> x >> y >> x2 >> y2 , --x , --y , --x2 , --y2;
	vector<string> c(n);
	vector<vector<int>> dis(n,vector<int>(m,1e9));
	for(int i=0 ; i<n ; ++i) cin >> c[i];
	queue<pii> pq;
	if(c[x][y] != '@')pq.push({x , y}) , dis[x][y] = 0;
	while(pq.size()){
		int x = pq.front().F , y = pq.front().S , d = dis[x][y]+1; pq.pop();
		for(int i=0 ; i<4 ; ++i){
			int xx = x , yy = y;
			for(int _ = 1;  _<=k ; ++_){
				xx += dx[i] , yy += dy[i];
				if(xx<0 || xx>=n || yy<0 || yy>=m || c[xx][yy]=='@' || dis[xx][yy] < d) break;
				if(dis[xx][yy] > d) dis[xx][yy] = d , pq.push({xx , yy});
			}
		}
	}
	cout << (dis[x2][y2]==1e9?-1:dis[x2][y2]) << '\n';
}

Measured memory_bytes: 11128
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const N = readInt();
      auto V = new int[N + 1];
      auto W = new int[N + 1];
      foreach (u; 1 .. N + 1) {
        V[u] = readInt();
        W[u] = readInt();
      }
      const Q = readInt();
      auto X = new int[Q];
      auto L = new int[Q];
      foreach (q; 0 .. Q) {
        X[q] = readInt();
        L[q] = readInt();
      }
      
      alias Entry = Tuple!(int, "w", int, "v");
      auto aux = new Entry[1 << 9];
      foreach (q; 0 .. Q) {
        int[] us;
        for (int u = X[q]; u; u >>= 1) {
          us ~= u;
        }
        const usLen = cast(int)(us.length);
        const half = usLen / 2;
        auto es = [Entry(0, 0)];
        foreach (i; 0 .. half) {
          foreach (h; 0 .. 1 << i) {
            aux[h].w = es[h].w + W[us[i]];
            aux[h].v = es[h].v + V[us[i]];
          }
          es = es.merge(aux[0 .. 1 << i]).array;
        }
        auto fs = [Entry(0, 0)];
        foreach (i; 0 .. usLen - half) {
          foreach (h; 0 .. 1 << i) {
            aux[h].w = fs[h].w + W[us[half + i]];
            aux[h].v = fs[h].v + V[us[half + i]];
          }
          fs = fs.merge(aux[0 .. 1 << i]).array;
        }
        int ans;
        int mx;
        for (int g = 0, h = 1 << (usLen - half); h--; ) {
          for (; g < 1 << half && es[g].w + fs[h].w <= L[q]; ++g) {
            chmax(mx, es[g].v);
          }
          if (g > 0) {
            chmax(ans, mx + fs[h].v);
          }
        }
        writeln(ans);
      }
    }
  } catch (EOFException e) {
  }
}


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

int main() {
  ll n;
  cin >> n;
  ll a;
  ll ans=0;
  for (ll i=1;i<=n;i++) {
    cin >> a;
    if ( i%2==1 && a%2==1) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
bool a[10][10],flg=0;
int h,w;
char c;
void dfs(int x,int y){
	if(flg==1)		return;
//	for(int i=1;i<=h;i++){
//		for(int j=1;j<=w;j++){
//			cout<<a[i][j]<<" ";
//		}
//		cout<<endl; 
//	}
//	cout<<endl;
	if(x==h&&y==w){
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				if(a[i][j]==0)
					return;
			}
		}
		flg=1;
//		exit(0);
		return;
	}
	if(a[x+1][y]==0){
		a[x+1][y]=1;
		dfs(x+1,y);
		a[x+1][y]=0;
	}
	if(a[x][y+1]==0){
		a[x][y+1]=1;
		dfs(x,y+1);
		a[x][y+1]=0;
	}
	if(a[x+1][y]==1&&a[x][y+1]==1)	return;
}
int main(){
	scanf("%d%d%c",&h,&w,&c);
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			a[i][j]=1;
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			scanf("%c",&c);
			if(c=='#'){
				a[i][j]=0;
			}
		}
		scanf("%c",&c);
	}
//	for(int i=1;i<=h;i++){
//		for(int j=1;j<=w;j++){
//			cout<<a[i][j]<<" ";
//		}
//		cout<<endl; 
//	}
	a[1][1]=1;
	dfs(1,1);
	if(flg==1)
		printf("Possible");
	else
		printf("Impossible");
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll k,c=0,ans=0; cin>>k;
    set<ll> s;
    while(1){
        ans++;
        c=(c*10)+7; c%=k;
        if(c==0){
            cout<<ans<<endl;
            break;
        }
        if(s.count(c)){
            cout<<-1<<endl;
            break;
        }
        s.insert(c);
    }
}


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

int c[10][10];
int f[10][10];
bool s[10][10];
int hanten[2] = { 1,0 };
int dx[5] = { -1,0,0,1,0 }, dy[5] = { 0,-1,1,0,0 };
int main() {
	int a; cin >> a;
	for (int b = 0; b < a; b++) {
		for (int d = 0; d < 10; d++) {
			for (int e = 0; e < 10; e++) {
				scanf("%d",&c[d][e]);
			}
		}
		for (int g = 0; g < 1024; g++) {
			memset(s, 0, sizeof(s));
			for (int h = 0; h < 10; h++) {
				for (int i = 0; i < 10; i++) {
					f[h][i] = c[h][i];
				}
			}
			for (int h = 0; h < 10; h++) {
				if (g & (1 << h)) {
					s[0][h] = true;
					for (int i = 0; i < 5; i++) {
						int x = dx[i], y = h + dy[i];
						if (x >= 0 && x < 10 && y >= 0 && y < 10) {
							f[x][y] = hanten[f[x][y]];
						}
					}
				}
			}
			for (int h = 1; h < 10; h++) {
				for (int i = 0; i < 10; i++) {
					if (f[h - 1][i]) {
						s[h][i] = true;
						for (int j = 0; j < 5; j++) {
							int x = h+dx[j], y = i + dy[j];
							if (x >= 0 && x < 10 && y >= 0 && y < 10) {
								f[x][y] = hanten[f[x][y]];
							}
						}
					}
				}
			}
			bool K = true;
			for (int i = 0; i < 10; i++) {
				for (int j = 0; j < 10; j++) {
					if (f[i][j])K = false;
				}
			}
			if (K) {
				for (int i = 0; i < 10; i++) {
					for (int j = 0; j < 10; j++) {
						if (j)cout << " ";
						cout << s[i][j];
					}
					cout << endl;
				}
			}
		}
	}
}

Measured memory_bytes: 3136
using System;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		bool[,] dp=new bool[n+1,n*100+1];
		dp[0,0]=true;
		for(int i=1;i<=n;i++){
			int q=int.Parse(Console.ReadLine());
			for(int j=0;j<=i*100;j++){
				if(j>=q&&dp[i-1,j-q]){dp[i,j]=true;}
				else{dp[i,j]=dp[i-1,j];}
			}
		}
		int a=n*100;
		for(;a>0;a--){
			if(dp[n,a]&&a%10!=0){break;}
		}
		Console.WriteLine("{0}",a);
	}
}

Measured memory_bytes: 13920
#include <stdio.h>

int main(void)
{
    int n ,m;
    int A[1000];
    
        scanf("%d" , &n);

    
    for (m = 0 ; m < n ; m++) {
            scanf("%d" , &A[m]);
    }
    
    /*Selection Sort*/
    int minj;
    int i ,j;
    int temp ,count;
    
    for (i = 0 ; i < n ; i++) {
        /*未ソート部分の先頭の要素をとりあえずminjにしてループjを開始し、要素内の最小要素を取り出す*/
        minj = i;
        for (j = i ; j < n ; j++) {
            /*minjに要素の中で一番小さいものを代入*/
            if ( A[minj] > A[j] )
                minj = j;
        }
        /*で先頭要素A[i]と要素中の最小要素minjをswap(ただし選択した先頭要素が最小値minjだった場合、ソートはされない)*/
        if (i != minj) {
            temp = A[i];
            A[i] = A[minj];
            A[minj] = temp;
            /*数える用*/
            count++;
        }
    }

    /*結果の表示*/
    for (int s = 0 ; s < n - 1 ; s++)
        printf("%d " , A[s]);
        
    printf("%d\n" , A[n - 1]);
    printf("%d\n" , count);
    
    return 0;
}



Measured memory_bytes: 2136
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    int n;
    cin>>n;
    vi v(n);
    rep(i,n)v[i]=i;
    vi x(n),y(n);
    rep(i,n)cin>>x[i]>>y[i];
    ld ans=0;
    do{
        ld len=0;
        rep(i,n-1)len+=sqrt((x[v[i]]-x[v[i+1]])*(x[v[i]]-x[v[i+1]])+(y[v[i]]-y[v[i+1]])*(y[v[i]]-y[v[i+1]]));
        ans+=len;
    }while(next_permutation(all(v)));
    int kai=1;
    rep(i,n)kai*=i+1;
    ans/=kai;
    printf("%.7Lf\n",ans);
}

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

int main() {
  ll N; cin >> N;
  vector<ll> vec;
  vec.push_back(1); vec.push_back(N);
  for(ll i = 2; i * i <= N; i++) {
    if(N % i == 0) {
      vec.push_back(i);
      vec.push_back(N/i);
    }
  }
  ll l = vec.size();
  if(l == 2) {
    cout << N-1 << endl;
  } else {
    sort(vec.begin(), vec.end());
    cout << vec[l/2-1] + vec[l/2] - 2 << endl;
  }
  return 0;
}


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


int main(){
    int n, m; cin >> n >> m;
    vector<ll> vec(n+1, 0);
    vector<bool> fl(n+1, true);
    
    rep(i, m) {
        int a; cin >> a;
        fl[a] = false;
    }

    if(n == 1) {
        cout << 1 << endl;
        return 0;
    }

    vec[0] = 1;
    vec[1] = 1;

    for(int i=0; i<=n-2; i++) {
        if(fl[i]) {
            vec[i+2] += vec[i];
            vec[i+2] %= mod;
        }
        if(fl[i+1]) {
            vec[i+2] += vec[i+1];
            vec[i+2] %= mod;
        }
    }

    if(fl[n]) cout << vec[n] << endl;
    else cout << 0 << endl;
}
   

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(x,y) for(ll i=x;i<y;i++)
#define vll vector<ll>
#define sll set<ll>
#define pb push_back
#define in insert
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define tc ll t;cin>>t;while(t--)
#define rev(x) reverse(all(x))
#define low_str(x) transform(all(x),x.begin(),::tolower)
#define up_str(x) transform(all(x),x.begin(),::toupper)
int main()
{
ll n;
cin>>n;
string s;
cin>>s;
if(n%2==1)
    cout<<"No";
else
{
    if(s.substr(0,n/2)==s.substr(n/2,n/2))
        cout<<"Yes";
    else
        cout<<"No";
}
return 0;
}


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

int main(){
    int k;
    cin >> k;
    int a[32] = {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};
    cout << a[k-1] << endl;
    return 0;
}


Measured memory_bytes: 256
/**********************
    Vikas Kumar Jha
    vkjha1010
**********************/
#include<bits/stdc++.h>
using namespace std;

#define ll          long long int 
#define ld          long double
#define mod         1000000007
#define fi          first
#define se          second
#define pb          push_back
#define mp          make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vb          vector<bool>
#define mii         map<ll,ll>
#define pqb         priority_queue<ll>
#define pqs         priority_queue<ll, vi, greater<ll> >
#define ps(x,y)     fixed << setprecision(y) << x
#define fast        ios_base::sync_with_stdio(0);   cin.tie(0); cout.tie(0);
#define w(t)        ll t; cin >> t; for(ll zx=1;zx<=t;++zx)  
#define fr(be,en)   for(ll i = be; i < en; i++)
ll pow(ll x,ll y){ if(y==0) return 1; if(y%2==1) return (((pow(x,y/2)*pow(x,y/2)%mod)*x)%mod); else return (pow(x,y/2)*pow(x,y/2))%mod;}
vb prime;   vi spf; 
void sieve(ll n) 
{   prime.resize(n+1,true); prime[0]=prime[1]=false;
    spf.resize(n+1,1);  spf[2]=2;
    for(ll i=4;i<=n;i+=2){ prime[i]=false; spf[i]=2; } 
    for (ll p=3; p*p<=n; p+=2) 
    {   if (prime[p] == true) 
        {   spf[p]=p;
            for (ll i=p*p; i<=n; i += p) 
            {   if(prime[i]==true)
                {   spf[i]=p;
                    prime[i] = false;
                }
            } 
        } 
    } 
} 

int main() {
    
    fast;
    ll n,w,sum=0;
    cin >> n >> w;
    ll wei[n],val[n];
    fr(0,n)
    {
        cin >> wei[i] >> val[i];
        sum+=val[i];
    }
    vector<vi > dp(n+1,vi(sum+1,LLONG_MAX));
    dp[0][val[0]]=wei[0];
    fr(0,n-1)
    {
        for(ll j=0;j<=sum;++j)
        {
            if(j==0)
            {
                dp[i+1][val[i+1]]=wei[i+1];
            }
            else if(dp[i][j]!=LLONG_MAX)
            {
                dp[i+1][val[i+1]+j]=min(dp[i+1][val[i+1]+j],dp[i][j]+wei[i+1]);
                dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            }
        }
    }
    ll maxy=-1;
    fr(0,sum+1)
    {
        if(dp[n-1][i]!=LLONG_MAX && dp[n-1][i]<=w)
            maxy=i;
    }
    cout << maxy ;
    return 0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

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

  vector < pair<double, double> > XY(N);
  for (int i = 0; i < N; i++){
    cin >> XY[i].first >> XY[i].second;
  }
  
  double ans = 0;
  for (int i = 0; i < N - 1; i++){
    for (int j = i + 1; j < N; j++){
      double X = XY[i].first - XY[j].first;
      double Y = XY[i].second - XY[j].second;
      ans += sqrt(pow(X, 2) + pow(Y, 2)) * (N - 1);
    }
  }
  cout << setprecision(32) <<  ans / (N * (N - 1) / 2) << endl;
  

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public void solve(){
        Scanner sc=new Scanner(System.in);
    int x=sc.nextInt();
    int  a=x*x*x;
        System.out.println(a);
    }

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

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

int main(){
	char s[1000];
	cin.getline(s,sizeof(s));
	for(int i=0;s[i]!='\0';i++){
		if((s[i]!=' ')&&(s[i]!='.')){
			putchar(s[i]-'a'+'A');
		}else{
			putchar(s[i]);
		}
	}cout<<endl;
	return 0;
}

Measured memory_bytes: 1112
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
        int n;
        cin>>n;
        int arr[n];
        for(int i=0;i<n;i++) cin>>arr[i];
        int dp[n];
        dp[0]=0;
        dp[1]=abs(arr[1]-arr[0]);
        for(int i=2; i<n; i++)
        {
                dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]));
        }
        cout<<dp[n-1];
        return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main() {
	int a, b, c;
	int answer = 0;

	scanf("%d %d %d", &a, &b, &c);

	for (; a <= b ; a++) {
		if (c % a == 0) {
			answer++;
		}
	}

	printf("%d\n", answer);


	return 0;
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

bool F[100][100];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int A, B;
	cin >> A >> B;
	for (int i = 1; i < 50; i += 2) {
		for (int j = 1; j < 100; j += 2) {
			if (--A) F[i][j] = true;
			else i = j = 1000;
		}
	}
	for (int i = 51; i < 100; i += 2) {
		for (int j = 1; j < 100; j += 2) {
			if (--B) F[i][j] = true;
			else i = j = 1000;
		}
	}
	cout << "100 100\n";
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			cout << ((F[i][j] ^ (i < 50)) ? '#' : '.');
		}
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
sss = [list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        if sss[i][j] == '#':
            continue
        else:
            cnt = 0
            for x in [-1, 0, 1]:
                for y in [-1, 0, 1]:
                    if 0 <= i + y < h and 0 <= j + x < w:
                        if sss[i + y][j + x] == '#':
                            cnt += 1

                    sss[i][j] = str(cnt)
for s in sss:
    print(''.join(s))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

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

int main(){
  fio();
  int k; cin>>k;
  string s; cin>>s;
  int t = 0;
  for(auto i:s){
  	if(t<k) cout<<i;
  	else break;
  	t++;
  }
  if(s.size()>k) cout<<"...";
  cout<<endl;
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

int a[100][100];
int b[100][100];
int c[100][100];

int main() {
  int H,W;
  while(cin>>H>>W) {
    REP(i,H)REP(j,W) cin >> a[i][j];
    REP(i,H)REP(j,W)cin>>b[i][j];
    int h,w; cin >> h >> w;
    REP(i,h)REP(j,w)cin>>c[i][j];
    ll ans = -(1LL<<60);
    REP(i,H-h+1)REP(j,W-w+1) {
      bool ok = 1;
      int sum = 0;
      REP(i2,h) {
        REP(j2,w) {
          sum += a[i+i2][j+j2];
          if (b[i+i2][j+j2] != c[i2][j2])
            ok = 0;
        }
      }
      if (ok) {
        chmax(ans, sum);
      }
    }
    if (ans == -(1LL<<60)) puts("NA");
    else cout << ans << endl;
  }
}


Measured memory_bytes: 1208
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
 
struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(20);
    }
}INIT;

LL n, k;
int a[404040];

LL ps[64][202020];

int main(){
    cin >> n >> k;
    REP(i, n)cin >> a[i];
    REP(i, n)a[i + n] = a[i];

    map<int, int> nxt;
    for(int i = 2 * n - 1;i >= 0;i--){
        if(i < n){
            ps[0][i] = nxt[a[i]] - i + 1;
        }
        nxt[a[i]] = i;
    }

    REP(i, 63){
        REP(j, 202020){
            if(ps[i][j] == HINF<LL>()){
                ps[i + 1][j] = HINF<LL>();
            }else{
                ps[i + 1][j] = ps[i][j] + ps[i][(j + ps[i][j]) % n];
                if(ps[i + 1][j] > HINF<LL>())ps[i + 1][j] = HINF<LL>();
            }
        }
    }

    LL len = n * k;
    LL pos = 0;

    for(int i = 63;i >= 0;i--){
        if(pos + ps[i][pos % n] <= len){
            pos += ps[i][pos % n];
        }
    }

    vector<int> ans;
    set<int> st;

    for(;pos < len;pos++){
        int x = a[pos % n];
        if(st.count(x)){
            while(st.count(x)){
                st.erase(ans.back());
                ans.pop_back();
            }
        }else{
            st.insert(x);
            ans.emplace_back(x);
        }
    }
    REP(i, (int)ans.size()){
        if(i)cout << " ";
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 123636
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,s = inpl()
res = 0
for i in range(n+1):
    for j in range(n+1):
        if 0 <= s - (i+j) <= n:
            res += 1
print(res)

Measured memory_bytes: 5248
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>

using namespace std;
int main (){
    int N;
    scanf("%d",&N);
    vector<tuple<string,int,int>> eval(N);
    for (int i = 0; i < N; i++){
        cin >> get<0>(eval[i]) >> get<1>(eval[i]);
        get<2>(eval[i]) = i+1;
        get<1>(eval[i])*=-1;
    }
    sort(eval.begin(),eval.end());
    for (int i = 0; i < N; i++){
        cout << get<2>(eval[i]) << endl;
    }
}


Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
#define time_passed 1.0 * clock() / CLOCKS_PER_SEC
ll MOD = 1e9 + 7;
ll MOD1 = 1e9 + 123;
ll MOD2 = 1e9 + 321;
vector<int> G[1000000];
vector<int> L(1000000, 0);
vector<int> vis(1000000, 0);
void dfs(ll y, ll c)
{
  vis[y] = c;

  for (auto h : G[y])
  {
    if (vis[h] == 0)
      dfs(h, c);
  }
}
int main()
{
    fio;
    ll t, c, p, a, n, q, k, i, l, m, u, f, j, x, y, b, z, d;
cin>>n>>m;
for(i=1;i<=m;i++)
cin>>a>>b,G[a].pb(b),G[b].pb(a);
c=0;

for (i = 1; i <= n; i++)
if(vis[i]==0)
dfs(i,++c);
cout<<c-1<<endl;
  return 0;
}

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

using namespace std;

int main(void) {
    int w,h,x,y,r;
    cin >>w>>h>>x>>y>>r;
    if(x+r<=w && x-r >=0){
        if(y+r<=h && y -r >=0){
            cout << "Yes"<<endl;
            return 0;
        }
    }
    cout <<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3120
n,m = map(int, input().split())
p = [0] * m
s = [0] * m
for i in range(m):
     p[i],s[i] = map(str,input().split())

lisa = [0] * n
lisw = [0] * n
for i in range(m):
     if lisa[int(p[i])-1] == 0:
          if s[i] == 'WA':
               lisw[int(p[i]) - 1] += 1
          else:
               lisa[int(p[i])-1] = 1
num = 0
for i in range(n):
     if lisa[i] == 1:
          num += lisw[i]



print(sum(lisa),num)

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

int main() {
    int h, w;
    while (true) {
        cin >> h >> w;
        if ((h == 0) && (w == 0)) {
            break;
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if ((i == 0) || (i == h - 1) || (j == 0) || (j == w - 1)) {
                    cout << "#";
                }
                else {
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0), cin.tie(0)
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const int inf = ~0u >> 1;
int d[maxn], h[maxn];
int main() {
    IO;
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> h[i];
    }
    d[1] = 0;
    d[2] = abs(h[2] - h[1]);
    for (int i = 3; i <= n; ++i) {
        d[i] = min(abs(h[i - 1] - h[i]) + d[i - 1], abs(h[i - 2] - h[i]) + d[i - 2]);
    }
    cout << d[n] << endl;
    return 0;
}

Measured memory_bytes: 4348
A = list(map(int, input().split()))

ans = float("inf")
for i in range(len(A)):
    for j in range(len(A)):
        for k in range(len(A)):
            if i == j or j == k or k == i:
                continue
            tmp = abs(A[j] - A[i]) + abs(A[k] - A[j])
            ans = min(ans, tmp)
print(ans)




Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

int main(void) {
	int N, d[50];
	cin >> N;
	for (int i=0; i<N; i++) cin >> d[i];
	int sum = 0;
	for (int i=0; i<N; i++) for (int j=0; j<N; j++) {
		if (i != j) sum += d[i] * d[j];
	}
	cout << sum / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  ll A,B,C,D;
  cin>>A>>B>>C>>D;
  ll CC,CC2,DD,DD2,CD,CD2;
  
  CC=B/C;
  CC2=(A-1)/C;
  CC-=CC2;
  
  DD=B/D;
  DD2=(A-1)/D;
  DD-=DD2;
  
  vector<ll> Q(2);
  Q[0]=min(C,D),Q[1]=max(C,D);
  while(Q[0]!=0){
    Q[1]%=Q[0];
    sort(all(Q));
  }
  ll X=C*D/Q[1];
  CD=B/X;
  CD2=(A-1)/X;
  CD-=CD2;
  
  cout<<B-A+1-CC-DD+CD<<endl;
}



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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

template<typename T> class RPQ : public PQ<T, vector<T>, greater<T>> { };
template<typename Cost> void dijkstra(int start, vector<pair<int, Cost>> g[], Cost dist[]) {
	RPQ<pair<Cost, int>> q;
	dist[start] = 0;
	q.emplace(dist[start], start);
	while(! q.empty()) {
		auto cp = q.top(); q.pop();
		int  p = cp.SE;
		Cost c = cp.FI;
		if(dist[p] != c) { continue; }
		for(auto && e : g[p]) {
			int  ep = e.FI;
			Cost ec = e.SE;
			if(setmin(dist[ep], dist[p] + ec)) { q.emplace(dist[ep], ep); }
		}
	}
	return;
}

int n, d[100001];
vector<pair<int, int>> g[100001];

int main() {
	cin >> n;
	
	incII(i, 0, n) { d[i] = n + 1; }
	
	inc(i, n) {
		g[i].EB(i + 1, 1);
		int p;
		p = 1; inc(j, 10) { p *= 6; if(i + p > n) { break; } g[i].EB(i + p, 1); }
		p = 1; inc(j, 10) { p *= 9; if(i + p > n) { break; } g[i].EB(i + p, 1); }
	}
	
	dijkstra(0, g, d);
	
	cout << d[n] << endl;
	
	// incII(i, 0, n) { cout << i << ": " << d[i] << endl; }
	// for(auto && e: g[0]) { cout << e.FI << endl; }
	
	return 0;
}


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

int main(){
    bool is_prime[1000000];

    is_prime[0] = is_prime[1] = false;
    for(int i=2;i<1000000;i++)
        is_prime[i] = true;

    for(int i=2;i*i<1000000;i++){
        if(is_prime[i]){
            for(int j=i*i;j<1000000;j+=i){
                is_prime[j] = false;
            }
        }
    }

    int n_prime[1000000];
    int cnt(0);
    for(int i=0;i<1000000;i++){
        if(is_prime[i]) cnt++;
        n_prime[i] = cnt;
    }

    while(1){
        int n;
        cin >> n;

        if(cin.eof())   break;

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

    return 0;
}


Measured memory_bytes: 7864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
//INF = 1 061 109 567 ; INF + INF = 2 122 219 134 ;
//LINF = 4 557 430 888 798 830 399 ; LINF + LINF = 9 114 861 777 597 660 798 ;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9+7;
const int maxn = (int)1e5+7;

//浮点型运算
const db eps = 1e-6;
bool eq(const db &a, db const &b) { return fabs(a - b) < eps; }
bool ls(const db &a, db const &b) { return a + eps < b; }
bool le(const db &a, db const &b) { return eq(a, b) || ls(a, b); }

void Init() {
}

int main ()
{
    char s[10];
    scanf("%s", s);
    rep(Mask, 0, (1 << 3)) {
        //cout<<Mask<<endl;
        int n = Mask;
        int op[3];
        per(i, 0, 3) {
            if (n & 1) op[i] = 1;
            else op[i] = 0;
            n >>= 1;
        }
        //rep(i, 0, 3) printf("%d ", op[i]); cout<<endl;
        int temp = s[0] - '0';
        rep(i, 0, 3) {
            if (op[i] == 1) temp += s[i+1] - '0';
            else temp -= s[i+1] - '0';
        }
        if (temp == 7) {
            printf("%d%c%d%c%d%c%d=7\n", s[0] - '0', (op[0]) ? '+' : '-',
            s[1] - '0', (op[1]) ? '+' : '-',
            s[2] - '0', (op[2]) ? '+' : '-',
            s[3] - '0');

            return 0;
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
#define base 10000
#define maxn 100
using namespace std;
int main()
{

    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d\n",2*b-a);

    return 0;
}


Measured memory_bytes: 256
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	long ch(int n, int k) {
		return k == 0 ? 1 : ch(n - 1, k - 1) * n / k;
	}
	void main() {
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		long[] vv = new long[n];
		for (int i = 0; i < n; i++)
			vv[i] = sc.nextLong();
		vv = Arrays.stream(vv).boxed().sorted((u, v) -> Long.signum(v - u)).mapToLong($->$).toArray();
		long sum = 0; int cnt = 0;
		long sum_ = 0; int cnt_ = 1; long ways = 0;
		for (int i = 0, j; i < n; i = j) {
			j = i + 1;
			while (j < n && vv[j] == vv[i])
				j++;
			int k = j - i;
			for (j = i; j < n && vv[j] == vv[i]; j++) {
				sum += vv[j];
				cnt++;
				if (a <= j + 1 && j + 1 <= b) {
					if (sum_ * cnt < sum * cnt_) {
						sum_ = sum;
						cnt_ = cnt;
						ways = ch(k, j - i + 1);
					} else if (sum_ * cnt == sum * cnt_)
						ways += ch(k, j - i + 1);
				}
			}
		}
		printf("%f\n%d\n", (double) sum_ / cnt_, ways);
	}
}


Measured memory_bytes: 36788
#include <cstdio>
#include <algorithm>
using namespace std;

int a[(int)1e5 + 10];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	int begin = 0;
	while (true) {
		sort(a + begin, a + n);
		while (a[begin] == 0) begin++;
		if (begin == n - 1) break;
		for (int i = begin + 1; i < n; i++) {
			a[i] %= a[begin];
			if (a[i] == 1) {
				puts("1");
				return 0;
			}
		}
	}
	printf("%d\n", a[n-1]);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  int c,d,e,f,g;
  int count=0;
  for (A; A<=B; A++){
    
   c = A / 10000;
   d = (A-c*10000)/1000;
   e = (A-c*10000-d*1000)/100;
   f = (A-c*10000-d*1000-e*100)/10;
   g = A % 10;
    
   if( c==g && d == f ){
   	 count++;
   }
  }
       cout << count <<endl;
}

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

#define MAXN 10
#define INF 0x3f3f3f3f
int D,G;
int P[MAXN+5],C[MAXN+5];

int main(){
    scanf("%d%d",&D,&G);
    for(int i=1;i<=D;i++)
        scanf("%d%d",&P[i],&C[i]);
    int Max=(1<<D)-1,Ans=INF;
    for(int i=0;i<=Max;i++){
        int cnt=0,rest=G;
        for(int j=D;j>=1&&rest>0;j--)
            if(i&(1<<(j-1))){
                int tmp=P[j]*j*100;
                if(tmp>=rest){
                    cnt+=(rest+100*j-1)/(100*j);
                    rest=0;
                    break;
                }
                else{
                    rest-=tmp+C[j];
                    cnt+=P[j];
                }
            }
        if(rest<=0)
            Ans=min(Ans,cnt);
    }
    printf("%d",Ans);
}


Measured memory_bytes: 128
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x, vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
//#define min(a, b, c) min(a, min(b, c))
//#define max(a, b, c) max(a, max(b, c))
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp;
string str;
set<ll> s;
vll v;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	cin>>a>>b;
	if(a>b)
	{
	    swap(a,b);
	}
	if((b-a)%2==0)
	cout<<(b-a)/2;
	else
	{
	    ll mi=2*1000000000000000000;
	    ll temp1=a;
	    ll temp2=b;
	    temp=a-1;
	    b-=temp;
	    if((b-1)%2==0)
	    {
	        mi=min(mi,temp+(b-1)/2);
	    }
	    else
	    {
	        mi=min(mi,temp+1+(b-1)/2);
	    }
	    //deb(mi);
	    a=temp1;
	    b=temp2;
	    temp=n-b;
	    a+=temp;
	    if((n-a)%2==0)
	    {
	        mi=min(mi,temp+(n-a)/2);
	    }
	    else
	    mi=min(mi,temp+1+(n-a)/2);
	    cout<<mi;
	}
}

Measured memory_bytes: 256
#include<cstdio>
 
const int mod=1000000007;
 
long long power(long long a,int k){
 
    long long ans=1,y=a;
 
    while(k){
 
        if(k%2)
 
            ans=ans*y%mod;
 
        y=y*y%mod;
 
        k=k/2;
 
    }
 
    return ans;
 
}
 
long long fun[1000005],ans=1;
 
int main(){
 
    long long n,m;
 
    scanf("%lld%lld",&n,&m);
 
    fun[0]=1;
 
    for(int i=1;i<1000005;i++){
 
        fun[i]=fun[i-1]*i%mod;
 
    }
 
    for(int i=2;i*i<=m;i++){
 
        if(m%i==0){
 
            long long s=0;
 
            while (m%i==0) {
 
                m=m/i;
 
                s++;
 
            }
 
            ans=ans*fun[n+s-1]%mod*power(fun[n-1], mod-2)%mod*power(fun[s], mod-2)%mod;
 
        }
 
    }
 
    if(m>1)
 
        ans=ans*n%mod;
 
    printf("%lld\n",ans);
 
    return 0;
 
}

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


int main()
{
	//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	//#endif
	
	//int t;
	//cin>>t;
	//while(t--)
	{
		int n,w;
		cin>>n>>w;
		int a[n][2];
		for(int i=0;i<n;i++)
		{
			cin>>a[i][0]>>a[i][1];
		}
		ll dp[100000+1];
		memset(dp,0x3f,sizeof(dp));
		dp[0]=0;
		for(int i=0;i<n;i++)
		{
			for(int j=100000;j>=0;j--)
			{
				if(j-a[i][1]>=0)
					dp[j]=min(dp[j],dp[j-a[i][1]]+a[i][0]);
			}
		}
		ll ans=0;
		for(int i=0;i<=100000;i++)
		{
			if(dp[i]<=w)
			{
				ans=max(ans,(ll)i);
			}
		}
		cout<<ans<<'\n';
		
		
	}
		
}


Measured memory_bytes: 4376