akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main()
{
  ll q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;
  vector<ll> vvs = {q, h, s, d};
  
  n *= 4;
  vector<pair<int, int>> vs;
  vs.push_back(make_pair(q * 8, 0));
  vs.push_back(make_pair(h * 4, 1));
  vs.push_back(make_pair(s * 2, 2));
  vs.push_back(make_pair(d, 3));

  sort(vs.begin(), vs.end());
  
  ll ans = 0;
  ll rest = n;
  int min_index = 4;
  for (auto &v : vs)
  {
	if (v.second < min_index)
	{
	  ans += (rest / (1 << v.second)) * vvs[v.second];
	  min_index = v.second;
	  rest -= rest - (rest % (1 << v.second));
	}
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 100005
#define INF 1000000
using namespace std;
 
int main(){
  int k, a[MAX];
  deque<int> dq;
  scanf("%d", &k);
  for(int i = 0; i < MAX; i++) a[i] = INF;
  a[1] = 1; dq.push_front(1);
  while(!dq.empty()){
    int t = dq.front(); dq.pop_front();
    if(a[t*10%k] > a[t]){
      a[t*10%k] = a[t];
      dq.push_front(t*10%k);
      if(t*10%k == 0) break;
    }
    if(a[(t+1)%k] > a[t] + 1){
      a[(t+1)%k] = a[t] + 1;
      dq.push_back((t+1)%k);
    }
  }
  printf("%d\n", a[0]);
}


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

int main()
{
    int x, y;
    int num;
    int minData[3000], maxData[3000];

    num = 0;

    while (1) {
        cin >> x >> y;
        if (x == 0 && y == 0) break;

        if ((x >= 0 && x <= 10000) && (y >= 0 && y <= 10000)) {
            if (x < y) {
                minData[num] = x;
                maxData[num] = y;
            } else {
                minData[num] = y;
                maxData[num] = x;

            }
            if (++num >= 3000) break;
        }
    }

    for (int i = 0; i < num; i++) {
        cout << minData[i] << " " << maxData[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3116
import java.util.*;
public class Main
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int [] a = new int [n]; Map<Integer, Integer> map = new HashMap<>(); long sum = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt(); sum += a[i];
            map.put(a[i], map.getOrDefault(a[i], 0) + 1);
        }
        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            int b = sc.nextInt(); int c = sc.nextInt();
            int frq = map.getOrDefault(b, 0);
            sum += ((long) c - b) * frq;
            System.out.println(sum);
            if (frq > 0) map.remove(b);
            map.put(c, map.getOrDefault(c, 0) + frq);
        }
    }


}

Measured memory_bytes: 67236
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; 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; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  int x = a.back(), y = a[0];
  double half = x/2.0;
  for (int i=1; i<n-1; i++) {
    if (abs(a[i]-half) < abs(y-half))
      y = a[i];
  }
  cout << x << ' ' << y << endl;
  return 0;
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

struct bit {
    vector<i32> t;
    i32 n;

    bit(i32 n): t(vector<i32>(n+1, 0)), n(n+1) {}

    void add(i32 i, i32 x) {
        for (i32 a = i; a <= n; a += a & -a) t[a] += x;
    }

    i32 sum(i32 i) {
        i32 res = 0;
        for (i32 a = i; a > 0; a -= a & -a) res += t[a];
        return res;
    }
};

int main() {
    i32 n;
    cin >> n;
    string s;
    cin >> s;
    bit t(n);
    vector<bit> count(26, bit(n));
    for (i32 i = 0; i < n; i++) {
        count[s[i] - 'a'].add(i+1, 1);
    }

    i32 q;
    cin >> q;
    for (i32 x = 0; x < q; x++) {
        i32 o;
        cin >> o;
        if (o == 1) {
            i32 i;
            char c;
            cin >> i >> c;
            count[s[i-1] - 'a'].add(i, -1);
            count[c - 'a'].add(i, 1);
            s[i-1] = c;
        } else {
            i32 l, r;
            cin >> l >> r;
            i32 ans = 0;
            for (i32 c = 0; c < 26; c++) ans += !!(count[c].sum(r) - count[c].sum(l-1));
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 110340
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
int main(){
    int w;cin>>w;
    int a,b;cin>>a>>b;
    int ans;
    if (a>b) swap(a,b);
    ans = (a+w<b)?b-(a+w):0;
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;

  int ball;
  int A = 0, B = K, sum = 0;
  for (int i = 0; i < N; i++){
    cin >> ball;
    sum += (ball < K - ball) ? 2 * ball : 2 * (K - ball);
  }
  cout << sum;
}


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

#define Int long long int
#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()

int main(){
    int n;
    cin >> n;
    vector<Int> vc(5,0);
    string march = "MARCH";
    REP(i,n){
        string s;
        cin >> s;
        if(s[0]=='M')vc[0]++;
        else if(s[0]=='A')vc[1]++;
        else if(s[0]=='R')vc[2]++;
        else if(s[0]=='C')vc[3]++;
        else if(s[0]=='H')vc[4]++;
    }


    //REP(i,5)cout << vc[i] << endl;
    unsigned Int ans=0;

    for(int i=0;i<5;i++){
        for(int j=i+1;j<5;j++){
            for(int k=j+1;k<5;k++){
                ans+=vc[i]*vc[j]*vc[k];
            }
        }
    }

    cout << ans << endl;
}


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

long long int N, d, n, w;

int main(){
    scanf("%lld", &N);
    for(int i = 1; i <= 3500; ++i){
        for(int j = 1; j <= 3500; ++j){
            d = 4 * i * j - j * N - i * N;
            n = i * j * N;
            if(d > 0 && __gcd(d, n) == d){
                w = n / d;
                cout << i << " " << j << " " << w << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

public static void main(String[] args){
    int X,A,B,m;
    Scanner scan=new Scanner(System.in);
    X=scan.nextInt();
    A=scan.nextInt();
    B=scan.nextInt();
    m=(X-A)%B;
    if(A+B<=X){
     System.out.println(m);
    }
    else{
     System.out.print("input error!");
    }
   }}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

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

  bool b = true;
  if(n%2 != 0) b = false;
  else {
    REP(i, 0, n/2 - 1) {
      if(s[i] != s[(n/2) + i]) b = false;
    }
  }
  yorn(b);
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/perl
#B - Shiritori

use strict;
use warnings;

my ($ret) = 'Yes';

# データ取得
my ($data_length);
    $data_length = <STDIN>;

# 
my ($i);
my ($word);
my (@word_list);
my ($last_word) = '';
my ($head);

for ($i = 0 ; $i < $data_length ; $i++) {
    $word = <STDIN>;
    chomp($word);

    $head = substr($word , 0 , 1);

    if (   (   ($last_word eq $head)
            && (!(grep {$_ eq $word} @word_list)))
        || ($last_word eq '')) {

        # None

    }else{
        $ret = 'No';
        last;
    }

    # 覚える
    $word_list[$i] = $word;

    # 最後の文字をとる
    $last_word = substr($word , length($word)-1 , 1);
}

print("$ret\n");

exit(0);


Measured memory_bytes: 768
#include <cstdio>

int main()
{
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);
if((a*100 + b*10 + c*1)%4==0)
{
	printf("YES");
}
	else
	{
		printf("NO");
	}
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

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

#define MAX 1100
int H,W,sx,sy,gx,gy;
string s[MAX];
ll mini[MAX][MAX];

struct Data {
  int x,y;
  ll v;
  bool operator < ( const Data &d ) const {
    return v > d.v;
  }
};

int dd[] = {0,1,0,-1};

void solve() {
  rep(i,H) rep(j,W) mini[i][j] = LLONG_MAX;
  mini[sy][sx] = 0;
  priority_queue<Data> Q;
  Q.push((Data){sx,sy,0});
  while( !Q.empty() ) {
    Data d = Q.top(); Q.pop();
    if( d.x == gx && d.y == gy ) break;
    rep(i,4) {
      int nx = d.x + dd[i];
      int ny = d.y + dd[(i+1)%4];
      if( !( 0 <= nx && nx < W && 0 <= ny && ny < H ) ) continue;
      if( s[ny][nx] == '#' ) continue;
      if( mini[ny][nx] > d.v ) {
	mini[ny][nx] = d.v;
	Q.push((Data){nx,ny,d.v});
      }
    }
    REP(dx,-2,3) {
      REP(dy,-2,3) {
	int nx = d.x + dx;
	int ny = d.y + dy;
	if( !( 0 <= nx && nx < W && 0 <= ny && ny < H ) ) continue;
	if( s[ny][nx] == '#' ) continue;
	if( mini[ny][nx] > d.v + 1 ) {
	  mini[ny][nx] = d.v + 1;
	  Q.push((Data){nx,ny,d.v + 1});
	}
      }
    }
  }
  if( mini[gy][gx] == LLONG_MAX ) puts("-1");
  else cout << mini[gy][gx] << endl;
}

int main() {
  cin >> H >> W;
  cin >> sy >> sx;
  cin >> gy >> gx;
  --sx, --sy;
  --gx, --gy;
  rep(i,H) cin >> s[i];
  solve();
  return 0;
}


Measured memory_bytes: 14168
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	int P = 0;
	for (int i = 0; i < N; ++ i) {
		int x;
		cin >> x;
		if (x == 1) P = i;
	}
	int r = 1<<30;
	for (int i = 0; i+K <= N; ++ i) if (i <= P && P < i+K) {
		r = min(r, (i+K-2)/(K-1) + (N-(i+K)+K-2)/(K-1));
	}
	cout << r+1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>
#include <iomanip>
#include <cmath>
#define PI acos(-1)
typedef long long ll;
const long long mod = 998244353;
const long long maxn = 1e9 + 5; 
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
using namespace std;

/*
int n,m,x;
int c[15],a[15][15],b[15],d[15],len,sum=100000000,cost;
int i, j, k;

void dfs(int step)
{
	if(step == len+1)
	{
		for(k = 1; k <= m; k++)	d[k]=0;
		for(k = 1;k <= m; k++)
			d[k] += a[b[j]][k];
		for(k = 1; k <= m; k++)
			if(d[k] < x) return;
		cost = 0;
		for(j = 1; j <= len; j++)
			cost += c[b[j]];
		sum = min(sum, cost);
		return;
	}
	
	for(i = b[step - 1] + 1; i <= n; i++)
	{
		b[step] = i;
		dfs(step+1);		
	}
}
int main()
{
	scanf("%d %d %d", &n, &m, &x);
	for(i = 1; i <= n; i++)
	{
		scanf("%d", &c[i]);
		for(j = 1; j <= m; j++)
			scanf("%d", &a[i][j]);
	}
	
	for(len = 1; len <= n; len++)
	{
		b[0] = 0;
		dfs(1);
	}
		
	if(sum == 100000000)
		printf("-1\n");
	else 
		printf("%d\n",sum);
	return 0;
}*/





int a[20][20],c[20],cur[20];int n,m,k,ans=INF;
void dfs(int x,int sum)
{
    for(int i=1;i<=m;i++){
        cur[i]+=a[x][i];
    }
    int fg=1;
    for(int i=1;i<=m;i++){
        if(cur[i]<k) fg=0;
    }
    if(fg==1) {ans=min(ans,sum+c[x]);}
    for(int i=x+1;i<=n;i++){
        dfs(i,sum+c[x]);
        for(int j=1;j<=m;j++){
            cur[j]-=a[i][j];
        }
    }
}
int main(){
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        cin>>c[i];
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        memset(cur, 0, sizeof(cur));
        dfs(i,0);
    }
    if(ans!=INF) cout<<ans<<endl;
    else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3196
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

//0-index 抽象化半開区間遅延セグツリー
template<typename T, typename E>
class segment_tree{
    typedef function<T(T,T)> F; //要素に適用する演算
    typedef function<T(T,E)> G; //作用素の適用
    typedef function<E(E,E)> H; //作用素の合成
    typedef function<E(E,int)> P;
private:
    int num_of_elm_;
    vector<T> dat_, lazy_;
    F f_;
    G g_;
    H h_;
    P p_;
    T ident_;
    E op_ident_;
public:
    segment_tree(int n, F f, G g, H h, P p, T ident, E op_ident):f_(f), g_(g), h_(h), p_(p), ident_(ident), op_ident_(op_ident){
        num_of_elm_ = 1;
        while(num_of_elm_<n)num_of_elm_*=2;
        dat_ .resize(2*num_of_elm_,ident);
        lazy_.resize(2*num_of_elm_,op_ident);
    }
    
    void eval(int k, int len){
        if(lazy_[k] == op_ident_)return ;
        
        if(k<num_of_elm_){
            lazy_[k*2]=h_(lazy_[k*2], lazy_[k]);
            lazy_[k*2+1]=h_(lazy_[k*2+1], lazy_[k]);
        }
        dat_[k] = g_(dat_[k],p_(lazy_[k], len));
        lazy_[k] = op_ident_;
    }
    
    T update(int L, int R, int val, int l=0, int r=0, int k=1){
        if(k==1)r = num_of_elm_;
        
        eval(k,r-l);
        if(r<=L || R<=l)return dat_[k];
        else if(L<=l && r<=R){
            lazy_[k] = h_(lazy_[k], val);
            return g_(dat_[k], p_(lazy_[k], r-l));
        }
        else{
            return dat_[k] = f_(update(L,R,val,l,(l+r)/2,k*2), update(L,R,val,(l+r)/2,r,k*2+1));
        }
        
    }
    
    T query(int L, int R,int l=0,int r=0, int k=1){
        if(k==1)r = num_of_elm_;
        
        eval(k,r-l);
        if(r<=L || R<=l)return ident_;
        else if(L<=l && r<=R){
            return dat_[k];
        }
        else{
            return f_(query(L,R,l,(l+r)/2,k*2), query(L,R,(l+r)/2,r,k*2+1));
        }
    }
};

int main(){
    int n,q;
    cin>>n>>q;
    auto f = [](int a, int b){return min(a,b);};
    auto g = [](int a, int b){return b;};
    auto h = g;
    auto p = [](int a, int len){return a;};
    segment_tree<int,int> st(n, f, g, h, p, (1LL<<31)-1, -1);
    rep(i,q){
        int com;
        cin>>com;
        if(com==0){
            int s,t,x;
            cin>>s>>t>>x;
            st.update(s,t+1,x);
        }else{
            int x;
            cin>>x;
            cout<<st.query(x,x+1)<<endl;
        }
    }
}




Measured memory_bytes: 4956
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

int N, M, dist[MAXN], id;
bool used[MAXN] = {};
vi A, B, G[MAXN], prv[MAXN];

priority_queue<pii, vector<pii>, greater<pii>> Q;

void Dijkstra(int s) {
    fill(dist, dist+N, INF);
    dist[s] = 0;
    
    Q.push(make_pair(dist[s], s));

    while(!Q.empty()){
        pii tmp = Q.top();
        Q.pop();
        // cout << tmp. first << " " << tmp.second << endl;
        id = tmp.second;

        if(dist[id] < tmp.first) continue;

        if(!used[id]){
            used[id] = true;
            dist[id] = tmp.first;
            rep(k, G[id].size()){
                if(!used[G[id][k]]){
                    Q.push(make_pair(dist[id]+1, G[id][k]));
                    prv[G[id][k]].push_back(id);
                }
            }
        }
    }
}

void solve(){
    Dijkstra(0);

    // rep(i, N) cout << dist[i] << endl;
    bool flag = true;

    rep(i, N){
        if(dist[i] == INF){
            flag = false;
            break;
        }
    }

    if(flag){
        cout << "Yes" << endl;
        for(int i = 1; i < N; ++i){
            rep(j, prv[i].size()){
                if(dist[i] == dist[prv[i][j]] + 1){
                    cout << prv[i][j] + 1 << endl;
                    break;
                }
            }
        } 
    } else {
        cout << "No" << endl;
    }

}

int main(){
    cin >> N >> M;
    A.resize(M), B.resize(M);

    rep(i, M) {
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;

        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }

    solve();
}


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

int a[100001];
int vis[100001];
int main(){
	int n,ans= 0;
	
	cin >> n;
	for(int i = 1;i<=n;i++){
		cin >> a[i];
	}
	int i = 1;
	while(!vis[i]&&i!=2){
		vis[i] = 1;
		ans++;
		i = a[i];
	}
	if(i!=2) cout << "-1";
	else cout << ans;
} 

Measured memory_bytes: 1024
<?php
//error_reporting(0);
//$N = (int)trim(fgets(STDIN));
$S = trim(fgets(STDIN));
//list($a,$b,$c) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$s = trim(fgets(STDIN));
//$a = array_map('intval',explode(" ",trim(fgets(STDIN))));

if (strpos($S,"7")!==false) {
  printf("Yes\n");
}
else {
  printf("No\n");
}


Measured memory_bytes: 16004
fun main(args: Array<String>) {
    val n = readInt()
    val s = readString()

    var ans = 0
    for (i in 0..999) {
        val l = String.format("%03d", i)
        var j = 0
        var one = true
        var two = true
        var three = true
        while (j < n) {
            when {
                one -> {
                    if (s[j] == l[0]) {
                        one = false
                    }
                }
                two -> {
                    if (s[j] == l[1]) {
                        two = false
                    }
                }
                three -> {
                    if (s[j] == l[2]) {
                        three = false
                    }
                }
            }
            if (!one && !two && !three) {
                ans++
                break
            }
            j++
        }

    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()

Measured memory_bytes: 43072
N, M = map(int, input().split())
X = list(sorted(map(int, input().split())))

L = [0] * (M - 1)
for i in range(1, M):
    L[i - 1] = X[i] - X[i - 1]

L = sorted(L, reverse=True)

print(sum(L[N - 1:]))


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


int main(){
    int n;
    float total = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        float m;
        scanf("%f", &m);
        char A[10];
        scanf("%s", A);
        if(A[0] == 'J'){
            total += m;
        }else{
            total += (m * 380000);
        }
    }
    printf("%f\n", total);
    return 0;
}

Measured memory_bytes: 384
n =int(input())
sp = []
for i in range(n):
  s,p = map(str, input().split())
  sp.append([s,int(p),i+1])
sp.sort(key= lambda x:x[1] ,reverse=True)
sp.sort(key= lambda x:x[0] )

for e in sp:
  print(e[2])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long n,h,da=0;
string st;
int main()
{
    cin>>n;
    cin>>st;
    for(int i=0;i<st.size();i++)
    {
        if(st[i]=='I')h++;
        else h--;
        if(h>da)da=h;
    }
    cout<<da<<endl;
    return 0;
}

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

pub struct Scanner<R>
where
    R: BufRead,
{
    reader: R,
}

impl<R> Scanner<R>
where
    R: BufRead,
{
    pub fn new(reader: R) -> Self {
        Self { reader }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: ::std::str::FromStr,
        <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
    {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .unwrap()
    }
}

use std::iter::*;

fn main() {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let mut sc = Scanner::new(stdin);

    loop {
        let n: usize = sc.next();
        if n == 0 {
            break;
        }
        let s: Vec<f64> = (0..n).map(|_| sc.next()).collect();
        let m: f64 = s.iter().fold(0., |acc, x| acc + x);
        let m = m / n as f64;
        let d: f64 = s
            .iter()
            .map(|x| (*x - m).powi(2))
            .fold(0.0, |acc, x| acc + x);
        let d = d / n as f64;
        let d = d.sqrt();

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



Measured memory_bytes: 5080
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

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

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	int n;
	cin >> n;
	vl v(n);
	cin >> v;
	for(ll x : v)
		if(x == 0)
			ret(0);
	ll a = 1;
	for(ll x : v)
	{
		if(a > (ll)1e18 / x)
			ret(-1);
		a *= x;
	}
	ret(a);
}


Measured memory_bytes: 3992
"use strict";

const main = arg => {
    const inputList = arg.trim().split("\n");
    // 回答を記述
    const X = parseInt(inputList[0].split(" ")[0]);
    const N = parseInt(inputList[0].split(" ")[1]);
    if (N == 0) {
        console.log(X)
    } else {
        const PList = inputList[1].split(" ").map(ele => parseInt(ele))

        const hundred = [...Array(100).keys()].map(i => ++i)
        hundred.unshift(0);

        const notExistPList = hundred.filter(ele => PList.indexOf(ele) == -1)

        const result = notExistPList.reduce((acc, cur) => {
            const accDif = Math.abs(X - acc);
            const curDif = Math.abs(X - cur);
            if (accDif == curDif) {
                return Math.min(acc, cur);
            } else if (accDif > curDif) {
                return cur;
            } else {
                return acc;
            }
        }, 101);

        if (Math.abs(X - result) >= Math.abs(X - (-1))) {
            console.log(-1)
        } else {
            console.log(result)
        }
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29596
#include <cstdio>

using namespace std;

#define MAX_N 10000
#define MAX_Q 500

// 2つの数列から同じ要素を含んでいる数を出力する

int linear_search(int n, unsigned int *S, int q, unsigned *T);

int main()
{
	unsigned int S[MAX_N];
	unsigned int T[MAX_Q];
	
	int n, q;
	int ans;
	
	// 初期化
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &S[i]);
	}
	
	// 初期化
	scanf("%d", &q);
	for (int i = 0; i < q; i++)
	{
		scanf("%d", &T[i]);
	}
	
	ans = linear_search(n, S, q, T);
	printf("%d\n", ans);
	
	return 0;
}

int linear_search(int n, unsigned int* S, int q, unsigned* T)
{
	int equal = 0;
	
	for (int i = 0; i < q; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (T[i] == S[j])
			{
				equal++;
				break;
			}
		}
	}
	
	return equal;
}



Measured memory_bytes: 2752
i = gets.chomp.to_i

As=gets.chomp.split(" ").map(&:to_i)

Bs = gets.chomp.split(" ").map(&:to_i)

Cs = gets.chomp.split(" ").map(&:to_i)
Cs << 0

befo = 0
sum = 0
As.each do |e|
  if e == befo + 1
  	sum += Cs[befo-1]
  end
  sum += Bs[e-1]
  befo = e
end

puts sum

Measured memory_bytes: 1788
#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 <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

const LL mod = 1e9 + 7;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N+1);
	set<int> a;
	REP(i, N) {
		int a_;
		cin >> a_;
		A[a_] ++;
		a.insert(a_);
	}

	if (a.size() <= K) {
		cout << 0 << endl;
	}
	else {

		int numremove = a.size()-K;
		int ans = 0;
		int num = 0;
		sort(ALL(A), less<int>());
		REP(i, SZ(A)) {

			ans += A[i];
			if (A[i] != 0) { num++; }
			if (num >= numremove) { break; }
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 10368
#include<bits/stdc++.h> 
//compiling code: g++ test.cpp(file) -o script(output) -std=c++11(version) -O2(make it 2x faster)
using namespace std;

int parent[200005], ranks[200005]; 


void initset(int n){
    for (int i=0; i<n; i++){
        parent[i] = i;
        ranks[i] = 0;
    }
}

int findset(int x){
    if (parent[x] == x) return x;
    parent[x] = findset(parent[x]); // path compression
    return parent[x];
}

bool sameset(int x, int y){
    return findset(x) == findset(y);
}

void mergeset(int x, int y){
    x = findset(x);
    y = findset(y);
    if(ranks[x] > ranks[y]){
        parent[y] = x;
    } else { //ranks[x] <= ranks[y]
        parent[x] = y;
        if (ranks[x] == ranks[y]){
            ranks[y]++;
        }
    }
}

int M, N, K, L;

int main(){
    cin >> N >> M;
    initset(N+M+5); // 5 is a buffer
    for(int i=0; i <N; i++){
        cin >> K;
        for(int j=0; j<K; j++){
            cin >> L;
            mergeset(i+1, N+L);
        }
    }

    for(int i=1; i<= N; i++){
        if(!sameset(i, 1)){
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}

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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int a,b;
    cin >> a >> b;
    cout << (a+b+1)/2 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    printf("%.8f\n", sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
}

Measured memory_bytes: 1228
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String output = "Three";

		// 個数の入力
		int num = sc.nextInt();

		String[] colors = new String[num];
		for(int i = 0; i < num ; i++) {
			colors[i] = sc.next();
		}

		sc.close();

		for (int i = 0; i < colors.length; i++) {
			if (colors[i].equals("Y")) {
				output = "Four";
				break;
			}
		}

		System.out.println(output);
	}
}

Measured memory_bytes: 23380
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

int main(){
	string a;
	cin>>a;
	
	if(a=="a"||a=="i"||a=="u"||a=="e"||a=="o"){
		cout<<"vowel"<<endl;
		}
	else{
		cout<<"consonant"<<endl;
		}
	}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

uint64_t T_NUM[51];
uint64_t P_NUM[51];
  
void AddBan(uint64_t X, uint64_t *T, uint64_t *P) {
  *T += 1; 
  if(*T == X) {
    printf("%ld\n", *P);
    exit(0);
  }
}

void AddPat(uint64_t X, uint64_t *T, uint64_t *P) {
  *T += 1;
  *P += 1;
  if(*T == X) {
    printf("%ld\n", *P);
    exit(0);
  }
}

void make_burger(int N, uint64_t X, uint64_t *T, uint64_t *P) {
  //printf("debug N=%d *T=%ld, *P=%ld\n", N, *T, *P);
  if(N == 0) {
    AddPat(X, T, P);
  } else {
    // B * P * B
    AddBan(X, T, P);

    if(X > (*T + T_NUM[N-1])) {
      *T += T_NUM[N-1];
      *P += P_NUM[N-1];
    } else {
      make_burger(N-1, X, T, P);
    }
    
    AddPat(X, T, P);

    if(X > (*T + T_NUM[N-1])) {
      *T += T_NUM[N-1];
      *P += P_NUM[N-1];
    } else {
      make_burger(N-1, X, T, P);
    }
    
    AddBan(X, T, P);
  }
}

int main(void) {
  int N;
  uint64_t X;
  scanf("%d %ld", &N, &X);

  T_NUM[0] = 1;
  P_NUM[0] = 1;
  for(int i = 1; i <= 50; i++) {
    T_NUM[i] = 3 + 2 * T_NUM[i-1];
    P_NUM[i] = 1 + 2 * P_NUM[i-1];
  }
  
  uint64_t T, P;
  T = 0; P = 0;
  make_burger(N, X, &T, &P);

  return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        Map<String, Integer> m = new HashMap<String, Integer>();
        int[] d = {-2, -1, 0};
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) for (int k = 0; k < 3; k++) {
                int ny = a[i] + d[j], nx = b[i] + d[k];
                if (ny <= 0 || ny + 2 > h || nx <= 0 || nx + 2 > w) continue;
                sb.append(ny).append('+').append(nx);
                String key = sb.toString();
                sb.delete(0, sb.length());
                m.put(key, m.getOrDefault(key, 0) + 1);
            }
        }
        long[] cnt = new long[10];
        for (String key : m.keySet()) {
            cnt[m.get(key)]++;
        }
        System.out.println(((long)(h - 2)) * (w - 2) - m.size());
        for (int i = 1; i <= 9; i++) {
            System.out.println(cnt[i]);
        }
    }
}


Measured memory_bytes: 206896
n = int(input())
a = list(map(int, input().split()))

a_min = min(a)
a_max = max(a)

a_sum = []
for i in range(a_min, a_max + 1):
    num=0
    for j in range(n):
        num += (a[j] - i) ** 2
    a_sum.append(num)
print(min(a_sum))

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <climits>
#include <stack>

using namespace std;

int main() {
	stack<int> S;

	int n;
	int u, v;
	int AdjList[101][99];
	int next[101];
	int Deg[101];
	bool Visited[101];
	int d[101], f[101], time;
	int i, j;
	cin >> n;
	for (i = 1; i <= n; i++) {
		Visited[i] = false;
		next[i] = 0;
		d[i] = 0;
		cin >> u;
		cin >> Deg[u];
		for (j = 0; j < Deg[u]; j++) {
			cin >> v;
			AdjList[u][j] = v;
		}
	}

	time = 1;
	for (i = 1; i <= n; i++) {
		if (Visited[i] != true) {
			v = i;
			S.push(v);
			while (S.empty() != true) {
				v = S.top();
				if (d[v] == 0) {
					d[v] = time++;
				}
				Visited[v] = true;
				for (i = next[v]; i < Deg[v]; i++) {
					u = AdjList[v][i];
					if (Visited[u] != true) {
						S.push(u);
						break;
					}
				}
				if (i == Deg[v]) {
					S.pop();
					f[v] = time++;
				}
				else {
					next[v] = i + 1;
				}
			}
		}
	}

	for (i = 1; i <= n; i++) {
		printf("%d %d %d\n", i, d[i], f[i]);
	}

	return 0;

}

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

using namespace std;

using ll = long long int;
using pii = pair<int, int>;

int main()
{
    ll S;
    cin >> S;

    const int N = 1000000000;

    const int q = S / N;
    const int r = S % N;

    int x1 = 0, y1 = 0;
    int x2, y2, x3, y3;
    if (q == N)
    {
        x2 = N;
        y2 = 0;
        x3 = 0;
        y3 = N;
    }
    else
    {
        x2 = N;
        y3 = q + 1;
        x3 = N - r;
        y2 = 1;
    }
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<vector>
#include<stdio.h>
#include<functional>
#include<algorithm>
using namespace std;

long long gcd(long long a, long long b) {
	if (a < b) return gcd(b, a);
	long long r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

long long lcm(long long m, long long n){
	return m * n / gcd(m, n);
}

int main() {
	long long a, b;
	cin >> a >> b;

	long long i = 2;
	long long x = gcd(a, b);
	long long y = x;
	long long ans = 1;
	while (y>= i * i) {
		if (x % i == 0) {
			while (x % i == 0) x /= i;
			ans++;
		}
		i++;
	}
	if (x != 1)ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
L, R = map(int, input().split())
if L+2019 <= R:
  print(0)
else:
  m = 2019
  for a in range(L, R+1):
    for b in range(a+1, R+1):
      m = min(m, ((a%2019)*(b%2019))%2019)
  print(m)

Measured memory_bytes: 9152
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;
//ll mod = 998244353;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	//t %= mod;
	if (n % 2 == 1)t *= a;
	return t /*% mod*/;
}

const int INF = 1001001001;
//const ll INF = 1e18;

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}

vector<pair<ll, ll>> prime_factorize(ll N) {
	vector<pair<ll, ll>> res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0;
		while (N % a == 0) {
			++ex;
			N /= a;
		}
		res.push_back({ a, ex });
	}
	if (N != 1) res.push_back({ N, 1 });
	return res;
}


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


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll MOD = 1000000007;
ll INF =1<<30;

int main(){
    ll x,k,d;
    cin >> x>>k >>d;
    if(x==0) {
        if(k%2==0) {cout << 0<<endl;
        return 0;}
        else {
            cout << abs(d) <<endl;
            return 0;
        }
    }
    if(x>0){
        if(x/d<=k){
            ll y = x%d;
            ll z = y-d;
            ll cnt = x/d;
            if((k-cnt)%2==0){
                cout << abs(y) <<endl;
                return 0;
            }
            else {
                cout << abs(z) <<endl;
                return 0;
            }
        }
        else{
            cout << x-d*k<<endl;;
            return 0;
        }
    }
    if(x<0){
        ll xx = -x;
        if(xx/d<=k){
            ll y = xx%d;
            ll z = y-d;
            ll cnt = xx/d;
            if((k-cnt)%2==0){
                cout << abs(y) <<endl;
                return 0;
            }
            else {
                cout << abs(z) <<endl;
                return 0;
            }
        }
        else{
            cout << xx-d*k<<endl;;
            return 0;
        }
    }
    
}

Measured memory_bytes: 3628
#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

int read() {
	char ch;
	for(ch=getchar();ch<'0'||ch>'9';ch=getchar());
	int x=ch-'0';
	for(ch=getchar();ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

const int N=2e5+5,Mo=1e9+7;

void mod(int &x) {x=x>=Mo?x-Mo:x;}
void inc(int &x,int y) {x=x+y>=Mo?x+y-Mo:x+y;}

int pwr(int x,int y) {
	int z=1;
	for(;y;y>>=1,x=(ll)x*x%Mo)
		if (y&1) z=(ll)z*x%Mo;
	return z;
}

int n,ql,qr,tmp,a[N],cnt[N],t[N],tag[N<<2],tr[N<<2];
vector<int> p[N];

void Ins(int x) {for(;x<=n;x+=x&-x) t[x]++;}
int Que(int x) {int res=0;for(;x;x-=x&-x) res+=t[x];return res;}

void mult(int v,int z) {
	tr[v]=(ll)tr[v]*z%Mo;
	tag[v]=(ll)tag[v]*z%Mo;
}

void down(int v) {
	if (tag[v]!=1) {
		mult(v<<1,tag[v]);
		mult(v<<1|1,tag[v]);
		tag[v]=1;
	}
}

void ins(int v,int l,int r,int x) {
	if (l==r) {tr[v]=tmp;return;}
	int mid=l+r>>1;down(v);
	if (x<=mid) ins(v<<1,l,mid,x);
	else ins(v<<1|1,mid+1,r,x);
	mod(tr[v]=tr[v<<1]+tr[v<<1|1]);
}

int query(int v,int l,int r) {
	if (ql<=l&&r<=qr) return tr[v];
	int mid=l+r>>1;down(v);
	int sum=0;
	if (ql<=mid) inc(sum,query(v<<1,l,mid));
	if (qr>mid) inc(sum,query(v<<1|1,mid+1,r));
	return sum;
}

int main() {
	n=read();
	fo(i,1,n) {
		a[i]=read();
		cnt[a[i]]++;
		p[a[i]].push_back(i);
	}
	fd(i,n,1) cnt[i]+=cnt[i+1];
	int sum=1,inv=pwr(2,Mo-2);
	fo(i,1,n) {
		if (cnt[i]-n+i<0) {puts("0");return 0;}
		sum=(ll)sum*(cnt[i]-n+i)%Mo;
	}
	tmp=(ll)sum*inv%Mo;
	fo(i,1,n<<2) tag[i]=1;
	int ans=0;
	fd(i,n,1) {
		if (!p[i].empty()) {
			int sz=p[i].size();
			fo(j,0,sz-1) {
				int x=p[i][j];
				ql=x;qr=n;inc(ans,query(1,1,n));
				inc(ans,(ll)sum*Que(x)%Mo);
				ql=1;qr=x;inc(ans,Mo-query(1,1,n));
				ins(1,1,n,x);Ins(x);
			}
		}
		mult(1,(ll)(cnt[i]-n+i-1)*pwr(cnt[i]-n+i,Mo-2)%Mo);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 19712
import java.util.*;
class Main{
	public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int r = sc.nextInt();
      int c = sc.nextInt();


			System.out.println(keta(r, c, 1,1));


      
    }
    public static long calc(long a,long b){
      System.out.println(factorial(a)+" "+factorial(b));
      return factorial(a+b)/(factorial(a)*factorial(b));
    }

		public static int keta(int a, int b, int c,int i){

			c = c*b;
			if(c > a){
				return i;
			}
			return keta(a,b,c,i+1);
		}

    public static long factorial(long n){
      if(n == 0){
        return new Long(1);
       }
       System.out.println(n * factorial(n-1));

      return n * factorial(n-1);
    }
}


Measured memory_bytes: 21844
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

int main()
{
	string s;
	ll a,b=0; cin>>a; cin>>s;
	for(int i=0;i<s.length();i++) if(s[i]!='.') b=b*10+(s[i]-'0');
	printf("%lld\n",(ll)((a*b)/100));
	return 0;
}

Measured memory_bytes: 3720
N,M = map(int,input().split())
order = {}
if N==1 and M==0:
  print(0)
else:
  for i in range(M):
    s,c = map(int,input().split())
    if order.get(s,57)==57:
        order[s]=c
    elif order.get(s,57)!=57 and order[s]!=c:
        print(-1)
        break
  else:
    moji = [1]+[0]*(N-1)
    for k in order.keys():
        moji[k-1]=str(order[k])
    if N!=1 and moji[0]=='0':
      print(-1)
    else:
      print(''.join([str(a) for a in moji]))

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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

/*
bool divisor(lld n){
    for(lld i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            if((i != n && cnt[i] > 0) || (i == n && cnt[i] > 1)) return true;
            if(i * i != n) {
                if((n/i != n && cnt[n/i] > 0) || (n/i == n && cnt[n/i] > 1)) return true;
            }
        }
    }
    return false;
}
*/

vector< lld > divisor(lld n) {
  vector< lld > ret;
  for(lld i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  return (ret);
}

int main() {
    lld N;
    lld A[200001];
    lld cnt[1000005];
    cin >> N;
    mem0(cnt);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        cnt[A[i]]++;
    }
    lld ans=N;
    for (int i = 0; i < N; i++) {
        if(cnt[A[i]] == 1){
            vector<lld> ret = divisor(A[i]);
            for(int j=0;j<ret.size();j++){
                if(ret[j] == A[i]) continue;
                if(cnt[ret[j]] > 0){
                    ans--;
                    break;
                }
            }
        } else {
            ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 13008
#include <stdio.h>
#include <string.h>
#define C "Cloudy"
#define S "Sunny"
#define R "Rainy"
int main() 
{
	char s[6];
	scanf("%s",s);
	if(strcmp(s,S)==0)
	{
		printf("%s",C);
	}
	if(strcmp(s,C)==0)
	{
		printf("%s",R);
	}
	if(strcmp(s,R)==0)
	{
		printf("%s",S);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N,b;
  cin >> N;
  vector<pair<pair<string ,int>,int>> data;
  string a;
  for(int i=0; i<N; i++){
    cin >> a >>b;
    data.push_back(make_pair(make_pair(a,-b),i+1));
  }
  sort(data.begin(),data.end());
  for(int i=0; i<N; i++)
    cout << data.at(i).second << endl;
}

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

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

  string s;
  cin >> s;

  int n = s.length();

  for (int i = 0; i < n; ++i) {
    if ((i & 1) && s[i] == 'R') {
      cout << "No\n";
      return (0);
    }

    if (!(i & 1) && s[i] == 'L') {
      cout << "No\n";
      return (0);
    }
  }

  cout << "Yes\n";

  return (0);
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;



int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  ll A=a*a,B=b*b,C=c*c;
  if (c-a-b>0 && A+B+C-2*a*b-2*b*c-2*a*c>0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<numeric>
#include<list>
#include<limits>
#include<algorithm>
#include<cmath>
#include<unordered_map>
#include<unordered_set>

#define pi 3.141592653589793
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

using namespace std;
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;

const long long MOD = 10e9 + 7;
const long long INF = 10e9 ;

template <typename T>
std::ostream& operator<<(ostream& os, 
                        const vector<T> &v)
{
    for (T const& i: v) {
        os << i << " ";
    }
    os<<endl;
    return os;
}

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
vector<int> sieve(int n){
    vector<bool> s(n, true);
    for(int i =2 ; i*i <= n; i++ )
        if(s[i])
            for(int j=2*i; j< n; j +=i )
                s[j] = false;

    vector<int> primes;
    for(int i =0; i<n; i++)
        if( s[i] )
            primes.push_back(s[i]);

    return primes;
}

int main(){
    int n, m;
    cin>>n>>m;
    VII ar(m);
    for(auto &i: ar) cin>>i;
    long long sum = 0; 
    for(auto i: ar) sum+=i;
    if( sum > n )
        cout<< " -1";
    else
        cout<< n - sum;

    return 0;
}

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

int main(){
    int a = 1,b = 1;
    for(int i = 0; i < 9; ++i){
        for(int j = 0; j < 9; ++j){
            cout<<a<<"x"<<b<<"="<<a*b<<endl;
            b += 1;
        }
        b = 1;
        ++a;
    }
}


Measured memory_bytes: 3076