akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mkmap;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<vi> vv;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
const ll mod=1000000007;
const int sz=1000001;
#define endl "\n"
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b) for(i=a;i<b;++i)
#define rrep(i,a,b) for(i=a;i>=b;--i)
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db(x) cout << (#x) << " = " << x << endl;

inline ll mult(ll a, ll b) {return (((a % mod) * (b % mod)) % mod);}

vector<vector<ll> > dp;

ll fun(vp &a,int i,int w){
    if(i<0 || w<1) return 0;
    if(dp[w][i]!=-1) return dp[w][i];
    if(a[i].F>w) return dp[w][i]=fun(a,i-1,w);
    return dp[w][i]=max(a[i].S+fun(a,i-1,w-a[i].F),fun(a,i-1,w));
}

int main(){
    fast;
    int t,tt,tti,n,m,x,y,z,i,j,k,temp,count,o,e,f,ans,sum,l,r,mx,mn;
    ll lx,ly,lz,ltemp;
    double fx,fy,fz;
    string s;
    
    cin>>n>>x;
    vp a(n);
    rep(i,0,n) cin>>a[i].F>>a[i].S;
    dp.resize(x+1,vector<ll>(n,-1));
    cout<<fun(a,n-1,x);
    // for(auto i:dp){
    //     for(auto j:i) cout<<j<<" ";
    //     cout<<endl;
    // }
}

/*
    
*/

Measured memory_bytes: 82304
<?php
  fscanf(STDIN,"%d%d",$n,$m);
$s_c = array();
for($i=0;$i<$m;$i++){
  fscanf(STDIN,"%d%d",$s,$c);
  if(isset($s_c[$s])&&$s_c[$s]!=$c){
    echo "-1\n";
    exit;
  }else{
	  $s_c[$s] = $c;
  }
}

 if(isset($s_c[1]) && $s_c[1] == 0 && $n>1){
    echo "-1";
    exit;
 }
for($i=1;$i<=$n;$i++){
  if(isset($s_c[$i])){
    echo $s_c[$i];
  }elseif($i==1 && $n!=1){
    echo 1;
  }else{
    echo 0;
  }
 }

//print_r($s_c);

Measured memory_bytes: 4732
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    int X, Y;
    cin >> X >> Y;
    int ans = 0;
    if(X == 1 && Y == 1) ans += 400000;
    if(X == 1) ans += 300000;
    if(X == 2) ans += 200000;
    if(X == 3) ans += 100000;
    if(Y == 1) ans += 300000;
    if(Y == 2) ans += 200000;
    if(Y == 3) ans += 100000;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>

using namespace std;


long int topDown(const vector<int> &w, const vector<long int> &p, vector<vector<long int> > &dp, int i, int s)
{
	if(i >= w.size() || s == 0)
		return 0;
	
	if(dp[i][s] == -1)
	{
		if(s - w[i] >= 0)
			dp[i][s] = max(topDown(w, p, dp, i+1, s), topDown(w, p, dp, i+1, s - w[i]) + p[i]);
		else
			dp[i][s] = topDown(w, p, dp, i+1, s);

	}
	
	return dp[i][s];
}

int main()
{
	int n, W;
	vector<long int> p;
	vector<int> w;
	vector<vector<long int> > dp;

	cin>>n>>W;

	p.resize(n);
	w.resize(n);
	dp.resize(n);

	for(int i = 0;i < n;i++)
	{
		cin>>w[i]>>p[i];
		dp[i].assign(W+1, -1);
	}

	
	cout<<topDown(w, p, dp, 0, W)<<'\n';

	return 0;
}


Measured memory_bytes: 78592
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
int a,b,x;
cin>>a>>b>>x;
if(a>x) cout<<"NO";
if(a==x) cout<<"YES";
if(a<x){
if((a+b)>=x){
    cout<<"YES";
}
else cout<<"NO";
}

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

int main()
{
	int n;
	cin >> n;
	
	vector<long long> t(n);
	for(int i = 0; i < n; i++)
	{
		cin >> t[i];
	}
	
	long long ans = 0;
	for(int i = 0; i < n; i++)
	{
		long long tmp = t[i];
		if(i == 0)
		{
			ans = tmp;
		}
		else
		{
			if(ans % tmp == 0 || tmp % ans == 0)
			{
				ans = ans > tmp ? ans : tmp;
			}
			else
			{
				long long euc = ans > tmp ? euclid(ans, tmp) : euclid(tmp, ans);
				ans = ans * (tmp / euc);
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<sstream>
#include<set>

using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n); i++)
#define forsn(i,s,n) for(int i=(s);i<(int)(n); i++)
#define esta(x,v) (find((v).begin(),(v).end(),(x)) !=  (v).end())
#define index(x,v) (find((v).begin(),(v).end(),(x)) - (v).begin())
#define debug(x) cout << #x << " = "  << x << endl
#define pb push_back
#define mp make_pair

typedef long long tint;
typedef pair<int,int> pint;
typedef pair<tint,tint> ptint;
typedef unsigned long long utint;
typedef long double ldouble;

typedef vector<int> vint;

int toNumber (string s)
{
	int Number;
	if ( ! (istringstream(s) >> Number) ) Number = 0; // el string vacio lo manda al cero
	return Number;
}

string toString (int number)
{
    ostringstream ostr;
    ostr << number;
    return  ostr.str();
}

tint ele(tint a, tint b){
	if(b==0)return 1;
	if(b%2==0){
		return ele(a*a, b/2);
	}else{
		return a*ele(a*a, b/2);
	}
}

tint mcd(tint a, tint b){
	if(a==0)return b;
	return mcd(b%a, a);
}

double d_abs(long a, long b){
	if(a>b){
		return a-b;
	}
	return b-a;
}

string s;
vector<int> L, p;

void findLongestPalindromicString()
{
   string s2="|";
   forn(i, s.size()){
	   s2+=s[i];
	   s2+='|';
   }
   forn(i, s2.size()*2)p.pb(-1);
   int c = 0, r = 0; // Here the first element in s2 has been processed.
	int m = 0, n = 0; // The walking indices to compare if two elements are the same
	for (int i = 1; i<(int)s2.size(); i++) {
		if (i>r) {
			p[i] = 0; m = i-1; n = i+1;
		} else {
			int i2 = c*2-i;
			if (p[i2]<(r-i-1)) {
				p[i] = p[i2];
				m = -1; // This signals bypassing the while loop below. 
			} else {
				p[i] = r-i;
				n = r+1; m = i*2-n;
			}
		}
		while (m>=0 && n<(int)s2.size() && s2[m]==s2[n]) {
			p[i]++; m--; n++;
		}
		if ((i+p[i])>r) {
			c = i; r = i+p[i];
		}
	}
	
    
}

void posta(string t){
	int m=(int)t.size();
	set<string> ans;
	forn(i, m){
		forsn(j, i+2, m){
			//cout<<i<<", "<<j<<endl;
			string cambio=t.substr(0, i);
			string rev="";
			forsn(a, i, j){
				rev=t[a]+rev;
			}
			cambio+=rev;
			cambio+=t.substr(j);
			//cout<<"eee "<<cambio<<endl;
			if(ans.find(cambio)==ans.end()){
				ans.insert(cambio);
				cout<<"meto "<<t.substr(i, j-i)<<": "<<cambio<<endl;
			}else{
				cout<<"no meto "<<t.substr(i, j-i)<<endl;
			}
		}
	}
	cout<<ans.size()<<endl;
}


void solve(){
	string t;
	cin>>t;
	tint m=t.size();
	map<char, tint> mapi;
	for(char a='a'; a<='z'; a++)mapi[a]=0;
	forn(i, m)mapi[t[i]]++;
	tint total=m*(m-1)/2;
	total++;
	for(char a='a'; a<='z'; a++){
		total-=mapi[a]*(mapi[a]-1)/2;
	}
	cout<<total<<endl;
}




int main (){
	int T;
	T=1;
	while(T--){
		solve();
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define Yay(s) s?cout << "Yay!" << endl:cout << ":(" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl
//#define P pair<int,int>


signed main(){
    int A,B;
    cin >> A >> B;
    cout << (A-1)*(B-1) << endl;
    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N; cin >> N;
  vector<int> A(N);
  for (auto& a : A) { cin >> a; }
  
  int res = 1;
  for (const auto& a : A) {
    if (a % 2 == 0) {
      auto p = a % 3 == 0 || a % 5 == 0;
      if (!p) {
        res = 0;
      }
    }
  }
  auto ans = res ? "APPROVED" : "DENIED";
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    int r = 0, g = 0, b = 0;
    rep(i, N) {
        if (S[i] == 'R') r++;
        if (S[i] == 'G') g++;
        if (S[i] == 'B') b++;
    }
    ll ans = (ll)r * g * b;
    rep(i, N) {
        REP(j, i + 1, N - 1) {
            int k = 2 * j - i;
            if(k >= N) continue;
            if(S[i] == S[j] || S[j] == S[k] || S[k] == S[i]) continue;
            ans--;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
LL x, y;
LL ans = 0;
/**********************************************/

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

    while(y >= x){
        ans++;
        y /= 2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
w_v = [list(map(int, input().split())) for i in range(N)]

w = [w_v[i][0] for i in range(N)]
v = [w_v[i][1] for i in range(N)]

#dp[i+1][j]:i番目までの品物で重さがjとなるときの価値の総和

dp = [[0 for j in range(W+1)] for i in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if j >= w[i]:
            dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])

Measured memory_bytes: 171656
use std::collections::VecDeque;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

const WHITE: u8 = 0;

const INFINITY: u64 = 10000000;

fn bfs(m: &Vec<Vec<u8>>, s: usize, color: &mut Vec<u8>, d: &mut Vec<u64>) {
    let mut q: VecDeque<u64> = VecDeque::new();
    q.push_back(s as u64);
    d[s] = 0;
    while q.len() > 0 {
        let u: usize = q.pop_front().unwrap() as usize;
        for v in 0..color.len() {
            if m[u][v] == 0 {
                continue;
            }
            if d[v] != INFINITY {
                continue;
            }
            d[v] = d[u] + 1;
            q.push_back(v as u64);
        }
    }
    for index in 0..d.len() {
        let number: i64;
        if d[index] == INFINITY {
            number = -1;
        } else {
            number = d[index] as i64;
        }
        println!("{} {}", index + 1, number);
    }
}

fn main() {
    let n: usize = read();
    let mut color: Vec<u8> = vec![WHITE; n];
    let mut m: Vec<Vec<u8>> = vec![vec![0; n]; n];
    let mut d: Vec<u64> = vec![INFINITY; n];
    for _ in 0..n {
        let index: usize = read();
        let count: usize = read();
        for _ in 0..count {
            let number: usize = read();
            m[index - 1][number - 1] = 1;
        }
    }
    bfs(&m, 0, &mut color, &mut d)
}



Measured memory_bytes: 5032
#include <stdio.h>

int main(void){
    int H,W,i,j;
    for(;;){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0) break;
        for(j=0;j<W;j++){
            printf("#");
        }
        printf("\n");
        for(i=1;i<H-1;i++){
            printf("#");
            for(j=1;j<W-1;j++){
                printf(".");
            }
            printf("#");
            printf("\n");
        }
        for(j=0;j<W;j++){
            printf("#");
        }
        printf("\n");
        printf("\n");
    }
    return 0;
}


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

using namespace std;

#define N 120000

int n,rta,rtb,sa[N],sb[N],A[N],B[N],c[N];
vector<int> a[N],b[N],g[N];
bool vis[N];

void add(int x,int y){
	g[x].push_back(y); g[y].push_back(x);
}

void dfs1(int u){
	for (int v:a[u]){
		sa[u]^=1;
		dfs1(v);
		if (A[u]){add(A[u],A[v]); A[u]=0;}
		else A[u]=A[v];
	}
	if (!A[u]) A[u]=u;
}

void dfs2(int u){
	for (int v:b[u]){
		sb[u]^=1;
		dfs2(v);
		if (B[u]){add(B[u],B[v]); B[u]=0;}
		else B[u]=B[v];
	}
	if (!B[u]) B[u]=u;
}

void dfs(int u){
	vis[u]=1;
	for (int v:g[u]) if (!vis[v]){c[v]=-c[u]; dfs(v);}
}

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i){
		int x; scanf("%d",&x);
		if (~x) a[x].push_back(i); else rta=i;
	}
	for (int i=1;i<=n;++i){
		int x; scanf("%d",&x);
		if (~x) b[x].push_back(i); else rtb=i;
	}
	dfs1(rta); dfs2(rtb);
	for (int i=1;i<=n;++i){
		if (sa[i]^sb[i]){puts("IMPOSSIBLE"); return 0;}
		if (sa[i]) vis[i]=1;
	}
	for (int i=1;i<=n;++i) if (!vis[i]){c[i]=1; dfs(i);}
	puts("POSSIBLE");
	for (int i=1;i<=n;++i) printf(i==n?"%d\n":"%d ",c[i]);
	
	return 0;
}
			

Measured memory_bytes: 22528
# nCk ( O(N) )
N_MAX = 10**6
MOD = 10**9 + 7
fac, finv, inv = [0]*N_MAX ,[0]*N_MAX, [0]*N_MAX
def com_init():
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1
    for i in range(2, N_MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

def com(n, k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

com_init()
n,k = map(int, input().split())
ans = 0
max_k = min(n-1,k)
for i in range(max_k+1):
    ans += (com(n,i)*com(n-1,i))
    ans%=MOD
print(ans)

Measured memory_bytes: 94164
S = input()

if 0 <= int(S[0:2]) <= 99 and 1 <= int(S[2:4]) <= 12:
    if (13 <= int(S[0:2]) <= 99 or int(S[0:2]) == 0) and 1 <= int(S[2:4]) <= 12:
        print("YYMM")
    elif 1 <= int(S[0:2]) <= 12 and 1 <= int(S[2:4]) <= 12:
        print("AMBIGUOUS")

elif 1 <= int(S[0:2]) <= 12 and 0 <= int(S[2:4]) <= 99:
    if 1 <= int(S[0:2]) <= 12 and (13 <= int(S[2:4]) <= 99 or int(S[2:4]) == 0):
        print("MMYY")
    elif 1 <= int(S[0:2]) <= 12 and 1 <= int(S[2:4]) <= 12:
        print("AMBIGUOUS")

else:
    print("NA")

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

INF = float('inf')


def main():
    N = int(input())
    A = list(map(int, input().split()))

    alice = 0
    bob = 0

    A = sorted(A, reverse=True)

    for _ in range(N):
        if len(A) != 0:
            alice += A.pop(0)
        if len(A) != 0:
            bob += A.pop(0)

    print(alice - bob)


if __name__ == '__main__':
    main()


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

const long long MAXprime=150000LL;
bool bp[MAXprime];

void boolprime()
{
	for (long long i = 0; i < MAXprime; ++i) bp[i]=1;
	bp[0]=0, bp[1]=0;
	for (long long i = 2; i*i < MAXprime; ++i)
	{
		if(bp[i])
		{
			for (long long j = 2; i*j < MAXprime; ++j) bp[i*j]=0;
		}
	}
}

int main(int argc, char const *argv[])
{
	boolprime();
	int memo[100005]={};
	for (int i = 1; i < 100005; i+=2)
	{
		if (bp[i]==1&&bp[(i+1)/2]==1)
		{
			memo[i]=1;
		}
	}
	int ans[100005]={};
	for (int i = 0; i < 100004; ++i)
	{
		ans[i+1]=ans[i]+memo[i];
	}
	int q;
	cin>>q;
	int l,r;
	for (int i = 0; i < q; ++i)
	{
		cin>>l>>r;
		cout<<ans[r+1]-ans[l]<<endl;
	}
	return 0;
}


Measured memory_bytes: 1536
// Implementation practice (Have seen the editorial)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef set<int> si;
typedef priority_queue<int> pqi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define loop(i, a) for (int i = 0; i < (a); i++)
#define loop1(i, a) for (int i = 1; i <= (a); i++)
#define loopr(i, a, b) for (int i = (a); i <= (b); i++)
#define dloop(i, a) for (int i = (a) - 1; i >= 0; i--)
#define dloopr(i, b, a) for (int i = (b); i >= (a); i--)
#define show(a) cout << a << "\n"
#define showloop(a, len) for (int i = 0; i < len; i++) cout << a[i] << "\n"
#define itloop(a, len) for (int i = 0; i < len; i++) cout << a[i] << "\n"
#define debug(a) cout << #a << ": " << (a) << "\n"
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) ((int)x.size())
#define ran(a, b) ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a))
const int MOD = 1000000007;
const double PI = acos(-1);

const int MAX = 1e5 + 10;
int n;
int L[MAX], R[MAX];

int main() {
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	ios::sync_with_stdio(false);cin.tie(NULL);

	mem(L, 0); mem(R, 0);
	cin >> n;
	loop1(i, n) {
		int l, r;
		cin >> l >> r;
		L[l] = 1; R[r] = 1;
	}

	int ans = 0, counter = 0;
	loop1(i, MAX - 1) {
		if (L[i]) counter++;
		if (counter > 0) ans++;
		if (R[i]) counter--;
	}

	show(ans);

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
	int ans = 0, n = 0, a;
	cin >> n;
	for (int i = 1; i <= n; i++) { cin >> a; ans += a; }
	if (ans % 2 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

using namespace std;

int main(){
	long long i,x;
	
	for(i=1;i<=i;i++){
		cin>>x;
		if(x==0) break;
		  else cout<<"Case "<<i<<": "<<x<<endl;
	}
			      
	return 0;
}


Measured memory_bytes: 3068
import sys
input = sys.stdin.readline
import numpy as np

N, K = [int(item) for item in input().split()]
h =np.array([int(item) for item in input().split()])
# print(h.shape)
dp = np.full(N+K, 10**10+1, dtype='int64')
dp[0] = 0

for i in range(1, N):
    max1 = min(N, i+K)
    cost = abs(h[i:max1] - h[i-1])
    # print(cost.shape, dp[i:max1].shape)
    dp[i:max1] = np.minimum(dp[i:max1], dp[i-1] + cost)

    # print(dp)
print(dp[N-1])


Measured memory_bytes: 23068
using System;
using System.Linq;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long res = 0;
        for (int i = 1; i < n / 2; i++)
        {
            var max = (n - 1) % i == 0 ? n / 2 : n - i;
            var cur = 0L;
            for (int j = 0; j < max; j += i)
                res = Max(res, cur += a[j] + a[n - 1 - j]);
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 30044
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli x[550][550];
	
signed main(){

	lli n,m,q;
	cin>>n>>m>>q;

	for(lli i=1;i<=m;i++){
		lli l,r;
		cin>>l>>r;
		x[l][r]++;
	}
	for(lli i=1;i<=n;i++){
		for(lli j=1;j<=n;j++){
			x[i][j]+=x[i][j-1];
		}
	}
	for(lli i=1;i<=n;i++){
		for(lli j=1;j<=n;j++){
			x[i][j]+=x[i-1][j];
		}
	}



	for(lli i=1;i<=q;i++){
		lli l,r;
		cin>>l>>r;
		cout<<x[r][r]+x[l-1][l-1]-x[r][l-1]-x[l-1][r]<<endl;
	}


	return 0;
 
}

Measured memory_bytes: 3072
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define sort_v(a) sort(a.begin(), a.end())

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

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;
}


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

int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i,n)
    {
        ll y = n/i;

        ans+=(y*(y+1)*i)/2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
N = int(input())

memo = [0] * 4
for i in range(N):
    str = input()
    if (str == 'AC'):
        memo[0] = memo[0] + 1
    elif (str == 'WA'):
        memo[1] = memo[1] + 1
    elif (str == 'TLE'):
        memo[2] = memo[2] + 1
    else:
        memo[3] = memo[3] + 1

print('AC x', memo[0])
print('WA x', memo[1])
print('TLE x', memo[2])
print('RE x', memo[3])


Measured memory_bytes: 69896
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}
string a[]={
"",
"',.!?",
"abcABC",
"defDEF",
"ghiGHI",
"jklJKL",
"mnoMNO",
"pqrsPQRS",
"tuvTUV",
"wxyzWXYZ"
};

int b[]={0,5,6,6,6,6,6,8,6,8};

int main(void){
  string str;
  while(getline(cin,str)){
    int n = 0 , m = 0;
    rep(i,str.size()){
      if(n == 0){
	if(str[i] == '0'){
	  cout<<' ';
	}else{
	  m = 1;
	}
      }else{
	if(str[i] == n +'0'){
	  ++m;
	}else{
	  cout<<a[n][--m%b[n]];
	  m = 1;
	}
      }
      n = str[i] - '0';
    }
    cout<<a[n][--m%b[n]]<<endl;
  }

}

Measured memory_bytes: 1184
n, q = map(int, input().split())

n_ = 1 # 実際に確保した配列のサイズ
while n_ < n:
  n_ *= 2

seg_tree = [0 for i in range(2*n_-1)]

def add(i, x):
  i += n_ - 1
  seg_tree[i] += x
  while i > 0 :
    i = int((i - 1)/2)
    #seg_tree[i] = seg_tree[i*2+1] + seg_tree[i*2+2]
    seg_tree[i] += x

def getSum(s, t):
  return query(s, t+1, 0, 0, n_)

def query(a, b, k, l, r):
  if r <= a or b <= l :
    return 0
  if a <= l and r <= b:
    return seg_tree[k]

  vl = query(a, b, k*2+1, l, int((l+r)/2))
  vr = query(a, b, k*2+2, int((l+r)/2), r)
  return vl + vr


output = []

for i in range(q):
  # print(seg_tree)
  line = list(map(int, input().split()))

  if line[0] == 0:
    add(line[1]-1, line[2])

  else :
    output.append(getSum(line[1]-1,line[2]-1))


for ans in output:
  print(ans)


Measured memory_bytes: 13048
#include <bits/stdc++.h>
using namespace std;
int n,a,b,cnt1,cnt2,dist1[100001],dist2[100001];
vector<int> g[100001];
void dfs1(int v,int p)
{
	for (int i=0;i<g[v].size();++i)
		if (g[v][i]!=p)
		{
			dist1[g[v][i]]=dist1[v]+1;
			dfs1(g[v][i],v);
		}
}
void dfs2(int v,int p)
{
	for (int i=0;i<g[v].size();++i)
		if (g[v][i]!=p)
		{
			dist2[g[v][i]]=dist2[v]+1;
			dfs2(g[v][i],v);
		}
}
int main()
{
	cin>>n;
	for (int i=0;i<n-1;++i)
	{
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs1(1,1);
	dfs2(n,n);
	for (int i=1;i<=n;++i)
		if (dist1[i]<=dist2[i]) ++cnt1;
		else ++cnt2;
	if (cnt1>cnt2) cout<<"Fennec";
	else cout<<"Snuke";
	return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

#define INF 10000000000

using namespace std;

typedef long long ll;

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

    vector<ll> dp(N, INF);
    dp[0] = 0;
    for (int i=1; i<=N; i++) {
        for (int j=max(0, i-K); j<i; j++) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }

    cout << dp[N-1] << endl;

    return 0;
}

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

using namespace std;

int main()
{
    char s1[100],s2[100],s3[100];
    char c1,c2,c3;
    scanf("%s  %s %s",&s1,&s2,&s3);
    c1=s1[0];
    c2=s2[0];
    c3=s3[0];
    printf("%c%c%c",c1, c2, c3);
    
}

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

ll minCost(ll arr[], ll n, ll dp[], ll k){

    if(dp[n] != -1)
        return dp[n];

    if(n == 1)
        return 0;

    ll ans = INT_MAX, ans1 = INT_MAX;

    for(ll i=1; i<=k; i++){
        if(n-i > 0)
            ans1 = abs(arr[n] - arr[n-i]) + minCost(arr, n-i, dp, k);
        ans = min(ans, ans1);
    }
    
    dp[n] = ans;

    return dp[n];
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n, k;
    cin >> n >> k;
    
    ll arr[n+1] = {0}, dp[n+1] = {0};
    dp[0] = -1;
    
    for(ll i=1; i<=n; i++){
        cin >> arr[i];
        dp[i] = -1;
    }
    
    cout << minCost(arr, n, dp, k) << endl;

    return 0;
}

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

using namespace std;


int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = n; i > 0; i--) {
        string a = to_string(i);
        if (a.size() % 2 != 0) ans++;
    }
 
    cout << ans << endl;
 
    return 0;
}

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

int main(){
    int i, n;
    cin >> n;
    double v[n], result;
    for(i=0; i<n; i++){
        cin >> v[i];
    }
    sort(v, v+n);
    result = v[0];
    for(i=1; i<n; i++){
        result = (result + v[i])/2.0;
    }
    printf("%.5lf", result);
    return 0;
}

Measured memory_bytes: 256
// Created by CAD on 2020/4/18.
#include <bits/stdc++.h>

#define fi first
#define se second
#define inf 0x3f3f3f3f
#define INF 0x7fffffffffffffff
#define mst(name, value) memset(name,value,sizeof(name))
#define FOPEN freopen("C:\\Users\\14016\\Desktop\\cad.txt","r",stdin)
#define tst1(a) cout<<#a<<":"<<a<<endl
#define tst2(a, b) cout<<#a<<":"<<a<<" "<<#b<<":"<<b<<endl
#define tst3(a, b, c) cout<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<endl
#define tst4(a, b, c, d) cout<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<" "<<#d<<":"<<d<<endl
#define lson (p<<1)
#define rson (p<<1|1)
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define ll long long
#define lowbit(i) (i&-i)
using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin >> n;
    ll ans=0;
    for(int i=1; i<=n; ++i)
        for(int j=1; j<=n; ++j)
            for(int k=1;k<=n;++k)
                ans+=__gcd(__gcd(i,j),k);
    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3624
<?php
list($n,$m) = explode(" ", trim(fgets(STDIN)));

//gyo-retuA
for($i = 0; $i < $n; $i++){
    $a[] = explode(" ", trim(fgets(STDIN)));
}

//gyo-retuB
for($i = 0; $i < $m; $i++){
    $b[] = trim(fgets(STDIN));
}

for($i = 0; $i < $n; $i++){
    $c[$i] = 0;
    for($j = 0; $j < $m; $j++){
        $c[$i] += $b[$j] * $a[$i][$j];
    }
    echo $c[$i].PHP_EOL;
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << min(a, b) + min(c, d) << '\n';
  return 0;
}


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

int num;
int a[21][21];

int retcost(int Island){
	int x=0;
	for(int i=1;i<=num;i++){
		if(a[Island][i]){
			a[i][Island]=0;
			x=max(x,a[Island][i]+retcost(i));
		}
	}
	return x;
}

int main(void){
	while(cin>>num,num){
		int I1,I2,t,ans,I[num+1]={},Cost=0;
		memset(a,0,sizeof(a));
		for(int i=1;i<num;i++){
			cin>>I1>>I2>>t;
			a[I1][I2]=a[I2][I1]=t;
			I[I1]++,I[I2]++;
			Cost+=t*2;
		}
		for(int i=1;i<=num;i++){
			for(int j=1;j<=num;j++){
				if((I[i]==1||I[j]==1)&&!((i==1&&I[i]==1)||(j==1&&I[j]==1))){
					Cost-=a[i][j]*2;
					a[i][j]=a[j][i]=0;
				}
			}
		}
		ans=Cost-retcost(1);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    int A, B, C, X, count = 0;
    scanf("%d%d%d%d", &A, &B, &C, &X);

    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            for(int k = 0; k <= C; k++){
                if(i * 500 + j * 100 + k * 50 == X)
                    count++;
                if(i * 500 + j * 100 + k * 50 >= X)
                    break;
            }
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
using Graph = vector<vector<int>>;

signed main() {
  string N;
  cin >> N;
  if( N.at(0) == '7' || N.at(1) == '7' || N.at(2) == '7' ) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3624
#include<algorithm>
#include<cassert>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    lint m, d;
    cin >> m >> d;

    lint ans = 0;
    reps(i, m){
        reps(j, d){
            vector<lint> v;
            lint t = j;
            while(t){
                v.push_back(t % 10);
                t /= 10;
            }

            if((int)v.size() > 1 && v[0] >= 2 && v[1] >= 2 && v[0] * v[1] == i){
                ++ans;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var sum = 0d;
        for (int i = 0; i < n; i++)
        {
            var ab = Console.ReadLine().Split(' ');
            var a = double.Parse(ab[0]);
            if (ab[1] == "JPY")
            {
                sum += a;
            }
            else
            {
                sum += a * 380000;
            }
        }
        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> Hs(N);
  for (int i = 0; i < N; i++) { cin >> Hs.at(i); }
  int count = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i; j >= 0; j--) {
      if (Hs.at(j) > Hs.at(i)) { break; }
      if (j == 0) { count++; }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
from sys import stdin
N=(stdin.readline().rstrip())
A=0
B=0
for ind,i in enumerate(list(N)):
    if ind%2==0 and i != "0":
        A+=1
    elif ind%2!=0 and i != "1":
        A+=1

for ind,i in enumerate(list(N)):
    if ind%2==0 and i != "1":
        B+=1
    elif ind%2!=0 and i != "0":
        B+=1
print(min(A,B))

Measured memory_bytes: 3956
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
using lint = long long;

#pragma GCC optimize ("Ofast", "unroll-loops")
#pragma GCC target ("arch=ivybridge")

const int nmax = 204800, block = 4096, unrl = 16;
int a[nmax], b[nmax];

int main() {

	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d", &a[i]);
	for (int i = 0; i < N; i++) scanf("%d", &b[i]);

	int ans = 0;
	for (int i = 0; i + unrl <= N; i += unrl) {
		for (int j = 0; j + block <= N; j += block) {
			for (int k = j; k < block + j; k++) {

				ans ^= (a[i + 0] + b[k]) ^ (a[i + 1] + b[k]);
				ans ^= (a[i + 2] + b[k]) ^ (a[i + 3] + b[k]);
				ans ^= (a[i + 4] + b[k]) ^ (a[i + 5] + b[k]);
				ans ^= (a[i + 6] + b[k]) ^ (a[i + 7] + b[k]);
              	ans ^= (a[i + 8] + b[k]) ^ (a[i + 9] + b[k]);
				ans ^= (a[i + 10] + b[k]) ^ (a[i + 11] + b[k]);
				ans ^= (a[i + 12] + b[k]) ^ (a[i + 13] + b[k]);
				ans ^= (a[i + 14] + b[k]) ^ (a[i + 15] + b[k]);

			}
		}
	}

	for (int i = 0; i < N / unrl * unrl; i++) {
		for (int j = N / block * block; j < N; j++) {
			ans ^= a[i] + b[j];
		}
	}	
	for (int i = N / unrl * unrl; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ans ^= a[i] + b[j];
		}
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("1 6");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("12345 678901");
            //175897
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        long[] wkArr = InputList[0].Split(' ').Select(X => long.Parse(X)).ToArray();

        long N = wkArr[0];
        long M = wkArr[1];

        Console.WriteLine(ExecNibunHou(N, M));
    }

    //2分法で最大で何件のSccを作れるかを返す
    static long ExecNibunHou(long pS, long pC)
    {
        long L = 0;
        long R = pS + pC;

        while (L + 1 < R) {
            long Mid = (L + R) / 2;

            bool CanCreate = DeriveCanCreate(Mid, pS, pC);
            if (CanCreate) L = Mid;
            else R = Mid;
        }
        return L;
    }

    //K個のSccを作れるかを返す
    static bool DeriveCanCreate(long pK, long pS, long pC)
    {
        //Cを作成
        if (pK * 2 > pC)
            return false;
        pC -= pK * 2;

        //Sを作成
        if (pK > pS + pC / 2)
            return false;

        return true;
    }
}


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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    string a, b, c;
    cin >> a >> b >> c;

    i64 ans = 0;
    for (i64 i = 0; i < n; i++) {
        switch ((a[i] == b[i]) + (b[i] == c[i]) + (c[i] == a[i])) {
        case 0:
            ans += 2;
            break;
        case 1:
            ans += 1;
            break;
        case 3:
            ans += 0;
            break;
        }
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 764
import java.util.Scanner;

class XCubic {
	private static final int STOP_CNT = 3;
	private int _x;
	public XCubic(int x) {
		_x = x;
	}
	public int calc(int cnt) {
		if (STOP_CNT <= cnt)
			return _x;
		
		return _x * calc(cnt + 1);
	}
}

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		XCubic xCubic = new XCubic(Integer.parseInt(scan.next()));
		System.out.println(xCubic.calc(1));
	}

}



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

int main(){
  long double x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  //cout<<pow(pow(x2-x1,2)+pow(y2-y1,2),0.5)<<endl;
  cout<<std::setprecision(10)<<sqrt(x1*x1+y1*y1+x2*x2+y2*y2-(x1*x2+y2*y1)*2)<<endl;
  //cout<<hypot(x2-x1,y2-y1)<<endl;
}



Measured memory_bytes: 3292
x = int(input())
dp = [0]*(x+105+1)
dp[100] = 1 
dp[101] = 1
dp[102] = 1
dp[103] = 1
dp[104] = 1
dp[105] = 1

for i in range(100,x+1):
    for j in range(100,106):
        dp[i+j] = max(dp[i] , dp[i+j])

print(dp[x])

Measured memory_bytes: 9500
#include <bits/stdc++.h>
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)
#define rep(i, n) repi(i, 0, n)
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
// using P = pair<int, int>;
struct Vec{
    double x, y;
};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
     return false;
}
using namespace std;
int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    int d, t, s;
    cin >> d >> t >> s;
    if (d / (double)s > t) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

#define endl "\n"

const int MAXN = 25;
const int MAXMASK = (1<<21)+10;
const int MOD = int(1e9) + 7;

int n;
bool comp[MAXN][MAXN];
int memo[MAXMASK];

int solve(int i, int mask){
    if(memo[mask]!=-1) return memo[mask];

    if(i>=n) return (mask==((1<<n)-1));

    memo[mask] = 0;
    for(int j=0; j<n; j++){
        if(comp[i][j] && (mask&(1<<j))==0){
            memo[mask] =( (memo[mask]+solve(i+1, mask|(1<<j)))>=MOD ?
                         (memo[mask]+solve(i+1, mask|(1<<j))) - MOD:
                         (memo[mask]+solve(i+1, mask|(1<<j))) );
        }
    }

    return memo[mask];
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;

    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin >> comp[i][j];

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

    cout << solve(0, 0) << endl;

    return 0;
}


Measured memory_bytes: 8448
#include<stdio.h>
#include<stdlib.h>
using namespace std;

int main () {
  int sx, sy, tx, ty;

  scanf("%d %d %d %d", &sx, &sy, &tx, &ty);

  // s ---> t
  for (int i = 0; i < abs(tx - sx); i++) {
    if (tx - sx > 0) printf("R");
    else printf("L");
  }
  for (int i = 0; i < abs(ty - sy); i++) {
    if (ty - sy > 0) printf("U");
    else printf("D");
  }

  // t ---> s
  for (int i = 0; i < abs(tx - sx); i++) {
    if (tx - sx > 0) printf("L");
    else printf("R");
  }
  for (int i = 0; i < abs(ty - sy); i++) {
    if (ty - sy > 0) printf("D");
    else printf("U");
  }
  
  // s ---> t
  if (ty - sy > 0) printf("D");
  else printf("U");
  for (int i = 0; i < abs(tx - sx) + 1; i++) {
    if (tx - sx > 0) printf("R");
    else printf("L");
  }
  for (int i = 0; i < abs(ty - sy) + 1; i++) {
    if (ty - sy > 0) printf("U");
    else printf("D");
  }
  if (tx - sx > 0) printf("L");
  else printf("R");

  // t ---> s
  if (ty - sy > 0) printf("U");
  else printf("D");
  for (int i = 0; i < abs(tx - sx) + 1; i++) {
    if (tx - sx > 0) printf("L");
    else printf("R");
  }
  for (int i = 0; i < abs(ty - sy) + 1; i++) {
    if (ty - sy > 0) printf("D");
    else printf("U");
  }
  if (tx - sx > 0) printf("R");
  else printf("L");
  printf("\n");

  return 0;
}


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

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    for (auto t : s)
    {
        cout << 'x';
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int A[100100];

signed main() {
    int N;
    cin >> N;
    rep(i, N) {
        cin >> A[i];
    }
    if (N == 2) {
        cout << abs(A[0] - A[1]) << endl;
        return 0;
    }
    sort(A, A + N);
    int chu = A[N / 2];
    int ans = 0;
    rep(i, N) {
        ans += abs(A[i] - chu) * 2;
    }
    ans -= abs(A[N / 2 - 1] - chu);

    int chu2 = A[(N - 1) / 2];
    int ans2 = 0;
    rep(i, N) {
        ans2 += abs(A[i] - chu2) * 2;
    }
    ans2 -= abs(A[N / 2 + 1] - chu2);
    
    cout << max(ans, ans2) << endl;
    return 0;
}


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

using namespace std;

const int N = 1e5 + 5;

int cost[N];
bool vis[N];
int dp[N];
int mincost [N];
int n;

int calcmincost (int x ) {
	
	
	if (x <= 1 ) return 0;
	
	if (mincost[x] != -1) return mincost[x];
	
	mincost[x]=min ( calcmincost(x-1) + abs(cost[x] - cost[x-1]) , calcmincost(x-2) + abs(cost[x] - cost[x-2])) ;
	return mincost[x];
}

int main (){
	memset(mincost,-1, sizeof mincost);
	scanf("%d",&n);
	
	for (int i=1;i<=n;i++) scanf("%d",&cost[i]);
	
	
	cost[0]=-1e9;
	mincost[1]=0;
	
	calcmincost(n);
	cout<<mincost[n];



}
	
	



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

const int N = 1e6 + 100;

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> A(n), B(n);
    for(int i = 0; i < n; i++) {
        cin >> A[i] >> B[i];
    }
    sort(A.rbegin(), A.rend());
    sort(B.begin(), B.end());

    if(n%2 == 1) {
        int r = B[n/2];
        int l = A[n/2];
        cout << r-l+1 << endl;
    }
    else {
        int l = A[n/2]+A[n/2-1], r = B[n/2]+B[n/2-1];
        cout << r-l+1 << endl;
    }

    return 0;
}



Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
int main() {
	int l=0,s=0,n;
	for(int i=0;i<5;i++){
		cin>>n; s+=(n+9)/10*10; l=max(l,(10-n%10)%10);
	}
	cout<<s-l;
}

Measured memory_bytes: 3564
# ac_072_b
# 英小文字からなる文字列S
# 前から数えて奇数文字列目だけ抜き出して作った文字列を出力。
# 文字列の先頭の文字を１文字目とする。

s = input()

# [0::2]０番目はじめて2つ刻みの意味[0,1,2,3,4,5]の場合[0,2,4,]=奇数番目になる。
# [1::2]１番目めからはじめて２つ刻み[0,1,2,3,4,5]の場合[1,3,5]=偶数番目になる。
# 奇数番目のみ抽出したい場合。
print(s[0::2])


Measured memory_bytes: 8868
#include <stdio.h>
int main(void){
  int a,b,c,max=0;
  scanf("%d%d%d",&a,&b,&c);
  max=(a>b)? a:b;
  if (max<c) max=c;
  printf("%d\n",a+b+c-max);
  return 0;
}

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

#define INF (1e9)
#define ul unsigned long

using namespace std;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}

struct Compare {
    constexpr bool operator()(tuple<ul, ul, ul, ul> const & a,
                              tuple<ul, ul, ul, ul> const & b) const noexcept
    { return get<0>(a) > get<0>(b); }
};


int main() {
    ul X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    vector<ul> A(X), B(Y), C(Z);
    cin >> A;
    cin >> B;
    cin >> C;
    sort(A.begin(), A.end(), greater<ul>());
    sort(B.begin(), B.end(), greater<ul>());
    sort(C.begin(), C.end(), greater<ul>());

    // vector<ul> arrived(X * Y * Z, 0);
    set<tuple<ul, ul, ul>> arrived;
    priority_queue<tuple<ul, ul, ul, ul>,
        vector<tuple<ul, ul, ul, ul>>,
        Compare> keys;
    keys.push(make_tuple(0, 0, 0, 0));

    const int indexes[][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};

    for (int i = 0; i < K; i++) {
        auto cur = keys.top();
        keys.pop();
        ul x = get<1>(cur);
        ul y = get<2>(cur);
        ul z = get<3>(cur);
        printf("%lu\n", A[x] + B[y] + C[z]);
        for (auto idx : indexes) {
            ul nx = x + idx[0];
            ul ny = y + idx[1];
            ul nz = z + idx[2];
            auto tmp = make_tuple(nx, ny, nz);
            if (nx >= X || ny >= Y || nz >= Z)
                continue;
            // if (arrived[nx + X*ny + X*Y*nz])
            //     continue;
            if (arrived.find(tmp) != arrived.end())
                continue;
            ul val = (A[0] - A[nx]) + (B[0] - B[ny]) + (C[0] - C[nz]);
            keys.push(make_tuple(val, nx, ny, nz));
            // arrived[nx + X*ny + X*Y*nz] = 1;
            arrived.insert(tmp);
        }
    }
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
int a[100003], b[100002];
int main() {
	int n;
	cin >> n;
	rep(i, n+1) cin >> a[i];
	rep(i, n)  cin >> b[i];
	ll cnt = 0;
	rep(i, n) {
		if (a[i] >= b[i]) {
			cnt += b[i];
			a[i] -= b[i];
		} else {
			cnt += a[i];
			b[i] -= a[i];
			a[i] = 0;
			if (a[i+1] >= b[i]) {
				cnt += b[i];
				a[i+1] -= b[i];
			} else { 
				cnt += a[i+1];
				b[i] -= a[i+1];
				a[i+1] = 0;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

int a[100];

int main()
{
    int count = 0;
    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {
            a[count++] = i * j;
        }
    }
    int n;
    cin >> n;
    for (int i = 0; i < count; i++)
    {
        if (a[i] == n)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256