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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  int n,m;
  while(true){
      cin>>n;
      if(n==0) break;
      std::vector<P> v;
      for(int i=0;i<n;i++){
          int h,r;cin>>h>>r;
          v.push_back(P(h,r));
      }
      cin>>m;
      for(int i=0;i<m;i++){
          int h,r;cin>>h>>r;
          v.push_back(P(h,r));
      }
      v.push_back(P(0,0));
      sort(v.begin(),v.end());
      ll dp[n+m+1]={};
      for(int i=1;i<=n+m;i++){
          for(int j=0;j<i;j++){
              int h1=v[i].first,r1=v[i].second,h2=v[j].first,r2=v[j].second;
              if(h2<h1&&r2<r1){
                  dp[i]=max(dp[i],dp[j]+1);
              }
          }
      }
      ll res=-1;
      for(int i=1;i<=n+m;i++)res=max(res,dp[i]);
          cout<<res<<endl;
  }
}

Measured memory_bytes: 3152
#include <iostream>
#include <iomanip>
using namespace std;
  
int main() {
   	int n;
  	cin>>n;
  	
  	for (int i=1;i<=n;i++){
    	if(i%3==0 || i%10==3 || (i/10)%10==3 ||(i/100)%10==3 || (i/1000)%10==3){
        	cout<<" "<<i;
        }
    }
  cout<<endl;
}
 


Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
#include<map>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n, k,x,y;
	cin >> n >> k;
	vector<int> minus, plus;
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		if (x >= 0) plus.push_back(x);
		else minus.push_back(x);
	}
	sort(plus.begin(), plus.end());
	sort(minus.begin(), minus.end(), greater<int>());
	
	for (int i = 0; i < 100001; i++)
	{
		plus.push_back(1000000000);
		minus.push_back(-1000000000);
	}

	int ans = INF,temp;

	ans = min(ans, plus[k - 1]);
	ans = min(ans, abs(minus[k - 1]));

	for (int i = 0; i < k; i++)
	{
		x = plus[k - 2-i];
		y = abs(minus[i]);
		temp = min(x, y) * 2 + max(x, y);
		ans = min(ans, temp);
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;
const int MAXN=505;
int n,m;
char a[MAXN][MAXN],b[MAXN][MAXN],dat[MAXN][MAXN];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%s",dat[i]+1);
	for(int i=1;i<=n;i++)
	{
		a[i][1]=b[i][m]='#';
		if(i&1) for(int j=2;j<=m-1;j++) a[i][j]='#';
		else for(int j=2;j<=m-1;j++) b[i][j]='#';
	}
	
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			a[i][j]=(dat[i][j]!='#'&&a[i][j]!='#')?'.':'#',
			b[i][j]=(dat[i][j]!='#'&&b[i][j]!='#')?'.':'#';
	for(int i=1;i<=n;i++) printf("%s\n",a[i]+1);
	puts("");
	for(int i=1;i<=n;i++) printf("%s\n",b[i]+1);
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#define MAXN 32

using namespace std;

const int infty = 1<<24;

int dfs(int now, int n, int par[MAXN], bool vis[MAXN], bool leaf[MAXN], int W[MAXN][MAXN]){
  int ret = 0;
  int cnt = 0;
  vis[now]=true;
  for(int i = 0; i < n; ++i){
    if(W[now][i]>0 && !vis[i]){
      ret += 2*W[now][i];
      ++cnt;
      par[i]=now;
      ret += dfs(i,n,par,vis,leaf,W);
      if(leaf[i])
	ret -= 2*W[now][i];
    }
  }
  if(cnt==0)leaf[now]=true;
  return ret;
}

int solve(int n, int W[MAXN][MAXN]){
  int ret = infty;
  for(int i = 0; i < n; ++i){
    bool leaf[MAXN]={false,};
    bool vis[MAXN]={false,};
    int par[MAXN];
    int D = dfs(i,n,par,vis,leaf,W);

    int path0child = -1;
    if(i!=0){
      int c = 0;
      int p = par[c];
      while(true){
	if(!leaf[c]){
	  D -= W[c][p];
	}
	if(p==i){path0child=c;break;}
	c = p;
	p = par[c];
      }
      if(leaf[0]){
	D += W[par[0]][0];
      }
    }

    int maxD = 0;
    for(int j = 0; j < n; ++j){
      if( !leaf[j] && W[i][j] > 0 && j != path0child ){
	maxD = max(maxD, W[i][j]);
      }
    }
    
    ret = min( ret, D - maxD );
  }
  return ret;
}

int main()
{
  while(true){
    int n;
    int W[MAXN][MAXN]={{0,},}; // 0 means unconnected
    cin >> n;
    //cout << n << endl;
    if( n == 0 ) break;
    for(int i = 0; i < n-1; ++i){
      int a,b,t;
      cin >> a >> b >> t;
      --a;--b;
      W[a][b] = W[b][a] = t;
    }
    cout << solve(n,W) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
from math import comb
mod = 10 ** 9 + 7
n, a, b = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)
print(sum(v[:a]) / a)
if v[0] != v[a - 1]:
    cur = v[a - 1]
    cnt = 0
    for i in range(n):
        if cur == v[i]:
            cnt += 1
    cnt2 = 0
    for i in range(a):
        if cur == v[i]:
            cnt2 += 1
    print(comb(cnt, cnt2))
else:
    cur = v[a - 1]
    cnt = 0
    for i in range(n):
        if cur == v[i]:
            cnt += 1
    ans = 0
    for i in range(a, b + 1):
        ans += comb(cnt, i)
    print(ans)

Measured memory_bytes: 9148
n,m=map(int,input().split())
h=list(map(int,input().split()))
ans=[1]*n
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    if h[a]<h[b]:
        ans[a]=0
    elif h[b]<h[a]:
        ans[b]=0
    else:
        ans[a]=0
        ans[b]=0
print(sum(ans))

Measured memory_bytes: 20140
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
using namespace std;
const int maxn=200010;
int n,tr[maxn][2],bg[maxn],tot=1;ll L;
bool num[100];
char s[maxn];
int lowbit(ll x)
{
	int r=0;
	for(;!(x&1);r++,x>>=1);
	return r;
}
void ins(int v,int id,int d,int len)
{
	if(tr[v][s[bg[id]+d-1]-'0']==0) 	tr[v][s[bg[id]+d-1]-'0']=++tot;
	if(d!=len) ins(tr[v][s[bg[id]+d-1]-'0'],id,d+1,len);
}
void dfs(int v,int d)
{
	for(int k=0;k<=1;k++)
		if(tr[v][k]==0) {if(L-d>0) num[lowbit(L-d)]^=1;}
		else dfs(tr[v][k],d+1);
}
int main()
{
	scanf("%d%lld",&n,&L);
	int top=0;
	for(int i=1;i<=n;i++)
	{
		bg[i]=top+1;
		scanf("%s",s+bg[i]);
		top+=strlen(s+bg[i]);
		ins(1,i,1,strlen(s+bg[i]));
	}
	dfs(1,0);
	for(int i=0;i<=60;i++) if(num[i]) {puts("Alice");return 0;}
	puts("Bob");
	return 0;
}

Measured memory_bytes: 5760
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nexString() string {
	sc.Scan()
	return sc.Text()
}

type restaurant struct {
	number   int
	cityName string
	point    int
}
type restaurants []restaurant

func (a restaurants) Len() int      { return len(a) }
func (a restaurants) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a restaurants) Less(i, j int) bool {
	if a[i].cityName == a[j].cityName {
		return a[i].point > a[j].point
	}
	return a[i].cityName < a[j].cityName
}

func guide(rs restaurants) []int {
	sort.Sort(rs)
	ints := make([]int, len(rs))
	for i, v := range rs {
		ints[i] = v.number
	}
	return ints
}

func main() {
	n := nextInt()
	rs := make(restaurants, n)
	for i := 0; i < n; i++ {
		rs[i] = restaurant{i + 1, nexString(), nextInt()}
	}
	for _, v := range guide(rs) {
		fmt.Println(v)
	}
}


Measured memory_bytes: 640
input=gets.chomp.split()
a=input[0].to_i
b=input[1].to_i
c=input[2].to_i
n=input[3].to_i

count=0
sum=0

i = n / c

while i >= 0
  j = (n - (c * i)) / b
  while j >= 0
    k = (n - (c * i) - (b * j)) / a
    sum = (c * i) + (b * j) + (a * k)
    if sum == n
      count += 1
    end
    j -= 1
  end
  i -= 1
end

puts count


Measured memory_bytes: 1788
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<math.h>
#define m 1000000007
using namespace std;
/*long long kum(long long a,long long b)
{
	long long  t = a;
	if(b == 1)
	return a;
	if(b%2 == 0)
	t=kum(a,b/2)*kum(a,b/2)%m;
	else
	t=kum(a,b/2)*kum(a,b/2)*a%m;
	return t%m;
}*/
int main()
{
	int a[100050];
	int n;
	scanf("%d",&n);
	int pos = 0;
//	for(int i = 1; i <= n; i++)
//		a[i] = abs(n - 2 * i +1);
	for(int i = 0; i < n; i++)
	{
		scanf("%d",&a[i]);
		if(a[i] == 0)
		pos++;
	}
	int ans = 0;
	int flag = 0;
	int sum;
	sort(a,a+n);
	for(int i = 0; i< n; i+=2)
	{
		if(a[i] == 0)
		{
			i--;
			continue;
		}
		if(a[i] == a[i+1])
		ans++;
		else
		{
			flag = 1;
			break;
		}
	}
	long long sum2=1;
	for(int i = 0; i < ans; i++)
		sum2 = sum2 % m * 2 % m;
	if(flag == 1 | pos > 1 )
	printf("0");
	else
	printf("%lld",sum2);
	return 0;
}

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


int main(){
	long long int  n,p;
	cin >> n >> p;
	long long int testP=p;
	long long int ans=1;
	if(n==1){
		cout << p <<endl;
		return 0;
	}
	for(long long int i=2;i<2000000;i++){
		testP=p;
		bool flag=true;
		for(long long int j=0;j<n;j++){
			if(testP%i==0){
				testP=testP/i;
			}else{
				flag=false;
				break;
			}
		}if(flag==true){
			ans=i;
		}
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp(aa,bb) make_pair(aa,bb)
#define _for(i,b) for(int i=(0);i<(b);i++)
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,b,a) for(int i=(b);i>=(a);i--)
#define mst(abc,bca) memset(abc,bca,sizeof abc)
#define X first
#define Y second
#define lowbit(a) (a&(-a))
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef long double ld;
const int N=100010;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const double eps=1e-6;

inline __int128 read()
{
    __int128 x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}

inline void write(__int128 x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
        write(x/10);
    putchar(x%10+'0');
}

void solve(){
	__int128 x=read(),k=read(),d=read();
	if(x<0) x=-x;
	if(x-k*d>=0) write(x-k*d);
	else{
		__int128 t1=x%d;
		__int128 p=x/d;
		k-=p;
		__int128 t2=d-t1;
		if(k%2==0) write(t1);
		else write(t2);
	}
}


int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("F:/laji/1.in", "r", stdin);
//	freopen("F:/laji/2.out", "w", stdout);
#endif
//	int t;cin>>t;while(t--)
	solve();
    return 0;
}



Measured memory_bytes: 3656
#include<stdio.h>
#include<math.h>

int isprime(int x);

int main()
{
  int count=0,i,n,a[10000];
  
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&a[i]);
  }
 
  for(i = 0; i < n;i++){
    if(isprime(a[i]) == 1)count++;
  }
  printf("%d\n",count);

  return 0;
}

int isprime(int x){
  int i;
  if(x == 2)return 1;

  if(x < 2 || x%2 == 0)return 0;

  i = 3;
  while(i <= sqrt(x)){
    if(x % i == 0)return 0;
    i += 2;
  }

  return 1;
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
     cin>>a>>b;


       if(b > 1)
      {
      int count=1,sum=a;
       while(sum < b)
       {
          count++;
           sum+=a;
           sum--;
       }
         cout<<count;
     }
      else
      cout<<"0";
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: u8 = read_as_vec()[0];
    let mut s = read_as_string().bytes().collect::<Vec<u8>>();

    let bias = 65;

    for i in 0..s.len(){
        s[i] -= bias;
    }

    for i in 0..s.len(){
        s[i] = (s[i] + n)%26;
    }

    for i in 0..s.len(){
        s[i] += bias;
    }

    let ans = s.into_iter().map(|x| x as char).collect::<String>();

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;

template<typename T>
class BIT {
    public:
    int n;
    vector<T> dat; // i: [1,n]

    BIT(int size): n(size+1), dat(vector<T>(n+1)) {}

    void add(int i, T x) {
        while (i <= n) {
            dat[i] += x;
            i += i & -i;
        }
    }

    T sum(int i) {
        T ret = 0;
        while (i > 0) {
            ret += dat[i];
            i -= i & -i;
        }
        return ret;
    }

    T range(int l, int r) {
        return sum(r) - sum(l-1);
    }
};

template<typename T>
ll inversion(vector<T> v, string op) {
    assert(op == "<=" || op == ">=" || op == ">" || op == "<");
    if (op == ">=" || op == "<") {
        reverse(all(v));
    }

    ll size = v.size();
    vector<pair<T, int>> vp(size);
    rep(i,size) {
        vp[i] = {v[i],i};
    }
    sort(all(vp));

    // 小さい順に 1..size の連番を振る
    vector<int> order(size);
    rep(i,size) {
        order[vp[i].second] = i+1;
    }

    // i < j, order[i] <= order[j] の個数を数える
    ll result = 0;
    BIT<int> bt(size);
    rep(i,size){
        result += bt.sum(order[i]);
        bt.add(order[i], 1);
    }

    if (op == ">" || op == "<") {
        return size*(size-1)/2 - result;
    } else {
        return result;
    }
}

ll n;
vector<int> a;

bool check(int x) {
    vector<int> b(n);
    rep(i,n){
        b[i] = (a[i] >= x ? +1 : -1);
    }
    vector<ll> s(n+1);
    rep(i,n){
        s[i+1] = s[i] + b[i];
    }
    return (n*(n+1)/2 + 1)/2 <= inversion(s, "<=");
}

int main(void) {
    cin >> n;
    a.resize(n);
    vector<int> meds(n);

    rep(i,n){
        cin >> a[i];
        meds[i] = a[i];
    }
    sort(all(meds));
    int l = 0, r = n;
    while (l + 1 < r) {
        int mid = (l+r)/2;
        if (check(meds[mid])) {
            l = mid;
        } else {
            r = mid;
        }
    }
    cout << meds[l] << endl;
    return 0;
}


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

int main(){
	int n;
	cin>>n;
	
	int min;
	int input;
	cin>>min;
	cin>>input;
	int maximumProfit = input - min; 
	if(min>input){
			min = input;
		}
	
	for(int i=2;i<n;i++){
		cin>>input;
		
		if( (input-min) > maximumProfit ){
			maximumProfit=input-min;
		}
		if(min>input){
			min = input;
		}
	}
	
	
	cout<<maximumProfit<<endl;
	return 0;
}

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

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; cout << "i=  ";for(ll i=0; i<num; i++) cout << i << "   ";cout << endl;  
  cout << "    ";
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<"   ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<"   ";}
  cout << endl;
}

// template <typename T>
// void print_pairvec(const vector<T> &v, ll num=0){
//   if(num == 0) num = (ll)v.size();
//   cout << endl; for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
// }
template <typename T>
void print_pairvec(const T &_pair, ll num=0){
  cout << endl; for(pair<ll, int> x: _pair){ cout << x.first << " " << x.second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

  

int main(){
  int K;
  cin >> K;
  string rep = "ACL";
  string ans;
  for(int i=0; i<K; i++) ans += rep;
  cout << ans << endl;

  return 0;
  // cout << fixed;//小数点を確実に10桁で表示するためのもの
  // cout << setprecision(10); 
}


Measured memory_bytes: 3660
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

//prototype declaration
int getint();
long long getllint();
double getdint();
char getch();
void setstring(char *s);
void showint(int i);
void showllint(long long i);
void showdint(double i);
void showchar(char c);
void showstring(char *s);

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main(void) {
	int n, i = 1;
	n = getint();
	if (n == 1 || n == 2 || n == 3 || n == 5 || n == 6 || n == 9 || n == 10 || n == 13 || n == 17) {
		showstring("No");
	} else {
		showstring("Yes");
	}
	return 0;
}

int getint() {
	int i;
	scanf("%d", &i);
	return i;
}

long long getllint() {
	long long i;
	scanf("%lld", &i);
	return i;
}

double getdint() {
	double i;
	scanf("%lf", &i);
	return i;
}

char getch() {
	char c;
	scanf("%c", &c);
	return c;
}

void setstring(char *s) {
	scanf("%s", s);
}

void showint(int i) {
	printf("%d\n", i);
}

void showllint(long long i) {
	printf("%lld\n", i);
}

void showdint(double i) {
	printf("%lf\n", i);
}

void showchar(char c) {
	printf("%c\n", c);
}

void showstring(char *s) {
	printf("%s\n", s);
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> tab(H, vector<char>(W));
  vector<int> row(H, 0);
  vector<int> col(W, 0);
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> tab.at(i).at(j);
      if(tab.at(i).at(j) == '#'){
        row.at(i) = 1;
        col.at(j) = 1;
      }
    }
  }

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(row.at(i)==1 && col.at(j)==1) cout << tab.at(i).at(j);
    }
    if(row.at(i)==1) cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
void prnt(int a[][3],int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        cout<<a[i][j]<<' ';
    }
    cout<<endl;
}
int main()
{
    int n;
    cin>>n;
    int l[n][3];
    int i,j;
    for(i=0;i<n;i++)
       for(j=0;j<3;j++)
          cin>>l[i][j];
    //prnt(l,n);
    int memory[n][3];
    memory[0][0]=l[0][0];
    memory[0][1]=l[0][1];
    memory[0][2]=l[0][2];
    for(i=1;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            if (j==0)
                memory[i][j]=max({memory[i-1][1]+l[i][j],memory[i-1][2]+l[i][j]});
            else if(j==1)
                memory[i][j]=max({memory[i-1][0]+l[i][j],memory[i-1][2]+l[i][j]});
            else
                memory[i][j]=max({memory[i-1][0]+l[i][j],memory[i-1][1]+l[i][j]});
        }
    }
    //prnt(memory,n);
    cout<<max({memory[n-1][0],memory[n-1][1],memory[n-1][2]})<<endl;
}

Measured memory_bytes: 5968
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

t22 = c12+c21-c11
t32 = t22+c31-c21
t23 = t22+c13-c12
t33 = t23+t32-t22
t = [t22,t23,t32,t33]
c = [c22,c23,c32,c33]
flag = True
for i in range(0,4):
    if t[i]!=c[i]:
        flag = False

if flag==True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rept(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}

void yes() {
	cout << "Yes" << endl;
}

void no() {
	cout << "No" << endl;
}

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

	int count = 0;
	
	rept(i, ((s.size()) / 2) ) {
		if (s[i] != s[s.size() - 1 - i])count++;
	}

	cout << count << endl;

	system("pause");
	return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

bool notPrime[312345] = {};

int main(void){
	notPrime[0] = notPrime[1] = 1;
	FOR(i, 2, 312345){
		if(!notPrime[i]){
			for(int32 j = 2;i*j < 312345;j++){
				notPrime[i*j] = 1;
			}
		}
	}

	int32 n;
	while(cin >> n && n){
		int32 cnt = 0;
		FOR(i, n+1, 2*n+1){
			cnt += !notPrime[i];
		}
		cout << cnt << endl;
	}
}


Measured memory_bytes: 3380
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int r,g,b;
  cin>>r>>g>>b;
  cout<<((g*10+b)%4==0?"YES":"NO")<<endl;
  return 0;
}


Measured memory_bytes: 764
#include <cstdio>

using namespace std;

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

int main()
{
  long long a, b;
  while (scanf(" %lld %lld ", &a, &b) == 2) {
    printf("%lld %lld\n", gcd(a, b), a * b / gcd(a, b));
  }
}

Measured memory_bytes: 0
N = int(input())

res = [0] * N


for x in range(1, 102):
    for y in range(1, 102):
        for z in range(1, 102):
            t1 = (x + y + z) ** 2

            if t1 > 15000:
                break

            n = t1 - x * y - y * z - z * x - 1
            
            if n >= N or n < 0:
                break
            res[n] += 1

for o in res:
    print(o)

Measured memory_bytes: 9304
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 2e5 + 7;
int a[MAXN], k;
ll sum[MAXN];
vector<int>vec;
vector<int>v[MAXN];
int id(int x) {return lower_bound(vec.begin(), vec.end(), x) - vec.begin();}
int main()
{
    int n, k; scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) 
    {
        scanf("%d", &a[i]);
        sum[i] = sum[i - 1] + a[i] - 1;
        sum[i] %= k;
        vec.push_back(sum[i]);
    }
    vec.push_back(0);
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    ll ans = 0;
    v[0].push_back(0);
    for (int i = 1; i <= n; i++)
    {
        int index = id(sum[i]);
        int p = upper_bound(v[index].begin(), v[index].end(), i - k) - v[index].begin();
        ans += (int)v[index].size() - p;
        v[index].push_back(i);
    }
    printf("%lld\n", ans);
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;

const int M = 1000000007, BIG = 0x3f3f3f3f;

int n;
string s;

int Process() {
  int ans = 0;
  int i = 0, j = n - 1;
  while (i < j) {
    while (i < n && s[i] == 'R')
      i++;
    while (j >= 0 && s[j] == 'W')
      j--;
    if (i >= j)
      break;
    ans++;
    i++;
    j--;
  }
  return ans;
}

void Output() { cout << Process() << "\n"; }

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

  while (cin >> n) {
    cin >> s;

    Output();
  }

  return 0;
}

Measured memory_bytes: 3708
use proconio::input;

fn main() {
    input! {
        n: usize,
        d: [u32; n]
    }

    solve(n, &d);
}

fn solve(n: usize, d: &[u32]) {
    let mut sum = 0;
    for i in 0..n {
        for j in (i + 1)..n {
            sum += d[i] * d[j];
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 2128
N, K = map(int, input().split())
A = list(map(int, input().split()))
mod = 1000000007

ans = 0
for i in range(len(A)):
    cnt1 = 0
    cnt2 = 0
    for j in range(i, i+len(A)):
        if A[i] > A[j%(len(A))]:
            if j < len(A):
                cnt1 += 1
            else:
                cnt2 += 1
    ans += (cnt1 * K * (K+1) // 2)
    ans += (cnt2 * (K-1) * K // 2)
    ans %= mod
print(ans)

Measured memory_bytes: 3188
#include <stdio.h>

int H, W;
char a[10][10];

int dfs(int x, int y){
    if(x >= H || y >= W || a[x][y] == '.') return 0;
    a[x][y] = '.';
    if(x == H-1 && y == W-1){
        for(int i=0; i<H; i++) for(int j=0; j<W; j++) if(a[i][j] == '#') return 0;
        return 1;
    }
    if(dfs(x+1, y)) return 1;
    if(dfs(x, y+1)) return 1;
    a[x][y] = '#';
    return 0;
}

int main(){
    scanf("%d%d", &H, &W);
    for(int i=0; i<H; i++) scanf("%s", a[i]);
    if(dfs(0, 0)) printf("Possible");
    else printf("Impossible");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 998244353;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}


int main(){
    ll n; cin >> n;
    string s;cin >> s;
    vector<ll> table(3*n,0);
    ll r = 0,g = 0,b = 0;
    rep(i,3*n){
        if(s[i] == 'R'){
            if(max({r,g,b}) == r)table[i] = 1;
            else if(r < g && r < b)table[i] = 3;
            else table[i] = 2;
            r++;
        }
        if(s[i] == 'G'){
            if(max({r,g,b}) == g)table[i] = 1;
            else if(g < r && g < b)table[i] = 3;
            else table[i] = 2;
            g++;
        }
        if(s[i] == 'B'){
            if(max({r,g,b}) == b)table[i] = 1;
            else if(b < r && b < g)table[i] = 3;
            else table[i] = 2;
            b++;
        }
    }
    vector<ll> dp(3,0);
    dp[0] = n;
    ll ret = 1;
    rep(i,3*n){
        // debug(i);
        // print(dp);
        ret *= dp[table[i]-1];
        ret %= MOD;
        dp[table[i]-1]--;
        if(table[i] < 3)dp[table[i]]++;
    }

    // print(table);

    cout << ret % MOD << endl;
}

Measured memory_bytes: 3076
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    if (n % 2 == 1) {
        puts("No");
        return 0;
    }
    else {
        n >>= 1;
        REP(i, n) {
            if (s[i] != s[i + n]) {
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define r 1000000007
int main(){
ll n,m;cin>>n>>m;
ll arr[m];ll dp[n+2];dp[0]=1;dp[1]=1;dp[2]=2;ll j=0;
for(ll i=0;i<m;i++){
    cin>>arr[i];
}
if(n<=2){
    if(n==1){
        dp[n]=1;
    }
    else if(n==2){
        if(arr[0]==1)
            dp[n]=1;
        else
            dp[n]=2;
    }
}
if(n>=3){
for(ll i=2;i<=n;i++){
  if(arr[j]==i-2&&j<m){j++;dp[i-2]=0;}
  if(arr[j]==i-1&&j<m){j++;dp[i-1]=0;}
  dp[i]=dp[i-1]+dp[i-2];
  dp[i]=dp[i]%r;
}
}
cout<<dp[n]<<endl;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>

using namespace std;

void insertionSort(int[], int);

void Solution()
{
	int n;
	int a[100] = {0};

	cin>>n;

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

	for(int i = 0; i < n - 1; i++)
	{
		cout<<a[i]<<" ";
	}
	cout<<a[n - 1]<<endl;

	insertionSort(a, n);
	
}

void insertionSort(int A[100], int N)
{
	int v = 0;

	for (int i = 1; i < N; i++)
	{
		v = A[i];

		int j = i - 1;

		while(j >= 0 && A[j] > v)
		{
			A[j + 1] = A[j];
			j--;
		}

		A[j + 1] = v;  // j = j -1

		for (int k = 0; k < N - 1; k++ )
		{
			cout<<A[k]<<" ";
		}

		cout<<A[N - 1]<<endl;
	}
}

int main()
{
	Solution();
	return 0;
}

Measured memory_bytes: 1160
from collections import deque

n, m, e, s, t, r = map(int, input().split())
edges = [[] for _ in range(n * 2 ** e)]
for _ in range(m):
  a, b = map(int, input().split())
  for i in range(2 ** e):
    edges[a + n * i].append(b + n * i)
    edges[b + n * i].append(a + n * i)

start = s
slide = {}
for i in range(e):
  a, b, c = map(int, input().split())
  slide[c] = 2 ** i
  if c == s:
    start = s + n * 2 ** i
  mask = 2 ** i
  for j in range(2 ** e):
    if mask & j:continue
    edges[a + n * (mask | j)].append(b + n * (mask | j))
    edges[b + n * (mask | j)].append(a + n * (mask | j))

goal = {t + n * i for i in range(2 ** e)}
dist = {}
dist[(start, 0)] = 0
que = deque()
que.append((0, 0, start))
while que:
  score, acc, node = que.popleft()
  if node in goal:
    print(score)
    break
  
  level = node // n
  if (s + n * level, 0) not in dist:
    dist[(s + n * level, 0)] = score + 1
    que.append((score + 1, 0, s + n * level))
  
  if acc == r:continue 
  for to in edges[node]:
    if to % n in slide:to = to % n + n * (to // n | slide[to % n])
    if (to, acc + 1) not in dist:
      dist[(to, acc + 1)] = score + 1
      que.append((score + 1, acc + 1, to))

else:
  print(-1)


Measured memory_bytes: 9760
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<int>> c(10, vector<int>(10)), a(h, vector<int>(w));
	rep(i, 10) rep(j, 10) {
		cin >> c[i][j];
	}
	rep(i, h) rep(j, w) {
		cin >> a[i][j];
	}
	for (int k = 0; k < 10; k++){       // 経由する頂点
		for (int i = 0; i < 10; i++) {    // 始点
			for (int j = 0; j < 10; j++) {  // 終点
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			}
		}
	}
	ll ans = 0;
	rep(i, h) rep(j, w) {
		if(a[i][j] == -1) continue;
		ans += c[a[i][j]][1];
	}
	cout << ans << endl;
	// rep(i, 10){
	// 	rep(j, 10) {
	// 		cout << c[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

struct Node { int key; struct Node *p, *left, *right; };

Node *T = NULL;

void Preorder(Node *id) {
	if (id == NULL) return;
	cout << " " << id->key;
	Preorder(id->left);
	Preorder(id->right);
}

void Inorder(Node *id) {
	if (id == NULL) return;
	Inorder(id->left);
	cout << " " << id->key;
	Inorder(id->right);
}

void treeInsert(Node *Z) {
	Node *y = NULL;
	Node *x = T;
	while (x != NULL) {
		y = x;
		if (Z->key < x->key)
			x = x->left;
		else
			x = x->right;
	}
	Z->p = y;
	if (y == NULL)
		T = Z;
	else if (Z->key < y->key)
		y->left = Z;
	else
		y->right = Z;
}

int main() {
	int n;
	cin >> n;
	Node *node = new Node[n];
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s == "insert") {
			cin >> node[i].key;
			node[i].left = NULL;
			node[i].right = NULL;
			treeInsert(&node[i]);
		} else {
			Inorder(T);
			cout << endl;
			Preorder(T);
			cout << endl;
		}
	}
	delete[] node;
	return 0;
}

Measured memory_bytes: 16632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll y=1e18,p=0,x;
    for(int i=-100;i<=100;i++){
        for(int j=0;j<n;j++){
            x=abs(a[j]-i);
            p=p+(x*x);
        }
        y=min(y,p);
        p=0;
    }
    cout<<y<<endl;
}


Measured memory_bytes: 3572
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;


/*----------------------------------------------------------------*/
signed main(){

    int N;
    cin >> N;
    int ans = 0;
    for(int n = 1; n <= N;n += 2){
        int cnt = 0;
        for(int i = 1;i <= n;i++){
            if(n%i == 0)cnt++;
        }
        if(cnt == 8)ans++;
    }
    cout << ans << endl;



	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://abc154.contest.atcoder.jp/tasks/abc154_b

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int l;
	cin>>l;
	int n=0,r=1;
	while(r<l){
		r*=2;
		n++;
	}
	if(r==l) n++;
	vector<vector<Pi>> g(n);
	rep(i,n-1){
		g[i].push_back(Pi(i+1,0));
		g[i].push_back(Pi(i+1,1<<i));
	}
	l--;
	r=(1<<(n-1));
	//[r,l]がまだ作れないやつ
	for(int i=n-1;i>=1;i--){
		int x=l+1-(1<<(i-1));
		if(r<=x && x+(1<<(i-1))-1==l){
			g[i-1].push_back(Pi(n-1,x));
			l=x-1;
		}
	}		
	int m=0;
	rep(i,n){
		m+=g[i].size();
	}
	cout<<n<<' '<<m<<endl;
	rep(i,n-1){
		rep(j,g[i].size()){
			cout<<i+1<<' '<<g[i][j].fi+1<<' '<<g[i][j].se<<endl;
		}
	}
}

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

int main(){
    string tmp, n;
    for(int i = 0; i < 3; i++){
      cin >> tmp[i];
      if(tmp[i] == '1'){
        n[i] = '9';
      }else if(tmp[i] == '9'){
        n[i] = '1';
      }else{
        n[i] = tmp[i];
      }
    }
    for(int j = 0; j < 3; j++){
      cout << n[j];
    }
    cout << endl;
    return 0;    
}


Measured memory_bytes: 256
#include <stdio.h>

int h(int x){
	return x/100*60+x%100;
}

int main(void) {
	int i,j,k,n,p,q,d[2048],t,s,f,x,r;
	while(scanf("%d%d%d",&n,&p,&q),n!=0){
		p=h(p);q=h(q);
		for(i=p;i<=q-1;i++) d[i]=n;
		for(i=1;i<=n;i++){
			scanf("%d",&t);
			for(j=1;j<=t;j++){
				scanf("%d%d",&s,&f);
				s=h(s);f=h(f);
				for(k=s;k<=f-1;k++) d[k]--;
			}
		}
		x=0;r=0;
		for(i=p;i<=q-1;i++){
			if(d[i]) x++;
			else x=0;
			if(x>r) r=x;
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 608
<?php
$n=(int)trim(fgets(STDIN))+1;
$o='';
for($i=1;$i<$n;$i++){
  if($i%3==0) $o.=' '.$i;
  else{
   $x=$i;
   while($x){
      if($x%10==3){
        $o.=' '.$i;
        break;
      }
      $x=floor($x/10);
    }
  }
}
print $o;
?>

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


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

	long int n;
	cin>>n;
	int h[n];
	int cost[n];
	for(int i = 0; i < n; i++) cin>>h[i];
	cost[0]=0;
	cost[1]=abs(h[1]-h[0]);
	for(int i = 2; i < n ; i++) {
		cost[i] = std::min(cost[i-1] + abs(h[i]-h[i-1]),cost[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<"\n";
	// for(int i = 0; i < n; i++) cout<<cost[i]<<" ";
	cout<<cost[n-1]<<"\n";
	return 0;
}

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

int main() {
	long long n,weight,sum=0;
	cin>>n>>weight;
	vector<long long> w(n+1),value(n+1);
	for(int i=1;i<=n;i++){
	    cin>>w[i]>>value[i];
	    sum+=value[i];
	}
	long long dp[n+1][sum+1];
	for(long long i=0;i<=n;i++){
	    for(long long j=0;j<=sum;j++){
	        dp[i][j]=INF;
	    }
	}
	
	
	for(long long i=0;i<=n;i++){
	    dp[i][0]=0;
	}
	dp[0][0]=0;
	for(int i=1;i<=n;i++){
	    for(int j=1;j<=sum;j++){
	        if(value[i]<=j){
	            dp[i][j]=min(dp[i-1][j],w[i]+dp[i-1][j-value[i]]);
	        }else{
	            dp[i][j]=dp[i-1][j];
	        }
	    }
	}
	long long ans=-1;
	for(int i=1;i<=n;i++){
	    for(int j=1;j<=sum;j++){
	        if(j>=ans&&dp[i][j]<=weight){
	            ans=j;
	        }
	    }
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 79232
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  long k; readV(k);
  auto n = 50, a = new long[](n);
  a[] = n-1+(k/n);

  foreach (i; 0..k%n)
    foreach (j; 0..n)
      a[j] += i == j ? n : -1;

  writeln(n);
  foreach (i; 0..n) {
    write(a[i]);
    if (i < n-1) write(" ");
  }
  writeln;
}


Measured memory_bytes: 256
/**
 *  author: mahfuzz
 *  created: 22.03.2020
**/
 
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x << ':' << x << "\n";
//~ const double pi = 2*acos(0.0);
//~ const long long mod = 1e9+7;
//~ const int max_n = 1e6+5;
typedef long long ll;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    string s; cin >> s;
    
    for(int i = 1; s[i]; i++){
        if(s[i] != s[i-1]){
            cout << "Yes\n";
            return 0;
        }
    }
    
    cout << "No\n"; 
        
    return 0;
}


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

const int N = 1e5 + 10;
bool lesser[N];
int a[N];
vector<int> g[N];

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    

    int n, m;
    cin >> n >> m;
    fill (lesser, lesser + N, false);
    for (int i = 1; i <= n; i++){
      cin >> a[i];
    }
    for (int i = 0; i < m; i++){
      int u, v;
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++){
      bool ok = true;
      for (auto it : g[i]){
        if (a[it] >= a[i]){
          ok = false;
          break;
        }
      }
      if (ok)
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 10376
use std::io::*;
use std::str::FromStr;
use std::collections::*;

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")
}



fn main() {
    let mut A = Vec::new();
    let mut B = Vec::new();
    let mut a = -1;
    let mut b = -1;
    while true {
        a = read();
        b = read();
        if a==0 && b==0 {
            break;
        }
        A.push(a);
        B.push(b);
    }
    let M = A.len();
    for m in 0..M {
        let mut cnt = 0;
        for i in 1..A[m]+1 {
            for j in i+1..A[m]+1 {
                for k in j+1..A[m]+1 {
                    if i==j && j==k && 1==k {
                        continue;
                    }
                    if i+j+k==B[m] {
                        cnt += 1;
                    }
                }
            }
        }
        println!("{}", cnt);  
    }
}


Measured memory_bytes: 5028
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N;
	while(~scanf("%d", &N)) {
		int n = 1;
		for(; n * (n + 1) / 2 < N; ++ n);
		for(; n >= 1; -- n) {
			if(N >= n) {
				printf("%d\n", n);
				N -= n;
			}
		}
		assert(N == 0);
	}
	return 0;
}


Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=3e3+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll dp[2][112][2];

void add(ll &a, ll b)
{
    a += b;
    if(a >= MOD) a %= MOD;
}

int main()
{
    IOS();
    string s;
    ll d;
    cin>>s>>d;
    ll fg = 0;
    dp[0][0][1] = 1;
    for(char c:s)
    {
        FILL(dp[!fg], 0);
        REP(i,d)REP(j, 10)
        {
            if(j < c - '0')add(dp[!fg][(i + j)%d][0], dp[fg][i][0] + dp[fg][i][1]);
            if(j == c - '0')add(dp[!fg][(i + j)%d][0], dp[fg][i][0]),add(dp[!fg][(i + j)%d][1], dp[fg][i][1]);
            if(j > c - '0')add(dp[!fg][(i + j)%d][0], dp[fg][i][0]);
        }
        fg = !fg;
    }
    cout<<(dp[fg][0][0] + dp[fg][0][1] - 1 + MOD)%MOD<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

ll dp[100001][4];
int main() {
	string s;
	cin >> s;
	int n = s.length(); 
	int mod = pow(10, 9) + 7;
	string t = "ABC";
	for (int i = n; i >= 0; i--) {
		for (int j = 3; j >= 0; j--) {
			if (i == n) {
				if (j == 3) {
					dp[i][j] = 1;
				}
				else {
					dp[i][j] = 0;
				}
			}
			else {
				if (j == 3) {
					int m;
					if (s[i] == '?') {
						m = 3;
					}
					else {
						m = 1;
					}
					dp[i][3] = m * dp[i + 1][3];
				}
				else {
					int m1, m2;
					if (s[i] == '?') {
						m1 = 3;
					}
					else {
						m1 = 1;
					}
					if (s[i] == '?' || s[i] == t[j]) {
						m2 = 1;
					}
					else {
						m2 = 0;
					}
					dp[i][j] =
						dp[i + 1][j] * m1 + m2 * dp[i + 1][j + 1];
				}
				dp[i][j] %= mod;
			}
		}
	}
	cout << dp[0][0] << endl;
	return 0;
}

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

using lint = long long int;
using pll = std::pair<lint, lint>;

using std::vector;
using std::priority_queue;

lint num[100010];
priority_queue<pll, vector<pll>, std::greater<pll> > pq;

int main(void) {
	lint N, M;
	scanf("%lld %lld", &N, &M);
	lint subbing = 0, cur = 0;

	for (int i = 1; i <= N; i++) {
		scanf("%lld", &num[i]);
	}
	for (int i = 1; i < N; i++) {
		if ((num[i + 1] - num[i] + M) % M > 1) {
			pq.push(pll(((num[i] + 1) % M + 1), -1));
			pq.push(pll(num[i + 1] % M + 1, ((num[i + 1] - num[i] + M) % M) - 1));
		}
		cur += (num[i + 1] - num[i] + M) % M;

		if (num[i] > 1 && num[i] < M && num[i + 1] < num[i]) {
			cur -= (M - num[i]);
			subbing++;
		}
	}

	while (!pq.empty() && pq.top().first <= 1) {
		pq.pop();
	}
	lint ans = cur;
	for (int i = 2; i <= M; i++) {
		while (!pq.empty() && pq.top().first == i) {
			if (pq.top().second == -1) {
				subbing++;
			}
			else {
				subbing--;
				cur += pq.top().second;
			}
			pq.pop();
		}

		cur -= subbing;
		ans = std::min(ans, cur);
	}

	printf("%lld", ans);

	return 0;
}

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



int main() {
    int n;
    cin >> n;
    
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    
    sort(d.begin(),d.end());
    
    cout << d[n/2] - d[n/2-1] << endl;
    
    
    return 0;
}




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

int main(){
    int N, D;
    int res;
    // vector<int64_t> vp;
    // int64_t vp[100010];
    // string res;
    // int64_t vp_xor = 0ll;


    cin >> N >> D;
    // for (int i=0; i<N; i++){
    //     cin >> vp[i];
    //     vp_xor ^= vp[i];
    // }

    res = N / (2 * D + 1);
    if (N % (2 * D + 1) != 0) res++;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256