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

int main(void) {
        int span, i, sum;
        while(scanf("%d", &span) != EOF) {
                sum = 0;
                for(i=span;i<=600-span;i+=span) {
                        sum += i*i*span;
                }
                printf("%d\n", sum);
        }

        return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 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;
}
int solve(int x){
    int r=0,l=1000000000;
    while(l-r>1){
        int mid=(r+l)/2;
        if(mid*mid>x)l=mid;
        else r=mid;
    }
    return r;
}
signed main() {
    int H,W;cin>>H>>W;
    vector<vector<int>>Grid(H,vector<int>(W,-1));
    queue<pair<int,int>>que;
    rep(i,H){
        string s;cin>>s;
        rep(j,W){
            if(s[j]=='#'){
                Grid[i][j]=0;
                que.push(make_pair(i,j));
            }
        }
    }
    int ans=0;
    while(!que.empty()){
        pair<int,int>p=que.front();que.pop();
        int x=p.first,y=p.second;
        chmax(ans,Grid[x][y]);
        rep(i,4){
            int nx=x+dx4[i],ny=y+dy4[i];
            if(nx<0||nx>=H||ny<0||ny>=W)continue;
            if(Grid[nx][ny]==-1){
                Grid[nx][ny]=Grid[x][y]+1;
                que.push(make_pair(nx,ny));
            }
        }
    }
    cout<<ans<<endl;
    
    
}


Measured memory_bytes: 24500
#include<bits/stdc++.h>
using namespace std;
typedef signed long long int ll;
ll inf=1000000007;



const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main(){
    string s;
    cin>>s;
    
    int n;
    n=(int)s.size();
    
    ll dp[100010][4]={};
    //dp[n][3]=1LL;
    //for(int i=0;i<3;i++) dp[n][i]=0;
    for(int i=n;i>=0;i--){
        
        //char c=s[i];
        
        for(int j=3;j>=0;j--){
            if(i==n){
                dp[i][j] = (j == 3 ? 1 : 0);
            }
            else{
                
                dp[i][j]=dp[i+1][j]*(s[i] =='?' ? 3LL : 1LL);
                if(j < 3 && (s[i] == '?' || s[i] == "ABC"[j])){
                        dp[i][j] += dp[i+1][j+1];

                }
                dp[i][j]%=MOD;
            }
            
        }
        
        /*if(c=='?'){
            //j=3
            //何を書くかで三通り
            dp[i][3]=3LL*dp[i+1][3];
            
            //j=2
            //?にA,B,Cを入れて丸しない
            dp[i][2]=3LL*dp[i+1][2];
            //cを入れて丸
            dp[i][2]+=dp[i+1][3];
            
            //j=1
            //A,B,Cで丸しない
            dp[i][1]=3LL*dp[i+1][1];
            //Bで丸
            dp[i][1]+=dp[i+1][2];
            
            //j=0
            //丸しない
            dp[i][0]=3LL*dp[i+1][0];
            //Aで丸
            dp[i][0]+=dp[i+1][1];
        }else if(c=='C'){
            //j=3
            dp[i][3]=dp[i+1][3];
            //j=2
            //丸をするかしないか
            dp[i][2]=dp[i+1][2]+dp[i+1][3];
            //j=1
            dp[i][1]=dp[i+1][1];
            //j=0;
            dp[i][0]=dp[i+1][0];
        }else if(c=='B'){
            //j=3
            dp[i][3]=dp[i+1][3];
            //j=2
            dp[i][2]=dp[i+1][2];
            //j=1
            dp[i][1]=dp[i+1][1]+dp[i+1][2];
            
            dp[i][0]=dp[i][0];
            
        }else if(c=='A'){
            //j=3
            dp[i][3]=dp[i+1][3];
            //j=2
            dp[i][2]=dp[i+1][2];
            
            dp[i][1]=dp[i+1][1];
            
            dp[i][0]=dp[i+1][0]+dp[i+1][1];
        }*/
        
        /*for(int j=0;j<4;j++){
            dp[i][j]%=inf;
        }*/
    }
    
    cout<<dp[0][0]<<endl;
    
    
    return 0;
}


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

using namespace std;


int main()
{
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    while(1) {
        if(C <= 0) {
            cout<<"Yes";
            return 0;
        }
        if(A<=0) {
            cout<<"No";
            return 0;
        }
        A-=D;
        C-=B;
    }
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
	int t[19];
	int n = 0;
	int c = 0;
	for(int i=0;i<19;++i){
		t[i] = 0;
	}
	for(int i=0;i<=9;++i){
		for(int j=0;j<=9;++j){
			t[i+j]++;
		}
	}

	while(scanf("%d", &n) != EOF){
		c = 0;
		for(int i=0;i<19&&i<=n; ++i){
			if(n - i > 18){ continue; }
			c += t[i] * t[n - i];
		}
		printf("%d\n", c);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int n,ans=0,dn;
int pd(int x){
	int sum=1;
	while(x%10!=x){
		x/=10;
		sum++;
	}
	return sum;
}
int main(){
	cin>>n;
	dn=pd(n);
	if(n==100000)
		cout<<"90909";
	else if(dn==4)
		cout<<"909";
	else if(dn==2)
		cout<<"9";
	else if(dn==1)
		cout<<n;
	else if(dn==3)
		cout<<n-90;
	else if(dn==5)
		cout<<n-9090;
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 256
import heapq

N,M = map(int,input().split())
A = list(map(int,input().split()))
A = list(map(lambda x: x*(-1), A))

heapq.heapify(A)

for _ in range(M):
    tmp_min = heapq.heappop(A)
    heapq.heappush(A, (-1)*(-tmp_min//2))
    
print(-sum(A))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;
  cin>>N;
  
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  
  
  double sum=0;
  for(int i=0;i<N;i++){
    sum+=(double)(1.0/A[i]);
  }
  
  cout<<(long double)(1/sum)<<endl;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const ll INF=1000000000000001;
const double PI=3.141592653589;


int main(){
  string n; cin>>n;
  ll num=0;
  int sn=0;
  rep(i,n.size()){
    num*=10;
    num+=n[i]-'0';
    sn+=n[i]-'0';
  }
  if(num%sn==0)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
S = input()
T = input()

ans = 'UNRESTORABLE' 

def match(k):
    for i in range(len(T)):
        if T[i] != S[i+k] and S[i+k] != '?':
            return False
    return True

def construct(k):
    ans = []
    for i in range(len(S)): ans.append(S[i])
    for i in range(len(T)): ans[i+k] = T[i]
    for i in range(len(S)):
        if ans[i] == '?':
            ans[i] = 'a'
    return ans

for i in range(len(S)-len(T)+1):
    if match(i):
        ans=construct(i)

for i in range(len(ans)):
    print(ans[i], end='')
print()

Measured memory_bytes: 3064
n = input()
a = list(map(int, input().split()))
flg = True
break_flg = False
total = 0
while True:
  for i, b in enumerate(a):
    if b%2 == 0:
      a[i] = b/2
    else:
      break_flg = True
      break
  if break_flg :
    break
  else:
    total += 1
print(total)


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  string a, b;
  cin >> a >> b;
  while (a.size() < b.size()) a = '0' + a;
  while (a.size() > b.size()) b = '0' + b;
  cout << (a > b ? "GREATER" : a < b ? "LESS" : "EQUAL") << endl;
}



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

int main(){
    long long int a,b,c,d,r,f,g,h,i;
    cin >> a;
    b = a / 3;
    c = a / 5;
    d = a / 15;
    if(b > 1){
    r = (b * 3 + 3) * b / 2;
    }else if(b == 1){
        r = 3;
    }else{
        r = 0;
    }
    if(c > 1){
    f = (c * 5 + 5) * c / 2;
    }else if(c == 1){
        f = 5;
    }else{
        f = 0;
    }
    if(d > 1){
    g = (d * 15 + 15) * d / 2;
    }else if(d == 1){
        g = 15;
    }else{
        g = 0;
    }
    h = (1 + a)*a/2;
    i = h - r - f + g;
    cout << i << endl;


    }

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define ll long long
#define faltu ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define binary(x) std::string binary = std::bitset<25>(x).to_string(); //to binary
#define inf 1000000007
#define mod 1000000007
#define pi pair<int,int>
#define lpi pair<int,int>
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define lvi vector<long long int>
#define pie 3.14159265358979323846
ll int MMM=inf;
int pw(int x,int y){int z=1;for(;y;y>>=1,x=1ll*x*x%MMM)if(y&1)z=1ll*z*x%MMM;return z;}
using namespace std;
vi pm;
void prm(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
              prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p]) pm.pb(p);
}
bool sortbysecdesc(const pair<ll int,ll int> &a,const pair<ll int,ll int> &b)
{
    return a.first>b.first;
}
bool cmp(int x,int y){return x>y;}
int vis[100003][4];
int main()
{
	faltu;
	int n,m,uu,vv,x,y;
	cin>>n>>m;
	vi v[n+1];
	for(int i=0;i<m;i++)
	{
		cin>>x>>y;
		v[x].pb(y);
	}
	cin>>uu>>vv;
	queue<pair<int,int> > q;
	q.push(mp(uu,0));
	int s;
	vis[uu][0]=1;
	while(!q.empty())
	{
		int f=q.front().first;
		s=q.front().second;
		q.pop();
		if(f==vv&&s%3==0)break;
		s++;
		for(int i=0;i<v[f].size();i++)
		{
			if(vis[v[f][i]][s%3])continue;
			q.push(mp(v[f][i],s));
			vis[v[f][i]][s%3]=1;
		}
	}
	if(!vis[vv][0])cout<<"-1"<<endl;
	else cout<<s/3<<endl;
}








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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int n;
	ll k;
	cin>>n>>k;
	vector<ll> a(n,0);
	rep(i,n)cin>>a[i];

	vector<ll> sum(n+1,0);
	rep(i,n)sum[i+1] = sum[i]+a[i];

	vector<ll> target(n+1);
	rep(i,n+1){
		target[i] = (sum[i]-i+k)%k;
	}

	ll ans=0;
	map<ll,ll> mp;
	mp[0] = 1;
	int cnt=1;
	repi(i,1,n+1){
		if(cnt==k){
			mp[target[i-k]]=max(0LL,mp[target[i-k]]-1);
			ans += mp[target[i]];
			mp[target[i]]+=1;
			// cout<<a[i-1]<<" "<<ans<<" "<<target[i]<<endl;
		}else{
			ans += mp[target[i]];
			mp[target[i]]+=1;
			cnt++;
			// cout<<a[i-1]<<" "<<ans<<" "<<target[i]<<endl;
		}
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> p(n);
  REP(i,n) cin>> p[i];
  VRSORT(p);
  int sum=0;
  
  REP(i,n){
    if(i==0) sum+= p[i] /2;
    else sum += p[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
  string str, p;
  cin >> str >> p;
  str += str;
  if(str.find(p) < str.size()){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
n = int(input())
w = map(int, input().split())
w = list(w)
W = sum(w)
flag = W/2
for i in range(len(w)):
  flag -= w[i]
  if flag == 0:
    print(0)
    break
  elif flag < 0:
    if i < len(w)-1:
      print(min(abs(sum(w[:i])-sum(w[i:])),abs(sum(w[:i+1])-sum(w[i+1:]))))
      break
    else:
      print(min(abs(sum(w[:i])-sum(w[i:]))))
      break



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

using namespace std;

int n;
const int MAX_A = 1e6 + 5;
int cnt[MAX_A] = {};

int main() {
    scanf("%d", &n);
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);

        if (cnt[a[i]] != 0) {
            cnt[a[i]] = 2;
            continue;
        }
        for (int j = a[i]; j < MAX_A; j += a[i]) {
            cnt[j]++;
        }
    }
    int ans = 0;
    for (auto x : a) {
        if (cnt[x] == 1) ans++;
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 8052
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#define int long long
using namespace std;
const int maxn = 3e2+10;
const int maxm = 9e4+10;

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

int to[maxm],net[maxm],h[maxn],w[maxm],e=1;
inline void add(int x,int y,int z){
	to[++e]=y;net[e]=h[x];h[x]=e;w[e]=z;
}

int k,m,n,t;
int dis[maxn][maxn],num[maxn],last[maxn],vis[maxn];
priority_queue< pair<int,pair<int,int>> > q;
inline void bfs(int s){
	memset(num,0x3f,sizeof(num));
	memset(vis,0,sizeof(vis));
	memset(last,0,sizeof(last));
	while(!q.empty())q.pop();
	q.push(make_pair(0,make_pair(k,s)));num[s]=0;last[s]=k;
	while(!q.empty()){
		int num1=-q.top().first,last1=q.top().second.first,x=q.top().second.second;q.pop();
		if(vis[x])continue;vis[x]=1;
		for(register int i=h[x];i;i=net[i]){
			int y=to[i];
			if(last1>=w[i]){
				if(num[y]>num1){
					num[y]=num1;
					last[y]=last1-w[i];
					q.push(make_pair(-num[y],make_pair(last[y],y)));
				}		
				else if(num[y]==num1){
					if(last1-w[i]>last[y]){
						last[y]=last1-w[i];
						q.push(make_pair(-num[y],make_pair(last[y],y)));
					}
				}
			}
			else {
				if(num[y]>num1+1){
					num[y]=num1+1;
					last[y]=k-w[i];
					q.push(make_pair(-num[y],make_pair(last[y],y)));
				}
				else if(num[y]==num1+1){
					if(k-w[i]>last[y]){
						last[y]=k-w[i];
						q.push(make_pair(-num[y],make_pair(last[y],y)));
					}
				}
			}
		}
	}
	//if(s==1)
	//	for(register int i=1;i<=n;i++)cout<<i<<" "<<num[i]<<" "<<last[i]<<endl;
	for(register int i=1;i<=n;i++){
		if(num[i]>=n)dis[s][i]=-1;
		else dis[s][i]=num[i];
	}
	return;
}

signed main(){
	n=read();m=read();k=read();
	for(register int i=1;i<=m;i++){
		int x=read(),y=read(),z=read();
		if(z>k)continue;
		add(x,y,z);add(y,x,z);
	}
	for(register int i=1;i<=n;i++){
		bfs(i);
	}
	t=read();
	while(t--){
		int x=read(),y=read();
		printf("%lld\n",dis[x][y]);
	}
	return 0;
}

Measured memory_bytes: 4088
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,t;
    cin>>n>>m;
    t=m/n;
    for(int i = t;i>=1;i--){
        if(m%i==0){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n), s(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        s[i] = (i ? s[i - 1] : 0) + a[i];
    }
    ll ans = s[n - 1];
    for (int i = 1; i < n - 2; ++i) {
        ll s1 = s[i] / 2;
        ll s2 = (s[n - 1] - s[i]) / 2;
        int p1 = upper_bound(s.begin(), s.end(), s1) - s.begin() - 1;
        int p2 = upper_bound(s.begin(), s.end(), s[i] + s2) - s.begin() - 1;
        for (int x = max(p1, 0); x < min(p1 + 2, i); ++x) {
            for (int y = max(p2, i + 1); y < min(p2 + 2, n - 1); ++y) {
                ll t[4] = {s[x], s[i] - s[x], s[y] - s[i], s[n - 1] - s[y]};
                sort(t, t + 4);
                ans = min(ans, t[3] - t[0]);
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3328
let readIntArray _ =
    stdin.ReadLine().Split(" ") |> Array.map int

()
|> readIntArray
|> fun [| width; height; n |] ->
    let cells =
        seq {
            for w in 1 .. width do
                for h in 1 .. height do
                    (w, h)
        }

    [| 1 .. n |]
    |> Array.map readIntArray
    |> Array.fold (fun s [| x; y; a |] ->
        match a with
        | 1 -> s |> Seq.filter (fun (w, _) -> w > x)
        | 2 -> s |> Seq.filter (fun (w, _) -> w <= x)
        | 3 -> s |> Seq.filter (fun (_, h) -> h > y)
        | _ -> s |> Seq.filter (fun (_, h) -> h <= y)) cells
    |> Seq.length
    |> printfn "%d"


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

#define DeltaCube23 ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define minimum(a) *min_element(a.begin(), a.end())
#define maximum(a) *max_element(a.begin(), a.end())
#define MOD 1000000007
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i >= (b); i--)

typedef long long int lli;

using namespace std;

const int mx=1e5+5;

int main()
{
    DeltaCube23
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n,a;
        cin>>n>>a;
        int arr[n];
        forf(i,0,n)
        cin>>arr[i];
        sort(arr, arr+n);
        lli ans=0;
        forf(i,0,a)
        ans+=arr[i];
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

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

    if(a <= 9 && b <= 9) cout << a*b << endl;
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    long long a,b[2000],i,j,n=0,m,x,y,z=0;
    char s[100];

    scanf("%lld%lld%lld",&x,&y,&z);

    if(x>=z) printf("%lld %lld\n",x-z,y);
    else if (x+y>=z) printf("0 %lld",x+y-z);
    else printf("0 0\n");

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

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

    ll h, w, k;
    cin >> h >> w >> k;
    vector<string> str(h);
    REP(i,h){
        cin >> str[i];
    }
    ll ans = 0;

    for(ll b = 0; b < (1 << h); b++) {
        for(ll c = 0; c<(1 << w);c++){
            bitset<6> biti(b);
            bitset<6> bitj(c);
            ll tmp = 0;
            REP(i,h){
                REP(j,w){
                    if(biti[i]==1 && bitj[j]==1 && str[i][j]=='#'){
                        tmp++;
                    }
                }
            }
            if(tmp==k){
                ans++;
            }
        }
    }

    cout << ans <<endl;

    
    return 0;
}

Measured memory_bytes: 3648
package main
import (
  "fmt"
  "os"
  "bufio"
  "strings"
)
func main() {
  stdin := bufio.NewScanner(os.Stdin)
  stdin.Scan()
  text := stdin.Text()
  s := strings.Split(text, " ")
  fmt.Println(s[1] + s[0])
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define mod 1000000007
#define F first
#define S second
#define mk make_pair
#define B(v) v.begin(), v.end()
int main()
{	
	int n,k;
	cin>>n>>k;
	int a[n+10],ans=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		ans+=2*min(a[i],k-a[i]);
	}
	cout<<ans<<endl;
	return 0;

}

Measured memory_bytes: 256
//	A	??????a	?¨????b
//	B	??????b	?¨????c
//	C	??????a	?¨????c

#include <stdio.h>

int main(){
	
	int a, b, c, i, j, k;
	int A[100][100], B[100][100];
	long int C[100][100], hoge = 0;
	
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	for(i = 0; i < a; ++i){
		for(j = 0; j < b; ++j){
			
			scanf("%d",&A[i][j]);
		}
	}
	
	for(i = 0; i < b; ++i){
		for(j = 0; j < c; ++j){
			
			scanf("%d",&B[i][j]);
		}
	}
	
	
	for(i = 0; i < a; ++i){
		for(j = 0; j < c; ++j){
			for(k = 0; k < b; ++k){
				
				hoge += (A[i][k] * B[k][j]);
			}
			C[i][j] = hoge;
			hoge = 0;
		}
	}
	
	for(i = 0; i < a; ++i){
		for(j = 0; j < c; ++j){
			
			if(j == 0){
				printf("%ld",C[i][j]);
			}
			else{
				printf(" %ld",C[i][j]);
			}
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
#define oo int(1e9)
using namespace std;
typedef long long ll;
const ll INF = (ll)(1e18);
string s, t;
vector<vector<int>> dp;
int n, m;

int main() {
	cin.tie(0); ios::sync_with_stdio(0); cout.tie(0);
	cin >> s; 
	cin >> t;
	n = s.size();
	m = t.size();
	dp.resize(n + 1,vector<int> (m + 1));
	for (int i = 1; i <= n; i++)
	    for (int j = 1; j <= m; j++)
	        if (s[i - 1] == t[j - 1]) dp[i][j] = dp[i -1][j - 1] + 1;
	        else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
	
	vector<char> ans;
	while (n > 0 && m > 0){
	    if (s[n - 1] == t[m - 1]){
	        ans.push_back(s[n - 1]);
	        n--; m--;
	    }
	    else if (dp[n][m] == dp[n - 1][m]) n--;
	       else  m--;
	}
	for (int i = ans.size() - 1; i >= 0; i--) cout << ans[i];
	return 0;
}

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

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

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

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

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

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

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

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

fn main() {
    input!(k: usize, s: String);
    if s.len() <= k {
        println!("{}", s)
    } else {
        let s = s
            .chars()
            .enumerate()
            .filter(|&(i, _)| i >= 0 && i < k)
            .fold("".to_string(), |s, (_, c)| format!("{}{}", s, c));
        println!("{}...", s)
    }
}


Measured memory_bytes: 2168
/********************/
/* K B G D E L T A */
/*     DA-IICT      */
/********************/
 
#include<bits/stdc++.h>
using namespace std;
using   ll=long long;
using   ld=long double;
#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define F(i,n)         for(ll i=0;i<n;i++)
#define rep(i,a,b)     for(ll i=a;i<b;i++)
#define repp(i,a,b)    for(ll i=a;i>=b;i--)
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define f              first
#define s              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323
#define mod            1000000007

void solve()
{
    ll n,u;

    cin>>n;

    vll ans(n+1);

    F(i,n)
    {
        cin>>u;

        ans[u]=i+1;
    }

    for(int i=1;i<=n;i++)
    {
        cout<<ans[i]<<" ";
    }
}

 
signed main(){
 
    fast;
 
    ll t=1;
 
    //cin>>t;
 
    while(t--)
    {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp14
{
    class Class22
    {
        static void Main()
        {
            var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NK[0];
            int K = NK[1];
            var h = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var DP = new long[N + 1];
            for(int i = 1; i <= N; i++) { DP[i] = long.MaxValue; }
            DP[0] = 0;

            for(int i = 0; i < N; i++)
            {
                for(int j = 1; j <= K; j++)
                {
                    if (i + j < N)
                    {
                        int k = Math.Abs(h[i] - h[i + j]);
                        DP[i + j] = Math.Min(DP[i + j], DP[i] + k);
                    }
                    else break;
                }
            }
            Console.WriteLine(DP[N-1]);
        }
    }
}


Measured memory_bytes: 20576
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n%2==0){
    float z=0.5;
    cout<<setprecision(6)<<fixed<<z<<"\n";
  }
  else{
    float z=(n/2)+1;
    cout<<setprecision(6)<<fixed<<(z/n)<<"\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bitset>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    bitset<999999 + 1> b;
    auto t = b;
    t.set();
    t[0] = false;
    t[1] = false;
    int i = 0;
    while (true) {
        bool done = false;
        while (!t[i]) {
            ++i;
            if (i == t.size()) {
                done = true;
                break;
            }
        }
        if (done) {
            break;
        }

        b[i] = true;
        for (int j = i; j < t.size(); j += i) {
            t[j] = false;
        }
    }

    string s;
    while (getline(cin, s)) {
        int n = stoi(s);
        int count = 0;
        for (int j = 1; j <= n; ++j) {
            if (b[j]) {
                ++count;
            }
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 3428
S = input()

year = int(S[:4])
month = int(S[5:7])
day = int(S[8:])

if (year <= 2018):
    print('Heisei')
elif (year==2019):
    if (month <= 4):
        print('Heisei')
    else:
        print('TBD')
else:
    print('TBD')


Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(bf.readLine());
       StringTokenizer st = new StringTokenizer(bf.readLine());
       int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
       for(int i=0; i<n; i++) {
         for(int j=i; j<n; j++) {
           int temp = a[i];
           a[i] = a[j];
           a[j] = temp;
           boolean sorted = true;
           for(int k=0; k<n; k++) {
             if(a[k] != (k+1)) sorted= false;
           }
           if(sorted) {
             out.println("YES");
             out.close();
             System.exit(0);
           }

           temp = a[i];
           a[i] = a[j];
           a[j] = temp;
         }
       }
       out.println("NO");

        // int n = Integer.parseInt(st.nextToken());

        out.close(); System.exit(0);
    }
}


Measured memory_bytes: 21204
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = sc.nextInt();
        int ans = 10_000_000;
        for (int t = -100; t <= 100; t++) {
            int cost = 0;
            for (int i = 0; i < n; i++) {
                cost += (t - a[i]) * (t - a[i]);
            }
            ans = Math.min(ans, cost);
        }
        System.out.println(ans);
    }
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    string s;

    cin>> s;

    int l= s.size() -1;

    if(s[l]== '3')
        cout<< "bon\n";

    else if( s[l] == '0' || s[l]== '1' || s[l]== '6' || s[l]== '8')
        cout<< "pon\n";

    else
        cout<< "hon\n";


    return 0;
}




Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
const int MOD = 998244353;

int main()
{
	int N, K;
	cin >> N >> K;
	ll ans = 0;
	for (int b = K + 1; b <= N; b++) {
		int num = b - K;
		ans += num * (N / b);
		num = N % b;
		ans += max(num - K + 1, 0);
	}
	if (K == 0) cout << (ll)N * N << endl;
	else cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

constexpr int MAX_M = 200000, MAX_N = 100000;

using P = std::pair<int, int>;
using PP = std::pair<int, P>;

int N, M;
int p[MAX_M], q[MAX_M], c[MAX_M];
std::vector<P> adj[MAX_N];
std::map<P, std::map<P, int> > G;
std::priority_queue<PP, std::vector<PP>, std::greater<PP> > pque;
std::map<P, int> d;

int main()
{
  scanf( "%d%d", &N, &M );
  rep( i, M )
  {
    scanf( "%d%d%d", p+i, q+i, c+i );
    --p[i], --q[i];
    adj[p[i]].push_back( P( q[i], c[i] ) );
    adj[q[i]].push_back( P( p[i], c[i] ) );
  }

  rep( i, N )
  {
    for( auto p : adj[i] )
    {
      G[P(i,-1)][P(i,p.second)] = 1;
      G[P(i,p.second)][P(p.first,p.second)] = 0;
      G[P(i,p.second)][P(i,-1)] = 0;
    }
  }
  
  pque.push( PP( 0, P( 0, -1 ) ) );
  d[P(0,-1)] = 0;

  while( !pque.empty() )
  {
    PP p = pque.top();
    pque.pop();

    if( d.count( p.second ) && d[p.second] < p.first )
      continue;

    for( auto v : G[p.second] )
    {
      if( !d.count( v.first ) || d[v.first] > d[p.second]+v.second )
      {
        d[v.first] = d[p.second]+v.second;
        pque.push( PP( d[v.first], v.first ) );
      }
    }
  }

  printf( "%d\n", d.count(P(N-1,-1)) ? d[P(N-1,-1)] : -1 );

  return 0;
}

Measured memory_bytes: 165484
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <ctime>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
#ifdef __linux
#define LLD "%lld"
#else
#define LLD "%I64d"
#endif

#define NMAX 100000

int n,m;
int rep[NMAX+1000];
ll s[NMAX+1000];

int find(int p){
	int r,i,t;
	ll sum=0;

	for(r=p;rep[r];r=rep[r])sum+=s[r];
	for(i=p;i!=r;i=t){
		t=rep[i];
		rep[i]=r;
		ll tmp=s[i];
		s[i]=sum;
		sum-=tmp;
	}
	return r;
}

void un(int a,int b,ll d){
	int rb=find(b);
	rep[rb]=a;
	s[rb]=d-s[b];
	find(b);
}

bool check(){
	int i;

	for(i=0;i<m;i++){
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		if(find(l)==find(r)){
			if(s[r]-s[l]!=d){
				return false;
			}
		}else{
			un(l,r,d);
		}
	}
	return true;
}

int main(){
	scanf("%d%d",&n,&m);
	if(check())printf("Yes\n");
	else printf("No\n");
	return 0;
}



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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define Pi 1
#define LL long long
#define ULL unsigned long long
#define LD long double

using namespace std;

#define MAX_H 105
#define MAX_W 105

int H, W;
string A[MAX_H];

int num['z' - 'a' + 1];

int main()
{
  memset(num, 0, sizeof(num));
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    cin >> A[i];
    for (int j = 0; j < W; j++) {
      num[A[i][j] - 'a']++;
    }
  }

  priority_queue<int> que;
  for (int i = 0; i <= 'z' - 'a'; i++) {
    if(num[i] > 0)
      que.push(num[i]);
  }

  if(H*W == 1) {
    cout << "Yes" << endl;
    return 0;
  } else if(H*W == 2) {
    int q = que.top();
    cerr << q << endl;
    if(q == 2) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
  } else if(H == 1 || W == 1) {
    int flag = 0;
    while(que.size()) {
      int q = que.top();
      que.pop();
      if(q%2 == 0) {
        q -= 2;
        if(q > 0)
          que.push(q);
        continue;
      } else {
        if(flag == 0) {
          flag = 1;
        } else {
          flag = 2;
          break;
        }
      }
    }

    int d = 0;
    if(H==1) {
      d = W%2;
    } else {
      d = H%2;
    }

    if(d == flag) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }

    return 0;
  }

  //2*2以上
  int four = 0, two = 0, one = 0;
  if(H%2 == 1 && W%2 == 1){
    one = 1;
  }

  four += (W/2) * (H/2);
  if(W%2 != 0) {
    two += H/2;
  }

  if(H%2 != 0) {
    two += W/2;
  }

  //cerr << four << " " << two << " " << one << endl;

  bool ansFlag = true;
  while(que.size() && ansFlag) {

    int q = que.top();
    que.pop();

    //cerr << q << endl;

    if(four > 0) {
      if(q >= 4) {
        q -= 4;
        four--;
      } else {
        ansFlag = false;
      }
      if(q > 0) {
        que.push(q);
      }
      continue;
    }

    if(two > 0) {
      if(q >= 2) {
        q -= 2;
        two--;
      } else {
        ansFlag = false;
      }
      if(q > 0) {
        que.push(q);
      }
      continue;
    }

    if(one > 0) {
      if(q >= 1) {
        q -= 1;
        one--;
      } else{
        ansFlag = false;
      }
      if(q > 0) {
        que.push(q);
      }
      continue;
    }

    ansFlag = false;
  }

  if(que.size() == 0 && four == 0 && two == 0 && one == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque

n = int(input())

color_ls = {i: None for i in range(n)}
dict_map = {i : [] for i in range(n)}
already = set()
for i in range(n - 1):
    u, v, w = [int(i) for i in sys.stdin.readline().split()]
    u -= 1
    v -= 1
    if i == 0:
        root = u
    dict_map[u].append([v, w])
    dict_map[v].append([u, w])
    already.update({u, v})
color_ls[root] = 0
cur = root
already.clear()
que = deque()
while True:
    candidate = dict_map[cur]
    for cand, w in candidate:
        if cand in already:
            continue
        already.add(cand)
        que.append(cand)
        if w % 2 == 0:
            color_ls[cand] = 0 if color_ls[cur] == 0 else 1
        else:
            color_ls[cand] = 1 if color_ls[cur] == 0 else 0
    if len(que) == 0 or len(already) == n:
        break
    cur = que.popleft()

for i in range(n):
    print(color_ls[i])

Measured memory_bytes: 105700
#include<iostream>
#include<string>

using namespace std;


int main(){


    string str;
    int c;
    cin>>str;
    c=(int)str.length();
    int count=0;

    for(int i=0; i<c; ++i){
        if(str[i]=='1'){
            ++count;
        }
    }

    cout<<count<<endl;



}

Measured memory_bytes: 384
from collections import Counter
H,W=map(int,input().split())
A=[]
for _ in range(H):
    A+=list(input())

#基本的に4個ずつないとダメ
#行数・列数が奇数の場合、真ん中の行・列は2個ずつでよい
#行数・列数が両方とも奇数の場合、全体の中心は1個でよい

C=Counter(A)
g4=0
g2=0
g1=0
for n in C.values():
    g4+=n//4
    g2+=(n%4)//2
    g1+=(n%4)%2

ans='No'
if (g1==1 and H&1 and W&1) or g1==0:
    if g4 >= (H//2)*(W//2):
        if (g2 + (g4 - (H//2)*(W//2))*2) == (H//2 if W&1 else 0) + (W//2 if H&1 else 0):
            ans='Yes'
print(ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<ll> p(51), b(51);

ll f(ll n, ll x) {
	if (x == 0) return 0;
	if (n == 0) return 1;
	if (x <= 1 + b[n-1])
		return f(n-1, x-1);
	else if (x == (2 + b[n-1]))
		return p[n-1] + 1;
	else if (x <= 2 + 2 * b[n-1])
		return p[n-1] + 1 + f(n-1, x-2-b[n-1]);
	return 2 * p[n-1] + 1;
}

int main() {
	ll n; cin >> n;
	ll x; cin >> x;
	p[0] = b[0] = 1;
	for (int i = 0; i < 50; i++) {
		b[i+1] = b[i] * 2 + 3;
		p[i+1] = p[i] * 2 + 1;
	}
	cout << f(n, x) << '\n';
	return 0;
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	unsigned long long num,ans=1,eps=(long long)1e18;
	bool chk=true,zero=false;
	for(int i=0;i<n;++i)
	{
		cin>>num;
		if(zero)continue;
		if((log10((double)num)+log10((double)ans) >18 || (num*ans>eps)) && !zero)
			chk=false;
		else
			ans*=num;

		if(num==0)zero=true,chk=true,ans=0;
	}
	if(chk)
		cout<<ans<<'\n';
	else cout<<"-1\n";
}


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) (a.begin(), a.end())
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

int pow(int a, int n) {
	int res = 1;
	while (n--)
		res *= a;
	return res;
}

void solve() {
	int mx = 0;
	int x;
	cin >> x;
	for (int b = 1; b <= x; ++b) {
		for (int p = 2; p <= 30; ++p) {
			if (pow(b,p) <= x) {
				mx = max(mx,pow(b,p));
			}
		}
	}	

	cout << mx << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Char (isSpace)
import Data.Vector.Unboxed.Mutable (IOVector)
import qualified Data.Vector.Unboxed.Mutable as VM

main :: IO ()
main = do
  n <- readLn
  as <- f
  solve n as
  where
    f = map read <$> words <$> getLine

solve :: Int -> [Int] -> IO ()
solve n as = do
  v <- VM.replicate n 0 :: IO (IOVector Int)
  forM_ as $ \i -> do
    x <- VM.read v (i - 1)
    VM.write v (i - 1) (x + 1)
  forM_ [0 .. n-1] $ \i -> do
    x <- VM.read v i
    print x

readil :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a]
readil f = unfoldr $ \s -> do
  (n, s') <- f s
  return (n, B.dropWhile isSpace s')


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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	string s;
	cin >> s;
	for (int i = 1; i < s.length(); ++i) {
		if (s[i] == s[i - 1]) {
			cout << "Bad\n";
			return 0;
		}
	}
	cout << "Good\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--, b--, c--, d--;
    string s;
    cin >> s;

    rep(i, 0, n-1) {
        if(i < a) continue;
        if(max(c, d) <= i) continue;
        if(s[i] == '#' && s[i+1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }

    if(c < d) cout << "Yes" << endl;
    else {
        bool ok = false;
        rep(i, b-1, d) if(s[i] == '.' && s[i+1] == '.' && s[i+2] == '.') {
            ok = true;
            break;
        }
        if(ok) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include<map>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;


int main() {
	int i, j;
	int k = 0;
	int moji = 0;
	string O, E;
	char X[200] = {};
	cin >> O >> E;
	moji = O.length() + E.length();
	for (i = 0; i < moji; i+=2) {
		X[i] = O[k];
		X[i + 1] = E[k];
		++k;
	}
	//cout << k << endl;
	cout << X << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin >> a[i];
  sort(a.begin(), a.end(), greater<>());
  int mx_a = a[0];
  int ai = 0;
  for (int i=1; i<n; i++) {
    if (a[i] == mx_a) continue;
    if (abs(mx_a/2 - a[i]) < abs(mx_a/2 - ai)) {
      ai = a[i];
    }
  }
  cout << mx_a << " " << ai << endl;
  return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(200000)
n,k = map(int,input().split())
mod = 10**9+7
gr = [set() for _ in range(n+1)]
for i in range(n-1):
    a,b = map(int,input().split())
    gr[a].add(b)
    gr[b].add(a)
ans = [0]*(n+1)
done = [0]*(n+1)
done[1] = -1
done[0] = -2
def dfs2(gr,p,v,done,ans):
    ans[v] = k-2-done[p]
    for x in gr[v]:
        if x == p:
            continue
        dfs2(gr,v,x,done,ans)
        done[v] += 1
    return
dfs2(gr,0,1,done,ans)
m = 1
for x in ans[1:]:
    m = m*x%mod
print(m)

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

using namespace std;
using ll = long long;

#define MOD 1000000007
template<int mod>
struct ModInt{
   int x;
   ModInt():x(0){}
   ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
   ModInt &operator+=(const ModInt &p){
       if((x+=p.x)>=mod)x-=mod;
       return *this;
   }
   ModInt &operator-=(const ModInt &p){
       if((x+=mod-p.x)>=mod)x-=mod;
       return *this;
   }
   ModInt &operator*=(const ModInt &p){
       x=(int)(1LL*x*p.x%mod);
       return *this;
   }
   ModInt &operator/=(const ModInt &p){
       *this*=p.inverse();
       return *this;
   }
   ModInt &operator^=(long long p){
       ModInt res = 1;
       for (; p; p >>= 1) {
           if (p & 1) res *= *this;
           *this *= *this;
       }
       return *this = res;
   }
   ModInt operator-()const{return ModInt(-x);}
   ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
   ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
   ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
   ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
   ModInt operator^(long long p)const{return ModInt(*this)^=p;}
   bool operator==(const ModInt &p)const{return x==p.x;}
   bool operator!=(const ModInt &p)const{return x!=p.x;}
   explicit operator int() const { return x; }
   ModInt operator=(const int p) {x = p; return ModInt(*this);}
   ModInt inverse()const{
       int a=x,b=mod,u=1,v=0,t;
       while(b>0){
           t=a/b;
           a-=t*b;
           std::swap(a,b);
           u-=t*v;
           std::swap(u,v);
       }
       return ModInt(u);
   }
   friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
       return os<<p.x;
   }
   friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
       long long x;
       is>>x;
       a=ModInt<mod>(x);
       return (is);
   }
};
typedef ModInt<MOD> mint;
 
struct MComb {
   std::vector<mint> fact;
   std::vector<mint> inversed;
   MComb(int n) { // O(n+log(mod))
       fact = std::vector<mint>(n+1,1);
       for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*mint(i);
       inversed = std::vector<mint>(n+1);
       inversed[n] = fact[n] ^ (MOD-2);
       for (int i = n - 1; i >= 0; i--) inversed[i]=inversed[i+1]*mint(i+1);
   }
   mint ncr(int n, int r) {
       return (fact[n] * inversed[r] * inversed[n-r]);
   }
   mint npr(int n, int r) {
       return (fact[n] * inversed[n-r]);
   }
   mint nhr(int n, int r) {
       assert(n+r-1 < (int)fact.size());
       return ncr(n+r-1, r);
   }
};
 
mint ncr(int n, int r) {
   mint res = 1;
   for (int i = n - r + 1; i <= n; i++) res *= i;
   for (int i = 1; i <= r; i++) res /= i;
   return res;
}

int main()
{
    int n, k;
    cin >> n >> k;
    vector<mint> dp(k + 1);
    for(int i = k; i >= 1; i--){

        mint cur = mint(k / i)^n;
        //int itr = k / i;
        for(int j = 2; j * i <= k; j++){
            cur -= dp[j * i];
        }
        dp[i] = cur;
    }

    mint ans = 0;
    for(int i = 1; i <= k; i++){
        //cerr << i << " " << dp[i] << endl;
        ans += mint(i) * dp[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3792
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

xy = []
for aa in a:
    for bb in b:
        xy.append(aa + bb)
xy.sort(reverse=True)
t =[]
for d in xy[:k]:
    for cc in c:
        t.append(d+cc)
t.sort(reverse=True)
for tt in t[:k]:
    print(tt)

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

int main() {
	ll l[3],r[3];
	for(int i=0;i<3;i++){
		ll a,b,c;
		cin>>a>>b>>c;
		l[i]=b-a;r[i]=c-b;
	}
	bool ans=true;
	for(int i=0;i<2;i++){
		if(l[i]!=l[i+1]||r[i]!=r[i+1]){
			ans=false;
			break;
		}
	}
	cout << (ans? "Yes":"No");
	return 0;
}

Measured memory_bytes: 256