akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int o(vector<int> y) {
	int a = 1;
	int x = y.at(0);
	for (int i = 1; i < y.size(); i++) {
		if (x != y.at(i)) a++;
		x = y.at(i);
	}
	return y.size()-a;
}

int main() {
	int n, k;
	string s;
	cin >> n >> k >> s;
	vector<int> y(n);
	rep(i, n) {
		if (s.at(i) == 'L') y.at(i) = 0;
		else y.at(i) = 1;
	}
	for (int i = 1; i < n - 1; i++) {
		if (k == 0) { cout << o(y) << endl;	return 0;
		}
		if (y.at(i) != y.at(i - 1) && y.at(i) != y.at(i + 1)) { y.at(i) = y.at(i - 1); k--; }
	}
	int x = 0;
	int a = y.at(0);
	rep (i,y.size()) {
		if (k == 0) { cout << o(y) << endl;	return 0; }
		if (y.at(i) != a) {
			if (x != 0) {
				for (int j = x; j < i; j++) y.at(j) = y.at(x - 1);
				x = 0; k--;
			}
			else x = i;
		}
		a = y.at(i);
	}
	cout << y.size()-1 << endl;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ll a,b,c;
  cin>>a>>b>>c;
  if(c<=a+b)
   cout<<"No";
  else if(4*a*b<(c-a-b)*(c-a-b))
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map( int, input().split() )

#print( x2 - x1, y2 - y1)

x3 = x2 - y2 + y1
y3 = y2 + x2 - x1
x4 = x1 - y2 + y1
y4 = y1 + x2 - x1

print(x3, y3, x4, y4)


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

#define say(obj) (cout << obj << endl)
#define endline (cout << endl)
#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to, cost;
	edge_(ll to, ll cost) : to(to), cost(cost) {}
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr int		INF = (int)1e7;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template <typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template <typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template <typename T>
ostream& operator << (ostream& os, const vector<vector<T>>& mat) {
	for (const vector<T>& m : mat) os << m << endl;
	return os;
}

template <typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

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

template <typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

int main()
{
	int A, B, K;
	cin >> A >> B >> K;

	for (int i = 0; i < K; i++) {
		if (i % 2 == 0) {
			if (A % 2 == 1) A--;
			B += A / 2;
			A /= 2;
		}
		else {
			if (B % 2 == 1) B--;
			A += B / 2;
			B /= 2;
		}
	}

	cout << A << " " << B << endl;

	return 0;
}

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

int main(){
  int A, B;
  cin >> A >> B;

  if(A>=13){
    cout << B << endl;
  } else if(A>=6&&A<=12){
    cout << B/2 << endl;
  } else if(A<=5){
    cout << "0" << endl;
  }
  

  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 500000

struct Node{
  int key;
  struct Node *r, *l, *p;
};
void insert(int);
void inOrder(struct Node *);
void preOrder(struct Node *);
struct Node *root, *NIL;
int main() {
  int i,m,z;
  char command[10];
  scanf("%d",&m);
  for (i = 0; i < m ; i++) {
    scanf("%s",command);
    if (strcmp(command,"insert")==0) {
      scanf("%d",&z);
      insert(z);
    }
    else if (strcmp(command,"print")==0) {
      inOrder(root);
      printf("\n");
      preOrder(root);
      printf("\n");
    }
  }
  return 0;
}
void insert(int n) {
  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z;

  z = (struct Node *)malloc(sizeof(struct Node));
  z->key = n;
  z->l = NIL;
  z->r = NIL;

  while ( x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->l;
    }
    else{
      x = x->r;
    }
  }
  z->p = y;
  if (y == NIL) {
    root = z;
  }else{
    if (z->key < y->key) {
      y->l = z;
    }else{
      y->r = z;
    }
  }
}
void inOrder(struct Node *v){
  if (v == NIL) {
    return;
  }
  inOrder(v->l);
  printf(" %d",v->key);
  inOrder(v->r);
}
void preOrder(struct Node *v){
  if (v == NIL) {
    return;
  }
  printf(" %d",v->key);
  preOrder(v->l);
  preOrder(v->r);
}

Measured memory_bytes: 24040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
int main() 
{
    int n,k;
    cin >> n >> k;

    double p[n+10];
    rep(i,n){
        cin >> p[i];
        p[i]=(p[i]+1)/2; 
    }


    double sum=0,maxs=0;
    for(int i=0;i<k;i++){
        sum+=p[i];   
    }
    maxs=sum;
    for(int i=0;i<n-k;i++){
        sum=sum+p[i+k]-p[i];
        maxs=max(maxs,sum);
    }

    double ans;
    ans=maxs/k;
    cout << setprecision(10) << maxs << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define H_MAX 50
#define W_MAX 50

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

namespace patch {
  template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
}

int main() {
	int n;
	cin >> n;
	vector<int> vh;
	int h;

	rep(i,n) {
		cin >> h;
		vh.pb(h);
	}
	int count = 0;
	int tc;
	bool flag;
	rep(i,n) {
		if(i==0){
			count++;
			continue;
		}
		tc = 0;
		flag = true;
		while(tc < i){
			if(vh[tc] > vh[i]){
				flag = false;
				break;
			}
			tc++;
		}
		if(flag==false)
			continue;
		count++;
	}
	cout << count << endl;
  return 0;
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define INF 1000000001
#define MOD 10000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const ull B=100000007;
int main(){
      int n;
      while(cin>>n&&n){
            int lb=-1,ub=n,a[n],cnt=0,k;
            REP(i,n)cin>>a[i];
            cin>>k;
            while(ub-lb>1){
                  int mid=(lb+ub)/2;
                  cnt++;
                  if(k==a[mid])break;
                  if(a[mid]>k)ub=mid;
                  else lb=mid;
            }
            cout<<cnt<<endl;
      }
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main(){
    int M1,D1,M2,D2;
    cin >> M1 >> D1 >> M2 >> D2;

    if (M1 == M2){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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, k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i,n) cin >> x.at(i);

    int ans = 1e9;
    rep(i, n-k+1) {
        ans = min(ans, abs(x.at(i)) + abs(x.at(i) - x.at(i+k-1)));
        ans = min(ans, abs(x.at(i+k-1)) + abs(x.at(i) - x.at(i+k-1)));
    }
    cout << ans << endl;
    return 0;
}


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

#undef int
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t=1;
	//cin >> t;
	while (t--) {
		int a,b;
		cin >> a>>b;
		if(b>=a)
			cout<<"unsafe"<<endl;
		else
			cout<<"safe"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int left = a + b;
		int right = c + d;

		if (left < right) {
			System.out.println("Right");
		} else if (left > right) {
			System.out.println("Left");
		} else {
			System.out.println("Balanced");
		}


		sc.close();

	}

}


Measured memory_bytes: 35628
n,m,*a=map(int,open(0).read().split())
a=set(a)
mod=10**9+7

dp=[0]*(n+1)

dp[0]=1
dp[1]=0 if 1 in a else 1

for st in range(2,n+1):
    if st in a:
        continue
    
    dp[st]=dp[st-1]+dp[st-2]
    dp[st]%=mod

print(dp[n])

Measured memory_bytes: 99592
#include<stdio.h>
#include<stdlib.h>
int exsearch(int*, int, int);
main()
{
        int i, n, q, m, *a;
        scanf("%d", &n);
        a = (int*)malloc(sizeof(int) * n);
        for(i = 0; i < n; i++){
        scanf("%d%*c", &a[i]);
        }
        scanf("%d", &q);
        for(i = 0; i < q; i++){
                scanf("%d%*c", &m);
                if(exsearch(a, m, n)){
                        printf("yes\n");
                }else{
                        printf("no\n");
                }
        }
        free(a);
}
int exsearch(int *a, int m, int n)
{
        int result = 0;
        if(!m){
                result = 1;
        return result;
        }else if(!n || m < 0 ){
                result = 0;
                return result;
        }else{
                result |= exsearch(a, m - a[n - 1], n - 1);
                result |= exsearch(a, m, n - 1);
        }
        return result;
}

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

struct Init {
  Init() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} Init;

signed main() {
  int N;
  vector<pair<int, int>> v;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    v.push_back(make_pair(x, y));
  }

  sort(v.begin(), v.end());

  double ans = 0;
  int cnt = 0;

  do {
    cnt++;
    double sum = 0;
    for (int i = 0; i < v.size() - 1; i++) {
      sum += sqrt(
          (v[i].first - v[i + 1].first) * (v[i].first - v[i + 1].first) +
          (v[i].second - v[i + 1].second) * (v[i].second - v[i + 1].second));
    }
    ans += sum;
  } while (next_permutation(v.begin(), v.end()));

  cout << double(ans / cnt) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

ll powll(ll a, ll n) {
    ll ans = 1;
    rep(i, n) {
        ans *= a;
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll A, B, C;
    cin >> A >> B >> C;
    int K;
    cin >> K;
    rep(i, K + 1) {
        rep(j, K + 1) {
            if (i + j > K) continue;
            int k = K - i - j;
            ll R = pow(2, i) * A;
            ll G = pow(2, j) * B;
            ll B = pow(2, k) * C;
            if (R < G && G < B) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 4040
def examB():
    H, W = LI()
    C = [LS() for _ in range(H)]
    ans = []
    for i in range(2*H):
        ans.append(C[(i)//2])
    for v in ans:
        print(" ".join(map(str,v)))


import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 3064
module WeightedDirectedGraph
  (Weight : sig
    type t
    val inf : t (* オーバーフローの恐れはないので，max_intとか突っ込んでも良い *)
    val zero : t
    val neg_inf : t (* オーバーフローの恐れはないので，min_intとか突っ込んでも良い *)
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end) :
sig
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  val bellman_ford :
    (* 頂点数n *)
    int ->
    (* 辺のリスト
       頂点は0からn-1までの整数でなくてはならない
       2n回呼び出されるので，リストを作るのに時間がかかるならメモ化すること *)
    (int * int * Weight.t) church_list ->
    (* 始点 *)
    int ->
    (* 頂点を受け取り，そこまでの距離を返す関数
       頂点に到達するパスが無ければinfを返し，
       そこに到達するまでに負閉路があればneg_infを返す *)
    (int -> Weight.t)
end =
struct
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  let bellman_ford n es s =
    (* 距離を覚えるやつ *)
    let d = Array.make n Weight.inf in
    (* 経路に負閉路が含まれる頂点を覚えるやつ *)
    let neg = Array.make n false in
    d.(s) <- Weight.zero;
    (* n回目以降の反復 手動ループアンローリング *)
    let rec loop' n =
      if
        0 < n &&
        es.fold (fun (u, v, c) b -> (* bは更新の有無 *)
          let open Weight in
          if neg.(u) then neg.(v) <- true;
          (* 原点から到達できない頂点は更新しない *)
          0 < Weight.compare inf d.(u)
          (* c は u から v への辺の重さ
             d.(u) + c < d.(v) *)
          && 0 < Weight.compare d.(v) (d.(u) + c)
          (* n 回目以降に変更が起こった場合，v までの経路に負閉路が含まれている *)
          && (d.(v) <- d.(u) + c; neg.(v) <- true; true) || b) false
      then loop' (n - 1) in
    (* n-1回目までの反復 *)
    let rec loop = function
      | 0 -> loop' n
      | n ->
          if
            es.fold (fun (u, v, c) b ->
              let open Weight in
              (* 原点から到達できない頂点は更新しない *)
              0 < Weight.compare inf d.(u)
              && 0 < Weight.compare d.(v) (d.(u) + c)
              && (d.(v) <- d.(u) + c; true) || b) false
          then loop (n - 1) in
    loop (n - 1);
    fun v -> if neg.(v) then Weight.neg_inf else d.(v)
end


module G = WeightedDirectedGraph (struct
  type t = int
  let zero = 0
  let inf = min_int
  let neg_inf = max_int
  let ( + ) = ( + )
  let compare x y = compare y x
end)

let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let abcs = Array.init m @@ fun _ -> Scanf.scanf "%d %d %d\n" @@ fun a b c -> a - 1, b - 1, c in
  let d = G.bellman_ford n { G.fold = fun f -> Array.fold_right f abcs } 0 (n - 1) in
  if max_int <= d
  then print_endline "inf"
  else Printf.printf "%d\n" d


Measured memory_bytes: 3968
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

template<typename T> void cinpb(vector<T>& x) { T n; cin >> n; x.push_back(n); }
ull gcd(ull a, ull b) { return b ? gcd(b, a%b) : a; }
ull lcm(ull m, ull n) {	return ((0 == m) || (0 == n)) ? 0 : ((m / gcd(m, n)) * n); }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

void yesno(bool f) { cout << (f ? "Yes" : "No") << endl; }

//

int main()
{
	int a, b;
	cin >> a >> b;

	if ( b % a == 0 )
	{
		cout << a + b << endl;
	}
	else
	{
		cout << b - a << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int A,B;
  cin>>A>>B;
  cout<<max({A+B, A-B, A*B})<<endl;

  return 0;
}


Measured memory_bytes: 256
/* ex9_2
    sak_Citrus  */

#include <stdio.h>
#include <stdlib.h>

//スタックの構造体
typedef struct node{
    char elem;
    struct node *next;
} node;

//リストの後ろ側に追加
void push(node **first,char elem){
    node *new = (node*)malloc(sizeof(node));
    if(new == NULL)exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//末端から取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    free(tmp);
    return elem;
}

int main(void){
    char elem;
    int count = 0;
    node *first = NULL;
    while(1){
        elem = fgetc(stdin);
        if(elem == '\n' || elem == EOF)break;
        //スタックの先頭と照合し、消せるならpop、消せなければpush
        if(first != NULL && first->elem != elem){
            pop(&first);
            count++;
        }else{
            push(&first,elem);
        }
    }
    
    printf("%d\n",count*2);

    return 0;
}

Measured memory_bytes: 4656
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a,a+n);
    int ans=a[0];
    for(int i=1;i<n-1;i++)if(abs((double)ans-(double)(a[n-1]*1.0/2))>abs((double)a[i]-(double)(a[n-1]*1.0/2)))ans=a[i];
    cout << a[n-1] << " " << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main()
{
	int r,g,b;
	int total;
	scanf("%d %d %d", &r,&g,&b);

	total = r * 100 + g * 10 + b;

	if (total % 4 == 0)
	{
		printf("YES");
	}
	else
	{
		printf("NO");
	}

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;
constexpr ll MOD = 1000000007;

#define rep(i, N) for(ll i=0; i<(N); ++i)

ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

template<typename T> inline string toString(const T &a) {
  ostringstream oss; oss << a; return oss.str();
}

ll gcd(ll x, ll y) { return x % y ? gcd(y, x % y) : y; }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << ((B - A + 1) - (B / C - A / C + (A % C == 0)) - (B / D - A / D + (A % D == 0)) + (B / lcm(C, D) - A / lcm(C, D) + (A % lcm(C, D) == 0))) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector<ll>
#define pb push_back
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define pii pair<ll,ll>
#define vii vector<pii>
#define MOD 1000000007LL
#define calc_fact(n) tgamma(n+1)
#define INF LONG_LONG_MAX

signed main()
{
    FIO;
    ll n;
    cin>>n;
    cout<<(n*(n+1))/2;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
#define llx(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;
int n,m,i,j,pre[300005],suf[300005],ans=1<<30;
string st;
int main()
{
	ios_base::sync_with_stdio(0);
	cin>>n>>st;
	st=" "+st;
	for (i=1;i<=n;i++)
	{
		pre[i]=pre[i-1]+(st[i]=='W');
	}
	for (i=n;i;i--)
	{
		suf[i]=suf[i+1]+(st[i]=='E');
	}
	for (i=1;i<=n;i++) ans=min(ans,pre[i-1]+suf[i+1]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 = 100000000;

int main(){
    int x , y, z;
    cin >> x >> y >> z;

    int tmp = (x - z) / (y + z);
    cout << tmp << endl;
}

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

using namespace std;
int ar[1000500];
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{


    int x;
    cin>>x;
    ar[x]++;
    ar[x+1]++;
    ar[x-1]++;








}
cout<<ar[max_element(ar,ar+1000506)-ar];















    return 0;
}


Measured memory_bytes: 640
K = gets.to_i
A, B = gets.split(" ").map(&:to_i)
count = 0

for i in (A..B) do
    if i % K == 0
        puts "OK"
        break
    else
        count += 1
    end
end

if count == B - A + 1
    puts "NG"
end


Measured memory_bytes: 14304
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#include <bitset>
#include <fstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

#define INF 1000000007ll
#define pb push_back
#define mp make_pair
#define err(x) cout<<#x<<"= "<<x<<endl;
#define rep(i,n) for(int i =0; i< n; i++)
#define ff first
#define ss second
#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define SIZE 300010
#define eps 1e-13

int main(){
//	#ifdef ONLINE_JUDGE
//	freopen("little.in", "r" , stdin);
//	freopen("little.out", "w", stdout);
// cin.tie(false); cout.tie(false);	
//	#endif
	ios::sync_with_stdio(false);
	int n,dir[SIZE],sum = 0;char S[SIZE];
	cin>>n;
	cin>>S;
	rep(i,n){
		if(S[i] == 'W') dir[i] = 0;
		else dir[i] = 1;
		sum+=dir[i];
	}
	int ans = INF,sum2=0;
	rep(now,n){
		if(now)sum2+= max(0,1-dir[now-1]);
		sum -= dir[now];
		ans = min(ans, sum+sum2);
	}
	cout<<ans<<endl;

	return 0;
};


Measured memory_bytes: 1792
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

int main() {
	int N;
	long int ans = 0;

	cin >> N;

	vector <int> A(N + 1);
	vector <int> B(N);

	for (int i = 0; i < N + 1; i++) {
		cin >> A.at(i);
	}

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

	for (int i = N - 1; i >= 0; i--) {
		if (B.at(i) >= A.at(i + 1)) {
			ans += A.at(i + 1);
			B.at(i) -= A.at(i + 1);
			A.at(i + 1) = 0;
		}
		else {
			ans += B.at(i);
			A.at(i + 1) -= B.at(i);
			B.at(i) = 0;
		}

		if (B.at(i) != 0 && B.at(i) >= A.at(i)) {
			ans += A.at(i);
			B.at(i) -= A.at(i);
			A.at(i) = 0;
		}
		else {
			ans += B.at(i);
			A.at(i) -= B.at(i);
			B.at(i) = 0;
		}
	}
	cout << ans << endl;

	return 0;
}


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

#define ll long long int
#define ull unsigned long long int
#define po2(z) 1<<(ll)z
#define fr(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define rf(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define TC ll test;cin>>test;while(test--)
#define tej ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod (ll)1000000007
#define MAX 100005


ll t[3001][3001];
int main(){

string s1,s2;
cin>>s1>>s2;
ll n=s1.length(),m=s2.length();

for(ll i=0;i<n+1;i++){
	for(ll j=0;j<m+1;j++){
		if(i==0||j==0){
			t[i][j]=0;
		}else if(s1[i-1]==s2[j-1]){
			t[i][j]=1+t[i-1][j-1];
		}else{
			t[i][j]=max(t[i][j-1],t[i-1][j]);
		}
	}
}
ll index=t[n][m];
char lcs[index];
//cout<<index<<endl;a
lcs[index]='\0';
if(t[n][m]==0){
	cout<<' ';
}else{
ll i=n,j=m;
while(i>0&&j>0){
	if(s1[i-1]==s2[j-1]){
		lcs[index-1]=s1[i-1];
		i--;
		j--;
		index--;
	}
	else if(t[i-1][j]>t[i][j-1]){
		i--;
	}else{
		j--;
	}
}

cout<<lcs;
}


}


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

typedef struct cmd {
    string s;
    int time;
} cmd;

queue<cmd> Q;

int main() {
    int n, q, t;
    cmd tmp;
    cin >> n >> q;
    for (int i = 0; i < n; i++) {
        cin >> tmp.s >> tmp.time;
        Q.push(tmp);
    }

    int a, elaps = 0;
    while(!Q.empty()) {
        tmp = Q.front();
        Q.pop();
        a = min(tmp.time, q);
        tmp.time -= a;
        elaps += a;
        if (tmp.time > 0) {
            Q.push(tmp);
        } else {
            cout << tmp.s << " " << elaps << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6344
object Main {
  def main(args: Array[String]): Unit = {
    var input_num = io.StdIn.readLong()

    if(input_num%2 == 1) println(0)
    else {
      input_num = input_num
      var total_five = 0l
      while(input_num >= 10) {
        total_five += input_num/5l/2
        input_num = input_num/5l
      }
      println(total_five)
    }
  }
}

Measured memory_bytes: 25508
#include <cstdio>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int n, k; scanf("%d %d", &n, &k);
	vector<int> h(n), dp(n, 2000000000); dp[0] = 0;
	for (int i = 0; i < n; ++i) scanf("%d", &h[i]);
	for (int i = 1; i < n; ++i) for (int p = max(0, i - k); p < i; ++p) 
		dp[i] = min(dp[i], dp[p] + (int)abs(h[p] - h[i]));
	printf("%d\n", dp[n-1]);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int N,S,K;
const int INF=1e9;
int main()
{
	cin>>N>>K>>S;
	if (S==INF)
	{
		for (int i=1;i<=K;++i) printf("%d ",S);
		for (int i=K+1;i<=N;++i) printf("%d ",1);
		cout<<endl;
	}
	else
	{
		for (int i=1;i<=K;++i) printf("%d ",S);
		for (int i=K+1;i<=N;++i) printf("%d ",S+1);
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1280
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	countFrom0 := 0
	countFrom1 := 0

	for i, c := range s {
		if i%2 == 0 {
			if c == '0' {
				countFrom1++
			}
			if c == '1' {
				countFrom0++
			}
		} else {
			if c == '1' {
				countFrom1++
			}
			if c == '0' {
				countFrom0++
			}
		}
	}

	fmt.Println(min(countFrom0, countFrom1))

}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 1280
import sys
input = sys.stdin.readline
from collections import Counter


def read():
    N = list(input().strip())
    return N,


def solve(N):
    s = sum(map(int, N))
    return "Yes" if s % 9 == 0 else "No"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 10788
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct Rect
{
	int h;
	int w;
	int d;

	Rect() {}
	Rect(int _h, int _w, int _d) : h(_h), w(_w), d(_d) {}

	bool operator<(const Rect& rhs) const {
		if(this->d == rhs.d) { return this->h < rhs.h; }
		return this->d < rhs.d;
	}
};

int main()
{
	vector<Rect> recs;

	for (int i = 1; i <= 150; ++i) {
		for (int j = i + 1; j <= 150; ++j) {
			int d = i * i + j * j;
			recs.emplace_back(i, j, d);
		}
	}

	while (1) {
		int h, w;
		cin >> h >> w;

		if (h == 0 && w == 0) { break; }

		sort(recs.begin(), recs.end());

		auto it = upper_bound(recs.begin(), recs.end(), Rect(h, w, h * h + w * w));
		cout << it->h << " " << it->w << endl;

	}
	return 0;
}

Measured memory_bytes: 3200
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    string s;
    cin>>s;
    int n=s.size();
    rep(i,n){
        cout<<'x';
    }
    cout<<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define INF 1000000000
#define MAX_V 2503
//ダイクストラ法
//計算量O(|V|^2)
int cost[MAX_V][MAX_V];
int d[MAX_V];
bool used[MAX_V];
int V;

void dijkstra(int s){
    fill(d, d + V, INF);
    fill(used, used + V, false);
    d[s] = 0;

    while(true){
        int v = -1;
        for(int u = 0; u < V; u++){
            if(!used[u] && (v == -1 || d[u] < d[v])) v = u;
        }
        if(v == -1) break;
        used[v] = true;

        for(int u = 0; u < V; u++){
            d[u] = min(d[u], d[v] + cost[v][u]);
        }
    }
}

int main(void){
    ll h, w;
    cin >> h >> w;


    char s[h][w];
    ll kuro_num = 0;

    rep(i, 0, h){
        rep(j, 0, w){
            cin >> s[i][j];
            if(s[i][j] == '#'){
                kuro_num++;
            }
        }
    }

    rep(i, 0, h * w){
        rep(j, 0, h * w){
            if(i == j) cost[i][j] = 0;
            else cost[i][j] = INF;
        }
    }

    rep(i, 0, h){
        rep(j, 0, w){
            if(s[i][j] == '.'){
                if(i > 0 && s[i-1][j] == '.'){
                    cost[i * w + j][(i-1) * w + j] = 1;
                }
                if(i < h-1 && s[i+1][j] == '.'){
                    cost[i * w + j][(i+1) * w + j] = 1;
                }
                if(j > 0 && s[i][j-1] == '.'){
                    cost[i * w + j][i * w + j - 1] = 1;
                }
                if(j < w-1 && s[i][j+1] == '.'){
                    cost[i * w + j][i * w + j + 1] = 1;
                }
            }
        }
    }


    V = h * w;
    dijkstra(0);
    if(d[V-1] >= 1000000000){
        cout << -1 << endl;
    }else{
        cout << V - (d[V-1] + 1) - kuro_num << endl;
    }
    return 0;
}


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

int main(void){
    int cnt, ans;
    string S, T;
    cnt = 0;
    cin >> S;
    cin >> T;
    ans = T.length();
    
    for (int i = 0; i < (int)(S.length() - T.length() + 1); i++){
        cnt = 0;
        for (int j = 0; j < (int)(T.length()); j++){
            if (S[i + j] != T[j]) cnt++;
        }
        
        ans = min(cnt, ans);
    }
    
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

bool B[1100][1100];
int main(){
    int H, W;
    cin >> H >> W;

    queue<tuple<int, int, int> > qu;
    REP(i,H){
        REP(j,W){
            char c;
            cin >> c;
            B[i][j] = c=='#';
            if(c == '#'){
                qu.push(make_tuple(i, j, 0));
            }
        }
    }

    int ans = 0;
    while(!qu.empty()){
        auto t = qu.front();
        qu.pop();

        int y = get<0>(t);
        int x = get<1>(t);
        int idx = get<2>(t);

        chmax(ans, idx);

        if(x-1 >= 0 && !B[y][x-1]){
            B[y][x-1] = true;
            qu.push(make_tuple(y, x-1, idx+1));
        }
        if(y-1 >= 0 && !B[y-1][x]){
            B[y-1][x] = true;
            qu.push(make_tuple(y-1, x, idx+1));
        }
        if(x+1 < W && !B[y][x+1]){
            B[y][x+1] = true;
            qu.push(make_tuple(y, x+1, idx+1));
        }
        if(y+1 < H && !B[y+1][x]){
            B[y+1][x] = true;
            qu.push(make_tuple(y+1, x, idx+1));
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13456
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize
    }

    let mut ans = 0;
    for i in 1..=n {
        for j in (i..=n).step_by(i) {
            ans += j;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2204
import numpy as np
import copy
from itertools import product


H, W, K = map(int, input().split())
B = np.array([list(input().rstrip()) for _ in range(H)], str)
ans = 0

for h, w in product(range(2 ** H), range(2 ** W)):
    C = copy.deepcopy(B)
    for i in range(H):
        b = h >> i & 1
        if b:
            C[i, :] = '.'

    for i in range(W):
        b = w >> i & 1
        if b:
            C[:, i] = '.'

    ans += np.sum(C == '#') == K

print(ans)

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



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	const int mx = 100, up = 10;
	vector<vector<int>> cnt(mx, vector<int>(mx));
	long long res = 0;
	for(auto rep = 0; rep < n; ++ rep){
		string s;
		cin >> s;
		auto it = find(s.begin(), s.end(), '.');
		array<int, 2> a{};
		if(it != s.end()){
			a = {it - s.end() + 1, it - s.end() + 1};
			s.erase(it);
		}
		long long x = stoll(s);
		while(x % 2 == 0){
			x /= 2;
			++ a[0];
		}
		while(x % 5 == 0){
			x /= 5;
			++ a[1];
		}
		for(auto i = max(0, up - a[0]); i < mx; ++ i){
			for(auto j = max(0, up - a[1]); j < mx; ++ j){
				res += cnt[i][j];
			}
		}
		++ cnt[a[0] + up][a[1] + up];
	}
	cout << res << "\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<int> vi;
#define pb push_back
#define en "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,s,e) for(ll i=e; i>=s; i--)
#define asort(arr,n) sort(arr,arr+n)
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(),greater<int>())
#define ff first
#define ss second
#define aout(a) for (auto u:a) {cout<<u<<" ";}cout<<en;

 
#define out(x1) cout << x1 << en
#define out2(x1,x2) cout << x1 << " " << x2 << en
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << en

 
#define in(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
 
#define arrin(a,n) forn(i,n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << en;
 

int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("oput.txt", "w", stdout);
#endif

ios_base::sync_with_stdio(false);
    cin.tie(NULL);


ll n,k;
in2(n,k);
ll arr[n];
arrin(arr,n);
ll possible[k];
for (ll i = 0; i < k; i++)
{possible[i]=i+1;
	
}
ll dp[n];

dp[0]=0;
dp[1]=abs(arr[1]-arr[0]);
for (ll i = 2; i < n; i++)
{
ll mina=INT_MAX;
for (ll j = 1; j <=k ; j++)
{if (i-j>=0){
mina=min(mina,dp[i-j]+abs(arr[i-j]-arr[i]));

}
}
dp[i]=mina;
}
// arrout(dp,n);
out(dp[n-1]);





    return 0;
}


Measured memory_bytes: 5116
package main

import (
	"fmt"
	"math"
	"strconv"
	"strings"
)

func makeAns(n int, A []int) map[int]struct{} {
	p := int(math.Pow(float64(2), float64(n)))

	ret := make(map[int]struct{}, p)

	f := "%0" + fmt.Sprintf("%db", n)
	for i := 0; i < p; i++ {
		a := 0
		str := fmt.Sprintf(f, i)
		for j, b := range strings.Split(str, "") {
			num, err := strconv.Atoi(b)
			if err != nil {
				panic(err)
			}
			if num != 0 {
				a += A[j]
			}
		}
		if a != 0 {
			ret[a] = struct{}{}
		}
	}
	return ret
}

func main() {
	var n int
	fmt.Scanf("%d", &n)

	A := make([]int, n)
	for i := range A {
		fmt.Scanf("%d", &A[i])
	}

	ans := makeAns(n, A)

	var q int
	fmt.Scanf("%d", &q)

	for i := 0; i < q; i++ {
		var m int
		fmt.Scanf("%d", &m)

		if _, ok := ans[m]; ok {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}


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

a=int(input())#500
b=int(input())#100
c=int(input())#50
x=int(input())

ans=0
for i in range(a+1):
	for j in range(b+1):
		for k in range(c+1):
			if i*500+100*j+50*k==x:
				ans+=1

print(ans)


Measured memory_bytes: 2940
n = int(input())
a = [[0,0] for i in range(n)]
for i in range(n):
    a[i][1],a[i][0] = map(int,input().split())
a.sort()

end = 0
for p,q in a:
    end += q
    if end > p:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 69108
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rrep(i,n) for(long long i=(n);i>=0;--i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// ========== debug ==========
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif
// ===========================

int main() {
  int D;
  ins(D);

  vi c(26), last(26, 0);
  vector<vi> s(D, vi(26));
  rep(i, 26) cin >> c[i];

  rep(i, D) {
    rep(j, 26)
      cin >> s[i][j];
  }

  ll ans = 0;
  rep(d, D) {
    int in(t);
    --t;
    ans += s[d][t];
    last[t] = d + 1;
    rep(i, 26) {
      ans -= c[i] * (d + 1 - last[i]);
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3676
import java.util.Scanner;

public class Main {

    private static final String format = "%d %d";

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        System.out.println(String.format(format, (a * b), (2 * (a + b))));
    }
}

Measured memory_bytes: 26320
def Fib(n):
    a=[0,1,1]
    if n<=2:
    	return a[n]
    else:
    	for i in range(n-2):
    		a.append(a[i+1]+a[i+2])
    	return a[n]
n,m=map(int,input().split())
if m==0:
	print(Fib(n+1)%(10**9+7))
	exit()
a=[]
for i in range(m):
	a.append(int(input()))
if a[0]!=1:
	a.insert(0,-1)
if a[-1]!=n-1:
	a.append(n+1)
b=[]
for i in range(len(a)-1):
	b.append(a[i+1]-a[i]-1)
	if a[i+1]-a[i]==1:
		print(0)
		exit()
ans=1
for i in range(len(b)):
	ans*=Fib(b[i])
	ans%=10**9+7
print(ans)

Measured memory_bytes: 460020
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	a1 := make([]int, n)
	a2 := make([]int, n)
	for i := range a1 {
		fmt.Scan(&a1[i])
	}
	for i := range a2 {
		fmt.Scan(&a2[i])
	}

	var max int
	for i := 0; i < n; i++ {
		sum := 0
		for j := 0; j <= i; j++ {
			sum += a1[j]
		}
		for j := i; j < n; j++ {
			sum += a2[j]
		}
		if sum > max {
			max = sum
		}
	}

	fmt.Println(max)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,m,a[55],b[55];
bool li[55][55]={};

int main(){
	cin >> n >> m;
	REP(i,0,m) cin >> a[i] >> b[i],a[i]--,b[i]--,li[a[i]][b[i]]=li[b[i]][a[i]]=true;
	
	int c=0;
	REP(i,0,m){
		queue<int> qu;
		set<int> st;
		li[a[i]][b[i]]=false;
		qu.push(a[i]);
		
		while(!qu.empty()){
			auto p=qu.front(); qu.pop();
			if(st.count(p)) continue; st.insert(p);
			
			REP(i,0,n) if(li[p][i]) qu.push(i);		
		}
		
		li[a[i]][b[i]]=true;
		if(st.size()<n) c++;
	}
	
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VII vector< vector<int> >
#define VLL vector< vector<LL> >
#define VS vector<string>
#define PII pair<int,int>
#define PIS pair<int,string>
#define PSI pair<string,int>
#define PLL pair<ll,ll>
LL facctorialMethod(int k);
int main(){
    LL n;
    string s,t,ans;
    cin >> n;
    cin >> s >> t;
    for(int i = 0; i < n; i++) {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;

    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


Measured memory_bytes: 3584
ABCD = input()
A = ABCD[0]
B = ABCD[1]
C = ABCD[2]
D = ABCD[3]

for i in range(2):
    for j in range(2):
        for k in range(2):
            if i == 0:
                op1 = "+"
            else:
                op1 = "-"
            if j == 0:
                op2 = "+"
            else:
                op2 = "-"
            if k == 0:
                op3 = "+"
            else:
                op3 = "-"
            if eval(A+op1+B+op2+C+op3+D) == 7:
                print((A+op1+B+op2+C+op3+D)+"="+"7")
                exit()

Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c;
    int s;
    while(scanf("%d%d%d",&a,&b,&c)!=EOF)
    {
        int min1=min(min(a,b),c);
        int max1=max(max(a,b),c);
        s=((min1)*(a+b+c-max1-min1))/2;
        printf("%d\n",s);
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
const int MOD=1000000007;
int N,M;
vector<bool> issafe;
int main(){
  cin>>N>>M;
  issafe.assign(N+1,true);
  for(int i=0; i<M; ++i){
    int a; cin>>a;
    issafe[a]=false;
  }
  vector<int> dp(N+1,0);
  
  dp[0]=1;
  if(issafe[1]) dp[1]=1;
  
  for (int n=2; n<=N; n++){
    if (issafe[n-1]) dp[n]+=dp[n-1];
    if (issafe[n-2]) dp[n]+=dp[n-2];
      dp[n]%=MOD;
  }
  cout<<dp[N]<<endl;
}
    
  

Measured memory_bytes: 640
from collections import Counter


def solve(V):
    n = len(V)
    ac = Counter(V[::2]).most_common(2)
    bc = Counter(V[1::2]).most_common(2)

    if ac[0][0] != bc[0][0]:
        return n - ac[0][1] - bc[0][1]
    else:
        if len(bc) == 1 or len(ac) == 1:
            return n // 2
        else:
            return n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])


if __name__ == "__main__":
    n = int(input())
    l = input()
    print(solve(l.split(" ")))

Measured memory_bytes: 16808