akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
 
using namespace std;
#define SAY_YES cout<<"YES"<<endl;
#define SAY_Yes cout<<"Yes"<<endl;
#define SAY_NO cout<<"NO"<<endl;
#define SAY_No cout<<"No"<<endl;
#define IFYES(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} 
#define IFYes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} 
#define IFyes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"yes"<<endl;}else{cout<<"no"<<endl;} 
#define DEBUG_OUTPUT_ARRAY(XXX,ONE) for(int i=0;i<(ONE);i++){cout<<"DEBUG: i = "<<i<<" -> "<<XXX[i]<<endl;}
#define DEBUG_OUTPUT_ARRAY2(XXX,ONE,TWO) for(int i=0;i<(ONE);i++){cout<<"<<< i = "<<i<<" >>>"<<endl;for(int j=0;j<(TWO);j++){cout<<"DEBUG: j = "<<j<<" -> "<<XXX[i][j]<<endl; } }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX,ONE,TWO) for(int i=0;i<(ONE);i++){cout<<i<<"  ";for(int j=0;j<(TWO);j++){cout<<XXX[i][j]<<" "; } cout<<endl;}
 
typedef pair<long long int,long long int> pll;
 
 
const long long int mod=1000000007;
const long long int INF=99999999999999999;
 
long long int N,K,a[105],res=INF;
int main() {
	cout << fixed << setprecision(18);
    cin>>N>>K;
    for(int i=0;i<N;i++){cin>>a[i];}
    for(int i=0;i<(1<<N-1);i++){
        long long int tmp=1,mymax=a[0],money=0;
        for(int j=0;j<N-1;j++){
            if(((1<<j)&i)==0){
                if(mymax>=a[j+1]){
                    money+=(-a[j+1]+mymax)+1;
                    mymax++;
                }
                tmp++;
            }else if(mymax<a[j+1]){
                tmp++;
            }
            mymax=max(mymax,a[j+1]);
        }
        if(tmp>=K){res=min(res,money);}
    }
    cout<<res<<endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f   first
#define s   second
#define pb          push_back
#define mod         1000000007
#define hell        998244353
#define inf         1000000000000000000LL
using namespace std;
ll n,k,m;
//ll dp[15][1005];
ll dp[100005];
ll lvl[100005];
ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2){res=(res*x)%mod;}
        x=(x*x)%mod;
        y/=2;
    }
    return res;
}
ll invmod(ll x)
{ return power(x,mod-2);}
void solve()
{   ll W,X,D,Y;
    cin>>n>>X>>Y;
    ll dis[n+1];
    memset(dis,0,sizeof(dis));
    ll dp[n];
    memset(dp,0,sizeof(dp));
    for(int i=2;i<=X;i++)
        dis[i]=i-1;
    dis[Y]=dis[X]+1;
    for(int i=X+1;i<Y;i++)
        dis[i]=min((ll)i-1,dis[Y]+(Y-i));
    for(int i=Y+1;i<=n;i++)
        dis[i]=dis[Y]+(i-Y);
    //for(int i=2;i<=n;i++) cout<<dis[i]<<" ";
    for(int i=1;i<=n;i++) dp[dis[i]]++;
    for(ll i=2;i<n;i++)
    {
        for(ll j=i+1;j<=n;j++)
        {   ll x;
            if(i>X && i<Y)
                if(j<Y)
                x=min(j-i,Y-X+1-(j-i));
            else x=(j-Y)+min(Y-i,i-X+1);
            else x=dis[j]-dis[i];
            //cout<<x<<" ";
            dp[x]++;
        }
        //cout<<"\n";
    }
    for(int i=1;i<n;i++)
        cout<<dp[i]<<"\n";
    


    
   

    
}

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

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
string s;
cin>>s;
if(s.at(5)=='0'&&s.at(6)<'5'){
    cout<<"Heisei"<<endl;
}else{
    cout<<"TBD"<<endl;
}

}









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

int main(){
	int a,b,c,d;
  	cin >> a >> b >> c >> d;
  
  	while( (a>0) && (c>0)){//aもbも体力がある間
      	c = c - b;
      	if(c<=0){//青木が負けたら
        	cout << "Yes" <<endl;
          	break;
        }
    	
      	a = a - d;
      	if(a<=0){//高橋が負けたら
        	cout << "No" << endl;
          	break;
        }
    }
  	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
using namespace std;
int main(){
	
	int n,m,a[80],b[80],k[57]={0};
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>a[i];
		k[a[i]]++;
		cin>>b[i];
		k[b[i]]++;
	}
	for(int i=1;i<=n;i++){
		cout<<k[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int a,b=0;
  cin>>a;
  b+=a/500*1000;
  a%=500;
  b+=a/5*5;
  co(b);
  return 0;
}


Measured memory_bytes: 256
#C問題
N,Y=map(int,input().split())
flag=0
for x in range(N+1):
    for y in range(N+1):
        if x+y>N:
            pass
        else:
            z=N-(x+y)
            if 10000*x+5000*y+1000*z == Y:
                flag=1
                X,Y,Z=x,y,z
                break
    if flag == 1:
        break
if flag == 0:
    print(-1,-1,-1,)
else:
    print(X,Y,Z)

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

int main() {
    int n;
    cin >> n;
    int MAX = 1e5 + 2;
    vector<int> a(n), b(n);
    vector<int> imos(MAX);
    vector<int> sum(MAX), rsum(MAX);
    for(int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
        imos[a[i]]++;
        imos[b[i]]--;
        sum[b[i]]++;
        rsum[a[i]]++;
    }
    for(int i = 1; i < MAX; ++i) {
        imos[i] += imos[i - 1];
        sum[i] += sum[i - 1];
    }
    for(int i = MAX - 1; i >= 1; --i) {
        rsum[i - 1] += rsum[i];
    }
    int ans1 = 0, ans2 = *max_element(imos.begin(), imos.end());
    for(int i = 0; i < n; ++i) {
        ans1 = max(ans1, n - sum[a[i]] - rsum[b[i]]);
    }
    cout << ans1 << ' ' << ans2 << endl;
}



Measured memory_bytes: 5472
/*  -*- coding: utf-8 -*-
 *
 * 3108.cc: Perfect
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 4;
const int MAX_W = 4;
const int M = 4;
const int BH = 4;
const int BW = 10;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

struct Tetro {
  int h, w;
  char cs[MAX_H][MAX_W + 4];
  Tetro() {}

  void read() {
    scanf("%d%d", &h, &w);
    for (int y = 0; y < h; y++) scanf("%s", cs[y]);
  }
};

struct Board {
  char bs[BH][BW + 4];
  Board() {}

  void read() {
    for (int y = 0; y < BH; y++) scanf("%s", bs[y]);
  }

  bool fit(Tetro &t, int x0, int y0) {
    if (y0 + t.h > BH || x0 + t.w > BW) return false;
    for (int ty = 0, by = y0; ty < t.h; ty++, by++)
      for (int tx = 0, bx = x0; tx < t.w; tx++, bx++)
	if (t.cs[ty][tx] == '#' && bs[by][bx] == '#') return false;
    return true;
  }

  void set(Tetro &t, int x0, int y0, char c) {
    for (int ty = 0, by = y0; ty < t.h; ty++, by++)
      for (int tx = 0, bx = x0; tx < t.w; tx++, bx++)
	if (t.cs[ty][tx] == '#') bs[by][bx] = c;
  }
  void set(Tetro &t, int x0, int y0) { set(t, x0, y0, '#'); }
  void unset(Tetro &t, int x0, int y0) { set(t, x0, y0, '.'); }
};

/* global variables */


Tetro ts[M];
Board bd;

/* subroutines */

bool check(int k, int u) {
  if (k >= M) return (u >= M - 1);

  Tetro &tk = ts[k];
  if (check(k + 1, u)) return true;

  for (int y0 = 0; y0 + tk.h <= BH; y0++)
    for (int x0 = 0; x0 + tk.w <= BW; x0++)
      if (bd.fit(tk, x0, y0)) {
	bd.set(tk, x0, y0);
	if (check(k + 1, u + 1)) return true;
	bd.unset(tk, x0, y0);
      }
  return false;
}

/* main */

int main() {
  for (int i = 0; i < M; i++) ts[i].read();

  int n;
  scanf("%d", &n);

  while (n--) {
    bd.read();

    if (check(0, 0)) puts("Yes");
    else puts("No");
  }
  return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<20,INF=1<<20;
const long double eps=1e-13;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,K;cin>>N>>K;
    vector<long double> x(N),y(N),c(N);
    for(int i=0;i<N;i++) cin>>x[i]>>y[i]>>c[i];
    
    long double left=0.0,right=1e6;
    
    if(K==1){
        cout<<0<<endl;
        return 0;
    }
    
    if(K==2){
        long double ans=INF;
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                ans=min(ans,(hypot(x[i]-x[j],y[i]-y[j])*c[i]*c[j])/(c[i]+c[j]));
            }
        }
        
        cout<<setprecision(25)<<ans<<endl;
        return 0;
    }
    
    for(int q=0;q<100;q++){
        long double mid=(left+right)/2.0;
        bool ok=false;
        
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(i==j) continue;
                int cnt=0;
                long double ri=mid/c[i],rj=mid/c[j];
                if(ri>rj+eps) continue;
                if(hypot(x[i]-x[j],y[i]-y[j])>ri+rj+eps) continue;
                
                long double x1=x[j]-x[i],y1=y[j]-y[i],a=(x1*x1+y1*y1+ri*ri-rj*rj)/2.0;
                
                long double xx=(a*x1+y1*sqrt((x1*x1+y1*y1)*ri*ri-a*a))/(x1*x1+y1*y1);
                long double yy=(a*y1-x1*sqrt((x1*x1+y1*y1)*ri*ri-a*a))/(x1*x1+y1*y1);
                
                //cout<<x1<<" "<<y1<<" "<<a<<" "<<ri<<" "<<rj<<" "<<xx<<" "<<yy<<endl;
                //cout<<ri<<" "<<a<<" "<<(x1*x1+y1*y1)*ri*ri-a*a+eps<<endl;
                
                xx+=x[i];
                yy+=y[i];
                
                if(hypot(x1,y1)+ri<rj+eps) continue;
                
                for(int k=0;k<N;k++){
                    if(hypot(xx-x[k],yy-y[k])<=mid/c[k]+eps) cnt++;
                }
                if(cnt>=K) ok=true;
            }
        }
        
        for(int i=0;i<N;i++){
            int cnt=0;
            for(int k=0;k<N;k++){
                if(hypot(x[i]-x[k],y[i]-y[k])<=mid/c[k]+eps) cnt++;
            }
            if(cnt>=K) ok=true;
        }
        
        if(ok) right=mid;
        else left=mid;
    }
    
    cout<<setprecision(25)<<right<<endl;
}






Measured memory_bytes: 256
# バージョン 3.4.X 以前
import fractions
# バージョン 3.5 以降
# mport math


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


def main():
    A, B, C, D = map(int, input().split())
    first = B // C - A // C
    first += 1 if A % C == 0 else 0
    second = B // D - A // D
    second += 1 if A % D == 0 else 0
    tmp = lcm(C, D)
    both = B // tmp - A // tmp
    both += 1 if A % tmp == 0 else 0
    print(B - A + 1 - first - second + both)
    return


main()


Measured memory_bytes: 5048
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var N = int.Parse(Console.ReadLine());

            var fact = 1;
            var town = new int[N][];
            for (int i = 0; i < N; i++)
            {
                fact *= i + 1;
                town[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            }

            var dist = 0.0;
            var x = 0;
            var y = 0;
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }
                    x = Math.Abs(town[i][0] - town[j][0]) * Math.Abs(town[i][0] - town[j][0]);
                    y = Math.Abs(town[i][1] - town[j][1]) * Math.Abs(town[i][1] - town[j][1]);
                    dist += (fact / N) * Math.Sqrt(x + y);
                }
            }

            Console.WriteLine(dist / fact);
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}

ll INF = 1e+18;
int iINF = 1e9;
int MAXI = 1e8 + 1;
using vec = vector<int>;

int 
main()
{
  int N, M; cin >> N >> M;
  int formula = (1900 * M) + ((N - M) * 100);
  int prob = (1 << M);
  cout << formula * prob << endl;
}

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

using namespace std;

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

    int n, d;
    cin >> n >> d;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        long long x, y;
        cin >> x >> y;
        if (d * 1LL * d >= x * x + y * y)
            ans++;
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,a,aa[110000];
pair<int,int> p[220000];
string s;
char c;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
    }
    rep(i,n){
        if(aa[i]%2==0){
            if(aa[i]%3!=0&&aa[i]%5!=0){
                cout<<"DENIED";
                return 0;
            }
        }
    }
    cout<<"APPROVED";
}

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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}


bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

bool palin(string S){//回文判定
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
/*vector<int> d(N+1,-1);

//頂点xとの各点との最短距離を求める
void bfs(int x,Graph &G){
  d[x] = 0;
  queue<<int> que;
  que.push(x);

  // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
}*/

int main(){
  int N;
  cin >> N;
  vector<int> A(N+2);
  for(int i = 1;i<=N;i++){
    cin >> A[i];
  }
  ll sum = 0;
  for(int i = 0;i<N+1;i++){
    sum += abs(A[i]-A[i+1]);
  }
  
  for(int i = 1;i<=N;i++){
    ll ans = 0;
    ans = sum - (abs(A[i-1]-A[i]) + abs(A[i]-A[i+1])) + abs(A[i-1]-A[i+1]);
    cout << ans << endl;
  }

 }

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

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

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    int ans = x;
    ans -= a;
    ans = ans - b*(ans/b);
    cout << ans << endl;
}

Measured memory_bytes: 256
#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>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char notes[110][10];
ll treasure[3030][3030];
ll dp[3030][3030][4];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	for (ll i = k + 1;i <= n;++i) {
		ll shukai = n / i;
		ll nokori = n % i;
		ll res = max((ll)0, i - k);
		ans += shukai * res;
		if (k == 0) {
			ans += nokori;
		}
		else {
			ans += max((ll)0, nokori + 1 - k);
		}
	}
	cout << ans << endl;
	return 0;
}


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

#define int long long

#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 2e5 + 5;

vector < int > Y[N],D[N];
int V[N],par[N],W[N],pw[N],M[N],pre[N],suf[N],sz[N],dep[N],n,i,j,x,y,ans;

void g(int x){
    M[x] = sz[x] = dep[x] == i;
    for(int i=0; i<Y[x].size(); i++){
        g(Y[x][i]);
        sz[x] += sz[ Y[x][i] ];
    }
    
    for(int i=0; i<Y[x].size(); i++)
        pre[i] = (pw[ sz[ Y[x][i] ] ] - M[ Y[x][i] ]) * (i ? pre[i-1] : 1) % mod;
    suf[ Y[x].size() ] = 1;
    for(int i=Y[x].size()-1; i>=0; i--)
        suf[i] = (pw[ sz[ Y[x][i] ] ] - M[ Y[x][i] ]) * suf[i+1] % mod;

    for(int i=0; i<Y[x].size(); i++)
        M[x] = (M[x] + M[ Y[x][i] ] * (i ? pre[i-1] : 1) % mod * suf[i+1]) % mod;
}

signed main(){
    cin >> n;
    for(pw[0]=i=1;i<=n;i++){
        scanf("%lld",&x);
        par[i] = x;
        V[x]++;
        dep[i] = dep[x]+1;
        D[ dep[i] ].pb(i);
        pw[i] = pw[i-1]*2 % mod;
    }

    ans = pw[n];
    for(i=1 ;; i++){
        if(D[i].size() == 0) break;
        for(j=0;j<D[i].size();j++){
            x = D[i][j];
            y = par[x];
            if(V[y] == 1 && y){
                Y[ par[y] ][ W[y] ] = x;
                W[x] = W[y];
                par[x] = par[y];
            }
            else{
                W[x] = Y[y].size();
                Y[y].pb(x);
            }
        }
        g(0);
        ans = (ans + M[0] * pw[ n+1-D[i].size() ]) % mod;
    }
    
    cout << (ans + mod) % mod;
    return 0;
}

Measured memory_bytes: 29952
x, y = map(int,input().split())
invx = -1*x
invy = -1*y
absx = abs(x)
absy = abs(y)
if x <= y:
    if y <= 0:
        print(str(y-x))
    elif x < 0:
        print(str(1 + abs(y - invx)))
    else:
        print(str(y-x))
else:
    if y == 0:
        print(str(1 + y - invx))
    elif y > 0:
        print(str(2 + invy - invx))
    elif x >= 0:
        print(str(1 + abs(y - invx)))
    else:
        print(str(2 + abs(x-y)))

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

#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define ll long long

int main(){
  ll a;
  string b;
  cin >> a >> b;

  ll c = 0;
  for(char i : b){
    if(i != '.') c = c*10 + i-'0';
  }

  ll ans = a * c / 100;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3616
#include<cstdio>

int main() {
  int height, width;

  while(true) {
    scanf("%d %d", &height, &width);

    if(height == 0 && width == 0) {
      break;
    }

    for(int i = 0; i < height; i++) {
      char current_char = (i % 2 == 0) ? '#' : '.';

      for(int j = 0; j < width; j++) {
        printf("%c", current_char);

        current_char = (current_char == '#') ? '.' : '#';
      }
      printf("\n");
    }

    printf("\n");
  }
}



Measured memory_bytes: 2684
# -*- coding: utf-8 -*-

X = int(input())
inf = 10 ** 5 + 10


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


prime_list = primes(inf)

for p in prime_list:
    if p >= X:
        print(p)
        exit()


Measured memory_bytes: 4148
import sys
N, W = map(int, input().split())
dp = [0] * (W + 1)
for weight, value in map(lambda x: map(int, x.split()), sys.stdin):
    for w in range(W - weight, -1, -1):
        if dp[w + weight] < dp[w] + value:
            dp[w + weight] = dp[w] + value
print(dp[-1])

Measured memory_bytes: 42876
from collections import defaultdict
import sys
N, M = map(int, input().split())
A = [int(i) for i in input().split()]

dic = defaultdict(int)
for i in range(M):
    b, c = map(int, input().split())
    dic[c] += b
for x in A:
    dic[x] += 1
dic = sorted(dic.items(), key=lambda x:x[0], reverse=True)
cur = 0
ans = 0
for x, y in dic:
    cur += y
    if cur > len(A):
        print(ans + x*(y - (cur - len(A))))
        sys.exit()
    else:
        ans += x*y

Measured memory_bytes: 43288
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);

int main(){
  int x[5];
  for (int i = 0; i < 5; i++) {
    cin >> x[i];
    if (x[i] == 0) {
      cout << i+1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3616
import numpy as np
n, m, c = map(int, input().split())
b = np.array(list(map(int, input().split())))

cnt = 0
for i in range(n):
    a = np.array(list(map(int, input().split())))
    if np.dot(a, b) + c > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 16664
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = 0;
        int max;
        int maxNum = 0;
        int minNum = 0;
        int min;
        int sum;
        List<Integer> list = new ArrayList<Integer>();

        while (true) {
            n = sc.nextInt();
            max = -1;
            min = 1001;
            sum = 0;

            //入力終了
            if (n == 0) {
                break;
            }

            int[] nums = new int[n];

            //得点入力
            for (int i = 0; i < n; i++) {
                nums[i] = sc.nextInt();
                if (max <= nums[i]) {
                    max = nums[i];
                    maxNum = i;
                }
                if (nums[i] <= min) {
                    min = nums[i];
                    minNum = i;
                }
            }

            //最高得点と最低得点を0に
            nums[maxNum] = 0;
            nums[minNum] = 0;

            for (int num : nums) {
                sum += num;
            }

            list.add(sum / (n - 2));
        }
        for (int num : list) {
            System.out.println(num);
        }
        sc.close();
    }

}



Measured memory_bytes: 29248
#include <iostream>
#include <vector>
#include <unordered_map>

typedef long long int llint;

const llint MOD = 1000000007;

inline llint add(llint a, llint b){
  a = a%MOD;
  b = b%MOD;
  return (a+b)%MOD;
}

inline llint mult(llint a, llint b){
  a = a%MOD;
  b = b%MOD;
  return (a*b)%MOD;
}


int main(void){

  llint n, k;
  std::cin >> n >> k;

  std::vector<llint> A(n);
  for(llint i=0; i<n; i++){
    std::cin >> A[i];
  }

  llint count = 0;

  //same group
  for(llint i=0; i<n; i++){
    for(llint j=i+1; j<n; j++){
      if(A[i]>A[j]) count = add(count, 1);
    }
  }
  count = mult(count, k);
  //std::cout << "in same: " << count << std::endl;

  //diff group
  llint total_small = 0;
  for(llint i=0; i<n; i++){
    for(llint j=0; j<n; j++){
      if(A[i]>A[j]) total_small = add(total_small, 1);
    }
  }

  llint kC2;
  if(k%2 == 0){
    kC2 = mult((k/2), (k-1));
  }else{
    kC2 = mult(k, (k-1)/2);
  }
  
  count = add(count, mult(kC2, total_small));
  //std::cout << "small: " << mult(kC2, total_small) << std::endl;

  std::cout << count << std::endl;
  
  
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b){
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


int factorial(int n){
  if(n == 0) return 1;
  return n*factorial(n-1);
}

int divisor(int a){
  int cnt = 0;
  for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
  return cnt;
}

int comb(int n, int k){
  return factorial(n) / (factorial(n-k)*factorial(k));
}

int answer(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}






int main(){
  string s;
  cin >> s;
  int ans = 700;
  rep(i,3) if(s[i] == 'o') ans+=100;
  cout << ans << endl;
  
  
  return 0;
}









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

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

 rep(i,s.size()) {
   s[i] = 'x';
 }
 cout << s << endl;
 return 0;
 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int a[200010];
int tong[200010];
int main()
{
	cin>>n;
	for(int i=1;i<n;i++)
	{
		scanf("%d",&a[i]);
		tong[a[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		printf("%d\n",tong[i]);
	}
	return 0;
}

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


int main(){
    string s; cin>>s;
    int n = s.size();
    ll ans = 0;
    for (int bit=0;bit<(1<<n-1);bit++){
        ll sum = 0;
        ll k = s[0]-'0';
        for (int i=0;i<n-1;i++){
            if (bit&(1<<i)){
                sum+=k;
                k = s[i+1]-'0';
            }else{
                k = k*10 + (s[i+1]-'0');
            }
        }
        ans += sum + k;
    }
    cout << ans << endl;
}

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

void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}

int N;
int64_t A[18];

map<vector<int>, int64_t> memo;

int64_t rec(int i, int j, int x, int y){
    if(j-i == 1) return 0;
    vector<int> v = {i, j, x, y};
    if(memo.count(v)) return memo[v];

    int64_t ret = 1e18;
    for(int m=i+1; m<j; m++) chmin(ret, rec(i, m, x, x+y) + rec(m, j, x+y, y) + (x+y)*A[m]);
    memo[v] = ret;
    return ret;
}

int main(){
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];

    cout << A[0] + rec(0, N-1, 1, 1) + A[N-1] << endl;
    return 0;
}


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

const int MAXW = 1e5 + 10;

long long knapsack[MAXW];
int N,W;

int main(){

	cin >> N >> W;

	for(int item = 1;item<=N;item++){
		int w,v;
		cin >> w >> v;
		for(int i = W;i>=w;i--) knapsack[i] = max(knapsack[i-w] + v,knapsack[i]);
	}

	long long best = 0;
	for(int i = 0;i<=W;i++) best = max(best,knapsack[i]);
	cout << best << endl;

	return 0;

}

Measured memory_bytes: 4392
#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
const int MAXN=1e5+100;
struct node {
	int st;
	int ed;
}mac[MAXN];
bool cmp(node a,node b)
{
	return a.ed<b.ed;
}
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++)
	{
		int pos,len;
		scanf("%d%d",&pos,&len);
		mac[i].st=pos-len;
		mac[i].ed=pos+len;
	}
	sort(mac+1,mac+n+1,cmp);
	int e=mac[1].ed,ans=1;
	for(int i=2;i<=n;i++)
		if(mac[i].st>=e)
		{
			ans++;
			e=mac[i].ed;
		}
	cout<<ans;
}

Measured memory_bytes: 4516
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
    
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

if e-a > k:
	print(":(")
else:
	print("Yay!")

Measured memory_bytes: 3060
#include <iostream>

int main() {
  int n, c = 0;
  long long x, y, d;
  std::cin >> n >> d;
  while(n--) {
    std::cin >> x >> y;
    if (x*x + y*y <= d*d) {
      c++;
    }
  }
  std::cout << c;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define all(v) (v).begin(),(v).end()
#define mod 1e9+7

using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using P = pair<int,int>;

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

Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

type testimony struct {
	x int
	y int
}

func genRow(table [][]int, row []int, i int, n int) [][]int {
	if i == n {
		row2 := make([]int, len(row))
		copy(row2, row)
		return append(table, row2)
	}
	row[i] = 1
	table = genRow(table, row, i+1, n)
	row[i] = 0
	table = genRow(table, row, i+1, n)
	return table
}

func run() int {
	var n int
	fmt.Scanf("%d\n", &n)

	testimonyTable := make([][]testimony, 0)

	for i := 1; i <= n; i++ {
		var a int
		fmt.Scanf("%d\n", &a)
		tt := make([]testimony, a)
		for j := 0; j < a; j++ {
			fmt.Scanf("%d %d\n", &tt[j].x, &tt[j].y)
		}
		testimonyTable = append(testimonyTable, tt)
	}

	table := make([][]int, 0)
	table = genRow(table, make([]int, n), 0, n)

	maxCount := 0
	for _, row := range table {
		count := 0
		for i := 0; i < len(row); i++ {
			// fmt.Println("i:", i)
			if row[i] == 0 {
				continue
			}

			honest := true
			for _, t := range testimonyTable[i] {
				// fmt.Println("t:", t, "row", row[t.x-1])
				if row[t.x-1] != t.y {
					honest = false
					break
				}
			}

			if !honest {
				count = 0
				break
			}

			count++
		}

		// fmt.Println(row, count)

		if maxCount < count {
			maxCount = count
		}
	}

	fmt.Println(maxCount)

	return 0
}

func main() {
	os.Exit(run())
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
typedef long long ll;
typedef std::pair<ll,ll> P;

#define rep(i,n) for(int i = 0; i < int(n); i++)
using namespace std;



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

struct dsu {
public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

int main() {
	int n, q;
	cin >> n >> q;
    dsu d(n);
    rep(i, q) {
        int t,u,v;
        cin >> t >> u >> v;
        if (t == 0) {
            d.merge(u, v);
        }
        else {
            if (d.same(u, v)) {
                cout << 1 << endl;
            }
            else {
                cout << 0 << endl;
            }
        }
    }
	return 0;
}


Measured memory_bytes: 3896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX/2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	vi a(n);
	vvi x(n, vi(0)), y(n, vi(0));

	rep(i, n) {
		cin >> a[i];
		rep(j, a[i]) {
			int xx, yy;
			cin >> xx >> yy;xx--;
			x[i].push_back(xx);
			y[i].push_back(yy);
		}
	}

	int ans = 0;

	rep(i, 1 << n) {

		int hone = 0;
		bool strange = false;

		rep(j, n) {
			if (!((i >> j) & 1))continue;
			hone++;
			rep(k, a[j])if ((i >> x[j][k]) % 2 != y[j][k])strange = true;
		}

		if (strange)continue;
		ans = max(ans, hone);

	}

	cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define all(x) x.begin(),x.end()
using namespace std;
#define mod 1000000007
const int maxn=1000000;
void solve() {
    int x;
    cin >> x;
    int sum = 0;
    for (int j = 1; j <= x - 1; ++j) {
        int n = j;
        int ff = 1;
        int cnt = 0;
        while (n % 2 == 0) {
            cnt++;
            n /= 2;
        }
        if(cnt)
        ff *= (cnt + 1);
        for (int i = 3; i <= sqrt(n); i += 2) {
            cnt = 0;
            while (n % i == 0) {
                cnt++;
                n /= i;
            }
            if(cnt)
            ff *= cnt + 1;
        }
        cnt=0;
        if(n>2){
            cnt++;
        }
        if(cnt)
        ff*=cnt+1;
        sum += ff;
    }
    cout << sum;

}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 3712
N = raw_input()
a = map(int,raw_input().split())
max_num = max(a)
min_num = min(a)

ans = []
b = 0
for i in range(min_num,max_num+1):
    for j in range(0,int(N)):
        b +=(a[j]-i)*(a[j]-i) 
    ans.append(b)
    b = 0
print min(ans)

Measured memory_bytes: 2568
#include <iostream>

int main(){
    long long a,b,c,d;
    std::cin >> a >> b >> c >> d;

    if(b<0 && d<0){
        std::cout << a*c << std::endl;        
    }
    else if(a>=0 && c>=0){
        std::cout << b*d << std::endl;        
    }
    else if(a>=0 && d<0){
        std::cout << a*d << std::endl;        
    }
    else if(c>=0 && b<0){
        std::cout << b*c << std::endl;        
    }
    else if(c>=0 && b<0){
        std::cout << a*d << std::endl;        
    }
    else{
        std::cout << std::max(a*c, b*d) << std::endl;
    }




    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
bool f[100010];
int ruiseki[100010];
int main(void){
    int n,l,r;
    cin >> n;
    for(int i = 2;i <= 100000;i++){
        if(!f[i]){
            for(int j = i+i;j <= 100000;j+=i) f[j] = true;
        }
    }
    for(int i = 3;i <= 100000;i+=2) if(!f[i] && !f[(i+1)/2]) ruiseki[i] = 1;
    for(int i = 3;i <= 100000;i++) ruiseki[i] += ruiseki[i-1];
    
    while(n > 0){
        cin >> l >> r;
        cout << ruiseki[r] - ruiseki[l-1] << endl;
        n--;
        if(n == 0) break;
    }
    return 0;
}

Measured memory_bytes: 1152
z = list(map(int,input().split()))
n = z[0]
l = [int(input()) for _ in range(n)]

ans = float('inf')
loop = 0
while loop < 4**n:
    ps = [loop // (4**j) % 4 for j in range(n)]
    loop += 1
    s = [[], [], [], []]
    for cnt,p in enumerate(ps):
        s[p].append(l[cnt])
    if not all(s[1:]):
        continue
    score = [(len(s[i]) - 1) * 10 + abs(sum(s[i]) - z[i]) for i in range(4)]
    ans = min(ans, sum(score[1:]))

print(ans)


Measured memory_bytes: 3064
import math

n = int(input())
sum_sm = 0
d = []

while n != 0:
    s = input().split()
    sn = [int(si) for si in s]
    m = sum(sn) / n
    for sni in sn:
        sum_sm += (sni - m) ** 2
    d.append(math.sqrt(sum_sm/n))

    n = int(input())
    sum_sm = 0

for di in d:
    print(di)



Measured memory_bytes: 5780
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define rrep2(x,from,to) for(long long x=(from-1);(x)>=(to);(x)--)
#define rrep(x,from) rrep(x,from,0)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long n;
priority_queue<long long> rque;
priority_queue<long long,vector<long long>,greater<long long> > que;
long long a[300006];
long long wa;
long long p;
long long maxwa;
long long
 mae[300006];
long long ans;
long long back[300006];
int main()
{
	cin>>n;
	rep(i,3*n)cin>>a[i];
	rep(i,n)
	{
		wa+=a[i];
		que.push(a[i]);
	}
	mae[n-1]=wa;
	rep2(i,n,2*n)
	{
		que.push(a[i]);
		p=que.top();
		wa+=(a[i]-p);
		que.pop();
		mae[i]=wa;
	}
	wa=0;
	rrep2(i,3*n,2*n)
	{
		wa+=a[i];
		rque.push(a[i]);
	}
	back[2*n-1]=wa;
	rrep2(i,2*n,n)
	{
		rque.push(a[i]);
		p=rque.top();
		wa+=(a[i]-p);
		rque.pop();
		back[i-1]=wa;
	}
	ans=mae[n-1]-back[n-1];
	rep2(i,n,2*n)
	{
		if(ans<mae[i]-back[i])
		ans=mae[i]-back[i];
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define int long long

const int N = 1e6 + 10;

int a[N], fl = 0;

signed main()
{
  int n;
  const int mx = (int)(1e18);
  cin >> n;
  for (int i = 1; i <= n; i++) 
  {
    cin >> a[i];
    if (a[i] == 0) fl = 1;
  }
  if (fl) 
  {
    printf("0\n");
    return 0;
  }

  int temp = 1;
  for (int i = 1; i <= n; i++)
  {
   if (mx / temp >= a[i]) temp = temp * a[i];
   else 
   {
     fl = 1; 
     break;
   }
  }
  if (fl) printf("-1\n");
  else printf("%lld\n", temp);
  return 0;
}


Measured memory_bytes: 4516
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=i+1
#print(a)

a.sort()

#bはaの最小から最大まで
x=0
z=n-1
y=(x+z)//2
while z!=x:
    s1=0
    s2=0
    for k in range(n):
        s1+=abs(a[k]-a[y])
    for k in range(n):
        s2+=abs(a[k]-a[y+1])
    if s1<s2 :
        z=y
        y=(x+z)//2
    elif s1==s2:
        x=y
        z=y
    else:
        x=y+1
        y=(x+z)//2
#x=y=zとなっている
s=0
for k in range(n):
    s+=abs(a[k]-a[y])

print(s)

Measured memory_bytes: 25708
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    int n;cin >> n;
    vector<int>l(n);
    int ans=0;
    rep(i,n){
        cin >> l[i];
    }
    int max=*max_element(l.begin(),l.end());
    for(int x:l){
        ans+=x;
    }
    ans-=max;
    if(max<ans){
        out("Yes");
    }
    else{
        out("No");
    }
    return 0;
}




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

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

  int n;
  int p[1000000];
  cin >> n;
  rep(i, n) cin >> p[i];

  vector<int> l;
  int cnt = 0;
  rep(i, n) {
    if (i+1 == p[i]) {
      cnt++;
    } else {
      if (cnt != 0) l.push_back(cnt);
      cnt = 0;
    }
  }
  if (cnt != 0) l.push_back(cnt);

  int ans = 0;
  for (int i : l) {
    ans += (i-1)/2+1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 2560
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;

#define MAXN 1000000

signed main() {
	int n, k; cin >> n >> k;
	int s, p, r; cin >> s >> p >> r;
	string t; cin >> t;
	rep(i, n-k) {
		if (t[i] == t[i + k]) {
			t[i + k] = 'z';
		}
	}
	int ans = 0;
	for (auto a : t) {
		if (a == 'r') ans += r;
		if (a == 's') ans += s;
		if (a == 'p') ans += p;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#Author: M@sud_P@rvez
from math import *
c=0

n,m=map(int,input().split())
for _ in range(n):
    a,b=map(int,input().split())
    x=a*a
    
    y=b*b
    
    z=sqrt(x+y)
    if z<=m:
        c+=1
        
        
print(c)



Measured memory_bytes: 9180
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		String T = scan.next();
		scan.close();

		String[] sArray = S.split("");
		String[] tArray = T.split("");

		int count = 0;
		for (int i = 0; i < sArray.length; i++) {
			if (!sArray[i].equals(tArray[i])) {
				count += 1;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 66804
#include <bits/stdc++.h>
using namespace std;
long long memo[50];
long long f(long long x){
  if(x==0||x==1)return memo[x]=1;
  if(memo[x]!=0)return memo[x];
  return memo[x]=f(x-1)+f(x-2);
}
int main() {
  int n;
  cin >>n;
  long long kotae=f(n);
  cout<<kotae<<endl;
}
  


Measured memory_bytes: 3100
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 1e-9;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<long long int>v(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> v[i];
		v[i] += v[i - 1];
	}
	vector<pair<pair<long long int, long long int>, pair<long long int, long long int>>>ml(N + 1, { { MOD*MOD,0 },{ MOD*MOD,0} });
	vector<pair<pair<long long int, long long int>, pair<long long int, long long int>>>mr(N + 1, { { MOD*MOD,0 },{ MOD*MOD,0} });
	int index = 1;
	for (int i = 2; i <= N; i++) {
		while (v[index] * 2 < v[i] && index + 1 < i) {
			index++;
		}
		ml[i].first = { max(v[i] - v[index],v[index]),min(v[i] - v[index],v[index]) };
		if (index > 1) {
			ml[i].second = { max(v[i] - v[index - 1],v[index-1]),min(v[i] - v[index - 1],v[index-1]) };
		}
	}
	index = N - 1;
	for (int i = N - 2; i >= 0; i--) {
		while ((v[N] - v[index]) * 2 < v[N] - v[i] && index - 1 > i) {
			index--;
		}
		mr[i].first = { max(v[N] - v[index],v[index] - v[i]),min(v[N] - v[index],v[index] - v[i]) };
		if (index + 1 < N) {
			mr[i].second = { max(v[N] - v[index + 1],v[index + 1] - v[i]),min(v[N] - v[index + 1],v[index + 1] - v[i]) };
		}
	}
	long long int ans = MOD * MOD;
	for (int i = 2; i <= N - 2; i++) {
		//cout << i << endl;
		//cout << ml[i].first.first << " " << ml[i].first.second << endl;
		//cout << ml[i].second.first << " " << ml[i].second.second << endl;
		//cout << mr[i].second.first << " " << mr[i].second.second << endl;
		//cout << mr[i].first.first << " " << mr[i].first.second << endl;
		ans = min(ans, max(ml[i].first.first, mr[i].first.first) - min(ml[i].first.second, mr[i].first.second));
		ans = min(ans, max(ml[i].second.first, mr[i].first.first) - min(ml[i].second.second, mr[i].first.second));
		ans = min(ans, max(ml[i].second.first, mr[i].second.first) - min(ml[i].second.second, mr[i].second.second));
		ans = min(ans, max(ml[i].first.first, mr[i].second.first) - min(ml[i].first.second, mr[i].second.second));
		//cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 14336