akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn dfs(graph: &Vec<Vec<usize>>, v: usize, n: usize, visit: &mut Vec<usize>) -> u64 {
    if visit.iter().sum::<usize>() == n {
        return 1;
    }
    let mut ans = 0;
    for i in 0..n as usize {
        if graph[v][i] == 0 || visit[i] == 1 {
            continue;
        }
        visit[i] = 1;
        ans += dfs(&graph, i, n, visit);
        visit[i] = 0;
    }
    return ans;
}

fn main() {
    input!{
        n: usize,
        m: usize,
        path: [(usize1, usize1); m],
    }
    let mut graph = vec![vec![0usize; n]; n];
    for (a, b) in path {
        graph[a][b] = 1;
        graph[b][a] = 1;
    }
    let mut visit = vec![0usize; n];
    visit[0] = 1;

    let ans = dfs(&graph, 0usize, n, &mut visit);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 100005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
int a[maxn];
ll dp[maxn][2];
ll dfs(int now, int lim) {
    if (now == -1) {
        return 1;
    }
    if (~dp[now][lim]) {
        return dp[now][lim];
    }
    int ub = lim ? a[now] : 1;
    ll sum = 0;
    if (ub == 0) {
        sum = dfs(now - 1, 1);
    }
    else {
        if (lim) {
            sum = 2 * dfs(now-1,1) + dfs(now-1,0);
        }
        else {
            sum = 3 * dfs(now-1,0);
        }
    }
    sum %= mod;
    return dp[now][lim] = sum;
}
ll solve(string s) {
    memset(dp, -1, sizeof(dp));
    int ptr = 0;
    while(s.size()) {
        a[ptr++] = s.back() - '0';
        s.pop_back();
    }
    return dfs(ptr-1,1);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    cout << solve(s) << '\n';
}

Measured memory_bytes: 7120
#include<stdio.h>
#define N 10000
int linsea(int key,int A[],int n);
int main(){
  int a,b,c=0,i;
  int S[N],T[N];
  scanf("%d",&a);
  for(i=0;i<a;i++)scanf("%d",&S[i]);
  scanf("%d",&b);
  for(i=0;i<b;i++)scanf("%d",&T[i]);
  for(i=0;i<b;i++){
  c+=linsea(T[i],S,a);
  }
  printf("%d\n",c);
}
int linsea(int key,int A[],int n){
  int i=0;
  A[n]=key;
  while(key!=A[i]){
    i++;
    if(i==n)return 0;
  }
    return 1;
}



Measured memory_bytes: 2100
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), a + n
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MOD(x) ((x) % (1e9 + 7))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

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

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	int n;
	scanf("%d", &n);
	VI d(n);
	EACH(e, d) { scanf("%d", &e); }
	ll result = 0;
	REP(i, n) {
		for(int j = i + 1; j < n; j++) {
			result += (ll)d[i] * (ll)d[j];
		}
	}
	printf("%lld\n", result);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
int n;cin>>n;
int m=n,p=m,counter=1,sum=0;
while(true){
    if(n<10)
        break;
    n/=10;
    counter+=1;
}
int x[counter];
for(int i=0;i<counter;i++){
    x[i]=m%10;
    m/=10;
    sum+=x[i];
}
cout<<(p%sum==0?"Yes":"No")<<endl;
return 0;}


Measured memory_bytes: 3588
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N;
	vector<int>A;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int a;
		cin>>a;
		A.push_back(a);
	}
	sort(A.begin(),A.end());
	ll c=0,r=0;
	for(int i=0;i<N-1;i++)
	{
		c+=A[i];
		if(c*2>=A[i+1])
		{
			r++;
		}
		else
		{
			r=0l;
		}
	}
	r++;//A[N-1]
	cout<<r<<endl;
}

Measured memory_bytes: 892
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef pair<int,int>pii;
int main(){
    int n;
    while(scanf("%d",&n),n){
        vector<pii>V;
        for(int i=0;i<n;i++){
            int p,sum=0;
            scanf("%d",&p);
            for(int i=0;i<4;i++){
                int m,s;
                scanf("%d%d",&m,&s);
                sum+=m*60+s;
            }
            V.push_back(pii(sum,p));
        }

        sort(V.begin(),V.end());
        printf("%d\n",V[0].second);
        printf("%d\n",V[1].second);
        printf("%d\n",V[n-2].second);
    }
    return 0;
}

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

using namespace std;
class Dice{
public:
    int face[7],n;
    Dice(){}
    void role_E(){
        role(1,3,6,4);
    };
    void role_N(){
        role(1,5,6,2);
    };
    void role_S(){
        role(1,2,6,5);
    };
    void role_W(){
        role(1,4,6,3);
    };
    void role_z(){
        role(2,3,5,4);
    }
    
    void role(int i, int j, int k, int l){
        n = face[l],face[l] = face[k], face[k] = face[j], face[j] = face[i], face[i] = n;
        
    }

};
bool sam(Dice C1, Dice C2){
    for (int i = 1; i < 7; i++){
        if (C1.face[i] != C2.face[i]) return false;
        
    }return true;
}
bool same(Dice C1, Dice C2){
    for (int i = 0; i < 6; i++){
        for(int j = 0; j < 4; j++){
            if(sam(C1,C2)) return true;
            C1.role_z();
        }
        if(i % 2 == 0) C1.role_W();
        else C1.role_N();
    }return false;
}


int main(){
    Dice dice1,dice2;
    
    for (int i = 1; i<7; i++) cin >> dice1.face[i];
    for (int i = 1; i<7; i++) cin >> dice2.face[i];
    
    if(same(dice1, dice2)) cout<<"Yes" <<endl;
    else cout<<"No"<<endl;
 return 0;
}


Measured memory_bytes: 3100
a, b, n = map(int, input().split())
A = []
# for i in range(1, n+1):
#     A.append((a * i)//b - a * (i//b))
# print(max(A))

x = 0
if n > (b - 1):
    x = b - 1
else:
    x = n
print((a * x)//b - a * (x//b))

Measured memory_bytes: 61756
#!/usr/bin/env python3
x1, y1, x2, y2 = [int(str) for str in input().strip().split()]

v23x = y1 - y2
v23y = x2 - x1

x3, y3 = x2 + v23x, y2 + v23y

v34x = y2 - y3
v34y = x3 - x2

x4, y4 = x3 + v34x, y3 + v34y

print(x3, y3, x4, y4)

Measured memory_bytes: 3316
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

const int DEBUG = 0;

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;


const int N = 200010;

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI l(n), r(n);
  REP(i, 0, n) {
    cin >> l[i] >> r[i];
  }
  sort(l.rbegin(), l.rend());
  sort(r.begin(), r.end());
  VL acc_l(n + 1), acc_r(n + 1);
  REP(i, 0, n) acc_l[i + 1] = acc_l[i] + l[i];
  REP(i, 0, n) acc_r[i + 1] = acc_r[i] + r[i];
  ll tot = 0;
  REP(x, 0, n + 1) {
    REP(delta, -1, 2) {
      int y = x + delta;
      if (y < 0 || y > n) continue;
      if (DEBUG) {
        DEBUGP(x);
        DEBUGP(y);
        DEBUGP(acc_l[x]);
        DEBUGP(acc_r[y]);
      }
      tot = max(tot, 2 * (acc_l[x] - acc_r[y]));
    }
  }
  cout << tot << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#define llint long long

using namespace std;

llint n;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	llint ans = 2*n;
	for(llint i = 1; i <= 1000005; i++){
		if(n % i) continue;
		ans = min(ans, i + n/i);
	}
	cout << ans-2 << endl;
	
	return 0;
}

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

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

    if (s[0] == '1') {
        char got = '1';
        for (int i = 0; i < (int)s.length(); i++) {
            if (i >= n) break;
            if (s[i] != '1') {got = s[i]; break;};
        }

        cout << got << endl;
    }
    else cout << s[0] << endl;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  map<ll,ll> m;
  rep(i,n){
    ll a; cin>>a;
    m[a]++;
  }
  vll a;
  for(auto e: m){
    if(e.second>=2){
      rep(_,e.second/2) a.push_back(e.first);
    }
  }
  sort(a.rbegin(),a.rend());
  if(a.size()<2) cout<<0<<endl;
  else cout<<a[0]*a[1]<<endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e+9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){

    int n,r;cin >> n >> r;

    if(n<=10)
    {
        r = r + 100*(10-n);
    }

    cout << r << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(pos,mp) for(ll pos=mp.begin();pos!=mp.end();pos -++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);

	if(a%b == 0)return(b);

	else return(gcd(b, a%b));
}

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

    ll a[n];
    rep(i, n)cin >> a[i];

    // 左向きと右向きの累積gcd
    ll left_gcd[n], right_gcd[n];
    left_gcd[0] = a[0];
    right_gcd[n-1] = a[n-1];

    rep(i, n-1){
        left_gcd[i+1] = gcd(left_gcd[i], a[i+1]);
        right_gcd[n-i-2] = gcd(right_gcd[n-1-i], a[n-i-2]);
    }

    ll ans = 1;
    // a[i]を抜いたgcdを求めていく
    rep(i, n){
        if(i == 0)ans = max(ans, right_gcd[i+1]);
        else if(i == n-1)ans = max(ans, left_gcd[i-1]);
        else {
            ll res = gcd(left_gcd[i-1], right_gcd[i+1]);
            ans = max(ans, res);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5944
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cctype>
using namespace std;

int main(){
    int n;
    while(cin>>n){
        if(n==0)break;
        int ans1=0;
        int ans2=0;
        int num,sum;
        for(int i=0; i<n; i++){
            cin>>num>>sum;
            if(num>sum){
                ans1+=num;
                ans1+=sum;
            }
            if(num<sum){
                ans2+=num;
                ans2+=sum;
            }
            if(num==sum){
                ans1+=num;
                ans2+=sum;
            }
        }
        cout<<ans1<<" "<<ans2<<endl;
    }
    return 0;
}

Measured memory_bytes: 2984
COLORS =  {
  'black'   => ['00', '00', '00'],
  'blue'    => ['00', '00', 'ff'],
  'lime'    => ['00', 'ff', '00'],
  'aqua'    => ['00', 'ff', 'ff'],
  'red'     => ['ff', '00', '00'],
  'fuchsia' => ['ff', '00', 'ff'],
  'yellow'  => ['ff', 'ff', '00'],
  'white'   => ['ff', 'ff', 'ff']
}

def d(r, g, b, rk, gk, bk)
  Math.sqrt((r - rk)**2 + (g - gk)**2 + (b - bk)**2)
end

while line = gets
  break if line.chomp == '0'
  *rgb = line.chomp.gsub(/^#/, '').scan(/.{2}/)

  similar_color = ''
  d_min = Float::INFINITY

  COLORS.each do |key, value|
    d = d(*value.map { |s| s.to_i(16) }, *rgb.map { |s| s.to_i(16) })
    if d < d_min
      similar_color = key
      d_min = d
    end
  end

  puts similar_color
end

Measured memory_bytes: 9640
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map(String::toInt)
    println(op139b(a, b))
}

fun op139b(a: Int, b: Int): Int {
    var plug = 1
    var count = 0

    while (plug < b) {
        count++
        plug = plug - 1 + a
    }
    return count
}



Measured memory_bytes: 37896
#include <iostream>
#include <iomanip>
#include <queue>
#include <deque>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

using namespace std;
using ll = long long;

const int kInf = 2e9;
const ll kLInf = 2e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int M, D;
int main()
{
   cout << fixed << setprecision(10);
   cin >> M >> D;
   ll cnt = 0;
   REP(i, M) {
      int month = i + 1;
      REP(j, D) {
         int day = j + 1;
         if (day % 10 >= 2) {
            if (day / 10 >= 2) {
               if ((day % 10) * (day / 10) == month) {
                  cnt++;
               }
            }
         }
      }
   }
   cout << cnt << endl;
      
   return 0;
}



Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a < b){
		cout << "a < b"<<endl;
	}
	if (a > b) {
		cout << "a > b" << endl;
	}
	if (a == b){
		cout << "a == b" << endl;
	}
	return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=3.141592654;
int main()
{
    double a,b,h,m;cin>>a>>b>>h>>m;
    double t=fabs(m*6-(h*30+m/2));
    if(t>=180) t=360-t;
    if(t==180) t-=180;
    if(t==0)
    {
        if(m*6==(h*30+m/2))
        {
            printf("%.20f",abs(a-b));
        }
        else
            printf("%.20f",a+b);
        return 0;
    }
    t*=pi/180;
    printf("%.20f",sqrt(a*a+b*b-2*a*b*cos(t)));
    return 0;
}




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

int a[101][2];
int main(){
	int n,m;
	int t=1;
	while(cin>>n>>m&&(n|m)){
		memset(a,0,sizeof(a));
		int cur=0;
		int nxt=1;
		a[0][cur]=n;
		for(int i=0;;i++){
			if(a[m][cur]){
				cout<<"Case "<<t<<": "<<i<<endl;
				break;
			}
			for(int j=0;j<m;j++){
				int b=a[j][cur];
				a[j][cur]=0;
				a[j+1][nxt]+=b/2;
				a[0][nxt]+=b/2;
				a[j][nxt]+=b%2;
			}
			swap(cur,nxt);
		}
		t++;
	}

	return 0;
}

Measured memory_bytes: 0
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] a = Console.ReadLine().ToCharArray();
            if(Char.IsUpper(a[0]))
            {
                Console.WriteLine("A");
            }else{
                System.Console.WriteLine("a");
            }

            
        }
    }
}


Measured memory_bytes: 25760
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

const LL mod = 1e9 + 7;

int main() {
  LL n, k;
  cin >> n >> k;
  vector<LL> a(n);
  rep(i, n) cin >> a[i];

  LL ans = 0;
  rep(i, n) {
    LL right = 0, left = 0;
    for (int j = i - 1; j >= 0; j --) {
      if (a[j] < a[i]) left ++;
    }
    for (int j = i + 1; j < n; j ++) {
      if (a[i] > a[j]) right ++;
    }
    LL t = (k * k) % mod;
    LL rl = (right + left) % mod;
    LL x = (((k * (k - 1) / 2) % mod)) % mod;
    LL y = (((k * (k + 1) / 2) % mod)) % mod;
    // ans += (((t * rl) % mod - (right * y) % mod) % mod - (left * x) % mod) % mod;
    ans += (((right * y) % mod) + ((left * x) % mod)) % mod;
    ans %= mod;
  }
  cout << ans << endl;
}


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

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

  vector<int> a(n + 1), b(n);
  for (int i = 0; i < n + 1; i++) {
    cin >> a[i];
  }

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

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    int cnt = min(a[i], b[i]);

    ans += cnt;
    a[i] -= cnt;
    b[i] -= cnt;

    int nxt = min(a[i + 1], b[i]);
    ans += nxt;
    a[i + 1] -= nxt;
  }
  cout << ans << '\n';
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    for (int i = 0; i < 100000; i++)
    {
        if ((int)(double(i) * 0.08) == a && (int)(double(i) * 0.1) == b)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,k,q;
  cin >> n >> k >> q;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  int ans=IINF;
  for(int i=0;i<n;i++){
    priority_queue<int,vector<int>,function<bool(int,int)>>
      thp([](const int &a, const int &b){return a>b;});
    priority_queue<int,vector<int>,function<bool(int,int)>>
      heap([](const int &a, const int &b){return a>b;});
    for(int j=0;j<n;j++){
      if(a[j]>=a[i]){
        heap.push(a[j]);
      }else{
        while(heap.size()>=k){
          thp.push(heap.top());
          heap.pop();
        }
        while(!heap.empty()) heap.pop();
      }
    }
    while(heap.size()>=k){
      thp.push(heap.top());
      heap.pop();
    }
    int tmp;
    for(int k=0;k<q;k++){
      if(thp.empty()) goto next;
      tmp=thp.top();
      thp.pop();
    }
    tmp-=a[i];
    ans=min(ans,tmp);
    next:;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
while True:
    n, x = map(int,input().split())
    if n==0 and x==0:
        break
    else:
        count=0
        for i in range(1, n-1): #range(a,b), i = a, a+1, a+2... b-1
            for j in range(i+1,n):
                for k in range(j+1,n+1):
                    if i + j + k == x:
                        count=count+1
        print(count)
                        


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

int main()
{
    int N, H;
    cin >> N;
    
    for(int i = 0; i < N; i++){
        string S;
        cin >> S;
        if(S == "Y"){
            H++; 
        }
    }
    if(H > 0){
        cout << "Four" << endl;
    }
    else if(H == 0){
        cout << "Three" << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int a,b,h,m;cin >> a >> b >> h >> m;
	double angleH = 30*h + 0.5*m;
	double angleM = 6.0*m;
	double diff = angleH-angleM;
	if(diff < 0.0) diff = -diff;
	if(diff > 180.0) diff = 360.0-diff;
	double rad = PI*diff/180.0;
	double dist = (a*1.0*a)+(b*1.0*b)-(2.0*a*b*cos(rad));
	cout << fixed << setprecision(15) << sqrt(dist) << '\n';
}


Measured memory_bytes: 4172
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
using namespace std;
typedef pair<long long,long long>p;
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
vector<long long> divisor(long long n) {
	vector< long long> ret;
	for (long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return (ret);
}
long long mod = 1e9 + 7;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int judge1 = 0, judge2 = 0;
	if ((s[0] == '0'&&s[1]!='0') || (s[0] == '1' && (s[1] == '0' || s[1] == '1' || s[1] == '2')))judge1 = 1;
	if ((s[2] == '0'&&s[3]!='0') || (s[2] == '1' && (s[3] == '0' || s[3] == '1' || s[3] == '2')))judge2 = 1;
	if (judge1 == 0 && judge2 == 0)cout << "NA";
	if (judge1 == 0 && judge2 == 1)cout << "YYMM";
	if (judge1 == 1 && judge2 == 0)cout << "MMYY";
	if (judge1 == 1 && judge2 == 1)cout << "AMBIGUOUS";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int e1,e2,e3,e4;
	scanf("%d %d %d %d",&e1,&e2,&e3,&e4);
	if(e1==e2&&e3==e4||e1==e3&&e2==e4||e1==e4&&e2==e3){
		printf("yes\n");
	}
	else
		printf("no\n");
	return 0;
}


Measured memory_bytes: 2044
/*May The Force Be With Me*/
#include <bits/stdc++.h>
#include <stdio.h>
#include <ctype.h>
#pragma GCC optimize ("Ofast")
#define ll long long
#define MOD 1000000007
#define endl "\n"
#define vll vector<long long>
#define mll map<long long,long long>
#define pll pair<long long, long long>
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define pb push_back
#define f first
#define s second
#define inf 1e18l
#define size_1d 10000000
#define size_2d 1000
#define rep(i,v,n) for(ll i = v; i < n; i++)
//Snippets: delta, sieve, fastexp, dfs, bfs, dijkstra, floodfill

using namespace std;

ll n;

void Input() {
	cin >> n;
}

void Solve() {
	vll a(n), b(n, 0);
	for (ll i = 0; i < n; i++) cin >> a[i];
	b[0] = a[0];
	for (ll i = 1; i < n; i++) b[i] = a[i] + b[i - 1];
	ll dp[n][n]; // min cost of combining interval i,j into one cell
	for (ll i = 0; i < n; i++)for (ll j = 0 ; j < n; j++)dp[i][j] = inf;
	for (ll i = n - 1; i >= 0; i--)for (ll j = i; j < n; j++) {
			if (i == j)dp[i][j] = 0;
			else {
				for (ll k = i; k < j; k++)
					dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + b[j] - ((!i) ? 0 : b[i - 1]));
			}
		}
	cout << dp[0][n - 1];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll T = 1;
	//cin >> T;
	//ll t = 1;
	while (T--) {
		Input();
		//cout << "Case " << t << ": ";
		Solve();
		//t++;
	}
	return 0;
}

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

int main() {
  int k;
  cin >> k;
  vector<ll> a;
  
  for (int i = 1; i <= 9; ++i) a.push_back(i);
  while (1) {
    if (k <= a.size()) {
      cout << a[k - 1] << endl;
      return 0;
    }
    k -= a.size();
    vector<ll> old;
    swap(old, a);
    for (ll x : old) {
      for (int i = -1; i <= 1; ++i) {
        int d = x%10 + i;
        if (d < 0 || d > 9) continue;
        ll nx = x*10 + d;
        a.push_back(nx);
      }
    }
  }
  return 0;
}
    
    


Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k, i;
	char c[250];
	scanf("%d", &k);
	scanf("%s", c);
	n = strlen(c);
	if(k >= n){
		for(i=0; i<n; i++){
		   printf("%c", c[i]);
	    }
	}
	else{
		for(i=0; i<k; i++){
		    printf("%c", c[i]);
	    }
	    printf("...");
	}
	return 0;                                                 
}

Measured memory_bytes: 3712
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s, t;
    cin >> n >> s >> t;
    rep(i, 0, n) cout << s[i] << t[i];
    cout << endl;
}

Measured memory_bytes: 3592
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	alice := 0
	bob := 0
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			alice += a[i]
			continue
		}
		bob += a[i]
	}
	fmt.Println(alice - bob)
}


Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <cmath>

using namespace std;

void a_remaining_time(void) {
	int a, b;
	cin >> a >> b;

	cout << (a + b) % 24 << endl;
}

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

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
# define MOD 1000000000+7
# define INF 1e9
# define LINF 1e18
typedef long long ll;
 
using namespace std;
int gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
 
int a[100001] = {}, b[100001] = {}, c[100001] = {};
int dp[100010][4] = {};

 
int main() {
 
	int n = 0;

	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}

	dp[1][1] = a[1];
	dp[1][2] = b[1];
	dp[1][3] = c[1];

	for (int i = 2; i <= n; i++) {

		dp[i][1] = max(dp[i - 1][2],dp[i - 1][3]) + a[i];

		dp[i][2] = max(dp[i - 1][1], dp[i - 1][3]) + b[i];

		dp[i][3] = max(dp[i - 1][1], dp[i - 1][2]) + c[i];

	}

	cout << max({ dp[n][1],dp[n][2],dp[n][3] }) << endl;



}

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

int x,y,z,a,b,c,n,s,ans[1111],dp1[1000],dp2[1000],M[1000][1000];

signed main(){
  cin>>x>>y>>z>>a>>b>>c>>n;
  r(i,x)dp1[abs(a-i)%n]++;
  r(i,n)r(j,n){
    M[i][j]=(j-i+n)%n;
  }
  r(i,y){
    int Y=abs(b-i)%n;
    r(j,n)dp2[j]+=dp1[M[Y][j]];
  }
  r(i,z){
    int Z=abs(c-i)%n;
    r(j,n)ans[j]+=dp2[M[Z][j]];
  }
  r(i,n)cout<<(i?" ":"")<<ans[i];
  cout<<endl;
}


Measured memory_bytes: 10912
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct Po{ll x,y;}a[110];
int ansn,n;
map<pair<ll,ll>,int> s;
int main(){
	cin>>n;
	for (int i=1;i<=n;i++)cin>>a[i].x>>a[i].y;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if (i!=j)s[make_pair(a[i].x-a[j].x,a[i].y-a[j].y)]++;
	for (auto i:s)ansn=max(ansn,i.second);
	cout<<n-ansn<<endl;
	return 0;
}


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

#define int long long 

signed main() {

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

  int n;
  cin >> n;

  vector<int> a(n);
  map<int, int> m;

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ans += m[i - a[i]];
    m[a[i] + i]++;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 27368
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {

		Scanner sc = new Scanner(System.in);

		int dir[][] = { { 0, -1 }, { 0, 1 }, { 1, 0 } };

		while (true) {
			final int w = sc.nextInt();
			final int h = sc.nextInt();

			if (w == 0 && h == 0) {
				break;
			}

			final int amount = sc.nextInt();
			final int capacity = sc.nextInt();
			final int init = sc.nextInt();

			int[][] map = new int[h][w];

			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					map[i][j] = sc.nextInt();
				}
			}

			PriorityQueue<Walk> queue = new PriorityQueue<Walk>();
			for (int i = 0; i < w; i++) {
				boolean[][] b = new boolean[h][w];
				Walk walk = new Walk(0, init, 0, i, b);
				walk.sanso--;
				queue.add(walk);
			}

			boolean flag = false;
			while (!queue.isEmpty()) {
				Walk walk = queue.poll();
				int y = walk.y;
				int x = walk.x;

				if (walk.sanso <= 0) {
					continue;
				} else if (walk.y >= h) {
					flag = true;
					System.out.println(walk.cost);
					break;
				}

				walk.visited[y][x] = true;

				if (map[y][x] <= 0) {
					walk.cost += (-map[y][x]);
				} else {
					walk.sanso = Math.min(map[y][x] + walk.sanso, capacity);
				}

				if (walk.cost > amount) {
					continue;
				}

				for (int i = 0; i < 3; i++) {
					int ny = y + dir[i][0];
					int nx = x + dir[i][1];
					if (nx >= 0 && nx < w && ny >= 0 && ny <= h - 1
							&& !walk.visited[ny][nx]) {
						boolean[][] nb = new boolean[h][w];
						for(int j = 0;j<h;j++){
							nb[j] = Arrays.copyOf(walk.visited[j], w);
						}
						Walk wa = new Walk(walk.cost, walk.sanso-1, ny, nx, nb);
						queue.add(wa);
					} else if (i == 2 && walk.y == h - 1) {
						Walk wa = new Walk(walk);
						wa.y++;
						queue.add(wa);
					}
				}
			}

			if (!flag) {
				System.out.println("NA");
			}

		}
	}
}

class Walk implements Comparable<Walk> {
	int cost;
	int sanso;
	int x, y;
	boolean[][] visited;

	public Walk(int cost, int sanso, int y, int x, boolean[][] visited) {
		super();
		this.cost = cost;
		this.sanso = sanso;
		this.x = x;
		this.y = y;
		this.visited = visited;
	}

	public Walk(Walk w) {
		this.cost = w.cost;
		this.sanso = w.sanso;
		this.x = w.x;
		this.y = w.y;
		visited = new boolean[w.visited.length][w.visited[0].length];
		for (int i = 0; i < w.visited.length; i++) {
			visited[i] = Arrays.copyOf(w.visited[i], w.visited[0].length);
		}
	}

	@Override
	public int compareTo(Walk arg0) {
		return this.cost - arg0.cost;
	}
}

Measured memory_bytes: 75108
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int a, b, count, t = 0;;

    for(;;){
      a = sc.nextInt(); b = sc.nextInt();
      if(a == 0 && b == 0)break;
      if(t++ != 0)out.println();
      for(count = 0;a <= b;a++)if(isleapyear(a)){
        out.println(a); count++;
      }
      if(count == 0)out.println("NA");
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static boolean isleapyear(int a){
    if(a % 400 == 0)return true;
    if(a % 100 == 0)return false;
    if(a % 4 == 0)return true;
    return false;
  }
}

Measured memory_bytes: 20724
#include<stdio.h>
int main(void)
{
    int n,z,i,a;
	z=0;
	a=1;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	   z=z+a;	   
	   a++;
	}
	printf("%d\n",z);
	return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	string 	str, s;
	cin >> str;
	s = str;
	sort(s.begin(), s.end());
	int t = s.length()/2, ans = 0;
	for(int i=0;i<s.length(); ++i){
		if(str[i] != s[i])ans++;	
	}	
	cout << ans/2;
}


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

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

    if( n < 600){
        cout << 8 << endl;
    }else if ( n < 800){
        cout << 7 << endl;
    }else if ( n < 1000){
        cout << 6 << endl;
    }else if ( n < 1200){
        cout << 5 << endl;
    }else if ( n < 1400){
        cout << 4 << endl;
    }else if ( n < 1600){
        cout << 3 << endl;
    }else if ( n < 1800){
        cout << 2 << endl;
    }else if ( n < 2000){
        cout << 1 << endl;
    }

}

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

typedef long long ll;

ll N,K;
ll a[100010];

//正負混合
ll b[100010];
//正のみ
ll c[100010];

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



  for(int i=1;i<=N;i++)cin>>a[i];

  b[1]=a[1];
  for(int i=2;i<=N;i++){
    b[i]=a[i]+b[i-1];
  }

  if(a[1]>0)c[1]=a[1];
  for(int i=2;i<=N;i++){
    if(a[i]>0)c[i]=a[i]+c[i-1];
    else c[i]=c[i-1];
  }

  ll ans=-1;



  for(int i=1;i<=N-K+1;i++){
    ans=max(ans,(b[K-1+i]-b[i-1])+c[i-1]+(c[N]-c[K-1+i]));
    ans=max(ans,c[i-1]+(c[N]-c[K-1+i]));
  }
  if(ans==-1)cout<<0<<endl;
  else
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    double m;
    cin>>n>>m;
    vector<int> v(n,0);
    rep(i,n) cin>>v[i];
    int sum=0;
    rep(i,n) sum+=v[i];
    int cnt=0;
    for(int i=0;i<n;i++){
        if(v[i]>=sum/(4*m)){
            cnt++;
        }
    }
    if(cnt>=m){
                cout<<"Yes"<<endl;
                return 0;
            }
    else cout<<"No"<<endl;
    return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  char b[H+2][W+2];
  
  for(int i = 0;i < H+2;i++) {
    for(int j = 0;j < W+2;j++){
      if(i==0 or j==0 or i==H+1 or j==W+1) 
        b[i][j]='#';
      else cin >> b[i][j];
      cout << b[i][j];
    }
    cout << endl;
  }
  return 0;
}

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

const ll MOD=1000000007;

int main(){
    ll A,B,N;
    cin>>A>>B>>N;
    ll X=min(N,B-1);
    cout<<(A*X/B)<<endl;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 998244353LL
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    for (auto p : v) cout << p << ",";
    cout << "]";
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os, const set<T> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int N;
int A[200000];
int B[200000];

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> N;
    rep(i, N) cin >> A[i], B[i] = A[i];

    sort(B, B+N, greater<int>());
    rep(i, N) cout << (A[i]==B[0]?B[1]:B[0]) << endl;
}

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

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  string s; cin >> s;
  int n=s.size();
  sort(all(s));
  s.erase(unique(all(s)),s.end());
  cout<<(n==s.size()?"yes":"no")<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int N,Alice=0,Bob=0;
  int i;
  cin>>N;
  vector<int> A(N);
  for(i=0;i<N;++i)cin>>A.at(i);
  sort(A.begin(),A.end());
  for(i=1;i<=N;++i){
    if(i%2==1)Alice+=A.at(N-i);
    if(i%2==0)Bob+=A.at(N-i);
  }
  cout<<Alice-Bob<<endl;
}

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

int main(){
  int n,m,x,a,i;
  cin>>n>>m>>x;
  fr(i,m){
    cin>>a;
    if(a>x){i--;break;}
  }
  cout<<min(i+1,m-i-1)<<endl;
}

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

using namespace std;

int main()
{
    while(true)
    {
        char raw_even[300]={};
        char raw_odd[300]={};
        int h, w;    

        scanf("%d %d", &h, &w);
        if(h == 0 && w == 0) break;
        else if(h == 0 || w == 0) { cout << "\n"; continue; };
        for(int i=0; i<w; i++)
        {
            raw_even[i] = (i%2==0) ? '#' : '.';
            raw_odd[i]  = (i%2==0) ?  '.' : '#';
        }
        for(int j=0; j<h; j++)
        {
            if(j%2==0) printf("%s\n", raw_even);
            else       printf("%s\n", raw_odd);
        }
        cout << "\n";
    }
}


Measured memory_bytes: 3124
from collections import defaultdict
mod = 10 ** 9 + 7

N, X = map(int, input().split())
S = list(map(int, input().split()))
S.sort()

dp = defaultdict(int)
dp[X] = 1

for i in reversed(range(N)):
    a = S[i]
    newDP = defaultdict(int)
    for key, val in dp.items():
        newDP[key] += val * i
        newDP[key] %= mod
        newDP[key % a] += val
        newDP[key % a] %= mod
    dp = newDP

ans = 0
for k, v in dp.items():
    ans = (ans + k * v) % mod
print(ans)

Measured memory_bytes: 5524
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

int solve() {
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    ll now = a[0];
    rep(i, n) now = __gcd(now, a[i]);
    if(now > 1) return 3;
//    if(n > 10000) return 2;
    map<ll, ll> mp;
    rep(i, n) {
        ll b = a[i];
        for(ll j = 2; j*j <= a[i]; ++j) {
            if(b == 1) break;
            if(b % j == 0) {
                if(mp[j] > 0) return 2;
                ++mp[j];
            }
            while(b % j == 0) b /= j;
        }
        if(b > 1) {
            if(mp[b] > 0) return 2;
            ++mp[b];
        }
    }
    return 1;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int ans = solve();
    if(ans == 1) cout << "pairwise coprime" << endl;
    else if(ans == 2) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}

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

int main()
{
    std::string s;
    std::cin >> s;

    bool ans = false;
    std::string first_s;
    for (int i = 0; i < s.length(); i++)
    {
        std::string tgt_s = {s[i]};
        if (i == 0)
            first_s = tgt_s;
        if (i > 0)
        {
            if (tgt_s == first_s)
                continue;
            else
            {
                ans = true;
                break;
            }
        }

    }

    if (ans == true)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rint register int
#define mem(a,b) memset(a,(b),sizeof(a))
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define For(i,j,k) for(Rint i=(j);i<=(k);i++)
#define Fordown(i,j,k) for(Rint i=(j);i>=(k);i--)

using namespace std;
typedef long long LL;

template<typename T>inline void read(T &x){
	x=0;T w=1,ch=getchar();
	while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
	x=x*w;
}

const int N=2e5+10;
int n,m;
int e,beg[N],nex[N<<1],to[N<<1];
bool s[N],vis[N<<1],Vis[N<<1],w[N<<1];
char ch;

inline void add(int x,int y,int z){
	to[++e]=y;
	nex[e]=beg[x];
	beg[x]=e;
	w[e]=z;
}
inline void dfs(int id,int x){
	for(Rint i=beg[x];i;i=nex[i])if(w[i]!=w[id]){
		if(!vis[i]){
			Vis[i]=vis[i]=1;
			dfs(i,to[i]);
			vis[i]=0;
		}
		else printf("Yes\n"),exit(0);
	}
}

int main(){
	read(n);read(m);
	For(i,1,n){
		do ch=getchar();while(ch!='A'&&ch!='B');
		s[i]=(ch=='A'?1:0);
	}
	For(i,1,m){
		int x,y;read(x);read(y);
		add(x,y,s[x]==s[y]);add(y,x,s[x]==s[y]);
	}
	For(i,1,m<<1)if(!Vis[i])dfs(i,to[i]);
	printf("No\n");
	return 0;
}

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

using namespace std;
int main()
{
	int H, W ;
	string a[102];
	cin >> H >> W;
	a[0] =a[H+1]= string(W, '#');
	
	for (int i=1; i <H+1; i++){
		cin>> a[i];
	}
	for (int i=0; i < H + 2; i++){
		cout <<'#'<< a[i]<<'#' << endl;
	}

	return 0;
}

Measured memory_bytes: 256