akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define OUT(x) cout<<x<<endl
int main(){
  int n,ud,ans;
  bool o;
  string ins;
  while(cin>>n&&n){
    o = false;
    ud = ans = 0;
    for(int i=0;i<n;i++){
      cin >> ins;
      if(ins == "lu" || ins == "ru")ud++;
      else ud--;
      if(!o&&ud==2){
	ans++;
	o = true;
      }
      else if(o&&!ud){
	ans++;
	o = false;
      }
    }
    OUT(ans);
  }
}

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int n, m;
    int l[100001], r[100001];
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> l[i] >> r[i];
    }

    int mx = INF, mn = -1;
    for (int i = 0; i < m; i++)
    {
        mx = min(mx, r[i]);
        mn = max(mn, l[i]);
    }
    // cout << mx << "," << mn << endl;
    cout << max(0LL, mx - mn + 1) << endl;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int_fast32_t n;
    string s;

    cin >> n >> s;

    vector<int_fast32_t> pr, pg, pb;

    for(int_fast32_t i = 0; i < n; ++i) {
        switch(s.at(i)) {
            case 'R':
                pr.emplace_back(i);
                break;
            case 'G':
                pg.emplace_back(i);
                break;
            case 'B':
                pb.emplace_back(i);
                break;
        }
    }

    uint_fast32_t ans = pr.size() * pg.size() * pb.size();

    for(int_fast32_t i: pr) {
        for(int_fast32_t j: pg) {
            if(i < j) {
                if(2 * i - j >= 0 && s.at(2 * i - j) == 'B') --ans;
                if(2 * j - i < n && s.at(2 * j - i) == 'B') --ans;
                if((j - i) % 2 == 0 && s.at((i + j) / 2) == 'B') --ans;
            }
            if(i > j) {
                if(2 * j - i >= 0 && s.at(2 * j - i) == 'B') --ans;
                if(2 * i - j < n && s.at(2 * i - j) == 'B') --ans;
                if((i - j) % 2 == 0 && s.at((i + j) / 2) == 'B') --ans;
            } 
        }
    }

    printf("%ld\n", ans);

    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans = 1e9;
void solve(ll x, ll y){
	ll odd = y%2;
	for(ll i=1; i<x; i++){
		ll A = max({(x-i)*y, y/2*i, (y/2+odd)*i});
		ll B = min({(x-i)*y, y/2*i, (y/2+odd)*i});
		ans = min(ans, A-B);
	}
	ll md3 = 0;
		if(x%3) md3 = 1;
		ans = min(ans, (x/3 + md3)*y - x/3*y);
}


int main(){
	ll h, w;
	cin >> h >> w;
	
	solve(h, w);
	solve(w, h);
	
	
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  long long n,i;
  cin >> n;
  for(i=1; i*i<=n; i++){
    if(i*i == n){
      i++;
      break;
    }
  }
  cout << (i-1) * (i-1) << endl;
  
  return 0;
}

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

int main () {
  string S, T;
  cin >> S >> T;
  
  int A, B;
  cin >> A >> B;
  
  string U;
  cin >> U;
  
  if (S == U) {
    cout << A - 1;
  } else {
    cout << A;
  }
  
  cout << " ";
  
    if (T == U) {
    cout << B - 1;
  } else {
    cout << B;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iomanip>
using namespace std;
int main(){
	string s;
	cin >> s;
	for(int i=0;i<s.size();i=i+2){
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


string s, t;

void solve()
{
    cin >> s >> t;
    int ans=0;
    for (int i=0; i<3; i++) if (s[i]==t[i]) ans++;
    nout(ans);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define se second
#define fi first
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef vector<int>  vi;
typedef pair<ii, ll>  iii;
typedef pair<double, double>  iidb;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const double PI = acos(-1);
#define initseg ll new_nodo=(nodo*2)+1,mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define offset 9000

const ll MOD=1e9+7;

#define cmplog 20
#define tam 600000


using namespace std;

int main()
{	
	ios::sync_with_stdio(false);cin.tie(0);
	int n;
	cin>>n;
	int c1,c2;
	c1=c2=0;
	forr(i,1,n+1)
	{
		forr(j,i,n+1)
		{
			if (i*j>=n)break;
			if (i!=j)c1++;
			else c2++;
		}
	}
	cout<<c1*2+c2<<endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
using namespace std;
const int mod=1000000007;
typedef long long ll;
typedef pair<int,int> P;


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

    rep(i,1,n){
        if((int)(i*1.08)==n){
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mxn= 5e5+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    rishabh();
    int t;
    t=1;
    while(t--){
        int n, ans=0;
        cin>>n;
        for(int i=1;true;i++){
            if(ans+i>=n){
                ans=i;
                break;
            }
            else ans=ans+i;
        }
        cout<<ans;
    }
}


Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 100000000

int main(){
    string s;cin>>s;
    string a="dream",b="dreamer",c="erase",d="eraser";//判定

    int key,i=s.size()-1;
    while(i>=0){
        int num=i;
        if(i-4>=0){
            if(s[i]=='m' && s[i-1]=='a' && s[i-2]=='e' && s[i-3]=='r' && s[i-4]=='d'){
                key=i-4;
                if(key==0){break;}
                i=key-1;
            }
            if(s[i]=='e' && s[i-1]=='s' && s[i-2]=='a' && s[i-3]=='r' && s[i-4]=='e'){
                key=i-4;
                if(key==0){break;}
                i=key-1;
            }
        }
        if(i-5>=0){
            if(s[i]=='r' && s[i-1]=='e' && s[i-2]=='s' && s[i-3]=='a' && s[i-4]=='r' && s[i-5]=='e'){
                key=i-5;
                if(key==0){break;}
                i=key-1;
            }
        }
        if(i-6>=0){
            if(s[i]=='r' && s[i-1]=='e' && s[i-2]=='m' && s[i-3]=='a' && s[i-4]=='e' && s[i-5]=='r' && s[i-6]=='d'){
                key=i-6;
                if(key==0){break;}
                i=key-1;
            }
        }
        
        if(i==num){key=1;break;}
    }

    if(key==0){cout<<"YES"<<endl;}
    else{cout<<"NO"<<endl;}

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
int main()
{
    std::string S;
    std::cin >> S;
    long ans = 0;

    int bs = 0;
    for (size_t i = 0; i < S.size(); i++) {
        if (S.at(i) == 'B') {
            bs++;
        } else {
            ans += bs;
        }
    }

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

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

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

  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A.at(i);

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

  int num = A.at(0);
  for(int i = 1; i < N; ++i) {
    if(num != A.at(i)) {
      num = A.at(i);
    }
    else {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int triangle(int,int,int);

int main(void){
	int AB,BC,CA,S;
	
	scanf("%d %d %d",&AB,&BC,&CA);
	
	S=triangle(AB,BC,CA);
	
	printf("%d\n",S);
	return 0;
}

int triangle(int a,int b,int c){
	
	return a*b/2;
	
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void) {
    int n,m,l,i,j,k;
    int a[100][100],b[100][100];
    long c[100][100];
     
    scanf("%d %d %d" ,&n ,&m ,&l);
     
    for (i=0; i<n; i++) {
        for (j=0; j<m; j++) {
            scanf("%d",&a[i][j]);
        }
    }
     
    for (i=0; i<m; i++) {
        for (j=0; j<l; j++) {
            scanf("%d",&b[i][j]);
        }
    }
     
    for (i=0; i<n; i++) {
        for (j=0; j<l; j++) {
            for (k=0; k<m; k++) {
                c[i][j] +=a[i][k]*b[k][j];
            }
        }
    }
    for (i=0; i<n; i++) {
        for (j=0; j<l-1; j++) {
            printf("%ld ",c[i][j]);
        }
        printf("%ld",c[i][j]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 760
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    int cur;
    cin >> cur;
    ll ans = 0;
    for(int i = 1; i < N; ++i){
        int A;
        cin >> A;
        if(cur >= A)    ans += cur - A;
        else    cur = A;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <ctype.h>
const int bufSize = 1e6;
inline char nc()
{
    #ifdef DEBUG
    return getchar();
    #endif
    static char buf[bufSize],*p1 = buf,*p2 = buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,bufSize,stdin),p1==p2)?EOF:*p1++;
}
template<typename T>
inline T read(T &r)
{
    static char c;
    r=0;
    for(c = nc();!isdigit(c);) c = nc();
    for(;isdigit(c);c=nc()) r = r * 10 + c - 48;
    return r;
}
const int maxn = 110;
int n;
int a[maxn];
int main()
{
    read(n);
    for(int i = 1;i<=n;++i) read(a[i]);
    int ans = 0;
    for(int i = 1;i<=n;i += 2)  ans += a[i] % 2;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N;
void func()
{
    cin >> N;
    int A[N + 1] = {};
    A[0] = INFTY;
    rep(i, 1, N + 1) cin >> A[i];
    sort(&A[0], &A[N + 1], greater<int>());
    ll ans = A[1];
    rep(i, 2, N / 2 + 1) ans += (A[i] * 2);
    if (N % 2)
        ans += A[N / 2 + 1];
    cout << ans << endl;
}
int main()
{
    func();
}

Measured memory_bytes: 4376
const main = (input: void) => {
  const n: number = parseInt(input.split('\n')[0],10);
  const a: number = input.split('\n')[1].split(' ')
                      .map(x => parseInt(x,10));
  let cnt: number = 0;

  for (let i = 0; i < n; i ++) {
    while (a[i] %2 === 0) {
      a[i] = a[i]/2;
      cnt++ ;
    }
  }
  console.log(cnt);
}

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

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

#define FAST ios_base::sync_with_stdio(false); \
			 cin.tie(nullptr);                 \
	         cout.tie(nullptr)

struct VAL
    {
    int ind, year, per;

    bool operator< (VAL over)
        {
        if (per != over.per) return (per < over.per);
        return (year < over.year);
        }
    };



vector<VAL> data;
vector<string> ansers;

long long a, b, k, n, m, tmp, ans = 0;





int main()
    {
    FAST;


    cin >> m >> n;

    data.resize(n);
    ansers.resize(n);

    for (int i = 0; i < n; i++)
        {
        cin >> data[i].per >> data[i].year;
        data[i].ind = i;
        }

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

    int cur_per = -1;
    int cur_counter = 0;

    for (int i = 0; i < n; i++)
        {
        if (cur_per == data[i].per) cur_counter++;
        else
            {
            cur_per = data[i].per;
            cur_counter = 1;
            }

        ansers[data[i].ind] = string("000000000000");
        for (int num = data[i].per, counter = 5; num > 0; num/= 10, counter--)
            {
            ansers[data[i].ind][counter] = '0' + num%10;
            }

        for (int num = cur_counter, counter = 11; num > 0; num/= 10, counter--)
            {
            ansers[data[i].ind][counter] = '0' + num%10;
            }
        }




    for (int i = 0; i < n; i++)
        {
        cout << ansers[i] << endl;
        }


    return 0;
    }


Measured memory_bytes: 9344
import java.util.Scanner;

public class Main{
	public Main(){
		Scanner sc = new Scanner(System.in);
		int f = 0;
		while(true){
			int n = sc.nextInt();
			if(n == 0){
				break;
			} else if(f == 1){
				System.out.println();
			}
			f = 1;
			
			Team[] team = new Team[n];
			
			for(int i = 0; i < n; i++){
				String str = sc.next();
				int score = (sc.nextInt())*3 + (sc.nextInt())*0 + sc.nextInt();
				team[i] = new Team(str, score);
			}
			sort(team, n);
			
			for(int i = 0; i < n; i++){
				team[i].print();
			}
		}
	}
	
	void sort(Team team[], int n){
		Team tmp;
		for(int i = n-1; i >= 0; i--){
			for(int j = 1; j <= i; j++){
				if(team[j].get() > team[j-1].get()){
					tmp = team[j];
					team[j] = team[j-1];
					team[j-1] = tmp;
				}
			}
		}
	}
	
	public static void main(String[] args){
		new Main();
	}
}

class Team{
	private String str;
	private int score;
	
	public Team(String str, int score){
		this.str = str;
		this.score = score;
	}
	
	public int get(){
		return score;
	}
	
	public void print(){
		System.out.println(str+","+Integer.toString(score));
	}
}

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

int solve(vector<int> graph[], vector<int>& dp, int node) {
    if(dp[node] == -1)
    {
        dp[node] = 0;
        for(int child : graph[node])
            dp[node] = max(dp[node], 1+solve(graph, dp, child));
    }

    return dp[node];
}

int main() {
    int n, m;
    cin >> n >> m;

    vector<int> graph[n+2];
    vector<int> dp(n+2, -1);
    for(int i=0; i<m; ++i)
    {
        int x, y;
        cin >> x >> y;
        graph[x].push_back(y);
    }

    int ans = 0;
    for(int i=1; i<=n; ++i)
        ans = max(ans, solve(graph, dp, i));
    
    cout << ans << endl;

    return 0;
}

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

int main() {
    cout<< fixed << setprecision(100);
    double pi = M_PI;
    double a, b, c;
    cin >> a >> b >> c;
    double rad = c * pi / 180;
    double s = a * b * sin(rad) / 2;
    cout << s << endl;
    double edge = sqrt(a * a + b * b - 2 * a * b * cos(rad));
    cout << a + b + edge << endl;
    cout << s * 2 / a << endl;
}



Measured memory_bytes: 3464
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(vec) vec.begin(), vec.end()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define repc(bit, k, n) for (ll bit = (1 << k) - 1; bit < (1 << n); bit = next_combination(bit))
#define repi(itr, vec) for (auto itr = vec.begin(); itr != vec.end(); ++itr)
#define lb(bec, val) lower_bound(ALL(bec), val)
using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  rep(i, n) cout << "ACL";
  cout << endl;

  return 0;
}


Measured memory_bytes: 3580
#include<stdio.h>
#include<string.h>
int main(){
  char s[1001],t[1001];
  scanf("%s%*c%s",s,t);
  int slen=strlen(s),tlen=strlen(t),i,j;
  int min=tlen;
  for(i=0;i<slen-tlen+1;i++){
    int temp=0;
    for(j=0;j<tlen;j++){
      if(s[i+j]!=t[j])
        temp++;
    }
    if(temp<min)
      min=temp;
  }
  printf("%d\n",min);
  return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int h, w, n; cin >> h >> w >> n;
	vi a(n), b(n);
	map<int, vi> pt;
	rep(i, n){
		cin >> a[i] >> b[i];
		pt[a[i]].pb(b[i]);
	}
	for(auto &p : pt) sort(all(p.second));
	
	vector<ll> ans(10);
	ans[0] = (h - 2) * (w - 2ll);
	
	set<pi> vis;
	auto cnt = [&](int y, int x){
		if(vis.count(pi(y, x))) return -1;
		vis.emplace(y, x);
		int c = 0;
		for(int i = y; i <= y + 2; i++) if(pt.count(i)){
			const vi &v = pt[i];
			c += lower_bound(all(v), x + 3) - lower_bound(all(v), x);
		}
		//dbg(y, x, c);
		return c;
	};
	
	rep(i, n) for(int y = max(1, a[i] - 2); y <= h - 2 && y <= a[i] + 2; y++){
		for(int x = max(1, b[i] - 2); x <= w - 2 && x <= b[i] + 2; x++){
			int c = cnt(y, x);
			if(c < 0) continue;
			--ans[0]; ++ans[c];
		}
	}
	for(ll i : ans) cout << i << endl;
	
	return 0;
}

Measured memory_bytes: 129152
#include<stdio.h>
int main(){
  int a[4][13],n,i,j,k,x;
  char m;
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      a[i][j]=0;
    }
  }
 
  scanf("%d",&n);
 
  for(k=0;k<2*n;k++){
    scanf("%c %d",&m,&x);
    if(m=='S')a[0][x-1]=1;
    else if(m=='H')a[1][x-1]=1;
    else if(m=='C')a[2][x-1]=1;
    else if(m=='D')a[3][x-1]=1;
  }
 
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      if(a[i][j]==0){
    if(i==0)printf("S %d\n",j+1);
    else if(i==1)printf("H %d\n",j+1);
    else if(i==2)printf("C %d\n",j+1);
    else if(i==3)printf("D %d\n",j+1);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
int main(void)
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a==b&&a!=c){
    printf("Yes\n");
  }
  else if(b==c&&b!=a){
    printf("Yes\n");
  }
  else if(a==c&&a!=b){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}


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

void dfs(int x, map<ll,vector<ll>> &g, set<ll> &visited, ll &c){
	c++;
	visited.insert(x);
	for(auto nei : g[x]){
		if(visited.find(nei) == visited.end())
			dfs(nei,g,visited,c);
	}
	
}

int main(){
	
	ll n,e,a,b;
	cin >> n >> e;

	map<ll,vector<ll>> g;
	set<ll> visited;
	for(int i = 0; i < e; i++){
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	ll ans= 0;
	for(int i = 1; i <= n; i++){
		if(visited.find(i) == visited.end()){
			ll curr = 0;
			dfs(i,g,visited,curr);
			ans = max(ans,curr);
		}
	}
	
	cout << ans << "\n";
}

Measured memory_bytes: 53568
use proconio::input;

fn main() {
    input! {
        a: i32,
        b: i32,
    }

    let ans = if a + b == 15 {
        "+"
    } else if a * b == 15 {
        "*"
    } else {
        "x"
    };

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


Measured memory_bytes: 2124
from itertools import product 
from collections import Counter
def main():
    N = int(input())
    pattern = list(product(list(range(1, 100)),repeat=3))
    l = list()
    for i in pattern:
        x, y, z = i
        n = x**2 + y**2 + z**2 + x*y + y*z + z*x
        l.append(n)
    ans = Counter(l)
    for i in range(1, N+1):
        if ans.get(i) == None:
            print(0)
        else:
            print(ans.get(i))

if __name__ == '__main__':
    main()

Measured memory_bytes: 118692
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  int a=N/4;
  int ans=0;
  for(int i=0;i<a+1;i++){
    if((N-4*i)%7==0){
      ans=1;
      break;
    }
  }
  if(ans==0)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
}
  


Measured memory_bytes: 256
/************************************************
 * Au: Hany01
 * Email: hany01dxx@gmail.com & hany01@foxmail.com
 * Inst: Yali High School
************************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
#define Rep(i, j) for (register int i = 0, i##_end_ = (j); i < i##_end_; ++ i)
#define For(i, j, k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define X first
#define Y second
#define PB(a) push_back(a)
#define MP(a, b) make_pair(a, b)
#define SZ(a) ((int)(a).size())
#define ALL(a) a.begin(), a.end()
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define y1 wozenmezhemecaia

template <typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }

template <typename T> inline T read() {
	register T _, __; register char c_;
    for (_ = 0, __ = 1, c_ = getchar(); c_ < '0' || c_ > '9'; c_ = getchar()) if (c_ == '-') __ = -1;
    for ( ; c_ >= '0' && c_ <= '9'; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}
//EOT


int main() {
#ifdef hany01
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
#endif

	LL A = read<LL>(), B = read<LL>(), C = read<LL>();
	cout << B + min(A + B + 1, C) << endl;

	return 0;
}

Measured memory_bytes: 764
use proconio::{input, fastout};

#[fastout]
fn main() {
  input!{
    n:usize,
    a:[u64;n]
  }
  let mut na = a.to_vec(); na.push(0);
  let mut m : u64 = 1000;
  let mut amin : u64 = 300;
  for i in 1..=n {
      if na[i-1] < amin {amin = na[i-1];}
      if na[i-1] > na[i] {
        m = (m/amin)*na[i-1] + (m-(m/amin)*amin);
        amin = na[i];
      }
  }
  println!("{}",m);
}


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

int main(){
    long long m = 1000000007;
    long long n,k;
    cin >> n >> k;
    long long ans = 0;
    for(int i = k; i <= n+1;i++){
        ans = (ans+1+(n-i+1)*i)%m;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(void) {
        int dish[5];
        for(int i=0;i<5;i++) {
                scanf("%d",&dish[i]);
        }
        int dishr[5];
        int dishsum = 0;
        int diffmax = 0;
        for (int i=0;i<5;i++) {
                dishr[i] = (dish[i]+9)/10;
                dishr[i] *= 10;
                dishsum += dishr[i];
//              printf("%d %d\n",dish[i],dishr[i]);
                if ((dishr[i]-dish[i])>diffmax) diffmax = dishr[i] - dish[i];
        }

        dishsum -= diffmax;
        printf("%d\n",dishsum);
        return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		while(true){
			var l=long.Parse(Console.ReadLine());
			if(l==0)break;
			Sol mySol =new Sol(l);
			mySol.Solve();
		}
	}
}

class Sol{
	public void Solve(){
		if(L==1){
			Console.WriteLine(1);
			return;
		}
		
		Dictionary<long,long> pr=PrimDec(L);
		Dictionary<long,long> highest=new Dictionary<long,long>();
		foreach(long k in pr.Keys){
			highest.Add(k,(long)Math.Pow(k,pr[k]));
		}
		
		
		long Total=0;
		for(long i=1;i*i<=L;i++){
			if(L%i!=0)continue;
			long j=L/i;
			
			long cnt0=1;
			long cnt1=1;
			foreach (long k in highest.Keys){
				if(i%highest[k]==0){
					cnt0*=(pr[k]+1);
					continue;//iが最高次を割り切るならjは割り切らない
				}
				if(j%highest[k]==0){
					cnt1*=(pr[k]+1);
				}
			}
			Total+=cnt0;
			if(i!=j)Total+=cnt1;
		}
		
		long Ans=(Total-1)/2+1;//(L,L)以外は必ず2回カウントされる
		Console.WriteLine(Ans);
	}
	long L;
	public Sol(long l_){
		L=l_;
	}

	Dictionary<long,long> PrimDec(long A){
	 	Dictionary<long,long> D=new Dictionary<long,long>();
	 	if(A==1)return null;
	 	long rem=A;
	 	for(long i=2;i<=(long)Math.Sqrt((double)A);i++){
	 		if(rem%i==0){
	 			long cnt=0;
	 			while(rem%i==0){cnt++;rem/=i;}
	 			D.Add(i,cnt);
	 		}
	 		if(rem==1)break;
	 	}
	 	if(rem!=1)D.Add(rem,1);
	 	return D;
	}



	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

Measured memory_bytes: 6348
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int
#define FIO  ios::sync_with_stdio(false); cin.tie(0);   cout.tie(0);
#define all(in) in.begin(), in.end()
typedef pair<ll, ll> pll;

void solve(){

    ll n;   cin >> n;
    vector<ll> v1(n), v2(n);

    for(int i = 0 ; i < n ; i++){
        cin >> v1[i];
    }

    for(int i = 0 ; i < n ; i++){
        cin >> v2[i];
    }

    reverse(v2.begin(), v2.end());

    ll val = -1, index = -1;
    for(int i = 0 ; i < n ; i++){
        if(v1[i] == v2[i]){
            val = v1[i];
            index = i;
            break;
        }
    }

    if(val == -1){
        cout << "Yes" << endl;
        for(int i = 0 ; i < n ; i++){
            cout << v2[i] << " ";
        }
        cout << endl;
        return;
    }
    ll index1 = -1, index2 = -1, cnt = 0, cnt1 = 0, cnt2 = 0;
    for(ll i = index ; i < n ; i++){
        if(v1[i] == val || v2[i] == val){
            index2 = i;
        }
        if(v1[i] == val && v2[i] == val){
            cnt++;
        }
    }
    for(ll i = index ; i >= 0 ; i--){
        if(v1[i] == val || v2[i] == val){
            index1 = i;
        }
    }
    cnt1 = index1;
    cnt2 = n - index2 - 1;
    if(cnt > cnt1 + cnt2){
        cout << "No" << endl;
        return;
    }

    cout << "Yes" << endl;
    for(int i = 0 ; i < index1 ; i++){
        if(cnt == 0){
            break;
        }
        ll tmp = v2[index];
        v2[index] = v2[i];
        v2[i] = tmp;
        index++;    cnt--;
    }

    for(int i = index2 + 1 ; i < n ; i++){
        if(cnt == 0){
            break;
        }
        ll tmp = v2[index];
        v2[index] = v2[i];
        v2[i] = tmp;
        index++;    cnt--;
    }

    for(int i = 0 ; i < n ; i++){
        cout << v2[i] << " ";
    }

}

int main(){
    FIO;
    solve();
    return 0;
}


Measured memory_bytes: 6344
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

  int D;
  cin>>D;
  
  int C[27];
  int S[366][27];
  int last[366][27];

  for(int d=1;d<=26;d++) cin>>C[d];
  for(int d=1;d<=D;d++){
    for(int i=1;i<=26;i++) cin>>S[d][i];
  }

  int ans=0;
  int T[366];
  for(int d=1;d<=D;d++) cin>>T[d];
  for(int d=1;d<=D;d++){
    for(int i=1;i<=26;i++) last[d][i]=last[d-1][i];
    last[d][T[d]]=d;
    
    for(int i=1;i<=26;i++) ans-=C[i]*(d-last[d][i]);
    
    ans+=S[d][T[d]];
  }
  
  int M;
  cin>>M;
  int di,q;
  rep(i,M){
    cin>>di>>q;
    T[di]=q;
    ans=0;
    for(int d=1;d<=D;d++){
      for(int i=1;i<=26;i++) last[d][i]=last[d-1][i];
      last[d][T[d]]=d;
    
      for(int i=1;i<=26;i++) ans-=C[i]*(d-last[d][i]);
    
      ans+=S[d][T[d]];
    }
    cout<<ans<<endl;
  }
  
  return 0;
}

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

namespace ABC134C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var conds = new List<int>(N);

            for (var i = 1; i <= N; i++)
                conds.Add(int.Parse(Console.ReadLine()));

            var max = conds.Max();
            var tmp = conds.ToList();
            tmp.Sort((a, b) => b - a);

            for (var i = 0; i < N; i++)
            {
                if (conds[i] == max)
                    Console.WriteLine(tmp[1]);
                else
                    Console.WriteLine(max);
            }
        }
    }
}

Measured memory_bytes: 18708
#include <iostream>
#include <algorithm>
#include <vector>
#define ll long long
#define INF (1000000000000)
#define NIL (-1)
using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll i = 0;
  for(i = 0; i < 100000; i++){
    if(i * (i+1) / 2 >= n){
      break;
    }
  }
  vector<ll> ans;
  for(ll k = i; k >= 1; k--){
    if(n >= k){
      n -= k;
      ans.push_back(k);
    }
  }
  for(ll i = 0; i < ans.size(); i++){
    cout << ans[ans.size() - i - 1] << endl;
  }
  
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int n,value,i,j,flag,cnt=0;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>value;
    flag=1;
    if(value==2)cnt++;
    if(value==1||value%2==0)continue;
    for(j=3;j*j<=value;j+=2){
      if(value%j==0){flag=0;break;}
    }
    if(flag==1){
      cnt++;
      //cout<<value<<endl;
    }
  }
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3100
n, m = gets.chomp!.split(" ").map(&:to_i)

answer = Array.new(0, m + 1)

n.times do |i|
    k, *a_k = gets.chomp!.split(" ").map(&:to_i)
    a_k.each do |j|
        answer[j] = (answer[j] || 0) + 1
    end
end

count = 0
answer.each do |ans|
    if ans == n
        count += 1
    end
end

puts count


Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>
#include <atcoder/dsu>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, q, a, b, c;
    cin >> n >> q;
    atcoder::dsu d(n+1);
    for(int i=0;i<q;++i) {
        cin >> a >> b >> c;
        if(a == 0) {
            d.merge(b, c);
        } else {
            cout << d.same(b, c) << endl;
        }
    }
}

Measured memory_bytes: 3952
#include<iostream>
#include<queue>
using namespace std;
int main(){
	int h,w; cin >> h >> w;
	char grid[50][50];
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++) cin >> grid[i][j];
	int minmass[50][50];
	int blacknum=0;
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++) {
		minmass[i][j]=(grid[i][j]=='.'?1e5:-1);
		if(grid[i][j]=='#') blacknum++;
	}
	minmass[0][0]=1;
	queue<pair<int,int>> q;
	q.push(make_pair(0,0));
	while(!q.empty()){
		int i=q.front().first;
		int j=q.front().second;
		q.pop();
		int x=1,y=0;
		for(int k=0;k<4;k++){
			if(0<=i+y&&i+y<h && 0<=j+x&&j+x<w){
				if(minmass[i+y][j+x]!=-1){
					if(minmass[i+y][j+x]>minmass[i][j]+1){
						minmass[i+y][j+x]=minmass[i][j]+1;
						q.push(make_pair(i+y,j+x));
					}
				}
			}
			int temp=x;
			x=y;
			y=-temp;
		}
	}
	int ans=h*w-minmass[h-1][w-1]-blacknum;
	if(minmass[h-1][w-1]==1e5) cout << -1 << endl;
	else cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
struct Enemy
{
  int X;
  int H;
};
 
int main(){
  int N, D, A;
  cin >> N >> D >> A;
  
  vector<Enemy> ene(N);
  for(int i = 0; i < N; i++) cin >> ene[i].X >> ene[i].H; 
  sort(ene.begin(), ene.end(), [](Enemy &e1, Enemy &e2){ return e1.X < e2.X;});
  
  vector<int> damageRange(N);
  int left  = 0, right = 0;
  while(left != N){
    int xs = ene[left].X;
    int xe = ene[right].X;
    if(abs(xe -xs) <= 2*D){
      if (right != N-1){
        ++right;
      }else{
        damageRange[left] = N-1;
        ++left;
      }
      continue;
    }
    damageRange[left] = right - 1;  
    ++left;
  }
  
  long long sum = 0;
  long long num = 0;
  vector<int> subtract(N+1);
  for(int i = 0; i < N; i++){
    sum -= subtract[i];
    ene[i].H -= sum;
    if (ene[i].H <= 0) continue;
    int range = damageRange[i];
    int numAttack = (ene[i].H + A -1)/A;
    num += numAttack;
    sum += numAttack * A;
    subtract[range + 1] += numAttack * A;
  }
  
  cout << num;
  return 0;
}

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

using namespace std;

int main(){
	int N;
	cin>>N;
    vector <int>a(N);
    for(int i=0 ; i<N ; i++){
        cin>>a[i];
    }
	
	int current=a[0];
	int count=0;
	while(1){
		count++;
		if(current==2){
			cout<<count<<"\n";
			break;
		}
		current=a[current-1];
		if(count>N){
			cout<<-1<<"\n";
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
    int N,B[101],A[102],i,sum=0;
    scanf("%d",&N);
    for(i = 1 ; i <= N-1 ; i++){
        scanf("%d",&B[i]);
    }
    A[1] = B[1];
    for(i = 1 ; i <= N-1 ; i++){
        if(B[i+1] < B[i] && i+1 < N){
            A[i+1] = B[i+1];  
        }else{
            A[i+1] = B[i];
        }
    }
    for(i = 1 ; i <= N ; i++){
        sum += A[i];

    }
    printf("%d ",sum);


    return 0;
}

Measured memory_bytes: 128
#include <iostream>
//#include <bits/stdc++.h>
#include <string>
using namespace std;
#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, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 */
int main()
{
	string s;
	cin >> s;
	char h[2] = {'+', '-'};
	REP(i,2) {
		REP(j,2) {
			REP(k,2) {
				int sum = 0;
				int A = s[0] - '0';
				int B = s[1]-'0';
				int C = s[2]-'0';
				int D = s[3]-'0';
				// cout << A << B << C << D << endl;
				if(h[i] == '+')
					sum += A + B;
				else
					sum += A - B;
				if(h[j] == '+')
					sum += C;
				else
					sum -= C;
				if(h[k] == '+')
					sum += D;
				else
					sum -= D;
				if(sum == 7) {
					cout << A << h[i] << B << h[j] << C << h[k] << D << "=7" << endl;
					return 0;
				}
			}
		}	
	}
    return 0;
}


Measured memory_bytes: 256
N = int(input())
v_list = list(map(int, input().split()))

v_list.sort()

for i in range(N-1):
    v_list[i+ 1] = (v_list[i] + v_list[i+1]) / 2
    v_list[i] = 0

print(v_list[-1])
    

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
  int num[3];
  
  cin >> num[0] >> num[1] >> num[2];
  sort(num, num+3);
  
  cout << (num[2] - num[1]) + (num[1] - num[0]) << endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <ctype.h>
using namespace std;

typedef long long ll;

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

int main() {
  int a, b, x;
  cin >> a >> b >> x;
  if (x < a || a + b < x) {
    cout << "NO" << endl;
    return 0;
  }

  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
#include <iomanip>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	unsigned size_; 
	std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	//unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	unsigned root(unsigned x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N,K;
	
	cin >> N >> K;
	double total;
	double m = 0.5;
	for (int i = 1; i <= N; i++)
	{
		int n = 0;
		while(i << n < K)
		{
			n++;
		}
		total += double(pow(m, n));
	}

	cout << std::setprecision(16)<< total / N << endl;

	
	return 0;
}


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

class MainClass
{
    static void Main()
    {
        string N = ReadLine();
        int K = int.Parse(ReadLine());
        var dp = new long[N.Length + 1,10, 2,  K + 1];
        for (int i = 0; i < 10; i++)
        {
            if (N[0] - '0' < i) continue;
            int canexceed = (N[0]-'0')==i?1:0;
            int nk = i>0?1:0;
            
            dp[0, i, canexceed,  nk] = 1;
        }

        for (int i = 0; i < N.Length-1; i++)
        {
            int n = N[i + 1] - '0';
            for (int j = 0; j < 10; j++)
            {
                for (int c = 0; c < 2; c++)
                {
                    for (int k = 0; k < K+1; k++)
                    {
                        for (int nj = 0; nj < 10; nj++)
                        {
                            var v = dp[i, j, c, k];
                            int canexceed = c;
                            int nk = nj>0?k+1:k;
                            if (nk > K) break;
                            if (c == 1)
                            {
                                if (nj > n) break;
                                if (nj < n) canexceed = 0;
                            }
                            dp[i + 1, nj, canexceed, nk] += v;
                        }
                    }
                }
            }
        }
        long ans = 0;
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 2; j++)
            {

                    ans += dp[N.Length-1, i, j, K];
                
            }
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 27460
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
bool gre(ll a, ll b) {
	if (a > b)return true;
	else return false;
}
int main() {
	int n, w;
	cin >> n >> w;
	ll a[200];
	ll cnt = 0;
	rep(i, n) {
		cin >> a[i];
	}
	sort(a, a + n,gre);
	rep(i, n) {
		if (w < a[n - 1 - i]||i==n-1) {
			cnt++; break;
		}
		ll dp[20001] = {}; dp[0] = 1;
		rep(j, n - 1 - i) {
			per(k, w+1) {
				if (k + a[j] <= w) {
					dp[k + a[j]] += dp[k];
				}
			}
			per(k, w + 1) {
				if (a[n - 1 - i] + k > w) {
					cnt = (cnt + dp[k]) % MOD;
					dp[k] = 0;
				}
				else break;
			}
		}
		w -= a[n - 1 - i];
	}
	cout << cnt % MOD << endl;
	return 0;
}


Measured memory_bytes: 3292
/*
 * H 行 W 列のマス目があり、i 行目の j 列目のマスをマス (i,j) と呼びます。
 * 
 * このマス目には 1 から H×W までの整数が重複なく書かれており、マス (i,j) に書かれている整数は Ai,j です。
 * 
 * 魔法少女であるあなたは、魔力 |x−i|+|y−j| を消費することでマス (i,j) に置かれた駒をマス (x,y) に瞬間移動させることができます。
 * 
 * あなたは、魔法少女としての能力を計るために、Q 回の実技試験を受けなければなりません。
 * 
 * i 回目の実技試験は、以下の手順で行われます。
 * 
 *     初めに、駒が整数 Li の書かれているマスに置かれている。
 * 
 *     駒の置かれているマスに書かれている整数を x とする。x が Ri でない限り、駒を x+D の書かれているマスに移動することを繰り返す。x=Ri となったら終了する。
 * 
 *     ただし、Ri−Li が D の倍数であることは保証される。
 * 
 * それぞれの実技試験に対し、あなたの消費する魔力の総和を求めてください。
 */

import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            // 入力
            int h = Integer.parseInt(sc.next());
            int w = Integer.parseInt(sc.next());
            int d = Integer.parseInt(sc.next());
            int[][] location = new int[h*w][2];
            for(int i=0; i<h*w; i++){
            	int a = Integer.parseInt(sc.next())-1;
            	location[a][0] = i/w;
            	location[a][1] = i%w;
            }
            long[] sum = new long[h*w];
            for(int i=0; i<h*w; i++){
            	if(i<d){
            		sum[i] = 0;
            	}
            	else{
            		sum[i] = sum[i-d] + (long)(Math.abs(location[i][0] - location[i-d][0]) + Math.abs(location[i][1] - location[i-d][1]));
            	}
            }
            
            int q = Integer.parseInt(sc.next());
            
            for(int i=0; i<q; i++){
            	// 入力
            	int l = Integer.parseInt(sc.next())-1;
            	int r = Integer.parseInt(sc.next())-1;
            	// 出力
                System.out.println(sum[r] - sum[l]);
            }
            
            sc.close();
        }
    }


Measured memory_bytes: 77748
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
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; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;


// 1-based
template <class T>
class BIT
{
public:
        std::vector<T> array;
        const T n;

        BIT(T n)
                : array(n+1, 0), n(n) {}

        // [0, i]
        T sum(T i)
        {
                T sm = 0;
                while(i) {
                        sm += array[i];
                        i -= i & -i;
                }
                return sm;
        }

        // [i, j]
        T sum(T i, T j)
        {
                return sum(j) - sum(i-1);
        }

        void add(long long i, T x)
        {
                while (i <= n) {
                        array[i] += x;
                        i += i & -i;
                }
        }
};

template <class T>
class RangeBIT
{
public:
        BIT<T> bit1;
        BIT<T> bit2;

        RangeBIT(T n)
                : bit1(n), bit2(n) {}

        // [0, i]
        T sum(T i)
        {
                return bit1.sum(i) + bit2.sum(i)*(i);
        }

        // [i, j]
        T sum(T i, T j)
        {
                return sum(j) - sum(i-1);
        }

        void add(T i, T j, T x)
        {
                bit1.add(i, -x * (i-1));
                bit1.add(j+1, x*j);
                bit2.add(i, x);
                bit2.add(j+1, -x);
        }
};


int main()
{
        ll n, q;
        cin >> n >> q;
        RangeBIT<ll> bit(n);

        rep(i, 0, q) {
                ll kind;
                cin >> kind;
                if (kind == 0) {
                        ll s, t, x;
                        cin >> s >> t >> x;
                        bit.add(s, t, x);
                } else {
                        ll a;
                        cin >> a;
                        cout << bit.sum(a, a) << endl;
                }
        }
}



Measured memory_bytes: 4412