akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
    int A[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> A[i][j];
        }
    }
    int n;
    cin >> n;
    vector<int> B(n);
    int bingo[3][3] = {0};
    for (int i = 0; i < n; i++) cin >> B[i];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if(A[j][k] == B[i]) bingo[j][k] = 1;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        int t = 0, y = 0;
        for (int j = 0; j < 3; j++) {
            y += bingo[i][j];
            t += bingo[j][i];
        }
        if(y == 3 || t == 3) ans = 1;
    }
    int l = 0, r = 0;
    for (int i = 0; i < 3; i++) {
        if(bingo[i][i]) l++;
        if(bingo[2-i][i]) r++;
    }
    if(l == 3 || r == 3) ans = 1;
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <limits>
#include <utility>
#include <algorithm>
#include <tuple>
#include <limits>

typedef long long ll;

int main(int argc, char *argv[])
{
    ll k;
    bool ok = true;

    std::cin >> k;

    ll cur = k;
    int digit = 0;
    int loop = 0;
    while(ok && cur > 0) {
        if (cur % 10 == 7) {
            digit++;
            cur /= 10;
            loop = 0;
        } else {
            cur += k;
            loop++;
            if (loop > 10) {
                ok = false;
            }
            if (digit > 1000000000) {
                ok = false;
            }
        }
    }

    if (ok) {
        std::cout << digit << std::endl;
    } else {
        std::cout << -1 << std::endl;
    }

    return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  long double n, ans;
  cin >> n;
  ans = (n / 3.0) * (n / 3.0) * (n / 3.0);
  cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
class bipertite_matching{
    private:
        int siz;
        vector<vector<int>> g;
        vector<bool> done;
        vector<int> match;
    public:
        bipertite_matching(int n){
            siz = n;
            g.resize(n);
            done.resize(n);
            match.resize(n,-1);
        }
        void add_edge(int u,int v){
            g[u].push_back(v);
            g[v].push_back(u);
        }
        bool dfs(int v){
            done[v] = true;
            for(int u:g[v]){
                int w = match[u];
                if (w < 0 || (!done[w] && dfs(w))){
                    match[v] = u;
                    match[u] = v;
                    return true;
                }
            }
            return false;
        }
        int bipartiteMatching(){
            int res = 0;
            rep(i,siz){
                if (match[i] < 0){
                    done.assign(siz,false);
                    if (dfs(i)) res++;
                }
            }
            return res;
        }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X,Y,E,x,y;
    cin >> X >> Y >> E;
    bipertite_matching g(X+Y);
    rep(i,E){
        cin >> x >> y;
        g.add_edge(x,X+y);
    }
    PRINT(g.bipartiteMatching());
}



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

const int N = 1 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, l, r;
long long a[N];
unsigned long long C[N][N];

bool read() {
    if (!(cin >> n >> l >> r))
        return false;

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

    return true;
}

void solve() {
    C[0][0] = 1;

    for (int i = 1; i < N; ++i)
        for (int j = 0; j <= i; ++j)
            C[i][j] = (j ? C[i - 1][j - 1] : 0ull) + C[i - 1][j];

    sort(a, a + n);
    reverse(a, a + n);
    auto P = 0ll;
    auto Q = 1ll;

    auto bgr = [](long long p1, long long q1, long long p2, long long q2) {
        return p1 * q2 - p2 * q1;
    };

    for (int i = l - 1; i < r; ++i) {
        auto sum = accumulate(a, a + i + 1, 0ll);

        if (bgr(sum, i + 1, P, Q) > 0) {
            P = sum;
            Q = i + 1;
        }
    }

    cout << setprecision(12) << fixed << static_cast<long double>(P) / Q << endl;
    auto ans = 0ll;

    for (int i = l - 1; i < r; ++i) {
        auto sum = accumulate(a, a + i + 1, 0ll);

        if (bgr(sum, i + 1, P, Q) == 0) {
            auto j1 = i;
            auto j2 = i;
            for (; j1 >= 0 && a[j1] == a[i]; --j1) { }
            for (; j2 < n && a[j2] == a[i]; ++j2) { }
            ans += C[j2 - j1 - 1][i - j1];
        }
    }

    cout << ans << endl;
}
 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vector<int> xs(n);
    rep(i, n) cin >> xs[i];
    int sml = min_element(xs.begin(), xs.end())[0];
    int max = max_element(xs.begin(), xs.end())[0];

    int best = INT32_MAX;
    for (int i = sml; i <= max; ++i)
    {
        int score = 0;
        for (auto x : xs)
        {
            score += (x - i) * (x - i);
        }
        best = min(best, score);
    }

    cout << best << endl;

    return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> a(n+1),b(n);
  for(int i=0;i<n+1;i++){
    cin>>a.at(i);
  }
  for(int i=0;i<n;i++){
    cin>>b.at(i);
  }
  int64_t p=0;
  for(int i=0;i<n;i++){
    if(a.at(i)+a.at(i+1)<b.at(i)){
      p+=a.at(i)+a.at(i+1);
      a.at(i+1)=0;
    }
    else{
      p+=b.at(i);
      a.at(i+1)=min(a.at(i+1),a.at(i)+a.at(i+1)-b.at(i));
    }
  }
  cout<<p<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
void nhap()
{
    scanf("%d%d%d",&a,&b,&c);
}
void solve()
{
    int s = a*100+b*10+c;
    if (s%4==0)
    {
        cout<<"YES"<<endl;
    }
    else {cout<<"NO"<<endl;}
}
int main()
{
    nhap();
    solve();
    return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b, c = rm()
if b >= c:
  print('delicious')
elif c-b > a:
  print('dangerous')
else:
  print('safe')









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

using namespace std;

int main(void){

    long n, sum;
    cin >> n >> sum;
    sum /= 1000;

    if(sum>n*10){
        cout << "-1 -1 -1" << endl;
        return 0;
    }

    for (long x = 0; x <= n; x++){
        for (long y = 0; y <= n; y++){
            for (long z = 0; z <= (n-x-y);z++){
                if(sum == x*10+y*5+z*1){
                    if(x+y+z>n)
                        break;

                    if(x+y+z==n){
                        printf("%d %d %d\n", x, y, z);
                        return 0;
                    }
                }
            }
        }
    }

    cout << "-1 -1 -1" << endl;
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  map<int, int> m_d;
  ++m_d[0];
  for (int i=0; i<n; i++) {
    int di;
    cin>>di;
    ++m_d[di];
  }
  vector<int> d1, d2;
  for (auto x: m_d) {
    if (x.second > 2) {
      cout<<0<<endl;
      return 0;
    } else if (x.second == 2) {
      d2.push_back(x.first);
      d2.push_back(24 - x.first);
    } else {
      d1.push_back(x.first);
    }
  }
  int ans = 0;
  int len1 = d1.size();
  int len2 = d2.size();
  int mask = 1 << len1;
  int max_s = 0;
  for (int i=0; i<mask; i++) {
    int t[len1+len2];
    for (int j=0; j<len1; j++) {
      if ((i >> j) & 1) {
        t[j] = d1[j];
      } else {
        t[j] = 24 - d1[j];
      }
    }
    for (int j=0; j<len2; j++) {
      t[j+len1] = d2[j];
    }
    int min_d = 24;
    for (int j=0; j<len1+len2; j++) {
      for (int k=0; k<len1+len2; k++) {
        if (j == k) {
          continue;
        }
        min_d = min(min(abs(t[k]-t[j]), 24-abs(t[k]-t[j])), min_d);
      }
    }
    max_s = max(min_d, max_s);
  }
  cout<<max_s<<endl;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")



int main()
{

	int N, M;
	cin >> N >> M;
	vec(H);
	pairs(F)
	fx(N) {
		vecp(H);
		F.push_back(make_pair(H[x],x+1));
	}
	sorts(F);
	map<int, int> P;
	fx(N) {
		if (x > 0 && F[x].first == F[x - 1].first) {
			P[F[x].second] = P[F[x-1].second];
		}
		else {
			P[F[x].second] = x;
		}

	}
	vector<vector<int>> G(N+1);
	fx(M) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int ans = 0;
	fx(N) {
		if (G[x + 1].size() == 0) {
			ans++;
		}
		else {
			int n = P[x + 1];
			bool flag = true;
			for (auto g : G[x+1]) {
				if (P[g]>=n) {
					flag = false;
					break;
				}
			}
			if (flag)ans++;
		}
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 14280
n,k=map(int,input().split())
if k==1 or n%k==0:
    ans=0
else:
    if n/2<k:
        x=abs(n-k)
        y=abs(x-k)
        ans=min(n,min(x,y))
    else:
        x=n%k
        y=abs(x-k)
        ans=min(x,y)
print(ans)


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

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string x;
    cin >> x;
    int n = x.length();
    int s = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        if (x[i] == 'T') {
            if (s == 0) ans++;
            else s--;
        } else {
            s++;
        }
    }
    ans += s;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 720
import copy
Input = [i for i in input()]

for i in range(2**3):
    AltInput=Input.copy()
    formula = AltInput.pop(0)
    for j in range(3):
        if((i >> j) & 1):
            formula += '+'
        else:
            formula += '-'
        formula += AltInput.pop(0)
    if(eval(formula) == 7):
        print(formula + '=7')
        break

Measured memory_bytes: 3444
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<queue>
#include<string.h>
#include<string>
#include<map>
#include<unordered_set>
#include<stack>
#include<vector>
#include<deque>
#define mod 1000000007
using namespace std;
struct str {
	long long node, cost, t;
};
long long n, m, k,b,r;
long long cal(int a, int b) {
	long long sum_n = 1;
	long long sum_r = 1;
	long long sum_m = 1;
	long long t = a - b;
	for (int i = 2; i <= a; i++)sum_n = (sum_n*i) % mod;
	for (int i = 2; i <= b; i++)sum_r = (sum_r*i) % mod;
	for (int i = 2; i <= t; i++)sum_m = (sum_m*i) % mod;
	long long p = mod-2, val = (sum_r*sum_m) % mod, temp = 1;
	while (p) {
		if (p & 1)temp = (temp * val) % mod;
		val = (val*val) % mod;
		p >>= 1;
	}
	return (sum_n*temp) % mod;
}
int main() {
	scanf("%lld %lld", &n, &b);
	r = n - b;
	long long ans = 0,sum=0;
	for (int i = 1; i <= b; i++) {
		ans = 0;
		long long temp_val = (cal(b-1, b-i))%mod;
		if (r + 1 >= i) {
			ans = (temp_val*cal(r + 1, i)) % mod;
		}
		printf("%lld\n",ans);
	}
	return 0;
}


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

using namespace std;
using i64 = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const i64 INFL = (1LL << 62);
const i64 MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  i64 n, k;
  cin >> n >> k;

  vector<i64> a(n);
  rep(i, n) { cin >> a[i]; }
  vector<i64> s(n + 1, 0);
  rep(i, n) { s[i + 1] = s[i] + a[i]; }
  map<i64, i64> mp;
  i64 ans = 0;

  for (i64 j = 0; j <= n; ++j) {
    int now = (s[j] - j) % k;
    if (j >= k) {
      int left = (s[j - k] - j) % k;
      if (left < 0) left += k;
      mp[left]--;
    }
    ans += mp[now];
    mp[now]++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 15872
n = int(input())
h = [int(i) for i in input().split(" ")]

f = False
c = 0

for k in range(0, 100):
    for i in range(0, n):
        if f:
            if k >= h[i]:
                f = False
                c += 1
        else:
            if k < h[i]:
                f = True
    if f:
        f = False
        c += 1

print(c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

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

  } else {
    total += k;
    cout << k << endl;
  }
}


Measured memory_bytes: 3624
import java.util.*;
import static java.lang.Math.ceil;
class Main{
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		long n = input.nextLong();
		long k = input.nextInt();
		Vector h = new Vector();
		for(int i = 0;i < n; ++i){
			long x  = input.nextInt();
			h.add(x);
		}
		long ans = 0;
		Collections.sort(h);
		Collections.reverse(h);
		for(int i = 0;i < n; ++i){
			if(k > 0){
				k--;
			}else{
				ans += (long)h.elementAt(i);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 96396
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int main() {
    string S, T;
    cin >> S >> T;
    string U;
    U = S + T;
    int  a = stoi(U);

    bool fl = false;
    for (int i = 1; i < 1000; i++) {
        if (a == i*i) {
            fl = true;
            break;
        }
    }
    if (fl)cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using namespace std;

const int maxn = 2e5 + 10;
int ar[maxn], ans1[maxn], ans2[maxn], n, x;     

int main(){
    int n;
    cin >> n;
    int ans = n;
    for(int i = 1; i <= n; i++){
        cin >> x;
        ar[x] = i;
    }
    for(int i = n - 1; i >= 1; i--){
        if(ar[i] < ar[i + 1])
             ans1[i] = ans1[i + 1];
        else
            ans1[i] = (n - i);
    }
    for(int i = 2; i <= n; i++){
        if(ar[i] > ar[i - 1])
            ans2[i] = ans2[i - 1];
        else
            ans2[i] = i - 1;
    }
    for(int i = 1; i <= n; i++)
        ans = min(ans, ans2[i] + ans1[i]);

    cout << ans << endl;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int x = s.nextInt();
		int t = s.nextInt();
		
		System.out.println((int)Math.ceil((double)n/(double)x) * t);
		

	}

}

Measured memory_bytes: 35680
package main

import "fmt"

func main() {
        var n, m int
        fmt.Scan(&n, &m)
        a := make([]int, n)
        for i := range a {
                fmt.Scan(&a[i])
        }

        b := 0
        c := map[int]int{0: 1}
        cnt := 0
        for _, a := range a {
                b = (b + a) % m
                if _, ok := c[b]; !ok {
                        c[b] = 1
                        continue
                }
                cnt += c[b]
                c[b]++
        }
        fmt.Println(cnt)
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

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

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

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

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	ll a[114514], b[114514];
	pll c[114514];
	cin>>n;
	REP(i, n){
		cin>>a[i]>>b[i];
		c[i]=pll(a[i]+b[i], i);
	}
	sort(c, c+n);
	ll ans=0;
	bool flag=true;
	FORR(i, 0, n){
		if(flag){
			ans+=a[(int)c[i].second];
		}
		else{
			ans-=b[(int)c[i].second];
		}
		flag=!flag;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 3840
// use proconio::marker::Chars;
use proconio::{fastout, input};
// use std::cmp::{max, min};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
    };

    let mut v: Vec<(u128, u128, u128)> = Vec::new();
    let mut result = vec![String::new(); m];

    for i in 0..m {
        input! {
            p: u128,
            y: u128
        }
        v.push((p, y, i as u128));
    }

    v.sort_by(|a, b| a.0.cmp(&b.0).then(a.1.cmp(&b.1)));

    let mut city = vec![1; n + 1];

    for vi in v.iter() {
        result[vi.2 as usize] = format!("{0: >06}{1: >06}", vi.0, city[vi.0 as usize]);
        city[vi.0 as usize] += 1;
    }

    for result_i in result.iter() {
        println!("{}", result_i)
    }
}


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

int main() {
	int n, a;
	int a1 = 0, a2 = 0, a4 = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a % 4 == 0) {
			a4++;
			continue;
		}
		else if (a % 2 == 0) {
			a2++;
			continue;
		}
		else {
			a1++;
		}
	}
	if (a2 == 0) {
		if (a1 <= a4 + 1) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		if (a1 <= a4) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cmath>
#include <complex>
#include <iostream>
using namespace std;

#define EPS 1e-6

typedef long double ldouble;
typedef complex<ldouble> P;

ldouble cross(const P &a, const P &b){
	return real(a) * imag(b) - imag(a) * real(b);
}

int n;
P z[10001];
ldouble Vabs;

const ldouble g = 9.8;

P jump(int &i){
	P dir = z[i] - z[i-1];
	P v = Vabs / abs(dir) * dir;
	const P &base = z[i];
	ldouble a = g / (real(v) * real(v) * 2.0);
	ldouble b = imag(v) / real(v);

	for(int j = i; j < n - 1; ++j){
		P z1 = z[j] - base;
		P z2 = z[j+1] - base;
		ldouble c = imag(z2 - z1) / real(z2 - z1);
		ldouble d = imag(z1) - c * real(z1);
		ldouble e = sqrt((b-c) * (b-c) - 4.0 * a * d);

		for(ldouble sgn = -1.0; sgn < 2.0; sgn += 2.0){
			ldouble x = (b - c + sgn * e) / (2.0 * a);
			if(x > real(z1) && x < real(z2)){
				ldouble y = -a * x * x + b * x;
				i = j;
				return P(x, y) + base;
			}
		}
	}

	i = n;
	return z[n-1];
}

int main(){
	ldouble x, y;
	cin >> n >> Vabs;
	for(int i = 0; i < n; ++i){
		cin >> x >> y;
		z[i] = P(x, y);
	}

	ldouble ans = 0.0;
	P prev = z[0];
	for(int i = 1; i < n; ++i){
		P dif = z[i] - prev;
		ans += abs(dif);
		if(i == n - 1) break;

		if(cross(dif, z[i+1] - z[i]) < -EPS){
			prev = jump(i);
		}
		else{
			prev = z[i];
		}
	}
	
	printf("%.20f\n", (double)ans);
}

Measured memory_bytes: 1576
#include<bits/stdc++.h>
#define MAX 10005
using namespace std;
 
int main(){
  int h, w, i, j, a[250005], cnt = 0;
  bool odd = false, t = false;
  
  scanf("%d%d", &h, &w);
  for(i = 0; i < h; i++) for(j = 0; j < w; j++)
    scanf("%d", &a[i*w + (i&1 ? j : w-1-j)]);
  
  for(i = 0; i < h*w; i++){
    if(odd) cnt++;
    if(a[i]&1) odd ^= true;
  }
  printf("%d\n", cnt);
  
  for(i = 0; i < h*w; i++){
    if(t) printf("%d %d %d %d\n", (i-1)/w+1, ((i-1)/w%2 ? (i-1)%w : w-1-(i-1)%w)+1, i/w+1, (i/w%2 ? i%w : w-1-i%w)+1);
    if(a[i]&1) t ^= true;
  }
}


Measured memory_bytes: 3072
#include <stdio.h>

int main(){
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        if(op == '?')break;
        if(op == '+')printf("%d\n", a + b);
        else if(op == '-')printf("%d\n", a - b);
        else if(op == '*')printf("%d\n", a * b);
        else if(op == '/')printf("%d\n", a / b);
    }
}


Measured memory_bytes: 2144
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

bool kai(string s){
    string t = s;
    reverse(all(t));
    if (s!=t){
        return false;
    }
    else{
        return true;
    }
}

signed main() {
    string s;cin>>s;
    int n = sz(s);

    if (kai(s) && kai(s.substr(0, n/2)) && kai(s.substr(n/2+1, n/2))){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
ans = "Yes"

for i in range(n//2):
    if s[i] == s[n - i - 1]:
        continue
    else:
        ans = "No"
for i in range(n//2):
    if s[i] == s[n//2 - i - 1]:
        continue
    else:
        ans = "No"

print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;

int main()
{
	for(int n,m,k;scanf("%d%d%d",&n,&m,&k),n|m|k;){
		double den=1;
		for(int i=0;i<n;i++) den*=m;
		ll p[10001]={1};
		for(int i=0;i<n;i++){
			ll t[10001]={};
			for(int j=1;j<=m;j++)
				for(int k=j;k<=10000;k++)
					t[k]+=p[k-j];
			memcpy(p,t,sizeof t);
		}
		
		double res=0;
		for(int i=0;i<=10000;i++)
			if(i<=k) res+=p[i]/den;
			else     res+=(i-k)*p[i]/den;
		printf("%.8f\n",res);
	}
}

Measured memory_bytes: 1220
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;


int main() {
    int N,K,q,c;
    cin >> N;
    cin >> K;
    q = 0;
    while(cin >> c){
        q += min(c,K-c);
    }
    cout << 2 * q;
}
        

Measured memory_bytes: 256
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


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

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


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

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    d, t, s = LI()
    if t >= d / s:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 27124
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

	vector<long long> a(n);
	cin >> a;

	long long p = 0;
	rep(i,n){
		if(abs(a[p]) < abs(a[i])) p = i;
	}

	vector<pair<int, int>> ans;
	if(a[p] > 0){
		rep(i,n){
			if(a[i] < 0){
				ans.emplace_back(p,i);
			}
		}
		rep(i,n - 1){
			ans.emplace_back(i, i + 1);
		}
	}else if(a[p] < 0){
		rep(i,n){
			if(a[i] > 0){
				ans.emplace_back(p,i);
			}
		}
		for(int i = n - 1; i > 0; i--){
			ans.emplace_back(i, i - 1);
		}
	}
	cout << ans.size() << endl;
	for(auto i : ans){
		cout << i.first + 1 << ' ' << i.second + 1 << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  string abcd;
  cin >> abcd;

  rep(i, 1<<3) {
    bitset<3> bit(i);
    int sum = abcd[0] - '0';
    string ans = "";
    ans += abcd[0];
    rep(j, 3) {
      if (bit[j] == 0) {
        sum += abcd[j+1] - '0';
        ans += "+";
        ans += abcd[j+1];
      }
      else {
        sum -= abcd[j+1] - '0';
        ans += "-";
        ans += abcd[j+1];
      }
    }
    if (sum == 7) {
      ans += "=7";
      cout << ans << endl;
      return 0;
    }
  }
}


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

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]) {
    bool all_visited = true;
    
    for(int i = 0; i < N; i++) {
        if(visited[i] == false) all_visited = false;
    }

    if(all_visited) {
        return 1;
    }

    int ret = 0;
    
    for(int i = 0; i < N; i++) {
        if(graph[v][i] == false) continue;
        if(visited[i]) continue;

        visited[i] = true;
        ret += dfs(i,N,visited);
        visited[i] = false;
    }

    return ret;
}

int main(void) {
    int N, M;
    cin >> N >> M;

    for(int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        graph[A-1][B-1] = graph[B-1][A-1] = true;
    }

    bool visited[nmax];
    for(int i = 0; i < N; i++) {
        visited[i] = false;
    }

    visited[0] = true;
    cout << dfs(0, N, visited) << endl;
    return 0;
}

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

public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        int a, b;
        a = input.nextInt();
        b = input.nextInt();
        System.out.println(gcd(a, b));
    }   
    
    static int gcd(int x, int y) {
        while (x > 0 && y > 0) {
            if (x > y) x %= y; else y %= x;
        }
        return x + y;
    }
}

Measured memory_bytes: 17312
from itertools import product
A, B, C, D, E, F = map(int, input().split())
ans = (-1, 0, 0)
for w1 in range(0,F+1,100*A):
    for w2 in range(0,F-w1+1,100*B):
        w = w1+w2
        for s1 in range(0,min(F-w+1,w//100*E+1),C):
            for s2 in range(0,min(F-w-s1+1,w//100*E-s1+1),D):
                s = s1+s2
                a = w+s
                ans = max(ans, (s/a if a!=0 else -1, a, s))
print(ans[1], ans[2])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define int long long int
#define vi vector<int>
#define vvi vector < vi >
#define pii pair<int,int>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define tr(k,st,en) for(int k = st; k <= en ; ++k)
#define trb(k,en,st) for(int k = en; k >= st ; --k)
using namespace std;

// n* k^k

void add_self(int& a, int b){
    a+=b;
    if (a >= mod) {
        a -= mod;
    }
    if (a < 0) {
        a += mod;
    }
}

int dp[402][402];

int32_t main()
{
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> arr(n);
    vector<int> presum(n);
    int refix = 0;
    for (int i = 0 ; i < n; i++) {
        cin>>arr[i];
        refix += arr[i];
        presum[i] = refix;
    }
    trb(L,n-1,0){
        tr(R,L,n-1){
            if (L==R) {
                dp[L][R] = 0;
            } else {
                dp[L][R] = 1e18;
                for (int i = L ; i < R  ; i++) {
                    dp[L][R] = min(dp[L][R], dp[L][i] + dp[i+1][R] + presum[R] - (L==0 ? 0 : presum[L-1]));
                }
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
}



Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

const int MOD = 1e9 + 7;

signed main(){

  int n; cin >> n;
  vector<vector<int>> G(n);
  for(int i = 0; i < n-1; i++){
    int x,y; cin >> x >> y;
    x--,y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }

  int root = 0;
  for(int i = 0; i < n; i++){
    if(G[i].size() == 1) root = i;
  }

  static int dp[100001][2];
  function< void(int,int) > dfs =
  [&](int u,int pre){
    dp[u][0] = dp[u][1] = 1;
    for(int v : G[u]){
      if(v == pre) continue;
      dfs(v,u);
      dp[u][0] = (dp[u][0] * (dp[v][0] + dp[v][1])) % MOD;
      dp[u][1] = (dp[u][1] * dp[v][0]) % MOD;
    }
  };
  dfs(root,-1);

  int ans = (dp[root][0] + dp[root][1]) % MOD;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 16640
// -*- coding:utf-8-unix -*-

use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [f64; n],
    }
    let mut a_list = vec![vec![0; 19]; 44];
    let mut ans: u64 = 0;
    for &ai in &a {
        let mut aa = (ai * 10f64.powi(9)).round() as usize;
        let mut count2 = 0;
        while aa % 2 == 0 {
            aa /= 2;
            count2 += 1;
        }
        let mut count5 = 0;
        while aa % 5 == 0 {
            aa /= 5;
            count5 += 1;
        }
        for i in 0..=43 {
            if i + count2 < 18 {
                continue;
            }
            for j in 0..=18 {
                if j + count5 < 18 {
                    continue;
                }
                ans += a_list[i][j];
            }
        }
        a_list[count2][count5] += 1;
    }
    println!("{}", ans);
}


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

int main() {
  ll x;
  cin >> x;
  ll a = 100;
  int y = 0;
  while (a < x) {
    a = a * 1.01;
    y++;
  }
  cout << y << endl;
  return 0;
}

Measured memory_bytes: 3636
N = int(input())
S = input()

right = {}
for s in S:
    right[s] = right.get(s, 0) + 1

answer = 0
left = {}
for s in S:
    left[s] = left.get(s, 0) + 1
    right[s] -= 1
    if right[s] == 0:
        del right[s]
    shared = len(set(left.keys()) & set(right.keys()))
    if shared > answer:
        answer = shared
print(answer)

Measured memory_bytes: 3064
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int h, w;
  char a[200][200];
  scanf("%d%d", &h, &w);
  for(int i = 0; i < h; i++){
    scanf("%s", a[i]);
  }

  for(int i = 0; i <= w + 1; i++){
    printf("%c", '#');
  }
  printf("\n");

  for(int i = 0; i < h; i++){
    printf("%c", '#');
    printf("%s", a[i]);
    printf("#\n");
  }

  for(int i = 0; i <= w + 1; i++){
    printf("%c", '#');
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 128
//sajeedreefy
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i,j,m,n,d,k,count=0;
    string st,s;
    cin >> st >> s;
    m=st.size();
    n=s.size();
    d=m-n+1;
    vector <int> vec;
    for(i=0;i<d;i++)
    {
        count=0;
        for(j=0,k=i;j<n;j++,k++)
        {
            if(s[j]!=st[k])
            {
                count++;
            }
        }
        vec.push_back(count);
    }
    cout << *min_element(vec.begin(),vec.end()) << endl;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	int h, w;
	vector<int> count;
	int d2 = 0, d1 = 0;

	scanf("%d%d", &h, &w);
	count.resize(26);
	for(int i = 0; i < h; ++i) {
		char buf[1024];
		scanf("%s", buf);
		for(int j = 0; j < w; ++j)
			count[buf[j] - 'a'] += 1;
	}
	for(int i = 0; i < 26; ++i) {
		if(count[i] % 4 >= 2)
			d2 += 1;
		if(count[i] % 2 == 1)
			d1 += 1;
	}

	int w2 = w / 2 * 2;
	int h2 = h / 2 * 2;

	int c4 = (w2 * h2) / 4;
	int c1 = (w - w2) * (h - h2);
	int c2 = (w * h - (c4 * 4 + c1)) / 2;

	bool ok = (d1 <= c1) && (d2 <= c2);

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

	return 0;
}

/* waffle */


Measured memory_bytes: 256
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

#setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')
MOD = 10**9 + 7

def main():
	rows, cols = rli()
	r0, c0 = rli(); r0 -= 1; c0 -= 1;
	r1, c1 = rli(); r1 -= 1; c1 -= 1;
	G = []
	for _ in range(rows):
		row = []
		for c in rll()[0]:
			if c == "#": 
				row.append(1)
			else:
				row.append(0)
		G.append(row)

	inside = lambda r, c: r>=0 and c>=0 and r<rows and c<cols	
	seen = [0 for _ in range(rows*cols+10)]
	Q = deque() #(num magics, r, c)
	Q.append((0, r0, c0))
	ans = INF
	while Q:
		magics, r, c = Q.pop()
		val = r*cols + c 
		if seen[val]: continue
		seen[val] = True
		if r == r1 and c == c1:
			ans = magics 
			break
		for dr in range(-2, 3):
			for dc in range(-2, 3):
				nr, nc = r + dr, c + dc 
				if not inside(nr, nc) or seen[cols*nr + nc] or G[nr][nc] == 1: continue
				if abs(dr) + abs(dc) > 1:
					Q.appendleft((magics+1, nr, nc))
				else:
					Q.append((magics, nr, nc))
	print(ans if ans < INF else -1)
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 238600
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using System.Threading;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();
            if (T.IndexOf(S)==0 && T.Length == S.Length+1)
            {
                Console.WriteLine("Yes");
            }
            else
                Console.WriteLine("No");
        }
    }
}

//文字列の入力
//string s = Console.ReadLine();
//整数の入力
//long n = long.Parse(Console.ReadLine());
//文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');
//整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine();
//Console.ReadKey();


Measured memory_bytes: 26172
S = input()
K = int(input())
one_length = 0
next_num = '1'
for (i, s) in enumerate(S):
    if s != '1':
        one_length = i
        next_num = s
        break

if one_length < K:
    print(str(next_num))
else:
    print('1')

# 1 or 一つ目の1以外

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

int main() {
  int H, W; cin >> H >> W;
  vector<string> a(H);
  for (int i = 0; i < H; i++) cin >> a.at(i);
  set<int> Y, X;
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (a.at(y).at(x) == '#') Y.insert(y);
    }
  }
  for (int x = 0; x < W; x++) {
    for (int y = 0; y < H; y++) {
      if (a.at(y).at(x) == '#') X.insert(x);
    }
  }
  for (int y : Y) {
    for (int x : X) cout << a.at(y).at(x);
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N;

int main()
{
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    cout << d[N / 2] - d[N / 2 - 1] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define mp            make_pair
#define PI            3.14159265
#define M             1000000007
#define MM            998244353
#define fr            first
#define sc            second
#define all(v)        (v).begin(),(v).end()
#define rall(v)       (v).rbegin(),v.rend()
#define vc            vector
#define vi            vector<int>
#define pii           pair<int,int>
#define psi           pair<string,int>
#define pis           pair<int,string>
#define mii           map<int,int>
#define msi           map<string,int>

int solve() {
    int n; cin>>n;
    double a[n],ans=0;
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    ans=a[0];
    for (int i = 1; i < n; ++i)
    {
        ans=(ans+a[i])/2;
    }
    cout<<ans;
}

signed main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>

using namespace std;

int dp[1000001];
int dp2[1000001];
vector<int> vi;

void solve(){
	for(int i=1;i*(i+1)*(i+2)/6 <= 1000000;i++){
		vi.push_back(i*(i+1)*(i+2)/6);
	}
	fill(dp,dp+1000001,9999999);
	fill(dp2,dp2+1000001,9999999);
	
	dp[0] = 0;
	dp2[0] = 0;
	for(int i=0;i<1000000;i++){
		if(dp[i] != 9999999){
			for(int j=0;j<vi.size();j++){
				if(i+vi[j] <= 1000000){
					dp[i+vi[j]] = min(dp[i+vi[j]],dp[i]+1);
				}else{
					break;
				}
			}
		}
		if(dp2[i] != 9999999){
			for(int j=0;j<vi.size();j++){
				if(i+vi[j] <= 1000000 && vi[j]%2 == 1){
					dp2[i+vi[j]] = min(dp2[i+vi[j]],dp2[i]+1);
				}
			}
		}
	}
}

int main(){
	int n;
	solve();
	while(true){
		cin >> n;
		if(n==0){
			break;
		}

		cout << dp[n] << " " << dp2[n] << endl;
	}
}

Measured memory_bytes: 9032
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


int n;
string s, t;

int read() {
  if (!(cin >> n >> s >> t)) {
    return 0;
  }
  return 1;
}

void solve() {
  for (int res = n; res >= 0; --res) {
    bool ok = 1;
    for (int i = 0; i < res; ++i) {
      if (s[i + n - res] != t[i]) {
        ok = 0;
        break;
      }
    }
    if (ok) {
      printf("%d\n", 2 * n - res);
      return;
    }
  }
  assert(0);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
l = len(s)
mod = 10**9+7
dp = [[0 for i in range(j+1)] for j in range(n+1)]
dp[0][0] = 1
for i in range(1,n+1):
  if i == 1:
    dp[1][0] = 1
  else:
    dp[i][0] = dp[i-1][1]*2+dp[i-1][0]
  dp[i][0] %= mod
  for j in range(1,i+1):
    if j < i-1:
      dp[i][j] = 2*dp[i-1][j+1]
    dp[i][j] += dp[i-1][j-1]
    dp[i][j] %= mod
print(dp[n][l])

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		String S = sc.next();
		if(S.length() <= K)
			System.out.println(S);
		else
			System.out.print(S.substring(0, K)+"...");
	}

}


Measured memory_bytes: 38652
//One Quadrillion and One Dalmatians
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
const int INF = 1 << 29;
int main ()
{
    unsigned long long N;
    cin >> N;
    
    string ans;
    int digit;
    for (; N > 0; N = N / 26) {
        N--;

        digit = N % 26;
        ans += 'a'+ (char) digit;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
    return 0;
}

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

long long  Len[51], Pat[51];

long long rec(long long k, long long x){
    if(x == Len[k]) return Pat[k];
    --x;
    long long ans = 0;
    if(x > 0) {
        long long l = min(x, Len[k - 1]);
        ans += rec(k - 1, l);
        x -= l;
    }
    if(x > 0){
        ans++;
        x--;
    }
    if(x > 0){
        long long l = min(x, Len[k - 1]);
        ans += rec(k - 1, l);
    }
    return ans;
}

int main(){
    long long  N, X;
    cin >> N >> X;

    Len[0] = Pat[0] = 1;
    for(int i = 1; i <= N; i++){
        Len[i] = Len[i - 1] * 2 + 3;
        Pat[i] = Pat[i - 1] * 2 + 1;
    }
    cout << rec(N, X) << endl;
    return 0;
}


Measured memory_bytes: 256
<?php
$A=[];
for($i=97;$i<123;$i++) $A[$i]=0;

while(1){
	$S=trim(fgets(STDIN));
	if(!$S){break;}

	foreach(str_split($S) as $c){
		$n=ord($c);
		if($n<65){}
		elseif($n<91){++$A[$n+32];}
		elseif($n<97){}
		elseif($n<123){++$A[$n];}
	}
}

for($i=97;$i<123;$i++) echo chr($i),' : ',$A[$i],PHP_EOL;

Measured memory_bytes: 15352
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

int main (void)
{
    intmax_t N;
    char S[30001];
    uint16_t digit[30000] = {};
    intmax_t ans = 0;

    scanf("%jd", &N);
    scanf("%s", S);

    for (int i = 0; i < 10; i++) {
        int pos1 = 0, pos2 = 0, pos3 = 0;
        while ((pos1 < N) && ((S[pos1] - '0') != i)) pos1++;
        for (int j = 0; j < 10; j++) {
            pos2 = pos1 + 1;
            while ((pos2 < N) && ((S[pos2] - '0') != j)) pos2++;
            for (int k = 0; k < 10; k++) {
                pos3 = pos2 + 1;
                while ((pos3 < N) && ((S[pos3] - '0') != k)) pos3++;
                if (pos3 < N) ans++;
            }
        }
    }

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    int P[n];
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> P[i];
        sum += P[i];
    }
    sort(P, P+n);
    sum -= P[n-1]/2;
    cout << sum << endl;
    return 0;
}




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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    int K = max(H, W);
    int J = min(H, W);
    int rest = N % K;
    if (N % K == 0) {
        cout << N / K << endl;
    } else {
        cout << N / K + 1 << endl;
    }
    // if (N > K) {
    //     // if (N / K < J) cout << N / K << endl;
    //     cout << N / K + 1 << endl;
    // } else {
    //     cout << 1 << endl;
    // }
}

Measured memory_bytes: 256