akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
int main(void){
  int n,i,j;
  scanf("%d",&n);
  int a[n],b[n];
  for(i=0;i<n;i++){
    scanf("%d%d",&a[i],&b[i]);
  }
  double ans=0;
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      ans+=sqrt(pow(a[i]-a[j],2)+pow(b[i]-b[j],2));
    }
  }
  printf("%.7f\n",ans/n*2);
  return 0;
}

Measured memory_bytes: 128
"use strict";

const permutateWithRepetitions = (
  permutationOptions,
  permutationLength
) => {
  if (permutationLength === 1) {
    return permutationOptions.map(permutationOption => [permutationOption]);
  }

  const permutations = [];

  const smallerPermutations = permutateWithRepetitions(
    permutationOptions,
    permutationLength - 1
  );

  permutationOptions.forEach((currentOption) => {
    smallerPermutations.forEach((smallerPermutation) => {
      permutations.push([currentOption].concat(smallerPermutation));
    });
  });

  return permutations;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const S = arg[1].split("").map(n=>parseInt(n));

    // 最大で1000通りしかありえないので全探索する
    const digits = [0,1,2,3,4,5,6,7,8,9];
    
    const combos = permutateWithRepetitions(digits, 3);
    
    let cnt = 0;
    
    for(let i in combos) {
        let digit1 = combos[i][0];
        let digit2 = combos[i][1];
        let digit3 = combos[i][2];
        
        let flag1 = false;
        let flag2 = false;
        let flag3 = false;

        for(let j=0; j<N; j++) {
            if(S[j] === digit1 && flag1 !== true) {
                flag1 = true;
            } else if(S[j] === digit2 && flag1 && flag2 !== true) {
                flag2 = true;
            } else if(S[j] === digit3 && flag1 && flag2) {
                flag3 = true;
            }
        }
        
        
        if(flag1 && flag2 && flag3) {
            cnt++;
        }
    }
    
    console.log(cnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 8212
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    int A[214514];
    int B[214514]={},C[214514]={};
    cin >> N;
    REP(i,N){
        cin >> A[i];
    }
    REP(i,N){
        if(i==0){B[i]=A[i];}
        B[i]=max(B[i-1],A[i]);
    }
    RREP(i,N){
        if(i==N-1){C[i]=A[i];}
        C[i]=max(C[i+1],A[i]);
    }
    cout << C[1] << endl;
    for(int i=1;i<N-1;i++){
        cout << max(B[i-1],C[i+1]) << endl;
    }
    cout << B[N-2] << endl;
    
    return 0;
}


Measured memory_bytes: 6656
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_A&lang=jp
#?¨???°?????????

def counting_sort(target_list):
    counter = [0 for i in range(10000)]

    for n in target_list:
        counter[n] += 1

    for i in range(1,10000):
        counter[i] = counter[i] + counter[i-1]

    result = [0 for i in range(len(target_list))]
    for n in target_list[::-1]:
        result[counter[n] - 1] = n
        counter[n] -= 1
    
    return result
if __name__ == "__main__":
    n_list = int(input())
    target_list = [int(s) for s in input().split()]
    sorted_list = counting_sort(target_list)
    print(" ".join([str(s) for s in sorted_list]))

Measured memory_bytes: 248048
#define _CRT_SECURE_NO_WARNINGS

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

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { D, R, U, L , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiouy"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }
bool cklex(string &a, string b) {
	if (b == "") return false;
	if (a == "") return a = b, true;
	if (sz(a) < sz(b)) return false;
	if (sz(b) < sz(a)) return a = b, true;
	if (a < b) return false;
	return a = b, true;
}

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; } //convert index from 2D array to 1D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) { return{ n / nCol, n % nCol }; } //convert index from 1D array to 2D array (row, col). (Zero-indexed)
template<typename T> void inter(T X) { cout << X << endl; fflush(stdout); }



int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int t = 1, tt=1;
	//cin >> t;
	while (t--) {
		int d, t, s;
		cin >> d >> t >> s;
		if ((d+s-1) / s <= t) cout << "Yes\n";
		else cout << "No\n";
	}


	return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    string s;
    cin >> s;
    if(s[0] == s[1] or s[1] == s[2] or s[2] == s[3])puts("Bad");
    else puts("Good");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;

int compare_int(const void *a, const void *b)
{
    return *(int *)b - *(int *)a;
}

int main(void)
{
    int ans = 0;
    int n, m, sum = 0, a[101];

    scanf("%d%d", &n, &m);
    rep(i, n)
    {
        scanf("%d", &a[i]);
        sum += a[i];
    }

    qsort(a, n, sizeof(int), compare_int);

    rep(i, m)
    {
        if (a[i] < (double)sum / 4 / m)
        {
            puts("No");
            return 0;
        }
    }

    puts("Yes");
    return 0;
}

Measured memory_bytes: 1628
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

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

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

N, M, Q = In.ints()


fromTo = defaultdict(list)

for i in range(Q):
    a, b, c, d = In.ints()

    fromTo[a].append((b,c,d))

ans = 0

def rec(arr,N,M,fromTo):
    if len(arr)==N:
        points = 0

        for i in range(len(arr)):
            idx = i+1
            if idx in fromTo:
                for rule in fromTo[idx]:
                    b,c,d = rule
                    if arr[b-1]-arr[i]==c:
                        points+=d
        global ans
        ans = max(ans, points)
        return

    highest = arr[-1]

    for i in range(highest, M+1):
        arr.append(i)
        rec(arr,N,M,fromTo)
        arr.pop(-1)


rec([1],N,M,fromTo)


Out.int(ans)

######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 73208
N = int(input())
d = list(map(int,input().split()))
ans = 0
d.sort()
        
if len(d) % 2 == 0:
    idx1 = int(len(d)/2)
    idx2 = int((len(d)/2)-1)
    if d[idx1] != d[idx2]:
        ans = d[idx1] - d[idx2]
        
print(ans)

Measured memory_bytes: 14428
import java.io.*;
import java.util.Objects;
import java.util.StringTokenizer;

public class Main {
  private static PrintWriter out;

  public static void main(String[] args) {
    Main main = new Main();
    Runtime.getRuntime().addShutdownHook(new Thread(() -> out.close()));
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));

    int N = sc.nextInt();
    int Y = sc.nextInt();
    Pair result = null;

    for (int x = 0; x <= N; x++) {
      for (int y = 0; y <= N-x ; y++) {
        int rest = Y - 10000*x - 5000*y;
        int z = rest / 1000;
        if (x+y+z == N){
          result = new Pair(x,y,z);
          break;
        }
        if (Objects.nonNull(result)) break;
      }
    }
    if (Objects.isNull(result)) result = new Pair(-1, -1, -1);
    out.println(result.resultStr());
    out.close();
  }

  class Pair{
    int x;
    int y;
    int z;
    
    Pair(int x, int y, int z){
      this.x = x;
      this.y = y;
      this.z = z;
    }

    String resultStr(){
      return String.format("%s %s %s",this.x, this.y, this.z);
    }
  }

  /*          
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


Measured memory_bytes: 29780
#include <iostream>
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using P = pair<int,int>;
using ll = long long;


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

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int ara[200005], n, k;
bool func(int mid)
{
    int temp= k;
    for(int i=0; i<n; i++)
    {
        temp-= ((ara[i]-1)/mid);
        if(temp<0)return 0;
    }
    return 1;
}
int main()
{
    scanf("%d %d", &n, &k);
    for(int i=0; i<n; i++)scanf("%d", &ara[i]);
    int lo= 1, hi= 1000000009, res;
    while(lo<=hi)
    {
        int mid= (lo+hi)/2;
        if(func(mid))res= mid, hi= mid-1;
        else lo= mid+1;
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 4504
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> S;
    sort(ALL(S));
    N = S.size();
    UNIQUE(S);
    if (N == S.size())
        cout << "yes" << endl;
    else
        cout << "no" << endl;
}

Measured memory_bytes: 3632
from sys import stdin,setrecursionlimit
k = int(stdin.readline().rstrip())
li = [i for i in range(1,10)]
#ルンルン最初の数
def runrun(before,kazu):
    if before == 0:
        li.append(int(kazu+str(before+1)))
        li.append(int(kazu+str(before)))
    elif before == 9:
        li.append(int(kazu+str(before-1)))
        li.append(int(kazu+str(before)))
    else:
        li.append(int(kazu+str(before+1)))
        li.append(int(kazu+str(before-1)))
        li.append(int(kazu+str(before)))
    if len(kazu)+1 >= 10:
        return
    else:
        if before == 0:
            return runrun(before+1,kazu+str(before+1)),runrun(before,kazu+str(before))
        elif before == 9:
            return runrun(before-1,kazu+str(before-1)),runrun(before,kazu+str(before))
        else:
            return runrun(before+1,kazu+str(before+1)),runrun(before-1,kazu+str(before-1)),runrun(before,kazu+str(before))
for i in range(1,10):
    runrun(i,str(i))
li.sort()
print(li[k-1])

Measured memory_bytes: 11628
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>

using namespace std;

int main() {
	int n; cin >> n;
	vector<pair<string,int> > s(n);
	for (int i = 0; i < n; ++i) {
		cin >> s[i].first; s[i].second = i;
		sort(s[i].first.begin(), s[i].first.end());
	}
	sort(s.begin(), s.end());
	long long ans = 0;
	for (int i = 0; i < n - 1; ++i) {
		int cnt = 1;
		while (i < n - 1 && s[i].first == s[i + 1].first) ans += cnt++, i++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8192
<?php
  fscanf(STDIN,"%s",$a);
  $arr = str_split($a);
  $s = 0;
  if($arr[0] == "1"){ ++$s; }
  if($arr[1] == "1"){ ++$s; }
  if($arr[2] == "1"){ ++$s; }
  echo $s;
?>

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1<<27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void yn(bool j){cout << (j ? "Yes" : "No") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> long long bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> void sortTwoVecter(vector<T1> &f, vector<T2> &s, bool isReverse = false){
    vector<pair<T1, T2>> p;
    rep(i, f.size()) p.emplace_back(make_pair(f[i], s[i]));
    if (!isReverse) sort(p.begin(), p.end());
    else sort(p.rbegin(), p.rend());
    rep(i, f.size()) tie(f[i], s[i]) = p[i];
    return;
}

ll N;
ll cnt = 0;
void dfs(string s){
    if (11 <= s.size()) return;
    // pt(s);
    ll num = stoi(s);
    if (N < num) return;
    bool t = false, f = false, sv = false;
    rep(i, s.size()){
        if (s[i] == '3') t = true;
        if (s[i] == '5') f = true;
        if (s[i] == '7') sv = true;
    }
    if (t && f && sv) cnt++;
    dfs(s + '3');
    dfs(s + '5');
    dfs(s + '7');
}


int main(){
    cin >> N;
    dfs("0");
    pt(cnt);
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	A, B, K := sc.NextInt(), sc.NextInt(), sc.NextInt()
	count := 0
	for i := min(A, B); i >= 1; i-- {
		if A%i == 0 && B%i == 0 {
			count++
			if count == K {
				fmt.Println(i)
				break
			}
		}
	}

}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


Measured memory_bytes: 640
P,Q,R = map(int,input().split())

Ans1 = P + Q
Ans2 = Q + R
Ans3 = R + P

if(Ans1 > Ans2):
	Ans1 = Ans2

if(Ans1 > Ans3):
	Ans1 = Ans3

print (Ans1)


Measured memory_bytes: 2940
program main
  implicit none
  
  integer(16) :: i,j,n,m,l,p=0,q=0
  
  read(*,*)n
  m = int(sqrt(real(n)))
  do i = 1, m
    l = n/i
    if (i*l == n) then
      p = i
      q = l
    end if
  end do
  write(*,'(i0)')p+q-2
end program main

Measured memory_bytes: 256
M, K = map(int,input().split())


if M == 1 and K == 1:
    print(-1)
elif M==1 and K == 0:
    print("0 0 1 1")
elif K >= 2**M:
    print(-1)
else:
    M = [i for i in range(2**M)]
    M.remove(K)
    ans = M + [K] + M[::-1] + [K]
    anstr = ""
    for a in ans:
        anstr += str(a) + " "
    print(anstr[:-1])

Measured memory_bytes: 16524
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
int n;
int cnt[N];
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		int x;
		scanf("%d", &x);
		if(x) ++cnt[x - 1];
		++cnt[x];
		++cnt[x + 1];
	}
	int ans = 0;
	for(int i = 0; i <= 100001; ++i) ans = max(ans, cnt[i]);
	printf("%d\n", ans); 
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    int p[8],c[8][8]={{1,2,1,2,1,4,1,4},
                        {1,2,1,4,1,4,1,2},
                        {1,4,1,2,1,2,1,4},
                        {1,4,1,4,1,2,1,2},
                        {2,1,2,1,4,1,4,1},
                        {2,1,4,1,4,1,2,1},
                        {4,1,2,1,2,1,4,1},
                        {4,1,4,1,2,1,2,1}};
    while(cin>>p[0]){
        for(int i=1;i<8;i++){
            cin>>p[i];
        }
        int q=0,ans=1000000,over=0;
        for(int i=0;i<8;i++){
            over=0;
            for(int j=0;j<8;j++){
                int o=0;
                if(p[j]-c[i][j]<0)o=0;
                else o=p[j]-c[i][j];
                over+=o;
            }
            if(over<ans){
                ans=over;
                q=i;
            }
        }
        for(int i=0;i<7;i++){
            cout<<c[q][i]<<" ";
        }
        cout<<c[q][7]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  
  double s = x / a;
  double ans;
  if(a * b == x/a){
    ans = 0;
  }
  else if (s < 0.5 * a * b) {
    double h = 2 * s / b;
    ans = atan(b/h) * 180 / M_PI;
      }else{
    //(bu+b)*a/2 = s
    double bu = 2*s/a -b;
    b-=bu;
    s-=a*bu;
    double h = 2 * s / b;
    ans = atan(b/h) * 180 / M_PI;
  }
  printf("%.10f\n",ans);
  return 0;
}

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

ll ans;
string s;

int dp(int i,ll j,ll k)
{
    if(i == s.length()-1) ans += j + k;
    else{
        dp(i+1,j+k,s[i+1]-'0');
        dp(i+1,j,k*10+s[i+1]-'0');
    }
    return 0;
}

int main()
{
    cin >> s;
    dp(0,0,s[0]-'0');
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include <algorithm>
using namespace std;
int abc113_b(){
    // 入力
    int n,t,a;
    cin >> n >> t >> a;
    vector<int> v;
    vector<double> w;
    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }

    //処理
    for (int i = 0; i < n; ++i) {
        double tmp = abs(a-t+v[i]*0.006);
        w.push_back(tmp);
    }
    vector<double>::iterator iter = min_element(w.begin(), w.end());
    size_t index = distance(w.begin(), iter);
    
    //出力
    cout << index+1 << endl;
    return 0;
}

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


Measured memory_bytes: 256
import java.util.*;

public class Main {


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

        int n  = sc.nextInt();

        ArrayList<Integer> p = new ArrayList<>();

        for(int i = 0; i < n; i++){
            p.add(sc.nextInt());
        }

        ArrayList<Integer> calcList = new ArrayList<>();
        int ans = 0;
        for(int i = 1; i < n - 1; i++){
            calcList.addAll(p.subList(i - 1, i + 2));
            Collections.sort(calcList);
            if(calcList.get(1).equals(p.get(i))){
                ans++;
            }

            calcList.clear();
        }

        System.out.println(ans);

        return;
    }
}


Measured memory_bytes: 21972
#include <iostream>

using namespace std;

typedef long long ll;
int main() {
    ll L, R, min = 2018;

    cin >> L >> R;
    if(R-L >= 2019) min = 0;
    else {
        for(ll i=L; i<=R-1; i++) {
            for(ll j=i+1; j<=R; j++) {
                ll t = (i*j)%2019;
                if(t<min) min = t;
            }
        }
    }

    cout << min << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
using namespace std;

/*MyAnswer*/
int main(void)
{
  int N;
  scanf("%d",&N);
  int A[N];
  int n = 0;
  int count[N];
  for(n = 0;n < N;n++){
    count[n] = 0;
  }
  int l;
  n = 0;
  while(n < N && cin>>l){
    A[n] = l;
    while(A[n]%2==0){
      A[n] = A[n]/2;
      count[n] = count[n] + 1;
    }
      n++;
  }
  int minCount = count[0];
  for(n = 0;n < N-1;n++){
    minCount = min(minCount,count[n]);
  }
  printf("%d\n",minCount);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

typedef long long ll;

int main(){
    char s[100001];
    ll r=0,b=0;
    scanf("%s",s);
    for(int i=0;i<strlen(s);i++){
        if(s[i]=='0') r++;
        else b++;
    }
    printf("%lld",2*((r>b)?b:r));

    return 0;
}

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

#define pb push_back
#define MAX 100005
#define ff first
#define INF 1000000005
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;

int n,h[100005],k;
int dp[100005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    for(int i = 0; i<n; ++i){
        cin>>h[i];
        dp[i] = INF;
    }
    dp[n-1]=0;
    for(int i = n-2;i>=0; i--){
        for(int j = 1; j<=k && i+j<n; ++j){
            dp[i] = min(dp[i],dp[i+j]+abs(h[i]-h[i+j])); 
        }
    }
    cout<<dp[0]<<"\n";
    return 0;
}

Measured memory_bytes: 1024
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
char in[110];
int main(){
	int a;scanf("%d",&a);
	double ret=0;
	for(int i=0;i<a;i++){
		double t;scanf("%lf%s",&t,in);
		if(in[0]=='J')ret+=t;
		else ret+=t*380000;
	}
	printf("%.12f\n",ret);
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    rep(i, n) cin >> a[i];
    mf_graph<int> graph(n*m+2);
    int s = n*m, t = n*m+1;
    rep(i, n) rep(j, m) {
        if (a[i][j]=='#') continue;
        if ((i+j)%2) graph.add_edge(i*m+j, t, 1);
        else graph.add_edge(s, i*m+j, 1);
    }
    rep(i, n) rep(j, m) {
        if ((i+j)%2 || a[i][j]=='#') continue;
        if (i>0 && a[i-1][j]=='.') graph.add_edge(i*m+j, (i-1)*m+j, 1);
        if (i<n-1 && a[i+1][j]=='.') graph.add_edge(i*m+j, (i+1)*m+j, 1);
        if (j>0 && a[i][j-1]=='.') graph.add_edge(i*m+j, i*m+j-1, 1);
        if (j<m-1 && a[i][j+1]=='.') graph.add_edge(i*m+j, i*m+j+1, 1);
    }
    cout << graph.flow(s, t) << endl;
    const auto& edges = graph.edges();
    for (const auto& e: edges) {
        if (e.from==s || e.to==t || e.flow==0) continue;
        int e0, e1;
        if (e.from<e.to) e0 = e.from, e1 = e.to;
        else e0 = e.to, e1 = e.from;
        int x0 = e0/m, y0 = e0%m, x1 = e1/m, y1 = e1%m;
        if (abs(x1-x0)==1) {
            a[x0][y0] = 'v';
            a[x1][y1] = '^';
        } else {
            a[x0][y0] = '>';
            a[x1][y1] = '<';
        }
    }
    rep(i, n) cout << a[i] << endl;
    return 0;
}

Measured memory_bytes: 5444
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define ll long long int
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define Mod 1000000007
#define limit 1000008
using namespace std;

void solve(int t)
{
    int i,j,n,m,ck=0,ct=0;
    cin >> n;
    int A[n+5][2];
    for(i=0; i<n; i++)
        cin >> A[i][0] >> A[i][1];
    for(i=0; i<n; i++)
    {
        if(A[i][0]!=A[i][1])
        {
            ct = 0;
        }
        else
        {
            ct++;
            if(ct>=3)
                ck=1;
        }
    }
    if(ck)
        cout <<"Yes\n";
    else
        cout <<"No\n";
    return ;
}
int  main()
{
//    Fast
//    Freed
//    Fout
    int t,tt=1;
   // cin >> tt;
    for(t=1; t<=tt; t++)
        solve(t);
    return 0;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
long long n,m,k,a[100005],dp[100005];
long long solve(long long p){
	if(p>n)return 1LL<<62;
	if(p==n)return 0;
	if(dp[p]>=1)return dp[p];
	long long p1=1LL<<62,p2=0,ret=1LL<<62;
	for(int i=p+1;i<=p+m;i++){
		p1=min(p1,a[i-1]);p2=max(p2,a[i-1]);
		ret=min(ret,solve(i)+(p2-p1)*(i-p)+k);
	}
	dp[p]=ret;
	return ret;
}
int main(){
	cin>>n>>m>>k;for(int i=0;i<n;i++)cin>>a[i];
	cout<<solve(0)<<endl;
	return 0;
}

Measured memory_bytes: 4308
from bisect import bisect_left

N,M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
# 一回の握手でとりうる最大の得点+1
hi = 2*10**5+1
lo = 0


# 一回の握手で得られる幸福度がmid以上になるような握手のみで、握手回数がM回を超えるか調べていく
while hi - lo > 1:
    mid = (hi+lo)//2
    # 左手の得点をaとしたときに一回の握手でmid点以上得られる握手の組み合わせの数
    cnt_hs = 0
    for a in A:
        # 左手の得点がaのとき、midを超えるにはもう一方の右手でmid-x以上の点をとる必要がある
        right = mid - a
        idx = bisect_left(A, right)
        # Aのうち、idxより先のものを選べばその握手の点がmidを超える
        cnt_hs += N - idx
    
    # mid以上の点を得られる握手の組み合わせの数がMを超えているな、必要以上に握手しているから、握手回数を減らす方向に調整
    if cnt_hs >= M:
        lo = mid
    else:
        hi = mid
        

# M回以上の握手するには一回の握手で何点とりましょう、という点の最低ラインloが求まった

B = sorted(A, reverse=True)
accum_B = [0]*N
accum_B[0] = B[0]
for i in range(1,N):
    accum_B[i] = accum_B[i-1] + B[i]

ans = 0
cnt_hs = 0
for a in A:
    # 一回の握手でlo点以上得るためにとるべき、右手の最低点
    right = lo - a
    # aを使った場合はlo点以上とれないならスキップ
    if A[-1] < right:
        continue
    idx = bisect_left(A, right)
    # aをN-idx回と、Aについてidxより先の部分の和の合計を得る
    # sum(A[idx:])みたいにできなくもないけど毎回計算するより累積でやる方が効率いい
    ans += a*(N-idx) + accum_B[N-1 - idx]
    # lo点以上得られる握手回数を累計
    cnt_hs += N-idx

# 設定回数以上握手している場合はその分減らす
# 一回の握手の最低点がloなので、一回オーバーするごとにlo減らす？
# とりうる握手の最低点はloだけど、この設定において実際の握手の最低点はloになっていて、本当にそれが複数あるのか？
if cnt_hs > M:
    ans -= (cnt_hs - M) * lo

print(ans)

Measured memory_bytes: 14460
#include<bits/stdc++.h>
#define fi(init, n) for(int i = init; i < n; i++)
#define fj(init, n) for(int j = init; j < n; j++)
typedef long long ll;
using namespace std;

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

    string s;
    cin >> s;
    cout << s[0]<<s[1]<<s[2];

    return 0;
}

Measured memory_bytes: 3652
#include"bits/stdc++.h"
//#include<boost/multi_array.hpp>
//#include<boost/optional.hpp>
//#include<boost/range/irange.hpp>
//#include<boost/range/algorithm.hpp>
//#include<boost/range/adaptors.hpp>

using namespace std;
//namespace adaptor = boost::adaptors;

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

void Main()
{
    int a, b;
    cin >> a >> b;
    for(int i = 1; i < 10001; i++) {
        if(int(i * 1.08) == i + a && int(i * 1.10) == i + b) {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

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

Measured memory_bytes: 256
N,M = map(int,input().split())
ls = []
for i in range(M):
    P,Y = map(int,input().split())
    ls.append([P,Y,i])
ls.sort()
num = 1
city = ls[0][0]
for i in range(M):
    if ls[i][0] == city:
        ls[i][1] = num
        num += 1
    else:
        num = 1
        ls[i][1] = num
        city = ls[i][0]
        num += 1
ls.sort(key=lambda x:x[2])
for i in range(M):
    print('{0:06d}'.format(ls[i][0])+'{0:06d}'.format(ls[i][1]))

Measured memory_bytes: 30548
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 100005
using namespace std;
using LL = long long;
int n,m,q;
LL in1[M], in2[M];
int main()
{
    while (~scanf("%d %d %d",&n, &m, &q)) {
        REP(i,1,n) scanf("%lld", &in1[i]);
        REP(i,1,m) scanf("%lld", &in2[i]);
        sort(in1+1, in1+n+1);
        sort(in2+1, in2+m+1);

        while (q--) {
            LL x, ans=(1LL<<61);
            LL a[2]={-1, -1}, b[2]={-1, -1};
            scanf("%lld", &x);

            int p = upper_bound(in1+1, in1+n+1, x) - in1 - 1;
            if (p>=1) a[0] = in1[p];
            p = lower_bound(in1+1, in1+n+1, x) - in1;
            if (p<=n) a[1] = in1[p];

            p = upper_bound(in2+1, in2+m+1, x) - in2 - 1;
            if (p>=1) b[0] = in2[p];
            p = lower_bound(in2+1, in2+m+1, x) - in2;
            if (p<=m) b[1] = in2[p];

            REP(i,0,1) REP(j,0,1) if (a[i]!=-1 && b[j]!=-1) {
                LL mi=0, mx=0;
                mi = min(mi, a[i]-x);
                mi = min(mi, b[j]-x);
                mx = max(mx, a[i]-x);
                mx = max(mx, b[j]-x);

                LL dis = min(abs(mi), abs(mx))*2 + max(abs(mi), abs(mx));
                ans = min(ans, dis);
            }
            printf("%lld\n", ans);
        }
    }
    
    return 0;
}



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

int main() {
    while (1)
    {
        string x;
        cin >> x;
        if(x=="-") break;
        int n=0;
        cin >> n;
        for(int i=0; i<n; i++){
            int h=0;
            cin >> h;
            int s=x.size();
            string bck = x.substr(0, h);
            string frnt = x.substr(h, s-h);
            x = frnt + bck;
        }
        cout << x << endl;
    }
    
    return 0;
}




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

using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Input();
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);

            int[] ans = new int[3];
            ans[0] = A + B;
            ans[1] = A - B;
            ans[2] = A * B;

            Console.WriteLine(ans.Max());
        }

        static string[] Input() => System.Console.ReadLine().Split();
    }
}


Measured memory_bytes: 13268
while(True):
    n,x = map(int,input().split())
    if n == 0 and x == 0:exit();
    count = 0
    for i in range(1,n):
        for j in range(i+1,n):
            for k in range(j+1,n+1):
                if i+j+k == x:
                    count += 1
    print(count)




Measured memory_bytes: 5592
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int A=sc.nextInt();
int B=sc.nextInt();
int C=sc.nextInt();
int D=sc.nextInt();
String ans;
if(A+B==C+D){ans="Balanced";}else if(A+B>C+D){ans="Left";}else{ans="Right";}
System.out.println(ans);
}}

Measured memory_bytes: 23892
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int N, M, C;
	int B[20];
	int A[20][20];
	cin >> N >> M >> C;
	int t;
	int a, b;
	for (t = 0; t < M; t++) {
		cin >> b;
		B[t]=b;
	}
	int i;
	for (i = 0; i < N; i++) {
		for (t = 0; t < M; t++) {
			cin >> a;
			A[i][t] = a;
		}
	}



	int answer=0;
	int total = 0;

	for (i = 0; i < N; i++) {
		total = 0;
		for (t = 0; t < M; t++) {
			total += A[i][t] * B[t];
		}
		total += C;

		if (total > 0)
			answer++;
	}
	cout << answer;
	return 0;
}


Measured memory_bytes: 764
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, a, N);
    bool ok = false;
    FOR(x, a)
    {
        ok |= x & 1;
    }
    YES(ok, "first", "second");
}

Measured memory_bytes: 3960
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max<int>(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max<int>(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

constexpr long long inf = (1ll << 60);

int main() {
  int N, X;
  std::cin >> N >> X;
  std::vector<int> A(N);
  for (int &x: A) {
    std::cin >> x;
  }
  long long ans = inf;
  std::vector<int> min = A;
  for (int d: range(0, N)) {
    long long sum = 0;
    for (int x: min) {
      sum += x;
    }
    chmin(ans, sum + (long long) X * d);
    for (int i: range(0, N)) {
      chmin(min[i], A[(i - d - 1 + N) % N]);
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
#define rep(i,b) loop(i,0,b)
#define loop(i,a,b) for(int i=(a);i<int(b);i++)

int s,d,m;
int k[128], w[128][64], p[128][64], f[128];
int dp[512];

void solve(){
    memset(dp,0,sizeof(dp));
    rep(i,d)rep(j,k[f[i]]){
        int p=::p[f[i]][j];
        int w=::w[f[i]][j];
        for(int l=m;;l--){
            if(l-p>=0)
                dp[l]=max(dp[l],dp[l-p]+w);
            else
                break;
        }
    }
    int ans=0;
    rep(i,m+1){
        if(dp[i]>dp[ans]){
            ans=i;
        }
    }
    cout<<dp[ans]<<" "<<ans<<endl;
}

int main(){
    while(scanf("%d%d%d",&s,&d,&m)!=EOF){
        rep(i,s){
            scanf("%d",&k[i]);
            rep(j,k[i]){
                scanf("%d%d",&w[i][j],&p[i][j]);
            }
        }
        rep(i,d){
            scanf("%d",&f[i]);
        }
        solve();
    }
}

Measured memory_bytes: 1268
use std::io;

/// 一行を読み込んで、空白で区切ったベクタにして返す
#[allow(dead_code)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect()
}

/// n行を読み込んで、数字を空白で区切って二次元のベクタにして返す
#[allow(dead_code)]
fn read_table<T>(n: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut ret: Vec<Vec<T>> = Vec::new();
    for _ in 0..n {
        ret.push(read::<T>());
    }
    ret
}

/// n行を読み込んで、1文字ずつを二次元のベクタにして返す
#[allow(dead_code)]
fn read_char_table(n: usize) -> Vec<Vec<char>> {
    let mut ret: Vec<Vec<char>> = Vec::new();
    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let chr = buf.trim().chars().collect();
        ret.push(chr);
    }
    ret
}

/// n行を読み込んで、一次元のベクタにして返す
#[allow(dead_code)]
fn read_array<T>(n: usize) -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut array = Vec::new();

    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        array.push(buf.trim().parse().unwrap());
    }
    array
}

fn main() {
    // 数値
    let k = {
        let i = read::<isize>();
        (i[0])
    };


    let t = k % 2;
    let v = k / 2;

    let ans = v * (v + t);

    println!("{}", ans);
}


Measured memory_bytes: 4352
# coding=utf-8

###
### for atcorder program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def get_input():
    N = []
    while True:
        try:
            N.append(input())
        except EOFError:
            break
    return N

def main():

    while True:
        N = int(input())
        if N == 0:
            break
        data = [int(x) for x in input().split()]

        m = sum(data) / N
    
        t = 0
        for i in data:
            t += (i-m)**2

        print(math.sqrt(t/N))



if __name__ == '__main__':
    main()




Measured memory_bytes: 5724