akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e3 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , m , k , ans = INF , cnt[MAXN][MAXN];
string s[MAXN];

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

    cin >> n >> m >> k;
    for(ll i = 1 ; i <= n ; i++)    cin >> s[i] , s[i] = "." + s[i];
    for(ll i = 1 ; i <= n ; i++){
        for(ll j = 1 ; j <= m ; j++){
            cnt[i][j] = cnt[i - 1][j] + ll(s[i][j] - 48);
        }
    }

    for(ll i = 0 ; i < (1ll << (n - 1)) ; i++){
        ll cur = 0;
        vector<ll> vec = {0};
        for(ll j = 0 ; j < n - 1 ; j++) if(i & (1 << j))    vec.push_back(j + 1);
        vec.push_back(n);
        vector<ll> C(SZ(vec) , 0);
        for(ll j = 1 ; j <= m ; j++){
            for(ll l = 0 ; l + 1 < SZ(vec) ; l++){
                ll L = vec[l] , R = vec[l + 1];
                ll x = cnt[R][j] - cnt[L][j];
                //cout << j << sep << l << sep << C[l] << sep << L << sep << R << sep << x << endl;
                if(x > k){
                    cur += MOD;
                    break;
                }
                if(C[l] + x > k){
                    for(ll t = 0 ; t + 1 < SZ(vec) ; t++)   C[t] = cnt[vec[t + 1]][j] - cnt[vec[t]][j];
                    cur++;
                    break;
                }
                C[l] += x;
            }
        }
        //cout << i << sep << cur << sep << SZ(vec) << endl;
        ans = min(ans , cur + SZ(vec) - 2);
    }
    cout << ans << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <queue>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};

int H, W;
vector<string> table;
vector<vector<int>> used;
pair<int, int> start;
int bfs(int y, int x)
{
    queue<pair<int, int>> que;
    que.push(make_pair(y, x));
    used[y][x] = 1;
    while(not que.empty())
    {
        pair<int, int> p = que.front(); que.pop();
        for(int i = 0; i < 4; i++)
        {
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(ny < 0 or nx < 0 or ny >= H or nx >= W) continue;
            if(table[ny][nx] == '#') continue;
            if(used[ny][nx]) continue;
            used[ny][nx] = used[p.first][p.second] + 1;
            que.push(make_pair(ny, nx));
        }
    }
    int res = 0;
    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            res = max(res, used[i][j]);
            used[i][j] = 0;
        }
    }
    return res - 1;
}
signed main(void)
{
    cin >> H >> W;
    table.resize(H);
    used.resize(H, vector<int>(W, 0));
    for(int i = 0; i < H; i++) cin >> table[i];
    int ans = 0;
    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            if(table[i][j] == '#') continue;
            ans = max(ans, bfs(i, j));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from fractions import gcd
from functools import reduce

N,M,*A = map(int,read().split())

# 「奇数倍」に帰着
A = [x >> 1 for x in A]

def merge(a,b):
    g = gcd(a,b)
    a //= g; b //= g
    if a % 2 == 0:
        return 0
    if b % 2 == 0:
        return 0
    n = a * b * g
    if n > 10 ** 9:
        return 0
    return n

x = reduce(merge, A)
if x == 0:
    answer = 0
else:
    answer = (M//x) - (M//(x+x))

print(answer)

Measured memory_bytes: 14504
def price(n):
  if n <= 10:
    x = 1150
  elif n <= 20:
    x = 1150 + (n - 10) * 125
  elif n <= 30:
    x = 1150 + 1250 + (n - 20) * 140
  else:
    x = 1150 + 1250 + 1400 + (n - 30) * 160
  return 4280 - x

while True:
  n = int(input())
  if n == -1: break
  print(price(n))


Measured memory_bytes: 5588
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
#define min(v,w) v>w?w:v;
#define max(v,w) v<w?w:v;
#define INF 0x3f3f3f3f3f3f3f3f
#define MAXN 30

struct p{
	int x,y;
};

int main(){  
	int i,j;
	int a,b;
    while(~scanf("%d%d",&a,&b))  { 
		a=a+b;
		i=0;
		while(a){
			i++;a/=10;
		}
		printf("%d\n",i);
	}
	return 0;
}

/*
((F(TF))(TF(F(TF(TF))))(F(TF))(TF))
(TFT)
((TFT)T)

*/

Measured memory_bytes: 1188
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first) {
        return a.first < b.first;
    } else {
        return a.second < b.second;
    }
}
const int MAX = 2000000;
const long long MOD = 1000000007;

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

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

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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    vector<long long> bit(62);
    rep(i, 0, 62) { bit[i] = 0; }
    rep(i, 0, N) { cin >> A[i]; }
    rep(r, 0, N) {
        for(long long i = 0; i < 62; ++i) {
            if(A[r] & ((long long)1 << i)) { // i が bit に入るかどうか
                bit[i]++;
            }
        }
    }
    long long ans = 0;
    for(long long i = 0; i < 62; ++i) {
        //  cout << "i;" << i << ",bit[i]:" << bit[i] << endl;
        long long po = (long long)1 << i;
        long long ko = bit[i] * (N - bit[i]);
        po = po % MOD;
        ko = ko % MOD;
        ans += po * ko;
        ans = ans % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    ll A, B;
    cin >> A >> B;
    ll N = __gcd(A, B);
    unordered_set<ll> s;
    while(N % 2 == 0) {
        s.insert(2);
        N /= 2;
    }
    ll N2 = N;
    for(ll i = 3; i*i < N; i+=2) {
        while (N2 % i == 0) {
            N2 /= i;
            s.insert(i);
        }
    }
    if (N2 > 1)
        s.insert(N2);
    cout << s.size() + 1 << endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

// sort(v.begin(), v.end(), [](auto &left, auto &right) {
//     return left.second < right.second;
// });

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, pair<pair<ll, ll>, ll> > > v;
    for (ll i = 0; i < m; i++)
    {
        ll p, y;
        cin >> p >> y;
        v.push_back(make_pair(i, make_pair(make_pair(p, y), 0)));
    }

    sort(v.begin(), v.end(), [](auto &left, auto &right) {
        if (left.second.first.first == right.second.first.first)
            return left.second.first.second < right.second.first.second;
        return left.second.first.first < right.second.first.first;
    });

    // for (auto t : v)
    // {
    //     cout << setw(6) << setfill('0') << t.second.first.first << setw(6) << setfill('0') << t.second.first.second << endl;
    // }

    ll cnt = 1;

    for (ll i = 0; i < m; i++)
    {
        if (i == 0)
        {
        }
        else if (v[i].second.first.first != v[i - 1].second.first.first)
        {
            cnt = 1;
        }
        else
        {
        }

        v[i].second.second = cnt;

        cnt++;
    }

    sort(ALL(v));

    for (auto t : v)
    {
        cout << setw(6) << setfill('0') << t.second.first.first << setw(6) << setfill('0') << t.second.second << endl;
    }
}

Measured memory_bytes: 6512
N = int(input())
H = list(map(int, input().split()))
ng=0
dec=0

for i in range(1,N):
    if (H[i-1]>H[i]):
        if (H[i-1]-1 == H[i]):
            if(dec==0):
                H[i-1]-=1
                dec=1
            else:
                ng=1
        else:
            ng=1
    if (H[i-1]<H[i]):
        dec=0
    if ng==1:
        break;

if(ng==0):
    print("Yes")
else:
    print("No")



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

const ll mod = 1e9+7;
#define MAX 2000

ll mpow(ll x,ll n){
    ll res = 1;
    while(n != 0){
        if(n&1) res = res*x % mod;
        x = x*x % mod;
        n = n >> 1; 
    }
    return res;
}
ll fac(ll i){
    static ll fatorial[MAX+1]={0};

    if(fatorial[i]) return fatorial[i];
    else if(i==0) return fatorial[0] = 1;
    else return fatorial[i] = fac(i-1)*i % mod;
}
ll ifac(ll i){
    static ll ifactorial[MAX+1]={0};

    if(ifactorial[i]) return ifactorial[i];
    else if(i==0) return ifactorial[0] = 1;
    else return ifactorial[i] = ifac(i-1)*mpow(i,mod-2) % mod;
}
ll comb(ll a,ll b){
    if(a==0 && b==0) return 1;
    if(a<b || a<0) return 0;
    ll tmp = ifac(a-b)*ifac(b) % mod;
    return tmp*fac(a) % mod;
}

int main(){
    ll n,k;
    cin >> n >> k;
    for(int i = 1;i <= k;i ++){
        cout << (comb(n-k+1,i)%mod*comb(k-1,i-1)%mod)%mod << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
typedef long long ll;
using namespace std;

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

	map<int, vector<int>> miv;

	int p;
	string S;
	for (int i = 0; i < M; i++) {
		cin >> p >> S;
		if (S == "AC") miv[p].push_back(1);
		else miv[p].push_back(0);
	}

	ll ans = 0;
	ll pena = 0;
	ll penaTmp = 0;
	for (int i = 1; i <= N; i++) {
		auto end = miv[i].end();
		penaTmp = 0;
		for (auto itr = miv[i].begin(); itr != end; itr++) {
			if (*itr == 0) {
				penaTmp++;
			} else {
				pena += penaTmp;
				ans++;
				break;
			}
		}
	}

	cout << ans << " " << pena << endl;

	return 0;
}


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

using namespace std;
const int N = 200;

int f[N][N];
char s[N][N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (i + j == 0) {
        f[0][0] = (s[0][0] == '#');
      } else {
        f[i][j] = (int) 1e9;
        if (i > 0) f[i][j] = min(f[i][j], f[i - 1][j] + (s[i - 1][j] == '.' && s[i][j] == '#'));
        if (j > 0) f[i][j] = min(f[i][j], f[i][j - 1] + (s[i][j - 1] == '.' && s[i][j] == '#'));
      }
    }
  }
  cout << f[h - 1][w - 1] << '\n';
  return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef unsigned long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
    int n,m,num; cin >> n >> m;
	vi invalid(n+1, 0);
    vll ans(n+2,0);
    
    rep(i,0,m){
    	cin >> num; invalid[num] = 1;
    }        
    
    ans[0] = 1;
    
    for(int i=1;i<=n;++i){
    	if(invalid[i]) continue;
    	
    	if(i-1>=0) ans[i] = (ans[i-1]+ans[i])%MOD;
    	if(i-2>=0) ans[i] = (ans[i-2]+ans[i])%MOD;
    }
    // deb(ans);
    
    cout << (ans[n] % MOD);
}

int main(){
    IOS;
    solve();
}

Measured memory_bytes: 4456
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from fractions import gcd

N,X,D = map(int,read().split())

if D == 0:
    if X == 0:
        print(1)
    else:
        print(N+1)
    exit()

g = gcd(X,D)
X //= g; D //= g
if D < 0:
    X,D = -X,-D

def F(d):
    # Xの個数 = d mod Dのとき
    event = []
    for n in range(d,N+1,D):
        # Xがn個
        low = X * n // D + n * (n-1) // 2
        high = X * n // D + n * (N+N-n-1) // 2
        event.append((low,0))
        event.append((high,1))
    event.sort()
    overlap = 0
    left_end = 0
    cnt = 0
    for x,t in event:
        if not t:
            if not overlap:
                left_end = x
            overlap += 1
        else:
            overlap -= 1
            if not overlap:
                cnt += x - left_end + 1
    return cnt

answer = sum(F(d) for d in range(min(D,N+1)))
print(answer)

Measured memory_bytes: 49752
/* ***********************************************
Author        :yang12138
Created Time  :2018年08月18日 星期六 20时17分41秒
File Name     :C.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)


int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	string s;
	ll k;
	cin>>s>>k;
	int one=0;
	char ch;
	for(int i=0;i<s.size();i++){
		if(s[i]=='1') one++;
		else{
			ch=s[i];
			break;
		}
	}
	if(k<=one){
		cout<<1<<endl;
	}
	else{
		cout<<ch<<endl;
	}

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define per(i,n) for (int i=n-1; i>=0; --i)
#define all(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using vi = vector<int>;
using vv = vector<vi>;

ll gcd(ll a, ll b){
    if(b>a)swap(a,b);
    while(a%b){
        a %= b;
        swap(a,b);
    }
    return b;
}

ll extGCD(ll a, ll b, ll &x, ll &y){
    if(b==0){
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

int main(){
    ll n;
    cin >> n;
    
    n *= 2LL;
    
    vector<ll> d;
    for(ll i=1; i<=n/i; i++){
        if(n%i)continue;
        if(gcd(i, n/i)!=1)continue;
        d.push_back(i);
        d.push_back(n/i);
    }
    ll ans = 2001001001001001;
    for(auto a: d){
        ll b = n/a;
        ll x, y;
        extGCD(a,b,x,y);
        //cout << a << " " << x << " " << y;// << endl;
        //cout << " " << ((-x)%b+b)%b << endl;
        ll k = ((-x)%b+b)%b * a;
        if(k)ans = min(ans, k);
        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#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__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    ll n; cin >> n;
    set<string> dic;
    for(int i=0;i<n;i++){
        string str; cin >> str;
        if(str == "insert"){
            string str; cin >> str;
            dic.insert(str);
        }else{
            string str; cin >> str;
            if(dic.find(str)!=dic.end()){
                cout << "yes" << endl;
            }else{
                cout << "no" << endl;
            }
        }
    }
}



Measured memory_bytes: 32176
#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 main(){
	string s,t;cin>>s>>t;
	int a,b;cin>>a>>b;
	string u;cin>>u;
	if(s==u)cout<<a-1<<' '<<b<<endl;
	else cout<<a<<' '<<b-1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define INF 1<<30

using namespace std;

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.SCG", "r", stdin );
	int e;
	while (scanf ("%d", &e ), e ) {
		int m = INF;
		for (int z = 0; z*z*z <= e; z++ ){
			for (int y = 0; y*y <= e - z*z*z; y++ ){
				int x = e - z*z*z - y*y;
				if (x >= 0 ){
					m = min (m, x + y + z );
				} // end if
			} // end for
		} // end for
		printf ("%d\n", m );
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,B,c;
    cin>>a>>B>>c;
    if(a+B>=c)
     cout<<"Yes";
    else 
     cout<<"No";
    
}   
    
    
     

     
   





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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

int res = 0;
string s, t;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s >> t;
    for(int i = 0; i < sz(s); ++i){
        res += s[i] != t[i];
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 3784
import numpy as np


def getInput():
    """

    :return: list of list of str. 1st dim: row, 2nd dim: column.
    """
    separator = ' '
    ret_array = []
    while True:
        try:
            row = input().split(sep=separator)
            ret_array.append(row)
        except EOFError:
            break
    return ret_array


g = getInput()

# number
xyz = np.array(list(map(int, g[0])), dtype=np.int32)
print(np.int32(np.floor((xyz[0] - xyz[2]) / (xyz[1] + xyz[2]))))


Measured memory_bytes: 21900
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
using namespace std;

int main() {
    int a;
    cin >> a;
    cout << a * a * 3 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define taskname "test1"
#define int long long
#define sz(a) static_cast<int>(a.size())
using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    int n;  cin >> n;
    if (n % 2 == 0) cout << n;
    else cout << n * 2;
}


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

#define ENDL '\n'
#define io ios_base::sync_with_stdio(false);cin.tie(0);
#define sayy cout<<"YES"<<ENDL;
#define sayn cout<<"NO"<<ENDL;

int main(){
    io

    int a;
    cin >> a;
    cout << a + pow(a,2) + pow(a,3) << ENDL;

    return 0;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int Q;

int f(int n, int t){
    if(n < 10){
        return t;
    }

    int s = 10, mx = 0;
    while(true){
        int x = n / s, y = n % s;
        if(x == 0){
            break;
        }

        mx = max(mx, x * y);
        s *= 10;
    }

    return f(mx, t + 1);
}

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    std::cin >> Q;

    for(int i=0;i<Q;++i){
        int N;
        std::cin >> N;

        int res = f(N, 0);
        std::cout << res << std::endl;
    }
}



Measured memory_bytes: 3188
#include <iostream>
#include <array>
#include <vector>
#include <climits>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) 
	{
		cin >> a.at(i);
	}
	
	auto result = INT_MIN;

	for (int s : a) {
		for (int e : a) {
			result = max(result, s - e);
		}
	}
	
	cout << result << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class BStringRotation {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();
            String t = in.nextString();

            for (int i = 0; i < s.length(); i++) {
                if ((s.substring(i, s.length()) + s.substring(0, i)).equals(t)) {
                    out.println("Yes");
                    return;
                }
            }

            out.println("No");
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 21204
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	unsigned long long int a,b;
	while(cin>>a>>b){
		int cnt=0;
		for(unsigned long long int k=a;k<=b;k*=2){
			cnt++;
		}
		cout<<cnt<<endl;
	}
}

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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e - a <= k) {
    cout << "Yay!" << endl;
  }
  else {
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
import collections

n = int(input())
li = list(map(int,input().split()))
c = collections.Counter(li)
ans = 0

for item in c.items():
    x = item[0] #要素
    y = item[1] #個数

    if x < y:
        ans += y-x

    if x > y:
        ans += y

print(ans)

Measured memory_bytes: 18676
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;

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

int main(){
	int H,W;
	while(cin>>H>>W,H||W){
		char fld[101][101];
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cin>>fld[i][j];
			}
		}
		int y=0,x=0;
		bool used[101][101]={},loop=false;
		while(true){
			if(used[y][x]==true){
				loop = true; break;
			}
			used[y][x] = true;
			char c = fld[y][x];
			int dir;
			if(c=='^') dir = 0;
			else if(c=='>') dir = 1;
			else if(c=='v') dir = 2;
			else if(c=='<') dir = 3;
			else break;
			y += dy[dir]; x += dx[dir];
		}
		if(loop==true) puts("LOOP");
		else printf("%d %d\n",x,y);
	}
    return 0;
}

Measured memory_bytes: 1176
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;

bool is_same_in_start(const char* super, const char* sub)
{
	for (int i = 0; sub[i] != '\0'; ++i)
		if (super[i] != sub[i])
			return false;
	return true;
}
int main()
{
	char buf[512];
	while (cin.getline(buf, sizeof(buf)))
	{
		const char* src = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
		char bin[512*5];
		memset(bin, 0, sizeof(bin));
		for (int i = 0; buf[i] != '\0'; ++i)
		{
			int t = strchr(src, buf[i]) - src;
			for (int j = 0; j < 5; ++j)
			{
				char c;
				if (t & (1 << j))
					c = '1';
				else
					c = '0';
				bin[i*5 + 4-j] = c;
			}
		}

		const char* dest = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		const char* code[] = { "101", "000000", "000011", "10010001", "010001", "000001"
			, "100101", "10011010", "0101", "0001", "110", "01001", "10011011", "010000"
			, "0111", "10011000", "0110", "00100", "10011001", "10011110", "00101"
			, "111", "10011111", "1000", "00110", "00111", "10011100", "10011101"
			, "000010", "10010010", "10010011", "10010000"
		};
		char dec[512];
		memset(dec, 0, sizeof(dec));
		char* p = bin;
		for (int i = 0; ; ++i)
		{
			int sel = -1;
			for (int j = 0; sel == -1 && j < sizeof(code)/sizeof(code[0]); ++j)
				if (is_same_in_start(p, code[j]))
					sel = j;
			if (sel == -1)
				break;

			p += strlen(code[sel]);
			dec[i] = dest[sel];
		}

		printf("%s\n", dec);
	}

	return 0;
}

Measured memory_bytes: 0
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,q,h,i,j,k,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> n >> q;
	cin >> s;
	vector<ll>		aa(n+1);
	vector<ll>		l(q),r(q);
	c = 0;
	for(i=2;i<=n;i++) {
		if (s[i-2]=='A' && s[i-1]=='C') c++;
		aa[i] = c;
	}
	for(i=0;i<q;i++) cin >> l[i] >> r[i];
	for(i=0;i<q;i++) {
		ans = aa[r[i]] - aa[l[i]];
		//if (aa[l[i]-1] != aa[l[i]]) ans--;
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 5864
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int compress( vector< int >& x,const int w){
  vector< int > xs;
  for(int i = 0; i < x.size() ; i++ ){
    for(int d = -1; d <= 1 ; d++ ){
      int nx = x[i] + d;
      if(0 <= nx && nx < w) xs.push_back(nx);
    }
  }
  sort(xs.begin(),xs.end());
  xs.erase(unique(xs.begin(),xs.end()),xs.end());
  for(int i = 0 ; i < x.size() ; i++ ){
    x[i] = find(xs.begin(),xs.end(),x[i]) - xs.begin();
  }
  return xs.size();
}
int main(){
  int w, h, n;
  const int dy[] = { 1, 0, -1, 0}, dx[] = { 0, 1, 0, -1};
  vector< int > x, y;
  while(cin >> w >> h, w){
    cin >> n;
    x.resize(2 * n), y.resize(2 * n);
    for(int i = 0; i < n; i++){
      cin >> x[i] >> y[i] >> x[n + i] >> y[n + i];
    }
    int neww, newh;
    neww = compress( x, w);
    newh = compress( y, h);
    bool mas[2000][2000] = {{}};
    for(int i = 0; i < n; i++){
      for(int j = x[i]; j < x[n + i]; j++){
        for(int k = y[i]; k < y[n + i]; k++){
          mas[k][j] = true;
        }
      }
    }
    int ret = 0;
    queue< int > quex, quey;
    for(int i = 0; i < newh ; i++ ){
      for(int j = 0; j < neww; j++ ){
        if(!mas[i][j]++){
          ret++;
          quex.push(j), quey.push(i); //あえてBFS
          while(!quex.empty()){
            int x = quex.front(), y = quey.front();
            quex.pop(), quey.pop();
            for(int i = 0 ; i < 4 ; i++ ){
              int ny = y + dy[i], nx = x + dx[i];
              if(ny < 0 || nx < 0 || nx >= neww || ny >= newh) continue;
              if(!mas[ny][nx]){
                quex.push(nx), quey.push(ny);
                mas[ny][nx] = true;
              }
            }
          }
        }
      }
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 5152
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)

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



int main(){
    
    int n,s,sum=0,Min=INF;
    
    cin>>n;
    rep(i,0,n){
        cin>>s;
        sum+=s;
        if(s%10!=0 && s<Min)Min=s;
    }
    if(Min==INF){
        cout<<"0"<<endl;
        return 0;
    }
    if(sum%10==0)sum-=Min;
    cout<<sum<<endl;
        
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
char S[50][52];
int X, Y, dist[50][50], dx[4]={-1,1,0,0}, dy[4]={0,0,-1,1}, q[2555], qed, qst;
int main(){
  int d, i, j, k, ni, nj, res, si, sj;
  rd(X);
  rd(Y);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<X;Lj4PdHRW++){
      rd(S[Lj4PdHRW]);
    }
  }
  for(i=0;i<X;i++){
    for(j=0;j<Y;j++){
      dist[i][j] = -1;
    }
  }
  dist[0][0] = 1;
  q[qed++] = 0;
  while(qst < qed){
    k = q[qst++];
    si = k / Y;
    sj = k % Y;
    for(d=0;d<4;d++){
      ni = si + dx[d];
      nj = sj + dy[d];
      if(0 <= ni  &&  ni < X && 0 <= nj  &&  nj < Y && S[ni][nj] != '#' && dist[ni][nj]==-1){
        dist[ni][nj] = dist[si][sj] + 1;
        q[qed++] = ni*Y+nj;
      }
    }
  }
  if(dist[X-1][Y-1]==-1){
    wt_L(-1);
    putchar_unlocked('\n');
    return 0;
  }
  res = -dist[X-1][Y-1];
  for(i=0;i<X;i++){
    for(j=0;j<Y;j++){
      if(S[i][j]=='.'){
        res++;
      }
    }
  }
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20180208-1

// --- original code ---
// int X, Y;
// char S[50][52];
// 
// int dist[50][50];
// int q[2555], qst, qed;
// int dx[4] = {-1,1,0,0}, dy[4] = {0,0,-1,1};
// {
//   int i, j, k;
//   int d, si, sj, ni, nj;
//   int res;
//   rd(X,Y,S(X));
// 
//   rep(i,X) rep(j,Y) dist[i][j] = -1;
//   dist[0][0] = 1;
//   q[qed++] = 0;
//   while(qst < qed){
//     k = q[qst++];
//     si = k / Y;
//     sj = k % Y;
//     rep(d,4){
//       ni = si + dx[d];
//       nj = sj + dy[d];
//       if(0 <= ni < X && 0 <= nj < Y && S[ni][nj] != '#' && dist[ni][nj]==-1){
//         dist[ni][nj] = dist[si][sj] + 1;
//         q[qed++] = ni*Y+nj;
//       }
//     }
//   }
// 
//   if(dist[X-1][Y-1]==-1){
//     wt(-1);
//     return 0;
//   }
// 
//   res = -dist[X-1][Y-1];
//   rep(i,X) rep(j,Y) if(S[i][j]=='.') res++;
//   wt(res);
// }


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define M 1000003
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+key%(M-1); }

int find(char str[]){
  int i=0,j,ke=getKey(str);
  while(1){
    j=(h1(ke)+h2(ke)*i)%M;
    if(strcmp(H[j],str)==0){
      return 1;
    }
    else i++;
    if(i==M||H[j][0]=='\0') break;
    
  }
  return 0;
  
  
  
}

int insert(char str[]){
  int j,i=0,ke=getKey(str);
  while(1){
    j=(h1(ke)+h2(ke)*i)%M;
    if(H[j][0]=='\0'){
      
      strcpy(H[j],str);
      return j;
    }
    else i++;
    
    if(i==M)break;
  }
}

int main(){
  int i, n  ;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
  
  scanf("%d", &n);
    
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
    
    if ( com[0] == 'i' ){
      insert(str);
    } else {
	  if (find(str)==1){
	    printf("yes\n");
	  } else {
	    printf("no\n");
	    }
    }
  }
  
  return 0;
}

Measured memory_bytes: 14280
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

string A,B;
int ans = 0;

void dfs(int p, string C, int k, int c)
{
	if(p < 0)
	{
		if(c == 0)
		{
			ans = max(ans, atoi(C.c_str()));
		}
		return;
	}
	else
	{
		int calc = A[p] - B[p] - c;
		if(calc >= 0)
		{
			dfs(p - 1, string(1, '0' + calc) + C, k, 0);
		}
		else
		{
			calc += 10;
			dfs(p - 1, string(1, '0' + calc) + C, k, 1);
			if(k)
			{
				dfs(p - 1, string(1, '0' + calc) + C, k - 1, 0);
			}
		}
	}
}

void solve()
{
	int K;
	cin >> A >> B >> K;
	while(A.size() > B.size())
	{
		B = "0" + B;
	}
	while(B.size() > A.size())
	{
		A = "0" + A;
	}
	dfs(A.size() - 1, "", K, 0);
	cout << ans << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;

int main() {
	int l, r, d;
	cin >> l >> r >> d;
	cout << r / d - (l - 1) / d; 
}


Measured memory_bytes: 3592
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int ans = 0;

        switch (s) {
            case "SUN":
                ans = 7;
                break;
            case "MON":
                ans = 6;
                break;
            case "TUE":
                ans = 5;
                break;
            case "WED":
                ans = 4;
                break;
            case "THU":
                ans = 3;
                break;
            case "FRI":
                ans = 2;
                break;
            case "SAT":
                ans = 1;
        }
        System.out.println(ans);
    }
}


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

int main() {
  int N,X,M,m;
  m=1000;
  cin>>N>>X;
  	for(int i=0;i<N;i++){
      cin>>M;
      X-=M;
      	if(m>M){
          m=M;
        }
    }
  cout<<N+ X/m<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	string p, q;
	for(int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		p += (char)('0' + x);
	}
	
	for(int i = 0; i < n; ++i) {
		int y;
		cin >> y;
		q += (char)('0' + y);
	}
	
	vector<int> val(n);
	for(int i = 0; i < n; ++i) {
		val[i] = i + 1;
	}
	
	int a = 0, b = 0;
	int cnt = 0;
	
	do {
		string tmp;
		for(int i = 0; i < n; ++i) {
			tmp += (char)('0' + val[i]);
		}
		
		if( p == tmp ) a = cnt;
		if( q == tmp ) b = cnt;
		
		cnt++;
		
	}while( next_permutation(val.begin(), val.end()) );
	
	cout << abs(a - b) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> ppiii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> query;

string s;
int dp[301][301][301];
bool seen[301][301][301];

int solve(int lhs, int rhs, int k) {
  if(lhs > rhs) return 0;
  if(lhs == rhs) return 1;
  if(seen[lhs][rhs][k]) return dp[lhs][rhs][k];
  seen[lhs][rhs][k] = true;
  dp[lhs][rhs][k] = max(solve(lhs+1, rhs, k), solve(lhs, rhs-1, k));
  if(s[lhs] == s[rhs]) dp[lhs][rhs][k] = max(dp[lhs][rhs][k], 2 + solve(lhs+1, rhs-1, k));
  else if(k > 0) {
    dp[lhs][rhs][k] = max(dp[lhs][rhs][k], 2 + solve(lhs+1, rhs-1, k-1));
  }
  return dp[lhs][rhs][k];
}

void solve() {
  cin >> s;
  int k;
  cin >> k;
  cout << solve(0, s.size()-1, k) << "\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << " ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 133376
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll N,M; cin >> N >> M;
    vector<ll> d;
    for(ll i=1;i*i<=M;i++){
        if(M%i==0){
            d.emplace_back(i);
            d.emplace_back(M/i);
        }
    }
    sort(all(d));
    reverse(all(d));
    for(auto v : d){
        ll num = M / v;
        if(num >= N){
            cout << v << endl;
            return 0;
        }
    }
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  if (s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }

  return 0;
}


Measured memory_bytes: 3624
import qualified Data.IntMap.Lazy as MA

main = do
  [_, m] <- map read . words <$> getLine :: IO [Int]
  xs <- map ((\[a, b] -> (read a, read b)) . words) . lines <$> getContents :: IO ([(Int, Int)])
  let ab = MA.toList $ foldr (\(a, b) mp -> MA.insertWith (+) a b mp) MA.empty xs
  putStrLn . show $ buy ab (0, m)

buy :: [(Int, Int)] -> (Int, Int) -> Int
buy ((a, b):xs) (total,req)
  | req >= b = buy xs (total + a * b, req - b)
  | True = total + a * req
buy [] (total, _) = total


Measured memory_bytes: 49532
#include<iostream>
#include<vector>
using namespace std;
int main(){

  int n;
  cin >> n;

  int C[n], V[n];
  for(int i = 0; i < n; i++){
    cin >> V[i];
  }
  for(int i = 0; i < n; i++){
    cin >> C[i];
  }
  int s[n];
  for(int j = 0; j < n; j++){
    s[j] = V[j] - C[j];
  }

  int ans = 0;

  for(int q = 0; q < n; q++){
    if(s[q] >= 0) ans += s[q];
  }

  cout << ans << endl;

}

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

a.sort(reverse=True)

num = None
hen = []
en = 0

for i in a:
    if en == 2:break
    if num == i:
        hen.append(num)
        num = None
        en += 1
    else:
        num = i
        
if en == 2:
    print(hen[0]*hen[1])
else:
    print(0)

Measured memory_bytes: 14224
A, B, K = map(int, input().split())
r = []
for i in range(A, min(A+K, B+1)):
    r.append(i)
for i in range(max(B-K+1, A), B+1):
    r.append(i)
for i in sorted(list(set(r))):
    print(i)


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

using namespace std;

struct KeepH{
        int h;
        int num;
        bool operator<(const KeepH &another) const
        {
        return h < another.h;
        };
};

int main(){
        int N;
        int x[110],y[110];
        KeepH H[110];
        int h,ZeroCount=0;

        cin>>N;
        for(int i=0; i<N; i++){
                cin>>x[i]>>y[i]>>h;
                H[i].h=h;
                H[i].num=i;
                if(h==0)ZeroCount++;
        }

        sort(H,H+N);

        long long int keepH;
        for(int i=0; i<=100; i++){
                for(int j=0; j<=100; j++){
                        bool fl=true;
                        keepH=H[ZeroCount].h+abs(x[H[ZeroCount].num]-i)+abs(y[H[ZeroCount].num]-j);
                        for(int r=ZeroCount+1; r<N; r++){
                                long long int culH=H[r].h+abs(x[H[r].num]-i)+abs(y[H[r].num]-j);
                                if(keepH!=culH) {
                                        fl=false;
                                        break;
                                }
                        }
                        if(!fl){
                                continue;
                        }
                        for(int r=0; r<ZeroCount; r++){
                                long long int culh=keepH-abs(x[H[r].num]-i)-abs(y[H[r].num]-j);
                                if(culh>0) {
                                        fl=false;
                                        break;
                                }
                        }
                        if(!fl){
                                continue;
                        }

                        cout<<i<<" "<<j<<" "<<keepH<<endl;
                        return 0;
                }
        }
        return 0;
}


Measured memory_bytes: 256