akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

#define MOD 1000000007

//かなり難しく、解説でギリギリ理解できた程度。
//典型的らしいので必ず解き直す。
// n = 13*a + b と表せるとする。この数の右側に1桁増やしてc(0~9)をおく。
// 10*n+c = 130*a + 10*b + c となる。
//この数を13で割った余りは、10*b + cを13で割った余りに一致。

//言い換え
// ABCDEFGを13で割った余りは、ABCDEFを13で割った余りをmとすると、10*m + Gを13で割った余りに一致。

//非常に大きい数をある数で割った余りは、1つ桁を削った数をある数で割った余りがわかれば計算できる。
//徐々に桁を増やしていけばよく、漸化式的になるため、動的計画法と相性がいい。

int main(){
  string S;
  cin >> S;
  vvll dp(S.size()+1, vll(13, 0)); //dp[i+1][j]はi桁目までで、余りがjとなる数
  dp.at(0).at(0) = 1;
  for(int i = 0; i < S.size(); i++){
    ll c;
    if(S.at(i) == '?') c = -1;
    else c = S.at(i) - '0';

    if(c != -1){
      for(int j = 0; j < 13; j++){
        dp.at(i+1).at((10 * j + c) % 13) += dp.at(i).at(j) % MOD;
        dp.at(i+1).at((10 * j + c) % 13) %= MOD;
      }
    }
    else{
      for(int j = 0; j <= 9; j++){
        for(int k = 0; k < 13; k++){
          dp.at(i+1).at((10 * k + j)%13) += dp.at(i).at(k) % MOD;
          dp.at(i+1).at((10 * k + j)%13) %= MOD;
        }
      }
    }

  }
  cout << dp.at(S.size()).at(5) << endl;
}

Measured memory_bytes: 13696
#include<iostream>    
#include<cstdio>  
#include<stdio.h>  
#include<cstring>    
#include<cstdio>    
#include<climits>    
#include<cmath>   
#include<vector>  
#include <bitset>  
#include<algorithm>    
#include <queue>  
#include<map> 
#define inf 9999999; 
using namespace std;

int x,y;
int main()
{
	int a[]={31,28,31,30,31,30,31,31,30,31,30,31};
	cin>>x>>y;
	if(a[x-1]==a[y-1])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef pair <int,int> P;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> vec(M, 0);
    rep(i, N)
    {
        ll K;
        cin >> K;
        rep(j, K)
        {
            ll A;
            cin >> A;
            vec[A - 1]++;
        }
    }
    ll count = 0;
    rep(i, M)
    {
        if (vec[i] == N) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}



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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)

int main()  
{ 
    FAST_INP;
    int n;
    cin >> n;
    vector<long long> d(n+1,0);
    long long ans=0;
    for(int i=1;i<=n;i++){
    	for (int j = 1; j * i <= n; j++) 
            d[i*j]++; 
	}
    
    for(int i=1;i<=n;i++){ 
    	ans+=i*d[i];
    } 
    
    cout << ans;
    return 0;
} 

Measured memory_bytes: 81312
#!/usr/bin/env python3
w,a,b=map(int,input().split())
if b>a:
    if b-w-a>0:
        print(b-w-a)
    else:
        print(0)
if a>b:
    if a-w-b>0:
        print(a-w-b)
    else:
        print(0)
if a==b:
    print(0)

Measured memory_bytes: 9120
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll > P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int n,x,t;
    cin >> n >> x >> t;
    int num = n/x;
    int ans;
    if(n%x>0){
        ans = (num+1)*t;
    }else{
        ans = num*t;
    }

    cout << ans << endl;
}

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

struct Helper {
  memo: Vec<(usize, usize)>
}

impl Helper {
  fn traverse(&self,
    index: usize,
    mut val: usize,
    mut total: usize
  ) -> usize {
    if val == 1 {
      return total
    }
    val -= 1;
    
    let (b_p, b_b) = self.memo[index-1];
    let last = b_p + b_b;
    if val < last {
      return self.traverse(index-1, val, total);
    } else if val == last {
      return total + b_b;
    }
    val -= last;
    total += b_b;
    
    if val == 1 {
      return total + 1;
    }
    val -=1;
    total +=1;
    
    if val < last {
      return self.traverse(index-1, val, total);
    } else if val == last {
      return total + b_b;
    }
    val -= last;
    total += b_b;
    
    if val == 1 {
      return total
    }
    
    panic!("total: {}, val: {}, index: {}", total, val, index);
  }
}

#[fastout]
fn main() {
  input! {
    n: usize,
    x: usize,
  }
  
  let mut memo: Vec<(usize, usize)> = vec![];
  memo.push((0, 1));
  
  for i in 1..=n {
    let a = memo[i-1].0 * 2usize + 2usize;
    let b = memo[i-1].1 * 2usize + 1usize;
    memo.push((a, b));
  }
  let helper = Helper { memo };
  let result = helper.traverse(n, x, 0);  

  println!("{}", result);
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main () {
    int n;
    cin >> n;
    vector <ll> h(n);
    rep(i,n) {
        cin >> h[i];
    }
    ll ma = 0;
    ll count =0;
    for(int i =0;i< n-1; i++) {
        if(h[i] >= h[i+1]) {
            count++;
            ma = max(ma,count);
        }
        else {
            count =0;
        }
    }
    cout << ma << endl;
}

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

#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

ll N, A[200000], LD[200000], RD[200000], L[200001], R[200001], res;
stack<lP>s, t;

ll f(ll x, ll y) {
	int cnt = 0;
	while (x < y) {
		x *= 4;
		cnt += 2;
	}
	return cnt;
}
ll ff(ll x, ll y) {
	int cnt = 0;
	while (x <= y) {
		x *= 4;
		cnt += 2;
	}
	return cnt;
}

int main() {
	cin >> N;
	for (int i = 0; i != N; ++i)
		cin >> A[i];
	for (int i = 0; i != N - 1; ++i) {
		if (A[i] < A[i + 1])
			LD[i] = ff(A[i], A[i + 1]) - 2;
		else
			LD[i] = -f(A[i + 1], A[i]);
	}
	for (int i = 0; i != N - 1; ++i) {
		if (A[i] > A[i + 1])
			RD[i] = ff(A[i + 1], A[i]) - 2;
		else
			RD[i] = -f(A[i], A[i + 1]);
	}
	s.push(mkp(llmax, N - 1));
	for (int i = N - 2; i >= 0; --i) {
		L[i] = L[i + 1];
		if (LD[i] >= 0)
			s.push(mkp(LD[i], i));
		else {
			ll d = -LD[i], p = i;
			ll c = 0;
			while (d) {
				if (s.top().first >= d) {
					s.top().first -= d;
					c += (s.top().second - p)*d;
					d = 0;
				}
				else {
					c += (s.top().second - p)*d;
					d -= s.top().first;
					p = s.top().second;
					s.pop();
				}
			}
			L[i] += c;
		}
	}
	t.push(mkp(llmax, 1));
	for (int i = 2; i != N + 1; ++i) {
		R[i] = R[i - 1];
		if (RD[i-2] >= 0)
			t.push(mkp(RD[i-2], i));
		else {
			ll d = -RD[i-2], p = i;
			ll c = 0;
			while (d) {
				if (t.top().first >= d) {
					t.top().first -= d;
					c += (p - t.top().second)*d;
					d = 0;
				}
				else {
					c += (p - t.top().second)*d;
					d -= t.top().first;
					p = t.top().second;
					t.pop();
				}
			}
			R[i] += c;
		}
	}
	res = llmax;
	for (int i = 0; i != N + 1; ++i) {
		res = min(res, L[i] + R[i] + i);
//		cout << L[i] << sp << R[i] << endl;
	}
	cout << res << endl;
}


Measured memory_bytes: 11392
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.Char

readInt = readLn :: IO Int
readInts = map read . words <$> getLine :: IO [Int]

judge s = if a ^ 2 + b ^ 2 == c ^ 2 then "YES" else "NO"
  where
    [a,b,c] = sort s

main = readLn >>= flip replicateM readInts >>= mapM_ (putStrLn . judge)

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

int a, b, c; long long k;

int main()
{
	scanf( "%d%d%d%lld", &a, &b, &c, &k );
	
	if( k % 2 == 0 ) 
		printf( "%d\n", a - b );
	else printf( "%d\n", b - a );
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define chmin(a,b)  a=min(a,b);

using namespace std;
int main(void)
{
  vector<int> oddp;
  oddp.assign(2048576,33554432);
  oddp[0]=0;
  vector<int> natp;
  natp.assign(2048576,33554432);
  natp[0]=0;
  for(int d=0;d<200;++d){
    for(int i=0;i<1048576;++i){
      if(i+d*(d+1)*(d+2)/6>1048576) break;
      chmin(natp[i+d*(d+1)*(d+2)/6],natp[i]+1);
      if(d*(d+1)*(d+2)/6%2) chmin(oddp[i+d*(d+1)*(d+2)/6],oddp[i]+1);
    }
  }
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    cout << natp[n] << ' ' << oddp[n] << endl;
  }
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,k; cin >> n >> k;
    vl a(n);
    rep(i,n) cin >> a[i];
    vl s(n+1);
    ll res = L_INF;
    for(int i=0;i+k-1<n;i++){
        ll ans = min(abs(a[i]),abs(a[i+k-1]));
        ans += abs(a[i+k-1] - a[i]);
        res = min(ans,res);
    }
    cout << res << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(){
  int a;
  scanf("%d",&a);
  if(a==22){
    printf("Christmas Eve Eve Eve\n");
  }else if(a==23){
    printf("Christmas Eve Eve\n");
  }else if(a==24){
    printf("Christmas Eve\n");
  }else{
    printf("Christmas\n");
  }
  return 0;
}

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

////////////////いろいろあるよ//////////////////////////////////
int main(){
	ll a,b,n;
  	cin >> a >> b >> n;
  
  	if(a==1){cout << 0 << endl; return 0;}
  	if(b==1){cout << 0 << endl; return 0;}
  	//if(n==1){cout << 0 << endl; return 0;}
  
  	unsigned long long x = n;
  	if(x>=b)x = b-1;
  	if(a*x<b){cout << 0 << endl; return 0;}
  	unsigned long long one = a*x;
  	unsigned long long two = one/b;
  
  	/*unsigned long long zx = n;
  	unsigned long long zone = a*zx;
  	unsigned long long ztwo = one/b;
  	unsigned long long zthree = (zx/b);
  	unsigned long long zfour = a*zthree;
  	unsigned long long zans = ztwo - zfour;*/
  	//cout << max(two,zthree) << endl;
  	cout << two << endl;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;

int main()
{
    string s;
    cin>>s;
    vector<int> row(s.length());
    vector<int>p;
    int count=0;
    rep(i,s.length())
    {
        if(s[i]=='R')
        {
            count++;
        }
        else
        {
            int even=count/2;
            int odd =count-even;
            row[i]+=even;
            row[i-1]+=odd;
            count=0;   
        }
        
    }
    count=0;
    for(int i=s.length()-1;i>=0;i--)
    {
        if(s[i]=='L')
        {
            count++;
        }
        else
        {
            int even=count/2;
            int odd=count-even;
            row[i]+=even;
            row[i+1]+=odd;
            count=0;
        }
        
    }
    rep(i,s.length())
    {
        cout<<row[i]<<" ";
    }

}

Measured memory_bytes: 1152
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int main(){

    int n;
    cin >> n;

    vector<int> s(n);

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

        cin >> s[i];

    }

    sort(s.begin(),s.end());

    int out = 0;

    for(int i = n-1; i >= 0;--i){

        out += s[i];

    }

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

        if(out%10 == 0){
            if(s[i]%10 != 0){
                out -= s[i];
                ++count;
            }
        }else ++count;
    }
    
    if(count == 0)out = 0;

    cout << out << endl;

    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(m)]

res = [0]*n
for l, r in lr:
    res[l-1] += 1
    if r < n:
        res[r] -= 1
res_imos =[0]*(n+1)
for i in range(n):
    res_imos[i+1] = res_imos[i]+res[i]
ans = 0
for i in range(n):
    if res_imos[i+1]==m:
        ans+=1
print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;

#define SZ(x) ((int)x.size())

const int N = (int)1e5+5;
int n, op[N];
ll a[N], sum[N], dp[N];
priority_queue<ll> pq;
vector<int> q;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%lld", &a[i]);
		sum[i] = sum[i - 1] + a[i];
		if (i == n) break;
		char s[2]; scanf("%s", s);
		if (s[0] == '-') op[i] = -1;
		else op[i] = 1;
	}
	int idx = 1;
	for (; idx <= n; ++idx) {
		dp[idx] = sum[idx];
		if (op[idx] == -1) break;
	}
	for (int i = idx + 1; i <= n; ++i) {
		dp[i] = dp[i - 1] + (ll)op[i - 1] * a[i];
		if (op[i - 1] == -1) {
			if (SZ(q)) {
				ll val = sum[i - 1] - sum[q.back() - 1];
				pq.push(dp[q.back() - 1] - val - sum[i - 1]);
			}
			q.push_back(i);
		}
		if (SZ(pq) > 0) dp[i] = max(dp[i], pq.top() + sum[i]);
	}
	printf("%lld", dp[n]);
	return 0;
}


Measured memory_bytes: 4336
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(){

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

    int d, t, s; cin >>d >>t >>s;

    if(s*t >= d) cout <<"Yes" <<endl;
    else cout <<"No" <<endl;

    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
const int N = 18;
ll a[1<<N];
pll res[1<<N];
void merge(int x,int y)
{
	if(res[y].second>=res[x].first)
	{
		res[x].first = res[y].first;
		res[x].second = res[y].second;
	}
	else if(res[y].second<=res[x].first&&res[y].first>=res[x].first)
	{
		res[x].second = res[x].first;
		res[x].first = res[y].first;
	}
	else if(res[y].first<=res[x].first&&res[y].first>=res[x].second)
	{
		res[x].second = res[y].first;
	}
}
int main()
{
	int n,i,j;
	scanf("%d",&n);
	for(i=0;i<(1<<n);i++)	scanf("%lld",&a[i]);
	for(i=0;i<(1<<n);i++)
	{
		res[i].first = a[i];
		res[i].second = -1ll;
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<(1<<n);j++)
		{
			if((j&(1<<i))==0)
			{
				merge(j|(1<<i),j);
			}
		}
	}
	ll ans = 0ll; 
	for(i=1;i<(1<<n);i++)
	{
		ans = max(ans,res[i].first+res[i].second);
		printf("%lld\n",ans);
	}
}


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    while (cin >> n, n) {
        vector<string> s(n); cin >> s;
        using Fop = function<ll(ll,ll)>;
        using Line = pair<ll, string>;
        vector<Line> v;
        each(str, s) {
            ll pos = 0;
            while (str[pos] == '.') ++pos;
            v.pb({pos, str.substr(pos)});
        }
        Fop plus = [](ll a, ll b) { return a + b; };
        Fop mult = [](ll a, ll b) { return a * b; };
        function<ll(ll&, Fop, ll)> dfs = [&](ll& pos, Fop merge, ll init) {
            ll res = init;
            ll nest = v[pos].first;
            while (pos < n && v[pos].first == nest) {
                if (v[pos].second == "*") {
                    ++pos;
                    res = merge(res, dfs(pos, mult, 1));
                }
                else if (v[pos].second == "+") {
                    ++pos;
                    res = merge(res, dfs(pos, plus, 0));
                }
                else {
                    res = merge(res, stoll(v[pos].second));
                    ++pos;
                }
            }
            return res;
        };
        ll pos = 0;
        cout << dfs(pos, plus, 0) << endl;
    }
}

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

int main(){
    string s;
    cin>>s;
    string s1 = s;
    reverse(s1.begin(),s1.end());
    for(int i=0;i<s.size();i++){
        if(s[i]!=s1[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


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

int ans = 0;

int main(){
	int N; cin >> N;
	string S; cin >> S;
	for(int st=0; st<N; st++){
		vector<int> z(N-st, 0);
		string s = S.substr(st);
		z[0] = s.size();
		int i = 1, j = 0;
		while(i < s.size()){
			while (i+j < s.size() && s[j] == s[i+j]) ++j;
			z[i] = j;
			if (j == 0) { ++i; continue;}
			int k = 1;
			while (i+k < s.size() && k+z[k] < j) z[i+k] = z[k], ++k;
			i += k; j -= k;
		}
		for(int en=1; en<s.size(); en++){
			if(ans < min(en, z[en])) ans = min(en, z[en]);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,a,b,c,d,x,y,xm,ym,mn;
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	x=n/a;	
	if(n%a!=0)	x++;
	xm=x*b;
	y=n/c;
	if(n%c!=0)	y++;
	ym=y*d;
	mn=min(xm,ym);
	printf("%d\n",mn);
	return 0;
}


Measured memory_bytes: 2760
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
As = [list(input()) for _ in range(N)]
Bs = [list(input()) for _ in range(M)]

def check(i, j):
    for h in range(M):
        for w in range(M):
            if As[i+h][j+w]!=Bs[h][w]:
                return False
    return True

for i in range(N-M+1):
    for j in range(N-M+1):
        if check(i, j):
            print('Yes')
            exit(0)
else:
    print('No')
                

Measured memory_bytes: 63580
import sys

while True:
    l = list(map(int, input().split()))
    if(l[0] == 0 and l[1] == 0):
        sys.exit()
    else:
        if(l[0] > l[1]):
            print('{0} {1}'.format(l[1], l[0]))
        else:
            print('{0} {1}'.format(l[0], l[1]))


Measured memory_bytes: 5620
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String ans = "hon";
        switch (n % 10) {
            case 0:
            case 1:
            case 6:
            case 8:
                ans = "pon";
                break;
            case 3:
                ans = "bon";
                break;
        }
        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 35736
#include<iostream>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>

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());
  a.push_back(-1);

  int c = a[0], count = 1;
  int res = 0;

  for (int i=0; i<N; i++, count++) {
    if (c != a[i+1]) {
      if (count > c) res += count - c;
      else if (count < c) res += count;

      c = a[i+1];
      count = 0;
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,i,m,j,x,y,k;
    cin>>n;
    cin>>m;
    map<ll,ll> mm;
    mm[n]++;
    mm[m]++;
    if(mm[1] == 0) cout<<1;
    else if(mm[2] == 0) cout<<2;
    else cout<<3;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int d,n;
  int ans=1;
  cin>>d>>n;
  for(int i=0;i<d;i++) ans*=100;
  if(n!=100) cout<<ans*n<<"\n";
  else cout<<ans*n+ans<<"\n";
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def inpl(): return [int(i) for i in input().split()]

n,k = inpl()
C =inpl()

ans = 10**9
for i in range(n-k+1):
    ans = min(ans,abs(C[i]-C[k+i-1])+min(abs(C[i]),abs(C[k+i-1])))

print(ans)

Measured memory_bytes: 14252
#include <iostream>

using namespace std;

// const int MAX_N = 1000;

typedef long long ll;

/*
bool wins [MAX_N][MAX_N];

void calc_wins (int a, int b) {
  wins[a][b] = 0;
  for (int t = 2; t <= a; t += 2) {
    if (!wins[a - t][b + t / 2]) wins[a][b] = 1;
  }
  for (int t = 2; t <= b; t += 2) {
    if (!wins[a + t / 2][b - t]) wins[a][b] = 1;
  }
}
*/

int main () {
  /*
  for (int i = 0; i < 300; i++) {
    for (int a = 0; a <= i; a++) {
      calc_wins(a, i - a);
    }
  }

  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      cout << (wins[i][j] ? '#' : '.');
    }
    cout << endl;
  }
  */

  ll a, b;
  cin >> a >> b;

  if (abs(a - b) <= 1) {
    cout << "Brown" << '\n';
  } else {
    cout << "Alice" << '\n';
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll memo[100000];
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/

int main(){
    ll N,K;
    ll now = 1;
    cin >> N >> K;
    rep(i,N){
        now += min(now,K);
    }
    cout << now << endl;
}

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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int a[100];
int main(){
	int n;cin>>n;
	rep(i,n)scanf("%d",&a[i]);
	ll cur=1000;
	rep(i,n-1){
		cur=max(cur,(cur/a[i])*a[i+1]+cur%a[i]);
	}
	cout<<cur<<endl;
}

Measured memory_bytes: 3760
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    set<ll>s={in(),in(),in()};
    cout<<(s.size()==2?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    }else if(a>b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <list>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> A;
  ll sum = 0;
  int cnt_minus_num = 0;
  int min_absolute_value = 1e9;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a < 0) {
      cnt_minus_num++;
      sum -= a;
      min_absolute_value = min(min_absolute_value, -a);
    }
    else {
      sum += a;
      min_absolute_value = min(min_absolute_value, a);
    }
  }
  if (cnt_minus_num % 2 != 0) {
    sum -= 2 * min_absolute_value; 
  }
  
  cout << sum;
  return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
        int X;
        cin >> X;
        bool ok(false);
        if (X == 3 || X == 5 || X == 7) {
                ok = true;
        }

        cout << ((ok) ? "YES" : "NO") << endl;
        return 0;
}


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

int main(){
int num = 0;

cin>>num;


int input = 0;
long long max = -1000000;
long long min = 1000000;
long long sum = 0;

for(int i = 1;i <= num;i++){
scanf("%d",&input);

if(input > max) max = input;
if(input < min) min = input;

sum = sum + input;
}

cout<<min<<" "<<max<<" "<<sum<<endl;
return 0;
}


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

#define MP make_pair
#define FF first
#define SS second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pie;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const ll LINF = 4e18;
const ll delta = 10067;

const int N = 2e5 + 20;
map<ll, ll> cnt;
ll p[N], n, ans;

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	cnt[0]++;
	for (int i = 1, x; i <= n; i++) {
		cin >> x;
		p[i] = p[i - 1] + x;
		ans += cnt[p[i]];
		cnt[p[i]]++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    string S;cin>>S;
    int N=S.size();
    int dpk[N+1];//L未満が確定
    int dpm[N+1];//L未満か未確定
    REPS(i,N){
        int d=S[i-1]-'0';
        if(i==1){
            dpk[i]=1;
            dpm[i]=2;
        }
        else{
            if(d==0){
                dpk[i]=(dpk[i-1]*3)%MOD;
                dpm[i]=dpm[i-1];
            }
            if(d==1){
                dpk[i]=(dpk[i-1]*3+dpm[i-1])%MOD;
                dpm[i]=(dpm[i-1]*2)%MOD;
            }
        }
    }
    cout<<(dpk[N]+dpm[N])%MOD<<endl;
}

Measured memory_bytes: 2048
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M, L = mapint()
dist = [[10**18]*N for _ in range(N)]
for _ in range(M):
    a, b, c = mapint()
    dist[a-1][b-1] = c
    dist[b-1][a-1] = c

for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j]=min(dist[i][j], dist[i][k]+dist[k][j])

oil = [[10**18]*N for _ in range(N)]
for i in range(N-1):
    for j in range(i+1, N):
        if dist[i][j]<=L:
            oil[i][j] = 1
            oil[j][i] = 1

for k in range(N):
    for i in range(N):
        for j in range(N):
            oil[i][j]=min(oil[i][j], oil[i][k]+oil[k][j])

Q = int(input())
for _ in range(Q):
    s, t = mapint()
    if oil[s-1][t-1]>=10**17:
        print(-1)
    else:
        print(oil[s-1][t-1]-1)

Measured memory_bytes: 78864
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string s;cin>>s;
  sort(s.begin(),s.end());
  if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}




#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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

    // 高さが全部 0 になるまでやる
    int res = 0;
    while (true) {
        // 最高高さが 0 だったらおしまい
        if (*max_element(h.begin(), h.end()) == 0) break;
        
        // 区間分割する
        int i = 0;
        while (i < N) {
            if (h[i] == 0) ++i; // 0 なら何もせずに次に進む
            else {
                ++res; // 区間の始まり
                while (i < N && h[i] > 0) {
                    --h[i]; // ついでに引いとく
                    ++i; // 区間の終わりまで一気に
                }
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<stdlib.h>

using namespace std;

int main()
{
	int n,i,j,k;
	string str;
	string str2[16];
	int ans[4];
	
	cin >> n ;
	
	for(i=0;i<n;i++)
	{
		cin >> str ;
		for(j=0;j<8;j++)
		{
			for(k=j+1;k<8;k++)
			{
				if(str[j]<str[k])
				{
					char a;
					a=str[j];
					str[j]=str[k];
					str[k]=a;
				}
			}
		}
		str2[0]=str;
		for(j=0;j<8;j++)
		{
			for(k=j+1;k<8;k++)
			{
				if(str[j]>str[k])
				{
					char a;
					a=str[j];
					str[j]=str[k];
					str[k]=a;
				}
			}
		}
		str2[1]=str;
		ans[0] = atoi(str2[0].c_str());
		ans[1] = atoi(str2[1].c_str());
		cout << ans[0]-ans[1] << endl;
	}
}

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

#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ll long long
#define pb push_back
#define zoom                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define pl pair<ll, ll>
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define trace1(x) cerr << #x << ": " << x << endl
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z) cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl
#define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl
#define trace(v)                                   \
    for (auto it = v.begin(); it != v.end(); it++) \
        cerr << *it << " ";                        \
    cerr << endl;
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;

void solve()
{
    int n,k;
    cin>>n>>k;

    vi v(n);

    forn(i,n){
        cin>>v[i];
    }

    sort(all(v));

    ll sum=0;
    forn(i,k){
        sum+=v[i];
    }

    cout<<sum<<endl;
}

int main()
{
    zoom;
    ll t=1;
    //cin >> t;

    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
   ll n,k;
   cin>>n>>k;
   ll s=0;
   //cin>>n;
   ll a[n];
   for(ll i=0;i<n;i++)
   cin>>a[i];
   sort(a,a+n);
   for(ll i=0;i<k;i++)
   s+=a[i];
   cout<<s<<endl;
   
}

Measured memory_bytes: 3676
n, m, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = a.reverse + b
warn c.inspect
s = 0
sum = 0
while s < a.size && sum + a[s] <= k
    sum += a[s]
    s += 1
end
s = a.size - s
e = a.size
while e < c.size && sum + c[e] <= k
    sum += c[e]
    e += 1
end
#warn [s, e, sum].inspect
max = e - s
while s < a.size
    sum -= c[s]
    s += 1
    while e < c.size && sum + c[e] <= k
        sum += c[e]
        e += 1
    end
    #warn [s, e, sum].inspect
    if e - s > max
        max = e - s
    end
end
puts max


Measured memory_bytes: 65704
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<cctype>
#include<stack>
#include<map>
#include<string>
#include<cstdlib>
#include<sstream>
#define ll long long
#define ull unsigned long long
const int INF = 0x3f3f3f3f;
const int maxn = 100000 + 10;
const int mod = 1e6+3;
int n,a[maxn],dp[maxn];
int main()
{
    int a,b;
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        int flag=0;
        int x=a+b;
        if(x%2==1) flag=1;
        if(flag==1) printf("IMPOSSIBLE\n");
        else printf("%d\n",x/2);
    }
    return 0;
}

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

int main(){
	ll a,b,k;
	cin >> a >> b >> k;
	ll T = a;
	ll A = b;
	int count = 0;
	while(count <= k-1){
		if(count % 2 == 0){
			if(T % 2 == 1){
				T -= 1;
				A += T/2;
				T /= 2;
			}else{
				A += T/2;
				T /= 2 ;
			}
		}else{
			if(A % 2 == 1){
				A -= 1;
				T += A/2;
				A /= 2;
			}else{
				T += A/2;
				A /= 2;
			}
		}
		count++;
	}
	
	cout << T << " " << A << endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

int main(){
	std::string S, T; std::cin >> S >> T;
	int N = S.size();
	for (int i = 0; i < S.size(); ++i) {
		if (S == T) {
			std::cout << "Yes" << std::endl;
			return 0;
		}
		char save = S[N - 1];
		for (int i = S.size() - 2; i >= 0; --i) {
			S[i + 1] = S[i];
		}
		S[0] = save;
	}
	std::cout << "No" << std::endl;

	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>

using namespace std;

int main(void) {
	int n, a[3];
	
	cin >> n;

	for(int i = 0; i < n; i++) {
		cin >> a[0] >> a[1] >> a[2];
		
		sort(a, a + 3);
		
		if(a[2] * a[2] == a[0] * a[0] + a[1] * a[1]) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1168
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n;
bool used[1000010];
int cmp[1000010];
vector<int> g[1000010], gr[1000010];
vector<int> vs;
void dfs(int x){
	used[x]=1;
	for(auto y:g[x]){
		if(!used[y]) dfs(y);
	}
	vs.push_back(x);
}
 
void rdfs(int v, int k){
	used[v]=1;
	cmp[v]=k;
	for(auto y:gr[v]){
		if(!used[y]) rdfs(y, k);
	}
}
 
int scc(){
	fill(used, used+n, 0);
	vs.clear();
	for(int i=0; i<n; i++){
		if(!used[i]) dfs(i);
	}
	fill(used, used+n, 0);
	int k=0;
	for(int i=vs.size()-1; i>=0; i--){
		if(!used[vs[i]]) rdfs(vs[i], k++);
	}
	return k;
}
int d[1000010];
int solve(int x){
	if(d[x]>=0) return d[x];
	int ret=0;
	for(auto y:g[x]){
		ret=max(ret, solve(y)+1);
	}
	return d[x]=ret;
}
int main()
{
	int N; cin>>N;
	int a[1010][1010];
	n=N*N;
	for(int i=0; i<N; i++){
		for(int j=0; j<N-1; j++){
			cin>>a[i][j];
			a[i][j]--;
		}
		for(int j=1; j<N-1; j++){
			int x, y;
			if(i>a[i][j-1]) x=a[i][j-1]*N+i;
			else x=i*N+a[i][j-1];
			if(i>a[i][j]) y=a[i][j]*N+i;
			else y=i*N+a[i][j];
			g[x].push_back(y);
			gr[y].push_back(x);
		}
	}
	int k=scc();
	if(k<n){
		cout<<-1<<endl;
		return 0;
	}
	fill(d, d+n, -1);
	int ans=1;
	for(int i=0; i<n; i++){
		ans=max(ans, solve(i)+1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 95212
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

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

	int max = 1;
	FOR(i, X + 1, 1)
	{
		FOR(j, X, 2)
		{
			if (pow(i, j) > X)break;

			max = std::max(max, (int)pow(i, j));
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
r,b,g,n=map(int,input().split())
cnt=0
for i in range(n//r+1):
  for j in range(n//b+1):
    if r*i+b*j==n:
      cnt+=1
    elif (n-r*i-b*j)%g==0 and (n-r*i-b*j)//g>=1:
      cnt+=1
print(cnt)

Measured memory_bytes: 40796
#include <stdio.h>
#include <stdlib.h>
int main(){
  int flag,i,j,size,n,tmp,c=0,k;
  int minj;
  int *A;
  scanf("%d",&size);
  A = (int *)malloc(size * sizeof(int));

  for(i=0;i<=size-1;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0;i<=size-1;i++){
   flag = 0;
    minj = i;
    for(j=i; j<=size-1; j++){
       
      if(A[j] < A[minj]){
	minj = j;
	if(flag == 0){
	  c++;
	  flag = 1;
	}
      }
    }
    if(flag = 1){
      tmp = A[i];
      A[i] = A[minj];
      A[minj] = tmp;
    }
      /*  
    for(k=0;k<size-1;k++){
    printf("%d ",A[k]);
    }
    printf("%d\n",A[k]);
      */
  }

  for(i=0;i<size-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  printf("%d\n",c);
  return 0;
}



Measured memory_bytes: 2144
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ll ret = 0;
    for (int i = 0; i < n - 1; ++i) {
        if (a[i] % 2 == 1 && a[i + 1] != 0) {
            ret++;
            a[i]--;
            a[i + 1]--;
        }
    }
    for (int i = 0; i < n; ++i) {
        ret += a[i] / 2;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String word;
        int count,length;
        
        while(true){
            //文字列
            word = sc.next();
            //文字列が「-」の場合処理終了
            if(word.equals("-")) break;
            //シャッフル回数
            count = Integer.parseInt(sc.next());
            
            StringBuilder sb = new StringBuilder(word);
            for(int i=0; i<count; i++){
                //切る文字の長さ
                length = Integer.parseInt(sc.next());
                //1～length文字目を末尾に追加
                sb.append(sb.substring(0,length));
                //1～length文字目を削除
                sb.delete(0,length);
            }
            System.out.println(sb);
            
        }
    }

}



Measured memory_bytes: 26164
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
using namespace std;

typedef long long ll;

set<int> st = {4, 6, 9, 11};

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int a, b; cin >> a >> b;
    if(a == 2 || b == 2) cout << "No";
    else if(st.count(a) && st.count(b)) cout << "Yes";
    else if(st.count(a) || st.count(b)) cout << "No";
    else cout << "Yes";
}

Measured memory_bytes: 3616
//MMS
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int n, M = -1000000, m = 1000000,y; 
	long sum = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> y;
		M = max(M,y);
		m = min(m, y);
		sum += y;
	}
	cout << m << " " << M << " " << sum << endl;
	return 0;
}


Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
int main(void){
	int i,j,n,m,hit,blow;
	int A[10]={0},B[10]={0};
	char str[1000];

	for( ; ; ){
		hit=0; blow=0;
		fgets(str,sizeof(str),stdin);
		sscanf(str,"%d %d",&n,&m);
		if(n+m==0) break;
		for(i=0;i<4;i++){
			A[i]=(int)(n/pow(10,i))%10;
			B[i]=(int)(m/pow(10,i))%10;
		}
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(i!=j && A[i]==B[j])
					blow+=1;
				else if(i==j && A[i]==B[j])
					hit+=1;			
			}
		}
		printf("%d %d\n",hit,blow);
	} 
	return 0;
}			

Measured memory_bytes: 652
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.container, std.typecons;

const auto n = 3;
const auto bits = 4;

void main()
{
  auto b = 0UL;
  foreach (i; 0..n) {
    auto rd = readln.split.to!(int[]);
    foreach (j, d; rd)
      b = b.setDigit(i * n + j, d);
  }

  auto g = goal;

  auto vi = [b: true];
  auto qi = new DList!bl(bl(b, 0));
  while (!qi.empty) {
    auto q = qi.front; qi.removeFront;
    if (q.b == g) {
      writeln(q.l);
      break;
    }
      
    auto i = q.b.findZero;

    void insertQueue(bl q, size_t j)
    {
      auto c = q.b.swapDigit(i, j);
      if (c !in vi) {
        qi.insertBack(bl(c, q.l + 1));
        vi[c] = true;
      }
    }

    if (i / n > 0)     insertQueue(q, i - n);
    if (i / n < n - 1) insertQueue(q, i + n);
    if (i % n > 0)     insertQueue(q, i - 1);
    if (i % n < n - 1) insertQueue(q, i + 1);
  }
}

alias Tuple!(ulong, "b", int, "l") bl;

ulong goal()
{
  auto r = 0UL;
  foreach (i; 0..n*n-1)
    r = r.setDigit(i, i + 1);
  return r;
}

ulong setDigit(ulong b, size_t i, int val)
{
  return b & (~(((1UL << bits) - 1) << i * bits)) | (val.to!ulong << i * bits);
}

int digit(ulong b, size_t i)
{
  return (b >> i * bits) & ((1UL << bits) - 1);
}

ulong swapDigit(ulong b, size_t i, size_t j)
{
  auto x = b.digit(i), y = b.digit(j);
  return b.setDigit(i, y).setDigit(j, x);
}

ptrdiff_t findZero(ulong b)
{
  foreach (i; 0..n*n)
    if (b.digit(i) == 0)
      return i;
  return -1;
}

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

int main(void){
    
    long long A,B;
    cin >> A >> B;
    
    for(int i = 1; i <= B;i++){
        if((A*i)%B==0){
            cout << A*i <<endl;
            return 0;
        }
        
    }
    
}

Measured memory_bytes: 256
N = int(input()) 
n = int(N**.5)
res = len(str(N))
arr = []
tmp = N
for i in range(2,n+1):
    if tmp % i == 0:
        while tmp % i == 0:
            arr.append(i)
            tmp = int(tmp/i)
if tmp != 1: arr.append(tmp) 
arr = [str(i) for i in arr]
print(str(N) + ": " + " ".join(arr))



Measured memory_bytes: 5644
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
typedef long long ll;
const int inf=1e9+7;
inline int poww(int a,int b)
{
    int base=a,ans=1;
    while(b)
    	{
          if(b&1)
             ans=(ans*base)%inf;
          base=(base*base)%inf;
          b>>=1;
    	}
    return ans;
}
/*
inline ll mul(ll x,ll y,ll mod)//O(1)快速乘
{
    ll tmp=(x*y-(ll)((long double)x/mod*y+1.0e-8)*mod);
    return tmp<0?tmp+mod:tmp;
}*/
inline ll read()
{
    ll p=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){p=p*10+c-'0';c=getchar();}
    return f*p;}
const int maxn=307;
int n,vis[maxn][maxn];
ll dis[maxn][maxn],ans;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			dis[i][j]=read(),vis[i][j]=1;
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				{
					if(i==j||j==k||i==k)continue;
					if(dis[i][j]==dis[i][k]+dis[k][j])
						vis[i][j]=0;
					else if(dis[i][j]>dis[i][k]+dis[k][j])
							return !printf("-1\n");
				}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i!=j)ans+=vis[i][j]*dis[i][j];
	printf("%lld\n",ans/2);
	return 0;
}


Measured memory_bytes: 1408
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <stdio.h>
#include <math.h>
#include <utility>
#include <algorithm>

using namespace std;

void solve() {

}

int main() {
	int a[5];
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] ;
	int min=a[0]%10;
	int ind=0;
	for (int i = 1; i < 5; i++) {
		int d = a[i] % 10;
		if (d == 0)continue;
		if (d < min) {
			min = d;
			ind = i;
		}
	}
	for (int i = 0; i < 5; i++) {
		if (i != ind) {
			int d = a[i] % 10;
			if (d == 0)continue;
			a[i] += 10 - d;
		}
	}

	int time = 0;
	for (int i = 0; i < 5; i++) {
		time += a[i];
	}
	cout << time;

	return 0;
}


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

int main()
{
	char a[1526],l;
	cin>>a;
	l=strlen(a);
	for(int i=0;i<l;i++)
	{
		if(a[i]=='C')
		{
			for(int j=i;j<l;j++)
			{
				if(a[j]=='F')
				{
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n, sum;

	scanf("%d", &n);
	sum = 0;
	while (n--) {
		int l, r;

		scanf("%d%d", &l, &r);
		sum += r - l + 1;
	}
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 128