akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#define buf 2000
int A[buf],M;
int a,b,i,j,k,f=0;
 
int solve(int p, int t);
 
int main(void){
	scanf("%d",&a);
	for (i = 0; i < a;i++)
		scanf("%d",&A[i]);
	scanf("%d",&b); 
	for(i=0;i<b;i++){
		scanf("%d",&M);
		if(solve(0, M))
			printf("yes\n");
		else
			printf("no\n");      
	}
	return 0;
}

int solve(int p,int t){
	if(t - A[p] == 0)
		return 1;
	if(p+1>a)
		return 0;
	if(solve(p + 1, t - A[p]) || solve(p + 1, t))
		return 1;
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdint>
using namespace std;

int main() {
    uint32_t n; cin >> n;
    vector<uint32_t> a(n);
    for (auto &e : a) cin >> e;
    sort(a.rbegin(), a.rend());

    queue<uint32_t> que;
    que.push(a[0]);
    uint64_t ans = 0;
    for (uint32_t i = 1; i < n; ++i) {
        ans += que.front(); que.pop();
        que.push(a[i]);
        que.push(a[i]);
    }

    cout << ans << endl;
}



Measured memory_bytes: 4852
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint(), K = getint();
	int h[100000];
	rep(i, N) h[i] = getint();
	pakuri_sort(N, h);

	int saishou = 1e9;
	rep(i, N - K + 1) {
		saishou = min(saishou, h[i + K - 1] - h[i]);
	}
	printf("%d", saishou);

	Would you please return 0;
}

Measured memory_bytes: 1024
// Gaurav Nuti
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define ar array
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define INF 1e9 

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

ll power_without_mod(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x); 
        y = y>>1;
        x = (x*x); 
    } 
    return res; 
}

bool comparep(pair<ll, ll> i1, pair<ll, ll> i2){
	return (i1.S < i2.S);
} 

ll modInverse(ll a)
{
    return power(a , mod - 2);
}

vector<vector<ll>> graph;
vector<bool> visited;
vector<ll> dist;
map<ll,ll> mymap;
ll max_dist = 1;

void bfs(int u1){
    visited[u1] = 1;
    dist[u1] = 1;
    mymap[1] = u1;
    queue<ll> q;
    q.push({u1});
    while(!q.empty()){
        ll u = q.front();
        q.pop();
        for(auto i=graph[u].begin();i!=graph[u].end();i++){
            if(!visited[*i]){
                dist[*i] = dist[u] + 1;
                visited[*i] = 1;
                max_dist = max(dist[*i],max_dist);
                mymap[dist[*i]] = *i;
                q.push({*i});
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif  
	
    ll t;
    // cin>>t;
    t = 1;
    for(ll z=0;z<t;z++){
        ll n;
        cin>>n;
        ll a[n];
        inp_arr(a,n);
        map<ll,ll> mymap;
        ll count = 0;
        for(ll j=0;j<n;j++){
            count += mymap[j+1 - a[j]];
            mymap[j+1+a[j]] += 1;
        }
        cout<<count;
    }
}

Measured memory_bytes: 27824
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int n;
  cin >> n;
  bool b = false;
  for(int i = 1; i < 10; i++){
    for(int j = 1; j < 10; j++){
      if(i * j == n){
        b = true; 
        break;
      } 
    }
  }
  if(b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 504
#include<stdio.h>
#define MAX 100000
#define VMAX 100000

int main(){
  int n,x,temp,i,j,p=0;
  int A[MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  x=A[n-1];
  i=p-1;
  for(j=p;j<n-1;j++){
    if(A[j]<=x){
      i=i+1;
      temp=A[i];
      A[i]=A[j];
      A[j]=temp;
    }
  }
  temp=A[i+1];
  A[i+1]=A[n-1];
  A[n-1]=temp;
  
  for(i=0;i<n;i++){
    if(x==A[i]){
      if(x<A[i+1]){
	printf("[%d]",A[i]);
      }
      else printf("%d",A[i]);
    }
    else printf("%d",A[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2120
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <cmath> 
#include <algorithm>
using namespace std; 

const char s[] = "RGBY";
int N, M, D;

int main() { 
    cin >> N >> M >> D; 
    for (int i = 0; i < N; i++, putchar('\n'))
        for (int j = 0, x, y; j < M; j++)
            x = (M + i + j) / D % 2,
            y = (M + i - j) / D % 2,
            putchar(s[2 * x + y]);
    return 0;
}

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

int main()
{
  int N, K[100], L[100], dp[1 << 16];

  while(cin >> N, N) {
    for(int i = 0; i < N; i++) {
      int M;
      cin >> M >> L[i];
      K[i] = 0;
      while(M--) {
        int S, E;
        cin >> S >> E;
        S -= 6, E -= 6;
        K[i] |= (1 << E) - (1 << S);
      }
    }
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    int ret = 0;
    for(int j = 0; j < 1 << 16; j++) {
      if(~dp[j]) {
        for(int i = 0; i < N; i++) {
          if(!(K[i] & j)) {
            dp[K[i] | j] = max(dp[K[i] | j], dp[j] + L[i]);
            ret = max(ret, dp[K[i] | j]);
          }
        }
      }
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1424
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;

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

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

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

public class Main {

    static int A, B;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        A = sc.nextInt();
        B = sc.nextInt();

        System.out.println(solve());
    }

    static int solve() {
        return A * B - A - B + 1;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 20820
import java.io.*;

public class Main{
	
	static int num = 0;	//Number of Combination
	
	public static void calcNum(int value, int remNum){	//Number of remaining factors
		if(remNum == 1){
			num++;
		}else{
			for(int i=0; i<10 && value-i >= 0; i++){
				if((value-i) < 9 * (remNum-1)){
					calcNum(value-i, remNum-1);
				}else if((value-i) == 9 * (remNum-1)) num++;
			}
		}
	}
	
	public static void main(String[] argv) throws NumberFormatException, IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		while((line = br.readLine()) != null){
			int value = Integer.parseInt(line);
			calcNum(value, 4);
			System.out.print(Integer.toString(num)+"\n");
			num = 0;
		}
	}
}

Measured memory_bytes: 18512
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(int argc, char const *argv[])
{
    int N, K;
    cin >> N >> K;
    vector<int> x;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        x.emplace_back(tmp);
    }

    int min = 2000000000;
    int d1, d2;
    for (int i = 0; i <= N - K; i++)
    {
        d1 = abs(x[i]) + abs(x[i] - x[i + K - 1]);
        d2 = abs(x[i + K - 1]) + abs(x[i + K - 1] - x[i]);
        if (d1 < min) min = d1;
        if (d2 < min) min = d2;
    }
    
    cout << min << endl;

    return 0;
}

Measured memory_bytes: 892
import java.util.*;

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

    int ans = 0;
    int right = 0;

    for (int left = 0; left < N; left++) {
      // 右隣がいまのマスより小さければright++
      while (right < N - 1 && H[right] >= H[right + 1]) {
        right++;
      }

      // 更新
      ans = Math.max(ans, right - left);
      if (left == right) {
        right++;
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 50836
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

N = 26
L = [0] * N
for d in range(1, D + 1):
    mx = -10**18
    nx = -1

    for i, (c, l) in enumerate(zip(C, L)):
        r = c * (d - l)
        if mx < r:
            mx = r
            nx = i

    L[nx] = d
    print(nx + 1)


Measured memory_bytes: 9296
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());

            List<int> v = new List<int>();
            string[] s = Console.ReadLine().Split(' ');

            for (int i = 0; i < N; i++)
            {
                v.Add(int.Parse(s[i]));
            }

            List<int> ans = new List<int>();
            while (v.Count > 0)
            {
                bool found = false;
                for (int i = v.Count - 1; i >= 0; i--)
                {
                    if (v[i] == i + 1)
                    {
                        ans.Add(i + 1);
                        v.RemoveAt(i);
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    Console.WriteLine(-1);
                    return;
                }
            }

            ans.Reverse();

            foreach(int n in ans)
            {
                Console.WriteLine(n);
            }
        }
    }
}

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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int gcd(int a, int b);

int main(){
    int k, sum=0;
    cin >> k;
    rep2(i, 1, k+1){
        rep2(j, 1, k+1){
            rep2(l, 1, k+1){
                sum += gcd(i, gcd(j, l));
            }
        }
    }
    cout << sum << endl;
    return 0;
}

int gcd(int a, int b){
    if(a < b) gcd(b, a);
    int r;
    while (b>0) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll MOD=1e9+7 ;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    ll n,k,q;cin >> n >> k >> q;
    int ary[q];
    rep(i,q) cin >> ary[i];

    int count_ary[n];
    rep(i,n) count_ary[i]=0;
    rep(i,q)
    {
        count_ary[ary[i]-1]++;
    }
    rep(i,n)
    {
        if ((ll)count_ary[i]-q+k>0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
        
    }
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main()
{
  int n,a,b,i,res=0;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a >> b;
    if(a==b)
      res++;
    else
      res=0;
    if(res>2){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 1234567;
 
int z[N];
int a[N];
int pos[N];
int at[N];
 
int main() {
  int n, m, q;
  scanf("%d %d", &n, &m);
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", z + i);
    z[i]--;
  }
  for (int i = 0; i < m; i++) {
    a[i] = -1;
    pos[i] = -1;
    at[i] = 0;
  }
  int known = 0;
  at[0] = n;
  at[m] = 0;
  for (int it = q - 1; it >= 0; it--) {
    int i = z[it];
    if (pos[i] == -1) {
      a[known] = i;
      pos[i] = known;
      at[known]--;
      known++;
      at[known]++;
      continue;
    }
    if (at[pos[i]] > 0) {
      at[pos[i]]--;
      at[pos[i] + 1]++;
    }
  }
  int first = -1;
  for (int i = 0; i <= m; i++) {
    if (at[i] > 0) {
      first = i;
      break;
    }
  }
  vector <int> all;
  for (int i = first; i < known; i++) {
    all.push_back(a[i]);
  }
  for (int i = 0; i < m; i++) {
    if (pos[i] == -1) {
      all.push_back(i);
    }
  }
  sort(all.begin(), all.end());
  for (int i = first; i < known; i++) {
    if (all[i - first] != a[i]) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 2428
#include<bits/stdc++.h>
#define crap ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define int ll

using namespace std;


int a,b;
int check(int m){
  if((floor((double)m*(0.08)))==a && (floor((double)(m*0.1)))==b) return 0;
  if((floor((double)m*(0.08)))<=a && (floor((double)(m*0.1)))<=b) return 1;
  //if(floor((double)m*(0.08))<=a && floor((double)(m*0.1))<=b) return 1;
  return 2;
}

int32_t main()
{
   
   
    crap;
    cin>>a>>b;
      int low = 1,high = 2000;
      int ans=-1;
      while(low<=high){
        int mid = (low+high)/2;

        if(check(mid)==0){
          ans = mid;
          high = mid-1;
        }
        else if(check(mid)==1)
          low = mid+1;
        else
          high = mid-1;
      }
      cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int main(void)
{
	int flag = 99;
	string str;
	cin >> str;
	int i;
	for (i = 0; i <3 ; i++)
	{
		if (str[i] == str[i + 1])
			flag = 0;
	}
	if (flag == 0)
	{
		cout << "Bad" << endl;
	}
	else
	{
		cout << "Good" << endl;
	}
	return 0;

}


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

int main() {
  int N, cnt=0;
  string S;
  cin >> N >> S;
  rep(i, N-2){
    if(S.substr(i,3)=="ABC") cnt++;
  }
  cout << cnt << endl;
}

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

int main(void) {
  int R, G, B, N; cin >> R >> G >> B >> N;
  int a = 0;
  for (int i = 0; i <= N/R; i++) {
    for (int j = 0; j <= (N-i*R)/G; j++) {
      if ((N-(i*R+j*G))%B == 0) a++;
    }
  }
  cout << a << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var S string
	fmt.Scan(&S)
	c := make([]int, len(S))
	for i := 0; i < len(S)-1; i++ {
		if S[i] == 'R' && S[i+1] == 'L' {
			c[i] = 1
			c[i+1] = 1
			a := i
			b := i + 1
			a--
			b++
			d := 1
			for a >= 0 && S[a] == 'R' {
				if d%2 == 1 {
					c[i+1]++
				} else {
					c[i]++
				}
				a--
				d++
			}
			d = 1
			for b < len(S) && S[b] == 'L' {
				if d%2 == 1 {
					c[i]++
				} else {
					c[i+1]++
				}
				b++
				d++
			}
		}
	}
	for i := 0; i < len(c); i++ {
		fmt.Print(c[i])
		if i < len(c)-1 {
			fmt.Print(" ")
		} else {
			fmt.Println("")
		}
	}
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var inf = int(1e9)

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 4736
n = gets.to_i
nums = gets.split.map(&:to_i)

cnt = 0
n.times do |i|
    n.times do |j|
        n.times do |k|
            if nums[i] < nums[j] && nums[j] < nums[k]
                next if nums[i] == nums[j] || nums[i] == nums[k] || nums[j] == nums[k]
                next if nums[i] + nums[j] <= nums[k]
                cnt += 1
            end
        end
    end
end
puts cnt

Measured memory_bytes: 14388
#include <stdio.h>
long double DP[305][305][305];
int main()
{
long long int Arr[310];
long long int i,j,k,n,one=0,two=0,three=0,x,y;
scanf("%lld",&n);
for(i=0;i<n;i++)
{
	scanf("%lld",&Arr[i]);
	if(Arr[i]==1)
		one++;
	else if (Arr[i]==2)
		two++;
	else if (Arr[i]==3)
		three++;
}
x=two+three;

DP[0][0][0]=0.0;
for(k=0;k<=three;k++)
{
	for(j=0;j<=x;j++)
		{	
			
			for(i=0;i<=n;i++)
			{
				if(i==0 && j==0 && k==0)
				continue;
			
				if(i>0)
					DP[i][j][k]=DP[i-1][j][k]*((long double)i/(i+j+k));
				if(j>0)
					DP[i][j][k]+=DP[i+1][j-1][k]*((long double)j/(i+j+k));
				if(k>0)
					DP[i][j][k]+=DP[i][j+1][k-1]*((long double)k/(i+j+k));
				DP[i][j][k]+=(long double)n/(i+j+k);
			}
		}
	}	
	printf("%0.10Lf\n",DP[one][two][three]);
	return 0;
}

Measured memory_bytes: 438400
n=int(input())
a=list((map(int,input().split())))
l=[0 for _ in range(8)]
f=0
for i in range(n):
    r=a[i]//400
    if r<8:
        l[r]+=1
    else:
        f+=1
amin=0

for i in range(len(l)):
    if l[i]>=1:
        amin+=1
        
print(max(1,amin),amin+f)
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 
//string is either 01010101 or 10101010
void solve(){
	string s; cin >> s;
	int n = s.size();
	int ans1 = 0, ans2 = 0;
	FOR(n){
		if(i&1 && s[i]=='0') ++ans1;
		if(i%2==0 && s[i]=='1') ++ans1;
		if(i&1 && s[i]=='1') ++ans2;
		if(i%2==0 && s[i]=='0') ++ans2;
	}
	cout << min(ans1,ans2);
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


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

void fnInput(vector<int> &rvnSort)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  rvnSort.resize(nMaxSiz);
  for (int i = 0; i < nMaxSiz; i++)
    cin >> rvnSort[i];
} 

void fnTrace(const vector<int> &cnrvnSort)
{
  for (int i = 0; i < cnrvnSort.size(); i++)
  {
    if (i) cout << " ";
    cout << cnrvnSort[i];
  }
  cout << endl;
}

void fnInsertionSort(vector<int> &rvnSort)
{
  for (int nSorting = 1; nSorting < rvnSort.size(); nSorting++)
  {
    int nTrg = rvnSort[nSorting];
    int nSorted = nSorting - 1;

    while (nSorted >= 0          &&
           nTrg  < rvnSort[nSorted])
    {
      rvnSort[nSorted + 1] = rvnSort[nSorted];
      nSorted--;
    }
    rvnSort[nSorted + 1] = nTrg;
    fnTrace(rvnSort);
  }
}

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

  vector<int> vnSort;

  fnInput(vnSort);
  fnTrace(vnSort);
  fnInsertionSort(vnSort);

  return 0;
}

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

int main(){
	int N; cin>>N;
	vector<int> A(N, 0), B(N, 0), C(N, 0);
	rep(i, N) cin>>A[i];
	rep(i, N) cin>>B[i];
	rep(i, N) cin>>C[i];
	sort(all(A));
	sort(all(C));
	int64_t ans = 0;
	for(int b:B){
		int ia = lower_bound(all(A), b) - A.begin();
		int ic = C.end() - upper_bound(all(C), b);
		ans += (int64_t)ia * ic;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define repi(i, a, b) for (long long i = (long long)(a); i < (long long)(b); i++)
#define drep(i, n) for (long long i = n - 1; i > 0; i--)
#define pb push_back
#define pb push_back
#define all(x) (x).begin(), (x).end()

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<string> w(n);
    for (int i = 0; i < n; i++)
    {
        cin >> w[i];
    }
    rep(i, n)
    {
        rep(j, n)
        {
            if (w[i] == w[j] && i != j)
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    rep(i, n - 1)
    {
        int length = w[i].length();
        if (w[i][length - 1] != w[i + 1][0])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);
    vector<long> a(3);
    int n;
    cin >> n;
    string s;
    cin >> s;
    long res = 1;
    long k = n;
    long p = 0;

    const long MOD = 998244353;

    for (int i = 0; i < 3 * n; i++) {
        int x;
        if (s[i] == 'R')
            x = 0;
        else if (s[i] == 'G')
            x = 1;
        else
            x = 2;

        int y = (x + 1) % 3;
        int z = (y + 1) % 3;
        if (a[y] > 0 && a[z] > 0) {
            res *= p;
            res %= MOD;
            res *= k;
            k--;
            res %= MOD;
            a[y]--;
            a[z]--;
            p--;
        } else if (a[y] > p || a[z] > p) {
            res *= max(a[y], a[z]) - p;
            res %= MOD;
            p++;
            a[x]++;
        } else {
            a[x]++;
        }
    }
    cout << res;

    return 0;
}

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

int main()
{
	int N, M, sum = 0, P, X;
	cin >> N;
	vector<int> T(N);
	for (int i = 0; i < N; i++) {
		cin >> T[i];
		sum += T[i];
	}
	cin >> M;
	while (M--) {
		cin >> P >> X;
		cout << sum + X - T[P - 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
program main
  implicit none
  integer :: n, o

  read *, n 
  if (n < 10) then
    o = n
  else if (n < 100) then
    o = 9
  else if (n < 1000) then
    o = n - 99 + 9
  else if (n < 10000) then
    o = 909
  else if (n < 100000) then
    o = n - 9999 + 909
  else
    o = 90909
  end if
  print '(i0)', o

end program


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)
bef=a[0]
ren=1
c=0 #二個以上の組が何個あるか
hen1=0
hen2=0
for i in range(1,n):
    if bef==a[i]:
        ren+=1
    else:
        if 2<=ren:
            if c==0:
                hen1=bef
                if 4<=ren:
                    hen2=bef
                    c=2
                    break
                c=1
            else:
                hen2=bef
                break
        bef=a[i]
        ren=1
if 2<=ren:
    if c==0:
        if ren<=4:
            hen1,hen2=bef,bef
    elif c==1:
        hen2=bef
print(hen1*hen2)

Measured memory_bytes: 62704
#include <iostream>
using namespace std;
int main(){
    int n[7];
    n[6]=0;
    for(int i=0;i<5;i++){
        cin>>n[i];
    }
   for(int j=1;j<5;j++){
       if(n[0]%10==0){
           n[5]=n[0];
           n[0]=n[j];
           n[j]=n[5];
       }
       else if(n[0]%10>n[j]%10&&n[j]%10!=0){
           n[5]=n[0];
           n[0]=n[j];
           n[j]=n[5];
       }
       else{
       }
   }
   for(int l=1;l<5;l++){
        if(n[l]%10==0){
        n[6]+=n[l];
        }
        else{
            n[6]+=(n[l]/10 + 1)*10;
        }
    }
    cout<<n[6]+n[0]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (ll i=a; i<b; i++)
// #define endl "\n"
const int mod = 1000000007;

ll power(ll x, ll y) 
{ 
    ll res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
        res%=mod;
        // n must be even now 
        y = y>>1; // y = y/2 
        x = x*x;
        x%=mod;  // Change x to x^2 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);    //Fast I/O
    cin.tie(NULL);
 
    // freopen("input.txt", "r", stdin);    // Read and write from a file
    // freopen("output.txt", "w", stdout);
    ll n, w;
    cin >> n >> w; 
    vector<ll> weight(n,0);
    vector<ll> value(n,0);
    rep(i,0,n)
        cin >> weight[i] >> value[i];
    vector< vector<ll> > dp (n, vector<ll> (w+1, -1));

    rep(i,0,n)
        dp[i][0]=0;
    
    rep(i,1,w+1){
        if(i>=weight[0])
            dp[0][i]=value[0];
        else
            dp[0][i]=0;
    }

    for(ll i=1; i<n; i++){
        for(ll j=1; j<=w; j++){
            if(weight[i] > j){
                dp[i][j]=dp[i-1][j];
                continue;
            }

            dp[i][j] = max(dp[i-1][j], value[i]+dp[i-1][j-weight[i]]);
        }
    }

    cout << dp[n-1][w] << endl;
 
    return 0;
}

Measured memory_bytes: 79488
#include<stdio.h>
#include<string.h>
#include<vector>
#include<algorithm>
struct S{int c,f,x,y,r;}s[24];
int A(int x){return x*x;}
char m[1<<24];
int n;
int F(int f)
{
	if(m[f]>=0)return m[f];
	std::vector<int>v[5];
	int i,j,k,r=0,t;
	for(i=0;i<n;++i)
		if((f&(1<<i))&&!(s[i].f&f))
			v[s[i].c].push_back(i);
	for(k=1;k<5;++k)
		for(i=0;i<v[k].size();++i)
			for(j=i+1;j<v[k].size();++j)
				r=std::max(r,2+F(f&~(1<<v[k][i])&~(1<<v[k][j])));
	return m[f]=r;
}
int main()
{
	int i,j;
	while(scanf("%d",&n),n)
	{
		memset(m,-1,sizeof(m));
		memset(s,0,sizeof(s));
		for(i=0;i<n;++i)scanf("%d%d%d%d",&s[i].x,&s[i].y,&s[i].r,&s[i].c);
		for(i=0;i<n;++i)
			for(j=i+1;j<n;++j)
				if(A(s[i].x-s[j].x)+A(s[i].y-s[j].y)<A(s[i].r+s[j].r))
					s[j].f|=1<<i;
		printf("%d\n",F((1<<n)-1));
	}
	return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  int sum = 0;
  int x = A;
  
  for(int i = A; i <= B; i++){
    if(x % 10 == x / 10000 &&
      (x - x % 10) / 10 % 10 == (x - x % 1000) / 1000 % 10)
      sum += 1;
    x++;
  }
  
  cout << sum <<endl;
}

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

string s, t;

bool ch();

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

  if(ch())
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

bool ch() {
  if(s == t) return 1;
  for(int i = 0; i < s.size(); ++i) {
    for(int j = 0; j < s.size(); ++j) {
      if(s[j] != t[(i + j) % s.size()]) break;
      if(j == s.size() - 1) return 1;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> S >> T;
  NeOut(T);NeOut(S);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=100010;
vector<int>vec[N];
int dfs(int u,int fa) {
    int re=0;
    for(int i=0; i<vec[u].size(); i++) {
        if(vec[u][i]!=fa) {
            re^=1+dfs(vec[u][i],u);
        }
    }
    return re;
}
int main() {
        int n;
        scanf("%d",&n);
        for(int i=1; i<n; i++) {
            int a,b;
            scanf("%d%d",&a,&b);
            vec[a].push_back(b);
            vec[b].push_back(a);
        }
    printf(dfs(1,0)?"Alice\n":"Bob\n");
    return 0;
}


Measured memory_bytes: 11904
//header files
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[])
{
	long long x,k,d,pos,sto0;
	long long final,final1,winner;
	cin>>x>>k>>d;
	if(k<=abs(x)/d)
		cout<<abs(x)-(k*d);
	else
	{
		sto0=abs(x)/d;
		final=abs(x)-(sto0*d);
		if(abs(final)< abs(final-d))
			k-=sto0;
		else
			k-=sto0+1;
		if(k%2==0)
			cout<<min(abs(final),abs(final-d));
		else
			cout<<max(abs(final),abs(final-d));
	}
	return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
int main (){
  long long X,N;
  cin>>X>>N;
  map<long long, long long>mp;
  for(long long i=0; i<N; i++){long long a;
                              cin >>a;
                              mp[a]++;}
  if (N==0){cout<<X<<endl;return 0;}
  for (long long i=0; i <1000; i++){if(mp[X-i]==0){cout<<X-i<<endl;return 0;}
                                   if(mp[X+i]==0){cout<<X+i<<endl;return 0;}}
}


Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll N;
  cin>>N;
  vector<ll> A(N);
  ll ans=0;
  REP(i,N)cin>>A[i];
  REP(k,62){
    ll cnt=0;
    REP(i,N){
      if((1LL<<k)&A[i]){
        cnt++;
      }
    }
    ans+=(1LL<<k)%MOD*cnt%MOD*(N-cnt)%MOD;
    ans%=MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2560
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


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

    double a, b, x;
    cin >> a >> b >> x;

    double a2 = a * a;

    if (2 * x / a / b > a) {
        cerr << "1\n";
        print((atan2(b - x / a2, a / 2) / (2 * 3.141592653589793) * 360));
    } else {
        print((atan2(b, 2 * x / a / b) / (2 * 3.141592653589793) * 360));
    }


    return 0;
}



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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
int a[N+2]={0};

int32_t  main(){
	IOS;
  int n,m;cin>>n>>m;
  int M=m;
  while(m--){
    int l,r;cin>>l>>r;
    a[r+1]-=1;
    a[l]+=1;
  }
  for(int i=1;i<=n;++i)a[i]+=a[i-1];
  int ans=0;
  for(int i=1;i<=n;++i)if(a[i]==M)ans++;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
using namespace std;
long long int n,m,s;
int main(){
	scanf("%lld",&n);m=n;
	while(m>0){
		s+=m%10;
		m/=10;
	}
	if(n%s==0) printf("Yes");
	else printf("No");
	return 0;
} 

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

static const int MAX = 200000;

int main() {
  string s,t;
  cin >> s;
  t = s;
  reverse(t.begin(), t.end());
  int cnt = 0;
  rep(i,s.size()) {
    if (s.at(i) != t.at(i)) cnt++;
  }
  if (cnt == 0) cout << 0 << endl;
  else cout << cnt / 2 << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<double> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];

    sort(v.begin(), v.end());

    for (int i = 0; i < N-1; i++) {
        double ave = (v[0] + v[1]) / 2;
        v.push_back(ave);
        v.erase(v.begin(), v.begin() + 2);

        sort(v.begin(), v.end());
    }

    cout << fixed << setprecision(10) << v[0] << endl;
    return 0;
}


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

int main() {
    int64_t n, m;
    cin >> n >> m;
    
    vector<vector<int64_t>> r(m+1);
    for (int i = 0; i < n; i++) {
        int64_t a, b;
        cin >> a >> b;
        if (a <= m) r[a].push_back(b);
    }

    priority_queue<int64_t> pq;
    int64_t ans = 0;
    for (int i = 1; i <= m; i++) {
        for (auto e : r[i]) pq.push(e);
        if (!pq.empty()) {
            auto a = pq.top(); pq.pop();
            ans += a;
        }
        
    }
    cout << ans << endl;
}


Measured memory_bytes: 5632
a=list(map(int,input().split()))
b=(a[0]+a[1]+a[2])%3
if a[0]+a[1]==a[2]:
  print("Yes")
elif a[1]+a[2]==a[0]:
  print("Yes")
elif a[0]+a[2]==a[1]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<unordered_set>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 200000 + 47;

int A[MAX];
int B[MAX];
int n;
int sz;
vector<PII> V;

bool ok(int a)
{
	FOR(i, 0, sz)
	{
		B[i] = A[i] <= a;
	}

	V.clear();

	int cnt = 1;
	FOR(i, 1, sz + 1)
	{
		if (B[i] != B[i - 1] || i == sz)
		{
			if (cnt >= 2)
			{
				int y;
				if (i - cnt <= n - 1 && n - 1 <= i - 1)
				{
					y = 0;
				}
				else
				{
					y = i - cnt > n - 1 ? i - cnt - n + 1 : n - i;
				}

				V.push_back(MP(y, B[i - 1]));
			}

			cnt = 1;
			continue;
		}

		cnt++;
	}

	if (SZ(V) == 0) return B[0];

	PII minn = MP(INF, INF);
	FOR(i, 0, SZ(V))
	{
		minn = min(minn, V[i]);
	}

	
	return minn.second;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	sz = 2 * n - 1;
	FOR(i, 0, sz)
	{
		cin >> A[i];
	}

	int l = 1, r = 2 * n - 2;
	while (r - l > 1)
	{
		int c = (r + l) / 2;
		if (ok(c))
		{
			r = c;
		}
		else
		{
			l = c;
		}
	}

	cout << r << "\n";
}


Measured memory_bytes: 2428
def add_alpha(char, add) :
    code = ord(char) + add
    if (code >= 91) :
        code -= 26
    return chr(code)


def main() :
    N = int(input())
    S = input()

    out = ""
    for s in S:
        out += add_alpha(s,N)

    print(out)

main()

Measured memory_bytes: 3060
k = int(input())
num_list = []
for num in range(1, k+1):
    if num % 2 != 0:
        for gsu in range(1, k+1):
            if gsu % 2 == 0:
                pair = []
                pair.append(num)
                pair.append(gsu)
                num_list.append(pair)
print(len(num_list))

Measured memory_bytes: 3188
import sys

n = int(input())
t = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
if t[n-1]!=a[0]:
    print(0)
    sys.exit()

m =[]
for i in range(n):
    mx = min(t[i],a[i])
    mn = 1
    if i == 0:
        mn = t[i]
    elif i == n-1:
        mn = a[i]
    else :
        if t[i]!=t[i-1] :
            if t[i-1] > a[i-1]:
                print(0)
                exit()
            if mx == t[i]:
                mn=t[i]
        if a[i]!=a[i+1] :
            if a[i] > t[i]:
                print(0)
                exit()
            if mx == a[i]:
                mn=a[i]
    m.append([mx,min(mx,mn)])
ans = 1
for i in range(n):
    ans = (ans * (m[i][0]-m[i][1]+1))%(10**9+7)
print(ans)


Measured memory_bytes: 21700
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[1000001];
int vis[1000001];
int dp[1000001];
int n,m,maxx=-1;
int max(int a,int b){
    return a>b?a:b;
}
void dfs(int x)
{
    vis[x]=1;
    for(int i=0;i<adj[x].size();i++){
        if(!vis[adj[x][i]]){
            dfs(adj[x][i]);
        }
        dp[x]=max(dp[x],1+dp[adj[x][i]]);
    }
}
int main() {
    int i,j,p,q;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>p>>q;
        adj[p].push_back(q);
    }
    for(i=1;i<=n;i++){
        if(!vis[i]){
            dfs(i);
        }
    }
    for(i=1;i<=n;i++){
        if(dp[i]>maxx)
        maxx=dp[i];
    }
    cout<<maxx;
}


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

int main()
{
	std::string s1, s2;
	std::cin >> s1 >> s2;
	using vi = std::vector<int>;
	std::vector<vi> dp(s1.size() + 1, (vi(s2.size() + 1)));
	for (int i{}; i <= (int)s1.size(); i++)
		dp[i][0] = i;
	for (int i{}; i <= (int)s2.size(); i++)
		dp[0][i] = i;
	for (int i{1}; i <= (int)s1.size(); i++)
		for (int j{1}; j <= (int)s2.size(); j++)
		{
			if (s1[i - 1] == s2[j - 1]) dp[i][j] = dp[i - 1][j - 1];
			else dp[i][j] = dp[i - 1][j - 1] + 1;
			dp[i][j] = std::min({dp[i][j], dp[i - 1][j] + 1, dp[i][j - 1] + 1});
		}
	printf("%d\n", dp.back().back());
	return 0;
}


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

int modi = 1e9+7;

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

	long long int dp[h+1][w+1];
	for(int i =0;i<=h;i++)
		dp[i][0] = 0;
	for(int i =0;i<=w;i++)
		dp[0][i] = 0;
	dp[0][1] = 1;
	dp[1][0] = 1;
	for(int i = 1;i<=h;i++){
		dp[i][1] = (dp[i-1][1] && g[i-1][0]=='.');
	}
	for(int i = 1;i<=w;i++){
		dp[1][i] = dp[1][i-1] && g[0][i-1]=='.';
	}

	for(int i = 2;i<=h;i++){
		for(int j = 2;j<=w;j++){
			dp[i][j] = 0;
			if(g[i-1][j-1]!='#'){
				dp[i][j] += dp[i-1][j] + dp[i][j-1];
				dp[i][j]%=modi;
			}
		}
	}
	cout << dp[h][w] << endl;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a, b;
  cin >> a >> b;
  cout << dup(a+b,2) << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <string.h>

int main(){
	int x,i,n;
	scanf("%d",&n);
	int c4=0,c2=0;
	for(i=0;i<n;i++){
		scanf("%d",&x);
		if(x%4==0)c4++;
		else if(x%2==0)c2++;
	}
	int c1=n-c4-c2;
	if(c2==0){
		if(c1-1<=c4)printf("Yes\n");
		else printf("No\n");
	}
	else {
		if(c1>c4){
			printf("No\n");
		}
		else{
			printf("Yes\n");
		} 
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <complex>
#include <algorithm>

using namespace std;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;

#define int i64

template<class T>
inline bool chmin(T &a, T b) { if(a > b) {a = b; return true;} return false; }
template <class T>
inline bool chmax(T &a, T b) { if(a < b) {a = b; return true;} return false; }
const int INF = 1LL << 60;

signed main() {
	string s;
	int x;
	cin >> s;
	if(s == "SUN") x = 7;
	if(s == "MON") x = 6;
	if(s == "TUE") x = 5;
	if(s == "WED") x = 4;
	if(s == "THU") x = 3;
	if(s == "FRI") x = 2;
	if(s == "SAT") x = 1;

	cout << x << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
      cin>>n;

        int arr[n];
       for(int i=0;i<n;i++)
         cin>>arr[i];

         sort(arr,arr+n);

      int count=0;
     int x=n/2 -1;

         count=arr[n/2]-arr[n/2 -1];
         cout<<count;
}


Measured memory_bytes: 640