akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main(){
    int a[5];
    for(int i = 0 ; i < 5; i++) cin >> a[i];
    int k;
    cin >> k;
    for(int i = 0; i < 5; i++){
        for(int j = i+1; j < 5; j++){
            if(abs(a[i]-a[j]) > k){
                cout << ":(";
                return 0;
            }
        }
    }
    cout << "Yay!";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N,A;
cin >> N >> A;
cout << N*N - A << endl;

return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
cake=[[int(i)for i in input().split()]for j in range(n)]
a=sum(sorted([sum(i)for i in cake],reverse=True)[:m])
b=sum(sorted([cake[i][0]+cake[i][1]-cake[i][2]for i in range(n)],reverse=True)[:m])
c=sum(sorted([cake[i][0]-cake[i][1]-cake[i][2]for i in range(n)],reverse=True)[:m])
d=sum(sorted([cake[i][0]-cake[i][1]+cake[i][2]for i in range(n)],reverse=True)[:m])
e=sum(sorted([0-cake[i][0]+cake[i][1]-cake[i][2]for i in range(n)],reverse=True)[:m])
f=sum(sorted([0-cake[i][0]+cake[i][1]+cake[i][2]for i in range(n)],reverse=True)[:m])
g=sum(sorted([0-cake[i][0]-cake[i][1]-cake[i][2]for i in range(n)],reverse=True)[:m])
h=sum(sorted([0-cake[i][0]-cake[i][1]-cake[i][2]for i in range(n)],reverse=True)[:m])
print(max(a,b,c,d,e,f,g,h))

Measured memory_bytes: 9244
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <iomanip>
using namespace std;
long long mod=1e9+7;
template<class T>struct nCk{
	vector<T> kai,gya,nck;
	nCk(int n){
		kai.resize(n+1);
		gya.resize(n+1);
		nck.resize(n+1);
	}
	T pow(T x,T n,T mod=1e9+7LL){
		T ret=1;
		if(n>0){
			ret=pow(x,n/2,mod);
			if(n%2==0){
				(ret=(ret*ret))%=mod;
			}else{
				(ret=((ret*ret)%mod)*x)%=mod;
			}
		}
		return ret;
	}
	T inv(T n,T mod=1e9+7LL){
		return pow(n,mod-2,mod);
	}
	vector<T> cul(T n,T mod=1e9+7LL){
		kai[n]=n;
		for(int i=n-1;i>0;i--){
			(kai[i]=kai[i+1]*i)%=mod;
		}
		gya[1]=inv(1,mod);
		for(int i=2;i<=n;i++){
			(gya[i]=gya[i-1]*inv(i,mod))%=mod;
		}
		for(int i=1;i<=n;i++){
			(nck[i]=kai[n+1-i]*gya[i])%=mod;
		}
		nck[0]=1;
		nck[n]=1;
		return nck;
	}
};
int main(){
	int n;
	int a[100001];
	cin>>n;
	int b[100001]={};
	for(int i=0;i<=n;i++){
		cin>>a[i];
		b[a[i]]++;
	}
	int mem;
	for(int i=1;i<=n;i++){
		if(b[i]==2){
			mem=i;
			break;
		}
	}
	int c=-1,d=-1;
	for(int i=0;i<=n;i++){
		if(a[i]==mem){
			if(c==-1){
				c=i;
			}else{
				d=i;
			}
		}
	}
	nCk<long long> e(n-1);
	vector<long long> ee=e.cul(n-1);
	nCk<long long> f(c+(n-d));
	vector<long long> ff=f.cul(c+(n-d));
	for(int i=1;i<=n+1;i++){
		if(i==1){
			cout<<n<<endl;
		}else if(i==n+1){
			cout<<1<<endl;
		}else if(i==n){
			if(d==c+1){
				cout<<n<<endl;
			}else{
				cout<<n+1<<endl;
			}
		}else{
			long long ans=0;
			//tukawanai
			(ans+=ee[i])%=mod;
			//hitotu
			(ans+=2*ee[i-1])%=mod;
			if(c+(n-d)+1>=i){
				(ans+=mod-ff[i-1])%=mod;
			}
			//hutatu
			(ans+=ee[i-2])%=mod;
			cout<<ans<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 8320
N=int(input())
p_list=[]

if N%2==0:
  count=0
  while N%2==0:
    count+=1
    N/=2
  p_list.append([2,count])

i=3
while i<N**0.5+1:
  if N%i==0:
    count=0
    while N%i==0:
      count+=1
      N/=i
    p_list.append([i,count])
  i+=2

if N!=1:
  p_list.append([int(N),1])

result=0
for i in range(len(p_list)):
  j=1
  while p_list[i][1]>=j:
    p_list[i][1]-=j
    j+=1
    result+=1
print(result)

Measured memory_bytes: 9248
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()

typedef long long int ll;

//ll num[50];
//ll num2[50];
//ll num[ten52];
//stack<char> stk;
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<string,ll>::iterator iter;
//map<ll,ll> mp;
//deque<char> deq;
priority_queue<ll> pq;


int main(void)
{
    double ans=0.0,d,d1,d2;
    //float f,g,h;
    long long int m,n,i,j,k=1;
    long long int a,a1,a2,a3,sum;
    string s,s1,s2;
    char c,c1;
    sum=a=a1=a2=a3=0;
    cin>>n>>m;
    a=n/m;
    cout<<min(abs(n-m*a),abs(n-m*(a+1)));
    return 0;
}


Measured memory_bytes: 256
import  itertools
n,m,q=map(int,input().split())

t=[]
for i in range(q):
    a,b,c,d=map(int,input().split())
    a-=1
    b-=1
    t.append([a,b,c,d])

def judge(l):
    ans=0
    for i in range(q):
        a,b,c,d=t[i]
        if l[b]-l[a]==c:
            ans+=d
    return ans

num=[]
ans=0
for i in range(1,m+1):
    num.append(i)

for df in itertools.combinations_with_replacement(num,n):

    ty=list(df)
    f=judge(ty)
    ans=max(ans,f)

print(ans)

Measured memory_bytes: 9224
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<functional>
#include<bits/stdc++.h>
using namespace std;
void bfs(vector <vector<int>> &adj,int x,vector <int> &ans)
{
	bool visited[adj.size()];
	memset(visited, false, sizeof(visited));
	vector <int> level(adj.size(),0);
	queue <int> que;
	que.push(x);
	level[x] =0;
	visited[x] = true;
	while(!que.empty())
	{	 x = que.front(); 
       	que.pop();
		for (int i = 0; i < adj[x].size(); i++) { 
            int b = adj[x][i]; 
  
            if (!visited[b]) { 
  
                que.push(b); 
  
                level[b] = level[x] + 1; 
  
                visited[b] = true; 
            } 
        } 
    } 
for(int i:level)
	ans[i]++;


	}


int main()
{
	int n,x,y;
	cin>>n>>x>>y;
	vector <int> ans(n+1,0);
	vector <vector<int>> adj(n+1);
	for(int i =1;i<n;i++){
		adj[i+1].push_back(i);
		adj[i].push_back(i+1);	}
	adj[x].push_back(y);
	adj[y].push_back(x);
	for(int i =1;i<=n;i++)
		bfs(adj,i,ans);
	for(int i=1;i<n;i++)
	cout<<ans[i]/2<<"\n";
	return 0;

}

Measured memory_bytes: 384
s=gets.chomp

a=[0]*s.size
idx=0
loop do
    if s[idx] == "R"
        e = s.index(/(L|$)/,idx)
        t = (e-idx)
        a[e-1] += t - t/2
        a[e] += t/2
        idx = e
    else
        e = s.index(/(R|$)/,idx)
        t = (e-idx)
        a[idx] += t - t/2
        a[idx-1] += t/2
        idx = e
    end
    break if idx >= s.size
end

print a.join(" ")

Measured memory_bytes: 3196
n = int(input())

if n == 1:
    print('a')
    exit()

def Find(value):
    i = 0
    accSum = 0
    while True:
        current = 26 ** i
        accSum += current
        if value < accSum:
            accSum -= current
            return i, accSum
        i+=1


maxI, accu = Find(n)

import string
alp = [chr(ord('a') + i) for i in range(26)]
s = ''
cur = n
for b in range(maxI):
    currentI = maxI - b

    diff = cur - accu
    ind = diff // (26 ** (currentI-1))
    s += alp[ind]

    accu += (26 ** (currentI - 1)) * ind

print(s)



Measured memory_bytes: 9668
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use std::collections::*;

fn prime_factorization(x: i64) -> std::collections::BTreeMap<i64, i64> {
    ((2..3).chain((3..).step_by(2)))
        .scan(x, |state, i| match *state {
            1 => None,
            _ => {
                let divisor = if i * i <= *state { i } else { *state };
                let mut index = 0;
                while *state % divisor == 0 {
                    *state /= divisor;
                    index += 1;
                }
                Some((divisor, index))
            }
        })
        .filter(|&(_, index)| index > 0)
        .collect()
}

fn main() {
    input! {
        n:i64
    }
    let ans: i64 = prime_factorization(n)
        .iter()
        .map(|(_, &index)| {
            (1..)
                .take_while(|&i| index >= i * (i + 1) / 2)
                .last()
                .unwrap()
        })
        .sum();
    println!("{}", ans);
}

Measured memory_bytes: 2172
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
  cout << fixed << setprecision(12);
  int n;
  cin >> n;
  int x[n], y[n];
  for(int i = 0; i < n; i++) {
    cin >> x[i];
  }
  for(int i = 0; i < n; i++) {
    cin >> y[i];
  }

  int ans1 = 0;
  long double ans2 = 0.0;
  long double ans3 = 0.0;
  int ans4 = 0;
  for(int i = 0; i < n; i++) {
    ans1 += abs(x[i] - y[i]);
    ans2 += pow(abs(x[i] - y[i]), 2);
    ans3 += pow(abs(x[i] - y[i]), 3);
    ans4 = max(ans4, abs(x[i] - y[i]));
  }
  cout << ans1 << endl;
  cout << pow(ans2, (double)1 / 2) << endl;
  cout << pow(ans3, (double)1 / 3) << endl;
  cout << ans4 << endl;

  return 0;
}



Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)a;i<=(sign)b;++i)
#define Fordown(i,a,b) for(register sign i=(sign)a;i>=(sign)b;--i)
bool cmax(sign &a,sign b){return (a<b)?a=b,1:0;}
bool cmin(sign &a,sign b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
  T ans=0,f=1;
  char ch=getchar();
  while(!isdigit(ch)&&ch!='-')ch=getchar();
  if(ch=='-')f=-1,ch=getchar();
  while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
  return ans*f;
}
template<typename T>void write(T x,char y)
{
  if(x==0)
  {
      putchar('0');putchar(y);
      return;
  }
  if(x<0)
  {
      putchar('-');
      x=-x;
  }
  static char wr[20];
  int top=0;
  for(;x;x/=10)wr[++top]=x%10+'0';
  while(top)putchar(wr[top--]);
  putchar(y);
}
void file()
{
  #ifndef ONLINE_JUDGE
      freopen("c.in","r",stdin);
      freopen("c.out","w",stdout);
  #endif
}
const int N=100+5;
ll n,m;
void input()
{
	n=read<ll>(),m=read<ll>();
	if(n>m)swap(n,m);
}
void work()
{
	if(n==1)
	{
		if(m==1)printf("1\n");
		else printf("%lld\n",m-2);
	}
	else printf("%lld\n",n*m-n*2-m*2+4);
}
int main()
{

	input();
	work();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
typedef long long ll;
const ll mod = 1e9 + 7;
int n, m;
int a[2005], b[2005];
ll dp[2005][2005];
ll serc(int ia, int ib) {
  if (ia == -1 || ib == -1) return 1;
  if (dp[ia][ib] != -1) return dp[ia][ib];
  ll ret = 0;
  if (a[ia] == b[ib]) {
    ret += serc(ia, ib-1) + serc(ia-1, ib);
    ret += mod;
    while  (ret >= mod) ret -= mod;
    // ret += serc(ia-1, ib-1) - serc(ia-1, ib-1)
  } else {
    ret += serc(ia-1, ib) + serc(ia, ib-1) - serc(ia-1, ib-1);
    ret += mod;
    while (ret >= mod) ret -= mod;
  }
  return dp[ia][ib] = ret;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) cin >> b[i];
  memset(dp, -1, sizeof(dp));
  cout << serc(n-1, m-1) << el;
  return 0;
}

Measured memory_bytes: 31872
#include <stdio.h>
#include <iostream>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

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

    int ans = 0;
    REP(0, i, 100000) {
        if (i * i <= N) {
            ans = i * i;
        } else {
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  int N, K, x, sum = 0;
  cin >> N;
  cin >> K;
  
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (K - x >= x) {
      sum += 2 * x;
    }
    else if (K - x < x) {
      sum += 2 * (K - x);
    }
    else {
      sum += 0;
    }
  }
  cout << sum << endl;
}

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

int main() {
	string s;
	cin >> s;
	for (unsigned i = 0; i < s.size()-1; i++) {
		if (s[i] == 'A' && s[i + 1] == 'C') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<atcoder/all>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long Int;

int main(){
    int n, q, t, u, v;
    cin >> n >> q;
    atcoder::dsu uf(n);
    while(q--){
        cin >> t >> u >> v;
        if(t == 0)uf.merge(u, v);
        else cout << int(uf.same(u, v)) << endl;
    }
    return 0;
}

Measured memory_bytes: 3468
N = int(input())
CSF = []
for _ in range(N - 1):
    c, s, f = map(int, input().split())
    CSF.append((c, s, f))
for i in range(N):
    t = 0
    for c, s, f in CSF[i:]:
        t = max(t, s)
        t = ((t - 1) // f + 1) * f
        t += c
    print(t)

Measured memory_bytes: 3188
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b,a%b);
}
 
ll lcm(ll a, ll b) {
    ll g = gcd(a,b);
    return a / g * b;   // Be careful not to overflow
}


vector<int> pp;
void preparePrime( int maxp )
{
    int i;
    vector<int> a(maxp+1);
    for(i=2; i<=maxp; i++) {
        int k=i+i;
        while(k<=maxp) {
            a[k]=1;
            k+=i;
        }
    }
    for(i=2; i<=maxp; i++) {
        if(a[i]==0) pp.push_back( i );
    }
    return;
}

void solve()
{
    int n;
    scanf("%d", &n);
    preparePrime(1000000);
    vector<int> z;
    int i;
    for (i = 1; i < (int)pp.size(); i++) {
        if (pp[i] % 5 == 1) {
            z.push_back(pp[i]);
            if (z.size() == n) break;
        }
    }
    for (i = 0; i < n; i++) {
        printf("%d", z[i]);
        if (i < n - 1) printf(" ");
    }
    printf("\n");
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 4732
#include<bits/stdc++.h>
#define int long long
int read(){char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();int k=1,kk=0;if (c=='-')c=getchar(),k=-1;while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return kk*k; }
using namespace std;
void write(int x){if (x<0)putchar('-'),x=-x;if (x)write(x/10),putchar(x%10+'0');}
void writeln(int x){write(x);if (x==0)putchar('0');puts("");}
void doit(int x,int y,int l,int r){
	int ll=(l-1)%(x+y)+1,rr=(r-1)%(x+y)+1;if (r-rr==l-ll){ for (int i=ll;i<=x&&i<=rr;i++)ll=i+1,putchar('A'); for (int i=ll;i<=rr;i++)putchar('B');
	}else{
		int dd=((r-rr)-(l-ll))/(x+y)-1; for (int i=ll;i<=x;i++)ll=i+1,putchar('A'); for (int i=ll;i<=x+y;i++)putchar('B');ll=dd;
		for (int i=1;i<=dd;i++){ for (int j=1;j<=x;j++)putchar('A'); for (int j=1;j<=y;j++)putchar('B'); }ll=1;
		for (int i=ll;i<=x&&i<=rr;i++)ll=i+1,putchar('A'); for (int i=ll;i<=rr;i++)putchar('B');
	}
}
int q,a,b,x,y,dd,mid,xx1,yy1,xx2,yy2,kk,ll,rr,ans;
struct lsg{int x,y,l,r,d;}ff[100];
signed main(){
	q=read();for (int i=1;i<=q;i++){
		a=read();b=read();x=read();y=read();memset(ff,0,sizeof(ff));
		if (a>=b){
			dd=a/b;if (a%b!=0)dd++; if (a/(b+1)+(a%(b+1)>0)<dd){ int kk=a/(b+1)+(a%(b+1)>0),fff=a-b*kk; ff[4].x=1;ff[4].d=fff; a-=fff;dd=kk; }ll=1;rr=b;
			while (ll<rr){
				int mid=(ll+rr+1)/2,xx=a-mid*dd,yy=b-mid,ddd; if (xx<0){rr=mid-1;continue;}
				if (xx){ddd=yy/xx;if (yy%xx)ddd++;}else {if (yy==0)ddd=0;else ddd=1e9;} if (ddd<=dd)ll=mid;else rr=mid-1;
			}int xx=a-ll*dd,yy=b-ll;
			ff[1].x=dd;ff[1].y=1;ff[1].d=ll;if (yy){ ff[3].y=dd;ff[3].x=1;ff[3].d=(yy-1)/dd;xx-=ff[3].d;yy-=ff[3].d*dd; ff[2].x=xx;ff[2].y=yy;ff[2].d=1; }
		}else{
			swap(a,b);dd=a/b;if (a%b)dd++;
			if (a/(b+1)+(a%(b+1)>0)<dd){ int kk=a/(b+1)+(a%(b+1)>0),fff=a-b*kk; if (x<=fff)doit(0,1,x,min(y,fff)); y-=fff;x-=fff;a-=fff;dd=kk; }ll=1;rr=b;
			while (ll<rr){
				int mid=(ll+rr+1)/2,xx=a-mid*dd,yy=b-mid,ddd;
				if (xx<0){rr=mid-1;continue;}
				if (xx){ddd=yy/xx;if (yy%xx)ddd++;}else {if (yy==0)ddd=0;else ddd=1e9;}
				if (ddd<=dd)ll=mid;else rr=mid-1;
			}int xx=a-ll*dd,yy=b-ll;
			ff[1].x=dd;ff[1].y=1;ff[1].d=ll;if (yy){ ff[3].y=dd;ff[3].x=1;ff[3].d=(yy-1)/dd;xx-=ff[3].d;yy-=ff[3].d*dd; ff[2].x=xx;ff[2].y=yy;ff[2].d=1;
			}swap(ff[1],ff[3]);swap(ff[1].x,ff[1].y);swap(ff[2].x,ff[2].y);swap(ff[3].x,ff[3].y);
		}for (int i=1;i<=4;i++){
			ff[i].l=ff[i-1].r+1;ff[i].r=ff[i].d*(ff[i].x+ff[i].y)+ff[i-1].r;if (ff[i].l>ff[i].r)continue;
			if (x<=ff[i].r&&y>=ff[i].l)doit(ff[i].x,ff[i].y,max(x,ff[i].l)-ff[i].l+1,min(y,ff[i].r)-ff[i].l+1);
		}puts("");
	} 
}

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

int main(){
    int H,W;
    cin >> H >> W;
    char Grid[H][W];
    for (int i=0;i<H;i++){
        for ( int j=0;j<W;j++){
            cin >> Grid[i][j];
        }
    }


    int mat[W*H][W*H];
    for (int i=0;i<H;i++){
        for ( int j=0;j<W;j++){
            for (int k=0;k<H;k++){
                for ( int l=0;l<W;l++){
                    mat[i*W+j][k*W+l]=W*H;
                    mat[k*W+l][i*W+j]=W*H;
                    if(Grid[i][j]=='.' && Grid[k][l]=='.' && ((abs(i-k)==0 && abs(j-l)==1) || (abs(i-k)==1 && abs(j-l)==0))){
                            mat[i*W+j][k*W+l]=1;
                            mat[k*W+l][i*W+j]=1;
                    }
                }
            }
        }
    }

    for (int k=0;k<W*H;k++){
        for (int i=0;i<W*H;i++){
            for ( int j=0;j<W*H;j++){
                mat[i][j] = min(mat[i][j],mat[i][k]+mat[k][j]);
            }
        }
    }

    int ans=0;
    for (int i=0;i<W*H;i++){
        for ( int j=0;j<W*H;j++){
            if( mat[i][j]!=W*H){
               ans = max(ans,mat[i][j]);
            }
        }
    }
    cout << ans << endl; 
};


Measured memory_bytes: 896
use proconio::input;

fn prev(a: &mut Vec<usize>, k: usize, n: usize) {
    if *a.last().unwrap() == 0 {
        a.pop();
    } else {
        *a.last_mut().unwrap() -= 1;
        while a.len() < n {
            a.push(k - 1);
        }
    }
}

fn main() {
    input!(k: usize, n: usize);
    let ans: Vec<usize> = {
        if k % 2 == 0 {
            std::iter::once(k / 2 - 1)
                .chain(std::iter::repeat(k - 1).take(n - 1))
                .collect()
        } else {
            let mut a = vec![k / 2; n];
            for _ in 0..n / 2 {
                prev(&mut a, k, n);
            }
            a
        }
    };
    println!(
        "{}",
        ans.iter()
            .map(|&x| (x + 1).to_string())
            .fold(String::new(), |acc, x| if acc.is_empty() {
                x
            } else {
                acc + " " + x.as_ref()
            })
    );
}


Measured memory_bytes: 7004
#include <iostream>
using namespace std;
int main() {
    string A, B, C; cin >> A >> B >> C;
    int a = A.length(), b = B.length();
    if (A[a - 1] == B[0] && B[b - 1] == C[0]) printf("%s\n", "YES");
    else printf("%s\n", "NO");
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}

template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind() {double x; scanf("%lf", &x); return x;}

///*....Bitmask....*///
int set_1(int n, int pos) {return n = (n | (1 << pos));}
int reset_0(int n, int pos) {return n = n & ~(1 << pos);}
bool check_bit(int n, int pos) {return n = n & (1 << pos);}

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

///*....Constraints....*///
const int N = (int) 1e7 + 2;
const int M = (int) 1e9 + 7;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;

int divisor[N];
void sieve()
{
  for (int i = 1; i <= (N); i++) {
    for (ll j = i; j <= N; j += i) {
      divisor[j]++;
    }
  }
}

int main()
{
  sieve();
  int t = 1, te = 0;
 // Int(t);
  while (t--) {
    int x;
    Int(x);

    ll res=0ll;
    for(int i=1;i<=x;++i){
      res+= divisor[i]*1ll*i;
    }

    printf("%lld\n", res);

    //printf("Case %d: ",++te);
  }
  return 0;
}






Measured memory_bytes: 42788
#include<iostream>
#include<vector>
#include<math.h>

using namespace std;

int main()
{
    int n = 0;
    string input, output;

    cin >> input >> output;

    for(int i = 0; i < input.length(); i++)
    {
        if(input[i]!= output[i])
        {
            n++;
        }
    }

    cout << n;
}

Measured memory_bytes: 3848
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int limit = Integer.parseInt(sc.next());
    int[] member = new int[n];
    int count = 0;
    for(int i = 0; i < n; i++) {
      member[i] = Integer.parseInt(sc.next());
      if(member[i] >= limit) count++;
    }
    System.out.println(count);
  }
}


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

int main() {
	vector<int> n(3);
	cin >> n[0] >> n[1] >> n[2];
	sort(n.begin(),n.end());

	cout << n[0] << " " << n[1] << " " << n[2] << endl;

	return 0;
}


Measured memory_bytes: 3160
//include
//------------------------------------------
#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 <climits>
#include <queue>

using namespace std;

//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);
const LL INF = 1e14;

LL dist_L[201][201];
LL dist_S[201][201];
LL dp[1001][201];
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M, R;
  while(cin >> N >> M, N){
	fill((LL*)dist_L, (LL*)dist_L+201*201, INF);
	fill((LL*)dist_S, (LL*)dist_S+201*201, INF);

	REP(i,N) dist_L[i][i] = dist_S[i][i] = 0;
	REP(i,M){
	  LL x, y, t; char c;
	  cin >> x >> y >> t >> c;
	  --x, --y;
	  if(c == 'L')
		dist_L[x][y] = dist_L[y][x] = min(dist_L[x][y], t);
	  else
		dist_S[x][y] = dist_S[y][x] = min(dist_S[x][y], t);
	}
	
	REP(k,N) REP(i,N) REP(j,N){
	  dist_L[i][j] = dist_L[j][i] = min(dist_L[i][j], dist_L[i][k]+dist_L[k][j]);
	  dist_S[i][j] = dist_S[j][i] = min(dist_S[i][j], dist_S[i][k]+dist_S[k][j]);
	}

	cin >> R;
	VI RS(R);
	REP(i,R){
	  cin >> RS[i];
	  --RS[i];
	}

	// dp[i][j] :<=> i???????????§?¨???????????????£??????????????????j?????¨??????????°??????????
	fill((LL*)dp, (LL*)dp+1001*201, INF);
	dp[0][RS[0]] = 0;
	REP(i,R-1){
	  REP(u,N){
		REP(v,N){
		  dp[i+1][v] = min(dp[i+1][v],
						   // Rs[i] -> u????????§???u -> v????????§???v->RS[i+1]????????§?§????
						   dp[i][u]+dist_L[RS[i]][u] + dist_S[u][v]+dist_L[v][RS[i+1]]
						   );
		}
		//?????????
		dp[i+1][u] = min(dp[i+1][u], dp[i][u]+dist_L[RS[i]][RS[i+1]]);
	  }
	}

	LL ans = INF;
	REP(u,N) ans = min(ans, dp[R-1][u]);
	cout << ans << endl;
  }  
  
  return 0;
}

Measured memory_bytes: 3416
#include <bits/stdc++.h>
#include <vector>
#define foi(i,n) for(int i = 0; i < n ; ++i)
#define pb push_back
#define int long long
using namespace std;
#define mod 1000000007
typedef vector<int> vi;
typedef vector<vi> vvi;
// ith index , j daala
vvi multiply(vvi a,vvi b,int n){
    vvi out(n);
    for(int i =0 ; i< n ; i++){
        int row = i ;
        out[i].resize(n);
        for(int j = 0 ; j < n ; j++){
            int col = j ;
            int answer = 0 ;
            for(int k = 0 ; k <n ; k++) answer = (answer%mod + a[row][k]*b[k][col]%mod)%mod;
            out[i][j] = answer;
        }
    }
    return out;
}

vvi powMultiply(vvi a,int b,int n,vvi &unity){
    if(b == 0) return unity;
    vvi x = powMultiply(a,b/2,n,unity);
    x = multiply(x,x,n);
    if(b%2 == 1) x = multiply(x,a,n);
    return x;
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int k;
    cin >> k;
    vvi inp(n);
    foi(i,n){
        inp[i].resize(n);
        foi(j,n) cin >> inp[i][j];
    }
    vvi unity(n);
    foi(i,n){
        unity[i].resize(n);
        foi(j,n){
            if(i == j) unity[i][j] = 1;
            else unity[i][j] = 0;
        }
    }
    vvi ans = powMultiply(inp,k,n,unity);
    //ans = multiply(inp,inp,n);
    /*foi(i,n){
        foi(j,n) cout << ans[i][j] << " ";
        cout << endl;
    }*/
    int answer = 0 ;
    foi(i,n){
        foi(j,n) answer  = (answer%mod + ans[i][j]%mod)%mod;
    }
    cout << answer;
}



Measured memory_bytes: 1664
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cstring>
using namespace std;
int n,m;
const int N=1e5+9;
int memo[N];
vector <vector<int> >graph;
int dp(int i)
{
    if(graph[i].empty())
        return 0;
    int &ret=memo[i];
    if(~ret)
        return ret;

    for(int u:graph[i])
    {
        ret=max(ret,dp(u)+1);
    }
    return ret;
}
int main()
{
    memset(memo,-1,sizeof memo);

    scanf("%d %d",&n,&m);
    graph.resize(n+1);
    while(m--)
    {
        int u,v;
        scanf("%d %d",&u,&v);
        graph[u].push_back(v);
    }
    int ans=0;
    for(int i=1;i<=n;++i)
        ans=max(dp(i),ans);
    printf("%d\n",ans);

    return 0;
}


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

int main() {
  int n,k;cin>>n>>k;
  int x,sx;
  rep(i,n){
    cin>>x;
    sx += 2*min(x, abs(x-k));
  }
  cout << sx;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main() {

  int n;

  int not_prime[11000];
  

  not_prime[0]=not_prime[1]=1;

  for(int i=2;i<=10000;i++) not_prime[i]=0;

  for(int i=2;i<=sqrt(10000);i++) {

    if(not_prime[i]==0) {

      for(int j=2*i;j<=10000;j+=i) {

	not_prime[j]=1;

      }

    }

  }

  while(1) {

    cin >> n;

    if(n==0) break;

    for(int i=n;i>=5;i--) {

      if(not_prime[i]==0 && not_prime[i-2]==0) {

	cout << i-2 << " " << i << endl;

	break;

      }

    }

  }

  return 0;

}

Measured memory_bytes: 908
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	int n;
  	cin >> n;
  	string s;
  	cin >> s;
  	int w = 0;
  	for(int  i = 0; i <= n-1; i++)
    {
      	if(s[i]=='W')
        {
          	w++;
        }
    }
    int ans = w;
  for(int i=n-1; i >=n-w ; i--)
  {
    if(s[i]=='W')
    {
      ans--;
    }
  }
  cout << ans;
}


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

using namespace std;

typedef long long llint;
const int MOD = 2019;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  reverse(s.begin(), s.end());
  int x = 1, tot = 0;
  vector<int> cnt(MOD);
  llint ans = 0;
  for (int i = 0; i < n; i++) {
    cnt[tot]++;
    tot += (s[i] - '0') * x;
    tot %= MOD;
    ans += cnt[tot];
    x = x * 10 % MOD;
  }
  cout << ans << endl;

  return 0;
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int MAX = -inf;
  int x = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'I') {
      x++;
    } else if (s[i] == 'D') {
      x--;
    }
    if (x > MAX) {
      MAX = x;
    }
  }
  cout << max(MAX, 0) << endl;

  return 0;
}


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

int main() {

	string S;
	cin >> S;

	int X;
	int dis;
	int ans = 1000;

	for (int i = 0; i < S.size()-2; i++) {

		X = (S[i] - '0') * 100 + (S[i + 1] - '0') * 10 + (S[i + 2] - '0');


		dis = fabs(X - 753);
		ans = min(ans, dis);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]
MOD = n

def solve(add):
    for i in range(n):
        for j in range(n):
            if s[(i+add) % MOD][j] != s[(j+add) % MOD][i]:
                return False
    return True

ans = 0
for i in range(n):
    if solve(i):
        ans += n
print(ans)

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

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    bool ans = 0;
    int la = a.size();
    int lb = b.size();
    int lc = c.size();
    if((a.at(la - 1) == b.at(0))&&(b.at(lb - 1) == c.at(0))){
        ans = 1;
    }
    if(ans){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll mod = 1000000007;

ll n,k;

ll calc(ll a){
    ll m,M;
    m = (a-1)*a/2;
    M = (n+n-a+1)*a/2;
    return M-m+1;
}

int main()
{
    cin >> n >> k;
    ll sum = 0;
    for (ll i = k; i <= n+1; i++) {
        sum += calc(i);
    }
    cout << sum%mod << endl;
}

/*
Ctrl+@ でコンソールを開け、以下で実行。
g++ d.cpp
./a.out

サンプルのダウンロードは oj d URL
テストは oj t
*/

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n; string s;
	cin >>n >>s;
	
	VI ct(28);
	rep(i,2*n) ct[s[i]-'a']++;
	int ks=0, kx=-1;;
	rep(i,28) if(ct[i]%2 !=0){ ks++; kx=i;}
	//if(ks>0){ puts("0"); return 0;}
	
	string s1=s.substr(0,n), s2=s.substr(n,n);
	//dbg(s,s1,s2);
	
	map<string, int> mp, mp2;
	//reverse(all(s1));
	rep(i,1<<n){
		string ky,vl;
		rep(j,n){
			if(i>>j&1) ky+=s1[j];
			else vl  += s1[j];
		}
		mp[ky+":"+vl]++;
	}
	//for(auto x :mp) printf("%s:%d, ",x.first.c_str(),x.second); puts("");
	ll ans =0;
	rep(i,1<<n){
		string ky,vl;
		rep(j,n){
			if(i>>j&1) ky=s2[j] +ky; 
			else vl = s2[j] +vl;
		}
		mp2[ky+":"+vl]++;
		string ky2=ky;
		reverse(all(ky2));
		if( mp.count(vl+":"+ky)) ans += mp[ky+":"+vl];
	}
	//for(auto x :mp2) printf("%s:%d, ",x.first.c_str(),x.second); puts("");
	cout << ans <<"\n";
	return 0;
}


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

typedef long long ll;

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (abs(a*b)/gcd(a,b))
#define sqr(a) (a*a)

#define tt int t; cin>>t; while(t--)
#define lo(i, a, b) for(int i=a; i<=b; i++)
#define rlo(i, a) for(int i=a; i>0; i--)
#define be(a) a.begin(),a.end()
#define nl cout<<"\n";
#define sp cout<<" ";

#define op() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    op();
    int k,x,a,b;
    cin>>k>>x;
    a=x-k+1;
    b=x+k-1;
    lo(i,a,b)
    {
        cout<<i;
        sp;
    }
    nl;
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);

		int edge[][] = new int[n][n];

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				edge[i][j] = (i == j) ? 0 : Integer.MAX_VALUE;
			}
		}

		int a[] = new int[m];
		int b[] = new int[m];
		int c[] = new int[m];

		for (int i = 0; i < m; i++) {
			str = br.readLine().split(" ");

			a[i] = Integer.parseInt(str[0]) - 1;
			b[i] = Integer.parseInt(str[1]) - 1;
			c[i] = Integer.parseInt(str[2]);

			edge[a[i]][b[i]] = c[i];
			edge[b[i]][a[i]] = c[i];
		}

		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				if (edge[i][k] == Integer.MAX_VALUE) {
					continue;
				}
				for (int j = 0; j < n; j++) {
					if (edge[k][j] == Integer.MAX_VALUE) {
						continue;
					}
					edge[i][j] = Math.min(edge[i][j], edge[i][k] + edge[k][j]);
				}
			}
		}

		int ans = 0;
		for (int i = 0; i < m; ++i) {
			if (c[i] > edge[a[i]][b[i]])
				ans++;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 24516
n = int(input())
*A, = map(int, input().split())
S = [0]
for i in range(n):
    S.append(S[-1]+A[i])
DP = [[None for r in range(n+1)] for l in range(n)]
def dp(l, r):
    if r <= l+1:
        return 0
    if DP[l][r] != None:
        return DP[l][r]
    DP[l][r] = S[r]-S[l]+min([dp(l, i)+dp(i, r) for i in range(l+1, r)])
    return DP[l][r]
print(dp(0, n))


Measured memory_bytes: 49116
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut cnt = [0; 4];
    for a in a { cnt[a] += 1; }
    const W: usize = 301;
    let mut dp = vec![vec![vec![0.0; W]; W]; W];
    for i in 0 .. W {
        for j in 0 .. W - i {
            for k in 0 .. W - i - j {
                if i == 0 && j == 0 && k == 0 { continue; }
                let fi = i as f64;
                let fj = j as f64;
                let fk = k as f64;
                let progress = (i + j + k) as f64 / n as f64;
                let mut sum = 1.0;
                if k > 0 {
                    sum += dp[i][j][k - 1] * fk / n as f64;
                }
                if j > 0 {
                    sum += dp[i][j - 1][k + 1] * fj / n as f64;
                }
                if i > 0 {
                    sum += dp[i - 1][j + 1][k] * fi / n as f64;
                }
                dp[i][j][k] = sum / progress;
            }
        }
    }
    puts!("{}\n", dp[cnt[3]][cnt[2]][cnt[1]]);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 241916
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,A,B;
  cin >> N >> A >> B;
  int sum=0;
  for (int i=1; i<=N; i++){
  	int keta=0;
    int k=i;
    while (k>0){
      keta += k%10;
      k = k/10;
    }
    
  
  	if (keta>=A && keta <= B){
    	sum += i;
    }
    
  }
	
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int total,i,j,N,min;min=10000000;total=0;
  scanf("%d",&N);
  int X[N];
  for(i=0;i<N;i++){
    scanf("%d",&X[i]);
  }
  for(i=1;i<101;i++){
    for(j=0;j<N;j++){
      total+=(X[j]-i)*(X[j]-i);
    }
    if(min>total)min=total;
    total=0;
  }
  printf("%d\n",min);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<n;i++)
#define unsigned long ul
using namespace std;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	string s;
    cin >> s;
    int n = s.length();
    int sum = 0;
    REP(i, n){
        if(s[i]-'0' != i%2)sum++;
    }
    if(n-sum < sum){
        cout << n-sum << endl;
    }else{
        cout << sum << endl;
    }
    //cout << min(n, n-sum) << endl;
	return 0;
}


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

int main(){
  int N; cin >> N;
  string S; cin >> S;
  for (char C: S){
    printf("%C", (C + N > 'Z' ? C + N - 26 : C + N));
  }
  printf("\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using vi = vector<int>;
using vv = vector<vi>;
using P  = pair<int,int>;
//const int INF = 1001001001;

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h)cin>>s[i];
    vi di = {0,1,0,-1};
    vi dj = {1,0,-1,0};
    int ans = 0;
    rep(i,h)rep(j,w){
        if(s[i][j]=='#')continue;
        vv check(h, vi (w, -1));
        queue<P> q;
        q.push(P(i,j));
        check[i][j]=0;
        while(!q.empty()){
            int pi = q.front().first;
            int pj = q.front().second;
            q.pop();
            int nc = check[pi][pj]+1;
            rep(a,4){
                int ni = pi+di[a];
                int nj = pj+dj[a];
                if(ni<0 || nj<0 || ni>=h || nj>=w)continue;
                if(s[ni][nj]=='#')continue;
                if(check[ni][nj]!=-1)continue;
                check[ni][nj] = nc;
                q.push(P(ni,nj));
                ans = max(ans, nc);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
import itertools
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[]
c=0
for i in range(n):
    for j in range(i,n):
        b=sum(a[i:j+1])
        l.append(b)
l.sort()
for i in range(len(l)):
    l[i]=format(l[i],'b').zfill(len(format(l[-1],'b')))
m=len(l[0])
l=l[::-1]
r=[0]*m
for i in range(m):
    for j in range(len(l)):
        if l[j][i]=='1':
            r[i]+=1
for i in range(m):
    ll=[]
    lll=[]
    if r[i]>=k:
        for j in range(len(l)):
            if l[j][i]=='1':
                ll.append(l[j])
            else:
                lll.append(l[j])
        l=ll
        if len(l)<k:
            l=l+lll
        elif len(l)==k:
            c+=2**(m-i-1)
            break
        elif len(l)>k:
            c+=2**(m-i-1)
    else:
        ll=l
ans=int(l[0],2)
for i in range(len(l)):
    ans&=int(l[i],2)
if len(l)>k:
    print(c)
else:
    print(ans)

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

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

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

  rep(i,2) rep(j,2){ // 0ならS,1ならW
    vi a(n); a[0] = i; a[1] = j;
    rep(k,n-2){
      if(a[k+1] == 0)
	if(s[k+1] == 'o') a[k+2] = a[k];
	else a[k+2] = not a[k];
      else
	if(s[k+1] == 'x') a[k+2] = a[k];
	else a[k+2] = not a[k];
    }
    bool f = false;
    if(a[n-1] == 0)
      if(s[n-1] == 'o' and a[n-2] == a[0]) f = true;
      else if(s[n-1] == 'x' and a[n-2] != a[0]) f = true;
      else ;
    else
      if(s[n-1] == 'o' and a[n-2] != a[0]) f = true;
      else if(s[n-1] == 'x' and a[n-2] == a[0]) f = true;
      else ;

    if(not f) continue;
    f = false;
    if(a[0] == 0)
      if(s[0] == 'o' and a[n-1] == a[1]) f = true;
      else if(s[0] == 'x' and a[n-1] != a[1]) f = true;
      else ;
    else
      if(s[0] == 'o' and a[n-1] != a[1]) f = true;
      else if(s[0] == 'x' and a[n-1] == a[1]) f = true;
      else ;

    if(f){
      rep(i,n)
	if(a[i] == 0) cout << "S";
	else cout << "W";
      cout << endl;
      return 0;
    }
  }
  cout << "-1\n";
}

Measured memory_bytes: 1016
import java.util.Scanner;
public class Main{
public static void main(String[] args){
try (Scanner sc = new Scanner(System.in)){
while(true){
int n = sc.nextInt();
if(n == 0){
break;
}
int[] score = new int[n];
for(int i = 0; i< score.length; i++){
score[i] = sc.nextInt();
}
double avg = 0, var = 0, tot = 0;
int sum = 0;
for(int i = 0; i<score.length; i++){
sum = sum + score[i];
}
avg = (double) sum / n;
for(int i = 0; i<score.length; i++){
tot = tot + (score[i] - avg) * (score[i] - avg);
}
var = tot / n;
System.out.println(Math.sqrt(var));
}
}
}
}



Measured memory_bytes: 31112
use proconio::input;
#[allow(unused_mut)]
fn main() {
    input! {
        n: usize,
        a: [usize;n]
    }
    let res = a
        .iter()
        .filter(|s| *s % 2 == 0)
        .all(|s| *s % 3 == 0 || *s % 5 == 0);
    if res {
        println!("APPROVED");
    } else {
        println!("DENIED");
    }
}


Measured memory_bytes: 2112
# 下、右、上、左、右下、右上、左下、左上
dx = [0, 1, 0, -1, 1, 1, -1, -1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]

h, w = map(int, input().split())

l = [(list(input())) for i in range(h)]

for y in range(h):
    for x in range(w):

        if l[y][x] == '#':
            continue

        cnt = 0

        for k in range(8):
            nx = x + dx[k]
            ny = y + dy[k]

            if nx < 0 or w <= nx or ny < 0 or h <= ny:
                continue

            if l[ny][nx] == '#':
                cnt += 1

        l[y][x] = str(cnt)

for y in range(h):
    print(''.join(l[y]))

Measured memory_bytes: 3188
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cmath>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	double n,sum=0,a;
	string s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a>>s;
		if(s=="JPY"){
			sum+=a;
		}else{
			sum+=a*380000.000000;
		}
	}
	cout<<fixed<<sum<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <array>
#include <set>
#include <climits>
#include <cassert>
#include <bitset>
#include <numeric>
using namespace std;
#define mod 1000000007



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

#ifdef HELL_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    freopen("error","w",stderr);
#endif 
    string s , t; cin>>s>>t;
    int a , b; cin>>a>>b;
    string u; cin>>u;
    if(u==s){
        cout<<a-1<<' '<<b<<endl;
    }else if(u==t){
        cout<<a<<' '<<b-1<<endl;
    }else{
        cout<<a<<' '<<b<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s[12];
    int h,w,k;
    cin>>h>>w>>k;
    for(int i=0;i<h;i++)
        cin>>s[i];
    int ans=1e9;
    for(int u=0;u<(1<<(h-1));u++){
        int x=__builtin_popcount(u);
        int r[x+1]={0};
        int flag=1;
        int cnt=x;
        for(int j=0;j<w;j++){
            int c[x+1]={0};
            int p=0;
            int mx=0;
            for(int i=0;i<h;i++){
                c[p]+=s[i][j]-'0';
                mx=max(mx,c[p]);
 				if(u&(1<<i)) p++;
            }
            if(mx>k) {flag=0;break;}
            mx=0;
            for(int i=0;i<=x;i++){
                mx=max(mx,r[i]+c[i]);
            }
            if(mx>k) {memset(r,0,sizeof(r));cnt++;}
            for(int i=0;i<=x;i++) r[i]+=c[i];
        }
        if(flag) ans=min(ans,cnt);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256