akhauriyash/Code-Regression huggingface dataset:
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main() {
    string s;
    while(cin>>s){
        ll ans=0;
        int x[]={1,9,36,84,126,126,84,36,9,1};
        rep(i,10){
            ans+=x[i]*(s[i]-'0');
        }
        cout<<ans%10<<endl;
    }

    
    return 0;
}


//1 9 36 84 126 126 84 36 9 1

Measured memory_bytes: 1180
import math

N = int(input())
#sqrtN = math.floor(math.sqrt(N))
#count = 1
#for i in range(sqrtN):
#   count += 2 *((N-1) // (i+2))
count = 0
for i in range(N):
  count += (N-1) // (i+1)
  
print(count)  

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> broken(n+1);
  rep(i,m) {
    int a;
    cin >> a;
    broken[a] = 1;
  }
  vector<int> dp(n+2);
  const int mod = 1000000007;
  dp[n] = 1;
  for (int i = n-1; i >= 0; i--) {
    if (broken[i]) {
      //dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i+1] + dp[i+2]) % mod;
  }
  cout << dp[0] << endl;
  return 0;
}    


Measured memory_bytes: 1024
(d,g),*a=$<.map{|s|s.split.map &:to_i}
f=[]
(0...1<<d).map{|b|
s=n=e=0
a.map{|p,c|e+=100;b&1>0?(n+=p;s+=p*e+c):(P=p;E=e);b/=2}
f<<n+[0,(g-s-1)/E+1].max if P&&g-s<=P*E
P||f<<n
}
p f.min


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
int main() {
  int a,b;cin>>a>>b;
  int ans=max(a+b,max(a-b,a*b));
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    try(Scanner sc = new Scanner(System.in)){
      int w = sc.nextInt();
      int n = sc.nextInt();
      int[] values = new int[w];
      for(int i=0;i<values.length;i++){
        values[i] = i + 1;
      }
      for(int i=0;i<n;i++){
        String str = sc.next();
        String[] ab = str.split(",");
        int a = Integer.parseInt(ab[0]) - 1;
        int b = Integer.parseInt(ab[1]) - 1;
        int c = values[a];
        values[a] = values[b];
        values[b] = c;
      }
      for(int i=0;i<w;i++){
        System.out.println(values[i]);
      }
    }
  }
}



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

int main() {
//    freopen("in.txt", "r", stdin);
    int dice[4][4] = {0};
    int tmp;
    string movitation;
    cin >> dice[2][3] >> dice[3][1] >> dice[2][2]
        >> dice[2][0] >> dice[1][1] >> dice[2][1];
    dice[0][1] = dice[2][3];

    cin >> movitation;
    for (int i = 0; i < movitation.length(); ++i) {
        if (movitation[i] == 'S') {
            tmp = dice[0][1];
            dice[0][1] = dice[1][1];
            dice[1][1] = dice[2][1];
            dice[2][1] = dice[3][1];
            dice[3][1] = tmp;

            dice[2][3] = dice[0][1];
        } else if (movitation[i] == 'N') {
            tmp = dice[3][1];
            dice[3][1] = dice[2][1];
            dice[2][1] = dice[1][1];
            dice[1][1] = dice[0][1];
            dice[0][1] = tmp;

            dice[2][3] = dice[0][1];
        } else if (movitation[i] == 'W') {
            tmp = dice[2][3];
            dice[2][3] = dice[2][2];
            dice[2][2] = dice[2][1];
            dice[2][1] = dice[2][0];
            dice[2][0] = tmp;

            dice[0][1] = dice[2][3];
        } else if (movitation[i] == 'E') {
            tmp = dice[2][0];
            dice[2][0] = dice[2][1];
            dice[2][1] = dice[2][2];
            dice[2][2] = dice[2][3];
            dice[2][3] = tmp;

            dice[0][1] = dice[2][3];
        }
    }
    cout << dice[2][3] << endl;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  vll a(n,-1);
  bool ok=true;
  rep(i,m) {
    ll s,c; cin>>s>>c;
    s--;
    if(a[s]==-1 || a[s]==c) a[s]=c;
    else ok=false;
  }
  if(!ok){
    cout<<-1<<endl;
    return 0;
  }
  
  if(n==1 && a[0]==-1){
    cout<<0<<endl;
    return 0;
  }
  
  if(n>1 && a[0]==0){
    cout<<-1<<endl;
    return 0;
  }
  
  ll ans=0;
  rep(i,n){
    if(a[i]==-1){
      if(i==0) a[i]=1;
      else a[i]=0;
    }
    ans=ans*10+a[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int mod = 1e9 + 9;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1 ;
	//cin >> t;
	while(t--){
		int n,k;
		cin >> n >> k;
		vector<int> h(n);
		for(int &a : h)
			cin >> a;
		vector<int> dp(n,mod);
		dp[0] = 0;
		for(int i = 0; i < n; i++){
			for(int j = i + 1; j <= i + k; j++){
				dp[j] = min(dp[j],dp[i] + abs(h[i] - h[j]));
			}
		}
		cout << dp[n-1] << endl;
	}
	return 0;
}


Measured memory_bytes: 3988
#include<bits/stdc++.h>
#define N 400005
using namespace std;
int n,m,x,y,q[N],b[N];
struct T
{
	int x,y;
}a[N];
bool cmp(T a,T b)
{
	return a.y>b.y;
}
int to[N*2],nxt[N*2],fst[N],l;
void link(int x,int y)
{
	to[++l]=y;nxt[l]=fst[x];fst[x]=l;
	to[++l]=x;nxt[l]=fst[y];fst[y]=l;
}
void biu()
{
	puts("No");
	exit(0);
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		link(x,y);
	}
	for (int i=1;i<=n;i++)
		b[i]=233333333;
	scanf("%d",&m);
	for (int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		a[i]=(T){x,y};
	}
	sort(a+1,a+m+1,cmp);
	int l=0,r=1,f=1;
	q[1]=a[1].x;b[a[1].x]=a[1].y;
	while(l<r)
	{
		l++;
		//cout<<q[l]<<endl;
		while(f<m&&a[f+1].y==b[q[l]])
		{
			f++;
			q[++r]=a[f].x;
			if (b[a[f].x]!=233333333&&b[a[f].x]!=a[f].y) biu();
			b[a[f].x]=a[f].y;
		}
		for (int i=fst[q[l]];i;i=nxt[i])
		if (b[to[i]]==233333333)
		{
			q[++r]=to[i];
			b[to[i]]=b[q[l]]-1;
		}
	}
	for (int i=1;i<=m;i++)
		if (b[a[i].x]!=a[i].y)biu();
	for (int i=1;i<=n;i++)
		for (int j=fst[i];j;j=nxt[j])
			if (abs(b[i]-b[to[j]])!=1) biu();
	puts("Yes");
	for (int i=1;i<=n;i++)
		printf("%d\n",b[i]);
}

Measured memory_bytes: 12672
#define _USE_MATH_DEFINES
#define MAX_N 1000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

static const double eps = 1e-8;

ll dp[100][100];

ll nCr(int n,int r){
	return dp[n][r] != -1 ? dp[n][r] : 
		dp[n][r] = (r==0|| n==r) ? 1 : nCr(n-1,r) + nCr(n-1,r-1);
}

int main(){
	memset(dp,-1,sizeof(dp));

	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		ll res=0;

		for(int i=0;i<=n;i++){
			for(int j=0;j<=n;j++){
				for(int k=0;k<=n;k++){
					if(i+2*j+3*k == n){
						res += nCr(i+j+k,i) * nCr((i+j+k)-i,j) * nCr((i+j+k)-i-j,k);
					}
				}
			}
		}

		printf("%lld\n",res/3650 + 1);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    int N,X,A[100000];
    ll cnt = 0;
    cin >> N >> X;
    for(int i = 0;i < N;i++){
        cin >> A[i];
        cnt += max(A[i]-X,0);
        A[i] = min(X,A[i]);
    }
    for(int i = 0;i < N-1;i++){
        if(A[i] + A[i+1] > X){
            ll dif = A[i+1]+A[i]-X;
            cnt += dif;
            A[i+1] -= dif;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int n = s.size();
	int ans = 0;
	rep(bit, 1 << (n - 1)) {
		int now = 0;
		rep(i, n) {
			now *= 10;
			now += s[i] - '0';
			if (bit & (1 << i)) {
				ans += now;
				now = 0;
			}
		}
		ans += now;

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

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            switch (Console.ReadLine())
            {
                case "Sunny":
                    Console.WriteLine("Cloudy");
                    break;
                case "Cloudy":
                    Console.WriteLine("Rainy");
                    break;
                case "Rainy":
                    Console.WriteLine("Sunny");
                    break;
            }
            Console.Read();
        }
    }
}

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

int main() {
  int n;
  cin>>n;
  pair<int,int> ba[200005];
  for (int i=0; i<n; i++)
    cin>>ba[i].second>>ba[i].first;
  sort(ba,ba+n);
  ll t=0;
  for (int i=0; i<n; i++) {
    t+=(ll)ba[i].second;
    if (t>ba[i].first) {
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}



Measured memory_bytes: 1792
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    int H, W;
    cin >> H >> W;
    char a[H][W];

    for(int i = 0; i < H; i++)
        for(int j = 0; j < W; j++)
            cin >> a[i][j];
    
    for(int i = 0; i < H + 2; i++)
    {
        for(int j = 0; j < W + 2; j++)
        {
            if(i > 0 && i < H + 1)
            {
                if(j > 0 && j < W + 1)
                {
                    cout << a[i-1][j-1];
                }
                else
                {
                    cout << '#';
                }
            }
            else
            {
                    cout << '#';
            }
       }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

S = input()
N = len(S)

s_cnt = 0
ans = 0
for i in range(N):
    if S[i] == 'S':
        s_cnt += 1
    else:
        if s_cnt == 0:
            ans += 1
        else:
            s_cnt -= 1
print(s_cnt + ans)

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

int main() {
    vector<int> v(3),v2(3);
    rep(i,3){
        int a; cin >> a;
        v[i]=a;
        v2[i]=a;
    }
    sort(v2.begin(),v2.end());
    if(v==v2 && v[0]!=v[1] && v[1]!=v[2])cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3104
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  vector<int> a(N), b(N);
  rep(i, N) { cin >> a[i] >> b[i]; }

  const int CLEN = H + 1;
  vector<int> cost(CLEN);

  rep(i, CLEN) {
    cost[i] = i == 0 ? 0 : H * 10'000;

    rep(j, N) { cost[i] = min(cost[i], cost[max(0L, i - a[j])] + b[j]); }
  }

  cout << cost[H] << endl;

  return 0;
}

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

using namespace std;

int main()
{
    int ans;
    string S, T, U1, U2;
    cin >> S;
    U1 = S;
    reverse(U1.begin(), U1.end());
    if (S == U1)
    {
        ans = 0;
    }
    else
    {
        for (int i = 0; i < S.size(); ++i)
        {
            if (S[i] != 'x')
            {
                T.push_back(S[i]);
            }
        }
        U2 = T;
        reverse(U2.begin(), U2.end());
        if (T != U2)
        {
            ans = -1;
        }
        else
        {
            int s = 0, t = 0;
            ans = 0;
            while (s < S.size() || t < U1.size())
            {
                if (s >= S.size())
                {
                    if (U1[t] == 'x')
                    {
                        ++ans;
                    }
                    ++t;
                }
                else if (t >= U1.size())
                {
                    ++s;
                }
                else if (U1[t] == 'x' && S[s] != 'x')
                {
                    ++t;
                    ++ans;
                }
                else if (U1[t] != 'x' && S[s] == 'x')
                {
                    ++s;
                }
                else
                {
                    ++s;
                    ++t;
                }
            }
        }
    }
    cout << ans << endl;
}


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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s; cin >> s;
    int len = s.size();
    if (s[len - 1] == 's') {
        s = s + "es";
    }
    else if (s[len - 1] != 's') {
        s = s + "s";
    }
    cout << s;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define PI acos(-1.0)
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define MOD 1000000007
#define MOD1 998244353
#define ep 0.000000001
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, 1};
int dy4[] = {1, -1, 1, -1};
//#define fio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int main()
{
    #ifndef ONLINE_JUDGE
    freopen ("in.txt", "r", stdin);
    freopen ("out.txt", "w", stdout);
    #endif
    ll a, b, c, d, ans;
    cin>>a>>b>>c>>d; vll v;
    v.pb(a*c);
    v.pb(a*d);
    v.pb(b*c);
    v.pb(b*d); sort(v.begin(), v.end());
    cout<<v.back()<<endl;
    return 0;
}
//https://thebestoffersintheweb.com/redirect/57a764d042bf8/

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
bool comp(int &a,int &b){
  return a>b;
}
struct Tree
{
  int node;
  vector<vector<int>> edge;
  vector<int> d;
  
  Tree(int _node){
    node = _node;
    edge.resize(node);
    rep(i,node) edge[i].resize(0);
    d.assign(node,-1);
  }
  
  void add(int from,int to){
    edge[from].push_back(to);
  }

  
  int dfs(int v){
    if(edge[v].size()==0) return 0;
    vector<int> vec(0);
    for(auto &w:edge[v]){
      if(d[w]==-1) vec.push_back(dfs(w));
      else vec.push_back(d[w]);
    }
    sort(vec.begin(), vec.end(),comp);
    int res = 0,j = 1;
    for(auto &w:vec){
      res = max(res,w+j);
      j++;
    }
    return d[v] = res;
  }
};
int main()
{
  int n;
  cin >> n;
  vector<int> a(n-1);
  rep(i,n-1){
    cin >> a[i];
    a[i]--;
  }

  Tree tr(n);

  rep(i,n-1){
    tr.add(a[i],i+1);
  }

  cout << tr.dfs(0) << "\n";
  
  return 0;
}


Measured memory_bytes: 13824
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8[:], ), cache=True)
def is_pair_copr(A):
    U = 1 << 20
    div_p = np.arange(U)
    for p in range(2, U):
        if div_p[p] != p:
            continue
        div_p[p::p] = p
    used = np.zeros(U, np.bool_)

    for x in A:
        while x > 1:
            p = div_p[x]
            while x % p == 0:
                x //= p
            if used[p]:
                return False
            used[p] = True
    return True

def main(A):
    U = 1 << 20
    # a prime factor of N
    pair = is_pair_copr(A)
    g = np.gcd.reduce(A)
    se = g == 1
    if pair:
        return 'pairwise coprime'
    if se:
        return 'setwise coprime'
    return 'not coprime'

A = np.array(read().split(), np.int64)[1:]

print(main(A))

Measured memory_bytes: 169752
#include<cstdio>
using namespace std;
int main(void)
{
	int n,i,x,y,b,p;
	int kin1,kin2;
	int m;
	scanf("%d",&n);
	for(i=0;i<n;i++)	{
		scanf("%d %d %d %d",&x,&y,&b,&p);
		kin1=x*b+y*p;
		if(b<5)	b=5;
		if(p<2)	p=2;
		kin2=(x*b+y*p)*4/5;
		if(kin2<kin1)	{
			printf("%d\n",kin2);
		}
		else {
			printf("%d\n",kin1);
		}
	}
	return 0;
}


Measured memory_bytes: 1032
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
char c[50][50];
int cnt[50][50];
int n,m;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>c[i][j];
			if(c[i][j]=='#'){
				for(int dx=-1;dx<=1;dx++){
					for(int dy=-1;dy<=1;dy++){
						if(!dx&&!dy) continue;
						int nx=i+dx,ny=j+dy;
						if(0<=nx&&nx<n&&0<=ny&&ny<m) cnt[nx][ny]++;
					}
				} 
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++)
			if(c[i][j]=='.') cout<<cnt[i][j];
			else cout<<'#';
		cout<<"\n";
	}
		
	re 0;
}

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

int main(){
    int n;
    cin>>n;
    
    int h[n+1];
    for(int i=1 ;i<=n;i++) cin>>h[i];
    
    int dp[n+1];
    
    for(int i=2;i<=n;i++){
        dp[1]=0;
        if(i==2)dp[2]  =abs(h[2]-h[1]);
        else{
            dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i-2]-h[i]));
        }
    }
    
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int N,K;cin>>N>>K;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  set<int> s;
  for(int i=0;i<K;i++)s.insert(v[i]);
  int ans=1;
  for(int i=K;i<N;i++){
    bool f=false;
    if(v[i-K]!=*s.begin())f=true;
    if(v[i]<*s.rbegin())f=true;
    //cout<<i<<" "<<*s.begin()<<" "<<*s.rbegin()<<endl;
    ans+=f;
    s.erase(v[i-K]);
    s.insert(v[i]);
    //cout<<i<<" "<<ans<<endl;
  }
  int mn=INF,mx=-1;
  int cnt=0;
  int a=0;
  for(int i=0;i<N;i++){
    if(mx<v[i]){
      cnt++;
    }
    else cnt=1;
    mx=v[i];
    if(cnt>=K){
      a++;
      cnt=-INF;
    }
  }
  //cout<<ans<<endl;
  //cout<<a<<endl;
  ans-=max(0LL,a-1);
  fin(ans);
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define ll long long
#define all(x) x.begin(),x.end()
#define TESTCASES 0
using namespace std;

const int MaxN = 2e5 + 5;
int n;
string s;


int Dp[2020];


int Go() {

  cin >> s;
  
  n = s.length();
  
  vector<int> A(n + 1,0);

  int k = 2019;
  int t = 1;

  for(int i = n - 1 ; 0 <= i ; --i){
    int c = s[i] - '0';
    A[i] = (t * c) % k;
    t = (t * 10) % k;
  } 

  for(int i = n - 1 ; 0 <= i ; --i){
    A[i] += A[i + 1];
    A[i] %= k;
  }

  map<int,ll> Mp;
  
  ll Ans = 0;

  for(int i = 0 ; i <= n ; ++i){
    
    if(Mp[A[i]]) Ans += Mp[A[i]];

    Mp[A[i]]++;
  }
  
  cout << Ans << endl;

 
  return 0;
}


int main() {


  int t;
  if (TESTCASES) scanf("%d", &t);
  else           t = 1;

  while (t--) Go();
}

Measured memory_bytes: 4452
public class Main {
	public static void main(String[] args) {
		for (int i = 0; i < 9; i++) {
			for (int j = 0; j < 9; j++) {
				int ni = i + 1;
				int nj = j + 1;
				int a = ni * nj;
				System.out.println(ni + "x" + nj + "=" + a);
			}
		}
	}
}

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

#define int long long int
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
bool sortbysecdesc(const pair<int,int> &a, 
                   const pair<int,int> &b) 
{ 
       return a.second>b.second; 
} 
 
/*
Mistakes
 
- while using pairs make sure you comparator datatype it's int by default change it as per the need
- Modify comparator if you want to
*/
#define f first
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll64 int64_t
#define pb push_back
#define pll pair<long long int,long long int>
#define pi pair<int,int>
#define mi map<int,int>
#define mll map<long long int,long long int>
#define umi unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define vpi vector<pair<int,int>>
#define vpll vector<pair<long long int,long long int>>
#define mod 1000000007
#define fp(i,x,n) for(int i=x;i<n;i++)
#define fn(i,x,n) for(int i=x;i>n;i--)
#define fpm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define asort_vp_second(vect) sort(vect.begin(), vect.end(), sortbysec)
#define asort_vp_first(vect) sort(vect.begin(), vect.end())
#define dsort_vp_first(vect) sort(vect.begin(), vect.end(), sortinrev) 
#define dsort_vp_second(vect) sort(vect.begin(), vect.end(), sortbysecdesc)
#define vi vector<int>
#define vll vector<long long int>
#define c(x) cout<<x<<endl;
#define M 1000000007
using namespace std; 

signed main()
{
    int n,x,t;
    cin>>n>>x>>t;
    
    int f = (n*t)/x;
    int z  = ceil((double)f/t);
    z=z*t;
    cout<<z<<endl;
}


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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


int main() {
  int q, r, l, ans;
  cin >> q;
  vector<int> s(100001, 0);
  

  //累積の計算
  for (int i =1; i< 100001; i++){
    if (IsPrime(i) && IsPrime((i+1)/2)) {
        s.at(i) = s. at(i-1) + 1;
    }else{
        s.at(i) = s. at(i-1);
    }
    //cout << s.at(i) << endl;
  }

  
 
  for (int i=1; i < q+1 ; i++){
    cin >> r >> l;
    ans = s.at(l) - s.at(r-1);
    cout << ans << endl;
  } 

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
  //入れ物を用意
  double a, b;
  // 入力を受け取る
  cin >> a >> b;
  double c = (a + b) / 2;
  cout << ceil(c) << endl;
}

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

int main(){
    string S;
    long result=0;
    long count=0;
    cin >> S;
    for(long i=0;i<S.size();i++){
        if(S[i]=='W'){
            result += i-count;
            count++;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 640
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,len=0,n0001,n01,n10,ans=0,res,ach10,ach01;
pii a[100010],b[100010];
vector <pair <LL,pii> > v;
vector <pii> ch11,ch00;

void chmin(int i,int j)
{
	if(ch11[i].se==ch00[j].se) return;
	ans=min(ans,res+ch11[i].fi+ch00[j].fi);
}

int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>a[i].fi>>a[i].se;
		v.pb({a[i].fi,{i,0}});
		v.pb({a[i].se,{i,1}});
	}
	sort(v.begin(),v.end());
	rep(i,n)
	{
		ans+=v[i].fi;
		if(v[i].se.se==0) b[v[i].se.fi].fi=1;
		else b[v[i].se.fi].se=1;
	}
	rep(i,n)
	{
		if((b[i].fi==0&&b[i].se==0)||(b[i].fi==1&&b[i].se==1)) n0001++;else
		if(b[i].fi==0&&b[i].se==1) n01++;else
		n10++;
	}
	if(n0001>0||(n0001==0&&(n01==0||n10==0)))
	{
		cout<<ans<<endl;
		rt0;
	}
	res=ans;
	ans=1e18;
	rep(i,n)
	{
		if(b[i].fi==1&b[i].se==0)
		{
			ch11.pb({a[i].se,i});
			ch00.pb({-a[i].fi,i});
			ach01+=a[i].se-a[i].fi;
		}
		else
		{
			ch11.pb({a[i].fi,i});
			ch00.pb({-a[i].se,i});
			ach10+=a[i].fi-a[i].se;
		}
	}
	sort(ch11.begin(),ch11.end());
	sort(ch00.begin(),ch00.end());
	chmin(0,0);
	chmin(0,1);
	chmin(1,0);
	ans=min(ans,min(res+ach01,res+ach10));
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 14444
X, Y, Z, K = map(int, input().split())
A, B, C = [sorted(list(map(int, input().split())))[:: -1][: K] for _ in range(3)]
D = []
for ai in A:
    for bi in B:
        D.append(ai + bi)

D = sorted(D)[:: -1][: K]

res = []
for di in D:
    for ci in C:
        res.append(di + ci)

res = sorted(res)[:: -1][: K]

for ans in res:
    print(ans)


Measured memory_bytes: 146520
/* created   : 2019-10-07 19:26:16
 * accepted  : 2019-10-07 21:45:31
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

template <class T>
vector<int> prime_factor(T n) {
  vector<int> fact;
  for (T i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      fact.push_back(i);
      while (n % i == 0) {
        n /= i;
      }
    }
  }
  if (n > 1) {
    fact.push_back(n);
  }
  return fact;
}

void solve() {
  ll a, b; cin >> a >> b;
  ll g = __gcd(a, b);
  auto fact = prime_factor<ll>(g);
  cout << fact.size() + 1 << '\n';
}

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


Measured memory_bytes: 256
s = input()
count_o = 0
count_z = 0

for i in range(0, len(s), 2):
	if s[i] == '1':
		count_o += 1
	else :
		count_z += 1
	if i + 1 < len(s):
		if s[i+1] == '0':
			count_o += 1
		else :
			count_z += 1
print(min(count_z, count_o))
	

Measured memory_bytes: 3188
#include <stdio.h>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	int x=a+b;
	int y=b+c;
	int z=a+c;
	if(x<y && x<z){
		printf("%d",x);
	}else if(y<x && y<z){
		printf("%d",y);
	}else if(z<x && z<y){
		printf("%d",z);
	}else if(x==y && y==z && x==z){
		printf("%d",x);
	}
return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**8)
def line_to_int(): return int(sys.stdin.readline())
def line_to_each_int(): return map(int, sys.stdin.readline().split())
def line_to_list(): return list(map(int, sys.stdin.readline().split()))
def line_to_list_in_iteration(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
# def dp(init, i, j): return [[init]*i for i2 in range(j)]
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
# from itertools import accumulate #A = [0]+list(accumulate(A))
# import bisect #bisect.bisect_left(B, a), bisect.bisect_right(B,a)

n = line_to_int()
a = line_to_list()

# from functools import reduce, partial
# from operator import mul

# prod = partial(reduce, mul)

# if 0 in a:
#     print(0)
# else:
#     if prod(a) <= 10**18:
#         print(prod(a))
#     else:
#         print(-1)
ans = a[0]
limit = 10**18
if 0 in a:
    print(0)
else:
    for i in range(1,n):
        if ans <= limit:
            ans = ans * a[i]
        else:
            print(-1)
            exit()
    if ans <= limit:
        print(ans)
    else:
        print(-1)

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

using namespace std;
const int INF = 0x3f3f3f3f;
const int L = 12;

int dp[1<<L];

void solve() {
    int n,m;
    cin >> n >> m;
    const int MSK = 1<<n;

    memset(dp, INF, sizeof dp);
    dp[0] = 0;
    for (int _ = 0; _ < m; _++) {
        int cost, _n;
        cin >> cost >> _n;
        int k = 0;
        for (int __ = 0; __ < _n; __++) {
            int x; cin >> x;
            k |= 1<<(x-1);
        }

        for (int msk = MSK-1; msk >= 0; msk--) {
            dp[msk|k] = min(dp[msk|k], dp[msk] + cost);
        }
    }
    if (dp[MSK-1] == INF) dp[MSK-1] = -1;
    cout << dp[MSK-1];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
S = input()
N = len(S)

curr = ["R","L"]
idx = 0
cnt = 0
E = []
for i, ch in enumerate(S):
  if ch != curr[idx]:
    E.append((idx,cnt))
    cnt = 1
    idx = 1 - idx
  else:
    cnt += 1
    
E.append((idx,cnt))
#print(E)

ans = []
for i in range(0,len(E),2):
  Rcnt = E[i][1]
  Lcnt = E[i+1][1]
  Rfill = Lfill = (Rcnt + Lcnt)//2
 
  if (Rcnt + Lcnt) % 2 == 1:
    if Rcnt % 2 == 1:
      Rfill += 1
    else:
      Lfill += 1
  
  for i in range(Rcnt - 1):
    ans.append(0)
  
  ans.append(Rfill)
  ans.append(Lfill)
  
  for i in range(Lcnt - 1):
    ans.append(0)

  
print(*ans,sep=" ")

Measured memory_bytes: 18664
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    w,a,b=MI()
    if a<=b<=a+w or a<=b+w<=a+w:ans=0
    else:ans=min(abs(a+w-b),abs(b+w-a))
    print(ans)

main()

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


using namespace std;

using ull = unsigned long long;

int main() {
    ull K, N;
    cin >> N >> K;
    vector<ull> p(N);
    for (ull i = 0; i < N; i++) {
        cin >> p[i];
    }
    ull acc = accumulate(p.begin(), p.begin() + K, 0LL);
    ull max_acc = acc;
    auto b = p.begin();
    for (auto it = p.begin() + K; it != p.end(); ++it) {
        acc -= *(it - K);
        acc += *it;
        max_acc = max(acc, max_acc);
        if (max_acc == acc) {
            b = it - K + 1;
        }
    }
    double ans = 0;
    for (auto it = b; it != b + K; it++) {
        ans += (double)(1 + *it) / 2.;
    }
    printf("%.12f\n", ans);
}


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

int main(void){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    double r = 0.0;
    pair<int,int> ans;

    for(int i=0; i*a*100<=f; i++){
        for(int j=0; i*a*100+j*b*100<=f; j++){
            if(i == 0 && j == 0){
                continue;
            }
            int w = i*a*100 + j*b*100;
            for(int k=0; w+k*c<=f; k++){
                for(int l=0; w+k*c+l*d<=f; l++){
                    int s = k*c + l*d;
                    double m = (double)s/(w+s);
                    if(m <= (double)e/(100+e) && m >= r){
                        ans.first = w+s;
                        ans.second = s;
                        r = m;
                    }
                }
            }
        }
    }

    cout << ans.first << " " << ans.second << endl;

    return 0;
}

Measured memory_bytes: 256
const Main = (input) => {
  const lines = input.split("\n");
  const [n, k] = lines[0].split(' ');
  const hs = lines[1].split(' ');
  let able = hs.filter(h => Number(h) >= Number(k));
  console.log(able.length);
};

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 27724
import sys

def LCS():
    str1=input()
    str2=input()

    l=len(str1)
    m=len(str2)
    x1=[0 for i in range(m+1)]
    for i in range(l):
        e1=str1[i]
        x2=x1+[]
        for j in range(m):
            if e1 == str2[j]:
                x1[j+1] = x2[j] + 1
            elif x1[j+1]<x1[j]:
                x1[j+1] = x1[j]
    return x1[-1]

n = int(input())
for i in range(n):
    
    print(LCS())



Measured memory_bytes: 5640
n=[]
n.push(gets.chomp.to_i)
n.push(gets.chomp.to_i)
n.push(gets.chomp.to_i)
n.push(gets.chomp.to_i)
n.push(gets.chomp.to_i)

cnt=0
rest=10
for i in 0..4
    if n[i]%10==0
        cnt+=n[i]
    else
        cnt+=n[i]/10*10+10
        if rest>n[i]%10
            rest=n[i]%10
        end
    end
   # puts cnt
end

puts cnt+rest-10

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	final int MAX_M = 100 * 1000;
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int n = scan.nextInt();
			if (n == 0)
				return;
			int[] p = new int[n];
			for (int i = 0; i < n; i++)
				p[i] = scan.nextInt();
			
			int[][] dp = new int[n + 1][MAX_M];
			int[][] ans = new int[n + 1][MAX_M];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < MAX_M; j++) {
					dp[i][j] = -1;
					ans[i][j] = MAX_M;
				}
			}

			dp[0][0] = 0;
			ans[0][0] = 0;
			
			for (int i = 0; i < n; i++) {
				// 商品を買わない
				for (int j = 0; j < MAX_M; j++) {
					dp[i + 1][j] = dp[i][j];
					ans[i + 1][j] = ans[i][j];
				}

				// 商品を買う
				int change = (p[i] % 1000 == 0) ? 0 : (1000 - p[i] % 1000);
				for (int j = 0; j < MAX_M; j++) {
					if (dp[i][j] == -1) continue;

					int get500Coin = j + change < 500 ? 0 : 1;
					int nextMoney = j + change - (500 * get500Coin);
					if (dp[i + 1][nextMoney] < dp[i][j] + get500Coin) {
						dp[i + 1][nextMoney] = dp[i][j] + get500Coin;
						ans[i + 1][nextMoney] = ans[i][j] + p[i];
					} else if (dp[i + 1][nextMoney] == dp[i][j] + get500Coin) {
						ans[i + 1][nextMoney] = Math.min(ans[i + 1][nextMoney], ans[i][j] + p[i]);
					}
				}
			}
			
			int maxMAX_MCoin = 0;
			int minPay = 0;
			for (int i = 0; i < MAX_M; i++) {
				if (maxMAX_MCoin < dp[n][i]) {
					maxMAX_MCoin = dp[n][i];
					minPay = ans[n][i];
				} else if (maxMAX_MCoin == dp[n][i]) {
					minPay = Math.min(minPay, ans[n][i]);
				}
			}
			System.out.println(maxMAX_MCoin + " " + minPay);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 641880
N = int(input())
points = sorted([list(map(int, input().split())) for i in range(N)], key=lambda x: -x[2])

for cx in range(101):
    for cy in range(101):
        # 初期化
        H = -1
        for point in points:

            if point[2] > 0:
                h = abs(point[0] - cx) + abs(point[1] - cy) + point[2]
                if H == -1:
                    H = h
                elif H != h:
                    H = -2
                    break
            else:
                if H > abs(point[0] - cx) + abs(point[1] - cy) + point[2]:
                    H = -2
                    break
        if H > 0:
            print(cx, cy, h)
            exit()


Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int count[n] ={};
    int manager[n] = {};
    manager[0] = -1;
    for(int i=1;i<n;++i)
    {
        cin >> manager[i];
        --manager[i];
    }

    for(int i=n-1;i>0;--i)
    {
        int man = manager[i];
        count[man] += 1;
    }

    for(int i=0;i<n;++i)
    {
        cout << count[i] << endl;
    }
}

Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define pii pair< int,int>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define ll long long int
#define mod 1000000007
#define mxn 2000010
#define sqr 320
ll arr[1000002],n,x;
int main() {
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
     ll n,a,b;
     cin>>n>>a>>b;
     cout<< (((b-a)%2) ? "Borys" :"Alice") ;
     return 0;
    }

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

using namespace std;

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

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pii, pii> ppp;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int W, H;
pii tp, kp;
int maps[50][50];
map<ppp, int> dp;

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

bool ok(pii p) {
	if (!(p.fi >= 0 && p.fi < H && p.se >= 0 && p.se < W)) return false;
	if (maps[p.fi][p.se] == 1) return false;
	return true;
}

int main() {
	while (cin >> W >> H, W || H) {
		cin >> tp.se >> tp.fi >> kp.se >> kp.fi;
		tp.se--; tp.fi--; kp.se--; kp.fi--;
		REP(i, H) REP(j, W) scanf("%d", &maps[i][j]);
		
		dp.clear();
		
		queue<ppp> que;
		que.push(ppp(tp, kp));
		dp[ppp(tp, kp)] = 0;
		int ans = INF;
		
		while (!que.empty()) {
			pii p1 = que.front().fi, p2 = que.front().se;
			que.pop();
			int c = dp[ppp(p1, p2)];
			
			if (p1 == p2) { chmin(ans, c); break; }
			if (c == 100) break;
			
			REP(i, 4) {
				pii np1(p1.fi + dy[i], p1.se + dx[i]);
				pii np2(p2.fi + dy[(i+2)%4], p2.se + dx[(i+2)%4]);
				
				bool o1 = ok(np1), o2 = ok(np2);
				
				if (!o1 && !o2) continue;
				ppp next(o1 ? np1 : p1, o2 ? np2 : p2);
				if (dp.find(next) != dp.end()) continue;
				dp[next] = c + 1;
				que.push(next);
			}
		}
		
		if (ans == INF) puts("NA");
		else cout << ans << endl;
		
	}
	return 0;
}

Measured memory_bytes: 14252
n = int(input())
R =[]
for i in range(n):
 R.append(int(input()))

maxR = R[1]
minR = R[0]
maxB = R[1] - R[0]
for i in range(1,n):
 if R[i] < minR:
  minR = R[i]
  maxR = R[i] - 1
 elif minR <= R[i] and R[i] <= maxR:
  continue
 else:
  maxR = R[i]
  if maxR - minR > maxB:
   maxB = maxR - minR

print(str(maxB))

Measured memory_bytes: 15600
#include <bits/stdc++.h>
using namespace std;
#define X ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(2)<<(x)
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
 
// long long p = 1e9+7;
 
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<int> VI;
typedef vector<pair<ll,ll>> VP;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<bool> VB;
 
// typedef pair<ll, ll> PL;
typedef unordered_map<ll, ll> UMP;
#define FOR(i,b,init) for(i=init;i<b;i++)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
 
// typedef  unordered_set<ll>;
 
 
// void printa(VI &x,ll n){
//     ll i;
//     FOR(i, n){
//         cout<<x[i]<<" ";
//     }
//     cout<<endl;
// }
 
 

/////GLOABLS VARS
ll MOD = 1e9+7;
ll gmx = 1e6+7; 

VL fact(gmx, 1);
//////FUNCTIONS
ll powp(ll val, ll deg)
{
    // debug(val, deg);
    if (!deg)
        return 1;
    if (deg & 1)
        return (powp(val, deg - 1) * val) % MOD;
    ll res = powp(val, deg >> 1);
    // debug(res);
    return (res * res) % MOD;
}
ll mx=1e5+7;
vector<VL> adj;
VL sub;
ll n;

void dfs(ll r, ll parent){
    sub[r]=1;
    // debug(r,parent);
    for(auto k: adj[r]){
        if(k==parent){continue;}
        dfs(k, r);
        sub[r]+=sub[k];
    }
    return;
}

//It is not easy but it can be fun, if you think!!!

//
// ll mx = 2*1e5+7;
// vector<vector<pl>> adj;
//dp[i] =(k-1)*dp[i-1]
// (k-1)**(n-2)-(k-1)**(n-3)
//

long countArray(int n, int k, int x) {
    // Return the number of ways to fill in the array.


}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
    #endif


    ll t,i,d,s;
    cin>>d>>t>>s;
    if(d>t*s){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
    // 1 3 1
    // cin>>t;
    // FOR(i,t,0){
    //     ll n;
    //     cin>>n;
        
    // }


   
}


Measured memory_bytes: 11028
using System;

namespace ABC_042_A_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            var word = Console.ReadLine().Split(' ');
            int A = int.Parse(word[0]);
            int B = int.Parse(word[1]);
            int C = int.Parse(word[2]);
            int r = A + B + C;
            if (r - 7 == 10)
            {
                if (A == B || A == C || C == B)
                { 
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
            else
            {
                Console.WriteLine("NO");
            }
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
n = int(input())
ps = list(map(int, input().split()))

ans = 0
for i in range(1, n - 1):
    window = (ps[i-1], ps[i], ps[i+1])
    if ps[i] != min(window) and ps[i] != max(window):
        ans += 1

print(ans)

Measured memory_bytes: 3060