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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = (ll) 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 300005;
int r, c;
char arr[1005][1005];
int br, bc, er, ec;
bool vis[1003][1003];
map<pair<int, int>, int> dis;

bool ok(int a, int b) {
    if (a >= 1 && a <= r && b >= 1 && b <= c && arr[a][b] == '.')
        return 1;
    return 0;
}

int main() {
    FAST
    cin >> r >> c >> br >> bc >> er >> ec;
    for (int i = 1; i <= r; i++) {
        for (int j = 1; j <= c; j++) {
            cin >> arr[i][j];
        }
    }

    deque<pair<pair<int, int>,int>> d;
    d.push_back({{br, bc},0});

    while (!d.empty()) {
        pair<pair<int, int>,int> cur = d.front();
        d.pop_front();
        if (cur.first.first == er && cur.first.second == ec) {
            return cout << cur.second << endl, 0;
        }
        if (vis[cur.first.first][cur.first.second])
            continue;
        vis[cur.first.first][cur.first.second] = 1;
        if (ok(cur.first.first + 1, cur.first.second)) {
            d.push_front({{cur.first.first + 1, cur.first.second},cur.second});
        }
        if (ok(cur.first.first - 1, cur.first.second)) {
            d.push_front({{cur.first.first - 1, cur.first.second},cur.second});
        }
        if (ok(cur.first.first, cur.first.second + 1)) {
            d.push_front({{cur.first.first, cur.first.second + 1},cur.second});
        }
        if (ok(cur.first.first, cur.first.second - 1)) {
            d.push_front({{cur.first.first, cur.first.second - 1},cur.second});
        }
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                if (ok(cur.first.first + i, cur.first.second + j)) {
                    d.push_back({{cur.first.first + i, cur.first.second + j},cur.second+1});
                }
            }
        }
    }
    cout << -1 << endl;

    return 0;
}


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

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int total = 0;
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
    total += a.at(i);
  }
  
  int stn = 0;
  if (total % (4 * m) == 0)
    stn = total / (4 * m);
  else
    stn = (total / (4 * m)) + 1;
  
  int pop = 0;
  for(int i = 0; i < n; i++) {
    if (a.at(i) >= stn)
      pop++;
  }
  
  if (pop >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl; 
  
  return 0;
}   

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long long a,b,x,c,d;
	cin>>a>>b>>x;
	c=a-1;if(c<0)c=0;
	c/=x;
	d=b/x;
	if(a==0)d++;
	cout<<d-c<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p 998244353

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

int power(int a, int N){
	if(N == 0) return 1;
	else if(N % 2 == 0) return power(MOD(a * a), N / 2);
	else return MOD(a * power(a, N - 1));
}

signed main(){
	int N, i;
	scanf("%lld", &N);
	vector<int> D(N);
	vector<int> Dnum(N, 0);
	for(i = 0; i < N; i++){
		scanf("%lld", &D[i]);
		Dnum[D[i]]++;
	}
	if(D[0] > 0 || Dnum[0] != 1){
		printf("0\n");
		return 0;
	}
	int ans = 1;
	for(i = 1; i < N; i++){
		ans = MOD(ans * power(Dnum[i - 1], Dnum[i]));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  unsigned long X, Y = 100;
  
  cin >> X;
  
  for(int i = 1; ; i++){
    Y = Y * 1.01;
    if(X <= Y){
      cout << i << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections;
using System.Linq;
class Program
{
    static int Main()
    {
        //int n = int.Parse(Console.ReadLine());
        string[] s = Console.ReadLine().Split(' ');
        int a, b, c;
        a = int.Parse(s[0]);
        b = int.Parse(s[1]);
        c = int.Parse(s[2]);

        int[] num = { a, b, c };
        Array.Sort(num);
        Array.Reverse(num);
        Console.WriteLine(num[0] - num[1] + (num[1] - num[2]) / 2 + ((num[1] - num[2]) % 2) * 2);

        return 0;
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
pi P[MAX_N];

void solve() {
	cin >> N >> M;
	rep(i, 0, M) cin >> P[i].fst >> P[i].sec;
	sort(P, P + M, [](const pi& p1, const pi& p2) { return p1.sec < p2.sec; });
	int cur = 0;
	int ans = 0;
	rep(i, 0, M) {
		if(cur <= P[i].fst) {
			cur = P[i].sec; ans++;
		}
	}
	cout << ans << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

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

const int N = 100179;

int main()
{
    ios::sync_with_stdio(false);

    ll a, b, c, d, n;
    cin >> a >> b >> c >> d >> n;
    b = min(b, a*2);
    c = min(c, b*2);
    d = min(d, c*2);
    cout << (n/2)*d + (n%2)*c << "\n";

    return 0;
}


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("7 6 8");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3");
            WillReturn.Add("12 15 18");
            //6
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("2");
            WillReturn.Add("1000000000 1000000000");
            //1000000000
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] AArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();
        int UB = AArr.GetUpperBound(0);

        //左からの累積GCDを求める
        int[] GCDArrLeft = new int[UB + 1];
        GCDArrLeft[0] = AArr[0];
        for (int I = 1; I <= UB; I++) {
            GCDArrLeft[I] = DeriveGCD(GCDArrLeft[I - 1], AArr[I]);
        }

        //右からの累積GCDを求める
        int[] GCDArrRight = new int[UB + 1];
        GCDArrRight[UB] = AArr[UB];
        for (int I = UB - 1; 0 <= I; I--) {
            GCDArrRight[I] = DeriveGCD(GCDArrRight[I + 1], AArr[I]);
        }

        int Answer = 0;
        for (int I = 0; I <= UB; I++) {
            int CurrGCD = 0;
            if (I == 0) {
                CurrGCD = GCDArrRight[1];
            }
            else if (I == UB) {
                CurrGCD = GCDArrLeft[UB - 1];
            }
            else {
                CurrGCD = DeriveGCD(GCDArrLeft[I - 1], GCDArrRight[I + 1]);
            }
            Answer = Math.Max(Answer, CurrGCD);
        }
        Console.WriteLine(Answer);
    }

    //ユークリッドの互除法で2数の最大公約数を求める
    static private int DeriveGCD(int pVal1, int pVal2)
    {

        pVal1 = Math.Abs(pVal1);
        pVal2 = Math.Abs(pVal2);

        int WarareruKazu = Math.Max(pVal1, pVal2);
        int WaruKazu = Math.Min(pVal1, pVal2);

        while (true) {
            int Amari = WarareruKazu % WaruKazu;
            if (Amari == 0) return WaruKazu;
            WarareruKazu = WaruKazu;
            WaruKazu = Amari;
        }
    }
}


Measured memory_bytes: 33116
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

#define ll long long int

const int MOD = 1000000007;

int main() {

	ll x, ans;

	cin >> x;
	switch (x % 11) {

	case 0:
		ans = x / 5.5;
		break;
	case 1:
	case 2:
	case 3:
	case 4:
	case 5:
	case 7:
	case 8:
	case 9:
	case 10:
		ans = x / 5.5;
		ans++;
		break;
	case 6:
		ans = x / 5.5;
		break;

	}

	cout << ans << endl;

	return 0;
}

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

string dec(string s){
string s1="this";
string s2="that";
	for(int a=0;a<26;a++){
		for(int b=0;b<26;b++){
			string s3=s1;string s4=s2;int fd3=-1,fd4=-1;
			for(int c=0;c<4;c++){
				s3[c]=(a*(s3[c]-'a')+b)%26+'a';
				s4[c]=(a*(s4[c]-'a')+b)%26+'a';
			}//c
			fd3=s.find(s3);fd4=s.find(s4);
			if( fd3>=0 || fd4>=0 ) {
			int N=0;int tp=0;
			for(int d=0;d<s.length();d++){
				if(s[d]==' ')continue;
					for(N=0;N<=26;N++){
						if( (s[d]-'a'+11*N-b)>=0 && (s[d]-'a'+26*N-b)%a==0 ){
						tp=N;
						s[d]='a'+(s[d]-'a'+26*tp-b)/a;
						break;
						}
					}
			}
			break;
		}
		}
	}
	
return s;
}


int main(void){
int num;

cin>>num;
string s;
	getline(cin,s);//read num->\n
for(int i=0;i<num;i++){
	getline(cin,s);
	cout<<dec(s)<<endl;
}
	return 0;
}



Measured memory_bytes: 3136
open System

let mutable c = 0
let n_float = stdin.ReadLine() |> float32
let n_sqrt = sqrt n_float |> int
let n = n_float |> int

let anss =
    seq { for i in 1..n_sqrt do 
            for j in 1..n_sqrt do 
                for k in 1..n_sqrt do
                    let e = i*i+j*j+k*k+i*j+j*k+k*i
                    yield e
    } |> Seq.toArray

let a = Array.zeroCreate n
Array.iter (fun x ->
            if x <= n then
                a.[x-1] <- a.[x-1]+1 
        ) anss

for i in a do
    printfn "%d" i

Measured memory_bytes: 39892
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;

using ll = long long;

int main()
{
    int n;
    string s;
    map<string, int> count;
    int max = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s;
        if (count.count(s) > 0) {
            count[s]++;
        }
        else {
            count[s] = 1;
        }
        if (count[s] > max) {
            max = count[s];
        }
    }
    for (const auto& p : count) {
        if (p.second == max) {
            cout << p.first << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 25216
def f(a):
	s=0;q=a[:n];s=sum(q);heapify(q);r=[s]
	for e in a[n:2*n]:s+=e-heappushpop(q,e);r+=[s]
	return r
import sys;from heapq import*;r=reversed;n,*a=map(int,sys.stdin.read().split());print(max(map(sum,zip(f(a),r(f([-e for e in r(a)]))))))

Measured memory_bytes: 127704
def main():
    N = int(input())
    print(N + N * N + N * N * N)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


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

bool check( string S )
{
    istringstream is( S );
    string word;
    while ( is >> word ) if ( word == "this" || word == "that" ) return true;
    return false;
}

string decode( string S )
{
    int T[S.size()];
    int F[S.size()];
    for ( int i = 0; i < (int)S.size(); i++ ) T[i] = (int)( S[i] - 'a' );

    for ( int i = 1; i < 500; i++ ) {
        if ( 26 % i == 0 ) continue;
        for ( int j = 0; j < 500; j++ ) {
            for ( int k = 0; k < (int)S.size(); k++ ) {
                F[k] = ( i * T[k] + j ) % 26;
            }
            string FS( S.size(), 'a' );
            for ( int k = 0; k < (int)S.size(); k++ ) {
                if ( S[k] == ' ' ) FS[k] = ' ';
                else FS[k] += F[k];
            }
            if ( check( FS ) ) return FS;
        }
    }
    return S;
}

int main( void )
{
    int n;
    cin >> n;
    cin.ignore();
    for ( int i = 0; i < n; i++ ) {
        string line;
        getline( cin, line );
        cout << decode( line ) << endl;
    }
    return 0;
}

Measured memory_bytes: 932
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <memory>

using namespace std;

#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x)  { cout << #x << ": ";                       \
        for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
        cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif

typedef pair<int, int> p;
typedef long long int ll;

int n;
vector<int> a;
vector<int> c;

ll combination(int n, int r) {
    if (r * 2 > n) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for (unsigned int i = 1; i <= r; ++i) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

int main(int argc, char *argv[]) {
    scanf("%d", &n);
    a.resize(n);
    c.resize(n);
    for (int i = 0; i < n; ++i) {
        int tmp;
        scanf("%d", &tmp);
        a[i] = tmp;
    }
    sort(a.begin(), a.end());
    int max_ai = -1;
    int max_aj = -1;
    ll max_c = 0;
    for (int i = n - 1; i >= n/2; --i) {
        int h = (a[i] + 1) / 2;
        int j = lower_bound(a.begin(), a.begin() + i, h) - a.begin();
        int d1 = abs(a[j] - h);
        if (j > 0 && abs(a[j - 1] - h) <= d1) {
            j = j - 1;
        }
        printf("%d %d\n", a[i], a[j]);
        return 0;
        // c[i] = combination(a[i], a[j]);
        // if (max_c < c[i]) {
        //     max_ai = a[i];
        //     max_aj = a[j];
        //     max_c = c[i];
        // }
    }
    printf("%d %d\n", max_ai, max_aj);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

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

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

const UINT mod = 1000000007;

UINT PowMod(UINT x, UINT y)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = PowMod(x, y / 2);
		return tmp * tmp % mod;
	}
	else
	{
		auto tmp = PowMod(x, y / 2);
		return (tmp * tmp % mod) * x % mod;
	}
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

int main()
{
	INT N, D;
	cin >> N >> D;

	INT t = D * 2 + 1;

	cout << (N + t - 1) / t << endl;
}


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

int n,m,ans;
int x[MAX_M],y[MAX_M],w[MAX_M];
vector<int> G[MAX_N];
vector<int> g[MAX_N];
vector<int> group[MAX_N];
int id[MAX_N];
bool visited[MAX_N];
vector<int> vd;
int dp[MAX_N];
int d[MAX_N];

bool dfs(int pos,int prev,int root){
  id[pos]=root;
  visited[pos]=true;
  group[root].push_back(pos);
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    if(i&&to==G[pos][i-1])return true;
    if(visited[to])return true;
    if(dfs(to,pos,root))return true;
  }
  return false;
}

bool check(){
  memset(visited,false,sizeof(visited));
  for(int i=0;i<n;i++)
    if(!visited[i]&&dfs(i,-1,i))return true;
  vector< int > deg(n);
  vector< vector<int> > graph(n);
  for(int i=0;i<m;i++){
    if(w[i]==1){
      int X=id[ x[i] ];
      int Y=id[ y[i] ];
      if(X==Y)return true;
      graph[X].push_back(Y);
      deg[Y]++;
    }
  }
  queue<int> Q;
  for(int i=0;i<n;i++)
    if(deg[i]==0&&id[i]==i)
      Q.push(i);
  while(!Q.empty()){
    int pos=Q.front();Q.pop();
    vd.push_back(pos);
    for(int to:graph[pos]){
      deg[to]--;
      if(deg[to]==0)Q.push(to);
    }
  }
  for(int i=0;i<n;i++)
    if(deg[i]>0)return true;
  return false;
}

int solve(int S){
  for(int pos:group[id[S]])d[pos]=-1;
  queue<int> Q;
  Q.push(S);
  d[S]=0;
  while(!Q.empty()){
    int pos=Q.front();Q.pop();
    for(int to:G[pos]){
      if(d[to]!=-1)continue;
      d[to]=d[pos]+1;
      Q.push(to);
    }
  }
  int res=S;
  for(int pos:group[id[S]]){
    if(d[pos]+dp[pos]>d[res]+dp[res])res=pos;
    ans=max(ans,d[pos]+dp[S]);
    for(int to:g[pos])dp[to]=max(dp[to],d[pos]+dp[S]+1);
  }
  return res;
}

int main(){
  scanf("%d %d",&n,&m);
  for(int i=0;i<m;i++){
    scanf("%d %d %d",&x[i],&y[i],&w[i]);
    x[i]--,y[i]--;
    if(w[i]==1){
      g[x[i]].push_back(y[i]);
    }
    if(w[i]==2){
      G[x[i]].push_back(y[i]);
      G[y[i]].push_back(x[i]);
    }
  }
  if(check()){
    printf("Infinite\n");
    return 0;
  }
  for(int root : vd )
    if(root==id[root])
      solve(solve(solve(root)));
  printf("%d\n",ans);  
  return 0;
}

Measured memory_bytes: 23692
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 驍ｨ・ｶ陝・ｽｾ陋滂ｽ､雎弱ｅ・∫ｹｧ繝ｻ笆ｽ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;

int main(){
  int N; cin >> N;
  vector<int> A(N);
  rep(i,N){
    cin>>A[i];
  }
  rep(i,N){
    if(i) cout<<" ";
    cout<<A[i];
  }
  cout<<endl;
  for(int i = 1 ; i <= N-1; i++){
    int v = A[i];
    int j = i-1;
    while(j>=0 && A[j] >v){
      A[j+1]=A[j];
      A[j]=v;
      j--;
     v=A[j+1];
    }
    rep(k,N){
      if(k) cout<<" ";
      cout<<A[k];
    } 
    cout<<endl;
  }
} 



Measured memory_bytes: 3108
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	string str[101];
	int h, w;
	cin >> h >> w;
	REP(i, h){
		cin >> str[i];
	}

	REP(i, h){
		cout << str[i] << endl;
		cout << str[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
	
	int N;
	
	cin >> N;
	
	vector<ll> A(N);
	
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	ll res=0;
	ll a = 1;
	for (int i = 0; i < N; i++) {
		if (A[i] % a == 0) {
			
			res += (A[i] / a) - 1;
			if (A[i] == a||a==1) {
				a++;
			}
		}
		else {
			res += (A[i] / a);
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
#include <algorithm>
#include <functional>
//#include<stdlib.h>
using namespace std;


int main() {
	int n,d;
	cin >> n>>d;
	cout << (n/(2*d+1)+((n%(2*d+1)!=0)?1:0));
	return 0;
}

Measured memory_bytes: 256
try:

  D1=[int(i) for i in input().split(" ")]

  D2=[int(i) for i in input().split(" ")]

  dts={

    "28":[2],

    "30":[4,6,9,11],

    "31":[1,3,5,7,8,10,12]

  }

  print(int(D1[0] in dts.get(str(D1[1]),[])))

except:

  print(0)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

string S;
ll N,K;
ll A[100];
ll ans;
 
int main(){
    cin >> N >> K;
    for(int i=0;i<K;i++){
        int d;
        cin >> d;
        for(int j=0;j<d;j++){
            int a;
            cin >> a;
            A[a-1] +=1;
        }
    }
    for(int i=0;i<N;i++){
        if(A[i] == 0){
            ans++;
        }
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
      #include <chrono>
    
      using namespace std;
      using namespace std::chrono; 
   
      typedef long long int ll;
   
      #define MOD (ll)(1e9+7)
      #define endl "\n"
      #define pb push_back
      #define TEST_CASES  ll t;cin>>t;while(t--)
      #define forn(i,a,n) for (int i = a; i < n; ++i)
      #define f first
      #define s second
      #define all(x) x.begin(), x.end()


      
      ll powD(ll x,ll y){
        ll res = 1;
        while(y > 0){
          if(y & 1)
            res = (res*x)%MOD;
          x = (x*x)%MOD;
          y = y>>1;
        }
        return res;
      }
  
      int main()
      {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int ans;
        forn(i,1,6){
          int x;
          cin>>x;
          if(x == 0)
            ans = i;
        }
        cout<<ans<<endl;
         
        
         
      }

      
    


Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	long long int a[100001];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);
	long long int ans = 1;
	long long int sum = a[0];
	for(int i = 1; i < n; i++){
		if(a[i] > 2 * sum) ans = 1;
		else ans++;
		sum += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	string s;
	int k;
	cin >> s >> k;
	set<string> st;
	rep(i, 0, s.size()) {
		string a;
		a = s[i];
		st.insert(a);
		rep(j, 1, 6) {
			if (i + j >= s.size()) {
				break;
			}
			a += s[i + j];
			st.insert(a);
		}
	}
	auto ite = st.begin();
	rep(i, 1, k) {
		ite++;
	}
	cout << *ite << endl;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1000000
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
ll s[N],S[N],f[N],g[N]; int a[N];
int main()
{	int n; cin>>n;
	for(rint i=1;i<=n;i++) scanf("%d",&a[i]),s[i]=s[i-1]+((a[i]&1)?0:1),S[i]=S[i-1]+a[i];
	for(rint i=2;i<=n+1;i++)
	f[i]=min(S[i-1],f[i-1]+(a[i-1]==0)*2+(a[i-1]%2==1));
	for(rint i=n-1;i>=1;i--)
	g[i]=min(S[n]-S[i],g[i+1]+(a[i+1]==0)*2+(a[i+1]%2==1));
//	for(rint i=2;i<=n+1;i++) cerr<<f[i]<<" ";fgx;
//	for(rint i=1;i<=n;i++) cerr<<g[i]<<" ";fgx;
	for(rint i=1;i<=n+1;i++) f[i]-=s[i-1],g[i]+=s[i];
//	for(rint i=2;i<=n+1;i++) cerr<<f[i]<<" ";fgx;
//	for(rint i=1;i<=n;i++) cerr<<g[i]<<" ";fgx;
	ll mn=f[1],ans=1e18;
	for(rint i=1;i<=n;i++) mn=min(mn,f[i+1]),ans=min(ans,g[i]+mn);
	cout<<ans;
	return 0;
}



Measured memory_bytes: 17408
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int t = sc.nextInt();
    
    int[] list = new int[n];
     for(int i = 0; i < n ; ++i){
       list[i] = sc.nextInt();
     }
    
    
    int ans = 0;
    for(int i = 1; i < n ; ++i){
      if(list[i]-list[i-1] <= t){
        int next = list[i] - list[i-1];
        ans += next;
      }else{
        ans += t;
      }
    }
    
    System.out.println(ans + t);
    
  }
  
}

Measured memory_bytes: 60128
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<list>
#include<map>
using namespace std;
#define ll long long
ll dp[505][505],sum,n,p,ans;
ll jian(ll x){
	return x<0?x+p:x;
}
ll add(ll x){
	return x>=p?x-p:x;
}
struct l1{
	ll dw,up,id;
}sid[200005];
ll cmp(l1 x,l1 y){
	ll tag1=(x.id<n),tag2=(y.id<n);
	ll d1,u1,d2,u2;
	if(tag1) d1=x.dw-1,u1=x.up;
	else d1=x.up,u1=x.dw-1;
	if(tag2) d2=y.dw-1,u2=y.up;
	else d2=y.up,u2=y.dw-1;
//	cout<<d1<<' '<<u1<<' '<<d2<<' '<<u2<<' '<<tag1<<' '<<tag2<<' '<<x.id<<' '<<y.id<<endl;
	if(d1!=d2) return d1<d2;
	if(u1!=u2) return u1<u2;
	return x.id>y.id;
}
ll solve(ll k){
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	sum=0;
	for(ll i=1;i<=2*n;i++){
//		cout<<sid[i].dw<<' '<<sid[i].up<<' '<<sid[i].id<<endl;
		for(ll t=0;t<=k;t++){
			if(sid[i].id>=n){
				ll qwq=sid[i].up+1-(i-1-(sum-t));
				dp[i][t]=(dp[i][t]+dp[i-1][t]*qwq)%p;
			}
			else{
				ll qwq=sid[i].up+1-(2*n-sid[i].id-1+k-t);
				dp[i][t]=(dp[i][t]+dp[i-1][t]*qwq)%p;
				if(t){
					qwq=sid[i].dw-(i-1-(sum-t+1));
					dp[i][t]=(dp[i][t]+dp[i-1][t-1]*qwq)%p;
				}
			}
		}
		sum+=sid[i].id<n;
	}
	return dp[2*n][k];
}
int main(){
	scanf("%lld%lld",&n,&p);
	for(ll i=0;i<=2*n-1;i++){
		sid[i+1].id=i;
		sid[i+1].dw=max((ll)ceil(sqrt(n*n-i*i)),0ll);
		sid[i+1].up=min((ll)floor(sqrt(4*n*n-i*i)),2*n-1);
	}
	sort(sid+1,sid+2*n+1,cmp);
	for(ll i=0;i<=n;i++){
		if(i&1) ans=jian(ans-solve(i));
		else ans=add(ans+solve(i));
	}
	printf("%lld",ans);
}

Measured memory_bytes: 5912
using static System.Console;

namespace UOA_PCKWU
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            while (true)
            {
                var input = ReadLine();
                if (input == "END OF INPUT") break;
                var text = input.Split(' ');
                foreach (var s in text)
                {
                    Write(s.Length);
                }

                WriteLine();
            }
        }
     }
 }


Measured memory_bytes: 13804
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  if (A - B * 2 < 1)
  {
    cout << 0 << endl;
  }
  else
  {
    cout << A - B * 2 << endl;
  }
}

Measured memory_bytes: 3588
class UnionFind {
    constructor(N){
        this.par = new Array(N).fill(-1)
    }

    root(x) {
        if (this.par[x] < 0) return x;
        return this.par[x] = this.root(this.par[x]);
    }

    unite(x, y) {
        let rx = this.root(x);
        let ry = this.root(y);
        if (rx == ry) return;
        if(this.par[rx] > this.par[ry]) [rx, ry] = [ry, rx]
        this.par[rx] += this.par[ry]
        this.par[ry] = rx
    }

    isSame(x, y) {
        let rx = this.root(x);
        let ry = this.root(y);
        return rx == ry;
    }
    
    size(x) {
        return -this.par[this.root(x)];
    }
};

function main(arg) {
    
    arg = arg.split("\n")
    let [N,M] = arg[0].split(" ").map(Number)
    let A = arg.slice(1).map(x=>Number(x.split(" ")[0]))
    let B = arg.slice(1).map(x=>Number(x.split(" ")[1]))
    

    let uf = new UnionFind(N)    //console.log(uf)
    
    for(let i=0; i<M; i++) {
        uf.unite(A[i]-1, B[i]-1)
    }
    let count=uf.par.filter(p=>p<0).length
    console.log(count-1)
}

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

Measured memory_bytes: 59920
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Wed Jan  9 23:27:55 2019
//
package main

import (
	"fmt"
	"sort"
)

func max(slice ...int) int {
	sort.Ints(slice)
	return slice[len(slice)-1]
}

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

	a, b, c := make([]int, N), make([]int, N), make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i], &b[i], &c[i])
	}

	dp := make([][3]int, N+1)
	for i := 1; i <= N; i++ {
		dp[i][0] = a[i-1] + max(dp[i-1][1], dp[i-1][2])
		dp[i][1] = b[i-1] + max(dp[i-1][2], dp[i-1][0])
		dp[i][2] = c[i-1] + max(dp[i-1][0], dp[i-1][1])
	}

	fmt.Println(max(dp[N][0], dp[N][1], dp[N][2]))
}


Measured memory_bytes: 10112
S = list(input())
T = input()
len_S = len(S)
ans = "No"

for i in range(len_S):
    new_S = ""
    for j in range(i, len_S):
        new_S += S[j]
    for k in range(0, i):
        new_S += S[k]
    if new_S == T:
        ans = "Yes"
        break

print(ans)


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

int n, m, a, b, c;

int main() {
    vector<int> w(3);
    cin >> n >> m >> w[0] >> w[1] >> w[2];
    sort(w.begin(), w.end());
    a = w[0], b = w[1], c = w[2];
    vector<vector<set<int>>> ls(n + 1, vector<set<int>>(101));
    for (int i = 0; i < m; i++) {
        int s, t;
        cin >> s >> t;
        ls[t][0].insert(s);
    }

    for (int i = 1; i <= c; i++) {
        for  (int j = 1; j <= n; j++) {
            for (auto k : ls[j][i - 1]) {
                for (auto l : ls[k][0]) {
                    ls[j][i].insert(l);
                }
            }
        }
    }

    set<int> slist;
    slist.insert(n);
    set<int> s;
    s.insert(n);
    vector<set<int>> touch(3);
    int turn = 0;
    bool flag = false;
    while (s.size()) {
        turn++;
        set<int> s_(s);
        s.clear();
        for (auto i : s_) {
            auto a_ = ls[i][a - 1];
            auto b_ = ls[i][b - 1];
            auto c_ = ls[i][c - 1];
            for (int j = 1; j <= n; j++) {
                if (
                        (a_.find(j) != a_.end() || touch[0].find(j) != touch[0].end())
                     && (b_.find(j) != b_.end() || touch[1].find(j) != touch[1].end())
                     && (c_.find(j) != c_.end() || touch[2].find(j) != touch[2].end())) {
                    if (slist.find(j) != slist.end()) continue;
                    slist.insert(j);
                    s.insert(j);
                }
                if (a_.find(j) != a_.end()) touch[0].insert(j);
                if (b_.find(j) != b_.end()) touch[1].insert(j);
                if (c_.find(j) != c_.end()) touch[2].insert(j);
            }
        }
        if (s.find(1) != s.end()) {
            flag = true;
            break;
        }
    }

    if (flag) {
        cout << turn << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 6948
S = raw_input()
a = [0 for i in range(len(S))]
flag = 0

for i in range(len(S)):
	a[i] = S[i]
	for j in range(i):
		if a[j] == S[i]:
			print "no"
			flag = 1
			break
	if flag == 1:
		break

if flag == 0:
	print "yes"

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
int partsum[102];
int main ()
{
  ios_base :: sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, i, ans = 10005, in;
  cin >> n;
  for(i = 1; i <= n; i++)
  {
    cin >> in;
    partsum[i] = partsum[i-1] + in;
  }
  for(i = 1; i <= n; i++)
  {
    ans = min(ans, abs(partsum[i] - (partsum[n] - partsum[i])));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K;
  string S;
  cin >> K >> S;
  int h = S.size();
  if(K >= h)
    cout << S << endl;
  else{
    for(int i = 0; i < K; i++)
      cout << S.at(i);
    cout <<"..." << endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define li long
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pli pair<li,li>
#define pll pair<ll,ll>
#define pb push_back
#define fori(i,k,n) for(int i = k;i<n; i++)
#define rfori(i,k,n) for(int i = k; i>=n; i--)
#define tc int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define inf INT_MAX
#define ninf INT_MIN
#define W(x) cout<<x<<endl
#define WW(x,y) cout<<x<<' '<<y<<endl;
#define in(x) cin>>x
//#define int long long
const ll mod = 998244353;
const ll mod2 = 1e9+7;
template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
} 
template<class T>
T power(T a,T b){
    T res = (T)1;
    while(b>0){
        if(b&1)res = res*a;
        b>>=1;
        a*=a;
    }
    return res;
}
struct Node{
    int first;int second;
    Node(int x,int y){
        this->first = x;
        this->second = y;
    }
};
struct comparator{
    bool operator()(const Node &a,const Node &b){
        int lena = a.second-a.first+1;
        int lenb = b.second-b.first+1;
        if(lena == lenb)return a.first<b.first;
        else return lena>lenb;
    }
};
ll power(ll x,ll y,ll mod){
    ll res = 1;
    x%=mod;
    while(y>0){
        if(y&1)res = (res*x)%mod;
        y>>=1;
        x = (x*x)%mod;
    }
    return res;
}

signed main(){
    long long n;
	cin>>n;
	vector<int> a;
	for(long long i=2;i*i<=n;i++) {
		if(n%i==0) {
			int cnt = 0;
			while(n%i==0) {
				n /= i;
				cnt ++;
			}
			a.push_back(cnt);
		}
	}
	if(n!=1)
		a.push_back(1);
	int cnt = 0;
	for(int i=0;i<a.size();i++) {
		double d = (sqrt(8.0*a[i] + 1.0) -1.0 )/2.0;
		cnt += d;
		// cout<<a[i]<<" "<<cnt<<"\n";
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define M0D 1000000007
int main(){

    int N,ans,num;
    bool able=false;
    cin >> N;
    for(int i=1; i<50000; i++){
      num = (int)i*1.08;
      if(num==N){
        able = true;
        ans = i;
        break;
      }
    }

    if(able) cout << ans <<  endl;
    else cout << ":(" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

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

Measured memory_bytes: 3804
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 1000000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 60
#define ll long long
#define ull unsigned long long
#define RNG mt19937
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;

vector<ll> v; 

inline ll grund(ll dep){
	ll cur = dep > 0;
	while((dep&1) == 0){
		cur<<=1;	
		dep>>=1;
	}
	return cur;
}

int N;
ll L;

struct node{
	node* c[2] = {};
	int dep = 0;
	node(){
		c[0] = c[1] = NULL;
		dep = 0;
	}
	node * getc(int x){
		return (c[x]?c[x]:c[x] = new node());
	}
	void add(string &s, int cur){
		dep = cur; 
		if(cur >= s.length())return;
		getc(s[cur] -'0')->add(s, cur + 1);
	}
	void solve(){
		if(c[0] == NULL && c[1] == NULL)return;
		if(c[0] == NULL)v.pb(grund(L-dep));
		else c[0]->solve();
		if(c[1] == NULL)v.pb(grund(L-dep));
		else c[1]->solve();
	}
	~node(){
		delete c[0];
		delete c[1];
	}
};

int main(){
	fast_io();
	node * root = new node();
	cin >> N >> L;
	string s;
	cu(i,0,N){
		cin >> s;
		root->add(s, 0);
	}
	root->solve();
	ll ans = 0;
	cu(i,0,v.size()){
		ans^=v[i];
	}
	cout << (ans==0?"Bob":"Alice") << '\n';
	delete root;
}


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

using namespace std;

int main() {

    int n, A[1000];
    double sum, avg;

    while (true) {

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

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

        sum = 0;
        for (int i = 0; i < n; ++i) sum += A[i];

        avg = sum / n;
        sum = 0;
        for (int i = 0; i < n; ++i) {
            sum += (avg - A[i]) * (avg - A[i]);
        }

        printf("%lf\n", sqrt(sum / n));
    }
}

Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define S first
#define T second

using namespace std; 

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

const int INF = 1 << 24;
const int N = 101;

int main(void){
    vector<pii> in;
    char c;
    for(int t, s; cin >> t >> c >> s, t; in.pb(mp(s, t)));

    sort(ALL(in), greater<pii>());
    int cur = 0, pre = -1;
    vi res(N);
    each(in, it){
        if(it->S != pre) pre = it->S, cur ++;
        res[it->T] = cur;
    }

    for(int t; cin >> t; cout << res[t] << endl);
 
    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
typedef  unsigned long long ull;
const double EPS= (1e-9);
using namespace std;
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=0;
ll G[209][209];
int main(){
    GO();
    int k;
    cin>>k;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++) G[i][j]=__gcd(i,j);
    }
    ll sum=0;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            ll gg=G[a][b];
            for(int c=1;c<=k;c++){
                sum+=G[gg][c];
            }
        }
    }
    cout<<sum<<"\n";
}


Measured memory_bytes: 3972
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long mod = 1000000007;


int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int n;
	cin >> n;
	vi h(n);
	for (int i = 0; i < n; i++)
		cin >> h[i];
	vi dp(n);
	for (int i = 1; i < n; i++)
	{
		dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
		if (i > 1)
			dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));

	}
	cout << dp[n - 1];
	
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int H, W, N, sr, sc; cin >> H >> W >> N >> sr >> sc;
    string S, T; cin >> S >> T;

    int t_l=0, t_r=0, t_u=0, t_d=0, a_l=0, a_r=0, a_u=0, a_d=0;

    for(int i=0; i < N; i++) {
        char t_tmp = S.at(i);
        char a_tmp = T.at(i);
        if(t_tmp == 'L') t_l++;
        if(t_tmp == 'R') t_r++;
        if(t_tmp == 'U') t_u++;
        if(t_tmp == 'D') t_d++;

        if(sc - t_l + a_r <= 0 || sc + t_r - a_l > W ||
           sr - t_u + a_d <= 0 || sr + t_d - a_u > H ) {
            cout << "NO" << endl;
            return 0;
        }

        if(a_tmp == 'L' && (t_r+sc-a_l-1) > 0) a_l++;
        if(a_tmp == 'R' && (sc-t_l+a_r+1) <= W) a_r++;
        if(a_tmp == 'U' && (t_d+sr-a_u-1) > 0) a_u++;
        if(a_tmp == 'D' && (sr-t_u+a_d+1) <= H) a_d++;
    }

    cout << "YES" << endl;

    return 0;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S;
    cin >> S;
    S = S;
    ll N = S.size();
    vector<vector<ll>> dp(N + 1, vector<ll>(2, INF));
    dp[0][0] = 0;
    dp[0][1] = 1;
    rep(i, N) {
        ll d = S[i] - '0';
        dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + d);
        dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + 10 - d);
        dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + (d % 9) + 1);
        dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + 10 - d - 1);
    }
    cout << dp[N][0] << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 55964
n=int(input())
XYS=[]
for _ in range(n):
  a=int(input())
  XY=[list(map(int,input().split())) for _ in range(a)]
  XYS.append(XY)

ans=0
for i in range(2**n):
  tp=[-1]*n
  for j in range(n):
    tp[j]=1 if i>>j&1 else 0
  flag=True
  for j in range(n):
    if flag==False: break
    for x,y in XYS[j]:
      if tp[j]==1:
        x,y=x-1,y
        if tp[x]!=y:
          flag=False
          break
  if flag:
    ans=max(ans,sum(tp))
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
    	var N = int.Parse(ReadLine());
        var A = ReadLine().Split(' ').Select(s => double.Parse(s)).ToArray();
        var ans = 1.0 / A.Sum(x => 1.0 / x);

        WriteLine(ans);
    }
}


Measured memory_bytes: 28312
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
long long int n,m,p,x,sum=0;
cin >> n;
long long int t[n];
for(int i=0;i<n;i++) {
  cin >> t[i];
  sum+=t[i];
}
cin >> m;
vector <pair<long long int,long long int>> v;
for(int i=0;i<m;i++) {
  cin>> p>>x;
  v.push_back(make_pair(p,x));
}
for(int i=0;i<m;i++){
 cout << sum-t[v[i].first-1]+v[i].second<<endl;
}

}


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

int main() {
    int x, y, c[20][20]{};
    ll dp[20][20];
    while(cin >> x >> y, x){
        for(int i=0;i<y;i++){
            for(int j=0;j<x;j++){
                cin >> c[i][j];
            }
        }
        for(int i=1;i<y+2;i++) fill(dp[i], dp[i]+x, 0LL);
        fill(dp[0], dp[0]+x, 1);
        for(int i=0;i<y-1;i++){
            for(int j=0;j<x;j++){
                if(c[i][j]==1) continue;
                if(c[i][j]==2) dp[i+2][j] += dp[i][j];
                else{
                    if(j-1>=0 && c[i+1][j-1]==0) dp[i+1][j-1] += dp[i][j];
                    if(j+1<x && c[i+1][j+1]==0) dp[i+1][j+1] += dp[i][j];
                    if(c[i+1][j] != 1) dp[i+1][j] += dp[i][j];
                }
            }
        }
        int ans = 0;
        for(int i=y-1;i<=y+1;i++){
            for(int j=0;j<x;j++){
                if(c[i][j] != 1) ans += dp[i][j];
            }
        }
        cout << ans << endl;
    }
    return 0;
}





Measured memory_bytes: 3068