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

int main() {
  long n,a,b,ans=0;
  cin >> n >> a >> b;
  vector<long> x(n);
  for(long i=0;i<n;i++) cin >> x[i];

  for(long i=1;i<n;i++) {
    ans+=min(a*x[i]-a*x[i-1],b);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3984
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    string s;
    cin>>s;
    int sum = 700;
    for(int i=0;i<3;++i){
        if(s[i]=='o')sum+=100;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    fp((n <= 8)&&(m <= 8),"Yay!",":(");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
int main(void)
{
  int n;
  cin >> n;
  
  vector<long long> a;
  for(int i=0; i<n; i++){
      long long tmp;
      cin >> tmp;
      a.push_back(tmp);
  }
  
  long long count=0;
  for(int i=0; i<n; i++){
      while(a[i] % 2 == 0){
          a[i] /=2;
          count++;
      }
  }
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

int main () {
  long long N, K;
  cin >> N >> K;
  
  vector<int> town(N);
  for (int i=0; i<N; i++){
    cin >> town.at(i);
    town.at(i) = town.at(i) - 1;
  }
  
  int now = 0;
  vector<int> count(N,0);
  long long roop_town,rest;
  bool flag=false;
  
  for (int i=0; i<K; i++){
    now = town.at(now);
    if (count.at(now) != 0){
      flag = true;
      roop_town = i-count.at(now);
      rest = K - i - 1;
      break;
    }
    count.at(now) = i;
  }
  if (flag){
    rest = rest % roop_town;
    for (int j=0; j<rest;j++)
      now=town.at(now);
  }
  cout << now+1 << endl;
}


Measured memory_bytes: 4800
def main():
    D = int(input())
    C = list(map(int, input().split()))
    S = [list(map(int, input().split())) for _ in range(D)]

    score = 0
    last_day = [-1] * 26

    for d in range(D):
        print(S[d].index(max(S[d])) + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9504
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
#define re register
using namespace std;
int n,m;
int mp[2052][2052];
inline void work(re int x,re int y,re int X,re int Y){
	if(x==X&&y==Y){
		mp[x][y]=1;
		return;
	}
	mp[x+X>>1][y+Y>>1]=1;
	int midx=x+X>>1,midy=y+Y>>1;
	work(x,y,midx-1,midy-1);
	work(midx+1,y,X,midy-1);
	work(x,midy+1,midx-1,Y);
	work(midx+1,midy+1,X,Y);
}
signed main(){
	int tmp=0;
	scanf("%d%d",&n,&m);
	if(n<m){
		for(re int i=1;i<=(1<<m);i+=(1<<n)){
			work(1,i,(1<<n)-1,i+(1<<n)-2);
		}
	}
	else{
		for(re int i=1;i<=(1<<n);i+=(1<<m)){
			work(i,1,i+(1<<m)-2,(1<<m)-1);
		}
	}
	for(re int i=1;i<(1<<n);++i){
		for(re int j=1;j<(1<<m);++j)
		printf("%d",mp[i][j]);
		putchar('\n');
	}
}

Measured memory_bytes: 11520
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        n1:[(i32,(i32,i32));n],
    }
    let mut tmp = (0, (0, 0));
    for x in 0..n {
        let tmp1: (i32, i32) = n1[x].1;
        let tmpx = tmp.1;
        if (tmp1.0 - tmpx.0).abs() + (tmp1.1 - tmpx.1).abs() <= (n1[x].0 - tmp.0) {
            if ((tmp1.0 - tmpx.0).abs() + (tmp1.1 - tmpx.1).abs() < (n1[x].0 - tmp.0)) {
                if ((tmp1.0 - tmpx.0).abs() + (tmp1.1 - tmpx.1).abs() - (n1[x].0 - tmp.0)).abs() % 2
                    == 1
                {
                    return print!("No");
                }
            }
            tmp = (n1[x].0, n1[x].1);
        } else {
            return print!("No");
        }
    }
    return print!("Yes");
}


Measured memory_bytes: 4544
#ifndef ONPC
  #define _FORTIFY_SOURCE 0
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("no-stack-protector")
  #pragma GCC optimize("unroll-loops")
  #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
  #pragma GCC optimize("fast-math")
#endif

#include <bits/stdc++.h>

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    int cnt = 0;

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

    for (int i = 0; i < n; i++){
      if (a[i] * 4 * m >= s) cnt++;
    }

    if (cnt >= m) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int a, b;

signed main() {
	cin >> a >> b;
	cout << ((a*b)%2 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

#define all(a) begin(a),end(a)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=998244353;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}
 
int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

void getvec(vector<pair<int,int>>&a){
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
}
 
const int N=1000002;

pair<int,int> dp[N];
bool vis[N];
vector<int>zz;

void dfs(int ind,int val){
  if(vis[ind]){
    return;
  }
  if(dp[ind].S!=-1){
    return;
  }
  vis[ind]=true;
  zz.pb(ind);
  if(dp[ind].F<=val){
    dp[ind].S=dp[ind].F;
    dp[ind].F=val;
  }
  else if(dp[ind].S<=val){
    dp[ind].S=val;
  }
  for(int i=0;i<19;i++){
    if((ind>>i)&1){
    }
    else{
      dfs(ind^(1<<i),val);
    }
  }
}

void solve(){
  int n;
  cin>>n;
  for(int i=0;i<(1<<n);i++){
    dp[i].F=dp[i].S=-1;
  }
  vector<pair<int,int>>a(1<<n);
  getvec(a);
  sort(all(a));
  int ans=0;
  for(int i=(1<<n)-1;i>=0;i--){
    dfs(a[i].S,a[i].F);
    for(auto j:zz){
      vis[j]=false;
    }
    zz.clear();
  }
  for(int i=1;i<(1<<n);i++){
    ans=max(ans,dp[i].F+dp[i].S);
    cout<<ans<<'\n';
  }
 
}
 
signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}


Measured memory_bytes: 9208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();

		if (a.equals("H")) {
			if (b.equals("H")) {
				System.out.println("H");
			} else {
				System.out.println("D");
			}
		} else {
			if (b.equals("H")) {
				System.out.println("D");
			} else {
				System.out.println("H");
			}
		}

		sc.close();


	}
}




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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


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

    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int64_t cnt=0;
int64_t f(int64_t h){
  if(h==1)return 1;
  if(h>1)return 2*f(h/2)+1;
}
  
int main(){
  int64_t h;
  cin >> h;
  cout << f(h) << endl;
}
  

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

int main(int argc, char* argv[])
{
    double a, b;
    int c, d;

    cin >> a >> b;
    
    c = (int)a / (int)b;
    d = (int)a % (int)b;

    printf("%d %d %.8lf\n",c,d,(double)a/b);
}

Measured memory_bytes: 3192
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getval(_T& a) {
	std::cin >> a;
}
template<class _T> static void getval(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getval(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	LLONG N, K, S;
	getval(N, K, S);

	LLONG other = N - K;
	LLONG otherVal = S + 1;
	if (otherVal > 1000000000LL) {
		otherVal = 1;
	}
	LLONG kCount = K;

	int idx = 0;
	std::vector<LLONG> ai(N);
	while (other || kCount) {
		if (kCount) {
			ai[idx] = S;
			idx++;
			kCount--;
		}
		if (other) {
			ai[idx] = otherVal;
			idx++;
			other--;
		}
	}
	for (int i = 0; i < N; i++) {
		printf("%lld\n", ai[i]);
	}
}


Measured memory_bytes: 4048
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

int main(void)
{
	int n, d, a;
	while(scanf("%d%d%d", &n, &d, &a)==3)
	{
		vpii xh(n);
		for(auto&m:xh)
		{
			scanf("%d%d", &m.first, &m.second);
			m.second=(m.second+a-1)/a;
		}

		sort(xh.begin(), xh.end());
		ll ans=0;
		int atk=0;

		deque<pair<ll,int> > re;

		for(int s=0;s<n;s++)
		{
			for(;!re.empty();)
			{
				if(re.front().first>=xh[s].first) break;
				atk-=re.front().second;
				re.pop_front();
			}
			xh[s].second-=atk;
			if(xh[s].second<=0) continue;
			ans+=xh[s].second;
			atk+=xh[s].second;
			re.push_back(make_pair(xh[s].first+2LL*d, xh[s].second));
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

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

    ll eight = 1;
    ll nine = 1;
    ll ten = 1;

    for(int i = 0; i < n; i++) {
        eight = (eight * 8) % MOD;
        nine = (nine * 9) % MOD;
        ten = (ten * 10) % MOD;
    }

    ll ans = (ten + eight - nine - nine + MOD + MOD) % MOD;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
import Control.Monad

inpr::[Int]->[Int]->Int
inpr ls1 ls2= (sum.(map (\(x,y)-> x*y))) (zip ls1 ls2)

solver::[Int]->Int->[[Int]]->Int
solver b c = length.filter (\ans -> (inpr ans b)+c > 0)

main::IO()
main=do
  (n:b:c:[])<-return.map read.words=<<getLine
  b<-return.map read.words=<<getLine
  anss<- forM [1..n] (\_-> return.map read.words=<<getLine)
  print (solver b c anss)


Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main()
{
	vector<int> ans;
	int n;
	cin >> n;
	cout << n << ": ";
	for (int i = 2; i <= sqrt(n)+1; i++){
		if (n == 1) break;
		while (1){
			if (n % i == 0){
				n /= i;
				ans.push_back(i);
			} else {
				break;
			}
		}
	}
	if (n != 1) ans.push_back(n);
	for (int i = 0; i < (int)ans.size(); i++){
		if (i == (int)ans.size()-1) cout << ans[i] << endl;
		else cout << ans[i] << " ";
	}
}




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

vector<int> to[100005];
const int INF = 1001001001;

int main()
{
    int n, m;
    cin >> n >> m;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    q.push(0);
    dist[0] = 0;
    
    rep(i, n)
    {
        int v = q.front(); q.pop();
        
        for(int u: to[v])
        {
            if(dist[u] != INF) continue;
            dist[u] = dist[v]+1;
            pre[u] = v+1;
            q.push(u);
        }
    }

    cout << "Yes" << endl;
    rep(i, n)
    {
        if(i == 0) continue;
        cout << pre[i]<< endl;
    }
    return 0;
}

Measured memory_bytes: 10492
#define _CRT_SECURE_NO_WARNINGS
#define ANS_NUM (1)

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#else
#define VS_ENDPAUSE()
#endif

#include <stdio.h>
#include <iostream>
#include <math.h>
#include <cmath>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;


#if ANS_NUM == 1
void func(void)
{
	int32 a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if((c>=a) && (c<=b)){
		printf("Yes\n");
	} else {
		printf("No\n");
	}
}
#endif



int main(void)
{
	func();

	VS_ENDPAUSE();
	return 0;
}










#if ANS_NUM == 2
void func(void)
{

}
#endif

#if ANS_NUM == 3
void func(void)
{

}
#endif

#if ANS_NUM == 4
void func(void)
{

}
#endif

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

void main(string[] argv)
{
	long x = readln.chomp.to!long;
	long a = readln.chomp.to!long;
	long b = readln.chomp.to!long;

	x -= a;
	writeln(x%b);
}


Measured memory_bytes: 256
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n: usize = s.trim().parse().unwrap();
    let mut k = 1;
    while (1 << (k + 1)) - 1 <= n {
        k += 1;
    }
    let mut a = vec![];
    let mut b = vec![];
    for i in 1..(k + 1) {
        a.push(i);
        b.push(i);
    }
    let mut h = k + 1;
    let mut t = n - ((1 << k) - 1);
    while t > 0 {
        let mut x = 0;
        while (1 << (x + 1)) <= t {
            x += 1;
        }
        t -= 1 << x;
        a.push(h);
        b.push(h);
        for i in (x..(b.len() - 1)).rev() {
            b[i + 1] = b[i];
        }
        b[x] = h;
        h += 1;
    }
    a.append(&mut b);
    let mut out = String::new();
    out.push_str(&format!("{}\n", a.len()));
    for a in a {
        out.push_str(&format!("{} ", a));
    }
    out.pop();
    println!("{}", out);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

int main(){
  int a,b,c;cin>>a>>b>>c;
  if(b>=c){
    cout << "delicious";
  }else if(a>=(c-b)){
    cout << "safe";
  }else{
    cout<<"dangerous";
  }
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int a,b,c,i,z=0;
  scanf("%d %d %d",&a,&b,&c);
  for(i=a;i<=b;i++)
    if(c%i==0)
      z+=1;
  printf("%d\n",z);
    return 0;
}

Measured memory_bytes: 1028
/**
*    author:  yuya1234
*    created: 22.07.2020 14:58:08
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
long double eps = 1.0E-14;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T>T lcm(T a,T b){return gcd(a,b)*(a/gcd(a,b))*(b/gcd(a,b));}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(15);

  int n,m,k;
  cin>>n>>m>>k;

  string ans="No";
  FOR(i,0,n)FOR(j,0,m)
  {
    if(i*(m-j)+j*(n-i)==k)ans="Yes";
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

struct uf_tree {
	std::vector<int> parent;
	int __size;
	uf_tree(int size_) : parent(size_, -1), __size(size_) {}
	void unite(int x, int y) {
		if ((x = find(x)) != (y = find(y))) {
			if (parent[y] < parent[x]) std::swap(x, y);
			parent[x] += parent[y];
			parent[y] = x;
			__size--;
		}
	}
	bool is_same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
	int size(int x) { return -parent[find(x)]; }
	int size() { return __size; }
};



//!!!問題をちゃんと読む!!!
//!!!問題をちゃんと読め!!!
//!!!問題は読みましたか？!!!


int imos[1000000];
int ans[1000000];
signed main() {
	int N,M;
	cin >> N >> M;
	rep(i, M) {
		int l,r;
		cin >> l >> r;
		imos[l]++;
		imos[r + 1]--;

	}

	int su = 0;
	rep(i, 200000) {
		su += imos[i];
		ans[i] = su;
	}
	int answer = 0;
	rep(i, 200000) {
		if (ans[i] == M) answer++;
	}
	cout << answer << "\n";

	return 0;
}

Measured memory_bytes: 5888
def main():
 
    def find(target):
        if parent[target] < 0:
            return target
        else:
            parent[target] = find(parent[target])
            return parent[target]
 
    def is_same(x, y):
        return find(x) == find(y)
 
    def union(x, y):
        root_x = find(x)
        root_y = find(y)
        if root_x == root_y:
            return
        if parent[root_x] > parent[root_y]:
            root_x, root_y = root_y, root_x
        parent[root_x] += parent[root_y]
        parent[root_y] = root_x

    def members(n, x):
        root = find(x)
        return [i for i in range(n) if find(i) == root]
 
    def get_size(x):
        return -parent[find(x)]
 
    def get_root():
        return [i for i, root in enumerate(parent) if root < 0]

    n, m = map(int, input().split())
    parent = [-1 for _ in range(n)]
    for _ in range(m):
        a, b = map(lambda x: int(x) - 1, input().split())
        union(a, b)
        # print(parent)
    ans = 0
    for i in range(n):
        ans = max(ans, get_size(i))
    print(ans)
    # 状況理解用
    # max_member = 0
    # for i in get_root():
    #     # print(i, members(n, i))
    #     max_member  = max(max_member, len(members(n, i)))
    # print(max_member)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14652
// Created by arvybhatt

#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

int main()
{
    fast;
	int n;cin>>n;
	int k;cin>>k;
	int h[n+1]={0};
	for(int i=0; i<k; i++)
	{
		int d;cin>>d;
		while(d--)
		{
			int x;cin>>x;
			h[x]++;
		}
	}    
	int count=0;
	for(int i=1; i<=n; i++)
	{
		if(h[i]==0)
			count++;
	}
	cout<<count;
    return 0;
}


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

int main()
{
    long long K, A, B;
    cin >> K >> A >> B;

    long long ans = 1;
    long long diff = B - A;
    if (diff > 2)
    {
        while (K > 0)
        {
            if (ans >= A && K - 2 >= 0)
            {
                ans += diff;
                K -= 2;
            }
            else
            {
                ans++;
                K--;
            }
        }
    }
    ans += K;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> in;
int input(){
string s;
if(!(cin>>s))return false;
in.clear();in.resize(15);
for(int i=0;i<s.size();i++){
in[s[i]-'0']++;
}
return true;
}
bool dfs(vector<int> &list){
if(list[0]==4){
for(int i=0;i<10;i++){
if(list[i]==2)return true;
}
return false;
}
for(int i=1;i<10;i++){
if(list[i]>=3){
vector<int> tmp = list;
tmp[i]-=3;
tmp[0]++;
if(dfs(tmp))return true;
}
}
for(int i=1;i<10-2;i++){
if(list[i]>0&&list[i+1]>0&&list[i+2]>0){
vector<int> tmp = list;
tmp[i]--;tmp[i+1]--;tmp[i+2]--;
tmp[0]++;
if(dfs(tmp))return true;
}
}
return false;
}
bool judge(int n){
vector<int> list = in;
list[n]++;
return dfs(list);
}
vector<int> solve(){
vector<int> res;
for(int i=1;i<10;i++){
if(in[i]==4)continue;
if(judge(i)){
res.push_back(i);
}
}
return res;
}
int main(){
while(input()){
vector<int> ans;
ans = solve();
if(ans.empty()){
cout<<0<<endl;
}else{
for(int i=0;i<ans.size()-1;i++){
cout<<ans[i]<<" ";
}cout<<ans[ans.size()-1]<<endl;
}
}
}

Measured memory_bytes: 1208
n, m = map(int, input().split())
a = [0] *n
b = [0] *n
c = [0] *m
d = [0] *m
for i in range(n):
    a[i], b[i] = map(int, input().split())
for j in range(m):
    c[j], d[j] = map(int, input().split())

ans = []



for i in range(n):
    judge = 10 ** 9
    num = 0
    for j in range(m):
        if judge > abs(a[i]-c[j])+abs(b[i]-d[j]):
            judge = abs(a[i]-c[j])+abs(b[i]-d[j])
            num = j+1
    ans.append(num)
#print(ans)
for i in ans:
    print(i)

Measured memory_bytes: 9080
#include "bits/stdc++.h"
using namespace std;
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll c=0,d=0,n1,m1,n2,m2,min=100000,k=0,ans=0;
    string s,s2;
    cin >> c;
    rep(i,c){
        cin >> s;
        if(s=="Y"){
            cout << "Four" <<endl; 
            return 0;
        }
    } 
    cout << "Three" <<endl; 
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
#define f first
#define s second
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
const double eps=1e-9;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b);
    return 0;
}


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

int main(){
  int N,M;
  cin>>N>>M;
  vector<vector<int>> A(M,vector<int>(3));
  vector<pair<int,string>> B(M);
  for(int i=0;i<M;i++){
    int P,Y;
    cin>>P>>Y;
    A.at(i)={P,Y,i};
  }
  sort(A.begin(),A.end());
  int k=0,j=0;
  for(int i=0;i<M;i++){
    if(A.at(i).at(0)==j)
      k++;
    else{
      k=1;
      j=A.at(i).at(0);
    }
    int64_t a=1000000000000LL+1000000LL*A.at(i).at(0)+k;
    B.at(i)=make_pair(A.at(i).at(2),to_string(a));
  }
  sort(B.begin(),B.end());
  for(pair<int,string> &i:B){
    for(int j=1;j<i.second.size();j++)
      cout<<i.second.at(j);
    cout<<endl;
  }
}

Measured memory_bytes: 13184
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

void fail(){
  cout << "No" << endl;
  exit(0);
}

signed main(){

  string s; cin >> s;

  int n = s.size();
  if(n % 2 == 0) fail();

  string t = s.substr(0, n/2);
  string r = t;
  reverse(t.begin(),t.end());
  //cout << t << " " << r << endl;
  if(t != r) fail();
  t = s.substr(n/2+1, n);
  r = t;
  reverse(t.begin(),t.end());
  //cout << t << " " << r << endl;
  if(t != r) fail();

  t = s.substr(0, n/2);
  r = s.substr(n/2+1, n);
  if(t != r) fail();
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[3005][3005];
char s1[3005],s2[3005];
int la1[3005][3005],la2[3005][3005];
int main(){
	scanf("%s%s",s1,s2);
	int len1=strlen(s1),len2=strlen(s2);
	bool flag=0;
	dp[0][0]=(s1[0]==s2[0]);
	la1[0][0]=-1;la2[0][0]=-1;
	for(int i=0;i<len2;i++){
		if(s1[0]==s2[i]){
			dp[0][i]=1;
			la1[0][i]=-1;
			la2[0][i]=i-1;
		}
		else{
			la1[0][i]=0;
			la2[0][i]=i-1;
			dp[0][i]=dp[0][i-1];
		}
	}
	for(int i=1;i<len1;i++){
		if(s1[i]==s2[0]){
			dp[i][0]=1;
			la1[i][0]=i-1;
			la2[i][0]=-1;
		}
		else{
			dp[i][0]=dp[i-1][0];
			la1[i][0]=i-1;
			la2[i][0]=0;
		}
		for(int j=1;j<len2;j++){
			dp[i][j]=dp[i][j-1];
			la1[i][j]=i;la2[i][j]=j-1;
			if(dp[i][j]<dp[i-1][j]){
				la1[i][j]=i-1;
				la2[i][j]=j;
				dp[i][j]=dp[i-1][j];
			}
			if(dp[i][j]<dp[i-1][j-1]+(s1[i]==s2[j])){
				la1[i][j]=i-1;
				la2[i][j]=j-1;
				dp[i][j]=dp[i-1][j-1]+(s1[i]==s2[j]);
			}
		}
	}
	string s;
	int x=len1-1,y=len2-1;
	while((~x)&&(~y)){
		if(la1[x][y]==x-1&&la2[x][y]==y-1){
			s+=s1[x];
			x=x-1;
			y=y-1;
		}
		else{
			int tx=la1[x][y],ty=la2[x][y];
			x=tx,y=ty;
		}
	}
	reverse(s.begin(),s.end());
	cout<<s;
	return 0;
}

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

int main(){
  string S; cin >> S;
  
  if(S == "SUN")
    cout << 7 << endl;
  if(S == "MON")
    cout << 6 << endl;
  if(S == "TUE")
    cout << 5 << endl;
  if(S == "WED")
    cout << 4 << endl;
  if(S == "THU")
    cout << 3 << endl;
  if(S == "FRI")
    cout << 2 << endl;
  if(S == "SAT")
    cout << 1 << endl;
  
  return 0;

}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Tenki
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int N = 3;

/* typedef */

/* global variables */

char s[N + 4], t[N + 4];

/* subroutines */

/* main */

int main() {
  scanf("%s%s", s, t);

  int cnt = 0;
  for (int i = 0; i < N; i++)
    if (s[i] == t[i]) cnt++;

  printf("%d\n", cnt);
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<pair<int,int>> vp;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<bool>> vbb;
typedef pair<int,int> pi;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define REP(n, x) for(int i = n; i < x; i++)
#define REPN(n, x) for(int i = x; i >= n; i--)
#define REPVS(arr) for(auto &x : arr)
#define REPV(arr) for(auto x : arr)
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(x) printf("%s\n", s.c_str())
#define F first
#define S second

const int INF = INT_MAX;

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

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n;
    cin >> n;
    string s;
    cin >> s;
    int red = 0;
    REP(0, n){
        if(s[i] == 'R')
            red++;
    }
    int temp = red;
    REP(0, temp){
        if(s[i] == 'R')
            red--;
    }
    pi(red);
    return 0;
}

Measured memory_bytes: 3820
#include <stdio.h>

int main(void)
{
  int A,B;
  scanf ("%d %d",&A,&B);
  if (B<A)	//BよりA大きい->逆に
  {
    int buf = A;
    A=B;
    B=buf;
  }
  //A<=B
  if (A==B) printf ("%d",2*A);
  else printf ("%d",2*B-1);
  return 0;
}

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

    class Program
    {
        static void Main(string[] args)
        {
            string[] strInputArray = Console.ReadLine().Split(' ');
            double[] inputArray = Array.ConvertAll<string, double>(strInputArray, delegate(string value) { return double.Parse(value); });
            double menseki = inputArray[0] * inputArray[0] * Math.PI;
            double enshu = 2 * inputArray[0] * Math.PI;

            Console.WriteLine(menseki.ToString("0.000000") + " " + enshu.ToString("0.000000"));
            Console.ReadLine();
        }
    }



Measured memory_bytes: 18004
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  string S, T;
  cin >> X;
  vector<ll> all_num;
  all_num.push_back((ll)1);
  rep_s(i, 2, 35){
    ll count_now = (ll)(i*i);
    while(count_now<=1000){
      all_num.push_back(count_now);
      count_now*=i;
    }
  }
  sort(ALL(all_num));
  rep(i, all_num.size()){
    //cout << all_num[i] << endl;
    if (all_num[i]>X) {
      cout<<all_num[i-1]<<endl;
      break;
    } else if(all_num[i] == X){
      cout << all_num[i] << endl;
      break;
    }
    
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
using namespace std;
typedef long long LL;
typedef LL ut;
const int SIZE=5+1e5;
const LL INF=1<<30;
const LL p=7+(1e9);
LL A[SIZE];
char B[SIZE];
bool isMinus[SIZE];
int main(){
	int N;
	cin >> N;
	LL ans=0;
	cin >> ans;
	REP(i,N-1){
		cin >> B[i];
		cin >> A[i];
		isMinus[i]=B[i]=='-';
	}
	LL freedom=0,needm=0,cost=0;
	REP(j,N-1){
		int i=N-1-j-1;
		cost+=A[i];
		needm+=A[i];
		if(isMinus[i]){
			freedom=max(freedom-A[i],needm-cost*2);
			cost=0;
		}
		else freedom+=A[i];
		
	}
	cout << freedom+ans << endl;
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

const int MAX_N=400010;

int N,M;
string S;
vector<vector<int>> G(MAX_N);
vector<bool> seen(MAX_N,false),finished(MAX_N,false);
bool cycle=false;

void dfs(int v){
    seen[v]=true;
    for (auto nv:G[v]){
        if (finished[nv]) continue;
        if (seen[nv]&&!finished[nv]){
            cycle=true;
            return;
        }
        dfs(nv);
    }
    finished[v]=true;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> S;
    rep(i,M){
        int a,b; cin >> a >> b; --a,--b;
        if (S[a]==S[b]){
            G[a].push_back(b+N);
            G[b].push_back(a+N);
        }
        else {
            G[a+N].push_back(b);
            G[b+N].push_back(a);
        }
    }
    rep(v,2*N) if (!seen[v]) dfs(v);
    if (cycle) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

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

ll f[N], g[N];

ll sum(ll a, ll b) {
	return (a + b + Mod + Mod) % Mod;
}
ll mul(ll a, ll b) {
	return (a * b) % Mod;
}
ll Pow(ll a, ll b) {
	ll res = 1;
	for (; b; b >>= 1, a = mul(a, a))
		if (b & 1)
			res = mul(res, a);
	return res;
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    ll n, k;
    cin >> n >> k;
    for (ll i = 1; i < N; i ++) {
    	ll res = k / i;
    	f[i] = Pow(res, n);
	}
	g[k] = 1;
	ll ans = 0;
	for (ll i = k; i; i --) {
		g[i] = f[i];
		for (ll k = i * 2; k < N; k += i) {
			g[i] = sum(g[i], -g[k]);
			
		}
		ans = sum(ans, mul(g[i], i));
	}
	cout << ans;
    return (0);
}

Measured memory_bytes: 5992
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>

using namespace std;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans=0;
    for(int i=1; i<=n-1; i++){
        int flag[26],tmp=0;
        memset(flag, 0, sizeof(flag));
        for(int j=0; j<i; j++){
            flag[s[j]-'a']++;
        }
        for(int j=i; j<n; j++){
            if(flag[s[j]-'a']!=0){
                tmp++;
                flag[s[j]-'a']=0;
            }
        }
        ans=max(ans, tmp);
    }
    cout << ans;

    return 0;
}

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

using namespace std;

int n;
int t[112123], a[112123];
bool ft[112123];
bool fa[112123];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) cin >> t[i];
	for (int i = 0; i < n; i++) cin >> a[i];
	ft[0] = true;
	fa[n-1] = true;
	for (int i = 1; i < n; i++) ft[i] = ft[i] || t[i] != t[i-1];
	for (int i = n-2; i >= 0; i--) fa[i] = fa[i] || a[i] != a[i+1];
	long long ans = 1;
	for (int i = 0; i < n; i++)
	{
		if (ft[i] && fa[i] && t[i] != a[i])
		{
			cout << "0\n";
			return 0;
		}
		if (ft[i] && t[i] > a[i])
		{
			cout << "0\n";
			return 0;
		}
		if (fa[i] && a[i] > t[i])
		{
			cout << "0\n";
			return 0;
		}
		if (!ft[i] && !fa[i])
		{
			ans = ans * min(t[i], a[i]);
			ans %= 1000000000 + 7;
		}
	}
	cout << ans << '\n';

	return 0;
}



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

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // ユークリッドの互除法（aが長辺）
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}          // オーバーフローしないように先に割る

const ll INF = LLONG_MAX;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("kannondou.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n = 30;
    vector<ll> h(n);
    rep(i,n)
    {
        cin >> h[i];
        if (h[i] == 0) break;
    }

    vector<ll> dp(n);

    for (ll elem : h)
    {
        if (elem == 0) break;
        rep(i,n)
        {
            dp[i] = -INF;
        }
        //cout << elem << endl;

        dp[0] = 1;
        for(int i = 1; i < elem; i++)
        {
            if (i == 1) {dp[i] = 2; continue;};
            if (i == 2) {dp[i] = 4; continue;};
            chmax(dp[i], dp[i-1] + dp[i-2] + dp[i-3]);
        }

        //cout << dp[elem-1] << endl;
        cout << dp[elem-1] / 10 / 365 + 1 << endl;
    }
    return 0;
}

/*
  - 最大値
    - long long : LLONG_MAX, LLONG_MIN, ULLONG_MAX(unsigned long long max)
  - vector
    vector<int> A(N);
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - string
    - loop
      for (char& c : s) {}
 */




Measured memory_bytes: 3100
#include<iostream>

#include<algorithm>
#include<cstring>
using namespace std;

int p[201];
int main() {
    int x, n;
    cin >> x >> n;
    for (int i =0 ;i < n; i++) {
        int a; cin >> a;
        p[a] = 1;
    }
    int ok = -1;
    for (int i = x; i >= 0; i--) {
        if (!p[i]) {ok = i; break;}
    } 
 //   cout << ok << endl;
    int ok2 = -1;
        for (int i = x; i <=101; i++) {
            if (!p[i]) {ok2 = i; break;}
        }
    if (ok2 == -1) {cout << ok; return 0;}
    else if (ok == -1) {cout << ok2; return 0;}
    else if (ok2 - x >= x-ok) cout << ok;
    else cout << ok2;

   // cout << ok << endl;
//    system("pause");
}

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

int main () {
  string S;
  cin >> S;
  int N = S.size();
  string ans = "Yes";
  for(int j=0; j<(N-1)/4; j++) {
    if(S.at(j)!=S.at((N-3)/2-j) || S.at((N+1)/2+j)!=S.at(N-1-j) || S.at(j)!=S.at(N-1-j)) {
      ans = "No";
    }
    else if (S.at((N-1)/4)!=S.at((N-1)*3/4+1)) {
      ans = "No";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256