akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n := nextInt()
	list := make([]int, n)
	for i := 0; i < n; i++ {
		list[i] = nextInt()
	}
	// fmt.Fprintln(out, list)
	sortList := quickSort(list)
	// fmt.Fprintln(out, sortList)

	var sum int = 0

	for _, v := range sortList {
		sum += v
	}

	fmt.Fprintln(out, sortList[0], sortList[n-1], sum)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func quickSort(val []int) []int {
	if len(val) < 2 {
		return val
	}

	pivot := val[0]

	left := []int{}
	right := []int{}

	for _, v := range val[1:] {
		if pivot >= v {
			left = append(left, v)
		} else {
			right = append(right, v)
		}
	}

	left = quickSort(left)
	right = quickSort(right)

	ret := append(left, pivot)
	ret = append(ret, right...)

	return ret
}



Measured memory_bytes: 9424
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> p(N), memp(N);
	for (int i = 0; i < N; i++) cin >> p[i];
	memp = p;

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

	int chng = 0;
	for (int i = 0; i < N; i++) {
		if (p[i] != memp[i]) chng++;
	}

	if (chng <= 2) cout << "YES" << "\n";
	else cout << "NO" << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct
{
	int n, e, w, s, t, b;
} dice;

void dice_scan(dice *x)
{
	scanf("%d %d %d %d %d %d", &x->t, &x->s, &x->e, &x->w, &x->n, &x->b);
}

void dice_rorate_n(dice *x)
{
	int temp;
	temp = x->n;
	x->n = x->t;
	x->t = x->s;
	x->s = x->b;
	x->b = temp;
}

void dice_rorate_e(dice *x)
{
	int temp;
	temp = x->e;
	x->e = x->t;
	x->t = x->w;
	x->w = x->b;
	x->b = temp;
}

void dice_rorate_r(dice *x)
{
	int temp;
	temp = x->n;
	x->n = x->w;
	x->w = x->s;
	x->s = x->e;
	x->e = temp;
}

int dice_equal(const dice *d1, const dice *d2)
{
	if(d1->n != d2->n) { return 0; }
	if(d1->e != d2->e) { return 0; }
	if(d1->w != d2->w) { return 0; }
	if(d1->s != d2->s) { return 0; }
	if(d1->t != d2->t) { return 0; }
	if(d1->b != d2->b) { return 0; }
	return 1;
} 

int main()
{
	dice d1, d2;
	int ok;

	dice_scan(&d1);
	dice_scan(&d2);

	ok = 0;
	for(int i = 0; i < 4; ++i)
	{
		for(int j = 0; j < 4; ++j)
		{
			ok += dice_equal(&d1, &d2);
			dice_rorate_n(&d1);
		}
		dice_rorate_e(&d1);
	}
	for(int i = 0; i < 4; ++i)
	{
		for(int j = 0; j < 4; ++j)
		{
			ok += dice_equal(&d1, &d2);
			dice_rorate_n(&d1);
		}
		dice_rorate_r(&d1);
	}

	printf("%s\n", ok ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 2112
using System;

namespace A
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int K = int.Parse(input[0]);
            int X = int.Parse(input[1]);

            if (X <= 500 * K)
            {
                Console.Write("Yes");
            }
            else
            {
                Console.Write("No");
            }
        }
    }
}

Measured memory_bytes: 11092
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }

  z->parent = y;

  if(y==NIL){
    root = z;
  }

  else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}

void inorder(Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if(u==NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(void){
  int n, i, x;
  string com;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    cin >> com;
    if(com == "insert" ){
      scanf("%d", &x);
      insert(x);
    }

    else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



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

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

    vector<int> vi(3);
    for (int i = 0; i < 3; i++) {
        cin >> vi.at(i);
    }
    sort(vi.begin(), vi.end());
    for (size_t i = 0; i < vi.size(); i++) {
        cout << vi.at(i);
        if (i != 2) {
            cout << " ";
        } else {
            cout << endl;
        }
    }
}


Measured memory_bytes: 3220
h, w = map(int, input().split())
f = [["."] * (w + 2)] + \
    [list("." + input() + ".") for i in range(h)] + \
    [["."] * (w + 2)]
ans = [['#']*w for i in range(h)]

for ch in range(1, h+1):
    for cw in range(1, w+1):
        if f[ch][cw] == '#':
            continue
        cnt = 0
        for hh in range(ch-1, ch+2,1):
            cnt += f[hh][cw-1:cw+2].count('#')
        ans[ch-1][cw-1] = str(cnt)
for i in range(h):
    print(''.join(ans[i]))

Measured memory_bytes: 9220
int binarySearch(int key, int n, int A[]){
  int left = 0;
  int right = n;
  while(left < right){
    int mid = (int)(left + right) / 2;
    if(A[mid] == key) return 1;
    else if (key < A[mid]) right = mid;
    else left = mid + 1;
  }
  return 0;
}

int main(){

  int i, n, q;
  scanf("%d", &n);
  int S[n];
  for(i=0; i<n; i++) scanf("%d", &S[i]);
  scanf("%d", &q);
  int T[n];
  for(i=0; i<n; i++) scanf("%d", &T[i]);

  int anw = 0;

  for(i=0; i<q; i++){
    if(binarySearch(T[i], n, S)) anw++;
  }

  printf("%d\n", anw);
  
  return 0;
}


Measured memory_bytes: 2356
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool v[1000][1000];
int main(){
	ll n, m, sx, sy, ex, ey, dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
	cin >> n >> m >> sx >> sy >> ex >> ey;
	sx--, sy--, ex--, ey--;
	string s[n];
	for (int i = 0; i < n; i++) cin >> s[i];
	deque<pair<ll, ll> > q;
	q.emplace_back(sx, sy);
	ll d[n][m];
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			d[i][j] = 2147483647;
		}
	}
	d[sx][sy] = 0;
	while (!q.empty()){
		ll cx = q.front().first, cy = q.front().second;
		q.pop_front();
		if (v[cx][cy]) continue;
		v[cx][cy] = true;
		if (cx == ex && cy == ey) break;
		for (int i = 0; i < 4; i++){
			int tx = cx + dx[i], ty = cy + dy[i];
			if (tx < 0 || tx >= n || ty < 0 || ty >= m || s[tx][ty] == '#' || d[tx][ty] <= d[cx][cy]) continue;
			q.emplace_front(tx, ty);
			d[tx][ty] = d[cx][cy];
		}
		for (int i = -2; i <= 2; i++){
			for (int j = -2; j <= 2; j++){
				int tx = cx + i, ty = cy + j;
				if (tx < 0 || tx >= n || ty < 0 || ty >= m || s[tx][ty] == '#' || d[tx][ty] <= d[cx][cy] + 1) continue;
				q.emplace_back(tx, ty);
				d[tx][ty] = d[cx][cy] + 1;
			}
		}
	}
	if (d[ex][ey] == 2147483647) printf("-1\n");
	else printf("%lld\n", d[ex][ey]);
}

Measured memory_bytes: 14516
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

inline int get_dice(){
    int ret;
    scanf(" %d", &ret);
    return ret-1;
}

inline void query(int move){
    printf("%d\n", move);
    fflush(stdout);
}

struct edge{
    int to;
    double cost;
};

const int N = 300;
vector<edge> G[N],rG[N];

void solve(){
    int m;
    scanf(" %d", &m);

    int a[6];
    rep(i,6) scanf(" %d", &a[i]);

    int s,g;
    scanf(" %d %d", &s, &g);
    --s;
    --g;

    vector<int> x(m);
    rep(i,m) scanf(" %d", &x[i]);

    auto IN = [&](int pos){
        return 0<=pos && pos<m;
    };

    auto move = [&](int pos, int aidx, int mul){
        if(mul==0) return pos;

        int nx = pos + mul*a[aidx];
        if(!IN(nx)) return -1;
        nx += x[nx];
        if(!IN(nx)) return -1;
        return nx;
    };

    rep(i,m){
        vector<int> ct(m);

        rep(j,6){
            vector<int> ttt(m);
            for(int k=-1; k<=1; ++k){
                int nx = move(i,j,k);
                if(nx!=-1) ttt[nx]=1;
            }

            rep(k,m) ct[k] += ttt[k];
        }

        rep(j,m){
            if(ct[j]>0){
                double COST = 1.0*ct[j]/6;
                G[i].pb({j, COST});
                rG[j].pb({i, COST});
            }
        }
    }

    const double INF = 19191919;
    vector<double> E(m,INF);
    vector<double> pp(m,1);
    vector<double> qq(m,0);

    E[g] = 0;

    using P = pair<double,int>;
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push({0,g});
    while(!pq.empty()){
        P cur = pq.top();
        pq.pop();
        int v = cur.se;
        if(cur.fi > E[v]) continue;

        // dbg(v);
        for(const auto &e:rG[v]){
            double tp = pp[e.to] + e.cost*E[v];
            double tq = qq[e.to] + e.cost;
            double ne = tp/tq;
            // dbg(e.to);dbg(ne);
            if(E[e.to] > ne){
                pp[e.to] = tp;
                qq[e.to] = tq;
                E[e.to] = ne;
                pq.push({E[e.to], e.to});
            }
        }
    }

    // rep(i,m) printf(" %d: %.5f\n",i,E[i]);

    int now = s;
    rep(loop,3000){
        // printf(" now %d \n", now);
        int idx = get_dice();

        double tmpE = E[now];
        int ans = 0;
        for(int i=-1; i<=1; ++i){
            int nxt = move(now, idx, i);
            // dbg(i);dbg(nxt);
            if(nxt!=-1){
                if(tmpE > E[nxt]){
                    ans = i;
                    tmpE = E[nxt];
                }
            }
        }

        now = move(now,idx,ans);
        query(ans);
        if(now == g) return;
    }

    while(1){}
}

int main(){
    solve();
    return 0;
}



Measured memory_bytes: 3420
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s.length()<6){
		cout<<"No"<<endl;
		return 0;
	}
	if(s[2]==s[3]&&s[4]==s[5])
	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
b = [0]*(N+1)
for i in range(N, 0, -1):
    temp = 0
    for j in range(1, N//i+1):

        temp += b[j*(i)]
    if temp % 2 != a[i-1]:
        b[i] = 1

print(b.count(1))
ans = []
for i in range(N):
    if b[i+1] == 1:
        ans.append(i+1)

print(" ".join(map(str, ans)))


Measured memory_bytes: 79848
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] P = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = scan.nextInt();
        }
        int ans = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            if (min >= P[i]) {
                ans += 1;
                min = P[i];
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 86892
import itertools

N=int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
a=0
b=0

index=0
for i in itertools.permutations(range(1,N+1), N):   
    if P==list(i):
        a=index
    if Q==list(i):
        b=index
    index+=1
print(abs(b-a))

Measured memory_bytes: 42096
#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 int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m;
int a[125252];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m)scanf("%d",a+i);
  int oa=-1,ob=-1;
  REP(i,m){
    if(a[i]%2==1){
      if(oa==-1)oa=i;
      else if(ob==-1)ob=i;
      else{
        puts("Impossible");
        return 0;
      }
    }
  }
  if(oa!=-1)
    swap(a[0],a[oa]);
  if(ob!=-1)
    swap(a[m-1],a[ob]);
  vi b;
  int sum = 0;
  if(a[0]>1){
    b.push_back(a[0]-1);
    sum += a[0]-1;
  }
  REP(i,m-2){
    b.push_back(a[i+1]);
    sum += a[i+1];
  }
  b.push_back(n-sum);
  printf("%d",a[0]);
  FOR(i,1,m)printf(" %d",a[i]);
  putchar('\n');

  printf("%d\n",b.size());

  printf("%d",b[0]);
  FOR(i,1,b.size())printf(" %d",b[i]);
  putchar('\n');

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  
  int ans=1;
  
  
  
  for(int i=N-1;i > 0;i--){
    if(H.at(i)<H.at(i-1)){
      H.at(i-1)-=1;
      if(H.at(i)<H.at(i-1)){
        ans=0;
        break;
      }
      else
        continue;
    }
    else
      continue;
  }
  
  if(ans == 1)
    cout << "Yes" << endl;
  
  else if(ans == 0)
    cout << "No" << endl;
  
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int OFF = (1 << 20);



int main () {

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

Measured memory_bytes: 256
#include <cstdio>

int main() {
  size_t n;
  scanf("%zu", &n);

  int a = 0;
  for (size_t i = 0; i < n; ++i) {
    char buf[4];
    scanf(" %s", buf);
    char c = buf[0];
    if (c == 'A') {
      ++a;
    } else {
      if (a == 0) return puts("NO"), 0;
      --a;
    }
  }
  puts(!a? "YES": "NO");
}



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

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

    vector<int> count_e(n, 0);
    vector<int> count_e_sum(n + 1, 0);
    vector<int> count_w(n, 0);
    vector<int> count_w_sum(n + 1, 0);

    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'E')
        {
            count_e[i]++;
        }
        else if (s[i] == 'W')
        {
            count_w[i]++;
        }
        count_e_sum[i + 1] = count_e_sum[i] + count_e[i];
        count_w_sum[i + 1] = count_w_sum[i] + count_w[i];
    }

    vector<int> ans(n);
    for (int i = 0; i < n; i++)
    {
        ans[i] = count_w_sum[i] + count_e_sum[n] - count_e_sum[i + 1];
    }

    int answer = *min_element(begin(ans), end(ans));

    cout << answer;
}

Measured memory_bytes: 6532
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

b = input()

if b == "A":
	print("T")
elif b == "T":
	print("A")
elif b == "C":
	print("G")
else:
	print("C")

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

int dfs(int cur, vector<vector<int> >& g, vector<bool>& vis) {
  int cnt = 1;
  vis[cur] = true;
  
  for(int i = 0;i < g[cur].size(); i++) {
    int v = g[cur][i];
    if(vis[v] == false)
      cnt = cnt + dfs(v,g,vis);
  }
  return cnt;
}

int main() {
  int n,m;
  cin>>n>>m;
  vector<vector<int> > g(n);
  int a,b;
  for(int i = 0;i < m;i++) {
    cin>>a>>b;
    g[a-1].push_back(b - 1);
    g[b-1].push_back(a - 1);
  }
  
  vector<bool> visited(n,false);
  int ans = -1;
  for(int i = 0;i < n;i++){
    if(visited[i] == false)
      ans = max(ans, dfs(i,g,visited));
  }
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 26600
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
#include <math.h>
#include <cctype>
using namespace std;
#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)
int32_t main() {
    ios_base::sync_with_stdio(false);
    int cnt = 0;
    string s;
    cin >> s;
    int mx = 0;
    for(auto x: s){
        if(x == 'R')
        {
            cnt++;
            mx=max(mx,cnt);
        }
        else
        {
            cnt = 0;
        }
    }
    cout << mx << "\n";
    return 0;
}


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

#define PI 3.14159265358979323

int main(){
   double r;
   cin >> r;
   
   cout << fixed << setprecision(5) << (double)PI * r * r << " " <<(double) 2 * PI * r << endl;
    
}

Measured memory_bytes: 1288
#include<stdio.h>
int main(void)
{
	int x;
	scanf("%d",&x);
	x=x%7;
	if(x==0) printf("thu\n");
	if(x==1) printf("fri\n");
	if(x==2) printf("sat\n");
	if(x==3) printf("sun\n");
	if(x==4) printf("mon\n");
	if(x==5) printf("tue\n");
	if(x==6) printf("wed\n");
	return 0;
}


Measured memory_bytes: 2680
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long  b = sc.nextLong();
        long ret = a*b/gcd(a,b);

        System.out.println(ret);
        // write your code here

    }
    static long gcd(long a, long b ){
        while(a==0){
            return b;
        }
        return gcd(b%a,a);
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define rep(i,n)       for(int i=0; i<n; i++)
#define clr(arr)       memset(arr, 0, sizeof arr)
#define all(x)         x.begin(), x.end()
const int MOD = 1e9 + 7;

#ifdef SMIT
template<class F, class S> ostream& operator<<(ostream &out, const pair<F, S> &p)
{
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out)
{
	out << '{';
	for (auto i = x.begin(); i != x.end(); i++)
		out << *i << (i == prev(x.end()) ? "" : ", ");
	return out << '}';
}
void dmp() {}
template<class T, class... Args> void dmp(T &&x, Args... args)
{
	cerr << x << ";  "; dmp(args...);
}
struct Nl {~Nl() {cerr << '\n';}};
#define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dmp(x), Nl(), cerr << ""
#else
#define debug(...) {}
#endif
// Yes you CAN


int n, a[101];
unordered_map<int, int> mp;
void solve()
{
// #define TEST
	cin >> n;
	rep(i, n)
	{
		cin >> a[i];
		mp[a[i]]++;
	}
	vector<pair<int, int>> v(mp.begin(), mp.end());
	sort(all(v));
	int ans = 0;
	for (int i = 0; i + 2 < (int)v.size(); i++)
	{
		for (int j = i + 1; j + 1 < (int)v.size(); j++)
		{
			for (int k = j + 1; k < (int) v.size(); k++)
			{
				if (v[i].first + v[j].first > v[k].first)
				{
					ans += v[i].second * v[j].second * v[k].second;
				}
				debug(v[i].first, v[j].first, v[k].first);
			}
		}

	}
	cout << ans << endl;

}

int32_t main()
{
#ifdef SMIT
	// freopen("/home/smit/Desktop/in.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(false); cin.tie(nullptr);

	int t = 1;
#ifdef TEST
	cin >> t;
#endif
	while (t--)
		solve();
}

Measured memory_bytes: 3656
k,n=map(int,input().split())
a=list(map(int,input().split()))
max = -1
for i in range(0,n-1):
  d=abs(a[i+1]-a[i])
  if max<d:
    max=d
if max<k-a[n-1]+a[0]:
  max=k-a[n-1]+a[0]
  
print(k-max)

Measured memory_bytes: 26444
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


class UnionFind():
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n

        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]

        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)

            if x == y:
                return

            if self.parents[x] > self.parents[y]:
                x, y = y, x

            self.parents[x] += self.parents[y]
            self.parents[y] = x

        def size(self, x):
            return -self.parents[self.find(x)]

        def same(self, x, y):
            return self.find(x) == self.find(y)

        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]

        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]

        def group_count(self):
            return len(self.roots())

        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}

        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():


    N,M=map(int,input().split())


    u =UnionFind(N)

    for i in range(M):
        a,b =map(int,input().split())
        a -=1
        b -=1
        u.union(a,b)

    print(u.group_count()-1)









if __name__ == "__main__":
    main()


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

bool solve() {
    long long N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    rep(i, 0, N) {
        long long mx = i * D - (N - 1 - i) * C;
        long long mn = i * C - (N - 1 - i) * D;
        if(mn <= abs(A - B) && abs(A - B) <= mx) return true;
    }
    return false;
}

int main() {
    cout << (solve() ? "YES" : "NO") << '\n';
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7

all_item = sum(a)

ans = 0
for i in range(n):
    all_item = (all_item - a[i])%mod
    ans = (ans + all_item*a[i])%mod
print(ans)


Measured memory_bytes: 31444
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1000000007;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
 
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n,k,s;
    cin >> n >> k >> s;

    if(n == k){
      rep(i,n) print(s);
      return 0;
    } else {
      rep(i, k) print(s);
      REP(i, k, n) {
        if(s == 1) {
          print(s + 1);
        } else {
          print(s - 1);
        }
      }
    }

}

Measured memory_bytes: 1280
from itertools import permutations
n,m=map(int,input().split())

M=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    M[a-1].append(b-1)
    M[b-1].append(a-1)

ans=0
for A in permutations(range(n),n):
    if A[0]==0:
        for i in range(n):
            if i==n-1:
                ans +=1
                break
            if A[i+1] not in M[A[i]]:break

print(ans)

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

int main()
{
    int q,oper,num,t=0;
    cin>>q;
    int arr[q]={0};
    while(q--)
    {
        cin>>oper;
        if(oper==0)
        {
            cin>>num;
            arr[t]=num;
            t++;
        }
        else if(oper==1)
        {
            cin>>num;
            cout<<arr[num]<<endl;
        }
        else if(oper==2)
        {
            arr[t-1]=0;
            t--;
        }
    }

}



Measured memory_bytes: 3864
#include <iostream>
using namespace std;
typedef long long ll;

ll A[100000];
ll B[100000];
int main(void){
    // Your code here!
    int N;
    cin >> N;
    for(int i = 0; i <= N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    
    ll total = 0;
    for(int i = 0; i < N; i++){
        if(A[i] < B[i] && (A[i] + A[i+1]) > B[i]){
            total += B[i];
            A[i+1] -= (B[i] - A[i]);
        } else if(A[i] < B[i] && (A[i] + A[i+1]) <= B[i]){
            total += A[i] + A[i+1];
            A[i+1] = 0;
        } else if(A[i] >= B[i]){
            total += B[i];
        }
    }
    cout << total << endl;
}


Measured memory_bytes: 1792
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	double n,k;
	cin>>n>>k;
	cout<<(ll)ceil((n-1)/(k-1));
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3836
a, b = map(int, input().split())  # 複数数値入力
c = list()
t = list()
ans = float("inf")

for i in range(a):
    C, T = map(int, input().split())
    if T > b:
        continue

    ans = min(ans, C)

if ans == float("inf"):
    print("TLE")
else:
    print(ans)


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
public class Aprob {
    public static void Main() {
        List<string> list = new List<string>();
        int[] count = new int[27];
        string S = Console.ReadLine();
        bool exist = false;
        for (int i = 0; i < S.Length; i++) {
            exist = false;
            for (int j = 0; j < list.Count; j++) {
                if (S.Substring(i, 1) == list[j]) {
                    count[j]++;
                    exist = true;
                    break;
                }
            }
            if (!exist) {
                list.Add(S.Substring(i, 1));
            }
        }
        string outp = "Yes";
        for (int i = 0; i < list.Count; i++) {
            if (count[i] % 2 != 1) {
                outp = "No";
            }
        }
        Console.WriteLine(outp);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#include <algorithm>

int main() {
  string s;
  cin >> s;
  
  int first_0_count = 0;
  int first_1_count = 0;
  
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '1' && i % 2 == 0)
      first_0_count++;
    if (s[i] == '0' && i % 2 == 1)
      first_0_count++;
    if(s[i] == '0' && i % 2 == 0)
      first_1_count++;
    if (s[i] == '1' && i % 2 == 1)
      first_1_count++;
  }
  
  cout << min(first_0_count, first_1_count) << endl;
  
}

Measured memory_bytes: 512
def func(lv, id):
    sz = 4 * 2 ** lv - 3
    num = 2 * 2 ** lv - 1
    mid = (sz + 1) / 2
    if lv == 0:
        return 1
    if id == 1:
        return 0
    if id == mid:
        return num / 2 + 1
    if id == sz:
        return num
    if 1 < id < mid:
        return func(lv - 1, id - 1)
    if mid < id < sz:
        return func(lv - 1, id - sz / 2 - 1) + num / 2 + 1

print func(*map(int, raw_input().split()))

Measured memory_bytes: 2568
/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

#include <bits/stdc++.h>
#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define LL long long
#define ll long long
#define LD double

#define HabdModeActive ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first
#define PI acos(-1)
#define MAX 5000005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
const int N = 1e3 + 5;
vector<int> vec[N];

int main() {
    HabdModeActive
    int n;
    cin >> n;
    int arr[n], s[n];
    for (int i = 0; i < n; i++)
        cin >> arr[i], s[i] = arr[i];
    sort(arr, arr + n);
    int cnt = 0;
    for (int i = 0; i < n; i++)
        if (arr[i] != s[i])
            cnt++;

    if (cnt == 2 || cnt == 0)
        cout << "YES";
    else cout << "NO";


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}
int a[N],c[N];

signed main()
{
	int n=read(),k=read();
	for (int i=1;i<=n;i++) a[i]=read();
	while (k--)
	{
		bool flag=1;
		for (int i=0;i<=n+1;i++) c[i]=0;
		for (int i=1;i<=n;i++)
		{
			int l=max(i-a[i],1),r=min(i+a[i],n);
			c[l]++;
			c[r+1]--;
		}
		for (int i=1;i<=n;i++) a[i]=c[i]+=c[i-1];
		for (int i=1;i<=n;i++)
		if (a[i]!=n) flag=0;
		if (flag) break;
	}
	for (int i=1;i<=n;i++) print(a[i],' ');

	return 0;
}

Measured memory_bytes: 5184
DBG = !true

n,m = gets.split.map{|x| x.to_i}
s = gets.chomp!
t = gets.chomp!
printf("n:%d m:%d s:%s t:%s\n", n, m, s, t) if DBG

g = n.gcd(m)
l = n.lcm(m)
ok = true
for i in 0...g
  if s[i*n/g] != t[i*m/g]
    ok = false
    break
  end
end
print (ok ? l : -1)


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

using namespace std;

int main(){

    int dig, sum, num;
    sum = 0;
    cin >> num;
    int n = num;

    while(num){
        dig = num % 10;
        sum = sum + dig;
        num = num / 10;
    }


    if(n % sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

int x;

int main(){
  cin >> x;
  int sum = 0;
  int ans = 0;
  while(true){
    ans++;
    sum += ans;
    if(sum >= x){
      cout << ans << endl;
      break;
    }
  }
  return 0;
}


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

namespace cs
{
    public class Program
    {
        public static void Main(string[] args)
        {
            
            var K = int.Parse(Console.ReadLine().Split(' ')[1]);
            var ho = Console.ReadLine().ToCharArray();
            var input = new int[ho.Length];
            for(int i = 0; i < input.Length; i++){
            	input[i] = int.Parse(ho[i].ToString());
            }
            var count = new int[input.Length];
            int parent = input[0];
            count[0] = (input[0] == 0) ? -1 : 1;
            int zeroCount = (input[0] == 0) ? 1 : 0;
            int oneCount = (input[0] == 0) ? 0 : 1;
            
            int divideCount = 0;
            
            for(int i = 1; i < input.Length; i++){
            	
            	if(input[i] != parent){
            		divideCount++;
            		parent = input[i];
            		if(input[i] == 0){
          				zeroCount++;
          			}else{
          				oneCount++;
          			}
            		count[divideCount] = (input[i] == 0) ? -1 : 1;
            	}else{
            		count[divideCount] += (1 * (count[divideCount] / Math.Abs(count[divideCount])));
            	}
            
            }
            
            count = count.Where(x => x != 0).ToArray();
         	
         	var ans = new List<int>();
         	var cnt = 0;
         	
         	var sum = 0;
         	var tailPoint = 0;
         	
         	for(int i = 0; i < count.Length; i++){
         	
         		sum += Math.Abs(count[i]);
         		
         		if(i == count.Length-1){
         			ans.Add(sum);
         		}
         	
         		if(count[i] > 0){
         			if(cnt >= K){
         				ans.Add(sum);
         				sum -= Math.Abs(count[tailPoint]);
         				tailPoint++;
         				if(count[tailPoint] < 0){
         					sum -= Math.Abs(count[tailPoint]);
         					tailPoint++;
         				}
         				cnt--;
         			}
         		}
         	
         		if(count[i] < 0){
         			cnt++;
         		}
         	
         	}
         	
         	Console.WriteLine(ans.Max());
         	
         	
         	
         }
            
    }
}



Measured memory_bytes: 18144
#include <iostream>
#include<string>
#include <math.h>
#include<algorithm>
#include<vector>
#include<bitset>
using namespace std ;
typedef long long int ll ;

int main (){
	int a ;
	cin >> a ;
	while (a>0)
	{
		if(a%10 == 7){ cout << "Yes" << endl ;return  0 ;}
		a/=10 ;
	}
	cout << "No" << endl ;
	
return 0 ;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
	string S, T;
	cin >> S;
	cin >> T;

	int n = S.size() - T.size() + 1;
	vector<int> a(n);

	for (int i = 0; i < n; i++) {
		a[i] = 0;
		for (int j = 0; j < T.size(); j++) {
			if (S[j + i] != T[j]) {
				a[i]++;
			}
		}
	}

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

	cout << min << endl;	
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <iomanip>
#include <sstream>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

template <typename T>
T gcd(T a, T b) {
	while (b != 0) {
		T temp = a;
		a = b;
		b = temp % b;
	}

	return a;
}

// cout << setfill('0') << setw(5) << number < endl;
// while(getline(cin, s)) { .. } | `s` is a string

void solve() {
	long double a;
	long double b;
	cin >> a >> b;
	cout << ll(a * b) << endl;
}	

int main(){
	IOS;
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif
	
	
	int t = 1;
	// cin >> t;
	while(t--)
		solve();
	
	return 0;
}





























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

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

  if (N % 1000 == 0)
  {
    cout << 0 << endl;
    return 0;
  }

  cout << 1000 - (N % 1000) << endl;
  return 0;
}


Measured memory_bytes: 3628
#!/usr/bin/env PyPy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7
import itertools

def main():
    N=I()
    F=[[] for _ in range(N)]
    P=[[] for _ in range(N)]
    
    for i in range(N):
        F[i]=LI()
        
    for i in range(N):
        P[i]=LI()
    
    def calc(L):
        temp=0
        for i in range(N):
            cnt=0
            for j in range(10):
                cnt+=L[j]*F[i][j]
            temp+=P[i][cnt]
            
        return temp
    
    ans=-1*(10**10)
    for ite in itertools.product([0,1], repeat=10):
        if sum(ite)!=0:
            ans=max(ans,calc(ite))

    print(ans)

main()


Measured memory_bytes: 39920
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  if(n % 2 == 1)
  {
    printf("%lf", double(n/2+1)/n);
  }
  else
  {
    cout << 0.5 << endl;
  }
}
    
         

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

void sort( int* a, int n )
{
    for( int i = 0; i < n; i++ )
        for( int j = n - 1; j >= i + 1; j-- )
            if( a[j] < a[j-1] )
            {
                int t = a[j];
                a[j] = a[j-1];
                a[j-1] = t;
            }
}

int main()
{
    int n, a[10], field;
    string str;

    while( cin >> n )
    {
        if( n == 0 )
            break;

        for( int i = 0; i < 10; i++ )
            a[i] = 0;

        field = 0;

        cin >> str;
        for( int i = 0; i < str.size(); i++ )
        {
            if( str[i] == 'M' )
                a[i%n]++;
            else if( str[i] == 'S' )
            {
                field += a[i%n] + 1;
                a[i%n] = 0;
            }
            else
            {
                a[i%n] += field + 1;
                field = 0;
            }
        }

        sort( a, n );

        for( int i = 0; i < n; i++ )
            cout << a[i] << " ";
        cout << field << endl;
    }
    return 0;
}



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

public class Main {
    private static ArrayList<Integer>[] g;
    private static long[] val, inc;
    private static int n, q;
    public static void main(String[] args) {
        Kattio in = new Kattio(System.in);
        n = in.nextInt();
        q = in.nextInt();

        g = new ArrayList[n + 1];
        for (int i = 0; i <= n; ++i) {
            g[i] = new ArrayList<>();
        }

        val = new long[n + 1];
        inc = new long[n + 1];
        for (int i = 0; i < n - 1; ++i) {
            int a = in.nextInt();
            int b = in.nextInt();

            g[a].add(b);
            g[b].add(a);
        }

        for (int i = 0; i < q; ++i) {
            int p = in.nextInt();
            long x = in.nextInt();

            inc[p] += x;
        }

        dfs(1, -1, 0l);
        for (int i = 1; i <= n; ++i) {
            in.print(val[i] + " ");
        } in.println(); 

        in.close();
        in.flush();
    }

    private static void dfs(int u, int p, long acc) {
        acc += inc[u];
        val[u] = acc;
        for (int v : g[u]) if (v != p) {
            dfs(v, u, acc);
        }
    }

}


class Kattio extends PrintWriter {
    public Kattio(InputStream i) {
	super(new BufferedOutputStream(System.out));
	r = new BufferedReader(new InputStreamReader(i));
    }
    public Kattio(InputStream i, OutputStream o) {
	super(new BufferedOutputStream(o));
	r = new BufferedReader(new InputStreamReader(i));
    }

    public boolean hasMoreTokens() {
	return peekToken() != null;
    }

    public int getInt() {
	return Integer.parseInt(nextToken());
    }

    public double getDouble() { 
	return Double.parseDouble(nextToken());
    }

    public long getLong() {
	return Long.parseLong(nextToken());
    }

    public String getWord() {
	return nextToken();
    }



    private BufferedReader r;
    private String line;
    private StringTokenizer st;
    private String token;

    private String peekToken() {
	if (token == null) 
	    try {
		while (st == null || !st.hasMoreTokens()) {
		    line = r.readLine();
		    if (line == null) return null;
		    st = new StringTokenizer(line);
		}
		token = st.nextToken();
	    } catch (IOException e) { }
	return token;
    }

    private String nextToken() {
        String ans = peekToken();
        token = null;
        return ans;
    }

    public int nextInt() {
        return Integer.parseInt(getWord());
    }

}

Measured memory_bytes: 136592
/******************************************
* AUTHOR : AMAN SAXENA *
* Nick : blue-meth *
* "There's some good in this world, and it's worth fighting for." *
* INSTITUTION : KIET Group of Institutions *
******************************************/
#include <bits/stdc++.h>

const long long MODULO=1000000007;
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define FOR1(i,a,n) for(int i=a;i<=n;i++)
#define FOR2(i,a,n) for(int i=a;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pi 3.14159265359

using namespace std;

ll amanpower(ll a, ll b) {
    ll r = 1;
    while (b > 0) 
    {
        if (b & 1) r = r * a;
        a = a * a;
        b >>= 1;
    }
    return r;
}

ll amanlcm(ll a, ll b)
{
     return a*(b/__gcd(a,b));
}


//********* CODE START *********


void solve()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if(a < b && b < c)
    {
        cout << "Yes";
        return ;
    }
    while(k>0)
    {
        if(b > a)
        {
            break;
        }
        else 
        {
            b*=2;
            k--;
        }
    }
    while(k>0)
    {
        if(c > b)
        {
            break;
        }
        else 
        {
            c*=2;
            k--;
        }
    }

    if(a < b && b < c)
    {
        cout << "Yes";
        return ;
    }
    cout << "No";


    

}

void test()
{
    int t;
    cin>>t;
    while(t--) //for(int j=1;j<=t;j++) cout << "Case #" << j << ": ";
    {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif
    
    // test();
    solve();

    
    return 0;
}

Measured memory_bytes: 3644
/*==============================================*\
ID:          shahidul_brur

Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh

 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};

const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = 3000;
const int LOGN = 20;
double p[maxn], dp[maxn][maxn];
bool vis[maxn][maxn];
int n;
double cal(int pos, int head){
	if(pos==n+1){
		return 1.0*(head>=(n+1)/2);
	}
	double &ret = dp[pos][head];
	if(vis[pos][head]) return ret;
	vis[pos][head] = 1;
	ret = p[pos]*cal(pos+1,head+1);
	ret+=(1-p[pos])*cal(pos+1,head);
	return ret;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n;
    for(int i=1;i<=n;i++)
    	cin>>p[i];
    cout << fixed << setprecision(12) << cal(1,0) << "\n";
    return 0;
}


Measured memory_bytes: 79616