akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

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

typedef long long ll;

int main()
{
    ll n, m, sum, a[100010], s[100010], mod[100010];
    map<ll, ll> mp;
    vector<ll> v;
    cin >> n >> m;
    sum = 0;
    REP(i, n)
    {
        cin >> a[i];
        sum += a[i];
        s[i] = sum;
        mod[i] = sum % m;

        if (mp[mod[i]] == 0)
        {
            v.push_back(mod[i]);
        }
        mp[mod[i]]++;
    }

    ll ans = 0;
    for (int i = 0; i < v.size(); i++)
    {
        if (v[i] % m == 0)
            ans += mp[v[i]];

        ans += mp[v[i]] * (mp[v[i]] - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}

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

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

    int temp = N;

    int fx = 0;
    for (int i = 0; i < 9; i++)
    {
        fx += temp % 10;
        temp /= 10;
    }

    if (N % fx == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
}


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

int main(){
	int a;
	int n,m;
	n=0;
	m=0;
	for(int i=0;i<3;i++){
		cin >> a;
		if(a==5)n+=1;
		if(a==7)m+=1;
	}
	if(n==2 && m==1)cout << "YES" << endl;
	else cout << "NO" <<endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    from collections import Counter
    n, m, *abc = map(int, open(0).read().split())
    a = Counter(abc[:n])
    *bc, = zip(*[iter(abc[n:])] * 2)
    bc = sorted(bc, key=lambda x: x[1], reverse=True)
    c = 0
    for i, j in bc:
        a[j] += i
        c += i
        if c > n:
            break

    cnt = n
    ans = 0
    keys = sorted(list(a.keys()), reverse=True)

    for k in keys:
        m = a[k]
        if m <= cnt:
            ans += k * m
            cnt -= m
        else:
            ans += k * cnt
            break

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39436
n = gets.to_i
b = gets.split.map(&:to_i)
a = Array.new(n,1000000)
n.times do |i|
    a[i] = b[i-1] if i > 0
    a[i] = b[i] if i < n-1 && a[i] > b[i]
end
p a.inject(:+)

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n;
    cin >> n;
    vector<vi> a(n,vi(3));
    rep(i,n)rep(j,3)cin >> a[i][j];
    vector<vi> dp(n,vi(3));
    rep(j,3)dp[0][j] = a[0][j];
    loop(i,1,n)rep(j,3){
        int t = 0;
        rep(k,3)if(j != k)t = max(t, dp[i-1][k]);
        dp[i][j] = max(dp[i][j], t + a[i][j]);
    }
    int ans = 0;
    rep(j,3)ans = max(ans, dp[n-1][j]);
    cout << ans << endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define REP(i, t) for(int i = 0; i < t; i++)
#define INF (1 << 30)

bool dicsort(string lhs, string rhs)
{
    int loop_time = min(lhs.size(), rhs.size());
    REP(i, loop_time)
    {
        if (lhs[i] != rhs[i]) return lhs[i] < rhs[i];
        if (i == loop_time - 1) return lhs.size() < rhs.size();
    }
}

int main()
{
    int N, L;
    cin >> N >> L;
    string S[110];
    REP(i, N) cin >> S[i];

    sort(&S[0], &S[N], dicsort);

    REP(i, N) cout << S[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
 
		Scanner sc=new Scanner(System.in);
		ArrayList<Integer> array=new ArrayList<>();
 
		//商品の種類数
		int N=sc.nextInt();
		//人気商品の数
		int M=sc.nextInt();
		int sum=0;
		int count=0;
 
		for(int i=0;i<N;i++) {
			array.add(sc.nextInt());
			sum+=array.get(i);
		}
		
		//4*M
		BigDecimal a=BigDecimal.valueOf(1);
		BigDecimal b=BigDecimal.valueOf(4*M);
		BigDecimal result=a.divide(b,4,RoundingMode.HALF_UP);
		
		
		BigDecimal sumBigDecimal=BigDecimal.valueOf(sum);
		BigDecimal get=result.multiply(sumBigDecimal);
		
		
		int get1=get.intValue();

		
		for(int entity:array) {
			if(entity>get1){
				count++;
			}
		
 
		}
 
		if(count>=M) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
 
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(void){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> s(h+5,vector<char>(w+5));
  for(int i=1;i<h+1;i++){
	for(int j=1;j<w+1;j++){
     cin >> s.at(i).at(j);
    }
  }
  for(int i=1;i<h+1;i++){
	for(int j=1;j<w+1;j++){
      if(s.at(i).at(j)=='#') continue;
      else{
        int n=0;
          if(s.at(i).at(j+1)=='#')n++;
          if(s.at(i+1).at(j)=='#')n++;
          if(s.at(i+1).at(j+1)=='#')n++;
           if(s.at(i).at(j-1)=='#')n++;
          if(s.at(i+1).at(j-1)=='#')n++; 
           if(s.at(i-1).at(j)=='#')n++;
          if(s.at(i-1).at(j+1)=='#')n++;
          if(s.at(i-1).at(j-1)=='#')n++;          
        
        s.at(i).at(j)=char(n+'0');
      }
      }
    }
    for(int i=1;i<h+1;i++){
		for(int j=1;j<w+1;j++){
          cout << s.at(i).at(j);
          if(j==w) cout<< "" <<endl;
        }
    }  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std; 
int arrCount[200005] = { 0 }; 
bool cmp(int iNum1, int iNum2){ 
    return iNum1 > iNum2;
}
int main(){
    ios::sync_with_stdio(false); 
    int nCount, nDiff, i, iTemp, iSum=0; 
    cin >> nCount >> nDiff; 
    for (i = 1; i <= nCount; ++i){ 
        cin >> iTemp; 
        ++arrCount[iTemp]; 
    }
    sort(arrCount, arrCount + 200005,cmp); 
    for (i = nDiff; arrCount[i] != 0; ++i){ 
        iSum += arrCount[i]; 
    }
    cout << iSum << endl;
    return 0; 
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
// #define double long double
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   100005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15

signed main(){
  fast;
   int x,y;
   cin>>x>>y;
   cout<<(3*x+y)/2<<endl;
}
  


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public boolean hasNext() {
		// return cnt < N;
		return cnt < 1;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
		String[] strArr = str.split(" ");
		int[] a = new int[N];
		for (int i = 0; i < N; i++)
			a[i] = Integer.parseInt(strArr[i]);
		// for (int i = 0; i < N; i++)
		// System.out.print(" " + a[i]);
		// System.out.println();
		long ans = 0;
		for (int i = 0; i < N; i++) {
			for (int n = a[i]; n % 2 == 0; n /= 2) {
				ans++;
			}
		}
		System.out.println(ans);

	}

	public void solve() {

	}
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int Q;
    cin >> Q;

    ll bsum = 0, lsum = 0, usum = 0;
    priority_queue<int> lower, upper;
    auto insert = [&](int v) {
        if (lower.empty() || lower.top() >= v) {
            lower.push(v);
            lsum += v;
        }
        else {
            usum += v;
            upper.push(-v);
        }
        while (lower.size() < upper.size()) {
            lsum -= upper.top();
            usum += upper.top();
            lower.push(-upper.top());
            upper.pop();
        }
        while (lower.size() > upper.size() + 1) {
            lsum -= lower.top();
            usum += lower.top();
            upper.push(-lower.top());

            lower.pop();
        }

        if (upper.size())
            assert(lower.top() <= -upper.top());
    };

    for (int q = 0, op, a, b; q < Q; q++) {
        cin >> op;
        if (op == 1) {
            cin >> a >> b;
            bsum += b;
            insert(a);
        } else {
            ll loc = lower.top();
            ll val = bsum + loc * lower.size() - lsum + usum - loc * upper.size();
            cout << loc << " " << val << "\n";
        }
    }

    return 0;
}



Measured memory_bytes: 3452
#include <stdio.h>
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
	char *JOI;
	int lvc = 0,j,o,i,c,J,O,I,minlv;

	JOI = new char[1000000];

	cin >> JOI;

	for(c = 0; c < strlen(JOI); c++){
		J = O = I = 0;
		if(JOI[c] == 'J'){
			for(j = c; JOI[j] == 'J';j++){
				J++;
			}
			for(o = j; JOI[o] == 'O';o++){
				O++;
			}
			for(i = o; JOI[i] == 'I'; i++){
				I++;
			}
			minlv = min(J,O);
			minlv = min(minlv,I);

			if(O <= minlv && minlv > lvc){
				lvc = minlv;
			}
			c = i-1;
		}
	}

	cout << lvc << endl;

	return 0;
}

Measured memory_bytes: 2140
import Data.Int
import Data.List

iogetints :: IO [Int]
iogetints = do 
	s <- getLine
	return $ map read $ words s

solve :: Int -> [Int] -> Int64
solve m xs = ans where
	p = map (\x -> (x `mod` m)) $ scanl1 (+) $ map fromIntegral xs
	ans = (sum $ map ((\x -> x * (pred x) `div` 2) . fromIntegral . length) $ group $ sort p) + (fromIntegral $ length $ filter (== 0) p)

main :: IO ()
main = do
	[n, m] <- iogetints
	a <- iogetints
	print $ solve m a

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

int main(){
  char s[2],tr;
  int a[3] ={1,0,0};
  while(cin >> s[0] >> tr >> s[1]){
	swap(a[s[0] -'A'],a[s[1] - 'A']);
  }
  for(int i=0;i<3;i++){
	if(a[i] == 1) cout << (char)('A' + i) << endl;
  }
  return 0;
}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


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

	ll N,K;
	cin >> N >> K;
	vector<ll> v(N);
	FOR(i,0,N)cin >> v[i];

	ll ans = 0;
	FOR(i,0,N+1){
		FOR(j,0,N+1){

			if(i+j>N)continue;
			if(i+j>K)continue;
			ll ansp = 0;
			priority_queue<ll> pq;
			FOR(l,0,i){pq.push(-v[l]);ansp+=v[l];}
			FOR(l,0,j){pq.push(-v[N-1-l]);ansp+=v[N-1-l];}
			if(i+j==K)ans = max(ansp,ans);
			if(i+j<K){
				FOR(l,0,K-i-j){
					if(pq.empty()){
						break;
					}
					if(pq.top()<0)break;
					ansp += pq.top();
					pq.pop();
				}
				ans = max(ans,ansp);
			}

		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define DESYNC ios::sync_with_stdio(0); cin.tie(0);
#define deb(x) cerr << ">> " << #x << " : " << x << "\n"
#define print(a) for(auto x : a) cout << x << " "; cout << endl;

using namespace std;

const int inf = 1e18 + 42;
const int M = 998244353;
const int MOD = 1e9 + 7;

int power(int x, int y) {
	if (y == 0) return 1;
	if (y & 1) return (x * power(x, y - 1));
	int t = power(x, y / 2);
	return (t * t);
}

int no_of_bits(int n) {
	int cnt = 0;
	while(n) cnt++, n >>= 1;
	return cnt;
}

const int MAX = 1e6 + 5;

// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

void solve()
{
	// int a;
	// cin >> a;
	// cout << a + a * a + a * a * a << endl;

	string s, t;
	cin >> s >> t;
	int cnt = 0;
	for(int i = 0; i < s.size(); i++)
	{
		if(s[i] != t[i]) cnt++;
	}
	cout << cnt << endl;
}

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


Measured memory_bytes: 3824
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int n;

int main(){
    scanf("%d",&n);
    int cnt0 = 0 , cnt2 = 0;
    rep(i,0,n) {
        int a;
        scanf("%d",&a);
        if(a & 1) cnt0 ++;
        else if(a % 4 == 0) cnt2 ++;
    }
    if(cnt2 >= cnt0) puts("Yes");
    else if(cnt0 - cnt2 == 1 && cnt0 + cnt2 == n) puts("Yes");
    else puts("No");
    return 0;
}


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

int main(void){
    int n,m;
    cin >> n >> m;
    int a[n][m] = {};
    int b[m] = {};
    int temp;
    //int c[m] = {};
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++) cin >> a[i][j];
    }
    for(int i=0; i<m; i++) cin >> b[i];

    for(int i=0; i<n; i++){
        temp = 0;
        for(int j=0; j<m; j++){
            temp += a[i][j] * b[j];
        }
        cout << temp <<endl;
    }

    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
    char s[11];
    cin >> s;
    char ans[11];
    int flag=0;
    int i = strlen(s);
    for (int j=0; j<i; j++){
        if(s[j]=='0'){
            ans[flag]='0';
            flag++;
        }else if(s[j]=='1'){
            ans[flag]='1';
            flag++;
        }else if(flag!=0){
            flag--;
        }
    }
    for(int i=0; i<flag; i++){
        cout << ans[i];
    }
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		var list = GetInts(1 << N).ToList();
		for(int i = 0; i < N; i++)
		{
			var next = new List<int>();
			for(int j = 0; j < list.Count - 1; j += 2)
				next.Add(list[j] == list[j + 1] ? list[j] : Abs(list[j] - list[j + 1]));
			
			list = next;
		}
		WriteLine(list[0]);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 20400
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <bitset>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to, s;
};

int main() {
	int n;
	cin >> n;
	int ans = 0;
	int bef = -1,cou = 0;
	REP(i, n) {
		int c;
		cin >> c;

		if (bef == c)cou++;
		else {
			ans += cou / 2;
			cou = 1;
		}
		bef = c;
	}
	ans += cou / 2;
	cout << ans << endl;

	return 0;
}


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

int main() {
  string s;
  string t;
  bool flag = false;
  string ans;

  cin >> s >> t;

  for (int i = 0; i < s.length(); i++) {
    int x = 0;
    for (int j = 0; j < t.length(); j++) {
      if (s[i+j] == t[j] || s[i+j] == '?') {
        x++;
      }
    }

    if (x == t.length()) {
      string tmp = s;
      tmp.replace(i, t.length(), t);
      replace(tmp.begin(), tmp.end(), '?', 'a');
      if (flag != true) {
        ans = tmp;
        flag = true;
      }
      if (ans > tmp) {
        ans = tmp;
      }
    }
  }

  if (flag) {
    cout << ans << endl;
  } else {
    cout << "UNRESTORABLE" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,x,y,z,q,c ;
  cin >> a ;
  x=a/100;
  if(x == 1 )
    c++;
    y=a-100*x;
    z=y/10;
    if(z == 1)
      c++;
      q=y-10*z;
      if(q == 1)
        c++;
  cout << c  ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
//setprecision(10);
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
        return b != 0 ? gcd(b, a % b) : a;
    }


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    llong n,m; cin>>n>>m;
    llong x=0;
    llong time=100*(n-m)+1900*m;
    llong cnt=pownew(2,m);
    cout<<time*cnt<<endl;
    return 0;
    }





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


using namespace std;


int main(){

	int N;
	cin >> N;
	int ans;
	int keta = log10(N)+1;
	if(keta==1){
		ans=N;
	}else if(keta==2){
		ans=9;
	}else if(keta==3){
		ans = 1+(N%100) + 100*((N/100)-1) +9;
	}else if(keta==4){
		ans = 9+100*9;
	}else if(keta==5){
		ans = 1+(N%10000) + 10000*((N/10000)-1) +9 +100*9;
	}else if(keta==6){
		ans = 9+100*9 + 10000*9;
	}

		

	cout << ans << endl;





}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        int[] sample = new int[30];
        int[] target = new int[30];

        for (int i = 0; i<30; i++) {
            sample[i] = -1;
            target[i] = -1;
        }
        
        for (int i = 0; i<S.length(); i++) {
            if (sample[S.charAt(i) - 'a'] < 0) {
                sample[S.charAt(i) - 'a'] = T.charAt(i) - 'a';
            }
            else if (sample[S.charAt(i) - 'a'] != T.charAt(i) - 'a'){
                System.out.println("No");
              	return;
            }

            if (target[T.charAt(i) - 'a'] < 0) {
                target[T.charAt(i) - 'a'] = S.charAt(i) - 'a';
            }
            else if (target[T.charAt(i) - 'a'] != S.charAt(i) - 'a'){
                System.out.println("No");
              	return;
            }
        }

        System.out.println("Yes");
    }
}

Measured memory_bytes: 28936
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int cost = 700;
    for(int i=0;i<3;i++){
      if(s.charAt(i)=='o'){
        cost+=100;
      }
    }
    System.out.println(cost);
  }
}


Measured memory_bytes: 22732
n,w = map(int,input().split())
wv_list = [map(int,input().split()) for _ in range(n)]
dp = [0]*(w+1)

for ww,vv in wv_list:
    for i in range(w, ww-1, -1):
        t = dp[i-ww] + vv
        if dp[i] < t:
            dp[i] = t
print(max(dp))

Measured memory_bytes: 41324
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void _main();
int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); return 0;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-5,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

void _main(){
  string s;
  cin >> s ;
  if(s[0]=='A') cout << "T" << endl;
  if(s[0]=='T') cout << "A" << endl;
  if(s[0]=='C') cout << "G" << endl;
  if(s[0]=='G') cout << "C" << endl;
  
}

Measured memory_bytes: 256
require 'set'

N, M = gets.split.map(&:to_i)
A = Set.new(M.times.map { gets.to_i })
MOD = 10 ** 9 + 7
dp = Array.new(N + 10, 0)
dp[0] = 1
N.times do |i|
  next if A.include?(i)
  dp[i + 1] = (dp[i + 1] + dp[i]) % MOD if i + 1 <= N
  dp[i + 2] = (dp[i + 2] + dp[i]) % MOD if i + 2 <= N
end
puts dp[N]

Measured memory_bytes: 9980
#include <stdio.h>
int map[10000001];
int main(void){
    int temp,i,num;
    map[0]=1;map[1]=1;
    for(i=2;i*i<10000001;i++){
        temp=2;
        while(temp*i < 10000001){
            map[i*temp]=1;
            temp++;
        }
    }
    while(1){
        scanf("%d",&num);
        if(num == 0)
            break;
        for(i=num;i-8>=0;i--)
            if(map[i] == 0 && map[i-2]==0 && map[i-6]==0 && map[i-8]==0){
                printf("%d\n",i);
                break;
            }
    }
    return 0;
}

Measured memory_bytes: 39660
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <set>

#define PI 3.1415926535897

typedef long long ll;

using namespace std;

ll n, m, q;
ll* a;
ll* b;
ll* c;
ll* d;

ll ans;

void dfs(vector<int> A) {
    if (A.size() == n + 1) {
        ll now = 0;
        for (int i = 0; i < q; i++) {
            if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(now, ans);
        return;
    }

    A.push_back(A.back());
    while (A.back() <= m) {
        dfs(A);
        A.back()++;
    }
}

int main() {
    cin >> n >> m >> q;
    a = new ll[q];
    b = new ll[q];
    c = new ll[q];
    d = new ll[q];
    
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    dfs(vector<int>(1,1));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
#include<stack>
#include <string>
#include<fstream>
#include<ctime>
#include<queue>

using namespace std;
#define LL long long
#define mxn 100010
#define mxe 1000010
#define eps 1e-4
#define inf 0x7fffffff

#include<iostream>
#include<cstdio>
#define INF 999999999;
#include<iostream>
using namespace std;

#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define MAX 1000000
using namespace std;
int amount[MAX];
int vis[MAX];
int prime[MAX];
int main(){
	memset(vis, 0, sizeof(vis));
	for(int i=0;i<MAX;i++)
        prime[i]=1;
	prime[0] = prime[1] = 0;
	for (int i = 2; i*i<= MAX; i++){
		if(prime[i])
		{
		    for(int j=i*i;j<=MAX;j+=i)
		        prime[j]=0;
		}
	}
	int sum = 0;
	for (int i = 0; i <= MAX; i++){
		if (prime[i]){
			sum++;
		}
		amount[i] = sum;
	}
	int n;
	while (cin >> n){
		cout << amount[n] << endl;
	}
	return 0;
}

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

int main(void) {
  int N, ma = -1, mi = 1001;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    ma = max(a, ma);
    mi = min(a, mi);
  }
  cout << ma - mi << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#include<string.h>

#define ARRAY 100000

int min(int x, int y) {

  if(x < y)
    return x;
  else
    return y;
 
}

typedef struct judge{

  char name[10];

  int t;

}P;


P Q[ARRAY+1];

int head, tail, n;


void enqueue(P x){

  Q[tail] = x;

  if ( tail == ARRAY ) tail = 1;

  else tail++;

}


P dequeue(){

  P x = Q[head];

  if ( head == ARRAY ) head = 1;

  else head++;

  return x;

}


int main(){

  int flag = 0,i,p,q;

  P s;

  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++) scanf("%s %d", Q[i].name, &Q[i].t);

  head = 1; tail = n+1;

  while( head != tail ){

    s = dequeue();

    p = min(q, s.t);

    s.t -= p;

    flag += p;

    if ( s.t > 0 )
      enqueue(s);

    else {

      printf("%s %d\n",s.name, flag);

    }

  }



  return 0;

}

Measured memory_bytes: 2160
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
    os<<endl;
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, map<T,S> const&M){
    for(auto e:M){
        os<<e;
    }
    os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<int64>> DP(N+2,vector<int64>(3,-INF)); //飛ばした回数
    DP[0][0] = 0;
    DP[1][1] = 0;
    vector<int64> A(N);
    REP(i,N) cin >> A[i];

    REP(i,N){
        int idx = i + 2;
        REP(j,3){
            chmax(DP[idx][j], DP[idx-2][j] + A[i]);
            if(j) chmax(DP[idx][j], DP[idx-1][j-1]);
        }
    }

    auto ans = DP.back()[1 + (N&1)];
    cout << ans << endl;
}


Measured memory_bytes: 15876
#include <iostream>
#include <string>
#include <vector> 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  
  vector<int> sum(S.size()+1, 0);
  // 0 0 1
  for(int i = 1; i < S.size(); i++)
    sum[i+1] = sum[i] + (S[i-1] == 'A' && S[i] == 'C');
  
  while(Q--) {
    int l, r;
    cin >> l >> r;
    cout << sum[r] - sum[l] << "\n";
  }
  return 0;
}

Measured memory_bytes: 1472
#include<stdio.h>

int main(void){
    char s[100000];
    scanf("%s",s);

    if((s[0]=='A' && s[1]=='A' && s[2]=='A') || (s[0]=='B' && s[1]=='B' && s[2]=='B')){
        printf("No\n");
    }else{
        printf("Yes\n");
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, k, s;
    cin >> n >> k >> s;

    if (s == 1000000000L) {
        const auto* delim = "";
        for (auto i : irange(0L, k)) {
            cout << delim << s;
            delim = " ";
        }
        for (auto i : irange(k, n)) {
            cout << delim << s - 1;
            delim = " ";
        }
    } else {
        const auto* delim = "";
        for (auto i : irange(0L, k)) {
            cout << delim << s;
            delim = " ";
        }
        for (auto i : irange(k, n)) {
            cout << delim << s + 1;
            delim = " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 1280
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N;
    string S;
    scan(N);
    scan(S);

    int ans;

    foreach (l ; 0 .. N) {
        auto z = Zalg(S[l .. $]);
        debug {
            writeln(z);
        }
        foreach (j ; 0 .. N - l) {
            ans = max(ans, min(j, z[j]));
        }
    }

    writeln(ans);
}

int[] Zalg(string S) {
    int N = S.length.to!int;
    auto z = new int[](N);
    z[0] = N;

    for (int i = 1, j = 0; i < N; ) {
        while (i + j < N && S[j] == S[i + j]) j++;
        z[i] = j;

        if (j == 0) {
            i++;
            continue;
        }

        int k = 1;
        while (i + k < N && k + z[k] < j) {
            z[i + k] = z[k];
            k++;
        }
        i += k;
        j -= k;
    }

    return z;
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 4988
// ConsoleApplication3.cpp : アプリケーションのエントリ ポイントを定義します。
//


#include <iostream>
#include <vector>


using namespace std;

int main()
{
	bool kekka = true;
	vector<vector<int>> data{ { 1, 2, 3 },{ 4, 5, 6 },{ 4, 5, 6 } };

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> data[i][j];
		}
	}

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {

			if (data[i][j] - data[i][(j + 1) % 3] != data[(i + 1) % 3][j] - data[(i + 1) % 3][(j + 1) % 3]) {
				kekka = false;
			}
			else if (data[i][j] - data[(i + 1) % 3][j] != data[i][(j + 1) % 3] - data[(i + 1) % 3][(j + 1) % 3]) {
				kekka = false;
			}
		}

	}
	if (kekka) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

//配列を、中心配列の点、半径Rの円盤で覆え。なるべく円盤の数少なめに
int main(){
    int n; cin >> n;
    ll h[n];
    for(int i=0; i<n; i++) cin >> h[i];
    
    bool f = true;
    int maxi = 0;
    ll max = h[0];
    for(int i=0; i<n; i++){
        if(max <= h[i]){
            maxi = i;
            max = h[i];
            //cout << max << " " << maxi << endl;
        }else{
            //cout << h[i] << endl;
            if(maxi < i && max - h[i] > 1){
                f = false;
                break;
            }
        }
    }
        
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    
        
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
ll vis[100005];
bool dp[100005];
bool dp2[100005];
ll col[100005];
ll par[100005];
vector<ll> v[100005];
bool rec(ll ver,ll pa)
{
	vis[ver]=1;
	par[ver]=pa;
	if(v[ver].size()==1&&ver!=1)
	{
		dp[ver]=true;
		return true;
 
	}
	int f=1;
		int f2=1;
	
	for(int i=0;i<v[ver].size();i++)
	{
		
		if(v[ver][i]!=pa&&col[v[ver][i]]!=col[ver])
			f2=0;
		if(vis[v[ver][i]]==0)
		{
			if(rec(v[ver][i],ver)==false)
			{
				f=0;
			}
			
		}
	}
	if(f)
		dp[ver]=true;
	if(dp[ver]&&f2)
	{
		dp2[ver]=false;
		return true;
	}
	dp2[ver]=true;
	return false;
 
 
 
}
int ans=-1;
void dfs2(int ver,int p)
{
	if(dp[ver])
	{
		ans=ver;

	}
	for(int i=0;i<v[ver][i];i++)
	{
		int v1=v[ver][i];
		if(v1!=p)
		{
			bool temp1=dp[ver];
			bool temp2=dp[v1];
			if(dp2[ver]&&dp[v1])
				dp[v1]=true;
			if(dp[v1]==false)
			{

			}
		}
	}
} 
 
int main()
{
	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	ll dp[n];
	dp[0]=0;
	dp[1]=abs(a[0]-a[1]);
	for(int i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1];
	
 
	return 0;
}

Measured memory_bytes: 5888
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String ans = "No";

		//入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if((a<=c && c<=b) || (b<=c && c<=a)) {
			ans = "Yes";
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 23252
#include <iostream>

int main()
{
	using namespace std;
	string red = "red";
	string b = "";
	int a = 0;
	cin >> a;
	cin >> b;
	if (3200 <= a)
	{
		cout << b << endl;
	}
	else
	{
		cout << red << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


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

    ll a,b,c,d,e,k;
    cin >> a>>b>>c>>d>>e>>k;
    if(e - a > k) cout <<":("<<endl;
    else cout <<"Yay!"<<endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
    char s[11];
    char t[12];
    scanf("%s", s);
    scanf("%s", t);
    for (int i=0; i<strlen(s); ++i){
        if (s[i]!=t[i]){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  
  int x[100] = {0};
  
  for ( int i = 0; i < s.size(); i++ ){
    x[ s[i] - 'a' ] ++;
  }
  
  for ( int i = 0; i < 100; i++ ){
    if ( x[i] % 2 == 1 ){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
#define mod 1000000007
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x
#define IO if(fopen("input.txt", "r")){freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);} std::ios::sync_with_stdio(false);
using namespace std;


signed main()
{

    IO
    int t = 1;
    // cin >> t;
    while (t--) {


        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int ans = -1000000000000000001;
        ans = max(ans, a * c);
        ans = max(ans, b * d);
        ans = max(ans, max(a * d, b * c));
        cout << ans;

    }


    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N, x;
    cin >> N >> x;// x: 1 ~ 2N-1
    ll M = 2*N-1;
    if(x == 1 || x == M){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    if(N == 2){
        cout << "1 2 3" << endl;
        return 0;
    }
    vector<ll> ans(M,0);
    vector<bool> used(M+1,false);
    if(x == M-1){
        ans[N-3] = x-1;
        ans[N-2] = x+1;
        ans[N-1] = x;
        ans[N] = x-2;
        used[x-1] = true;
        used[x+1] = true;
        used[x] = true;
        used[x-2] = true;
    }
    else{
        ans[N-2] = x+1;
        ans[N-1] = x;
        ans[N] = x-1;
        ans[N+1] = x+2;
        used[x+1] = true;
        used[x] = true;
        used[x-1] = true;
        used[x+2] = true;
    }
    int idx = 1;
    rep(i,M){
        if(ans[i] > 0)continue;
        while(used[idx])idx++;
        ans[i] = idx;
        used[idx] = true;
    }
    // print(ans);
    rep(i,M){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 4824
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string.h>
#include<queue>
#include<utility>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
	long long a,b;
	cin>>a>>b;
	if(a%2==b%2) cout<<(a+b)/2;
	else cout<<"IMPOSSIBLE";
	return 0;
}

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

int main() {
	int n;
	std::cin >> n;

	std::vector<int> vec(n);
	for (auto&& e : vec)
		std::cin >> e;

	std::vector<int> dp(n + 1);
	std::unordered_map<int, int> last;

	last[0] = 0;
	for (int i = 1; i <= n; ++i) {
		int x = vec[i - 1];
		if (last.count(x - 1) == 0)
			continue;

		dp[i] = dp[last[x - 1]] + 1;
		last[x] = i;
	}

	int ans = n - *std::max_element(dp.begin(), dp.end());
	std::cout << (ans == n ? -1 : ans) << std::endl;
}

Measured memory_bytes: 10056
/*░░░░░░░▄▄▄▀▀▀▄▄███▄
░░░░░▄▀▀░░░░░░░▐░▀██▌
░░░▄▀░░░░▄▄███░▌▀▀░▀█
░░▄█░░▄▀▀▒▒▒▒▒▄▐░░░░█▌
░▐█▀▄▀▄▄▄▄▀▀▀▀▌░░░░░▐█▄
░▌▄▄▀▀░░░░░░░░▌░░░░▄███████▄
░░░░░░░░░░░░░▐░░░░▐███████████▄
░░░░░le░░░░░░░▐░░░░▐█████████████▄
░░░░toucan░░░░░░▀▄░░░▐██████████████▄
░░░░░░has░░░░░░░░▀▄▄████████████████▄
░░░░░arrived░░░░░░░░░░░░█▀██████*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
char s[100 * 1000 + 7];
int main()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	scanf("%s", s);
	int n = strlen(s);
	int g = 0, p = 0;
	int res = 0;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'p')
		{
			if (p + 1 <= g)
			{
				p++;
			}
			else
			{
				g++;
				res--;
			}
		}
		else if (s[i] == 'g')
		{
			if (p + 1 <= g)
			{
				res++;
				p++;
			}
			else
			{
				g++;
			}
		}
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 512