akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX_N 200001
using namespace std;
using Graph = vector<vector<int>>;
using Map = map<int, int>;
vector<bool> seen;
Map M;
int64_t CNT[MAX_N];
void dfs(const Graph &G, int v, int plus) {
    seen[v] = true;
    CNT[v] = plus + M[v];
    for (auto next_v : G[v]) {
      if (seen[next_v])
        continue;
      dfs(G, next_v, CNT[v]);
    }
}

int main(void) {
  int N, Q;
  cin >> N >> Q;
  Graph G(N + 1);
  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  rep(i, Q) {
    int p, x;
    cin >> p >> x;
    M[p] += x;
  }

  seen.assign(N+1, false);
  dfs(G, 1, 0);

  rep(i, N) { cout << CNT[i+1] << " "; }
  cout << endl;
  return 0;
}


Measured memory_bytes: 43008
#!/usr/bin/env ruby

# 手のリストを読み込んで、勝ち負けリストを返す
def solve(list)
    # 最初の要素=グーの数
    # 二番目の要素=チョキの数
    # 三番目の要素=パーの数
    number_list = [0,0,0]
    # 手を読みこんで、number_listを更新
    for t in list
        number_list[t] += 1
    end
    # 一番少ない手が1以上ある = すべての手は1以上ある
    #  -> あいこ
    if number_list.min > 0
        # あいこのときは全員引き分け
        return [3,3,3,3,3]
    end
    # 一番多い手が5人いる = 5人とも同じ手を出した
    #  -> あいこ
    if number_list.max == 5
        return [3,3,3,3,3]
    end

    # ここまできたってことは、すくなくともあいこではない。
    #  -> 手は二種類しかいない。 
    #
    # 勝った手をwinと置く。
    win = 0
    # グーとチョキがいる -> グーがかち
    if number_list[0] > 0 and number_list[1] > 0
        win = 0
    end
    # チョキとパーがいる -> チョキのかち
    if number_list[1] > 0 and number_list[2] > 0
        win = 1
    end
    # パーとグーがいる -> パーのかち
    if number_list[2] > 0 and number_list[0] > 0
        win = 2
    end

    win_lose_list = [0,0,0,0,0]
    # 手リストを読んで、その手が勝ちの手だったら、
    # win_lose_listの対応する値は1(=勝ち)
    # ちがったら、2(=負け)
    for i in 0..4
        # i番目の人が出した手
        t = list[i]
        # 勝った手だったら、勝ち、そうでないなら負け
        if t == win
            win_lose_list[i] = 1
        else
            win_lose_list[i] = 2
        end
    end
    return win_lose_list
end

def main
    # 0がくるまで無限ループ
    while true
        # 手のリスト
        list = []
        # 5行ずつで読みこむ
        for i in 0..4
            line = gets
            num = line.to_i
            # もし、0があったら、main関数を終了。
            if num == 0
                return
            end
            # 手リストに追加
            # グー=1,チョキ=2,パー=3だけど、
            # グー=0,チョキ=1,パー=2に定義しなおす。
            # なんでかっていうと、後で配列の添字に使いたいから。
            list.push(num-1)
        end
        # この時点で手リストは長さ5の配列
        # 勝ち負けリストを取得
        win_lose_list = solve(list)
        # 中身を出力
        for k in win_lose_list
            p k
        end
    end
end

if __FILE__ == $0
    main
end

Measured memory_bytes: 6128
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=305;
int col[2][2*MAXN][2*MAXN],n,D1,D2;
vector<pii> fac[2];
bool in(int x,int y){return x>=0&&x<2*n&&y>=0&&y<2*n;}
void DFS(int x,int y,int o)
{
	for(auto p:fac[o])for(int u=-1;u<=1;u++)if(u)for(int v=-1;v<=1;v++)if(v)
		if(in(x+u*p.first,y+v*p.second))
		{
			int ux=x+u*p.first,uy=y+v*p.second;
			if(col[o][ux][uy]!=-1)continue;
			col[o][ux][uy]=col[o][x][y]^1;DFS(ux,uy,o);
		}
}
void color(int o)
{
	memset(col[o],-1,sizeof(col[o]));
	for(int i=0;i<2*n;i++)for(int j=0;j<2*n;j++)if(col[o][i][j]==-1)
		col[o][i][j]=0,DFS(i,j,o);
}
int sqr(int x){return x*x;}
int dis(pii u,pii v){return sqr(u.first-v.first)+sqr(u.second-v.second);}
vector<pii> ans[2][2];
int main()
{
	n=read();D1=read();D2=read();
	for(int i=0;i*i<=D1;i++)if(floor(sqrt(D1-i*i))==ceil(sqrt(D1-i*i)))fac[0].emplace_back(mp(i,sqrt(D1-i*i)));
	for(int i=0;i*i<=D2;i++)if(floor(sqrt(D2-i*i))==ceil(sqrt(D2-i*i)))fac[1].emplace_back(mp(i,sqrt(D2-i*i)));
	color(0);color(1);
	for(int i=0;i<2*n;i++)for(int j=0;j<2*n;j++)
		ans[col[0][i][j]][col[1][i][j]].emplace_back(mp(i,j));
	for(int i=0;i<=1;i++)for(int j=0;j<=1;j++)if(SZ(ans[i][j])>=n*n)
	{
//		for(auto p:ans[i][j])for(auto q:ans[i][j])
//			assert(dis(p,q)!=D1&&dis(p,q)!=D2);
		int cnt=0;
		for(auto p:ans[i][j])
		{
			pr1(p.first),pr2(p.second);
			++cnt;if(cnt==n*n)break;
		}
		return 0;
	}
	return 0;
}


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

using namespace std;

#define int long long

const int inf = 0x3f3f3f3f3f3f3f3f;
const int N = 100000;

int n, m, s;
int a[N + 1];
int dp[N + 1];
int q[N], head, tail;

#undef int
signed main() {
#define int long long
  cin >> n >> m >> s;
  for (int i = 1; i <= n; i++) cin >> a[i];
  q[tail++] = 0;
  int now = -1, mn = inf;
  for (int i = 1; i <= n; i++) {
    while (now + 1 < i && 2 * a[now + 2] < 2 * a[i] - s)
      now++, mn = min(mn, dp[now] - a[now] - 2 * a[now + 1]);
    while (head < tail && q[head] <= now) head++;
    while (head < tail &&
           dp[q[tail - 1]] - a[q[tail - 1]] >= dp[i - 1] - a[i - 1])
      tail--;
    q[tail++] = i - 1;
    dp[i] = min(dp[q[head]] - a[q[head]] + a[i] + s, mn + 3 * a[i]);
  }
  cout << dp[n] + m - a[n] << "\n";
#undef int
  return 0;
}


Measured memory_bytes: 2560
using System;

class Program
{
    static void Main(string[] args)
    {
        var abx = Console.ReadLine().Split(' ');
        var a = int.Parse(abx[0]);
        var b = int.Parse(abx[1]);
        var c = int.Parse(abx[2]);

        if (a <= c && c <= a + b)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <vector>
 
using namespace std;
 
int main() {
  long long n;
  cin >> n;
 
  long long a, b;
  cin >> a >> b;
 
  vector<long long> x(n + 1);
 
  for (int i = 1; i <= n; i++)
    cin >> x[i];
  
  long long sum = 0;
 
  for (int i = 1; i < n; i++) {
    int dis = x[i + 1] - x[i];
    if (dis * a < b)
      sum += dis * a;
    else
      sum += b;
  }
 
  cout << sum << "\n";
 
  return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    ll ret = 1 + k;
    if (b > a + 2) {
        ll temp = a;
        k -= (a - 1);
        if (k > 1) {
            temp += (b - a) * (k / 2);
            if (k % 2 == 1)
                temp++;
            chmax(ret, temp);
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	static class Pair {
		int l, r;
		char c;

		Pair(int l, int r, char c) {
			this.l = l;
			this.r = r;
			this.c = c;
		}

		int getLen() {
			return r - l + 1;
		}
	}

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int K = Integer.parseInt(tokens[1]);
		char[] str = in.readLine().toCharArray();
		Deque<Pair> que = new ArrayDeque<>();
		que.add(new Pair(0, 0, str[0]));
		for (int i = 1; i < str.length; ++i) {
			Pair last = que.getLast();
			if (last.c == str[i]) {
				que.getLast().r = i;
			} else {
				que.addLast(new Pair(i, i, str[i]));
			}
		}

		// 配列化
		Pair[] pairs = que.toArray(new Pair[0]);
		if (pairs.length <= 2 * K) {
			// 全部反転可能
			System.out.println(N - 1);
			return;
		}
		// 反転によって連続が最大になる範囲を求める
		int min = -1, max = -1, size = -1;
		for (int i = 0; i < pairs.length; ++i) {
			int toIndex = i + 2 * K;
			if (toIndex >= pairs.length) {
				toIndex = (((pairs.length - 1) - i) / 2) * 2;
			}
			int s = pairs[toIndex].r - pairs[i].l + 1;
			if (s > size) {
				size = s;
				min = pairs[i].l;
				max = pairs[toIndex].r;
			}
		}
		int min2 = -1, max2 = -1, size2 = -1;
		for (int i = 1; i < pairs.length; ++i) {
			int toIndex = i + 2 * K;
			if (toIndex >= pairs.length) {
				toIndex = (((pairs.length - 1) - i) / 2) * 2;
			}
			int s = pairs[toIndex].r - pairs[i].l + 1;
			if (s > size2) {
				size2 = s;
				min2 = pairs[i].l;
				max2 = pairs[toIndex].r;
			}
		}
		if (size2 > size) {
			size = size2;
			max = max2;
			min = min2;
		}
		// 反転処理
		Arrays.fill(str, min, max + 1, str[min]);

		// うれしい人を数える
		int count = 0;
		if (str.length >= 2) {
			if (str[0] == 'R') {
				if (str[0] == str[1]) {
					++count;
				}
			}
			if (str[N - 1] == 'L') {
				if (str[N - 1] == str[N - 2]) {
					++count;
				}
			}
			for (int i = 1; i < N - 1; ++i) {
				int target = -1;
				if (str[i] == 'R') {
					target = i + 1;
				} else
					target = i - 1;
				if (str[i] == str[target]) {
					++count;
				}
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 26068
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int X,Y;

signed main(){
	cin>>X>>Y;
	for(int i=0;i<=X;i++){
		int j=X-i;
		if(j>=0&&2*i+4*j==Y){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int n, m, q;
vector<int> a, b, c, d;
vector<int> v;

int dfs(int p = 0) {
  if (p == n) {
	int res = 0;
	rep (i, q) if (v[b[i] - 1] - v[a[i] - 1] == c[i]) res += d[i];

	return res;
  }
  
  int res = 0;
  rep (i, m) {
	if (v.size() != 0 && v.back() > i + 1) continue;
	v.push_back(i + 1);
	res = max(res, dfs(p + 1));
	v.pop_back();
  }

  return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	cin >> n >> m >> q;
	a.resize(q), b.resize(q), c.resize(q), d.resize(q);
	rep (i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
	cout << dfs() << endl;
    
    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
#define MAX 100001

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}

int main(){
  int n,i, A[MAX];

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1){
      printf("parent key = %d, ",A[parent(i)]);
    }
   if(left(i)<=n){
      printf("left key = %d, ",A[left(i)]);
    }
    if(right(i)<=n){
      printf("right key = %d, ",A[right(i)]);
    }
    printf("\n");
  }
return 0;
}

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

int main(){
  int n; cin>>n;
  int d[n];
  for(int i = 0; i<n; i++)cin>>d[i];
  long long sum = 0;
  for(int i = 0; i<n; i++){
    for(int j = i+1; j<n; j++) sum+=d[i]*d[j];
  }
  cout<<sum;
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  string s[8];
  REP(i,8)
    cin >> s[i];
  REP(k,3) {
    cout << 90*(k+1) << endl;
    REP(y,8) {
      REP(x,8) {
        if (k==0)
          cout << s[7-x][y];
        else if (k==1)
          cout << s[7-y][7-x];
        else
          cout << s[x][7-y];
      }
    cout << endl;
    }
  }
}

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

unsigned long long n,m,a[100009],ll[100008];
bool ppap[100009];

int main() {
    // insert code here...
    cin>>n>>m;
    for (int i=0; i<m; i++) {
        cin>>a[i];
        ppap[a[i]]=true;
    }
    ll[0]=1;
    for (int i=0; i<n; i++) {
        ll[i]%=1000000007;
        if (ppap[i]==false) {
            ll[i+1]+=ll[i];
            ll[i+2]+=ll[i];
        }
    }
    cout<<ll[n]%1000000007<<endl;
}

Measured memory_bytes: 1920
<>;($x,$y)=glob,printf"%f\n",sort{$b<=>$a}0,map.159154*(-$~+($~=$_))-.5,(@b=sort{$a<=>$b}map+(/ /*atan2$'-$y,$`-$x)x!/^$x $y/,@a),"@b"+6.2832for@a=<>

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

struct StCity
{
  StCity() : m_nPref(0), m_nYear(0) { }

  int m_nPref;
  int m_nYear;
};

void fnInput(int& rnPrefSiz, vector<StCity>& rvoCity)
{
  int nCitySiz;
  cin >> rnPrefSiz >> nCitySiz;
  rvoCity.resize(nCitySiz);

  for (StCity& roCity : rvoCity)
    cin >> roCity.m_nPref >> roCity.m_nYear;
}

void fnIdNum(int nPrefSiz, const vector<StCity>& cnrvoCity)
{
  vector<vector<int>> vvnCity(nPrefSiz);

  for (int i = 0; i < cnrvoCity.size(); ++i)
    vvnCity[ cnrvoCity[i].m_nPref - 1 ].push_back( cnrvoCity[i].m_nYear );

  for (int i = 0; i < vvnCity.size(); ++i)
  {
    sort( begin(vvnCity[i]), end(vvnCity[i]) );
    vvnCity[i].erase( unique( begin(vvnCity[i]), end(vvnCity[i]) ), end(vvnCity[i]) );
  }

  for (int i = 0; i < cnrvoCity.size(); ++i)
  {
    int nPref = cnrvoCity[i].m_nPref - 1;
    cout << setfill('0') << setw(6) << nPref + 1;

    int nIdNum = lower_bound( begin( vvnCity[ nPref ] ), end( vvnCity[ nPref ] ), 
                              cnrvoCity[i].m_nYear ) - begin( vvnCity[ nPref ] );   
    cout << setfill('0') << setw(6) << nIdNum + 1 << endl;
  }
}
  
int main()
{
  int nPrefSiz;
  vector<StCity> voCity;
  
  fnInput(nPrefSiz, voCity);
  fnIdNum(nPrefSiz, voCity);

  return 0;
}

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

int main() {
  int n;
  double prob[51] = { 0.0 };
  double nprob[51] = {0.0};
  double ans[100001];
  ans[0] = 0.0;
  ans[1] = 1.0;
  ans[2] = 1.5;
  prob[0] = 1;
  nprob[0] = 0;
  for(int j=1; j<50; ++j) {
    double pos = 1.0/((double)(1<<j));
    prob[j] = prob[j-1]*pos;
    nprob[j] = (1-pos)*prob[j-1];
  }

  for(int i=3; i < 100001; ++i) {
    ans[i] = 0.0;
    for(int j=1; i-j-1>=0 && j<50; ++j) {
      ans[i] += nprob[j]*(j+ans[i-j-1]);
    }
    if(i-1 < 50)
      ans[i] += i*prob[i-1];
  }

  cout.precision(10);
  while(1) {
    cin>>n;
    if(!n) break;
    cout<<ans[n]<<endl;
  }
}

Measured memory_bytes: 0
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,p=map(int,input().split())
a=list(map(int,input().split()))

lst=[0,0]

for i in range(n):
    lst[a[i]%2]+=1
# print(lst)

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

tmp1=pow(2,lst[0])
tmp2=0
for i in range(lst[1]+1):
    if p==0 and i%2==0:
        tmp2+=comb(lst[1],i)
    elif p==1 and i%2==1:
        tmp2+=comb(lst[1],i)
print(tmp1*tmp2)
# print(tmp1,tmp2)

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

int main() {
  std::string s;
  std::cin >> s;
  int start, end;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'A') {
      start = i;
      break;
    }
  }
  for (int i = s.length() - 1; i > 0; i--) {
    if (s[i] == 'Z') {
      end = i;
      break;
    }
  }
  std::cout << end - start + 1 << "\n";
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(){
  int a,b,sum,n;

  while(scanf("%d%d",&a,&b)!=EOF){
    sum = a + b;
    n = 1;
    while(1){
      sum /= 10;
      if(sum != 0)n++;
      else {
	printf("%d\n",n);
	break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a;
    cin>>n;
    long long sum=0;
    int ma=-INT_MAX;
    for(int i=0;i<n;i++){
        cin>>a;
        sum+=a;
        if(ma<a)ma=a;
    }
    cout<<sum-ma/2<<endl;
    return 0;
}

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

    if (str == "SUN") cout << 7 << endl;
    else if (str == "MON") cout << 6 << endl;
    else if (str == "TUE") cout << 5 << endl;
    else if (str == "WED") cout << 4 << endl;
    else if (str == "THU") cout << 3 << endl;
    else if (str == "FRI") cout << 2 << endl;
    else if (str == "SAT") cout << 1 << endl;
}

Measured memory_bytes: 256
package main

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

// Scan Standard Input
var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	for {
		n, _ := strconv.Atoi(nextLine())

		if n == 0 {
			return
		}

		ss := strings.Split(nextLine(), " ")

		m := average(ss)

		s_total := 0.0
		for i := 0; i < n; i++ {
			s, _ := strconv.ParseFloat(ss[i], 64)
			s_total += (s - m) * (s - m)
		}
		x := math.Sqrt(s_total / (float64)(n))
		fmt.Printf("%.8f\n", x)
	}
}

func average(xs []string) float64 {
	total := 0.0
	for _, v := range xs {
		a, _ := strconv.ParseFloat(v, 64)
		total += a
	}
	return total / (float64)(len(xs))
}



Measured memory_bytes: 1196
#include <stdio.h>
int max(int a,int b){
	if(a<b){return b;}
	else return a;
}
int min(int c,int d){
	if(c<d){return c;}
	else return d;
}

int main(void) {
	int n,i,a[1000],Max,Min;
	Max=0;Min=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++){
		if(i==0){Max=a[i];Min=a[i];continue;}
		Max=max(Max,a[i]);
		Min=min(Min,a[i]);
	}
	printf("%d\n",(Max-Min));
	return 0;
}

Measured memory_bytes: 128
a,b,k=map(int,input().split())
s=[]
for i in range(a,a+k):
    s.append(i)
for i in range(b-k+1,b+1):
    s.append(i)
s=list(set(s))
s=sorted(s)
for i in range(len(s)):
    if a<=s[i]<=b:
        print(s[i])


Measured memory_bytes: 3064
#include <iostream>

int main(void){
  
    int A,B;;
   
    std::cin >> A >> B;

    if(A+B==3)
        std::cout << 3;
    if(A+B==4)
        std::cout << 2;
    if(A+B==5)
        std::cout << 1;
    return 0;
}


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

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    cin >>a >>b >>c;
    if(a == b && b == c){
        cout << "No" << "\n";
        return 0;
    }
    
    if(a!=b && a !=c &&b!=c){
        cout << "No" << "\n";
        return 0;
    }
    
    cout << "Yes" << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ld long double
const int maxn = 1e5 + 10 , mod = 1e9 + 7;

int n, m, x, res;
string s[1000], t[1000];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	cin >> m;
	for (int i = 0; i < m; i++)
		cin >> t[i];
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
			if (s[i] == s[j])
				x ++;
		for (int j = 0; j < m; j++)
			if (s[i] == t[j])
				x --;
		res = max (res, x);
		x = 0;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
long long p[1100000];
long long dp[1100000];
long long dp2[1100000];
long long T;
long long calc(int a,int b){
	long long ret=max(T,(p[b]-p[a+1])*2);
//	printf("%d %d: %lld\n",a,b,ret);
	return ret;
}
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	T=c;
	for(int i=0;i<a;i++)scanf("%lld",p+i+1);
	for(int i=0;i<=a;i++)dp[i]=dp2[i]=99999999999999999LL;
	dp[0]=0;
	//dp2[0]=0;
	int t=1;
 
	for(int i=1;i<=a;i++){
		while((p[i]-p[t])*2>T){
			t++;
		}
		dp[i]=min(dp[t-1]+T,dp2[t-1]+p[i]*2);
		dp2[i]=min(dp2[i-1],dp[i-1]-p[i]*2);
	//	printf("%lld %lld\n",dp[i],dp2[i]);
	}
	printf("%lld\n",dp[a]+b);
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	string a, b;
	cin >> a >> b;
	if(b.substr(0, a.size()) == a)
		cout << "Yes";
	else
		cout << "No";





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int a, b;
    cin >> a >> b;
    int ans = 0;
    int now = 1;
    while(now < b) {
        now += a-1;
        ans++;
    } 

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 384
object Main extends App {
	import scala.io.StdIn._
	import scala.math

	val N = readLine.split(" ").map(_.toInt)
	val a = (N(0) - N(1)).abs
	val b = (N(0) - N(2)).abs

	if(a < b) println("A")
	else println("B")
}

Measured memory_bytes: 25416
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans = 0;
    int num[] = {25, 10, 5, 1};
    for(int i = 0; i < 4; i++)
    {
        ans += n / num[i];
        n %= num[i];
    }
    cout << ans << endl;
    return 0;
}




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

typedef long long lint;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const lint inv = MOD - 2;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    lint n;
    cin >> n;
    vector<lint> a(n), b(n);
    rep(i, n){
        cin >> a[i];
    }
    rep(i, n){
        cin >> b[i];
    }
    lint ans = 0;
    for(lint i = 1 ; i <= (1 << 28) ; i *= 2){
        vector<lint> v(n);
        rep(j, n){
            v[j] = b[j] % (i*2);
        }
        SORT(v);
        lint cnt = 0;
        rep(j, n){
            auto it1 = lower_bound(v.begin(), v.end(), i - a[j] % (i*2));
            auto it2 = lower_bound(v.begin(), v.end(), i*2 - a[j] % (i*2));
            auto it3 = lower_bound(v.begin(), v.end(), i*3 - a[j] % (i*2));
            auto it4 = lower_bound(v.begin(), v.end(), i*4 - a[j] % (i*2));
            cnt += (it4 - it3) + (it2 - it1);
        }
        if(cnt % 2 == 1){
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> a(N);
    vector<ll> b(M);
    rep(i,N){
        cin >> a[i];
    }
    rep(i,M){
        cin >> b[i];
    }
    vector<ll> c = convolution<998244353>(a,b);
    rep(i,N + M - 1){
        cout << c[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 27232
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)

int dp[100005][3];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int> a(n),b(n),c(n);
    REP(i,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[0][0]=a[0], dp[0][1]=b[0], dp[0][2]=c[0];
    FOR(i,1,n-1){
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
    }
    int ans = max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<ans;
}


Measured memory_bytes: 2560
from math import gcd
def readinput():
    n,x=map(int,input().split())
    xx=list(map(int,input().split()))
    return n,x,xx

def main(n,x,xx):
    y=[0]*len(xx)
    for i in range(len(xx)):
        y[i] = abs(xx[i] - x)
    if len(y)==1:
        ans=y[0]
    else:
        ans=gcd(y[0],y[1])
        for i in range(2,n):
            ans=gcd(ans,y[i])
    return ans

if __name__=='__main__':
    n,x,xx=readinput()
    ans=main(n,x,xx)
    print(ans)


Measured memory_bytes: 20192
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pl;
typedef queue<ll> ql;
typedef set<ll> sl;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll &b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll &b) {if(b > a) {a = b; return 1;} return 0;}
const ll inf = 1LL << 60;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const ll max = 500010;
ll num, L, M, N, ans=0, count=0;
#define fin {cout << "No" << endl; return 0;}

int main() {
  string str;
  cin >> str;
  N = str.size();
  L = (N-1)/2;
  rep(i, N) if(str[i]!=str[N-1-i]) fin;
  rep(i, L) if(str[i]!=str[L-1-i]) fin;
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef unsigned long long ull;
typedef std::pair<int,int> P;

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};
const ull MOD = 1e9+7;

ull dp[10001];

int main(){
    int N, W;
    std::cin >> N >> W;

    int w[200], sum = 0;
    REP(i, N){
        std::cin >> w[i];
        sum += w[i];
    }

    std::sort(w, w+N, std::greater<int>());

    ull res = 0;
    if(sum <= W){res = 1;} // 全員入れる

    dp[0] = 1;

    REP(i, N){ // i番目は入れない
        sum -= w[i];

        for(int j=std::max(0,W-sum-w[i]+1);j<=W-sum;j++){
            res = (res + dp[j]) % MOD;
        }

        for(int j=W-w[i];j>=0;j--){
            if(j+w[i] <= W){
                dp[j+w[i]] = (dp[j+w[i]] + dp[j]) % MOD;
            }
        }
    }

    std::cout << res << std::endl;
}

Measured memory_bytes: 1240
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll A[100001];
	ll ans=0;
	ll minP=1;
	scan(N);
	rep(i,N){
		scan(A[i]);
		if(A[i]>minP){
			ans+=(A[i]-1)/minP;
		}
		else if(A[i]==minP){
			minP=A[i]+1;
		}
		if(i==0) minP=2;
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
    using namespace std;
    	int  main(){
        	int a,b,n,i;
        	string s;
        	cin >> a >> b >> s;
          	for(i=0;i<a+b+1;i++){
              if(s[i]=='-')
                n++;
            }
        	if(s[a] == '-' && n == 1){
             	cout << "Yes" << endl;
          	}else{
     	    	cout << "No" << endl;
         	}
       	 	return 0;
      }

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define out(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define out2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define sum(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
lint binary_search(function<bool(lint)> func) {
    lint left = -1;
    lint right =LINF-1;
    while (right - left > 1) {
        lint mid = left + (right - left) / 2;
        if (func(mid)) right = mid;
        else left = mid;
    }
    return right;
}
int main(){
    lint n,m;
    cin>>n>>m;
    cout<<binary_search([&](lint x){
        if(n>=x&&m>=x*2)return 0;
        else if(m>=x*2 && (m-x*2)/2+n>=x)return 0;
        else return 1;
    })-1;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int MAX_N = 10e5 + 1;
char s[MAX_N];

int main(){
    scanf("%s", s);

    int len = strlen(s);
    char t[len + 1], u[len];
    for(int i = 0; i < len; i++){
        if(i % 2 == 0){
            t[i] = '0';
            u[i] = '1';
        }else{
            t[i] = '1';
            u[i] = '0';
        }
    }

    int a = 0, b = 0;
    for(int i = 0; i < len; i++){
        if(s[i] != t[i]){
            a++;
        }
        if(s[i] != u[i]){
            b++;
        }
    }

    printf("%d\n", min(a, b));


    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <algorithm>


void sort_x(){
    
}

int main() {
    int n, x;
    scanf("%d %d", &n, &x);
    
    int L;
    int count=1,now=0;

    int i=0;
    while ( i < n ) {
        std::cin >> L;
        now += L;
        if (now>x){
            break;
        }
        count++;
        i++;
        
    }
    
    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 10000000000;
int main() {
	string S; cin >> S;
	int t = S.size(), cnt = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'S') cnt++;
		if (S[i] == 'T'&&cnt > 0) { t -= 2; cnt--; }
	}
	cout << t<< endl;
	return 0;
}

Measured memory_bytes: 640
n, m = map(int, input().split())
ppp = []
ppm = []
pmp = []
pmm = []
mpp = []
mpm = []
mmp = []
mmm = []

for i in range(n):
  x, y, z = [int(i) for i in input().split()]
  ppp += [(x + y + z)]
  ppm += [(x + y - z)]
  pmp += [(x - y + z)]
  pmm += [(x - y - z)]
  mpp += [(- x + y + z)]
  mpm += [(- x + y - z)]
  mmp += [(- x - y + z)]
  mmm += [(- x - y - z)]
  
ppp.sort(reverse=True)
ppm.sort(reverse=True)
pmp.sort(reverse=True)
pmm.sort(reverse=True)
mpp.sort(reverse=True)
mpm.sort(reverse=True)
mmp.sort(reverse=True)
mmm.sort(reverse=True)

cakes = []
cakes += [sum(ppp[:m])]
cakes += [sum(ppm[:m])]
cakes += [sum(pmp[:m])]
cakes += [sum(pmm[:m])]
cakes += [sum(mpp[:m])]
cakes += [sum(mpm[:m])]
cakes += [sum(mmp[:m])]
cakes += [sum(mmm[:m])]

#print(cakes)
print(max(cakes))

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

int main(){

    int n;
    cin >> n;

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

    int tmp = n;
    while(tmp > 4){
        tmp -= 4;
        if(tmp % 7 == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    tmp = n;
    while(tmp > 6){
        tmp -= 7;
        if(tmp % 4 == 0){
            cout << "Yes" << endl ;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    while (cin >> n && n) {
        bool flag = false;
        int type = 0;
        for (int i = 0; i < n; ++i) {
            int k;
            cin >> k;
            if (k > 0) ++type;
            if (k > 1) flag = true;
        }
        if (flag) {
            cout << type + 1 << '\n';
        } else {
            cout << "NA" << '\n';
        }
    }
    return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 X, N; cin >> X >> N;
    vector<i64> P(N);
    REP(i, N) cin >> P[i];

    i64 ans;
    i64 mind = 1000000;
    for (i64 i = -1; i <= 101; i++) {
        bool ok = true;
        REP(j, N) {
            if (i == P[j]) ok = false;
        }
        if (ok) {
            if (chmin(mind, abs(X - i))) {
                ans = i;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int K = sc.nextInt();
		int X = sc.nextInt();

		for (int i = X - K + 1; i < X + K; i++) {
			System.out.print(i + " ");
		}
	}
}

Measured memory_bytes: 22868
#include <stdio.h>
#include <string.h>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)

int dp[1010][1010] = {0};
int main(){
    int Q;
    scanf("%d", &Q);
    
    rep(q, Q){
        char X[1010], Y[1010];
        scanf("%s%s", X, Y);
        int nx = strlen(X), ny = strlen(Y);
        rep(i, nx+1) dp[i][0] = 0;
        rep(j, ny+1) dp[0][j] = 0;
        rep(i, nx){
            rep(j, ny){
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
                if(X[i] == Y[j]) dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);  
            }
        }
        printf("%d\n", dp[nx][ny]);
    }
}


Measured memory_bytes: 5708
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;
int main(){
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			cout<<i<<"x"<<j<<"="<<i*j<<"\n";
		}
	}
	return 0;
}

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

int main(int argc, const char * argv[]) {
    int i;
    int n = 0;
    int x = 0;
    int count = 0;
    int *L, *point;
    
    scanf("%d %d", &n, &x);
    L = (int *)calloc(n, sizeof(int));
    point = (int *)calloc(n+1, sizeof(int));
    
    for(i=0; i<n; i++){
        scanf("%d",&L[i]);
    }

    point[1] = L[0];
    
    for(i=2; i<n+1; i++){
        point[i] = point[i-1] + L[i-1];
    }
    for(i=0; i<n+1; i++){
        if(point[i] <= x){count++;}
    }
    printf("%d\n", count);
    
    return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

s = list(input())
t = list(input())

n = len(s)-1
m = len(t)-1

res = m
for i in range(n):
    tmp = 0
    if i+m-1 >= n:
        break
    for j in range(m):
        if s[i+j] != t[j]:
            tmp += 1
    res = min(res,tmp)

print(res)

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

int main() {
        int n;
        int ans=0;
        string s;
        cin>>n;
        cin>>s;
        for(int i=1;i<n-1;++i){
                int keep=0;
                string one=s.substr(0,i),two=s.substr(i,n-i);
                for(char c='a';c<='z'; ++c)
                {
                        if(one.find(c)!=string::npos&&two.find(c)!=string::npos) keep++;
                }
                ans=max(ans,keep);
        }
        cout<<ans<<endl;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
int main(){
  int n;
  cin >> n;
  int ans;
  if(1000-n>0){
    ans=1000-n;
  }else if(n%1000==0){
    ans=0;
  }else{
    string s=to_string(n);
    int a=1+int(s.at(0)-48);
    ans=1000*a - n;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
int main()
{
	int n,i=1;
	cin>>n;
	while (i<=n)
	{
		i=i*2;
	}
	i=i/2;
	cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, j, k, n, b, f, r, v;
	int count[4][3][10] = { 0 };

	scanf("%d", &n);

	for (i = 0; i < n; i++) {

		scanf("%d %d %d %d", &b, &f, &r, &v);

		count[b - 1][f - 1][r - 1] += v;
	}

	for (i = 0; i < 4; i++) {
		for (j = 0; j < 3; j++) {
			
			for (k = 0; k < 10; k++) {
				printf(" %d", count[i][j][k]);
			}
			
			putchar('\n');

		}
		if (i < 3) {
			printf("####################\n");
		}
	}

	return 0;
}

Measured memory_bytes: 612
#include <stdio.h>

int main( void ){
    int W,H,x,y,r;
    scanf( "%d%d%d%d%d" , &W, &H, &x, &y, &r );
    if( x + r > W || y + r > H  ){
        printf( "No\n" );
    } else if ( x < 0 || y < 0 ) {
        printf( "No\n" );
    } else {
        printf( "Yes\n" );
    }
    return 0;
}

Measured memory_bytes: 1808
parseInt(x) = parse(Int,x)
parseMap(x::Array{SubString{String}, 1}) = map(parseInt, x)
function main()
    a,b,c = map(parseInt, split(readline()))
  	if b/a < c
    	println(Int64(floor(b/a)))
  else
    println(Int64(c))
  end
end
main()


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

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

    int n,x;
    cin>>n>>x;

    vector<int> a(n);

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

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

    int cnt=0;

    for(int i=0;i<n;i++)
    {
        x-=a[i];
        if(x<0)break;
        cnt++;
    }
    if(x>0)cnt--;

    cout<<cnt<<"\n";

    return 0;
}


Measured memory_bytes: 3668
s=input()
S=[]
i=0
leng=len(s)
while(i<leng):
    if s[i]=="A":
        S.append("A")
        i+=1
    elif i+1<leng and s[i]=="B" and s[i+1]=="C":
        S.append("B")
        i+=2
    else:
        S.append("C")
        i+=1
T=S[::-1]
l=[0]*len(T)
ans=0
t=len(T)
for i in range(len(T)-1):
    if T[i]=="B":
        l[i+1]=l[i]+1
    elif T[i]=="A":
        l[i+1]=l[i]
        ans+=l[i]
if T[-1]=="A":
    ans+=l[-1]
print(ans)


Measured memory_bytes: 56288
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

LL x;

int main(void) {
    cin >> x;
    LL ans = 0;
    if (x % 11 == 0) {
        ans = (x / 11) * 2;
    } else {
        if (x % 11 > 6) ans = (x / 11) * 2 + 2;
        else ans = ((x / 11) * 2) + 1;
    }
    cout << ans << endl;
}


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

int main(){
	ll n,k,s;
	cin >> n >> k >> s;
	
	vector<ll> ans(n);
	
	
	rep(i,k){
		ans[i] = s;
	}
	for (int j = k; j < n; ++j) {
		if(s == 1e+9){
			ans[j] = s-1;
		}else{
			ans[j] = s+1;
		}
	}
	
	rep(i,n){
		cout << ans[i] << " ";
	}
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
ll a[maxn];
int main() {
	int n;
	cin >> n;
	ll sum1 = 0, sum2 = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum1 += a[i];
		sum2 += a[i] * a[i];
	}
	ll x = sum1 / n;
	ll ans1 = sum2 - 2 * sum1 * x + n * x * x;
	x++;
	ll ans2 = sum2 - 2 * sum1 * x + n * x * x;
	cout << min(ans1, ans2) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    char a[4];
    scanf("%s",a);
    for(int i=0;i<4;i++){
        if(a[i]=='1')a[i]='9';
        else if(a[i]=='9')a[i]='1';
    }
    printf("%s\n",a);
}

Measured memory_bytes: 128
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n string
	for {
		fmt.Scan(&n)
		if len(n) == 1 && toInt(n) == 0 {
			break
		}
		fmt.Println(sum(n))
	}
}

func sum(n string) int {
	sum := 0
	for i := 0; i < len(n); i++ {
		sum += toInt(string(n[i]))
	}
	return sum
}

func toInt(s string) int {
	i, _ := strconv.Atoi(s)
	return i
}



Measured memory_bytes: 1164