akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define INF (1LL << 30)
#define int long long
#define pii pair<long long, long long>
#define MOD 1000000007
#define print(x) cout << (x) << endl
using namespace std;
typedef long long ll;

/*
    Eratosthenes
 */
bool is_prime[102];
vector<int> P;
void Eratosthenes(const int N)
{
    for (int i = 0; i <= N; i++)
    {
        is_prime[i] = true; //初期化
    }
    for (int i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (int j = 2 * i; j <= N; j += i)
            {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
}

int solve(int N)
{
    vector<int> cnt(P.size());
    // if (N <= 9)
    // {
    //     return 0;
    // }
    // else if (N == 10)
    // {
    //     return 1;
    // }
    // else if (N == 100)
    // {
    //     return 543;
    // }
    // else
    // {

    for (int i = 0; i < P.size(); ++i)
    {
        for (int j = 1; j <= N; ++j)
        {
            int t = j;
            while (t % P[i] == 0)
            {
                t /= P[i];
                cnt[i]++;
            }
        }
    }

    int a = 0, b = 0, c = 0, d = 0;

    for (int i = 0; i < P.size(); ++i)
    {
        if (cnt[i] >= 74)
            c++;
        for (int j = 0; j < P.size(); ++j)
        {
            if (i != j)
            {
                if (cnt[i] >= 2 && cnt[j] >= 24)
                    a++;
                if (cnt[i] >= 4 && cnt[j] >= 14)
                    b++;
            }

            for (int k = 0; k < P.size(); ++k)
            {
                if (i != k && j != k && i != j)
                {
                    if (cnt[i] >= 2 && cnt[j] >= 4 && cnt[k] >= 4)
                        d++;
                }
            }
        }
    }

    return (a + b + c + d / 2);
    /*
        75 = 3 * 5^2

        1) p^74
        2) p^2 * q^24
        3) p^2 * q^4 * r^4
        4) p^4 * q^14

     */
    // }
}

signed main()
{
    int N;
    cin >> N;
    Eratosthenes(N);
    cout << solve(N) << endl;

    // rep(i, N)
    // {
    //     cout << "i: " << i << " " << is_prime[i] << endl;
    // }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        for(var i = 0; i < num; i++)
        {
            var v = ar[i];
            var j = i - 1;
            while (j >= 0 && ar[j] > v)
            {
                ar[j + 1] = ar[j];
                j--;
            }
            ar[j + 1] = v;
            WriteLine(string.Join(" ", ar));
        }
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}



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

int main(){
  string s;
  cin >> s;
  cout << s[0] << s.size() - 2 << s[s.size()-1] << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

int main(){ 
        ll n,m;
        cin >> n >> m;
        vector<ll> s;
        s.push_back(m);
        for(ll x=sqrt(m);x>=1;x--){
                if(m%x==0){
                              s.push_back(x);
                              s.push_back(m/x);
                }
        }
        sort(s.begin(),s.end());
        for(ll i=s.size()-1;i>=0;i--){
                if(m/s[i]>=n){
                        cout << s[i] << endl;
                        return 0;
                }
        }
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int a,b,l;
  cin>>a>>b;
  int i=0;
  while(true){
    l=(a-1)*i+1;
    if(b<=l){
      cout<<i<<endl;
      return 0;
    }
    i++;
  } 
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> X(N, 0);
    for (int i = 0; i < N; ++i) cin >> X[i];
    vector<int> C(100, 0);
    int ans = 10000000;
    for (int i = 1; i <= 100 ; ++i) {
        int cost_sum = 0;
        for (int j = 0; j < N; ++j) {
            cost_sum += pow(X[j] - i, 2);
        }
        ans = min(ans, cost_sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# input
N, M = map( int, input().split() )
H    = [ int(x) for x in input().split() ]
L    = dict()
for nn in range( N ):
    L[nn+1] = list()

for mm in range( M ):
    Am, Bm = map( int, input().split() )
    L[Am].append( Bm )
    L[Bm].append( Am )
            
##
ans = 0
for ii in range( N ):
    if( len(L[ii+1]) == 0 ):
        ans += 1
    else:
        Hi   = H[ii]
        flag = True
        for jj in range( len(L[ii+1]) ):
            if( Hi <= H[ L[ii+1][jj]-1 ] ):
                flag = False
        if(flag):
            ans += 1
            
print(ans)

Measured memory_bytes: 37764
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d,cou=0;
        int n = sc.nextInt();
        int arr[] = new int[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        int flag = 1;
        while (flag==1){
            flag = 0;
            for(int j=n-1;j>=1;j--){
                if(arr[j] < arr[j-1]){
                    d=arr[j];
                    arr[j]=arr[j-1];
                    arr[j-1]=d;
                    flag = 1;
                    cou++;
                }
            }
        }

        for(int k=0;k<n;k++){
            System.out.print(arr[k]);
            if(k!=n-1){
                System.out.print(" ");
            }
        }
        System.out.println("\n"+cou);
        sc.close();
    }
}


Measured memory_bytes: 26268
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
using namespace std;

void print_vec(vector<int> & v){
for (vector<int>::iterator vec_itr = begin(v); vec_itr!=end(v)-1; ++vec_itr ){
                cout << *vec_itr << " ";
            }
            cout << *(end(v)-1)<< "\n";
}


// main
int main(){
    int N;
    cin >> N;
    vector<int> A(N, 0);
    REP(i, N){
        cin >> A[i];
    }
    bool flag = false;
    int count = 0;
    while(true){
        // 偶数判定
        REP(i, N){
            if(A[i] % 2 != 0) flag = true;
        }
        if(flag) break;

        REP(i, N){
            A[i] = A[i]/2;
        }
        count++;
    }

    cout << count << "\n";

    return 0;
}

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int L=a+b;int R=c+d;
  if(L>R) cout<<"Left"<<endl;
  else if(L<R) cout<<"Right"<<endl;
  else cout<<"Balanced"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main(void){

  int A[N], n, i, j, minj, c=0, x;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }

  for(i = 0; i < n; i++){

    minj = i;

    for(j = i; j < n; j++){

      if(A[j] < A[minj]){

        minj = j;
      }
    }
    if(minj != i) c++;
    x = A[i];
    A[i] = A[minj];
    A[minj] = x;
  }

  for(i=0;i<n;i++){

    printf("%d",A[i]);
    if(i != n-1) printf(" ");
  }

  printf("\n%d\n",c);
return 0;
}

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


int main(){
    int n;  cin >> n;
    map<ll, ll> balls;
    set<ll> kinds;
    vector<ll> a(n);
    for(int i=0; i<n; i++){
        ll x;  cin >> x;
        x--;    a.at(i) = x;
        balls[x] += 1;
        kinds.insert(x);
    }
    map<ll, ll> isOff;
    ll ans=0;
    for(auto x: kinds){
        ll a = balls[x];
        ans += a*(a-1)/2;
        isOff[x] = a*(a-1)/2-(a-1)*(a-2)/2;
    }

    for(int i=0; i<n; i++){
        int key = a.at(i);
        cout << ans-isOff[key] << endl;
    }

}

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

#define ll long long
#define mod 1000000007LL

ll ans[1000005][2][2];
int n;

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

    cin >> n;
    ans[n][1][1] = 1LL;
    for(int i=n-1;i>=0;i--)
    {
        for(int j=0;j<2;j++)
        {
            for(int k=0;k<2;k++)
            {
                ans[i][j][k] = (ans[i+1][1][k]%mod+ans[i+1][j][1]%mod)%mod;
                ans[i][j][k] = (ans[i][j][k]%mod+((ans[i+1][j][k]%mod)*(8LL%mod))%mod)%mod;
            }
        }
    }
    cout << ans[0][0][0] << endl;
}


Measured memory_bytes: 34768
#include<iostream>

using namespace std;

int card[200],n;

void riffle()
{
	int card2[200];
	for(int i=0;i<2*n;i++)	card2[i]=card[i];
	for(int i=0;i<n;i++)	card[2*i]=card2[i],card[2*i+1]=card[n+i];
}

void cut(int k)
{
	int card2[200];
	for(int i=0;i<2*n;i++)	card2[i]=card[i];
	for(int i=k;i<2*n;i++)	card[i-k]=card2[i];
	for(int i=0;i<k;i++)	card[2*n-k+i]=card2[i];
}

int main()
{
	int m;	cin>>n>>m;
	for(int i=0;i<2*n;i++)	card[i]=i+1;
	for(int i=0;i<m;i++){
		int op;	cin>>op;
		if(op==0)	riffle();
		else		cut(op);
	}
	for(int i=0;i<2*n;i++)	cout<<card[i]<<endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int i,j,a[2][100],n,dp[2][100];
    scanf("%d",&n);
    memset(dp,0,sizeof(dp));
    for(i=0;i<2;i++){
        for(j=0;j<n;j++){
            scanf("%d",&a[i][j]);
        }
    }
   dp[0][0]=a[0][0];dp[1][0]=a[0][0]+a[1][0];
   for(i=1;i<n;i++){
    dp[0][i]=dp[0][i-1]+a[0][i];
   }
   for(i=1;i<n;i++){
    dp[1][i]=max(dp[0][i],dp[1][i-1])+a[1][i];
   }
   printf("%d\n",dp[1][n-1]);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;using std::queue;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;using std::swap;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::vector<int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}

namespace ndifix{
template<class T> void sort(T &v){std::sort(v.begin(),v.end());}
template<class T> void rsort(T &v){std::sort(v.rbegin(),v.rend());}
}

int main(){
  int n;cin>>n;
  vector<int> a(n);for(int i=0;i<n;i++)cin>>a[i];
  vector<int> m(n);
  LL buf=0;
  int sgn[2]={-1,1};
  for(int i=0;i<n-1;i++)buf+=a[i]*sgn[i%2];
  m[0]=a[n-1]-buf;m[0]*2;
  
  for(int i=1;i<n;i++){
    m[i]=a[i-1]-m[i-1]/2;m[i]*=2;
  }
  for(int i=0;i<n;i++)cout<<m[i]<<(i==n-1?"\n":" ");
  
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
using namespace std;
typedef long double LD;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define P=pair<int,int>;

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

    // 無限大の値
    const long long INF = 1LL << 60;

    // DP テーブル
    long long dp[100010];

int main() {
    int n, k;cin>>n>>k;
    vector<int> h(n);
    rep(i, n) cin>>h[i];


   
    // DP テーブル全体を初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < n; ++i) {
        for(int j=1; j<=k; j++){
            chmin(dp[i + j], dp[i] + abs(h[i+j]-h[i]));
            }
        }

    // 解を得て出力
    cout << dp[n-1] << endl;

}

Measured memory_bytes: 1408
#include <iostream>
//#include <vector>
using namespace std;

int main() {
    int n;
    int a[100001];
    int count = 0;

    cin >> n;
    for(int i=1; i<=n; i++) {
        cin >> a[i];
    }

    int flag = 1;
    int j = 1;
    for(int i=0; i<n; i++) {
        if(a[j] != 2) {
            j = a[j];
            count++;
        }else {
            count++;
            flag = 0;
            cout << count << endl;
            break;
        }
    }
    if(flag == 1) {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
#define f(x) x*x

int S(int d){
	int s,i,x;
	s = 0;
	for(i=1;(i*d)<=(600-d);i++){
		s = s + f(i*d)*d; 
	}
	
	return s;
}


int main(void) {
	int d;
	while(scanf("%d\n",&d) != EOF){
	printf("%d\n",S(d));
	}
	return 0;
}


Measured memory_bytes: 2068
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const N = lines[0]-0;
    const t = lines[1].split(" ").map(v=>v-0);
    const tsum = t.reduce((a,b)=>a+b, 0);
    const M = lines[2];
    const px = lines.filter((v,i)=>i>2).map(v=>v.split(" ").map(v=>v-0));
    px.forEach(([p, x])=>{
        console.log(tsum-t[p-1]+x);
    })
});


Measured memory_bytes: 30276
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num = Integer.parseInt(scanner.nextLine());
        for (int i = 0; i < 3; i++) {
            if (num % 10 == 7) {
                System.out.println("Yes");
                scanner.close();
                return;
            }
            num /= 10;
        }
        System.out.println("No");
        scanner.close();
        return;
    }
}


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

int main()
{
	int i, j, h, w;

	cin >> h >> w;

	while ((h!=0)&&(w!=0)) {
		for (i=0; i < w; i++)
			cout << '#';
		cout << endl;

		for (i=0; i < (h-2); i++) {
			cout << '#';
			for (j=0; j < (w-2); j++)
				cout << '.';
			cout << '#' << endl;
		}
		
		for (i=0; i < w; i++)
			cout << '#';
		cout << endl;

		cout << endl;
		cin >> h >> w;
	}
	return 0;
}

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

struct comp {
	bool operator()(int a, int b) const {
		return a > b;
	}
};

int main() {

	vector<int> w, k;
	int p, pw, pk;
	comp c;

	for (int i = 0; i < 10; ++i) {
		cin >> p;
		w.push_back(p);
	}
	for (int i = 0; i < 10; ++i) {
		cin >> p;
		k.push_back(p);
	}

	sort(w.begin(), w.end(), c);
	sort(k.begin(), k.end(), c);

	pw = 0;
	pk = 0;
	for (int i = 0; i < 3; ++i) {
		pw += w.at(i);
		pk += k.at(i);
	}

	cout << pw << " " << pk << endl;

	return 0;
}

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

def main():
    x, y, z, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))

    ab = [aa + bb for aa in a for bb in b]
    ab.sort(reverse=True)
    ab = ab[:3000]

    abc = [aabb + cc for aabb in ab for cc in c]
    abc.sort(reverse=True)

    for i in range(k):
        print(abc[i])


main()

Measured memory_bytes: 137864
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    while(1){
	string s;
	cin>>s;
	if( s=="0"){
	    break;
	}
	ll res = 0;
	vector<int> a(11,0);
	for(int i=0;i<s.size();i++){
	    int k = s[i]-'0';
	    vector<int> b(11,0);
	    for(int j=0;j<11;j++){
		b[(10*j+k)%11] += a[j];
	    }
	    if( k != 0 )b[k]++;
	//    for(int j=0;j<11;j++)cout<<b[i]<<' ';
	    a = b;
	    res += b[0];
	}
	cout<<res<<endl;
    }
    return 0;
}



Measured memory_bytes: 3148
#include <stdio.h>
int main(void) {
	int a, b, d, i;
	a = 0;
	b = 0;
	d = 0;
	i = 0;
	scanf("%d", &a);
	d = 100000;
	for (i = 1; i <= a; i++) {
		d = d * 1.05;
		b = d % 1000;
		if (b >= 1) {
			d = d - b;
			d = d + 1000;
		}
	}
	printf("%d\n", d);


	return 0;
}

Measured memory_bytes: 1776
#![allow(non_snake_case,unused_imports,dead_code)]
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::Ordering;

use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {
    input!{
        N:usize,
        M:usize,
        L:usize,
        R:[Usize1;L],
        ABC:[(Usize1,Usize1,isize);M]
    }
    let INF = 1e15 as isize;
    let mut G = GraphWarshallFloyd::new(N,INF);
    for &(a,b,c) in &ABC{
        G.set(a,b,c);
        G.set(b,a,c);
    }
    G.run();
    let ans = check_all(L,&R,&G);
    println!("{}",ans);
}

fn check_all(L:usize,R:&Vec<usize>,G:&GraphWarshallFloyd)->isize{
    let mut ans = 1e15 as isize;
    for i in 0..L{
        let tmp = _check_all(L,R,G,i,1<<i);
        ans = min(ans,tmp);
    }
    ans
}

fn _check_all(L:usize,R:&Vec<usize>,G:&GraphWarshallFloyd,p:usize,done:usize)->isize{
    let mut ans = 1e15 as isize;
    if done==(1<<L)-1 { return 0;}
    for i in 0..L{
        if done>>i&1==1{continue;}
        ans = min(ans,G.get(R[p],R[i]) + _check_all(L,R,G,i,done|(1<<i)));
    }
    ans
}

struct GraphWarshallFloyd{
    N:usize,
    Dist:Vec<Vec<isize>>,
    INF:isize
}

impl GraphWarshallFloyd {
    fn new(N:usize,INF:isize) -> GraphWarshallFloyd{
        let mut ret = GraphWarshallFloyd{N:N,Dist:Vec::new(),INF:INF};
        ret.Dist = vec![vec![INF;N];N];
        for i in 0..N{
            ret.Dist[i][i] = 0;
        }
        ret
    }
    fn set(&mut self,from:usize,to:usize,dist:isize){
        self.Dist[from][to] = dist;
    }
    fn get(&self,from:usize,to:usize)->isize{
        self.Dist[from][to]
    }
    fn run(&mut self){
        let N = self.N;
        for k in 0..N{
            for i in 0..N{
                for j in 0..N{
                    self.Dist[i][j] = min(self.Dist[i][j],self.Dist[i][k]+self.Dist[k][j]);
                }
            }
        }
    }
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  int ans;
  ans = W * h;
  ans += (H * w) - (h * w);
  ans = (H * W) - ans;
  print(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
using namespace std;
int main(){
    string thth[2]={"this","that"};
    string ths[2][26][26];
    for(int i=0;i<2;i++){
        for(int ia=0;ia<26;ia++){
            for(int ib=0;ib<26;ib++){
                ths[i][ia][ib]="    ";
            }
        }
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<2;j++){
            thth[j][i]-='a';
        }
    }
    for(int ia=0;ia<26;ia++){
        for(int ib=0;ib<26;ib++){
            for(int j=0;j<4;j++){
                for(int k=0;k<2;k++){
                    ths[k][ia][ib][j]=(thth[k][j]*ia+ib)%26;
                }
            }
        }
    }
    int n;
    cin>>n;
    string line,ins;
    getline(cin,line);
    for(int ii=0;ii<n;ii++){
        int aa=0,bb=0;
        vector<string> strs;
        getline(cin,line);
        stringstream ss(line);
        while(ss>>ins){
            strs.push_back(ins);
        }
        for(int i=0;i<strs.size();i++){
            for(int j=0;j<strs[i].size();j++){
                strs[i][j]-='a';
            }
        }
        for(int i=0;i<strs.size();i++){
            if(strs[i].size()==4){
                for(int ia=0;ia<26;ia++){
                    for(int ib=0;ib<26;ib++){
                        for(int j=0;j<2;j++){
                            if(strs[i]==ths[j][ia][ib]){
                                aa=ia;
                                bb=ib;
                                goto TO;
                            }
                        }
                    }
                }
            }
        }
TO:
        char cry[26];
        for(int i=0;i<26;i++){
            cry[(i*aa+bb)%26]=i;
        }
        for(int i=0;i<strs.size();i++){
            for(int j=0;j<strs[i].size();j++){
                strs[i][j]=cry[strs[i][j]]+'a';
            }
        }
        for(int i=0;i<strs.size()-1;i++){
            cout<<strs[i]<<' ';
        }
        cout<<strs[strs.size()-1]<<endl;
    }
}

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

inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
    return x * f;
}

const int M = 1e5 + 10;

struct P {
    int b;ll c;
    bool operator < (const P &rhs) const {
        return c > rhs.c;      
    }
} p[M];

int main() {
    int n = read(), m = read();
    priority_queue<ll, vector<ll>, greater<ll> > que;
    for (int i = 0; i < n; i++) {
        int x = read();
        que.push((ll)x);
    }    
    for (int i = 0; i < m; i++) p[i].b = read(), p[i].c = (ll)read();
    sort(p, p + m);
    for (int i = 0; i < m; i++) {
        int b = p[i].b;
        if (p[i].c <= que.top()) break;
        while (b--) {
            if (que.top() < p[i].c) {
                que.pop();
                que.push(p[i].c);
            } else {
                break;
            }
        }
    }
    ll sum = 0;
    while (!que.empty()) {
        int x = que.top(); que.pop();
        sum += x;
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 2804
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        sc.close();

        switch (N.charAt(N.length() - 1)) {
            case '2':
            case '4':
            case '5':
            case '7':
            case '9':
                System.out.println("hon");
                break;
            case '0':
            case '1':
            case '6':
            case '8':
                System.out.println("pon");
                break;
            case '3':
                System.out.println("bon");
                break;
        }
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<pair<pair<string,int>,int>> p(N);
  for(int i=0;i<N;i++){
    string S;
    int P;
    cin >> S >> P;
    p.at(i)=make_pair(make_pair(S,-1*P),i);
  }
  sort(p.begin(),p.end());
  for(int i=0;i<N;i++){
    cout << p.at(i).second+1 << endl;
  }
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int n;cin>>n;string s;cin>>s;

  int x=0;
  int ma=0;
  rep(i,0,n){
    if(s[i]=='I')x++;
    else x--;
    ma=max(ma,x);
  }

  out(ma);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define pb push_back
const int N = 1e5 + 10;
const int oo = 1e12;

int n, H, W;
int ans[10], x[N], y[N];
set<ii> st, ma;

void add(int x, int y)  {
    if(x <= 0 || x >= H - 1 || y <= 0 || y >= W - 1) return;
    if(ma.find(ii(x, y)) != ma.end()) return;
    int idem = 0;
    for(int i = 0; i < 3; ++i)  for(int j = 0; j < 3; ++j)
        if(st.find(ii(x + i, y + j)) != st.end())
            idem ++;
    //cout << x << ' ' << y << ' ' << idem << '\n';
    ans[idem] ++;
    ma.insert(ii(x, y));
}

signed main()
{
	//freopen("test.txt", "r", stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> H >> W >> n;

	for(int i = 1; i <= n; ++i) {
        cin >> x[i] >> y[i];
        st.insert(ii(x[i], y[i]));
	}
	for(int i = 1; i <= n; ++i)  {
        for(int bx = -2; bx <= 0; ++bx) for(int by = -2; by <= 0; ++by) {
            add(x[i] + bx, y[i] + by);
        }
	}

    ans[0] = H*W - 2*(H + W) + 4;
	for(int i = 1; i <= 9; ++i) ans[0] -= ans[i];
	for(int i = 0; i <= 9; ++i) cout << ans[i] << '\n';
}


Measured memory_bytes: 64384
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    ll sum = 0;
    sum += (n / 500) * 1000;
    n -= (n / 500) * 500;
    sum += (n / 5) * 5;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  string S;
  cin>>S;
  int N=S.size();

  string ans=S;
  rep(i,N) if(S[i]=='?') ans[i]='D';
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3752
/*
	一次操作将 l ~ r 的点灯全部取反
	考虑做差, 一个数的值等于这个数与前面的数的 xor
	那么一次操作只会取反两个位置 l 和 r + 1
	然后所有前缀和位置都必须要是 0
	一个联通块内一次可以将两个 1 给消掉, 判下奇偶性然后随便差下分就好了
*/
#include <bits/stdc++.h>
#define N 200005

using namespace std;

int n, m;
int head[N], nex[N << 1], to[N << 1], eid[N << 1], ecnt;
int p[N], s[N];

struct light {
	int pos, state;
}lig[N];

bool cmpLight(const light &lhs, const light &rhs) { return lhs.pos < rhs.pos; }

inline int read() {
	int x = 0; char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x;
}
inline void addE(int u, int v, int id) {
	to[++ecnt] = v, eid[ecnt] = id;
	nex[ecnt] = head[u], head[u] = ecnt;
}

int cntOne;
int dif[N], fa[N], fe[N];
bool vis[N];

void dfs(int u) {
	if(s[u]) ++dif[u], ++cntOne;
	for(int i = head[u], v; i; i = nex[i]) {
		v = to[i];
		if(fa[v]) continue;
		fa[v] = u, fe[v] = eid[i], dfs(v);
		dif[u] += dif[v];
	}
}

int main() {
	n = read(), m = read();
	for(int i = 1; i <= n; ++i)
		lig[i].pos = read(), lig[i].state = read();
	
	sort(lig + 1, lig + n + 1, cmpLight);
	for(int i = 1; i <= n; ++i)
		p[i] = lig[i].pos, s[i] = lig[i].state;
	for(int i = n + 1; i >= 1; --i)
		s[i] = s[i] ^ s[i - 1];
		
	for(int i = 1, l, r; i <= m; ++i) {
		l = read(), r = read();
		l = lower_bound(p + 1, p + n + 1, l) - p;
		r = upper_bound(p + 1, p + n + 1, r) - p - 1;
		if(l <= r) {
			addE(l, r + 1, i), addE(r + 1, l, i);
		}
	}
	
	for(int i = 1; i <= n + 1; ++i)
		if(!fa[i]) {
			fa[i] = i;
			dfs(i);
			if(cntOne & 1) {
				puts("-1");
				return 0;
			}
		}
	
	int cnt = 0;
	for(int i = 1; i <= n + 1; ++i)
		if(dif[i] & 1)
			vis[fe[i]] = true, ++cnt;
	
	printf("%d\n", cnt);
	for(int i = 1; i <= m; ++i)
		if(vis[i])
			printf("%d ", i);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 13312
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

vector<int> g[100005];
int n;

vector<int> res;
void dfs(int v, int p = -1, int cnt = 0) {
	res[v] = cnt;
	for (int c : g[v]) {
		if (c == p) continue;
		dfs(c, v, cnt + 1);
	}
}

vector<int> distcalc(int a) {
	res = vector<int>(n);
	dfs(a);
	return res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int u, v;
	cin >> n >> u >> v;
	u--; v--;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	auto distA = distcalc(u);
	auto distT = distcalc(v);
	int ans = 0;
	rep(i, n) {
		if (distA[i] < distT[i]) maxs(ans, distT[i]);
	}
	cout << ans - 1 << endl;
	return 0;
}


Measured memory_bytes: 10744
#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Int = long long;
struct Data {
    Int num0, num1, inv0, inv1;
    // inv0 : number of 0 after 1 (inversion number)
    // inv1 : number of 1 after 0
    static Data id() {
        return Data { 0, 0, 0, 0 };
    }
    Data combine(const Data &y) {
        return Data { num0 + y.num0, num1 + y.num1,
                     inv0 + y.inv0 + num1 * y.num0,
                     inv1 + y.inv1 + num0 * y.num1 };
    }
    Data flip() {
        return Data { num1, num0, inv1, inv0 };
    }
};
struct SegTree {
    int N;
    vector<Data> A;
    vector<bool> B;
    SegTree(int n) {
        N = 1; while (N < n) N *= 2;
        A.resize(2 * N, Data { 1, 0, 0, 0 });
        B.resize(2 * N);
        for (int i = N - 1; i > 0; i--) {
            A[i] = A[2*i+0].combine(A[2*i+1]);
        }
    }
    void down(int node, int nodeL, int nodeR) {
        if (!B[node]) return;
        A[2*node+0] = A[2*node+0].flip();
        A[2*node+1] = A[2*node+1].flip();
        B[2*node+0] = B[2*node+0] ^ 1;
        B[2*node+1] = B[2*node+1] ^ 1;
        B[node] = 0;
    }
    void flip_0(int L, int R, int node, int nodeL, int nodeR) {
        if (R <= nodeL || nodeR <= L) return;
        if (L <= nodeL && nodeR <= R) {
            A[node] = A[node].flip();
            B[node] = B[node] ^ 1;
            return;
        }
        down(node, nodeL, nodeR);
        flip_0(L, R, 2*node+0, nodeL, (nodeL + nodeR) / 2);
        flip_0(L, R, 2*node+1, (nodeL + nodeR) / 2, nodeR);
        A[node] = A[2*node+0].combine(A[2*node+1]);
    }
    void flip(int L, int R) {
        return flip_0(L, R, 1, 0, N);
    }
    Data invnum_0(int L, int R, int node, int nodeL, int nodeR) {
        if (R <= nodeL || nodeR <= L) return Data::id();
        if (L <= nodeL && nodeR <= R) return A[node];
        down(node, nodeL, nodeR);
        Data d = Data::id();
        d = d.combine(invnum_0(L, R, 2*node+0, nodeL, (nodeL + nodeR) / 2));
        d = d.combine(invnum_0(L, R, 2*node+1, (nodeL + nodeR) / 2, nodeR));
        return d;
    }
    Int invnum(int L, int R) {
        return invnum_0(L, R, 1, 0, N).inv0;
    }
};
int main() {
    int N, Q; cin >> N >> Q;
    SegTree st(N);
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        if (a) st.flip(i, i + 1);
    }
    for (int i = 0; i < Q; i++) {
        int t, l, r; cin >> t >> l >> r; l--;
        if (t == 1) {
            st.flip(l, r);
        } else {
            cout << st.invnum(l, r) << '\n';
        }
    }
    return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    ll h, w; cin >> h >> w;
    if (h == 1 || w == 1) { 
        cout << 1 << endl;
        return 0;
    }
    if (h * w % 2 == 1) cout << (h * w / 2) + 1 << endl;
    else cout << h * w / 2 << endl;
}


Measured memory_bytes: 888
#include<iostream>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
  
using namespace std;

int main() {
	int a, b, x;
	cin >> x >> a >> b;
	cout << ( ( x-a ) % b ) << endl;
	return 0;	
}

Measured memory_bytes: 256
// たなこふ先生の input マクロ (´･_･`)
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

const COST: [usize; 10] = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6];

use std::collections::HashMap;

struct Solver {
    cache: HashMap<usize, Option<Vec<usize>>>,
}

impl Solver {
    fn new() -> Solver {
        Solver{cache: HashMap::new()}
    }

    fn solv(&mut self,
            n: usize, digits: &Vec<usize>) -> Option<Vec<usize>> {
        if ! self.cache.contains_key(&n) {
            let ans = if n == 0 {
                Some(Vec::new())
            } else if n == 1 {
                None
            } else {
                digits.iter().filter_map(|&d| {
                    if COST[d] > n {
                        None
                    } else {
                        self.solv(n-COST[d], digits).map(|v| {
                            let mut v = v;
                            v.push(d);
                            v.sort_by(|a, b| b.cmp(a));
                            v
                        })
                    }
                }).max_by(|a, b| {
                    let blen = b.len();
                    if a.len() == blen {
                        a.cmp(&b)
                    } else {
                        a.len().cmp(&blen)
                    }
                })
            };
            self.cache.insert(n, ans);
        }

        self.cache.get(&n).unwrap().clone()
    }
}

fn main() {
    input! {
        n: usize,
        m: usize,
        digits: [usize; m],
    }

    for d in Solver::new().solv(n, &digits).unwrap() {
        print!("{:?}", d);
    }
    print!("\n");
}


Measured memory_bytes: 544996
#include <bits/stdc++.h>
using namespace std;
 
// #define int long long
 
/* short */
#define pb push_back
#define print(x) cout << x << '\n'
 
/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = INT_MAX;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}

bool shinobu(string s)
{
  if (s == "/" || s == "*" || s == "+" || s == "-"){
    return (false);
  }

  return (true);
}

signed main()
{
  //ios::sync_with_stdio(false);
  string in;

  while (cin >> in){
    char c;
    stack<double> st;
    bool line;
    while (scanf("%c", &c), c == '\n' ? line = true : line = false, true){
      if (shinobu(in)){
        st.push(atof(in.c_str()));
        //cout << "tst: " << st.top() << endl;
      } else {
        double n1 = st.top(); st.pop();
        double n2 = st.top(); st.pop();
        if (in == "-"){
          st.push(n2 - n1);
        }
        if (in == "+"){
          st.push(n2 + n1);
        }
        if (in == "*"){
          st.push(n2 * n1);
        }
        if (in == "/"){
          st.push(n2 / n1);
        }
        //cout << "calc: " << n2 << in << n1 << "=" << st.top() << endl;
      }
      if (line) break;
      cin >> in;
    }
    printf("%f\n", st.top());
  }

  return (0);
}

Measured memory_bytes: 1276
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;
int main() {
	vector<int>a(3);
	rep(i, 0, 3)cin >> a[i];
	sort(all(a));
	int sum = 0;
	sum = a[1] - a[0] + a[2] - a[1];
	cout << sum;

	return 0;
}





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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n;
  int a;

  cin >> n;

  vector<int> nums(100005, 0);

  REP (i, n) {
    cin >> a;
    nums[a]++;
    nums[a + 1]++;
    nums[a + 2]++;
  }

  cout << to_string(*max_element(nums.begin(), nums.end())) << endl;
}


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

#define ll       long long
#define LL       long long
#define ull      unsigned ll
#define pii      pair<int, int>
#define pll      pair<ll, ll>
#define mp       make_pair
#define ff       first
#define ss       second
#define sz(s)    (int) s.size()
#define all(s)   s.begin(), s.end()

template<typename T> inline void smin(T &a, T b) {
    a = a < b ? a : b;
}
template<typename T> inline void smax(T &a, T b) {
    a = a > b ? a : b;
}

template<typename T> inline void Int(T &n) {
    n = 0;
    int f = 1;
    register int ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n *= f;
}
template<typename T, typename TT> inline void Int(T &n, TT &m) {
    Int(n), Int(m);
}
template<typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) {
    Int(n), Int(m, l);
}

#define error(args...) { string _s = #args; replace(all(_s), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {
    cout << endl;
}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}

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

int add(int a, int b) {
    a += b;
    if(a >= mod) a -= mod;
    return a;
}
int sub(int a, int b) {
    a -= b;
    if(a <= 0) a += mod;
    return a;
}
int mul(int a, int b) {
    return (ll) a * b % mod;
}

const int inf = (int) 2e9 + 5;
const ll  Inf = (ll) 2e18 + 5;
const int   N = (int) 2e5 + 5;




int solve() {
    int n; Int(n);
    vector<int> dp(n + 1, inf);
    dp[1] = 0;
    vector<int> h(n + 1);
    for(int i = 1; i <= n; i++) {
        Int(h[i]);
    }
    for(int i = 1; i <= n; i++) {
        if(i + 1 <= n) smin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        if(i + 2 <= n) smin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }
    printf("%d\n", dp[n]);
    return 0;
}

int main() {
    int test = 1, tc = 0;
    //Int(test);
    while(test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}




Measured memory_bytes: 1024
/* ex 5_4
   yy8332 */

#include <stdio.h>
#include <string.h>

int main(void){
  char str1[11], *str2;
  int len1, len2, ans, i;

  //入力読み取り
  scanf("%s", str1);

  len1 = strlen(str1);

  //最長部分文字列の取得
  ans = 0;

  for(i = 0; i < len1; i++){
    if(str1[i] == 'A' || str1[i] == 'C' || str1[i] == 'G' || str1[i] == 'T'){
      len2 = 0;
      str2 = &str1[i];
      while(*str2 == 'A' || *str2 ==  'C' || *str2 == 'G' || *str2 == 'T'){
        len2++;
        str2++;
      }
      i += len2 - 1;
    }
    if(len2 > ans){
      ans = len2;
    }
  }

  //出力
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 1676
package main

import "fmt"

func main() {
	var a, b, c, d, e, f int
	fmt.Scan(&a, &b, &c, &d, &e, &f)
	a *= 100
	b *= 100

	ansSugar := 0
	ansSolution := a
	for ai := 0; a*ai <= f; ai++ {
		for bi := 0; b*bi <= f; bi++ {
			for ci := 0; c*ci <= f; ci++ {
				for di := 0; d*di <= f; di++ {
					water := a*ai + b*bi
					sugar := c*ci + d*di
					solution := water + sugar
					if solution > f {
						continue
					}
					if sugar*(100+e) > e*solution {
						continue
					}
					if sugar*ansSolution > ansSugar*solution {
						ansSugar = sugar
						ansSolution = solution
					}
				}
			}
		}
	}
	fmt.Println(ansSolution, ansSugar)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int n, q;
	cin >> n;
	vector<int> S(n);

	for (int i = 0; i < n; i++)
	{
		cin >> S.at(i);
	}

	cin >> q;

	int count = 0;
	int t;

	for (int i = 0; i < q; i++)
	{
		cin >> t;

		auto result = find(S.begin(), S.end(), t);
		if (result != S.end())
		{
			count++;
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 3108
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()

for h in range(1, 3501):
    for n in range(1, 3501):
        if 4*h*n-N*n-N*h==0: continue
        w=(N*h*n)/(4*h*n-N*n-N*h)
        if w>0 and w.is_integer():
            print(h, n, int(w))
            exit()


Measured memory_bytes: 40796
function Main(input) {
	input = input.split("\n");
	t = input[0].split("");
	s = input[1].split("");
	
	var result = 0
	for (var i = 0; i < s.length; i++) {
	if  (s[i] != t[i]) {
	result = result + 1;
	} else {
	}
	}
	
	console.log(result);
	}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 36496
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int mod = 1000000007;

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
void ini_func(vector<ll>& a, vector<ll>& b,ll N) {
	ll k, c;
	for (ll i = 0; i < N; i++) {
		cin >> k >> c;
		a.push_back(k);
		b.push_back(c);
	}


}
int num[4]= {1,-1,1,-1};
int main() {
	
	int W, H;
	int N;
	cin >> W >> H >> N;
	vector<ll>x, y, a;
	int X, Y, Z;
	for (int i = 0; i < N; i++) {

		cin >> X>>Y>>Z;
		x.push_back(X);
		y.push_back(Y);
		a.push_back(Z);
	}
	ll big[4] = { 0,W,0,H };
	for (int i = 0; i < N; i++) {
		ll tmp = a[i] - 1;
		if (a[i]-1< 2) {
			big[tmp] = num[tmp]*max(big[tmp] * num[tmp], x[i] * num[tmp]);
		}
		else{
			big[tmp] = num[tmp] * max(big[tmp] * num[tmp], y[i] * num[tmp]);
		}
	}
	
		if (big[1]>big[0]&&big[3]>big[2]) {
			
			cout << (big[1] - big[0]) * (big[3] - big[2]);
		}
		else { cout << 0; }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
    int x = 0,f = 1;char ch = getchar();
    for(;!isdigit(ch);ch = getchar())if(ch == '-') f = -f;
    for(;isdigit(ch);ch = getchar())x = 10 * x + ch - '0';
    return x * f;
}
signed main()
{
	int ans = 0;
	int a = read(),b = read(),c = read();
	if(c <= a + b + 1)cout<<b + c<<endl;
	else
	{
		cout<<a+b+b+1<<endl;
	}
}

Measured memory_bytes: 256