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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
 // c_p_c();
  int n,s = 0;
  cin >> n;
  int a[n];
  unordered_map <int,int> mp;
  for(int i=0;i<n;i++)
  {
    cin >> a[i];
    s+=a[i];
    mp[a[i]] += 1;
  }
  int q;
  cin >> q;
  while(q--)
  {
    int b,c;
    cin >> b >> c;    
   int val = mp[b];
    s -= (val*b);
    s += (val*c);
    mp.erase(b);
    mp[c] += val;
    cout<<s<<endl;
  }
  return 0;
}



Measured memory_bytes: 7400
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int a; cin >> a;
    cout << a+a*a+a*a*a << endl;
return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

	ll n, wt;
	cin>>n>>wt;
	ll a[n], w[n];
	for(int i=0;i<n;i++){
		cin>>w[i]>>a[i];
	}
	ll dp[n+2][wt+2];
	memset(dp, 0, sizeof(dp));
	for(int i=0;i<=n;i++){
		for(int j=0;j<=wt;j++){
			if(i==0 || j==0){
				dp[i][j] = 0;
			}
			else if(w[i-1]<=j){
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + a[i-1]);
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	cout<<dp[n][wt];
	return 0;
}




Measured memory_bytes: 80000
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int best = 0;
    int n;
    cin >> n;
    vector<int> a(n + 1, 0);
    for(int i = 1; i < n + 1; i++)
    {
        cin >> a[i];
    }
    vector<int> pre(n + 1, 0);
    for(int i = 1; i < n + 1; i++)
    {
        pre[i] = gcd(pre[i - 1], a[i]);
    }
    vector<int> suf(n + 2, 0);
    for(int i = n; i > 0; i--)
    {
        suf[i] = gcd(suf[i + 1], a[i]);
    }
    for(int i = 1; i < n + 1; i++)
    {
        best = max(best, gcd(pre[i - 1], suf[i + 1]));
    }
    cout << best;

    return 0;
}


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

template<size_t max_N, size_t prime_size>
struct Prime{
    bool sieve[max_N];
    int_fast64_t prime[prime_size];
    size_t counter = 0;
    constexpr Prime() : sieve(), prime() {
        for(int_fast64_t i = 0; i < max_N; ++i)
            sieve[i] = true;
        for(int_fast64_t i = 2; i < max_N; ++i){
            if(sieve[i] && i % 5 == 2){
                prime[counter] = i;
                ++counter;
                if(counter > prime_size)break;
            }
            for(int_fast64_t j = i * i; j < max_N; j += i)
                sieve[j] = false;
        }
    }
};

constexpr auto p = Prime<555555, 60000>();

long long int N;

int main(){

    scanf("%lld", &N);
    for(int i = 0; i < N; ++i)cout << p.prime[i] << " ";
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    string S;cin >> S;
    int N = S.size();
    int p = 1;
    REPP(i,0,N-1){
        if(S[i] == S[N-2-i]) continue;
        cout << -1 << endl;
        return 0;
    }
    if(S[0] == '0' || S[N-1] == '1'){
        cout << -1 << endl;
        return 0;
    }
    REPP(i,2,N+1){
        if(S[i-1] == '1') for(;p < i;++p)cout << i << ' ' << p << endl;
    }
	cout << N << ' ' << N-1 << endl;
}

Measured memory_bytes: 1616
from sys import stdin 
input=stdin.readline
def main():
  n=int(input())
  l=tuple(tuple(map(int,input().split())) for i in range(n-1))
  for i in range(n):
    now=0
    for a,s,d in l[i:]:
      if now<=s:now=s+a
      else:now=(now+d-1)//d*d+a
    print(now)
if __name__=="__main__":
  main()


Measured memory_bytes: 3188
#include <cstdio>
#include <vector>
#include <algorithm>
typedef long long ll;

const int N=200005,P=1000000007;
struct Node
{
    int a,b,c;
    inline void operator+=(const Node &o)
    {
        c=(ll(a+b+c)*o.c+ll(b+c)*o.b+(ll)c*o.a)%P;
        b=((ll)a*o.b+(ll)b*o.a)%P,a=(ll)a*o.a%P;
    }
}v;

ll Pow(ll a,ll b,ll s=1){for(;b;b>>=1,a=a*a%P)if(b&1)s=s*a%P;return s%P;}

int n,h[N],l[N],r[N],t,Ans;
std::vector<Node> q[N];

void DFS(int x)
{
    if(!h[x])return q[r[x]=++t].push_back(v),void();
    int m=0,y,z;
    for(int i=h[x];i;i=l[i])
    {
        if(DFS(i),i==h[x]){r[x]=r[i];continue;}
        y=q[r[x]].size(),z=q[r[i]].size(),m=std::max(m,std::min(y,z));
        if(y<z)std::swap(y,z),std::swap(r[x],r[i]);
        for(int j=1;j<=z;++j)q[r[x]][y-j]+=q[r[i]][z-j];
    }
    m=(int)q[r[x]].size()-m;
    for(int j=(int)q[r[x]].size()-1;j>=m;--j)q[r[x]][j].a=(q[r[x]][j].a+q[r[x]][j].c)%P,q[r[x]][j].c=0;
    q[r[x]].push_back(v);
}

int main()
{
    scanf("%d",&n),v=(Node){(P+1)>>1,(P+1)>>1,0};
    for(int i=1,x;i<=n;++i)scanf("%d",&x),l[i]=h[x],h[x]=i;
    DFS(0);
    for(int i=(int)q[r[0]].size()-1;i>=0;--i)Ans=(Ans+q[r[0]][i].b)%P;
    printf("%d\n",int(Ans*Pow(2,n+1)%P));
    return 0;
}

Measured memory_bytes: 23924
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;

int n;
long long m;
int a[N];

int sq[N];
long long sg[N];
void pre()
{
    for (int i = N - 2; i >= 0; --i)
    {
        sq[i] = sq[i + 1] + a[i];
        sg[i] = sg[i + 1] + (a[i] * 1LL * i);
    }
}

bool stg(int s)
{
    long long q = 0;
    for (int i = 0; i < N; ++i)
    {
        if (i < s)
            q += (a[i] * 1LL * sq[s - i]);
        else
            q += (a[i] * 1LL * sq[0]);
    }
    return (m >= q);
}

int main()
{
    scanf("%d%lld", &n, &m);
    for (int i = 1; i <= n; ++i)
    {
        int x;
        scanf("%d", &x);
        ++a[x];
    }
    pre();
    int l = 0, r = N - 1;
    int u;
    while (l <= r)
    {
        int m = (l + r) / 2;
        if (stg(m))
        {
            r = m - 1;
            u = m;
        }
        else
            l = m + 1;
    }
    long long q = 0, g = 0;
    for (int i = 0; i < N; ++i)
    {
        if (i < u)
        {
            q += (a[i] * 1LL * sq[u - i]);
            g += (sg[u - i] * a[i]);
            g += (a[i] * 1LL * sq[u - i]) * 1LL * i;
        }
        else
        {
            q += (a[i] * 1LL * sq[0]);
            g += (sg[0] * a[i]);
            g += (a[i] * 1LL * sq[0]) * 1LL * i;
        }
    }
    m -= q;
    g += m * (u - 1);
    printf("%lld\n", g);
    return 0;
}


Measured memory_bytes: 3072
function Main(input) {
	tmp = input.split(" ");
	var a = parseInt(tmp[0]);
	var b = parseInt(tmp[1]);
	var r = "";
	if(a<=5){ r = 0; }
	if(a>=6 && a<= 12){ r = b/2; }
	if(a>=13){ r = b; }
	console.log(r);
}

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

Measured memory_bytes: 22076
#include <iostream>
#include <vector>

void Swap( int& a, int& b ){
    int tmp = std::move(a);
    a = std::move(b);
    b = std::move(tmp);
}

// when 0th Recurtion, params -> Partition( v, 0, v.size() );
int Partition( std::vector<int>& v, int p, int r ){
    --r;
    int x = v[r];
    int i = p - 1;
    for( int j = p; j < r; ++j ){
        if( v[j] <= x ){
            Swap( v[++i], v[j] );
        }
    }
    Swap( v[i+1], v[r] );
    return i + 1;
}

int main(){
    int n;
    std::cin.tie(0);
    std::cin >> n;

    std::vector<int> v(n);
    for( auto& elem : v ){
        std::cin >> elem;
    }

    int r = Partition( v, 0, v.size() );

    for( int i = 0; i < v.size(); ++i ){
        if( i != r ){
            std::cout << v[i] << ( ( i != v.size()-1 )? " " : "\n" );
        }else{
            std::cout << "[" << v[i] << "]" << ( ( i != v.size()-1 )? " " : "\n" );
        }
    }

}


Measured memory_bytes: 3016
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		String ans = solve();
		System.out.println(ans);
	}
	
	private static String solve() {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if (Math.abs(x - a) > Math.abs(x - b)) {
			return "B";
		} else {
			return "A";
		}
	}
}

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

int main() {
	long long  n,temp,ans=1;
	cin>>n;
	for(long long i=0;i<n;i++){
		cin>>temp;
		ans=ans/__gcd(ans,temp)*temp;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;

  vector<vector<bool>> dp(F+1,vector<bool>(F+1,false));
  dp.at(0).at(0)=true;

  for(int i=1;i<=F;i++){
    for(int j=0;j<=i;j++){
      if(i-100*A>=0){
        dp.at(i).at(j)=dp.at(i-100*A).at(j)||dp.at(i).at(j);
      }
      if(i-100*B>=0){
        dp.at(i).at(j)=dp.at(i-100*B).at(j)||dp.at(i).at(j);
      }
      if(i-C>=0&&j-C>=0){
        dp.at(i).at(j)=dp.at(i-C).at(j-C)||dp.at(i).at(j);
      }
      if(i-D>=0&&j-D>=0){
        dp.at(i).at(j)=dp.at(i-D).at(j-D)||dp.at(i).at(j);
      }
    }
  }

  int i_a=100*A,j_a=0;
  for(int i=1;i<=F;i++){
    for(int j=0;j<=i;j++){
      if(dp.at(i).at(j)&&j*(100+E)<=E*i){
        if(100*j_a*i<100*j*i_a){
          i_a=i;
          j_a=j;
        }
      }
    }
  }

  cout<<i_a<<" "<<j_a<<endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

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

    ll n, a, b;
    cin >> n >> a >> b;

    if (a > b)
        cout << 0;
    else if (n == 1)
        cout << (a == b);
    else
        cout << (n - 1) * b + a - a * (n - 1) - b + 1;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
int main(){
    ll h,w;cin >> h >> w;
    ll g=h*w;
    if(h==1&&w>1){
        cout << 1 << endl;
        return 0;
    }
    else if(w==1&&h>1){
        cout << 1 << endl;
        return 0;
    }
    if(g%2==0) cout << g/2 << endl;
    else cout << g/2+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#B
#入力
S=input()
#処理
while True:
    if S=="":
        print("Yes")
        break
    elif S[0]=="L":
        print("No")
        break
    
    if S[1:]=="":
        print("Yes")
        break
    elif S[1]=="R":
        print("No")
        break
        
    S=S[2:]
        

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

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

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

int R, C, N;

int ep(int x, int y) {
  if ((x==0||x==R||y==0||y==C)) {
    if (x==0) return (R+C)*2-y;
    else if (x==R) return R+y;
    else if (y==0) return x;
    else if (y==C) return R*2+C-x;
  }
  return -1;
}

int main() {
  cin >> R >> C >> N;
  vector<p_ll> pos;
  rep(i,N) {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    int ep1 = ep(x1,y1), ep2 = ep(x2,y2);
    if (ep1!=-1&&ep2!=-1) {
      pos.push_back(make_pair(i,ep1));
      pos.push_back(make_pair(i,ep2));
    }
    // cout << ep1 << " " << ep2 << endl;
  }
  sort(pos.begin(),pos.end(),[](const p_ll &x, const p_ll &y){return x.second<y.second;});

  stack<int> order;
  for (auto x: pos) {
    if (order.size()&&order.top()==x.first) order.pop();
    else order.push(x.first);
  }
  string result = order.empty() ? "YES" : "NO";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 6384
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const long long MXN = 1e5 + 1;
const long long MNN = 1e2 + 1;
const long long MOD = 998244353;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, b[MXN];

int main(){
    ios;
    //    freopen("B.in", "r", stdin);
    //    freopen("B.out", "w", stdout);
    cin >> n;
    if(n == 3){
        cout << 2 << ' ' << 5 << ' ' << 63 << ' ';
        return 0;
    }
    llong x = 3;
    for( ; x + 6 <= 30000 && n >= 4; x += 12, n -= 2){
        cout << x << ' ' << x + 6 << ' ';
    }
    x = 2;
    for( ; n >= 3; x += 6, n -= 3){
        cout << x << ' ' << x + 2 << ' ' << x + 4 << ' ';
    }
    if(n == 1){
        cout << x + 4;
    }if(n == 2){
        cout << x << ' ' << x + 2;
    }
    return 0;
}


Measured memory_bytes: 384
l_ = input().split()
l = [int(s) for s in l_]

if l[1] <= l[2]:
    max_ = l[1]
else:
    max_ = l[2]

if l[1] + l[2] >= l[0]:
    min_ = l[1] + l[2] - l[0]
else:
    min_ = 0

print("{} {}".format(max_, min_))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>


using namespace std;

int main()
{
	long long int n, q;
  
	cin >> n >> q;
  
	long long int s[200010],t[200010],x[200010],d[200010];
  
  for(int i=0;i<n;i++){
    
	 cin >> s[i] >> t[i] >> x[i];
  }
  
  for(int i=0;i<q;i++){
	cin >> d[i];
  }

    set<pair<pair<long long int, long long int>, long long int>> events;
  
	set<long long int>bye;
	for(int i=0;i<n;i++)
	{
		events.insert(make_pair(make_pair(s[i] - x[i], x[i]), 1));
		events.insert(make_pair(make_pair(t[i] - x[i], x[i]), 0));
	}
  
	for(int i=0;i<q;i++)
	{
		if (!events.empty())
		{
			while ((*events.begin()).first.first <= d[i])
			{
				if ((*events.begin()).second == 1) bye.insert((*events.begin()).first.second);
				else bye.erase(bye.find((*events.begin()).first.second));
				events.erase(events.begin());
				if (events.empty()) break;
			}
		}

		long long int ans;
		if (bye.empty()) ans = -1;
      
		else ans = *bye.begin();
      
		cout << ans << endl;
	}
}


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

int main(){
 int N;
 cin>>N;
 int v[N+1];
 for(int i=1;i<=N;i++){
    cin>>v[i];
 }

 int *dp = new int [N+1]();
 dp[1]=0;
 dp[2]=abs(v[2]-v[1]);

 for(int i=3;i<=N;i++){
  dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
 }
cout<<dp[N]<<endl;
    return 0;
}

Measured memory_bytes: 1024
/// Kazuki Hoshino
/// Lost July

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

string s, t;
int w;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> s >> w;

int k = s.size()-1;

rep(i, 0, k){
if(0+w*i<=k)
cout << s[0+w*i];
}



return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=20;
const int inf=1e9+7;
int a[N],b[N],val[N],to[N];
vector<int> pos[3*N][2];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,ans=inf,now;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		cin>>b[i];
	}
	for(i=0;i<(1<<n);i++){
		for(j=0;j<n;j++){
			if((i&(1<<j))){
				val[j]=b[j];
				pos[b[j]][(j+1)%2].push_back(j);
			}
			else{
				val[j]=a[j];
				pos[a[j]][j%2].push_back(j);
			}
		}
		sort(val,val+n);
		j=k=0;
		bool cac=true;
		while(j<n){
			vector<int> lis[2];
			while(k<n&&val[j]==val[k]){
				lis[k%2].push_back(k);
				k++;
			}
			if(lis[0].size()!=pos[val[j]][0].size()||lis[1].size()!=pos[val[j]][1].size()){
				cac=false;
				break;
			}
			sort(pos[val[j]][0].begin(),pos[val[j]][0].end());
			sort(pos[val[j]][1].begin(),pos[val[j]][1].end());
			for(l=0;l<lis[0].size();l++){
				to[pos[val[j]][0][l]]=lis[0][l];
			}
			for(l=0;l<lis[1].size();l++){
				to[pos[val[j]][1][l]]=lis[1][l];
			}
			j=k;
		}
		if(cac){
			now=0;
			for(j=0;j<n;j++){
				for(k=j+1;k<n;k++){
					if(to[j]>to[k]){
						now++;
					}
				}
			}
			ans=min(ans,now);
		}
		for(j=0;j<n;j++){
			if((i&(1<<j))){
				pos[b[j]][(j+1)%2].clear();
			}
			else{
				pos[a[j]][j%2].clear();
			}
		}
	}
	if(ans==inf){
		ans=-1;
	}
	cout<<ans;
}

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

#define int long long int

void fileioe(){
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout); 
	freopen("error.txt","w",stderr);
}
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
#define fioe() fileioe()
#else
#define fioe() 1
#endif
//!

int32_t main()
{
	GO
	//fioe();
	int k;
	cin>>k;
	int ans = 0;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			for(int x=1;x<=k;x++){
				ans += __gcd(i,__gcd(j,x));
			}
		}
	}	
	cout<<ans<<endl;
	return 0;
}

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

int main(){
	std::ios::sync_with_stdio(false);
	lld t=1;
	//cin>>t;
	
	while(t--){
		lld x,a,b;
		cin>>x>>a>>b;
		lld r=x-a;
		cout<<r%b<<"\n";
	}
	
}

Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    A, B, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    x = [0]*M
    y = [0]*M
    c = [0]*M
    for i in range(M):
        x[i], y[i], c[i] = map(int, input().split())
    
    res = min(a) + min(b)
    for i in range(M):
        res = min(res, a[x[i]-1] + b[y[i]-1] - c[i])
    
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 92076
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<ll> &v) {
    std::for_each(v.begin(), v.end(), [](ll x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    // N点をとる
    // min max of とくもんだい問題
    ll N;
    cin >> N;
    // i番目はi点
    ll sum = 1;
    set<int> s;
    s.insert(1);
    for(int i = 1; i < N; i++) {
        sum += (i + 1);
        s.insert(i + 1);
        if(sum >= N) {

            break;
        }
    }

    for(auto hoge : s) {
        if(hoge != sum - N) {
            cout << hoge << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 512
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def comb(a,b):
        return fact[a]*fact[a-b]*inv[b]%mod

    n,a,b,c = LI()
    inv_100 = pow(100,mod-2,mod)
    a = a*inv_100%mod
    b = b*inv_100%mod
    c = (1-c*inv_100)%mod
    c = pow(c,mod-2,mod)
    fact = [1]
    N = 200000
    for i in range(1,N+1):
        fact.append(fact[-1]*i%mod)
    inv = [None]*(N+1)
    inv[N] = pow(fact[N], mod-2, mod)
    for i in range(N)[::-1]:
        inv[i] = inv[i+1]*(i+1)%mod
    ans = 0
    pa = pow(a,n,mod)
    pb = pow(b,n,mod)
    for i in range(n):
        ans += inv[n-1]*inv[i]*fact[n+i]*pow(c,n+i+1,mod)*(pa*pow(b,i,mod)+pb*pow(a,i,mod))%mod
        ans %= mod
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 55024
#include<iostream>
using namespace std;
int main(){
    while(1){
        string str;
        cin>>str;
        if(str == "0") break;
        int sum=0;
        for(int i=0;i<(int)str.size();i++){
            sum+=str[i]-'0';
        }
        cout<<sum<<endl;
    }
    return 0;
}



Measured memory_bytes: 3176
N, M, K = map(int, input().split())
MOD = 10 ** 9 + 7

def pow(x, n) :
    y = 1
    while n > 0 :
        if n & 1 :
            y = (y * x) % MOD
        x = (x * x) % MOD
        n >>= 1

    return y

def comb(n, r) :
    if n < r or n < 0 :
        return 0

    factorial = [0] * (n + 1)
    factorial[0] = 1

    for i in range(1, n + 1) :
        factorial[i] = (factorial[i-1] * i) % MOD

    return (factorial[n] * pow(factorial[n-r], MOD - 2) * pow(factorial[r], MOD - 2)) % MOD

res = 0

for i in range(N) :
    for j in range(M) :
        if i > 0 and j > 0 :
            res += 2 * (N - i) * (M - j) * (i + j)
        else :
            res += (N - i) * (M - j) * (i + j)

res *= comb(N * M - 2, K - 2)

print(res % MOD)

Measured memory_bytes: 40900
object Main extends App {

  val Array(n, m) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  var a: Array[Long] = scala.io.StdIn.readLine.split(" ").map(_.toLong).sorted

  val bc = (1 to m).map { _ =>
    val Array(b, c) = scala.io.StdIn.readLine.split(" ").map(_.toInt)

    (b, c.toLong)
  }.sortWith((o1, o2) => o1._2 > o2._2)

  var inx = 0
  bc.foreach { bbcc =>
    var cnt = bbcc._1
    val cc = bbcc._2
    while (cnt > 0 && inx < a.length && a(inx) < cc) {
      a.update(inx, cc)
      inx += 1
      cnt -= 1
    }
    // println(a.deep)
  }
  println(a.sum)
}

Measured memory_bytes: 78692
def cmb(N, r, mod):
    if ( r<0 or r>N ):
        return 0
    r = min(r, N-r)
    return g1[N] * g2[r] * g2[N-r] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
mod = 10 ** 9 + 7

n = int(input())
lis = list(map(int,input().split()))
li = [-1] * n

for i in range( 2, n + 2 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for i in range(n+1):
    if li[lis[i]-1] != -1:
        left = li[lis[i]-1]+1
        right = i+1
        break
    else:li[lis[i]-1] = i

for k in range(1,n+2):
  #     print(nCr(n+1,k,mod),nCr(left+n-right,k-1,mod))
    ans = cmb(n+1,k,mod)-cmb(left+n-right,k-1,mod)
    if ans < 0:
        ans += mod
    print(ans)


Measured memory_bytes: 76524
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define MP make_pair
#define PB push_back
typedef long long ll;
int main(){
	int n,w,h,s,t;
	int fld[100][100];
	while(cin>>n,n){
		cin>>w>>h;
		memset(fld,0,sizeof(fld));
		rep(i,n){
			int x,y;
			cin>>x>>y;
			fld[x][y]=1;
		}
		int ans=0;
		cin>>s>>t;
		for(int x=1;x<=w;x++)for(int y=1;y<=h;y++){
			int cnt=0;
			rep(xx,s){
				if(x+xx>w)break;
				rep(yy,t){
					if(y+yy>h)break;
					cnt+=fld[x+xx][y+yy];
				}
				ans=max(ans,cnt);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repbtw(i, a, b) for (int i = a; i <= (int)(b); i++)
#define all(v) v.begin(), v.end()
#define pr(x) cout << x << endl


int main()
{
    int s, w;
    cin >> s >> w;

    pr((w >= s ? "unsafe" : "safe"));

    return 0;
}



Measured memory_bytes: 3632
s = input().rstrip()

to_z = [z for z in s[0::2] if z == '1']
to_o = [o for o in s[1::2] if o == '0']
a = len(to_z) + len(to_o)
to_z = [z for z in s[1::2] if z == '1']
to_o = [o for o in s[0::2] if o == '0']
b = len(to_z) + len(to_o)
if a < b:
    print(a)
else:
    print(b)

Measured memory_bytes: 4084
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
#include<numeric>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    string s;
    cin >> s;
    bool flg[26] = {0};
    int n = s.length();
    rep(i, n) flg[s[i]-'a'] = 1;
    if ( n != 26 ) {
        cout << s;
        rep(i, 26) {
            if ( flg[i] ) continue;
            cout << (char)(i+'a');
            return 0;
        }
    }

    vector<char> s_v(n);
    rep(i, n) s_v[i] = s[i];
    if ( !next_permutation(s_v.begin(), s_v.end())) {
        cout << -1 << endl;
        return 0;
    }
    rep(i, n) {
        cout << s_v[i];
        if ( s_v[i] != s[i] ) {
            cout << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;

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


int main(){
  int n;
  cin >> n;
  vector<int> w(n);

  int sum1 = 0, sum2 = 0;
  int ans = INT_MAX;
  rep(i, n) cin >> w[i];
  for(int i = 0; i < n; ++i){
    sum1 = 0;
    sum2 = 0;
    for(int j = 0; j < i; ++j){
      sum1 += w[j];
    }
    for(int j = i; j < n; ++j){
      sum2 += w[j];
    }

    ans = min(ans, abs(sum1 - sum2));
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<numeric>
#include<limits>
#include <cstdint>
using namespace std;
#define ll long long int
#define rep(N) for(ll i=0;i<N;i++)
#define rep2(N1,N2) for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)for(ll k=0;k<N3;k++)
#define For(i,N) for(ll i=0;i<N;i++)

void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}

ll kai(ll x) {
	ll a = 1;
	if (x <= 0)
		return 1;
	else {
		for (ll i = 0; i < x; i++)
			a = a * (i + 1);
		return a;
	}
}

ll rui(ll x, ll y) {
	ll a = 1;
	for (ll i = 0; i < y; i++)
		a = a * x;
	return a;
}
const int nmax = 150;
int cccc[nmax][nmax];
ll comb(ll n, ll k) {
	if (n < k) {
		cout << "error n<k" << endl;
		return -1;
	}
	if (cccc[n][k] > 0)return cccc[n][k];
	if (k == 0 || n == k)return 1;
	return cccc[n][k] = comb(n - 1, k - 1) + comb(n - 1, k);
}

ll keta(ll a) {
	ll i = 1;
	while (1) {
		if (a < pow((ll)10, i))
			return i;
		i++;
	}
}
vector<ll> v;
ll n, m;
//m進数全探索
ll inc(ll a = n - 1) {
	if (a == 0 && v[0] == m) {
		v[0] = -1;
		return v[0];
	}
	if (v[a] == m) {
		v[a] = 0;
		inc(a - 1);
		return v[a];
	}
	else {
		++v[a];
		return v[a];
	}
}

int main() {
	cout.precision(20);
	ll H, N;
	cin >> H >> N;
	vector<ll>A(N + 1);
	rep(N)cin >> A[i + 1];
	int flag = 1;
	ll c = 0;
	rep(N)
		c += A[i + 1];
	if (c < H)
		flag = 0;
	Yn(flag);
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, tmp, N, ans=1;
    cin >> N;
    vector<int> d(N);

    for(int i=0; i<N; i++){
	cin >>d[i];
    }
    sort(d.begin(), d.end());

    for(int i=0; i<N-1; i++){
	if(d[i]<d[i+1])
	    ans++;	
    }
    cout << ans<<endl;
    
}



Measured memory_bytes: 256
use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let (n, h): (usize, usize) = {
        let mut split = buf.split_whitespace();
        (split.next().unwrap().parse().unwrap(), split.next().unwrap().parse().unwrap())
    };
    let (mut a, mut b): (Vec<usize>, Vec<usize>) = (0..n).map(|_| {
        buf.clear();
        input.read_line(&mut buf).unwrap();
        let mut split = buf.split_whitespace();
        (split.next().unwrap().parse::<usize>().unwrap(), split.next().unwrap().parse::<usize>().unwrap())
    }).unzip();
    a.sort();
    b.sort();
    let mut damage = 0;
    let mut count = 0;
    let max_repeat = *a.last().unwrap();
    for i in b.iter().filter(|&&x| x > max_repeat).cloned().rev() {
        count += 1;
        damage += i;
        if damage >= h {
            return writeln!(output, "{}", count).unwrap();
        }
    }
    writeln!(output, "{}", count + (h - damage + max_repeat - 1) / max_repeat).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "1 10
3 5
",
            "3\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "2 10
3 5
2 6
",
            "2\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "4 1000000000
1 1
1 10000000
1 30000000
1 99999999
",
            "860000004\n",
        );
    }

    #[test]
    fn case4() {
        test(
            "5 500
35 44
28 83
46 62
31 79
40 43
",
            "9\n",
        );
    }
}

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


void solve(std::string s, std::string t){
    int a =s.size();
    int b= t.size();
    int dp[a+1][b+1] ={};
    int pre[a+1][b+1] ={};
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
            if(dp[i+1][j] > dp[i][j+1]){
                dp[i+1][j+1] = dp[i+1][j];
                pre[i+1][j+1] = 1;
            }else{
                dp[i+1][j+1] = dp[i][j+1];
                pre[i+1][j+1] = 2;
            }
            if(s[i] == t[j]){
                if(dp[i][j] >= dp[i+1][j+1]){
                    dp[i+1][j+1] = dp[i][j] +1;
                    pre[i+1][j+1] = 3;
                }
            }
        }
    }
    string rans = "";
    int si = a -1;
    int ti = b -1;
    while(si >= 0 && ti >=0){
        if(pre[si+1][ti+1]==3){
            rans += s[si];
            si--;
            ti--;
        }else if(pre[si+1][ti+1] ==2){
            si--;
        }else{
            ti--;
        }
    }
    reverse(rans.begin(),rans.end());
    cout << rans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string s;
    std::cin >> s;
    std::string t;
    std::cin >> t;
    solve(s, t);
    return 0;
}


Measured memory_bytes: 70656
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n  = Integer.parseInt(br.readLine());
		String[] AStr = br.readLine().split(" ");
		int[] A = new int[n];
		for(int i = 0; i < n ; i++){
			A[i] = Integer.parseInt(AStr[i]);
		}
		int q = partition(A);

		StringBuffer sb = new StringBuffer();
		for(int i = 0 ; i < n ; i++){
			if(i == q){
				sb.append("[");
				sb.append(A[i]);
				sb.append("]");
				sb.append(" ");
			}else{
				sb.append(A[i]);
				sb.append(" ");
			}
		}

		System.out.println(sb.toString().trim());
	}

	public static int partition(int[] A){
		int x = -1;
		int tmp;
		for(int i = 0 ; i < A.length - 1 ; i++ ){
			if(A[i] <= A[A.length - 1]){
				tmp = A[++x];
				A[x] = A[i];
				A[i] = tmp;
			}
		}
		tmp = A[A.length - 1];
		A[A.length - 1] = A[++x];
		A[x] = tmp;
		return x;
	}

}

Measured memory_bytes: 41400
using System;

namespace ConsoleApp1
{

    class Program
    {

        static void Main(string[] args)
        {
            long x = long.Parse(Console.ReadLine());

            long a = 100;
            long cnt = 0;

            while (a < x)
            {
                a += a / 100;
                cnt++;
            }

            Console.WriteLine(cnt);
        }

    }
}



Measured memory_bytes: 27292
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	char a,b;
	cin>>a>>b;
	if(a-b>0)
	printf(">\n");
	if(a-b<0)
	printf("<\n");
	if(a==b)
	printf("=\n");
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	ll a[n+1],b[n+1];
	memset(a,-1,sizeof(a));
	for(i=1;i<n;i++){
		cin>>b[i];
	}

	for(i=1;i<n;i++){
		if(a[i]==-1||a[i]>b[i]){
			a[i]=b[i];
		}
		if(a[i+1]==-1||a[i+1]>b[i]){
			a[i+1]=b[i];
		}
	}

	ll ans=0;
	for(i=1;i<=n;i++){
		//cout<<a[i]<<" ";
		ans+=a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n') *_q = 0; } while(0)

typedef double D;
D variance(vector<D> &dataset){
    double sum = 0;
    int num = dataset.size();
    FOREACH(it, dataset) sum += *it;
    double avg = sum / num;
    double avgsum = 0;
    FOREACH(it, dataset){
        avgsum += (*it - avg) * (*it - avg);
    }
    return avgsum / num;
}

int main(){

    while(1){
        int n;
        cin >> n;
        if(n == 0) break;

        vector<double> d;
        int p;
        REP(i,n){
            cin >> p;
            d.push_back(p);
        }
        double v = variance(d);
        printf("%.9f\n", sqrt(v));
    }

    return 0;
}

Measured memory_bytes: 1252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
 
class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {
        for (int i = 1;; i++) {
            String x = br.readLine();
            if(x.equals("0")) break;
            out.println("Case "+i+": "+x);
        }
        out.flush();
    }
}

Measured memory_bytes: 29336
#include<stdio.h>
int main()
{
	int e,x,y,z,r;
	for(;scanf("%d",&e),e;)
	{
		r=10000000;
		for(z=0;z*z*z<=e;z++)
			for(y=0;y*y<=e-z*z*z;y++)
				if(e-y*y-z*z*z+y+z<r)
					r=e-y*y-z*z*z+y+z;
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 600
/*
Nahid Hossain
Jahangirnagar University
Roll:54
*/
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 2000000000000000000
#define mod 1000000007
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 200005
ll a[ma],b[ma];





int main()
{
    ll n,i,j;
    while(cin>>n)
    {
        vector<pair<ll,ll> >v;

        for(i=1;i<=n;i++)
        {
            cin>>a[i];
            v.pb(mk(a[i],i));
            b[i]=a[i];
        }

        ll ans=0;

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

        for(i=0;i<v.sz;i++)
        {
            ll x=i+1;
            ll y=v[i].ss;
            if(y%2==0&&x%2==1)ans++;
        }

        cout<<ans<<endl;

    }
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;

#define rep(i, n) \
for(int i = 0; i <n; i++)
#define REP(i, a, b) \
for(int i = int(a); i <= int(b); i++)
#define TRvi(c, it) \
for(vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for(vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for(msi::iterator it = (c).begin(); it != (c).end(); it++)

#define INF 2000000000

#define MEMSET_INF 127
#define MEMSET_HALF_INF 63

void solve(){
    int n;
    cin>>n;
    if(n%7==0){n/=7;}
    long long ans = 1;
    int curr = 1;
    if(n%2==0 || n%5==0){
        cout<<-1<<endl;
    }else{
        while(curr<=n) {
            ans%=n;
            if(ans==0){
                break;
            }
            ans=(ans*10)%n;
            ans+=1;
            ans%=n;
            curr+=1;
        }
        cout<<curr<<endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
// 型シノニム
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
// 定数
constexpr ll INF   = 1e16;
constexpr ll INM   = 114514;
constexpr ll MOD   = 1e9 + 7;
constexpr ld EPS   = 1e-12;
constexpr ll dx[4] = {1, 0, -1, 0};
constexpr ll dy[4] = {0, 1, 0, -1};
// 便利関数
void IOS() { ios::sync_with_stdio(false), cin.tie(0); }
template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <class T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T>
bool chmin(T &a, const T &b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll mod) {
	if (a > 0) return a % mod;
	if (a % mod == 0) return 0;
	ll x = -a / mod + 1;
	a += x * mod;
	return a % mod;
}
ll powm(ll a, ll b, ll m) {
	if (b == 0) {
		return 1;
	} else if (b % 2 == 0) {
		ll d = powm(a, b / 2, m);
		return (d * d) % m;
	} else {
		return (powm(a, b - 1, m) * a) % m;
	}
}

// 本体


int main() {
	IOS();
	ll n, m;
	cin >> n >> m;
	vector<bool> ac(n + 1, false);
	vector<ll> pe(n + 1, 0);
	for (int i = 0; i < m; i++) {
		int num;
		string s;
		cin >> num >> s;
		if(s == "AC"){
			ac[num] = true;
		}else if(!ac[num]){
			pe[num]++;
		}
	}
	ll isac = 0, pen = 0;
	for (int i = 1; i <= n;i++) {
		if(ac[i]){
			isac++;
			pen += pe[i];
		}
	}
	cout << isac << " " << pen << endl;
}


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

using namespace std;


int main() {
	int N;
	cin >> N;
	string s;
	cin >> s;
	char x = s[0];
	int ans = 1;
	for (int i = 1; i < N; i++) {
		if (x != s[i]) { x = s[i]; ans++; }
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1e9+7;
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;

int main(){
    int N;
    cin >> N;
    if (1 <= N && N <= 9) cout << N << endl;
    else if ( 10 <= N && N <= 99) cout << 9 << endl;
    else if (100 <= N && N <= 999) cout << 9+N-99 << endl;
    else if (1000 <= N && N <= 9999) cout << 909 << endl;
    else if (10000 <= N && N <= 99999) cout << 909+N-9999;
    else cout << 90909 << endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#define MAX 100
using namespace std;
string a,b;
int n;
int x[MAX+10],y[MAX+10],z[MAX*2+10];
int len1,len2,i,j;
int main(){
	cin>>n;
	int jkl=n,jkl1=n-1;
	i=0;
	while(jkl!=0){
		x[i++]=jkl%10;
		jkl/=10;
	}len1=i;
	i=0;
	while(jkl1!=0){
		y[i++]=jkl1%10;
		jkl1/=10;
	}len2=i;
//	cin>>a;
//	b=a;
		
		
//		for(j=0,i=len1-1;i>=0;i--){
//			x[i]=a[j++]-'0';
//		} 
//		for(j=0,i=len2-1;i>=0;i--){
//			y[i]=b[j++]-'0';
//		}
//		if(x[0]>0)x[0]-=1;
//		else {
//			
//		}
		for(i=0;i<len1;i++){
			for(j=0;j<len2;j++)
				z[i+j]=z[i+j]+x[i]*y[j];
		}
		for(i=0;i<MAX*2;i++){
			if(z[i]>=10){
				z[i+1]=z[i+1]+z[i]/10;
				z[i]=z[i]%10;  
			}
		}
		for(i=MAX*2;i>0;i--) {
			if(z[i]==0)
				continue;
			else
				break;
		}
		
		//大数除
//		for(;i>=0;i--)
//			printf("%d",z[i]);
//		
    int k[102],xt=0,c[102];
    int L=i+1,L1=1;
    for(int i1=1;i1<=L;i1++)
        k[i1]=z[i--];
    for(i=1;i<=L;i++){
        c[i]=(xt*10+k[i])/2;
        xt=(xt*10+k[i])%2;
    }
    while(c[L1]==0&&L1<L)
        L1++;
    for(i=L1;i<=L;i++)
        printf("%d",c[i]);
    cout<<endl;
}

Measured memory_bytes: 256
l = [int(i) for i in input().split()]
cnt = 0
while not(l[0] == l[1] == l[2]):
  cnt += 1
  if l[0]-l[1]==l[0]-l[2]==1 or l[1]-l[0]==l[1]-l[2]==1 or l[2]-l[0]==l[2]-l[1]==1:
    print(cnt)
    exit()
  else:
    l[l.index(min(l))] += 2
print(cnt)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n,i,a,res=0;
  int c[9];
  cin >> n;
  fill(c,c+9,0);
  for(i=0;i<n;i++){
    cin >> a;
    if(a<3200)
      c[a/400]++;
    else
      c[8]++;
  }
  for(i=0;i<8;i++)
    if(c[i]>0)
      res++;
  if(res==0){
    res=1;
    c[8]--;
  }
  cout << res << " " << res+c[8] << endl;
  return 0;
}

Measured memory_bytes: 3552
#include <set>
#include <vector>
#include <iostream>
using namespace std;

void solve() {
    int n; cin >> n;
    long long a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    string s; cin >> s;
    set<long long, greater<long long> > vs;
    for (int i = n-1; i >= 0; i--) {
        long long msb = 1LL<<60;
        while ((msb & a[i]) == 0) msb /= 2;
        // cerr << " " << a[i] << ' ' << msb << endl;
        if (s[i] == '0') {
            long long tmp = a[i];
            for (long long x : vs) {
                if ((msb & x) > 0 && msb * 2 > x) {
                    tmp ^= x;
                    while (msb > 0 && (msb & tmp) == 0) msb /= 2;
                }
            }
            // cerr << "add " << tmp << endl;
            if (tmp > 0) vs.insert(tmp);
        } else {
            long long tmp = a[i];
            for (long long x : vs) {
                if ((msb & x) > 0 && msb * 2 > x) {
                    tmp ^= x;
                    while (msb > 0 && (msb & tmp) == 0) msb /= 2;
                }
            }
            // cerr << "check " << a[i] << " " << tmp << endl;
            if (tmp > 0) {
                cout << "1\n";
                return;
            }
        }
    }
    cout << "0\n";
}

int main() {
    int t; cin >> t;
    while (t--) solve();
}


Measured memory_bytes: 3484