akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;

int main() {
    int n; cin >> n;
    map<int,int> m;
    for(int i = 0;i < n;i++){
        int x; cin >> x;
        auto z = m.find(x);
        if(m.end()==z){
            m.insert(make_pair(x,1));
        }else{
            z->second++;
        }
    }
    int ans = 0;
    for(auto a:m){
        if(a.first < a.second){
            ans += a.second-a.first;
        }else if(a.first > a.second){
            ans += a.second;
        }
    }
    cout << ans;
}



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

int main() {
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if(r <= x && x <= (w - r) && r <= y && y <= (h - r))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1156
import fractions
s=input().split()
a,b,c,d=int(s[0]),int(s[1]),int(s[2]),int(s[3])
g=fractions.gcd(c,d)
l=(d*c)//g
e=-((a-1)//c)+b//c-((a-1)//d)+b//d+(a-1)//l-(b//l)
print(b-a+1-e)


Measured memory_bytes: 5048
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

signed main() {
    int D, G;
    cin >> D >> G;
    vector<int> p(D);
    vector<int> c(D);
    for (int i = 0; i < D; i++) {
        cin >> p[i] >> c[i];
    }

    int ret = INF;

    for (int i = 0; i < (1 << D); i++) {
        int score = 0;
        int num = 0;
        int max_idx = -1;

        for (int j = 0; j < D; j++) {
            if ((i >> j) & 1) {
                score += p[j] * (j+1) * 100 + c[j];
                num += p[j];
            } else {
                max_idx = max(max_idx, j);
            }
        }

        if (max_idx == -1) {
            if (score >= G) ret = min(ret, num);
            continue;
        }

        if (score + (max_idx + 1) * 100 * (p[max_idx] - 1) >= G) {
            if (score >= G) {
                ret = min(ret, num);
            } else {
                num += ceil(1.0 * (G - score) / ((max_idx + 1) * 100.0));
                ret = min(ret, num);
            }
        }

    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;
 

int main() {
    ios_base::sync_with_stdio(false);
    
    int n;
    string s; 
    cin >> n;
    cin >> s;
    vector<int> r,g,b;
    rep(i,n) {
        if (s[i]=='R') r.push_back(i);
        else if (s[i]=='G') g.push_back(i);
        else b.push_back(i);
    }
    ll ans=r.size()*g.size()*b.size();
    rep(i,n) {
        repr(j,i+1,n-1) {
            int k=j+(j-i);
            if (k>=n) continue;
            if (s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i]) --ans;
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3644
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX_N = 100000;

int main(int argc, char const *argv[])
{
	int n, v[MAX_N];
	cin >> n;
	map<int, int> mpe, mpo;
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}

	map<int, int> emp, omp;
    for (int i = 0; i < n; i+=2) emp[v[i]]++;
    for (int i = 1; i < n; i+=2) omp[v[i]]++;
    vector<pair<int, int> > evec, ovec;
    for (auto x : emp) {
    	evec.push_back(make_pair(x.second, x.first));
    }
    for (auto x : omp) {
    	ovec.push_back(make_pair(x.second, x.first));
    }
    sort(evec.begin(),evec.end());
    sort(ovec.begin(),ovec.end());
    reverse(evec.begin(), evec.end());
    reverse(ovec.begin(), ovec.end());
    int ans = 0;
    if (evec[0].second==ovec[0].second)
    {
    	if (n == 2) ans = 1;
    	else {
    		int e0 = 0, o0 = 0, e1 = 0, o1 = 0;
    		for (int i = 0; i < evec.size(); ++i)
    		{
    			if (i==0) e1 += evec[i].first;
    			else if (i == 1) e0 += evec[i].first;
    			else {
    				e0 += evec[i].first;
    				e1 += evec[i].first;
    			}
    		}
    		for (int i = 0; i < ovec.size(); ++i)
    		{
    			if (i==0) o1 += ovec[i].first;
    			else if (i == 1) o0 += ovec[i].first;
    			else {
    				o0 += ovec[i].first;
    				o1 += ovec[i].first;
    			}
    		}
    		// if (e0 < o0) ans = e1 + o0;
    		// else ans = e0 + o1;
    		ans = min(e1+o0, e0+o1);
    	}
    }
    else {
    	for (int i = 1; i < evec.size(); ++i)
    	{
    		ans += evec[i].first;
    	}
    	for (int i = 1; i < ovec.size(); ++i)
    	{
    		ans += ovec[i].first;
    	}
    }

    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6520
#include <stdio.h>

int main()
{
  int n, i, ans = 3000000, count = 0, d;
  char a[300000];
  int l[300000], r[300000];

  scanf("%d", &n);
  scanf("%s", a);

  for(i=0; i<n; i++){
    if(a[i]=='W')count++;
    l[i] = count;
    /*printf("%d\n", l[i]);*/
  }
 
  count = 0;

  for(i=n-1; i>=0; i--){
    if(a[i]=='E')count++;
    r[i] = count;
    /*printf("%d\n", r[i]);*/
  }

   for(i=0; i<n; i++){
    if(i==0) d = r[1];
    else if(i==n-1) d = l[n-2];
    else d = l[i-1] + r[i+1];

    if(ans>d)ans = d;
  } 
  
  printf("%d\n", ans);
  
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    
    if (r - l == 0) {
      sum += 1;
    } else {
      sum += r - l + 1;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
//om namah shivaay
//faith over fear
//no one wants to die,yet death is the destination we all share 

#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
    double r;
    cin>>r;
    printf("%0.2f",2*PI*r);
}

Measured memory_bytes: 3760
#include <algorithm>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")" << endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long> vl;
typedef vector<vector<long>> vvl;
typedef vector<string> vs;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec)
{
    os << "[";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template <typename T>
T input()
{
    T t;
    cin >> t;
    return t;
}

template <typename T>
vector<T> input(const int N)
{
    vector<T> v(N);
    repeat(i, N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b)
{
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b)
{
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod)
{
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod)
{
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod)
{
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod)
{
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod)
{
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x)
    {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main()
{
    int N;
    cin >> N;
    vi V = input<int>(N);
    vi C = input<int>(N);
    long long diff = 0;

    long long total = 0;
    for (int i = 0; i < N; ++i) {
        diff = V[i] - C[i];
        if (diff > 0) {
            total += diff;
        }
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    N, L = map(int, input().split())

    apples = range(L, L + N)

    ans = sum(apples)
    if apples[0] * apples[-1] <= 0:
        # 区間に0を含むので, それを食べればよい
        pass
    else:
        # 以後, 区間の両端の積は正なので, 区間内の符号はすべて等しい
        if apples[0] > 0:
            # すべて正なので, apples[0]が絶対値最小で最適
            ans -= apples[0]
        else:
            # すべて負なので, apples[-1]が絶対値最小で最適
            ans -= apples[-1]
    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 2940
// Problem : Z - Frog 3
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_z
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

template<class T>
T maxm(initializer_list <T> l){
	T ans=-INF;
	for(T i:l)
	ans=max2(ans,i);
	return ans;
}

struct line
{
	int m,b;
};

double intersect(line x,line y)
{
	if(x.m==y.m) return INF;
	return (double)(y.b-x.b)/(double)(x.m-y.m);
}

vector<line> st;
vector<long double> points;

int eval(int x,line y)
{
	return x*y.m+y.b;
}

void addline(line x)
{
	if(st.empty())
	{
		st.pb(x);
		return;
	}
	if(size(st)==1)
	{
		points.pb(intersect(x,st[0]));
		st.pb(x);
		return;
	}
	while(size(points))
	{
		line l1=st.back();
		st.pop_back();
		if(intersect(x,st.back())<=points.back())
		{
			points.pop_back();
		}
		else
		{
			st.pb(l1);
			break;
		}
	}
	points.pb(intersect(x,st.back()));
	st.pb(x);
}

int findbest(int x)
{
	int ind=lower_bound(all(points),x)-points.begin();
	return eval(x,st[ind]);
}
int dp[200001],h[200001];
void solve()
{
int n,c;
cin>>n>>c;
for(int i=1;i<=n;i++)
cin>>h[i];
dp[1]=0;
line l;
l.m=-2*h[1];
l.b=h[1]*h[1];
addline(l);
for(int i=2;i<=n;i++)
{
	dp[i]=findbest(h[i])+h[i]*h[i]+c;
	l.m=-2*h[i];
	l.b=h[i]*h[i]+dp[i];
	addline(l);
}
cout<<dp[n];
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
}


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

//省略形
#define rep(i,n) for(auto i=0; i<n ; ++i)
#define REP(i,a,b) for(auto i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//よく使う定数
const int INF = 1e9;
const int MOD = 1e9+7;
//逆元
const int INV = 1e9+5;

//UnionFindTree
struct union_find{
  vector<int> data;
  union_find(int size) : data(size , -1) { }

  void merge(int x , int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(data[y] < data[x]) swap(x , y);
    data[x] += data[y];
    data[y] = x;
    return; 
  }

  bool same(int x , int y){
    x = root(x) , y = root(y);
    return x == y;
  }

  int root(int x){
    return data[x] < 0 ? x : (data[x] = root(data[x]));
  }

  int size(int x){
    return -data[root(x)];
  }
};

//プロトタイプ宣言
void faster(void);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T modpow(T , T , T);
bool is_palindrome(string);

//メモ
//最大公約数:__gcd　|　最小公倍数:__lcm
//回文は反転させて一致すればよい


int main(){
  ll x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x  << " " << y;
}























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//繰り返し自乗法
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//繰り返し自乗法(剰余)
template <class T>
T modpow(T x , T y , T mod){
  if(y == 0) return 1;
  if(y%2 == 1){
    ll temp = modpow(x,y-1,mod);
    return temp*x%mod;
  }
  else{
    ll temp = pow_mod(x,y/2,mod);
    return temp*temp%mod;
  }
}

bool is_palindrome(string s){
    string t(s.rbegin(),s.rend());
    return s == t;
}

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

class Program
{
    static void Main(string[] args)
    {
        var NKQ = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, K, Q) = (NKQ[0], NKQ[1], NKQ[2]);
        var A = new int[Q];
        for (int i = 0; i < Q; i++)
            A[i] = int.Parse(ReadLine());

        var ansCount = new int[N];
        var totalAnsCount = 0;
        for (int i = 0; i < Q; i++)
        {
            ansCount[A[i] - 1]++;
            totalAnsCount++;
        }

        for (int i = 0; i < N; i++)
        {
            var point = K - totalAnsCount + ansCount[i];

            if (0 < point)
                WriteLine("Yes");
            else
                WriteLine("No");
        }
    }
}


Measured memory_bytes: 32148
#include <stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int a[n];
  int i,b;
  for(i=0;i<n;i++){
    scanf("%d",&b);
    a[i] = b;
  }
  int max = 0;
  int count = 0;
  for(i=0;i<n;i++){
    if(a[i] >= max){
      count++;
      max = a[i];
    }
  }

  printf("%d\n",count);
}

Measured memory_bytes: 128
// Problem : A - Go to School
// Contest : Virtual Judge - woah
// URL : https://vjudge.net/contest/391014#problem/A
// Memory Limit : 1048 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#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;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n;
	cin>>n;
	vpi a(n);
	loop(i,n)
	{
		cin>>a[i].f;
		a[i].s=i+1;
	}
	sort(all(a));
	loop(i,n)
	cout<<a[i].s<<" ";
	
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3996
n, total = map(int, input().split())
flag1 = False
flag2 = True
for i in range(n+1):
    x = i
    for j in range(n+1-x):
        y = j
        z = n - x - y
        if x*10000 + y*5000 + z*1000 == total:
            flag1 = True
            break
    if flag1:
        print(x, y, z)
        flag2 = False
        break

if flag2:
    print("-1 -1 -1")


Measured memory_bytes: 3064
/*
 * main.cpp
 *
 *  Created on: 2020/04/09
 *      Author: SkAaO
 */

#include <iostream>

using namespace std;

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

	int min_f = 1;

	for(int i = 0; i < N; i++){
		min_f = min(min_f + K, min_f * 2);
	}

	cout << min_f << endl;

	return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt(); //りんごの個数
		int l = stdIn.nextInt(); 
		
		int cnt = 0;
		int min = Integer.MAX_VALUE;
		int index = 0;
		int[] flavor = new int[n];
		
		for(int i = 0; i < n; i++) {
			cnt += l+i;
			int abs = Math.abs(l+i);
			flavor[i] = l+i;
			
			if(min > abs) {
				min = abs;
				index = i; 
			}
			
			
		}
		int ans = cnt-flavor[index];
		System.out.println(ans);
	}

}


Measured memory_bytes: 22612
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
#include <assert.h>
#include <cstring>
#include <set>
using namespace std;

typedef long long ll;

int main()
{
    ll n, d;
    cin >> n >> d;
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        if(x*x + y*y <= d*d)
        {
            ans++;
        }
    }
    cout << ans << "\n";
    
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
using namespace std::literals::chrono_literals;
using namespace std::literals::string_literals;
using ll = long long;

#define repi(i, s, n) for (long long i {s}, i##_len{n}; i < i##_len; ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) std::begin(x), std::end(x)

namespace xmaho
{
inline namespace input
{
template<typename T>
T get_value(std::istream& is = std::cin);
template<typename C>
C get_container(std::istream& is = std::cin, typename C::size_type length = std::numeric_limits<typename C::size_type>::max());
}
}
namespace xmaho
{
inline namespace integer
{
template<typename C>
constexpr auto ssize(const C& c) noexcept(noexcept(c.size()))
  -> typename std::common_type<std::ptrdiff_t, typename std::make_signed<decltype(c.size())>::type>::type;
template <class T, ptrdiff_t N>
constexpr std::ptrdiff_t ssize(const T (&)[N]) noexcept;
}
}
using namespace xmaho;

int main()
{
  const auto h {get_value<ll>()};
  const auto a {get_value<ll>()};

  cout << ((h + (a - 1))/ a) << '\n';
  return 0;
}

class initalization
{
  class custom_numpunct: public std::numpunct<char>
  {
  public:
    using numpunct::numpunct;
  protected:
    std::string do_truename() const override { return "Yes"; }
    std::string do_falsename() const override { return "No"; }
  };

public:
  initalization()
  {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.imbue(std::locale(std::cout.getloc(), new custom_numpunct{}));
    std::cout << std::boolalpha << std::fixed << std::setprecision(15);
  }
} initalize;

template<typename T>
T xmaho::input::get_value(std::istream& is)
{ T v {}; is >> v; return v; }

template<typename C>
C xmaho::input::get_container(std::istream& is, typename C::size_type length)
{
  C v {};
  if (length != std::numeric_limits<typename C::size_type>::max())
    v.reserve(length);
  typename C::value_type e {};
  for (auto i {length}; i != 0 && is >> e; --i)
    v.push_back(std::move_if_noexcept(e));
  return v;
}

template<typename C>
constexpr auto xmaho::integer::ssize(const C& c) noexcept(noexcept(c.size()))
  -> typename std::common_type<std::ptrdiff_t, typename std::make_signed<decltype(c.size())>::type>::type
{ return c.size(); }

template <class T, ptrdiff_t N>
constexpr std::ptrdiff_t xmaho::integer::ssize(const T (&)[N]) noexcept
{ return N; }


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <chrono>
#include<assert.h>
#define MAX 1000001
#define pii pair<int, int>
#define F first
#define S second
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl "\n"
#define int long long
#define forn(i, n) for (long long i = 0; i < long long(n); ++i)
#define IOS                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
using namespace std;
inline bool is_palindrome(const string &s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
int32_t main()
{
    auto start = chrono::high_resolution_clock::now();
    IOS
    int n;
    cin>>n;
    vector<int> dp(3);
    for(int i=0;i<n;i++){
        if(i==0){
            int a,b,c;
            cin>>a>>b>>c;
            dp[0] = a,dp[1] = b,dp[2]  =c;
        }
        else{
            int a,b,c;
            cin>>a>>b>>c;
            int x = dp[0],y = dp[1],z = dp[2];
            dp[0] = a + max(y,z);
            dp[1] = b + max(x,z);
            dp[2] = c + max(x,y);
        }
    }
    cout<<max({dp[0],dp[1],dp[2]});
    auto end = chrono::high_resolution_clock::now();
    double time_taken = chrono::duration_cast<chrono::nanoseconds>(end - start).count();
    time_taken *= 1e-9;
    //cout << fixed << time_taken;
    return 0;
}

Measured memory_bytes: 256
def bisect_right_rev(lst, x):
    if lst[0] < x:
        return 0
    if x <= lst[-1]:
        return len(lst)

    a = 0
    b = len(lst) - 1

    while abs(b - a) > 1:
        c = (a + b) // 2

        if lst[c] < x:
            b = c
        else:
            a = c
    
    return b

N = int(input())
A = [int(input()) for _ in range(N)]
seq = []

for i in range(N):
    if len(seq) == 0:
        seq.append(A[i])
    else:
        ind = bisect_right_rev(seq, A[i])
        if ind == len(seq):
            seq.append(A[i])
        else:
            seq[ind] = A[i]

print(len(seq))

Measured memory_bytes: 81732
#include<stdio.h>
int main(void)
{
	int n,h[100000],k=0,i;
	scanf("%d", &n);
	for(i=1; i<=n; i++)
	{
		scanf("%d", &h[i]);
		if(h[i-1]<h[i]&&i>0)
		h[i]--;
		if(h[i-1]>h[i])
		k=1;
	}
	if(k==0)
	printf("Yes\n");
	else
	printf("No\n");
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 99999999999999
#define MAX_V 100010
#define MAX_E 2019

    /*Solve*/

int main(){
    int N;
    cin >> N;
    int x[110],y[110],h[110];
    int H;
    bool OK=0;
    rep(i,N){
        cin >> x[i] >> y[i] >> h[i];
    }
    rep(cx,101)rep(cy,101){
        rep(i,N){
            if(h[i]){
                H=h[i]+abs(cx-x[i])+abs(cy-y[i]);
                OK=1;
            }
        }
        rep(i,N){
            if (max(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i])
                OK=0;
        }
        if(OK){cout << cx << " " << cy << " " << H;
            return 0;}
    }
}

Measured memory_bytes: 256
from collections import Counter
S = input()
C = Counter(S)
#print(C)
if len(S) == 1:
  print("YES")
elif len(S) == 2:
  if S[0] != S[1]:
    print("YES")
  else:
    print("NO")
else:
  if len(C) <= 2:
    print("NO")
  elif abs(C["a"] - C["b"]) > 1 or abs(C["b"] - C["c"]) > 1 or abs(C["c"] - C["a"]) > 1:
    print("NO")
  else:
    print("YES")

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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> f(N + 1, 0);
    for (int x = 1; x <= 100; x++) {
        for (int y = 1; y <= 100; y++) {
            for (int z = 1; z <= 100; z++) {
                int n = x * x + y * y + z * z + x * y + y * z + z * x;
                if (n > N) continue;
                f[n]++;
            }
        }
    }
    for (int i = 1; i <= N; i++) cout << f[i] << "\n";
}

Measured memory_bytes: 3588
t = []
x = []
y = []
N = int(input())
s = []
 
for i in range(N):
    t1, x1, y1 = [int(i) for i in input().split()]
    t.append(t1)
    x.append(x1)
    y.append(y1)
 
for i in range(N):
    if i == 0 and t[i] < abs(x[i]) + abs(y[i]):
        s.append(0)
    elif i > 0 and t[i] - t[i - 1] < abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]):
        s.append(0)
    else:
        if (t[i] % 2 == 1 and x[i] % 2 == 0 and y[i] % 2 == 0) or (t[i] % 2 == 1 and x[i] % 2 == 1 and y[i] % 2 == 1):
            s.append(0)
        elif (t[i] % 2 == 0 and x[i] % 2 == 1 and y[i] % 2 == 0) or (t[i] % 2 == 0 and x[i] % 2 == 0 and y[i] % 2 == 1):
            s.append(0)
        else:
            s.append(1)
 
for i in s:
    if i == 0:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 12560
using System;
using System.Collections.Generic;

namespace Topcoderhenomiti
{
    class Program
    {
        static void Main(string[] args)
        {
            //OhgasFotune.run();
            //new KeitaiMessage().run();
            //MakePurseLight.run();
            AOJ201.solve();
        }
    }

    class AOJ201
    {
        class item
        {
            public string name;
            public int v;
            public List<item> components;

            private int min_val = 0;

            public item()
            {
                components = new List<item>();
            }
            public int minVal()
            {
                if (min_val > 0)
                {
                    return min_val;
                }

                if (components.Count == 0)
                {
                    min_val = v;
                }
                else
                {
                    int sum = 0;
                    foreach (item i in components)
                    {
                        sum += i.minVal();
                    }
                    min_val = sum < v ? sum : v;
                }

                return min_val;
            }
        }

        public static void solve()
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) return;
                solve2(n);
            }
        }

        public static void solve2(int n)
        {
            char[] delimi = { ' ' };



            //item情報取得
            List<item> items = new List<item>(n);
            for (int i = 0; i < n; i++)
            {
                item a = new item();
                string[] str = Console.ReadLine().Split(delimi);
                a.name = str[0];
                a.v = int.Parse(str[1]);
                items.Add(a);
            }

            //レシピ取得
            int m = int.Parse(Console.ReadLine());
            for (int i = 0; i < m; i++)
            {
                string[] str = Console.ReadLine().Split(delimi);
                foreach (item it in items)
                {
                    if (it.name == str[0])
                    {
                        for (int j = 2; j < str.Length; j++)
                        {
                            foreach (item in_it in items)
                            {
                                if (in_it.name == str[j])
                                {
                                    it.components.Add(in_it);
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }

            //解答
            string hoge = Console.ReadLine();
            foreach (item it in items)
            {
                if (it.name == hoge)
                {
                    Console.WriteLine(it.minVal());
                }
            }
        }
    }
}

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

int main()
{
    int N;
    cin >> N;
    vector<long long> A(N, 0);
    for (int i = 0; i < N;++i){
        long long a;
        cin >> a;
        A[i] = a - i;
    }

    sort(A.begin(), A.end());
    long long b = A[N / 2];

    long long ans = 0;
    for (int i = 0; i < N; ++i){
        ans += abs(A[i] - b);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
		 
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String[] reversePolish = s.nextLine().split(" ");
		System.out.println(evaluate(reversePolish));
	}
	 
	public static int evaluate(String[] reversePolish) {
	 
		Stack<String> stack = new Stack<String>();
	 
		for (String t : reversePolish) {
			if (!t.equals("+") && !t.equals("-") && !t.equals("*") && !t.equals("/")) {
				stack.push(t);
			} else {
				int num1 = Integer.valueOf(stack.pop());
				int num2 = Integer.valueOf(stack.pop());
				switch (t) {
				case "+":
					stack.push(String.valueOf(num1 + num2));
					break;
				case "-":
					stack.push(String.valueOf(num2 - num1));
					break;
				case "*":
					stack.push(String.valueOf(num1 * num2));
					break;
				case "/":
					stack.push(String.valueOf(num2 / num1));
					break;
				}
			}
		}
		int answer = 0;
		answer = Integer.valueOf(stack.pop());
	 
		return answer;
	}
}


Measured memory_bytes: 26184
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

fr r = map head . group $ [(r-100) `div` 100, (r-1) `div` 100]
ft t = map head . group $ [t `div` 30, (t+29) `div` 30]
f r t = (\i j -> 5 * i + j + 1) <$> ft t <*> fr r


main = getInt >>= flip replicateM getInts >>= mapM_ (putStrLn . sjoin . apply2 f)



Measured memory_bytes: 4072
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();

		if (A*B%2 == 0) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}

	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N, K;
    int sum = 0;
    cin >> N >> K;
    int x[N];
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }

    for (int i = 0; i < N; i++) {
        int A = abs(x[i] - 0);
        int B = abs(x[i] - K);
        if (A > B) {
            sum += 2 * B;
        } else if (A < B) {
            sum += 2 * A;
        } else if (A == B) {
            sum += 2 * A;
        }
    }

    cout << sum << endl;
    return 0;
}


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

using namespace std;

int main(){

	int a;
	char n;
	string z = "abcdefghijklmnopqrstuvwxyz";

	cin>> n;

	a = int(n - '0' + 1);

	//n = a;

	//cout << a << endl;
	cout << z[a-49] << endl;

}


Measured memory_bytes: 256
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 100000001
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int dp[120][1050];
bool my_compare(pair<ll, string> a, pair<ll , string> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         //return a.first < b.first; // 昇順
        return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    //double mini=INF;
    int maxi=0,f=0,sum=0,mini=INF;
    string str,str1,str2;
    int i,m;
    int n;
    int a,b,d,c;
    int e,weight;
    cin>>m;
    vector<ll> beki;
    rep(i,40){
        ll tmp=i;
        rep(j,40){
            tmp*=i;
            if(tmp<2000) beki.push_back(tmp);
        }
    }
    sort(beki.begin(),beki.end());

    auto po=lower_bound(beki.begin(),beki.end(),m);
    if(*po!=m) --po;
    cout<<*po<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int each_sum(int n) {
  auto sum = 0;

  while(n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(int argc, char *argv[])
{
  int n, a, b;
  cin >> n >> a >> b;

  int total = 0;

  for (auto i = 1; i <= n; ++i) {
    int sum = each_sum(i);
    if (a <= sum && sum <= b) {
      total += i;
    }
  }

  cout << total;
  return 0;
}

Measured memory_bytes: 256
//       In the name of         ****                      God                     ****

/*

Copyright (C)          JadedBeast

                                   Morocco

created : 10/3/2019

*/

#include <bits/stdc++.h>

using namespace std;
const unsigned int mod =1e9+7;
inline void Boost() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
int H,W;
char m[1001][1001];
int DP[1001][1001];
long long dp(int h,int w){
	if(h==H && w==W)
		return 1;
	if(m[h][w]=='#')
		return DP[h][w]=0;
	if(h>H || w>W )
		return 0;
	if(DP[h][w]!=-1)
		return DP[h][w];
	if(h<H || w<W)
		return DP[h][w]=(dp(h+1,w)+dp(h,w+1))%mod;

	return 0;

}


int main() {
	Boost();
	
	cin >> H >> W;



	for (int i=1 ;i<=H ;i++)
		for(int j=1 ;j<=W;j++)
			cin >> m[i][j];

	memset(DP,-1,sizeof(DP));


	cout << dp(1,1)<<endl;

    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)

#define each(it, c) \
    for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x) cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x[5];
    rep(i, 5) cin >> x[i];
    rep(i, 5) if (x[i] == 0) cout << i + 1 << endl;
}

Measured memory_bytes: 3636
import math

def plot(x,y):
    print(f'{x:.8f} {y:.8f}')

def koch(n, x1,y1,x2,y2):
    if n==0:
        plot(x1,y1)
        return
    sx=(2*x1+x2)/3
    sy=(2*y1+y2)/3
    tx=(x1+2*x2)/3
    ty=(y1+2*y2)/3
    ux=(tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
    uy=(tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
    koch(n-1, x1,y1, sx,sy)
    koch(n-1, sx,sy, ux,uy)
    koch(n-1, ux,uy, tx,ty)
    koch(n-1, tx,ty, x2,y2)
    
    
n=int(input())
koch(n, 0,0, 100,0)
plot(100,0)


Measured memory_bytes: 5748
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int a[]=new int[3001];
int b[]=new int[3001];
int x=0;
do{
	a[x]=scan.nextInt();
	b[x]=scan.nextInt();
	if(a[x]==0&&b[x]==0)break;
	x++;
}while(true);
x=0;
do{
	if(a[x]==0&&b[x]==0)break;
	if(a[x]<b[x]){
		System.out.println(a[x]+" "+b[x]);
	}
	else{
		System.out.println(b[x]+" "+a[x]);
	}
	x++;
}while(true);
	}
}

Measured memory_bytes: 36332
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		int i, j, min, w, cnt=0;
		for(i=0; i<N; i++){
			A[i] = sc.nextInt();
		}
		for(i=0; i<N-1; i++){
			min = i;
			for(j=i+1; j<N; j++){
				if(A[min]>A[j]) min = j;
			}
			if(min!=i){
				w      = A[i];
				A[i]   = A[min];
				A[min] = w;
				cnt++;
			}
		}
		for(i=0; i<N; i++){
			if(i!=0) System.out.print(" ");
			System.out.print(A[i]);
		}
		System.out.println();
		System.out.println(cnt);
	}
}

Measured memory_bytes: 19632
#include <iostream>
#include <unordered_map>

using namespace std;

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

  unordered_map<char, char> s2t, t2s;

  for (int i = 0; i < s.size(); i++) {
    if (s2t.find(s[i]) != s2t.end()) {
      if (s2t[s[i]] != t[i]) {
	cout << "No" << endl;
	exit(0);
      }
    } else {
      s2t[s[i]] = t[i];
    }

    if (t2s.find(t[i]) != t2s.end()) {
      if (t2s[t[i]] != s[i]) {
	cout << "No" << endl;
	exit(0);
      }
    } else {
      t2s[t[i]] = s[i];
    }
  }

  cout << "Yes" << endl;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    //dp[i][j] 鍵1-iを使ってjの箱を開ける最小値
    int N, M; cin >> N >> M;
    int states = pow(2, N);
    int dp[states];
    int A[M];
    int B[M] = {};
    rep(i, M){
        int a, b; cin >> a >> b;
        A[i] = a;
        rep(j, b){
            int c; cin >> c;
            B[i] += pow(2, c-1);
        }
    }
    rep(i, states) dp[i] = mod;
    dp[0] = 0;
    rep(s, states){
        rep(j, M){
            int t = s | B[j];
            dp[t] = min(dp[t], dp[s] + A[j]);
        }
    }
    if(dp[states-1] != mod) cout << dp[states-1] << endl;
    else cout << -1 << endl;
    //rep(i, M) {rep(j, states) cout << dp[i][j] << " "; cout << endl;}
    return 0;
}

void solve(){}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, n) for (int i = 1; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

constexpr int mod = 1000000007;
struct ModInt {
    lint x;
    ModInt (lint a) : x((a % mod + mod) % mod) {}
    ModInt operator-() const {
        return ModInt(-x);
    }
    ModInt &operator+=(const ModInt &a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &a) {
        if ((x -= a.x) < 0) x += mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &a) {
        (x *= a.x) %= mod;
        return *this;
    }
    ModInt operator+(const ModInt &a) const {
        ModInt res(*this);
        return res += a;
    }
    ModInt operator-(const ModInt &a) const {
        ModInt res(*this);
        return res -= a;
    }
    ModInt operator*(const ModInt &a) const {
        ModInt res(*this);
        return res *= a;
    }
    ModInt pow(lint t) const {
        if (!t) return 1;
        ModInt a = pow(t / 2);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    ModInt inv() const {
        return pow(mod - 2);
    }
    ModInt &operator/=(const ModInt &a) {
        return (*this) *= a.inv();
    }
    ModInt operator/(const ModInt &a) const {
        ModInt res(*this);
        return res /= a;
    }
    friend ostream &operator<<(ostream &os, const ModInt &a){
        os << a.x;
        return os;
    }
};

int main() {
    int N, K;
    cin >> N >> K;
    
    vector<ModInt> G;
    rep(i, K + 1) G.push_back(ModInt{0});
    ModInt ans = 0;
    for (int i = K; i >= 1; --i) {
        ModInt M(K / i);
        G[i] = M.pow(N);
        for (int j = 2; i * j <= K; ++j) G[i] -= G[i * j];
        ans += G[i] * ModInt{i};
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4308
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
    int a, b, c;
    char op;
    while (true)
    {
        cin >> a >> op >> b;
        if (op == '?')
        {
            break;
        }
        
        switch (op)
        {
        case '+':
            c = a + b;
            break;
        case '-':
            c = a - b;
            break;
        case '*':
            c = a * b;
            break;
        case '/':
            c = a / b;
            break;        
        default:
            break;
        }
        cout << c << endl;
    }
    
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int Q;
long long a,b; 
long long solve(long long a,long long b){
	long long le=0,ri=3e9;
	long long res;
	while(le+1<ri){
		long long mi=(le+ri)/2LL;
		if(mi*(mi+1)<a*b){
			le=mi;
		}
		else{
			ri=mi;
		}
	}
	return ri-2+((a*b)-1)/ri+(a==b);
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>Q;
	while(Q--){
		cin>>a>>b;
		cout<<solve(a,b)<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    long long count=0;
    int max1=a[0];
    for(int i=1;i<n;i++)
        {
            if(a[i]>max1)
                max1=a[i];
            else
                count+=max1-a[i];
        }
    printf("%lld\n",count);
    return 0;
}


Measured memory_bytes: 4604
def factorial_mod(a, M):
    # return a!(mod M)
    ans = 1
    for i in range(a,1,-1):
        ans = (ans * i) % M
    return ans
def test(n, a, M):
    # return (nCaの分子) % M
    ans = 1
    for i in range(a):
        ans = (ans * (n-i)) % M
    return ans
def combination_mod(n,a,M):
    # return nCa % M
    tmp = factorial_mod(a,M)
    tmp = pow(tmp, M-2, M)
    ans = test(n,a,M) * tmp % M
    return ans
def output(n,a,b):
    M = 10**9+7
    ans = (pow(2,n,M) - 1 - combination_mod(n,a,M) - combination_mod(n,b,M)) % M
    return ans
n, a, b = map(int, input().split())
print(output(n,a,b))

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

#define mp make_pair
#
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repn(i, n) for(int i = 1; i < n; ++i)
#define repm(n, m)  for(int i = n; i <= m; ++i)

int main(){
    int a, b; cin >> a >> b;
    
    int ans = 0;
    repm(a, b){
        if((i/10000 == i %10) && (i /1000 % 10 == i % 100 /10))
            ans++; 
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import math

n = int(input())
min_value = 10 ** 9

for a in range(1, int(math.sqrt(n)) + 1):
  b = int(n / a)
  if n % a == 0 and n % b == 0:
    min_value = min(min_value, max(len(str(a)), len(str(b))))
print(min_value)

Measured memory_bytes: 9192