akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int n,m,a[100010],b[100010],r[100010],i,d[100010][2],f[100010],s;
  while(scanf("%d %d",&n,&m),n){
    for(i=0;i<m;i++)scanf("%d %d",&a[i],&b[i]);
    if(n<=m)goto END;
    for(i=0;i<=n;i++)r[i]=f[i]=0;
    for(i=0;i<m;i++){
      d[a[i]][r[a[i]]++]=b[i];
      d[b[i]][r[b[i]]++]=a[i];
      if(r[a[i]]==3||r[b[i]]==3)goto END;
    }
    for(i=1;i<=n;i++){
      if(r[i]%2==0)continue;
      r[i]=2;
      s=i;
      while(r[s]==2){
	r[s]=0;
	f[s]=1;
	if(f[d[s][0]])s=d[s][1];
	else          s=d[s][0];
      }
      r[s]=0;
      f[s]=1;
    }
    for(i=0;i<n&&r[i+1]==0;i++);
    printf("%s\n",i-n?"no":"yes");
    continue;
  END:;
    printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2996
n=int(input())
#l=list(map(int,input().split()))  #inputした数値列をintにしてlistを作成 けどなぜか使えない
list = input().split(" ")
list_int = []
for i in list:
  list_int.append(int(i)) 
k = [0]*n                         #大きさnのリスト
for i in list_int:
  k[i-1] = k[i-1]+1
for j in range(n):
  print(k[j])

Measured memory_bytes: 34012
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
  long long a[200001];
    long long ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i)a[i]=a[i]+a[i-1];
    }
    sort(a,a+n);
    long long cnt=1;
    for(int i=0;i<n;i++){
        if(a[i]==0)ans++;
        if(i){
            if(a[i]==a[i-1])cnt++;
            else{
                ans+=cnt*(cnt-1)/2;
                cnt=1;
            }
        }
    }
    ans+=cnt*(cnt-1)/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

signed main() {
    string S;
    cin >> S;
    int ans = 0;
    for (int i = 0; i < S.length(); i++) {
        for (int j = i + 1; j <= S.length(); j++) {
            bool check = true;
            for (int k = i; k < j; k++) {
                if (S[k] != 'A' && S[k] != 'C' && S[k] != 'G' && S[k] != 'T') check = false;
            }
            if (check) ans = max(ans, j - i);
        }
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

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

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll k,s;
    cin>>k>>s;
    ll ans=0;
    rep(i,k+1){
        rep(j,k+1){
            if(s-i-j>=0 && s-i-j <=k){
                ans ++;
            }
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
import Data.Char
import Data.Maybe
import qualified Data.Map.Strict as M

main = getContents >>= mapM_ (putStrLn . unwords . solve . words) . lines

solve :: [String] -> [String]
solve xs = map (decrypt n)  xs
   where n = head . mapMaybe (flip M.lookup keys) $ xs

keys :: M.Map String Int   
keys = M.fromList $ concatMap (\s -> map (\n -> (encrypt n s, n)) [0..25]) ["the", "this", "that"]
   
ceaser :: Int -> Char -> Char
ceaser key c 
   | c < 'a' || c > 'z' = c
   | otherwise          = chr . flip mod 128 $ n'
   where n' | n > 122   = n - 26
            | n < 97    = n + 26
            | otherwise = n
               where n = ord c + key
               
encrypt :: Int -> String -> String
encrypt key = map $ ceaser key

decrypt :: Int -> String -> String
decrypt key = map $ ceaser (- key)


Measured memory_bytes: 3740
#!/usr/bin/env ruby
# require 'pry'

# N
# a_1 b_1
# ...
# a_N b_N
# ↑を[[a_1,..a_N],[b_1,..b_N]]にする
# N = gets.to_i
# a, b = N.times.map{gets.split.map(&:to_i)}.transpose

a,b,k = gets.split.map &:to_i
ary=[*(1..100)].reverse!
ary2 = ary.map do |e|
  e if a % e == 0 && b % e == 0
end.compact!

puts ary2[k-1]

Measured memory_bytes: 14288
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<list>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int msb32(uint32_t x) { return 31 - __builtin_clz(x); }
int msb(uint64_t x) {
  if(x < (1ULL<<32)) return msb32((uint32_t)x);
  return 32 +msb((uint32_t)(x>>32));
}

struct bit_base {
  uint64_t bases[64];
  bit_base() { std::fill_n(bases, 64, (uint64_t)0); }
  uint64_t add(uint64_t n) {
    int x = msb(n);
    while(bases[x] > 0) {
      n ^= bases[x];
      if(n == 0) return 0;
      x = msb(n);
    }
    return bases[x] = n;
  }
};

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int T; std::cin >> T;
  for(int t = 0; t < T; ++t) {
    int N; std::cin >> N;
    std::vector<uint64_t> A(N);
    for(auto& Ai: A) std::cin >> Ai;
    std::string S; std::cin >> S;
    bit_base b;
    for(int n = N-1; n >= 0; --n) {
      if(S[n] == '0') {
        b.add(A[n]);
      } else {
        if(b.add(A[n]) > 0) { std::cout << "1\n"; break; }
      }
      if(n == 0) { std::cout << "0\n"; break; }
    }
  }
  return 0;
}



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

int main(){
  int n,k;
  cin >> n >> k;
  vector<char> s(n);
  for(int i=0;i<n;i++){
    cin >> s.at(i);
  }
  if(s.at(k-1) =='A'){s.at(k-1) = 'a';}
  else if(s.at(k-1) =='B'){s.at(k-1) = 'b';}
  else if(s.at(k-1) =='C'){s.at(k-1) = 'c';}
  
  for(int i=0;i<n;i++){
    cout << s.at(i); 
  }
}

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

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    int ans = 10000;
    int lenS = s.length();
    int lenT = t.length();
    for(int i = 0; i < lenS-lenT+1; i++){
        int change = 0;
        for(int j = 0; j < lenT; j++){
            if(s[i+j] != t[j]){
                change++;
            }
        }
        ans = min(ans, change);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3620
import numpy as np

N,M=map(int, input().split())
a=[]
b=[]
for _ in range(M):
  t = list(map(int, input().split()))
  a.append(t)
  b += [t[1]]

b = np.array(b)
idx = np.argsort(b)
a=np.array(a)
a=a[idx]

n=1
r = a[0][1]
for i in range(M):
  if r <= a[i][0]:
    n+=1
    r=a[i][1]

print(n)





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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int x;
  cin>>x;
  int sho = x / 100;
  int sa = x - sho * 100;
  if(sa <= sho*5) {
    cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N = 100005;
#define M 998244353
#define double long double
#define BINF 10000000000001
#define MAXN 500005
#define init(arr,val) memset(arr,val,sizeof(arr))
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;



#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);


    
    int a;
    double b;
    cin >> a >> b;
    double ans = a * b;
    int x = ans;
    cout << x << endl;
    
return 0;
}


Measured memory_bytes: 3772
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
            B[i] = A[i];
        }
        sc.close();

        Arrays.sort(B);
        int count = 0;
        for(int i = 0; i < N; i+=2){
            if(Arrays.binarySearch(B, A[i])%2 == 1){
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 64712
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    ll n,k;
    cin >> n >> k;
    ll a,b;
    vector<ll> A(100010,0);
    rep(i,n){
        cin >> a >> b;
        A[a] += b;
    }
    ll tot = 0;
    rep(i,100010){
        tot += A[i];
        if(tot >= k){
            cout << i << endl;
            break;
        }
    }


    return 0;
}

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

#define ll long long int 
ll mod=1e9+7;

// vector<int> g[200005];
// int vis[200005];
// queue<int> q;
// int level[200005];

// void dfs(int i)
// {
//     vis[i] = 1;
//     for(int j=0;j<g[i].size();j++)
//     {
//         int child = g[i][j];
//         if(vis[child] == 0)
//         {
//             dfs(child);
//         }
//     }
// }

// void bfs(int i)
// {
//     vis[i] = 1;
//     while(!q.empty())
//     {
//         int top = q.front();
//         int len_adj = g[top].size();
//         int j;
//         for(j=0;j<len_adj;j++)
//         {
//             int v = g[top][j];
//             if(vis[v]==0)
//             {
//                 vis[v]=1;
//                 q.push(v);
//                 level[v] = level[top] + 1;
//             }
//         }   
//         q.pop();
//     }
// }

ll modular_exponentiation(ll base, ll power)
{
    ll ans = 1;
    base = base % mod;
    while (power > 0)
    {
        if (power & 1)
        {
            ans = (ans * base) % mod;
        }

        power /= 2;
        base = (base * base) % mod;
    }
    return ans;
}

int main()
{
    /* Faster input ouput */
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    /* To read input from a file and output to a file */
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    
    int t = 1;
    // cin >> t;
    while(t--)
    {        
        ll x;
        cin >> x;
        ll base = 100;
        ll ans = 0;

        while(base < x)
        {
            ll add = base/100;
            base += add;
            ans++;
        }

        cout << ans << '\n';
    }

    
    
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
long long int adj[1000][1000];
long long int h[100000+10];
map<long long int,long long int>mp;
long long int val;
long long int answe1,res;
vector<lli>vect[400];
//set<lli>s;
/*void primeFactors(int n)
{
    // Print the number of 2s that divide n
    while (n % 2 == 0)
    {
        s.insert(2);
        n = n/2;
    }

    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            s.insert(i);
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        s.insert(n);
}
*/
int main()
{

    fast;



    lli INF=1e18+5;

    lli n,W;
    cin>>n>>W;
    lli total=0;
    vector<lli>weight(n),value(n);
    for(lli i=0;i<n;i++)
    {
        cin>>weight[i]>>value[i];
        total+=value[i];
    }
  //  cout<<total<<"\n";
    vector<lli>dp(total+1,INF);
    dp[0]=0;
    for(lli i=0;i<n;i++)
    {
        for(lli v=total-value[i];v>=0;v--)
        {
            //cout<<"haa "<<i<<" \n";
            dp[v+value[i]]=min(dp[v+value[i]],dp[v]+weight[i]);
            //cout<<dp[v+value[i]]<<"\n";
        }
    }
    lli ans=0;
    for(lli i=0;i<=total;i++)
    {
       // cout<<dp[i]<<" ";
        if(dp[i]<=W)
        {
            ans=max(ans,i);
        }
    }

    cout<<ans;


    return 0;

}


Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = Math.max(0, A - B*2);
		System.out.println(ans);
	}
	
	public static long gcd(long a, long b) {
		long remainder = a % b;
		if (remainder == 0) {
			return b;
		} else {
			return gcd(b, remainder);
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


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

int main(){
	int n, m;
	cin >> n >> m;
	int a[n], b[n + 1]{}, c[n + 1]{}, ans = n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(0 < a[i] - b[a[i]]) c[a[i] - b[a[i]]]++;
		b[a[i]]++;
	}
	for(int i = 1; i <= n; i++) if(c[i]) ans--;
	while(m--){
		int x, y;
		cin >> x >> y;
		x--;
		b[a[x]]--;
		if(0 < a[x] - b[a[x]] && c[a[x] - b[a[x]]] == 1) ans++;
		if(0 < a[x] - b[a[x]]) c[a[x] - b[a[x]]]--;
		a[x] = y;
		if(0 < a[x] - b[a[x]] && c[a[x] - b[a[x]]] == 0) ans--;
		if(0 < a[x] - b[a[x]]) c[a[x] - b[a[x]]]++;
		b[a[x]]++;
		cout << ans << endl;
	}
}

Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main( void )
{
	string s;
	string t;
	while ( cin >> s >> t && t != "X" )
	{
		vector <string> list;
		string token;

		// _ª éÈçA_[XRA
		if ( s.find( "_" ) != string::npos )
		{
			token = "";
			for ( int i = 0; i < s.size(); i++ )
			{
				if ( s[i] == '_' )
				{
					list.push_back( token );
					token = "";
				}
				else
				{
					token += s[i];
				}
			}
			list.push_back( token );
		}
		else if ( s[0] >= 'A' && s[0] <= 'Z' )
		{
			token = "";
			s[0] = tolower( s[0] );
			for ( int i = 0; i < s.size(); i++ )
			{
				if ( s[i] >= 'A' && s[i] <= 'Z' )
				{
					list.push_back( token );
					token = "";
					token += tolower( s[i] );
				}
				else
				{
					token += s[i];
				}
			}
			list.push_back( token );
		}
		else if ( s[0] >= 'a' && s[0] <= 'z' )
		{
			token = "";
			for ( int i = 0; i < s.size(); i++ )
			{
				if ( s[i] >= 'A' && s[i] <= 'Z' )
				{
					list.push_back( token );
					token = "";
					token += tolower( s[i] );
				}
				else
				{
					token += s[i];
				}
			}
			list.push_back( token );
		}

		if ( t == "U" )
		{
			for ( int i = 0; i < list.size(); i++ )
			{
				list[i][0] = toupper( list[i][0] );
			}
		}
		else if ( t == "L" )
		{
			for ( int i = 1; i < list.size(); i++ )
			{
				list[i][0] = toupper( list[i][0] );
			}
		}
		else if ( t == "D" )
		{
			for ( int i = 1; i < list.size(); i++ )
			{
				list[i] = "_" + list[i];
			}
		}

		string kotae = "";
		for ( int i = 0; i < list.size(); i++ )
			kotae += list[i];
		cout << kotae << endl;
	}

	return 0;
}

Measured memory_bytes: 0
N, M = map(int, input().split())
P = []
S = []
for i in range(M):
    p, s = input().split()
    P += [int(p)]
    S += [s]

CA = 0
PN = 0
d = {key:0 for key in P}
for i in range(len(P)):
    if d[P[i]] >= 0:
        if S[i] == "WA":
            d[P[i]] += 1
        elif S[i] == "AC":
            PN += d[P[i]]
            CA += 1
            d[P[i]] = -1

print(CA, PN)


Measured memory_bytes: 22580
/*
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_R = 100;
const int MAX_C = 100;

/* typedef */

/* global variables */

int as[MAX_R + 1][MAX_C + 1];

/* subroutines */

/* main */

int main() {
  int r, c;
  cin >> r >> c;

  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++) {
      cin >> as[i][j];
      as[i][c] += as[i][j];
    }

  for (int j = 0; j <= c; j++)
    for (int i = 0; i < r; i++) as[r][j] += as[i][j];
  
  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      if (j) putchar(' ');
      printf("%d", as[i][j]);
    }
    putchar('\n');
  }
  return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

const int MAX_N = 1e5 + 5, BLACK = 0, WHITE = 1, MOD = 1e9 + 7;
vector <int> tree[MAX_N];
long long no_of_ways[MAX_N][2];

long long dfs_count(int parent, int v, int colour)
{
    if(no_of_ways[v][colour] != -1)
    {
        return no_of_ways[v][colour];
    }

    no_of_ways[v][colour] = 1;

    for(int i = 0; i < tree[v].size(); i++)
    {
        int child = tree[v][i];

        if(child == parent) continue;

        long long no_of_subtrees = 1;

        if(colour == BLACK)
        {
            no_of_subtrees = dfs_count(v, child, WHITE);
        }
        else if(colour == WHITE)
        {
            no_of_subtrees = (dfs_count(v, child, BLACK) + dfs_count(v, child, WHITE))%MOD;
        }

        no_of_ways[v][colour] = (no_of_ways[v][colour]*no_of_subtrees)%MOD;
    }

    return no_of_ways[v][colour];
}

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

    for(int i = 1; i <= no_of_vertices - 1; i++)
    {
        int x, y;
        cin >> x >> y;

        tree[x].push_back(y);
        tree[y].push_back(x);
    }

    memset(no_of_ways, -1, sizeof(no_of_ways));

    long long answer = (dfs_count(0, 1, BLACK) + dfs_count(0, 1, WHITE))%MOD;

    cout << answer;
    return 0;
}

Measured memory_bytes: 17024
#include<bits/stdc++.h>
#define ll long long
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl;
using namespace std;
int memo[100005],a[100005];
int n;
int dp(int i)
{
    if(memo[i]!=-1)
    {
        return memo[i];
    }
    if(i>=n-1)
    {
        return 0;
    }
    int ret1=INT_MAX,ret2=INT_MAX;
    ret1=abs(a[i+1]-a[i])+dp(i+1);
    if(i<n-2)
    ret2=abs(a[i+2]-a[i])+dp(i+2);
    return memo[i]=min(ret1,ret2);
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;++i)
    {
        scanf("%d",&a[i]);
    }
    memset(memo,-1,sizeof memo);
    printf("%d",dp(0));
    return 0;
}




Measured memory_bytes: 4096
#include <stdio.h>

int main(void)
{
	int d;
	
	while(scanf("%d",&d)!=EOF)
	{
		int i=0;
		int sum=0;
		
		for(;;)
		{
			sum += d * (d * i)*(d * i);//縦 * 横
			
			if((d*i) == (600-d)) break;
			
			i++;
		}
		printf("%d\n",sum);
	}
}


Measured memory_bytes: 2040
import java.util.Scanner;

/**
 * Combinatorial - Knapsack Problem
 */
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line;

		int N = sc.nextInt();
		int W = sc.nextInt();
		int[] vs = new int[N + 1];
		int[] ws = new int[N + 1];
		int[] dp = new int[W + 1];

		for (int i = 1; i <= N; i++) {
			vs[i] = sc.nextInt();
			ws[i] = sc.nextInt();
		}

		for (int i = 1; i <= N; i++) {
			for (int j = ws[i]; j <= W; j++) {
				dp[j] = Math.max(dp[j], dp[j - ws[i]] + vs[i]);
			}
		}

		System.out.println(dp[W]);
	}
}

Measured memory_bytes: 26964
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,str;
  int cnt=0;
  cin>>s>>str;

            for(int i=0;i<3;i++)
                if(s[i]==str[i]){
                   cnt++;}
                   cout<<cnt<<endl;



return 0;}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s,t;
	cin >>s >>t;
	int n =sz(s);
	if(s == t.substr(0, n)) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

// https://atcoder.jp/contests/abc142/tasks/abc142_c
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();


		int[] result = new int[N];
		for(int i=0;i<N;i++) {
			result[sc.nextInt()-1] = i+1;
		}

		sc.close();

		for(int i=0;i<N;i++) {
			if(i!=N-1) {
				System.out.print(result[i]+" ");
			}else {
				System.out.print(result[i]);
			}

		}

	}

}


Measured memory_bytes: 62236
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const double eps = 1e-8;
const int N = 30005;
int A,B,C,D,E,F;
int pd[N],pdd[N];
int cceil(int x,int y) {
	if(x%y==0) return x/y;
	else return x/y+1;
}
int main() {
//	freopen("1.in","r",stdin);
	cin>>A>>B>>C>>D>>E>>F;
	int lim=0;
	for(int i=0;i*A<=F/100;i++)
		pd[i*A]=1,lim=i*A;
	for(int i=0;i<=lim;i+=A)
		for(int j=1;j*B+i<=F/100;j++)
			pd[j*B+i]=1;
	lim=0;
	for(int i=0;cceil(i*C,E)*100+i*C<=F;i++)
		pdd[i*C]=1,lim=max(lim,i*C);
	for(int i=0;i<=lim;i+=C) 
		for(int j=0;cceil(j*D+i,E)*100+j*D+i<=F;j++)
			pdd[i+j*D]=1;
	int max_sg=0,max_all=min(A,B)*100;
	double max1=0;
	for(int i=0;i<=F;i++) {
//		if(i==96)
//			cout<<"Fuck\n";
		if(pdd[i])
			for(int j=cceil(i,E);j<=F/100;j++)
				if(pd[j]&&i+j*100<=F&&i*100.0/(1.0*i+100.0*j)>max1+eps)
					max_sg=i,max_all=i+j*100,max1=i*100.0/(1.0*i+100.0*j);
	}
	cout<<max_all<<' '<<max_sg<<endl;
	return 0;
}

Measured memory_bytes: 256
import math
import string


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


a, b = map(int, input().split())
print(math.ceil((a+b)/2))


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

#define int long long
#define endl "\n"
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) rep(i,n)
#define repn(i,n) for(int i=n;i>=0;i--)

  int dp[8000][6000];
signed main(){
  cin.tie(0);
  //ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  int a[n];
  rep(i,n){
    cin>>a[i];
  }
  int fl[n]={0};
  vector<pair<int,int> > p;
  bool flag=false;
  int fs=1,sc=0;
  int prev=0,num=0;
  rep(i,n){
    //cout<<prev<<" "<<num<<endl;
    if(!flag){
      if(a[i] == i+1){
        p.push_back(make_pair(fs,sc));
        fl[i]=1;
      }
      else if(a[i] > i+1){
        flag=true;
        prev=a[i]+1;
        num=i+1;
        fl[a[i]-1]=1;
      }
    }else{
      if(a[i]>=prev){
        fl[a[i]-1]=1;
        fs++;
	prev=a[i];
        while(fl[prev-1]==1) prev++;
      }else if(a[i]==num){
        fl[a[i]-1]=1;
        sc++;
        while(fl[num-1]==1) num++;
      }else{cout<<0<<endl;return 0;}
      if(prev==num){
        flag=false;
        p.push_back(make_pair(fs,sc));
        fs=1;sc=0;
      }
    }
  }
  if(flag)  p.push_back(make_pair(fs,sc));
  rep(i,p.size() ){
    //  cout<<p[i].fst<<" "<<p[i].scd<<endl;
  }

   rep(i,p.size() + 1){
    rep(j,n+1){
      dp[i][j]=0;
    }
  }
   dp[0][0]=1;

  rep(i,p.size() ){
    repn(j,n){
      if(j+p[i].fst <= n+1){
        dp[i+1][j+p[i].fst]+=dp[i][j];
        dp[i+1][j+p[i].fst]%=MOD;
      }
       if(j+p[i].scd <= n+1){
        dp[i+1][j+p[i].scd]+=dp[i][j];
        dp[i+1][j+p[i].scd]%=MOD;
      }
    }
  }
  int ans=0;/*
  rep(i,p.size() + 1){
    rep(j,n+1){
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;}*/

  for(int i=n-m;i<m+1;i++){
    ans+=dp[p.size()][i];
    ans%=MOD;
  }
  cout<<ans<<endl;


  return 0;
}



Measured memory_bytes: 218920
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long lo;
typedef long double ld;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto it : a)
#define INF 100000007
#define MOD 1000000009
#define M 1000000007
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define endl "\n"
#define eps 1e-8
#define PI 3.141592653589793
#define debug(x) cout<<#x<<"="<<x<<endl
#define debug2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;
#define print_matrix(a,n,m) REPE(0,n,0,m){cout<<(a)[i][j]<<((j==m-1)?'\n':' ');}
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}
int main(){
    std::ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);cout.precision(20);
    lo n,m;
    cin>>n>>m;
    cout<<2*m-n;
    return 0;
}


Measured memory_bytes: 256
#include<iostream> 
using namespace std;
int main()
{
	int k,n,i,sumn=0,sumi=0,ans=0;
	cin>>k;
	for(n=1;n<=k;n=n+2)
		sumn++;
	for(i=2;i<=k;i=i+2)
		sumi++;
	ans=sumn*sumi;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  bool flag = true;
  REP(i, n) {
    int x;
    cin >> x;
    flag = flag && (x % 2 == 0);
  }
  string s = flag ? "second" : "first";
  cout << s << endl;
}

Measured memory_bytes: 3624
W, H, N = map(int, input().split())
left, right, bottom, top = 0, W, 0, H
for _ in range(N):
  x, y, a = map(int, input().split())
  if a == 1:
    left = max(left, x)
  elif a == 2:
    right = min(right, x)
  elif a == 3:
    bottom = max(bottom, y)
  elif a == 4:
    top = min(top, y)
if right > left and top > bottom:
  ans = (right - left) * (top - bottom)
else:
  ans = 0
print(ans)

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<ll, ll> P;
typedef pair<double, double >pd;
typedef pair<string, string> sP;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 5e14;
const double eps = 1e-10;
const double PI = acos(-1);
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

ll n;
vector<ll>ans;

int main() {
	cin >> n;
	if (n == 0) {
		cout << 0 << endl;
		return 0;
	}
	ll sum = 0;
	while (n != 1) {
		if (abs(n) % 2 == 1) {
			ans.eb(1);
			if (n < 0) {
				n = n / -2 + 1;
			}
			else {
				n = n / -2;
			}
		}
		else {
			ans.eb(0);
			if (n < 0) {
				n = n / -2;
			}
			else n = n / -2;
		}
	}
	ans.eb(1);
	for (int i = ans.size()-1;i >=0;i--) {
		cout << ans[i];
		sum += pow(-2, i);
		if (sum == n)return 0;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main(){
    ll x, y, r, d;
    double f;
    cin >> x >> y;
    d = x / y;
    r = x % y;
    f = 1.0*x / y;
    printf( "%d %d %.10f" , d, r, f);
    return 0;
}



Measured memory_bytes: 3204
import collections
N = int(input())
A = [int(i) for i in input().split()]

if set(A) == {0}:
    print('Yes')
    exit()


if N % 3 != 0:
    print('No')
    exit()

c = collections.Counter(A)

for v in c.values():
    if v % (N//3) != 0:
        print('No')
        exit()


if len(c) == 2 and c.most_common()[1][0] == 0 and c.most_common()[0][0] ^ 0 == c.most_common()[0][0]:
    print('Yes')
    exit()
elif len(c) == 3 and \
        (c.most_common()[0][0] ^ c.most_common()[1][0] ^ c.most_common()[2][0]) == 0:
    print('Yes')
    exit()


else:
    print('No')


Measured memory_bytes: 14468
n, k = map(int, input().split())
h_array = [int(x) for x in input().split()]
res = [0 for x in range(n)]
for index in range(n):
    ret = float("inf")
    if index == 1:
        res[index] = abs(h_array[index] - h_array[index - 1])
        continue
    elif index == 0:
        res[index] = 0
        continue
    for i in range(1, k + 1):
        if index - i < 0:
            continue
        ret = min(ret, abs(h_array[index] - h_array[index - i]) + res[index - i])
    res[index] = ret

print(res[-1])


Measured memory_bytes: 56544
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5+7;
int n, m, p[N];
vector<int> vec[N];
ll t[N], s[N], f[N], g[N];
void dfs1(int x, int fa)
{
	f[x] = 1;
	for(int i = 0; i < vec[x].size(); i++)
	{
		int y = vec[x][i];
		if(y!=fa)
		{
			dfs1(y, x);
			f[x] = f[x]*(f[y]+1)%m;
		}
	}
	return;
}
void dfs2(int x, int fa)
{
	ll c = 1;
	int tot = 0;
	vector<int> tmp;
	for(int i = 0; i < vec[x].size(); i++)
	{
		int y = vec[x][i];
		if(y!=fa)
		{
			p[++tot] = y;
			t[tot] = f[y];
		}
	}
	s[tot+1] = 1;
	for(int i = tot; i >= 1; i--)
	{
		s[i] = (t[i]+1)*s[i+1]%m;
	}
	for(int i = 1; i <= tot; i++)
	{
		g[p[i]] = (g[x]*c%m*s[i+1]+1)%m;
		tmp.push_back(p[i]);
		c = c*(t[i]+1)%m;
	}
	for(int i = 1; i <= tot; i++)
	{
		dfs2(tmp[i-1], x);
	}
	return;
}
int main()
{
	g[1] = 1;
	scanf("%d%d", &n, &m);
	for(int i = 2; i <= n; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	dfs1(1, 0);
	dfs2(1, 0);
	for(int i = 1; i <= n; i++)
	{
		printf("%lld\n", g[i]*f[i]%m);
	}
    return 0;
}

Measured memory_bytes: 19456
#ABC 113 B
n = int(input())
t, a = map(int, input().split())
heights = list(map(int, input().split()))
min_h = 10000
for i in range(1, n+1):
    h = abs(t - heights[i-1] * 0.006 - a)
    if h < min_h:
        min_h = h
        count = i
print(count)
    

Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
  int n;
  scanf("%d", &n);
  char s[n];
  scanf("%s", s);
  
  if(n%2 == 1) {
    printf("No\n");
    return 0;
  }
  
  for(int i = 0; i < n/2; i++) {
    if(s[i] != s[n/2+i]) {
      printf("No\n");
      return 0;
    }
  }
  
  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 128
inf = 7 + (10 ** 9)
n, m = map(int, input().split())
dp1 = [0] * (n + 1)
dp1[0] = 1
for _ in range(m):
    a = int(input())
    dp1[a] = - inf
for i in range(n):
    if i < n:
        if (dp1[i + 1] != -inf) & (dp1[i] != -inf):
                dp1[i + 1] = dp1[i + 1] + dp1[i]
    if i + 1 < n:
        if (dp1[i + 2] != -inf) & (dp1[i] != -inf):
                dp1[i + 2] = dp1[i + 2] + dp1[i]
print(dp1[-1] % inf)

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

int main() {
  string s;
  cin >> s;
  if(s.size() % 2 != 0) {
    cout << "No";
    return 0;
  }
  for(int i = 0; i < s.size(); i += 2) {
    if(!(s[i] == 'h' && s[i + 1] == 'i')) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

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

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

  int A, B; cin >> A >> B;
  for (int x = 1; x <= 1000; x++) {
    if ((int)(x * 0.08) == A && (int)(x * 0.1) == B) {
      cout << x << "\n";
      return 0;
    }
  }
  cout << -1 << "\n";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b, res = 0;
    cin >> a >> b;
    for (int i = a; i <= b; i++) {
        if (i / 10000 == i % 10 && i / 1000 % 10 == i / 10 % 10) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include "iostream"
using namespace std;

int main(){
    long long n, m; cin>> n>>m;
    long long sum = 0;
    for(long long i=0; i<m; i++){
        long long a; cin>>a;
        sum += a;
    }
    cout<<(sum>n?-1:n-sum)<<'\n';
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<long long> vll, vLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    cin >> H>>W;
    int c[H][W];
    int cc[H][W];
    REP(i,H) {
        REP(j,W) {
            cin >> c[i][j];
            cc[i][j]=c[i][j];
        }
    }
    int ans =0;
    REP(i,H){
        REP(j,W-1){
            if(c[i][j]%2==1){
                c[i][j]-=1;
                c[i][j+1] +=1;
                ans ++;
            }
        }
    }
    for(int i=0;i<H-1;i++){
        if(c[i][W-1]%2==1){
            c[i][W-1]-=1;
            c[i+1][W-1] +=1;
            ans ++;
        }
    }
    cout << ans << endl;
    REP(i,H){
        REP(j,W-1){
            if(cc[i][j]%2==1){
                cc[i][j]-=1;
                cc[i][j+1] +=1;
                cout << i+1 <<" " << j+1 << " " << i+1 << " " << j+2 << endl;
            }
        }
    }
    for(int i=0;i<H-1;i++){
        if(cc[i][W-1]%2==1){
            cc[i][W-1]-=1;
            cc[i+1][W-1] +=1;
            cout << i+1 <<" " << W << " " << i+2 << " " << W << endl;
        }
    }
    

    return 0;
}

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

int sum(vector<int> vec) {
  int sum = 0;
  for (int i = 0; i < vec.size(); i++) {
    if (vec.at(i) == 1) {
      sum++;
    }
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  vector<int> memo(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    memo.at(i) = 0;
  }

  memo.at(0) = 1;
  int current = 1;
  while(true) {
    int next = vec.at(current - 1);
    if (next == 2) {
      cout << sum(memo) << endl;
      break;
    } else if (memo.at(next - 1) == 1) {
      cout << -1 << endl;
      break;
    } else {
      memo.at(next - 1) = 1;
      current = next;
    }
  }
}


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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        //Solve();
        return;
    }

    public static string Solve()
    {
        int N = ReadInt();
        double[] v = ReadDoubles();
        double sum = 0;
        Array.Sort(v);
        sum = v[0];
        for (int i = 1; i < N; i++)
        {
            sum = (sum + v[i]) / 2;
        }
        return sum.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 11476
#include<iostream>
using namespace std;
int a,b,c,d;
int main(){
	cin>>a>>b>>c>>d;
	a=a+b;c=c+d;
	if(a>c){
		cout<<"Left"<<endl;return 0;
	}
	if(a<c){
		cout<<"Right"<<endl;return 0;
	}
	cout<<"Balanced"<<endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif
int N, A, B, C;
vector<int> L;

int dfs(int a, int b, int c, int now, int mp) {
    int res = MOD;
    if (now == N) {
        if (a != 0 && b != 0 && c!=0) {
            res = mp + abs(A - a) + abs(B - b) + abs(C - c);
        }
    } else {
        int aa = (a == 0) ? 0 : 10;
        res = min(res, dfs(a + L[now], b, c, now + 1, mp + aa));
        int bb = (b == 0) ? 0 : 10;
        res = min(res, dfs(a, b + L[now], c, now + 1, mp + bb));
        int cc = (c == 0) ? 0 : 10;
        res = min(res, dfs(a, b, c + L[now], now + 1, mp + cc));
        res = min(res, dfs(a, b, c, now + 1, mp));
    }
    return res;
}

void Main() {
    cin >> N >> A >> B >> C;
    L.resize(N, 0);
    rep(i, N) cin >> L[i];
    int ans = dfs(0, 0, 0, 0, 0);
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
N,X=map(int,input().split())
a=[2**(i+2)-3 for i in range(N+1)]
p=[2**(i+1)-1 for i in range(N+1)]
def ans(n,x):
    if n==0:
        return 1
    if x<=1:
        return 0
    elif x<=2**(n+1)-2:
        return ans(n-1,x-1)
    elif x==2**(n+1)-1:
        return p[n-1]+1
    elif x<=2**(n+2)-4:
        return p[n-1]+1+ans(n-1,x+1-2**(n+1))
    else:
        return p[n]
print(ans(N,X))


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
    int m,f,r;
    cin >>m>>f>>r;
    while(m!=-1||f!=-1||r!=-1){
        if(m==-1||f==-1) cout << "F" << endl;
        else if(m+f>=80) cout << "A" << endl;
        else if(m+f>=65) cout << "B" << endl;
        else if(m+f>=50) cout << "C" << endl;
        else if(m+f>=30)
            if(r>=50) cout << "C" << endl;
            else cout << "D" << endl;
            else cout << "F" << endl;
         
        cin >> m >> f >> r;
    }
 
    return 0;
}


Measured memory_bytes: 3116
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.math.BigInteger
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val s = sc.nextLine()
    val n = s.length
    var ans = 0
    for (i in 1 until n / 2) {
        val t = s.substring(0, i)
        if (s.startsWith(t + t)) {
            ans = 2 * i
        }
    }
    println(ans)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


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

int main() {
    ll n,k;
    std::cin >> n>>k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll res = 0;
    for (int i = 0; i < n-k; i++) {
        res += a[i];
    }
    std::cout << res << std::endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<queue>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
char S[1000011];
bool test(vector<pair<int, int> > &V) {
    sort(V.begin(), V.end());
    int idx = 0;
    int L = 0;
    priority_queue<int> Q;

    while (1) {
	while (idx < (int)V.size() && V[idx].first <= L) {
	    Q.push(V[idx].second);
	    idx++;
	}

	if (Q.empty()) break;

	L += Q.top();
	Q.pop();
	if (L < 0) return false;
    }

    if (idx != (int)V.size()) return false;

    return true;
}

void MAIN() {
    scanf("%d", &N);


    vector<pair<int, int> > V;
    vector<pair<int, int> > W;
    int all = 0;
    REP (i, N) {
	scanf("%s", S);
	int len = strlen(S);

	int depth = 0;
	int mi = 0;
	REP (j, len) {
	    if (S[j] == '(') depth++;
	    else depth--;
	    amin(mi, depth);
	}
	int ma = 0;
	depth = 0;
	for (int j=len; j--;) {
	    if (S[j] == '(') depth++;
	    else depth--;
	    amax(ma, depth);
	}

	if (depth >= 0) {
	    V.emplace_back(-mi, depth);
	} else {
	    W.emplace_back(ma, -depth);
	}

	all += depth;
    }



    bool yes = (all == 0 && test(V) && test(W));


    puts(yes? "Yes": "No");

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 14960
#include <stdio.h>

int main()
{
	int i, N;
	double v[51];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%lf", &(v[i]));
    
	int j, flag[51] = {}, argmin[2];
	double min[2];
	for (i = 0; i < N - 1; i++) {
		min[0] = 1001;
		min[1] = 1001;
		argmin[0] = 0;
		argmin[1] = 0;
		for (j = 1; j <= N; j++) {
			if (flag[j] == 0) {
				if (v[j] < min[0]) {
					min[1] = min[0];
					min[0] = v[j];
					argmin[1] = argmin[0];
					argmin[0] = j;
				} else if (v[j] < min[1]) {
					min[1] = v[j];
					argmin[1] = j;
				}
			}
		}
		flag[argmin[0]] = 1;
		v[argmin[1]] = (min[0] + min[1]) / 2;
	}

	printf("%lf\n", v[argmin[1]]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
   long long a,b,c,d;
   cin>>a>>b>>c>>d;
   if(a+b>c+d){
      cout<<"Left"<<endl;
   }
   else if((a+b)==(c+d)){
      cout<<"Balanced"<<endl;
   }
   else{
      cout<<"Right"<<endl;
   }

   return 0;
}


Measured memory_bytes: 256