akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

#define F 26

typedef struct trieNode{
  int cnt;
  struct trieNode *next[F];
} trie;

trie* newNode(void){
  static trie *buf=NULL;
  if(buf==NULL) buf=(trie *)malloc(sizeof(trie)*(400000+100000+1));
  trie *res=buf++;
  res->cnt=0;
  int i;
  for(i=0;i<F;i++) res->next[i]=NULL;
  return res;
}

void add(trie *r,char *s){
  while(1){
    r->cnt++;
    if(*s=='\0') break;
    if(r->next[*s-'a']==NULL) r->next[*s-'a']=newNode();
    r=r->next[*s-'a'];
    s++;
  }
  return;
}

int count(trie *r){
  return r==NULL?0:r->cnt;
}

void calc(trie *r,char *s,int *cnt,int *before){
  while(*s!='\0'){
    int local=r->cnt;
    int i;
    for(i=0;i<F;i++){
      int c=count(r->next[i]);
      local-=c;
      if(*s!='a'+i) cnt[(*s-'a')*F+i]+=c;
    }
    *before+=local;
    r=r->next[*s-'a'];
    s++;
  }
  return;
}

void run(void){
  int n;
  scanf("%d",&n);
  char **sp=(char **)malloc(sizeof(char *)*n);
  char *s=(char *)malloc(sizeof(char)*(400000+n));
  trie *root=newNode();
  char *p=s;
  int i;
  for(i=0;i<n;i++){
    scanf("%s",p);
    add(root,p);
    sp[i]=p;
    while(*p!='\0') p++;
    p++;
  }
  int *before=(int *)calloc(n,sizeof(int));
  int *cnt=(int *)calloc(F*F*n,sizeof(int));
  for(i=0;i<n;i++) calc(root,sp[i],cnt+F*F*i,before+i);
  int q;
  scanf("%d",&q);
  while(q--){
    int k;
    char pe[27];
    scanf("%d%s",&k,pe);
    k--;
    int ans=before[k];
    int j;
    for(i=F-1;i>=0;i--){
      for(j=i-1;j>=0;j--){
	ans+=cnt[(k*F+pe[i]-'a')*F+pe[j]-'a'];
      }
    }
    printf("%d\n",ans+1);
  }
}

int main(void){
  run();
  return 0;
}


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

const int N = 100010;

int main(void){
  // input
  int n, m, h[N], ma[N];
  cin >> n >> m;
  for(int i=0; i<n; i++){
    cin >> h[i];
    ma[i] = 0;
  }
  // O(n)
  for(int i=0; i<m; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    ma[a] = max(ma[a], h[b]);
    ma[b] = max(ma[b], h[a]);
  }
  // O(n)
  int ans = 0;
  for(int i=0; i<n; i++){
    if(h[i]>ma[i]){
      ans++;
      // cout << "i = " << i << endl;
    }   
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4396
#include <cstdio>
#include <cstring>

char s[1005];

int main() {
	int w;
	scanf("%s", s);
	scanf("%d", &w);
	int len = strlen(s);
	for (int i = 0; i < len; i += w) printf("%c", s[i]);
	printf("\n");
	return 0;
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> T(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &T[i]);
  }

  ll ans = 1;
  rep(i, 0, sz(T)) { ans = lcm(ans, T[i]); }
  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) {
  T c = min(a, b), d = max(a, b);
  return c * (d / gcd(c, d));
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int sum = A;
		int answer = 1;

		while (sum < B) {
			sum += A - 1;
			answer++;
		}

		if (B == 1) {
			System.out.println(0);
		} else {
			System.out.println(answer);
		}
	}
}


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

int main(void){
    int n;
    std::cin >> n;

    std::vector<int> a(n);
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
        a[i]--; 
    }

    int count = 0;

    for(int i = 0; i < n; i++){
        if(i == a[a[i]]) count++;
    }

    int ans = count / 2;
    std::printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
bool sqr(long double x) {
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);
} 
int main() {
    int m, n, c = 0;
    cin >> m >> n;
    int a[m][n];
    for(int i = 0; i < m; i++) {
        for(int j = 0; j < n; j++) cin >> a[i][j];
    }
    for(int i = 0; i < m - 1; i++) {
        for(int k = i + 1; k < m; k++) {
            long double s = 0;
            for(int j = 0; j < n; j++) s += pow(a[i][j] - a[k][j], 2);
            if(sqr(s)) c++;
        }
    }
    cout << c;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,answer;
  cin >> N;
  int p[N];
  map<int,int> invalid;
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  if (p[0] == 1) {
    answer = 1;
    swap(p[0],p[1]);
  } else {
    answer = 0;
  }
  for (int i = 1; i < N; i++) {
    if (p[i] == i+1) {
      if (i+1 < N && p[i+1] == i+2) {
        swap(p[i],p[i+1]);
      } else {
        swap(p[i],p[i-1]);
      }
      answer++;
    }
  }
  cout << answer;
}

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

int read(){
	int x=0; char c=getchar(); int flag=1;
	while(!isdigit(c)) { if(c=='-') flag=-1; c=getchar(); }
	while(isdigit(c)) { x=((x+(x<<2))<<1)+(c^48); c=getchar(); }
	return x*flag;
}

const int mod=1e9+7;

int n,k;
int dp[2005][2005];//i个白球，j种颜色 

int fac[4000005],Inv[4000005]; 

int C(int n,int m){
	if(m<0||n<m) return 0;
    return 1ll*(1ll*fac[n]*Inv[m]%mod)*Inv[n-m]%mod; 
}

void exgcd(int a,int b,int &x,int &y){
    if(b==0) { x=1; y=0; return ; }
    exgcd(b,a%b,y,x); y-=a/b*x;
}

int inv(int a){
    int x=0,y=0;
    exgcd(a,mod,x,y);
    return (x%mod+mod)%mod;
}

signed main(){
	fac[0]=1;
	for(int i=1;i<=4000000;i++) fac[i]=1ll*fac[i-1]*i%mod;
	Inv[4000000]=inv(fac[4000000]);
	for(int i=3999999;i>=0;i--) Inv[i]=1ll*Inv[i+1]*(i+1)%mod;
	
    n=read(),k=read();
    if(k==1) { puts("1"); return 0; } 
	dp[0][0]=1;
    
    for(int i=1;i<=n;i++){ 
	    dp[i][0]=1;
		for(int j=1;j<=i;j++){
			dp[i][j]=(dp[i-1][j]+1ll*(1ll*dp[i][j-1]*C(n*k-(j-1)*(k-1)-i-1,k-2))%mod*(n-j+1)%mod)%mod; 
		} 
	}
	
	printf("%d\n",dp[n][n]);
    return 0;
}


Measured memory_bytes: 47232
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
int SQ=400;
struct wolf{
	vector<int>v;
	int m;
	wolf(){
		v.clear();
		m=99999999;
	}
};
vector<wolf>li;
int tmp[210000];
int c[210000];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",c+i);
	wolf now;
	for(int i=0;i<a;i++){
		now.v.push_back(c[i]);
		now.m=min(now.m,c[i]);
		if(i%SQ==SQ-1){li.push_back(now);now=wolf();}
	}
	if(now.v.size())li.push_back(now);
	for(int i=0;i<b;i++){
		int p,q,r;scanf("%d%d%d",&p,&q,&r);
		if(p==0){
			int at=0;
			int me=0;
			for(int j=0;j<li.size();j++){
				if(at<=r&&r<at+li[j].v.size()){
					int ind=r-at;
					me=li[j].v[ind];
					for(int k=ind+1;k<li[j].v.size();k++){
						li[j].v[k-1]=li[j].v[k];
					}
					li[j].v.pop_back();
					li[j].m=99999999;
					for(int k=0;k<li[j].v.size();k++)
						li[j].m=min(li[j].m,li[j].v[k]);
					break;
				}
				at+=li[j].v.size();
			}
			at=0;
			for(int j=0;j<li.size();j++){
				if(at<=q&&q<at+li[j].v.size()){
					int ind=q-at;
					li[j].v.push_back(0);
					for(int k=li[j].v.size()-1;k>ind;k--){
						li[j].v[k]=li[j].v[k-1];
					}
					li[j].v[ind]=me;
					li[j].m=99999999;
					for(int k=0;k<li[j].v.size();k++)
						li[j].m=min(li[j].m,li[j].v[k]);
					break;
				}
				at+=li[j].v.size();
			}
		}
		if(p==1){
			int at=0;
			int ret=99999999;
			for(int j=0;j<li.size();j++){
				if(q<=at&&at+li[j].v.size()<=r+1)ret=min(ret,li[j].m);
				else if(!(at+li[j].v.size()<=q||r<at)){
					for(int k=0;k<li[j].v.size();k++){
						if(q<=at+k&&at+k<=r)ret=min(ret,li[j].v[k]);
					}
				}
				at+=li[j].v.size();
			}
			printf("%d\n",ret);
		}
		if(p==2){
			int at=0;
			for(int j=0;j<li.size();j++){
				if(q<at+li[j].v.size()){
					li[j].v[q-at]=r;
					li[j].m=99999999;
					for(int k=0;k<li[j].v.size();k++)li[j].m=min(li[j].m,li[j].v[k]);
					break;
				}
				at+=li[j].v.size();
			}
		}
		if(i%SQ==SQ-1){
			int at=0;
			for(int j=0;j<li.size();j++)
				for(int k=0;k<li[j].v.size();k++)
					tmp[at++]=li[j].v[k];
			now=wolf();
			li.clear();
			for(int j=0;j<a;j++){
				now.v.push_back(tmp[j]);
				now.m=min(now.m,tmp[j]);
				if(j%SQ==SQ-1){li.push_back(now);now=wolf();}
			}
			if(now.v.size())li.push_back(now);
		}
	}
}

Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>
#include <queue>

#include <cstdio>
#include <cstring>
#include <climits>

#define REP(i, n) for(typeof(n) i = 0; i < (n); ++i)

using namespace std;

int getInt(){ int ret; scanf("%d", &ret); return ret; }

int memo[1<<16];
int t[20][20];
int n;

inline int taosita(int flag, int n){
  return (flag & (1 << n)) == 0;
}

int solve(const int flag){
  if(flag == 0) return 0;
  if(memo[flag] != -1) return memo[flag];

  int ret = INT_MAX;
  REP(i, n) if(!taosita(flag, i)){
    const int rest = solve(flag ^ (1 << i));
    ret = min(ret, t[i][0] + rest);

    REP(j, n) if(taosita(flag, j))
      ret = min(ret, t[i][j+1] + rest);
  }

  return memo[flag] = ret;
}

int main(){
  while(n = getInt()){
    REP(i, n) REP(j, n+1) t[i][j] = getInt();
    memset(memo, -1, sizeof(memo));
    printf("%d\n", solve((1<<n) - 1));
  }
  return 0;
}

Measured memory_bytes: 1136
"""
abc167でC問題にてbit全探索を解けなかったので猛省
"""

N = list(input())

L = len(N)
ans = 0

for i in range(0, 1 << L-1):
    s = []
    minus = [N[0]]
    for j in range(L-1):
        if (i >> j) & 1:
            s.append(int("".join(minus)))
            minus = [N[j+1]]
        else:
            minus.append(N[j+1])
    s.append(int("".join(minus)))
    ans += sum(s)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

vector<ll> ans;
vector<ll> adj[N];

int vis[N][11];

void func(ll v,ll d,ll c)
{
    if(vis[v][d]==1){return;}
    vis[v][d]=1;
    if(d==0){ans[v]=c;return;}
    func(v,d-1,c);
    for(auto u:adj[v]){
        func(u,d-1,c);
    }
}

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

    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<m;++i){
        ll a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    ll q;
    cin>>q;
    vector<pair<ll,pi> > query(q);
    for(ll i=0;i<q;++i){
        cin>>query[i].first>>query[i].second.first>>query[i].second.second;
    }
    reverse(query.begin(),query.end());

    ans.resize(n+1,0);

    for(ll i=1;i<=n;++i){
        for(ll j=0;j<=10;++j){
            vis[i][j]=0;
        }
    }

    for(ll i=0;i<q;++i)
    {
        ll v=query[i].first;
        ll d=query[i].second.first;
        ll c=query[i].second.second;
        func(v,d,c);
    }
    for(ll i=1;i<=n;++i){
        cout<<ans[i]<<endl;
    }

    return (0);
}


Measured memory_bytes: 26612
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    auto B = aryread();
    long a, b;
    foreach (i; 0 .. N)
    {
        a += max((B[i] - A[i]) / 2, 0);
        b += max(A[i] - B[i], 0);
    }
    writeln(a < b ? "No" : "Yes");
}


Measured memory_bytes: 4260
#include <stdio.h>

#define MAX 10000

int S[MAX];
int T[MAX];
int Q[MAX];
int tail = 0;

int has_elem(int *Q, int v)
{
	int i;
	for (i = 0; i < tail; i++) {
		if (v == Q[i])
			return 1;
	}
	return 0;
}

int main(int argc, char *argv[])
{
	int n, q, i, j;
	int same = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &S[i]);
	scanf("%d", &q);
	for (i = 0; i < q; i++)
		scanf("%d", &T[i]);

	for (i = 0; i < n; i++) {
		for (j = 0; j < q; j++) {
			if (S[i] == T[j] && !has_elem(Q, T[j])) {
				same++;
				Q[tail++] = T[j];
			}
		}
	}
	
	printf("%d\n", same);

	return 0;
}


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


int main(){
  int n, x; cin >> n >> x;
  int a, b, c;
  int p=0;
  int amax = (x-1000*n)/9000;
  if (amax<0) cout << -1 << " " << -1 << " "<< -1 << endl;
  else {
    for (a=0; a<=amax; a++){
      b = (x - 1000*n - 9000*a)/4000;
      c = n - a- b;
      if (10000*a + 5000*b + 1000*c == x&&a>=0&&b>=0&&c>=0) {
        cout << a << " " << b << " " << c << endl;
        p++;
        break;
      }
    }
  }
  if (p==0) cout << -1 << " " << -1 << " "<< -1 << endl;
}


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

int main() {
  int N; cin >> N;
  int A[100]; for (int i = 0; i < N; i++) cin >> A[i];

  int min = 10e9 + 1, max = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] < min) min = A[i];
    if (A[i] > max) max = A[i];
  }

  cout << max - min << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll s, c;
  cin >> s >> c;
  ll ans = 0;
  ans += min(s, c / 2);
  c -= ans * 2;
  ans += c / 4;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	// h, wをスタートとしたときの最も遠い点への距離
	int g(char[][] S, int h, int w) {
		int[][] d = new int[H][W];
		for (int i = 0; i < H; i++) {
			Arrays.fill(d[i], -1);
		}

		d[h][w] = 0;

		Deque<List<Integer>> q = new ArrayDeque<>();
		q.add(Arrays.asList(h, w));

		while (!q.isEmpty()) {
			List<Integer> l = q.poll();
			int y = l.get(0);
			int x = l.get(1);

			int c = d[y][x];

			// 上
			if (y > 0 && d[y - 1][x] == -1 && S[y - 1][x] == '.') {
				d[y - 1][x] = c + 1;
				q.add(Arrays.asList(y - 1, x));
			}

			// 下
			if (y < H - 1 && d[y + 1][x] == -1 && S[y + 1][x] == '.') {
				d[y + 1][x] = c + 1;
				q.add(Arrays.asList(y + 1, x));
			}

			// 左
			if (x > 0 && d[y][x - 1] == -1 && S[y][x - 1] == '.') {
				d[y][x - 1] = c + 1;
				q.add(Arrays.asList(y, x - 1));
			}

			// 右
			if (x < W - 1 && d[y][x + 1] == -1 && S[y][x + 1] == '.') {
				d[y][x + 1] = c + 1;
				q.add(Arrays.asList(y, x + 1));
			}

		}

		int result = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				result = Math.max(result, d[i][j]);
			}
		}

//		System.err.println("result " + result);
		return result;

	}

	int H, W;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		H = sc.nextInt();
		W = sc.nextInt();

		char[][] S = new char[H][W];
		for (int i = 0; i < H; i++) {
			String x = sc.next();
			for (int j = 0; j < W; j++) {
				S[i][j] = x.charAt(j);
			}
		}

		sc.close();

		int ans = Integer.MIN_VALUE;
		for (int sth = 0; sth < H; sth++) {
			for (int stw = 0; stw < W; stw++) {

				if (S[sth][stw] == '#') {
					continue;
				}
//System.err.println(sth + "," + stw);
				ans = Math.max(ans, g(S, sth, stw));

			}
		}

		out.println(ans);

	}

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


Measured memory_bytes: 29612
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

ll a[N], ps[N], sf[N];
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    ll n;
    cin >> n;
    for (int i = 1; i <= n; i ++) {
    	cin >> a[i];
    	ps[i] = __gcd(a[i], ps[i - 1]);
	}
	if (n == 1) {
		return cout << a[1], 0;
	}
	for (int i = n; i; i --) sf[i] = __gcd(sf[i + 1], a[i]);
	ll ans = 0;
	for (int i = 1; i <= n; i ++)
		ans = max(ans, __gcd(ps[i - 1], sf[i + 1]));
	cout << ans;
    
    return (0) ;
}


Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> P;

int main() {
	int t; cin >> t;
	Loop(i, t) {
		int n, d; cin >> n >> d;
		int cnt = 0;
		Loop(j, n - 1) {
			int x = 127 - d;
			d = x;
			cnt++;
		}
		cout << cnt * 127 + d << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main() {
	int n;
	scanf("%d", &n);
	char j[4][4] = {"AC", "WA", "TLE", "RE"};
	int ans[4] = {0};
	for (int i = 0; i < n; i++) {
		char s[10];
		scanf("%s", s);
		for (int k = 0; k < 4; k++) {
			if (strcmp(s, j[k]) == 0) {
				ans[k]++;
			}
		}
	}
	for (int i = 0; i < 4; i++) {
		printf("%s x %d\n", j[i], ans[i]);
	}
	return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <complex>
using namespace std;
int main() {
	long int n;
	cin >> n;
	long long int a;
	long int sum = 0;
	for (int i = 0;i < n;i++) {
		cin >> a;
		sum += a;
	}
	cout << sum / n << endl;
}

Measured memory_bytes: 1168
import java.util.*;
public class Main {
    public static void main(String args[])
    {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();
        int counter = 0;
        while(a > 0 && c > 0)
        {
            if(counter % 2 == 0)
            {
                c -= b;
            }
            else
            {
                a -= d;
            }
            counter++;
        }
        if(a <= 0)
        {
            System.out.println("No");
        }
        else
        {
            System.out.println("Yes");
        }
    }
}


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

typedef long long int ll;
typedef double d;

#define tt int t; cin>>t; while(t--)
#define lo(i, a, b) for(int i=a; i<b; i++)
#define rlo(i, a) for(int i=a; i>0; i--)

#define be(a) a.begin(),a.end()
#define sz(x) x.size()

#define nl cout<<"\n";
#define sp cout<<" ";

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    su;
    int l,k;
    string s;
    cin>>k>>s;
    l=sz(s);
    if(l>k)
    {
        s=s.substr(0,k)+"...";
    }
   cout<<s;
    nl;
    return 0;
}


Measured memory_bytes: 3572
#include<iostream>
using namespace std;
int s[100002];
int n,q,t;
bool binary_search(int key){
    int left=0,right=n,mid;
    while(left<right){
        mid=left+(right-left)/2;
        if(s[mid]==key)return true;
        if(s[mid]>key){
            right=mid;
        }else{
            left=mid+1;
        }
    }
    return false;
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    cin>>q;
    int cnt=0;
    for(int i=0;i<q;i++){
        cin>>t;
        cnt+=binary_search(t);
    }
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 3484
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int Difference(int x, int y){
    if(x > y){
        return x - y;
    }else{
        return y - x;
    }
}

int main(){
    int n, x, y;
    int ans[4000];
    cin >> n >> x >> y;
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            int minum = min(Difference(j,i),min(Difference(x , i) + 1 + Difference(j , y), Difference(y, i)+1+Difference(j, x)));
            ans[minum]++;
        }
    }
    for(int i = 1; i < n; i++){
        cout << ans[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <queue>
#include <map>
#include <stack>
#define ll long long
using namespace std;



int main(){
  //cout<<123<<endl;
  ll N;
  cin>>N;
  ll Tsum=0; ll Asum=0;
  vector <ll> A(0); vector <ll> B(0); vector <pair <ll,ll> > sum(0);
//   vector <pair <ll,ll> > Takahasi(0); vector <pair <ll,ll> > Aoki(0);
  
  for(int i=0;i<N;i++){
    ll a;
    scanf("%lld",&a);
    A.push_back(a);
    ll b;
    scanf("%lld",&b);
    B.push_back(b);
    sum.push_back(make_pair(a+b, i));
   /* Takahasi.push_back(make_pair(a+b, a));
    Aoki.push_back(make_pair(a+b, b));
    */
  }
  sort(sum.begin(),sum.end());
  reverse(sum.begin(), sum.end());
  
  for(int j=0;j<N;j++){
    if(j%2==0){
      // TK turn
      ll index = sum.at(j).second;
      Tsum += A[index];
     // sum.erase(sum.begin());
     // A.erase(A.begin()+index);
   //   B.erase(B.begin()+index);
      continue;
    } else {
      ll index = sum.at(j).second;
      Asum += B[index];
     // sum.erase(sum.begin());
     // A.erase(A.begin()+index);
   //   B.erase(B.begin()+index);
      continue;
      
    }
  }
  
  ll ans = Tsum - Asum;
  
  cout<<ans<<endl;
  // sort(Takahasi.begin(), Takahasi.end());
  // sort(Aoki.begin(),Aoki.end());
  
  
 
  
 
  return 0;
}


Measured memory_bytes: 3676
N = int(input())
R = [list(map(int,input().split())) for k in range(N)]
B = [list(map(int,input().split())) for k in range(N)]
 
R = sorted(R, key = lambda x: -1*x[1])
B = sorted(B)
 
ans = 0
for b in B:
    for r in R:
        if r[0] < b[0] and r[1] < b[1]:
            ans += 1
            R.remove(r)
            break
 
print(ans)

Measured memory_bytes: 3064
import copy
import queue
q = queue.Queue()
N, M = map(int, input().split())
nodes = [[] for i in range(N)]
idxStock = []
for i in range(M):
    a, b = map(int, input().split())
    nodes[a - 1].append(b - 1)
    nodes[b - 1].append(a - 1)

dist = [-1] * N
ans = [-1] * N

q.put(0)
while not q.empty():
    now = q.get()
    for i in nodes[now]:
        if dist[i] != -1:
            continue
        dist[i] = dist[now] + 1
        q.put(i)
        ans[i] = now
print("Yes")
for i in range(1, N):
    print(ans[i]+1)

Measured memory_bytes: 35320
from math import factorial
mod=10**9+7

def mod_cmb(n,k,mod):
    def ext_gcd(a,b):
        if b==0:
            return a, 1, 0
        else:
            d,x,y=ext_gcd(b,a%b)
            x-=(a//b)*y 
        return d,y,x
    p,q=1,1
    for i in range(n-k+1,n+1):
        p=(p*i)%mod
    for i in range(2,k+1):
        q=(q*i)%mod
    return int(p*(ext_gcd(q,mod)[1]%mod)%mod)

a,b=map(int,input().split())

x=abs(a-b)
c=max(a,b)-x*2
d=min(a,b)-x


if c%3==0 and d%3==0 and c==d and c>=0:
    print(mod_cmb(x+c//3*2,c//3,mod))
else:
    print(0)

Measured memory_bytes: 3064
import sys
n = int(input())
ans = [0]*(n+1) #ans[k]:入力値kでの答え
#初期値３、４、５
if n == 1 or n == 2:
  print(0)
  sys.exit()
  
if 3<= n <=5:
  print(1)
  sys.exit()
  
  
ans[3] = 1
ans[4] = 1
ans[5] = 1
  
for i in range(6,n+1):
  start = 3
  stop = i-3
  s = 1
  for j in range(start,stop+1):
    s = (s+ans[j]) % (10**9+7)
    
  ans[i] = s
  
print(ans[-1])  

Measured memory_bytes: 9092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <cstdlib>
#include <set>

using namespace std;
 
int main(void){

    long N,A,B;
    long tmp1,tmp2;
    long ans;
    
    cin >> N >> A >> B;

    if ( A + B <= 0){
        cout << 0;
        return 0;
    }

    tmp1 = N / (A + B);

    tmp2 = N % (A + B);

    if (tmp2 < A){
        ans = tmp1 * A + tmp2;
    } else {
        ans = (tmp1 + 1) * A;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque

input = sys.stdin.readline

class Bellman_Ford:
    def __init__(self, v=None, e=None, lis=None, start=None, end=None, inf=float('inf')):
        self.V = v
        self.E = e
        self.lis = lis
        self.start = start if start else 0
        self.end = end if end else self.V-1
        self.inf = inf
        self.close_minus = False
    
    def getlist(self, lis):
        self.lis = lis
    
    def def_start(self, s):
        self.start = s
    
    def def_end(self, e):
        self.end = e

    def def_inf(self, inf):
        self.inf = inf
    
    def def_vertice(self, v):
        self.V = v
    
    def def_edge(self, e):
        self.E = e

    def prepare(self):
        self.cost = [self.inf]*self.V # 各頂点への最小コスト
        self.cost[self.start] = 0 # 自身への距離は0

    def search(self):
        for i in range(self.V):
            update = False # 更新が行われたか
            for x, y, z in self.lis:
                if self.cost[y] > self.cost[x] + z:
                    self.cost[y] = self.cost[x] + z
                    update = True
            if not update:
                break
            # 負閉路が存在
            if i == self.V - 1:
                self.close_minus = True
                return False
        return True

    def main(self):
        self.prepare()
        self.search()
    
    def cost_all(self):
        return self.cost

def main():
    n, m, p = map(int, input().split())
    
    graph = [None]*m
    tree_forth = [[] for _ in range(n)]
    tree_back = [[] for _ in range(n)]
    
    for i in range(m):
        a, b, c =map(int, input().split())
        tree_forth[a-1].append(b-1)
        tree_back[b-1].append(a-1)
        c = p-c
        graph[i] = (a-1, b-1, c)
    
    already1, already2 = [True]*n, [True]*n
    for already, tree, start in zip([already1, already2], [tree_forth, tree_back], [0, n-1]):
        not_yet = deque([start])
        already[start] = False
        while not_yet:
            key = not_yet.pop()
            for v in tree[key]:
                if already[v] == False:
                    continue
                already[v] = False
                not_yet.append(v)
    
    graph_new = []
    for i in range(m):
        a, b, c = graph[i]
        if already1[a] or already1[b] or already2[a] or already2[b]:
            continue
        graph_new.append((a, b, c))
       
    bf = Bellman_Ford(v=n, e=m, lis=graph_new)
    bf.main()
    if bf.close_minus:
        print(-1)
    else:
        print(max(0, -bf.cost[n-1]))
    
    
    
if __name__ == "__main__":
    main()

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

using namespace std;

int main(){
  int h, w, n, a[10009], g[109][109];
  cin >> h >> w >> n;
  for(int i=1;i<=n;i++)cin >> a[i];
  int idx=1;
  for(int i=0;i<h;i++){
    for(int j=(i%2==0?0:w-1);0<=j&&j<=w-1;j+=(i%2==0?1:-1)){
      while(a[idx]==0)idx++;
      g[i][j]=idx;
      a[idx]--;
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)cout << g[i][j] << (j==w-1?'\n':' ');
  }
}



Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
# define int long long
const int inf = 2147400000 ;
using namespace std;
inline int read(){
    char c = getchar() ; int x = 0, w =1 ;
    while(c>'9'||c<'0'){ if(c=='-') w = -1; c = getchar() ;}
    while(c>='0'&&c<='9'){ x=x*10+c-'0'; c=getchar() ;}
    return x*w ;
}
int a,b,c,k ;
# undef int 
int main(){
# define int long long
    cin>>a>>b>>c>>k;
    if(k&1){
    	if(b-a>1e18)
    	  cout<<"Unfair\n";
    	else 
    	cout<<b-a<<endl;
	}
	else {
	    if(b-a>1e18)
    	  cout<<"Unfair\n";
		cout<<a-b<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
a = list(map(int, input().split())) 
b = list(map(int, input().split()))

from bisect import bisect_right
"""
if n>m:
    a, b = b, a
    n, m = m, n
"""
c = [b[0]]
for i in range(1, m):
    c.append(c[-1]+b[i])
a.insert(0,0)
x = 0
result = [0]
for i in range(n+1):
    x += a[i]
    if x > k:
        break
    y = k - x
    z = bisect_right(c, y)
    result.append(z+i)
print(max(result))

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

int main() {
	cin.tie(NULL);
	cout.tie(NULL);
	int cnt=0;
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		ll a;
		cin>>a;
		if((i+1)%2!=0&&a%2!=0)
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;

const int INF = 1e9 ;
const int maxN = 200;

int a[maxN];
int b[maxN];
int tot = 0;
int p[maxN];

void prime()
{
	for(int i=2;i<=100;i++)
	{
		if(b[i] == 0)
		{
			p[++tot] = i;
			for(int j=2;i*j<=100;j++)
			{
				b[i*j] = 1;
			}
		}
	}
}
int c[maxN][maxN];
void work(int x)
{
	int y = x;
	for(int i=2;i<=y;i++)
	{
		int ans = 0;
		if(y%i == 0)
		{
			while((y%i) == 0)
			{
				y/=i;
				ans++;
			}
		}
		c[x][i] = ans;
	}
}
int n;
int f[maxN][maxN];
int g[maxN];
int main()
{
	scanf("%d",&n);
	prime();
	for(int i=2;i<=n;i++)
	{
		work(i);
	}
	for(int j=1;j<=n;j++)
	{
		for(int i=1;i<=n;i++)
		{
			a[j] += c[i][j];
		}
	}
	for(int i=1;i<=tot;i++)
	{
		int x = p[i];
		int y = a[x];
		g[i] = y;
	}
	f[0][1] = 1;
	for(int k=1;k<=tot;k++)
	{
		for(int i=1;i<=75;i++)
			for(int j=0;j<=g[k];j++)
			{
				if(i*(j+1) <= 100) 
					f[k][i*(j+1)] += f[k-1][i];
			}
	}
	printf("%d\n",f[tot][75]);
    return 0;
} 

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

int main() { int N; cin >> N; int ans; vector<int> A(N);

for(int i = 0; i < N; i++) cin >> A.at(i); 
 sort(A.begin(), A.end());
ans = A.at(N - 1) - A.at(0);  
  
   cout << ans << endl;
  return 0;
 
}


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

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

    string s;
    cin >> s;

    if (s.size() != (a + b + 1)) {
        cout << "No" << endl;
        return 0;
    }

    for (int i = 0; i < s.size(); i++) {
        if (i != a && (s[i]<48 || s[i]>57)) {
            cout << "No" << endl;
            return 0;
        }
    }

    if (s[a] == '-') cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 384
const main = function(input){
  var nums = input.trim().split(" ").map(i=>parseInt(i));
  var n = nums[0];
  var k = nums[1];
  var ans = 1;
  
  if(k<=n && n%k ===0){
  	ans = 0;
  }
  
  console.log(ans);


}


main(require("fs").readFileSync("/dev/stdin","utf-8"));

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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}
// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll n;
    cin>>n;
    ll ac=0;
    ll tle =0;
    ll wa=0;
    ll re=0;
    while(n--)
    {
        string s;
        cin>>s;
        if(s=="AC")
        ac++;
        else if(s=="TLE")
        tle++;
        else if(s=="RE")
        re++;
        else if(s=="WA")
        wa++;
    }
    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE x "<<re<<"\n";    
}
// Driver Function
int main()
{
    ll compte = 1;
   // test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3596
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n, = map(int, readline().split())
xyp = tuple(tuple(map(int, readline().split())) for _ in range(n))

N = 1<<n
INF = 1<<60
resx = []
resy = []
for i in range(n):
    x,y,p = xyp[i]
    rx = [abs(x)]*N
    ry = [abs(y)]*N
    for j in range(n):
        for k in range(1<<j):
            rx[k+(1<<j)] = min(rx[k],abs(x-xyp[j][0]))
            ry[k+(1<<j)] = min(ry[k],abs(y-xyp[j][1]))
    
    for j in range(N):
        rx[j] *= p
        ry[j] *= p
    resx.append(rx)
    resy.append(ry)

cnt = [n]*N
for j in range(n):
    for k in range(1<<j):
        cnt[k+(1<<j)] = cnt[k]-1

ans = [INF]*(n+1)
for m0 in range(N):
    v = cnt[m0]
    mx = (N-1)&~m0
    while mx>=0:
        my = (N-1)^m0^mx
        r = 0    
        for i in range(n):
            if m0>>i&1:
                r += min(resx[i][mx],resy[i][my])
        if r < ans[v]:
            ans[v] = r
        mx = (mx-1)&~m0


for i in ans:
    print(i)



Measured memory_bytes: 82976
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi pair<ll,ll>
map<pi,ll>m;
int reverse(int x)
{
	int temp = 0;
	while(x)
	{
		temp = temp*10 + x%10;
		x/=10;
	}
	return temp;
}
int main()
{
	int n;cin>>n;
	ll res = 0;
	int f,l;
	for(int i=1;i<=n;i++)
	{
		int r = reverse(i);
		//cout<<"i = "<<i<<" r = "<<r<<endl;
		int f = i%10;
	    int l = r%10;
	    //cout<<"f = "<<f<<" l = "<<l<<"\n\n";
	    m[make_pair(f,l)]++;
	    //cout<<m[make_pair(f,l)]<<"\n";
	}
	for(int i=1;i<=n;i++)
	{
		int r = reverse(i);
		//cout<<"i = "<<i<<" r = "<<r<<endl;
		int f = i%10;
	    int l = r%10;
	    //cout<<"l = "<<l<<" f = "<<f<<"\n";
		res += m[make_pair(l,f)];
		//cout<<"res = "<<res<<"\n\n";
		//cout<<res<<"\n";
	}
	cout<<res<<"\n";
}

Measured memory_bytes: 256
s = input()

old2 = s[0]
old1 = s[1]

if old2 == old1:
    print(1,2)
    exit()

for i in range(len(s)-2):
    #print(i)
    if old2 == s[i+2]:
        print(i+1,i+3)
        exit()
    elif old1 == s[i+2]:
        print(i+2,i+3)
        exit()
    old2 = s[i+1]
    old1 = s[i+2]

print(-1,-1)

Measured memory_bytes: 40940
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int area = a*b;
	int length = 2*a+2*b;
	System.out.println(area +" "+length);
	}
}

Measured memory_bytes: 26248
#import<iostream>
#import<atcoder/all>
long N,Q,i,a;main(){std::cin>>N>>Q;atcoder::fenwick_tree<long>b(N);for(;i++<N;b.add(i-1,a))std::cin>>a;for(;std::cin>>i>>a>>N;Q--){if(i)std::cout<<b.sum(a,N)<<'\n';else b.add(a,N);}}

Measured memory_bytes: 8204
k = int(input())

def snuke(n):
    s = sum(map(int, str(n)))
    return n / s

digit = 0
ans = 1
for _ in range(k):
    print(ans)
    if snuke(ans + 10 ** digit) > snuke(ans + 10 ** (digit + 1)):
        digit += 1
    ans += 10 ** digit


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {

    int h,w;
    cin>>h>>w;
    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    vvi g(h,vi(w));
    int x=0,y=0,pos=0;
    int ri=1;
    while(1){
        int num=pos+1;
        g[y][x]=num;
        if(ri){
            x++;
            if(x==w){
                x--;
                ri=0;
                y++;
            }
        } else {
            x--;
            if(x==-1){
                x++;
                ri=1;
                y++;
            }
        }
        v[pos]--;
        if(v[pos]==0)pos++;
        if(pos>=n)break;
    }
    rep(i,h)dump(g[i]);
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



int main()
{
	int n, a, b;
	while (scanf("%d%d%d", &n, &a, &b), n | a | b)
	{
		static bool c[1145140 * 2];
		fill_n(c, n + 1, false);
		c[0] = true;
		int res = 0;
		for (int i = 0; i <= n; ++i)
		{
			if (c[i])
				c[i + a] = c[i + b] = true;
			else
				++res;
		}
		printf("%d\n", res);
	}
}

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

map<string,int> h;

// 空白区切りで文字列を分割して返す
vector<string> split_words(string s){
	bool flag = false;
	vector<string> vs;
	string str;
	s.push_back(' ');
	for(int i=0 ; i < s.size() ; i++ ){
		char c = s[i];
		if( flag == false ){
			if( c != ' '){
				flag = true;
				str.clear();
				str.push_back( c );
			}
		}else{
			if( c != ' ' ){
				str.push_back( c );
			}
			if( c == ' ' ){
				flag = false;
				vs.push_back( str );
				str.clear();
			}
		}
	}
	return vs;
}

// 接頭辞のリストアップ
void ini(){
	h["yotta"] =  24;
	h["zetta"] =  21;
	h["exa"]   =  18;
	h["peta"]  =  15;
	h["tera"]  =  12;
	h["giga"]  =   9;
	h["mega"]  =   6;
	h["kilo"]  =   3;
	h["hecto"] =   2;
	h["deca"]  =   1;
	h["deci"]  =  -1;
	h["centi"] =  -2;
	h["milli"] =  -3;
	h["micro"] =  -6;
	h["nano"]  =  -9;
	h["pico"]  = -12;
	h["femto"] = -15;
	h["ato"]   = -18;
	h["zepto"] = -21;
	h["yocto"] = -24;
}

int cnt_pre(string s){
	int a=0;
	for(int i=0 ; i < s.size() ; i++ ){
		if( s[i] == '.' ) return a;
		a++;
	}
	return a;
}

int cnt_zero(string s){
	int cnt=0;
	for(int i=0 ; i < s.size() ; i++ ){
		if( s[i] == '0' )
			cnt++;
		if( s[i] >= '1' && s[i] <= '9' )
			return cnt;
	}
	return cnt;
}

int main(){
	ini();
	
	int n;
	cin >> n;
	cin.ignore();
	for(int i_ = 0 ; i_ < n ; i_++ ){
		string s;
		getline( cin , s );
		
		vector<string> vs = split_words( s );
		string unit, prefix;
		string num = vs[0];
		if( vs.size() == 3 ){
			prefix = vs[1];
			unit = vs[2];
		}else if( vs.size() == 2 ){
			if( h.count( vs[1] ) ){
				prefix = vs[1];
			}else{
				unit = vs[1];
			}
		}
		
		// '.' までの数値の個数
		int a = cnt_pre( num );
		// 先頭の '0' の数
		int pre_zero = cnt_zero( num );
		
		int b=0;
		if( !prefix.empty() ){
			b = h[prefix];
		}
		if( pre_zero == 0 ){
			cout << num[0];
			
			// 小数点以下が出力できるとき
			if( num.size() > 1 ) cout << ".";
			// 小数点以下の数値を出力
			for(int i=1 ; i < num.size() ; i++ ){
				if( num[i] == '.' ) continue;
				cout << num[i];
			}
			// 10^x の部分の出力
			cout << " * 10^" << (a+b-1);
			// 単位の部分の出力
			if( !unit.empty() ) 
				cout << " " << unit;
		}else{
			cout << num[pre_zero+1];
			
			// 小数点以下が出力できるとき
			if( num.size() > pre_zero+2 ) cout << "." ;
			// 小数点以下の数値を出力
			for(int i = pre_zero+2 ; i < num.size() ; i++ ){
				if( num[i] == '.' ) continue;
				cout << num[i];
			}
			// 10^x の部分の出力
			cout << " * 10^" << (a+b-1-pre_zero);
			// 単位の部分の出力
			if( !unit.empty() ) 
				cout << " " << unit;
		}
		cout << endl;
	}
}

Measured memory_bytes: 0
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
s=input().rstrip()
td=[]
for _ in range(q):
	t,d=input().split()
	td.append((t,d))
l=-1;r=n+1
while r-l>1:#l以上r未満
	mid=(l+r)//2
	now=mid
	if not 0<=now<n:
		if now==-1:
			l=mid
		else:
			r=mid
		continue
	for i in range(q):
		if s[now]==td[i][0]:
			if td[i][1]=="L":
				now-=1
			else:
				now+=1
		if not 0<=now<n:
			f=0
			break
	if now==-1:
		l=mid
	else:
		r=mid
Left=l
l=-2;r=n
while r-l>1:#l over r以下
	mid=(l+r)//2
	now=mid
	if not 0<=now<n:
		if now==n:
			r=mid
		else:
			l=mid
		continue
	for i in range(q):
		if s[now]==td[i][0]:
			if td[i][1]=="L":
				now-=1
			else:
				now+=1
		if not 0<=now<n:
			f=0
			break
	if now==n:
		r=mid
	else:
		l=mid
Right=r#Right,Leftはどこまで排除されるか
print(Right-Left-1)

Measured memory_bytes: 81100
#include<bits/stdc++.h>
#define MO 998244353
typedef long long ll;
const int maxn = 3000000;

ll n,m,ans;
ll inv[maxn],fac[maxn];

ll C(ll n, ll m)
{
	if (n < m) return 0;
	return fac[n]*inv[m]%MO*inv[n-m]%MO;
}
ll f(ll n, ll m, ll k)
{
	ll ret = 0;
	for (ll p=0; p<=k; p++)
		if (((m-p)&1)==0){
			ret = (ret+C((m-p)/2ll+n-1, n-1)*C(n, p)%MO)%MO;
		}
	return ret;
}
int main()
{
	scanf("%lld%lld",&n,&m);
	fac[0] = inv[0] = inv[1] = 1;
	for (int i=2; i<=n+3*m; i++)
		inv[i] = (MO-1ll*MO/i*inv[MO%i]%MO);
	for (int i=1; i<=n+3*m; i++)
		inv[i] = inv[i-1]*inv[i]%MO, fac[i] = fac[i-1]*i%MO;
	ans = (f(n, 3*m, m)-n*(f(n, m-1, m))%MO+MO)%MO;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 41216
// コードをここに挿入。
function main(input) {
    const x = parseInt(input, 10);
    var max_b = Math.floor(Math.sqrt(x));
    var ans = 0;
    if (x === 1) {
        console.log(x);
    }
  else{
    for (var i = max_b; i > 2; i--) {
        var bp = i;
        while (bp <= x) {
            bp *= i;
            if (bp <= x && bp >= ans) {
                ans = bp;
            }
        }
    }
    console.log(ans);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 22972