akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * @param args
 */
public class Main {
    static final String HASHMARK = "#";
    static final String DOTMARK  = ".";
    static final String SPACE    = " ";
    
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            while ((sStr = stdReader.readLine()) != null) {
                String[] inputs = sStr.split(" ");
                
                int n = Integer.valueOf(inputs[0]);
                call(n);
            }
            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
    }
    
    // void call(int n){
    // int i = 1;
    // CHECK_NUM:
    // int x = i;
    // if ( x % 3 == 0 ){
    // cout << " " << i;
    // goto END_CHECK_NUM;
    // }
    // INCLUDE3:
    // if ( x % 10 == 3 ){
    // cout << " " << i;
    // goto END_CHECK_NUM;
    // }
    // x /= 10;
    // if ( x ) goto INCLUDE3;
    // END_CHECK_NUM:
    // if ( ++i <= n ) goto CHECK_NUM;
    //
    // cout << endl;
    // }
    
    private static void call(int n) {
        int i = 1;
        boolean flg = false;
        
        while (true) {
            // CHECK_NUM:
            int x = i;
            if (x % 3 == 0) {
                System.out.print(SPACE + i);
                if (++i <= n) {
                    continue;
                } else {
                    break;
                }
            }
            
            // INCLUDE3:
            do {
                if (x % 10 == 3) {
                    System.out.print(SPACE + i);
                    if (++i <= n) {
                        flg = true;
                        break;
                    }
                }
                x /= 10;
            } while (0 != x );
            if (flg) {
                flg = false;
                continue;
            }
            if (++i <= n) {
                continue;
            } else {
                break;
            }
        }
        
        System.out.println();
    }
}

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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

int n, a[N];
vector<int> b[2];
map<int, int> l, r;

int main() {
	megaRandom();
	cin >> n;
	for(int i = 1; i <= n; i ++) {
		cin >> a[i];
		b[i & 1].pb(a[i]);
	}
	
	sort(all(b[1]));
	sort(all(b[0]));
	reverse(all(b[1]));
	reverse(all(b[0]));
	
	sort(a + 1, a + n + 1);
	int ps = 1;
	for(int i = 1; i <= n; i ++) {
		if(a[i] != a[i - 1])
			ps = i;	
		l[a[i]] = ps;
	}
	ps = n;
	for(int i = n; i >= 1; i --) {
		if(a[i] != a[i + 1])
			ps = i;
		r[a[i]] = ps;			
	}
	int cnt = 0;
	for(int i = 1; i <= n; i ++) {
		bool opp = (i & 1) ^ 1;
		if(l[b[i & 1].back()] <= i && i <= r[b[i & 1].back()])
			b[i & 1].pp();
		else 
			b[opp].pp(), cnt ++;
	}
	cout << cnt / 2;
	return 0;  
}


Measured memory_bytes: 10364
import java.util.*;
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a > b) {
      System.out.println(a - 1);
    }
    else {
      System.out.println(a);
    }
  }
}
    

Measured memory_bytes: 35524
#!/usr/bin/env python3

N, K = map(int, input().split())
H = list(map(int, input().split()))

if N <=K:
    print(abs(H[0]-H[-1]))
    exit()


dp = [float('inf') for _ in range(N+K+1)]

dp[0] = 0

for i in range(1, K+1):
    dp[i] = abs(H[0] - H[i])

for i in range(N):
    for j in range(i+1, i+K+1):
        if j < N:
            dp[j] = min(dp[i] + abs(H[i]-H[j]), dp[j])

print(dp[N-1])



Measured memory_bytes: 83488
#include<iostream>
#include<map>

#define LL long long

using namespace std;

LL a[200005];
LL s[200005];
LL x[200005]; 



int main(){

    int n;
    cin >> n;


    for(int i = 1; i <= n; i++){
         cin >> a[i];
         s[i] = s[i-1] + a[i];
         x[i] = x[i-1] ^ a[i];
     }

    LL ans = 0;    
    int l = 1;


    for(int r = 1; r <= n; r++){

          while( (s[r]-s[l-1]) != (x[r]^x[l-1])){
              l++;
            }
          
          ans += r - l + 1;
       }

    
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 4992
n = gets.to_i
as = gets.split.map(&:to_i)
ans = [as]
bs = as

(1...n).each do |i|
  bs = bs.dup
  v = bs[i]
  j = i - 1

  while j >= 0 && bs[j] > v
    bs[j + 1] = bs[j]
    j -= 1
  end

  bs[j + 1] = v
  ans << bs
end

ans.each do |i|
  puts i.join(' ')
end



Measured memory_bytes: 6968
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chimin(T& a, T b) {
    if (a > b) { a = b; return true; } return false;
}

template<class T> inline bool chimax(T& a, T b) {
    if (a < b) { a = b; return true; } return false;
}

const long long INF = 1LL << 60;

int main() {
    int N; cin >> N;
    vector<int> cnt(4);
    for (int i = 0; i < N; i++) {
        string S; cin >> S;
        if (S == "AC") cnt.at(0)++;
        else if (S == "WA") cnt.at(1)++;
        else if (S == "TLE") cnt.at(2)++;
        else cnt.at(3)++;
    }
    cout << "AC x " << cnt.at(0) << endl;
    cout << "WA x " << cnt.at(1) << endl;
    cout << "TLE x " << cnt.at(2) << endl;
    cout << "RE x " << cnt.at(3) << endl;
}

Measured memory_bytes: 3628
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	int a, b;
	char op;
	cin >> a >> op >> b;
	cout << (op == '+' ? a + b : a - b) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(){
    char s[101];
    scanf("%s", s);
    bool yes = true;
    for(int i=0; s[i] != '\0'; i++){
        if(i % 2 == 0){
            // odd number (even id)
            if(!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')){
                yes = false;
                break;
            }
        }else{
            if(!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')){
                yes = false;
                break;
            }
        }
    }
    if(yes){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
n=int(input())
a=[]
b=[]


for i in range(n):
  A=int(input())
  a.append(A)
  b.append(A)

a.sort()
for i in range(n):
  if b[i]!=a[n-1]:
    print(a[n-1])
  else:
    print(a[n-2])


Measured memory_bytes: 82136
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define Q 1000000007

// ll white, black;
// vector<vector<char>> c(h, vector<char>(w));
// ll ans = 0;
// vector<ll> a(N);
// const int M = 2;
// void dfs(vector<int> &A) {
//     // 終端条件 --- 10 重ループまで回したら処理して打ち切り
    

//     if(A.size() == h+w){
//       // rep(i, A.size()) cout << A[i];
//       // cout << " ";
//       vector<vector<char>> tmp(h, vector<char>(w));
//       rep(i, h){
//         rep(j, w) tmp[i][j] = c[i][j];
//       }
//       ll cnt = black;
//       for(ll i = 0; i < h; i++){
//         if(A[i] == 1){
//           // cout << i << " ";
//           rep(j, w){
//             if(tmp[i][j] == '#'){
//               tmp[i][j] = 'r';
//               cnt--;
//             }
//           }
//         }
//       }
//       for(ll i = h; i < h+w; i++){
//         if(A[i] == 1){
//           // cout << i << " ";
//           rep(j, h){
//             if(tmp[j][i-h] == '#'){
//               tmp[j][i-h] = 'r';
//               cnt--;
//             }
//           }
//         }
//       }

//       // cout << cnt << endl;
//       if(cnt == k) ans++;
      
//       return;
//     }

//     for (int v = 0; v < M; ++v) {
//         A.push_back(v);
//         dfs(A);
//         A.pop_back(); // これが結構ポイント
//     }
// }

ll max(vector<ll> a) {
  return *max_element(a.begin(), a.end());
}

ll max_index(vector<ll> a) {
  vector<ll>::iterator max_it = max_element(a.begin(), a.end());
  return distance(a.begin(), max_it);
}

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

  ll ls = s.length();
  ll lt = t.length();

  ll ans = lt, count = 0;
  rep(i,ls-lt+1){
    count = 0;
    for(ll j = 0; j<lt; j++){
      if(s[i+j] != t[j]){
        count++;
      }
    }
    // cout << i << count << endl;
    if(count < ans){
      ans = count;
    }
  }

  cout << ans << endl;
  

  return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

int gcd(int a,int b){
  int c;
  while((c=a%b)!=0){
    a=b;
    b=c;
  }
  return b;
}
int main(){
  long a1,m1,a2,m2,a3,m3,count,x1,x2,x3,i,ac,bc,cc;
  long long int lc;
  do{
    scanf("%ld %ld %ld %ld %ld %ld",&a1,&m1,&a2,&m2,&a3,&m3);
    if(!a1&&!m1&&!a2&&!m2&&!a3&&!m3) break;
    for(i=a1,ac=1;i!=1;i=(a1*i)%m1,ac++);
    for(i=a2,bc=1;i!=1;i=(a2*i)%m2,bc++);
    for(i=a3,cc=1;i!=1;i=(a3*i)%m3,cc++);
    lc=ac*bc/gcd(ac,bc);
    lc=lc*cc/gcd(lc,cc);
    printf("%lld\n",lc);
    
  }while(1);
  return 0;
}

Measured memory_bytes: 0
import sys
import heapq
input = sys.stdin.readline
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

P = {}
for a, b in AB:
    if a <= M:
        if not a in P.keys():
            P[a] = [b]
        else:
            P[a].append(b)

B = sorted(P.items(), key=lambda x:x[0], reverse=True)
Q = []
for k, v in B:
    v.sort(reverse=True)
    A = v[:M-k+1]
    for a in A:
        heapq.heappush(Q, a)
    maxp = max(len(Q)-M+k-1, 0)
    for _ in range(maxp):
        heapq.heappop(Q)

print(sum(Q))

Measured memory_bytes: 47344
import java.util.*;

class Main{

    public static void puts(char[][] str){
	for(int i=0;i<str.length;i++){
	    for(int j=0;j<str[i].length;j++){
		System.out.print(str[i][j]);
	    }
	    System.out.print('\n');
	}
	return;
    }
    
    public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
	int h=sc.nextInt();
	int w=sc.nextInt();
	char[][] a=new char[h][w];
	for(int i=0;i<h;i++){
	    a[i]=(sc.next()).toCharArray();
	}
	char[][] b=new char[h][w];
	char[][] r=new char[h][w];
	for(int i=0;i<h;i++){
	    for(int j=0;j<w;j++){
		if(j==0){
		    b[i][j]='#';
		    r[i][j]='.';
		}
		else if(j==w-1){
		    b[i][j]='.';
		    r[i][j]='#';
		}
		else{
		    if(i%2==0){
			b[i][j]='.';
			r[i][j]='#';
		    }
		    else{
			b[i][j]='#';
			r[i][j]='.';
		    }
		}
	    }
	}
	for(int i=0;i<h;i++){
	    for(int j=0;j<w;j++){
		if(a[i][j]=='#'){
		    r[i][j]='#';
		    b[i][j]='#';
		}
	    }
	}
	puts(b);
	puts(r);

	return;
    }
    
}


Measured memory_bytes: 50356
#include <stdio.h>
#define M 20000
#define N 10000

typedef struct /*水たまりの情報をいれる構造体*/
{
  int S;/*面積*/
  int h;/*縁の高さ*/
  int yoko;/*面積計算の終了位置x座標*/
}Mizutamari;

typedef struct
{
  int x;
  int y;
}Zahyo;

Mizutamari MT[N];
Zahyo Z[M];

int main()
{
  int Y=0,X=0 /*現在の点の座標*/
    ,y_max=0,x_max=0 /*xyのMAX*/
    ,S_sum=0 /*水たまりの面積の合計*/
    ,menseki
    ,n=0/*水たまりの数*/
    ,j=0/*座標スタックの数*/
    ,i,k=1;/*変数*/

  char c;/*入力したものをいれるやつ*/

  while(scanf("%c",&c)!=EOF)
    {
      menseki=0;
      if(c=='\\')
	{
	  /*座標スタックに現在のx,yをそれぞれ記憶。
	    ついでにx++,y--をして現在の点の座標を動かす*/
	  Z[j].x=X++;
	  Z[j].y=Y--;
	  j++;
	}
      else if(c=='/')
	{
	  
	  X++;
	  Y++;

	  if(y_max<Y)
	    {
	      y_max=Y;
	      x_max=X;
	    }
	  
	  if(j>0)
	    {
	      /*面積計算*/
	      menseki=X-1-Z[j-1].x;
	      /*もし現在の点のy座標より低い位置で
		面積を計算したMTがあるならそれを取り出して足す！！*/
	      while(n>0 && MT[n-1].h<Y &&MT[n-1].yoko>=x_max)
		{
		  menseki+=MT[n-1].S;
		  n--;
		}
	      /*MTに代入*/
	      MT[n].S=menseki;
	      MT[n].h=Y;
	      MT[n].yoko=X;
	      
	      n++;
	      j--;
	    }
	}
      else if(c=='_')
	{
	  X++;
	}
     
    }
  for(i=0;i<n;i++)
    {
      S_sum+=MT[i].S;
    }
  
  /*表示*/
  printf("%d\n",S_sum);
  if(n!=0)
    {
      printf("%d ",n);
      for(i=0;i<n-1;i++)printf("%d ",MT[i].S);
      printf("%d\n",MT[n-1].S);
    }
  else
    {
      printf("%d\n",n);
    }
  return 0;
}



Measured memory_bytes: 2108
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def comb(n, k):
    return fact[n] * pow(fact[n-k], mod-2, mod) * pow(fact[k], mod-2, mod) % mod

s = I()
n = s // 3

fact = [1] * (s+1)
for i in range(2, s+1):
    fact[i] = i * fact[i-1]
    fact[i] %= mod

ans = 0
for i in range(1, n+1):
    t = 3*i
    u = s - t
    ans += comb(u + i - 1, i - 1)
    ans %= mod
print(ans)

Measured memory_bytes: 67508
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	HashSet<Character> set = new HashSet<Character>();
	String str = sc.next();
	for(int i = 0; i<str.length(); i++) {
	    set.add(str.charAt(i));
	}
	for(int i = 0; i<26; i++) {
	    if(!set.contains((char)('a'+i))) {
		System.out.println((char)('a'+i));
		return;
	    }
	}
	System.out.println("None");
    }
}

Measured memory_bytes: 24804
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;

int main(){
   int a,b,c;
   cin>>a>>b>>c;
   cout<<a+b+c-max({a,b,c})<<endl;
}

   


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

int pizza_prise(int A, int B, int C, int X, int Y){
  int prise = INT_MAX;
  for(int i = 0; i < (X+Y)*2; i++){
    double sum = C * i;
    int x = X-i/2;
    int y = Y-i/2;
    if(0 < x) sum += x*A;
    if(0 < y) sum += y*B;
    if (prise > sum){
      prise = sum;
    }
  }
  return prise;
}

int main(){
  int A=0,B=0,C=0,X=0,Y=0;
  cin >> A >> B >> C >> X >> Y;
  cout << pizza_prise(A,B,C,X,Y);
  return 0;
}

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

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

const int inf=1e9;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,T,c,t; cin>>N>>T;
	int ret=inf;
	while(N--) {
		cin>>c>>t;
		if(!(t>T))
			ret=min(ret,c);
	}
	if(ret==inf) { cout << "TLE" << endl; return 0; }
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
import itertools

N = int(input())
P = input().replace(' ','')
Q = input().replace(' ','')

item = []
for i in range(1,N + 1):
    item.append(str(i))
lst = list(itertools.permutations(item))

item2 = []
for l in lst:
    item2.append(''.join(l))

a = abs(item2.index(P) - item2.index(Q))
print(a)


Measured memory_bytes: 10868
#include <set>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iostream>
using namespace std;
int main() {
    int t; cin >> t;
    while (t--) {
        int n; cin >> n;
        int K[n], L[n], R[n];
        vector<int> left, right;
        long long ans = 0;
        for (int i = 0; i < n; i++) {
            cin >> K[i] >> L[i] >> R[i];
            if (L[i] > R[i]) left.push_back(i);
            else right.push_back(i);
            ans += max(L[i], R[i]);
        }
        sort(left.begin(), left.end(), [&](int i, int j) { return K[i] < K[j]; });
        sort(right.begin(), right.end(), [&](int i, int j) { return K[i] > K[j]; });
        multiset<int> ld, rd;
        for (int i : left) {
            ld.insert(L[i] - R[i]);
            if (K[i] < ld.size()) {
                ans -= *ld.begin();
                ld.erase(ld.begin());
            }
        }
        for (int i : right) {
            rd.insert(R[i] - L[i]);
            if (n - K[i] < rd.size()) {
                ans -= *rd.begin();
                rd.erase(rd.begin());
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 15164
import Prelude
import Data.List

takeodd :: [a]->[a]
takeodd []=[]
takeodd [x]=[x]
takeodd (x:y:ys)=x:(takeodd ys)

main :: IO ()
main = do
    -- 整数の入力(捨て)
    n <- getLine
    -- スペース区切り整数の入力
    els <- map read . words <$> getLine
    -- 文字列の入力
    -- 出力
    putStrLn$show$sum$takeodd$sort els


Measured memory_bytes: 1020
#include <stdio.h>
#include <iostream>
#include <algorithm>
#define Re register int
#define LL long long

int N,M,X[100005],d[100005];
LL ans;

template <typename T> inline void read(T &var)
{
	T x=0; int w=0; char ch=0;
	while (!isdigit(ch)) w|=ch=='-',ch=getchar();
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	var=w?-x:x;
}
inline bool cmp_min(int a,int b) {return a<b;}
inline bool cmp_max(int a,int b) {return a>b;}
int main(int argc, char const *argv[])
{
	//freopen("1.in","r",stdin);
	read(N),read(M); if (N>M) {printf("0\n"); return 0;}
	for (Re i=1; i<=M; ++i) read(X[i]);
	std::sort(X+1,X+M+1,cmp_min); ans=X[M]-X[1];
	for (Re i=1; i<M; ++i) d[i]=X[i+1]-X[i];
	std::sort(d+1,d+M,cmp_max);
	for (Re i=1; i<N; ++i) ans-=d[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y, ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        if(y%2==0)
         return (p*p)%z;
        else
        return (x*((p*p)%z))%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
ll po(ll x)
{
    ll c=0;
    while(x>0)
    {
        x=x&(x-1);
        c++;
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
     ll a,b,c;
     cin>>a>>b>>c;
     if(c>=a&&c<=b)
     cout<<"Yes";
     else
     cout<<"No";}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> a(100001, 0);
	rep(i,n){
		int x;
		cin >> x;
		a[x]++;
	}
	int ans = 0;
	rep(i,m){
		int j = (m-i)%m;
		if(i == j){
			int s = 0;
			for(int k = i; k < 100001; k += m) s += a[k];
			ans += s/2;
		}
		else if(i < j){
			int s = 0, sx = 0;
			for(int k = i; k < 100001; k += m) s += a[k]/2*2, sx += a[k] & 1;
			int t = 0, tx = 0;
			for(int k = j; k < 100001; k += m) t += a[k]/2*2, tx += a[k] & 1;
			if(sx > tx){
				swap(s, t);
				swap(sx, tx);
			}
			ans += sx;
			tx -= sx;
			int x = min(tx, s);
			ans += x;
			s -= x;
			ans += s/2;
			ans += t/2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int x,y,z,a,ans;
int main()
{
    cin>>x>>y>>z;
    a=z;
    while(a+y+z<=x)
    {
        a+=y+z;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
main(void){
    
    int n,i,min,max;
    int x[100001];
    long en=0;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    min=1000000;
    for(i=0;i<n;i++){
        if(min > x[i]){
            min = x[i];
        }
    }
    max=-1000000;
    for(i=0;i<n;i++){
        if(max < x[i]){
            max = x[i];
        }
    }
    i=0;
    while(i!=n){
        en=en+x[i];
        i++;
    }
    printf("%d %d %ld\n",min,max,en);
    
}



Measured memory_bytes: 2144
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 ll n;
 cin >> n;
 vector<ll> div;
 for(ll i=1;i*i<=n;i++){
   if(n%i==0){
      div.push_back(i);
    }
 }
 cout << div.back()+n/div.back()-2 << endl;
 return 0;
}


Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(v)";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var mod = 1e9+7;
function abmod(){for(var a=arguments,r=a[0],i=1;i<a.length;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i++])%mod;return r;}

console.log(main());
function main(){
  var n = o.a();
  var x = o.a();
  var s = o.l().sort((a,b)=>b-a);
  var dp = {};
  dp[x] = 1;
  for(var i = 0; i < n; i++){
    var dp2 = {};
    for(var j in dp){
      j = +j;
      if(dp2[j])dp2[j] += dp[j] * (n-i-1), dp2[j] %= mod;
      else dp2[j] = dp[j]*(n-i-1) % mod;
      var m = j % s[i];
      if(dp2[m])dp2[m] += dp[j], dp2[m] %= mod;
      else dp2[m] = dp[j];
    }
    dp = dp2;
  }
  var ans = 0;
  for(i in dp){
    i = +i;
    ans += abmod(i,dp[i]);
  }
  return ans % mod;
}

Measured memory_bytes: 46028
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
#define llx(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len) {char ss[len];scanf("%s",ss);(st)=ss;}
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	cout<<max(max(a+b,a-b),a*b);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long int     ll;
typedef  vector<int>       vi;
typedef  pair<int, int>     pii;
#define  int               ll
#define  F                 first
#define  S                 second
#define  pb                push_back
#define  mp                make_pair
#define  si(x)             (int)x.size()
#define  all(x)            x.begin(),x.end()
#define  minv(m,n)         *min_element(m,n)
#define  maxv(m,n)         *max_element(m,n)
#define  mem(a,x)          memset(a,x,sizeof(a))
#define  deb(x)            cout<<#x<<" = "<<x<<endl
#define  rep(i,n)          for(int i=0;i<n;i++)
#define  prs(x)            fixed <<setprecision(x)
#define  w(ttz)            int ttz;cin>>ttz;while(ttz--)
#define  show(a)           for(auto x:a){cout<<x<<" ";}cout<<endl;
void iosbase(void);

int32_t main()
{
  iosbase();
  string s;
  cin >> s;
  std::vector<char> v;
  for (int i = 0 ; i < si(s) ; i++)
  {
    if (s[i] == '0')
    {
      v.pb('0');

    }
    else if ( s[i] == 'B' and v.empty() == false)
    {
      v.erase(v.end() - 1);
    }
    else if (s[i] == 'B' and v.empty() )
      continue;
    else
    {
      v.pb('1');
    }
  }
  for (auto x : v)
    cout << x;
  cout << endl;


}


void iosbase(void) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cout.tie(nullptr);
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
}

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

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

    if(N < 105)
    {
        cout << 0 << endl;
    }
    else if(N >= 105 && N < 135)
    {
        cout << 1 << endl;
    }
    else if(N >= 135 && N < 165)
    {
        cout << 2 << endl;
    }
    else if(N >= 165 && N < 189)
    {
        cout << 3 << endl;
    }
    else if(N >= 189 && N < 195)
    {
        cout << 4 << endl;
    }
    else if(N >= 195 && N <= 200)
    {
        cout << 5 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;

void main() {
	auto first = new char[0];
	auto last = readln.chomp.dup;

	uint queryMax = readln.chomp.to!uint;

	foreach (i;0..queryMax) {
		auto query = readln.chomp.split(' ');

		if (query[0] == "1") {
			swap(first, last);
		} else if (query[0] == "2") {
			if (query[1] == "1") {
				first ~= query[2];
			} else if (query[1] == "2") {
				last ~= query[2];
			} else {
				assert(false);
			}
		} else {
			assert(false);
		}
	}

	foreach_reverse (c;first) {
		write(c);
	}
	writeln(last);
}


Measured memory_bytes: 3992
parse_input(type=String, x=readline()) = begin
  type == String && return x
  parse(type, x)
end
parse_inputs(type=String) = parse_input.(type, split(readline()))

function solve()
  _ = parse_input()
  A = parse_inputs(BigInt)
  end_a = A[end]
  ans = 0
  for a in A[end-1:-1:1]
    ans += a*end_a
    end_a += a
  end
  mod(ans, (10^9)+7)
end

println(solve())


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

using namespace std;

const int INF = 2147483647;

char s[52][52];
int h, w;
typedef pair < int , int > p;
queue < p > q;
int dis[52][52]; 
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int bfs()
{
	for (int i = 0; i < h; i++) 
		for (int j = 0; j < w; j++) dis[i][j] = INF;
	q.push(p(0, 0));
	dis[0][0] = 0;
	while(q.size())
	{
		p f = q.front(); 
		q.pop();
		if (f.first == h - 1 && f.second == w - 1) break;
		for (int i = 0; i < 4; i++) 
		{
			int nx = f.first + dx[i], ny = f.second + dy[i];
			if (0 <= nx && nx < h && 0 <= ny && ny < w && s[nx][ny] != '#' && dis[nx][ny] == INF) { q.push(p(nx, ny)); dis[nx][ny] = dis[f.first][f.second] + 1; }
		}
	}
	return dis[h - 1][w - 1];
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> h >> w;
	int cnt = 0;
	for (int i = 0; i < h; i++) 
		for (int j = 0; j < w; j++) 
		{ 
			cin >> s[i][j]; 
			if (s[i][j] == '#') cnt++;
		}
	int ans = bfs();
	/*for (int i = 0; i < h; i++) 
		for (int j = 0; j < w; j++) cout << dis[i][j] << endl;*/
	if (ans == INF) cout << -1 << endl;
	else cout << h * w - ans - 1 - cnt << endl;
	return 0;
}

Measured memory_bytes: 764
#include <stdio.h>
#include <iostream>
using namespace std;

int calcSumOfNumbers(const char x[]);

int main(void)
{	
	while (1) {
		char x[1000] = "\0";
		cin >> x;
		
		if (x[0] == '0') break;
		
		cout << calcSumOfNumbers(x) << endl;
	}
	
	return 0;
}

int calcSumOfNumbers(const char x[])
{
	int sum = 0;
	for (int i = 0; x[i] != '\0'; i++) {
		sum += x[i] - '0';
	}
	
	return sum;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t,u;
  cin>>t>>u;
  s=t+u;
  int n=stoi(s);
  string a="No";
  for(int i=4;i<=720;i++){
    if(i*i==n){a="Yes"; break;}
  }
  cout<<a<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
int s, w;
// main solution goes here:
void execute(int test_number)
{
    cin>>s>>w;
    if (s<=w) cout<<"unsafe";
    else cout<<"safe";
}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    if (!is_interactive)
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a == b && a == c)cout << 1 << endl;
    else if (a == b || a == c || b == c)cout << 2 << endl;
    else cout << 3 << endl;
}

Measured memory_bytes: 3628
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
N = int(input())
b = [int(input()) for i in range(N)]# ソートを行う

hit = list()

ans = "No"
for i in range(N):
        if b[i] == A[0]:
                hit.append(1)
        if b[i] == A[1]:
                hit.append(2)
        if b[i] == A[2]:
                hit.append(3)
        if b[i] == B[0]:
                hit.append(4)
        if b[i] == B[1]:
                hit.append(5)
        if b[i] == B[2]:
                hit.append(6)
        if b[i] == C[0]:
                hit.append(7)
        if b[i] == C[1]:
                hit.append(8)
        if b[i] == C[2]:
                hit.append(9)

dct = sorted(hit)


if 1 in dct:
        if 2 in dct:
                if 3 in dct:
                        ans = "Yes"
        if 4 in dct:
                if 7 in dct:
                        ans = "Yes"
        if 5 in dct:
                if 9 in dct:
                        ans = "Yes"
if 2 in dct:
        if 5 in dct:
                if 8 in dct:
                        ans = "Yes"

if 3 in dct:
        if 6 in dct:
                if 9 in dct:
                        ans = "Yes"
        if 5 in dct:
                if 7 in dct:
                        ans = "Yes"

if 4 in dct:
        if 5 in dct:
                if 6 in dct:
                        ans = "Yes"

if 7 in dct:
        if 8 in dct:
                if 9 in dct:
                        ans = "Yes"

print(ans)

Measured memory_bytes: 3188
n = int(input())
A = list(map(int, input().split()))
for i in range(1, n):
    print(' '.join(map(str, A)))
    temp = A[i]
    j = i - 1
    while A[j] > temp and j >= 0:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = temp
print(' '.join(map(str, A)))


Measured memory_bytes: 5600
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a,b,c,d] <- getIntList
    putStrLn $ if abs (a-c) <= d || (abs (a-b) <= d && abs (b-c) <= d) then "Yes" else "No"

Measured memory_bytes: 380
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

using namespace std;

//arc071 怪文書
//a[50][26]を作成し、値がn以上なら出力する
int main(){
  string alphabet = "abcdefghijklmnopqrstuvwxyz";
  ll N,T,res;
  cin >> N;

  ll ari[50][26] = {{}};

  string tmpS;

  REP(i,N)
  {
    cin >> tmpS;
    ll cnt[26] = {};

    for(auto c:tmpS)
    {
      REP(j,26)
      {
        if(c == alphabet[j])
        {
          ari[cnt[j]][j]++;
          cnt[j]++;
        }
      }
    }
  }

  REP(i,26)
  {
    REP(j,50)
    {
      if(ari[j][i] >= N)
      {
        cout << alphabet[i];
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=2005,INF=1<<29;
int dis[MAX][MAX];

void floyd(int N){
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                chmin(dis[i][j],dis[i][k]+dis[k][j]);
            }
        }
    }
}

struct edge{int to;ll cap;int rev;};

vector<edge> G[MAX];
int level[MAX];
int iter[MAX];

void add_edge(int from,int to,ll cap){
    G[from].push_back((edge){to,cap,int(G[to].size())});
    G[to].push_back((edge){from,0LL,int(G[from].size())-1});
}

void BFS(int s){
    memset(level,-1,sizeof(level));
    queue<int> que;
    level[s] =0;
    que.push(s);
    while(!que.empty()){
        int v=que.front();que.pop();
        for(int i=0;i<G[v].size();i++){
            edge &e =G[v][i];
            if(e.cap>0&&level[e.to]<0){
                level[e.to]=level[v]+1;
                que.push(e.to);
            }
        }
    }
}

ll DFS(int v,int t,ll f){
    if(v==t) return f;
    for(int &i=iter[v];i<G[v].size();i++){
        edge &e =G[v][i];
        if(e.cap>0&&level[v]<level[e.to]){
            ll d= DFS(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

ll max_flow(int s,int t){
    ll flow=0;
    for(;;){
        BFS(s);
        if(level[t]<0) return flow;
        memset(iter,0,sizeof(iter));
        ll f;
        while((f=DFS(s,t,INF))>0){
            flow+=f;
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,M,Q;cin>>N>>M>>Q;
        if(N+M+Q==0) break;
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++) dis[i][j]=INF;
            dis[i][i]=0;
        }
        for(int i=0;i<M;i++){
            int a,b,c;cin>>a>>b>>c;
            dis[a][b]=c;
            dis[b][a]=c;
        }
        
        floyd(N);
        
        vector<pair<int,int>> S(Q);
        for(int i=0;i<Q;i++) cin>>S[i].fi>>S[i].se;
        
        for(int i=0;i<2*Q+2;i++){
            G[i].clear();
            level[i]=0;
            iter[i]=0;
        }
        
        for(int i=0;i<Q;i++){
            for(int j=0;j<Q;j++){
                if(i==j) continue;
                if(dis[S[i].fi][S[j].fi]<=S[j].se-S[i].se){
                    add_edge(i,Q+j,1);
                }
            }
        }
        
        for(int i=0;i<Q;i++){
            add_edge(2*Q,i,1);
            add_edge(i+Q,2*Q+1,1);
        }
        
        cout<<Q-max_flow(2*Q,2*Q+1)<<"\n";
    }
}




Measured memory_bytes: 50508
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	string s;
	cin >> s;
	if(s[0] == '9' or s[1] == '9') P("Yes");
	else P("No");
}

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int a,b,k;
  cin >> a >> b >> k;
  
  int ca = a;
  int cb = b;
  ca -= k;

  if(ca < 0){
    ca = 0;
    cb -= k - a;
    if(cb < 0){
      cb = 0;
    }
  }

  cout << ca << " " << cb << endl;

  return 0;
}

Measured memory_bytes: 256
m,n = map(int,input().split())
mod = 10**9+7
# print(pow(m,n,mod))

def power(x,n,m):
    res = 1
    if n > 0:
        res = power(x,n//2,m)
        if n%2 == 0: res = res*res%m
        else: res = res*res%mod*x%m
    return res

print(power(m,n,mod))


Measured memory_bytes: 5600
N = gets.chomp.to_i
p = gets.chomp.split.map(&:to_i)

[*0..N - 1].combination(2) { |i, j|
  a = p.map.with_index { |n, index|
    if index == i
      p[j]
    elsif index == j
      p[i]
    else
      p[index]
    end
  }
  if a == p.sort
    puts "YES"
    exit
  end
}

if p == [*1..N]
  puts "YES"
else
  puts "NO"
end


Measured memory_bytes: 2300
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#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 <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, (int)vec.size() - 1)std::cout << vec[i] << " ";
	if(!vec.empty())std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int x;
bool a[1010];
int main() {
	std::cin>>x;
	a[1]=true;
	for(int i=2;i<32;i++){
		int cnt=i;
		while(true){
			cnt*=i;
			if(cnt>1000)break;
			a[cnt]=true;
		}
	}
	for(int i=x;i>=1;i--){
		if(a[i]){
			std::cout<<i<<std::endl;
			return 0;
		}
	}
	return 0;
}

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

template <typename Tp, typename Fp>
class disjoint_sparse_table{
    Tp **table;
    Fp func;
    size_t length, lg;
public:
    disjoint_sparse_table(size_t n, Tp *values, Fp f): length(n), func(f){
        lg = CHAR_BIT * sizeof(int) - __builtin_clz(std::max((size_t)1, n-1));
        table  = new Tp*[lg];
        *table = new Tp[n * lg];
        for(int i=1;i<lg;++i) table[i] = *table + n * i;
        for(int i=0;i<n;++i) table[0][i] = values[i];
        for(int s=1;s<lg;++s){
            size_t w = 1<<s;
            for(int i=0;i<n;i+=w<<1){
                size_t l = std::min(i + w, n) - 1, r = i + w;
                table[s][l] = values[l];
                for(int j=l-1;j>=i;--j) table[s][j] = f(values[j], table[s][j+1]);
                if(r >= n) continue;
                table[s][r] = values[r];
                for(int j=r+1;j<r+w && j<n;++j) table[s][j] = f(table[s][j-1], values[j]);
            }
        }
    }
    Tp get(size_t left, size_t right, Tp id=Tp{}) const{
        if(left >= right || right > length) return id;
        if(left + 1 == right) return table[0][left];
        size_t s = CHAR_BIT * sizeof(int) - __builtin_clz(left ^ --right) - 1;
        return func(table[s][left], table[s][right]);
    }
};

int pinv[200001];

struct node{
    pair<int, int> val;
    node *children[3];
};
bool operator<(node lhs, node rhs){
    return rhs.val < lhs.val;
}

template<typename dst>
node *solve(int l, int r, const dst &todd, const dst &teven){
    node *ret = new node();
    int sl, sr;
    ret->children[0] = ret->children[1] = ret->children[2] = nullptr;
    ret->val.first  = (l % 2 ? todd : teven).get(l, r);
    sl = pinv[ret->val.first];
    ret->val.second = (l % 2 ? teven : todd).get(sl+1, r);
    sr = pinv[ret->val.second];
    if(l < sl) ret->children[0] = solve(l, sl, todd, teven);
    if(sl+1 < sr) ret->children[1] = solve(sl+1, sr, todd, teven);
    if(sr+1 < r) ret->children[2] = solve(sr+1, r, todd, teven);
    return ret;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    auto fmin = [](int x, int y){ return min(x, y); };

    vector<int> p;
    static int table[2][200000];
    for(int i=0;i<n;++i){
        int x;
        cin >> x;
        pinv[x] = i;
        table[i%2][i] = x;
        table[(i+1)%2][i] = INT32_MAX;
    }
    disjoint_sparse_table<int, decltype(fmin)> todd{n, table[1], fmin}, teven{n, table[0], fmin};
    priority_queue<node> q;
    q.push(*solve(0, n, todd, teven));
    while(!q.empty()){
        node v = q.top();
        q.pop();
        p.push_back(v.val.first);
        p.push_back(v.val.second);
        for(int i=0;i<3;++i){
            if(v.children[i] == nullptr) continue;
            q.push(*v.children[i]);
        }
    }
    for(int i=0;i<n;++i) cout << p[i] << " \n"[i+1==n];
    return 0;
}

Measured memory_bytes: 45432
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-24 21:52:18
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

  int n; cin >> n;
  deque<int> dq;
  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    if (i & 1) {
      dq.emplace_front(a);
    } else {
      dq.emplace_back(a);
    }
  }

  if (n & 1) reverse(all(dq));

  for (int e : dq) cout << e << " ";
  cout << endl;

  return 0;
}

Measured memory_bytes: 3072