akhauriyash/Code-Regression huggingface dataset:
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scan(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}

// header
int n;
vector<int> a;
void input(){
    cin>>n;
    scan(n,a);
}
void src(){
    int s=*min_element(ALL(a));
    int e=*max_element(ALL(a));
    vector<int> b(e-s+1);
    iota(ALL(b),s);
    transform(ALL(b),b.begin(),[](auto x){int sum=0;rep(i,n) sum+=(x-a[i])*(x-a[i]);return sum;});
    cout<<*min_element(ALL(b));
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N=0;
  cin>>N;
  vector<int> vec(N,0);
  for(int i=0; i<N; i++){
    cin>>vec.at(i);
  }
  int64_t sum=0;
  for(int i=1; i<N; i++){
    if(vec.at(i-1)>vec.at(i)){
      sum+=vec.at(i-1)-vec.at(i);
      vec.at(i)=vec.at(i-1);
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3960
#include <algorithm>
#include <array>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
auto constexpr infty<int> = 1'100'100'100;
template<>
auto constexpr infty<long long int> = 1'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

namespace { // Graph Basics

template<typename WeightT>
struct Edge {
  int from, to;
  WeightT weight;
  Edge(int s, int d, WeightT w): from(s), to(d), weight(w) {}
};

template<typename WeightT>
bool
operator< (Edge<WeightT> const &lhs, Edge<WeightT> const &rhs) {
  if (lhs.weight != rhs.weight) {
    return lhs.weight < rhs.weight;
  } else if (lhs.from != rhs.from) {
    return lhs.from < rhs.from;
  }
  return lhs.to < rhs.to;
}

template<typename WeightT>
using Edges = std::vector<Edge<WeightT> >;

template<typename WeightT>
using AdjacencyList = std::vector<Edges<WeightT> >;

template<typename WeightT>
void
add_undir_edge(AdjacencyList<WeightT> &graph, int u, int v, WeightT w) {
  graph[u].emplace_back(u, v, w);
  graph[v].emplace_back(v, u, w);
}

} // namespace

namespace { // Dijkstra's algorithm

template<typename WeightT>
struct DijkstraResult {
  std::vector<WeightT> distance;
};

template<typename WeightT>
DijkstraResult<WeightT>
dijkstra_algorithm(AdjacencyList<WeightT> const &g, int start, WeightT inf) {
  int const N = g.size();
  std::vector<bool> done(N, false);
  std::vector<WeightT> dist(N, inf);
  using P = std::tuple<WeightT, int>;
  std::priority_queue<P, std::vector<P>, std::greater<P> > que;
  que.emplace(0, start);
  while (!que.empty()) {
    WeightT dist2u; int u; std::tie(dist2u, u) = que.top();
    que.pop();
    if (dist2u >= dist[u]) {
      continue;
    }
    dist[u] = dist2u;
    for (auto &&e : g[u]) {
      que.emplace(dist2u + e.weight, e.to);
    }
  }
  return {
    dist
  };
}

} // namespace

using namespace std;

using Graph = AdjacencyList<lli>;

void solve(Graph const &g) {
  auto const res = dijkstra_algorithm(g, 0, infty<lli>);
  REP(i, g.size()) {
    cout << (res.distance[i] % 2 == 0 ? 0 : 1) << '\n';
  }
}

int main() {
  // cout << fixed << setprecision(10);

  int N;
  cin >> N;
  Graph g(N);
  REP(i, N-1) {
    int U, V, W;
    cin >> U >> V >> W;
    add_undir_edge(g, --U, --V, (lli)W % 2);
  }
  solve(g);
  return 0;
}


Measured memory_bytes: 9344
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
p = 0
l = -1
for a in A:
    p += B[a-1]
    if a-l == 1:
        p += C[l-1]
    l = a
print(p)

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

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  long long cnt=0;
  bool hantei=false;
  int start=0;
  for(int i=0;i<n;i++){
    if(a[i]==i+1){
      int tmp=a[i];
      if(i!=n-1){
        a[i]=a[i+1];
        a[i+1]=tmp;
        cnt++;
      }else{
        for(int j=n-2;j>=0;j--){
          cnt++;
          if(a[j]!=n&&a[i]!=j+1)break;
        }
      }
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
static long ModInv(long a,long m){return Modpow(a,m-2,m);}
static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
static long[] f;
static long mod=(long)1e9+7;
//......................................@uthor_Alx..............................................

   public static void main(String[] args) throws  IOException{
				assign();
				int t=1;//int_v(read()),cn=1;
				while(t--!=0){
					int n=int_v(read());
					int[] arr=int_arr();
					int[] f=new int[n];
					for(int i:arr){f[i]++;}
					boolean b=true;
					if((n%2==0&&f[0]>0)||f[0]>1){b=false;}
					if(n%2==0){
						for(int i=1;i<n;i+=2){
							if(f[i]!=2){
								b=false;break;
							}
						}
					}
					if(n%2==1){
						for(int i=2;i<n;i+=2){
							if(f[i]!=2){
								b=false;break;
							}
						}
					}
					if(!b){
						out.write("0");
					}
					else{
						out.write(Modpow(2l,n/2,mod)+"");
					}
					
				}
			    
			    out.flush();

	}
}

	       

	       


Measured memory_bytes: 41268
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  cin >> n;
  m = 0;
  lep(i,1,n){
    m += i;
  }
  print(m);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf INT_MAX
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(int *)a-*(int *)b;
}

int main(void){
	int x=in(),a=in(),b=in(),t;
	t=b-a;
	if(t<=0){
		puts("delicious");
	}
	else if(t<=x){
		puts("safe");
	}
	else{
		puts("dangerous");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define lli long long int
#define fw(i, s, e) for (ll i = s; i < e; ++i)
#define fe(i, s, e) for (ll i = s; i <= e; ++i)
#define fb(i, e, s) for (ll i = e; i >= s; --i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define mem(a, i) memset(a, i, sizeof(a))
#define ld long double
#define endl "\n"
#define in(P) \
    ll P;     \
    cin >> P;
int main()
{
    FASTIO
    in(n);
    in(a);
    in(b);

    // if (a + b >= n)
    // cout << a << endl;
    // else
    {
        ll t = n / (a + b) * a;
        ll rem = n - n / (a + b) * (a + b);
        cout << t + min(a, rem) << endl;
    }

    return 0;
}

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

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

Measured memory_bytes: 764
import sys
sys.setrecursionlimit(10 ** 9)
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

n, m = I()
a = sorted(I())
q = []
for i in range(m):
    q.append(I())
q.sort(key = lambda x: (x[1], x[0]), reverse = True)
cur = 0
for b, c in q:
    while cur < n and a[cur] >= c:
        cur += 1
    while cur < n and b and a[cur] < c:
        b -= 1
        a[cur] = c
        cur += 1
print(sum(a))

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

int main() {
  string A;
  int N=0, S=0, E=0, W=0;
  cin >> A;
  rep(i, A.size()){
    if(A.at(i)=='N') N=1;
    else if(A.at(i)=='S') S=1;
    else if(A.at(i)=='E') E=1;
    else if(A.at(i)=='W') W=1;
  }
  if(N+S==1 || E+W==1) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def solve(n,s=""):
    if n == 0:
        return s
    else:
        return solve((n-1-26)//26+1,str(chr(ord("a")+(n-1)%26))+s)



def main():
    N = int(input())
    print(solve(N))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9152
#include <stdio.h>

int
main(void)
{
  int a, b;
  while(1) {
    scanf("%d%d", &a, &b);
    if (a == 0 && b == 0) {
      break;
    }
    if (a > b) {
      printf("%d %d\n", b, a);
    } else {
      printf("%d %d\n", a, b);
    }
  }
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int n;
map<int, int> gu, ki;
vector<int> kazu;

void disp(int i)
{
    cout << i << endl;
    exit(0);
}

int main()
{
    cin >> n;
    kazu.resize(n);
    REP(i, n / 2)
    {
        int j, k;
        cin >> j >> k;
        kazu[2 * i] = j;
        kazu[2 * i + 1] = k;
        gu[j]++;
        ki[k]++;
    }
    if (gu.size() == 1 && ki.size() == 1 && kazu[0] != kazu[1]) disp(0);
    if (gu.size() == 1 && ki.size() == 1) disp(n / 2);

    priority_queue<pint, vector<pint>> gus, kis;
    for (auto pa : gu) gus.push(pint(pa.second, pa.first));
    for (auto pa : ki) kis.push(pint(pa.second, pa.first));



    if (gus.top().second != kis.top().second) disp(n - gus.top().first - kis.top().first);
    if (gu.size() == 1)
    {
        while (gus.top().second == kis.top().second) kis.pop();
        disp(n - gus.top().first - kis.top().first);
    }
    if (ki.size() == 1)
    {
        while (gus.top().second == kis.top().second) gus.pop();
        disp(n - gus.top().first - kis.top().first);
    }

    int u = gus.top().first;
    int v = kis.top().first;
    gus.pop();
    kis.pop();
    int ans = max(u + kis.top().first, v + gus.top().first);
    disp(n - ans);
}


Measured memory_bytes: 6524
// inputに入力データ全体が入る
function Main(input) {
	input = input.split("\n");
	var line = input[0].split(" ");
	var ball = parseInt(line[0]);
	var color = parseInt(line[1]);
	console.log(color*Math.pow(color-1,ball-1));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <algorithm>
#include <iostream>
#include <stdio.h>

using namespace std;

int main(void){
    int i,IMAX=0,num[100]={0},a,ans=0,max=0;
    while(cin >> a){
        num[a-1]++;
        IMAX++;
    }
    for(i=0;i<IMAX;i++){
        if(max<num[i]){
            max=num[i];
            ans=i+1;
        }
    }
    cout << ans << endl;
    for(i=ans;i<IMAX;i++){
        if(max==num[i]) cout << i+1 << endl;
    }

    return 0;
}

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

int main(void){
  string s,t;
  int count=0;
  cin>>s>>t;
  if(s[0]==t[0])	count++;
  if(s[1]==t[1])	count++;
  if(s[2]==t[2])	count++;
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <cstdio>

int a[100005];

int main()
{
    int n, k, q; scanf("%d%d%d", &n, &k, &q);
    for (int i = 0; i < q; i++)
    {
        int x; scanf("%d", &x);
        a[x]++;
    }
    for(int i = 1; i <= n; i++)
        printf(k - q + a[i] > 0 ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(Int i = 0; i < (Int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    Int a, v; cin >> a >> v;
    Int b, w; cin >> b >> w;
    Int t; cin >> t;
    bool a_win = false;
    if(a > b)
    {
        a -= v * t;
        b -= w * t;
        if(a <= b)
        {
            a_win = true;
        }
        else
        {
            a_win = false;
        }
    }
    else
    {
        a += v * t;
        b += w * t;
        if(a >= b)
        {
            a_win = true;
        }
        else
        {
            a_win = false;
        }
    }
    cout << (a_win ? "YES" : "NO") << endl;
    
}

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

Measured memory_bytes: 3652
package main

import "fmt"

var N, X, Y int
var arr = make([]bool, 2001)
var ans = map[int]int{}

func main() {
	fmt.Scan(&N, &X, &Y)
	for i := 1; i<=N; i++ {
		queue := []int{i}
		visited := map[int]bool{ i: true }
		for k := 1; k<=N-1; k++ {
			nextQueue := []int{}
			for _, v := range queue {
				if v != 1 && !visited[v-1] {
					visited[v-1] = true
					nextQueue = append(nextQueue, v-1)
				}
				if v != N && !visited[v+1] {
					visited[v+1] = true
					nextQueue = append(nextQueue, v+1)
				}
				if v == X && !visited[Y] {
					visited[Y] = true
					nextQueue = append(nextQueue, Y)
				}
				if v == Y && !visited[X] {
					visited[X] = true
					nextQueue = append(nextQueue, X)
				}
			}
			ans[k] += len(nextQueue)
			queue = nextQueue 
		}
	}
	for i := 1; i <= N-1; i++ {
		fmt.Println(ans[i]/2)
	}
}


Measured memory_bytes: 7684
#include <iostream>
#include <fstream>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cassert>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <list>
#include <forward_list>
#include <array>
#include <cstring>
#include <cmath>
#include <tuple>
#include <complex>
#include <bitset>
#include <climits>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pld = pair<LD, LD>;
const int M = 1e9 + 7;


inline int my_mod(const int a, const int m = M)
{
    return (a % m + m) % m;
}


int comp(const int sum_so_far, const int cur_nr)
{
    return my_mod(sum_so_far + cur_nr);
}


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

    int N, K;
    cin >> N >> K;

    vector<int> nrs(N + 1), pref(N + 1), suff(N + 1);
    iota(begin(nrs), end(nrs), 0);
    partial_sum(begin(nrs), end(nrs), begin(pref), comp);  // prefix sum.
    partial_sum(nrs.rbegin(), nrs.rend(), begin(suff), comp);  // suffix sum.
    /*for (int i = 0; i <= N; ++i)
    {
        cout << "pref[" << i << "]: " << pref[i] << endl;
    }
    cerr << endl;
    for (int i = 0; i <= N; ++i)
    {
        cout << "suff[" << i << "]: " << suff[i] << endl;
    }
*/
    int res = 0;
    for (int i = K; i <= N + 1; ++i)
    {
        res = my_mod(res + my_mod(suff[i - 1] - pref[i - 1] + 1));
    }

    cout << res;
}


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

int main () {

    int N;
    scanf("%d", &N);

    map<int, int> D;
    for (int i = 0; i < N; i++) {
        int d;
        scanf("%d", &d);

        D[d]++;
    }

    int M;
    scanf("%d", &M);

    string ans = "YES";
    for (int i = 0; i < M; i++) {
        int t;
        scanf("%d", &t);

        if (D[t] == 0) {
            ans = "NO";
            break;
        }
        D[t]--;
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
	long long int a, b, c, k;
  	cin>>a>>b>>c>>k;
  	
  	long long int sum=0;
  	if(a>k){
    	sum=k;
    }else if(a<=k && k<=a+b){
    	sum=a;
    }else if(a+b<k){
    	sum=a-(k-(a+b));
    }
  
  	cout<<sum<<endl;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  vector<ll> v(1,26);
  ll x = 26*26;
  ll n; cin >> n;
  int k = 1;
  while(n > v.back()){
    v.push_back(v.back() + x);
    x *= 26;
    k++;
  }
  if(v.size() == 1){
    cout << char('a' + n - 1) << endl;
    return 0;
  }
  ll y = n - v[v.size()-2] - 1;
  debug(y);
  string s;
  for(int i = 0; i < k; ++i){
    s += char(y%26 + 'a');
    y/=26;    
  }
  reverse(s.begin(),s.end());
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

struct Student{
	int id,score;
};

struct Data{
	int score,first,second;
	bool strike,spare;
};

int main(){

	int num,tmp,index,pre_score;
	char buf[120];
	Student students[40];
	Data game_data[12];
	bool First;

	while(true){
		scanf("%d",&num);
		if(num == 0)break;

		for(int i = 0; i < 40; i++){
			students[i].score = 0;
		}

		getchar();

		for(int i = 0; i < num; i++){
			for(int k=0; k <= 11; k++){
				game_data[k].score = 0;
				game_data[k].first = 0;
				game_data[k].second = 0;
				game_data[k].strike = false;
				game_data[k].spare = false;
			}

			First = true;

			fgets(buf,120,stdin);

			tmp = 0;
			index = 0;
			pre_score = -1;
			for(int k = 0; buf[k] != '\n'; k++){
				if(buf[k] >= '0' && buf[k] <= '9'){
					tmp = 10*tmp + (buf[k] - '0');

					if(buf[k+1] == '\n'){
						if(pre_score == -1){
							game_data[index].first = tmp;
							game_data[index].score = tmp;
						}else{
							game_data[index].second = tmp;
							game_data[index].score = pre_score + tmp;
						}
					}
				}else{
					if(First){
						students[i].id = tmp;
						First = false;
					}else{

						if(pre_score == -1){
							game_data[index].first = tmp;
							if(tmp == 10){
								game_data[index].score = 10;
								game_data[index].strike = true;
								index++;
							}else{
								pre_score = tmp;
							}

						}else{
							game_data[index].second = tmp;
							game_data[index].score = pre_score + tmp;
							if(pre_score + tmp == 10){
								game_data[index].spare = true;
							}

							index++;

							pre_score = -1;
						}
					}

					tmp = 0;
				}
			}

			for(int k = 0; k <= 11; k++){
				students[i].score += game_data[k].score;
					if(k <= 8 && game_data[k].spare == true){
					students[i].score += game_data[k+1].first;
				}

				if(k <= 8 && game_data[k].strike == true){
					students[i].score += game_data[k+1].first;
					if(game_data[k+1].first == 10){
						students[i].score += game_data[k+2].first;
					}else{
						students[i].score += game_data[k+1].second;
					}
				}
			}
		}

		for(int i = 1; i <= num-1; i++){
			for(int k = num-1; k >= i; k--){
				if(students[k].score > students[k-1].score)swap(students[k],students[k-1]);
				else if(students[k].score == students[k-1].score && students[k].id < students[k-1].id)swap(students[k],students[k-1]);
			}
		}

		for(int i=0; i < num; i++){
			printf("%d %d\n",students[i].id,students[i].score);
		}
	}

    return 0;
}

Measured memory_bytes: 2588
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#include <memory.h>
#include <map>
#include <math.h>
#include <utility>
#include <set>

#pragma warning(disable:4996)
using namespace std;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;
const double PI = 3.141592653589793238;
const Int INF = 999999999999;
typedef pair<int, int> P;


int main()
{
	string a;

	auto s = string::npos;
	while (getline(cin, a)){
		REP(i, 26){
			for (auto& x : a){
				if (x<'a' || x>'z'){
					continue;
				}
				++x;
				if (x > 'z')x = 'a';
			}
			if (a.find("this") != s || a.find("the") != s || a.find("that") != s)
				cout << a << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1180
// inputに入力データ全体が入る
function Main(input) {
  var a,b;
  a = Number(input.split('\n')[0].split(' ')[0]);
  b = Number(input.split('\n')[0].split(' ')[1]);
  
  if(a === b){
    console.log(0);
  }else if((a + b) % 2 === 0){
    console.log((a+b)/2);
  }else{
    console.log('IMPOSSIBLE');
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T &a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T &a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T &a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}
}

int main() {

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

	// 最初はA
	// 次からはA - 1増える

	int ans = 0;
	int num = 1;
	while (num < b) {
		ans++;
		num += a - 1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        if 4*n*h - N*n - N*h > 0:
            if N * h * n % (4*n*h - N*n - N*h) == 0:
                print(h, n, N * h * n // (4*n*h - N*n - N*h))
                exit()

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
  int a,b;
  char op;
  scanf("%d %c %d",&a,&op,&b);
  if(op=='-'){
    printf("%d",a-b);
  }else if(op=='+'){
    printf("%d",a+b);
  }
  return 0;
}

Measured memory_bytes: 128
n, y = map(int, input().split())
ans = '-1 -1 -1'
for i in range(n+1):
    for j in range(n-i+1):
        if i * 10**4 + j * 5000 + (n-i-j)*1000 == y:
            ans = ' '.join(list(map(str, [i, j, n-i-j])))
print(ans)

Measured memory_bytes: 3060
s = input()
n = len(s)
dp = [0] * (n+1)
dp[0] = 1
for i in range(1,n+1):
    if i >= 5:
        if s[i-5:i] == "dream" or s[i-5:i] == "erase":
            dp[i] = dp[i-5]
    if i >= 6:
        if s[i-6:i] == "eraser":
            dp[i] = dp[i-6]
    if i >= 5:
        if s[i-7:i] == "dreamer":
            dp[i] = dp[i-7]
if dp[n]:
    print('YES')
else:
    print('NO')



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

int main() {
    long int n,ans=0;
    cin>>n;
    long int a[n],b[n];
    vector<long int> v(n);
    for(long int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(long int i=0;i<n;i++)
    {
        cin>>b[i];
        long int d=(a[i]-b[i]);
        if(d>0)
        ans+=d;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int64_t Euclidean(int64_t a, int64_t b){
    if (b > a) swap(a, b);
    int64_t r = 1;
    while (r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}
int64_t gcm(int64_t a, int64_t b){
    int64_t c = Euclidean(a, b);
    return a / c * b;
}
int main(){
    int N;
    cin >> N;
    vector<int64_t> T(N);
    for (int i = 0; i < N; i++){
        cin >> T.at(i);
    }
    for (int i = 0; i < N - 1; i++){
        T.at(i + 1) = gcm (T.at(i + 1), T.at(i));
        //cout << T.at(i + 1) << endl;
    }
    cout << T.at(N - 1) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
  int i, j, k, A[100], N, key;

  scanf("%d", &N);
  for(i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  
  for(i = 1; i < N; i++) {

    for(k = 0; k < N; k++) {
      if ( k > 0 ) printf(" ");
      printf("%d", A[k]);
    }
    printf("\n");
    
    key = A[i];
    j = i - 1;

    while(j >= 0 && A[j] > key) {
      A[j+1] = A[j];
      j--;
      A[j+1] = key;
    }
  }
  
  for(i = 0; i < N; i++) {
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  int n,m,p;
  while(cin>>n>>m>>p,n||m||p){
    double ans=0;
	vector<int>in(n);
	rep(i,n){cin>>in[i];ans+=in[i];}
	if(!in[m-1])cout<<0<<endl;
	else{
	  ans*=100-p;
	  ans/=in[m-1];
	  cout<<(int)ans<<endl;
    }
  }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define shalaby ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);cerr.tie(0);
#define mod 100000000
using namespace std;

inline int D()
{
    int t;
    scanf("%d",&t);
    return t;
}
inline ll llD()
{
    ll t;
    scanf("%lld",&t);
    return t;
}
const int Max=1e5+8;
const int OO=-1e6;
int xt[4]= {1,0,0,-1};
int yt[4]= {0,1,-1,0};
////////////////////////////////////////////////////////////////////////////////////

ll mem[100005][5],a[100005],b[100005],c[100005],n,m;
bool valid(int x,int y)
{
    return x>-1 && y>-1 && x<n && y<m;
}
void init()
{
    memset(mem,-1,sizeof mem);
}
/////////////////////////////////////////////////////////////////////
ll solve(int i=0, int k=3)
{
    if(i==n)
        return 0;
    ll &ret=mem[i][k];
    if(~ret)return ret;
    ret =0;
    if(k!=0)
        ret=max(ret,solve(i+1,0)+a[i]);

    if(k!=1)
        ret=max(ret,solve(i+1,1)+b[i]);
    if(k!=2)
        ret=max(ret,solve(i+1,2)+c[i]);
    return ret;
}

int main()
{
    init();
    int T=1;
///   T=D();
    while(T-->0)
    {
        cin >> n ;
        for(int i=0; i<n; i++)
        {
            cin >> a[i] >> b[i]>>c[i];
        }
        cout << solve();
    }
}


Measured memory_bytes: 16128
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        int[] a = Read.ints();
        Console.WriteLine((a[1]*1900+(a[0]-a[1])*100)*Math.Pow(2,a[1])
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            );Console.ReadLine();
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        for (long i = 2; i < n; i++) { if (n % i == 0) return false; }
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

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

void solve(long long N)
{

    cout << N * N * N << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    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(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
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;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    ll N; cin >> N;
    vector<ll> L(N);
    REP(i,N){
        cin >> L[i];
    }
    sort(ALL(L));
    ll ans = 0;
    REP(i,N){
        for (size_t j = i + 1; j < N; j++) {
            for (size_t k = j + 1; k < N; k++) {
                ll a = L[i];
                ll b = L[j];
                ll c = L[k];
                if ((a == b) or (b == c)) continue;
                if ((a+b>c) and (b+c>a) and (c+a>b)) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>

using namespace std;

#define N 100001

const int mod=1e9+7;

int a[N],inv[N];

int Pow(int p,int q)
{
	int s=1;
	for(;q;q>>=1,p=1LL*p*p%mod)
		if(q&1) s=1LL*s*p%mod;
	return s;
}

int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i) inv[i]=Pow(i,mod-2); 
	long long p=1,ans=a[k];
	for(int i=k+1;i<=n;++i)
	{
		 p=p*(i-1)%mod;
		 p=p*inv[i-k]%mod;
		 ans=(ans+a[i]*p%mod)%mod;
	}
	ans-=a[n-k+1];
	p=1;
	for(int i=k+1;i<=n;++i)
	{
		 p=p*(i-1)%mod;
		 p=p*inv[i-k]%mod;
		 ans=(ans-a[n-i+1]*p%mod)%mod;
	}
	if(ans<0) ans+=mod;
	printf("%d",ans);
}
		 

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

int main(){
    int h,w;
    cin >> h >> w;
    string s[h];
    for(int i=0;i<h;++i) cin >> s[i];
    for(int i=0;i<h;++i){
        cout << s[i] << endl;
        cout << s[i] << endl;
    }
}

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

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

    ll n = s.size() ;
    // cout << n << endl;
    queue<pair<char,ll>> q;
    ll max_len = 0;

    rep(i, n)
    {
        char c = s.at(i);
        ll beg = i;
        while (i<n)
        {
            if(s.at(i) == c)i++;
            else break;
        }
        if(max_len < i-beg) max_len = i-beg;
        q.push(make_pair(c, i-beg));
        i--;
    }
    
    //cout << max_len << endl;
    ll ans =0;
    ll past_len = 0;
    while (!q.empty()) 
    {
        auto p = q.front();
        auto len = p.second;
        if(p.first=='<')
        {
            ans += len*(len+1)/2 - len;
            past_len = len;
        }
        else
        {
            ans+= len*(len+1)/2;
            if(past_len > len) ans+= past_len-len;
        }

        // cout << p.first << p.second  << ans << endl;
        q.pop();
        if(q.empty() and p.first=='<') ans += len;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4868
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const double pi=3.1415926535897932384626433832795;
int n,l,t[3030];
double sumx,sumy,x,y;
int main()
{
	scanf("%d %d",&n,&l);
	for(int i=1;i<=n;++i)scanf("%d",&t[i]);
	double sumcos,sumsin,sumcosi,sumsini,curcos,cursin;
	for(int i=1;i<=n;++i)
	{
		curcos=cos(pi*t[i]/l);
		cursin=sin(pi*t[i]/l);
		sumx+=n*(curcos*sumcos-cursin*sumsin)-2*i*(curcos*sumcos-cursin*sumsin)+2*(curcos*sumcosi-cursin*sumsini);
		sumy+=n*(curcos*sumsin+cursin*sumcos)-2*i*(curcos*sumsin+cursin*sumcos)+2*(curcos*sumsini+cursin*sumcosi);
		sumcos+=curcos;sumsin+=cursin;
		sumcosi+=curcos*i;sumsini+=cursin*i;
	}
	sumx=sumx*6/n/(n-1)/(n-2);
	sumy=sumy*6/n/(n-1)/(n-2);
	printf("%.12lf %.12lf",sumx,sumy);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>

int main() {
	std::string s;
	std::cin >> s;
	for (int i = 0;i < 3 ;i++) {
		std::cout << s[i];
}
	std::cout << 8;
	for (int i = 4;i < s.size();i++) {
		std::cout << s[i];
	}
	std::cout << std::endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define LL long long
using namespace std;
const LL m=(LL)1000000000*1000000000;
int n;
int main(){
	//int T;  cin>>T;
	int T=1;
	while(T --> 0){
		scanf("%d",&n);
		LL x;
		LL bwl=1;
		while(n --> 0){
			scanf("%lld",&x);
			if(x==0){
				bwl=0;
				break;
			}
			if(bwl!=-1){
				if(m/bwl<x){
					bwl=-1;
				}
				else{
					bwl=bwl*x;
				}
			}
		}
		printf("%lld\n",bwl);
	}
	return 0;
}




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

int main() {
  string s;
  cin >> s;
  int price = 700;
  if (s[0] == 'o') price+=100;
  if (s[1] == 'o') price+=100;
  if (s[2] == 'o') price+=100;
  cout << price << endl;
}

Measured memory_bytes: 256
object Main extends App {
  import scala.io.StdIn._

  val n = readLine.trim.toInt
  val info = Array.tabulate(n){_ ⇒
    val Array(x, y, h) = readLine.trim.split(' ').map(_.toInt)
    Info(x, y, h)
  }
  println(
    (0 to 100).flatMap{x ⇒ (0 to 100).map{y ⇒ Coordinate(x, y)}}.flatMap { center ⇒
      val suspect = info.map(inverseHeight(center, _))
      suspect.find{
        case Equal(_) ⇒ true
        case _ ⇒ false
      } match {
        case Some(Equal(h)) ⇒ if (suspect.forall{
          case Equal(height) ⇒ h == height
          case Lower(height) ⇒ h <= height
        }) Some(center, h) else None
        case _ ⇒ if(suspect.forall{
          case Equal(height) ⇒ 1 == height
          case Lower(height) ⇒ 1 <= height
        }) Some(center, 1) else None
      }
    }.head.let{case (Coordinate(x, y), h) ⇒ s"$x $y $h"}
  )
  def inverseHeight(center: Coordinate, info: Info): Either = {
    info match {
      case Info(x, y, 0L) ⇒ Lower((center.x - x).abs + (center.y - y).abs)
      case Info(x, y, h) ⇒ Equal(h + (center.x - x).abs + (center.y - y).abs)
    }
  }
  sealed trait Either
  case class Lower(height: Long) extends Either
  case class Equal(height: Long) extends Either
  implicit class RichInt(val value: Long){
    def abs: Long = if (value >= 0) value else -value
  }
  case class Coordinate(x: Int, y: Int)
  case class Info(x:Int, y:Int, h:Long)
  implicit class ScopeFunc[T](value: T){
    def let[A](func: T ⇒ A): A = func(value)
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}

Measured memory_bytes: 37360
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long

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

    int x = max(a, max(b, c));

    if(3 * x % 2 == (a + b + c) % 2) {
        cout << (3 * x - (a + b + c)) / 2 << endl;
        return 0;
    }

    x++;
    cout << (3 * x - (a + b + c)) / 2 << endl;
    return 0;
}


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

using ll =long long;

//最大公約数
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//
//
//
int main(){
cout<<fixed<<setprecision(10);
double T,X;cin>>T>>X;
  cout<<T/X<<endl;
}


Measured memory_bytes: 256
<?php
      
    	$n = trim(fgets(STDIN));
		$str = str_split($n);
        $l = count($str); ;
		$ans = "Yes";
		for($i =0; $i<$l; $i++){
            if((($i+1) % 2) == 0){
              switch ($str[$i]) {
                  case "L":
                  case "U":
                  case "D":
                      break;
                  default:
       			      $ans = "No";
              }
            }
          	else{
              switch ($str[$i]) {
                  case "R":
                  case "U":
                  case "D":
                      break;
                  default:
       			      $ans = "No";
              }
            }
        }

		echo $ans;
?>

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int a[n-1],cmax,p;
    scanf("%d",&cmax);
    for(int i=0; i<n-1; i++)
    {
        scanf("%d",&p);
        if(p>cmax)
            {
                a[i]=cmax;
                cmax=p;
            }
        else a[i]=p;
    }
    int k=cmax/2,d=1000000000,flag=0;
    for(int i=0; i<n-1; i++)
    {
        if(d>abs(a[i]-k))
        {
            d=abs(a[i]-k);
            flag=a[i];
        }
    }
    printf("%d %d\n",cmax,flag);
    return 0;
}


Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;

class APassword {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int x;
	    in >> x;

	    out << x*x*x << endl;
	}
};


int main() {
	APassword solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort()
max_a = a[-1]
for i in range(len(a) - 1):
    if 2 * a[i] > max_a:
        half_ind = i
        break
    if i == (len(a) - 2):
        half_ind = n - 1

if half_ind == 0:
    print(str(a[-1]) + " " + str(a[half_ind]))
elif half_ind == n - 1:
    print(str(a[-1]) + " " + str(a[half_ind - 1]))
else:
    if abs(2 * a[half_ind] - a[-1]) > abs(2 * a[half_ind - 1] - a[-1]):
        print(str(a[-1]) + " " + str(a[half_ind - 1]))
    else:
        print(str(a[-1]) + " " + str(a[half_ind]))

Measured memory_bytes: 14100
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-9
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 512

#define ldouble long double

using namespace std;

const int N = 1000031;

int n;
vector<int> g[N];
int val;
int dp[N];

void dfs(int v)
{
	vector<pair<int,int> > order;
	for (int i=0;i<g[v].size();i++)
	{
		int to=g[v][i];
		dfs(to);
		order.push_back(make_pair(dp[to],to));
	}
	sort(order.begin(),order.end());
	reverse(order.begin(),order.end());
	for (int i=0;i<order.size();i++)
	{
		dp[v]=max(dp[v],order[i].first+i+1);
	}
}

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin>>n;
	for (int i=2;i<=n;i++)
	{
		cin>>val;
		g[val].push_back(i);
	}	

	dfs(1);
	cout<<dp[1]<<endl;

	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 36608