akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T> inline T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

ll dp[100010][2]={};//B,W

VV<int> e(100010,V<int>(0));
V<bool> used(100010,false);

void solve(int v){
  dp[v][0]=1;
  dp[v][1]=1;
  if(siz(e[v])!=0){
    rep(i,0,siz(e[v])){
      int ne=e[v][i];
      if(used[ne])continue;
      
      used[ne]=true;
      solve(ne);
      (dp[v][0]*=dp[ne][1])%=mod;
      (dp[v][1]*=dp[ne][0]+dp[ne][1])%=mod;
    }
  }
  return;
}

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int n;cin>>n;
  rep(i,0,n-1){
    int x,y;cin>>x>>y;
    x--;y--;
    e[x].pb(y);
    e[y].pb(x);
  }
  used[0]=true;
  solve(0);
  cout<<(dp[0][0]+dp[0][1])%mod<<ENDL;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

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

int main(){
  int a, b;
  cin >> a >> b;
  
  int product = a * b;
  
  if (product %  2 == 0) {
    cout << "Even" << endl; 
  }
  else{
    cout << "Odd" << endl;
  }
  
  
  
}

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

int main()
{
    std::string S;   cin >> S;
    int L = S.length();
    int cnt = 0;
    S += 'R';
    std::vector<int> v(L,0);
    for(int i=0; i<L; i++){
        if(S[i] == 'R'){
            cnt++;
            if(S[i+1] == 'L'){
                if(cnt%2 == 1){
                    v[i] += cnt/2 + 1;
                    v[i+1] += cnt/2;
                }else{
                    v[i] += cnt/2;
                    v[i+1] += cnt/2;        
                }
                cnt = 0;
            }
        }else if(S[i] == 'L'){
            cnt++;
            if(S[i+1] == 'R'){
                if(cnt%2 == 1){
                    v[i - cnt] += cnt/2;
                    v[i - cnt + 1] += cnt/2 + 1;
                }else{
                    v[i - cnt] += cnt/2;
                    v[i - cnt + 1] += cnt/2;                   
                }
                cnt = 0;
            }
        }
    }
    for(int i=0; i<L; i++)
        cout << v[i] << " ";
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
	int n,y, z,x,ans;
scanf("%d", &n);
z=n/15;
y=z*200;
x=n*800;
ans=x-y;
printf("%d" , ans ) ;
	
	return 0;
}
    

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifdef LOCAL
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define debug(x) ;
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

int dp[SIZE][100][3]; //{桁, mod, {0: 等, 1: 多, 2: 少}}

int main(){
  string k;
  int d;

  cin >> k >> d;

  dp[0][0][0] = 1;

  ll ans = 0;

  for(int i=0;i<k.size();i++){
    int p = k[i] - '0';
    debug(p);

    for(int j=0;j<d;j++){
      for(int l=(i==0);l<=9;l++){
        if(l < p) {
          dp[i+1][(j+l)%d][1] += dp[i][j][1];
          dp[i+1][(j+l)%d][2] += dp[i][j][0] + dp[i][j][2];
        }
        if(l == p) {
          dp[i+1][(j+l)%d][0] += dp[i][j][0];
          dp[i+1][(j+l)%d][1] += dp[i][j][1];
          dp[i+1][(j+l)%d][2] += dp[i][j][2];
        }
        if(l > p) {
          dp[i+1][(j+l)%d][1] += dp[i][j][0] + dp[i][j][1];
          dp[i+1][(j+l)%d][2] += dp[i][j][2];
        }

        dp[i+1][(j+l)%d][0] %= mod;
        dp[i+1][(j+l)%d][1] %= mod;
        dp[i+1][(j+l)%d][2] %= mod;
      }
    }
  }

  for(int i=1;i<=k.size();i++){
    ans += dp[i][0][0] + dp[i][0][2];
    if(i < k.size()) ans += dp[i][0][1];
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define int ll
#define ll __int128
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
const ll inf = 1e18;

ll n, x, d, ans;
map<pii, set<pll> > tb;

template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}

inline int getGcd(int a, int b) {
    return b ? getGcd(b, a % b) : a;
}

inline ll comb(int n) {
    return (ll) n * (n - 1) / 2;
}

void print(ll x) {
    if (x >= 10) print(x / 10);
    putchar('0' + (x % 10));
    return;
}

signed main() {
    read(n), read(x), read(d);
    if (d < 0) x = -x, d = -d;
    if (d == 0 && x == 0) return print(1), 0;
    if (d == 0) return print(n + 1), 0;
    int gcd = getGcd(x, d);
    x /= gcd, d /= gcd;
    for (R int i = 0; i <= n; ++i) {
        ll w = (ll) (n - i - i) * x;
        int r = (w % d + d) % d, om = 0;
        ll del = (w - r) / d, lt = 2 * comb(n - i) - comb(n) + del, rt = comb(n) - 2 * comb(i) + del;
        if (lt & 1) om = 1, ++lt, ++rt;
        lt /= 2, rt /= 2;
        auto it = tb.find(mp(r, om));
        if (it == tb.end()) {
            set<pll> tmp;
            tmp.clear(), tmp.insert(mp(lt, rt));
            tb[mp(r, om)] = tmp;
        }
        else {
            auto &s = it->second;
            auto l = s.upper_bound(mp(lt - 1, inf)), r = s.upper_bound(mp(rt, inf));
            if (l != s.begin() && prev(l)->second >= lt) --l;
            while (l != r) {
                lt = min(l->first, lt), rt = max(l->second, rt);
                ++l, s.erase(prev(l));
            }
            s.insert(mp(lt, rt));
        }
    }
    for (auto &k : tb)
        for (auto &t : k.second)
            ans += t.second - t.first + 1;
    print(ans);
    return 0;
}

Measured memory_bytes: 40832
#include <iostream>
#include <cmath>

using namespace std;

int main(){
	const int divide = 11;
	unsigned long long int x, ans, t;
	cin >> x;

	ans = x / divide * 2;
	if (x % 11 == 0)
	{
		cout << ans;
	}
	else if (x % 11 > 6)
		cout << ans + 2;
	else
		cout << ans + 1;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
  int n, x;
  while(1){
    int ans=0;
    cin >> n >> x;
    if(x==0&&n==0) break;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            for (int k = 1; k <= n; k++){
                if(i<j&&j<k) if(i+j+k==x) ans++;
            }
        }
    }
    cout << ans << endl;
  } 
  
}


Measured memory_bytes: 3076
n,d = gets.split.map(&:to_i)
s = n.times.map{gets.split.map(&:to_i)}

cnt = 0
s.combination(2) do |a,b|
  r2 = a.zip(b).map{|x,y| (x-y)**2 }.inject(:+)
  cnt +=1 if Math.sqrt(r2).to_i**2 == r2 
end
p cnt

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll C;

int main(){
  cin>>C;
  while(C--){
    ll N,K;
    cin>>N>>K;
    if(N%2==0)N--;
    ll L=(N+1)/2;
    if(K>L){
      cout<<-1<<endl;
      continue;
    }
    ll lb=0,ub=N;
    while(ub-lb>1){
      ll X=(lb+ub)/2;
      //dbg(X);
      
      ll t=N;
      ll d=2;
      ll cnt=0;
      while(t>=1){
        ll nt = t/3;
        if(nt%2==0) nt--;

        ll hi=t,lo=nt+2;
        if(lo>hi) lo=1;
        ll num = (hi-lo)/2 + 1;

        if(X-lo*(d/2)>=0){
          ll i=(X-lo*(d/2))/d;
          //dbg(hi); dbg(lo);
          //dbg(i);
          cnt+=min(num,i+1);
        }
        t = nt;
        d*=2;
      }
      if(cnt>=K)ub=X;
      else lb=X;
    }
    cout<<ub<<endl;
  }
  return 0;
}



Measured memory_bytes: 3068
# -*- coding: utf-8 -*-

N = int(input())

values = [0]*N
value_count_map = {}
for i in range(N):
    in_value = int(input())
    values[i] = in_value
    value_count = 0
    if in_value in value_count_map:
        value_count = value_count_map[in_value]
    value_count_map[in_value] = value_count + 1

max_value = max(value_count_map.keys())
value_count = value_count_map.pop(max_value)
if value_count == 1:
    next_max_value = max(value_count_map.keys())
for row in range(N):
    if value_count > 1:
        print(max_value)
    elif values[row] == max_value:
        print(next_max_value)
    else:
        print(max_value)



Measured memory_bytes: 18640
def solve(string):
    abc = sorted(map(int, string.split()))
    ans = 0
    oe = sum([_abc % 2 == 0 for _abc in abc])
    if 1 <= oe <= 2:
        for i, _ in enumerate(abc):
            if abc[i] % 2 == oe % 2:
                abc[i] += 1
        ans += 1
    return str(ans + (abc[-1] - abc[0]) // 2 + (abc[-1] - abc[1]) // 2)


if __name__ == '__main__':
    print(solve(input()))


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  int ans = 48 - m;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		try {
		    Scanner sc=new Scanner(System.in);
		    int a=sc.nextInt();
		    int b=sc.nextInt();
		    int c=sc.nextInt();
		    System.out.println(c+" "+a+" "+b);
		} catch(Exception e) {
		}
	}
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  vector<bool> good(N);
  rep(i,N) {
    cin >> H[i];
    good[i] = true;
  }
  rep(i,M) {
    int A, B;
    cin >> A >> B;
    if (H[A-1] > H[B-1]) good[B-1] = false;
    else if (H[A-1] < H[B-1]) good[A-1] = false;
    else {
      good[A-1] = false;
      good[B-1] = false;
    }
  }
  int ans = 0;
  rep(i,N) if (good[i]) ++ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3396
N = int(input())
A = list(map(int, input().split()))
c = 0
f = True
while(True):
  for i in range(N):
    if A[i]%2 == 1:
      f = False
  if f:
    for i in range(N):
      A[i] /= 2
    c += 1
  else:
    break
print(c)

Measured memory_bytes: 2940
x = input()
#tのラストとsの最初を知りたい
n = len(x)
a = []
for i in range(n):
  if x[i]=="S":
    a.append(x[i])
  else:
    if len(a)!=0 and a[-1]=='S' :
      a.pop()
    else:
      a.append(x[i])
print(len(a))

Measured memory_bytes: 10708
def cin():  return list(map(int,input().split()))
c = [0] * 4
for i in range(3):
    in1, in2 = cin()
    c[in1 - 1] += 1
    c[in2 - 1] += 1
c = sorted(c)
if c == [1, 1, 2, 2]:  print("YES")
else:  print("NO")

Measured memory_bytes: 61832
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.stream.Stream;

public class Main {
  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    int n = Integer.parseInt(br.readLine());
    int ans = 0;
    if (n >= 400 && n <= 599) ans = 8;
    if (n >= 600 && n <= 799) ans = 7;
    if (n >= 800 && n <= 999) ans = 6;
    if (n >= 1000 && n <= 1199) ans = 5;
    if (n >= 1200 && n <= 1399) ans = 4;
    if (n >= 1400 && n <= 1599) ans = 3;
    if (n >= 1600 && n <= 1799) ans = 2;
    if (n >= 1800 && n <= 1999) ans = 1;

    out.println(ans);
    out.close();
  }
}

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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 1000000
#define MOD 1000000001
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pi 3.14159265358979323846
#define Q ll _; cin >> _; while(_--)
#define endl "\n"
#define cy cout << "Yes\n";
#define cn cout << "No\n";
#define flush fflush(stdout);

int main(){

    fast;

    ll i,j,n;
    cin >> n;
    ll a[n];
    map<ll,ll> vis;
    for(i=0;i<n;i++){
        cin >> a[i];
        vis[a[i]]++;
    }
    sort(a,a+n);
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    if(a[0]==a[n-1]){
        cout << 0 << endl;
        return 0;
    }

    map<ll,ll> notprime;

    for(i=0;i<n;i++){
        if(!notprime[a[i]]){
            ll tmp = a[i];
            for(j=2;tmp<=a[n-1];j++){
                tmp = a[i]*j;
                notprime[tmp] = 1;
            }
        }
    }

    ll cnt = 0;
    for(i=0;i<n;i++){
        if(!notprime[a[i]]){
            if(vis[a[i]]==1){
                cnt++;
            }
        }
    }

    cout << cnt << endl;

}

//    cout << fixed << setprecision(12);


Measured memory_bytes: 77004
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    ll N, K;
    cin >> N >> K;
    ll ans = 1e9;
    vector<ll> v(N);
    vector<ll> diff(N - 1);
    rep(i, N) cin >> v[i];
    sort(v.begin(), v.end());
    // rep(i, N - 1) {
    //     // cout << v[i + 1] - v[i] << endl;
    //     diff[i] = v[i + 1] - v[i];
    // }
    for(int i = 0; i < N - K + 1; i++) {
        ans = min(ans, v[i + K - 1] - v[i]);
    }
    cout << ans << '\n';
}
// 10 11 12 14 15
// 1 1 2 1


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <deque>
#include <queue>
#include <assert.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    map<int,ll> mp;
    ll sum=0;
    for(int i=0;i<n;i++){
    	int a; cin >> a;
    	mp[a]++;
    	sum+=a;
    }
    int q; cin >> q;
    while(q--){
    	ll b,c; cin >> b >> c;
    	ll p=mp[b];
    	sum-=p*b;
    	sum+=p*c;
    	mp[b]=0;
    	mp[c]+=p;
    	cout << sum << endl;
    }

}




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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll sum = 0;
    rep(i,n) sum += a[i];
    vector<ll> x(n);
    x[0] = sum;
    int t = 1;
    rep(i,n/2){
        x[0] -= 2*a[t];
        t += 2;
    }
    rep(i,n-1){
        x[i+1] = 2*a[i] - x[i];
    }
    rep(i,n) cout << x[i] << ' ';
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  long long a,b,c,d;
  cin>>a>>b>>c>>d;
  long long ans = max(a*c, b*d);
  ans = max(ans,a*d);
  ans = max(ans,b*c);
  cout<<ans<<endl;
}

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

int main(){

    int n;
    cin >> n;
    ll ans =0;
    for (int i = 1; i <= n; i++){
        if (i % 3 && i % 5) ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
 
using namespace std;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif
 
#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000000
#define ll long long
#define db double
#define str string
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Forrev(i,s,e) for (ll i=(s); i>=(e); i--)
#define all(v) v.begin(),v.end()
 
#define vll vector<ll>
#define vs vector<string>
#define mapll map<ll,ll>
#define pll pair<ll,ll>
#define initialise(a, x) memset(a, x, sizeof(a))
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>
 
#define ff first
#define ss second
#define endl "\n"
#define mp make_pair
const ll mod=1e9 + 7;
 
ll takemod(ll a) {
    return ((a%mod)+mod)%mod;
}
 
ll gcd(ll a, ll b) { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);        
}
 
ll fast_exp(ll base, ll expo) {
    ll res=1;
    while(expo>0) {
        if(expo&1) res=(res*base)%mod;
        base=(base*base)%mod;
        expo>>=1;}
    return res;
}
 
ll modinv(ll a) {
    return takemod(fast_exp(takemod(a), mod-2));
}
 
const int N = 1e5+1;

vector<int> graph[N];
int visited[N], dp[N];

int dfs(int index) {
	
	if (dp[index] != -1)
		return dp[index];
	dp[index] = 0;

	for (int a: graph[index]) 
		dp[index] = max(dp[index], 1 + dfs(a));
	return dp[index];
}

void solve () {
	
	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		graph[a].push_back(b);
	}
	memset(dp,-1,sizeof(dp));

	int ans = 0;
	for (int i = 1; i <=n; i++) {
		if (dp[i] == -1)
			dp[i] = dfs(i);
		ans = max(ans, dp[i]);
	}
	
	cout << ans << endl;
}

 
signed main() 
{
    fast_cin();
    
    
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    
    
    return 0;    
}

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

int main(){
  int n,x;
  cin>>n>>x;
  
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  
  int sum=0,ans=0;
  for(int i=0;i<n;i++){
    sum+=a[i];
    if(sum<=x){
      ans++;
    }
  }
  
  ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N;
    
    cin >> N;
    if (N == 1) cout << "Hello World" << endl;
    else if (N == 2) {
        int A, B;
        cin >> A >> B;
        cout << A + B << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  sort(a.begin(),a.end());
  cout << a[n - 1] - a[0] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
   int m,f,b;
   scanf("%d %d %d",&m,&f,&b);
   if(m >= b){printf("0\n");}
   else if((m+f)<b){printf("NA\n");}
   else printf("%d\n",b-m);
   return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
typedef long long LL;
typedef pair<int,int> pii;


void run_case() {
    int n; cin >> n;
    vector<vector<LL>> dp(n+1, vector<LL>(n+1));
    vector<pair<LL, int>> buf(n+1);
    for(int i = 0; i < n; ++i) {
        LL A;
        cin >> A;
        buf[i+1] = make_pair(A, i+1);
    }
    sort(buf.begin()+1, buf.end(), [&](const pair<LL, int> a, const pair<LL, int> b) {
        return a.first > b.first;
    });
    for(int i = 0; i <= n; ++i) {
        for(int j = 0; i + j < n; ++j) {
            int now = i + j + 1;
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]+buf[now].first*1LL*abs(buf[now].second-(i+1)));
            dp[i][j+1] = max(dp[i][j+1], dp[i][j]+buf[now].first*1LL*abs(buf[now].second-(n-j)));
        }
    }
    LL ans = 0;
    for(int i = 0; i <= n; ++i)
        ans = max(ans, dp[i][n-i]);
    cout << ans;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(10);
    run_case();
    cout.flush();
    return 0;
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  for(int i=0;i<s.size();++i) {
    if( ( !( i & 1 ) && s[i] == 'L' ) || ( ( i & 1 ) && s[i] == 'R' ) ) { puts("No"); return 0; }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	N := 0
	M := 0
	fmt.Scan(&N, &M)

	Lmin := 0
	Rmax := 100001

	for i := 0; i < M; i++ {
		L, R := 0, 0
		fmt.Scan(&L, &R)
		if L > Lmin {
			Lmin = L
		}

		if R < Rmax {
			Rmax = R
		}
	}

	t := Rmax - Lmin
	if t < 0 {
		fmt.Println(0)
	} else {
		fmt.Println((Rmax - Lmin) + 1)
	}
}


Measured memory_bytes: 5504
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    K, X = LI()
    if K * 500 >= X:
        print("Yes")
    else:
        print("No")
    return


# B
def B():
    n = I()
    s = S()
    cnt = 0
    for i in range(n - 2):
        if s[i] == "A":
            if s[i + 1] == "B" and s[i + 2] == "C":
                cnt += 1
    print(cnt)
    return


# C
def C():
    n = I()
    p = LI()
    q = LI()
    a_cnt = [1] * n
    b_cnt = [1] * n
    a = 0
    b = 0
    for i in range(1, n + 1):
        num = 1
        for j in range(1, n + 1 - i):
            num *= j
        a += sum(a_cnt[:p[i - 1]]) * num
        b += sum(b_cnt[:q[i - 1]]) * num
        a_cnt[p[i - 1] - 1] = 0
        b_cnt[q[i - 1] - 1] = 0
    print(abs(a - b))
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 38340
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define ll long long
#define pii pair<int,int> 
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
int inf=1000001000;
ll INF=100000000000000000;
ll MOD=1000000007;
//g++ code.cpp   ./a.out 
 
int main() {
    int k,x;
    cin >> k >> x;
    if(500*k>=x){
        Yes;
        return 0;
    }
      if(500*k<x){
        No;
        return 0;
    }
}



Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> lpair;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B;
    cin >> A >> B;
    if(A <= 9 && B <= 9){
        print(A*B);
    }else{
        print(-1);
    }
    

}


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

#define null				""
#define all(dat)			dat.begin(), dat.end()
#define over(msg)			cout << msg << endl, exit(0);
#define loop(i, to)			for (int i = 0; i < to; ++i)
#define cont(i, to)			for (int i = 1; i <= to; ++i)
#define foreach(i, dat)		for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long			num;

using namespace std;

int n, m, dp[100005], ans;
vector<int> g[100005];

void dfs(int u) {
	if (dp[u] != -1)  return;
	dp[u] = 0;
	for (int v : g[u]) {
		if (dp[v] == -1) {
			dfs(v);
		}
		dp[u] = max(dp[u], dp[v] + 1);
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	cont (i, m) {
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
	}
	memset(dp, -1, sizeof(dp));
	cont (i, n) {
		if (dp[i] == -1) {
			dfs(i);
		}
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 8192
#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 int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;

//価値v,重さw
int Knapsack(int n,int W, vector<int>& v,vector<int>& w){
    W++;
    twovec(dp,n,W);
    dp[0][w[0]] = v[0];
    FOR(i,1,n){
        if(w[i] >= W) continue;
        dp[i][w[i]] = max(v[i],dp[i-1][w[i]]);
        REP(j,W){
            if(dp[i-1][j] != 0){
                dp[i][j] = max(dp[i][j],dp[i-1][j]);
                if(j+w[i] < W){
                    dp[i][j+w[i]] = dp[i-1][j] + v[i];
                }
            }
        }
    }
    int ans = 0;
    REP(i,W){
        ans = max(ans,dp[n-1][i]);
    }
    return ans;
}

//価値v,重さw
int Knapsack_(int n,int W, vector<int>& v,vector<int>& w){
    W++;
    vec(dp,W);
    REP(i,n){
        if(w[i] >= W) continue;
        dp[w[i]] = max(v[i],dp[w[i]]);
        REP(j,W){
            if(j+w[i] >= W) break;
            if(dp[j] != 0){
                dp[j+w[i]] = max(dp[j] + v[i],dp[j+w[i]]);
            }
        }
        //Debug(dp);
    }
    //Debug(dp);
    int ans = 0;
    REP(i,W){
        ans = max(dp[i],ans);
    }
    return ans;
}


signed main(){
    int W;
    cin >> n >> W;
    vec(v,n);
    vec(w,n);
    REP(i,n){
        cin >> v[i] >> w[i];
    }
    print(Knapsack_(n,W,v,w));
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



Measured memory_bytes: 3196
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);

template<class T> inline T sqr(T x) {return x*x;}

double f(int x, double p) {
	return x / (2.0 * p);
}

int main() {
	int x,p;
	cin >> x >> p;
	if (p == 100) {
		cout << (x + 1) / 2 << endl;
		return 0;
	}
	if (x % 2 == 1) {
		//cout << (1-1.0*p/100) + 1 + (x - 1) / (2.0 * p / 100) << endl;
		//cout << (x - 1) / (2.0 * p / 100) << endl;
		//printf("%.08f\n", (1-1.0*p/100) + 1 + (x - 1) / (2.0 * p / 100));
		printf("%.08f\n", 1+1.0*p/100*(f(x-1,1.0*p/100))+(1-1.0*p/100)*(f(x+1,1.0*p/100)));
	} else {
		//cout << x / (2.0 * p / 100) << endl;
		printf("%.08f\n", f(x, 1.0*p/100));
	}
	
	return 0;
}

Measured memory_bytes: 256
import queue

"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
T = 0 
for i in range(N):
	if B[i] > A[i]:
		B[i] -= A[i]
		T += A[i]
		T += min(B[i],A[i+1])
		A[i+1] -= min(B[i],A[i+1])
	else:
		T += B[i]
print(T)

Measured memory_bytes: 20540
fun main(args: Array<String>) {
    val a = readLine()!!.toInt()
    val b = readLine()!!.toInt()
    val c = readLine()!!.toInt()
    val d = readLine()!!.toInt()
    val e = readLine()!!.toInt()
    val k = readLine()!!.toInt()

    println(if (e-a>k) ":(" else "Yay!")
}

Measured memory_bytes: 29988
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1e9;
const long double EPS = 1e-10;

int main() {
  int n, m, r;
  cin >> n >> m >> r;
  vector<int> p(r);
  rep(i, r) {
    cin >> p[i];
    p[i]--;
  }
  vector<vector<int>> d(n, vector<int>(n, INF));
  rep(i, n) d[i][i] = 0;
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    d[a - 1][b - 1] = c;
    d[b - 1][a - 1] = c;
  }

  rep(k, n) {
    rep(i, n) {
      if (d[i][k] == INF) continue;
      rep(j, n) {
        if (d[k][j] == INF) continue;
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  sort(p.begin(), p.end());
  int ans = INF;
  while (next_permutation(p.begin(), p.end())) {
    int res = 0;
    rep(i, r - 1) res += d[p[i]][p[i + 1]];
    ans = min(ans, res);
  }
  cout << ans << endl;




  
  return 0;
}

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

const long long MAX_N = 1e5 + 5;
long long n, m;
long long par[MAX_N];
bool Mark[MAX_N];
vector <int> G[MAX_N], topo;

int dfs (int v) {
	Mark[v] = true;
	for (int i = 0; i < G[v].size(); i++)
		if (!Mark[G[v][i]])
			dfs(G[v][i]);
			
	topo.push_back(v);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n - 1 + m; i++) {
		int v, u;
		cin >> v >> u;
		v--; u--;
		
		G[v].push_back(u);
	}
	
	for (int i = 0; i < n; i++)
		if (!Mark[i])
			dfs(i);
			
	reverse(topo.begin(), topo.end());
	
	for (int i = 0; i < n; i++) {
		int v = topo[i];
		
		for (int j = 0; j < G[v].size(); j++)
			par[G[v][j]] = v + 1;
	}
		
	for (int i = 0; i < n; i++)
		cout << par[i] << " ";
	return 0;
}

Measured memory_bytes: 9848
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

	if (n <= k) {
		cout << 0 << endl;
		return 0;
	}

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

	sort(h.rbegin(), h.rend());

	long long sum = 0;
	for (int i = 0; i < k; i++) {
		h[i] = 0;
	}
	for (int i = k; i < n; i++) {
		sum += h[i];
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
char a[300010];
int w[300010],e[300010];
int ans=0x7fffffff;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<=n;i++)
	{
		scanf("%c",&a[i]);
		w[0]=e[0]=0;
		if(i)
		{
		
		if(a[i]=='W') w[i]=w[i-1]+1,e[i]=e[i-1];
		else e[i]=e[i-1]+1,w[i]=w[i-1];
	   } 
	}
	for(int i=1;i<=n;i++)
		ans=min(ans,w[i-1]+e[n]-e[i]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2944
package main

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

func main(){
	var s string
	var q int
	fmt.Scan(&s)
	fmt.Scan(&q)
	str := []rune(s)
	sc := bufio.NewScanner(os.Stdin)
	for i:=0; i<q; i++{
		sc.Scan()
		com := strings.Split(sc.Text(), " ")
		a, _ := strconv.Atoi(com[1])
		b, _ := strconv.Atoi(com[2])
		if com[0] == "print"{
			fmt.Println(string(str[a:b+1]))
		}else if com[0] == "reverse"{
			for i, j := a, b; i<j; i, j = i+1, j-1{
				str[i], str[j] = str[j], str[i]
			}
		}else{
			runes := []rune(com[3])
			j := 0
			for i:=a; i<=b; i++{
			    str[i] = runes[j]
				j++
			}
		}
	}
}


Measured memory_bytes: 1264
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple


int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	string s; cin>>s;
	int len=s.length();
	string ans="";
	for(int i=0;i<len;i++)
	{
	    if(s[i]=='B')
	    {
	        if(!ans.empty()) ans.erase(ans.length()-1);
	        
	    }
	    else ans += s[i];
	    
	}
	cout<<ans;
	
	
	return 0;
}


Measured memory_bytes: 256
def main():
    li = list(map(int, input()))
    option_0 = []
    option_1 = []
    count_0 = 0
    count_1 = 0

    #print(li)
    for i in range(len(li)):
        if i%2 == 0:
            option_0.append(0)
            option_1.append(1)
        else:
            option_0.append(1)
            option_1.append(0)
    
    #print(option_0)
    #print(option_1)
    for i in range(len(li)):
        if option_0[i] != li[i]:
            count_0 += 1
        if option_1[i] != li[i]:
            count_1 += 1

    print(min(count_0, count_1))

if __name__ == '__main__':
    main()

Measured memory_bytes: 5536
s = input()
counter = 0
max_count = 0
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C' or s[i] =='G' or s[i] == 'T':
        counter += 1
    else:
        if counter > max_count:
            max_count = counter
            counter = 0
        else:
            counter = 0
if counter > max_count:
    max_count = counter
print(max_count)
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define ll long long int
using namespace std;
int n,k ;
int a[100005];
int dp[100005];
int main()
{
    cin>>n>>k;
    memset(dp,0,sizeof(dp));
    rep(i,1,n+1)
    {
        cin>>a[i];
    }
    //sort(a+1,a+n+1);
  //  rep(i,1,k+1)
  //  cout<<dp[i]<<" ";
    for(int stones = 0;stones<=k;stones++)
    {
        rep(i,1,n+1)
        {
            if(stones>=a[i] && !dp[stones-a[i]])
            {
                dp[stones] = true;
            }
        }
    }
    cout<<(dp[k] ? "First" : "Second" );
   // cout<<dp[k]<<endl;
}


Measured memory_bytes: 640
import Data.List
import Data.Char
import Text.Printf

main = interact $ show . solve . read'
  where
    solve [p1x, p1y, p2x, p2y] = sqrt $ (p2x - p1x) ** 2 + (p2y - p1y) ** 2
    read' = map read . words :: String -> [Double]



Measured memory_bytes: 4068
#include <stdio.h>
#define MAX 45
int A[MAX];

int Fibonacci(int);

int main() {
  int i,n,ans;
  for(i = 0; i < MAX; i++) {
    A[i] = 0;
  }
  scanf("%d",&n);
  ans = Fibonacci(n);
  printf("%d\n",ans);

  return 0;

}

int Fibonacci(int n) {
  if(n == 0) {
    A[n] = 1;
    return A[n];
  }

  if(n == 1) {
    A[n] = 1;
    return A[n];
  }

  else if(A[n] != 0) return A[n];
  else {
    A[n] =  Fibonacci(n - 1) + Fibonacci(n - 2);
    return A[n];
  }
}

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

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            // 文字列の入力
            string s = Console.ReadLine();

            string result = "Yes";

            var ss = 0;

            if (s.Length != inputLongArray[0] + inputLongArray[1] + 1) {
                result = "No";
            }else if(s[inputLongArray[0]] != '-') {
                result = "No";
            } else if(int.TryParse(s.Substring(0, inputLongArray[0]), out ss) == false) {
                result = "No";
            }else if (int.TryParse(s.Substring(inputLongArray[0] + 1), out ss) == false) {
                result = "No";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
#include <stdio.h>

int main() {
  int N;
  double v[1100];

  scanf("%d", &N);

  int i;
  int j;
  int temp;
  for (i = 0; i < N; i++) {
    scanf("%lf", &v[i]);
  }

  //v[i]を小さい順にソート。

  for (i = 0; i < N - 1; i++) {
    for (j = 0; j < N - 1; j++) {
      if (v[j+1] < v[j]) {
        temp = v[j];
        v[j] = v[j+1];
        v[j+1] = temp;
      }
    }
  }





  for (i = 0; i <= N - 2; i++) {
    v[i+1] = (v[i+1] + v[i]) / 2;
  }

  printf("%f\n", v[N-1]);




  return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;
import static java.lang.Long.bitCount;

public class Main {

    public static void main(String[] args) {
        FastScanner in = new FastScanner();
        int n, k;
        n = in.nextInt();
        k = in.nextInt();
        int []a = new int[n+1];
        for(int i=1; i<=n; ++i)
            a[i] = in.nextInt();

        int []dp = new int[400100];;
        int itr = 0;
        while(true){
            if(itr == k)
                break;
            ++itr;
            int ok = 1;
            Arrays.fill(dp, 0);
            for(int i=1; i<=n; ++i){
                if(i-a[i]>=0) dp[i-a[i]]++;
                else dp[0]++;
                dp[i+a[i]+1]--;
            }
            for(int i=1; i<=n; ++i){
                dp[i] += dp[i-1];
            }
            for(int i=1; i<=n; ++i){
                if(dp[i] != a[i]){
                    ok = 0;
                    break;
                }
            }
            a = Arrays.copyOf(dp, 200100);
            if(ok == 1)
                break;
        }

        for(int i=1; i<=n; ++i){
            System.out.print(a[i] + " ");
        }
    }

    static void sort(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }

    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 61392
#include<iostream>
using namespace std;
typedef long long li;
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int x; cin >>x;
  int m=1;
  repa(i,2,x){
    int b=i*i;
    while(b<=x){
      m=max(m,b);
      b*=i;
    }
  }
  print(m);
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <limits>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    uint N;
    cin >> N;
    vector<char> v(N, 0);
    for (auto &&i: irange(0U, N)){
        cin >> v.at(i);
    }
    for (auto &&i: irange(0U, N)){
        if (v.at(i)=='Y'){
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  ll n;
  cin >> n;
  vi p;
  p.push_back(2);
  while (pow(2, p.size() + 1) - 1 <= n) {
    p.push_back(p.back() + 2);
  }
  n -= pow(2, p.size()) - 1;
  int add = p.back() + 1;
  ll mask = 1LL << p.size();
  while (mask > 0) {
    if (n & mask) {
      p.push_back(add);
      n -= mask;
    }
    mask >>= 1;
    add -= 2;
  }
  vi p2 = p;
  sort(all(p2));
  cout << p.size() * 2 << endl;
  rep (i, p2.size()) {
    cout << p2[i] << " ";
  }
  rep (i, p.size()) {
    cout << p[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;

double dist(ll x, ll y) {
	return sqrt(x * x + y * y);
	}

void solve() {		
	int n, d;	
	cin >> n >> d;
	int cnt = 0;
	vector<pair<int, int >> p(n);
	for(int i = 0; i < n; ++i) {
		int x, y;
		cin >> x >> y;
		if(dist(x, y) <= d) cnt++;
		}
		cout << cnt << endl;
}


	

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






Measured memory_bytes: 4760
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> B(N-1);
	for(int i=0; i<N-1; ++i) cin >> B[i];
	int ans=B[0]+B[N-2];
	for(int i=1; i<N-1; ++i) ans += min(B[i-1], B[i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;
int N;string s;
set<string> ans_set;

void dfs(string s){
  if(s.size()==N){ans_set.insert(s);return;}
  char mx_ch='a';
  for(char a:s){
    mx_ch=max(mx_ch,a);
  }
  for(char a='a';a<=mx_ch+1;a++){
    dfs(s+a);
  }
  return;
}

int main(){
  cin>>N;
  dfs("a");
  for(auto e:ans_set){
    print(e)
  }
}


Measured memory_bytes: 14208
fun main(args: Array<String>) {
    val (n, a, b) = readLine()!!.split(" ").map(String::toInt)
    var num = 0
    for(i in 1..n) {
        val iStr = i.toString()
        var sum = 0
        for(j in 0..iStr.length -1) {
            val iInt = iStr[j].toString().toInt()
            sum = sum + iInt
        }
        if(sum >= a && sum <= b) {
            num += i
        }
    }
    println(num)
}

Measured memory_bytes: 38800
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll n;
  cin >> n;

  vector<ll> a(n);
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }

  vector<vector<ll>> g(n);
  for (int i = 1; i < n; i++) {
    ll boss = a[i];

    g[boss].push_back(i);
  }

  for (int i = 0; i < n; i++) {
    ll cnt = g[i].size();
    cout << cnt << ln;
  }

  return 0;
}

Measured memory_bytes: 15512