akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
int n;
string s;
int main(){	
//	freopen("a.gir","r",stdin);
// 	freopen("a.cik","w",stdout);
	scanf("%d",&n);
	cin>>s;
	if(n%2==1){
		printf("No\n");
		return 0;
	}
	for(int i=0,j=n/2;j<n;i++,j++){
		if(s[i]!=s[j]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
}

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

using namespace std;

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> xs(N), ys(M);
  for (int i = 0; i < N; i++) cin >> xs[i];
  for (int i = 0; i < M; i++) cin >> ys[i];
  int xs_max = *max_element(xs.begin(), xs.end());
  int ys_min = *min_element(ys.begin(), ys.end());

  if (xs_max >= ys_min) {
    cout << "War";
  } else if (xs_max < Y && X < ys_min) {
    cout << "No War";
  } else {
    cout << "War";
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    vector<vector<ll>> doub(62, vector<ll>(n, 0));
    for (ll i = 0; i < n; i++)
    {
        cin >> doub[0][i];
        doub[0][i]--;
    }
    for (ll i = 0; i < 61; i++)
    {
        for (ll j = 0; j < n; j++)
        {
            doub[i + 1][j] = doub[i][doub[i][j]];
        }
    }
    ll now = 0;
    for (ll i = 0; i < 62; i++)
    {
        if ((k >> i) & 1)
        {
            now = doub[i][now];
        }
    }
    cout << now + 1 << endl;
}

Measured memory_bytes: 101664
#include <stdio.h>
int main(void)
{
  int n,m,sum=0;
  scanf("%d",&n);
  m=n;
  while(m>0)
  {
    sum+=m%10;
    m=m/10;
  }
  if(n%sum==0)
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        ll n;
        cin >> n;
        ll abc[n][3];
        rep(i, n) {
            rep(j, 3)cin >> abc[i][j];
        }

        ll dp[n + 1][3];
        rep(i, n + 1) rep(j, 3) dp[i][j] = 0;
        rep(i, n) {
            rep(j, 3) {
                rep(k, 3) {
                    if (j == k) continue;
                    dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + abc[i][j]);
                }
            }
        }
        ll ans = 0;
        rep(i, 3) ans = max(dp[n][i], ans);
        cout << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 4992
def main():
    N = int(input())
    h = list(map(int, input().split()))

    dp = [0] * N
    dp[1] = abs(h[0] - h[1])
    for i in range(2, N):
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))

    print(dp[-1])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 20616
//Awwawa! Dis cold yis ratten buy tEMMIE!
#include <bits/stdc++.h>
#define ll long long
#define maxn 305 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
int dp[maxn][maxn][maxn]; //当前编号 前缀和  不动个数 
int k;
char inp[maxn];
int ex[maxn];
int um[maxn], cnt = 0; 
int sum[maxn];
int s1[maxn][maxn][maxn], s2[maxn][maxn][maxn];
int main() {
	scanf("%s", inp + 1);
	cin >> k;
	int l = strlen(inp + 1);
	int s = 0;
	int tot = 0;
	for (int i = 1; i <= l; i++)
		if (inp[i] == '0')
			um[++cnt] = tot, tot = 0;
		else tot++;
	um[++cnt] = tot;
	for (int i = 1; i <= cnt; i++) 
		s += um[i], 
		sum[i] = sum[i - 1] + um[i];
	for (int i = cnt + 1; i >= 1; i--) { 
		for (int m = s; m >= sum[i - 1]; m--)
			for (int u = m; u >= 0; u--) {
				if (i == cnt + 1) {
					if (s - u <= k) dp[i][m][u] = 1;
					else dp[i][m][u] = 0;
				}
				else {
					dp[i][m][u] = s2[i + 1][min(s + 1, m + um[i] + 1)][u + um[i]];
					dp[i][m][u] = (dp[i][m][u] + s1[i + 1][m][m - u] - 
												 s1[i + 1][min(s + 1, m + um[i] + 1)][m - u]) % mod;
					if (dp[i][m][u] < 0) dp[i][m][u] += mod;
				}
				s2[i][m][u] = (s2[i][m + 1][u] + dp[i][m][u]) % mod;
			}
		
		for (int dv = 0; dv <= s; dv++)
			for (int u = s; u >= dv; u--)
				s1[i][u][dv] = (s1[i][u + 1][dv] + dp[i][u][u - dv]) % mod;
		
	} 
	cout << dp[1][0][0] << endl;
	return 0;
}


Measured memory_bytes: 85108
#include <string.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define REP1(i,n) for(int i=1;i<=(n);++i)

#define SORT(V) sort((V).begin(), (V).end())

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

string S;

int main() {
  cin >> S;
  int l = S.size();
  LL sum = 0;
  REP(i, 1 << (l-1)) {
    LL n = 0;
    cerr << "-\n";
    REP(j, l - 1) {
      if ((i & (1 << j)) != 0) {
        sum += n * 10 + (S[j] - '0');
        cerr << n * 10 + (S[j] - '0') << endl;
        n = 0;
      } else {
        n = n * 10 + (S[j] - '0');
      }
    }
    cerr << n * 10 + (S[l - 1] - '0') << endl;
    sum += n * 10 + (S[l - 1] - '0');
  }
  cout << sum << endl;
}


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

using namespace std;

using ll = long long;

struct State {
    int at;
    ll cost;
    int prev;
    State(int at, ll cost, int prev) : at(at), cost(cost), prev(prev) {}
    bool operator>(const State& s) const {
        if (cost != s.cost) return cost > s.cost;
        if (prev != s.prev) return prev > s.prev; //最短経路を辞書順最小にする(省略可)
        return at > s.at;
    }
};

struct Edge {
    int to;
    ll cost;
    Edge(int to, ll cost) : to(to), cost(cost) {}
};

typedef vector<vector<Edge> > AdjList; //隣接リスト

const ll INF = 1000000000000000LL;
const int NONE = -1;

//sは始点、mincは最短経路のコスト、Prevは最短経路をたどる際の前の頂点
void dijkstra(int s, vector<ll>& minc, AdjList& graph){
    priority_queue<State, vector<State>, greater<State> > pq;
    pq.push(State(s, 0, NONE));
    while(!pq.empty()) {
        State cur = pq.top();
        pq.pop();
        if (minc[cur.at] <= cur.cost) continue;
        minc[cur.at] = cur.cost;
        for(Edge e : graph[cur.at]) {
            ll cost = cur.cost + e.cost;
            if (minc[e.to] <= cost) continue;
            pq.push(State(e.to, cost, cur.at));
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;
    AdjList g1(n), g2(n);
    for (int i = 0; i < m; i++) {
        int u, v;
        ll a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        g1[u].emplace_back(v, a);
        g1[v].emplace_back(u, a);
        g2[u].emplace_back(v, b);
        g2[v].emplace_back(u, b);
    }

    vector<ll> minc1(n, INF), minc2(n, INF);
    dijkstra(s, minc1, g1);
    dijkstra(t, minc2, g2);

    vector<ll> ans(n, INF);
    for (int i = n - 1; i >= 0; i--) {
        ans[i] = min(ans[i], minc1[i] + minc2[i]);
        if (i < n - 1) ans[i] = min(ans[i], ans[i + 1]);
    }

    for (int i = 0; i < n; i++) {
        cout << INF - ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 19024
#include <bits/stdc++.h>
 
using namespace std;
 
#define fastio          std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PAUSE_EXE       assert(false)
#define MAX             500001
#define MAX2            500001
#define SIZE            500001
#define MOD             1000000007LL
#define REP(i,n)        for(__typeof(n) i=0; i<n; ++i)
#define CREP(i,n)       for(__typeof(n) i=n-1; i>=0; --i)
#define MYREP(i,a,b)    for(__typeof(a) i=a; i<=b; ++i)
#define MYCREP(i,a,b)   for(__typeof(a) i=b; i>=a; --i)
#define sz(a)           int((a).size())
#define pb              push_back
#define mp              make_pair
#define fi              first
#define sec             second
#define all(c)          (c).begin(),(c).end()
#define allr(c)         (c).rbegin(),(c).rend()
#define loop(c,i)       for(typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define loopr(c,i)      for(typeof(c.end()) i = c.end(); i != c.begin(); )
 
int bucket_size;
vector<int> num(MAX), freq(SIZE);
vector<int> ans(MAX2);
 
struct query
{
    int ind, l, r;
}q[MAX2];
 
bool cmp(query a, query b)
{
    int ax = a.l/bucket_size;
    int bx = b.l/bucket_size;
    if (ax != bx)
        return ax < bx;
    return a.r < b.r;
}
 
int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    MYREP(i, 1, n)
        scanf("%d", &num[i]);
    REP(i, m)
    {
        // inPos(q[i].l) , inPos(q[i].r);
        scanf("%d %d", &q[i].l, &q[i].r);
        q[i].ind = i;
    }
    bucket_size = ceil(sqrt(n));
    sort(q, q+m, cmp);
    int start, end;
    int sum;
    start = end = 0;
    sum = 0;
    REP(i, m)
    {
        while (start < q[i].l)
        {
            --freq[num[start]];
            if (freq[num[start]] == 0)
                sum--;
            ++start;
        }
        while (end > q[i].r)
        {
            --freq[num[end]];
            if (freq[num[end]] == 0)
                sum--;
            --end;
        }
 
        while (start > q[i].l)
        {
            --start;
            ++freq[num[start]];
            if (freq[num[start]] == 1)
                sum++;
        }
        while (end < q[i].r)
        {
            ++end;
            ++freq[num[end]];
            if (freq[num[end]] == 1)
                sum++;
        }
 
        ans[q[i].ind] = sum;
    }
    REP(i, m)
        printf("%d\n", ans[i]);
    return 0;
}


Measured memory_bytes: 15420
def get_input():
  lst = []
  pair = [int(n) for n in input().split(" ")]
  while pair != [0, 0]:
    lst.append(pair)
    pair = [int(n) for n in input().split(" ")]
  return lst

def to_str(lst):
  return [str(n) for n in lst]

lst = get_input()
for pair in lst:
  print(' '.join(to_str(sorted(pair))))

Measured memory_bytes: 7008
import copy

# 約数列挙
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 2
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] + [n]

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


n = int(input())
if n == 2:
    print(1)
    exit()

div1 = make_divisors(n-1)
cnt = len(div1)

div2 = make_divisors(n)


for i in div2:
    x = copy.deepcopy(n)
    while x >= i:
        if x % i == 0:
            x //= i
        else:
            break
    if x == 1 or x % i == 1:
        cnt += 1

print(cnt)

Measured memory_bytes: 74884
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

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

ll calcCombination(int n, int m){
	int i, j;
	ll ans = 1;
	for (i = 0; i < m; i++){
		ans *= n - m + i + 1;
		ans /= i + 1;
	}
	return ans;
}

int main(){
	int N, A, B;
	vll V;
	int i, j, k;
	cin >> N >> A >> B;
	for (i = 0; i < N; i++){
		ll v;
		cin >> v;
		V.push_back(v);
	}
	sort(V.begin(), V.end());
	ll max_sum = 0;
	for (i = 0; i < A; i++){
		max_sum += V[N - i - 1];
	}
	double max_ave = double(max_sum) / double(A);
	int count = 0;
	int count_s = 0;
	for (i = 0; i < N; i++){
		if (V[i] == V[N - A]){
			count++;
			if (i >= N - A){
				count_s++;
			}
		}
	}
	if (count_s < A){
		ll ans = calcCombination(count, count_s);
		cout << fixed << setprecision(8) << max_ave << endl;
		cout << ans << endl;
	}
	else{
		ll ans = 0;
		int from = A;
		int to = min(B, count);
		for (i = from; i <= to; i++){
			ll ans_tmp = calcCombination(count, i);
			ans += ans_tmp;
		}
		cout << fixed << setprecision(8) << max_ave << endl;
		cout << ans << endl;
	}
}

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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  vector<int> v;
  for(int i = 2; i <= 55555; i++) {
    int f = 1;
    for(int e : v) {
      if(i % e == 0) { f = 0; break; }
    }
    if(f) v.emplace_back(i);
  }
  cerr << v.size() << endl;
  int n; cin >> n;
  for(int el : v) {
    if(el % 5 == 1) {
      cout << el;
      n--;
      if(n == 0) return (cout << endl, 0);
      cout << " ";
    }
  }
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define s(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;
int main() {
	int ans = 700;
	string s;
	cin >> s;
	rep(i, 3) {
		if (s[i] == 'o')ans += 100;
	}
	cout << ans << endl;
	return 0;
}
	



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

int main(){
  int n,k;
  cin >> n >> k;
  int l[n];
  for(int i=0;i<n;i++)
    cin >> l[i];

  //sort
  int t;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      if(l[i] < l[j]){
        t = l[i];
        l[i] = l[j];
        l[j] = t;
      }
    }
  }

  //calc
  int sum=0;
  for(int i=0;i<k;i++)
    sum += l[i];
  cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 256
import sys
import numba
from numba import jit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@jit
def main(n):
  wa = 0
  for i in n:
    wa += int(i)
  if wa%9 == 0:
    return 'Yes'
  else:
    return 'No'

n= readline().split()
print(main(n))


Measured memory_bytes: 110000
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,k,a[MAXN],b[MAXN],c[MAXN],sum;
int main()
{
    scanf("%lld",&n);
    sum=0;
    for(ll i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        sum+=a[i];
    }
    for(ll i=1;i<=n;i++)
    {
        scanf("%lld",&b[i]);
        sum-=b[i];
    }
    if(sum<0)
    {
        puts("-1");
        return 0;
    }
    sum=0;
    vector<P> v;
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        if(a[i]<b[i])
        {
            sum+=b[i]-a[i];
            ans++;
        }
        else
        {
            v.push_back(P(a[i]-b[i],i));
        }
    }
    sort(v.begin(),v.end(),greater<P>());
    for(ll i=0;i<(int)v.size();i++)
    {
        if(sum==0) break;
        ll cc=min(sum,v[i].F);
        sum-=cc; ans++;
    }
    assert(sum==0);
    printf("%lld\n",ans);
    return 0;
}



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define MP make_pair
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define fst first
#define snd second

string b[32];
int H, W, n;

bool can_clear(int h, int w) {
  int cnt_h = 1;
  int hi = h+1;
  while (hi < H && b[hi][w] == b[h][w]) hi++, cnt_h++;
  hi = h-1;
  while (0 <= hi && b[hi][w] == b[h][w]) hi--, cnt_h++;
  if (cnt_h >= n) return true;

  int cnt_w = 1;
  int wi = w+1;
  while (wi < W && b[h][wi] == b[h][w]) wi++, cnt_w++;
  wi = w-1;
  while (0 <= wi && b[h][wi] == b[h][w]) wi--, cnt_w++;

  return cnt_w >= n;
}

void drop() {
  for (int j = W-1; j >= 0; j--) {
    for (int i = H-1, bottom = H-1; i >= 0; i--) {
      if (b[i][j] != '.') {
	swap(b[i][j], b[bottom][j]);
	bottom--;
      }
    }
  }
}

bool can_all_clear() {
  drop();  
  bool do_clear[32][32];
  bool flag = true;
  while (flag) {
    flag = false;
    REP(i, H) REP(j, W)
      do_clear[i][j] = b[i][j] != '.' && can_clear(i, j);
    REP(i, H) REP(j, W) {
      if (do_clear[i][j]) {
	b[i][j] = '.';
	flag = true;
      }
    }
    drop();
  }
  REP(i, H) REP(j, W) {
    if (b[i][j] != '.') return false;
  }
  return true;
}

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

  cin >> H >> W >> n;
  string board[32];
  REP(i, H) cin >> board[i];

  REP(i, H) b[i] = board[i];
  if (can_all_clear()) {
    cout << "YES" << endl;
    return 0;
  }

  REP(i, H) REP(j, W-1) {
    if (board[i][j] == '.' && board[i][j+1] == '.') continue;
    REP(l, H) b[l] = board[l];
    swap(b[i][j], b[i][j+1]);
    if (can_all_clear()) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 1212
/*
 *  Author :: Kattu37
 */

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortallr(x) sort(allr(x))
#define PI 3.1415926535897932384626
#define mod 1000000007

typedef pair<int, int>  pii;
typedef pair<ll, ll>  pll;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pll>   vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;

void solve()
{
	int n;
	cin >> n;

	vector<ll> count(n + 1, 1);
	count[0] = 0;

	for (ll i = 2; i <= n; i++)
	{
		for (int j = i; j <= n; j += i)
			count[j]++;
	}
	ll sum = 0;
	for (int i = 1; i <= n; i++)
	{
		//cout << count[i] << " ";
		sum += i * count[i];
	}

	cout << sum << "\n";
}

int main(void)
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}

	return 0;
}


Measured memory_bytes: 81344
#include<bits/stdc++.h>
using namespace std;
int l,n,i;
string a[105];
int main()
{
    cin>>l>>n;
    for(i=0;i<l;i++)
    {
    	cin>>a[i];
	}	
    sort(a,a+l); 
    for(i=0;i<l;i++)
        cout<<a[i];
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative

main :: IO ()
main = do 
    [a, b] <- map read . words <$> getLine
    putStrLn $ solve a b 

solve :: Int -> Int -> String
solve x y = if (1 <= x && x <= 9) && (1 <= y && y <= 9)
            then show (x * y)
            else "-1"

Measured memory_bytes: 508
from functools import reduce


def resolve():
    while (True):
        n = int(input())
        if n == 0:
            break
        ss = list(map(int, input().split()))

        m = sum(ss) / n
        a2 = reduce(lambda x, y: x + (y - m) ** 2, ss, 0)
        print((a2 / n) ** 0.5)


resolve()



Measured memory_bytes: 6336
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = Number(input[0][0]);

  let AC = 0;
  let WA = 0;
  let TLE = 0;
  let RE = 0;

  for (let i = 1; i <= N; i++) {
    const S = input[i][0];

    switch (S) {
      case "AC": {
        AC += 1;
        break;
      }
      case "WA": {
        WA += 1;
        break;
      }
      case "TLE": {
        TLE += 1;
        break;
      }
      case "RE": {
        RE += 1;
        break;
      }
    }
  }

  return [`AC x ${AC}`, `WA x ${WA}`, `TLE x ${TLE}`, `RE x ${RE}`].join("\n");
};

console.log(main(read()));


Measured memory_bytes: 49316
n, k = [int(i) for i in input().split()]

array = [None for i in range(n)]

for i in range(n):
    array[i] = [int(i) for i in input().split()]

# print(array)
#
# print(sorted(array))

sa = sorted(array)

# print(sa)

cnt = 0

for i in range(n):
    cnt += sa[i][1]
    if cnt >= k:
        print(sa[i][0])
        break


Measured memory_bytes: 22428
n = gets.to_i
t = gets.chomp.split(" ").map(&:to_i)
m = gets.to_i
p = m.times.map{gets.chomp.split(" ").map(&:to_i)}
sum = t.inject(:+)
for i in 0..m-1
  puts sum - t[p[i][0] - 1] + p[i][1]
end

Measured memory_bytes: 1788
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Long h = sc.nextLong();
        Long w = sc.nextLong();
        if (h == 1 || w ==1) {
            System.out.println(1);
        } else {
            long res = h * (w/2);
            if (w % 2 == 1) {
                res += (h+1)/2;
            }
            System.out.println(res);
        }
    }
}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// ?????????????????\????????????
		Scanner sc = new Scanner(System.in);

		// ??\???????????°????????\???????????°input
		int input = sc.nextInt();

		// ?????????????????°
		int cnt = 1;

		// ??°?????????????????????
		while (cnt <= input) {

			// 1?????????3?????´??°??¨???3????????°?????????
			if (cnt % 10 == 3 || cnt % 3 == 0) {

				System.out.print(" " + cnt);

				// 10????????\?????§3???????????´??°?????????????????????
			} else {

				// ?????????????????°???String????????????
				String s_cnt = Integer.toString(cnt);

				// 3???????????´??°?????????
				if (s_cnt.contains("3")) {

					System.out.print(" " + cnt);

				} else {
					// ????????????
				}
			}

			// ?????????????????°????¢????
			cnt++;

		}
		// ????????????????????????
		System.out.println();
		sc.close();
	}
}

Measured memory_bytes: 29328
object Main{
  def main(args: Array[String])= {
val arr = io.StdIn.readLine().split(' ')
    val m = arr(0).toInt
    val d = arr(1).toInt

    var count = 0

    (3 to m).foreach{
      mi =>
        (2 to d).foreach{
          di =>
            val d1 = di % 10
            val d10 = if(di < 10) 0 else (di - d1) / 10

            if(mi == d1 * d10 && d1 >=2 && d10 >= 2) {
              count += 1
            }
        }
    }

    println(count)
  }
}

Measured memory_bytes: 25524
import Control.Applicative
import Control.Monad

isThree :: Int -> Bool
isThree a 
    | a `mod` 3 == 0 = True
    | '3' `elem` (show a) = True
    | otherwise = False

main = do 
    num <- getLine
    putStr " "
    putStrLn $ unwords . (map show) $ filter isThree [1..(read num)]


Measured memory_bytes: 4132
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

int main()
{
	INT n, m;
	cin >> n >> m;

	vector<INT> a;
	for (size_t i = 0; i < m; i++)
	{
		INT tmp;
		cin >> tmp;
		a.push_back(tmp);
	}

	if (n >= m)
	{
		cout << 0 << endl;
		return 0;
	}

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

	vector<INT> l;

	for (size_t i = 0; i < a.size() - 1; i++)
	{
		l.push_back(a[i + 1] - a[i]);
	}
	sort(l.begin(), l.end());

	for (size_t i = 0; i < (n - 1); i++)
	{
		l.pop_back();
	}

	cout << accumulate(l.begin(), l.end(), 0) << endl;

	return 0;
}


Measured memory_bytes: 2548
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
 
void trace(int A[],int N){
int i;
for(i=0;i<N;i++){
if(i>0)printf(" ");
printf("%d",A[i]);
}
printf("\n");
}
 
void insertionSort(int A[],int N){
int j,i,v;
for(i=1;i<N;i++){
v=A[i];
j=i-1;
while(j>=0&&A[j]>v){
A[j+1]=A[j];
j--;
}
A[j+1]=v;
trace(A,N);
}
}
 
int main(){
int N,i,j;
int A[100];
 
scanf("%d",&N);
for(i=0;i<N;i++)scanf("%d",&A[i]);
 
trace(A,N);
insertionSort(A,N);
 
return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    ll tmp = 0;
    for (ll i = 0; i < (ll)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T x, T y){
    if (x == 0 || y == 0) {
        return 0;
    }

    while (x != y){
        if (x > y) {
            x -= y;
        }else{
            y -= x;
        }
    }
    return x;
}

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    ll n;
    cin >> n;



    string s="";
    ll i=0;

    if (n == 0) {
        s = "0";
    }

    while(n != 0){
        s = to_string(n & 1) + s;
        n -= (n & 1);
        n /= -2;
        i++;
    }

    cout << s << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


// map の key, value を全て抜き出す。
// for (auto itr = mp.begin(); itr != mp.end(); itr++) {
//     cout << "key" << itr->first << " value" << itr->second << endl;
// }

// 文字列の検索
// string s="abc";
// if (s.find('d') == string::npos){
//     cout << "find" << endl;
// }else{
//     cout << "not find" << endl;
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
vector<ll> v;
vector<string> vs;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
map<ll, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	int w, a, b;
	cin >> w >> a >> b;
	int ans = abs(a - b) - w;
	cout << (ans <= 0 ? 0 : ans) << endl;
}

Measured memory_bytes: 256
N = int(input())
A1 = [j for j in map(int, input().split())]
A2 = [j for j in map(int, input().split())]

tot_lis = []

for j in range(N):
    tot_lis.append(sum(A1[:j+1]) + sum(A2[j:]))

print(max(tot_lis))

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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a'){
    cout << "vowel" << endl;
  }
  else if (c == 'e'){
    cout << "vowel" << endl;
  }
  else if (c == 'i'){
    cout << "vowel" << endl;
  }
  else if (c == 'o'){
    cout << "vowel" << endl;
  }
  else if (c == 'u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

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

#define int long long
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    int ans = 0;
    for(int i = 0; i < k; i++) {
        ans += a[i];
    }
    cout << ans << endl;

    return 0;
}


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

ll dp[3005][3005];

int main(){
    string s,t;
    cin >> s >> t;
    ll n,m;
    n=s.size();
    m=t.size();
    for(ll i=0;i<=n;i++) dp[i][0]=0;
    for(ll j=0;j<=m;j++) dp[0][j]=0;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            if(s[i]==t[j]) dp[i+1][j+1]=dp[i][j]+1;
            else dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
        }
    }
    ll res=dp[n][m];
    string ans="";
    while(n>0&&m>0){
        if(s[n-1]==t[m-1]){
            ans=s[n-1]+ans;
            n--;
            m--;
        }else if(dp[n][m]==dp[n-1][m]){
            n--;
        }else{
            m--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 74168
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF 1e9+7
#define LLINF 1e18
// #define int ll
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int a=0,b=0,c=0;
    rep(i,s.size()){
        if(s[i]=='a') a++;
        else if(s[i]=='b') b++;
        else c++;
    }
    bool can=0;
    if(a==b && b==c) can=1;
    else{
        if(a<=b && a<=c){
            if(b==a+1 && c==b) can=1;
            else if(a==b && c==a+1) can=1;
            else if(a==0 && a==c && b==1) can=1;
            else if(a==c && b==a+1) can=1;
        }
        else if(b<=a && b<=c){
            if(a==c && a==b+1) can=1;
            else if(a==b+1 && b==c) can=1;
        }
        else if(a==b && a==c+1) can=1;
    }
    if(can) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=1e5+20;

struct node {
	int v,next,w;ll cost;
};
node e[maxn<<1];
int cnt=1,start[maxn];
inline void addedge(int u,int v,int w,ll cost){ e[++cnt]=(node){v,start[u],w,cost};start[u]=cnt;}
inline void Addedge(int u,int v,int w,ll cost){ addedge(u,v,w,cost); addedge(v,u,0,-cost);}

int n;
ll rx[maxn],ry[maxn],rc[maxn];
ll bx[maxn],by[maxn],bc[maxn];

int S,T,tot;
int Sn,Tn;
int MID[5],num1[maxn],num2[maxn];

//1:-,-
//2:+,+
//3:-,+
//4:+,-

inline void init()
{
	n=read();
	Sn=++tot; Tn=++tot;
	REP(i,1,4)MID[i]=++tot;
	REP(i,1,n)
	{
		rx[i]=read(); ry[i]=read(); rc[i]=read();
		num1[i]=++tot;
		Addedge(Sn,num1[i],rc[i],0);
		REP(j,1,4)
		{
			int res=0;
			if(j==1 || j==3)res-=rx[i]; else res+=rx[i];
			if(j==1 || j==4)res-=ry[i]; else res+=ry[i];
			res=-res;
			Addedge(num1[i],MID[j],rc[i],res);
		}
	}
	REP(i,1,n)
	{
		bx[i]=read(); by[i]=read(); bc[i]=read();
		num2[i]=++tot;
		Addedge(num2[i],Tn,bc[i],0);
		REP(j,1,4)
		{
			int res=0;
			if(j==1 || j==3)res-=bx[i]; else res+=bx[i];
			if(j==1 || j==4)res-=by[i]; else res+=by[i];
			Addedge(MID[j],num2[i],bc[i],res);
		}
	}
}

inline ll min_cost(int _S,int _T)
{
	ll ans=0;
	S=_S; T=_T;
	static ll dist[maxn];
	static int vis[maxn],pre[maxn];
	queue<int>q;
	while(1)
	{
		REP(i,1,tot)dist[i]=1ll<<60,vis[i]=0,pre[i]=0;
		q.push(S); dist[S]=0;
		while(!q.empty())
		{
			int u=q.front();q.pop();vis[u]=0;
			EREP(i,u)
			{
				int v=e[i].v;
				if(dist[v]>dist[u]+e[i].cost && e[i].w)
				{
					dist[v]=dist[u]+e[i].cost;
					pre[v]=i;
					if(!vis[v])vis[v]=1,q.push(v);
				}
			}
		}
		if(dist[T]==(1ll<<60))break;
		int flow=0x3f3f3f3f;
		for(int i=pre[T];i;i=pre[e[i^1].v])chkmin(flow,e[i].w);
		for(int i=pre[T];i;i=pre[e[i^1].v])e[i].w-=flow,e[i^1].w+=flow;
		ans+=1ll*dist[T]*flow;
	}
	return ans;
}

inline void doing()
{
	printf("%lld\n",-min_cost(Sn,Tn));
}

int main()
{
	init();
	doing();
	return 0;
}


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


int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int x, y;
    cin >> x >> y;

    int ans = INT_MAX;

    for (int z = (x+y)*2; z >= 0; z--) {
        int _x = max(0, x-z/2);
        int _y = max(0, y-z/2);
        ans = min(ans, _x*a+_y*b+z*c);
    }

    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

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

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

struct Point {
    double x;
    double y;
};

double r = M_PI * 60.0 / 180.0;

void koch(int d, Point p1, Point p2) {
    if (d == 0) return;

    // calculate s, t
    Point s, t;
    s.x = (p2.x - p1.x)/3 + p1.x;
    s.y = (p2.y - p1.y)/3 + p1.y;
    t.x = ((p2.x - p1.x)/3)*2 + p1.x;
    t.y = ((p2.y - p1.y)/3)*2 + p1.y;

    Point u;
    u.x = (t.x - s.x) * cos(r) - (t.y - s.y) * sin(r) + s.x;
    u.y = (t.x - s.x) * sin(r) + (t.y - s.y) * cos(r) + s.y;

    koch(d-1, p1, s);
    cout << s.x << " " << s.y << endl;
    koch(d-1, s, u);
    cout << u.x << " " << u.y << endl;
    koch(d-1, u, t);
    cout << t.x << " " << t.y << endl;
    koch(d-1, t, p2);
}

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

    Point start, end;
    start.x = 0.00000;
    start.y = 0.00000;
    end.x = 100.00000;
    end.y = 0.00000;

    cout << start.x << " " << start.y << endl;
    koch(n, start, end);
    cout << end.x << " " << end.y << endl;

    return 0;
}



Measured memory_bytes: 3412
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
use std::cmp::{max, min};
#[fastout]
fn main() {
    input! {
        s: Chars
    }
    let mut ans = s.len() - 1;
    for i in b'a'..=b'z' {
        let u = check(s.clone(), i as char);
        ans = min(u, ans);
    }
    println!("{}", ans);
}
fn check(s: Vec<char>, c: char) -> usize {
    let mut a = 0;
    let mut pre = 0;
    for i in 0..s.len() {
        if s[i] == c {
            a = max(a, pre);
            pre = 0;
        } else {
            pre += 1;
        }
    }
    max(a, pre)
}


Measured memory_bytes: 2160
import math,fractions
a=list(map(int,input().split()))
A=a[1]-a[0]+1
B=a[1]//a[2]-(a[0]-1)//a[2]
C=a[1]//a[3]-(a[0]-1)//a[3]
d=a[2]*a[3]//fractions.gcd(a[2],a[3])
D=a[1]//d-(a[0]-1)//d
print(A-B-C+D)

Measured memory_bytes: 5040
x,y=map(int,input().split())
a=(2*y-x)/3
b=(2*x-y)/3
mod=10**9+7
if a==int(a) and b==int(b) and a>=0 and b>=0:
  def mul(x,y):
    return ((x%mod)*(y%mod))%mod
  
  def power(x,y):
    if y==0:
      return 1
    elif y==1:
      return x%mod
    elif y%2==0:
      return power(x,y//2)**2%mod
    else:
      return power(x,y//2)**2*x%mod
    
  def div(x,y):
    return mul(x,power(y,mod-2))
  
  p=1
  for i in range(int(a+1),int(a+b+1)):
    p=mul(p,i)
  q=1
  for i in range(1,int(b+1)):
    q=mul(q,i)
  print(div(p,q))
else:
  print(0)

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

int main() {
	int n; cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	vector<int> res;
	for (int i = 0; i < n; i+=2)
	{
		res.push_back(a[i]);
	}
	reverse(res.begin(), res.end());
	for (int i = 1; i < n; i+=2)
	{
		res.push_back(a[i]);
	}

	if(n % 2 == 0) reverse(res.begin(), res.end());
	for (int i = 0; i < n; i++)
	{
		cout << res[i];
		if(i == n-1) cout << endl;
		else cout << " ";
	}

	return 0;
}


Measured memory_bytes: 3828
//
//  main.cpp
//  Colorful Slimes
//
//  Created by 王博浩 on 2019/8/12.
//  Copyright © 2019 王博浩. All rights reserved.
//

#include <iostream>
#include <algorithm>
using namespace std;
//const ll llf=(1ll<<63)-1;
typedef long long ll;
const ll llf=(1ll<<63)-1;
ll dp[2010][2010];ll a[2010];
int main()
{
    ll n,x;
    cin>>n>>x;
    int i;
    for(i=1;i<=n;i++)
        cin>>a[i];
    int k;
    for(i=1;i<=n;i++)
        dp[i][0]=a[i];
    for(k=1;k<n;k++)
    {
        for(i=1;i<=n;i++)
        {
            int temp=i-k;
            if(temp<=0) temp+=n;
            dp[i][k]=min(dp[i][k-1],(ll)a[temp]);
        }
    }
    ll sum=0;ll ans=llf;
    for(i=0;i<n;i++)
    {
        sum=0;
        for(int j=1;j<=n;j++)
            sum+=dp[j][i];
        sum+=i*x;
        ans=min(ans, sum);
    }
    cout<<ans<<endl;
    return 0;
}


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


int main(){
    int n;
    cin >> n;
    long long sum=0;
    vector<int> v(n);
    for(int i=0;i<n-1;i++)cin >> v[i];
    sum+=v[0] + v[n-2];
    for(int i=0;i<n-2;i++){
    	sum+=min(v[i],v[i+1]);
    	
    }
    cout << sum;
}

Measured memory_bytes: 256
var
	N,K,i,p,q,x,tmp,get:Longint;
	ans,now,make:double;
begin
	read(N,K);
	if N>=K then begin
		ans:=(N-K+1)/N;
		q:=K-1;
	end
	else q:=N;
	make:=1;
	get:=1;
	for i:=1 to 1 do begin
		if q=0 then break;
		get:=get*2;
		make:=make*0.5;
		p:=K div get;
		if p<q then begin;
			ans:=ans+(q-p)/N*make;
			q:=p;
		end;
	end;
	for i:=q downto 1 do begin
		tmp:=(K+i-1)div i;
		x:=1;
		now:=1/N;
		while tmp>x do begin
			now:=now*0.5;
			x:=x*2;
		end;
		ans:=ans+now;
	end;
	writeln(ans:0:9);
end.

Measured memory_bytes: 128
#-------------------------------------------------------------------------------
# Name:        module6
# Purpose:
#
# Author:      user
#
# Created:     12/04/2020
# Copyright:   (c) user 2020
# Licence:     <your licence>
#-------------------------------------------------------------------------------
from math import gcd



def main():
    k = int(input())
    total = 0

    for a in range(1,k+1):
        for b in range(1,k+1):
            for c in range(1,k+1):
                total += gcd(gcd(a,b),c)
    print(total)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<string> s(N);
    int base = 0;
    REP(i,N) {
        cin >> s[i];
        REP(j,s[i].length()-1){
            if(s[i][j] == 'A' && s[i][j+1] == 'B'){
                base++;
            }
        }
    }
    dump(base)
    int cnta = 0;
    int cntb = 0;
    int cntc = 0;

    REP(i,N){
        int len = s[i].length();
        if(s[i][0] == 'B' && s[i][len-1] == 'A') cnta++;
        else if(s[i][0] == 'B') cntb++;
        else if(s[i][len-1] == 'A') cntc++;
    }

    int ans = 0;
    if(cnta == 0){
        cout << base + min(cntb,cntc) << endl;
        return 0;
    }

    if(cntb != 0 && cntc != 0){
        ans += cnta+1;
        cntb--; cntc--;
        ans += min(cntb,cntc);
        cout << ans+ base << endl;
    }
    else if(cntb == 0 && cntc != 0){
        ans += cnta;
        cout << ans +base << endl;
    }
    else if(cntb != 0 && cntc == 0){
        ans += cnta;
        cout << ans + base << endl;
    }
    else if(cntb == 0 && cntc == 0 && cnta >= 2){
        cout << ans + cnta-1 + base << endl;
    }


}

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    string s;
    cin >> s;
    int n = s.size();
    stack<int> st;
    rep(i,n){
        if(st.size() && st.top() != s[i]){
            st.pop();
        }else{
            st.push(s[i]);
        }
    }
    cout << n- st.size() << endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)


int main(){
    int a,b;
    cin >> a >> b;
    if (a <= b) cout << a << endl;
    else cout << a-1 << endl;

   return 0;

}

Measured memory_bytes: 256
while 1:
    n,k = [int(i) for i in input().split()]
    if not (n and k):
        break
    a = [int(input()) for i in range(n)]
    b = [0]*len(a)

    for i in range(n):
        b[i] = b[i-1] + a[i]
    b = b + [0]

    c = [b[i + k - 1] - b[i - 1] for i in range(n - k + 1)]

    print(max(c))


Measured memory_bytes: 15432
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> n1(n),n2(n);
  for(int i=0;i<n;i++)cin>>n1[i];
  for(int i=0;i<n;i++)cin>>n2[i];
  vector<int> test;
  for(int i=1;i<=n;i++)test.push_back(i);
  int c1=-1,c2=-1,c3=0;
  while(1){
    if(c1==-1 and test==n1)c1=c3;
    if(c2==-1 and test==n2)c2=c3;
    c3++;
    next_permutation(test.begin(),test.end());
    if(c1!=-1 and c2!=-1)break;
  }
  cout<<abs(c1-c2)<<endl;
}


Measured memory_bytes: 256
def input_int():
    return int(input())


def input_int_tuple():
    return map(int, input().split())


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


N, K, Q = input_int_tuple()
A = []
for i in range(Q):
    A.append(input_int())

points = [0] * (N+1)

for a in A:
    points[a] += 1

for point in points[1:]:
    if K - (Q - point) > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 82444
function main (input) {
  const A = parseInt(input.split(' ')[0],10);
  const B = parseInt(input.split(' ')[1],10);
  const X = parseInt(input.split(' ')[2],10);

  if (X > A+B) {
    console.log('NO');
  } else if (A > X) {
    console.log('NO');
  } else {
    console.log('YES');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<stdio.h>
int F[45];


void fibonacci(int n)
{
  int i;
  for(i=0;i<=n;i++)
    F[i]=0;
  F[0]=1;
  F[1]=1;
  for(i=2;i<=n;i++)
    {
      F[i]=F[i-2]+F[i-1];
    }
}




int main()
{
  int n;
  scanf("%d",&n);
  fibonacci(n);
  printf("%d\n",F[n]);
  
  return 0;
}



Measured memory_bytes: 2104
#include <stdio.h> 
 int main(){ 
    int a, b; 
    char op; 
    while(1){ 
        scanf("%d %c %d", &a, &op, &b); 
        if(op=='?'){ 
            break; 
    	}else 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); 
        } 
    } 
    return 0; 
 } 



Measured memory_bytes: 2048
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

# 個数制限なしナップサック問題
N,W = map(int,input().split())

dp = [0 for j in range(W+1)]

for i in range(N):
    v,w = map(int,input().split())
    # dp[j] = 重さj以下でつくれる最大の価値
    for j in range(W+1):
        # jがwより小さいとき、wは選べない
        if j >= w:
            dp[j] = max(dp[j],dp[j-w] + v)

print(dp[W])



Measured memory_bytes: 5988
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<=b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;



int main(){
    INIT; 
    int N, X; cin >> N >> X;
    V<int> l;
    REP(i,N) {
        int x; cin >> x; 
        l.push_back(x);
    }
    int d = 0;
    int ans = 1;
    REP(i,N) {
        d += l[i];
        if(d <= X) ans++;
    }
    cout << ans;
}


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

int main()
{
    int n,x,i;
    cin>>n;
    vector<int> v;
    vector<int> dp(n);
    for(i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    dp[0]=0;
    dp[1]=abs(v[0]-v[1]);
    for(i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(v[i-1]-v[i]),dp[i-2]+abs(v[i-2]-v[i]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1276