akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#define INF 1000000
#define MAX_TOSHI 30
#define MAX_KEN   8

using namespace std;

int data[MAX_TOSHI][MAX_TOSHI];
int ken[MAX_KEN];
int n, m, p, a, b;

double solve() {
  double cost[MAX_TOSHI][1 << MAX_KEN];
  bool visited[MAX_TOSHI][1 << MAX_KEN];
  double mini, ans;
  int p1,p2;

  for(int i = 0; i < m; i++) {
    for(int j = 0; j < (1 << n); j++) {
      cost[i][j] = INF;
      visited[i][j] = false;
    }
  }

  cost[a][0] = 0;

  while(1) {
    mini = INF;
    for(int i = 0; i < m; i++) {
      for(int j = 0; j < (1 << n); j++) {
	if(visited[i][j]) continue;
	if(cost[i][j] < mini) {
	  mini = cost[i][j];
	  p1 = i;
	  p2 = j;
	}
      }
    }

    if(mini == INF) break;
    visited[p1][p2] = true;

    for(int i = 0; i < m; i++) {
      if(data[p1][i] == INF) continue;
      for(int j = 0; j < n; j++) {
	if(visited[i][p2|(1<<j)]) continue;
	if(p2 & (1 << j)) continue;
	double newCost = cost[p1][p2] + (double)data[p1][i]/ken[j];

	if(newCost < cost[i][p2|(1<<j)]) {
	  cost[i][p2|(1<<j)] = newCost;
	}
      }
    }
  }
  ans = INF;
  for(int j = 0; j < (1 << n); j++) {
    if(cost[b][j] < ans) ans = cost[b][j];
  }
  return ans;
}

main() {
  double ans;
  while(1) {
    for(int i = 0; i < MAX_TOSHI; i++) {
      for(int j = 0; j < MAX_TOSHI; j++) {
	data[i][j] = INF;
      }
    }
    cin >> n >> m >> p >> a >> b;
    if(n == 0 && m == 0 && p == 0 && a == 0 && b == 0) break;
    a--, b--;
    for(int i = 0; i < n; i++) {
      cin >> ken[i];
    }
    for(int i = 0; i < p; i++) {
      int s, g, d;
      cin >> s >> g >> d;
      s--, g--;
      data[s][g] = data[g][s] = d;
    }
    if((ans = solve()) == INF) printf("Impossible\n");
    else                       printf("%.3f\n", ans);
  }
}

Measured memory_bytes: 980
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String fst = br.readLine();
		Dice dice = new Dice(fst);
		dice.sim(br.readLine());
		System.out.println(dice.getTop());
	}
}


class Dice{
	private int top;
	private int forth;
	private int right;
	private int left;
	private int back;
	private int bottom;
	Dice(String str){
		String[] s = str.split(" ");	
		top = Integer.parseInt(s[0]);
		forth = Integer.parseInt(s[1]);
		right = Integer.parseInt(s[2]);
		left = Integer.parseInt(s[3]);
		back = Integer.parseInt(s[4]);
		bottom = Integer.parseInt(s[5]);
	}

	public void sim(String st){
		int work;
		for (int i = 0; i<st.length() ; i++ ) {
			switch(st.charAt(i)){

				case 'N':
				work = top;
				top = forth;
				forth = bottom;
				bottom = back;
				back = work;
				break;

				case 'E':
				work = top;
				top = left;
				left = bottom;
				bottom = right;
				right = work;
				break;

				case 'S':
				work = top;
				top = back;
				back = bottom;
				bottom = forth;
				forth = work;
				break;

				case 'W':
				work = top;
				top = right;
				right = bottom;
				bottom = left;
				left = work;
				break;

			}
		}

	}
	public int getTop(){
		return top;
	}
}

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

using namespace std;

const int64_t INF = INT64_C(1) << 60;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<vector<pair<int, int>>> G(N);
  for (int i = 0; i < N - 1; i++) {
    G[i + 1].emplace_back(make_pair(i, 0));
  }
  for (int i = 0; i < M; i++) {
    int l, r, c;
    cin >> l >> r >> c;
    l--, r--;
    G[l].emplace_back(make_pair(r, c));
  }
  priority_queue<pair<int64_t, int>, vector<pair<int64_t, int>>, greater<pair<int64_t, int>>> que;
  que.push(make_pair(0, 0));
  vector<int64_t> dist(N, INF);
  dist[0] = 0;
  while (!que.empty()) {
    auto q = que.top();
    que.pop();
    int u = q.second;
    for (auto g : G[u]) {
      int v = g.first, c = g.second;
      if (chmin(dist[v], dist[u] + c)) {
        que.push(make_pair(dist[v], v));
      }
    }
  }
  if (dist[N - 1] != INF) {
    cout << dist[N - 1] << '\n';
  } else {
    cout << -1 << '\n';
  }
  return 0;
}


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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	string s; read(s);
	vector<int> a(sz(s) + 1);
	
	for (int i = 0, c = 0; i < s.length(); i++) {
		if (s[i] == '<') c++; else c = 0;
		chmax(c, 0);
		chmax(a[i + 1], c);
	}
	for (int i = s.length() - 1, c = 0; i >= 0; i--) {
		if (s[i] == '>') c++; else c = 0;
		chmax(c, 0);
		chmax(a[i], c);
	}

	ll ans = 0;
	rep(i, 0, sz(s) + 1) ans += a[i];
	write(ans);
}


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

int main()
{
    int h,w;
    cin >> h >> w;
    vector<vector<int>> a(h,vector<int>(w));
    vector<vector<int>> b(h,vector<int>(w));
    vector<vector<int>> c(h,vector<int>(w));
    rep(i,h) rep(j,w) cin >> a[i][j];
    rep(i,h) rep(j,w) cin >> b[i][j];
    rep(i,h) rep(j,w) c[i][j] = abs(a[i][j]-b[i][j]);

    // dp[h+1][w+1][6401]
    int d = 80*((h+w+1)/2)+1;
    bool dp[h+1][w+1][d];
    memset(dp, false, sizeof(dp));
    dp[0][1][0] = true;

    rep(i,h)
        rep(j,w)
            rep(k,d) {
                int d1 = abs(k-c[i][j]);
                int d2 = k+c[i][j];
                bool has_d1 = (dp[i][j+1][d1] || dp[i+1][j][d1]);
                bool has_d2 = d2<d && (dp[i][j+1][d2] || dp[i+1][j][d2]);
                if(has_d1 || has_d2) dp[i+1][j+1][k] = true;
            }

    rep(i,d) {
        if(dp[h][w][i]) {
            cout << i << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 41344
#include <iostream>
using namespace std;
int color,n,k,ans;
int x,y;

void check(int a,int b,int c){
	//cout << a<< " "<< b<< " "<<c <<endl; 
	if(a>=b){
		c-=(a-1)%3;
	}else{
		c-=(b-1)%3;
	}
	if(c==-1)c=2;
	if(c==0)c=3;
	ans=c;
	return;
}


int main(){
	cin >>n>>k;
	color=(n/2+n%2)%3;
	if(color==0)color=3;
	for(int i=0;i<k;i++){
		cin >> x>>y;
		if(n%2==0){
			if(x>n/2&&y>n/2){
				check(x-n/2,y-n/2,color);
			}else if(x>n/2){
				check(x-n/2,n/2-y+1,color);
			}else if(y>n/2){
				check(n/2-x+1,y-n/2,color);
			}else{
				check(n/2-x+1,n/2-y+1,color);
			}
		}else{
			if(x>n/2&&y>n/2){
				check(x-n/2,y-n/2,color);
			}else if(x>n/2){
				check(x-n/2,n/2-y+2,color);
			}else if(y>n/2){
				check(n/2-x+2,y-n/2,color);
			}else{
				check(n/2-x+2,n/2-y+2,color);
			}
		}
		cout <<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3056
import java.util.*;

public class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] boxes = new int[n];
		boolean[] reds = new boolean[n];
		Arrays.fill(boxes, 1);
		reds[0] = true;
		for (int i = 0; i < m; i++) {
			int x = sc.nextInt() - 1;
			int y = sc.nextInt() - 1;
			if (boxes[x] == 1 && reds[x]) {
				reds[x] = false;
				reds[y] = true;
			} else if (reds[x]) {
				reds[y] = true;
			}
			boxes[x]--;
			boxes[y]++;
		}
		int count = 0;
		for (boolean b : reds) {
			if (b) {
				count++;
			}
		}
		System.out.println(count);
	}
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define repi(i,a,b) for(int i = (a); i<= (b); i++)
#define repA(i,n) for(int i=n; i>=0; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())

typedef long long ll;
typedef long double ld;
const ll mod = (ll)(1e9+7);//998244353;
const int N = (int)(2e6+5);

void pre() {

}

void solve() {
  ll n;  cin>>n;
  ll ans = 0;
  for(int i=1; i<=n; i++) {
    ll nums = n/i;
    ans += nums*(nums+1)/2 * i;
  }
  cout<<ans;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  #endif
  int t = 1;
  pre();
  //cin>>t;
  rep(i,t)  {
    //cout<<"\nCase #"<<(i+1)<<"\n";
    solve();
    cout<<'\n';
  }
  return 0;
}


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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

template<class T>
bool umin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

int cmp(int a, int b) {
    if (a == b) {
        return 0;
    }
    return a < b ? -1 : 1;
}

void solve() {
    string a[3];
    read(a[0], a[1], a[2]);

    int i = 0;
    while (a[i].size()) {
        int x = a[i][0] - 'a';
        a[i].erase(0, 1);
        i = x;
    }
    print((char) (i + 'A'));
}

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

    int tt = 1;
//    read(tt);
    FOR(tt) {
//        write("Case #", i + 1, ": ");
        solve();
    }

}



Measured memory_bytes: 3632
import java.util.Scanner;

//Run Length
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			char[] s = sc.next().toCharArray();
			StringBuilder sb = new StringBuilder();
			int i = 0;
			while(i<s.length){
				if(s[i]=='@'){
					int x = s[++i]-'0';
					i++;
					while(x--!=0)sb.append(s[i]);
				}
				else sb.append(s[i]);
				i++;
			}
			System.out.println(sb);
		}
	}
}

Measured memory_bytes: 25580
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>

using namespace std;

pair<int,long long> partition(int* a, int p, int r) {
	int x = a[r - 1];
	int cnt = p - 1;
	long long cost = 0;
	for (int i = p;i < r;i++) {
		if (a[i] <= x) {
			cnt++;
			if (cnt != i) {
				swap(a[cnt], a[i]);
				cost += a[cnt] + a[i];
			}
		}
	}
	return make_pair(cnt, cost);
}

long long quicksort( int *a, int l, int r) {
	long long cost = 0;
	if (l < r) {
		
		pair<int,long long> q = partition(a, l, r);
		cost += q.second;
		cost += quicksort(a, l, q.first);
		cost +=quicksort(a, q.first + 1, r);
	}
	return cost;
}

void set(int*a,int*b,int n){
	for (int i = 0;i < n;i++) {
		a[i] = b[i];
	}
}




int main() {
	int n;
	long long cost=0;
	cin >> n;
	map<int, int> ma;
	int* a = new int[n];
	int* ori = new int[n];
	bool *s = new bool[n];

	for (int i = 0;i < n;i++) {
		cin >> a[i];
		ori[i] = a[i];
		s[i] = false;
	}
	quicksort(a, 0, n);
	int minimum = a[0];
	for (int i = 0;i < n;i++) {
		ma[a[i]] = i;
	}
	for (int i = 0;i < n;i++) {
		if (!s[i]) {
			int first = i;
			vector<int> v;
			v.push_back(ori[i]);
			int index = ma[ori[i]];
			int mini = ori[i];
			s[i] = true;
			while (index != i) {
				s[index] = true;
				mini = min(mini, ori[index]);
				v.push_back(ori[index]);
				index = ma[ori[index]];
			}
			int a, b;
			a = b = 0;
			for (int i = 0;i < v.size();i++) {
				a += v[i];
			}
			b = a;
			a += mini * (v.size() - 2);
			b += mini + (v.size() + 1) * minimum;
			cost += min(a, b);
		}
	}
	cout << cost << endl;
}


Measured memory_bytes: 3208
#pragma GCC optimize(3)
#pragma GCC optimize("inline")
#pragma once
#include<bits/stdc++.h>
#define q register
typedef long long ll;
using namespace std;
string s;
ll tag1,tag2,ans,tot;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    for(q ll i=0;i<s.length();i++){
        if((s[i]=='C')&&(!ans)){
            tag1=i,ans++;
               tot=tag1;    
        }
        if(s[i]=='F'){
            tag2=i;   
            if(ans)   {
           		puts("Yes");
        		return 0;
            }
        }
    }
    puts("No");
    return 0;
}

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

int64_t f(int64_t w, int64_t x, int64_t h)
{
  int64_t s1 = w * h;
  int64_t s2 = x * (h / 2);
  int64_t s3 = x * ((h + 1) / 2);
  auto p = minmax({s1, s2, s3});
  return p.second - p.first;
}

int main()
{
  int64_t h, w;
  cin >> h >> w;
  int64_t ans = min(h % 3 == 0 ? 0 : w, w % 3 == 0 ? 0 : h);
  if (ans != 0) {
    int64_t w3 = w / 3;
    int64_t h3 = h / 3;
    ans = min(ans, f(w3, w - w3, h));
    ans = min(ans, f(w3 + 1, w - w3 - 1, h));
    ans = min(ans, f(h3, h - h3, w));
    ans = min(ans, f(h3 + 1, h - h3 - 1, w));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    int n;
    cin>>n;
    string a1;
    cin>>a1;
    vector<string> a(n);
    for (int i = 0; i < n; i++)
    {
        a.at(i)=a1[i];
    }
    sort(a.begin(), a.end());
    vector<int> b(26,0);
    int c=0;
    string d=a.at(0);
    for (int i = 0; i < n; i++)
    {
        if (a.at(i)==d)
        {
            b.at(c)++;
        }else
        {
            c+=1;
            b.at(c)++;
            d=a.at(i);
        }
        
        
    }
    int64_t e=1;
    for (int i = 0; i < 26; i++)
    {
        e=(e*(b.at(i)+1))%1000000007;
    }
    e--;
    cout<<e<<endl;

    

    



    return 0;
}

Measured memory_bytes: 6680
import sys
input = sys.stdin.readline
import heapq


def read():
    N = int(input().strip())
    P = []
    for i in range(N):
        p = int(input().strip())
        P.append(p)
    return N, P


def solve(N, P):
    h = []
    for i in range(N):
        heapq.heappush(h, (P[i], i+1))
    max_count = 0
    count = 0
    prev = -1
    for _ in range(N):
        p, i = heapq.heappop(h)
        if prev < i:
            count += 1
            prev = i
        else:
            max_count = max(max_count, count)
            count = 1
            prev = i
    max_count = max(max_count, count)
    return N - max_count


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 37560
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-11
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007
const int N = 500031;

string st;

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin>>st;
	if (st[0]==st[2])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 256
"""pythonで整数処理"""

def divisors(n):
    """約数の配列を返す"""
    yakusu = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            yakusu.append(i)
            if i * i != n:
                yakusu.append(n // i)
    return yakusu

class ModInt:
    """mod計算を勝手にやってくれるクラス"""
    def __init__(self, x, mod=1000000007):
        self.x = x % mod
        self.mod = mod

    def __repr__(self):
        return str(self.x)

    def __add__(self, other):
        if isinstance(other, self.__class__):
            return self.__class__(self.x + (other.x % self.mod))
        else:
            return self.__class__(self.x + (other % self.mod))

    def __sub__(self, other):
        if isinstance(other, self.__class__):
            return self.__class__(self.x - (other.x % self.mod) if \
                (self.x - (other.x % self.mod)) > 0 else (self.x - (other.x % self.mod)) + self.mod)
        else:
            return self.__class__(self.x - (other % self.mod) if \
                (self.x - (other % self.mod)) > 0 else (self.x - (other % self.mod)) + self.mod)

    def __mul__(self, other):
        if isinstance(other, self.__class__):
            return self.__class__(self.x * (other.x % self.mod))
        else:
            return self.__class__(self.x * (other % self.mod))

    def __truediv__(self, other):
        return self.__class__(self.x * other.inv().x)

    def __pow__(self, other):
        if isinstance(other, self.__class__):
            return self.__class__(pow(self.x, other.x, self.mod))
        else:
            return self.__class__(pow(self.x, other, self.mod))

    def inv(self):
        return self.__class__(pow(self.x, self.mod - 2, self.mod))

def modcomb(n, r, mod=1000000007):
    """
    nCrを返す。
    ModIntが必要。
    1 <= r <= n <= modが必要。
    """
    x = ModInt(1, mod)
    y = ModInt(1, mod)
    for i in range(r):
        x = x * (n - i)
        y = y * (i + 1)
    return x / y
        
n,a,b = map(int,input().split())
print(ModInt(2)**n-modcomb(n,a)-modcomb(n,b)-1)

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        
        int p = 2;
        int q = 1;
        double num1 = 1;
        double num2 = 1;
        double power = Math.pow(p, q);
        
        for(p = 2; Math.pow(p, q) <= X; p++){
            for(q = 2; Math.pow(p, q) <= X; q++){
                num1 = Math.pow(p, q);
            }
            if(num2 < num1){
                num2 = num1;
            }
            q = 1;
        }
        System.out.println((int)num2);
    }
}

Measured memory_bytes: 21844
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())

sum = 0
for i in range(1,K+1):
    for j in range(i,K+1):
        for k in range(j,K+1):
            if i == j and j==k:
                sum += i
            elif i == j or j == k or k == i:
                sum += 3*gcd(i,j,k)
            else:
                sum += 6*gcd(i,j,k)

print(sum)


Measured memory_bytes: 9584
#include <iostream>

typedef long long ll;

ll solve(const int &K, const int &S) {
    ll ans = 0;
    for (int x=0; x<=K; ++x) {
        for (int y=0; y<=K; ++y) {
            int z = S - x - y;
            if (0<=z && z<=K) ++ans;
        }
    }
    return ans;
}

int main() {
    int K, S;
    std::cin >> K >> S;
    std::cout << solve(K, S) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>

constexpr int NX = 3, NY = 3;
constexpr int SIZE = NX*NY;

using namespace std;

typedef pair< int, vector<int> > PuzzleState;

set< vector<int> > visited;

bool IsSolved( const vector<int>& s ) {
    int cnt = s[SIZE-1] == 0 ? 1 : 0;
    for ( int i=0; i<SIZE; ++i ) {
	if ( s[i] == i+1 ) ++cnt;
    }
    return cnt == SIZE;
}

bool IsVisited( const vector<int>& s ) {
    return visited.find( s ) != visited.end();
}

int Solve( const vector<int>& init_s ) {

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

    queue< PuzzleState > state;
    state.push( make_pair(0, init_s) );
    visited.insert( init_s );

    while ( !state.empty() ) {

	PuzzleState curr = state.front();

	if ( IsSolved( curr.second ) ) return curr.first;
	state.pop();
	
	int x, y;
	for ( int i=0; i<SIZE; ++i ) {
	    if ( curr.second[i] == 0 ) {
		x = i%NX;
		y = i/NY;
		break;
	    }
	}

	for ( int i=0; i<4; ++i ) {
	    int nx = x + dx[i];
	    int ny = y + dy[i];
	    if ( nx >= 0 && nx < NX && ny >= 0 && ny < NY ) {

		swap( curr.second[NX*y+x], curr.second[NX*ny+nx] );
		curr.first += 1;
		
		if ( !IsVisited( curr.second ) ) {
		    state.push( curr );
		    visited.insert( curr.second );
		}
		
		curr.first -= 1;
		swap( curr.second[NX*y+x], curr.second[NX*ny+nx] );
	    }
	}
    }
    return 1000000;
}

int main() {

    vector<int> s(SIZE);
    for ( int i=0; i<SIZE; ++i ) cin >> s[i];

    cout << Solve( s ) << endl;
    
    return 0;
}



Measured memory_bytes: 23488
#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;

#define ordered_set tree<long long, null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update>
//s.find_by_order(index) returns iterator to the index-th element
//in O(logn) time.



typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vii;
typedef vector<string> vss;
typedef vector<pair<ll, ll> > vpll;
typedef unordered_map<ll ,ll> mpll;
typedef unordered_map<int ,int> mpii;
typedef unordered_map<char ,ll> mpcl;
typedef pair<ll , ll> pll;
typedef complex<double> cd;
typedef vector< complex<double> > vcd;


#define fore(i,n) for(i=0;i<n;i++)
#define forz(i,s,f) for(i=s;i<f;i++)
#define forer(i,n) for(i=n-1;i>=0;i--)
#define forzr(i,s,f) for(i=s;i>=f;i--)
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
#define pvec(i,vec) fore(i,vec.size())cout<<vec[i]<<" ";cout<<"\n";

const ll mod=1e9+7;
const ll modulo=998244353;
const double pi = 3.14159265358979323846;


ll power(ll x,ll y,ll m)//gives (x^y)%m
{
    ll ans=1;
    while (y>0)
    {
        if(y & 1)
        {
            ans=(ans*x)%m;
        }
        y=y/2;
        x=(x*x)%m;
    }
    return ans;
}

bool sortbysec(pll &a,pll &b)
{
    return(a.ss<b.ss);
}

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

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

long double logn(long double a,long double n)
{
	return(log(n)/log(a));
}

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
    
	ll te=1,test,i,j,n,m,flag,k,p,temp,l,r,d;
	//cin>>te;
	for(test=1;test<=te;test++)
	{
		cin>>l>>r>>d;

		ll ans=0;
		forz(i,l,r+1)
		{
			if(i%d==0)
				ans++;
		}
		cout<<ans<<"\n";
		/*vll a(n);
		fore(i,n)
		{
			cin>>a[i];
		}*/
		
		//cout<<"hello\n";
		//cout<<"Case #"<<test<<": ";
	}

	return 0;
}

Measured memory_bytes: 3692
#include <stdio.h>
#include <stdlib.h>

typedef struct drink{
  long price;
  long stock;
}drink;

int compare(const void *a,const void *b){
  drink *A =(drink *)a;
  drink *B =(drink *)b;
  return A->price - B->price;
}

int main(){
  int N,M;
  scanf("%d%d",&N,&M);
  drink* D =(drink*)malloc(sizeof(drink)*N);
  for(int i=0;i<N;i++){
    scanf("%d%d",&D[i].price,&D[i].stock);
  }
  qsort(D,N,sizeof(drink),compare);

  long cost = 0;
  long item = 0;
  for(int j=0;j<N;j++){
    if(item + D[j].stock < M){
      cost += (D[j].price)*(D[j].stock);
      item += D[j].stock;
    }else if(item + D[j].stock >= M){
      cost += (D[j].price)*(M - item);
      item += M;
      j = N+1;
    }
  }
  printf("%ld\n",cost);
  
  return 0;
}

Measured memory_bytes: 3324
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, a, b, mxa=0,mxb, ans;

    scanf("%d",&n);
    while(n--){
        scanf("%d %d",&a,&b);
        if(a>mxa){mxa=a;mxb=b;}
    }
    ans=mxa+mxb;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define P pair<int,int>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define re(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
int n;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    string a[n];
    rep(i,n){
        cin>>a[i];
        sort(a[i].begin(),a[i].end());
    }
    sort(a,a+n);
    int ans=0;
    int kai=0;
    rep(i,n-1){
        if(a[i]!=a[i+1]){
            kai++;
            ans+=kai*(kai-1)/2;
            kai=0;
        }
        else{
            kai++;
        }
    }
    kai++;
    ans+=kai*(kai-1)/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std ;
int main () {
  vector<int> line(3) ;
  for(int i  = 0 ; i < 3 ; i++) cin >> line[i] ;
  sort(line.begin(),line.end()) ;
  for(int i  = 0 ; i < 2 ; i++) cout << line[i] << ' ';
  cout << line[2] << endl ;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+9;
const double ep=1e-7;
const int mod=998244353;
const int INF=0x3f3f3f3f;
const double pi=acos(-1);
#define debug1 puts("?");
#define debug(x) cout<<"##"<<(x)<<endl;
#define mk make_pair
#define PII pair<int,int>
#define PIII pair<int,PII >
#define PIII1 pair<PII,int>
#define PIL pair<int,ll>
#define PLL pair<ll,ll>
#define eb emplace_back
#define fi first
#define se second
#define rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define dep(i,a,b) for(register int i=(a);i>=(b);--i)
#define sd(x) scanf("%d",&(x))
#define slld(x) scanf("%lld",&(x))
#define sdd(x,y) scanf("%d%d",&(x),&(y))
#define sc(s) scanf("%s",(s))
#define pd(x) printf("%d\n",(x))
#define plld(x) printf("%lld\n",(x))
#define pdk(x) printf("%d ",(x))
#define plldk(x) printf("%lld ",(x))
#define pdd(x,y) printf("%d %d\n",(x),(y))
typedef long long ll;
int n,A,K;
struct node{
	int l,r;
	int ma;
}a[maxn<<2];
void build(int k,int l,int r)
{
	a[k].l=l;a[k].r=r;
	if(l==r)return;
	int mid=(l+r)>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
}
void pushup(int k)
{
	a[k].ma=max(a[k<<1].ma,a[k<<1|1].ma);
}
void update(int k,int l,int x)
{
	if(a[k].l==l&&a[k].r==l)
	{
		a[k].ma=x;return;
	}
	int mid=(a[k].l+a[k].r)>>1;
	if(l<=mid)update(k<<1,l,x);
	else update(k<<1|1,l,x);
	pushup(k);
}
int query(int k,int l,int r)
{
	if(l<0)l=0;
	if(r>300000)r=300000;
	if(r<l)return 0;
	if(a[k].l>=l&&a[k].r<=r)return a[k].ma;
	int MA=0;
	int mid=(a[k].l+a[k].r)>>1;
	if(l<=mid)MA=max(MA,query(k<<1,l,r));
	if(r>mid)MA=max(MA,query(k<<1|1,l,r));
	return MA;
}
void solve()
{
	sdd(n,K);
	build(1,0,300000);
	rep(i,1,n)
	{
		sd(A);
		int x=query(1,A-K,A+K);
		update(1,A,x+1);
	}
	pd(a[1].ma);
	
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T=1;
//	sd(T);
	while(T--)solve();
} 

Measured memory_bytes: 16120
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long
#define INF 10e9

using namespace std;
using P = pair<int, int>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

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 N;
ll int K;
vector<ll int> a;
vector<ll int> f;
vector<pair<ll int, pair<ll int, ll int>>> scores;

ll int check(ll int a, ll int b) {
  //cout << a << " " << b << "\n";
  if (a == b) {
    return a;
  } else {
    ll int c = (a + b) / 2;

    ll int sum = 0;

    Rep(i, N) {
      ll int tmp_score = scores[i].first;
      ll int div = scores[i].second.second;

      if (tmp_score > c) {
        if ((tmp_score - c) % div == 0) {
          sum += (tmp_score - c) / div;
        } else {
          sum += (tmp_score - c) / div + 1;
        }
      }
    }

    if (sum <= K) {
      return check(a, c);
    } else {
      return check(c + 1, b);
    }
  }
}

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

  Rep(i, N) {
    ll int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }

  sort(a.begin(), a.end(), greater<ll int>());

  Rep(i, N) {
    ll int tmp;
    cin >> tmp;
    f.push_back(tmp);
  }

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

  Rep(i, N) {
    scores.push_back(make_pair(a[i] * f[i], make_pair(a[i], f[i])));
  }
  
  sort(scores.begin(), scores.end());

  //Rep(i, N) {
  //  cout << (scores[i]).first << "\n";
  //}
  
  ll int ans;
  ans = check(0, scores[N-1].first);

  printf("%lld\n", ans);
} 

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

int main(){
    int64_t w, h, x, y;
    cin >> w >> h >> x >> y;
    int a = -1;
    if(x*2==w && y*2==h){
        a = 1;
    }else{
        a = 0;
    }
    cout << fixed << setprecision(10);
    cout << w*h/2.0 << " " << int(a) << endl;
    return 0;
}

Measured memory_bytes: 256
k,n = [int(aaa) for aaa in input().split()]
a = [int(aaa) for aaa in input().split()]
fmax = -1
for i in range(1,n):
    f = a[i] - a[i-1]
    if f > fmax:
        fmax = f
f = k-a[-1] + a[0]
if f > fmax:
    fmax = f
print(k-fmax)



Measured memory_bytes: 26444
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

char key[][ 2 ][ 9 ] = {
	{ "\'", "000000" },
	{ "?", "000001" },
	{ "W", "000010" },
	{ ",", "000011" },
	{ "D", "0001" },
	{ "L", "00100" },
	{ "O", "00101" },
	{ "S", "00110" },
	{ "T", "00111" },
	{ "H", "010000" },
	{ ".", "010001" },
	{ "F", "01001" },
	{ "C", "0101" },
	{ "K", "0110" },
	{ "I", "0111" },
	{ "R", "1000" },
	{ "Z", "10010000" },
	{ "-", "10010001" },
	{ "X", "10010010" },
	{ "Y", "10010011" },
	{ "A", "100101" },
	{ "J", "10011000" },
	{ "M", "10011001" },
	{ "B", "10011010" },
	{ "G", "10011011" },
	{ "U", "10011100" },
	{ "V", "10011101" },
	{ "N", "10011110" },
	{ "Q", "10011111" },
	{ " ", "101" },
	{ "E", "110" },
	{ "P", "111" },
};

int main()
{
	string code;

	while( getline( cin, code ) ){
		string bits;
		int length = code.size();
		for( int i = 0; i < length; ++i ){
			char c = code[ i ];
			if( c >= 'A' && c <='Z' ){
				c -= 'A';
			}else{
				switch( c ){
					case ' ': c = 0x1A; break;
					case '.': c = 0x1B; break;
					case ',': c = 0x1C; break;
					case '-': c = 0x1D; break;
					case '\'': c = 0x1E; break;
					case '?': c = 0x1F; break;
				}
			}
			c <<= 3;
			for( int i = 0; i < 5; ++i ){
				if( c & 0x80 ){
					bits += '1';
				}else{
					bits += '0';
				}
				c <<= 1;
			}
		}
		length = bits.size();
		int index = 0;
		string decrypt;
		bool found = true;
		while( found ){
			found = false;
			for( int i = 0; i < 32; ++i ){
				int l = strlen( key[ i ][ 1 ] );
				if( bits.find( key[ i ][ 1 ], index, l ) != index ){
					continue;
				}
				decrypt += key[ i ][ 0 ];
				index += l;
				found = true;
				break;
			}
		}
		cout << decrypt << endl;
	}

	return 0;
}

Measured memory_bytes: 896
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($cond:expr, $a:expr, $b:expr) => {
        if $cond {
            $a
        } else {
            $b
        }
    }
}

const MOD: i64 = 1e9 as i64 + 7;

fn main() {
    input! {
        h: usize, w: usize,
        table: [chars; h]
    };

    let mut dp = vec![vec![0; w]; h];
    dp[0][0] = 1;
    for i in 0..h {
        for j in 0..w {
            if table[i][j] == '#' {
                continue;
            }
            if i >= 1 {
                dp[i][j] += dp[i-1][j];
            }
            if j >= 1 {
                dp[i][j] += dp[i][j-1];
            }
            dp[i][j] %= MOD;
        }
    }
    println!("{}", dp[h-1][w-1]);
}

Measured memory_bytes: 16636
import numpy as np
import itertools

N = int(input())

A = np.arange(1, 10)
B = np.arange(1, 10)

lists = list(itertools.product(A,B))
multis = []
for i in range(len(lists)):
    multi = lists[i][0] * lists[i][1]
    multis.append(multi)
    
if N in multis:
    print('Yes')
else :
    print('No')

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

using namespace std;

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
    map<int, int> cnt;
    int res = 0;
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        int x; cin >> x;
        cnt[x]++;
    }

    vector<int> q;
    for(auto x: cnt) q.push_back(x.second);
    sort(q.begin(), q.end());
    // for(auto x: q) cout << x << ' ';
    for(int i = 0; i < int(q.size()) - k; i++) res += q[i];

    cout << res;
}


Measured memory_bytes: 10744
from itertools import permutations

N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]

#グリッド座標を3種類に分ける
rem = [[] for _ in range(3)]
for i in range(N):
    for j in range(N):
        rem[(i+j+2)%3].append(c[i][j])
# print(rem)

cost = [[] for _ in range(3)]

for i in range(3):
    for s in range(C):
        tmp = 0
        for t in rem[i]:
            tmp += D[t-1][s]
        cost[i].append((tmp, s+1))

for i in cost:
    i.sort()
    i = i[:3]
 
ans = 1e10
for i in cost[0]:
    for j in cost[1]:
        for h in cost[2]:
            if i[1] != j[1] and j[1] != h[1] and h[1] != i[1]:
                ans = min(ans,i[0]+j[0]+h[0])
print(ans)

Measured memory_bytes: 13536
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp()//true for a before b
{
	bool ans = 0;
	return ans;
}

const int N = (1e3) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 650;

ll a[N];
vi op;

void func(int &n)
{
	int i;
	if(n == 2)
	{
		op.pb(2);
		n--;
		return;
	}
	if(a[1] > 0LL && a[3] > 0LL)
	{
		n -= 2;
		op.pb(2);
		a[1] += a[3];
		fo(i,2,n+1)
			a[i] = a[i+2];
		return;
	}
	if(a[1] > 0LL)
	{
		op.pb(3);
		if(n > 3)
		{
			n -= 2;
			a[2] += a[4];
			fo(i,3,n+1)
				a[i] = a[i+2];
			return;
		}
		n--;
		return;
	}
	if(a[3] > 0LL)
	{
		op.pb(1);
		op.pb(1);
		n -= 2;
		fo(i,1,n+1)
			a[i] = a[i+2];
		return;
	}
	op.pb(2);
	n -= 2;
	a[1] += a[3];
	fo(i,2,n+1)
		a[i] = a[i+2];
	return;
}

void solve()
{
	int n, i;
	ll ans, sodd, seven;
	cin >> n;
	sodd = 0LL;
	seven = 0LL;
	fo(i,1,n+1)
		cin >> a[i];
	fo(i,1,n+1)
	{
		if(i&1)
			sodd += max(0LL, a[i]);
		else
			seven += max(0LL, a[i]);
	}
	if(sodd > seven)
	{
		ans = sodd;
	}
	else if(seven > sodd)
	{
		ans = seven;
		op.pb(1);
		n--;
		fo(i,1,n+1)
			a[i] = a[i+1];
	}
	else if(sodd > 0LL)
	{
		ans = sodd;
	}
	else
	{
		ans = -INFLL;
		fo(i,1,n+1)
			ans = max(ans, a[i]);
		for(i = n; i > 0; i--)
		{
			if(a[i] == ans)
				break;
			op.pb(i);
		}
		i--;
		while(i--)
			op.pb(1);
		cout << ans << '\n' << sz(op) << '\n';
		fo(i,0,sz(op))
			cout << op[i] << '\n';
		return;
	}
	while(n > 1)
		func(n);
	cout << ans << '\n' << sz(op) << '\n';
		fo(i,0,sz(op))
			cout << op[i] << '\n';
	return;
}

int main()
{
	sws;
	// clock_t clk;
	// clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1;
	// cout << fixed << setprecision(9);
	// cin >> t;
	while(t--)
		solve();
	// Code ends here

	// clk = clock() - clk;
	// cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

nn = inputs[0][0]
xx = inputs[0][1]
arr = inputs[1].clone

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p nn
  p xx
  p arr
end

cnt = 0
pos = 0
arr.each do |a_i|
  pd pos
  if pos <= xx
    cnt += 1
  end
  pos += a_i
end

pd pos
if pos <= xx
  cnt += 1
end


puts cnt


Measured memory_bytes: 1788
n = int(input())
a = list(map(int,input().split()))
a.sort()
a.reverse()
count = 1
x = 0
y = 0
for i in range(1,n):
    if a[i] == a[i-1]:
        count+=1
    else:
        count = 1
    if count == 2 and x == 0:
        x = a[i]
        count = 0       
    elif count == 2 and y == 0:
        y = a[i]
print(x*y)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#include<unordered_map>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

# define w() int x; cin>>x; while(x--)
#define v vector<int>
#define push(x) push_back(x)
#define show(x) for(int i=0;i<x.size();i++) cout<<a[i]<<" "; cout<<endl; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
void sly()
{
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#ifndef ONLINE_JUDGE
        freopen ("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

}
int main()
{
    sly();
    int k;
    cin>>k;
  	int a,b;
  	cin>>a>>b;
  	int flag=0;
  	for(int i=1;i<=k;i++)
  	{
  		// cout<<a<<endl;
  		if(a%k==0 && a<=b)
  		{
  			flag=1;
  			cout<<"OK"<<endl;
  			break;
  		}
  		if(a>b)
  			break;
  		a++;
  	}	
   if(flag==0)
   	cout<<"NG"<<endl;
    return 0;
}




Measured memory_bytes: 3652
#include <iostream>
#include <vector>

int f(std::vector<std::vector<int> > a, std::vector<int> b, int c) {

    int result = 0;
    for (int i = 0; i < a.size(); i++) {
        int d = 0;
        for (int j = 0; j < a[i].size(); j++) {
            d += a[i][j] * b[j];
        }
        d += c;
        if (d > 0) {
            result++;
        }
    }
    return result;
}

int main() {

    int n, m, c;
    std::cin >> n >> m >> c;

    std::vector<int> b;
    for (int i = 0; i < m; i++) {
        int tmp;
        std::cin >> tmp;
        b.push_back(tmp);
    }

    std::vector<std::vector<int> > a;
    for (int i = 0; i < n; i++) {
        std::vector<int> aa;
        for (int j = 0; j < m; j++) {
            int tmp;
            std::cin >> tmp;
            aa.push_back(tmp);
        }
        a.push_back(aa);
    }

    int result = f(a, b, c);
    std::cout << result << std::endl;

    return 0;
}


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

int n, k, p, *w;

bool check(){
  int tk = k, i=0;
  int rest = p;

  while(i<n) {
    if ((rest -= w[i]) < 0) {
      if (tk == 1) return false;
      tk--;
      rest = p;
    } else {
      i++;
    }
  }
  return true;
}

int main() {
  int left = 0, right = 1;
  cin >> n >> k;
  int sbe6oj[n];
  w = sbe6oj;
  for(int i=0; i<n; i++) {
    cin >> w[i];
    right += w[i];
  }
  while(left+1 != right) {
    p = (left+right)/2;
    if (check()) right = p;
    else left = p;
  }
  cout << right << endl;
  return 0;
}

Measured memory_bytes: 1552
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  string S, T; cin >> S >> T;
  int ans = 1e9;
  for(int i=0;i<sz(S)-sz(T)+1;i++){
    int preans = 0;
    rep(j,sz(T)){
      if(S[i+j]!=T[j]) preans++;
    }
    chmin(ans, preans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
n, m, x = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]

ans = 10 ** 18
for bit_state in range(1 << n):
    tmp = [0] * m
    cost = 0
    for i in range(n):
        if bit_state & (1 << i):
            for j in range(m):
                tmp[j] += info[i][j + 1]
            cost += info[i][0]

    for j in range(m):
        if tmp[j] < x:
            break
    else:
        ans = min(cost, ans)

if ans == 10 ** 18:
    print(-1)
else:
    print(ans)

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

int main()
{
    int n;
    ll ans = 1;
    cin >> n;
    vector<ll> A(n);
    ll max = 1000000000000000000;

    rep(i, n)
    {
        ll a;
        cin >> a;
        if (a == 0)
        {
            cout << 0 << endl;
            return 0;
        }
        A[i] = a;
    }

    rep(i, n)
    {
        if (A[i] > max / ans)
        {
            cout << -1 << endl;
            return 0;
        }
        ans *= A[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048
#include <iostream>
#include <vector>
#include <string>

using namespace std;

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

  vector<int> ans(s.length(), 0);

  int r_counter = 0;
  int l_counter = 0;

  for(int i = 0; i < s.length(); ++i){
    if(s[i] == 'R') ++r_counter;
    if(1 <= i){
      if(s[i-1] == 'R' && s[i] == 'L'){
        ans[i-1] = 1;
        ans[i] = 1;
        if(2 <= r_counter){
          ans[i-1] += (r_counter - 1) / 2; 
          ans[i] += (r_counter - 1) - (r_counter - 1) / 2; 
        }
        r_counter = 0;
      }
    }
  }

  for(int i = s.length()-1; 0 <= i; --i){
    if(s[i] == 'L') ++l_counter;
    if(i <= s.length() - 2){
      if(s[i] == 'R' && s[i+1] == 'L'){
        if(2 <= l_counter){
          ans[i] += (l_counter - 1) - (l_counter - 1) / 2; 
          ans[i+1] += (l_counter - 1) / 2; 
        }
        l_counter = 0;
      }
    }
  }

  for(int i = 0; i < s.length()-1; ++i){
    cout << ans[i] << " ";
  }
  cout << ans[s.length()-1] << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.*;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[5];
		for(int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		int time = 0;
		
		int min = 10;
		int sub = 0;
		for(int i = 0; i < a.length; i++) {
			int tmp = a[i]%10;
			
			if( tmp < min && tmp != 0) {
				sub = i;
				min = tmp;
			}
		}
		int tmpi = a[4];
		a[4] = a[sub];
		a[sub] = tmpi;
		
		for(int i = 0; i < a.length-1; i++) {
			if(a[i]%10 == 0) {
				time += a[i];
			}else {
				int tmp = a[i]%10;
				time += a[i] + (10-tmp);
			}
		}
	
			time += a[4];
	
			System.out.println(time);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define ll long long
typedef pair<ll , ll > pii;
ll mod=998244353;
ll p=1e9+7;
double PI= 3.14159265;
int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    int x=n%10;
    if( x == 2 || x == 4 || x == 5 || x== 7 || x == 9){
        cout<<"hon";
    }
    if( x == 0 || x == 1 || x== 6 || x == 8 ){
        cout<<"pon";
    }
    if( x == 3){
        cout<<"bon";
    }
    return 0;
}
 

Measured memory_bytes: 3652