akhauriyash/Code-Regression huggingface dataset:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left 
import sys,math,itertools,fractions,pprint
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,m = inpl()
a = inpl()
a.sort(reverse = True)
su = sum(a)
res = 0
for i in range(m):
    if a[i]*4*m < su:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 64748
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
double square(int SQ){
	double KAGA;
	KAGA=SQ*SQ;
	return KAGA;
}
int main(){
	string s,kaga="0123456789abcdef";
	string color[8]={"black","blue","lime","aqua","red","fuchsia","yellow","white"};
	int RK[8]={0,0,0,0,255,255,255,255};
	int GK[8]={0,0,255,255,0,0,255,255};
	int BK[8]={0,255,0,255,0,255,0,255};
	int C[3];
	double tmp;
	double MIN;
	string ans;
	while(cin>>s,s!="0"){
		for(int i=2,j=0;j<3;i+=2,j++){
			C[j]=0;
			for(int k=0;k<20;k++){
				if(s[i]==kaga[k]){
					C[j]+=k;
					k+=30;
				}
			}
			for(int k=0;k<20;k++){
				if(s[i-1]==kaga[k]){
					C[j]+=k*16;
					k+=30;
				}
			}
		}
		
		ans="?";
		MIN=10000000;
		
		for(int i=0;i<8;i++){
			tmp=sqrt(square(C[0]-RK[i])+square(C[1]-GK[i])+square(C[2]-BK[i]));
			if(MIN>tmp){
				MIN=tmp;
				ans=color[i];
			}
		}
		
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 1188
import numpy as np
import sys
input = sys.stdin.readline
 
n = int(input())
a = list(map(int,input().split()))
ans = 1

for i in a:
    ans *= i
    if ans > 10**18:
        ans = -1
        break
 
if 0 in a:
    ans = 0

print(ans)

Measured memory_bytes: 39996
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
#define F first
#define S second
using namespace std;

typedef long long ll;
ll n, k;
pair<ll, ll> a[N];
int main()
{
	int i;
	cin >> n >> k;
	for (i = 0; i < n; i++) scanf("%lld %lld", &a[i].F, &a[i].S);
	sort(a, a + n);
	for (i = 0; k > 0; k -= a[i++].S);
	cout << a[i - 1].F;
    return 0;
}

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

vector<int> v[100009], ans;
bool vs[100009];

void dfs(int n)
{
	vs[n] = true; ans.push_back(n);
	for (int i = 0; i < v[n].size(); i++)
		if (!vs[v[n][i]]) {
			dfs(v[n][i]);
			return;
		}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		v[a].push_back(b); v[b].push_back(a);
	}
	int c = 0; vs[1] = true;
	for (int i = 0; i < v[1].size(); i++) {
		if (!vs[v[1][i]]) {
			dfs(v[1][i]);
			c++;
			if (c == 1) {
				reverse(ans.begin(), ans.end()); ans.push_back(1);
			}
		}
		if (c >= 2) break;
	}
	cout << ans.size() << '\n';
	for (int i = 0; i < ans.size(); i++)
		cout << ans[i] << " ";
	cout << '\n';
	return 0;
}

Measured memory_bytes: 9848
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#define ll long long
#define add push_back
using namespace std; 

int main() {

    ios::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);

    int t;  t = 1; //cin >> t;
    while(t--){
        ll n; cin >> n;
        ll answ = 0;
        for(int i = 1; i <= n; i++){
            ll a1 = i;
            ll an = n - n % i;
            ll N = (an - a1) / i + 1;
            ll sn = ((a1 + an) * N) / 2;
            //cout << a1 << " " << an << " " << N <<" " << sn << endl;
            answ += sn;
        }
        cout << answ << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>
double h(double x1,double y1,double x2,double y2,double px,double py){
	  double ax, ay, bx, by;
	  ax = x2 - x1;
	  ay = y2 - y1;
	  bx = px - x1;
	  by = py - y1;
	  return ax*by-ay*bx;
}
int main()
{
	double x1,x2,x3,y1,y2,y3,xp,yp,a,b,c;
	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
		a=h(x1,y1,x2,y2,xp,yp);
		b=h(x2,y2,x3,y3,xp,yp);
		c=h(x3,y3,x1,y1,xp,yp);
		if((a>0&&b>0&&c>0)||(a<0&&b<0&&c<0)){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}

	return 0;
}

Measured memory_bytes: 2588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    int need = 1;
    rep(i, n) {
        if (a[i] == need) {
            ++need;
        }
    }
    if (n - (need - 1) == n) cout << -1 << endl;
    else cout << n - (need - 1) << endl;
}


Measured memory_bytes: 4000
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
 
int p[201010];
int q[201010];
int c[201010];
 
map<pair<int,int>,int> idx;
//map<int,pair<int,int> > vtx;
int cnt=0;	
void doit(pair<int,int> v){
	if(idx.count(v)>0)return;
	//printf("%d %d: %d\n",v.first,v.second,cnt);
	idx[v]=cnt;
//	vtx[cnt]=v;
	cnt++;
}
 
 
main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d%d",&p[i],&q[i],&c[i]);p[i]--;q[i]--;
	}
	
	
	doit(make_pair(0,-1));
	doit(make_pair(n-1,-1));
	
	for(int i=0;i<m;i++){
		doit(make_pair(p[i],-1));
		doit(make_pair(q[i],-1));
		
		doit(make_pair(p[i],c[i]));
		doit(make_pair(q[i],c[i]));
	}
	
	vector<vector<pair<int,int> > > adj(idx.size());
 
	for(int i=0;i<m;i++){
		int w=idx[make_pair(p[i],-1)];
		int x=idx[make_pair(p[i],c[i])];
		int y=idx[make_pair(q[i],c[i])];
		int z=idx[make_pair(q[i],-1)];
		adj[w].push_back(make_pair(x,1));
		adj[x].push_back(make_pair(y,0));
		adj[y].push_back(make_pair(z,0));
		adj[z].push_back(make_pair(y,1));
		adj[y].push_back(make_pair(x,0));
		adj[x].push_back(make_pair(w,0));
		//printf("%d--%d--%d--%d\n",w,x,y,z);
	}
	int st=0;
	int go=1;
	
	
	multimap<int,int> que;
	vector<int> cost(idx.size(),1010101010);
	cost[st]=0;
	que.insert(make_pair(0,st));
	int ans=-1;
	for(;!que.empty();){
		pair<int,int> fr=*(que.begin());
		que.erase(que.begin());
		int c=fr.first;
		int now=fr.second;
		
		if(now==go){
			ans=c;
			break;
		}
		
		int s=adj[now].size();
		for(int i=0;i<s;i++){
			int next=adj[now][i].first;
			int edgc=adj[now][i].second;
			if(cost[next]>c+edgc){
				cost[next]=c+edgc;
				que.insert(make_pair(cost[next],next));
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 70528
# import bisect
from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
import math

import sys

# import numpy as np

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


def main():
    s = int(input())

    CONST = 10**9

    if s % CONST != 0:
        a = CONST
        d = math.ceil(s/CONST)
        b = CONST - (s % CONST)
        c = 1
    else:
        a = CONST
        b = 0
        c = CONST
        d = s // CONST

    print(0, 0, a, b, c, d)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
h, w = map(int, input().split())
a = []
for i in range(h):
    tmp = list(input())
    a.append(tmp)
H = [0] * h
W = [0] * w

b = list(zip(*a))

for i in range(h):
    if a[i].count('#') != 0:
        H[i] = 1

for i in range(w):
    if b[i].count('#') != 0:
        W[i] = 1

c = []
for i in range(h):
    tmp = []
    for j in range(w):
        if H[i] == 1 and W[j] == 1:
            tmp.append(a[i][j])
    if tmp != []:
        c.append(tmp)

for i in range(len(c)):
    print(''.join(c[i]))

Measured memory_bytes: 9416
N = int(input())
A = list(map(int,input().split()))
minus = 0
Min = float("inf")
ans = 0
for i in range(N):
  if A[i] < 0:
    minus += 1
  Min = min(Min,abs(A[i]))
  ans += abs(A[i])
if minus % 2 == 0:
  print(ans)
else:
  print(ans - (2 * Min))

Measured memory_bytes: 14332
import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;
 
public class Main {
	static final long MOD = 998244353L;
	//static final long INF = -1000000000000000007L;
	//static final long MOD = 1000000007L;
	//static final int INF = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		//int N = sc.ni();
		String S = sc.next();
		String T = sc.next();
		pw.println(T + S);
		pw.close();
	}
	
	//Find the GCD of two numbers
	public static long gcd(long a, long b) {
		if (b == 0)
			return a;
		else
			return gcd(b,a%b);
	}
	
	//Fast exponentiation (x^y mod m)
	public static long power(long x, long y, long m) { 
		long ans = 1;
		x %= m;
		while (y > 0) { 
			if(y % 2 == 1) 
				ans = (ans * x) % m; 
			y /= 2;  
			x = (x * x) % m;
		} 
		return ans; 
	}
	
    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
        	  public int compare(int[] arr1, int[] arr2) {
				  return arr1[1]-arr2[1]; //ascending order
	          }
		});
		return array;
	}
    
    public static long[][] sort(long[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    long[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<long[]>() {
			  @Override
        	  public int compare(long[] arr1, long[] arr2) {
				  return 0;
	          }
		});
		return array;
	}
    
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int ni() { 
            return Integer.parseInt(next()); 
        } 
  
        long nl() { 
            return Long.parseLong(next()); 
        } 
  
        double nd() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str;
        }
    }
}

Measured memory_bytes: 19540
package main

import (
	"fmt"
	"math"
)

func main() {
	var A, B, C int
	fmt.Scanf("%d", &A)
	fmt.Scanf("%d", &B)
	fmt.Scanf("%d", &C)

	fmt.Println(math.Max(float64(C-(A-B)), 0))
}


Measured memory_bytes: 512
function Main(input){
	input = input.split("\n");
  var NM = input[0].split(" ");
  var N = NM[0]*1;
  var M = NM[1]*1;
  var prefs = [];
  var cities = [];
  for(var i = 0;i < M;i++){
  	var a = input[i+1];
    var P = a.split(" ")[0]*1;
    var Y = a.split(" ")[1]*1;
    if(prefs[P]===undefined)prefs[P] = [];
    prefs[P].push({i:i,pref:P,year:Y});
  }
  for(var i = 0;i <= N;i++){
  	var pref = prefs[i];
    if(!pref)continue;
    pref.sort(function(a,b){
    	return a.year-b.year;
    })
    for(var j = 0;j < pref.length;j++){
    	pref[j].ID = ("00000"+pref[j].pref).slice(-6)+("00000"+(j+1)).slice(-6);
      cities.push(pref[j]);
    }
  }
  cities.sort(function(a,b){
  	return a.i-b.i;
  })
  return cities.map(a=>a.ID).join("\n");
}

console.log(Main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 84596
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        boolean[][] a = new boolean[h][w];
        for (int i = 0; i < h; i++) {
            String s = sc.next();
            for (int j = 0; j < w; j++) {
                if (s.charAt(j) == '.')
                    a[i][j] = true;
            }
        }

        while (true) {
            int x = -1;
            int y = -1;
            for (int i = 0; i < h; i++) {
                boolean check = true;
                for (int j = 0; j < w; j++) {
                    check &= a[i][j];
                }
                if (check)
                    y = i;
            }
            for (int i = 0; i < w; i++) {
                boolean check = true;
                for (int j = 0; j < h; j++) {
                    check &= a[j][i];
                }
                if (check)
                    x = i;
            }

            if (x != -1) {
                boolean[][] nex = new boolean[h][w - 1];
                for (int i = 0; i < h; i++) {
                    for (int j = 0; j < w; j++) {
                        if (j == x)
                            continue;
                        if (j > x)
                            nex[i][j - 1] = a[i][j];
                        else
                            nex[i][j] = a[i][j];
                    }
                }
                w--;
                a = nex;
            } else if (y != -1) {
                boolean[][] nex = new boolean[h - 1][w];
                for (int i = 0; i < h; i++) {
                    for (int j = 0; j < w; j++) {
                        if (i == y)
                            continue;
                        if (i > y)
                            nex[i - 1][j] = a[i][j];
                        else
                            nex[i][j] = a[i][j];
                    }
                }
                h--;
                a = nex;
            } else {
                break;
            }
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                System.out.print(a[i][j] ? "." : "#");
            }
            System.out.println();
        }

    }

}


Measured memory_bytes: 26208
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*  ________       __      ________  _    __       __       ________               *
* |  ______|     /  \    |  ____  || |  / /      /  \     |  ____  |              *
* | |______     / /\ \   | |____| || |_/ /      / /\ \    | |____| |              *
* |______  |   / /__\ \  |  __  __||  __ \     / /__\ \   |  __  __|              *
*  ______| |  / ______ \ | |  \ \  | |  \ \   / ______ \  | |  \ \                *
* |________| /_/      \_\|_|   \_\ |_|   \_\ /_/      \_\ |_|   \_\               *
*                                                                                 *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________

#include<bits/stdc++.h>
using namespace std;

int main()
{
	int N,M;

	cin >> N >> M;

	if(N == M)
	{
		cout << "Yes" << endl;
	}
     
    else
    {
    	cout << "No" << endl;
    } 



	return 0;
}

Measured memory_bytes: 256
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5;
const int INF = INT_MAX;
const db PI = acos(-1);

int dp[N];
bool broken[N];

void test();

int main() {
    fast_io();
    test();
    return 0;
}

void test() {
    int n, k;
    cin >> n >> k;
    int a[k];
    for (int i = 0; i < k; ++i) {
        cin >> a[i];
        broken[a[i]] = true;
    }
    dp[0] = 1;
    for (int i = 1; i <= n; ++i) {
        if (i == 1) {
            if (!broken[i]) {
                dp[i] = 1;
            }
        } else {
            if (!broken[i]) {
                dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
            }
        }
    }
    cout << dp[n] << "\n";
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll combination(ll n, ll r) {
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
    ll divisor = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int main() {
	int n;
	cin >> n;
	vector<int>divisor(n);
	for (int i = n; i > 1; i--) {
		int k = 2;
		int tmp = i;
		while (tmp >= k ) {
			if (tmp%k == 0) {
				divisor[k-1]++;
				tmp /= k;
			}
			else {
				k++;
			}
			//cout << tmp << endl;
		}
    }
	ll count = 1;
	int M = 1e9 + 7;
	rep(i, n) {
		if (divisor[i] >= 1) {
			count *= (divisor[i] + 1);
			count %= M;
		}
	}
	cout << count << endl;
	
}


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

void bubbleSort(int A[], int N) {
    /// ソート後の配列と交換回数を標準出力する
    bool flag = true;
    int count = 0;
    while (flag) {
        flag = false;
        for (int j = N - 1; j >= 1; j--)
        {
            if (A[j] < A[j - 1]) {
                swap(A[j], A[j-1]);
                count++;
                flag = true;
            }
        }
    }
    for (int i = 0; i < N - 1; i++) {
        cout << A[i] << " ";
    }
    cout << A[N-1] << "\n" << count << endl;
}

int main() {
    int N;
    int A[1000];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    bubbleSort(A, N);
    return 0;
}


Measured memory_bytes: 3080
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		String input = scan.next();

		char[] inputArray = input.toCharArray();

		int ans = 0;

		for (int i = 0; i < inputArray.length; i++) {
			if (inputArray[i] == '1') {
				ans++;
			}
		}

		System.out.println(ans);

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 26968
import java.util.*;

public class Main {
  public static void main(String[] args) {
   
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int m = sc.nextInt();
    int stack;
    int ans;
    
    x -= m;
    
    for(int i = 1; i < n;i++){
      stack = sc.nextInt();
      x -= stack;
      if(m > stack) m = stack;
    }
    
    ans = n + x/m;
    System.out.println(ans);
  }
}


Measured memory_bytes: 35960
#include<stdio.h>
int main(void)
{
    int a,b,c;
    int i,count;
    while(scanf("%d %d",&a,&b) != EOF){
        c = a + b;
        count = 1;
        for(;;){
            if(c < 10) break;
            c = c / 10;
            count++;
        }
        printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int X, Y, A, B, C;
long long p[100000], q[100000], r[100000];
pair<long long, int> cand[200000];
int main() {
	
	cin >> X >> Y >> A >> B >> C;
	for (int i = 0; i < A; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < B; i++) {
		cin >> q[i];
	}
	for (int i = 0; i < C; i++) {
		cin >> r[i];
	}

	
	/*まず全部取る場合の候補を見つける*/
	sort(p, p + A);
	sort(q, q + B);
	
	for (int i = 0; i < X; i++) {
		cand[i] = make_pair(p[A - 1 - i], 0);
	}
	for (int i = 0; i < Y; i++) {
		cand[X + i] = make_pair(q[B - 1 - i], 1);
	}

	sort(cand, cand + X + Y);
	sort(r, r + C);
	
	long long ans = 0;
	for (int i = 0; i < X + Y; i++) {
//		cout << cand[i].first << " ";
		ans += cand[i].first;
	}

	long long kari = ans;

	int t = 0; 
	int Xrem = X;
	int Yrem = Y;
	for (int i = 0; i < X + Y; i++) {
//		cout << i << " ans: " << ans << " ";
		if (cand[i].second == 0 && Xrem>0) {
			kari = kari - cand[i].first + r[C - 1 - t];
			Xrem--; t++;
			if (ans < kari) { ans = kari; }
		}
		if (cand[i].second == 1 && Yrem > 0) {
			kari = kari - cand[i].first + r[C - 1 - t];
			Yrem--; t++;
			if (ans < kari) { ans = kari; }
		}
//		cout << "\n";
		if (t >= C) { break; }
	}

	cout << ans;
}


Measured memory_bytes: 5760
#include <stdio.h>

bool echo(int half, char S[]) {
  for(int i = 0; i < half; i++) {
    if(S[i] != S[i + half]) {
      return false;
    }
  }

  return true;
}

int main() {
  int N;
  char S[102];
  scanf("%d %s", &N, S);
  (N % 2 == 0 && echo(N/2, S)) ? puts("Yes") : puts("No");
  
  return 0;
}

Measured memory_bytes: 1616
class Dice:
    def __init__(self, default = [1, 2, 3, 4, 5, 6]):
        self.d = default

    def e(self):
        self.d[0], self.d[2], self.d[3], self.d[5] = self.d[3], self.d[0], self.d[5], self.d[2]

    def w(self):
        self.d[0], self.d[2], self.d[3], self.d[5] = self.d[2], self.d[5], self.d[0], self.d[3]

    def n(self):
        self.d[0], self.d[1], self.d[4], self.d[5] = self.d[1], self.d[5], self.d[0], self.d[4]

    def s(self):
        self.d[0], self.d[1], self.d[4], self.d[5] = self.d[4], self.d[0], self.d[5], self.d[1]

    def r(self):
        self.d[1], self.d[2], self.d[3], self.d[4] = self.d[3], self.d[1], self.d[4], self.d[2]

    def top(self):
        return self.d[0]

    def forward(self):
        return self.d[1]

    def right(self):
        return self.d[2]

    def bottom(self):
        return self.d[5]

    def forTop(self, num):  #ある目がトップd[0]になるように回転させる。トップ以外の状態は知らん。
        for i in range(4):
            if self.top() == num:
                break
            self.e()
        else:
            for j in range(3):
                if self.top() == num:
                    break
                self.s()
    def same(self, dice):
        if self.d == dice.d:
            return True

    def same_rotate(self, dice):
        saved_d = self.d[:]
        for i in range(4):
            for j in range(4):
                if self.same(dice):
                    self.d = saved_d
                    return True
                else:
                    self.e()
            self.s()
        for i in range(4):
            for j in range(4):
                if self.same(dice):
                    self.d = saved_d
                    return True
                else:
                    self.e()
            self.r()
        for i in range(4):
            for j in range(4):
                if self.same(dice):
                    self.d = saved_d
                    return True
                else:
                    self.s()
            self.r()
        self.d = saved_d
        return False



def main():
    n = int(input())
    data = [Dice(list(map(int, input().split()))) for _ in range(n)]

    for i in range(n - 1):
        for j in range(i + 1, n):
            if data[i].same_rotate(data[j]):
                print('No')
                return

    print('Yes')
    return





if __name__ == '__main__':
    main()







Measured memory_bytes: 5660
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

//////////////////////////

int main(){fastio
    
    string a,b;cin>>a>>b;
    rep(i,0,a.size()-1){
        if(a[i]!=b[i]){
            cout<<"No"<<endl;return 0;
        }
    }
    cout<<"Yes"<<endl;
    
    return 0;
}



Measured memory_bytes: 3672
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<vector>
#include <map>
#define I int
#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define P(a) printf("%d\n",a)
#define PL(a) printf("%lld\n",a)
#define PT(t) printf("Case %d: ",t)
#define PB(a) push_back(a)
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define ll long long 
using namespace std;
#define mx 500004
#define md 2000000000000000000ll
typedef pair<int, int >P;
typedef vector<ll>V;

////////define value/////

int main(){

   ll n,m,k;
   cin>>n>>m>>k;
   ll x= (n+m-k);
   if(x<0)x=0;
   if(n>=k)cout<<n-k<<" "<<m<<endl;
   else 
   cout<<0<<" "<<x<<endl;

    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

ll lcm(ll a, int b) {
    return a * b / gcd(a, b);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int w,h;
  while(cin>>w>>h,w+h){
    bool Map[h][w]={};
    pair<int,int> uMap[h][w][2]={};
    pair<int,int> wMap[h][w][2]={};
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	for(int k=0;k<2;k++){
	  uMap[i][j][k]=mp(-1,-1);
	  wMap[i][j][k]=mp(-1,-1);
	}
      }
    }
    for(int i=0;i<2*h-1;i++){
      if(i%2==0){
	for(int j=1;j<w;j++){
	  int aa;
	  cin>>aa;
	  if(aa){
	    int point=0;
	    if(uMap[i/2][j][0].F>=0)point++;
	    uMap[i/2][j][point]=mp(i/2,j-1);
	    point =0;
	    if(uMap[i/2][j-1][0].F>=0)point++;
	    uMap[i/2][j-1][point]=mp(i/2,j);
	  }
	}
      }else{
	for(int j=0;j<w;j++){
	  int aa;cin>>aa;
	  if(aa){
	    int point=0;
	    if(wMap[(i/2)+1][j][0].F>=0)point++;
	    wMap[(i/2)+1][j][point]=mp(i/2,j);
	    point=0;
	    if(wMap[i/2][j][0].F>=0)point++;
	    wMap[(i/2)][j][point]=mp((i/2)+1,j);
	  }
	}
      }
    }
    Map[0][0]=true;
    queue<pair<pair<int,int>,int > >que;
    que.push(mp(mp(0,0),0));
    int ans=-1;
    while(!que.empty()){
      pair<int,int> now=mp(que.front().F.F,que.front().F.S);
      int num=que.front().S;
      if(now.F==h-1&&now.S==w-1){
	//cout<<now.F<<" "<<now.S<<endl;
	ans=num;break;
      }
      que.pop();
      int vx[4]={0,1,0,-1};int vy[4]={1,0,-1,0};
      for(int i=0;i<4;i++){
	int a=now.F+vx[i],b=now.S+vy[i];
	if(i%2){
	  if((a>=0&&a<h&&b>=0&&b<w)&&(!(wMap[a][b][0].F==now.F&&wMap[a][b][0].S==now.S))&&(!(wMap[a][b][1].F==now.F&&wMap[a][b][1].S==now.S))&&(!Map[a][b])){
	    que.push(mp(mp(a,b),num+1));
	    Map[a][b]=true;
	  }
	}else{
	  if((a>=0&&a<h&&b>=0&&b<w)&&(!(uMap[a][b][0].F==now.F&&uMap[a][b][0].S==now.S))&&(!(uMap[a][b][1].F==now.F&&uMap[a][b][1].S==now.S))&&(!Map[a][b])){
	    que.push(mp(mp(a,b),num+1));
	    Map[a][b]=true;
	  }
	}
      }
    }
    cout<<ans+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 3104
import scala.io.StdIn

object Main extends App {
  val n: Array[Int] = StdIn.readLine().toCharArray.map(c => c - 48)
  var result = ""
  (0 to 1).foreach { ope1 =>
    (0 to 1).foreach { ope2 =>
      (0 to 1).foreach { ope3 =>
        val r1: Int = (if (ope1 == 1) n(0) + n(1) else n(0) - n(1))
        val r2: Int = (if (ope2 == 1) r1 + n(2) else r1 - n(2))
        val r3: Int = (if (ope3 == 1) r2 + n(3) else r2 - n(3))
        if (r3 == 7) {
          result = n(0).toString + (if (ope1 == 1) "+" else "-") + n(1).toString +
            (if (ope2 == 1) "+" else "-") + n(2).toString +
            (if (ope3 == 1) "+" else "-") + n(3).toString + "=7"
        }
      }
    }
  }
  
  println(result)
}


Measured memory_bytes: 27216
n, m, l = map(int, input().split())
a = []
b = []

for i in range(n):
    a.append(list(map(int, input().split())))

for j in range(m):
    b.append(list(map(int, input().split())))

for i in range(n):
    c = []
    for j in range(l):
        matrix = 0
        for k in range(m):
            matrix += a[i][k] * b[k][j]
        c.append(matrix)
    print(*c)



Measured memory_bytes: 6572
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// for(auto i : MP){
//   cout << i.first << " " << i.second << endl;
// }
map<ll, ll> PrimeFac(ll n){
  map<ll, ll> mp;
  ll cnt = 0;
  while(n%2 == 0){
    n /= 2;
    cnt++;
  }
  if(cnt != 0) mp[2] = cnt;
  for(ll i = 3; i*i <= n; i += 2){
    cnt = 0;
    while(n%i == 0){
      n /= i;
      cnt++;
    }
    if(cnt != 0) mp[i] = cnt;
  }
  if(n != 1) mp[n] = 1;
  return mp;
}

ll func(ll n){
  ll cnt = 1, res = 1;
  for(ll i = 2; i < 65; i++){
    cnt += i;
    if(n < cnt) break;
    res++;
  }
  return res;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N; cin >> N;
  auto MP = PrimeFac(N);
  ll ans = 0;
  for(auto i : MP){
    ans += func(i.second);
  }
  cout << ans << endl;
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
//const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    vector<string> nums;
    rep(a,10)rep(b,10)rep(c,10){
        nums.emplace_back(to_string(a)+to_string(b)+to_string(c));
    }
    
    int n; string s;
    cin >> n >> s;
    
    int ans = 0;
    for(string t : nums){
        for(char c : s){
            if(t.back() == c){
                t.pop_back();
                if(t.empty()){ ans++; break; }
            }
        }
    }
    
    cout << ans << endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

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

    if (a == b)
        OP(c);
    else if (b == c)
        OP(a);
    else if (c == a)
        OP(b);

        
    return 0;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	long long int MOD = 998244353;
	
	int N;
	cin >> N;

	vector<int> d;

	rep(i, N){
		int a;
		cin >> a;
		d.push_back(a);
	}

	// 要素が１つのとき
	if(N == 1){
		if(d[0] != 0){
			cout << "0";
			return 0;
		}
		else{
			cout << "1";
			return 0;
		}
	}

	// 頂点１から頂点１への距離は０でなくてはならない
	if(d[0] != 0){
		cout << "0";
		return 0;
	}

	sort(all(d));
	
	// ０はただ１つでなければならない
	if(d[1] == 0){
		cout << "0";
		return 0;
	}

	// 距離は0, 1, 2, 3, 4, ...　のように連続しなければならない
	int con_front = 1;
	int con_back = 1;
	long long ans = 1;

	rep(i, N){
		if(i == N - 1){
			if (d[i - 1] == d[i]){
				rep(j, con_back % MOD){
					ans *= con_front % MOD;
					ans %= MOD;
				}
			}
			else{;
				ans *= (con_front % MOD);
				ans %= MOD;
			}

			break;
		}
		else{
			if(d[i + 1] != d[i] && d[i + 1] != d[i] + 1){
				cout << "0";
				return 0;
			}
		}

		if(d[i] == d[i + 1]){
			con_back++;
		}
		else{
			if(i != 0){
				rep(j, con_back % MOD)
				{
					ans *= con_front % MOD;
					ans %= MOD;
				}
			}
	
			con_front = con_back;
			con_back = 1;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <cmath>
#define ll long long
using namespace std;

int main() {
	int Q; cin >> Q;
	ll a, b;
	for(int i=0; i<Q; ++i){
	    cin >> a >> b;
	    if(a==b) cout << (a-1)*2 << endl;
	    else if(abs(a-b)==1) cout << (min(a, b)-1)*2 << endl;
	    else{
	        ll c=sqrt(a)*sqrt(b);
	        if(c*c==a*b) cout << 2*c-3 << endl;
	        else if(c*(c+1)>=a*b) cout << 2*c-2 << endl;
	        else cout << 2*c-1 << endl;
	    }
	}
	return 0;
}


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

// template < typename T >
// void (const vector < T > & )

void solve () {

}

double dist (pii a, pii b) {
    ll dist_sqr = (a.first - b.first) * (a.first - b.first)
                     + (a.second - b.second) * (a.second - b.second);
    return sqrt (dist_sqr);
}

int main() {
    int n;
    cin >> n;
    vector < pii > a (n);
    for (pii & x : a) scanf ("%d %d", & (x.first), & (x.second));
    double totalDistance = 0.0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            totalDistance += dist (a[i], a[j]);
        }
    }
    printf ("%.6lf\n", totalDistance / n);
    return 0;
}


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

int main(void){
  int n;
  cin >> n;
  vector<string> words(n);
  for(int i = 0; i < n; i++){
    cin >> words[i];
  }

  for(int i = 0; i < n; i++){
    if(count(words.begin(), words.end(), words[i]) > 1){
      cout << "No" << endl;
      return 0;
    }
    if(i != n-1 && words[i].back() != words[i+1].front()){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<map>
#include<cmath>
using namespace std;




int main(){

int X,ans,i,j,max;

std::cin >> X;



if(X==1){
  max=1;

}

else{

for(i=2;i<=sqrt(X);i++){
  for(j=2;pow(i,j)<=X;j++){
     ans=pow(i,j);
     if(max<ans) max=ans;

  }

}

}

std::cout << max << '\n';








  return 0;
}


Measured memory_bytes: 384
/*
  -------------
  Prateek Celly
  DA-IICT
  -------------
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007

bool comp(pair<string,ll> a,pair<string,ll> b){
  if(a.ff==b.ff) return a.ss>b.ss;
  return a.ff<b.ff;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin>>n;
  pair<string,ll> p[n];
  map<pair<string,ll>,ll > m;
  for(ll i=0;i<n;i++) cin>>p[i].ff>>p[i].ss,m[p[i]]=i+1;
  sort(p,p+n,comp);
  for(ll i=0;i<n;i++) cout<<m[p[i]]<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  string s = "";
  while (n--) {
    s = char(n % 26 + 'a') + s;
    n /= 26;
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  int negatives = 0;
  int smallest = -1;
  int smallestIndex = -1;
  for (int i = 0; i < n; i++) {
    int v = a.at(i);
    if (v < 0) {
      negatives++;
    }
    int absed = abs(v);
    if (smallest == -1 || smallest > absed) {
      smallest = absed;
      smallestIndex = i;
    }
  }

  long sum = 0;
  bool evenNegatives = negatives%2 == 0;
  for (int i = 0; i < n; i++) {
    if (evenNegatives || smallestIndex != i) {
      sum += abs(a.at(i));
    } else {
      sum -= abs(a.at(i));
    }
  }
  cout << sum << endl;
  return 0;
}


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

void Value_Check(int *p,int key){
    
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(*(p + i * 3 + j) == key){
                *(p + i * 3 + j) = 0;
                return;
            }
        }
    }
}

void Hit_Check(int *p,bool *flag){

    int sum;
    
    //横チェック
    for(int i=0;i<3;i++){
        sum = 0;
        for(int j=0;j<3;j++){
            if(*(p + i * 3 + j) == 0){
                sum++;
            }
        }
        
        if(sum == 3){
            *flag = true;
            return;
        }
    }
    
    //縦チェック
    for(int i=0;i<3;i++){
        sum = 0;
        for(int j=0;j<3;j++){
            if(*(p + j * 3 + i) == 0){
                sum++;
            }
        }
        
        if(sum == 3){
            *flag = true;
            return;
        }
    }
    
    //斜めチェック
    sum = 0;
    for(int i=0;i<3;i++){
        if(*(p + i * 3 + i) == 0){
            sum++;
        }
    }
    
    if(sum == 3){
        *flag = true;
        return;
    }
    
    sum = 0;
    for(int i=0;i<3;i++){
        if(*(p + i * 3 + (2-i)) == 0){
            sum++;
        }
    }
    
    if(sum == 3){
        *flag = true;
        return;
    }
}

int main(void){
    
    int data[3][3];
    int N;
    bool flag = false;
    
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> data[i][j];
        }
    }
    
    cin >> N;
    
    for(int i=0;i<N;i++){
        int b_i;
        cin >> b_i;
        Value_Check(&data[0][0],b_i);
    }
    
    Hit_Check(&data[0][0],&flag);
    
    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M, Q;
vi G[MAX_N];

int ans[MAX_N];
pi MQ[MAX_N][11]; //[v][dist]=pi(id,color) 

void solve() {
	cin >> N >> M;
	rep(i, 0, M) {
		int a, b;
		cin >> a >> b; a--; b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	cin >> Q;
	rep(i, 0, N) 
		rep(j, 0, 11) MQ[i][j] = pi(-1, 0);

	rep(i, 0, Q) {
		int v, d, c;
		cin >> v >> d >> c; v--;
		pi p = pi(i, c);
		rep(j, 0, d + 1) {
			if(MQ[v][j] < p) {
				MQ[v][j] = p;
			}
		}
	}
	rep(q, 0, 10) {
		// rep(i, 0, N) debug(i, vector<pi>(MQ[i], MQ[i] + 11));
		rep(v, 0, N) {
			rep(i, 1, 11) {
				if(MQ[v][i].fst == -inf) continue;
				pi p = MQ[v][i];
				rep(j, 0, sz(G[v])) {
					int n = G[v][j];
					if(MQ[n][i - 1] < p) {
						MQ[n][i - 1] = p;
					}
				}
			}
		}
	}
	rep(i, 0, N) {
		cout << MQ[i][0].sec << "\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 20728