akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}


int main(){
    string a;cin >> a;
    ll len = a.size();
    // vector<ll> cnt(len,0);
    map<char,ll> mp;
    ll res = 0;
    mp[a[0]]++;
    for(int i = 1;i < len;i++){
        if(mp[a[i]] == 0){
            mp[a[i]]++;
            res += i;
        }
        else{
            res += i-mp[a[i]];
            mp[a[i]]++;
        }
        // print(a[i], mp[a[i]], res);
    }
    res++;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    ll n,k;
    in>>n>>k;
    cout<<min(n%k,k-n%k)<<'\n';
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		int[] input = new int[tmpArray.length];
		for(int i = 0; i < tmpArray.length ; i++){
			input[i] = Integer.parseInt(tmpArray[i]);
		}
		
		Arrays.sort(input);
		
		for(int i = input.length - 1; i >= 0; i--){
			System.out.print(input[i]);
			if(i != 0){
				System.out.print(" ");
			}
			else{
				System.out.println();
			}
		}
	}

}

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

int main() {
  string str;
  cin >> str;
  int q;
  cin >> q;
  for (int i{}; i < q; ++i) {
    string command;
    cin >> command;
    size_t a, b;
    cin >> a >> b;
    if (command == "print") {
      cout << str.substr(a, b - a + 1) << endl;
    } else if (command == "reverse") {
      auto first = str.begin() + a;
      auto last = first + b - a + 1;
      reverse(first, last);
    } else {
      string p;
      cin >> p;
      str.replace(a, b - a + 1, p);
    }
  }
  return 0;
}



Measured memory_bytes: 3184
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def check(N, v, honests, layers):
  for i in range(N):
    if (v >> i) & 1 == 0:
      continue
    elif (honests[i] & ~v) != 0:
      return False
    elif (layers[i] & v) != 0:
      return False

  return True


def main():
  N = int(input())
  honests = [0] * N
  layers = [0] * N
  result = 0

  for i in range(N):
    for _ in range(int(input())):
      x, y = map(int, input().split())
      if y == 1:
        honests[i] |= 1 << (x - 1)
      else:
        layers[i] |= 1 << (x - 1)

  for v in range(2 ** N):
    if check(N, v, honests, layers):
      result = max(sum((v >> i) & 1 for i in range(N)), result)

  print(result)


if __name__ == '__main__':
  main()


Measured memory_bytes: 42348
h,w = map(int, input().split())

def bisect(h, w):
    return h//2 * w, (h-h//2) * w

def solve(h, w):
    # 三
    h_3 = round(h/3)
    top = h_3*w
    middle, bottom = bisect(h-h_3, w)

    # 上部と別向き
    right, left = bisect(w, h-h_3)

    return min(
        max(top,middle,bottom) - min(top,middle,bottom),
        max(top,right,left) - min(top,right,left)
        )

if h%3 == 0 or w%3 == 0:
    print(0)
else:
    print(min(solve(h,w), solve(w,h)))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
 
ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}
int main(){
    ll n;
    cin>>n;
    ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<"\n";
}

Measured memory_bytes: 3628
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        SugarWater solver = new SugarWater();
        solver.solve(1, in, out);
        out.close();
    }

    static class SugarWater {
        int a;
        int b;
        int c;
        int d;
        int e;
        int f;
        double max = 0;
        int sugar;
        int water;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            a = in.nextInt();
            b = in.nextInt();
            c = in.nextInt();
            d = in.nextInt();
            e = in.nextInt(); // キャパ
            f = in.nextInt(); // Max濃度
            double limit = (double) e / (e + 100);

            for (int aa = 0; aa <= 30; aa++) {
                for (int bb = 0; bb <= 30; bb++) {
                    if (aa == 0 && bb == 0) {
                        continue;
                    }
                    for (int cc = 0; cc <= 100; cc++) {
                        for (int dd = 0; dd <= 100; dd++) {
                            int water = (aa * a * 100) + (bb * b * 100);
                            int sugar = (cc * c) + (dd * d);
                            if (f < sugar + water) {
                                continue;
                            }
                            if (limit < (double) sugar / (sugar + water)) {
                                continue;
                            }
                            double kosa = (double) 100 * sugar / (water + sugar);
                            if (max < kosa) {
                                max = kosa;
                                this.sugar = sugar;
                                this.water = water;
                            }
                        }
                    }
                }
            }

            if (max > 0) {
                out.println(sugar + water + " " + sugar);

            } else {
                out.println(100 * a + " " + 0);
            }

        }

    }
}



Measured memory_bytes: 39304
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] strArray = line.split(" ");
        int A = Integer.parseInt(strArray[0]);
        int B = Integer.parseInt(strArray[1]);
        int C = Integer.parseInt(strArray[2]);
        
        int capacity = A - B;
        int result = (C > capacity) ? C - capacity : 0;
        
        System.out.println(result);
    }



}

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

typedef unsigned uint;
typedef long long INT;
typedef unsigned long long UINT;
const int INF = 1001001001;
const INT INFLL = 1001001001001001001LL;

 int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
INT lin() { INT x; scanf("%lld", &x); return x; }

int main(){
    int a, b, c;
    double fa, fb, fc;
    char S[128], sa[128], sb[128], sc[128];
    // int N = in();
    // int K = in();
    // scanf("%s", S);

    int N = in();
    int K = in();

    UINT ullAns = 0;
    for (UINT k = K; k <= N + 1; ++k) {
        UINT Ak = ((k * (N - k + 1)) % (1000000000 + 7))  + 1;
        ullAns = (ullAns + (Ak % (1000000000 + 7))) % (1000000000 + 7);
    }

    printf("%llu", ullAns % (1000000000 + 7) );

    return 0;
}







Measured memory_bytes: 3800
#include<stdio.h>
int main(void){
   int c, n, ice[10], i;
   scanf("%d", &n);
   while ( n ) {
   for ( i = 0; i <= 9; i++ ) ice[i] = 0;
   for ( i = 0; i < n; i++ ) {
      scanf("%d", &c);
      ice[c]++;
   }
   for ( i = 0; i <= 9; i++ ) {
      if ( ice[i] > 0 ) {
         while ( ice[i] > 0) {
            printf("*", ice[i]);
            ice[i]--;
         }
      }else printf("-");
      printf("\n");
   }
   scanf("%d", &n);
   }
}

Measured memory_bytes: 1772
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	int a, b, c, k[105];
	cin >> a >> b >> c;
	for (int i = 0; i < a; ++i) { cin >> k[i]; }
	int ans = -1;
	for (int i = b - c; i <= b + c; ++i) {
		for (int j = 0; j < a; ++j) {
			if (i%k[j] == 0) {
				cout << j + 1 << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 3124
fun main(args: Array<String>) {
    val N = readLine()!!.map { it.toInt() }
    val b = readLine()!!.split(" ").map { it.toInt() }
    var list = mutableListOf<Int>()
    if (check(b.toMutableList(), list)) {
        for(i in list.reversed())
        println(i)
    } else {
        println(-1)
    }
}

fun check(b: MutableList<Int>, list: MutableList<Int>): Boolean {
    if (b.size == 0) {
        return true
    }
    for (i in b.size downTo 1) {
        if (i == b[i - 1]) {
            list.add(i)
            b.removeAt(i - 1)
            return check(b, list)
        }
    }
    return false
}

Measured memory_bytes: 37916
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
 
  int D;cin>>D;
  
  if(D==22){
    cout<<"Christmas Eve Eve Eve"<<endl;
  }
  else if(D==23){
    cout<<"Christmas Eve Eve"<<endl;
  }
  else if(D==24){
    cout<<"Christmas Eve"<<endl;
  }
  else{
    cout<<"Christmas"<<endl;
  }
}


Measured memory_bytes: 3572
#include<iostream>
#include<cstdio>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
#include<time.h>
#include<string.h>
#include<cstring>
#include<string>
#define ll long long
using namespace std;
const int maxn=1e5+10;
int n,m;
ll a,b;
int main() {
	cin>>a>>b;
	ll k=(a+b)/2;
	if((a+b)!=2*k){
		cout<<"IMPOSSIBLE"<<endl;
	}
	else {
		cout<<k<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}
ll n,m,k;
vector<vl> a(3000 + 1, vl(3000 + 1, 0));
vector<vector<vl>> dp(4, vector<vl>(3000 + 1, vl(3000 + 1, -1)));
ll ans;

ll f(int i,int j,int k) {
    if(i>n||j>m) return 0;
    if(dp[k][i][j]!=-1) return dp[k][i][j];
    if(k==3) {
        dp[k][i][j] = f(i+1,j,0);
    }
    else {
        ll res1 = max(f(i,j+1,k),f(i,j+1,k+1)+a[i][j]);
        ll res2 = max(f(i+1,j,0),f(i+1,j,0)+a[i][j]);
        dp[k][i][j] = max(res1,res2);
    }
    ans=max(dp[k][i][j],ans);
    return dp[k][i][j];

}

void solve()
{
    
    cin>>n>>m>>k;
    
    for(int i=0;i<k;i++) {
        ll x,y;
        cin>>x>>y;
        cin>>a[x][y];
    }
    f(1,1,0);
    cout<<ans;

}

int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        //cout << newl;
    }

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int N, A, B, C, D;
    string S;
    cin >> N >> A >> B >> C >> D >> S;
    A--, B--, C--, D--;

    bool res = false;
    if (C > D) {
        for (int i = B - 1; i < D; ++i) {
            if (i+2 < N && S[i] == '.' && S[i+1] == '.' && S[i+2] == '.') {
                res = true;
            }
        }
    } else {
        res = true;
    }

    while (B < D) {
        if (B+1 <= D && S[B+1] == '.') B++;
        else if (B+2 <= D && S[B+2] == '.') B += 2;
        else {
            res = false;
            break;
        }
    }

    while (A < C) {
        if (A+1 <= C && S[A+1] == '.') A++;
        else if (A+2 <= C && S[A+2] == '.') A += 2;
        else {
            res = false;
            break;
        }
    }

    cout << (res ? "Yes" : "No") << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    long M = 1_000_000_007;
    char[] D = scanner.next().toCharArray();
    int N = D.length;
    long[][] dp = new long[2][N + 1];
    dp[1][0] = 1;
    for (int i = 1; i <= N; i++) {
      if (D[i - 1] == '0') {
        dp[0][i] = 3 * dp[0][i - 1] % M;
        dp[1][i] = dp[1][i - 1];
      } else {
        dp[0][i] = (3 * dp[0][i - 1] % M + dp[1][i - 1]) % M;
        dp[1][i] = 2 * dp[1][i - 1] % M;
      }
    }
    System.out.println((dp[0][N] + dp[1][N]) % M);
  }
}


Measured memory_bytes: 27836
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int h, w;
using Graph = vector<vector<int>>;
Graph G;
vector<pair<int,int>> vis;
int cnt;

void dfs(int x, int y)
{
	G[x][y] = cnt;
	for(int dx = -1; dx <= 1; dx++){
		for(int dy = -1; dy <= 1; dy++){
			int nx = x + dx;
			int ny = y + dy;
			if(nx<0 || nx>=h || ny<0 || ny>=w || 
				G[nx][ny]!=1)
				continue;
			dfs(nx,ny);
		}
	}
}

int main()
{
	int time = 0;
	while(1){
		cin >> w >> h;
		if(h==0&&w==0) break;
		G.clear();
		G.resize(h);
		rep(i,h) G[i].resize(w);
		rep(i,h)rep(j,w){//input
			cin >> G[i][j];
		}
		cnt = 1;
		rep(i,h)rep(j,w){
			if(G[i][j]==1){ 
				cnt++;
				dfs(i,j);
			}
		}
		// rep(i,h)rep(j,w){
		// 	if(j!=w-1) printf("%d ", G[i][j]);
		// 	else printf("%d\n", G[i][j]);
		// }
		time++;
		cout << cnt-1 << endl;
	}
}



Measured memory_bytes: 3292
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N; cin >> N;
    if (N < 600)cout << 8 << endl;
    else if (N < 800)cout << 7 << endl;
    else if (N < 1000)cout << 6 << endl;
    else if (N < 1200)cout << 5 << endl;
    else if (N < 1400)cout << 4 << endl;
    else if (N < 1600)cout << 3 << endl;
    else if (N < 1800)cout << 2 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int h[100001];
int dp[100001];
int n;
int solve(int stone)
{
    if(stone+1==n) return dp[stone]=abs(h[stone]-h[stone+1]);
    if(stone+2==n) return dp[stone+2]=abs(h[stone]-h[stone+2]);
    if(dp[stone]!=-1) return dp[stone];
    return dp[stone]=min(abs(h[stone]-h[stone+1])+solve(stone+1),abs(h[stone]-h[stone+2])+solve(stone+2));
}

int main()
{
    int i;
    scanf("%d",&n);

    for(i=1; i<=n; i++)
        scanf("%d",&h[i]);

    memset(dp,-1,sizeof(dp));
    printf("%d\n",solve(1));


    return 0;
}


Measured memory_bytes: 3328
n,x=map(int,input().split())

def p(n,x):
    if x<=n:
        return 0
    if n==0:
        return 1
    i=0
    while 2**(2+i)-3+n-i<=x:
        i+=1
    if 2**(i+1)-2+n-i==x:
        return 2**i-1
    else:
        return 2**i+p(i-1,x-(2**(i+1)+n-i-2)-1)

print(p(n,x))


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

using namespace std;

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

    vector<int> h(n + 10);

    for(int i = 1; i <= n; i++){
        cin >> h[i];
    }
    vector<bool> cnt(n + 10, 1);
    for(int i = 1; i <= m; i++){
        int v1, v2;
        cin >> v1 >> v2;
        if(h[v1] <= h[v2]){
            cnt[v1] = 0;
        }
        if(h[v2] <= h[v1]){
            cnt[v2] = 0;
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        /*if(cnt[i]){
            cout << i << " ";
        }*/
        ans += cnt[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

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

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

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	int n, k;
	cin >> n >> k;
	double ans = 0;
	for (int i = 1; i <= n; i++) {
		double a = 1.0 / n;
		int b = i;
		while(b<k){
			b *= 2;
			a /= 2;
		}
		ans += a;
	}
	printf("%.12f", ans);
	return 0;
}










Measured memory_bytes: 256
def main():
    X = int(input())
    l = [pow(i, 5, 10**20) for i in range(1000)]
    for vi, i in enumerate(l):
        for vj, j in enumerate(l):
            if i + j == X:
                print(vi, -vj)
                return
            elif i - j == X:
                print(vi, vj)
                return
            elif j - i == X:
                print(-vi, -vj)
                return
main()


Measured memory_bytes: 84988
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(string s) {
  for (char &c: s)
    if (c == ',') c = ' ';
  cout << s << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	string s;
	cin >> s;
	solve(s);
	return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  double su = 0;
  for(int i=0;i<n;++i) {
    double a; cin >>  a;
    su += 1.0 / a;
  }
  cout << 1.0 / su << endl;
}


Measured memory_bytes: 256
// ref: https://atcoder.jp/contests/abc110/submissions/3251714

#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

uint64  divNum(uint64& target, const uint64 divisor){
    uint64 num  =0ull;
    for(;;){
        uint64 div = target / divisor;
        uint64 mod = target - divisor * div;
        if(mod!=0ull){ break; }
        target = div;
        ++num;
    }
    return num;
}

tuple<vector<uint64>,vector<uint64>> factor(uint64 target){
    vector<uint64> vecPrime;
    vector<uint64> vecNum;
    
    uint64 num2 = divNum(target, 2ull);
    if(num2!=0ull){
        vecPrime.push_back(2ull);
        vecNum.push_back(num2);
    }
    
    for(uint64 divisor=3; divisor<=target; divisor+=2){
        if(target==1){ break; }
        
        uint64 num = divNum(target, divisor);
        if(num==0ull){ continue; }
        
        vecPrime.push_back(divisor);
        vecNum.push_back(num);
    }
    return tie(vecPrime, vecNum);
}

uint64 pow_mod(uint64 base, uint64 exp, const uint64 mod){
    uint64 ret=1ull;
    for(; exp>0ull; exp>>=1ull){
        if(exp & 1){
            ret = ret*base;
            ret %= mod;
        }
        base = base*base;
        base %= mod;
    }
    return ret;
}
uint64 comb_mod(uint64 n, uint64 r, const uint64 mod){
    if(n==r || n==0ull || r==0ull){ return 1ull; }
    
    uint64 p=1ull, q=1ull;
    r = min(r,n-r);
    for(uint64 i=1ull; i<=r; ++i){
        p *= n; --n;
        p %= mod;
        
        q *= i;
        q %= mod;
    }
    return (p*pow_mod(q,mod-2,mod)) % mod;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    const uint64 mod = 1e9 + 7;
    
    uint64 N, M; cin >> N >> M;
    
    vector<uint64> vecPrime, vecNum;
    tie(vecPrime, vecNum) = factor(M);
    
    uint64 ans=1ull;
    for(uint i=0; i<vecNum.size(); ++i){
        ans *= comb_mod(vecNum[i]+N-1ull, N-1ull, mod);
        ans %= mod;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 998244353;

struct state
{
	LL siz, sum;
	state()
	{
		siz = sum = 0;
	}
	state(LL x)
	{
		siz = 1; sum = x;
	}
	state(LL x, LL y)
	{
		siz = x; sum = y;
	}
};
state operator+(const state& A, const state& B)
{
	return state(A.siz + B.siz, A.sum + B.sum);
}
bool operator<(const state& A, const state& B)
{
	return A.sum * B.siz < B.sum * A.siz;
}

int n, r, c[200005];
state st[200005];
int par[200005], rt[200005];
vector<int> G[200005];
set<pair<state, int> > S;

void dfs(int v, int p)
{
	par[v] = p;
	rep(i, G[v].size()) {
		int u = G[v][i];
		if(u == p) continue;
		dfs(u, v);
	}
}

int root(int x)
{
	return rt[x] == x ? x : rt[x] = root(rt[x]);
}

bool solve()
{
	if(scanf("%d", &n) != 1) return false;
	r = 1;
	rep1(i, n) G[i].clear();
	rep(i, n - 1) {
		int u = i + 2, v;
		scanf("%d", &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	
	int sum = 0;
	rep1(i, n) {
		scanf("%d", &c[i]);
		c[i] = 1 - c[i];
		sum += c[i];
	}
	dfs(r, 0);

	rep(i, n + 1) st[i] = state(c[i]);
	S.clear();
	rep1(i, n) S.insert(MP(st[i], i));
	
	rep(i, n + 1) rt[i] = i;
	LL ans = 0;
	while(!S.empty()) {
		int v = S.rbegin()->second;
		S.erase(MP(st[v], v));
		rt[v] = par[v];
		int u = root(v);
		if(u != 0) S.erase(MP(st[u], u));
		ans += st[u].siz * st[v].sum;
		st[u] = st[u] + st[v];
		if(u != 0) S.insert(MP(st[u], u));
	}
	
	ans = ans - 1LL * sum * (sum + 1) / 2;
	printf("%lld\n", ans);
	return true;
}

int main()
{
	while(solve());
	return 0;
}

Measured memory_bytes: 42108
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)
const int N = 3000, M = 7 + 1e9;
int n, a[N];
ll dp[N][N][2];
ll cal(int i, int j, int p){
	if( i == j ){
		if(p)
			return a[i];
		return -a[i];
	}
	ll &ret =  dp[i][j][p];
	if(~ret)
		return ret;
	if(p==0){
		return ret = min(cal(i+1, j, !p)-a[i], cal(i, j-1, !p)-a[j]);
	}else{
		return ret = max(cal(i+1, j, !p)+a[i], cal(i, j-1, !p)+a[j]);
	}
}
int main()
{
	memset(dp, -1, sizeof dp);
	cin >> n;
	f(i, 0, n)
		cin >> a[i];
	cout << cal(0, n-1, 1);
 
}

Measured memory_bytes: 141056
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, M; cin >> N >> M;
    //assert(N <= 200 && M <= 200);
    vec A(N); cin >> A;
    vec X(M), Y(M);
    REP(i, M){
        cin >> X[i] >> Y[i];
        X[i]--;
    }
    vec cnt(N + 1, 0);
    REP(i, N) cnt[A[i]]++;
    vec n_in(N, 0);
    IFOR(i, 1, N + 1){
        FOR(j, 1, cnt[i] + 1) if(i - j >= 0) n_in[i - j]++;
    }
    int now = 0;
    REP(i, N) if(n_in[i] == 0) now++;
 
    vec ans(M);
    REP(q, M){
        if(A[X[q]] - cnt[A[X[q]]] >= 0){
            if(--n_in[A[X[q]] - cnt[A[X[q]]]] == 0) now++;
        }
        cnt[A[X[q]]]--;
        A[X[q]] = Y[q];
        cnt[A[X[q]]]++;
        if(A[X[q]] - cnt[A[X[q]]] >= 0){
            if(n_in[A[X[q]] - cnt[A[X[q]]]]++ == 0) now--;
        }
        ans[q] = now;
    }
    Out(ans);

    return 0;
}


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

using namespace std;
typedef long long ll;

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

    ll pls = 0, mns = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] < b[i]) pls += (b[i] - a[i]) / 2;
        else if (a[i] > b[i]) mns += a[i] - b[i];
    }

    if (pls >= mns) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 384
import bisect
n = int(input())

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort()
B.sort()
C.sort()

dpA = [0]*n
dpB = [0]*n

for i in range(n):
    dpB[i] = n-bisect.bisect_right(C,B[i])
for i in range(n-2,-1,-1):
    dpB[i] += dpB[i+1] 
for i in range(n):
    x = bisect.bisect_right(B,A[i])   
    if x == n:
        dpA[i] = 0
    else:
        dpA[i] = dpB[x]

print(sum(dpA))


Measured memory_bytes: 23328
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

const int M=1000000;
int n;
vl a;

int main(){
	cin>>n;
	a=vl(n);
	for(auto &i:a) cin>>i;
	vl b(M+1);
	for(int i=0;i<n;i++){
		int x=a[i];
		for(int j=1;j*j<=x;j++) if(x%j==0){
			(b[j]+=x)%=mod;
			if(j*j<x) (b[x/j]+=x)%=mod;
		}
	}
	for(int i=M;i>0;i--){
		(b[i]*=b[i])%=mod;
		for(int j=2*i;j<=M;j+=i) b[i]=(b[i]-b[j]*j%mod+mod)%mod;
		b[i]=Div(b[i],i);
	}
	ll res=0;
	for(auto i:b) (res+=i)%=mod;
	for(auto i:a) res=(res-i+mod)%mod;
	cout<<Div(res,2)<<endl;
}

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

int main()
{
	int h, n;
	cin >> h >> n;
	int a[n+1];
	for (int i = 1; i <= n; ++i) cin >> a[i];
	
	bool flag = false;
	for (int i = 1; i <= n; ++i)
	{
		h = h - a[i];
		
		if (h <= 0)
		{
			flag = true;
			break;
		}
		else
		{
			flag = false;
		}
	}
	
	if (flag)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
}


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

void Main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;
using P = pair<int,int>;
using ll = long long;

int main(){
    int a,b,v,w;
    cin>>a>>v>>b>>w;
    int t;
    cin>>t;
    if(w-v>=0)cout<<"NO"<<endl;
    else if((double)abs(b-a)/(double)(v-w)<=t)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 3620
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()
A = getArray(N)

for i in A:
    if i % 2 != 0:
        print('first')
        exit()
print('second')

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

int main() {
	int a,b;
    cin>>a>>b;
  	string s;
  	cin>>s;
  if(s.at(b-1)== 'A')
    s.at(b-1) = 'a';
  else if(s.at(b-1)=='B')
    s.at(b-1) ='b';
  else if(s.at(b-1)=='C')
    s.at(b-1) ='c';
  
 cout<<s<<endl;
    
  return 0;
}

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

using namespace std;

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

  int64_t n, a, b;
  cin >> n >> a >> b;

  int64_t dist = b - a;
  int64_t ans = 0;
  if (dist % 2 == 0) {
    ans = dist / 2;
  } else {
    ans = min(a, n - b + 1);
    ans += (dist - 1) / 2;
  }

  cout << ans << '\n';

  return 0;
}


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

using namespace std;

int conv(string s){
    int res=0;
    for(int i=0;i<(int )s.length();i++){
        res*=10;
        res+=(s[i]-'0');
    }
    return res;
}

int solve(string s){
    string s2=s;
    int res=0;
    int val=conv(s);
    set<int> st;
    while(val>=10){
        int ma=-1;
        for(int i=1;i<(int )s2.length();i++){
            string a=s2.substr(0,i),b=s2.substr(i);
            int v1=conv(a),v2=conv(b);
            ma=max(ma,v1*v2);
        }
        //cout<<ma<<endl;
        if(st.find(ma)!=st.end()){
            res=-1;
            break;
        }
        st.insert(ma);
        val=ma;
        s2=to_string(ma);
        res++;
    }
    return res;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int q;cin>>q;
  for(int i=0;i<q;i++){
      string n;cin>>n;
      cout<<solve(n)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3268
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

int a, b, c;

int main()
{
    cin >> a >> b >> c;
    if (b - a == c - b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    unsigned int x;
    int h=0,m=0,s=0,i=0;
    scanf("%d",&x);
    h=x/3600;
    if(h!=0)
        x-=3600*h;
    m=x/60;
    if(m!=0)
        x-=60*m;
    printf("%d:%d:%d\n",h,m,x);
    return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int X,ans=1;
  cin>>X;
  FOR(i,2,sqrt(X)+1){
    FOR(j,2,sqrt(X)+1){
      if(X>=pow(i,j) && pow(i,j)>=ans) ans=pow(i,j);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
int main() {
  int n, count = 1;
  cin >> n;
  vector<int> A(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < n - 1; i++) {
    if (A.at(i) != A.at(i + 1)) count++;
  }
  if (count % 2 == 1) {
    cout << count << endl;
  } else if (count % 2 == 0) {
    cout << count - 1 << endl;
  }
}

Measured memory_bytes: 640
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

const int INF = 1e8;

struct edge
{
    int c;
    P p;
    edge(P p, int c) : p(p), c(c) {}
    bool operator>(const edge &r) const { return c > r.c; }
};

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    int x1, y1, x2, y2;
    cin >> y1 >> x1 >> y2 >> x2;
    x1--;
    y1--;
    x2--;
    y2--;

    vvchar g(h, vchar(w));
    rep(y, h) rep(x, w) cin >> g[y][x];
    priority_queue<edge, vector<edge>, greater<edge>> q;
    q.emplace(edge(P(y1, x1), 0));
    vector<int> dir = {1, 0, -1, 0, 1};
    vvint d(h, vint(w, INF));
    d[y1][x1] = 0;

    while (q.size())
    {
        edge e = q.top();
        P p = e.p;
        q.pop();
        int y = p.first, x = p.second;
        if (p == P(y2, x2))
            break;
        int now = d[y][x];
        rep(i, 4)
        {
            int dx = dir[i], dy = dir[i + 1];
            for (int i = 1; i <= k; ++i)
            {

                int nx = x + dx * i,
                    ny = y + dy * i;
                if (ny < 0 || ny >= h || nx < 0 || nx >= w || g[ny][nx] == '@' || d[ny][nx] <= now)
                    break;

                if (d[ny][nx] > now + 1)
                {
                    d[ny][nx] = now + 1;
                    q.push(edge(P(ny, nx), now + 1));
                }
            }
        }
    }

    if (d[y2][x2] == INF)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << d[y2][x2] << endl;
    }

    return 0;
}

Measured memory_bytes: 11872
#include<bits/stdc++.h>
#define pr(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define Toggle(n,i) (n^(1<<i))
#define Check(n,i) (n&(1<<i))
#define Set(n,i) (n|(1<<i))
#define Reset(n,i) (n&(~(1<<i)))
#define fo(i,x,y) for(int i=(x);i<=(y);++i)
#define me(arr,val) memset(arr,val,sizeof arr)
#define inf 10e8
#define infl LLONG_MAX
#define mod 1000000007
#define f first
#define s second
#define  g(t,a)  (get<a>(t))
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
//int dx[]={+1,-1,0,0};//vertical horizontal
//int dy[]={0,0,+1,-1};//vertical horizontal
//int dx[]={+1,+1,-1,-1,+2,-2,+2,-2};//knights move
//int dy[]={+2,-2,+2,-2,+1,+1,-1,-1};//knights move
//int dx[]={+1,-1,0,0,+1,+1,-1,-1};//vertical horizontal diagonal
//int dy[]={0,0,+1,-1,-1,+1,+1,-1};//vertical horizontal diagonal
using namespace std;
using namespace __gnu_pbds;
/*typedef tree<int, null_type,less<int>, rb_tree_tag,
             tree_order_statistics_node_update>indexed_set;
for set use above*/
typedef tree<pair<int,int>, null_type,less_equal<pair<int, int>>, rb_tree_tag,
tree_order_statistics_node_update> indexed_multiset;


int main()
{
    ll k,x;
    scanf("%lld%lld",&k,&x);
    if(k*500>=x)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
   
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int a = in.readInt(); 
		int b = in.readInt(); 
	    char s[] = in.readString().toCharArray(); 
	    for(int i = 0; i<a; i++) {
	    	if(!(s[i] >= '0' && s[i] <= '9')) {
	    		System.out.println("No"); 
	    		return; 
	    	}
	    }
	    for(int i = a+1; i<=a+b; i++) {
	    	if(!(s[i] >= '0' && s[i] <= '9')) {
	    		System.out.println("No"); 
	    		return ; 
	    	}
	    }
	    if(s[a] != '-') {
	    	System.out.println("No"); 
	    	return;
	    }
	    System.out.println("Yes"); 
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 21076
import math
import numpy
import sys
readline = sys.stdin.readline


def main():
    n = int(input())
    A = list(map(int, input().split()))
    avgA = numpy.average(A)
    B = list(map(lambda x: abs(x - avgA) ,A))
    minB = min(B)

    print(B.index(minB))


if __name__ == '__main__':
    main()


Measured memory_bytes: 26572