akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

const double PI = acos(-1.0);
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int R; cin >> R;
    cout << fixed << setprecision(5) << PI*R*2 << ln;

}

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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int64_t n;
  cin >> n;
  vector<int64_t> a(n);
  vector<int64_t> b(n);
  vector<int64_t> c(n);
  rep(i,n){
    cin >> a.at(i);
  }
  rep(i,n){
    cin >> b.at(i);
  }
  rep(i,n){
    cin >> c.at(i);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  int64_t cnt = 0;
  rep(i,n){
    int64_t center = b.at(i);
    auto headitr = lower_bound(a.begin(),a.end(),center);
    int64_t headnum = distance(a.begin(),headitr);
    auto bottomitr = upper_bound(c.begin(),c.end(),center);
    int64_t bottomnum = n - distance(c.begin(),bottomitr);
    cnt += headnum * bottomnum;
  }
  cout << cnt << endl;
    
    
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
int main() {
  ll n;
  cin >> n;
  vl a(n);
  ll k=1;
  rep(i,n){
    cin >> a[i];
    if(a[i]%2==0){
      k *=2;
    }
  }
  cout << pow(3,n)-k << endl;
}

Measured memory_bytes: 256
//In the Name of ̲A̲l̲l̲a̲h̲

#define pb push_back
#define F first
#define S second
#define sz size()
#define ll long long

#include <bits/stdc++.h>

using namespace std;

ll n, w[101], v[101], mx, dp[100001][101];

int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> mx;
	for (int i = 0; i < n; i++)
    {
        cin >> w[i] >> v[i];
    }
    for (ll i = w[0]; i <= mx; i++)
        dp[i][0] = v[0];
    for (ll i = 0; i < n; i++)
    {
        for (ll j = 1; j <= mx; j++)
        {
            dp[j][i] = dp[j][i-1];
            if (j>=w[i])
                dp[j][i] = max(dp[j][i],dp[j-w[i]][i-1]+v[i]);
        }
    }
    cout << dp[mx][n-1];
}

/*𝐻𝒶𝒹𝒾*/


Measured memory_bytes: 79232
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 2e5 + 10;
vector < int > g[maxN];
int p[maxN];
bool used[maxN];
int mex[maxN];
bool on_cyc[maxN];
void dfs(int v) {
    used[v] = true;
    set < int > s;
    for (int to : g[v]) {
        if (on_cyc[to]) continue;
        dfs(to);
        s.insert(mex[to]);
    }
    while (s.count(mex[v])) mex[v]++;
}
int val[maxN][2];
const int LG = 20;
int up[2 * maxN][LG];
int gg[2 * maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
        g[p[i]].emplace_back(i);
    }
    int c = 1;
    while (!used[c]) {
        used[c] = true;
        c = p[c];
    }
    vector < int > cyc;
    memset(used, 0, sizeof used);
    while (!used[c]) {
        cyc.emplace_back(c);
        on_cyc[c] = true;
        used[c] = true;
        c = p[c];
    }
    for (int v : cyc) {
        dfs(v);
    }
    for (int i = 0; i < cyc.size(); i++) {
        set < int > s;
        for (int to : g[cyc[i]]) {
            if (on_cyc[to]) continue;
            s.insert(mex[to]);
        }
        val[i][0] = mex[cyc[i]];
        s.insert(mex[cyc[i]]);
        while (s.count(val[i][1])) val[i][1]++;
        assert(val[i][1] != val[i][0]);
    }
    for (int i = 0; i < cyc.size(); i++) {
        gg[i] = val[i][0];
        gg[i + cyc.size()] = val[i][1];
        int prv = (i + cyc.size() - 1) % cyc.size();
        for (int j = 0; j < 2; j++) {
            if (val[prv][0] == val[i][j]) up[cyc.size() * j + i][0] = prv + cyc.size();
            else up[cyc.size() * j + i][0] = prv;
        }
    }
    for (int i = 0; i + 1 < LG; i++) {
        for (int j = 0; j < 2 * cyc.size(); j++) {
            up[j][i + 1] = up[up[j][i]][i];
        }
    }
    for (int i = 0; i < cyc.size(); i++) {
        int steps = cyc.size() - 1;
        int where = i;
        for (int j = 0; j < LG; j++) {
            if (steps & (1 << j)) where = up[where][j];
        }
        if (gg[where] > gg[i]) {
            cout << "POSSIBLE";
            return 0;
        }
    }
    cout << "IMPOSSIBLE";
    return 0;
}

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

int solve(long long N, std::vector<long long> a)
{
    long long cnt = 0;
    long long n = 1;
    for (int i = 1; i <= N; i++)
    {
        cnt++;
        if (a[n] == 2)
        {
            //if (i == 1)
            //    cout << "1" << endl;
            //else
            cout << cnt << endl;

            return 0;
        }

        n = a[n];
    }

    cout << "-1" << endl;
}

// Generated by 1.1.7.1 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);
    std::vector<long long> a(N + 1);
    for (int i = 1; i <= N; i++)
    {
        scanf("%lld", &a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);++(i))
#define EACH(e,v) for(auto& e:v)

/*
・セグメント木
  >         build O(N)
  > query, update O(logN)
[備考] 結合律, 単位元を持つ二項演算を, 任意の区間に関してlogNで行うデータ構造
[使用例]
SegmentTree<int> seg_sum(N, [](int a, int b){ return a+b; }, 0 );       // 区間和
SegmentTree<int> seg_min(N, [](int a, int b){ return min(a,b); }, INF); // 区間min
seg_min.set(k,x);     // 要素kに値xを設定
seg_min.build();      // 上のセグメントに値を設定
seg_min.update(k,x);  // 要素kを値xに変更
seg_min.add(k,x);     // 要素kに値xを加算
seg_min.query(l,r);   // 区間[l,r)に対する二項演算の結果を返す
*/

template<typename T> struct SegmentTree {

  using F = function< T(T,T) >;

  vector< T > seg;

  int size;       // データの数以上の最小の2冪, 最下段のデータの個数
  const F func;
  const T M1;

  SegmentTree(int n, const F f, const T &M) : func(f), M1(M) {
    size = 1; while (size < n) size *= 2;
    seg.resize(2 * size - 1, 0);
  }

  void set(int k, T x) {
    seg[k + size - 1] = x;
  }

  void build() {
    for (int i = size - 2; i >= 0; --i) {
      // iの子は, (2*i+1, 2*i+2)
      seg[i] = func(seg[2*i+1], seg[2*i+2]);
    }
  }

  void update(int k, T x) {
    // kをseg内の添字に対応させる <- (size - 1)を足す
    k += size - 1;
    seg[k] = x;
    while (k > 0) {
      k = (k - 1) / 2;
      seg[k] = func(seg[2*k+1], seg[2*k+2]);
    }
  }

  void add(int k, T x) {
    // kをseg内の添字に対応させる <- (size - 1)を足す
    k += size - 1;
    seg[k] += x;
    while (k > 0) {
      k = (k - 1) / 2;
      seg[k] = func(seg[2*k+1], seg[2*k+2]);
    }
  }

  T query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = size;
    if (r <= a || l >= b) return M1;
    if (l >= a && r <= b) return seg[k];
    T f_l = query(a, b, 2*k+1, l, (l+r)/2);
    T f_r = query(a, b, 2*k+2, (l+r)/2, r);
    return func(f_l, f_r);
  }

  void debug() {
    for (int i = 0; i < 2 * size - 1; ++i) {
      cerr << seg[i] << " \n"[i==2*size-2];
    }
  }

};

// 低い花から順に植えていく
// dp[i] := i番目の花が一番高いときの美しさの最大値
// dp[i] = max(k=0..i-1){dp[k]} + A[i]
// 区間maxをセグ木で取得してO(NlogN)

const int INF = 1 << 30;

int N;
vector<pair<int,int>> H;
vector<int> A;

signed main() {

  cin >> N;

  H.resize(N);
  REP(i, N) {
    cin >> H[i].first;
    H[i].second = i;
  }
  sort(H.begin(), H.end());

  A.resize(N);
  REP(i, N) cin >> A[i];

  SegmentTree<ll> dp(N, [](ll a, ll b){ return max(a,b); }, 0);

  EACH(h, H) {
    int i = h.second;
    ll q = dp.query(0, i);
    dp.update(i, q + A[i]);
  }

  cout << dp.query(0, N) << endl;

}


Measured memory_bytes: 6656
//Be Name Khoda
//man az biganegan  hargez  nanalam
//ke harche kard ba man ashena kard
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma optimize O3
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long int LL;
typedef LL ll;
typedef long double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); }
#define MKP make_pair
#define RETD(x) { cout << fixed << setprecision(15) << x; exit(0); }
#define GEI(x) scanf("%d",&x)
#define GEL(x) scanf("%lld",&x)
#define ALL(x) x.begin(),x.end()
const ll M=2e6+5,LG=32,SM=600+5,inf=1e18+5;
ll mod=1e9+7;

ll n;
str s;
ll cnt[M];

int main()
{
    cin >> s;
    n=SZ(s);
    ll res=n*(n-1)/2;
    for (char c:s)
    {
        res-=cnt[c];
        cnt[c]++;
    }       
    RET(res+1);
}

Measured memory_bytes: 640
N,x = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
for i in range(1,N):
    cnt = A[i-1] + A[i] - x
    if cnt > 0:
        A[i] = max(0,x-A[i-1])
        ans += cnt
print(ans)


Measured memory_bytes: 14060
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
//INF = 1 061 109 567 ; INF + INF = 2 122 219 134 ;
//LINF = 4 557 430 888 798 830 399 ; LINF + LINF = 9 114 861 777 597 660 798 ;
const int INF = 0x3f3f3f3f;     // -INF: 0xc0   abs(-INF) = INF + 1
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9+7;     // when MOD = 1e9+7, inv2 = 500000004
const int M = 328;
const int B = 203;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int N = 2e5+7;
int a[N],f[N];
int n;
ll k;
bool can(ll x) {
	ll res = k;
	rep(i,0,n) {
		ll b = x / f[i];
		res -= max(0ll,a[i] - b);
	}
	return res >= 0;
}
int main()
{
	scanf("%d%lld",&n,&k);
	rep(i,0,n) scanf("%d",&a[i]);
	rep(i,0,n) scanf("%d",&f[i]);
	sort(a,a+n);
	sort(f,f+n);
	reverse(f,f+n);
	ll l = 0,r = 1e12+7;
	while(l < r) {
		ll m = (l + r) >> 1;
		if(can(m)) r = m;
		else l = m + 1;
	}
	printf("%lld\n",l);
	return 0;
}


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

const long double EPS = 1e-10;

using namespace std;

const complex<long double> I = complex<long double>(0, 1);

int main(){
  int N, K;
  cin >> N >> K;
  
  vector<complex<long double>> meats(N);
  vector<long double> c(N);
  for(int i = 0; i < N; i++){
    long double re, im;
    cin >> re >> im >> c[i];
    meats[i] = complex<long double>(re, im);
  }
  
  long double ok = 200000, ng = 0;
  for(int k = 0; k < 100; k++){
    long double mid = (ok + ng) * 0.5;
    
    vector<complex<long double>> candidates = meats;
    for(int i = 0; i < N; i++){
      for(int j = i + 1; j < N; j++){
        long double d = abs(meats[i] - meats[j]);
        
        if(d > mid / c[i] + mid / c[j] - EPS) continue;
        if(abs(mid / c[j] - mid / c[i]) > d - EPS) continue;
        
        long double t = (mid / c[i]) * (mid / c[i]) - (mid / c[j]) * (mid / c[j]) + d * d;
        t /= d * 2;
        
        if((mid / c[i]) * (mid / c[i]) - t * t < EPS) continue;
        
        complex<long double> dir = (meats[i] - meats[j]) / d * sqrt((mid / c[i]) * (mid / c[i]) - t * t) * I;
        
        candidates.push_back(meats[i] + (meats[j] - meats[i]) / d * t + dir);
        candidates.push_back(meats[i] + (meats[j] - meats[i]) / d * t - dir);
      }
    }
    
    bool good = false;
    for(auto heat_source : candidates){
      int count = 0;
      for(int i = 0; i < N; i++){
        if(abs(heat_source - meats[i]) <= mid / c[i] + EPS){
          ++count;
        }
      }
      
      if(count >= K){
        good = true;
        break;
      }
    }
    
    (good ? ok : ng) = mid;
  }
  
  cout << fixed << setprecision(10) << ok << endl;
  
  return 0;
}

Measured memory_bytes: 3988
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	int i = 0, j = 0, k = 0;
	char next = 'a';
	while(1){
		if(next=='a'){
			if(i>a.length()-1){
				cout << 'A' << endl;
				break;
			}
			next = a[i];
			i++;
		}
		else if(next=='b'){
			if(j>b.length()-1){
				cout << 'B' << endl;
				break;
			}
			next = b[j];
			j++;
		}
		else{
			if(k>c.length()-1){
				cout << 'C' << endl;
				break;
			}
			next = c[k];
			k++;
		}
	}
}


Measured memory_bytes: 256
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> convertstring(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i] - '0');
	}
	return d;
}
map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
vector<ll> divisor(ll n) {
	vector<ll>res;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i != 0)continue;
		res.push_back(i);
		if (i * i != n)res.push_back(n / i);
	}
	return res;
}

int A, B,K;
int main()
{
	cin >> A >> B>>K;
	int cnt = 0;
	for (int c = 100; c >= 0; --c) {
		if (A % c == 0 && B % c == 0) {
			cnt++;
		}
		if (cnt == K) {
			cout << c << endl;
			return 0;
		}
	}


}


Measured memory_bytes: 256
/*
	Author: Luis Manuel D?az Bar?n (LUISMO)
	Problem:
	Online Judge:
	Idea:
*/
#include<bits/stdc++.h>
// Types
#define ll long long
#define ull unsigned long long
// IO
#define sf scanf
#define pf printf
#define mkp make_pair
#define fi first
#define se second
#define endl "\n"

using namespace std;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll inf = 1e16 + 3;
const int mod = 1e9 + 7;
const int lim = 2e5 + 17 ;

int N, xi, yi;

vector<int> adj[lim];

ll dp[lim][2];
bool mark[lim][2];

// 0-white, 1-black

ll DFS(int idx, int father, int color)
{
	if(mark[idx][color])
		return dp[idx][color];

	ll curr = 1;
	
	for(int i = 0; i < adj[idx].size(); i++)
	{
		int nxt = adj[idx][i];
		if(nxt != father)
		{
			ll aux = DFS(nxt, idx, 0);

			

			if(!color)
			{
				ll aux2 = DFS(nxt, idx, 1);

				aux = (aux + aux2) % mod;				
			}

			curr = (curr * aux) % mod;
		}
	}
	mark[idx][color] = true;
	dp[idx][color] = curr;

	// cout << idx << " " << color << " " << curr << endl;

	return dp[idx][color];
}


void solve()
{
	cin >> N;
	for(int i = 0; i < N - 1; i++)
	{
		cin >> xi >> yi;
		adj[xi].push_back(yi);
		adj[yi].push_back(xi);
	}

	ll a1 = DFS(1, -1, 0);

	ll a2 = DFS(1, -1, 1);

	// cout << a1 << " "<< a2 << endl;

	ll answ = (a1 + a2) % mod;
	cout << answ << endl;
}


void fastIO()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
}

void IO()
{
	if(fopen("d:\\lmo.in","r") != NULL)
	{
		freopen("d:\\lmo.in","r",stdin);
	}
	else if(fopen("/media/Beijing/lmo.in","r") != NULL)
	{
		freopen("/media/Beijing/lmo.in", "r", stdin);
	}
}

int main()
{
	IO();

	fastIO();

	solve();
}


Measured memory_bytes: 19712
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

//用意する配列の最大個数
#define MAXMATRIX 100

//シグマの計算((Σ[k = 0 → m] array_a[i][k] * array_b[k][j])
long int sigma(int i, int j, int m, long int matrix_a[MAXMATRIX][MAXMATRIX], long int matrix_b[MAXMATRIX][MAXMATRIX]);

int main(void)
{
    //行列aと行列b
    long int matrix_a[MAXMATRIX][MAXMATRIX], matrix_b[MAXMATRIX][MAXMATRIX];
    //iとjはループ変数、nとmとlは(n * m)の行列と(m * l)の行列の要素数
    int i, j, n, m, l;

    scanf("%d %d %d", &n, &m, &l);

    //行列aの要素を入力
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            scanf("%ld", &(matrix_a[i][j]));
        }

    }

    //行列bの要素を入力
    for(i = 0; i < m; i++){
		for(j = 0; j < l; j++){
			scanf("%ld", &(matrix_b[i][j]));
		}
    }

    //n*lの行列の結果を出力
    for(i = 0; i < n; i++){
		for(j = 0; j < l; j++){
			printf("%ld", sigma(i, j, m, matrix_a, matrix_b));
			//各行において、最後の要素でないならスペースを入れる
			if((l - j) != 1){
				printf(" ");
			}
		}
		printf("\n");
    }

    return 0;
}

long int sigma(int i, int j, int m, long int matrix_a[MAXMATRIX][MAXMATRIX], long int matrix_b[MAXMATRIX][MAXMATRIX])
{
	//kはループ変数
    int k;
	long int ans;

    //初期値は0
    ans = 0;

    //((Σ[k = 0 → m] array_a[i][k] * array_b[k][j])の計算
    for(k = 0; k < m; k++){
        ans += matrix_a[i][k] * matrix_b[k][j];
    }

    return ans;
}


Measured memory_bytes: 2112
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
  int a,b;
  char c;
  string s;
  cin>>a>>b;
  cin>>s;
  int i,n;
  n=s.size();
  for(i=0;i<n;i++)
  {
    if(i!=b-1){cout<<s[i];}
    else{c=s[i]-'A'+'a';cout<<c;}
  }
}
 

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

int main(){
    string s;
    vector <string> day = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    cin >> s;
    vector<string>::iterator it = find(day.begin(),day.end(),s);
    int ans = 7-(it-day.begin());
    cout << ans<< endl;
    return 0;

}

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

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

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

Measured memory_bytes: 3516
#include<iostream>
#include<string>
using namespace std;
int main(){
  int N,K;
  string S;
  cin >> N >> S >> K;
  
  for(int i=0;i<N;i++){
    if (S[i] != S[K-1])S[i]='*';
  }
  
  cout << S << endl;
}
  
  

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func debug(a ...interface{}) {
	if os.Getenv("ONLINE_JUDGE") == "false" {
		fmt.Fprintln(os.Stderr, a...)
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	d := make([][2]int, n)
	for i := 0; i < n; i++ {
		d[i][0], d[i][1] = scanInt(), scanInt()
	}
	f := false
	for i := 0; i < n-2; i++ {
		if d[i][0] == d[i][1] && d[i+1][0] == d[i+1][1] && d[i+2][0] == d[i+2][1] {
			f = true
		}
	}
	if f {
		fmt.Fprintln(wr, "Yes")
	} else {
		fmt.Fprintln(wr, "No")
	}
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;

using namespace std;

//Binary exponent
ll Bin_pow(ll a,ll b)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
        {
            res=res*a;
        }
        a=a*a;
        b>>=1;
    }
    return res;
}

//GCD
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll t;
	cin>>t;
	map<string,ll>mp;
	while(t--)
	{
	    string s;
	    cin>>s;
	    mp[s]++;
	}
	
    cout<<"AC x "<<mp["AC"]<<"\n";
    cout<<"WA x "<<mp["WA"]<<"\n";
    cout<<"TLE x "<<mp["TLE"]<<"\n";
    cout<<"RE x "<<mp["RE"]<<"\n";
}

Measured memory_bytes: 3684
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <bitset>

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

using namespace std;

int main() {
	int N, A = 0, B = 0;
	scanf("%d", &N);
	vector<int> a(N);
	rep(i, N) {
		scanf("%d", &a[i]);
	}
	sort(a.begin(), a.end(), greater<int>());

	for (int i = 0; i < N; i++) {
		if ((i + 1) % 2 == 0) B += a[i];
		else A += a[i];
	}

	printf("%d", A - B);
}




Measured memory_bytes: 3764
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    if(x < 1200)
        cout << "ABC" << endl;
    else
        cout << "ARC" << endl;

    return 0;
}


Measured memory_bytes: 256
import Data.List

exist :: Int -> Int -> [Int] -> [Int] -> Bool
exist x' y' xs ys =
  case find (\z -> and (map (< z) xs) && and (map (>= z) ys)) zs of
    Just _  -> True
    Nothing -> False
 where zs = [(x'+1)..y']

main = do
  [_, _, x', y'] <- map read.words <$> getLine
  xs <- map read.words <$> getLine
  ys <- map read.words <$> getLine
  if exist x' y' xs ys then putStrLn "No War" else putStrLn "War"


Measured memory_bytes: 1020
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
int n;
int main(){
  scan(n);
  if(n==10||n==100||n==1000||n==10000||n==100000){
    prin(10);
  }
  else{
    int res=n%10;
    while(n>=10){
      n/=10;	    
      res+=n%10;
    }
    prin(res);
  }

  return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
s = input()

if s[k-1] == 'A':
    s = s[:k-1]+'a'+s[k:]
elif s[k-1] == 'B':
    s = s[:k-1]+'b'+s[k:]
else:
    s = s[:k-1]+'c'+s[k:]

print(s)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;

typedef struct {
	int t;
	int x;
	int y;
} datum;

bool cmp_t(const datum &left, const datum &right) {
	return left.t < right.t;
}

int main()
{
	int A1,A2,A3;
	cin >> A1 >> A2 >> A3;
	if ( (A1 + A2 + A3) >= 22) cout << "bust" << endl;
	else cout << "win" << endl;
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  int a = (n + 1) / 2;
  cout << setprecision(15) << (float) a / n << endl;
}


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

#define fi first
#define se second
#define pb push_back
#define sz(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " is " << x << "\n";

using ll = long long;
using ii = pair<ll,ll>;

const int N = 2e5+10;
int n, a[N], b[N];

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++) cin >> b[i];
  reverse(b, b + n);
  for(int l = 0; l < n; l++) {
    if(a[l] != b[l]) continue;
    int r = l;
    while(r + 1 < n && a[r + 1] == b[r + 1]) r++;

    vector<int> idx;
    for(int i = 0; i < n; i++) if(a[i] != a[l] && b[i] != b[l]) 
      idx.push_back(i);
    if(sz(idx) < r - l + 1) { cout << "No\n"; return 0; }
    for(int i = 0; i < r - l + 1; i++) 
      swap(b[l + i], b[idx[i]]);
  }
  cout << "Yes\n";
  for(int i = 0; i < n; i++) cout << b[i] << " "; cout << "\n";
  return 0;
}

Measured memory_bytes: 5848
def resolve():
    n, m, c = map(int, input().split())
    b = [int(i) for i in input().split()]

    ans = 0
    for _ in range(n):
        a = [int(i) for i in input().split()]
        _ans = 0
        for _a, _b in zip(a, b):
            _ans += (_a * _b)
        if _ans + c > 0:
            ans += 1

    print(ans)


resolve()

Measured memory_bytes: 3060
#include <stdio.h>

int main(int argc,char* argv[]){
  int m,d;
  int sumdays;
  int months_days[] = {31,29,31,30,31,30,31,31,30,31,30,31};
  int i;
  char* str;
  
  for(;;){
    sumdays = 0;
    scanf("%d %d",&m,&d);
    if(m == 0){break;}
    
    sumdays += d;
    for(i = 0; i < (m - 1);i++){
      sumdays+= months_days[i];
    }
    
    switch(sumdays%7){
    case 0:
      str = "Wednesday";
      break;
    case 1:
      str = "Thursday";
      break;
    case 2:
      str = "Friday";
      break;
    case 3:
      str = "Saturday";
      break;
    case 4:
      str = "Sunday";
      break;
    case 5:
      str = "Monday";
      break;
    case 6:
      str = "Tuesday";
      break;
    }

    printf("%s\n",str);
    
  }
  
  
  return 0;
  
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 00:25:12 2019

@author: yuta
"""

C1 = list(map(int,input().split()))
C2 = list(map(int,input().split()))
C3 = list(map(int,input().split()))

def mat(m):
    count = 0
    for i in range(len(m)):
        for j in range(len(m)):
            if m[i][j] != 0:
                count += 1
    if count == 0:
        return 0
    else:
        return 1
    
def main(c1,c2,c3):
#行列の要素を挿入
    matrix_i = [c1,c2,c3]
    min_i = [min(c1),min(c2),min(c3)]
    min_j = [0,0,0]
#i行の最小値をi行から引く
    for i in range(3):
        for j in range(3):
            matrix_i[i][j] = matrix_i[i][j] - min_i[i]
    matrix_j = matrix_i
#j列の最小値をmin_jに入れる
    for j in range(3):
        min_j[j] = min(matrix_i[0][j],matrix_i[1][j],matrix_i[2][j])
#j列の最小値をj列から引く
    for i in range(3):
        for j in range(3):
            matrix_j[i][j] = matrix_j[i][j] - min_j[j]
#行列の全成分が0ならYes,違うならNo
    if mat(matrix_j) == 0:
        print("Yes")
    else:
        print("No")    

main(C1,C2,C3)


Measured memory_bytes: 3064
import numpy as np
 
N,T = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
AB = sorted(AB)

dp = np.zeros(T,np.int64)  
ans = 0
for a, b in AB:
    ans = max(ans, dp.max() + b)
    np.maximum(dp[a:], dp[:-a] + b, out=dp[a:])
print(ans)

Measured memory_bytes: 12776
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;

int main(void) {
	int i, a = 0;
	ll ans = 0;
	string x, s = "";
	cin >> x;
	for (i = 0; i < x.size() - 1; i++) {
		if (x[i] == 'B' && x[i + 1] == 'C') {
			s += "D";
			i++;
		}
		else
			s += x[i];
	}
	if (x.size() > 1 && x[x.size() - 2] != 'B' || x[x.size() - 1] != 'C')
		s += x[x.size() - 1];
	for (i = 0; i < s.size(); i++) {
		switch (s[i]) {
		case 'A':
			a++;
			break;
		case 'D':
			ans += a;
			break;
		default:
			a = 0;
			break;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 776
N, M = map(int, input().split())
List = [list(map(int, input().split())) for i in range(N)]

def hantei(x):
  for j in range(N):
    if x not in List[j][1:]:
      return(0)
  return(1)

ans = 0
for i in range(1,M+1):
  ans = ans + hantei(i)
print(ans)

Measured memory_bytes: 3060
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	l := getNextInt64(scanner)
	r := getNextInt64(scanner)
	aa := make([]int64, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt64(scanner)
	}
	dp1 := halfdp(n>>1, aa[:n>>1])
	dp2 := halfdp(n-n>>1, aa[n>>1:])
	kk1 := make([][]int64, n+1)
	kk2 := make([][]int64, n+1)
	for i := 0; i < len(dp1); i++ {
		kk1[dp1[i].k] = append(kk1[dp1[i].k], dp1[i].a)
	}
	for i := 0; i < len(dp2); i++ {
		kk2[dp2[i].k] = append(kk2[dp2[i].k], dp2[i].a)
	}
	var ans int64
	for i := 0; i < k+1; i++ {
		ans += countless(r+1, kk1[i], kk2[k-i]) - countless(l, kk1[i], kk2[k-i])
	}
	fmt.Fprintln(writer, ans)
}

type pair struct {
	k int
	a int64
}

func halfdp(n int, aa []int64) []pair {
	bb := make([]pair, 1)
	for i := 0; i < n; i++ {
		bb = merge(aa[i], bb)
	}
	return bb
}

func merge(a int64, aa []pair) []pair {
	n := len(aa)
	bb := make([]pair, n)
	for i := 0; i < n; i++ {
		bb[i].k = aa[i].k + 1
		bb[i].a = aa[i].a + a
	}
	cc := make([]pair, n<<1)
	j := 0
	k := 0
	for i := 0; i < n<<1; i++ {
		if isfirst(j, k, aa, bb) {
			cc[i].k = aa[j].k
			cc[i].a = aa[j].a
			j++
			continue
		}
		cc[i].k = bb[k].k
		cc[i].a = bb[k].a
		k++
	}
	return cc
}

func isfirst(a, b int, aa, bb []pair) bool {
	if a >= len(aa) {
		return false
	}
	if b >= len(bb) {
		return true
	}
	return aa[a].a <= bb[b].a
}

func countless(n int64, kk1, kk2 []int64) int64 {
	var ans int64
	r := len(kk2) - 1
	for l := 0; l < len(kk1); l++ {
		for r >= 0 && kk1[l]+kk2[r] >= n {
			r--
		}
		ans += int64(r + 1)
	}
	return ans
}



Measured memory_bytes: 87652
let h, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let _ = for i = 1 to h do for j = 0 to w - 1 do Scanf.scanf " %s" (fun s -> if s = "snuke" then Printf.printf "%c%d\n" Char.(chr @@ code 'A' + j) i) done done

Measured memory_bytes: 512
from collections import deque
H,W=map(int,input().split())
S=[input() for i in range(H)]
ans=0
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            continue
        st=(i,j)
        q=deque([st])
        dx=[1,-1,0,0]
        dy=[0,0,1,-1]
        dist=[[-1 for j in range(W)] for i in range(H)]
        dist[st[0]][st[1]]=0
        while(len(q)>0):
            r=q.popleft()
            x,y=r
            for k in range(4):
                nx=x+dx[k]
                ny=y+dy[k]
                if 0<=nx<H and 0<=ny<W:
                    if dist[nx][ny]==-1 and S[nx][ny]==".":
                        dist[nx][ny]=dist[x][y]+1
                        q.append((nx,ny))
        tmp=max([max(i) for i in dist])
        ans=max(tmp,ans)
print(ans)


Measured memory_bytes: 3316
#include <stdio.h>
#define NUM_DIGIT 100

int main(void) {
	int p, q, m, space;
	int mod[NUM_DIGIT];
	size_t i, mod_idx;
	
	while (scanf("%d %d", &p, &q) != EOF) {
		for (mod_idx = 0; mod_idx < NUM_DIGIT; mod_idx++) {
			mod[mod_idx] = 0;
		}
		mod_idx = 0;
		m = p % q;
		p = m * 10;
		mod[mod_idx++] = m;

		space = -1;
		while (m) {
			putchar((p / q) + '0');
			m = p % q;
			p = m * 10;
			for (i = 0; mod[i]; i++) {
				if (m == mod[i]) {
					space = i;
					break;
				}
			}
			if (space >= 0)
				break;
			mod[mod_idx++] = m;
		}
		putchar('\n');

		if (m) {
			mod_idx -= space;
			while (space--) {
				putchar(' ');
			}
			while (mod_idx--) {
				putchar('^');
			}
			putchar('\n');
		}
	}
	return 0;
}

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

int n;
unordered_map<int, double> dp[301][301];

double rec(int a, int b, int c) {
	if (a == 0 && b == 0 && c == 0) return 0;
	if (dp[a][b].count(c)) return dp[a][b][c];
	
	double res = 1. / (1. * (a + b + c) / n);	
	if (a > 0) {
		res += 1. * a / (a + b + c) * rec(a - 1, b, c); 
	}
	if (b > 0) {
		res += 1. * b / (a + b + c) * rec(a + 1, b - 1, c);
	}
	if (c > 0) {
		res += 1. * c / (a + b + c) * rec(a, b + 1, c - 1);
	}
	
	//cerr << a << " " << b << " " << c << " " << res << endl;
	
	return dp[a][b][c] = res;
}
int main() {
	cin >> n;
	
	int a = 0;
	int b = 0;
	int c = 0;
	
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		
		if (x == 1) a++;
		if (x == 2) b++;
		if (x == 3) c++;
	}
	
	printf("%.10lf\n", rec(a, b, c));
}


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

void answer1() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  long long a, b, x;
  cin >> a >> b >> x;
  // 素朴な実装
  long long count = 0;
  for (long long i = a; i <= b; i++) {
    if (i % x == 0) {
      count++;
    }
  }
  cout << count << endl;
}

void answer2() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  long long a, b, x;
  cin >> a >> b >> x;
  long long count = (b / x) - (a / x);
  if (a % x == 0) {
    count++;
  }
  cout << count << endl;
}

int main() {
  //answer1(); // 実行時間制限超過
  answer2();
}


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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007
#define int long long

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N;

void init()
{
	cin >> N;
}

bool ch(int x)
{
	int r = 0;
	int t = 1;
	while (x) {
		if (x % 4 == 1) r += t * 3;
		if (x % 4 == 2) r += t * 5;
		if (x % 4 == 3) r += t * 7;
		t *= 10;
		x /= 4;
	}
	return N >= r;
}

int calc(int x)
{
	int a[4] = {0, 0, 0, 0};
	while (x) {
		a[x % 4] = 1;
		x /= 4;
	}
	if (a[0]) return 0;
	reps(i, 1, 4) if (a[i] == 0) return 0;
	return 1;
}

void solve()
{
	int i = 0;
	int res = 0;
	while (ch(i)) {
		res += calc(i);
		i++;
	}
	cout << res << endl;
}





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

int main() {
  long long N, a=1e9, b;
  cin >> N;
  
  b = (a-(N%a))%a;
  cout << "0 0 1000000000 1 " << b << " " << (N+b)/a;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  string S;
  cin >> S;
  
  if (N % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  
  string s1;
  s1 = S.substr(N/2);
  S = S.erase(N/2);
  
  if (s1 == S) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<vector<ll>>v;
int main() {
	ll n,i,j,k;
	cin>>n>>k;
	vector<ll>v(n);
	for(i=0;i<n;i++){
	    cin>>v[i];
	}
	sort(v.begin(),v.end());
	bool a[k+1]={0};
	for(i=0;i<=k;i++){
	    for(j=0;j<n;j++){
	        if(v[j]<=i && a[i-v[j]]==0){
	            a[i]=1;
	        }
	    }
	}
	if(a[k]==1){
	    cout<<"First";
	}
	else{
	    cout<<"Second";
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  vector<pair<int,int> > r(m);
  REP(i,m){cin>>r[i].first>>r[i].second;r[i].second--;}
  sort(r.begin(),r.end());
  int range[200003][2];
  REP(i,n){
      range[i][0] = range[i][1] = i;
  }
  REP(i,m){
      int ind = r[i].second;
      range[ind][0] = min(range[ind][0],ind);
      range[ind][1] = max(range[ind][1],max(ind + 1,range[ind+1][1]));
      range[ind+1][0] = min(range[ind+1][0],min(ind,range[ind][0]));
      range[ind+1][1] = max(range[ind+1][1],ind + 1);
  }
  REP(i,n){
      if(i)cout << ' ';
      cout << range[i][1] - range[i][0] + 1;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 5196
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

const int st_num = 100005;
int st_nowpc[st_num];
int st_lastin[st_num];
vector<pair<int,int> > st_GatData[st_num];
int main(){
	while(1){
		REP(i,st_num){
			st_nowpc[i] = 0;
			st_GatData[i].clear();
		}
		int N,M;
		int r;
		cin >> N >> M;
		if(N==0&&M==0) break;
		cin >> r;
		REP(i,r){
			int t,n,m,s;
			cin >> t >> n >> m >> s;
			if(s==1) {
				if(st_nowpc[m]==0) {
					st_lastin[m] = t;
				}
				st_nowpc[m]++;
			}
			if(s==0){
				st_nowpc[m]--;
				if(st_nowpc[m]==0){
					st_GatData[m].pb(make_pair(st_lastin[m],t));
				}
			}
		}
		int q;
		cin >> q;
		REP(i,q){
			int ts,tm,m;
			cin >> ts >> tm >> m;
			ll int sum = 0;
			REP(j,st_GatData[m].size()){
				int sttime = max(st_GatData[m][j].first,ts);
				int endtime = min(st_GatData[m][j].second,tm);
				if(endtime-sttime>0) sum+=(endtime-sttime);
			}
			cout << sum << endl;
		}
	}

}

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

int main() {
	int h, w, k; 
	cin >> h >> w >> k;
	vector<string> S(h);
	rep(i, h) cin >> S[i];
	int ans = 1001001001;
	rep(bit, (1 << h - 1)) {
		int cnt_h = 0;
		rep(i, h - 1) if (bit & (1 << i)) cnt_h++;
		int cnt_w = 0;
		vector<int> sum(cnt_h + 1, 0);
		bool elf = true;
		rep(i, w) {
			vector<int> tmp(cnt_h + 1, 0);
			int now = 0;
			rep(j, h) {
				if (S[j][i] == '1') tmp[now]++;
				if (bit & (1 << j)) {
					now++;
				}
			}
			rep(j, cnt_h + 1) {
				if (tmp[j] > k) elf = false;
				if (sum[j] + tmp[j] > k) {
					cnt_w++;
					rep(k, cnt_h + 1) {
						sum[k] = tmp[k];
					}
					break;
				}
				else {
					sum[j] += tmp[j];
				}
			}
		}
		if (!elf) continue;
		ans = min(ans, cnt_h + cnt_w);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import itertools
import copy

input = sys.stdin.readline
n, m = map(int, input().split())
drink = []
for _ in range(n):
    a, b = map(int, input().split())
    drink.append([a, b])
drink.sort()
ans = 0
for i in range(n):
    num = drink[i][1]
    if num <= m:
        ans += drink[i][0] * num
        m -= num
    else:
        ans += drink[i][0] * m
        m = 0
    if m == 0:
        break
print(ans)


Measured memory_bytes: 20544
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n;
	while (cin >> n, n) {
		vector<int>v(10001,0);
		rep(i, 0, n) {
			int p, a, b; cin >> p >> a >> b;
			v[p] = a + b;
		}
		auto it = max_element(all(v));
		cout << distance(v.begin(), it) << " " << *it << endl;
	}
	return 0;
}

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

using namespace std;

const int md = int(1e9) + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

const int N = 100010;

int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;

  vector<int> fac(N * 2), finv(N * 2);
  fac[0] = finv[0] = 1;
  for (int i = 1; i < 2 * N; i++) {
    fac[i] = mul(fac[i - 1], i);
    finv[i] = inv(fac[i]);
  }

  auto get = [&](int m, int n) {
    int res = fac[m + n];
    res = mul(res, finv[m]);
    res = mul(res, finv[n]);
    return res;
  };

  int ans = 0, l, r;
  for (int i = 0; i < h - a; i++) {
    l = get(i, b - 1);
    r = get(h - i - 1, w - b - 1);
    add(ans, mul(l, r));
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1920
n,y = list(map(int,input().split()))
y /= 1000
ans = [0,0,0]
# print(y)
for i in range(n+1):
    for j in range(0,n+1-i):
        a = i*10 + j*5
        b = i+j
        # print(a,b)
        if a + (n-(i+j)) == y:
            ans = [i,j,n-(i+j)]

if sum(ans) >0:
    print(ans[0],ans[1],ans[2])
else:
    print(-1,-1,-1)

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

long gcd(long x, long y) {
  if (x < y) swap(x, y);
  long t;
  while (x % y != 0) {
    t = x % y;
    x = y;
    y = t;
  }
  return y;
}

long lcm(long x, long y) {
  return x * y / gcd(x, y);
}

int main() {
  long x,y;
  cin>>x>>y;

  cout << lcm(x,y);

  return 0;
}


Measured memory_bytes: 256