akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FASTIO
using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;

    Vi L(K + 1), R(K + 1);

    int cnt;
    int idx;
    cnt = 0;
    idx = 0;
    while (cnt < K) {
        while (idx < N && S[idx] == 'x') ++idx;
        ++cnt;
        L[cnt] = idx;
        idx += C + 1;
    }

    cnt = 0;
    idx = N - 1;
    while (cnt < K) {
        while (idx >= 0 && S[idx] == 'x') --idx;
        ++cnt;
        R[K - cnt + 1] = idx;
        idx -= C + 1;
    }

    Vi ans;
    for (int i = 1; i <= K; i++) {
        if (L[i] == R[i]) ans.push_back(L[i]);
    }

    int n_ans = (int)ans.size();
    for (int i = 0; i < n_ans; i++) {
        cout << ans[i] + 1 << '\n';
    }

    return 0;
}

Measured memory_bytes: 4236
def main():
    N = int(input())
    status = ['AC', 'WA', 'TLE', 'RE']
    counter ={}
    for key in status:
        counter[key] = 0
    for _ in range(N):
        s = input().rstrip()
        counter[s] += + 1
    for key in status:
        print(f"{key} x {counter[key]}")

if __name__ == "__main__":
    main()

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a * b % 2 == 0) {
    cout << "Even" << endl;
    return 0;
  } else {
    cout << "Odd" << endl;
    return 0;
  }
}

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

int main()
{
  int n, d;
  cin >> n >> d;
  int ans = 0;
  rep(i, n)
  {
    ll x, y;
    cin >> x >> y;
    double dis = sqrt(x * x + y * y);
    //cout << dis << endl;
    if (d >= dis)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3552
from collections import deque


def main():
    N, M = map(int, input().split())
    xy = [list(map(int, input().split())) for _ in range(M)]

    G = [[] for _ in range(N)]
    ins = [0] * N
    for i in range(M):
        G[xy[i][0] - 1].append(xy[i][1] - 1)
        ins[xy[i][1] - 1] += 1

    DP = [0] * N
    queue = deque()
    for i in range(N):
        if ins[i] == 0:
            queue.append(i)

    while queue:
        v = queue.popleft()
        for i in G[v]:
            ins[i] -= 1
            if ins[i] == 0:
                DP[i] = max(DP[i], DP[v] + 1)
                queue.append(i)

    print(max(DP))


if __name__ == '__main__':
    main()

exit()


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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif


const int P = 1e9 + 7;
const int MAX = 300;
set<vector<int>> x;
vector<set<vector<int>>::iterator> zr,zb;
int res = 1;
int sil[MAX],odw[MAX];
int newt[MAX][MAX];
string z;
int n,k;
void add(vector<int> ak){
  auto pom = x.insert(ak);
  if(pom.SE){
    int mn = 1;
    int sum = 0;
    int sum2 = 0;
    R(i,SZ(ak)){
      sum += ak[i];
      sum2 += ak[i] * i;
      mn = (mn * odw[ak[i]]) % P;
    }
    int a = n + 2 + (sum - ak[0]) * 2 - 1;
    int b = 2 * sum2 + 2 * sum;
    if(a >= b){
      res += mn * sil[sum] % P * newt[a][b] % P;
      zr.PB(pom.FI);
      zb.PB(pom.FI);
    }
  }
}
void dod(vector<int> pom,int zak){
  R(i,SZ(pom))if(i != zak && (i == 0 || pom[i-1])){
    if(i)pom[i-1]--;
    pom[i]++;
    add(pom);
    pom[i]--;
    if(i)pom[i-1]++;
  }
  if(SZ(pom) != zak){
    if(SZ(pom))pom.back()--;
    pom.PB(1);
    add(pom);
  }
}
int pot(int a,int w){
  int r = 1;
  while(w){
    if(w & 1){
      r = r * a % P;
    }
    w/=2;
    a = a * a % P;
  }
  return r;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  sil[0] = 1;
  R(i,MAX-1){
    sil[i+1] = (i+1) * sil[i] % P;
  }
  R(i,MAX){
    odw[i] = pot(sil[i],P-2);
  }
  R(i,MAX)R(j,i+1){
    if(j == 0){
      newt[i][j] = 1;
    }else{
      newt[i][j] = newt[i-1][j-1] + newt[i-1][j];
      if(newt[i][j] >= P)
        newt[i][j] -= P;
    }
  }
  cin >> n >> k >> z;

  auto xx = x.insert(vector<int>());
  zr.PB(xx.FI);
  zb.PB(xx.FI);
  R(i,k){
    if(z[i] == 'r'){
      vector<set<vector<int>>::iterator> pom;
      swap(pom,zr);
      for(auto el:pom){
        dod(*el,1);
      }
    }else{
      vector<set<vector<int>>::iterator> pom;
      swap(pom,zb);
      for(auto el:pom){
        dod(*el,0);
      }
    }
  }
  cout << res % P << "\n";
}


Measured memory_bytes: 84460
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int mod=1e9+7;
int n,cnt;
ll modpow(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1) res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
int main(){
    cin>>n;
    map<pair<ll,ll>,pair<int,int> >m;
    
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        if(!a&&!b){cnt++;continue;}
        
        ll g=__gcd(a,b);
        a/=g,b/=g;
        
        if(b<0) a=-a,b=-b;
        
        if(a<=0) m[{b,-a}].second++;
        else m[{a,b}].first++;    
    }
    ll ans=1;
    for(auto u:m){
        ans=(ans*(modpow(2,u.second.first)+modpow(2,u.second.second)-1+mod)%mod)%mod;
    }
    cout<<(ans-1+cnt+mod)%mod;
    return 0;
}  

Measured memory_bytes: 16088
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    int n,m;
    cin>>n>>m;
    if(n==1)return cout<<m<<endl,0;
	ll i=(m+n-1)/n;
	while(i>1){
		ll chk=(n-1)*i;
		ll chk2=m-chk;
		if(chk2>0&&chk2%i==0)return cout<<i<<endl,0;		
		i--;
	}
	cout<<"1"<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 256
import sys
H,W,M=map(int,input().split())

hlist=[0]*H
wlist=[0]*W
hwset=set()
for _ in range(M):
  h,w=map(int,input().split())
  hlist[h-1]+=1
  wlist[w-1]+=1
  hwset.add((h-1,w-1))
  
hmax=max(hlist)
hlist2=[]
for i in range(H):
  if hlist[i]==hmax:
    hlist2.append(i)

wmax=max(wlist)
wlist2=[]
for i in range(W):
  if wlist[i]==wmax:
    wlist2.append(i)
#print(hlist2,wlist2)

H2=len(hlist2)
W2=len(wlist2)

if H2*W2>M:
  print(hmax+wmax)
else:
  for i in range(H2):
    ii=hlist2[i]
    for j in range(W2):
      jj=wlist2[j]
      if not (ii,jj) in hwset:
        print(hmax+wmax)
        sys.exit(0)
  else:
    print(hmax+wmax-1)

Measured memory_bytes: 176764
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int N, K;
int D[2001];
int E[4001], ne[4001], he[2001];
void dfs(int v, int d) {
	D[v] = d;
	for (int to = he[v]; to; to = ne[to]) {
		if (D[E[to]] < 0) dfs(E[to], d + 1);
	}
}

int dfs2(int v, int prev, int d) {
	if (d > K / 2) return 0;
	int ret = 1;
	for (int to = he[v]; to; to = ne[to]) {
		if (E[to] != prev) ret += dfs2(E[to], v, d + 1);
	}
	return ret;
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	N = getint();
	K = getint();
	int tmp = 1;
	int jisuu[2001] = {};
	rep(i, N - 1) {
		int a = getint(), b = getint();
		E[tmp] = b;
		ne[tmp] = he[a];
		he[a] = tmp++;
		E[tmp] = a;
		ne[tmp] = he[b];
		he[b] = tmp++;
		jisuu[a]++;
		jisuu[b]++;
	}

	if (K == 1) {
		printf("%d\n", N - 2);
		return 0;
	}

	rep1(j, N) D[j] = -1;
	dfs(1, 0);
	int saidai = 0;
	int doko, doko2;
	rep1(i, N) if (saidai < D[i]) {
		saidai = D[i];
		doko = i;
	}
	rep1(j, N) D[j] = -1;
	dfs(doko, 0);
	saidai = 0;
	bool muri[2001] = {};
	rep1(i, N) {
		if (saidai < D[i]) {
			saidai = D[i];
			doko2 = i;
		}
		if (D[i] < K / 2) {
			muri[i] = 1;
		}
	}
	if (saidai <= K) {
		printf("0\n");
		return 0;
	}
	rep1(j, N) D[j] = -1;
	dfs(doko2, 0);
	rep1(i, N) {
		if (D[i] < K / 2) muri[i] = 1;
		if (jisuu[i] == 1) muri[i] = 1;
	}

	if (K % 2 == 0) {
		int kotae = N;
		rep1(i, N) {
			if (!muri[i]) {
				int kazu = dfs2(i, -1, 0);
				kotae = min(kotae, N - kazu);
			}
		}
		printf("%d", kotae);
	}
	else {
		int kotae = N;
		rep1(i, N) {
			for (int to = he[i]; to; to = ne[to]) {
				int j = E[to];
				if (i < j) {
					if (!muri[i] && !muri[j]) {
						int kazu = dfs2(i, j, 0) + dfs2(j, i, 0);
						kotae = min(kotae, N - kazu);
					}
				}
			}
		}
		printf("%d", kotae);
	}

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double db;

const db inf = 1e18;
const db pi = acos(-1);
const db eps = 1e-9;
const int mod = 998244353;

int main () {
	#ifdef ernestico
		freopen ("a.in", "r", stdin );
//		freopen ("a.out", "w", stdout );
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n, s; cin >> n >> s;
	vector <int> a(n);
	for ( int &i : a ) cin >> i;

	vector <int> dp(s+1);
	dp[0] = 1;
	for ( int i : a )
		for ( int j = s; j >= 0; j -- ) {
			dp[j] += dp[j];
			if ( dp[j] >= mod ) dp[j] -= mod;

			if ( j >= i ) {
				dp[j] += dp[j-i];
				if ( dp[j] >= mod ) dp[j] -= mod;
			}
		}

	cout << dp[s] << endl;

	return 0;
}


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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, A, B;
long long V[50];
long long dp[51][51];
long long num[51][51];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> A >> B;
  rep(i, N) cin >> V[i];
  dp[0][0] = 0;
  num[0][0] = 1;
  rep(i, N) {
    rep(j, i+1) {
      if (dp[i+1][j] == dp[i][j]) {
        num[i+1][j] += num[i][j];
      }
      else if (dp[i+1][j] < dp[i][j]) {
        num[i+1][j] = num[i][j];
        dp[i+1][j] = dp[i][j];
      }

      long long v = dp[i][j] + V[i];
      if (dp[i+1][j+1] == v) {
        num[i+1][j+1] += num[i][j];
      }
      else if (dp[i+1][j+1] < v) {
        num[i+1][j+1] = num[i][j];
        dp[i+1][j+1] = v;
      }
    }
  }
  long long ma = dp[N][A], mb = A;
  long long cnt = num[N][A];
  for (int i=A+1; i<=B; i++) {
    if (ma * i == dp[N][i] * mb) {
      cnt += num[N][i];
    }
    if (ma * i < dp[N][i] * mb) {
      ma = dp[N][i];
      mb = i;
      cnt = num[N][i];
    }
  }
  cout << fixed << setprecision(15) << ((double)ma/(double)mb) << "\n";
  cout << cnt << "\n";
  return 0;
}


Measured memory_bytes: 256
N ,x  = map(int, input().split())
As  = list(map(int, input().split()))


cnt = 0
cnt += max(0,As[0] - x) 
As[0] = min(As[0],x)

# print(cnt)
for i in range(N-1):
    if As[i] + As[i+1] <= x:
        continue
    else:
        n = As[i] + As[i+1] - x
        As[i+1] -= n
        cnt += n
print(cnt)

Measured memory_bytes: 14060
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0), cin.tie(0)
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const int inf = ~0u >> 1;
int d[maxn], h[maxn];
int main() {
    IO;
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> h[i];
    }
    d[1] = 0;
    d[2] = abs(h[2] - h[1]);
    for (int i = 3; i <= n; ++i) {
        d[i] = abs(h[i - 1] - h[i]) + d[i - 1];
        //cout << "i = " << i << " j = " << 1 << " d[i] = "  << d[i] <<endl;
        for (int j = 2; j <= min(k, i - 1); ++j) {
            d[i] = min(d[i], abs(h[i - j] - h[i]) + d[i - j]);
            //cout << "i = " << i << " j = " << j << " d[i] = "  << d[i] <<endl;
        }
    }
    cout << d[n] << endl;
    return 0;
}

Measured memory_bytes: 4396
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void run(void){
  char *s=(char *)malloc(sizeof(char)*(100000+1));
  scanf("%s",s);
  int len=strlen(s);
  int k;
  scanf("%d",&k);
  int i;
  for(i=0;i<len;i++){
    if(s[i]=='a') continue;
    int c=26-(s[i]-'a');
    if(c<=k){
      k-=c;
      s[i]='a';
    }
  }
  if(k%26>0){
    s[len-1]='a'+(k+(s[len-1]-'a'))%26;
  }
  printf("%s\n",s);
}

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


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

const int N = 1010,mod = 1e9+7;
typedef long long LL;

int n,m;
int dp[N][N];
char g[N][N];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>m;
    for(int i = 1; i<=n; i++)
        for(int j = 1; j<=m; j++) cin>>g[i][j];
    
    
    dp[1][1] = 1;
    for(int i = 1; i<=n; i++){
        for(int j = 1; j<=m; j++){
            if(g[i-1][j] == '.') dp[i][j] = (dp[i][j] + dp[i-1][j]) %mod;
            if(g[i][j-1] == '.') dp[i][j] = (dp[i][j] + dp[i][j-1]) %mod;
        }
    }
    
    cout<<dp[n][m];
    return 0;
}

Measured memory_bytes: 8052
n=int(input())
l=[chr(ord('a') + i) for i in range(26)]
ans=''
while n:
  a = n%26
  ans+=l[a-1]
  if n%26==0:
    n//=26
    n-=1
  else:
    n//=26
    ans = list(ans)
print(''.join(ans[::-1]))

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

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

   vector<int> vec(N);
   vec = vector<int>(N,0);

   for (int i = 0; i < M; i++)
   {
      cin >> a >> b;
      vec.at(a-1)++;
      vec.at(b-1)++;
   }

   for (int i = 0; i < N; i++)
   {
      cout << vec.at(i) << endl;
   }
   
}

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

using namespace std;

int n;

int main() {
  cin >> n;
  int a[n], b[n], c[n], order[n];
  rep(i,n) {
    cin >> a[i];
    a[i]--;
  }
  rep(i,n) cin >> b[i];
  rep(i,n-1) cin >> c[i];
  
  int counter = 0;
  rep(i, n) {
    counter += b[a[i]];
    if (i>0) {
      if(a[i] - a[i-1] == 1) {
        counter += c[a[i-1]];
      }
    }
  }
  
  cout << counter;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b )   for (int i = a; i < b; i++)

using namespace std;

void solve()
{
 int m=0,k=0,d=0,c=0;
 
  cin>>k;
  
  rep(i,0,10000000)
  {
    c+=7;
    c%=k;
    c*=10;
    d++;
    if(c==0)
      break;
  }
  if(c==0) cout<<d;
  else 
    cout<<-1;
}



int main() {

 

   int TESTS = 1;
  // cin>>TESTS;
  while (TESTS--) {
    solve();

  }

  return 0;
}


Measured memory_bytes: 3596
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離

s = input()
t = input()
sl = len(s)
tl = len(t)

dp = [[0 for _ in range(tl+1)] for _ in range(sl+1)]

for i in range(sl):
    for j in range(tl):
        if s[i] == t[j]: dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1)
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])

ans = ''
while sl > 0 and tl > 0:
    if dp[sl][tl] == dp[sl][tl-1]:
        tl -= 1
    elif dp[sl][tl] == dp[sl-1][tl]:
        sl -= 1
    else:
        ans = s[sl-1] + ans
        sl -= 1
        tl -= 1
print(ans)




Measured memory_bytes: 125144
from math import floor

n = int(input())

ans_list = []
ans_num = 0
ans = 1
while ans_num < n:
    ans += 5
    for i in range(2, floor(ans ** 0.5) + 1):
        if ans % i == 0:
            break
    else:
        ans_list.append(ans)
        ans_num += 1
print(*ans_list)

Measured memory_bytes: 3060
import sys
n = int(input())

if n%4 == 0 or n%7 == 0:
    print('Yes')
else:
    for i in range(n//4+1, 0, -1):
        j = 0
        while i*4+j*7 < n:
            j += 1
        if i*4+j*7 == n:
            print('Yes')
            sys.exit()
    print('No')


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

const int MAX_N = 2e5;
vector<int> adjacencyList[MAX_N + 1];
bool mark[MAX_N + 1];
int answer;

int size_moalefe(int v) {
	int result = 1;
	for (int u : adjacencyList[v]) {
		if (not mark[u]) {
			mark[u] = true;
			result += size_moalefe(u);
		}
	}
	return result;
}

int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 1, A, B; i <= M; ++i) {
		cin >> A >> B;
		adjacencyList[A].push_back(B);
		adjacencyList[B].push_back(A);
	}
	for (int i = 1; i <= N; ++i) {
		if (not mark[i]) {
			mark[i] = true;
			answer = max(answer, size_moalefe(i));
		}
	}
	cout << answer << endl;
}


Measured memory_bytes: 24064
#include<iostream>
using namespace std;
int main()
{
    int sx, sy, tx, ty, i;
    cin >> sx >> sy >> tx >> ty;
    for(i = sy; i < ty; i++)   printf("U");
    for(i = sx; i < tx; i++)   printf("R");
    for(i = ty; i > sy; i--)   printf("D");
    for(i = tx; i > sx-1; i--) printf("L");
    for(i = sy; i < ty+1; i++) printf("U");
    for(i = sx-1; i < tx; i++) printf("R");
                                printf("DR");
    for(i = ty; i > sy-1; i--) printf("D");
    for(i = tx+1; i > sx; i--) printf("L");
                                printf("U\n");
    return 0;
}

Measured memory_bytes: 256
#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(){
  
  ll n; cin >> n;
  vector<ll> a(n), s(n);
  ll sum = 0;
  rep(i,n){
    cin >> a[i];
    // a[i] = 1000000000;
    a[i] = a[i]%Q;
    sum += a[i];
  }
  // cout << sum << endl;
  rep(i,n-1){
    sum -= a[i];
    s[i] = sum % Q;
  }
  
  ll ans = 0;
  rep(i,n-1){
    ans += (a[i] * s[i]) % Q;
  }
  

  ans = ans % Q;
  cout << ans << endl;
  

  return 0;
}

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

int main(void){
	int n;
	cin >> n;
	map<int, int> a;
	for(int i = 0; i < n; i++){
		int tmp;
		cin >> tmp;
		a[tmp]++;
	}
	int ans = 0;
	for(auto itr = a.begin(); itr != a.end(); ++itr){
		int diff = itr->second - itr->first;
		if(diff >= 0){
			ans += diff;
		}else{
			ans += itr->second;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

int main(){
	int n,k,x,y;
	cin>>n>>k>>x;
	
	if(n==k&&k==x){
		cout<<1<<endl;
		}
	else if(n==k||k==x||x==n){
		cout<<2<<endl;
		}
	else{
		cout<<3<<endl;
		}
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    int p[N];
    rep(i, N) cin >> p[i];
    sort(p, p+N);
    int sum = 0;
    rep(i, N-1) sum += p[i];
    sum += p[N-1]/2;
    cout << sum << endl;
}


Measured memory_bytes: 256
let S = stdin.ReadLine().ToCharArray()

let folder x c =
    let i = 
        match c with
        | 'a' -> 0
        | 'b' -> 1
        | _ -> 2
    Array.set x i (x.[i]+1)
    x

let counter = S |> Array.fold folder [|0; 0; 0|]

if counter |> Array.filter ((<>) 0) |> Array.forall ((=) 1) then
    "YES"
elif counter |> Array.exists ((=) 0) then
    "NO"
else
    let mini = Array.min counter
    if counter 
       |> Array.map (fun x -> x - mini)
       |> Array.exists ((<) 1)
    then "NO"
    else "YES"
|> stdout.WriteLine

Measured memory_bytes: 13268
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iterator>

using namespace std;

int main() {
  int n;
  vector<int> d;

  scanf("%d", &n);

  int tmp;
  for(int i = 0; i < n; i++) {
    scanf("%d", &tmp);
    d.push_back(tmp);
  }

  sort(d.begin(), d.end());
  auto end = unique(d.begin(), d.end());
  printf("%d\n", distance(d.begin(), end));
}


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

int main(){
  int n, v;
  int i, j, k;
  cin>>n;
  int a[n];
  for(i = 0; i < n; i++){
    cin>>a[i];
  }

  for(i = 0; i < n; i++){

    v = a[i];
    j = i -1;
    while((j >= 0)&&(a[j] > v)){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;

    for(k = 0; k < n-1; k++){
      cout<<a[k]<<" ";
    }
    cout<<a[n-1];
    /*if(i != n-1) */cout<<endl;
  }
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lson l,(l+r)/2,rt<<1
#define rson (l+r)/2+1,r,rt<<1|1
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define pll pair<long long,long long>
#define pii pair<int,int>
#define pq priority_queue
const int N=2e5+5,MD=1e9+7,INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-9,e=exp(1),PI=acos(-1.);
int a[N],b[N],dp[N];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
     int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i],b[a[i]]=i,dp[i]=1;
    for(int i=1;i<=n;i++)
        if(b[a[i]-1]<i) dp[i]=dp[b[a[i]-1]]+1;
    int ma=0;
    for(int i=1;i<=n;i++)
        ma=max(ma,dp[i]);
    cout<<n-ma;
    return 0;
}


Measured memory_bytes: 2688
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class BOrdinaryNumber {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            int n = s.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = s.nextInt();
            int count = 0;
            for (int i = 1; i < n - 1; i++) {
                if (a[i - 1] > a[i] && a[i] > a[i + 1])
                    count++;
                else if (a[i - 1] < a[i] && a[i] < a[i + 1])
                    count++;
            }
            w.println(count);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

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

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

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

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

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

        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S,T;
    cin >> S >> T;
    int size = S.size();
    queue<char> s,t;
    for(int i = 0;i < size;i++){
        s.push(S.at(i));
        t.push(T.at(i));
    }
    for(int i = 0;i < size;i++){
        if(s == t){
            cout << "Yes";
            break;
        }
        else{
            s.push(s.front());
            s.pop();
            if(i == size - 1){
                cout << "No";
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LL long long int
const LL MOD=1e9+7;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//            When something is important enough, you do it even if the odds are not in your favor.

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    LL t=1;//cin>>t;
    while(t--){
      LL n,x,t;cin>>n>>x>>t;
      LL a=n/x;
      if(n%x) a++;
      cout<<a*t;
    }
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
int main(void){
 int hand[6],box[14],i,j;
 while(scanf("%d,%d,%d,%d,%d",&hand[1],&hand[2],&hand[3],&hand[4],&hand[5])!=EOF){
  for(i=1;i<=13;i++){box[i]=0;}for(i=1;i<=5;i++)for(j=1;j<14;j++)if(hand[i]==j)box[j]++;
  for(i=1;i<=13;i++){
   if(box[i]==4){printf("four card\n");break;}
   else if(box[i]==3){
      for(j=1;j<=13;j++){
       if(box[j]==2){printf("full house\n");break;}
       if(j==13){printf("three card\n");break;}
      }break;
   }
   else if(box[i]==2){
      for(j=i+1;j<=13;j++){
       if(box[j]==3){printf("full house\n");break;}
       if(box[j]==2){printf("two pair\n");break;}
       if(j==13){printf("one pair\n");break;}
      }break;
   }
   else if(i==13){box[0]=box[13];
      for(j=1;j<=10;j++){
       if(box[j]==1&&box[j+1]==1&&box[j+2]==1&&box[j+3]==1&&box[(j+4)%13]==1){
        printf("straight\n");break;
       }
       if(j==10){printf("null\n");break;}
      }break;
   }
  }
 }
 return 0;
}

Measured memory_bytes: 580
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	while(true)
	    {
	int n=scan.nextInt();
	if(n==0)break;
	int a=0,b=0;
	for(int i=0;i<n;i++)
	    {
		int x,y;
		x=scan.nextInt();
		y=scan.nextInt();
		if(x>y)a+=x+y;
		else if(x<y)b+=x+y;
		else 
		    {
			a+=x;
			b+=y;
		    }

	    }
System.out.println(a+" "+b);
	    }
    }
}

Measured memory_bytes: 51688
#include <bits/stdc++.h>
using namespace std;
bool next_term(vector<int> &f){
    f[0]++;
    for(int i=0; i<f.size() - 1; i++){
        if(f[i] == 2) f[i+1]++;
        f[i] %= 2;
    }
    return (f.back() != 2);
}

bool satisfied(vector<int> &s, int x){
    for(auto si : s){
        if( si < x ) return false;
    }
    return true;
}

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for(int i=0; i<n; i++){
        cin >> c[i];
        for(int j=0; j<m; j++){
            cin >> a[i][j];
        }
    }
    vector<int> fragment(n, 0);
    int ans = INT_MAX;
    while(next_term(fragment)){
        vector<int> skills(m, 0);
        int cost = 0;
        for(int i=0; i<n; i++){
            if(fragment[i]){
                cost += c[i];
                for(int j=0; j<m; j++){
                    skills[j] += a[i][j];
                }
            }
        }
        if(satisfied(skills, x)) ans = min(cost, ans);
    }
    cout << (ans == INT_MAX ? -1 : ans) << endl;
}

Measured memory_bytes: 3600
// Problem : C - Low Elements
// Contest : AtCoder Beginner Contest 152
// URL : https://atcoder.jp/contests/abc152/tasks/abc152_c
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

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

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int cmin = 10000000, ans = 0;
	int N; cin >> N;
	rep(i, N) {
		int v; cin >> v;
		cmin = min(cmin, v);
		ans += (cmin == v);
	}
	cout << ans << endl;
}


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


ll gcd( ll a, ll b ) {
  if(a%b==0)return b;
  else gcd(b,a%b);
}
ll lcm(ll  a, ll b ) {
  return a*b/gcd(a,b);
}
int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll A  =  b/c - (a - 1)/c;
  ll B =  b/d - (a - 1)/d;
  ll AB = b/lcm(c,d) - (a-1)/lcm(c,d);

  cout << (b - a + 1) - A - B + AB << endl;
  return 0;
}

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

void eratos(int n, vector<bool> &isPrime) {
  isPrime.at(0) = false;
  isPrime.at(1) = false;
  for (int i = 2; i <= n; i++) {
    if (isPrime.at(i)) {
      for (int j = i*2; j <= n; j += i) isPrime.at(j) = false;
    }
  }
}

int main() {
  int X; cin >> X;
  vector<bool> isPrime(1000001, true);
  eratos(1000000, isPrime); // 1 から 100 万まで素数判定の bool 表を作成
  while (1) {
    if (isPrime.at(X)) {
      cout << X << endl;
      return 0;
    }
    else X++;
  }
}

Measured memory_bytes: 384
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

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

ans = 0
if Y < X:
    Y, X = X, Y
    B, A = A, B

if 2 * C < A + B:
    ans += 2*X*C
    ans += (Y-X)*min(B, 2*C)
else:
    ans += X*A + X*B
    ans += (Y-X)*min(B, 2*C)

print(ans)


Measured memory_bytes: 9188
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

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

    if(a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;
int n,m,x;
int c[15],a[15][15],b[15],d[15],len,sum=100000000,cost;
void dfs(int step)
{
    if(step==len+1)
    {
        for(int i=1; i<=m; i++)
        {
            d[i]=0;
        }
        for(int j=1; j<=len; j++)
            for(int k=1; k<=m; k++)
            {
                d[k]+=a[b[j]][k];
            }
        for(int i=1; i<=m; i++)
        {
            if(d[i]<x)
                return;
        }
        cost=0;
        for(int i=1; i<=len; i++)
            cost+=c[b[i]];
        sum=min(cost,sum);
        return;
    }
    for(int i=b[step-1]+1; i<=n; i++)
        b[step]=i,dfs(step+1);

}
int main()
{
    scanf("%d%d%d",&n,&m,&x);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&c[i]);
        for(int j=1; j<=m; j++)
            scanf("%d",&a[i][j]);
    }
    for(len =1; len<=n; len++)
        b[0]=0,dfs(1);
    if(sum==100000000)
        printf("-1\n");
    else
        printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 3820
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        String hed = sc.next();
        String s = sc.next();
        String foot = sc.next();

        System.out.println("A" + s.substring(0,1) + "C");
    }
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	int s,t;
	cin>>s>>t;
	vector<vector<char>>v(s+3,vector<char>(t+3));
	for(int i=0;i<s;i++)
	{
		for(int j=0;j<t;j++)
		{
			char w;
			cin>>w;
			v[i][j]=w;
		}
	}

	vector<vector<ll>>dp(s+3,vector<ll>(t+3,0));
	for(int i=1;i<=s;i++)
	{
		for(int j=1;j<=t;j++)
		{
			if(i==1 && j==1)
				dp[i][j]=1;
			else
			{
				if(v[i-1][j-1]=='#')
					dp[i][j]=0;
				else
					dp[i][j]=(dp[i-1][j]+dp[i][j-1])%(int)(1e9+7);
			}
		}
	}
	cout<<dp[s][t];
}

Measured memory_bytes: 12236
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

/*
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()
*/

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-9;

void solve() {
    ll x;
    cin >> x;
    ll ans = 1;
    for(ll i = 1; i <= 40; i++) {
        ll b = i;
        for(ll j = 2; j <= 10; j++) {
            b *= i;
            if(b <= x) chmax(ans, b);
            else break;
        }
    }
    cout << ans << endl;
    return;
}

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


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char inputdata[20001];
  int stack1[20001],Area_queue[10000],Area_stack[10000];
  int i,j,k,area_count=0,stack_count=0,len,num,total=0;

  scanf("%s",inputdata);
  len = strlen(inputdata);

  for(i=0;i<len;i++){
    if(inputdata[i] =='/' && stack_count != 0){
      Area_queue[area_count]+= i - stack1[--stack_count];
      if(stack_count == 0)area_count++;
    }
    else if(inputdata[i] =='\\'){
      stack1[stack_count++] = i;
    }
  }
  if(stack_count != 0){
    num = stack1[0];
    stack_count=0;
    j=0;
    for(i=len;i>num;i--){
      if(inputdata[i] =='/'){
	stack1[stack_count++] = i;
      }
      else if(inputdata[i] =='\\'){
	if(stack_count != 0){
	  Area_stack[j] +=stack1[--stack_count] - i;
	  if(stack_count == 0){
	    j++;
	  }
	}
      }
    }
    for(;j>0;){
      Area_queue[area_count++]=Area_stack[--j];
    }
  }
  for(i=0;i<area_count;i++)total+=Area_queue[i];
  if(area_count == 0){
    printf("0\n");
    printf("0\n");
  return 0;
  }
  printf("%d\n",total);
  printf("%d",area_count);
  for(i=0;i<area_count;i++){
    if(area_count-1 != i)printf(" %d",Area_queue[i]);
    else printf(" %d\n",Area_queue[i]);
  }
  return 0;
}
      
      
      
      



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int a[10001],bns,n; 
int main()
{
    scanf("%d",&n); 
    for(int i=1;i<=2*n;i++)  
        scanf("%d",&a[i]); 
    sort(a+1,a+1+2*n);  
    for(int i=1;i<=2*n;i+=2) 
        bns+=a[i]; 
    printf("%d\n",bns); 
    return 0;
}

Measured memory_bytes: 256
fun main() {
  val n = readLine()!!.toInt()
  val a = LongArray(100001){0}
  val c = readLine()!!.split(' ').map { it.toLong() }.toLongArray()
  c.forEach{a[it.toInt()]++}
  var sum = c.sum()

  val q = readLine()!!.toInt()
  for(i in 0 until q){
    val (v,newV) = readLine()!!.split(' ').map { it.toInt() }
    if(v > newV){
      sum -= (v-newV)*a[v]
      a[newV] += a[v]
      a[v] = 0
    }else {
      sum += (newV - v)*a[v]
      a[newV] += a[v]
      a[v] = 0
    }
    println(sum)
  }
}

Measured memory_bytes: 66596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;


int main()
{
	ll MOD = 998244353;
	int N, K;
	cin >> N >> K;
	vi A(K), B(K);
	for (int i = 0; i < K; ++i)
	{
		cin >> A[i] >> B[i];
	}

	vl f(N); f[0] = 1;
	vl a(N); a[1] = -1;

	for (int i = 0; i < N; ++i)
	{
		if (i > 0)
		{
			f[i] = f[i - 1] + a[i];
			f[i] %= MOD;
			while (f[i] < 0)
				f[i] += MOD;
		}
		for (int k = 0; k < K; ++k)
		{
			if (i + A[k] < N)
			{
				a[i + A[k]] += f[i];
				a[i + A[k]] %= MOD;
			}
			if (i + B[k] + 1 < N)
			{
				a[i + B[k] + 1] -= f[i];
				a[i + B[k] + 1] %= MOD;
			}
		}
	}
	cout << f[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 6412
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        int N = sc.nextInt();
        var A = sc.ArrayInt(N);
        var wa = new long[N + 1];
        for (int i = 0; i < N; i++) {
            wa[i + 1] = wa[i] + A[i];
        }
        WriteLine(wa.GroupBy(l => l).Where(grp => grp.Count() > 1).Select(grp => Combination.Calc(grp.Count(), 2)).Sum());
    }

    class Combination {
        static int mod = 1000000007;

        public static long Calc(int a, int b) {
            if (b > a - b) return Calc(a, a - b);

            long ansMul = 1;
            long ansDiv = 1;
            for (int i = 0; i < b; i++) {
                ansMul *= (a - i);
                ansDiv *= (i + 1);
                //ansMul %= mod;
                //ansDiv %= mod;
            }
            //return ansMul * ModPow(ansDiv, mod - 2) % mod;
            return ansMul / ansDiv;
        }

        private static long ModPow(long a, int p) {
            if (p == 0) return 1;
            if (p % 2 == 0) {
                long half = ModPow(a, p / 2);
                return half * half % mod;
            } else {
                return a * ModPow(a, p - 1) % mod;
            }
        }
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 51604
import java.util.Scanner;
 
public class Main {
 
	public static final MyScanner in = new MyScanner();

	public static void main(String[] args) {


		double A = in.nextLong();
		double B = in.nextLong();
		double N = in.nextLong();

		double x = -1;
		if(N < B) {
			x = N;
		} else {
			x = B-1;
		}

//		for(double a=1;a<N+1;a++) {
//			System.out.println(Math.floor(A*a/B) - (A * Math.floor(a/B)));
//		}
//
//		System.out.println();
//		System.out.println(x);
		System.out.println((long)(Math.floor(A*x/B) - (A * Math.floor(x/B))));
	}

	public static class Obj implements Comparable<Obj>{
		int a;
		int b;
		int c;
		int d;
		@Override
		public int compareTo(Obj o) {
			return Integer.compare(this.a, o.a);
		}

		
	}

	public static class MyScanner {
		Scanner sc = new Scanner(System.in);
		String next() { return sc.next();}
		int nextInt() { return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next()); }
	}
}

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

int gcd(int a, int b)
{
    int x = max(a, b);
    int y = min(a, b);
    int ret;
    for (int i = 1; i <= y; i++)
    {
        if (x%i == 0 && y%i == 0) ret = i;
    }
    return ret;
}

int main(void) 
{
    int K;
    cin >> K;
    long long sum = 0;
    for (int a = 1; a <= K; a++)
    {
        for (int b = 1; b <= K; b++)
        {
            for (int c = 1; c <= K; c++)
            {
                sum += gcd(gcd(a, b), c);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632