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

using namespace std;

struct Node{
  int key;
  Node *parent,*left,*right;
};
Node *root,*NIL;

Node* find(int k){
  Node* x=root;
  while(x!=NIL&&k!=x->key){
    if(k<x->key) x=x->left;
    else x=x->right;
  }
  return x;
}

Node* getMinimum(Node* x){
  while(x->left!=NIL) x=x->left;
  return x;
}

Node* getSuccessor(Node* x){
  if(x->right!=NIL) return getMinimum(x->right);
  else{
    Node* y=x->parent;
    while(y!=NIL&&x==y->right){
      x=y;
      y=y->parent;
    }
    return y;
  }
}

void deleteNode(Node* z){
  Node *y,*x;
  if(z->left==NIL||z->right==NIL){
    y=z;
  }else{
    y=getSuccessor(z);
  }
  if(y->left!=NIL){
    x=y->left;
  }else{
    x=y->right;
  }
  if(x!=NIL){
    x->parent=y->parent;
  }
  if(y->parent==NIL){
    root=x;
  }else if(y==(y->parent)->left){
    (y->parent)->left=x;
  }else{
    (y->parent)->right=x;
  }
  if(y!=z) z->key=y->key;
}

void insert(int k){
  Node* y=NIL;
  Node* x=root;
  Node* z;
  z=(Node*)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL) root=z;
  else{
    if(y==NIL){
      root=z;
    }else{
      if(z->key<y->key) y->left=z;
      else y->right=z;
    }
  }
}

void inorder(Node* u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node* u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    string com;
    cin >> com;
    if(com=="print"){
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
    else if(com=="insert"){
      int z;
      cin >> z;
      insert(z);
    }
    else if(com=="find"){
      int z;
      cin >> z;
      Node* t=find(z);
      if(t==NIL) cout << "no\n";
      else cout << "yes\n";
    }
    else if(com=="delete"){
      int z;
      cin >> z;
      Node* t=find(z);
      deleteNode(t);
    }
  }
}

Measured memory_bytes: 22012
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        PatisserieABC solver = new PatisserieABC();
        solver.solve(1, in, out);
        out.close();
    }

    static class PatisserieABC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            long[] x = new long[n];
            long[] y = new long[n];
            long[] z = new long[n];

            for (int i = 0; i < n; i++) {
                x[i] = Long.parseLong(in.next());
                y[i] = Long.parseLong(in.next());
                z[i] = Long.parseLong(in.next());
            }

            long result = 0;
            for (int i = 0; i < (1 << 3); i++) {
                List<Tuple> scores = new ArrayList<>();
                long tx = 0;
                long ty = 0;
                long tz = 0;
                for (int j = 0; j < n; j++) {
                    if ((i & 1) == 1) {
                        // x
                        tx = -x[j];
                    }
                    if ((i & 1) == 0) {
                        // x
                        tx = x[j];
                    }
                    if ((i >> 1 & 1) == 1) {
                        // y
                        ty = -y[j];
                    }
                    if ((i >> 1 & 1) == 0) {
                        // y
                        ty = y[j];
                    }
                    if ((i >> 2 & 1) == 1) {
                        tz = -z[j];
                    }
                    if ((i >> 2 & 1) == 0) {
                        tz = z[j];
                    }
                    scores.add(new Tuple(tx, ty, tz, (tx + ty + tz)));
                }
                Collections.sort(scores, Collections.reverseOrder());

                long score = 0;
                for (int k = 0; k < m; k++) {
                    score += scores.get(k).score;
                }
                result = Math.max(result, score);
            }
            out.println(result);

        }

        class Tuple implements Comparable<Tuple> {
            long x;
            long y;
            long z;
            long score;

            public Tuple(long x, long y, long z, long score) {
                this.x = x;
                this.y = y;
                this.z = z;
                this.score = score;
            }

            public int compareTo(Tuple o) {
                return Long.compare(this.score, o.score);
            }

        }

    }
}



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

typedef long long ll;

int main() {
    string S;
    cin >> S;
    ll ans = 0, n = S.size();
    rep(i, 1 << (n - 1)) {
        //cout << i << " ";
        ll sum = 0, t = S[0] - '0';
        rep(j, n - 1) {
            if (i >> j & 1) {
                t = t * 10 + S[j + 1] - '0';
            } else {
                sum += t;
                t = S[j + 1] - '0';
            }
        }
        sum += t;
        //cout << i << " " << sum << endl;
        ans += sum;
    }
    cout << ans << endl;
}

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

int main()
{
	long long int X;
	cin>>X;
	
	long long int A=0,B=0;
	
	
	if(X==1)
	{
		cout<<1<<" "<<0<<endl;
	}
	else
	{ int f=0;
		for(int i=1000;i>=-1000;--i)
		{
			for(int j=999;j>=-1000;--j)
			{
			   A=pow(i,5);
			   B=pow(j,5);
			  
			   if((A-B)==X||(A+B==X))
			   { f=1;
			   if(A-B==X)
			   {
			   	A=i;
			   	B=j;
			   }
			   else
			   {
			   	A=i;
			   	B=-j;
			   }
			   	break;
			   }
			}
			if(f==1)
			{
				break;
			}
		}
		
		cout<<A<<" "<<B<<endl;
		}
}

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

using namespace std;

string solve(int A, int B, int C)
{
    return A + B >= C ? "Yes" : "No";
}

int main()
{
    ios::sync_with_stdio(false);

    int A, B, C;
    cin >> A >> B >> C;

    auto ans = solve(A, B, C);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

const int mod = 1e9 + 7;
const int MXN = 110;
const int MXK = 1e5 + 5;
int n, k;
int a[MXN];
int dp[MXK];

void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
} 

void sub_self(int& a, int b) {
    a -= b;
    if(a < 0) {
        a += mod;
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> k;
    dp[0] = 1;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        vector<int> fake(k + 1);    
        for(int j = k; j >= 0; j--) {
            int tmp = dp[j];
            int l = j + 1, r = j + min(a[i], k - j);
            if(l <= r) {
                add_self(fake[l], tmp);
                if(r + 1 <= k) {
                    sub_self(fake[r + 1], tmp);
                }
            }
        }
        int ps = 0;
        for(int j = 0; j <= k; j++) {
            add_self(ps, fake[j]);
            add_self(dp[j], ps);
        }
    }
    cout << dp[k] << endl;
    return 0;
}

Measured memory_bytes: 4432
N, M = map(int, input().split())
X = [[] for _ in range(N)]
ans_list = ["a" for i in range(M)]
for i in range(M):
    p, y = map(int, input().split())
    X[p - 1].append((i, y))
for i in range(N):
    if len(X[i]) != 0:
        X[i].sort(key=lambda x: x[1])
        for j in range(len(X[i])):
            ans_list[X[i][j][0]] = "{:06}".format(
                i + 1) + "{:06}".format(j + 1)

for i in range(len(ans_list)):
    print(ans_list[i])


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

int main(){
    int n;cin >> n;
    int max = 0;
    long long ans = 0;
    for(int i=0; i<n; i++){
        int tmp; cin >> tmp;
        if(max < tmp) {
            max = tmp;
        } else {
            ans += max-tmp;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
int t=0;
vector<int> d,f;
vector<bool> used;
void dfs(int now,vector<vector<int>> &gr){
  if(used[now]) return;
  used[now] = true;
  t++;
  d[now] = t;
  REP(i,gr[now].size()){
    dfs(gr[now][i],gr);
  }
  t++;
  f[now] = t;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  d.resize(n);
  f.resize(n);
  used.assign(n,false);
  vector<vector<int>> gr(n);
  REP(i,n){
    int k;
    cin >> k >> k;
    REP(j,k){
      int v;
      cin >> v;
      gr[i].push_back(v-1);
    }
  }
  REP(i,n){
    dfs(i,gr);
  }
  REP(i,n){
    cout << i+1 << " " << d[i] << " " << f[i] << endl;
  }
}



Measured memory_bytes: 3164
n = int(input())
h = [int(i) for i in input().split()]

f_inf = float('inf')

dp = [f_inf] * (10**5+10)

dp[0] = 0

def rec():
    for i in range(1, n):
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i-1]))
        if i > 1:
            dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i-2]))


rec()
print(dp[n-1])


Measured memory_bytes: 13980
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

int a,b,c;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	printf("%d\n",max(c-(a-b),0));
	return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N, 0);
    for (int i = 0;i < N; i++) {
        cin >> A.at(i);
    }
    vector<int> ball(N+1, 0);
    int kind = 0;
    for (int i = 0; i < N; i++) {
        ball.at(A.at(i))++;
    }
    for (int i = 0; i < N+1; i++) {
        if (ball.at(i)) {
            kind++;
        }
    }
    sort(ball.begin(), ball.end());
    int ans = 0, now = 0;
    while (kind - K > 0) {
        if (ball.at(now)) {
            ans += ball.at(now);
            kind--;
        }
        now++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
var lines = [];

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
})

rl.on('line', function (x) {
    lines.push(x);
});

rl.on("close", function () {
    var a = Number(lines[0].split(" ")[0]);
    var b = Number(lines[0].split(" ")[1]);

    var ba = b - a;
    var h = Array(999).fill(0);

    for (var i = 1; i <= 999; i++) {
        h[i] = h[i - 1] + i;
        if (ba === i) { console.log(h[i] - b); return (0) }
    }

});

Measured memory_bytes: 7628
n=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
p1=0
p2=0
for i in range(n):
    a=A[i]
    b=B[i]
    if(a%2!=b%2):
        p1+=1
        b+=1
    if(a>b):
        p1+=a-b
    elif(a<b):
        p2+=(b-a)//2
if(p2>=p1):
    print("Yes")        
else:
    print("No")

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

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)


using namespace std;

void swap(int *a,int *b){
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

void babbleSort(int *a,int *b,int num){

	for(int i=0;i<num;i++){
		for(int j=num-1;j>i;j--){
			if(a[j]<=a[j-1]){
				swap(&a[j],&a[j-1]);
				swap(&b[j],&b[j-1]);
			}
		}
	}

}

int main(){

	int n;

	cin>>n;


	int *flag;
	flag = new int[n];
	vector<pair<int,int>> a(n);
	vector<pair<int,int>> b(n);
	int tmpX,tmpY;
	REP(i,n){
		cin>>tmpX>>tmpY;
		a[i] = make_pair(tmpX,tmpY);
	}
	REP(i,n){
		cin>>tmpX>>tmpY;
		b[i] = make_pair(tmpX,tmpY);
	}
	REP(i,n)flag[i]=0;

	sort(a.begin(),a.end());
	sort(b.begin(),b.end());

	lli ans=0;

	REP(i,n){
		int maxY=-10000;
		int point=-1;
		REP(j,n){
			if( (a[j].first<b[i].first && (a[j].second<b[i].second))){
				if(flag[j]==0){
					if(maxY<a[j].second){
						maxY = a[j].second;
						point = j;
					}
				}
			}
		}
		if(point>=0){
			ans++;
			flag[point]=1;
		}
	}

	cout<<ans<<endl;


	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/numeric>
#define oo 0x3f3f3f3f
#define long long long

using namespace std;
//using namespace __gnu_cxx;

long calc(string str) {
    vector<long> v;
    for (int i = 0; i < (int)str.size(); ++i) {
        int j = i;
        while(j < (int)str.size() && str[j] != '+')
            ++j;
        v.push_back(stoll(str.substr(i, j - i)));
        i = j;
    }
    long ret = 0;
    for (auto x : v)
        ret += x;
    return ret;
}

long solve(int idx, string str) {
    if (idx == (int)str.size()) {
        return calc(str);
    }
    long ret = solve(idx + 1, str);
    str.insert(idx, "+");
    ret += solve(idx + 2, str);
    return ret;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    string str;
    cin >> str;
    cout << solve(1, str) << '\n';

    return 0;
}
	

Measured memory_bytes: 3656
n = int(input())
l = [input() for _ in range(n)]

a = ["AC", "WA", "TLE", "RE"]
b = []

for s in a:
    b.append(l.count(s))

d = ["AC x ", "WA x ", "TLE x ", "RE x "]

for i, di in enumerate(d):
    print("{}{}".format(d[i], b[i]))

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

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

    while(1)
    {
        C -= B;
        if(C<=0)
        {
            cout<<"Yes"<<endl;
            break;
        }

        A -= D;
        if(A<=0)
        {
            cout<<"No"<<endl;
            break;
        }
    }

    return 0;
}

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

// using ll = long long;
// #define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

const int MAX = 105;
int H,W;
bool g[MAX][MAX];
int dp[MAX][MAX];

signed main() {
  cin >> H >> W;
  REP(h, H) {
    REP(w, W) {
      char c;
      cin >> c;
      g[h][w] = (c == '.');
      dp[h][w] = INT_MAX;
    }
  }
  // g[h][w]: 白の時true
  if(g[0][0]) dp[0][0] = 0;
  else dp[0][0] = 1;
  REP(h, H) {
    REP(w, W) {
      if(h == 0 && w == 0) continue;
      if(h-1 >= 0) {
        // 上のマスと比較

        // 以下二つの条件のどちらかに当てはまるとき、そのマスの色を変える必要がない
        // すでにそのマスが白い
        // 上のマスが黒い（そのマスが黒だとしても上のマスと一緒に色を変える）
        if(g[h][w] || !g[h-1][w]) {
          dp[h][w] = min(dp[h][w], dp[h-1][w]);
        } else {
          dp[h][w] = min(dp[h][w], dp[h-1][w]+1);
        }
      }
      if(w-1 >= 0) {
        // 左のマスト比較

        // 以下二つの条件のどちらかに当てはまるとき、そのマスの色を変える必要がない
        // すでにそのマスが白い
        // 左のマスが黒い（そのマスが黒だとしても左のマスと一緒に色を変える）
        if(g[h][w] || !g[h][w-1]) {
          dp[h][w] = min(dp[h][w], dp[h][w-1]);
        } else {
          dp[h][w] = min(dp[h][w], dp[h][w-1]+1);
        }
      }
    }
  }

  cout << dp[H-1][W-1];
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 
  
  int h, w;
  cin >> h >> w;

  for (int i = 0; i < w + 2; ++i) cout << "#";
  cout << "\n";

  for (int i = 0; i < h; ++i) {
    cout << "#";
    for (int j = 0; j < w; ++j) {
      char c; cin >> c;
      cout << c;
    }
    cout << "#\n";
  }

  for (int i = 0; i < w + 2; ++i) cout << "#";
  cout << "\n";
}


Measured memory_bytes: 3608
n = int(input())
wl = []
for i in range(n):
    w = input()
    if i != 0:
        wp = wl[-1]
        if w[0] != wp[-1]:
            print("No")
            break
        if w in wl:
            print("No")
            break
    wl.append(w)
else:
    print("Yes")

Measured memory_bytes: 3060
fun main() {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    val dp = LongArray(8)
    dp[0] = 1

    s.forEach {
        when (it) {
            'R' -> {
                dp[7] += dp[3]
                dp[6] += dp[2]
                dp[5] += dp[1]
                dp[4] += dp[0]
            }
            'G' -> {
                dp[7] += dp[5]
                dp[6] += dp[4]
                dp[3] += dp[1]
                dp[2] += dp[0]
            }
            'B' -> {
                dp[7] += dp[6]
                dp[5] += dp[4]
                dp[3] += dp[2]
                dp[1] += dp[0]
            }
        }
    }

    val exclude = (0..n-3).sumBy { l ->
        (1..n).count { w ->
            val c = l + w
            val r = c + w
            r < n && s[l] != s[c] && s[c] != s[r] && s[r] != s[l]
        }
    }

    println(dp[7]-exclude)
}

Measured memory_bytes: 36612
use std::cmp::Ordering;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

struct Restaurant {
    i: i32,
    s: String,
    p: i32,
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let mut ts: Vec<Restaurant> = Vec::new();
    for i in 0..n {
        ts.push(Restaurant {
            i: i + 1,
            s: read(&mut stdin_lock, &mut buf, b' '),
            p: read(&mut stdin_lock, &mut buf, b'\n'),
        });
    }
    ts.sort_by(|a, b| match a.s.cmp(&b.s) {
        Ordering::Less => Ordering::Less,
        Ordering::Greater => Ordering::Greater,
        Ordering::Equal => b.p.cmp(&a.p),
    });
    for t in ts.iter() {
        println!("{}", t.i);
    }
}


Measured memory_bytes: 4352
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		int a1 = sc.nextInt();
		int a2 = sc.nextInt();
		int a3 = sc.nextInt();
		println(a1 + a2 + a3 >= 22 ? "bust" : "win");
	}
}


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

using namespace std;
#define l long long int 

int main()
{
  l n,x;
  cin>>n;
  vector<l> ar(n+1,0);
  for(l i=1;i<n;i++)
  {
    cin>>x;
    ar[x]++;
  }
  for(l i=1;i<=n;i++)
    cout<<ar[i]<<"\n";
  return 0;
}

Measured memory_bytes: 4840
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cstring>
#include <algorithm>
#include <vector>
//#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <map>
#include <numeric>
using namespace std;
#define fin << '\n'
#define finl << '\n';
#define finn cout << '\n'
#define unless(flg) if(!(flg))
#define alles(obj) obj.begin(), obj.end()
//bashise
#define elif else if
#define echo cout <<
#define read cin >>
//javaise
#define bash push_back
#define makePair make_pair
#define isEmpty empty
//germanise
#define drucken(obj) cout << obj << '\n'
#define lesen(obj) cin >> obj
#define fur for
#define wenn if
#define sonst else
#define Zahl int
// type-define
#define String string
#define Stack stack
#define Queue queue
#define pQueue priority_queue
#define Vector vector
#define Pair pair
#define Map map
typedef long long llong;
typedef bool boolean;
typedef Pair<int,int> Pii;
typedef Vector<int> Vi;
// utils
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
boolean isMovable(int x,int y,int w,int h){return (x>=0&&y>=0&&x<w&&y<h);};
const int INF = 1 << 29;

#define int llong

int x[100100];
int ans;

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

    int n, a, b;
    read n >> a >> b;
    for ( int i = 0; i < n; i++ ) {
        read x[i];
    }
    for ( int i = 1; i < n; i++ ) {
        ans += min(b, ( x[i] - x[i-1] ) * a);
    }

    echo ans fin;

    return 0;
}


Measured memory_bytes: 1024
W, a, b = map(int,input().split())
 
if (a+W)<=b:
  print(b-(a+W))
elif (a<= b)and (b<(a+W)):
  print(0)
elif ((a-W)<=b) and(b<a):
  print(0)
elif b<(a-W):
  print(a-(b+W))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint a(n), b(n), diff(n);
    rep(i, n) cin >> a[i];
    rep(i, n) {
        cin >> b[i];
        diff[i] = a[i] - b[i];
    }
    sort(all(diff));
    if (diff.front() >= 0) {
        puts("0");
        return 0;
    }

    int idx = diff.size()-1;
    int ans = 1;
    rep(i, diff.size()) {
        if (diff[i] >= 0) break;
        ans++;
        while(diff[i] < 0) {
            if(idx <= i || diff[idx] < 0) {
                puts("-1");
                return 0;
            }
            if (-diff[i] <= diff[idx]) {
                diff[idx] += diff[i];
                diff[i] = 0; 
            } 
            else {
                diff[i] += diff[idx];            
                idx--;
                ans++;
            }
        }
        
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main()
{
    string n ;
    cin >> n ;
    if(n.at(0)=='1')
        n.at(0)='9' ;
   else  if(n.at(0)=='9')
        n.at(0)='1' ;

    if(n.at(1)=='9')
        n.at(1)='1' ;
   else  if(n.at(1)=='1')
        n.at(1)='9' ;
    if(n.at(2)=='9')
        n.at(2)='1' ;
    else if(n.at(2)=='1')
        n.at(2)='9' ;
    cout << n;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int ans;
  char str[16];
  fgets(str,sizeof(str),stdin);
  switch (str[0])
  {
    case 'S':
      { if(str[1] == 'U')
      {
        ans = 7;
      }else
      {
        ans = 1;
      }
  	break;}
  case 'M':{ans = 6;
  break;}
  case 'T':
     {
      if(str[1] == 'U')
  	{
  	  ans = 5;
  	}else
  	{
  	  ans = 3;
  	}
  	break;
     }
   case 'W':
  {
    ans = 4;
  	break;
  }
  default:
  ans = 2;
  }
  printf("%d",ans);
  return 0;
}
    

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MAX 100009
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef vector<long long> vl;

vl v;
ll cnt[200009];
set<ll> s;

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

    v.resize(n);
    for(int i = 0; i < n; ++i) {
        cin >> v[i];
        s.insert(-v[i]);
        cnt[v[i]]++;
    }

    /*for(auto it : s)
        cout << it << " ";
    cout << endl;*/

    for(int i = 0; i < n; ++i) {
        ll p = (*s.begin());
        p *= -1;

        //cout << i << " " << v[i] << " " << p << " " << cnt[p] << endl;
        if(p != v[i] or cnt[p] > 1)
            cout << p << endl;
        else {
            auto it = s.begin();
            ++it;
            p = (*it)*-1;

            cout << p << endl;
        }
    }

    
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
#include <iostream>  
using namespace __gnu_pbds;  
using namespace std;  
  
// Declaring ordered_set 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update>  
    ordered_set;*/  


#define ll long long int
#define ld long double
#define le length()
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mkp make_pair
#define ppl pair<ll,ll>
#define ppi pair<int,int>
#define ppli pair<ll,int>
#define ps push
#define mod 1000000007
#define fi first
#define se second
#define debug1(x) cout<<#x<<" = "<<x<<'\n';
#define debug2(x, y) cout << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define all(v) v.begin(),v.end()
#define mset(x) memset(x,0,sizeof(x))
#define sz size()


ll power(ll a,ll b)
{
    if(b==0)
    return 1;
    if(b==1)
    return a;
    ll r=power(a,b/2)%mod;
    if(b%2==0)
    return (r*r)%mod;
    else
    return (((r*r)%mod)*a)%mod;
}
#define pri 1000009
int prime[pri];
int sumprime[pri];
void sieve(int n)
{ 
    prime[0]=prime[1]=1;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(!prime[i])
        {
            for(int j=2*i;j<=n;j=j+i)
            {
                prime[j]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(!prime[i])
        {
            sumprime[i]=sumprime[i-1]+1;
        }
        else
        {
            sumprime[i]=sumprime[i-1];
        }
    }
}

bool comp(const pair<ll,ll> &a, 
               const pair<ll,ll> &b)
{
       return (a.second < b.second);
}

const int N=5*1e5+9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  /*  #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
    string s,t;
    cin>>s>>t;
    t+=s;
    cout<<t<<"\n";   


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    int m1,m2,d1,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    int out = 1;
    if(m1 == m2){
        out = 0;
    }
    cout << out << endl;
    return 0;
}


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


int main()
{
	int H, W;

	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		for (int i = 0; i<H; i++) {

			for (int j = 0; j<W; j++) {
				if (i == 0 || i == H - 1 || j == 0 || j == W - 1) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3072
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		Map<String, Integer> map = new TreeMap<>();
		
		int n = sc.nextInt();
		
		for (int i = 0; i < n; i++) {
			
			String s = sc.next();
			
			if (map.containsKey(s)) {
				
				int tmp = map.get(s);
				
				map.put(s, ++tmp);
				
			} else {
				
				map.put(s, 1);
				
			}
			
		}
		
		int m = sc.nextInt();
		
		for (int i = 0; i < m; i++) {
			
			String t = sc.next();
			
			if (map.containsKey(t)) {
				
				int tmp = map.get(t);
				
				map.put(t, --tmp);
				
			} else {
				
				map.put(t, -1);
				
			}
			
		}
		
		int ans = 0;
		
		for (String key : map.keySet()) {
			
			ans = Math.max(ans, map.get(key));
			
		}
		
		System.out.println(ans);
		
	}

}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;


class Graph{
    struct edge{
        int vertice;
        ll weight;
    };

    vector<vector<edge>> g;
    unsigned int n;

public:
    Graph(unsigned int n): n{n}{
        g.resize(n);
    }

    void add_edge(int u, int v){
        g[u].emplace_back(edge{v, 1});
    };

    void add_edge(int u, int v, ll w){
        g[u].emplace_back(edge{v, w});
    }

    vector<edge>& get_edge(int v){
        return g[v];
    }

    unsigned int get_num_vertices(){
        return n;
    }

    vector<edge>& operator[](int v){
        return get_edge(v);
    }
};


void dfs(int v, int prev, int dis, vector<int>& disList, Graph& g){
    disList[v] = dis;
    for(auto e: g[v]){
        if(e.vertice == prev)   continue;
        dfs(e.vertice, v, dis+1, disList, g);
    }
}

int dfs2(int v, int prev, vector<int>& d1, vector<int>& d2, Graph& g, bool even){
    int res = 0;
    for(auto e: g[v]){
        if(e.vertice == prev)   continue;
        if(d1[e.vertice] < d2[e.vertice]){
            res = max(res, dfs2(e.vertice, v, d1, d2, g, even));
        }
        else if(d1[e.vertice] == d2[e.vertice]){
            res = max(res, d2[e.vertice]);
        }
    }
    res = max(d2[v]-1, res);

    return res;
}

int main(){
    int n;  cin >> n;
    Graph g(n);

    int u, v;   cin >> u >> v;
    u--; v--;
    for(int i = 0; i < n-1; i++){
        int a, b;   cin >> a >> b;
        a--; b--;
        g.add_edge(a, b);
        g.add_edge(b, a);
    }

    vector<int> d1(n, 0), d2(n, 0);
    dfs(u, u, 0, d1, g);
    dfs(v, v, 0, d2, g);

    cout << dfs2(u, u, d1, d2, g, d1[v] % 2 == 0) << endl;


    return 0;
}

Measured memory_bytes: 16000
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
long long n, m, a, b, c, dist[2000]; vector<pair<long long, long long>>x[3000];
int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) { cin >> a >> b >> c; a--; b--; x[a].push_back(make_pair(b, c)); }
	for (int i = 0; i < n; i++)dist[i] = -(1LL << 60);
	dist[0] = 0; long long P = dist[n - 1];
	for (int i = 0; i < 8 * n; i++) {
		for (int j = 0; j < n; j++) {
			for (pair<long long, long long> k : x[j]){
				dist[k.first] = max(dist[k.first], dist[j] + k.second);
			}
		}
		if (P != dist[n - 1] && i >= 5 * n) { cout << "inf" << endl; return 0; }
		P = dist[n - 1];
	}
	cout << dist[n - 1] << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#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 mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, c; cin>>a>>b>>c;
	cout << a*b/2 << endl;
	return 0;
}

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

int main(){
	string st;
	cin>>st;
	for(int i=0;i<st.size();i++){
		if(st[i]=='A'||st[i]=='T'||st[i]=='C'||st[i]=='G'){
			st[i]='1';
		}
	}
	int maxl=0,s=0;
	for(int i=0;i<st.size();i++){
		while(st[i]=='1'&&i<st.size()){
			s++;
			if(s>maxl) maxl=s;
			i++;
		}
		s=0;
	}
	cout<<maxl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>

using namespace std;

typedef long long in;

int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int> > a(n);
    for(int i=0;i<n;i++){
        cin >> a[i].first >> a[i].second;
    }
    vector<int> p(m+2);
    int q;
    for(int i=0;i<n;i++){
        for(int j=1;j*j<=m;j++){
            if(a[i].second/j-(a[i].first-1)/j>=1){
                p[j+1]-=1;
                p[j]+=1;
            }
            q=j;
        }
        int ind=1;
        int o=m+1;
        while(ind<=q){
            if(a[i].second/ind<=q)
                break;
            p[min(o-1,a[i].second/ind)+1]-=1;
            p[max(q,(a[i].first-1)/ind)+1]+=1;
            o=max(q,(a[i].first-1)/ind)+1;
            ind++;
        }
    }
    int res=0;
    for(int i=1;i<p.size()-1;i++){
        res+=p[i];
        cout << res << endl;
    }
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    stack<char> q;
    q.push(s[0]);
    for (int i = 1; i < s.size(); i++) {
        if (q.empty()) q.push(s[i]);
        else if (q.top() == s[i]) q.push(s[i]);
        else q.pop();
    }
    cout << s.size() - q.size() << endl;
}

Measured memory_bytes: 512
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, P = MAP()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

ans = 1
for p in factorization(P):
	ans *= p[0]**(p[1]//N)
print(ans)


Measured memory_bytes: 5204
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <bitset>
using namespace std;
typedef long long ll;
const ll inf = 4e18;
const ll mod = 1e9+7;
#define print(X) cout << X << endl
#define vec vector
#define pb push_back
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define removeV(x,val) x.erase(x.remove(x.begin(), x.end(), val), x.end());
#define rep(i, n) for (ll (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define repd(i, m, n) for (ll (i) = (m); (i) > (n); --(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;
inline string YesNo(bool cond) { return cond ? "Yes" : "No"; }
inline string YESNO(bool cond) { return cond ? "YES" : "NO"; }

string join(const vector<string>& v, const char* delim = 0) {
  string s;
  if (!v.empty()) {
    s += v[0];
    for (int i = 1, c = v.size(); i < c; ++i) {
      if (delim) s += delim;
      s += v[i];
    }
  }
  return s;
}
//---------------------------------------------------------------------------
int main(void)
{
  vec<string> c(3,string(5,'\0'));
  rep(i,3) {
    cin>>c[i];
  }
  print(c[0].substr(0,1)+c[1].substr(1,1)+c[2].substr(2,1));
}


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

int main() {
  string x;
  cin >> x;
  if (x == "ABC") cout << "ARC";
  if (x == "ARC") cout << "ABC";
  return 0;
}

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

const int INF = 1e9+7;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main() {
	int n,m;
	cin >> n >> m;
	if(m == n){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll w,h,x,y;cin>>w>>h>>x>>y;
  cout<<w*h*0.5<<" ";
  if(w*0.5==x && h*0.5==y)cout<<1<<endl;
  else cout<<0<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int sum=0;
  int ara[n+5];
  for(int i=0;i<n;i++)cin>>ara[i],sum+=ara[i];
  if(sum%10==0)
  {
    sort(ara,ara+n);
    bool f=true;
    for(int i=0;i<n;i++)
    {
      if((sum-ara[i])%10)
      {
        sum-=ara[i];
        cout<<sum<<endl;
        f=false;
        break;
      }
    }
    if(f)cout<<0<<endl;
  }
  else cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cstring>

using namespace std;

const int N = 1010;
int P[N], D[N], T[N];

typedef long long ll;

ll dp[N];

int main(){
	int L, n;
	cin >> L >> n;
	map<int, int> m;
	vector<ll> v;
	for (int i = 0; i < n; ++i){
		cin >> P[i] >> D[i] >> T[i];
		m[P[i]] = i;
		v.push_back(P[i]);
	}
	v.push_back(0), v.push_back(L);
	sort(begin(v), end(v));

	memset(dp, 0x7f, sizeof(dp));
	dp[0] = 0;
	for (int i = 0; i < v.size()-1; ++i){
		int pos = v[i];
		if (m.count(pos)){
			int nxt = pos + D[m[pos]];
			int it = lower_bound(begin(v), end(v), nxt)-begin(v);
			dp[it] = min(dp[it], dp[i] + v[it] - nxt + T[m[pos]]);
		}
		dp[i + 1] = min(dp[i + 1], dp[i] + v[i + 1] - v[i]);
	}

	cout << dp[v.size() - 1] << endl;

	return 0;
}


Measured memory_bytes: 1284
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner=new Scanner(System.in);
        double l=scanner.nextDouble();
        double ll=(double)3;
        double l1=(double)l/ll;
        double l2=(double)l/ll;
        double l3=(double)((double)l-(double)((double)l1+(double)l2));
        double ans=(double)((double)l1*(double)l2*(double)l3);
        System.out.println(ans);
    }
}


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

int n;
vector<int> w;
bool canTake[301][301];
int dp[301][301];

int solve(int l, int r){
    if(l >= r){
        return 0;
    }else if(canTake[l][r]){
        return r - l;
    }else if(dp[l][r] >= 0){
        return dp[l][r];
    }

    int res = max(solve(l + 1, r), solve(l, r - 1));
    for(int i = l + 1 ; i < r ; ++i){
        res = max(res, solve(l, i) + solve(i, r));
    }

    return dp[l][r] = res;
}

int main(){
    while(cin >> n, n){
        w.resize(n);
        for(int i = 0 ; i < n ; ++i){
            cin >> w[i];
        }

        fill(canTake[0], canTake[n + 1], false);

        for(int len = 2 ; len <= n ; len += 2){
            for(int i = 0 ; i <= n - len ; ++i){
                for(int j = i + 1 ; j < i + len ; ++j){
                    if(canTake[i][j] && canTake[j][i + len]){
                        canTake[i][i + len] = true;
                    }
                }
                if(len == 2 && abs(w[i] - w[i + 1]) <= 1){
                    canTake[i][i + 2] = true;
                }
                if(canTake[i][i + len]){
                    int l = i - 1, r = i + len;
                    while(0 <= l && r < n && abs(w[l] - w[r]) <= 1){
                        canTake[l][r + 1] = true;
                        --l;
                        ++r;
                    }
                }
            }
        }

        fill(dp[0], dp[n + 1], -1);

        int ans = solve(0, n);
        cout << ans << endl;
    }
}


Measured memory_bytes: 3564
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
        int consumed = 0;
        for(int i = 0; i < n; i++) {
          int value = sc.nextInt();
          int index = 0;
          while(index * value + 1 <= d) {
            consumed++;
            index++;
          }
        }
    
		// 出力
		System.out.println(consumed + x);
	}
}

Measured memory_bytes: 22996
use proconio::input;

fn main() {
    input!(n: usize, z: i32, w: i32, a: [i32; n]);
    println!(
        "{}",
        if n == 1 {
            (a[n - 1] - w).abs()
        } else {
            (a[n - 1] - w).abs().max((a[n - 2] - a[n - 1]).abs())
        }
    );
}


Measured memory_bytes: 2164
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int H, W;
  int h, w;

  sc.scan(H, W);
  sc.scan(h, w);

  writeln((H * W) - ((h * W) + ((H - h) * w)));
}


Measured memory_bytes: 256
program sample
    implicit none
  
    integer(8) :: i,j,m,n,a,b,ans
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n,m
    allocate(x(n))
    x(:)=-1
    if(m==0)then
        if(n==1)then
            write(*,*)0
            stop
        else 
            write(*,*)10**(n-1)
            stop
        end if
    end if

    do i=1,m
        read(*,*)a,b
        if(a==1 .and. b==0 .and. n/=1)then
            write(*,*)'-1'
            stop
        else if(a>n)then
            write(*,*)'-1'
            stop
        else if(x(a)==-1)then
            x(a)=b
        else if(x(a)/=b)then
            write(*,*)'-1'
            stop
        end if
    end do
    ans=0
    do i=1,n
        if(x(i)==-1)then
            if(i==1)then
                x(i)=1
            else
                x(i)=0
            end if
        end if
        ans=ans+x(i)*10**(n-i)
    end do
    write(*,*)ans
  
    stop
end program sample
  



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

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

  int64_t calcu = n ;
  int64_t digit = 0 ;
  while(calcu != 0)
  {
    digit += calcu % 10 ;
    calcu /= 10 ;
  }



  if(n % digit == 0)
  {
    cout << "Yes" << endl ;
  }
  else
  {
    cout << "No" << endl ;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
int a[2005];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
    }
    ll sum = 0;
    sort(a, a + n);
    for (int i = 0; i < n - 2; i++) {
        for (int j = i + 1; j < n - 1; j++) {
            int pos = lower_bound(a, a + n, a[i] + a[j]) - a;
            sum += pos - j - 1;
        }
    }
    cout << sum;
}



Measured memory_bytes: 3664
i = list(map(int, input().split()))

A = i[0]
B = i[1]
C = i[2]
D = i[3]
flg = 0
while(A>0 and C>0):
    C -= B
    if(C<=0):
        flg = 1
        break
    A -= D
    if(A<=0):
        flg = 2
        break

if(flg == 1):
    print("Yes")
else:
    print("No")

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

int main()
{
    long long x;
    std::cin >> x;
    long long res = x / 11;
    res *= 2;
    if(x %11 != 0)res++;
    if(x % 11 >= 7)res++;
    std::cout << res << std::endl;
}

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

using namespace std;

string a[100];

int main()
{
	int n; cin >> n;
	string S; cin >> S;

	for (int i = 0; i < n; ++i) cin >> a[i];

	int ans = 0;

	for (int i = 0; i < n; ++i) {
		string s = a[i];
		int len = s.length();
		for (int j = 1; j < len; ++j) {
			for (int k = 0; k < len; ++k) {
				int cnt = 0;
				int idx = 0;
				int now;
				for (now = k; now < len; now += j) {
					if (s[now] == S[idx]) {
						idx++;
						cnt++;
					} else {
						idx = cnt = 0;
						break;
					}

					if (cnt == S.length()) {
						ans++;
						goto next;
					}
				}
			}
		}
next:;
	}

	printf("%d\n", ans);
}

Measured memory_bytes: 1224