akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n1 = int.Parse(Console.ReadLine().Trim());
            int[] numbers1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int length = numbers1.Length;
            int last_index = length - 1;

            int sum = numbers1[0] + numbers1[last_index];

            for (int i = 0; i < length - 1; i++)
            {
                sum += Math.Min(numbers1[i], numbers1[i + 1]);
            }

            Console.WriteLine($"{sum}");
        }
    }
}


Measured memory_bytes: 13396
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 998244353;
const ll MAX = 200001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}
int main(){
  ll h,n; cin >> h >> n; 
  vector<pair<ll,ll>> hpmp(n);
  
  rep(i,n){
    ll x,y; cin >> x >> y;
    hpmp[i] = make_pair(x,y);
  }
  
  
  vector<ll> dp(h+1,INT_MAX);
  dp[0] = 0;
 
  for(ll i=1; i <= h; i++){
    for(ll j=0; j < n; j++){
      dp[i] = min(dp[i],
                  dp[max(i-hpmp[j].first,0LL)] + hpmp[j].second);
    }
  }
  
  cout << dp[h] << endl;
  
  
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007 
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int ans;
int x[9];
int n;
string s;
int mv[10][10];
P pos[10];

int main(){
	cin>>n>>s;
	for(int i=1;i<n;i++){
		mv[s[i-1]-'0'][s[i]-'0']++;
	}
	ans = INF;
	int p[9];
	rep(i,9) p[i] = i+1;
	do{
		rep(i,9){
			pos[p[i]] = mp(i/3,i%3);
		}
		int sum = 0;
		repn(i,9)repn(j,9){
			sum += mv[i][j] * (abs(pos[i].fi-pos[j].fi)+abs(pos[i].sc-pos[j].sc));
		}
		if(ans > sum){
			ans = sum;
			rep(i,9) x[i] = p[i];
		}
	}while(next_permutation(p,p+9));
	int C = 0;
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cout<<x[C++];
		}
		cout<<endl;
	}
}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 

const int mod = 1000000007;
const int inf = 1e9;

int main(){
    int n;
    cin >> n;
    cout << ceil(n/2.0);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main( void )
{
	// ³ê½f[^É the, this, that Ì¢¸ê©ªÜÜêéÈçÎ
	// »êðoÍµÄI¹·éÆ¢¤àÌÅµå¤B

	string keys[3] = { "the", "this", "that" };
	string input;
	while ( cin.eof() == false )
	{
		getline( cin, input );
		for ( int i = 0; i <= 26; i++ )
		{
			for ( string::iterator it = input.begin(); it != input.end(); it++ )
			{
				if ( *it == '\n' ) it = input.erase( it );
				if ( 'a' <= *it && *it <= 'z' )
				{
					(*it)++;
					if ( *it > 'z' ) *it = 'a';
				}
			}
			bool not_found = true;
			for ( int j = 0; not_found && j < 3; j++ )
			{
				if ( input.find( keys[j] ) != string::npos ) not_found = false;
			}
			if ( not_found == false )
			{
				cout << input << endl;
				break;
			}
		}
	}

	return 0;
}

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

int main()
{
    char s[3];
    cin>>s;
    if(s[0]==s[1] && s[1]==s[2] && s[2]==s[0])
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;
    static CF_Reader in;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new CF_Reader();

        long H = in.longNext();
        long n = in.longNext();
        long attack = 0;
        for (long i = 0; i < n; i++) {
            attack += in.longNext();
        }
        out.println((H <= attack) ? "Yes": "No");

        out.close();
    }

    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

        public int[] nextIntArray(final int n) throws IOException {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = intNext();
            return a;
        }

        public long[] nextLongArray(final int n) throws IOException {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = longNext();
            return a;
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}


Measured memory_bytes: 31648
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,m,q=map(int,input().split())
x=[[0]*n for _ in range(n)]
for i in range(m):
    l,r=map(int,input().split())
    x[l-1][r-1]+=1
res=[[0]*n for _ in range(n)]
for i in range(n):
    res[i][0]=x[i][0]
    for j in range(1,n):
        res[i][j]=res[i][j-1]+x[i][j]
for i in range(q):
    p,q=map(int,input().split())
    ans=0
    for k in range(p-1,q):
        ans=ans+res[k][q-1]-res[k][p-2] if p!=1 else ans+res[k][q-1]
    print(ans)

Measured memory_bytes: 85264
program main
  implicit none
  integer(8) :: n, i, j, q, r, cnt, m
  integer(8), allocatable :: ca(:), cb(:), cc(:), cq(:), pt(:)
  character(10 ** 5) :: s
  m = 10 ** 9 + 7
  read *, s
  n = len_trim(s)
  allocate (ca(0:n), cb(0:n), cc(0:n), cq(0:n), pt(-3:n))
  ca = 0
  cb = 0
  cc = 0
  cq = 0
  do i = 1, n
    if (s(i:i) == "A") ca(i) = 1
    if (s(i:i) == "B") cb(i) = 1
    if (s(i:i) == "C") cc(i) = 1
    if (s(i:i) == "?") cq(i) = 1
    ca(i) = ca(i) + ca(i - 1)
    cb(i) = cb(i) + cb(i - 1)
    cc(i) = cc(i) + cc(i - 1)
    cq(i) = cq(i) + cq(i - 1)
  end do
  q = cq(n)

  call prep_pt()

  cnt = 0
  do j = 2, n - 1
    if (s(j:j) == "A" .or. s(j:j) == "C") cycle
    if (s(j:j) == "?") then
      r = q - 1
    else if (s(j:j) == "B") then
      r = q
    end if
    cnt = cnt + ca(j - 1) * (cc(n) - cc(j)) * pt(r)
    cnt = modulo(cnt, m)
    cnt = cnt + cq(j - 1) * (cc(n) - cc(j)) * pt(r - 1)
    cnt = modulo(cnt, m)
    cnt = cnt + ca(j - 1) * (cq(n) - cq(j)) * pt(r - 1)
    cnt = modulo(cnt, m)
    cnt = cnt + cq(j - 1) * (cq(n) - cq(j)) * pt(r - 2)
    cnt = modulo(cnt, m)
  end do
  print "(i0)", cnt

  contains

  subroutine prep_pt()
    integer(8) :: i
    pt(:) = 0
    pt(0) = 1
    do i = 1, n
      pt(i) = modulo(pt(i - 1) * 3, m)
    end do
  end subroutine prep_pt
end program main


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

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

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

int main(){
    int H,W; cin>>H>>W;
    string board[H]; CINA(board,H);
    int d[H][W];
    FILL2(d,H,W,20000);
    d[0][0] = (board[0][0]=='#');
    REP(i,H){
        if(i>0){
            REP(j,W){
                chmin(d[i][j],d[i-1][j] + (board[i][j]!=board[i-1][j]));
            }
        }
        
        for(int j=1;j<W;++j){
            chmin(d[i][j],d[i][j-1]+(board[i][j]!=board[i][j-1]));
        }
        
    }
    cout << (d[H-1][W-1]+1)/2 << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define INFINITOLL 1000000000000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    long double a;
    long double b;
    cin >> a >> b;

    // cout << fixed << setprecision(20) << (a * b) << endl;
    cout << fixed << setprecision(0) << (ll) (a * b) << endl;

    return 0;
}

Measured memory_bytes: 3728
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int l = scanner.nextInt();
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int d = scanner.nextInt();
		int ac = a % c == 0 ? a / c : a / c + 1;
		int bd = b % d == 0 ? b / d : b / d + 1;
		System.out.println(l - Math.max(ac, bd));
	}
}

Measured memory_bytes: 17180
N,M=map(int,input().split())
ba=[[0,0] for _ in range(M)]

for i in range(M):
    ba[i][1],ba[i][0]=map(int,input().split())
    
ba.sort()

ans=0
prev=-1#直近で橋を落とした位置

for i in range(M):
    if prev<ba[i][1] or prev>ba[i][0]:
        ans+=1
        prev=ba[i][0]-1
        
print(ans)





Measured memory_bytes: 54432
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  ll t1, t2;
  cin >> t1 >> t2;
  ll a1, a2;
  cin >> a1 >> a2;
  ll b1, b2;
  cin >> b1 >> b2;

  ll p = (a1-b1)*t1;
  ll q = (a2-b2)*t2;

  if (p > 0) {
    p *= -1;
    q *= -1;
  }

  if (p+q < 0) cout << 0 << endl;
  else if (p+q == 0) cout << "infinity" << endl;
  else {
    ll s = (-p)/(p+q);
    ll t = (-p)%(p+q);
    if (t != 0) cout << 1 + 2*s << endl;
    else cout << 2*s << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
bool P[40000];
int main(){
	P[0]=P[1]=1;
	for(int i=2;i<1<<15;i++)if(!P[i])for(int j=i+i;j<1<<15;j+=i)P[j]=1;
	int n,c;
	while(cin>>n,n){
		c=0; for(int i=2;i+i<=n;i++)if(!P[i]&&!P[n-i])c++;
		cout<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Pipes;
using System.Linq;
using System.Reflection.PortableExecutable;
using System.Runtime.InteropServices.ComTypes;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Security.Cryptography.X509Certificates;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        Queue<int> q = new Queue<int>();
        bool[] hasVisit;
        int[] prev;
        void bfs(List<List<int>> v)
        {
            while (q.Count != 0)
            {
                int now = q.Dequeue();
                for (int i = 0; i < v[now].Count; i++)
                {
                    int next = v[now][i];
                    if (!hasVisit[next])
                    {
                        hasVisit[next] = true;
                        prev[next] = now;
                        q.Enqueue(next);
                    }
                }
            }
        }

        void Omame()
        {
            cin = new Scanner();
            int K = cin.nextInt();
            int A = cin.nextInt();
            int B = cin.nextInt();

            for (int i = A; i <= B; i++)
            {
                if (i % K == 0)
                {
                    Console.WriteLine("OK");
                    return;
                }
            }
            Console.WriteLine("NG");
        }
    }
}


Measured memory_bytes: 27696
#include<bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
using namespace std;
int main()
{
    FLASH
    ll x;
    ll k,a;
    cin >> x;
    a = 100;
    ll i = 0;
    while(a < x)
    {
        k = a * (0.01);
        a += k;
        i++;
    }
    cout << i;
    return 0;
}



Measured memory_bytes: 3652
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/24 15:36:57 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	int	n;
	cin >> n;
	int	gcdv;
	cin >> gcdv;
	rep(i, n - 1)
	{
		int	x;
		cin >> x;

		gcdv = __gcd(gcdv, x);
	}
	cout << gcdv << endl;
}
// END

int		main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int dp(int now, int prev, const vvi &g) {
  vi v;
  for(auto &nxt: g[now]) {
    if(nxt == prev) continue;
    v.push_back(dp(nxt, now, g));
  }
  if(v.empty()) {
    return 0;
  }
  sort(v.rbegin(), v.rend());
  int ma = 0;
  int tmp = 1;
  REP(i, SZ(v)) {
    chmax(ma, tmp + v[i]);
    tmp++;
  }
  return ma;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vvi g(n);
  REP(i, n-1) {
    int j; cin >> j;
    j--;
    g[j].push_back(i+1);
  }

  cout << dp(0, -1, g) << endl;



}








Measured memory_bytes: 19380
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
class Main{
    public void run(){
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            br.lines()
                .forEach(n -> fib(n));
        }catch(Exception e){
        }
    }

    public void fib(String n){
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(1);
        for(int i = 2;i <= Integer.parseInt(n);i++ ){
            list.add(list.get(i - 2) + list.get(i - 1));
        }
        System.out.println(list.get(Integer.parseInt(n)));
    }
    public static void main(String[] args){
        new Main().run();
    }
}

Measured memory_bytes: 30652
#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>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; string s; cin>>n>>s;
  map<char,ll> m;
  rep(i,n){
    m[s[i]]++;
  }
  ll ans=m['R']*m['G']*m['B'];
  ll span=1;
  ll tmp=0;
  while(span<n){
    rep(i,n){
      if(span*2+i>=n) break;
      if(s[i]!=s[i+span] && s[i+span]!=s[i+span*2] && s[i+span*2]!=s[i]) tmp++;
    }
    span++;
  }
  cout<<ans-tmp<<endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int n;
vector<string> s;

int dp[MX][4][4][4];

int solve(int idx, int a, int b, int c){
	if(a < 0 || b < 0 || c < 0 || a > 4 || b > 4 || c > 4) return 0;
	if(idx == n){
		return a >= 0 && b >= 0 && c >= 0;
	}

	auto &ret = dp[idx][a][b][c];
	if(ret != -1) return ret;

	ret = 0;

	if(s[idx] == "AB"){
		ret |= solve(idx + 1, a - 1, b + 1, c);
		ret |= solve(idx + 1, a + 1, b - 1, c);
	}
	else if(s[idx] == "AC"){
		ret |= solve(idx + 1, a - 1, b, c + 1);
		ret |= solve(idx + 1, a + 1, b, c - 1);
	}
	else{
		ret |= solve(idx + 1, a, b - 1, c + 1);
		ret |= solve(idx + 1, a, b + 1, c - 1);
	}

	return ret;
}


void build(int idx, int a, int b, int c){

	if(idx == n) return;
	
	if(s[idx] == "AB"){
		if(solve(idx + 1, a - 1, b + 1, c)){
			cout << "B\n", build(idx + 1, a - 1, b + 1, c);
		}
		else{
			cout << "A\n", build(idx + 1, a + 1, b - 1, c);
		}
	}
	else if(s[idx] == "AC"){
		if(solve(idx + 1, a - 1, b, c + 1)){
			cout << "C\n", build(idx + 1, a - 1, b, c + 1);
		}
		else{
			cout << "A\n", build(idx + 1, a + 1, b, c - 1);
		}
	}
	else{
		if(solve(idx + 1, a, b + 1, c - 1)){
			cout << "B\n", build(idx + 1, a, b + 1, c - 1);
		}
		else{
			cout << "C\n", build(idx + 1, a, b - 1, c + 1);
		}
	}
}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

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

	s.resize(n);
	for(auto &x : s) cin >> x;

	memset(dp, 0xff, sizeof dp);

	a = min(a, 3);
	b = min(b, 3);
	c = min(c, 3);

	if(solve(0, a, b, c) == 1){
		cout << "Yes\n";
		build(0, a, b, c);
	}
	else{
		cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 39104
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define int long long
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    string S;
    cin >> S;
    int ans = 0;
    int cnt = 0;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == 'W') {
            ans+=i-cnt;
            cnt++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
#define MOD 1000000007
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

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

	ll n,x;
	cin>>n;
	ll a[n]; ll b[n];
	for(ll i=0; i<n; i++)
		{ cin>>x; a[i]=x;b[i]=x;} 
	sort(b,b+n);
	ll max= b[n-1];
	ll sec= b[n-2];
	
	for(ll i=0; i<n; i++)
	{
		if(a[i] == max)
			cout<<sec<<endl;
		else cout<<max<<endl;
	}
	
	return 0;
}

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

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

	string a[ n ], b[ m ];

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

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

	bool issame = false;
	for( int i = 0; i <= n - m and !issame; i++ ) {
		for( int j = 0; j <= n - m and !issame; j++ ) {
			
			issame = true;
			for( int x = 0; x < m; x++ ) {
				for( int y = 0; y < m; y++ ) {
					if( a[ i + x ][ j + y ] != b[ x ][ y ] ) {
						issame = false;
						break;
					}
				}
				if( !issame ) {
					break;
				}
			}
		}
	}

	cout << ( issame ? "Yes" : "No" ) << endl;

	return 0;
}

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

long divide2(long x) {
    if (x % 2 == 1) {
        return 0;
    }
    if (x == 0) {
        return 0;
    }

    return divide2(x / 2) + 1;
}

int main()
{
    long n;
    cin >> n;
    long ans  = 1000;
    for (long i = 0; i < n; i++) {
        long a, temp;
        cin >> a;
        temp = divide2(a);
        ans = min(ans, temp);

        if (ans == 0) {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vl a(n);
    REP(i, n) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << 0 << endl;
            return;
        }
    }
    ll ans = 1;
    REP(i, n) {
        if (1000000000000000000 / ans < a[i]) {
            cout << -1 << endl;
            return;
        }
        ans *= a[i];
        if (ans > 1000000000000000000) {
            cout << -1 << endl;
            return;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3972
//*******Abhijit Burman***********//
//Jalpaiguri Government Engineering College//
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

#define pb push_back
#define mk make_pair
#define MAXX (1000000000000000000+7)
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)




int solve()
{
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
   cout<<a[k-1]<<endl;
    return 0;
}
int main()
{
    fio;

// 	#ifndef ONLINE_JUDGE
//     // for getting input from input.txt
//     freopen("input.txt", "r", stdin);
//     // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
// 	#endif


	
	ll t=1;
	//cin>>t;
	while(t--)
	{
	   
	    solve();
	}
	return 0;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

vll a, f;
ll asum;
ll n, k;

// minimum x (C(x) == true)
bool C(ll mid){
    ll r = 0;
    rep(i, n){
        r += min(mid/f[i], a[i]);
    }
    return r >= asum;
}

ll BinarySearchMin(ll lb, ll ub){
    // 返り値の範囲：(lb, ub]
    // 条件：
    //   (lb, ub]で検証できること
    //   C(lb)==false, C(ub)==true
    while(ub - lb > 1){
        ll mid = ((lb + ub) >> 1);
        if(C(mid)){
            // (lb, mid]
            ub = mid;
        }else{
            // (mid, ub]
            lb = mid;
        }
    }
    return ub;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cin >> n >> k;
    a.resize(n);
    f.resize(n);
    rep(i, n){
        cin >> a[i];
    }
    rep(i, n){
        cin >> f[i];
    }
    sort(ALL(a));
    sort(ALL(f));
    reverse(ALL(f));
    dump(a);
    dump(f);
    asum = max(0ll, accumulate(ALL(a), 0ll)-k);
    dump(asum);
    cout << BinarySearchMin(-1, 1000000000010) << endl;
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    string s;cin>>s;
    int g = 0;
    for(int i = 0;i<4;i++){
      if(s[i] =='+') g+=1;
      else g-=1;
    }
    cout<<g;
    return 0;
}

Measured memory_bytes: 3592
# import sys; input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**7)
# from collections import defaultdict
ALPHABET_SIZE = 26

def getlist():
	return list(map(int, input().split()))

class Node(object):
	def __init__(self, char):
		self.char = char
		self.children = {}
		self.flag = [0] * ALPHABET_SIZE

class Trie(object):
	def __init__(self):
		self.root = Node(' ')

	def _convert_char_to_num(self, char):
		return ord(char) - 97

	def insert(self, word, tail):
		res = 0 #合う値
		current = self.root
		currentFlag = [0] * ALPHABET_SIZE

		for char in word:
			char_index = self._convert_char_to_num(char)
			for i in range(ALPHABET_SIZE):
				currentFlag[i] += current.flag[i]
			res += currentFlag[char_index]
			currentFlag[char_index] = 0

			if char_index in current.children:
				current = current.children[char_index]

			# if current.children[char_index] != -1:
			# 	current = current.children[char_index]
			else:
				new_node = Node(char)
				current.children[char_index] = new_node
				current = new_node

		char_index = self._convert_char_to_num(tail)
		res += currentFlag[char_index]

		current.flag[self._convert_char_to_num(tail)] += 1

		return res

#処理内容
def main():
	N = int(input())
	L = []
	for i in range(N):
		S = input()[::-1]
		L.append([len(S), S])

	L.sort(key = lambda x:x[0])

	ans = 0
	trie = Trie()
	for val, s in L:
		s1 = s[:-1]
		tail = s[-1]
		ans += trie.insert(s1, tail)
		# print(ans)

	print(ans)

if __name__ == '__main__':
	main()


Measured memory_bytes: 714448
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, M;
  cin >> N >> M;
  llvec P(M, 0);
  llvec Y(M, 0);
  map<ll, llvec> ysort;
  rep(i, M){
    cin >> P[i] >> Y[i];
    ysort[P[i]].push_back(Y[i]);
  }
  rep(i, N+1){
    sort(ALL(ysort[i]));

  }

  rep(i, M){
    ll num =(ll) (lower_bound(ALL(ysort[P[i]]), Y[i]) - ysort[P[i]].begin());
    cout << setfill('0') <<setw(6)<< P[i];
    cout << setfill('0') <<setw(6)<< num+1;
    cout << endl;
  }
  

  
  
  return 0;
}


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

#define io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pii pair<ll, ll>
#define piii pair<ll, pair<ll, ll>>
#define debug(x) cout<<#x<<" = "<<x<<endl

using namespace std;
const int N = 300005;
ll t, n, m, k, q, a, b, x, y, ans, arr[N];
bool vis[N], valid;
ll mod = 998244353;
string s;

unordered_map<ll, ll> cnt;

bool ok(ll x) {
    for (int i = 1; i * i <= x; ++i) {
        if (x % i != 0)
            continue;
        if (cnt[i] || cnt[x / i])
            return false;
    }
    return true;
}

int main() {
    io;
    t = 1;
//    cin >> t;
    while (t--) {
        cin >> n;
        for (int i = 0; i < n; ++i) {
            cin >> arr[i];
            ++cnt[arr[i]];
        }
        for (int i = 0; i < n; ++i) {
            --cnt[arr[i]];
            ans += ok(arr[i]);
            ++cnt[arr[i]];
        }
        cout << ans << endl;
    }
    return 0;
}
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);


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

int main() {
  int a,b;
  cin>>a>>b;
  string ans="Impossible";
  if(a%3==0) ans="Possible";
  else if(b%3==0) ans="Possible";
  else if((a+b)%3==0) ans="Possible";
  cout<<ans<<endl;
 }


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
struct node{
  int key;
  struct node *parent;
  struct node *right;
  struct node *left;
};
typedef struct node *Node;
Node T;
#define NIL NULL;
void Insert(int);
int Find(int);
void Preorder(Node);
void Inorder(Node);
int main()
{
  int n,i,key;
  char S[7];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",S);
    if(S[0]=='i'){
      scanf("%d",&key);
      Insert(key);
    }
    else if(S[0]=='f'){
      scanf("%d",&key);
      if(Find(key))printf("yes\n");
      else printf("no\n");
    }
    else{
      Inorder(T);
      printf("\n");
      Preorder(T);
      printf("\n");

    }
  }
  return 0;
}

void Insert(int key)
{
  Node y,x,z;
  y=NIL;
  x=T;
  z=malloc(sizeof(struct node));
  z->key=key;
  z->left=NIL;
  z->right=NIL;
  while(x!=NULL){
    y=x;
    if( z->key < x->key )x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NULL){
    T=z;
  }
 else if(z->key<y->key){
      y->left=z;
  }
  else{
    y->right=z;
  }
}

int Find(int key)
{
  Node TT;
  TT=T;
  while(TT!=NULL && TT->key!=key){
    if(key<TT->key)TT=TT->left;
    else TT=TT->right;
  }
  if(TT==NULL)return 0;
  else return 1;
}
void Preorder(Node T)
{
  printf(" %d",T->key);
  if(T->left!=NULL){
    Preorder(T->left);
  }
  if(T->right!=NULL){
    Preorder(T->right);
  }

}

void Inorder(Node T)
{
  if(T->left!=NULL && T->right!=NULL){
    Inorder(T->left);
    printf(" %d",T->key);
    Inorder(T->right);

  }
  if(T->left!=NULL && T->right==NULL){
   Inorder(T->left);
     printf(" %d",T->key);
  }

  if(T->right!=NULL && T->left==NULL){
  printf(" %d",T->key);
 Inorder(T->right);

  }
  if(T->left==NULL && T->right==NULL)printf(" %d",T->key);

}



Measured memory_bytes: 20456
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const ll mod=1000000007;
const ll inf=1e18;
int main(){
  ll n,m,k;
  cin >> n >> m >> k;
  ll a[n+1],b[m+1];
  for(int i=0;i<n;i++)cin >> a[i];
  for(int i=0;i<m;i++)cin >> b[i];
  ll sa[n+1]={},sb[m+1]={};
  //sa[i]..aのi番目までの和(1-indexed)
  for(int i=0;i<n;i++)sa[i+1]=sa[i]+a[i];
  for(int i=0;i<m;i++)sb[i+1]=sb[i]+b[i];
  ll s=0;
  for(int i=0;i<=n;i++){
    if(sa[i]<=k){  //sa[i]>kなら論外
      ll c=upper_bound(sb,sb+m+1,k-sa[i])-sb;  //sb[c]+sa[i]が初めてkを超えるようなcを探す
      c--;


      s=max(s,c+i);
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 9840
using System;
using System.Collections;
using System.Collections.Generic;


public class C
{
	public static void Main()
	{
		int N = Int32.Parse(Console.ReadLine());
		
		int[] A = new int[N];
		string[] args = Console.ReadLine().Split(' ');
		for(int i = 0; i < N; i++)
			A[i] = Int32.Parse(args[i]);
		
		int result = gcd(A[0], A[1]);
		for(int i = 2; i < N; i++)
			result = gcd(result, A[i]);
		
		Console.WriteLine(result);		
	}
	
	public static int gcd(int x, int y)
	{
		return (y == 0) ? x : gcd(y, x % y);
	}	
}

Measured memory_bytes: 20064
/*..........................*\
|         T.R.FORKAN           |
 \*..........................*/


 /**************************************************************************************\
 |                                                                                      |
 |           _______   ______    _______   _    _       ____   ___      _               |
 |          |  _____| / ____ \  |  ___  | | |  / /     / _  | |   \    | |              |
 |          | |      | |    | | | |   | | | | / /     / / | | | |\ \   | |              |
 |          | |____  | |    | | | |___| | | |/ /     / /  | | | | \ \  | |              |
 |          |  ____| | |    | | |  __  _| |   |     / /___| | | |  \ \ | |              |
 |          | |      | |____| | | |  \ \  | |\ \   / _____  | | |   \ \| |              |
 |          |_|       \______/  |_|   \_\ |_| \_\ /_/     |_| |_|    \___|              |
 |                                                                                      |
 |                                                                                      |
 \**************************************************************************************/


#include<bits/stdc++.h>
using namespace std;

#define    lcm(a,b)    (a*b)/gcd(a,b)
#define    gcd(a,b)    __gcd(a,b)
#define    pi    2*acos(0)
#define    eif    else if
#define    ll    long long
#define    llu    unsigned long long
#define    pb    push_back
#define    popb    pop_back
#define    pf    push_front
#define    popf    pop_front
#define    r0    return 0
#define    all(x)    x.begin(),x.end()
#define    memset(x,y)    memset(x,y,(sizeof(x)/sizeof(*x)))
#define    max_e    max_element
#define    min_e    min_element
#define    lowb    lower_bound
#define    upb    upper_bound
#define    F    first
#define    S    second
#define    bs    binary_search
#define    speed    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define    siz    INT_MAX
#define    read    freopen("cin.txt","r",stdin);
#define    write    freopen("cout.txt","w",stdout);
#define    prnt(x)    printf("%d",x)
#define    nl    printf("\n");
#define    siz    1000007


int Int(){int x;scanf("%d",&x);return x;}
ll int LL(){ll int x;scanf("%lld",&x);return x;}
llu int LLU(){llu int x;scanf("%llu",&x);return x;}
double din(){double x;scanf("%lf",&x);;return x;}



#define Int Int()
#define din din()
#define LL LL()
#define LLU LLU()
//#define siv siv()
//int ara[26];
//distance(ara,max_e(ara+1,ara+b)
int main()
{
    //read
    //write
    //speed
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
    //main();
    r0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i,max=1;
  
  scanf("%d",&n);
  
  while(n>=max)
    max=max*2;
  
  if(max==1)
  printf("%d",max);
  else
  printf("%d",max/2);
  
    
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main (void){
	
	int N,T;
	int c[100],t[100];
	int i;
	int ans = 10000;
	
	scanf("%d\t%d\n",&N, &T);
	
	for( i = 0; i < N; i++ ){
		scanf("%d\t%d\n",&c[i], &t[i]);
		
		if( t[i] <= T ){
			if( ans >= c[i]){
				ans = c[i];
			}
		}
	}
	
	if(ans == 10000){
		printf("TLE\n");
	}else{
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
#coding: UTF-8

N = int(input())

cnt = 0
#A.Bは対称
for i in range(1,N): #A
  for j in range(i,N): #B
    if i*j<N:
      #i=jなら+1
      if i==j:
        cnt += 1
      else:
        cnt += 2
    else:
      #それ以上jあげても無理
      break
print(cnt)

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
pair<int, vector<string>> merge(pair<int, vector<string>> A, pair<int, vector<string>> B){
  vector<string> tmp;
  for (string S : A.second){
    tmp.push_back(S);
  }
  for (string S : B.second){
    tmp.push_back(S);
  }
  sort(tmp.begin(), tmp.end());
  pair<int, vector<string>> ans;
  ans.first = A.first + B.first;
  if (tmp.size() <= 10){
    ans.second = tmp;
  } else {
    int sz = tmp.size();
    for (int i = 0; i < 5; i++){
      ans.second.push_back(tmp[i]);
    }
    for (int i = sz - 5; i < sz; i++){
      ans.second.push_back(tmp[i]);
    }
  }
  return ans;
}
pair<int, vector<string>> dfs(string &s, int c){
  if (c == 25){
    return make_pair(1, vector<string>(1, s));
  } else {
    int n = s.size();
    bool exist = false;
    for (int i = 0; i < n; i++){
      if (s[i] - 'a' == 25 - c){
        exist = true;
      }
    }
    pair<int, vector<string>> ans = make_pair(0, vector<string>(0));
    if (!exist){
      ans = merge(ans, dfs(s, c + 1));
      for  (int i = 0; i < n; i++){
        if (s[i] - 'a' == 24 - c){
          s[i]++;
          ans = merge(ans, dfs(s, c + 1));
          s[i]--;
        }
      }
    } else {
      for (int i = 0; i < n; i++){
        if (s[i] - 'a' == 25 - c){
          break;
        }
        if (s[i] - 'a' == 24 - c){
          s[i]++;
          ans = merge(ans, dfs(s, c + 1));
          s[i]--;
        }
      }
    }
    return ans;
  }
}
int main(){
  while (1){
    string s;
    cin >> s;
    if (s == "#"){
      break;
    }
    pair<int, vector<string>> ans = dfs(s, 0);
    cout << ans.first << endl;
    int sz = ans.second.size();
    for (int i = 0; i < sz;i++){
      cout << ans.second[i] << endl;
    }
  }
}


Measured memory_bytes: 3180