akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n,k;cin >>n >> k;
    int a[n];
    int s = 0;
    rep(i,n){
        cin >> a[i];
        s += a[i];
    }
    vector<int> num;
    for(int g = 1;g*g <= s;g++){
        if(s%g == 0){
            num.push_back(g);
            if(g*g != s)num.push_back(s/g);
        }
    }
    sort(num.rbegin(),num.rend());
    auto check = [&](int g){
        int ret = 0;
        vector<int> amari;
        int sum = 0;
        rep(i,n){
            amari.push_back(a[i]%g);
            sum += a[i]%g;
        }
        sort(amari.rbegin(),amari.rend());
        rep(i,min(n,sum/g)){
            if(amari[i])ret += g-amari[i];
        }
        return ret <= k;
    };
    for(auto g:num){
        if(check(g)){
            cout << g << endl;
            return 0;
        }
    }
    return 0;
}   

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

int main(){
int a,b,sum=0;
double t;
cin >>a >>b;
cin >>t;

if(t+0.5<a){
sum=0;
}else{
    for(int i=1; a*i<t+0.5; i++){
        sum+=b;
    }
}
    cout <<sum <<endl;

return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        int n = scanner.nextInt();
        char[] str = scanner.next().toCharArray();
        //odd number cannot be string twice
        if (n % 2 == 1) System.out.println("No");
        else {
            boolean bad = false;
            for(int i = 0, j = n/2 ; i < n/2; i++,j++) {
                if (str[i] != str[j]) {
                  System.out.println("No");
                  return;
                }
            }
            System.out.println("Yes");
        }
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 23124
#include <stdio.h>

int main()
{
	int N;
	scanf("%d", &N);
	int b[N];
	int a[N];
	int j;
	int i = 0;
	while (i < N - 1)
		scanf("%d", &b[i++]);
	a[N - 1] = b[N - 2];
	// j = N - 2;
	i = N - 2;
	while (i >= 1)
	{
		if (b[i] > b[i - 1])
		{
			a[i] = b[i - 1];
		}
		else if (b[i] <= b[i - 1])
		{
			a[i] = b[i];
		}
		i--;
	}
	a[0] = b[0];
	i = 0;
	int sum = 0;
	while (i < N)
		sum += a[i++];
	printf("%d", sum);
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	int nm[110];
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			nm[i * j] = 1;
		}
	}
	if (nm[n] == 1) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	cout << n*n*3 << endl;
}


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

int main(){
    LL N, A, B;
    cin >> N >> A >> B;
    vector<double>  v(N);
    for(int i = 0;i < N;i++)    cin >> v[i];
    sort(v.rbegin(), v.rend());
    LL comb[51][51];
    for(int i = 0;i < 51;i++)for(int j = 0;j < 51;j++)  comb[i][j] = 0;
        for(int i = 0;i < 51;i++){
            for(int j = 0;j <= i;j++){
                if(j == 0)  comb[i][j] = 1;
                else    comb[i][j] = comb[i-1][j-1]+comb[i-1][j];
            }
        }
    double ans = 0.0;
    for(int i = 0;i < A;i++)    ans += v[i];
    cout.precision(20);
    cout << fixed << ans/(double)A << endl;
    if(A == N || v[A-1] > v[A]){
        cout << 1 << endl;
    }else{
        bool f = false;
        int id;
        int n = 0;
        for(int i = 0;i < N;i++){
            if(v[i] == v[A-1]){
                if(!f){
                    f = true;
                    id = i;
                }
                n++;
            }
        }
        LL sum = comb[n][A-id];
        if(v[0] == v[A-1])  for(int i = A-id+1;i <= B-id;i++)   sum += comb[n][i];
        cout << sum << endl;
    }
}

Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), N = ip[0], K = ip[1];
	int[] h;
	foreach(i; 0..N) {
		h ~= ri;
	}
	h.sort();
	ulong res = ulong.max;
	foreach(i; 0..N-K+1) {
		res = min(res, h[i+K-1] - h[i]);
	}
	res.writeln;
}

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

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n]++;
  return ret;
}

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll n, m;
  cin >> n >> m;
  auto f = prime_factor(m);

  COMinit();
  ll ans = 1;
  for (auto x : f) {
    ll cnt = x.second;
    ans *= COM(x.second + n - 1, n - 1);
    ans %= MOD;
  }

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

Measured memory_bytes: 12160
m = 1000000007

from sys import stdin
f_i = stdin

N = int(f_i.readline())

n_type = [''] * N
for i in range(N):
    t = f_i.readline().rstrip()
    n_type[i] = t

adj = [[] for i in range(N)]
for i in range(N - 1):
    s, t = map(int, f_i.readline().split())
    s -= 1
    t -= 1
    adj[s].append(t)

from itertools import combinations

def prod(nums):
    p = 1
    for n in nums:
        p *= n
    return p

import sys
sys.setrecursionlimit(4000)

def dfs(node):
    nt = n_type[node]
    chld = adj[node]
    if nt == 'E':
        if chld:
            return prod(map(dfs, chld)) % m
        else:
            return 1
    elif nt == 'E?':
        if chld:
            return (prod(map(dfs, chld)) + 1) % m
        else:
            return 2
    elif nt == 'A':
        return sum(map(dfs, chld)) % m
    elif nt == 'A?':
        return (sum(map(dfs, chld)) + 1) % m
    else:
        cnt = 0
        c_s = tuple(map(dfs, chld))
        for i in range(1, len(chld) + 1):
            for vals in combinations(c_s, i):
                cnt += prod(vals)
        if len(nt) == 1:
            return cnt % m
        else:
            return (cnt + 1) % m

print(dfs(0))


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


bool check(vector<int>& s, vector<int>& c, vector<int>& ans)
{
    int N = ans.size();
    int M = s.size();
    REP(i, M){
        if(ans[s[i]] == -1 or ans[s[i]] == c[i]) ans[s[i]] = c[i];
        else return false;
    }
    if(N > 1 and ans[0] == 0) return false;
    if(N == 1 and ans[0] == -1) ans[0] = 0;
    REP(i, N) if(ans[i] == -1) ans[i] = (i==0)? 1: 0;

    return true;
}


int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> s(M), c(M);
    REP(i, M){
        cin >> s[i] >> c[i];
        --s[i];
    }

    vector<int> ans(N, -1);
    if(check(s, c, ans)){
        REP(i, N) cout << ans[i];
        cout << endl;
    }else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

ll L[100010];

void solve(long long N, long long A, long long B, vector<long long> X) {
  FOR(i, 1, N) {
    ll d = X[i] - X[i - 1];
    if (d * A > B) {
      //テレポートしたほうが早い
      L[i] = B;
    } else {
      L[i] = d * A;
    }
  }

  ll ans = 0;
  REP(i, N) ans += L[i];

  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long A;
  long long B;
  long long N;
  cin >> N;
  vector<long long> X(N - 1 + 1);
  cin >> A;
  cin >> B;
  for (int i = 0; i <= N - 1; i++) {
    cin >> X[i];
  }
  solve(N, A, B, X);
  return 0;
}


Measured memory_bytes: 2688
package main
import(
    "fmt"
    "os"
    "strings"
)

func main(){
    var s string
    fmt.Scan(&s)
    words := []string{"dream", "dreamer", "erase", "eraser"}
    for s != "" {
        op := false
        for _, v := range words {
            if strings.HasSuffix(s, v) {
                s = s[:len(s) - len(v)]
                op = true
            }
        }
        if !op {
            fmt.Println("NO")
            os.Exit(0)
        }
    }
    fmt.Println("YES")
}

Measured memory_bytes: 2572
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong();
    long w = sc.nextLong();
    if (h == 1 || w == 1) {
      System.out.println(1);
    } else if (h * w % 2 == 1) {
      System.out.println(h * w / 2 + 1);
    } else {
      System.out.println(h * w / 2);
    }
    sc.close();
  }
}


Measured memory_bytes: 35600
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <queue>
#include <functional>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

using V = vector<int>;
using VV = vector<V>;
using P = pair<int, int>;

int main() {
	int dx[] = {4, 2}, dy[] = {2, 4};
	for (int w, h; w = in(), h = in();) {
		P s = {in() - 1, in() - 1}, g = {in() - 1, in() - 1};
		int n = in();
		VV m(h, V(w));
		while (n--) {
			int c = in(), d = in(), x = in() - 1, y = in() - 1;
			for (int i = 0; i < dy[d]; i++)
				for (int j = 0; j < dx[d]; j++)
					m[i + y][j + x] = c;
		}
		function<bool(int, int, int)> f = [&](int x, int y, int c) {
			if (x == g.first && y == g.second)
				return true;
			int dx = 1, dy = 0;
			for (int i = 0; i < 4; i++) {
				int tx = x + dx, ty = y + dy;
				if (tx >= 0 && ty >= 0 && tx < w && ty < h && m[ty][tx] == c) {
					m[ty][tx] = 0;
					if (f(tx, ty, c))
						return true;
				}
				swap(dx, dy *= -1);
			}
			return false;
		};
		int c = m[s.second][s.first];
		m[s.second][s.first] = 0;
		outl(c ? f(s.first, s.second, c) ? "OK" : "NG" : "NG");
	}
}


Measured memory_bytes: 2624
#include<stdio.h>
#include<stdlib.h>

#define MAX 100005
#define NIL -1

struct Node {
  int p,l,r;
};

struct Node T[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p==NIL)printf("root, ");
  else if(T[u].l==NIL) printf("leaf, ");
  else  printf("internal node, ");

  printf("[");

  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i) printf(", ");
    printf("%d",c);
  }
 printf("]\n");
}

void rec(int u, int p){
  D[u]=p;
  if(T[u].r!=NIL)rec(T[u].r,p);
  if(T[u].l!=NIL)rec(T[u].l,p+1);
}


int main(){
  int i,j,d,v,c,l,r,n;

  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    T[i].p=T[i].l=T[i].r=NIL;

  for(i=0;i<n;i++){
     scanf("%d",&v);
     scanf("%d",&d);
     for(j=0;j<d;j++){
       scanf("%d",&c);
       if(j==0) T[v].l=c;
       else T[l].r=c;
       l=c;
       T[c].p=v;
     }
  }
  
  for(i=0;i<n;i++)
    if(T[i].p==NIL)r=i;
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);

  return 0;
}



Measured memory_bytes: 6380
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	int n; cin >> n;
	vector<vector<int> > g(n, vector<int>(n,0));
	rep(i, n) {
		int u, k; cin >> u >> k;
		rep(j, k) {
			int to; cin >> to;
			g[u-1][to-1]=1;
		}
	}

	rep(i, n) {
		rep(j, n) {
			if (j != (n-1)) {
				cout << g[i][j] << " ";
			}
			else {
				cout << g[i][j];
			}
		}
		cout << endl;
	}
}

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

	return 0;
}



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

using namespace std;
typedef long long ll;

int main(void) {
	int num, i;
	ll a, b, ans = 0;
	cin >> num >> a >> b;
	vector<ll> d(num);
	for (i = 0; i < num; i++)
		scanf("%d", &d[i]);
	for (i = 0; i < num - 1; i++)
		ans += min(a * (d[i + 1] - d[i]), b);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  vector<ll> sum(N); // 累積和
  sum[0] = A[0];
  for (int i=1; i<N; i++) sum[i] = sum[i-1]+A[i];
  int res = N;
  for (int i=N-2; i>=0; i--) {
    if (2*sum[i]<A[i+1]) {
      res = N-i-1;
      break;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <climits>

typedef long long ll;

using namespace std;

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

    ll _min(INT_MAX), _max(INT_MIN), _sum(0);
    for (ll i=0; i<n; i++)
    {
        cin >> a;

        _min = min(_min, a);
        _max = max(_max, a);
        _sum += a;
    }

    cout << _min << ' ' << _max << ' ' << _sum << endl;

    return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    
    cout << 3*n*n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef long double td;
typedef vector<td> vd;
typedef pair<ll,ll> ii;
typedef vector<ii> vii; typedef vector<bool> vb;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(ll i = ll(a); i < (ll)(b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define show(v,n) cerr << #v << " = "; forn(i,n) cerr << v[i] << " "; cerr << endl;
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
int MAXN = 500005;

struct item
{
	int w, v;
};

ll knapsack(vector <item> &v, int n, int w)
{
	ll dp[n+1][w+1];
	memset(dp,0,sizeof(dp));
	dp[0][v[0].w]=v[0].v;
	forr(i,1,n)
	{
		forn(j,w+1)
		{
			dp[i][j]=dp[i-1][j];
			if(j-v[i].w < 0) continue;
			dp[i][j]=max(dp[i][j],dp[i-1][j-v[i].w] + v[i].v);
		}
	}
	ll ans = 0;
	forn(i,w+1) ans=max(ans,dp[n-1][i]);
	return ans;
}
 
int main()
{ 	
	FIN;
	#ifdef input
		freopen("test1.txt", "r", stdin);
	#endif

	int n, w;
	cin >> n >> w;
	vector <item> v(n);
	forn(i,n) cin >> v[i].w >> v[i].v;
	cout << knapsack(v,n,w) << endl;
    return 0;
}

Measured memory_bytes: 82528
#include <stdio.h>
int fib(int);

int f[50];

int main()
{
  int i,n;
  for(i=0;i<50;i++)
    f[i]=-1;
  scanf("%d",&n);
  printf("%d\n",fib(n));
}
int fib(n)
{
  if(n==0 || n==1)
    return 1;
  if(f[n]!=-1)
    return f[n];
  return f[n] = fib(n-1) + fib(n-2);
}




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



int main(){

	long int a[100][100] = {};
	long int b[100][100] = {};
	long int ans[100][100] = {};
	int n, m,l;

	cin >> n >> m>>l;

	for (int i = 0; i <n; i++)
	{ 
		for (int j = 0; j < m; j++)
		{
			cin >> a[i][j];
		}
	}
	for (int i = 0; i <m; i++)
	{
		for (int j = 0; j < l; j++)
		{
			cin >> b[i][j];
		}
	}

	for (int i = 0; i <n; i++)
	{
		for (int j = 0; j < l; j++)
		{
			for (int k = 0; k < m; k++)
			{
				ans[i][j] += a[i][k] * b[k][j];
			}
			
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < l; j++)
		{
			cout << ans[i][j];
			if (j  == l-1){
				cout << endl;
			}
			else {
				cout << ' '; 
			}
		}
		
	}


}


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

int main()
{
 int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p, q, r;
  for (int i = 0;i < a;i++)
  {
    int tmp;
    cin >> tmp;
    p.push_back(tmp);
  }  
  for (int i = 0;i < b;i++)
  {
    int tmp;
    cin >> tmp;
    q.push_back(tmp);
  }
    for (int i = 0;i < c;i++)
  {
    int tmp;
    cin >> tmp;
    r.push_back(tmp);
  }
  sort(p.begin(),p.end());
  sort(q.begin(),q.end());
  sort(r.begin(),r.end());
  priority_queue<int, vector<int>, greater<int>> pq;
  for (int i = 0; i < x; i++)
  {
    pq.push(p[a-i-1]);
//    cout << p[a-i-1] << endl;
  }
   for (int i = 0; i < y; i++)
   {
    pq.push(q[b-i-1]);
//     cout << q[b-i-1] << endl;
   }
  

  int idx = c-1;
  while (idx >= 0 && pq.top() <= r[idx])
  {
    pq.pop();
      pq.push(r[idx]);
    idx--;
  }
  long long ret = 0;
  while (!pq.empty())
  {
//    cout << "," << pq.top() << endl;
    ret += pq.top();
      pq.pop();
  }
  cout << ret << endl;
}
 

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

int main(void){
    int n ;
    double ans=0 ;
    cin >> n ;
    for (int i=0; i<n; i++){
        double a ;
        cin >> a;
        ans+=(1/a);
    }
    cout << 1/ans << endl ;
}

Measured memory_bytes: 256
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
inline int read()
{
	int num=0, w=0;
	char ch=0;
	while (!isdigit(ch))
	{
		w|=ch=='-';
		ch = getchar();
	}
	while (isdigit(ch))
	{
		num = (num<<3) + (num<<1) + (ch^48);
		ch = getchar();
	}
	return w? -num: num;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=2e6+10;
#define int long long
int a[N];
void solve()
{
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=2;i<=n;i++)
		if(a[i]<a[i-1])
		{
			ans+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	cout<<ans<<endl;
}	
signed main()
{
	int t=1; 
	while(t--)
		solve();
	return 0;
}



Measured memory_bytes: 5192
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

ll df(ll a, ll b)
{
    if (b < 0) a = -a, b = -b;
    return a / b - (a % b < 0);
}

ll dc(ll a, ll b)
{
    if (b < 0) a = -a, b = -b;
    return a / b + (a % b > 0);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, a[5];
    cin >> n;
    ll min = 1e15; int mi = -1;
    for (int i = 0; i < 5; ++i)
    {
        cin >> a[i];
        if (a[i] <= min)
            min = a[i], mi = i;
    }
    cout << 4 + dc(n, min);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
# define rep(i,n) for(int i=0;i<n;i++)
void solve(){
   int n;
   cin>>n;
   int a[n];
   rep(i,n)
   cin>>a[i];
   lli sum=0;
   for(int i=1;i<n;i++){
       if(a[i-1]>a[i]){
           sum+=(a[i-1]-a[i]);
           a[i]=a[i-1];
       }
   }
   cout<<sum<<endl;
}
int main()
{
    int t;
   // cin>>t;
    t=1;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 4272
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int n;
   cin >> n;
   rep(i, 1, 10) rep(j, 1, 10) {
      if (i * j == n) {
         cout << "Yes" << endl;
         return 0;
      }
   }
   cout << "No" << endl;
   return 0;
}

Measured memory_bytes: 256
import bisect
def main():
  N = int(input())
  A = sorted(list(map(int, input().split())))
  B = sorted(list(map(int, input().split())))
  C = sorted(list(map(int, input().split())))
  b_c = [0]*N
  for i, b in enumerate(reversed(B)):
    b_c[-1-i]  = b_c[-i] +N-bisect.bisect_right(C, b)
  ans = 0
  for i in A:
    posi = bisect.bisect_right(B, i)
    if posi < N:
      ans += b_c[posi]
  print(ans)

if __name__ == "__main__":
  main()

Measured memory_bytes: 22720
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(1, n):
    now = a[i] + a[i-1]
    if x >= now:
        continue
    ans += now - x
    a[i] -= min(a[i], now-x)

print(ans)

Measured memory_bytes: 14540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    ll S; cin >> S;
    ll x = S % INF;
    ll y = S / INF;
    if(y == INF) cout << 0 << " " << 0 << " " << INF << " " << 0 << " " << 0 << " " << INF << endl;
    else cout << 0 << " " << 0 << " " << INF << " " << 1 << " " << INF - x << " " << 1 + y << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main(void) {
	int N,A,B,C,X;
	cin >> N;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> X;

	while (N!=0||A!=0||B!=0||C!=0||X!=0) {
		int *y = new int[ N ];
		int *check = new int [ N ];
		int count_f = -1;
		int count_n = 0;
		bool clear = false;
		int L = 0;
		for (int i = 0; i < N; i++) {
				cin >> y[i];
		}
		while ((!clear) && !(count_f > 10000)) {
				count_f++;
				if (X == y[L]) {
					count_n++;
					L++;
				}
				
				if (count_n == N) {
					clear = true;
				}
				X = ((A*X)+B)%C;
		}
		if (count_f > 10000) {
			count_f = -1;
		}
		cout << count_f << endl;

		cin >> N;
		cin >> A;
		cin >> B;
		cin >> C;
		cin >> X;

		delete[] y; 
	}
	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

vector<int> to[55];
vector<bool> visited(55,0);

void dfs(int a,int b,int v,int p = -1){
    visited[v]=1;
    for(int u:to[v]){
        if(visited[u])continue;
        if(u==a&&v==b)continue;
        if(v==a&&u==b)continue;
        dfs(a,b,u,v);
    }
}

int main(){
    int n,m;
    cin >> n >> m;
    int a[m],b[m];
    rep(i,m){
        int at,bt;
        cin >> at >> bt;
        at--,bt--;
        a[i]=at;
        b[i]=bt;
        to[at].push_back(bt);
        to[bt].push_back(at);
    }
    int ans = 0;
    rep(i,m){
        rep(j,n)visited[j]=0;
        dfs(a[i],b[i],0);
        int c = 0;
        rep(j,n)c+=visited[j];
        if(c!=n)ans++;
    }
    cout << ans << endl;
}

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

int main() {
  int N, X, answer=0;
  cin >> N >> X;
  vector<int> L(N), D(N+1);
  D.at(0) = 0;
  for (int i=0; i<N; i++) {
    cin >> L.at(i);
  }
  for (int i=0; i<N; i++) {
    D.at(i+1) = D.at(i) + L.at(i);
  }
  for (int i=0; i<=N; i++) {
    if (D.at(i) <= X) {
      answer++;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n;
int a[16][16];
LL dp[1 << 16];
bool vis[1 << 16];
LL search(int bit){
    auto &res = dp[bit];
    if(vis[bit])return res;
    vis[bit] = true;

    LL tmp = 0;
    REP(i, n)for(int j = i + 1;j < n;j++)if(((1 << i) & bit) && ((1 << j) & bit))tmp += a[i][j];
    res = tmp;

    for(int nxt = (bit - 1) & bit;nxt > 0; nxt = (nxt - 1)&bit){
        res = max(res, search(nxt) + search(bit ^ nxt));
    }
    return res;
}

int main(){
    cin >> n;
    REP(i, n)REP(j, n)cin >> a[i][j];
    cout << search((1 << n) - 1) << endl;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
vector <int> adj[100001];
bool visited[100001];
bool colors[100001];
void derp(int cur){
    visited[cur]=1;
    for(int i=0; i<adj[cur].size(); i++){
        if(!visited[abs(adj[cur][i])]){
            if(adj[cur][i]<0){
                colors[-1*(adj[cur][i])]=!colors[cur];
            }
            else colors[adj[cur][i]]=colors[cur];
            derp(abs(adj[cur][i]));
        }
    }
}
int main(){
    int n;
    cin>>n;
    for(int i=0; i<n-1; i++){
        int u,v,w;
        cin>>u>>v>>w;
        if(w%2==0){
            adj[u].push_back(v);
            adj[v].push_back(u);
        }
        else{
            adj[u].push_back(-v);
            adj[v].push_back(-u);
        }
    }
    derp(1);
    for(int i=1; i<=n; i++){
        cout<<colors[i]<<endl;
    }
}

Measured memory_bytes: 8192
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
const int MOD = 1000000007;

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define mod_mul(x, y) x*y%MOD
#define mod_add(x, y) (x+y)%MOD
#define mod_sub(x, y) (x-y)%MOD
#define INF_INT 100000000

typedef std::vector<std::vector<int>> Matrix;

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

long lcm( long m, long n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}


long nCr(long n, long r){
    if(n==r || r==0){
        return 1;
    } else {
        return mod_add(nCr(n-1,r),nCr(n-1,r-1));
    }
}

int N, M;
int dp[101][101];


void wf(){
    for(int k =0; k<N; k++){
        for(int i=0; i<N; i++){
            for(int j =0; j<N; j++){
                dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
            }
        }
    }
}



int main(){
    cin >> N >> M;
    int edges[1000][3];

    for(int i=0; i<N;i++){
        for(int j=0; j<N;j++){
            if(i==j) dp[i][j] = 0;
            else dp[i][j] = 100000000;
        }
    }

    for (int i = 0; i < M; i++) {
        int in,out,cost; cin >> in >> out >> cost;
        edges[i][0] = in-1;
        edges[i][1] = out-1;
        edges[i][2] = cost;
        dp[in-1][out-1] = cost;
        dp[out-1][in-1] = cost;
    }

    wf();
    int ans = 0;

    for (int i = 0; i < M; i++) {
        int in = edges[i][0];
        int out = edges[i][1];
        int cost = edges[i][2];

        bool used = false;

        for(int s=0; s<N; s++){
            for(int t=0;t<N; t++){
                if(dp[s][in]+cost+dp[out][t]== dp[s][t]){
                    used = true;
                }
            }
        }

        if(!used){
            ans++;
        }
    }

    cout << ans << endl;


    return 0;

}


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

using namespace std;

const int N=1e6+3;

const double eps=0.000000001;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans;

char s[N];

void IO(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("test.txt","r",stdin);
	#endif
}

int main(){
	//IO();
	scanf("%d",&n);
	int mn=1e9;
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		if (x<mn)
			ans++;
		mn=min(mn,x);
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int ctr[100010];
	memset(ctr,0,sizeof(ctr));
	int ntr;
	int m=-1;
	for(int i=0;i<n;i++){
		scanf("%d",&ntr);ctr[ntr]++;
		m=max(m,ntr);
	}
	int mx=0;
	for(int i=0;i<=m;i++){
		mx=max(mx,ctr[i]+ctr[i+1]+ctr[i+2]);
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <math.h>
#include <set>
#include <string>
using namespace std;

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

	int *h = new int[N];

	for(int i=0; i<N; i++)
	{
		int t;
		cin>>t;
		h[i]=t;
	}

	//iに行くまでの最小コストを保存し続ければよい
	int *cost = new int[N];
	cost[0] = 0;
	cost[1] = abs(h[0]-h[1]);
	for(int i=2; i<N; i++)
	{
		cost[i] = min(abs(h[i]-h[i-2])+cost[i-2],abs(h[i]-h[i-1])+cost[i-1]);
	}

	cout<<cost[N-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int longest_path(vector<vector<int>> &adj)
{
	int n = adj.size();
	int indegree[n] = {0};
	int l_path[n] = {0};
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < adj[i].size(); ++j)
		{
			indegree[adj[i][j]]++;
		}
	}
	queue<int> q;
	for (int i = 0; i < n; ++i)
	{
		if (indegree[i]==0)
		{
			q.push(i);
		}
	}
	while(!q.empty())
	{
		int u  = q.front();
		q.pop();
		for (int i = 0; i < adj[u].size(); ++i)
		{
			indegree[adj[u][i]]--;
			l_path[adj[u][i]] = max(l_path[adj[u][i]],l_path[u]+1);
			if (indegree[adj[u][i]] == 0)
			{
				q.push(adj[u][i]);
			}

		}
	}
	int answer = INT_MIN;
	for (int i = 0; i < n; ++i)
	{
		answer = max(answer, l_path[i]);
	}
	return answer;
}
int main()
{
	/*
	the code will be similar to topological sort
	*/
	//cout << "Enter number of vertices\n";
	int n;
	cin >> n;
	vector<vector<int>> adj(n);
	//cout << "Enter number of edges\n";
	int e, u, v;
	cin >> e;
	//cout << "Enter the u-v pairs where edge goes from u to v\n";
	while(e--)
	{
		cin >> u >> v;
		adj[u-1].push_back(v-1);
	}
	//cout << "Answer : " << longest_path(adj) + 1 << '\n';
	cout << longest_path(adj);
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include "set"
#include "map"
#include "unordered_map"
#include <string>
#include <iomanip>
#include <numeric>
#include "cmath"

using namespace std;
#define double long double
#define int long long
#define all(a) a.begin(), a.end()


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

    string s; cin>>s;

    for(int i=0; i<s.size()-2; i++){
        if (s[i]==s[i+1] || s[i]==s[i+2] || s[i+1]==s[i+2]){
            return cout<<i+1<<' '<<i+3<<'\n', 0;
        }
    }

    if (s[0]==s[1]){
        cout<<1<<' '<<2<<'\n';
        return 0;
    }

    cout<<"-1 -1";
}

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

int main(){
  int m;
    cin>>m;
  string meirei,moji;
  map<string,int> dic;
  while(m--){
    cin>>meirei>>moji;
    if(meirei=="insert"){
      dic.insert(make_pair(moji,1));
    }else{
      if(dic.find(moji)!=dic.end()){
        cout<<"yes"<<endl;
      }else{
        cout<<"no"<<endl;
      }
    }
  }


}

Measured memory_bytes: 36868
import java.util.Scanner;

class Main{
  public static void main(String... args){
    char[] s = new Scanner(System.in).next().toCharArray();
    int[] arr = {0,0};
    
    for(char c : s){
      if(c == '1')arr[1]++;
      else arr[0]++;
    }
    
    
    System.out.println(2*Math.min(arr[0],arr[1]));
  }
}


Measured memory_bytes: 27088
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<iomanip>
using namespace std;
#define INF 1145141145141919810.00000
int t[100], s[100][100], v[100][2], r, n, a, b, c; double u[100], d, MINX;
int main() {
	while (true) {
		MINX = INF;
		memset(u, INF, sizeof(u));
		memset(s, 0, sizeof(s));
		memset(t, 0, sizeof(t));
		memset(v, 0, sizeof(v));
		cin >> r >> n; if (!r) { break; }
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			for (int i = a + 50; i < b + 50; i++) {
				for (int j = 0; j < c; j++) {
					s[i][j] = 1;
				}
			}
		}
		for (int i = 1; i < 100; i++) {
			for (int j = 0; j < 100; j++) {
				if (s[i][j] == 1) {
					v[i][0] = j + 1;
				}
			}
			for (int j = 0; j < 100; j++) {
				if (s[i - 1][j] == 1) {
					v[i][1] = j + 1;
				}
			}
			t[i] = min(v[i][0], v[i][1]);
		}
		for (int i = 50 - r + 1; i <= 50 + r - 1; i++) {
			d = sqrt(pow(r, 2) - pow(50 - i, 2));
			u[i] = t[i] + r - d;
			MINX = min(MINX, u[i]);
		}
		cout << fixed << setprecision(20) << MINX << endl;
	}
}

Measured memory_bytes: 1284
m, d = map(int, input().split())

cnt = 0
for i in range(1, m + 1):
    for j in range(1, d + 1):
        d1 = j % 10
        d2 = j // 10
        if d1 >= 2 and d2 >= 2 and d1 * d2 == i:
            cnt += 1

print(cnt)


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9
const ll mod = 1e9+7;
const int mx = 1005;
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
ll fact(ll x, ll n){
  ll ans = 1;
  REP(i, n){
    ans *= x;
  }
  return ans;
}
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
  }
  vector<int> prime;
  vector<bool> isPrime(mx+2, true);
  isPrime[0] = isPrime[1] = false;
  FOR(i, 2, mx){
    if(isPrime[i] == false) continue;
    prime.push_back(i);
    for(int j = 2; i * j <= mx; j++){
      isPrime[i*j] = false;
    }
  }
  map<int, int> lcm;
  vector<map<int, int>> pr(N);
  REP(i, N){
    int a = A[i];
    for(int j =0; prime[j] * prime[j] <= A[i] && j != prime.size(); j++){
      while(a % prime[j] == 0){
        a /= prime[j];
        pr[i][prime[j]]++;
      }
    }
    pr[i][a] = 1;
    cerr << "i:" << i << " a:" << a << endl;
    for(auto mp: pr[i]){
      cerr << mp.first << " " << mp.second << endl;
      lcm[mp.first] = max(lcm[mp.first], mp.second);
    }
  }
  ll l = 1;
  for(auto mp:lcm){
    l *= fact(mp.first, mp.second);
    l %= mod;
  }
  ll ans = 0;
  REP(i, N){
    ans += l * modinv(A[i], mod);
    ans %= mod;
  }
  // REP(i, N){
  //   cerr << "i:" << i << " A[i]:" << A[i] << endl;
  //   ll add = 1;
  //   for(auto mp: lcm){
  //     cerr << "mp.first:" << mp.first<< " mp.second:" << mp.second << " " << fact(mp.first, mp.second - pr[i][mp.first]) << endl;
  //     add *= fact(mp.first, mp.second - pr[i][mp.first]);
  //     add %= mod;
  //   }
  //   cerr << "add:" << add << endl;
  //   ans += add;
  //   ans %= mod;
  // }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3584
n = gets.to_i
ary = gets.split.map(&:to_i)
sum = 0
count = 0
ary.each do |i|
  if i.even?
    sum+=1
    if i%3==0 || i%5==0
      count+=1
    end
  end
end
puts sum==count ? "APPROVED": "DENIED"

Measured memory_bytes: 1788
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val x = sc.nextInt()
    println(10 - x / 200)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34412
from collections import deque

def main():
    N = int(input())
    l = deque()
    mozi = list("abcdefghijklmnopqrstuvwxyz")
    a, b = divmod(N, 26)
    N -= 1

    while True:
        a, b = divmod(N, 26)
        l.appendleft(mozi[b])
        N = a
        N -= 1
        if a == 0:
            break

    print("".join(l))


main()

Measured memory_bytes: 9476