akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e16
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)     for(lint i=n-1;i>=0;--i)
#define REPR1(i,n)    for(lint i=n;i>0;--i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
void dijkstra(const vector<vector<pair<lint, lint>>>&edge, vector<lint>&cost, lint start = 0)
{
	fill(ALL(cost), INF); cost[start] = 0;
	priority_queue<pair<lint, lint>, vector<pair<lint, lint>>, greater<pair<lint, lint>>> node_queue; node_queue.push(make_pair(0, start));
	while (!node_queue.empty())
	{
		const lint  tpn_cost = node_queue.top().first, tpn_index = node_queue.top().second; node_queue.pop();
		REPC(i, edge[tpn_index])
		{
			const lint dst_index = i.first, dst_cost = i.second;
			if (tpn_cost + dst_cost < cost[dst_index])
			{
				cost[dst_index] = tpn_cost + dst_cost;
				node_queue.push(make_pair(cost[dst_index], dst_index));
			}
		}
	}
	return;
}
signed main()
{
	lint n = in(), m = in(), s = in(), t = in();
	vector<vector<pair<lint, lint>>>edge_yen(n), edge_snook(n);
	REP(i, m)
	{
		lint u = in(), v = in(), a = in(), b = in();
		edge_yen[u - 1].push_back(make_pair(v - 1, a));
		edge_yen[v - 1].push_back(make_pair(u - 1, a));
		edge_snook[u - 1].push_back(make_pair(v - 1, b));
		edge_snook[v - 1].push_back(make_pair(u - 1, b));
	}
	vector<lint>cost_yen(n), cost_snook(n);
	dijkstra(edge_yen, cost_yen, s - 1);
	dijkstra(edge_snook, cost_snook, t - 1);
	vector<pair<lint, lint>>cost(n);
	REP(i, n)cost[i] = make_pair(cost_yen[i] + cost_snook[i], i);
	sort(ALL(cost));
	lint exchange_point = 0;
	REP(i, n)
	{
		while (cost[exchange_point].second < i) exchange_point++;
		cout << (1000000000000000 - cost[exchange_point].first) << endl;
	}
}

Measured memory_bytes: 19836
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let v = read_vec::<usize>();
    let n = v[0];
    let m = v[1];
    let l = v[2];

    let a = read_vec2::<u32>(n);
    let b = read_vec2::<u32>(m);

    let mut c = vec![vec![0u64; l]; n];
    for i in 0..n {
        for j in 0..l {
            for k in 0..m {
                c[i][j] += a[i][k] as u64 * b[k][j] as u64;
            }
        }
    }

    for i in 0..n {
        let s = c[i].iter().map(|x| x.to_string()).collect::<Vec<String>>().join(" ");
        println!("{}", s);
    }
}



Measured memory_bytes: 5052
def main():
    n=int(input())
    a,b=map(int,input().split())
    p=map(int,input().split())
    A,B,C = 0,0,0
    for pp in p:
        if pp <= a:
            A += 1
        elif pp <= b:
            B += 1
        else:
            C += 1
    print(min(A,B,C))

if __name__ == "__main__":
    main()

Measured memory_bytes: 8912
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int n = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            if(i % 3 != 0 && i % 5 != 0) ans += i;
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 35756
#include<bits/stdc++.h>
using namespace std;
#define ll long long
	
signed main(){
	ll n, i, j;
	cin >> n;
	ll a[n+1][3];

	for( i = 1 ; i <= n ; i++ ){
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	ll dp[n+1][3];
	dp[0][0] = dp[0][1] = dp[0][2] = 0;
	a[0][0] = a[0][1] = a[0][2] = 0;

	dp[1][0] = a[1][0];
	dp[1][1] = a[1][1];
	dp[1][2] = a[1][2];

	for( i = 2 ; i <= n ; i++ ){
		dp[i][0] = max(  dp[i-1][1], dp[i-1][2]  ) + a[i][0];
		dp[i][1] = max(  dp[i-1][0], dp[i-1][2]  ) + a[i][1];
		dp[i][2] = max(  dp[i-1][1], dp[i-1][0]  ) + a[i][2];
	}
	j = max( { dp[n][0] , dp[n][1], dp[n][2] } );
	cout << j << endl;
	// cout << endl;
	// for( i = 1 ; i <= n ; i++ ){
	// 	cout << dp[i][0] << ' ' << dp[i][1] << ' ' <<  dp[i][2] << endl;
	// }
	// cout << endl;

	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using graph = vector<vector<int>>;
using wgraph = vector<vector<pair<int, lint>>>;
const lint INF = 1001001001001001LL;
const lint MOD = 1000000007LL;
const double PI = 3.1415926535897932;
int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

void yes(){ cout << "yes" << endl; }
void Yes(){ cout << "Yes" << endl; }
void YES(){ cout << "YES" << endl; }
void no(){ cout << "no" << endl; }
void No(){ cout << "No" << endl; }
void NO(){ cout << "NO" << endl; }
void possible(){ cout << "possible" << endl; }
void Possible(){ cout << "Possible" << endl; }
void POSSIBLE(){ cout << "POSSIBLE" << endl; }
void impossible(){ cout << "impossible" << endl; }
void Impossible(){ cout << "Impossible" << endl; }
void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(int i = s; i < t; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()


// 最小全域技を求める
// O(E log V)
// verify http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_A


template<typename T>
T prim(vector<vector<pair<int, T>>> &g){
    int n = (int)g.size();
    T ret = 0;
    vector<bool> used(n, false);
    using P = pair<T, int>;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, 0});
    while(!que.empty()){
        auto p = que.top();
        que.pop();
        if(used[p.second]) continue;
        used[p.second] = true;
        ret += p.first;
        for(auto &e : g[p.second]){
            que.push({e.second, e.first});
        }
    }

    return ret;
}

int main(){
  
  lint w, h; cin >> w >> h;
  vector<lint> p(w);
  rep(i, w) cin >> p[i]; 
  vector<lint> q(h);
  rep(i, h) cin >> q[i];
  p.push_back(INF);
  q.push_back(INF);
  sort(all(p));
  sort(all(q));
  
  lint i = 0;
  lint j = 0;
  lint ans = 0;
  while(!(p[i] == INF and q[j] == INF)){
    if(p[i] < q[j]){
      ans += p[i] * (h - j + 1);
      i++;
    }else{
      ans += q[j] * (w - i + 1);
      j++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int H = sc.nextInt();
		long[] a = new long[N];
		long[] b = new long[N];
		long A = 0;
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextLong();
			b[i] = sc.nextLong();
			A = Math.max(A, a[i]);
		}
		sc.close();
		List<Data> list = new ArrayList<Data>();
		for(int i = 0; i < N; i++) {
			if(b[i] > A) {
				list.add(new Data(a[i], b[i]));
			}
		}
		Collections.sort(list, new MyComparator());
		long sum = 0;
		int l = list.size();
		long cnt = 0;
		for(int i = l - 1; i >= 0; i--) {
			sum += list.get(i).b;
			cnt++;
			if(sum >= H) {
				System.out.println(cnt);
				System.exit(0);
			}
		}
		long res = H - sum;
		cnt += (res + A - 1) / A;
		System.out.println(cnt);
	}
	static class Data{
		long a, b;
		public Data(long a, long b) {
			this.a = a;
			this.b = b;
		}
	}
	static class MyComparator implements Comparator<Data>{
		@Override
        public int compare(Data d1, Data d2) {
			if(d1.b < d2.b) {
				return -1;
			}else if(d1.b == d2.b) {
				return 0;
			}else {
				return 1;
			}
		}
	}
}

Measured memory_bytes: 84360
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    REP(i, n) cin >> p[i];
    
    sort(ALL(p));

    int res = 0;
    for(int i = 0; i < k; i++) {
        res += p[i];
    }


    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3568
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
        for j in range(W):
            if (j+i)%2==0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7004
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;

int main(){

    int res100,res10,res1;
    int N;

    cin >> N;

    for(int i = N; i <= 999; ++i){
        res100 = i/100;
        res10 = (i-res100*100)/10;
        res1 = (i-res100*100-res10*10)/1;
        if(res100 == res10 && res10 == res1){
            cout << i << endl;
            return 0;
        } 
    }
}

Measured memory_bytes: 888
var readline = require('readline')
var reader = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

var lines = [];
reader.on('line', function(line) {
  lines.push(line);
});

reader.on('close', function() {
  var AB = lines[0].split(' ').map(Number);
  var A = AB[0], B = AB[1];
  console.log(Math.ceil((B-1)/(A-1)));
});

Measured memory_bytes: 7628
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };
struct Node T[MAX];
int n;

void preParse(int u) {
    if ( u == NIL ) return;
    printf( " %d", u);
    preParse(T[u].l);
    preParse(T[u].r);
    
}

void inParse(int u) {
    if ( u == NIL ) return;
    inParse(T[u].l);
    printf(" %d", u);
    inParse(T[u].r);
}

void postParse(int u) {
    if ( u == NIL ) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d", u);
}

int main() {
    
    int i, v, l, r, root;
    
    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) {
        T[i].p = NIL;
    }
    for ( i = 0; i < n; i++ ) {
        scanf ( "%d %d %d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if ( l != NIL ) T[l].p = v;
        if ( r != NIL ) T[r].p = v;
    }
    
    for ( i = 0; i < n; i++ ) if ( T[i].p == NIL ) root = i;
    
    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
    
}



Measured memory_bytes: 2096
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, K, ans = 0; cin >> N >> K;
    for (int i = 0; i < N; ++i) {
        int x; cin >> x;
        if (abs(0 - x) <= abs(K - x)) ans += 2 * x;
        else ans += 2 * abs(K - x);
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 3624
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        while(true){
            int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            if(n[0] == 0 && n[1] == 0){
                break;
            }else{
                Array.Sort(n);
                Console.WriteLine(n[0] + " " + n[1]);
            }
        }
    }
}


Measured memory_bytes: 16368
using System;

namespace Kyopuro
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split(' ');
            string[] b = Console.ReadLine().Split(' ');
            string c =(Console.ReadLine());


            int na = int.Parse(b[0]);
            int nb = int.Parse(b[1]);

            if(c == a[0])
            {
                na--;
            }
            else
            {
                nb--;
            }

            Console.WriteLine(na + " "+ nb);




        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    string s;
    cin >> s;
    map<char,int> mp;
    for(int i=0; i<s.size(); i++){
        mp[s[i]]++;
    }
    for(auto it : mp){
        if(it.second%2!=0){
            cout << "No" <<endl;
            return 0;
        }
    }
    cout << "Yes"<<endl;
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int TATE = 1;
	static int YOKO = 0;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			char[] s1 = in.nextString().toCharArray();
			char[] s2 = in.nextString().toCharArray();

			List<Integer> list = new ArrayList<>();
			for (int i = 0; i < n; i++) {
				if (s1[i] == s2[i]) {
					list.add(TATE);
				} else {
					list.add(YOKO);
					i++;
				}
			}

			long ans = 0;

			if (list.get(0) == TATE) {
				ans += 3;
			} else {
				ans += 6;
			}

			for (int i = 1; i < list.size(); i++) {
				if (list.get(i) == TATE) {
					if (list.get(i-1) == TATE) {
						ans = ans*2%MOD;
					} else {
						ans = ans*1%MOD;
					}
				} else {
					if (list.get(i-1) == TATE) {
						ans = ans*2%MOD;
					} else {
						ans = ans*3%MOD;
					}
				}
			}

			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 23252
#coding : utf8

def digitSum(number):
    s = str(number)
    li = list(map(int,list(s)))
    return sum(li)

if __name__ == '__main__':
    inputNum = int(input())
    minimum = inputNum

    for i in range(1,int(inputNum/2+1)):
        temp = digitSum(i) + digitSum(inputNum-i)
        if(minimum > temp):
            minimum = temp

    print(minimum)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

#define int long long

signed main()
{
    int A, B, N;
    cin >> A >> B >> N;
    // for (int i = 1; i <= 100; i++)
    // {
    //     cout << A * i / B - A * (i / B) << endl;
    // }
    if (N >= B)
    {
        int x = B - 1;
        cout << A * x / B - A * (x / B) << endl;
    }
    else
    {
        int x = N;
        cout << A * x / B - A * (x / B) << endl;
    }
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  string s1, s2;
  cin >> s1 >> s2;
  if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int i=0;
  char text[1000];
  scanf("%s",text);
  while(text[i]!=0){
    text[i] -= 3;
    if(text[i]<65){
      text[i] += 26;
    }
    i++;
  }
  printf("%s\n",text);
  return(0);
}

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

using namespace std;

#define int long long

template <typename T> T gcd(T m, T n) { return n == 0 ? m : gcd(n, m % n); }
template <typename T> T lcm(T m, T n) { return n * m / gcd(n, m); }
template <typename T> T fact(T n) { return (n == 0 ? 1 : n * fact(n - 1)); }
template <typename T> T modpow(T a, T e, T m) { return (e == (T)0 ? 1 : ((a % m) * modpow((a % m), e - 1, m)) % m); }

constexpr int MOD = 1e9 + 7;

const int MAX = 999999;

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 X;
int Y;

signed main(void) {
  int num;
  cin >> X >> Y;

  COMinit();

  // num = 0;
  // // X == 2 * Y || Y == 2 * X
  // // X == Y
  // // X + 1 == Y - 1 || X - 1 == Y + 1
  // // X + 1 == Y || Y + 1 == X
  // if (X == 2 * Y || Y == 2 * X) {
  //   num = 1;
  // } else if (X == Y && X % 2 == 1) {
  //   // (X - 1) C (X - 1) / 2
  // } else {
  //   num = 0;
  // }
  int i = 0, j = 0;

  int d;
  for (d = 0;; ++d) {
    if (X + d == 2 * (Y - d)) { break; }

    if (Y - d <= 0) {
      d = -1;
      break;
    }
  }
  // cout << d << endl;

  if (d == -1) {
    num = 0;
  } else {
    // combination
    // vector<int> numerator;   // 分子
    // vector<int> denominator; // 分母
    // int n = Y - d;

    // num = 1;
    // for (int i = 1; i <= d; ++i) {
    //   if ((n - i + 1) % i == 0) {
    //     int e = (n - i + 1) / i;
    //     if (e != 1) numerator.push_back(e);
    //   } else {
    //     numerator.push_back(n - i + 1);
    //     denominator.push_back(i);
    //   }
    // }

    // for (auto &e : denominator) { num /= e; }
    // num %= MOD;
    num = COM(Y - d, d);
  }

  cout << num << endl;
}

Measured memory_bytes: 23680
import java.util.*;

public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        String S = sc.next();
        if(S.charAt(0) == S.charAt(1) && S.charAt(1) == S.charAt(2)) {
        	System.out.println("No");
        }else {
        	System.out.println("Yes");
        }
	}
}


Measured memory_bytes: 35668
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
ll a[100005] ;


void Merge(ll a[],ll l, ll mid,ll r)
{
    int i,j,k ;
    ll n1 = mid-l+1;
    ll n2 = r-mid ;
    ll L[n1],R[n2];

    for(int i = 0 ; i < n1 ; i++)
    {
        L[i] = a[i+l] ;
    }
    for(int j = 0 ; j < n2 ; j++)
    {
        R[j] = a[j+mid+1] ;
    }
    i = 0, j = 0,k = l ;
    while(i < n1 && j < n2)
    {
        if(L[i] <= R[j])
        {
            a[k++] = L[i++];
        }
        else
        {
            a[k++] = R[j++] ;
        }
    }
    while(i < n1)
    {
        a[k++] = L[i++] ;
    }
    while(j < n2)
    {
        a[k++] = R[j++] ;
    }
}

void Merge_Sort(ll a[],ll l,ll r)
{
    if(l < r)
    {
        ll mid = l + (r-l)/2 ;
        Merge_Sort(a,l,mid);
        Merge_Sort(a,mid+1,r);
        Merge(a,l,mid,r) ;
    }
}


int main()
{

   ll n ;
   cin >> n ;
   memset(a,0,sizeof n);
   ll  cnt = 0 ;
   for(int i = 0 ; i < n ; i++)
   {
      cin >> a[i] ;
   }
   Merge_Sort(a,0,n-1) ;
   int cn1 = 0,cn2 = 0 ;
   for(int i = 0 ; i < n ; i++)
   {
       if(a[i] != a[i+1])
       {
           cn1++ ;
           cn2 = 0;
       }
       else
       {
           cn2++ ;
           if(cn2&1)
           {
               cn1-- ;
           }
           else
           {
               cn1++;
           }
       }
   }
   cout << cn1 << endl;
   return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

void solve()
{
    int N;
    cin >> N;
    string result;
    cin >> result;
    sort(result.begin(), result.end());

    REP0(i, N - 1)
    {
        string S, tmp;
        cin >> S;
        sort(S.begin(), S.end());
        set_intersection(S.begin(), S.end(),
                         result.begin(), result.end(),
                         inserter(tmp, tmp.end()));
        result.swap(tmp);
        tmp.clear();
    }

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

    cout << result << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
import numpy as np
def main():
    bingo = np.zeros((3,3))
    bingo[0,:] = np.array(list(map(int, input().split())))
    bingo[1,:] = np.array(list(map(int, input().split())))
    bingo[2,:] = np.array(list(map(int, input().split())))
    N = int(input())

    for i in range(N):
        bi = int(input())
        bingo -= (bingo==bi)*bi

    ans = "No"
    
    if sum(bingo[0,:])==0 : ans = "Yes"
    if sum(bingo[1,:])==0 : ans = "Yes"
    if sum(bingo[2,:])==0 : ans = "Yes"

    if sum(bingo[:,0])==0 : ans = "Yes"
    if sum(bingo[:,1])==0 : ans = "Yes"
    if sum(bingo[:,2])==0 : ans = "Yes"
    
    if bingo[0,0]+bingo[1,1]+bingo[2,2] ==0 : ans = "Yes"
    if bingo[2,0]+bingo[1,1]+bingo[2,0] ==0 : ans = "Yes"

    print(ans)

    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 12488
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
using namespace std;


const ll N   =  100005;
const ll mod = 1e9 + 7;


ll pw[60];
void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k;
  cin>>n;
  pw[0] =1;
  for (int i = 1; i < 60; ++i)
  {
  	pw[i] = 2*pw[i-1];
  }

  while(n>1)
  {
  	n/=2;
  	c++;
  	ans += pw[c];
  }
c(ans+1);
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  ll T=1;
  //cin>>T;
  while(T--){
  solve();
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
			int numN = scanner.nextInt();
			int numn;
			
            for(numn = 3; numn <= numN; numn++){

            	if (numn % 3 == 0){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 100 / 10 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 1000 / 100 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn % 10000 / 1000 == 3){
            		System.out.print(" "+numn);
            	}
            	else if(numn / 10000 == 3){
            		System.out.print(" "+numn);
            	}
            	else{
            	}
            }
            System.out.println();
	}
}

Measured memory_bytes: 28548
N = gets.to_i
M = Array.new(N+1, -1)
M[1] = 1
(2 .. N).each do |i|
  (2 .. N).find do|j|
    k = i ** j
    if k <= N
      M[k] = k
      false
    else
      true
    end
  end
end
puts M.max


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX = 1000;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
//setprecision(15)

#define MAX 1000000
int minf[MAX + 1];
int p[MAX + 1];

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

void sieve() {
	memset(minf, -1, sizeof(minf));
	for (int i = 2; i <= MAX; i++) {
		if (minf[i] != -1) continue;
		minf[i] = i;
		for (int j = i * 2; j <= MAX; j += i) {
			minf[j] = i;
		}
	}
}

int div(int n) {
	while (n != 1) {
		int d = minf[n];
		if (p[d] == 1) return 1;
		p[d] = 1;
		while (n % d == 0) n = n / d;
	}
	return 0;
}

int main() {
	sieve();
	memset(p, -1, sizeof(p));
	int N; cin >> N;
	int i;
	int pc_flg;
	vector<int> A(N);
	for (i = 0; i < N; i++) cin >> A[i];
	for (i = 0; i < N; i++) {
		int ret = div(A[i]);
		if (ret == 1) break;
	}
	if (i == N) {
		cout << "pairwise coprime" << endl;
		return 0;
	}
	int r = A[0];
	for (int i = 1; i < N; i++) {
		r = gcd(r, A[i]);
	}
	if (r == 1) {
		cout << "setwise coprime" << endl;
		return 0;
	}
	cout << "not coprime" << endl;
}

Measured memory_bytes: 14824
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int m=-1;
  int cnt=0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    cnt+=tmp;
    m=max(m, tmp);
  }
  cnt-=(m/2);
  cout << cnt << endl;
}

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

int main()
{

  int D,G;
  cin >> D >> G;
  int p[11],c[11];
  for(int i=0;i<D;i++)
  {
    cin >> p[i] >> c[i];
  }
  int ans = 1e9;
  for(int mask = 0;mask < (1<<D);++mask)
  {
    int s=0,num=0,rest_max=-1;

    for(int i=0;i<D;++i)
    {
      if(mask>>i & 1)
      {
        s += 100 * (i+1) * p[i] + c[i];
        num += p[i];
      }
      else
      {
        rest_max = i;
      }
    }

    if(s<G)
    {
      int s1 =100*(rest_max+1);
      int need = (G-s+s1-1)/s1;
      if(need >= p[rest_max])
      {
        continue;
      }
      num += need;
    }
    ans = min(ans,num);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 250

/* Global Variable */
int A[MAX+1];

int main() {
  int i, H;

  scanf("%d", &H);
  for ( i = 1; i <= H; i++ ) //1-origin
    scanf("%d", &A[i]);

  for ( i = 1; i <= H; i++ ) {
    printf("node %d: key = %d, ", i, A[i]);
    if ( i / 2 > 0 ) printf("parent key = %d, ", A[i / 2]);
    if ( 2 * i <= H ) printf("left key = %d, ", A[2 * i]);
    if ( 2 * i + 1 <= H ) printf("right key = %d, ", A[2 * i + 1]);
    printf("\n");
  }

    return 0;
}

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

int main(){

  unsigned long long int a,b,c,r,count,x,y;

  while(cin >> x >> y, x, y){
    count = 0;

    a = max(x,y);
    b = min(x,y);
    while(b!=0){

      c = a/b;
      r = a%b;
      a = b;
      b = r;

      count++;

    }

    cout << a << ' ' << count << endl;

  }
}

Measured memory_bytes: 1152
import numpy as np

s1=np.array(input().split(),dtype=np.int32)
s2=np.array(input().split(),dtype=np.int32)

M=[1,2,3,4,5,6,7,8,9,10,11,12]

m=s1[0]
idx=M.index(m)
if(s2[0]==M[(idx+1)%len(M)]):
    print(1)
else:
    print(0)

Measured memory_bytes: 21520
def main():
    N = int(input())
    *A, = map(int, input().split())

    ans = f(N, A)
    print(ans)


def f(N, A):
    ans = -float("inf")
    for i, a1 in enumerate(A):
        for j, a2 in enumerate(A):
            if i != j:
                ans = max(ans, abs(a1 - a2))

    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
// In the Name of Allah
// Ya Ali

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define F first
#define S second
#define all( x ) x.begin() , x.end()
#define pb push_back
#define mp make_pair
#define uniq( x ) sort( all( x ) ) , x.resize( unique( all( x ) ) - x.begin())

const int maxn = 2e5 + 10 ;
const int INF = 1e18 ;

int n , a , b , c , d , t , dp[ maxn ] ;
vector< int > vv ;

void solve()
{
 cin >> n >> a >> b >> c >> d ;

 for(int i = 1 ; i <= n ; i *= 2){
   for(int j = i ; j <= n ; j *= 3){
      for(int k = j ; k <= n ; k *= 5){
         vv.pb( n/k ) ;
         vv.pb( (n+k-1)/k ) ;
      }
   }
 }


 uniq( vv );

// cout << vv.size() << "\n" ;

 dp[ 0 ] = d ;
 for(int i = 1 ; i < vv.size() ; i ++){
   int x = vv[ i ];

   dp[ i ] = 9*INF ;

   long double xx = x , dd = d , check = 9e18 ;
   long double val = xx*dd ;
   if( val < check ){
     dp[ i ] = x*d ;
   }

   int x1 = x/2 , y1 = (x+1)/2 , dx1 = x%2 , dy1 = (2-(x%2))%2 ;
   int x2 = x/3 , y2 = (x+2)/3 , dx2 = x%3 , dy2 = (3-(x%3))%3;
   int x3 = x/5 , y3 = (x+4)/5 , dx3 = x%5 , dy3 = (5-(x%5))%5;

   int indx1 = lower_bound( all( vv ) , x1 ) - vv.begin() ;
   int indx2 = lower_bound( all( vv ) , x2 ) - vv.begin() ;
   int indx3 = lower_bound( all( vv ) , x3 ) - vv.begin() ;
   int indy1 = lower_bound( all( vv ) , y1 ) - vv.begin() ;
   int indy2 = lower_bound( all( vv ) , y2 ) - vv.begin() ;
   int indy3 = lower_bound( all( vv ) , y3 ) - vv.begin() ;

 //  if( indx1 == vv.size() || indx2 == vv.size() || indx3 == vv.size()|| indy1 == vv.size()|| indy2 == vv.size()|| indy3 == vv.size())
 //     cout << "NOOOOOOOo\n" ;

   dp[ i ] = min( dp[ i ] , dp[ indx1 ] + dx1*d + a ) ;
   dp[ i ] = min( dp[ i ] , dp[ indx2 ] + dx2*d + b ) ;
   dp[ i ] = min( dp[ i ] , dp[ indx3 ] + dx3*d + c ) ;
   dp[ i ] = min( dp[ i ] , dp[ indy1 ] + dy1*d + a ) ;
   dp[ i ] = min( dp[ i ] , dp[ indy2 ] + dy2*d + b ) ;
   dp[ i ] = min( dp[ i ] , dp[ indy3 ] + dy3*d + c ) ;

 }

// cout << vv[ vv.size()-1 ] << "\n" ;

 cout << dp[ vv.size()-1 ] << "\n" ;
}

signed main()
{
 ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);

 cin >> t ;

 while( t -- ){
  solve();
 }

    return 0;
}


Measured memory_bytes: 3820
n = int(input())
lst = list(enumerate(list(map(int, input().split()))))
 
sorted_lst = sorted(lst, key = lambda x: x[1])
left_next_index = list(range(-1, n - 1)) + [-1, -1]
right_next_index = list(range(1, n + 1)) + [n, n]
 
ans = 0
for i, p in sorted_lst:
    l2 = left_next_index[i]
    l1 = left_next_index[l2]
    r1 = right_next_index[i]
    r2 = right_next_index[r1]
    
    a = p * ((l2 - l1) * (r1 - i) + (r2 - r1) * (i - l2))
    ans += a
    
    left_next_index[r1] = l2
    right_next_index[l2] = r1
print(ans)

Measured memory_bytes: 26580
//Author : hardRock
//Problem Link :

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
//#include <bits/stdc++.h>

using namespace std;


int main() {

    //freopen("A.in","r",stdin);
    //freopen("A.out","w",stdout);

	string s;
	cin >> s;
	
	int val1 = 0, val2 = 0, cnt = 0;
	
	for(int i = 0; i < s.size(); ++i) {
		if(s[i] == 'A'){val1 = i; break;}
	}
	
	for(int i = s.size() - 1; i >= 0; --i) {
		if(s[i] == 'Z'){val2 = i; break;}
	}
	
	for(int i = val1; i <= val2; ++i) {
		cnt++;
	}
	
		
	cout << cnt << endl; 
	
	//system("pause");
    return 0;
}










Measured memory_bytes: 640
// AtCoder.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <math.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    bool valid = false;
    while(n > 0){
        if(n % 10 == 7) valid = true;
        n /= 10;
    }
    cout << (valid ? "Yes": "No") << endl;
    return 0;
}

Measured memory_bytes: 3576
#include<stdio.h>
int main(void){
	int a = 0;
	int b = 0;
	int x = 0;
	scanf("%d", &a);
	scanf("%d", &b);
	x = (b-1) / (a-1);
	if((b-1) % (a-1) != 0){
		x++;
	}
	printf("%d\n", x);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>

using namespace std;

int day(int year) //??´???????????¨??´?????\???????????????
{
	int sum = 0;
	
	if (year % 3 == 0) {
		sum = 200;
	}
	else {
		sum = 195;
	}


	return (sum);
}

int main(void)
{
	int n;
	int i, j;
	int day;
	int year; //?????¬?????¢????????????????????´
	vector <int> y(150), m(150), d(150);

	cin >> n;

	

	for (i = 0; i < n; i++) {
		cin >> y[i] >> m[i] >> d[i];
	}

	for (i = 0; i < n; i++) {
		day = 0;
		if (y[i] % 3 == 0) {
			day = day + (20 - d[i] + 1);
			day = day + (10 - m[i]) * 20;

		}
		else {
			if (m[i] % 2 != 0) {//?\???°
				day = day + (20 - d[i] + 1);
				day = day + ((10 - m[i])/ 2 + 1) * 19 + ((10 - m[i]) / 2) * 20;
				day = day + 5;


			}
			else {
				day = day + (19 - d[i] + 1);
				day = day + ((10 - m[i]) / 2) * 20 + ((10 - m[i]) / 2) * 19;
				day = day + 5;
			}


		}
		year = (1000 - y[i] - 1);

		day = day + (year / 3) * 200;
		day = day + (year - year / 3) * 195;

		

		

		cout << day << endl;
 

	}




	return (0);
}

Measured memory_bytes: 3052
N,C = map(int,input().split())
stc = sorted([list(map(int,input().split())) for i in range(N)], key = lambda x:(x[2],x[0]))
cnow = 0
tnow = 0
end = max(i[1] for i in stc)
imos = [0 for i in range(end+2)]
for s,t,c in stc:
    if cnow == c and tnow == s:
        imos[s]+=1
    else:
        imos[s-1] += 1
    imos[t] -=1
    cnow = c
    tnow = t
for i in range(end):
    imos[i+1] += imos[i]
print(max(imos))

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

int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n*3);
	for(int i = 0;i<n*3;i++)cin >> a[i];
	sort(a.begin(),a.end(),greater<ll>());
	ll ans = 0;
	for(int i = 1;i<=n*2;i+=2)
	{
		ans += a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#!/usr/bin/env ruby
# opt(i, c) = max{ h(ai) + opt(i+1, a), h(bi) + opt(i+1, b) }

n = STDIN.readline.strip.to_i
h = STDIN.read.split("\n").map{|l| l.split(' ').map(&:to_i)}

def opt(h)
  # puts "h:#{h}"
  m = []
  m[h.size-1] = h[-1]
  # puts "m:#{m}"
  (h.size-2).downto(0) do |i|
    m[i] = []
    [[1, 2], [0, 2], [0, 1]].each_with_index do |c, j|
      # puts "i:#{i}, c:#{c}, j:#{j}, m:#{m}"
      m[i][j] = c.map{|k| m[i+1][k] + h[i][j]}.max
    end
  end
  m[0].max
end

puts opt(h)


Measured memory_bytes: 28156
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;

int main(void) {
    int A,B; cin >> A >> B;
    string ans = "No";
    int i = 1;
    while (i < 4) {
        if ((A * B * i) % 2 == 1) ans = "Yes";
        i++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3552
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

ll dp[30][(1<<21)];
ll ma=1e9+7;
ll mod(ll a){
if(a>=0)
    return a;
else return -a;
}
int n;
int a[30][30];
ll fun(int p,int mask){
if(p==n && mask==0){
    return 1;
}
if(dp[p][mask]!=-1)
    return dp[p][mask];
ll x=0;
for(int i=0;i<n;i++){
    if((mask & (1<<i)) && a[p][i])
    {

        x=(x+fun(p+1,mask^(1<<i)))%ma;
    }
}
dp[p][mask]=x;
return x;


}



int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);

cin>>n;
memset(dp,-1,sizeof(dp));
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)
        cin>>a[i][j];
}
cout<<fun(0,(1<<n)-1)<<endl;


}


Measured memory_bytes: 491776
#include <stdio.h>

long max(long a,long b){
  if(a>=b){
    return a;
  }else{
    return b;
  }
}

long maximam(long a,long b,long c){
  if(a>=b && a>=c){
    return a;
  }else if(b>=a && b>=c){
    return b;
  }else{
    return c;
  }
}

int main(void){
  long N;
  scanf("%ld",&N);

  int point[N][3];
  long dp[N][3];

  for(int i = 0;i<N;i++){
    for(int j = 0;j<3;j++){
      scanf("%d",&point[i][j]);
    }
    for(int j = 0;j<3;j++){
      if(i != 0){
        switch(j){
          case 0:
            dp[i][j] = max(dp[i-1][1]+point[i][j],dp[i-1][2]+point[i][j]);
            break;
          case 1:
            dp[i][j] = max(dp[i-1][0]+point[i][j],dp[i-1][2]+point[i][j]);
            break;
          case 2:
            dp[i][j] = max(dp[i-1][0]+point[i][j],dp[i-1][1]+point[i][j]);
            break;
        }
      }else{
        for(int k = 0;k<3;k++){
          dp[i][k] = point[i][k];
        }
      }
    }
  }

  printf("%ld\n",maximam(dp[N-1][0],dp[N-1][1],dp[N-1][2]));
  return 0;
}

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

using ll = long long;
using ld = long double;

const int N = 1e5;
const ll MOD = 1e9 + 7;

ll fac[2 * N + 69], ifac[2 * N + 69];

ll binpow(ll a, ll b) {
  ll ret = 1;
  while(b) {
    if(b & 1) ret = ret * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return ret;
}

ll inv(ll a) {
  return binpow(a, MOD - 2);
}

ll C(int a, int b) {
  if(a < b || a < 0 || b < 0) return 0;
  ll ret = fac[a];
  ret = (ret * ifac[b]) % MOD;
  ret = (ret * ifac[a - b]) % MOD;
  return ret;
}

void solve() {

  fac[0] = 1;
  for(int i = 1; i <= 2 * N; i++) fac[i] = (fac[i - 1] * i % MOD);
  ifac[2 * N] = inv(fac[2 * N]);
  for(int i = 2 * N - 1; i >= 0; i--) ifac[i] = (ifac[i + 1] * (i + 1)) % MOD;

  int h, w, a, b;
  cin >> h >> w >> a >> b;
  ll ans = 0;
  for(int i = 0; i < w - b; i++) {
    ans = (ans + C(a + w - b - 2 - i, a - 1) * C(h - a + b - 1 + i, h - a - 1)) % MOD;
  }
  cout << ans << '\n';
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);

  int TC = 1;
  // cin >> TC;
  for(int i = 1; i <= TC; i++) {
    // cout << "Case #" << i << ": ";
    solve();
  }
  
  return 0;
}

Measured memory_bytes: 6796
#include <stdio.h>
#include <string.h>
int main(){
  int n,i;
  char s[101],t[101];
  scanf("%d%s%s",&n,s,t);
  for(i=n;i;i--)if(!(strncmp(&s[n-i],t,i)))break;
  printf("%d",n*2-i);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>

using namespace std;
using lli = long long int;

int main(void){
    int a,b;
    cin >> a >> b;
    int total = (a+b)/2;
    if((a+b)%2==1 )total++;
    cout << total << endl;
}


Measured memory_bytes: 256
N = input() 
l = [int(i) for i in raw_input().split()]
dp = [0] * N
dp [1] = abs(l[0] - l[1])
for i in range(2, N):
  dp [i] = min(dp [i - 1] + abs(l [i] - l [i - 1]), dp [i - 2] + abs(l [i] - l [i - 2]))
print dp [N - 1]

Measured memory_bytes: 12184
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
const long long INF = 1LL << 60;
const int inf = 1e9;
ll mod = 1e9 + 7;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    if (s[n - 1] == '2' || s[n - 1] == '4' || s[n - 1] == '5' || s[n - 1] == '7' || s[n - 1] == '9')
    {
        cout << "hon" << endl;
    }
    else if (s[n - 1] == '3')
    {
        cout << "bon" << endl;
    }
    else
    {
        cout << "pon" << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
int main () {
  int n;
  scanf("%d", &n);
  ld ans = 0;
  FOR(i, 1, n) {
    int t; scanf("%d", &t);
    ans += 1.0 / (ld)t;
  }
  ans = 1.0 / ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long ll;

bool notprime[100000];
vector<int> p;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	for(int i=2;i<100000/2;i++){
		if(!notprime[i]){
			p.push_back(i);
			for(int j=i+i;j<100000/2;j+=i){
				notprime[j]=1;
			}
		}
	}
	while(1){
		int m,a,b; cin >> m >> a >> b;
		if(m==0&&a==0&&b==0)break;
		int l=2,r=2;
		int ma=4;
		for(int i=0;i<p.size();i++){
			if(p[i]*2>m)break;
			for(int j=i;j>=0;j--){
				if(p[i]*p[j]>m)continue;
				if(p[i]*p[j]<ma)break;
				if(a*p[i]<=b*p[j]){
					if(ma<p[i]*p[j]&&p[i]*p[j]<=m){
						ma=p[i]*p[j];
						l=p[j];
						r=p[i];
					}
				}else break;
			}
		}
		cout << l << " " << r << endl;
	}
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  rep(i,n) cin>>a[i];
  rep(i,n)cin>>b[i];
  rep(i,n-1)cin>>c[i];
  int prev=-1;
  int s=0;
  rep(i,n) {
    s+=b[a[i]-1];
    //cout << b[a[i]-1]<<endl;
    if(prev==a[i]-1) {
      s+=c[prev-1];
      //cout << c[prev-1]<<endl;
    }
    prev=a[i];
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n, a;
  cin >> n;
  if(n/100 > n/10%10 || (n/100 == n/10%10 && n/100 >= n%10))
    a = n/100;
  else a = n/100+1;
  cout << a << a << a << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int k;
  string s;
  cin >> k;
  cin >> s;

  string ans = "";
  if ( s.size() <= k ) {
    cout << s << endl;
  }else {
    rep (i,k) {
      ans += s[i];
    }
    ans += "...";
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 2e5; int n, m;

int parent[maxN];
int root(int u)
{
  return parent[u] < 0 ? u : parent[u] = root(parent[u]);
}
void merge(int u, int v)
{
  if ((u = root(u)) == (v = root(v))) return;
  if (parent[u] > parent[v]) swap(u, v);
  parent[u] += parent[v];
  parent[v] = u;
}

int main()
{
  while (scanf("%d %d", &n, &m) != EOF)
  {
    memset(parent, -1, sizeof(parent));
    for (int i = 0; i < m; i++)
    {
      int u, v; scanf("%d %d", &u, &v); u--, v--;
      merge(u, v);
    }

    map<int, set<int>> groups;
    list<list<int>> ans;
    for (int i = 0; i < n; i++)
      groups[root(i)].insert(i);

    while (!groups.empty())
    {
      list<int> now;
      list<int> toRemove;
      for (auto &g: groups)
      {
        now.push_back(*g.second.begin());
        g.second.erase(g.second.begin());
        if (g.second.empty())
          toRemove.push_back(g.first);
      }
      ans.push_back(now);
      for (int i: toRemove)
        groups.erase(i);
    }

    printf("%d\n", (int)ans.size());
  }
  return 0;
}

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

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

    long long a, b, c, k;
    cin >> a >> b >> c >> k;

    long long ans = 0;
    ans += max(0LL, min(k, a));
    k -= a;

    k -= b;

    ans += -1 * max(0LL, min(k, c));
    k -= c;

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>

//構造体の宣言
typedef struct Card{
	char mark;	//絵柄
	int value;	//数字
}Card;

int main(){
	int N;	//カードの枚数
	int flag = 1;		//フラグ
	int stbflag = 1;	//安定な出力か調べるためのフラグ
	Card s;				//ソート用変数
	int index = 0;		//未ソート部分の先頭インデックス
	int minj;			//最小値の位置（選択ソート用）
	
	//要素数の入力
	scanf("%d%*c",&N);
	
	Card Ab[N];	//バブルソート用の配列
	Card As[N];	//選択ソート用の配列
	
	//まずはバブルソート用の配列へ入力
	for(int i = 0;i < N;i++){
		scanf("%c%d%*c",&Ab[i].mark,&Ab[i].value);
	}
	
	//それを選択ソート用の配列へコピー
	memcpy(As,Ab,sizeof(Ab));
	
	//バブルソート
	while(flag){
		flag = 0;
		for(int j = N - 1;j >= index + 1;j--){
			
			if(Ab[j].value < Ab[j - 1].value){
				//交換
				s = Ab[j];
				Ab[j] = Ab[j - 1];
				Ab[j - 1] = s;
				//フラグ処理
				flag = 1;
			}
		}
		//インデックスを後ろにずらす
		index++;
	}
	
	//配列の出力
	for(int i = 0;i < N;i++){
		if(i == N - 1){
			printf("%c%d\n",Ab[i].mark,Ab[i].value);
		}
		else{
			printf("%c%d ",Ab[i].mark,Ab[i].value);
		}
	}
	
	printf("Stable\n");
	
	//選択ソート
	for(int i = 0;i < N;i++){
		//最小値の位置を初期化
		minj = i;
		
		//minjから最後までの最小値の位置を求める
		for(int j = i;j < N;j++){
			if(As[j].value < As[minj].value){
				minj = j;
			}
		}
		//交換が行われるとき
		if(minj != i){
			//交換
			s = As[i];
			As[i] = As[minj];
			As[minj] = s;
		}
	}
	
	//配列の出力
	for(int i = 0;i < N;i++){
		if(i == N - 1){
			printf("%c%d\n",As[i].mark,As[i].value);
		}
		else{
			printf("%c%d ",As[i].mark,As[i].value);
		}
		
		//バブルソートと照合する
		if(!(Ab[i].mark == As[i].mark && Ab[i].value == As[i].value)){
			stbflag = 0;
		}
	}
	
	//安定な出力だった場合
	if(stbflag){
		printf("Stable\n");
	}
	//そうでなかった場合
	else{
		printf("Not stable\n");
	}
	
	return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <string.h>

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

using namespace std;

int main()
{

	while(true)
	{
		int x[102];
		memset(x,0,sizeof(x));
		int a,b;
		while(cin >> a >> b && a && b)
		{
			x[a]++;
			x[b]++;
		}

		if(cin.eof()) break;

		int count = 0;
		rep(i,102)
		{
			if(x[i]%2 == 1) count++;
		}

		if(count == 2)
		{
			if(x[1]%2 == 1 && x[2]%2 == 1)
			{
				cout << "OK" << endl;
			}
			else
			{
				cout << "NG" << endl;
			}
		}
		else
		{
			cout << "NG" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1156
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
int a,b;
cin>>a>>b;
int c=a+b;
if(c%2==0) cout<<c/2<<endl;
else cout<<(c+1)/2<<endl;
}

Measured memory_bytes: 256