akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, i, j, k, l, m;
    cin >> n >> k;
    vector<ll> data;
    for (i = 1; i <= n;i++){
        cin >> m;
        data.pb(m);
    }
    sort(data.begin(), data.end());
    ll sum = 0;
    for (i = 0; i < k;i++){
        sum += data[i];
    }
    cout << sum << "\n";
    return 0;
}

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

int main(){
  int N,min_cost=1000000000;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  for(int i=-100;i<101;i++){
    int cost=0;
    for(int j=0;j<N;j++){
      int B=(i-A.at(j))*(i-A.at(j));
      cost+=B;
    }
    min_cost=min(min_cost,cost);
  }
  cout << min_cost << endl;
} 

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, a; vector<int>p;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a; p.push_back(a);
	}
	sort(p.begin(), p.end());
	p.erase(unique(p.begin(), p.end()), p.end());
	cout << p.size() << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  string s,t;
  cin >> s >> t;
  ll a=s.size(),b=t.size();
  bool can=false;
  if(a>=b){
    for(ll i=a-1;i>=b-1;i--){
      bool c=true;
      for(ll j=0;j<b;j++){
        if(s[i-j]!=t[b-1-j]&&s[i-j]!='?'){
          c=false;
        }
      }
      if(c){
        for(ll k=i;k>i-b;k--){
          s[k]=t[k-i+b-1];
        }
        rep(i,a){
          if(s[i]=='?'){
            s[i]='a';
          }
        }
        can=true;
        break;
      }
    }
  }
  if(!can){
    cout << "UNRESTORABLE" << endl;
  }
  else{
    cout << s << endl;
  }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int n;cin>>n;
	vi a(n);
	int cnt=0;
	rep(i,n){
		cin>>a[i];
		if(a[i]%2)cnt++;
	}
	if(cnt>0){
		cout<<"first"<<endl;
	}
	else cout<<"second"<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

VI G[100010];
int reached[100010];
int color[100010];


int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class281
    {
        static void Main()
        {
            double R = double.Parse(Console.ReadLine());
            Console.WriteLine(2*R*Math.PI);
        }
    }
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int main() {
    int a, b, k;
    cin >> a >> b >> k;

    int g = min(a,b);
    int cnt = 0;
    int ans;
    repmr(i,1,g){
        if(a % i == 0 && b % i == 0){
            cnt++;
            if(cnt == k){
                ans = i;
                break;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll a,b;
    cin>>a>>b;
    ll left=b-(a-1);
    ll right=b+(a-1);
   ll lef=max(left,-1000000ll);
   ll ri=min(right,1000000ll);
    for(ll i=lef;i<=b;i++){
        cout<<i<<" ";
    }
    for(ll i=b+1;i<=ri;i++){
        cout<<i<<" ";
    }
cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
        public static void main(String args[]) {
                try(Scanner sc = new Scanner(System.in)) {
                        long N = sc.nextLong();
                        long min = 1L << 60;
                        long ans = - (1L << 60);
                        for (long i = 0; i < N; i++) {
                                long now = sc.nextLong();
                                ans = Math.max(ans, now - min);
                                min = Math.min(min, now);
                        }
                        System.out.println(ans);
                }
        }
}

Measured memory_bytes: 99240
import sys
from collections import Counter
from operator import itemgetter, attrgetter
n=0
 
n = input()
d_list= list(map(int, input().split()))
cnt=0
for i in range(1,len(d_list)-1):
    b=d_list[i-1]
    m=d_list[i]
    a=d_list[i+1]
    if (b< m <a) or (a< m< b):
        cnt+=1
        
    
print(cnt)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define si(a) scanf("%d",&a)
#define sll(a) scanf("%lld",&a)
#define sl(a) scanf("%ld",&a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%ld\n",a)
#define pll(a) printf("%lld\n",a) 
#define sc(a) scanf("%c",&a)a
#define pc(a) printf("%c",a)
#define ll long long
#define mod 1000000007

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF INT_MAX
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define VI vector<int>
#define VL vector<ll>
#define PI pair<int,int>
#define PL pair<ll,ll>
long double PIE=acos(-1);
//////////////////////////////////////////////////////////////
const ll N=1e5+5;
ll Ans=1;
bool done[1000009];
vector < ll > primes;

void FindPrime(ll N)
{
    done[1] = 1;
    for(int i=2;i<=N;i++)
	{
        if(done[i]) continue;
        for(int j=i*2;j<=N;j+=i)
		{
            done[j] = 1;
        }
        primes.push_back(i);
    }
}

ll solve(ll Num)
{
    for(int i=0;i<primes.size();i++)
	{
    	int p=primes[i];
        if(p*p*p > Num) break;
        ll Count = 1;
        while(Num%p == 0)
		{
            Num /= p,Count++;
        }
        Ans *= Count;
    }
    ll sq = (ll)sqrt(Num);
    if(!done[Num]) 
	Ans *= 2;
    else if(sq*sq == Num && !done[sq]) 
	Ans *= 3;
    else if(Num != 1) 
	Ans *= 4;
    return Ans;
}


ll fact[N], invfact[N];



ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

ll modinv(ll k)
{
	return pow(k, mod-2, mod);
}


ll nCr(ll x, ll y)
{
	if(y>x)
		return 0;
	ll num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}

void initinv()
{
	fact[0]=1;
	fr(i,1,N)
	{
		fact[i]=(i*fact[i-1])%mod;
	}
	invfact[N]=modinv(fact[N]);
	for(int i=N-1;i>=1;i--)
	{
		invfact[i]=((i+1)*invfact[i+1])%mod;
	}
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
ll dp[100005][3];
int main()
{
	int n;
	cin>>n;
	ll a,b,c;
	ll p,q,r;
	fr(i,1,n)
	{
		cin>>a>>b>>c;
		if(i==1)
		{
			dp[i][0]=a;
			dp[i][1]=b;
			dp[i][2]=c;
		}
		else
		{
			dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
			dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
			dp[i][2]=c+max(dp[i-1][1],dp[i-1][0]);
		}
	}
	ll ans=max(dp[n][0],max(dp[n][1],dp[n][2]));
	cout<<ans;
    return 0;
}





Measured memory_bytes: 5932
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF /*1000000007*/ 1000000000000000003
#define MOD 1000000007

using namespace std;
using P = pair<int, long long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
vector<P> connect[100005];
long long cost[100005];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int N, M;
	cin >> N >> M;

	for (int i = 0; i < M;++i) {
		int a, b; long long c;
		cin >> a >> b; cin >> c;
		--a, --b;
		connect[a].push_back(make_pair(b, -c));
	}

	for (int i = 0; i < N;++i) {
		cost[i] = INF;
	}
	cost[0] = 0;
	
	bool isInf = false;
	for (int i = 0; i < N;++i) {
		for (int j = 0; j < N;++j) {
			for (P e : connect[j]) {
				if (cost[j] != INF && cost[j] + e.second < cost[e.first]) {
					cost[e.first] = cost[j] + e.second;
					if (i == N - 1 && e.first == N - 1)isInf = true;
				}
			}
		}
	}

	if (isInf)cout << "inf" << endl;
	else cout << -cost[N - 1] << endl;
}


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

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

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int N; cin >> N;
    for(int i = 9; i >= 1; i--) {
        if(N % i == 0 && N / i <= 9) {
            cout << "Yes" << "\n";
            return 0;
        }
    }
    cout << "No" << "\n";
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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;}

signed main(){
    int N;cin>>N;
    cout<<N*800-N/15*200<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

func changeAtoB(a *int, b *int) {
	var tmp int
	tmp = *a
	*a = *b
	*b = tmp
}

func changeAtoC(a *int, c *int) {
	var tmp int
	tmp = *a
	*a = *c
	*c = tmp
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	X, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	scanner.Scan()
	Y, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	scanner.Scan()
	Z, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	changeAtoB(&X, &Y)
	changeAtoC(&X, &Z)

	fmt.Println(X, Y, Z)

}


Measured memory_bytes: 1832
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	h := getNextInt(scanner)
	w := getNextInt(scanner)
	geta := 10000
	aa := make([][]int, h)
	for i := 0; i < h; i++ {
		aa[i] = make([]int, w)
		for j := 0; j < w; j++ {
			aa[i][j] = getNextInt(scanner)
		}
	}
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			aa[i][j] = absint(aa[i][j] - getNextInt(scanner))
		}
	}
	grid := makeGrid(h, w)
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			grid[i][j] = big.NewInt(0)
		}
	}
	grid[0][0].SetBit(grid[0][0], geta+aa[0][0], 1)
	grid[0][0].SetBit(grid[0][0], geta-aa[0][0], 1)
	for i := 1; i < w; i++ {
		grid[0][i].Or(grid[0][i], lshed(grid[0][i-1], aa[0][i]))
		grid[0][i].Or(grid[0][i], rshed(grid[0][i-1], aa[0][i]))
	}
	for i := 1; i < h; i++ {
		grid[i][0].Or(grid[i][0], lshed(grid[i-1][0], aa[i][0]))
		grid[i][0].Or(grid[i][0], rshed(grid[i-1][0], aa[i][0]))
	}
	for i := 1; i < h; i++ {
		for j := 1; j < w; j++ {
			grid[i][j].Or(grid[i][j], lshed(grid[i-1][j], aa[i][j]))
			grid[i][j].Or(grid[i][j], rshed(grid[i-1][j], aa[i][j]))
			grid[i][j].Or(grid[i][j], lshed(grid[i][j-1], aa[i][j]))
			grid[i][j].Or(grid[i][j], rshed(grid[i][j-1], aa[i][j]))
		}
	}

	for i := 0; i < geta; i++ {
		if grid[h-1][w-1].Bit(geta+i) == 1 {
			fmt.Fprintln(writer, i)
			return
		}
		if grid[h-1][w-1].Bit(geta-i) == 1 {
			fmt.Fprintln(writer, i)
			return
		}
	}
}
func absint(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func makeGrid(h, w int) [][]*big.Int {
	index := make([][]*big.Int, h, h)
	data := make([]*big.Int, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

func lshed(b *big.Int, i int) *big.Int {
	return big.NewInt(0).Lsh(b, uint(i))
}
func rshed(b *big.Int, i int) *big.Int {
	return big.NewInt(0).Rsh(b, uint(i))
}


Measured memory_bytes: 32128
#include <iostream>
using namespace std;
int main(void)
{
  int a, b, c;
  cin >> a;
  cin >> b;
  cin >> c;
  if (a < b && b < c)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3104
#include <stdio.h>

int main(void) {
	int N, K;
	int h[100] = {0};
	int d, a;
	int sum = 0;
	
	scanf("%d %d", &N, &K);

	for(int i = 0; i < K; i++) {
		scanf("%d", &d);
		
		for(int j = 0; j < d; j++) {
			scanf("%d", &a);
			
			if(h[a-1] == 0) {
				h[a-1] = 1;
			}
		}
	}
			
	for(int i = 0; i < N; i++) {
		sum += h[i];
	}
	sum = N - sum;
	
	printf("%d", sum);
	
	return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int suf[11][11];
int main()
{
    int arr[] = {1, 10, 100, 1000, 10000, 100000, 1000000};
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i++)
    {
        int k = 0;
        int tmp = i;
        while (tmp > 0)
        {
            k++;
            tmp /= 10;
        }
        if (i % 10 != 0)
        {
            suf[i / arr[k - 1]][i % 10]++;
            // if (i > 10) suf[i % 10][i / arr[k - 1]]++;
        }
    }
    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {
            // if (i != j) ans += suf[i][j] * 2;
            // else ans += suf[i][j];
            ans += suf[i][j] * suf[j][i];
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
// B.

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n, k;
	cin >> n >> k;
	vector<int> h(n), cost(n, 1 << 30);
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	cost[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 1; j <= k; ++j) {
			if (i + j < n) {
				cost[i + j] = min(cost[i + j], cost[i] + abs(h[i + j] - h[i]));
			}
		}
	}
	cout << cost[n - 1] << endl;
	return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ZERO(a) memset(a,0,sizeof(a))

int dp[1020][1020];

int lcs(string x, string y) {
    int n=x.size(), m=y.size();
    rep(i,n) rep(j,m) {
        if(x[i] == y[j])
            dp[i+1][j+1] = dp[i][j] + 1;
        else
            dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
    }
    return dp[n][m];
}

int main() {
    int q; cin >> q;
    rep(data,q) {
        ZERO(dp);
        string x, y;
        cin >> x >> y;
        int ans = lcs(x,y);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 5288
#include <iostream>
#include <deque>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <iterator>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<4;i++){
		cout<<s[i];
	}
	cout<<" ";
	for(int i=4;i<12;i++){
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long n,k,a,b;
	scanf("%lld %lld",&n,&k);
	a=n%k;
	b=a-k;
	if(a<b*-1) printf("%lld\n",a);
	else  printf("%lld\n",b*-1);
	return 0;
}

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

using namespace std;

int main() {

    int a;
    int b;
    cin >> a >> b;

    if ((a + b) % 2 == 0) {
    cout << (a + b)/2 << endl;
}

    else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

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

int main() {
  int n;
  cin >> n ;
  vector<string> ao(n);

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

int m;
cin >>m;
  vector<string> aka(m);

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int kazoe = 0;
    for (int j = 0; j < n; j++) {
      if (ao[i] == ao[j]) {
        kazoe++;
      }
    }
    for (int k = 0; k < m; k++) {
      if (ao[i] == aka[k]) {
        kazoe--;
      }
    }
  ans = max(ans, kazoe);
}
cout << ans << endl;
}


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

int N;
int A[200001];


int main() {
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
    }
    int id = 1;
    int count = 0;
    for (int i = 1; i <= N; i++) {
        if (A[i] == id) id += 1;
        else count += 1;
    }
    if (count == N) count = -1;
    cout << count << endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define repr(i, n) for(int i = n;i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define MOD 1000000007

typedef long long ll;

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

    int n,max,a,b,c;
    cin >> n;

    repr(i,n){
        a = sqrt((double)i);
            
        if(a * a == i){
            max = i;
            break;
        }
    }

    cout << max << endl;
    
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer x = nil;
  while(1)
    {
      x = x->next;
      if(x == nil) return nil;
      if(x->key == key) return x;
    }
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  NodePointer p,n;
  p = t->prev;
  n = t->next;
  p->next = n;
  n->prev = p;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if( t == nil) return;
  deleteNode(t);
}

void delete(int key){
  NodePointer x = listSearch(key);
  if(x != nil) deleteNode(x);
}


void insert(int key){
  NodePointer x,y;
  x = malloc(sizeof(struct node));
  x->key = key;
  y = nil->next;
  nil->next = x;
  x->prev = nil;
  y->prev = x;
  x->next = y;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }
  printList();
  return 0;
}

Measured memory_bytes: 31784
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#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;
//const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

ll MOD;

ll mod_pow(ll x,ll n){
  x%=MOD;
  ll res=1;
  while(n>0){
    if(n&1) res=res*x%MOD;
    x=x*x%MOD;
    n>>=1;
  }
  return res;
}

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

void mul(ll &a,ll b){
  a%=MOD;b%=MOD;
  a=a*b%MOD;
}

vector<ll> lagrangeInterpolation(vector<ll> X,vector<ll> Y){
    int N=X.size();
    rep(i,N) X[i]=(X[i]%MOD+MOD)%MOD;
    rep(i,N) Y[i]=(Y[i]%MOD+MOD)%MOD;
    vector<ll> A(N,1);
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i==j) continue;
            mul(A[i],(X[i]-X[j]+MOD)%MOD);
        }
        if(A[i]==0) continue;
        A[i]=Y[i]*mod_pow(A[i],MOD-2)%MOD;
    }

    int cur=0;
    vector<vector<ll>> dp(2,vector<ll> (N+1,0));
    dp[0][0]=(-X[0]+MOD)%MOD;
    dp[0][1]=1;
    for(int i=1;i<N;i++){
        for(int j=0;j<=N;j++){
            if(dp[cur][j]==0) continue;
            add(dp[1-cur][j],(dp[cur][j]*(-X[i])%MOD+MOD)%MOD);
            if(j+1<=N) add(dp[1-cur][j+1],dp[cur][j]);
        }

        for(int j=0;j<=N;j++) dp[cur][j]=0;
        cur=1-cur;
    }

    vector<ll> invX(N,0);
    rep(i,N){
        if(X[i]==0) continue;
        invX[i]=mod_pow(X[i],MOD-2);
    }
    vector<ll> C(N,0);
    for(int i=0;i<N;i++){
        if(A[i]==0) continue;
        if(X[i]==0){
            for(int j=0;j<N;j++) add(C[j],dp[cur][j+1]*A[i]%MOD);
            continue;
        }

        ll pre=0;
        for(int j=0;j<N;j++){
            ll val=(-(dp[cur][j]-pre+MOD)%MOD*invX[i]%MOD+MOD)%MOD;
            add(C[j],val*A[i]%MOD);
            pre=val;
        }
    }
    return C;
}

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

  int P;
  cin>>P;
  vector<ll> A(P);
  rep(i,P) cin>>A[i];

  MOD=P;
  vector<ll> X(P);
  rep(i,P) X[i]=i;

  vector<ll> C=lagrangeInterpolation(X,A);
  
  for(auto n:C) cout<<n<<" ";
  cout<<endl;


  return 0;
}


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

const int INF = 1000000000;

int main(){

int n,m;
int a,b,c,t;
int k,p,q,r;

while(true){
 cin >> n >> m;
 if(n==0 && m==0) break;
 int C[100][100];
 int T[100][100];
 for(int i=0; i<m; i++){
  for(int j=0; j<m; j++){
   if(i==j){
    C[i][j] = T[i][j] = 0;
   }else{
    C[i][j] = T[i][j] = INF;
   }
  }
 }
 for(int i=0; i<n; i++){
  cin >> a >> b >> c >> t;
  C[a-1][b-1] = C[b-1][a-1] = c;
  T[a-1][b-1] = T[b-1][a-1] = t;
 }

 for(int x=0; x<m; x++){
  for(int y=0; y<m; y++){ 
   for(int z=0; z<m; z++){
    if(T[y][z]>T[y][x]+T[x][z]){
     T[y][z]=T[y][x]+T[x][z];
    }
    if(C[y][z]>C[y][x]+C[x][z]){
     C[y][z]=C[y][x]+C[x][z];
    }
   }
  }
 }

 cin >> k;
 for(int i=0; i<k; i++){
  cin >> p >> q >> r;
  if(r==0){
   cout << C[p-1][q-1] << endl;
  }else{
   cout << T[p-1][q-1] << endl;
  }
 }
}

return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
int main() {
    lli a,b,c,d;
    cin>>a>>b>>c>>d;
    
    lli o = a*c; 
    o = max(o,a*d);
    o =max(o,b*d);
    o = max(o,b*c);
    cout<<o<<endl;

}


Measured memory_bytes: 3568
#include <stdio.h>

int main() {
    int x,y,i,j,flg=0,a[]={1,3,5,7,8,10,12},b[]={4,6,9,11};
    scanf("%d %d",&x,&y);
    if(x==2 || y==2){printf("No\n");
        flg =1;
    }
    for(i=0;i<7;i++){
        if(x==a[i]){for(j=0;j<7;j++){
            if(y==a[j]){printf("Yes\n");
            flg =1;
            break;}
                }
            
        }
    }
    for(i=0;i<4;i++){
        if(x==b[i]){for(j=0;j<4;j++){
            if(y==b[j]){printf("Yes\n");
            flg =1;
            break;}
                }
        }
    }
    if(flg ==0){printf("No\n");}
    return 0;}

Measured memory_bytes: 128
#include<stdio.h>
using namespace std;
int main()
{
	char c1, c2, c3, c4, c5, c6;
	while(~scanf(" %c%c%c\n %c%c%c", &c1, &c2, &c3, &c4, &c5, &c6))
		if(c1 == c6 && c2 == c5 && c3 == c4)
		{	
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Stack{
	private final int SIZE = 101;
	private int[] st;
	private int top;
	public Stack(){
		st = new int[SIZE];
		top = -1;
	}
	public void push(int v){
		st[++top] = v;
	}
	public int pop(){
		return st[top--];
	}
	public int peek(){
		return st[top];
	}
	public boolean isEmpty(){
		return (top == -1);
	}
}
class Graph{
	private final int MAX_VERTS = 101;
	//?¨????????????°
	private boolean[] wasVisited;
	private int[] d,f;
	private int tt;
	private int adjMat[][];
	public int nVerts;
	private Stack stack;
	public Graph(){
		wasVisited = new boolean[MAX_VERTS];
		tt = 0;
		d = new int[MAX_VERTS];
		f = new int[MAX_VERTS];
		adjMat = new int[MAX_VERTS][MAX_VERTS];
		nVerts = 0;
		for(int i=0;i<MAX_VERTS;i++){
			wasVisited[i] = false;
			for(int j=0;j<MAX_VERTS;j++)
				adjMat[i][j] = 0;
		}
		stack = new Stack();
	}
	public void addEdge(int start,int end){
		adjMat[start][end] = 1;
	}
	public int getUnvisitedVertex(int v){
		for(int n=1;n<=nVerts;n++){
			if(adjMat[v][n] == 1 && wasVisited[n-1] == false)
				return n;
		}
		return -1;
	}
	public void dfsVisit(int r){
		wasVisited[r] = true;
		d[r] = ++tt;
		stack.push(r+1);
		while(!stack.isEmpty()){
			//v???vertexList????????????????????????
			int v = getUnvisitedVertex(stack.peek());
			if(v==-1){
				int u = stack.peek() -1;
				f[u] = ++tt;
				stack.pop();
			}else{
				wasVisited[v-1] = true;
				d[v-1] = ++tt;
				stack.push(v);
			}
		}
	}
	public void dfs(){
		for(int i=0;i<nVerts;i++){
			if(wasVisited[i]==false)
				dfsVisit(i);
		}
		for(int i=0;i<nVerts;i++){
			System.out.println(i+1 +" "+d[i]+" "+f[i]);
		}
	}
}
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Graph graph = new Graph();
		int n = Integer.parseInt(br.readLine());
		graph.nVerts = n;
		for(int i=0;i<n;i++){
			String[] line = br.readLine().split(" ");
			for(int j=0;j<Integer.parseInt(line[1]);j++){
				//vn?????£??\?????????????????????????????????
				int vn = j+2;
				graph.addEdge(Integer.parseInt(line[0]), Integer.parseInt(line[vn]));
			}
		}
		graph.dfs();
	}
}

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

int main() {
  int n,x,a = 0,count = 0;
  cin >> n >> x;
  vector<int> kasi(n);
  for (int i = 0; i < n; i++) {
    cin >> kasi.at(i);
    a += kasi.at(i);
  }
  x -= a;
  sort(kasi.begin(), kasi.end());
  int answer = x / kasi.at(0) + n;
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <stack>
#include <utility>
#include <vector>
#include <math.h>

#define rep(i, n) for (auto i = 0; i < (n); i++)
#define MOD 1e9 + 7
typedef long long ll;

using namespace std;

int main() {
  string s, t;
  cin >> s;
  cin >> t;
  int ans = 0;
  rep(i, s.size()) {
    if (s[i] != t[i]) ans++;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3496
#include <cstdio>
#include <vector>
using namespace std;

int c=0;

void merge(vector<int>& A, int left, int mid, int right) {
	int i,j,k;
	int n1=mid-left;
	int n2=right-mid;
	vector<int> L, R;
	L.resize(n1+1);
	R.resize(n2+1);
	for(i=0; i<n1; ++i) {
		L[i]=A[left+i];
	}
	for(i=0; i<n2; ++i) {
		R[i]=A[mid+i];
	}
	L[n1]=1000000001;
	R[n2]=1000000001;
	i=j=0;
	for(k=left; k<right; ++k) {
		++c;
		if(L[i]<=R[j]) {
			A[k]=L[i];
			++i;
		} else {
			A[k]=R[j];
			++j;
		}
	}
	return;
}

void mergeSort(vector<int>&A, int left, int right) {
	if(left+1<right) {
		int mid=left+(right-left)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
	return;
}

int main() {
	vector<int> A;
	int n;
	int i;
	scanf("%d",&n);
	A.resize(n);
	for(i=0; i<n; ++i) {
		scanf("%d", &A[i]);
	}
	mergeSort(A,0,n);
	for(i=0; i<n-1; ++i) {
		printf("%d ",A[i]);
	}
	printf("%d\n%d\n",A[n-1],c);
	return 0;
}

Measured memory_bytes: 6320
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;
ll m,n;
int main(){
    cin>>m>>n;
    if(m==n){
        puts("Yes");
    }else{
        puts("No");
    }
}

Measured memory_bytes: 256
fn main() {
	let stdin = std::io::stdin();
	let mut s = String::new();
	stdin.read_line(&mut s).unwrap();
	
	let input = s.trim().split(" ").map(|c| c.parse::<i32>().unwrap()).collect::<Vec<i32>>();
	let a = input[0];
	let b = input[1];
	
	if a < b {
		println!("a < b");
	}else if a > b {
		println!("a > b");
	}else{
		println!("a == b");
	}
}



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

int main() {
  
  string S;
  cin >> S;
  
  if ( S == "Sunny" ) {
    cout << "Cloudy" << endl;
  }
  if ( S == "Cloudy" ) {
    cout << "Rainy" << endl;
  }
  if ( S == "Rainy" ) {
    cout << "Sunny" << endl;
  }
  
  

}

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

int main() {
	int n, L = 0, R = 0;
	char s[200] = {}, ans;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == '(') {
			L++;
		}
		if (s[i] == ')') {
			if (L > 0) L--;
			else R++;
		}
	}
	for (int j = 0; j < n; j++) {
		s[n - 1 - j + R] = s[n  -1 - j];
	}
	for (int j = 0; j < R; j++) s[j] = '(';
	for (int i = 0; i < L; i++) {
		s[n + R + i] = ')';
	}
	for (int i = 0; i < n + R+L; i++)
		cout << s[i];
	cout << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}

  int ans = 0;
  string s; cin>>s;
  int temp = 0;
  REP(i,s.size()){
    if(s[i]=='R'){
      ++temp;
      chmax(ans,temp);
    }else{
      temp = 0;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3624
const funcA = (input: string): void => {
    const hoge: number[] = input.split(" ").map(Number);
    const fuga: number[] = hoge.slice().sort(
        (a: number, b: number): number => { return a-b; }
    );
    console.log((fuga[0]*fuga[1]) / 2);
}

funcA(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  n, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  x, _ := strconv.Atoi(sc.Text())

  d := 0
  cnt := 1
  for i := 0; i < n; i++ {
    sc.Scan()
    l, _ := strconv.Atoi(sc.Text())
    d = d + l
    if d <= x {
      cnt++
    }
  }

  fmt.Println(cnt)

}



Measured memory_bytes: 640
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

struct Node {
    int player;
    std::vector<int> children;
    int height;
    int rank;
};

const int MAX_N = 100050;
int N;
int a[MAX_N];

Node tree[MAX_N];

void dfs_set_rank(int node, int rank) {
    tree[node].rank = rank;

    for (auto c : tree[node].children) {
        dfs_set_rank(c, rank + 1);
    }
}

int main(int argc, char **argv) {
    std::cin >> N;

    a[1] = 0;
    for (int i = 2; i <= N; i++) {
        std::cin >> a[i];
    }

    for (int i = 2; i <= N; i++) {
        tree[a[i]].children.push_back(i);
    }

    dfs_set_rank(1, 0);

    std::vector<std::pair<int, int>> node_rank_vec;

    for (int i = 1; i <= N; i++) {
        node_rank_vec.push_back(std::pair<int, int>({i, tree[i].rank}));
    }

    std::sort(node_rank_vec.begin(), node_rank_vec.end(),
        [](const std::pair<int, int>& a, const std::pair<int, int>& b) { return a.second > b.second; }
    );

    for (auto p : node_rank_vec) {
        int node = p.first;
        int tmp = 0;
        std::vector<int> child_height;
        for (int c : tree[node].children) {
            child_height.push_back(tree[c].height);
        }
        std::sort(child_height.begin(), child_height.end());
        for (int h : child_height) {
            tmp = std::max(tmp, h) + 1;
        }
        tree[node].height = tmp;

        //std::cout << "check:" << node << " " << tmp << std::endl;
    }

    std::cout << tree[1].height << std::endl;

    return 0;
}

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

int main(){
	int n,m;
	cin >> n >> m;

	vector<int> height(n+1);
	vector<int> kari_height(n+1);
	
	for(int i = 1; i <= n; i++){
		cin >> height.at(i);
		kari_height.at(i) = 0;
	}

	for(int i = 0; i < m; i++){
		int a,b;
		cin >> a >> b;
		kari_height.at(a) = max(kari_height.at(a), height.at(b));
		kari_height.at(b) = max(kari_height.at(b), height.at(a));
	}

	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(height.at(i) > kari_height.at(i))
			ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 4060
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "ctime"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

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


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

	cin >> N >> L >> R;
	int a = 0, b = 0, c = 0;
	for (int i = 0; i < N; i++) {
		cin >> M;
		if (M <= L)a++;
		else if (M <= R)b++;
		else c++;
	}
	cout << min({ a,b,c }) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int max = 0;
    int ans = 0;

    int H;
    for (int i = 0; i < N; ++i) {
        cin >> H;
        if (H >= max) {
            ans++;
            max = H;
        }
    }

    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main(){
    int x, y, s;
    while(cin>>x>>y>>s, x|y|s){
        int ans = 0;
        for(int i=1; i<s; i++){
            int p, q;
            for( p = (i * 100) / (100+x); p*(100+x)<(i+1)*100; p++);
            p--;
            for( q = ((s-i) * 100) / (100+x); q*(100+x)<(s-i+1)*100; q++);
            q--;
            if( p*(100+x)/100 + q*(100+x)/100 != s ) continue;
            int _p = p * (100+y) / 100;
            int _q = q * (100+y) / 100;
            ans = max(ans, _p+_q);
//          cout << p << " " << q << " " << _p+_q <<  endl;
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y;
    cin>>x>>y;
    if(x==y){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
     return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	N, K := sc.NextInt(), sc.NextInt()
	fmt.Print(N - K + 1)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}//standard output
        static void myerr(Object t){System.err.println(t);}//standard error
        static String getStr(){return sc.next();}
        static int getInt(){return Integer.parseInt(getStr());}
        static long getLong(){return Long.parseLong(getStr());}
        static boolean hasNext(){return sc.hasNext();}
        static char[] mySplit(String str){return str.toCharArray();}
        static String toKaigyo(String[] list){return String.join("\n",list);}
        static String toHanSp(String[] list){return String.join(" ",list);}
        public static void main(String[] args){
          int X = getInt();
          ArrayList<Long> list = new ArrayList<Long>();
          list.add(new Long(0));
          for(int i = 1; i < 120; i++){
            list.add((long)Math.pow(i,5));
            list.add(-1 * (long)Math.pow(i,5));
          }
          for(int i = 0; i < list.size(); i++){
            for(int j = 0; j < list.size(); j++){
              long mae = list.get(i);
              long ato = list.get(j);
              if(mae - ato == X){
                boolean isMinus1 = false;
                boolean isMinus2 = false;
                int outputMae;
                int outputAto;
                if(mae < 0){
                  isMinus1 = true;
                  mae *= -1;
                }
                outputMae = (int)Math.pow(mae, 0.2);
                if(ato < 0){
                  isMinus2 = true;
                  ato *= -1;
                }
                outputAto = (int)Math.pow(ato, 0.2);
                if(isMinus1){
                  outputMae *= -1;
                }
                if(isMinus2){
                  outputAto *= -1;
                }
                myout(outputMae + " " + outputAto);
                return;
              }
            }
          }
        }
        //Method addition frame start

        //Method addition frame end
}


Measured memory_bytes: 38844
import math
N = int(input())
As = list(map(int,input().split(" ")))
Bs = list(map(int,input().split(" ")))
over = []
under = []
for a,b in zip(As,Bs):
    if a < b:
        under.append(b-a)
    if a > b:
        over.append(a-b) #1個
#overの要素を幾つ使えばunderを包めるか
if len(under) == 0:
    print(0)
    exit()

over.sort(reverse=True)
under_sum = sum(under)
l = len(over)
for i in range(l):
    under_sum -= over[i]
    if under_sum  <= 0:
        break
if under_sum  > 0:
    print(-1)
else:
    print(i+ 1 + len(under)) #これは少なくとも全部書き換える
# +overで使った分の長さ

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

int main()
{
    char str[101];
    scanf("%s", str);
    int count = 0;

    for (int i = 0, j = strlen(str) - 1; i < j; i++) {
        if (str[i] != str[j]) {
            count++;
        }
        j--;
    }
    cout << count << "\n";
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,ans=0;cin>>n;
  for(ll i=1;i*i<=n;++i) 
    if(n%i==0 && n/i>1 && n%(n/i-1)==i) ans+=(n/i)-1;
  print(ans);
  return 0;
}


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

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

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

	vector<int> ans(N);
	rep(i, N)
	{
		int a;
		cin >> a;
		a--;

		ans[a] = i + 1;
	}

	rep(i, N)
	{
		if (i > 0)
		{
			cout << " ";
		}

		cout << ans[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1152