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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    vector<vector<ll>> A;
    ll maxi = 0;
    cin >> N;
    A.resize(2, vector<ll>(N));
    rep(i, 2) rep(j, N) cin >> A[i][j];
    rep(i, N) {
        ll count = 0;
        rep(j, N) {
            if(i == j) {
                count += A[0][j];
                count += A[1][j];
            } else if(i > j) {
                count += A[0][j];
            } else {
                count += A[1][j];
            }
        }
        maxi = max(maxi, count);
    }
    cout << maxi << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <array>
#include <tuple>
#include <utility>
#include <numeric>
#include <iomanip>
#include <cctype>
#include <cmath>
#include <assert.h>
#include <cstdlib>
#include <list>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s << "[";
    for (int i = 0; i < v.size(); i++) s << (i == 0 ? "" : ", ") << v[i];
    s << "]";
    return s;
}

#define ALL(a) (a).begin(), (a).end()

int main() {
    int n;
    ll t;
    cin >> n >> t;

    vector<ll> times(n);
    for (int i = 0; i < n; i++) {
        cin >> times[i];
    }
    ll ans = 0,
       cur = 0;
    for (int i = 0; i < n; i++) {
        if (i > 0) ans += min(t, times[i] - cur);
        cur = times[i];
    }
    ans += t;
    cout << ans << endl;

    return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(5e5 + 5);

/////////////////////////////////////////////////////////////
class StringMatching {
 public:
  static const int MAX_N = (int)(8e6 + 100);

  string s;
  string t;
  string phi;
  string sct;
  vector<int> z;

  StringMatching(string s, string t, char phi) {
    this->s = s;
    this->t = t;
    this->phi = phi;
    this->z = vector<int>(MAX_N, 0);
    init();
  }

  void init() {
    sct = t + phi + s;
    make_z();
  }

  void make_z() {
    int n = sct.size();
    int l = 0, r = 0;

    z[0] = sct.size();

    for (int i = 1; i < n; ++i) {
      if (i > r) {
        l = r = i;
        while (r < n && sct[r - l] == sct[r]) r += 1;

        z[i] = r - l;
        r -= 1;
      } else {
        int k = i - l;  // focus at prefix-substring (begin with sct[k]) with which already dealed

        // no prefix-substring (begin with sct[i]) longer than (r - i + 1) could be expected
        // since, "sct[0..(r - l)] == sct[l..r]" entails "sct[k..(r - l)] == sct[i..r]",
        // but z[k] is smaller than length of sct[i..r]
        if (z[k] < r - i + 1) {
          z[i] = z[k];
        } else {  // there could be longer prefix-substring (begin with sct[i])
          l = i;
          while (r < n && sct[r - l] == sct[r]) r += 1;

          z[i] = r - l;
          r -= 1;
        }
      }
    }
  }

  bool match_from(int i) {
    return z[t.size() + 1 + i] == t.size();
  }
};
/////////////////////////////////////////////////////////////

string s;
string t;

vector<int> graph[MAX_N];
vector<int> tsorted;
int flg[MAX_N];  // 0: not-visited, 1: done, -1, temporary

int path[MAX_N];

int ans;

bool visit(int i) {
  if (flg[i] == -1) {
    return false;
  }

  if (flg[i] == 0) {
    flg[i] = -1;

    for (auto &e : graph[i]) {
      if (!visit(e)) {
        return false;
      }
    }

    flg[i] = 1;

    tsorted.push_back(i);
  }

  return true;
}

bool topological_sort() {
  for (int i = 0; i < s.size(); ++i) {
    flg[i] = 0;
  }

  for (int i = 0; i < s.size(); ++i) {
    if (flg[i] == 0) {
      if (!visit(i)) {
        return false;
      }
    }
  }

  reverse(tsorted.begin(), tsorted.end());

  return true;
}

int main(void) {
  // Here your code !
  cin >> s;
  cin >> t;

  int target_size = s.size() + t.size();

  string s_replicate = s;

  while (s_replicate.size() < target_size) {
    s_replicate += s;
  }

  StringMatching sm(s_replicate, t, '_');

  for (int i = 0; i < s.size(); ++i) {
    if (sm.match_from(i)) {
      int target = (i + t.size()) % s.size();

      graph[i].push_back(target);
    }
  }

  if (!topological_sort()) {
    printf("%d\n", -1);
    return 0;
  }

  int length = 0;

  for (auto &e: tsorted) {
    for (auto &child: graph[e]) {
      path[child] = max(path[child], path[e] + (int)(t.size()));
      length = max(length, path[child]);
    }
  }

  ans = length / t.size();

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

  return 0;
}


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

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

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let nm = read_vec::<u64>();
    let (n,m) = (nm[0],nm[1]);
    let v = read_vec2::<u64>(m as u32);
    let ans = v.into_iter().fold(HashMap::new(),|mut map,x| {
        let y = map.get(&x[0]).map(|i| i + 1).unwrap_or(1);
        let z = map.get(&x[1]).map(|i| i + 1).unwrap_or(1);
        map.insert(x[0], y);
        map.insert(x[1], z);
        map
    });
    // let mut ans:Vec<_> = sub.iter().collect();
    // ans.sort_by(|a,b| a.0.cmp(b.0));
    for m in 1..n+1 {
        println!("{}", ans.get(&m).unwrap_or(&0) );
    }
}

Measured memory_bytes: 4352
//#define _GLIBCXX_DEBUG
//#define _CRTDBG_MAP_ALLOC
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const ll LINF = 9187201950435737471;
const ll nLINF = -9187201950435737472;
const int INF = 2139062143;
const int nINF = -2139062144;
const ull ULINF = numeric_limits<ull>::max();
const int MAXN = 4000 + 15;
const ll MOD = 1e9 + 7;
int C = 700;
const double PI = acos(-1);
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd;

#define all(_v) _v.begin(), _v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define sqr(_v) (_v * _v)
#define vi vector <int>
#define vii vector <pair <int, int> >
#define eb emplace_back


inline void IO() {
#if(DEBUG_LEVEL > 0)
    freopen("../input.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
}

template <typename T>
istream& operator >> (istream& in, vector<T>& a) {
    for (auto& i : a)
        in >> i;
    return in;
}

template <typename T>
ostream& operator << (ostream& out, const vector<T>& a) {
    for (auto& i : a) {
        out << i << " ";
    }
    return out;
}

template <typename T, typename D>
istream& operator >> (istream& in, pair<T, D>& a) {
    in >> a.first >> a.second;
    return in;
}

template <typename T, typename D>
ostream& operator << (ostream& out, const pair<T, D>& a) {
    out << a.first << " " << a.second;
    return out;
}

inline void solve() {
    ll h, n;
    cin >> h >> n;
    while (n--) {
        ll x;
        cin >> x;
        h -= x;
    }
    if (h <= 0) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}

signed main() {
    IO();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int MAX_N = 200005;
const ll MOD = 1e9+7;
ll A[MAX_N],B[MAX_N];
map<P,P> ab;

ll mygcd(ll a, ll b)
{
	if (b == 0) return a;
	else return mygcd(b,a%b);
}

ll pow2(ll n)
{
	if (n == 0) return ll(1);
	if (n == 1) return ll(2);
	if (n % 2 == 0)
	{
		ll p = pow2(n/2);
		return p*p%MOD;
	}
	else
	{
		return 2 * pow2(n-1) % MOD;
	}
}

int main()
{
	ll N;
	cin >> N;
	rep(i,N)
	{
		cin >> A[i] >> B[i];
		ll g = mygcd(abs(A[i]),abs(B[i]));
		if (g != 0)
		{
			A[i] /= g;
			B[i] /= g;
		}
	}
	/*
	rep(i,N)
	{
		cout << A[i] << " " << B[i] << endl;
	}
	*/
	ll ans = 1;
	ll cnt0 = 0;
	rep(i,N)
	{
		if (A[i] == 0 && B[i] == 0)
		{
			cnt0++;
			continue;
		}
		if (A[i] < 0 || (A[i] == 0 && B[i] < 0))
		{
			A[i] *= -1;
			B[i] *= -1;
		}
		if (B[i] > 0) ab[P(A[i],B[i])].first++;
		else ab[P(ll(-1) * B[i],A[i])].second++;
	}
	for (auto i : ab)
	{
		ans = ans * (pow2(i.second.first) + pow2(i.second.second) + MOD - 1) % MOD;
		//cout << i.first.first << " " << i.first.second << " ";
		//cout << ans << endl;
	}
	ans = (ans + cnt0 + MOD - 1) % MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 22196
#include <iostream>

using namespace std;

int main()
{
    int n, k, x = 1, cnt = 0;
    cin >> n >> k;
    while (x * 2 <= x + k && cnt != n) {
        cnt++;
        x *= 2;
    }
    cout << x + (n - cnt) * k;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=5e3+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
}
int n;
const int mo=1e9+7;
vector<int>E[N];
#define pb push_back
void input()
{
	int x,y;
	n=read<int>();
	For(i,2,n)
	{
		x=read<int>(),y=read<int>();
		E[x].pb(y),E[y].pb(x);
	}
}
int mc[N],dp[N][N],size[N],tmp[N];
void add(int &x,int y)
{
	x+=y;x-=(x>=mo?mo:0);
}
void DP(int u,int pre)
{
	size[u]=1;
	dp[u][1]=1;
	for(int v:E[u])if(v^pre)
	{
		DP(v,u);
		For(i,0,size[u]+size[v])tmp[i]=0;
		For(i,0,size[u])For(j,0,size[v])add(tmp[i+j],1ll*dp[u][i]*dp[v][j]%mo);
		For(i,0,size[u]+size[v])dp[u][i]=tmp[i];
		size[u]+=size[v];
	}
	For(i,1,size[u])add(dp[u][0],mo-1ll*dp[u][i]*mc[i]%mo);
}
void work()
{
	mc[0]=1;
	For(i,1,n)if(mc[i]%2==0)mc[i]=1ll*mc[i-2]*(i-1)%mo;
	DP(1,0);
	write((mo-dp[1][0])%mo,'\n');
}
int main()
{
	input();
	work();
	return 0;
}

Measured memory_bytes: 97408
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	VI h, w;
	while (true) {
		int x, y;
		cin >> x >> y;
		if (x == 0 && y == 0)break;
		h.PB(x); w.PB(y);
	}
	rep(i, SZ(h)) {
		int x = h[i], y = w[i];

		rep(j, x) {
			rep(k, y) {
				if ((j + k) % 2 == 0)cout << "#";
				else cout << ".";
			}
			puts("");
		}
		puts("");
	}
}


Measured memory_bytes: 3120
#include <iostream>

using namespace std;

int main(){
  int n,c[200];
  while(cin>>n,n){
    for(int i=0;i<2*n;++i) c[i]=0;
    for(int i=0;i<n;++i){
      int t;cin>>t;c[t-1]=1;
    }
    int p=0,q=0;
    bool f=true,g=false;
    while(1){
      for(int i=0;i<2*n;++i){
	if(f&&c[i]==1){
	  c[i]=-1;f=false;++p;
	}
	else if(!f&&c[i]==0){
	  c[i]=-1;f=true;++q;
	}
	if(p==n||q==n){
	  g=true;break;
	}
      }
      if(f) f=false;
      else f=true;
      if(g) break;
    }
    cout<<((p==n)?p-q:0)<<'\n'<<((q==n)?q-p:0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include<climits>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int getAverageScore(int N, VI S){
	int min = S[0];
	int max = S[0];
	int sum = 0;
	FOR(i, 0, N){
		sum += S[i];
		if (min >= S[i]){ min = S[i]; }
		if (max <= S[i]){ max = S[i]; }
	}
	sum -= min;
	sum -= max;
	return sum / (N-2);
}
int main(){
	int N;
	VI S;
	int b;
	int c = INT_MAX;
	while (true){
		cin >> N;
		if (N == 0){ break; }
		//if (c != INT_MAX){ cout << endl; }
		REP(i, N){
			cin >> b;
			S.push_back(b);
		}
		c = getAverageScore(N, S);
		cout << c << endl;
		S.clear();
	}
	return 0;
}

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

using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)for(auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second;debug("%s: %.5lf s\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()/1000.0), blockTime.second = false)

template <typename T>std::string NumberToString ( T Number ){std::ostringstream ss; ss << Number;return ss.str(); } // Usages NumberToString(3)
template <typename T>T StringToNumber ( const string &Text ){istringstream ss(Text);T result;return ss >> result ? result : 0;} // StringToNumber<int>("3")

string StrCpy(string str, long long int start, long long int end){string temp = "";for(long long int i=start; i<=end; i++){temp += str[i];}return temp;}

#define ull unsigned long long int
#define ll long long int 
#define gcd(a, b)  __gcd(a, b)
#define lcm(a, b)  ((a*b)/gcd(a, b))

ll vec[1000009];
ll val[1000009];
ll prio[100009][5];

int solve(){
    ll N,M;
    cin >> N >> M;
    val[0] = 0;
    for(ll i=1; i<=N; i++){
        cin >> val[i];
    }

    ll a,b;

    for(ll i=0; i<M; i++){
        cin >> a >> b;
        if(val[b]>prio[a][0]){
            prio[a][0] = val[b];
        }
        if(val[a]>prio[b][0]){
            prio[b][0] = val[a];
        }
    }

    ll cnt = 0;

    for(ll i=1; i<=N; i++){
        if(prio[i][0] < val[i]){
            //cout << " == " << i  << endl;
            cnt++;
        }
    }

    cout << cnt << endl;

   

    return 0;
}

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

    time__("programm time"){
        solve();
	}
    return 0;

}

Measured memory_bytes: 8448
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	Integer d[] = new Integer[n];
	int size = 101;
	int count = 0;

	for(int i=0;i<n;i++) {
		d[i]  = sc.nextInt();
	}
	Arrays.sort(d,Collections.reverseOrder());
	for(int i=0;i<n;i++) {
		if(size>d[i]) {
			size = d[i];
			count++;
		}
	}
	System.out.println(count);
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
int a[101];
int ans=0;
int comp(const int &a,const int &b)
{
    return a>b;
}
using namespace std;
int main () {
int n,k;
cin>>n>>k;
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<n;i++)
sort(a,a+n+1,comp);
for(int i=0;i<k;i++){
 ans+=a[i];
  }
cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int min(int a,int b){
    return(a>b)?b:a;
}

int main(void){
    int n,res=0;
    scanf("%d",&n);
    int b[n];
    for(int i=0;i<n-1;i++)scanf("%d",&b[i]);
    for(int i=n-2;i>0;i--){
        res+=min(b[i],b[i-1]);
    }
    printf("%d\n",res+b[0]+b[n-2]);
    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ans = 0
    for a, b in combinations(A, 2):
        ans += a*b
    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62572
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        
        if(a >= 13){
            System.out.println(b);
        }else if(a >= 6){
            System.out.println(b/2);
        }else{
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 23508
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;
	public static Node[] nodes;
	public static StringBuilder ans;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int V = sc.nextInt();
		nodes = new Node[V];
		int[] in_num = new int[V];

		for(int i = 0; i < V; i++){
			in_num[i] = 0;
		}

		int node_id,left_child,right_child;

		for(int loop = 0; loop < V; loop++){

			node_id = sc.nextInt();
			left_child = sc.nextInt();
			right_child = sc.nextInt();

			nodes[node_id] = new Node(left_child,right_child);

			if(left_child != -1){
				in_num[left_child]++;
			}
			if(right_child != -1){
				in_num[right_child]++;
			}
		}

		int root = -1;
		for(int i = 0; i < V; i++){
			if(in_num[i] == 0){
				root = i;
				break;
			}
		}

		ans = new StringBuilder();

		ans.append("Preorder\n");
		Preorder(root);
		ans.append("\nInorder\n");
		Inorder(root);
		ans.append("\nPostorder\n");
		Postorder(root);
		ans.append("\n");

		System.out.print(ans.toString());
	}

	public static void Preorder(int node_id){

		ans.append(" ").append(Integer.toString(node_id));

		if(nodes[node_id].left_child != -1){
			Preorder(nodes[node_id].left_child);
		}
		if(nodes[node_id].right_child != -1){
			Preorder(nodes[node_id].right_child);
		}
	}

	public static void Inorder(int node_id){

		if(nodes[node_id].left_child != -1){
			Inorder(nodes[node_id].left_child);
		}
		ans.append(" ").append(Integer.toString(node_id));

		if(nodes[node_id].right_child != -1){
			Inorder(nodes[node_id].right_child);
		}
	}

	public static void Postorder(int node_id){

		if(nodes[node_id].left_child != -1){
			Postorder(nodes[node_id].left_child);
		}
		if(nodes[node_id].right_child != -1){
			Postorder(nodes[node_id].right_child);
		}
		ans.append(" ").append(Integer.toString(node_id));
	}

}


class Node{

	public int left_child;
	public int right_child;

	Node(int arg_left_child,int arg_right_child){
		left_child = arg_left_child;
		right_child = arg_right_child;
	}
}


Measured memory_bytes: 26280
-- | Main entry point to the application.
module Main where

import Control.Applicative
import Control.Monad
import Data.List
import Debug.Trace
import Text.Printf

rInt :: String -> Int
rInt str = read str :: Int

condd :: Int -> Int -> String
condd a b
    | a < b = "a < b"
    | a == b = "a == b"
    | a > b = "a > b"

-- | The main entry point.
main :: IO ()
main = do
    [a, b] <- (map rInt . words) <$> getLine
    putStrLn $ condd a b

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
#define MOD 1000000007
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

int main()
{	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	
	ll n, m;
	cin>>n>>m;
	ll a[n][m];
	for(ll i=0; i<n; i++)
		for(ll j=0; j<m; j++)
			cin>>a[i][j];

	ll count=0;
		for(ll i=0; i<n-1; i++)
		{
			for(ll k=i+1; k<n; k++)
			{	ll sum=0,ans=0;
				double y=0.0;

				for(ll j=0; j<m; j++)
				{
					sum = ( a[i][j] - a[k][j] ) ;
					sum= sum*sum;
					ans+=sum;
				}
				y = sqrt(ans);
				//cout<<y<<" ";
				if( floor(y)==ceil(y))
					count++; 
			}
		}
		cout<<count;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

bool isOK(ll ans, ll K, const priority_queue<tuple<ll, ll, ll>> &q) {
	bool ret = false;
	ll cnt = 0;
	priority_queue<tuple<ll, ll, ll>> tmp_q = q;
	tmp_q.push(make_tuple(0, 0, 1));
	while(cnt<=K) {
		tuple<ll,ll,ll> t = tmp_q.top();
		tmp_q.pop();
		ll x = dup(get<0>(t)-ans, get<2>(t)); // (A*F - ans) / F
		if(x<=0) {
			ret = true;
			break;
		}
		cnt += x;
	}
	
	return ret;
}


int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	vector<ll> F(N);
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> F[i];

	sort(A.begin(), A.end());
	sort(F.begin(), F.end());
	reverse(F.begin(), F.end());
	
	priority_queue<tuple<ll, ll, ll>> que;
	rep(i, N) {
		que.push(make_tuple(A[i]*F[i], A[i], F[i]));
	}
	
	ll left = get<0>(que.top());
	ll right = -1;
	// 二分探索
	while(right+1<left) {
		ll mid = (right + left) /2;
		// cout << "mid: " << mid;
		if(isOK(mid, K, que)){
			left = mid;
			// cout << " is OK" << endl;
		} else {
			right = mid;
			// cout << " is NG" << endl;
		}
	}
	// left ぎりぎりOK
	// right ぎりぎりNG

	cout << left << endl;
	
	return 0;
}

Measured memory_bytes: 20620
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b;
	cin>>a>>b;
	if(a>0)  cout<<"Positive";
	else
	  if(b>=0)  cout<<"Zero";
	    else
	      if((a&1)^(b&1))  cout<<"Positive";
	        else  cout<<"Negative";
	return 0;
}
//>Positive
//<Negative
//Zero 

Measured memory_bytes: 256
<?php

$n = trim(fgets(STDIN));

$count = 0;
for($a=1;$a<$n;$a++){
    for($b=1;$b<$n;$b++){
        if($a*$b < $n){
           $count++; 
        }
        if($a*$b >= $n){
            break;
        }   
    }
}

echo $count;

?>

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    for (int i = 0; i < b; ++i) {
        for (int j = 0; j < a; ++j) {
            cout << "0";
        }
        for (int j = 0; j < w - a; ++j) {
            cout << "1";
        }
        cout << '\n';
    }
    for (int i = 0; i < h - b; ++i) {
        for (int j = 0; j < a; ++j) {
            cout << "1";
        }
        for (int j = 0; j < w - a; ++j) {
            cout << "0";
        }
        cout << '\n';
    }
}

Measured memory_bytes: 1280
from itertools import product
h, w, k = map(int, input().split())
c = [[1 if j == '#' else 0 for j in input()] for i in range(h)]
cnt = 0
for br in product([0, 1], repeat=h):
    for bc in product([0, 1], repeat=w):
        if sum(c[i][j]*br[i]*bc[j] for i, j in product(range(h), range(w))) == k:
            cnt += 1
print(cnt)

Measured memory_bytes: 9144
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define print_array(ary, size) cout << ary[0]; rep1(i, 1, size - 1) cout << ' ' << ary[i]; cout << endl;
typedef long long ll;
typedef unsigned long long ull;

int M[100][100] = { 0 };
int dist[100];

int main()
{
	int n, u, k, v;
	int current;
	int current_dist = 0;
	queue<int> Q;

	cin >> n;
	rep(i, n) {
		dist[i] = -1;
		cin >> u >> k;
		rep(j, k) {
			cin >> v;
			M[u - 1][v - 1] = 1;
		}
	}

	dist[0] = current_dist;
	Q.push(1);

	while (!Q.empty()) {
		current = Q.front();
		current_dist = dist[current - 1];

		rep(i, n) {
			if (M[current - 1][i] && dist[i] == -1) {
				Q.push(i + 1);
				dist[i] = current_dist + 1;
			}
		}
		Q.pop();
	}

	rep(i, n) cout << i + 1 << ' ' << dist[i] << endl;

	return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll getpre(ll i){

	if(i % 4 == 0)return i;
	if(i % 4 == 1)return 1;
	if(i % 4 == 2)return i + 1;
	if(i % 4 == 3)return 0;

}
int main(){
	ll a,b;
	while(cin>>a>>b)
    {
        b = getpre(b);
        if(a) a = getpre(a-1);
        // cout<<"a = "<<a<<"  b = "<<b<<endl;
        cout<<(a^b)<<endl;
    }
	return 0;
}


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

typedef long long ll;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 999999999
#define DEBUG(s) cout << s << endl

using namespace std;

int main()
{
    bool beforeB;
    int ans = 0;
    string s;
    cin >> s;
    REP(i, s.size())
    {
        bool nowB = s[i] == 'B' ? true : false;
        if (i)
            if (beforeB != nowB)
                ans++;
        beforeB = nowB;
    }
    cout << ans;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
  int k, s;
  cin >> k >> s;
  
  int ans0 = 0;
  int ans1 = 0;
  int ans2 = 0;
  int ans3 = 0;
  int ans4 = 0;
 
  for (int x = 0; x <= k; x++) {
    int y = 0;
    for (; y <= k - 1; y += 2) {
      int z = 0;
      for (; z <= k - 3; z += 4) {
        ans0 += x+y+z == s-0; 
        ans1 += 2*(x+y+z == s-1);
        ans2 += 2*(x+y+z == s-2);
        ans3 += 2*(x+y+z == s-3);
        ans4 += x+y+z == s-4; 
      }

      for (; z <= k; z++) {
        ans0 += x+y+z == s;
        ans1 += x+y+z == s-1;
      }
    }
    
    for (; y <= k; y++) {
      int z = 0;
      for (; z <= k - 3; z += 4) {
        ans0 += x+y+z == s-0; 
        ans1 += x+y+z == s-1; 
        ans2 += x+y+z == s-2; 
        ans3 += x+y+z == s-3;
      }

      for (; z <= k; z++) {
        ans0 += x+y+z == s;
      }
    }
  }

  int ans = ans0+ans1+ans2+ans3+ans4;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << max(0,c-abs(a - b)) << endl;
}


Measured memory_bytes: 256
/**
*    created: 15.05.2020 05:20:55
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int main() {
    int r,g;
    cin>>r>>g;
    //r+x=2g
    cout << 2*g-r << endl;
}

Measured memory_bytes: 256
/* ex4_3 melo */
#include <stdio.h>
int Height_Snow(int Height1,int Height2);//プロトタイプ宣言（雪の積もっている高さを返す関数を設定）
int main(void){
    int Height_S_W ,Height_S_E;//整数の箱を二つ用意
    scanf("%d%d",&Height_S_W,&Height_S_E);//雪から塔の頂上までの高さをそれぞれ代入
    printf("%d\n",Height_Snow(Height_S_W,Height_S_E));//雪の積もっている高さを表示
    return 0;
}
int Height_Snow(int Height1,int Height2){//雪の積もっている高さを返す関数
    int Num_W,result;//整数の箱を三つ用意し、そのうち一つに０を代入
    int Tower_H=0;
    Num_W=Height2-Height1-1;//西の方の塔が何番目か
    while(Num_W>0){//西の塔の高さを求める
        Tower_H=Tower_H+Num_W;
        Num_W=Num_W-1;
    }
    result=Tower_H-Height1;//雪の積もっている高さ
    return(result);//雪の積もっている高さを返す
}

Measured memory_bytes: 128
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert
#define aer(v) (v).erase((v).begin(),(v).end()) 

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int dp[111111][3];

main(){
	int n;cin>>n;
	int a[n][3];
	rep(i,n)rep(j,3)cin>>a[i][j];
	//rep(i,3)dp[0][i]=a[0][i];
	rep(i,n){
		dp[i+1][0]+=max(dp[i][1],dp[i][2])+a[i][0];
		dp[i+1][1]+=max(dp[i][0],dp[i][2])+a[i][1];
		dp[i+1][2]+=max(dp[i][0],dp[i][1])+a[i][2];
	}
	dump(max({dp[n][0],dp[n][1],dp[n][2]}));
}






Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {

    private static long[][] dp;
    private static int[] w;
    private static int[] v;

    public static void main( String[] args ) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int w1 = sc.nextInt();

        dp = new long[n + 1][w1 + 1];
        w = new int[n + 1];
        v = new int[n + 1];

        w[0] = 0;
        v[0] = 0;

        for (int i = 1; i <= n; i++) {
            w[i] = Integer.parseInt(sc.next());
            v[i] = Integer.parseInt(sc.next());
        }

        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= w1; j++) {
                dp[i][j] = -1;
            }
        }

        System.out.println(nap(n, w1));
        sc.close();
    }

    private static long nap( int i, int j ) {
        if (dp[i][j] >= 0)
            return dp[i][j];

        long rem;

        if (i == 0) {
            rem = 0;
        }
        //if weight of item is more than remainingWeight then try next item by skipping current item
        else if (j < w[i]) {
            rem = nap(i - 1, j);
        } else {  //try to get maximumValue of either by picking the currentItem or not picking currentItem
            rem = Math.max(nap(i - 1, j - w[i]) + v[i], nap(i - 1, j));
        }

        dp[i][j] = rem;

        return rem;
    }
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "<" << #__VA_ARGS__ << ">:", debug_out(__VA_ARGS__)
#define INF LLONG_MAX


int main()
{
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  if((v-w) * t >= abs(a-b))
	cout << "YES" << endl;
  else
	cout << "NO" << endl;
			 
}


Measured memory_bytes: 3632
import heapq
WHITE = 0
GRAY = 1
BLACK = 2
INFTY = 10**16
def dijkstra(s, VC):
    color = [WHITE for i in range(N)]
    d = [INFTY for i in range(N)]
    d[s] = 0
    pq = []
    heapq.heappush(pq, (0, s))

    while len(pq) != 0:
        u = heapq.heappop(pq)[1]
        color[u] = BLACK

        for v, c in VC[u]:
            if color[v] != BLACK:
                if d[u] + c < d[v]:
                    d[v] = d[u] + c
                    color[v] = GRAY
                    heapq.heappush(pq, (d[v], v))

    return d

N, M = map(int, input().split())
V = [[] for i in range(N)]
for m in range(M):
    L, R, C = map(int, input().split())
    V[L-1].append([R-1, C])
    V[R-1].append([L-1, C])
for i in range(1, N):
    V[i].append([i-1, 0])

d = dijkstra(0, V)
ans = d[N-1]
if ans == INFTY:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 96092
/* TLE*/
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


signed main(){
	int N;
	cin >> N;
	vector<int> A(N), B(N), C(N);
	for(int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	for(int i = 0; i < N; ++i) {
		cin >> B[i];
	}
	for(int i = 0; i < N; ++i) {
		cin >> C[i];
	}
	sort(ALL(A));
	sort(ALL(B));
	sort(ALL(C));
	int res = 0;
	for(int i = 0; i < N; ++i) {
		res += (int)(lower_bound(ALL(A), B[i]) - A.begin()) * (int)(C.end() - upper_bound(ALL(C), B[i]));
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector<int> a(3);
	rep(i, n) a[s[i] - 'a']++;
	sort(a.begin(), a.end());
	if (a[2] - a[0] <= 1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

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

int n;
int h[100005];
int dp[100005];

int solve(int x){
    if (x >= n-1) return 0;
    else if (dp[x] != -1) return dp[x];
    else if (x == n-2){
        return dp[x] = abs(h[x+1]-h[x]);
    }
    else {
        return dp[x] = min(abs(h[x+1]-h[x])+solve(x+1),abs(h[x+2]-h[x])+solve(x+2));
    }
}

int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    memset(&dp,-1,sizeof(dp));
    for (int i = 0; i < n; i++){
        cin >> h[i];
    }
    cout << solve(0) << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
const int MAX_M = int(1e5) + 10;

int N,M;
int X[MAX_M];
int L[MAX_M];

int main()
{
  cin >> N >> M;
  REP(i,0,M) cin >> X[i];
  if (N >= M) {
    cout << 0 << endl;
    return 0;
  }

  // N < M の場合:
  sort(X, X+M);
  REP(i,0,M-1) L[i] = X[i+1] - X[i];
  sort(L, L+M-1, greater<int>()); // 逆順

  // L[i] を大きい順にN-1個とる
  int m = 0;
  REP(i,0,N-1) m += L[i];

  int ans = X[M-1] - X[0] - m;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography.X509Certificates;

namespace AtCoder.Contest.A
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();

			int n = cin.NextInt();
			var l = cin.ArrayInt(2 * n).ToList();
			l.Sort();
			int ans = 0;
            for (int i = 0; i < 2 * n; i++)
            {
				if (i % 2 == 0) ans += l[i];
            }
            Console.WriteLine(ans);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13268
#include<cstdio>
const int MaxN=100010;
int N,x[MaxN],M,p[MaxN],q[MaxN];
long long ans[MaxN],K;
void swp(int&a,int&b){int t=a;a=b;b=t;}
bool vis[MaxN];
int list[MaxN];
int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++)scanf("%d",x+i),p[i]=i;
	scanf("%d%lld",&M,&K);
	while(M--){
		int a;scanf("%d",&a);
		swp(p[a-1],p[a]);
	}
	for(int i=0;i<=N;i++)if(!vis[i]){
		int len=0,j=i;
		for(;!vis[j];vis[j]=1,j=p[j])list[len++]=j;
		int r=K%len;
		for(int t=0;t<len;t++)
			p[list[t]]=list[r],r=(r+1)%len;
	}
	for(int i=0;i<=N;i++)q[p[i]]=i;
	for(int i=1;i<=N;i++)ans[q[i-1]]+=x[i],ans[q[i]]-=x[i];
	for(int i=0;i<N;i++)printf("%lld.0\n",ans[i]),ans[i+1]+=ans[i];
}

Measured memory_bytes: 3840
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H == 0 && W ==0)	break;
			for(int i = 0; i < H; i++) {
				for(int j = 0; j < W; j++) {
					System.out.printf("#");
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		}
	}
}



Measured memory_bytes: 59256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll h,w;
ll direction2[4][2]={{1,0},{0,1},{0,-1},{-1,0}};
bool valid(int a,int b)
{
    if(a>=1&&a<=h&&b>=1&&b<=w)return true;
    else return false;
}

int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    ll s=1,x;
    cin>>h;
    if(h==1)cout<<1<<endl;
    for(int i=2;i<=32;i++){x=i;//cout<<x<<endl;
    //if(x<=h)s=max(s,x);
        while(x<=1000){
            x*=i;//cout<<x<<endl;
            if(x<=h)s=max(s,x);
        }
    }
    if(h!=1)cout<<s;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// あみだの種類数をあらかじめ計算しておくやり方
// f(n)：n本の縦線で1列分の横線がひけるあみだの種類数

const int mod = 1e9 + 7;

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

	int h, w, k;
	cin >> h >> w >> k;

	ll dp[h+1][w];
	rep(i, h+1) rep(j, w) dp[i][j] = 0;
	dp[0][0] = 1;

	// あみだの種類数の計算
	ll f[20];
	f[0] = 1;
	f[1] = 1;
	f[2] = 2;
	for(int i = 3; i < 20; i++){
		f[i] = f[i-2] + f[i-1];
		f[i] %= mod;
	}

	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			// 左の線から移動する、同じ線、右の線から移動するの3パターン
			// （両端の線の場合は左の線からの移動、もしくは右の線からの移動がない）
			// それぞれの場合で左の線と同じ線の間、同じ線と右の線の間が決まり
			// それ以外の線のあみだの種類数を足してゆく。

			if(j > 0) dp[i+1][j] += dp[i][j-1] * f[j-1] * f[w-j-1];
			dp[i+1][j] += dp[i][j] * f[j] * f[w-j-1];
			if(j < w-1) dp[i+1][j] += dp[i][j+1] * f[j] * f[w-j-2];
			dp[i+1][j] %= mod;

			// cout << (i+1) << " " << j << " " << dp[i+1][j] << endl;
		}
	}
	// cout << endl;
	cout << dp[h][k-1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N;
    string s;
    cin >> N >> s;
    deque<char> ans, que;

    REP(i, s.size()) {
        char now = s[i];
        if (now == '(') {
            que.push_back(now);
            ans.push_back(now);
        } else {
            if (!que.empty()) {
                que.pop_back();
                ans.push_back(')');
            } else {
                ans.push_front('(');
                ans.push_back(')');
            }
        }
    }
    while (!que.empty()) {
        ans.push_back(')');
        que.pop_back();
    }

    string out(ALL(ans));
    print(out);
    return 0;
}

Measured memory_bytes: 256