akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
  os << "[";
  REP(i, SZ(v)) {
    if (i) os << ", ";
    os << v[i];
  }
  return os << "]";
}

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

template<class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

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

  int n; cin >> n;
  vector<bool> v(n);
  REP(i, n) {
    int a, b; cin >> a >> b;
    v[i] = a == b;
  }

  bool ans = false;
  REP(i, n-2) {
    ans |= v[i] && v[i+1] && v[i+2];
  }

  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String ori = "CODEFESTIVAL2016";
		String str = s.next();
		String[] arr1 = ori.split("");
		String[] arr2 = str.split("");

		int count = 0;
		for(int i=0;i<arr1.length;i++){
			if(!arr1[i].equals(arr2[i])){
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 9040
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
  input! {
    n: usize,
    h: [i32; n]
  };

  let mut dp = vec![std::i32::MAX; n];
  dp[0] = 0;
  for i in 0..n {
    for j in i+1..min(i+3,n) {
      dp[j] = min(dp[j], dp[i]+(h[i]-h[j]).abs());
    }
  }

  println!("{}", dp[n-1]);
}

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

using namespace std;

typedef struct _BLOCK {
	int pos;
	int S;
	int left;
	int right;
	double level;
}BLOCK;

int main(void) {
	int d;
	cin >> d;
	for (int i = 0; i < d; i++) {
		vector<_BLOCK> blocks;
		int n, b[10], h[10];
		int m, f[10], a[10];
		int l, p[10], t[10];
		int order[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
		double res[10];
		cin >> n;
		for (int j = 0; j < n; j++)
			cin >> b[j] >> h[j];
		cin >> m;
		for (int j = 0; j < m; j++)
			cin >> f[j] >> a[j];
		cin >> l;
		for (int j = 0; j < l; j++)
			cin >> p[j] >> t[j];
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < l - 1; k++) {
				int tmp;
				if (t[k + 1] < t[k]) {
					tmp = t[k];
					t[k] = t[k + 1];
					t[k + 1] = tmp;
					tmp = p[k];
					p[k] = p[k + 1];
					p[k + 1] = tmp;
					tmp = order[k];
					order[k] = order[k + 1];
					order[k + 1] = tmp;
				}
			}
		}
		for (int j = 0; j < n + 1; j++) {
			if (j == 0) {
				blocks.push_back({ b[j], b[j] * 30, 50, h[j], 0.0 });
			}
			else if (j < n) {
				blocks.push_back({ b[j], (b[j] - b[j - 1]) * 30, h[j - 1], h[j], 0.0 });
			}
			else {
				blocks.push_back({ 100, (100 - b[j - 1]) * 30, h[j - 1], 50, 0.0 });
			}
		}
		for (int j = 0; j < l; j++) {
			int rtime;
			if (j == 0)
				rtime = t[j];
			else
				rtime = t[j] - t[j - 1];
			for (int k = 0; k < m; k++) {
				int x;
				double v;
				int low_height, low_dir, old_dir;
				for (x = 0; x < n + 1; x++) {
					if (blocks.at(x).pos > f[k])
						break;
				}
				v = (double)a[k] * rtime;
				do {
					if (blocks.at(x).left < blocks.at(x).right)
						low_dir = -1;
					else
						low_dir = 1;
					low_height = min(blocks.at(x).left, blocks.at(x).right);
					blocks.at(x).level += (v / blocks.at(x).S);
					v = 0;
					if (blocks.at(x).level > low_height) {
						v = (blocks.at(x).level - low_height) * blocks.at(x).S;
						blocks.at(x).level = low_height;
						if (x + low_dir < 0 || x + low_dir > n)
							break;
						if (low_height == min(blocks.at(x + low_dir).left, blocks.at(x + low_dir).right) && blocks.at(x + low_dir).level == min(blocks.at(x + low_dir).left, blocks.at(x + low_dir).right)) {
							if (low_dir == -1) {
								blocks.at(x + low_dir).pos = blocks.at(x).pos;
								blocks.at(x + low_dir).right = blocks.at(x).right;
							}
							else {
								blocks.at(x + low_dir).left = blocks.at(x).left;
								
							}
							blocks.at(x + low_dir).S += blocks.at(x).S;
							blocks.erase(blocks.begin() + x);
							n--;
							if (low_dir == 1)
								x--;
						}
						x += low_dir;
					}
					old_dir = low_dir;
				} while (v > 0);
			}
			for (int k = 0; k < n+1; k++) {
				if (blocks.at(k).pos > p[j]) {
					res[order[j]] = blocks.at(k).level;
					break;
				}
			}
		}
		for (int j = 0; j < l; j++)
			cout << res[j] << endl;
	}
}

Measured memory_bytes: 1288
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>

#include <vector>
#include <algorithm>
#include <numeric>
#include <tuple>

using i2 = std::tuple<int, int>;

std::string create_code(int ken, int birth_order) {
  std::stringstream ss;
  ss << std::setw(6) << std::setfill('0') << (ken+1);
  ss << std::setw(6) << std::setfill('0') << (birth_order+1);
  return ss.str();
}

int main() {
  int KEN_COUNT, SHI_COUNT;
  std::cin >> KEN_COUNT >> SHI_COUNT;
  std::vector<std::vector<i2>> shi_by_ken(KEN_COUNT);
  for (int i=0;i<SHI_COUNT;i++) {
    int ken, b;
    std::cin >> ken >> b;
    shi_by_ken[ken-1].push_back(i2(i, b));
  }
  for (int i=0;i<KEN_COUNT;i++) {
    std::sort(shi_by_ken[i].begin(), shi_by_ken[i].end(), [&](auto const& lhs, auto const& rhs) -> bool {
      return std::get<1>(lhs) < std::get<1>(rhs);
    });
  }
  std::vector<i2> id(SHI_COUNT);
  for (int i=0;i<KEN_COUNT;i++) {
    auto& shi = shi_by_ken[i];
    for (int j=0;j<shi.size();j++) {
      id[std::get<0>(shi[j])] = i2(i, j);
    }
  }
  for (int i=0;i<SHI_COUNT;i++) {
    std::cout << create_code(std::get<0>(id[i]), std::get<1>(id[i])) << std::endl;
  }
}


Measured memory_bytes: 7808
#include <stdio.h>
#include <string.h>
int main(void) {
    int city[6][2]={{1,2},{-1,3},{1,-1},{4,5},{5,2},{2,1}},i,now;
    char route[100];
    while (1) {
        scanf(" %s\n",route);
        if (route[0]=='#') break;
        now=0;
        for (i=0; i<strlen(route)&&now!=-1; i++) {
            now=city[now][route[i]-'0'];
        }
        if (now==5) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }
    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long h, msb=39; cin >> h;
    bitset<40> b(h);
    while(!b.test(msb)) msb--;
    cout << setprecision(15) << pow(2,msb+1)-1 << endl;
    return 0;
}

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

bool check(int x, int y ,int z){
    int a[3];
    a[0]=x,a[1]=y,a[2]=z;
    sort(a,a+3);
    return (a[0]+a[1]>a[2]) &&(a[0]!=a[1] && a[1]!=a[2]);
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    int a[n];
    for(int& i : a)cin >>i;

    int cnt=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(check(a[i],a[j],a[k])){
                   cnt++; 
                }
            }
        }
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 3656
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(1, n-3+2):
    if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1]):
        cnt += 1
print(cnt)

Measured memory_bytes: 9076
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define ubo upper_bound
#define lbo lower_bound
#define VI vector<int>
#define VL vector<ll>
#define VP vector<pii >
#define all(x) x.begin(), x.end()
#define M vector<VI >
 
using namespace std;
 
int main(){

	int n; cin >> n;
	VL l(n);
	for(ll &i : l) cin >> i;
	sort(all(l));

	int ans = 0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			if(l[i] == l[j]) continue;
			for(int k=j+1; k<n; k++){
				if(l[j] == l[k]) continue;
				if(l[i]+l[j] > l[k]) ans++;
			}
		}
	}

	cout << ans << '\n';
 
	return 0;
}


Measured memory_bytes: 3628
n=int(input())
a=list(map(int,input().split()))
x4=0
x2=0
for i in a:
  if i%4==0:
    x4+=1
  elif i%2==0:
    x2+=1
if x4*2+x2>=n or x4>=n//2:
  print("Yes")
else:
  print("No")

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

int main(){
    long long int N,K;
    cin >> N >> K;

    if(N==K) {
        cout << 0 << endl;
    }

    if(N>K) {
        long long int step = (N - K)/K;
        N -= step*K;
        //cout << N << endl;
        if((N - K)>=((long double)(K)/2)) {
            cout << K - (N - K) << endl; 
        } else {
            cout << N - K << endl;
        }

    }

    if(N<K) {
        if(N>=((long double)(K)/2)) {
            cout << K - N << endl;
        } else {
            cout << N << endl;
        }

    } 


}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#define N1 1001
using namespace std;
int Change(string);
void DP();
int N,W,n,v[N1],w[N1];
int main(){
  int t,i,j;
  string in;
  n=1;
  while(1){
    cin >> W;
    if(W==0) break;
    cin >> N;
    for(i=1;i<=N;i++){
      cin >> in;
      for(j=0;j<in.size();j++){
	if(in[j]==','){
	  t=j;
	  break;
	}
      }
      v[i]=Change(in.substr(0,t));
      w[i]=Change(in.substr(t+1,in.size()-t-1));
    }
    DP();
  }
  return 0;
}
int Change(string str){
  int len=str.size(),ret=0,x=1,i=0;
  while(len){
    ret=ret*x+(str[i]-'0');
    i++;
    x=10;
    len--;
  }
  return ret;
}
void DP(){
  int dp[N1][N1],c[N1][N1],maxv,minw,x,y,t,sum,i,j,k;
  for(i=0;i<=W;i++) dp[0][i]=0;
  for(i=0;i<=N;i++) dp[i][0]=0;
  maxv=0;
  for(i=1;i<=N;i++){
    for(j=1;j<=W;j++){
      if(j>=w[i]){
	if(dp[i-1][j]<dp[i-1][j-w[i]]+v[i]){
	  dp[i][j]=dp[i-1][j-w[i]]+v[i];
	  c[i][j]=1;
	}
	else{
	  dp[i][j]=dp[i-1][j];
	  c[i][j]=0;
	}
      }else{
	dp[i][j]=dp[i-1][j];
	c[i][j]=0;
      }
      maxv=max(maxv,dp[i][j]);
    }
  }
  minw=2000000000;
  for(i=1;i<=N;i++){
    for(j=1;j<=W;j++){
      if(maxv==dp[i][j]){
	t=j;
	sum=0;
	for(k=i;k>=1;k--){
	  if(c[k][t]==1){
	    sum+=w[k];
	    t-=w[k];
	  }
	}
	minw=min(minw,sum);
      }
    }
  }
  cout << "Case " << n << ':' << endl;
  cout << maxv << endl << minw << endl;
  n++;
}

Measured memory_bytes: 9044
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  vector<int> s(10);
  s[a]++;
  s[b]++;
  s[c]++;
  s[d]++;
  if(s[1]&&s[9]&&s[7]&&s[4]){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M >> K;
	vector<long long int>v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	if (N == 1) {
		cout << abs(K - v[0]) << endl;
		return 0;
	}
	cout << max(abs(v[N - 1] - K), abs(v[N - 2] - v[N - 1])) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        long[] count = new long[n+1];
        for (int i = 1; i <= 1000; i++) {
            for (int j = 1; j <= 1000; j++) {
                for (int k = 1; k <= 1000; k++) {
                    int tmp = i * i + j * j + k * k + i * j + j * k + k * i;
                    
                    if (tmp <= n) {
                        count[tmp]++;
                    }
                }
            }
        }
        
        for (int i = 1; i <= n; i++) {
            System.out.println(count[i]);
        }
    }
}


Measured memory_bytes: 39012
def main():
	N, K = [int(x) for x in input().split(" ")]
	S = list(input())
	cnt = [0] # idx = 0, 2, 4 ... -> handstand
	a = 0
	for i in range(len(S)):
		if S[i] == "0":
			if a % 2 == 0:
				a += 1
				cnt.append(1)
			else:
				cnt[-1] += 1
		elif S[i] == "1":
			if a % 2 == 0:
				cnt[-1] += 1
			else:
				a += 1
				cnt.append(1)
	if S[-1] == "0":
		cnt.append(0)

	if K >= (len(cnt) - 1) / 2:
		print(N)
		return 0

	T = [sum(cnt[:(2 * K + 1)])]
	for i in range(0, len(cnt) - 2 * K - 2, 2):
		T.append(T[-1] - cnt[i] - cnt[i + 1] + cnt[i + 2 * K + 1] + cnt[i + 2 * K + 2])
	print(max(T))

main()

Measured memory_bytes: 11968
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner S = new Scanner(System.in);
		int n = S.nextInt();
		int m = S.nextInt();
		int[][] A = new int[n][m];
		int[] b = new int[m];
		int[] ans = new int[n];
		
		for(int i = 0;i < n;i++){
			for(int j = 0;j < m;j++){
				A[i][j] = S.nextInt();
			}
		}
		
		for(int i = 0;i < m;i++){
			b[i] = S.nextInt();
		}
		
		for(int i = 0;i < n;i++){
			for(int j = 0;j < m;j++){
				ans[i] += A[i][j] * b[j];
			}
		}
		
		for(int i = 0;i < n;i++){
			System.out.println(ans[i]);
		}
	}		
}

Measured memory_bytes: 31104
#include <iostream>
using namespace std;
void showResevation(int *arr){
    for(int i=0; i<1000; i++){
        cout << arr[i] << " ";
    }
    cout << endl;
}
int main(void){
    int elRes[1000] = {};
    int resStart, resEnd;
    cin >> resStart >> resEnd;
    for(int i=resStart; i<=resEnd-1; i++){
        elRes[i] = 1;
    }

    int loops, rs, re;
    cin >> loops;
    for(int i=0; i<loops; i++){
        cin >> rs >> re;
        for(int j=rs;j<=re-1;j++){
            if(elRes[j] == 1){
                cout << 1 << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
    return 0;
}



Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
using namespace std;

int main(){
int a,b,d,r;
double f,af,bf;
cin>>a>>b;
d=a/b;
r=a%b;
af=a;
bf=b;
f=af/bf;
cout<<d<<" "<<r<<" "<< fixed << setprecision(5)<<f<<endl;
}


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

#define ll long long

int main() {
	int n,q,x,b,c;
	int i;
	ll ans=0;
	cin >> n;
	int a[100001] = { 0 };
	//vector<int>a(n+1);
	for (i = 1; i <= n; i++) {
		cin >> x;
		ans += x;
		a[x]++;
	}

	cin >> q;
	for (i = 0; i < q; i++) {
		cin >> b >> c;
		x = a[b];
		a[c] += x;
		a[b] = 0;
		ans = ans + (c - b)*x;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4012
K = int(input())
ans = 0
def gcd(a,b):
    while b > 0:
        a,b = b,a%b
    return a
for a in range(1,K+1):
    for b in range(1,K+1):
        ab = gcd(a,b)
        for c in range(1,K+1):
            ans += gcd(ab,c)
print(ans)

Measured memory_bytes: 73720
#include <bits/stdc++.h>
#define REPZ(i, z, n) for(decltype(n) i = (z); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12
#define MOD 998244353//合同式の法

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// intの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 setprecision()
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
using namespace std;
const int mod=998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}c(200009);
void dfs(){ 
  return;
}
int main(){
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n,m,k; cin >> n >> m >> k;
  mint res=0;
  mint color=m;
  for(ll i=n-1;i>=0;i--){
    mint comb=c(n-1,i);
    if(i<=k) res+=color*comb;
    color*=m-1; 
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 6244
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Util{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
        int N = ri();
		int[] LArray = ria();
        if(N < 3) {
            Console.WriteLine(0);
		    Console.ReadLine();
            return;
        }
        
        Array.Sort(LArray);
        int[][] Lss = Combination.Enumerate(LArray, 3, withRepetition:false).ToArray();

        int ans = 0;
        foreach (int[] Ls in Lss)
        {
            if(Ls.Distinct().Count() != 3) continue;

            Array.Sort(Ls);
            if(Ls[2] < Ls[0] + Ls[1]) ans++;
        }


		Console.WriteLine(ans);
		Console.ReadLine();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
    static int[] generateNums(int num, int N){return Enumerable.Repeat(num, N).ToArray();}
    static int[] generateSuretsu(int N){return Enumerable.Range(0, N).ToArray();}
}

public static class Combination {
	//使い方:int[][] Is = Combination.Enumerate(nums, k, withRepetition:false).ToArray();
    public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) {
        if (k == 1) {
            foreach (var item in items)
                yield return new T[] { item };
            yield break;
        }
        foreach (var item in items) {
            var leftside = new T[] { item };

            // item よりも前のものを除く （順列と組み合わせの違い)
            // 重複を許さないので、unusedから item そのものも取り除く
            var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

            foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
                yield return leftside.Concat(rightside).ToArray();
            }
        }
    }
}


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

using namespace std;
typedef long long ll;
int main(){
    ll x;
    cin>>x;
    ll sum = 100;
    ll tot =0;
    while(sum<x){
    	ll res = sum *0.01;
    	//cout<<res<<"0---";
    	sum += res;
    	tot++;
	}
	cout<<tot;
	return 0;
} 

Measured memory_bytes: 3596
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
using namespace std;

int main() {
	int n, count = 0;
	cin >> n;
	bool flag = true;
	for (int i = 0; i < n; i++) {
		char c;
		int k;
		cin >> c;
		cin >> k;
		if (c == '(') {
			count += k;
		} else {
			count -= k;
		}

		if (count < 0)
			flag = false;
	}
	if (flag and count == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> l(n * 2);
	for (int i = 0; i < n * 2; i++)
		cin >> l[i];
	sort(l.begin(), l.end());
	int ans = 0;
	for (int i = 0; i < n * 2; i += 2)
		ans += l[i];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>

const int INF = 1000000009;
const long LINF = 1123456789012345678; 

long n, m;

int main(){
	scanf("%ld%ld", &n, &m);
	long ans = 0;
	for(long a = 1; a <= n; a++){
		if((m*INF-2*a) % m != 0){
			continue;
		}
		long x = (m*INF - a) % m;
		long num;
		if(x == 0){
			num = n / m;
		}else{
			num = (n-x)/m + 1;
		}
		ans += num + num*(num-1);
		//printf("%ld %ld %ld %ld\n", a, x, num, num + num*(num-1));
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf = 10e17;
const ll mod = inf;//1000000007;
const ld eps = 10e-9;



ll solve(void);
ll gcd(ll x, ll y);


ll mulmod(ll x, ll y)
{
	return (x * y) % mod;
}

ll submod(ll x, ll y)
{
	return (x - y + 100 * mod) % mod;
}

ll power(ll n, ll r)
{
	if ( r == 0 ) { return 1; }
	if ( r == 1 ) { return n; }
	if ( n == 0 ) { return 0; }
	if ( n == 1 ) { return 1; }

	if (r % 2 == 0)
	{
		ll y = power(n, r/2);
		return mulmod(y, y);
	}
	else
	{
		ll y = power(n, (r-1)/2);
		return n * mulmod(y, y) % mod;
	}
}

ll gcd(ll x, ll y)
{
	if (y == 1) { return 1;}
	if (x % y == 0) { return y; }
	return gcd(y, x % y);
}

vector<ll> perm;
vector<ll> inv;
void init_inv(ll m)
{
	perm.resize(m);
	inv.resize(m);
	
	perm[0] = 1;
	inv[0] = 1;

	for (ll i = 1; i < m; i++)
	{
		perm[i] = mulmod(perm[i-1], i);
	}
	
	for (ll i = 1; i < m; i++)
	{
		inv[i] = power(perm[i], mod - 2);
	}
}

ll ncr(ll n, ll r)
{
	// n (n-1) ... (n-r)
	if ( r == n || r == 0 ) { return 1; }

	ll ans = 1;
	for (ll i = 0; i < r; i++)
		ans = mulmod(ans, n - i);

	 return mulmod(ans, inv[r]);
	// return mulmod(perm[n], mulmod(inv[n-r], inv[r]));
}

bool binary_check(ll mid, ll key)
{
	return mid >= key;
}

ll binary_search()
{
//	ll ng = 0;
//	ll ok = x;
//
//	while (abs(ok - ng) > 1)
//	{
	//	ll mid = (ok+ng) / 2;
	//	if (binary_check(mid, k)) ok = mid;
	//	else ng = mid;
	//}

	return 0;
	//return ok;
}

void pushorcreate(map<ll, vector<ll>> &m, ll key, ll i)
{
	if (m.find(key) == m.end())
	{
		m[key] = vector<ll>(1, i);
	}
	else {
		m[key].push_back(i);
	}
}

bool iskaibun(string s)
{
	ll n = s.length();

	bool b = true;
	for (ll i = 0; i < n; i++)
		b &= (s[i] == s[n - 1 - i]);

	return b;
}

ll solve(void)
{
	ll d;
	cin >> d;

	ld x = (ld)d;
	ld ans = x * x * x / 27.0;
	printf("%.8Lf\n", ans);

	return 0;
}

int main(void)
{
	while (solve())
	{
	}
	return 0;
}


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

typedef unsigned long ul;
typedef long long int ll;
typedef pair<ll, ll> P;
#define pb push_back
#define mp make_pair
#define REP(i,n) REPN(i,0,n)
#define REPN(i,m,n) for(int i=m; i<(n); i++)
#define dump(x) cout << #x << " = " << (x) << endl

void search(char s[400][400], bool memo[400][400], P& p, int m, int n, int h, int w) {
    char now = s[m][n];
    memo[m][n] = true;

    if (m != h-1) {
        char down = s[m+1][n];
        if ((down != now) && (memo[m+1][n] == false)) {
            if (down == '#') {
                p.first = p.first + 1;
            } else {
                p.second = p.second + 1;
            }
            search(s, memo, p, m+1, n, h, w);
        }
    }

    if (m != 0) {
        char up = s[m-1][n];
        if ((up != now) && (memo[m-1][n] == false)) {
            if (up == '#') {
                p.first = p.first + 1;
            } else {
                p.second = p.second + 1;
            }
            search(s, memo, p, m-1, n, h, w);
        }
    }

    if (n != w-1) {
        char right = s[m][n+1];
        if ((right != now) && (memo[m][n+1] == false)) {
            if (right == '#') {
                p.first = p.first + 1;
            } else {
                p.second = p.second + 1;
            }
            search(s, memo, p, m, n+1, h, w);
        }
    }

    if (n != 0) {
        char left = s[m][n-1];
        if ((left != now) && (memo[m][n-1] == false)) {
            if (left == '#') {
                p.first = p.first + 1;
            } else {
                p.second = p.second + 1;
            }
            search(s, memo, p, m, n-1, h, w);
        }
    }
}

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

    int h, w;
    cin >> h >> w;
    char s[400][400];
    REP(i, h) {
        REP(j, w) {
            cin >> s[i][j];
        }
    }

    bool memo[400][400];
    REP(i, h) {
        REP(j, w) {
            memo[i][j] = false;
        }
    }

    ll sum = 0;
    REP(i, h) {
        REP(j, w) {
            if (memo[i][j] == false) {
                P p = mp(0, 0);
                if (s[i][j] == '#') {
                    p.first = p.first + 1;
                } else {
                    p.second = p.second + 1;
                }
                search(s, memo, p, i, j, h, w);
                sum += (p.first * p.second);
            }
        }
    }

    cout << sum << '\n';
}


Measured memory_bytes: 25600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    string s;
    cin>>s;
    s[5]=' ';
    s[13]=' ';
    cout<<s<<endl;
}

Measured memory_bytes: 256
//1803115
#include<stdio.h>
#include<stdlib.h>
int main()
{
    long n,m,l,x,i,j,k,*a,*b,*c;
    scanf("%ld %ld %ld",&n,&m,&l);
    a=(long *)malloc(n*m*sizeof(long));
    for(i=0;i<n*m;i++)
    {
        scanf("%ld",&x);
        *(a+i)=x;
    }
    b=(long *)malloc(m*l*sizeof(long));
    for(i=0;i<m*l;i++)
    {
        scanf("%ld",&x);
        *(b+i)=x;
    }
    c=(long *)malloc(n*l*sizeof(long));
    for(i=0;i<n*l;i++) *(c+i)=0;
    for(i=0;i<n;i++)
    {
        for(j=0;j<l;j++)
        {
            for(k=0;k<m;k++)
            {
                *(c+i*l+j)+=*(a+i*m+k) * *(b+k*l+j);
            }
        }
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<l;j++)
        {
            if(j==l-1) printf("%ld",*(c+i*l+j));
            else printf("%ld ",*(c+i*l+j));
        }
        printf("\n");
    }
    free(a);
    free(b);
    free(c);
    return 0;
}


Measured memory_bytes: 2104
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll dvalue[base10_6];
vll dindex;
vll dindextmp;
ll base = 0;
ll N;
ll K;
ll x_[base10_6]={};
ll _x[base10_6]={};
ll ltmp;
string stmp;
double dtmp;

ll llmin(ll a,ll b){
    if(a>=b) return b;
    return a;
}
ll llmax(ll a,ll b){
    if(a<=b) return b;
    return a;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    cin >> K;

    rep(ni,N){
        cin >> ltmp;
        dvalue[ni]=ltmp;
    }
    rep(ki,K){
        ll cntN = 0;
        rep(ni,N) x_[ni]=0;
        rep(ni,N) _x[ni]=0;
        rep(ni,N){
            ll pos = ni;
            ll rumen = dvalue[ni];
            ll left = llmax(0,pos-rumen);
            ll right = llmin(N-1,pos+rumen);
            _x[left]++;
            x_[right]++;
        }

        ll sta = 0;
        ll fin = 0;
        
        rep(ni,N){
            sta = sta + _x[ni];
            dvalue[ni] = sta-fin;
            if(dvalue[ni]==N) cntN++;
            fin = fin + x_[ni];
        }
        if(cntN==N) break;
    }
    rep(ni,N){
        cout << dvalue[ni];
        cout << " ";
    }


}

Measured memory_bytes: 8320
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let q: usize = input();
    let qs: Vec<Query> = (0..q)
        .map(|_| {
            let i: i32 = input();
            if i == 1 {
                let (a, b) = (input(), input());
                Query::Q1(a, b)
            } else {
                Query::Q2
            }
        })
        .collect();

    let mut heapl = std::collections::BinaryHeap::new();
    let mut heapr = std::collections::BinaryHeap::new();
    let mut ans = 0i64;
    for q in qs {
        match q {
            Query::Q1(a, b) => {
                ans += b;
                heapl.push(a);
                heapr.push(-a);
                let l = heapl.pop().unwrap();
                let r = heapr.pop().unwrap();
                let r = -r;
                if l <= r {
                    heapl.push(l);
                    heapr.push(-r);
                } else {
                    ans += i64::abs(r - l);
                    heapl.push(r);
                    heapr.push(-l);
                }
            }
            Query::Q2 => {
                let l = heapl.pop().unwrap();
                println!("{} {}", l, ans);
                heapl.push(l);
            }
        }
    }
}

enum Query {
    Q1(i64, i64),
    Q2,
}


Measured memory_bytes: 16636
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class Solver {
        public void solve(Scanner in, PrintWriter out) {
            int H = in.nextInt();
            int A = in.nextInt();
            int count = 0;

            do {
                H -= A;
                count++;
            }
            while (H > 0);

            out.println(count);
        }
    }
}

Measured memory_bytes: 21844
while 1:
    k=input().split()
    H=int(k[0])
    W=int(k[1])
    if H==0 and W==0:
        break
    for i in range(H):
        msg=""
        for j in range(W):
            if (i+j)%2 ==0:
                msg +="#"
            else:
                msg +="."
        print(msg)
    print("")


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


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

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int len = 0;
        for (int j = 0; j + i <= N; j++) {
            if (S[j] == S[j + i]) {
                if (len < i) len++;
                ans = max(ans, len);
            } else {
                len = 0;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;

using namespace std;

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

    if (a + b+ c == 17)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


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

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
#define int long long int

int BN, NA, BA;

int count(const string &str) {
  int res = 0;
  for (int i = 0; i < str.length() - 1; i++) {
    if (str[i] == 'A' && str[i + 1] == 'B') {
      res++;
    }
  }
  return res;
}

void solve() {
  int N;
  cin >> N;

  int ans = 0;
  while (N--) {
    string s;
    cin >> s;
    if (s.front() == 'B' && s.back() == 'A') {
      BA++;
    } else if (s.front() == 'B') {
      BN++;
    } else if (s.back() == 'A') {
      NA++;
    }
    ans += count(s);
  }

  if (BA == 0) {
    ans += min(BN, NA);
  } else if (BN == 0 && NA == 0) {
    ans += (BA - 1);
  } else if (BN == 0 || NA == 0) {
    ans += BA;
  } else {
    NA--;
    ans += BA + 1;
    BN--;
    ans += min(BN, NA);
  }

  // cout << BA << " " << BN << " " << NA << endl;

  cout << ans << endl;
}

signed main() {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INF 1000000000000 //10^12

int main(){
    ll k;
    cin >>k;
    ll ans=0;
   // vector<ll> gcds;
    //REP(i,k) gcds.push_back(__gcd())
    REP(i,k){
        REP(j,k){
            REP(l,k){
                ans+=(ll)__gcd((int)i+1,(int)__gcd((int)j+1,(int)l+1));
            }
        }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

/*

*/


void solve(){

    string s,t;
    cin >> s >> t;
    cout << t << s << endl;

}

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N;
  cin>>N;
  long long l[2]={2,1};

  for(int i=0;i<N;i++){
    long long temp=l[0]+l[1];
    l[0]=l[1];
    l[1]=temp;
  }
  cout<<l[0]<<endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iomanip>
#include<iostream>
#include<map>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<vector>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
AdjList getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

long long Manhattan_dist(long long x1, long long y1, long long x2, long long y2){return abs(x1-x2) + abs(y1-y2);}

void out(bool ans){
	if(ans == true) cout << "yes" << endl;
	else cout << "no" << endl;
}
void Out(bool ans){
	if(ans == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}
void OUT(bool ans){
	if(ans == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}
unsigned long long gcd(const unsigned long long a, const unsigned long long b){
	return (b==0) ? a : gcd(b,a%b);
}
int main(){
	int N,K;
	cin >> N>>K;
	vector<int> l = getv<int>(N);
	sort(l.rbegin(),l.rend());
	int ans = 0;
	// for(int i = N-1; i>=N-K; --i)
	for(int i = 0; i<K; ++i)
		ans += l[i];
	cout << ans << endl;
}



Measured memory_bytes: 256
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 100001
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
char A,B;
int main()
{
    //std::ios::sync_with_stdio(false);
    scanf("%c %c", &A, &B);
    if(A=='H')
    {
        printf("%c\n", B);
    }
    else
    {
        if(B=='H') puts("D");
        else puts("H");
    }
    //system("pause");
}


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

using namespace std;
int n;
int h[1000000];
int dp[1000000];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        cin>>h[i];
    h[0]=-100000;
    dp[1]=0;
    dp[0]=0;
    for(int i=2;i<=n;i++)
        dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
    printf("%d\n",dp[n]);
}


Measured memory_bytes: 4736
#include<iostream>
#include<cmath>
#include<cstdlib>
using namespace std;
struct coo{
	int x;
	int y;
	int h;
}c[110];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>c[i].x;
		cin>>c[i].y;
		cin>>c[i].h;
	}
	int ch;
	int p=0;
	while(c[p].h==0) p++;
	for(int i=0;i<=100;i++)
	{
		for(int j=0;j<=100;j++)
		{
			int ch=c[p].h+abs(i-c[p].x)+abs(j-c[p].y);
			int f=0;
			for(int k=0;k<n;k++)
			{
				int hh=ch-abs(i-c[k].x)-abs(j-c[k].y);
				if(hh<0) hh=0;
				if(hh!=c[k].h)
				{
					f=1;
					break;
				}
			}
			if(!f)
			{
				cout<<i<<' '<<j<<' '<<ch<<endl; return 0;
			} 
		}
	}
	
	
} 


Measured memory_bytes: 256
n=gets.chomp.to_i
a=gets.chomp.to_s.split("")
b=gets.chomp.to_s.split("")
c=gets.chomp.to_s.split("")

ttl = 0
n.times do |i|
  ab = a[i] == b[i] 
  bc = b[i] == c[i]
  ca = c[i] == a[i]
  if ab && bc && ca
  elsif ab || bc || ca
    ttl += 1
  else
    ttl += 2
  end
end

puts ttl

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    int n;
    cin>>n;
    int a[n+1];
    map<int,int> mp;
    int x;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        mp[i]=x;
    }
    int count=0;
    for(auto i:mp)
    {
       if(mp[i.second]==i.first)
       count++; 
    }
    cout<<count/2;
  }  
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#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 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


ll dp[100010][3];

int main() {
    ll a[100010][3];
    
    int N; cin >> N;
    REP(i,N){
        REP(j,3){
            cin >> a[i][j];
        }
    }
    REP(i,N){
        REP(j,3){
            REP(k,3){
                if(j != k){
                    if(dp[i+1][k]<dp[i][j] + a[i][k]){
                        dp[i+1][k] = dp[i][j] + a[i][k];
                    }
                }  
            }
        }
    }
    ll res = 0;
    REP(i,3){
        if(res<dp[N][i]){
            res = dp[N][i];
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 4992
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


//main function
fn main() {
    let n: i32 = read();
    println!("{}",3*n*n);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
typedef long long ll;
// cd test ; rm -R ./*; cd .. 

int main(void) {
  
  ll x, y;
  cin >> x >> y;

  ll ans = 0;
  ll now = x;
  while (1) {
    if (now > y) break;
    now *= (ll)2;
    ans++;
  }
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

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

/** Problem1159 : Next Mayor **/
int main()
{
	int n, get[50], stone;

	
	while (cin >> n >> stone, n||stone) {
		fill(get, get+50, 0);
		int i=0;
		while (1) {
			if (stone>0) {
				stone--;
				get[i%n]++;
			} else {
				bool flg=true;
				rep(j, n) {
					if (j!=i%n && get[j]>0) {
						flg=false;
						break;
					}
				}
				if (flg) {
					cout << i%n << endl;
					goto end;
				} else {
					stone = get[i%n];
					get[i%n] = 0;
				}
			}
			i++;
		}
	end:;
	}
	return 0;
}

Measured memory_bytes: 1160