akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

long long int x, y, W[8001] = {}, H[8001] = {}, num1 = 1, num2 = 1;
bool flag = true, dp1[8001][16001] = {}, dp2[8001][16001] = {};
char s[8010] = {};

int main() {
	cin >> s;
	cin >> x >> y;
	for (int i = 0; i <= 8000; i++) {
		if (s[i] == NULL) {
			break;
		}
		if (s[i] == 'T') {
			if (flag) {
				flag = false;
				num1++;
			}
			else {
				flag = true;
				num2++;
			}
		}
		else if (s[i] == 'F') {
			if (flag) {
				W[num1]++;
			}
			else {
				H[num2]++;
			}
		}
	}
	dp1[1][W[1] + 8000] = true;
	for (int i = 2; i <= num1; i++) {
		for (int j = 1; j <= 16000; j++) {
			if (dp1[i - 1][j - W[i]] || dp1[i - 1][j + W[i]])
				dp1[i][j] = true;
		}
	}
	if (!dp1[num1][x + 8000]) {
		cout << "No" << endl;
		return 0;
	}
	dp2[1][H[1] + 8000] = true;
	dp2[1][-H[1] + 8000] = true;
	for (int i = 2; i <= num2; i++) {
		for (int j = 1; j <= 16000; j++) {
			if(dp2[i - 1][j - H[i]] || dp2[i - 1][j + H[i]])dp2[i][j] = true;
		}
	}
	if (dp2[num2][y + 8000]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 121600
#ifndef bhartiya
    // #pragma GCC optimize("Ofast")
    // #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

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

typedef long long ll;
typedef pair<ll, ll> pll;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#define pb push_back
#define bitc  __builtin_popcountl
#define mp make_pair
#define ff first
#define ss second

#define swap(a,b) {a=a^b;b=a^b;a=a^b;}
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)

#ifdef bhartiya
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
					  cout << "\n\nTime elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
}
#else
#define endl '\n'
#define trace(...)
#define start_routine()
#define end_routine()
#endif

#define inf 200000000000000ll
#define mod 1000000007ll
#define eps 1e-7

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


int main() 
{ 
    start_routine();
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.precision(10);
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        ll n,a,b;
        cin>>n>>a>>b;
        ll x = max(0ll, a+b-n);
        cout<<min(a,b)<<' '<<x<<endl;

    }
    end_routine();
}

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

using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mem(x, y) memset(x, y, sizeof x);
#define int long long
#define fi first
#define se second

const int maxn = (int) 1e6 + 6;
const double EPS = 1e-9;
const int INF = (int)1e18 + 18;
const int mod = (int)1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int digits(int n){return floor(log10(n))+1 ;}
bool ispoweroftwo (int x) { return x && (!(x&(x-1))); }



signed main(){
    int n,k;cin>>n>>k;
    vector<int> v(n+1);
    for(int i=1;i<=n;i++) cin>>v[i];
    vector<int> dp(n+1,INF);
    
    dp[0]=dp[1]=0;
    dp[2]=abs(v[2]-v[1]);
    for(int i=3;i<=n;i++){
        for(int j=1;j<=k;j++)
            {if(i-j>=1)
            {dp[i]=min(abs(v[i]-v[i-j])+dp[i-j],dp[i]);}}
    }
    cout<<dp[n]<<endl;
    
    
    
    return 0;
    
}




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

int main(){
  int n,d,result = 0;
  cin >> n >> d;
  int x[n][d];
  for(int i = 0;i < n;i++){
    for(int j = 0;j < d;j++){
      cin >> x[i][j];
    }
  }
  for(int i = 0;i < n;i++){
    for(int j = i+1;j < n;j++){
      int kyori = 0;
      for(int k = 0;k < d;k++){
        kyori += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
      }
      for(int l = 1;l <= 130;l++){
        if(kyori == l*l){
          result++;
        }
      }
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

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

  while (1) {
    int n, m;
    cin >> n >> m;
    if (n == 0 && m == 0) {
      break;
    }

    std::vector<int> goods(n);
    for (int i = 0; i < n; i++) {
      cin >> goods[i];
    }
    int result = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 1; j < n; j++) {
        if (i == j) continue;
        int sum = goods[i] + goods[j];
        // cerr << "\033[93m" << sum << "\033[m" << endl;
        if (sum <= m) {
          result = std::max(result, sum);
        }
      }
    }
    if (result == 0) {
      cout << "NONE" << endl;
    } else {
      cout << result << endl;
    }
  }

  return 0;
}



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

int a[10234];
vector<int>v;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < 3; i++)v.push_back(1 << 30);

	sort(a, a + n);
	for (int i = 0; i < min(n,8); i++) {
		for (int j = 0; j < min(8,n); j++) {
			if (i == j)continue;
			string s = to_string(a[i]);
			string b = to_string(a[j]);
			s += b;
			int c = stoi(s);
			if (v[2] >= c) {
				v.push_back(c);
				if (v[3] < v[2])swap(v[3], v[2]);
				if (v[2] < v[1])swap(v[2], v[1]);
				if (v[1] < v[0])swap(v[1], v[0]);
				v.pop_back();
			}
		}
	}
	cout << v[2] << endl;
	return 0;
}

Measured memory_bytes: 3284
#include<iostream>
#include<map>
#include<iomanip>

using namespace std;
using ll=long long;

#define rep(i, a, n) for (int i = (a); i < (n); ++i)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  string w;
  cin>>w;
  map<char,int>mp;

  rep(i,0,w.size()){
    auto itr = mp.find(w[i]);
    if( itr != mp.end() ) {
      mp[w[i]]++;
    } else {
      mp[w[i]]=0;
    }
  }

  bool flag=true;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
      if(itr->second%2==0){
        flag=false;
        break;
      }
  }
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

Measured memory_bytes: 256
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   998244353
#define    inf  9223372026854775807
#define    ninf   -inf
#define    ima   2047483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(12)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
#define    fbo    find_by_order
#define    ook    order_of_key
#define    upb    upper_bound
#define    lowb   lower_bound 
#define    lte(v,x)   upb(all(v),x)-v.be()
#define    gte(v,x)   v.end()-lowb(all(v),x)
const    ld   PI=3.1415926535897932384626433832792884197169399375105820974944;
inline ll modpow(ll x,ll n){if(x==0)return 0;if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}
inline ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}



int main()
{       io 
int testcases=1;     //   cin>>testcases;
while(testcases--)
{





ll a,b;
cin>>a>>b;
cout<<a*b;













}return 0;}

Measured memory_bytes: 3640
#include <stdio.h>

#define NUMBER 4

void bsort(int a[],int n)
{
  int i,j;

  for(i = 0; i < n -1;i++){
    for (j = n-1; j>i-1; j--){
      if(a[j-1]>a[j]){
        int temp = a[j];
        a[j] = a[j-1];
        a[j-1] = temp;
      }
    }
  }
}

int main(void)
{
  int i;
  int a[NUMBER];

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

  bsort(a,NUMBER);

  if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9)
   printf("YES");
  else
   printf("NO");

  return 0;
}


Measured memory_bytes: 128
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
#if DEBUG
            ReadLine();
#endif
        }

        void Solve(ConsoleInput cin)
        {
            int n = cin.ReadInt;

            int[] a = new int[n];
            int[] b = new int[n];
            int[] c = new int[n];

            for (int i = 0; i < n; i++)
            {
                a[i] = cin.ReadInt;
                b[i] = cin.ReadInt;
                c[i] = cin.ReadInt;
            }

            long[,] dp = new long[n + 1, 3];
            dp[0, 0] = dp[0, 1] = dp[0, 2] = 0;

            for (int i = 0; i < n; i++)
            {
                dp[i + 1, 0] = Math.Max(dp[i, 1] + b[i], dp[i, 2] + c[i]);
                dp[i + 1, 1] = Math.Max(dp[i, 0] + a[i], dp[i, 2] + c[i]);
                dp[i + 1, 2] = Math.Max(dp[i, 0] + a[i], dp[i, 1] + b[i]);
            }

            Console.WriteLine(Math.Max(dp[n, 0], Math.Max(dp[n, 1], dp[n, 2])));
        }

        class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;

            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }

            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }

            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 18624
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Segment_Tree{
	private:
	int n;
	vi date;
	int Query_func(int a,int b,int k,int l,int r){
		if(r<=a||b<=l) return 0;
		if(a<=l&&r<=b) return date[k];
		int m=(l+r)/2;
		return Query_func(a,b,k*2+1,l,m)+Query_func(a,b,k*2+2,m,r);
	}
	public:
	Segment_Tree(int n_){
		n=1;
		while(n<n_) n*=2;
		date=vi(2*n-1);
	}
	void Update(int k){
		k+=n-1;
		date[k]++;
		while(k>0){
			k=(k-1)/2;
			date[k]=date[k*2+1]+date[k*2+2];
		}
	}
	int Query(int a){
		return Query_func(a,n,0,0,n);
	}
	int Open(int k){
		return date[k+n-1];
	}
};

ll n,k;
vl a;

int main(){
	cin>>n>>k;
	a=vl(n);
	for(int i=0;i<n;i++) cin>>a[i];
	vl b(n+1);
	Segment_Tree st(n+1);
	map<ll,int> m;
	ll K=0;
	for(int i=0;i<n;i++){
		b[i]=K;
		K+=k-a[i];
	}
	b[n]=K;
	sort(b.begin(),b.end());
	for(int i=0;i<=n;i++) m[b[i]]=i;
	ll res=0;
	K=0;
	for(int i=0;i<n;i++){
		st.Update(m[K]);
		K+=k-a[i];
		res+=st.Query(m[K]);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 17920
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author toshibablack
 */

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<=(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x,0,sizeof(x))
#define MINF(x) memset(x,0x3f,sizeof(x))
#define MMINUS(a) memset(a,0xff,sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1.0/LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

using namespace std;

class BKagamiMochi {
public:
    ll N;
    vector<ll> v;

    void solve(std::istream& in, std::ostream& out) {
        in >> N;
        REP(i, N) { ll tmp; in >> tmp; v.push_back(tmp); }
        sort(ALL(v));
        v.erase(unique(ALL(v)), v.end());
        out << v.size() << endl;
    }
};


int main() {
    BKagamiMochi solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    int n;
    String[] s;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        s = deduplication(s);
        System.out.println(s.length);
    }

    // 配列内の重複を排除
    private String[] deduplication(String[] s) {
        Set<String> deduplicatedList = new LinkedHashSet<String>();
        for (int i = 0; i < s.length; i++) {
            deduplicatedList.add(s[i]);
        }
        String[] ret = deduplicatedList.toArray(new String[deduplicatedList.size()]);
        return ret;
    }
}

Measured memory_bytes: 73732
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////

ll p(ll n) {
	if (n == 0) { return 1; }
	if (n == 1) { return 2; }
	ll x = p(n / 2);
	ll y = p(n % 2);
	return (x*x) % MOD*y%MOD;
}

ll iv(ll i) {
	if (i == 1) { return 1; }
	return MOD - iv(MOD%i)*(MOD / i) % MOD;
}

ll com(ll n, ll a) {
	ll A = 1;
	repn(i, a) { A *= i; A %= MOD; }
	ll B = 1;
	repn(i, a) { B *= (n + 1 - i); B %= MOD; }

	return iv(A) *B % MOD;
}
int main() {

	ll n,a,b;
	cin >> n>>a>>b;


	ll ans = p(n) - com(n, a) - com(n, b) - 1;

	ans %= MOD;

	if (ans < 0) { ans += MOD; }

	cout << ans;
	
	system("PAUSE");

	

}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  long long T;
  long long t[N];
  cin >> N >> T;
  for(int i=0; i<N; i++){
    cin >> t[i];
  }
  long long ans = 0;
  for(int i=0; i<N-1; i++){
    if(t[i+1] - t[i] < T){
      ans += t[i+1] - t[i];
    }else{
      ans += T;
    }
  }
  cout << ans + T << endl;
  return 0;
}


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

#define ll long long 
#define d  double 
#define endl "\n"

const ll int MOD=1e9+7;

void solve()
{
	int k,n;
	string s,str;
	cin >> k >> str;
	n = str.size();
	if(n>k)
	{
		s = str.substr(0,k);
		cout <<s + "...\n";
	}
	else
		cout << str << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

struct UnionFind {
    vector<int> data;
    vector<int> sizes;
    
    UnionFind(int n) : data(n) ,sizes(n, 1){
        for(int i = 0; i < n; i++) data[i] = i;
    }
    
    int root(int x) {
        if (data[x] == x) return x;
        return data[x] = root(data[x]);
    }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (y < x) swap(x, y);
        data[y] = x;
        sizes[x] += sizes[y];
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int size(int x) {
        return sizes[root(x)];
    }
};

signed main(){start();
    int n,m;
    cin>>n>>m;
    Vi a(m),b(m),c(m);
    REP(i,0,m){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--; b[i]--;
    }
    
    UnionFind UF(n);
    REP(i,0,m){
        UF.unite(a[i],b[i]);
    }
    map<int,int> ans;
    REP(i,0,n){
        ans[UF.root(i)]++;
    }
    cout<<ans.size()<<endl;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 200100;
ll n, k;
ll arr[maxn];

bool valid(ll x) {
	ll cnt = 0LL;
	for(int i=1;i<=n;i++) {
		cnt += ((arr[i] + x - 1) / x - 1);
	}
	return cnt <= k;
}

int main() {
	cin>>n>>k;
	ll maxval = 0LL;
	for(int i=1;i<=n;i++) {
		cin>>arr[i];
		maxval = max(maxval, arr[i]);
	}

	ll result = maxval;
	for(ll cekor=maxval;cekor>0;cekor/=2) {
		while(result - cekor >= 1 && valid(result-cekor)) result -= cekor;
	}
	cout<<result<<"\n";
}

Measured memory_bytes: 5156
import sys

n = int(input())
if n==10000 or n==1000 or n==2000 or n==3000 or n==4000 or n==5000 or n==6000 or n==7000 or n==8000 or n==9000:
  change = 0
  
elif 10000 > n >= 1000:
    hyaku=(n%1000)
    change = 1000 - hyaku
else:
  change = 1000-n

print(change)

Measured memory_bytes: 9124
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>

using namespace std;
#define LL long long
const int N = 100010;
template<typename T>inline void read(T& x){
	x = 0;
	int f = 0;
	char ch = getchar();
	for(;!isdigit(ch);ch = getchar())
		f |= (ch == '-');
	for(;isdigit(ch);ch = getchar())
		x = (x << 1) + (x << 3) + (ch ^ 48);
	x = f ? -x : x;
}
LL gcd(LL x,LL y){
	if(x < y)
		swap(x,y);
	return (y == 0) ? x : gcd(y,x % y);
}
char s[N],t[N];
LL n,m;
int main(){
	read(n),read(m);
	scanf("%s %s",s + 1,t + 1);
	LL g = gcd(n,m);
	LL len = n / g * m; 
	LL pos1 = 1,pos2 = 1,s1 = 1,t1 = 1;
	while(pos1 <= len && pos2 <= len){
		if(pos1 == pos2){
			if(s[s1] != t[t1])
				return puts("-1"),0;
			pos1 += len / n,pos2 += len / m;
			s1++,t1++;
		}
		else if(pos1 < pos2)
			pos1 += len / n,s1++;
		else 
			pos2 += len / m,t1++;
	}
	printf("%lld",len);
	return 0;
}



Measured memory_bytes: 384
class SwappingTwoNumbers:
    def output(self, n):
        n.sort()
        print "%d %d" % (n[0], n[1])

if __name__ == "__main__":
    stn = SwappingTwoNumbers();
    while True:
        n = map(int, raw_input().split())
        if n[0] == 0 and n[1] == 0:
            break
        stn.output(n)

Measured memory_bytes: 6360
n=int(input())
arr=list(map(int, input().split()))
INF=1e9+5

dp=[INF for i in range(n)]
dp[0]=0

for i in range(len(arr)):
    for j in (i+1,i+2):
        if(j<n):
            dp[j]=min(dp[j], dp[i]+abs(arr[j]-arr[i]))

print(dp[n-1])


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

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

  int i;
  i = N / (2*D+1);
  if ( N % (2*D+1) == 0 ) cout << i << endl;
  else cout << i+1 << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  ll ret = (a * x + b * y);
  ret = min(ret, (c * (min(x, y) * 2) + a * (x - min(x, y)) + b * (y - min(x, y))));
  ret = min(ret, (c * (max(x, y) * 2) + a * (max((ll)0, x - max(x, y))) +
                  b * (max((ll)0, y - max(x, y)))));
  cout << ret << endl;
}


Measured memory_bytes: 256
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void solve() throws Exception {
		scanInt();
		int a = scanInt() - 1;
		int b = scanInt() - 1;
		out.print(((a ^ b) & 1) != 0 ? "Borys" : "Alice");
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 22996
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << "\n"; }

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

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


#line 2 "tmp.cpp"

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

  int n;
  cin >> n;
  vl a(n);
  map<int, ll> cnt;
  map<int, int> idx;
  REP(i, n) {
    cin >> a[i];
    if (idx.find(a[i]) == idx.end()) {
      idx[a[i]] = i;
    }
    cnt[a[i]]++;
  }

  sort(a.rbegin(), a.rend());
  a.erase(unique(a.begin(), a.end()), a.end());

  int s = a.size();
  vl ans(n, 0);

  ll now = cnt[a[0]];
  int now_idx = idx[a[0]];

  FOR(i, 1, s) {
    ans[now_idx] += (a[i - 1] - a[i]) * now;
    now += cnt[a[i]];
    chmin(now_idx, idx[a[i]]);
  }

  ans[0] += a[s - 1] * now;

  REP(i, n) { cout << ans[i] << endl; }

  return 0;
}


Measured memory_bytes: 13568
#include<stdio.h>
int main(void){
    int i, d, m1, m2, m3;
    m1 = 0;
    m2 = 0;
    m3 = 0;
    for(i=0; i<10; i++) {
        scanf("%d", &d);
        if(d>m1){
          m3 = m2;
          m2 = m1;
          m1 = d;
        }else if(d>m2){
          m3 = m2;
          m2 = d;
        }else if(d>m3){
          m3 = d;
        }
    }
    printf("%d\n%d\n%d\n", m1, m2, m3);
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    ll shoji = 1000;
    ll kabu = 0;
    bool flag = false;
    for(int i=0; i<N-1; ++i){
        for(int j=i+1; j<N; ++j){
            if(A[i]<A[j]){
                kabu = shoji/A[i];
                shoji = shoji%A[i];
                shoji += kabu*A[j];
                kabu = 0;
                break;
            }
            else break;
        }
    }
    cout << shoji << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int x;
  x=0;
  cin >> s;
  for(int i=0;i<4;i++){
    if(s.at(i)=='+'){
      x++;
    }
  }
  for(int i=0;i<4;i++){
    if(s.at(i)=='-'){
      x--;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String S = in.readLine();

		long[] A = new long[S.length()];

		Arrays.fill(A, 0);

		long r=0;
		int rIndx = -1;
		long l=0;
		boolean flg = true;
		for(int i=0;i<S.length();i++){
			if(flg){
				if(S.charAt(i)=='R'){
					r++;
				}else{
					l=1;
					rIndx=i-1;
					flg=false;
				}
			}
			else{
				if(S.charAt(i)=='L'){
					l++;
				}else{
					A[rIndx]=(l+r)/2;
					A[rIndx+1]=(l+r)/2;

					if(Math.abs(l+r)%2==1){
						if(l%2==0){
							A[rIndx]++;
						}else{
							A[rIndx+1]++;
						}
					}
					flg=true;
					r=1;

				}

			}
		}
		A[rIndx]=(l+r)/2;
		A[rIndx+1]=(l+r)/2;

		if(Math.abs(l-r)%2==1){
			if(l%2==0){
				A[rIndx]++;
			}else{
				A[rIndx+1]++;
			}
		}
		for(int i=0;i<S.length()-1;i++){
			System.out.print(A[i]+" ");
		}
		System.out.println(A[S.length()-1]);
	}
}


Measured memory_bytes: 48024
n,d=map(int,input().split(" "))
s=[list(map(int,input().split(" "))) for i in range(0,n)]
from math import*
#print(s)
co=0
for i in range(0,n-1):
    for j in range(i+1,n):
        combi=[abs(x-y)**2 for (x,y)in zip(s[i],s[j])]
        if sqrt(sum(combi))%1==0:
            co+=1
print(co)

Measured memory_bytes: 3064
use std::io::{BufRead, Write};
use std::io;
use std::iter;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let mut split = s.split_whitespace();
    let n = split.next().unwrap().parse::<usize>().unwrap();
    let mut count = vec![[0usize; 26];n];
    for i in &mut count {
        let mut s = String::new();
        input.read_line(&mut s).unwrap();
        let t = s.trim();
        for c in t.chars() {
            i[c as usize - 'a' as usize] += 1;
        }
    }
    let max = (0..26)
        .map(|i| count.iter().map(|j| j[i]).min().unwrap())
        .collect::<Vec<_>>();
    writeln!(output,
             "{}",
             (0..26)
                 .flat_map(|i| iter::repeat((b'a' + i) as char).take(max[i as usize]))
                 .collect::<String>())
            .unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v = Vec::<u8>::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
    #[test]
    fn case1() {
        test("3
cbaa
daacc
acacac\n",
             "aac\n");
    }
    #[test]
    fn case2() {
        test("3
a
aa
b\n",
             "\n");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>
#include <complex>
#define ll long long
using namespace std;


int main() {
	int n, k;
	string s;
	cin >> n >> k >> s;
	s[k - 1] = s[k - 1] - 'A' + 'a';
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<ll> A(N), AA(N, 0);
  REP(i, N){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  REP(i, N){
    if(i == 0 || i == N-1){
      AA[i] = A[i];
    }else{
      AA[i] = AA[i-1]+A[i];
    }
  }
  ll ans = 1;
  for(int i = N-1; i > 0; i--){
    if(A[i] <= AA[i-1]*2){
      ans++;
    }else{
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  ll n;
  cin>>n;
  ll h[n];
  fo(i,n)
  cin>>h[i];
  ll dp[n];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(ll i=2;i<n;i++)
    dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
  cout<<dp[n-1];
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 101
void initialize(void);
void push(int);
int pop(void);
int isEmpty(void);
int isFull(void);
int S[MAX];
int top;

int main(void){


  int x,y,i=0;
  char s[MAX];
  initialize();
  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      x = pop();
      y = pop();
      x = x + y;
    }
    else if(s[0] == '-'){
      x = pop();
      y = pop();
      x = y - x;
    }
    else if(s[0] == '*'){
      x = pop();
      y = pop();
      x = x * y;
    }
    else x = atoi(s);

    push(x);
  }


  printf("%d\n",S[top]);
  return 0;
}

void initialize(void){
  top = 0;
}

int isEmpty(void){
  if( top == 0)return 1;
  else return 0;
}

int isFull(void){
  if( top >= MAX -1)return 1;
  else return 0;
}

void push(int x){
  if(isFull() == 1) printf("error overflow\n");

  top++;
  S[top] = x;
}

int pop(){
  if(isEmpty() == 1) printf("error underflow\n");

  top--;
  return S[top+1];
}

Measured memory_bytes: 548
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N;
  cin >> N;
  vector<int> A(N-1);
  rep(i,N-1) cin >> A[i];
  vector<int> buka(N);
  rep(i,N-1) buka[A[i]-1]++;
  rep(i,N) cout << buka[i] << endl;
  return 0;
}

Measured memory_bytes: 4508
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main(){
	ll a, b, c;
	cin >> a >> b >> c;
	// √a + √b < √c 
	// <-> a + b + 2√ab < c
	// <-> c - a - b > 2√ab 
	// <-> c > a + b && a^2 + b^2 + c^2 + 2ab - 2bc - 2ca > 4ab   
	if(c > a+b && a*a + b*b + c*c + 2*a*b - 2*b*c - 2*c*a > 4*a*b) cout << "Yes" << endl;
	else cout << "No" << endl;
	return;
}

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

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	char a[1], b[1];
	scanf("%s %s",&a,&b);

	if (a[0] == 'H' && b[0] == 'H'){
		printf("H\n");
	}
	else if (a[0] == 'D' && b[0] == 'D'){
		printf("H\n");
	}
	else if (a[0] == 'D' && b[0] == 'H'){
		printf("D\n");
	}
	else printf("D\n");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
	// ABC145-C, 
	int n; cin >> n;
	vector<P> p(n);
	rep(i, n) cin >> p[i].first >> p[i].second;
	sort(ALL(p));
	double ans = 0;
	int num = 0;
	do {
		num++;
		double dist = 0;
		rep(i, n) {
			if (i == 0) continue;
			dist += sqrt((p[i].first - p[i - 1].first) * (p[i].first - p[i - 1].first) + (p[i].second - p[i - 1].second) * (p[i].second - p[i - 1].second));
		}
		ans += dist;
	} while (next_permutation(p.begin(), p.end()));
	cout << setprecision(15) << ans / num << endl;

	return 0;
}

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

int main() {
    int W, H, r, x, y;
    cin >> W >> H >> x >> y >> r;
    if (0 <= x-r && x+r <= W && 0 <= y-r && y+r <= H) {
        cout << "Yes" << endl;
    } else {
       cout << "No" << endl;
    }
}


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

int main() {
  string S,T;
  cin>>S>>T;
  int s=S.size();
  int ans=0;
  rep(i,s) if(S.at(i)!=T.at(i)) ans++;
  cout<<ans;

}


Measured memory_bytes: 3916
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int x, y, a, b, c;
	cin>>x>>y>>a>>b>>c;
	ll p[100010], q[100010], r[100010];
	for(int i=0; i<a; i++) cin>>p[i];
	for(int i=0; i<b; i++) cin>>q[i];
	for(int i=0; i<c; i++) cin>>r[i];
	sort(p, p+a, greater<ll>());
	sort(q, q+b, greater<ll>());
	sort(r, r+c, greater<ll>());
	vector<ll> v;
	for(int i=0; i<x; i++) v.push_back(p[i]);
	for(int i=0; i<y; i++) v.push_back(q[i]);
	for(int i=0; i<c; i++) v.push_back(r[i]);
	sort(v.begin(), v.end(), greater<ll>());
	ll ans=0;
	for(int i=0; i<x+y; i++) ans+=v[i];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8848
#include<bits/stdc++.h>
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
using namespace std;

int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a%b);
}
int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}
int ncr(int n, int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i){
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}
signed main(){

#ifndef ONLINE_JUDGE
   // freopen("input.txt","r", stdin);
#endif

    fastIO

    int n;
    cin >> n;
    int arr[n],dp[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
        dp[i] = 0;
    }
    dp[1] = abs(arr[0] - arr[1]);
    for(int i=2;i<n;i++){
        if(i > 1){
            dp[i] = dp[i-2] + abs(arr[i-2] - arr[i]);
//            cout << "1-dp[i] = " << dp[i] << endl;
        }
        dp[i] = min(dp[i], dp[i-1] + abs(arr[i-1] - arr[i]));
//        cout << "2-dp[i] = " << dp[i] << endl;
    }
    cout << dp[n-1];

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
using namespace std;
typedef long long ll;

int main(void){
    int n;
    cin>>n;
    typedef std::pair<int, int> pair;
    vector<pair> w(n);
    rep(i, n){
        int a, b;
        cin>>a>>b;
        w[i].first=b;
        w[i].second=a;
    }
    sort(w.begin(), 
        w.end());
    
    bool ans=true;
    int sum=0;
    rep(i, n){
        sum+=w[i].second;
        if(sum>w[i].first){
            ans=false;
            break;
        }
    }
    
    if (ans==true){
        cout<<"Yes";
    } 
    else {
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 1920
using System;
using System.Linq;
class Program
{
    public static void Main()
    {
        int[] qhsd = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        double n = int.Parse(Console.ReadLine());
        double[][] cost = new double[4][];
        double[] q = { 0.25, 0.5, 1.0, 2.0 };
        int[] m = { 8, 4, 2, 1 };

        for (int i = 0; i < 4; i++)
        {
            cost[i] = new double[3];
            cost[i][0] = q[i];
            cost[i][1] = m[i] * qhsd[i];
            cost[i][2] = qhsd[i];
        }

        Array.Sort(cost, (a, b) => (int)a[1] - (int)b[1]);

        long sum = 0;
        for (int i = 0; i < 4; i++)
        {
            sum += (int)Math.Floor(n / cost[i][0]) * (long)cost[i][2];
            n = n % cost[i][0];
        }
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
using namespace std;
  ll countDivisors(ll n) 
{ 
    ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                cnt++; 
  
            else 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	ll n;
	cin>>n;
   ll h[n],dp[n]={0};
	for(i=0;i<n;i++)
	cin>>h[i];
	dp[1]=abs(h[1]-h[0]);
	for(i=2;i<n;i++)
	{
		dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
	}
	cout<<dp[n-1];
	cout<<"\n"; 
 } 
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long power = 1;
		for(int i = 1; i <= n; i++)
			power = (power*i)%1000000007;
		System.out.println(power);
	}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;
int main(){
    ll n,ans = 0;
    cin>>n;
    vector<ll>bitcnt(62,0);
    rep(i,n){
        ll a;
        cin>>a;
        rep(j,60){
            if(a & (1LL << j)){
                bitcnt[j]++;
            }
        }
    }
    rep(i,60){
        ll notbit = n - bitcnt[i];
        ll standbit =  notbit * bitcnt[i];
        ans += ((1LL << i)%MOD * (standbit%MOD))%MOD;
        ans %= MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n=1000;
  map<char,set<char> > G;
  G['A'].insert('B');
  G['A'].insert('D');
  G['B'].insert('A');
  G['B'].insert('C');
  G['B'].insert('E');
  G['C'].insert('B');
  G['C'].insert('F');
  G['D'].insert('A');
  G['D'].insert('E');
  G['D'].insert('G');
  G['E'].insert('B');
  G['E'].insert('D');
  G['E'].insert('F');
  G['E'].insert('H');
  G['F'].insert('C');
  G['F'].insert('E');
  G['F'].insert('I');
  G['G'].insert('D');
  G['G'].insert('H');
  G['H'].insert('E');
  G['H'].insert('G');
  G['H'].insert('I');
  G['I'].insert('F');
  G['I'].insert('H');
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    bool f=1;
    for(int i=0;i<(int)s.size()-1;i++){
      f&=G[s[i]].count(s[i+1]);
    }
    if(f) cout<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 3148
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
const int maxN = 3e3 + 7;
const int mod = 1e9 + 7;

inline int pls(int x, int y) {return (x + y) % mod;}
inline int mul(int x, int y) {return 1LL * x * y % mod;}
inline int mns(int x, int y) {return pls(x, mod - y);}
inline void Add(int &x, int y) {x = pls(x, y);}
inline void Mul(int &x, int y) {x = mul(x, y);}

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n, m;
int f[maxN][maxN][2];

inline int sp(int x) {return x == 1 || x == n;}

int main() {

	n = ri() + 1, m = ri();
	rep (i, 1, n) f[0][i][(i == 1)] = 1;
	rep (i, 1, m) rep (j, 1, n) rep (k, 0, 1) {
		rep (d, -1, 1) {
			int y = j + d;
			if (y < 1 || y > n) continue;
			if (d != 0) {
				Add(f[i][y][k | (y == 1)], f[i-1][j][k]);
			}
			else {
				Add(f[i][y][k | (j == 2)], f[i-1][j][k]);
				if (!sp(j)) Add(f[i][y][k], f[i-1][j][k]);
			}
		}
	}

	int res = 0;
	rep (i, 1, n) Add(res, f[m][i][1]);
	printf("%d\n", res);

	return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

const long long MAX = 510000;  // 最大を決めておく
// fac…階乗、inv…逆数、finv…逆数の累積積
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理、先にやっておく
void nCr_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// nCrを計算する (前処理は忘れないように)
long long nCr(int n, int r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

// ====================================================================

int main() {
  nCr_init();

  ll h, w, k;
  cin >> h >> w >> k;

  ll ans = 0;
  for (ll dx = 1; dx < w; dx++) {  // その横幅を、全探索。
    ans = (dx * (w - dx) * h % MOD * h % MOD * nCr(h * w - 2, k - 2) % MOD + ans) % MOD;
  }
  for (ll dy = 1; dy < h; dy++) {  // その横幅を、全探索。
    ans = (dy * (h - dy) * w % MOD * w % MOD * nCr(h * w - 2, k - 2) % MOD + ans) % MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 12288
n = int(input())
x = list(map(float, input().split()))
y = list(map(float, input().split()))
dif = [abs(i-j) for i, j in zip(x, y)]
print(sum(dif))
print(sum([i**2 for i in dif])**0.5)
print(sum([i**3 for i in dif])**(1/3))
print(max(dif))



Measured memory_bytes: 5664
n = input()
n = n.split(" ")
n = list(map(int, n))
len_ = n[1]

length = input()
length = length.split(" ")
length = list(map(int, length))
length.sort()


length.reverse()
len_max = length[0 : len_]
max_ = sum(len_max)

print(max_)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll x;
    cin >> x;
    ll ans = (x/11)*2;
    ll b = x%11;
    if(b >= 1 && b <= 6) ans++;
    else if(b >= 7) ans+= 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void resolve()
{
    int N, K;
    cin >> N >> K;

    int ans = 1;
    while (N > 0) {
        N = N / K;
        if (N > 0) ans++;
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 256