akhauriyash/Code-Regression huggingface dataset:
/**********************************************************/
/**            Bismillahir-rahmanir-rahim                **/
/**  In the name of Allah, the Beneficent, the Merciful. **/
/**********************************************************/
/****@author: Sayed Sohan, CSE 13th batch(2016), MBSTU*****/
/**********************************************************/

#include <bits/stdc++.h>
using namespace std;
//              Typedefs
typedef long long               ll;
typedef unsigned long long      ull;

//              Templates
template<class T>               using min_heap = \
                                priority_queue<T, \
                                std::vector<T>, std::greater<T>>;

//              Basic-Defs
#define PB                      push_back
#define MP                      make_pair
#define SP                      " "
#define NL                      "\n"
#define all(v)                  v.begin(), v.end()

//              DEBUG--SECTION
#define DE                      cout<<"HERE\n";
#define DE1(x)                  cout<<x<<"###\n";
#define DE2(x,y)                cout<<x<<"####"<<y<<"\n";
#define Pause                   system("pause");

//              Functions
#define clr(arr,value)          memset(arr,value,sizeof(arr))
#define __FAST_IO               ios_base::sync_with_stdio(0);\
                                cin.tie(0);cout.tie(0);
#define NUM1(x)                 __builtin_popcount(x)
#define LCM(x,y)                (x*y)/__gcd(x,y)

//              Sizes--Math     0123456789
#define MOD                     1000000007   //1e9+7 
#define MAX                     100050      
#define INF                     1e18
#define PI                      acos(-1)
#define eps                     1e-6

//** your code goes from here


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    __FAST_IO;
    
    ll i,j,k,n,m,T; //basic variables

    
    ll a,b,c;
    cin>>a>>b>>c>>k;

    ll sum = min(a,k);
   	k-=a;
   	k-=b;
   	if(k>0){
   		sum-=min(c,k);
   	}
   	cout<<sum<<NL;


    /// Don't forget to set array size....
    return 0;
}




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

int main() {
  int N, K;
  int sum=0;
  cin >> N >> K;
  
  rep(i, N) {
    int x;
    cin >> x;
    if (x < K-x) sum += x;
    else sum += K-x;
  }
  
  cout << 2*sum << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
#include <iostream>
typedef long long ll;
using namespace std;
#define maxn 200050
const ll mod=1000000007;
ll a[2000000],v[2000005];
int main()
{
    ll n,h,ans=0,i,j,an;
    scanf("%lld",&n);
    for(i=1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
        v[a[i]]++;
    }
    for(j=1; j<=n; j++)
    {
        if(v[j]>=2)
        {
            //printf("*%lld %lld\n",j,v[j]);
            ans+=v[j]*(v[j]-1)/2;
           // printf("ans=%lld\n",ans);
        }
    }
    an=ans;
    for(i=1; i<=n; i++)
    {
        ans=an;
         if(v[a[i]]>=2)
        {
            ans-=v[a[i]]*(v[a[i]]-1)/2;// printf("**ans=%lld\n",ans);
            ans+=(v[a[i]]-1)*(v[a[i]]-2)/2;// printf("***ans=%lld\n",ans);
        }
        printf("%lld\n",ans);
    }


    return 0;
}


Measured memory_bytes: 7296
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

  static double a, b, h, m;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    a = Double.parseDouble(in[0]);
    b = Double.parseDouble(in[1]);
    h = Double.parseDouble(in[2]);
    m = Double.parseDouble(in[3]);

    br.close();

    double ang = Math.PI * Math.abs(30.0 * h + 0.5 * m - 6.0 * m) / 180.0;

    out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * Math.cos(ang)));

    out.flush();
  }
}


Measured memory_bytes: 33116
# -*- coding:utf-8 -*-
import bisect

def solve():
    N = int(input())
    Ls = list(map(int, input().split()))
    Ls.sort()

    # O(N^2 * logN)の全探索で解く
    ans = 0
    for a_i in range(N):
        for b_i in range(a_i+1, N):
            c_i = bisect.bisect_left(Ls, Ls[a_i]+Ls[b_i])
            if c_i > b_i:
                ans += c_i - b_i - 1
            else:
                pass

    print(ans)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3188
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
using namespace std;
using ll=long long;
#define MOD  1000000007

int x[110],y[110],a[110];
int xmax=0,xmin=999,ymax=0,ymin=999;
int flag[4]={0,0,0,0};

int main(int argc, char const *argv[]) {
  int w,h,n;
  std::cin >> w >> h >>n;
  int W=w,H=h;

  for(int i=0; i<n; i++) std::cin >> x[i] >> y[i] >> a[i];
  
    for(int j=0; j<n; j++){
      if(a[j]==1 && x[j]>xmax){ xmax=x[j]; flag[0]=1;}
    }
    if(flag[0]==1)W=W-xmax;

    for(int j=0; j<n; j++){
      if(a[j]==2 && x[j]<xmin){ xmin=x[j]; flag[1]=1;}
    }
    if(flag[1]==1)W-=w-xmin;

    for(int j=0; j<n; j++){
      if(a[j]==3 && y[j]>ymax){ ymax=y[j]; flag[2]=1;}
    }
    if(flag[2]==1) H=H-ymax;

    for(int j=0; j<n; j++){
      if(a[j]==4 && y[j]<ymin) {ymin=y[j]; flag[3]=1;}
    }
    if(flag[3]==1) H-=h-ymin;

    if(H<=0 || W<=0)std::cout << '0' << '\n';
    else std::cout << H*W << '\n';
  
  
  return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    string a, b, c;
    cin >> a >> b >> c;

    queue<char> A;
    queue<char> B;
    queue<char> C;

    REP(i, a.length()){
        A.push(a[i]);
    }
    REP(i, b.length()){
        B.push(b[i]);
    }
    REP(i, c.length()){
        C.push(c[i]);
    }

    char now = 'a';

    while(1){
        if(now == 'a'){
            if(A.empty()) break;
            now = A.front();
            A.pop();
        }
        if(now == 'b'){
            if(B.empty()) break;
            now = B.front();
            B.pop();
        }
        if(now == 'c'){
            if(C.empty()) break;
            now = C.front();
            C.pop();
        }
    }
    cout << char(toupper(now)) << endl;
    return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}
     
vector<int> v[100];     

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    int n , m;
    cin >> n >> m;
    for(int i = 1; i <= m; ++i){
        int x , y;
        cin >> x >> y;
        v[y].pb(x);
        v[x].pb(y);
    }    
    for(int i = 1; i <= n; ++i){
        cout << sz(v[i]) << "\n";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<stdio.h>
using namespace std;
typedef long long ll;
ll mod = 998244353;



int main(){
	ll N;
	cin>>N;
	int ni = 0;
	vector<ll>A(N);
	ll M = 0;
	ll L = 1000000000;
	for(int i = 0; i < N; i++){
		cin>>A[i];
		if(A[i] < 0)ni++;
		M+=abs((int)A[i]);
		if(L > abs(A[i]))L = abs(A[i]);
	}
	if(ni % 2 == 0)cout<<M<<endl;
	else cout<<M - L - L<<endl;
	return 0;
}

Measured memory_bytes: 1024
package scc;
sub new{
	return bless[map[],1..$_[1]],$_[0];
}
sub add_edge{
	my$self=shift;
	push@{$self->[$_[0]]},$_[1];
}
sub scc{
	my$self=shift;
	my$now_ord=0,$group_num=0,@low,@ord=(-1)x@{$self},@ids;
	my@visited;
	my$dfs;
	$dfs=sub{
		my$v=shift;
		$low[$v]=$ord[$v]=$now_ord++;
		push@visited,$v;
		for$to(@{$self->[$v]}){
			if($ord[$to]==-1){
				$dfs->($to);
				$low[$v]=$low[$to]if$low[$v]>$low[$to];
			}
			else{
				$low[$v]=$ord[$to]if$low[$v]>$ord[$to];
			}
		}
		if($low[$v]==$ord[$v]){
			while(){
				my$u=pop@visited;
				$ord[$u]=@{$self};
				$ids[$u]=$group_num;
				last if$u==$v;
			}
			$group_num++;
		}
	};
	for$i(0..$#ord){
		$dfs->($i)if$ord[$i]==-1;
	}
	$_=$group_num-1-$_ for@ids;
	my@groups=map[],1..$group_num;
	for$i(0..$#ids){
		push@{$groups[$ids[$i]]},$i;
	}
	return\@groups;
}
package main;
my($N,$M)=split$",<>;
my$scc=scc->new($N);
for(1..$M){
	my($a,$b)=split$",<>;
	$scc->add_edge($a,$b);
}
$groups=$scc->scc();
print scalar(@{$groups}),$/;
for$L(@{$groups}){
	print scalar(@{$L}),$","@{$L}",$/;
}


Measured memory_bytes: 289832
#[allow(dead_code)]
fn main() {
    let (a,b) = i::u2();
    println!("{}", a * b);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }
    pub fn str() -> String {
        read()
    }
    pub fn s() -> Vec<char> {
        str().chars().collect()
    }
    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn u4() -> (usize, usize, usize, usize) {
        (read(), read(), read(), read())
    }

    pub fn u5() -> (usize, usize, usize, usize, usize) {
        (read(), read(), read(), read(), read())
    }

    pub fn u6() -> (usize, usize, usize, usize, usize, usize) {
        (read(), read(), read(), read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn iv3(n: usize) -> Vec<(i64, i64, i64)> {
        (0..n).map(|_| iv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn uv4(n: usize) -> Vec<(usize, usize, usize, usize)> {
        (0..n)
            .map(|_| uv(4))
            .map(|a| (a[0], a[1], a[2], a[3]))
            .collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 2144
#include <stdio.h>
#include <string.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int cnt[13], ty[8];

bool straight() {
    rep (k, 10) {
        bool f = true;
        rep (i, 5) if (cnt[(k+i)%13] == 0) f = false;
        if (f) return true;
    }
    return false;
}

int main() {
    int a, b, c, d, e;
    while (scanf("%d,%d,%d,%d,%d", &a, &b, &c, &d, &e) != EOF) {
        memset(cnt, 0, sizeof(cnt));
        memset(ty, 0, sizeof(ty));
        a--, b--, c--, d--, e--;
        cnt[a]++;
        cnt[b]++;
        cnt[c]++;
        cnt[d]++;
        cnt[e]++;
        rep (i, 13) ty[cnt[i]]++;
        if (ty[4]) puts("four card");
        else if (ty[2] && ty[3]) puts("full house");
        else if (straight()) puts("straight");
        else if (ty[3]) puts("three card");
        else if (ty[2] >= 2) puts("two pair");
        else if (ty[2] >= 1) puts("one pair");
        else puts("null");
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    ll X;
    cin>>X;
    ll bank=100,cnt=0;
    while(bank<X){
        bank*=1.01;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 3544
#include <stdio.h>
#define index(a,n,e) ((n)<0?(e):(a[n]))
#define updl(o,n) (o>(n)&&(o=(n)))
int main(){
	int h,n,dp[10010],a,m;
	scanf("%d%d",&h,&n);
	dp[0]=0;
	for(int i=1;i<=h;i++){
		dp[i]=2147483647;
	}
	for(int ii=0;ii<n;ii++){
		scanf("%d%d",&a,&m);
		for(int i=0;i<=h;i++){
			updl(dp[i],index(dp,i-a,0)+m);
		}
	}
	printf("%d\n",dp[h]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
string make_string(T N)
{
    string ret;
    T now = N;
    while (now > 0)
    {
        T x = now % 10;
        ret += (char)('0' + x);
        now /= 10;
    }
    reverse(all(ret));
    return ret;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N, Z, W;
    cin >> N >> Z >> W;
    vector<ll> a(N);
    loop(i, N) cin >> a[i];
    if (N == 1)
    {
        putout(abs(a[0] - W));
        return 0;
    }
    putout(max(abs(a[N - 2] - a[N - 1]), abs(a[N - 1] - W)));
    return 0;
}


Measured memory_bytes: 3652
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-18 21:29:02
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

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

int main()
{
    long n;
	cin >> n;

	if (n == 0) {
		cout << 0 << endl;
		return 0;
	}

	string ans = "";
	while (n != 0) {
		int r = n%(-2);
		if (r < 0) r += 2;
		ans += to_string(r);
		n = (n-r)/(-2);
	}

	reverse(all(ans));
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/**Bismillahir Rahmanir Raheem
    Author:Refatul Fahad**/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
#define IOS  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define sz(s)  (int)s.size()
#define all(s)  s.begin(),s.end()
const int N = 1e5 + 5;
const ll M = (ll)1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}

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

int len[3005][3005];
int main() {

    //IOS;
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    //cin>>test;
    for(int cs=1; cs<=test; ++cs) {
        string s,t,ts,ans;
        s+='#',t+='#';
        cin>>ts;
        s+=ts;
        cin>>ts;
        t+=ts;
        for(int i=1; i<sz(s); ++i) {
            for(int j=1; j<sz(t); ++j) {
                if(s[i]==t[j]) {
                    len[i][j]=len[i-1][j-1]+1;
                } else {
                    len[i][j]=max(len[i][j-1],len[i-1][j]);
                }
            }
        }
        int i=sz(s)-1,j=sz(t)-1;
        while(i>0&&j>0) {
            if(s[i]==t[j]) {
                ans+=s[i];
                --i,--j;

            } else if(len[i][j]==len[i][j-1]) {
                --j;
            } else {
                --i;
            }
        }
        reverse(ans.begin(),ans.end());
        if(sz(ans))
            cout<<ans<<endl;
        else cout<<' ';
    }
    return 0;
}



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

typedef long long int ll;
typedef vector<int> vi;			
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> 	pii;
typedef vector<bool> vb;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#ifdef LOCAL
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}

void solve(){
	int a, b, c, k; cin>>a>>b>>c>>k;
	int cnt = 0;
	while(b<=a) b *= 2, cnt++;
	while(c<=b) c *= 2, cnt++;
	if(cnt<=k) cout<<"Yes"; else cout<<"No";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef LOCAL
		freopen(".inp.txt", "r", stdin);
    	freopen(".out.txt", "w", stdout);
    	freopen(".err.txt", "w", stderr);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 3680
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf = 10e17;
const ll mod = inf;//1000000007;
const ld eps = 10e-9;



ll solve(void);
ll gcd(ll x, ll y);


ll mulmod(ll x, ll y)
{
	return (x * y) % mod;
}

ll submod(ll x, ll y)
{
	return (x - y + 100 * mod) % mod;
}

ll power(ll n, ll r)
{
	if ( r == 0 ) { return 1; }
	if ( r == 1 ) { return n; }
	if ( n == 0 ) { return 0; }
	if ( n == 1 ) { return 1; }

	if (r % 2 == 0)
	{
		ll y = power(n, r/2);
		return mulmod(y, y);
	}
	else
	{
		ll y = power(n, (r-1)/2);
		return n * mulmod(y, y) % mod;
	}
}

ll gcd(ll x, ll y)
{
	if (y == 1) { return 1;}
	if (x % y == 0) { return y; }
	return gcd(y, x % y);
}

vector<ll> perm;
vector<ll> inv;
void init_inv(ll m)
{
	perm.resize(m);
	inv.resize(m);
	
	perm[0] = 1;
	inv[0] = 1;

	for (ll i = 1; i < m; i++)
	{
		perm[i] = mulmod(perm[i-1], i);
	}
	
	for (ll i = 1; i < m; i++)
	{
		inv[i] = power(perm[i], mod - 2);
	}
}

ll ncr(ll n, ll r)
{
	// n (n-1) ... (n-r)
	if ( r == n || r == 0 ) { return 1; }

	ll ans = 1;
	for (ll i = 0; i < r; i++)
		ans = mulmod(ans, n - i);

	 return mulmod(ans, inv[r]);
	// return mulmod(perm[n], mulmod(inv[n-r], inv[r]));
}

bool binary_check(ll mid, ll key)
{
	return mid >= key;
}

ll binary_search()
{
//	ll ng = 0;
//	ll ok = x;
//
//	while (abs(ok - ng) > 1)
//	{
	//	ll mid = (ok+ng) / 2;
	//	if (binary_check(mid, k)) ok = mid;
	//	else ng = mid;
	//}

	return 0;
	//return ok;
}



ll solve(void)
{
	ll x;
	cin >> x;

	ll p = 100;

	for (ll i = 0; i < 10000; i++)
	{
		p += p / 100;
		if (p >= x) { cout << i + 1 << endl; break;}
	}

	// 100 * (1 + r + r^2 + r^3 + ... + r^n)
	// = 100 * (r^(n+1) - 1)/ (r-1) >= X


	return 0;
}

int main(void)
{
	while (solve())
	{
	}
	return 0;
}


Measured memory_bytes: 3628
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
array_sum = sum(a) % mod
ans = 0
for i in range(n):
    ans += a[i] * array_sum % mod
    ans -= a[i] * a[i] % mod
print((ans * pow(2,-1,mod)) % mod)

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

typedef pair <string, string> P;

map <P, int> rec[2];

int main(){
	int n;
	string s;
	long long ans;
	cin >> n >> s;
	auto solve = [&](string str, int id){
		int len = str.size();
		string s1, s2;
		for (int i = 0; i < (1 << len); i++){
			s1.clear(); s2.clear();
			for (int j = 0; j < len; j++){
				if (i & (1 << j)) s1.push_back(str[j]);
				else s2.push_back(str[j]);
			}
			rec[id][{s1, s2}]++;
		}
	};
	solve(s.substr(0, n), 0);
	reverse(s.begin(), s.end());
	solve(s.substr(0, n), 1);
	ans = 0;
	for (auto it : rec[0])	
		ans += 1LL * it.second * rec[1][it.first];
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 108288
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cctype>
#include <cassert>
#include <cstring>
#include <climits>
 
using namespace std;
 
#define FOR(k,a,b) for(int k=(a); k < (b); k++)
#define FORE(k,a,b) for(int k=(a); k <= (b); k++)
#define REP(k,a) for(int k=0; k < (a); k++)
 
#define ALL(c) (c).begin(), (c).end()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define RANGE(lb, x, ub) ((lb) <= (x) && (x) < (ub))
 
#define dump(x) cerr << #x << ": " << (x) << endl;
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
 
const int INF = 1000000000;
const double EPS = 1e-10;
const double PI = acos(-1.0);

bool test(int n, string &s, string &result) {
	REP(i, n) {
		int prev = (i - 1 + n) % n;
		int next = (i + 1) % n;
		if (s[i] == 'o') {
			if ((result[i] == 'S' && result[prev] == result[next]) ||
			(result[i] == 'W' && result[prev] != result[next])) {}
			else {
				return false;
			}
		} else {
			if ((result[i] == 'S' && result[prev] != result[next]) ||
			(result[i] == 'W' && result[prev] == result[next])) {}
			else {
				return false;
			}
		}
	}
	return true;
}

string fill(int i, int n, string &s, string &result) {
	int prev = (i - 1 + n) % n;
	char kind = result[i];
	char prev_kind = result[prev];
	char answer = s[i];

	if (i == n - 1) {
		return test(n, s, result) ? result : "";
	}

	if (answer == 'o') {
		if (kind == 'S') {
			result[i + 1] = prev_kind;
		} else {
			result[i + 1] = (prev_kind == 'S') ? 'W' : 'S';
		}
	} else {
		if (kind == 'S') {
			result[i + 1] = (prev_kind == 'S') ? 'W' : 'S';
		} else {
			result[i + 1] = prev_kind;
		}
	}

	return fill(i + 1, n, s, result);
}
 
int main(void) {
	int n; cin >> n;
	string s; cin >> s;

	string tmp = "";
	REP(i, n) tmp += ' ';

	tmp[0] = 'S'; tmp[1] = 'S';
	if (fill(1, n, s, tmp) != "") {
		cout << tmp << endl;
		return 0;
	}

	tmp[0] = 'S'; tmp[1] = 'W';
	if (fill(1, n, s, tmp) != "") {
		cout << tmp << endl;
		return 0;
	}

	tmp[0] = 'W'; tmp[1] = 'S';
	if (fill(1, n, s, tmp) != "") {
		cout << tmp << endl;
		return 0;
	}

	tmp[0] = 'W'; tmp[1] = 'W';
	if (fill(1, n, s, tmp) != "") {
		cout << tmp << endl;
		return 0;
	}
	
	cout << "-1" << endl;

    return 0;
}


Measured memory_bytes: 704
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

int main(void) {

	int k;
	string a;
	
	cin >> k;
	cin >> a;

	int b = a.size();

	if (k >=b) {
		cout << a;
	}
	else {
		cout << a.substr(0,k) << "..."<< endl;
	}

	return 0;
}

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

int main()
{
	string S, T;

	cin >> S >> T;

	int count = 0;
	for (int i = 0; i < 3; i++)
		if (S[i] == T[i])
			++count;

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


Measured memory_bytes: 256
//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>

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;


bool isBipartiteGraph(vector<vector<int>>& E, vector<int>& color, int v, int c) {
	if( color[v] != 0 ) {
		return (color[v] == c); 	
	}
	color[v] = c;
	for(auto& e : E[v]) {
		if( isBipartiteGraph(E,color,e,2-(c-1)) == false ) return false;
	}
	return true;
}


int main(void) {
	LL N;
	LL M;
	cin >> N >> M;
	vector<vector<int>> E;
	E.resize(N);
	
	for(int i=0; i<M; i++) {
		int A,B;
		cin >> A >> B;
		A--;
		B--;
		E[A].push_back(B);
		E[B].push_back(A);
	}
	
	vector<int> color(N);
	if( isBipartiteGraph(E,color,0,1) ) {
		LL BW[3] = {0};
		for( auto c : color ) {
			BW[c] ++;
		}
		cout << BW[1]*BW[2] - M << endl;
	}else {
		cout << N*(N-1)/2 -M << endl;
	}
	
	return 0;
}

Measured memory_bytes: 6528
H, W, K = map(int, input().split())

G = [list(input()) for _ in range(H)]

def calc(lst1, lst2):
    tmp = 0
    for h in range(H):
        for w in range(W):
            if G[h][w] == '#' and lst1[h] == 0 and lst2[w] == 0:
                tmp += 1
    # print (lst1, lst2, tmp)
    return tmp



ans = 0
for i in range(2 ** H):
    lst1 = [0] * H
    for j in range(H):
        if (i >> j) & 1:
            lst1[j] = 1
    for k in range(2 ** W):
        lst2 = [0] * W
        for l in range(W):
            if (k >> l) & 1:
                lst2[l] = 1
        if calc(lst1, lst2) == K:
            # print (lst1, lst2)
            ans += 1

print (ans)
# print (G)


Measured memory_bytes: 9220
/*
[abc131] F - Must Be Rectangular!
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;
const int MAX_XY = 1e5 + 1;

int N;
int x[MAX_N], y[MAX_N];
vector<int> g[2 * MAX_XY];
bool visited[2 * MAX_XY];
int cx, cy, ce;

void dfs(int v) {
    if (visited[v]) {
        return;
    }
    visited[v] = true;

    if (v < MAX_XY) {
        cx++;
    } else {
        cy++;
    }
    ce += g[v].size();

    for (int to : g[v]) {
        dfs(to);
    }
}

ll solve() {
    for (int i = 0; i < N; i++) {
        g[x[i]].push_back(y[i] + MAX_XY);
        g[y[i] + MAX_XY].push_back(x[i]);
    }

    ll ans = 0;
    for (int i = 0; i < MAX_XY; i++) {
        cx = cy = ce = 0;
        dfs(i);
        ans += (ll)cx * cy - ce / 2;
    }

    return ans;
}

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

    cout << solve() << endl;

    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

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

int main()
{
	ll n,ans=INF;
	string s;
	cin >> n >> s;
	vll w(n+1),e(n+1);
	w[0]=0;
	e[0]=0;
	rep(i,n){
		if(s[i]=='W'){
			w[i+1]=w[i]+1;
			e[i+1]=e[i];
		}
		else{
			e[i+1]=e[i]+1;
			w[i+1]=w[i];
		}
	}
	rep(i,n){
		ll l=w[i+1-1]-w[0];
		ll r=e[n]-e[i+1];
		chmin(ans,l+r);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5380
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, m, drink = 0, ans = 0; cin >> n >> m;
    vector<pair<ll, ll>> shop(n);
    rep(i, n) cin >> shop[i].first >> shop[i].second;
    sort(all(shop));
    
    rep(i, n){
        if(drink+shop[i].second >= m){
            // その店で目標に達する場合
            ans += shop[i].first * (m-drink);
            break;
        }
        else{
            // その店で目標に達さない場合
            drink += shop[i].second;
            ans += shop[i].first * shop[i].second;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef vector<pair<ll, ll>> vpll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(20);
    string s;
    cin >> s;
    if (s == "RRR") {
        cout << 3 << "\n";
    } else if (s.find("RR") != -1) {
        cout << 2 << "\n";
    } else if (s.find("R") != -1) {
        cout << 1 << "\n";
    } else {
        cout << 0 << "\n";
    }
    return 0;
}

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

int main() {
  int A, N, B, C;
  string op;
  cin >> N >> A;

  B = N - A;
  C = N % 500;
  if (N <= A) {
    cout << "Yes" << endl;
  }else if (C <= A) {
    cout << "Yes" <<endl;
  } else {
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
n = int(input())
s = str(input())

dp = [[0] * (n+1) for _ in range(n+1)]
ans = 0

for i in range(n):
    for j in range(i,n):
        if s[i] == s[j]:
            dp[i+1][j+1] = dp[i][j] + 1
            ans = max(ans, min(j-i, dp[i+1][j+1]))

print(ans)


Measured memory_bytes: 230024
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto ab = readln.split.to!(int[]);
    auto A = ab[0];
    auto B = ab[1];
    writeln(max(A+B, A-B, A*B));
}

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

int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int r=0;
	for(auto c:s)
		if(c=='R')
			r++;
	string t="";
	int l=n-r;
	while(r--)
		t.push_back('R');
	while(l--)
		t.push_back('W');
	int ans=0;
	for(int i=0;i<n;i++)
		if(s[i]!=t[i])
			ans++;
	ans=ans/2;
	cout<<ans;
	
}




Measured memory_bytes: 3916
import math

n,m = list(map(int, input().split()))
switchlist = []

for i in range(m):
    a = list(map(int, input().split()))
    switchlist.append([])
    for j in range(a[0]):
        switchlist[i].append(a[j+1])
switchval = list(map(int, input().split()))

ans = 0
#print(switchlist)
    
for i in range(2**n):
    zeroone=[]
    ii=i
    flag=1
    for j in range(n):
        zeroone.append(ii%2)
        ii=ii//2
    #print(zeroone)
    for j in range(m):
        count=0
        for k in range(len(switchlist[j])):
            #print(j,k)
            count+=zeroone[switchlist[j][k]-1]
        #print(count,switchval[j])
        if(count%2 != switchval[j]):
            flag=0
            
    if(flag==1):
        ans+=1
        
print(ans)

Measured memory_bytes: 3064
n = gets.to_i
h = gets.split.map(&:to_i)
max = h.max
cnt = 0
for i in 0..(max-1)
  ifwt = -1
  for j in 0..(n-1)
    if h[j] > i && ifwt == -1
      ifwt *= -1
      cnt += 1
    elsif h[j] <= i && ifwt == 1
      ifwt *= -1
    end
  end
end
puts cnt

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

typedef long long ll;

int main(){
  ll N;
  std::cin >> N;
  std::vector<ll> h(N);
  for(int i = 0 ; i < N ; i++){
    std::cin >> h[i];
  }
  std::vector<ll> dp(N);

  for(int i = 1; i < N ; i++){
    dp[i] = (long long)1e18;
  }
  dp[0] = 0;
  dp[1] = std::fabs(h[1]-h[0]);
  
  for(int i = 2 ; i < N; i++){
    dp[i] = std::min(dp[i - 1] + std::fabs(h[i] - h[i-1]),
		     dp[i - 2] + std::fabs(h[i] - h[i-2]) );
  }
  std::cout << dp[N-1] << std::endl;
  return 0;
}


Measured memory_bytes: 4704
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int w = sc.nextInt();//????????¬??°
		int h = sc.nextInt();//?¨??????¬??°
		int n = sc.nextInt();//?¨?????????°
		int spot[][] = new int[n][2];
		int idou [][] = new int [n-1][2];
		for(int i = 0;i < n;i++){
			spot[i][0] = sc.nextInt();
			spot[i][1] = sc.nextInt();	
		}
		/*for(int i = 0;i < n;i++){
			System.out.print(spot[i][0]+" ");
			System.out.println(spot[i][1]);
		}*/
		int result = 0;
		for(int i = 0;i < n-1;i++){
			idou[i][0] = Math.abs(spot[i][0] - spot[i+1][0]);
			idou[i][1] = Math.abs(spot[i][1] - spot[i+1][1]);
			if(((spot[i][1] > spot[i+1][1])&&(spot[i][0] < spot[i+1][0]))||((spot[i][1] < spot[i+1][1])&&(spot[i][0] > spot[i+1][0]))){
				idou[i][0] = idou[i][0] + idou[i][1];
			}
			//System.out.print("?§?????????¢"+spot[i][0]+"-"+spot[i+1][0]+"??§"+idou[i][0]+" ");
			//System.out.println("?§?????????¢"+spot[i][1]+"-"+spot[i+1][1]+"??§"+idou[i][1]);
			if(idou[i][0] > idou[i][1]){
				result = result + idou[i][0];
			}
			else{
				result = result + idou[i][1];
			}
		}
		System.out.println(result);
	}

}

Measured memory_bytes: 25192
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

ll a[4];
ll b[4];
ll c[5]={10,50,100,500,1000000000};
_;
int main(){
	ll n;
	while(scanf("%lld",&n),n){
		if(_++)puts("");
		rep(i,0,4)scanf("%lld",a+i);
		ll s=-n;
		rep(i,0,4)s+=a[i]*c[i];
		for(int i=3;i>=0;i--)b[i]=s%c[i+1]/c[i];
		rep(i,0,4)if(b[i]<a[i])printf("%lld %lld\n",c[i],a[i]-b[i]);
	}
}




Measured memory_bytes: 1916
import java.util.*;
import java.lang.*;
import java.io.*;
 
public final class Main
{
    public static void main (String[] args) throws java.lang.Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int w = in.nextInt();
        int[] weight = new int[n];
        long[] values = new long[n];

        for(int i =0; i< n; i++) {
            weight[i] = in.nextInt();
            values[i] = in.nextLong();
        }

        long[][] dp = new long[n+1][w+1];

        for(int i =0; i<=n; i++){
            for(int j =0; j<=w; j++){
               if(i==0 || j ==0) dp[i][j] = 0;
               else if(weight[i-1]<=j) {
                 dp[i][j] = Math.max(values[i-1] + dp[i-1][j-weight[i-1]],
                    dp[i-1][j]);
               } else{
                dp[i][j] = dp[i-1][j];
               }
            }
        }

        System.out.println(dp[n][w]);
    }
}


Measured memory_bytes: 125392
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    ll n;
    cin>>n;
    int l=0;
    ll s=0;
    for(int i=1;;i++){
        l++;
        s+=pow(26,i);
        if(s>=n) break;
    }
    string ans;
    for(int i=0;i<l;i++){
        n--;
        ans+='a'+n%26;
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}

Measured memory_bytes: 4104
open System.IO
open System
open System.Linq
open System.Collections.Generic

let sw = new StreamWriter(Console.OpenStandardOutput())
sw.AutoFlush <- false

let _n = stdin.ReadLine() |> int64
let _a = stdin.ReadLine().Split() 

let memoize fn = 
    let cache = new System.Collections.Generic.Dictionary<_,_>()
    (fun x ->
    match cache.TryGetValue x with
    | true, v -> v
    | false, _ -> 
        let v = fn (x)
        cache.Add(x,v)
        v)

/// nC2
let c2 n = n * (n - 1L) / 2L
let memC2 = memoize c2

//let countByA = _a |> Array.countBy id |> Map.ofSeq
let countByA =  _a |> Array.countBy id |> dict
//let countByA =  _a |> Array.countBy id |>fun x -> x.ToDictionary(fst,snd)

// 全部の答えを出して余分な数を引く方針
let ansWhole = 
    countByA
    |> Seq.map (fun x -> memC2 (int64 x.Value))
    |> Seq.sum

let unNeeded aNum = 
    let x = int64 countByA.[aNum]
    // xC2 - (x-1)C2 = x-1
    x-1L

let memUnNeeded = memoize unNeeded
/// それぞれの答え
let ansEach aNum = ansWhole - memUnNeeded aNum |> string

_a
|> Seq.map ansEach
|> Seq.iter stdout.WriteLine

stdout.Flush()
stdout.Close()

Measured memory_bytes: 54724
#include<iostream>
using namespace std;
int dp[100000][3]={0};
 
int ans(int a[100000][3],int i,int j,int n)
{
	if(i==n)
		return 0;
 
	if(dp[i][j]!=0)
		return dp[i][j];
 
	int best=0;
	for(j;j<3;j++)
	{
		for(int k=0;k<3;k++) 
		{
			if(k==j)
				continue;
			best=max(best,a[i][j]+ans(a,i+1,k,n));
		}
		if(i!=0)
			break;
	}
	return dp[i][j]=best;
}
 
int main()
{
	//ios_base::sync_with_stdio(0);           
	//cin.tie(NULL);
	//cout.tie(NULL);
	int n,a[100000][3];
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
			cin>>a[i][j];
	}
	cout<<ans(a,0,0,n);
    
    return 0;
}

Measured memory_bytes: 15324
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define mkp make_pair
//# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

using namespace std;

ll q , w , e , z ;


int main()
{
	speed;

    string s ;
    cin >> s ;
    for(int i = 0 ; i < s.size() -1 ; i ++ ){
    while( true ){
        if(s[i]!=s[i+1]){
            break ;
        }
        if(s[i]==s[i+1]){
            if(s[i]=='0'){
                s[i+1]='1';
                z++;
            }
            else{
                s[i+1]='0';
                z++;
            }
        }
    }
    }
    cout<<z;
	time;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  sort(x.begin(), x.end());
  int z = 0;
  for (int i = 0; i < n-1; i++) {
    z += x[i];
  }
  cout << z+x[n-1]/2 << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    int x[100];
    cin >> n;
    rep(i,n) cin >> x[i];
    int ans = 300000;
    rep(i,100) {
        int sum = 0;
        rep(j,n) {
           sum+=(i-x[j])*(i-x[j]);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

string m[10];
int H, W;

bool check(int h, int w, vector<string> s)
{
	if (h >= H || w >= W)
	{
		return false;
	}
	if (m[h][w] == '.')
	{
		return false;
	}
	s[h][w] = '.';
	if (h == H - 1 && w == W - 1)
	{
		REP(i, H)
		{
			REP(j, W)
			{
				if (s[i][j] == '#')
				{
					return false;
				}
			}
		}
		return true;
	}

	return check(h + 1, w, s) || check(h, w + 1, s);
}

int main()
{
	cin >> H >> W;
	REP(i, H)
	{
		cin >> m[i];
	}

	vector<string> t(H);
	REP(i, H)
	{
		t[i] = m[i];
	}

	string s = "Impossible";
	if (check(0, 0, t))
	{
		s = "Possible";
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
s = input()
n = len(s)
dp = [[0] * 13 for _ in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    for j in range(13):
        if s[i] == '?':
            for d in range(10):
                dp[i + 1][(10 * j + d) % 13] += dp[i][j]
                dp[i + 1][(10 * j + d) % 13] %= MOD
        else:
            dp[i + 1][(10 * j + int(s[i])) % 13] += dp[i][j]
print(dp[n][5])

Measured memory_bytes: 62004