akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N;
  int ans = 0;

  cin >> N;

  vector<int> d(N);
  for(int i = 0; i < N; i++){
    cin >> d[i];
  }
  sort(d.begin(), d.end());

  if(d[N/2-1] == d[N/2]){
    cout << 0 << endl;
  }else{
    cout << d[N/2] - d[N/2 - 1] << endl;
  }

}


Measured memory_bytes: 640
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>


#define ll long long
#define int ll
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 300 + 1;

int n , m, L;
int d[N][N] ,ans[N][N] , u[N * N] , v[N * N] , c[N * N];

main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n >> m >> L;
	for(int i = 1; i <= n ; i++)
		for(int j = 1; j <= n ; j++)
			if(i != j)d[i][j] = 1e18, ans[i][j] = 1e18;	
	for(int i = 1 ; i <= m; i++){
		cin >> u[i] >> v[i] >> c[i];	
		if(c[i] <= L){
			d[u[i]][v[i]] = d[v[i]][u[i]] = c[i];
        }
	}
	for(int k = 1; k <= n; k++)
		for(int i = 1 ; i <= n; i++)
			for(int j = 1 ; j <= n ; j++){
				d[i][j] = min(d[i][j] , d[i][k] + d[k][j]); if(d[i][j] <= L)ans[i][j] = 0;
			}
	for(int k = 1; k <= n; k++)
		for(int i = 1 ; i <= n; i++)
			for(int j = 1 ; j <= n ; j++)
				ans[i][j] = min(ans[i][j] , ans[i][k] + 1 + ans[k][j]);
	int q;
	cin >> q;
	while(q--){
		int s , t;
		cin >> s >> t;
		if(ans[s][t] >= 1e18)
			cout <<"-1\n";
		else cout << ans[s][t] << '\n';
	}
}


Measured memory_bytes: 2944
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 1000000007;
        
//bool operator< (pint a, pint b) {
	//return a.second < b.second;

//}



ll gcd(ll a, ll b) {

	if (b == 0)
		return a;

	return gcd(b, a % b);


}

ll max(ll a, ll b) {
	if (a < b) {
		return b;
	}
	else
		return a;

}

ll min(ll a, ll b) {
	if (a < b)
		return a;

	return b;
}




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

vector<pint> list;










void floyd(int N, ll** d) {

	rep(k, N+1){
		rep(i, N+1) {
			if (d[i+1][k+1] == inf) continue;
			rep(j, N+1) {
				if (d[j+1][k+1] == inf) continue;

				d[i+1][j+1] = min(d[i+1][j+1], d[i+1][k+1] + d[j+1][k+1]);

			}

		}
	}




}


ull modpow(ull a, ull b) {
	ll retval = 0;

	if (b == 0) { return 1; }

	else if (b % 2 == 0) {
		retval = modpow(a, b / 2) % mod;
		return (retval * retval) % mod;
	}

	else {
		
		return ((a % mod) * modpow(a, b - 1)) % mod;
	}
}

ull modkaijou(ull a) {

	if (a == 1 || a == 0) { return 1; }

	ll retval = 1;

	for (ull i = a; i >= 1; i--) {
		retval = (retval * (i % mod)) % mod;
	}

	return retval % mod;
}

ull modcomb(ull a, ull b) {

	if (a == 0 || b == 0) return 1;

	return (((modkaijou(a) * modpow(modkaijou(a-b), mod - 2)) % mod) * modpow(modkaijou(b), mod - 2)) % mod;
}



stack<int> to_1;


class DisjointSet {
public:
	vector<int> p, rank, num;


	DisjointSet() {}

	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		num.resize(size, 0);
		rep(i, size) { p[i] = i; rank[i] = 0; num[i] = 1; }
	}

	bool same(int x, int y) {

		return findSet(x) == findSet(y);

	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	void link(int x, int y) {
		if (rank[x] > rank[y]) {

			p[y] = x;
			num[x] += num[y];

		}

		else {
			p[x] = y;
			num[y] += num[x];
			if (rank[x] == rank[y]) {

				rank[y]++;
			}

		}


	}


	ll NumberOfElements(int x) {

		return num[findSet(x)];

	}


	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);
			num[x] = 1;
		}

		return p[x];
	}



};




bool compare_b(pint a, pint b) {
	if (a.first < b.first) {
		return true;
	}
	else if (a.first == b.first) {
		return a.second < b.second;
	}

	else {
		return false;
	}

}

int ketasuu(int a) {

	int ret = 1;
	int val = a;
	while (val / 10 != 0) {

		ret += 1;
		val /= 10;
	}
	return ret;
}




string S;

ll N, M;


int main() {
	cin >> S;

	ll ans = 0;
	ll val = 0;

	ll index = 0;
	rep(i, S.size()) {
		index = 0;
		while (S[i + index] == 'A' || S[i + index] == 'C' || S[i + index] == 'G' || S[i + index] == 'T') {
		
			index += 1;
		}

		ans = max(index, ans);
	}


	cout << ans << endl;

	return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    
    vector<int> num;
    int now = 1; //今見ている数(1から入れたい)
    int cnt = 0; //nowがいくつ並んでいるか

    for (int i=0; i<N; i++) {
        if (S[i] == (char)('0' + now)) cnt++;
        else {
            num.push_back(cnt); //nowが連続した個数を入れる
            now = 1 - now; //1と0の切り替え
            cnt = 1; //新しいカウントの初期化
        }
    }
    if (cnt != 0) num.push_back(cnt);
    
    if (num.size() % 2 == 0) num.push_back(0);
    
    int Add = 2 * K + 1;
    
    vector<int> sum(num.size() + 1); //累積和を作る
    for (int i=0; i<num.size(); i++) {
        sum[i+1] = sum[i] + num[i];
    }
    
    int ans = 0;
    for (int i=0; i<num.size(); i+=2) {
        int left = i;
        int right = min(i + Add, (int)num.size());
        int tmp = sum[right] - sum[left];
        
        ans = max(tmp, ans);
    }
    
    cout << ans << endl;
    
}

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


void solve(long long N, long long A, long long B){
    cout << min(N*A, B) << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>


constexpr long long int MOD = 1000000007LL;
long long int power(const long long int base, const int exp) {
	switch (exp) {
	case 0: return 1LL;
	case 1: return base % MOD;
	default: return power(base * base % MOD, exp >> 1) * power(base, exp & 1) % MOD;
	}
}
int main() {
	int n, m, k; std::cin >> n >> m >> k;
	std::vector<long long int> factorial(n + m + k + 1, 1), div(n + m + k + 1, 1), inverse(n + m + k + 1, 1);
	for (auto i = 2; i < factorial.size(); ++i) {
		factorial[i] = i * factorial[i - 1] % MOD;
		div[i] = (MOD - MOD / i) * div[MOD % i] % MOD;
		inverse[i] = div[i] * inverse[i - 1] % MOD;
	}
	const auto combination = [&factorial, &inverse](const int n, const int r) {return factorial[n] * inverse[n - r] % MOD * inverse[r] % MOD; };
	long long int result{ power(3, m + k) };
	long long int prev{ 1 };
	for (auto len = n + 1; len <= n + m + k; ++len) {
		const auto rest = len - n;
		const auto a_pattern = combination(len - 1, n - 1);
		const auto min = std::max(rest - k, 0);
		const auto max = std::min(rest, m);
		prev <<= 1;
		if (min > 0) {
			prev += MOD - combination(rest - 1, min - 1);
		}
		if (rest > m) {
			prev += MOD - combination(rest - 1, m);
		}
		prev %= MOD;
		result = (result + a_pattern * prev % MOD * power(3, n + m + k - len)) % MOD;
	}
	std::cout << result << std::endl;
}

Measured memory_bytes: 24232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

const int N = 1e6;
int pena[N];

int main() {
    Fill(pena, 0);
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int p;
        string s;
        cin >> p >> s;
        if(s[0] == 'W' && pena[p] < N) pena[p]++;
        if(s[0] == 'A' && pena[p] < N) pena[p] += N;
    }
    int acs = 0, sumpena = 0;
    for(int i = 1; i <= N; i++)
        if(pena[i] >= N) {
            acs++;
            sumpena += pena[i] - N;
        }
    cout << acs << ' ' << sumpena << endl;
}

Measured memory_bytes: 4224
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)


////////////////////////////////////////////////////////////

int main(){
	int n , x;
	cin >> n >> x;
	vector<int> m(n);
	
	long sum = 0;
	
	rep(i,0,n){
		cin >> m[i];
		sum += m[i];
	}
	vsort(m);
	x -= sum;

	cout << n + x/m[0] << endl;

	ret 0;
}

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

typedef struct{
  int value; 
  int weight;
}SET;

int main(){
  int cnt=1;

  while(1){
    
    int w,n;
    SET data[1111];
    int memo[1111][1111]={{0}};
    
    scanf("%d",&w);
    if(w==0) break;
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
      scanf("%d,%d",&data[i].value,&data[i].weight);
    }
    
    memo[0][data[0].weight]=data[0].value;
    int max_value=data[0].value;
    int max_weight=data[0].weight;
    
    for(int i=1;i<n;i++){
      if(data[i].value>memo[i-1][data[i].weight]){
	memo[i][data[i].weight]=data[i].value;
      }
      for(int j=1;j<=w;j++){
	if(memo[i-1][j]>0 && memo[i-1][j]>memo[i][j]){
	  memo[i][j]=memo[i-1][j];
	}
	
	if(j+data[i].weight<=w && memo[i-1][j+data[i].weight]<data[i].value+memo[i-1][j]){
	  memo[i][j+data[i].weight] = data[i].value+memo[i-1][j];
	}
	
	if(memo[i][j]==max_value){
	  if(max_weight>j){
	    max_weight=j;
	  }
	}
	if(memo[i][j]>max_value){
	  max_value=memo[i][j];
	  max_weight=j;
	}
      }
    }
    printf("Case %d:\n",cnt);
    printf("%d\n",max_value);
    printf("%d\n",max_weight);
    cnt++;
    
  }	

  return 0;
}

Measured memory_bytes: 6028
/* atcoder */
#include "bits/stdc++.h"
using namespace std;

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* main */
void Main(void)
{
    int x;
    cin >> x;
    cout << x * x * x << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}



Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

void solve(){
    int n, d, r;
    cin >> n >> d >> r;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        int x = 1;
        int cnt = 0;
        while(x <= d){
            x += a;
            cnt++;
        }
        ans += cnt;
    }
    cout << ans + r;
    
}

int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}
// vse dolzhny vyiti v internet po hhtp


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int x; cin >> x;
    cout << (x^1) << endl;
}

Measured memory_bytes: 3604
n=input()
h=list(map(int,input().split()))
dp=[0]*len(h)
dp[1]=abs(h[1]-h[0])
for i in range(2,len(h)):
    dp[i]=min(abs(h[i-2]-h[i])+dp[i-2],abs(h[i-1]-h[i])+dp[i-1])
print (dp[-1])

Measured memory_bytes: 13980
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

class input
{
public:
    input()
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var) { return std::cin >> var, *this; }
    template <class T>
    inline input& operator,(T& var) { return *this >> var; }

    template <class T>
    inline T read()
    {
        T var;
        std::cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            std::cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            std::cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            std::cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

    template <class T, class... Args>
    void impl(T&& v, Args&&... args)
    {
        cout << std::forward<T>(v) << ' ';
        impl(std::forward<Args>(args)...);
    }
    template <class T>
    void impl(T&& v)
    {
        cout << std::forward<T>(v);
    }

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class... Args>
    void operator()(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
        cout << '\n';
    }
    template <class... Args>
    void noreturn(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
        cout << '\n';
    }
};

void prog()
{
    input in;
    output out;
    auto s = in.read<std::string>();

    int w = 0, b = 0;
    int f = 1;
    for (char c : s) {
        if (c == '0') {
            if (f) ++w;
            if (!f) ++b;
        } else {
            if (!f) ++w;
            if (f) ++b;
        }
        f = 1 - f;
    }
    out(std::min(w, b));
}

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


Measured memory_bytes: 512
// ※※※ 解答不能 ※※※
// 正解者のソースを学習する(一部改変).
// tourist氏
// https://atcoder.jp/contests/agc038/submissions/7638338
#include <bits/stdc++.h>
using namespace std;

template <typename T, class F = function<T(const T&, const T&)>>
class SparseTable{
    public:
    int n;
    vector<vector<T>> mat;
    F func;
    SparseTable(const vector<T>& a, const F& f) : func(f) {
        n = static_cast<int>(a.size());
        int max_log = 32 - __builtin_clz(n);
        mat.resize(max_log);
        mat[0] = a;
        for (int j = 1; j < max_log; j++) {
            mat[j].resize(n - (1 << j) + 1);
            for (int i = 0; i <= n - (1 << j); i++) {
                mat[j][i] = func(mat[j - 1][i], mat[j - 1][i + (1 << (j - 1))]);
            }
        }
    }
    T get(int from, int to) const {
        assert(0 <= from && from <= to && to <= n - 1);
        int lg = 32 - __builtin_clz(to - from + 1) - 1;
        return func(mat[lg][from], mat[lg][to - (1 << lg) + 1]);
    }
};

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    vector<int> a(n);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    SparseTable<int> smin(a, [&](int i, int j) { return min(i, j); });
    SparseTable<int> smax(a, [&](int i, int j) { return max(i, j); });
    vector<int> bad(n - 1);
    for(int i = 0; i < n - 1; i++) bad[i] = (a[i] > a[i + 1]);
    vector<int> pref(n);
    for(int i = 0; i < n - 1; i++) pref[i + 1] = pref[i] + bad[i];
    int ans = 0;
    int nosort = 0;
    for(int i = 0; i <= n - k; i++){
        if(pref[i + k - 1] - pref[i] == 0){
            nosort = 1;
            continue;
        }
        if(i > 0 && smin.get(i - 1, i + k - 2) == a[i - 1] && smax.get(i, i + k - 1) == a[i + k - 1]) continue;
        ++ans;
    }
    printf("%d\n", ans + nosort);
    return 0;
}

Measured memory_bytes: 28800
from collections import defaultdict
N = int(input())
d = defaultdict(int)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            d[i*i+j*j+k*k+i*j+j*k+k*i] += 1
for i in range(1,N+1):
    print(d[i])

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

int su[100005];

int main(){
    int n;
    int sum = 0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&su[i]);
        sum += abs(su[i] - su[i-1]);
    }
    sum += abs(su[n]);
    for(int i=1;i<=n;i++){
        printf("%d\n", sum + abs(su[i+1] - su[i-1]) - abs(su[i] - su[i-1]) - abs(su[i+1] - su[i]));
    }
}


Measured memory_bytes: 1664
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>

using namespace std;

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

    vector<int> data(N);
    for(int i = 0; i < N; ++i){
        int a;
        cin >> a;
        data[a-1] = i;
    }

    set<int> po;
    po.insert(-1);
    po.insert(N);
    int64_t ans = 0;
    for(int i = 0; i < N; ++i){
        auto it = po.lower_bound(data[i]);
        ans += int64_t(i+1) * (*it - data[i]) * (data[i] - *(--it));
        po.insert(data[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 10368
//Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define     ff      	    	first
#define     pb 	         	push_back
#define     ss          		second
#define     ll      	    	long long
#define     MAX  	       	5000
#define     mpi         		map<int, int>
#define     mpll        		map<ll, ll>
#define     pll         		pair<ll, ll>
#define     plld        		pair<ll, double>
#define     SKILLER     		ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     vi          		std::vector<int>
#define     vll         		std::vector<ll>
#define     vs          		std::vector<string>
#define     vvi         		std::vector<std::vector<int>>
#define     vvll        		std::vector<std::vector<ll>>
#define     all(v)      		v.begin(), v.end()
#define     allr(v)      		v.rbegin(), v.rend()
#define     loop(i, a, b) 	for(int i = a; i < b; i++)
#define 	  debug(x) 		cout << x <<" " <<"\n";
#define 	  debug1(x, y) 	cout << x << " " << y  << "\n";
#define 	  debug2(x, y, z) 	cout << x << " " << y << " " << z<<"\n";
#define 	  int 			ll
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
    	SKILLER;
    	
        int l, r, d; cin >> l >> r >> d;
        int x = r/d;
        x -= max(0LL, (l - 1)/d);
        cout << x;
    	return 0;
}

Measured memory_bytes: 3580
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	parseProblem()
}

func parseProblem() {
	str := scanString(sc)
	exists := map[byte]struct{}{}
	for i := 0; i < len(str); i++ {
		exists[str[i]] = struct{}{}
	}
	if len(exists) == len(str) {
		fmt.Println("yes")
	} else {
		fmt.Println("no")
	}
	return
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

Measured memory_bytes: 1780
K,N=map(int,input().split())
*A,=map(int,input().split())
ans=float('inf')
for i in range(N-1):
  a,b=A[i],A[i+1]
  b=abs(K-b)
  ans=min(ans, a+b)
print(min(ans,A[N-1]-A[0]))

Measured memory_bytes: 85580
fn read<T: std::str::FromStr>() -> T {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).ok();
	s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().split_whitespace()
		.map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
	(0..n).map(|_| read_vec()).collect()
}

pub trait LexicalPermutation {
	/// Return `true` if the slice was permuted, `false` if it is already
	/// at the last ordered permutation.
	fn next_permutation(&mut self) -> bool;
}
impl<T> LexicalPermutation for [T] where T: Ord {
	/// Original author in Rust: Thomas Backman <serenity@exscape.org>
	fn next_permutation(&mut self) -> bool {
		// These cases only have 1 permutation each, so we can't do anything.
		if self.len() < 2 { return false; }

		// Step 1: Identify the longest, rightmost weakly decreasing part of the vector
		let mut i = self.len() - 1;
		while i > 0 && self[i-1] >= self[i] {
			i -= 1;
		}

		// If that is the entire vector, this is the last-ordered permutation.
		if i == 0 {
			return false;
		}

		// Step 2: Find the rightmost element larger than the pivot (i-1)
		let mut j = self.len() - 1;
		while j >= i && self[j] <= self[i-1]  {
			j -= 1;
		}

		// Step 3: Swap that element with the pivot
		self.swap(j, i-1);

		// Step 4: Reverse the (previously) weakly decreasing part
		self[i..].reverse();

		true
	}
}

fn main() {
	let n: isize = read();
	let mut a: Vec<usize> = read_vec();
	let b: Vec<usize> = read_vec();
	let c: Vec<usize> = read_vec();

	let mut satisfy = 0;

	let mut remember_num: isize = n+2;

	for i in a {
		satisfy += b[i-1];
		if (i as isize) - remember_num == 1 { satisfy += c[i-2] }
		remember_num = i as isize;
	}

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


Measured memory_bytes: 4352
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}

#define MOD 1000000007

#define MED (100000 / 2)
int left_side[100000];

map<int, long long> recur(vector<int> vec)
{
	map<int, long long> ans;
	if (vec.size() == 1)
	{
		ans[vec[0]] = 1;
		return ans;
	}
	int n = vec.size();
	int n1 = n / 2;
	int n2 = n - n1;

	vector<int> v1, v2;
	for (int i = 0; i < n; i++)
	{
		if (i < n1)
			v1.push_back(vec[i]);
		else
			v2.push_back(vec[i]);
	}
	auto a1 = recur(v1), a2 = recur(v2);

	for (auto x : a1)
	{
		ans[x.first] += x.second;
		for (auto y : a2)
		{
			ans[x.first + y.first] += x.second * y.second;
		}
	}

	for (auto y : a2)
		ans[y.first] += y.second;

	return ans;
}


int main() {

#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n, a;
	cin >> n >> a;
	vector<int> vec(n);
	for (int i = 0; i < n; i++)
	{
		cin >> vec[i];
		vec[i] -= a;
	}

	if (n == 1)
	{
		int cnt = 0;
		for (int i = 0; i < n; i++)
			if (vec[i] == 0)
				cnt++;
		cout << cnt;
		return 0;
	}

	cout << recur(vec)[0];
	return 0;

	int n1 = n / 2;
	int n2 = n - n1;

	for (int i = 0; i < (1 << n1); i++)
	{
		int sum = 0;
		for (int j = 0; j < n1; j++)
		{
			if (i & (1 << j))
				sum += vec[j];
		}

		left_side[MED + sum] += 1;
	}

	long long ans = 0;
	for (int i = 0; i < (1 << n2); i++)
	{
		int sum = 0;
		for (int j = 0; j < n2; j++)
		{
			if (i & (1 << j))
				sum += vec[n1 + j];
		}

		ans += left_side[MED - sum];
	}

	cout << ans - 1;

	return 0;
}


Measured memory_bytes: 384
import collections
    
n = int(input())

def division(n):
    if n < 2:
        return []
    
    prime_factors = []
    
    for i in range(2,int(n**0.5)+1):
        while n % i == 0:
            prime_factors.append(i)
            n //= i
    if n > 1:
        prime_factors.append(n)
        
    return prime_factors

num = []

for i in range(1,n+1):
    div = division(i)
    num.extend(div)
c = collections.Counter(num)

div_num = 1

n2, n4, n14, n24, n74 = 0,0,0,0,0

for k,v in c.items():
    if 2<=v:
        n2 += 1
    if 4<=v:
        n4 += 1
    if 14<=v:
        n14 += 1
    if 24<=v:
        n24 += 1
    if 74<=v:
        n74 += 1

ans = n74 + n24*(n2-1) + n14*(n4-1) + n4*(n4-1)*(n2-2)//2

print(ans)

Measured memory_bytes: 9680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;

struct mint {
  ll x;
  mint(ll x = 0): x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
  mint& operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct cominit {
  vector<mint> fact, ifact;
  cominit(int n): fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; i--) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int r) {
    if (n < r or r < 0) return 0;
    return fact[n] * ifact[r] * ifact[n - r];
  }
};

int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  } else if (n == 2) {
    cout << 2 << endl;
    return 0;
  }
  mint ans = 0;
  cominit nCr(n + 1);
  for (int i = 2; i <= n; i++) {
    mint now = nCr(n, i);
    now *= mint(2).pow(i) - 2;
    now *= mint(8).pow(n - i);
    ans += now;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 18756
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i = 0; i < N; i++) cin >> h[i];
  sort(h.begin(), h.end());
  int ans = *h.rbegin();
  for(int i = 0; i + K - 1 < N; i++) ans = min(ans, h[i + K - 1] - h[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        IntStream.range(0,3)
                .mapToObj(i->scanner.next().toCharArray()[i])
                .forEach(System.out::print);
        System.out.println();
        scanner.close();
    }
}

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

int dict_order(int n, int *arr){
  
  if(n==1) return 0;
  
  int first = arr[0];
  int next_arr[n-1];
  
  rep(i,n-1){
    if(arr[i+1] > first) next_arr[i] = arr[i+1] - 1;
    else next_arr[i] = arr[i+1];
  }
  
  int factorial = 1;
  rep(i,n-1){
    factorial *= (i+1);
  }
  
  return (first-1)*factorial + dict_order(n-1, next_arr);
}


int main(){
  int n;
  cin >> n;
  int p[n], q[n];
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  
  int a = dict_order(n,p);
  int b = dict_order(n,q);
  
  cout << abs(a-b) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	int m, f, r;
	while (cin >> m >> f >> r && (m >= 0 || f >= 0 || r >= 0)) {
		int k = m + f;
		if (m == -1 || f == -1) cout << "F\n";
		else if (k < 30) cout << "F\n";
		else if (k < 50) {
			if (r >= 50) cout << "C\n";
			else cout << "D\n";
		}
		else if (k<65) {
			cout << "C\n";
		}
		else if (k < 80) {
			cout << "B\n";
		}
		else {
			cout << "A\n";
		}
	}
}


Measured memory_bytes: 3084
N = int(input())
S = [0 for i in range(N)]
for i in range(N):
  S[i] = input()
 
dic = {"M":0, "A":0, "R":0, "C":0, "H":0}
for i in range(N):
  if S[i][0] in dic:
    dic[S[i][0]] += 1
    
ans = dic["M"]*dic["A"]*dic["R"]+dic["M"]*dic["A"]*dic["C"]+dic["M"]*dic["A"]*dic["H"]+dic["M"]*dic["R"]*dic["C"]+dic["M"]*dic["R"]*dic["H"]+dic["M"]*dic["C"]*dic["H"]+dic["A"]*dic["R"]*dic["C"]+dic["A"]*dic["R"]*dic["H"]+dic["A"]*dic["C"]*dic["H"]+dic["R"]*dic["C"]*dic["H"]
print(ans)

Measured memory_bytes: 9768
// C - Energy Drink Collector
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

	map<int,int> AB;
	for(int i=0; i<N; ++i){
		int a,b; cin>>a>>b;
		AB[a] += b;
	}

	ll yen = 0;
	for(auto e:AB){
		int a,b; tie(a,b) = e;
		int c = min(M,b);
		yen += (ll)c*a;
		M -= c;
		if(M<=0)break;
	}
	cout<< yen <<endl;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;

int n, k;
bool dislike[10];

inline bool Check(int x) {
  do {
    if (dislike[x % 10])
      return false;
  } while (x /= 10);
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 1, x; i <= k; ++i) {
    cin >> x;
    dislike[x] = true;
  }
  for (; n; ++n) {
    if (Check(n)) {
      cout << n << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
/// Zhupengfei 2018
/// Hereby declare: this program is in public domain.

/// Solution for problem: abc103A

#include <bits/stdc++.h>

#ifdef LOCAL
#pragma GCC poison printf // To avoid fastio problems
#pragma GCC poison scanf
#endif

using namespace std;

int a[3];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
    cin>>a[0]>>a[1]>>a[2];
    sort(a, a+3);
    cout<<abs(a[1]-a[0]) + abs(a[2]-a[1])<<endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,0,-1,1,-1,-1,1};
const int dy[]={0,1,-1,0,1,1,-1,-1};
const int INF = 1e8;
const double EPS = 1e-8;
#define PB push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> Pii;
typedef pair<int,vi > P;
typedef unsigned long long ll;
int H[1510010];
int W[1000010];
int main(){
	int N,M;
	while(scanf("%d %d",&N ,&M),N){
		memset(H,0,sizeof(H));
		memset(W,0,sizeof(W));
		int c[1510]={0};
		int d[1510]={0};
		rep(i,N){
			scanf("%d" ,&c[i+1]);
			c[i+1] += c[i];
		}
		rep(i,M){
			scanf("%d" ,&d[i+1]);
			d[i+1] += d[i];
		}
		int ma = -INF;
		rep(i,N+1){
			reps(j,i+1,N+1){
				H[c[j]-c[i]]++;
				ma = max(ma,c[j]-c[i]);
			}
		}
		rep(i,M+1){
			reps(j,i+1,M+1){
				W[d[j]-d[i]]++;
				ma = max(ma,d[j]-d[i]);}

		}
		int ans = 0;
		reps(i,1,ma+1){
			if(H[i] && W[i]){
				ans += H[i]*W[i];
			}
		}
		printf("%d\n",ans);
	}
    return 0;
}

Measured memory_bytes: 11012
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int x=stdIn.nextInt(),t=stdIn.nextInt();
		if(0>x-t) System.out.print("0");
		else System.out.print(x-t);
	}
}

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

int main()
{
  string S, T;
  cin >> S >> T;
  vector<int> S_alphabet('z' - 'a' + 1, 0);
  vector<int> T_alphabet('z' - 'a' + 1, 0);

  rep(i, S.size())
  {
    S_alphabet[S[i] - 'a']++;
    T_alphabet[T[i] - 'a']++;
  }

  sort(S_alphabet.begin(), S_alphabet.end());
  sort(T_alphabet.begin(), T_alphabet.end());
  string ans = "No";
  if (S_alphabet == T_alphabet)
    ans = "Yes";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 776
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

struct Info{
	char ID[11];
};

enum Door{
	CLOSE,
	OPEN
};

bool strCmp(char* base, char* comp){
	int length1 = 0,length2 = 0;
	for(int i=0;base[i] != '\0'; i++)length1++;
	for(int i=0;comp[i] != '\0'; i++)length2++;
	if(length1 != length2)return false;

	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i])return false;
	}
	return true;
}

int main(){

	int N,M;
	bool FLG;
	scanf("%d",&N);
	Info info[N];

	for(int i = 0; i < N; i++)scanf("%s",info[i].ID);

	Door door = CLOSE;
	char tmp[11];

	scanf("%d",&M);

	for(int i = 0; i < M; i++){
		scanf("%s",tmp);
		FLG = false;
		for(int k = 0; k < N; k++){
			if(strCmp(tmp,info[k].ID)){
				FLG = true;
				break;
			}
		}
		if(FLG){
			if(door == CLOSE){
				printf("Opened by %s\n",tmp);
				door = OPEN;
			}else{
				printf("Closed by %s\n",tmp);
				door = CLOSE;
			}
		}else{
			printf("Unknown %s\n",tmp);
		}
	}

	return 0;
}

Measured memory_bytes: 2768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a * n,b) << endl;
    return 0;
}

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

int main()
{
    int n, k, ans;
    cin >> n >> k;
    ans = 0;
    for(int i=0; i<n; i++){
        int t;
        cin >> t;
        t = min(t, k-t);
        ans += 2*t;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 500005
using namespace std;
int n,a[N];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	a[n+1]=0;int ans=abs(a[2]);
	for (int i=2;i<=n;i++) ans=ans+abs(a[i+1]-a[i]);
	printf("%d\n",ans);
	for (int i=1;i<n-1;i++){
		ans=ans-abs(a[i+1]-a[i-1])-abs(a[i+2]-a[i+1]);
		ans=ans+abs(a[i]-a[i-1])+abs(a[i+2]-a[i]);
		printf("%d\n",ans);
	}ans=0;
	for (int i=1;i<n;i++) ans=ans+abs(a[i]-a[i-1]);
	ans=ans+abs(a[n-1]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
typedef long long ll;
using namespace std;

int main() {
    int n, l, sum = 0, flag = 1;
    cin >> n >> l;
    int m = abs(l);
    for(int i = 0; i < n; i++) sum += l+i;
    for(int i = 0; i < n; i++) {
        m = min(m, abs(l+i));
        if(abs(l+i) == min(m, abs(l+i)) && l+i < 0) flag = 0;
    }
    if(flag == 1) cout << sum-m << endl;
    else cout << sum+m << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int n, sum=0;
    scanf("%d", &n);
    int v[n], c;
    for (int i=0; i<n; i++) scanf("%d", v+i);
    for (int i=0; i<n; i++) {
        scanf("%d", &c);
        sum += max(0, v[i] - c);
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(int i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(int i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007
 

int N,W;
vi v(1000), w(1000);
vvi dp(1000,vi(10001,-1));


int calc(int i,int j){
	if(i>=N) return 0;
	if(dp[i][j]!=-1) return dp[i][j];
	int ret;
	if(j+w[i]>W) ret=calc(i+1,j);
	else ret=max(calc(i+1,j),calc(i+1,j+w[i])+v[i]);
	return dp[i][j]=ret;
}


int main(){
	cin>>N>>W;
	rep(i,N) cin>>v[i]>>w[i];
	cout<<calc(0,0)<<endl;
}

Measured memory_bytes: 40348
#include<iostream>
#include<cmath>

using namespace std;

int main(){
    int D,N;
    cin >> D >> N ;
    if(D==0 && N == 100){
        cout << 101 << endl;
        return 0;
    }
    if(D==1 && N == 100){
        cout << 10100 << endl;
        return 0;
    }
    if(D==2 && N == 100){
        cout << 1010000 << endl;
        return 0;
    }    
    int x = 1;
    for(int i= 0;i<D;i++){
        x = x*100;
    }
    cout << x*N << endl;
    return 0;
}

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

typedef long l;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define mp make_pair

const int DX[] = {1, 0, -1, 0, 1, 1, -1, -1}, DY[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

  int a[n + 2];
  int total = 0;
  a[0] = 0;
  a[n + 1] = 0;
  REP(i, n) {
    cin >> a[i + 1];

    total += abs(a[i + 1] - a[i]);
  }

  total += abs(a[n + 1] - a[n]);
  FOR(i, 1, n + 1) {
    cout << total - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]) << endl;
  }


}



Measured memory_bytes: 1664
n = list(map(int, list(input())))
k = int(input())

N = len(n)

a = [[0 for _ in range(k+1)] for _ in range(len(n)+1)]
b = [[0 for _ in range(k+1)] for _ in range(len(n)+1)]
b[0][0] = 1

for i, x in enumerate(n):
    a[i+1][0] = a[i][0] + b[i][0]
    for j in range(1, k+1):
        temp = a[i][j-1] * 9 + a[i][j]
        if x > 0:
            temp += b[i][j] + b[i][j-1] * (x-1)
        a[i+1][j] = temp
        if x == 0:
            b[i+1][j] = b[i][j]
        else:
            b[i+1][j] = b[i][j-1]

#print(a)
#print(b)

print(a[N][k] + b[N][k])

Measured memory_bytes: 3064
x,k,d=input().split()
x=int(x)
k=int(k)
d=int(d)
if(abs(x)>k*d):
    print(abs(x)-k*d)
else:
    i=abs(x)//d
    a=abs(x)%d
    k=k-i
    if(k==0):
        print(a)
    elif(k%2==0):
        print(a)
    else:
        print(abs(a-d))
        
        

Measured memory_bytes: 9188
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int i,j,k;
  string st[51];
  for(i=0;i<n;i++) cin >> st[i];
  int ch[51][3]={{}};
  for(i=0;i<n;i++){
    int c[3]={};
    for(j=0;j<m;j++){
      if(st[i][j]=='W') c[0]++;
      if(st[i][j]=='B') c[1]++;
      if(st[i][j]=='R') c[2]++;
    }
    for(k=0;k<3;k++) {
      ch[i][k]=m-c[k];
      //cout << ch[i][k] << endl;
    }
  }
  int dp[51][3]={{}};
  int inf = 1 << 20;
  fill(dp[0],dp[50],inf);
  dp[0][0]=ch[0][0];
  for(i=1;i<n-1;i++){
    for(j=0;j<3;j++){
      for(k=j;k<3;k++){
        dp[i][k]=min(dp[i][k],dp[i-1][j]+ch[i][k]);
      }
    }
  }
  int o=inf;
  for(k=1;k<3;k++) o=min(o,dp[n-2][k]+ch[n-1][2]);
 
  cout << o << endl;
  return 0;
}

Measured memory_bytes: 1208