akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
/*                   وتزودوا فإن خير الزاد التقوى                    */
/*       وما تدري نفس ماذا تکسب غدا وما تدري نفس باي ارض تموت      */
#include <bits/stdc++.h>
#include<unordered_map>
#include<iomanip>
#include<fstream>
using namespace std;
#include<iostream>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define dll double
#define PI acos(-1)
#define watch(x) cout<<#x<<" = { "<<x<<" }\n"
#define sz(n) n.size()
#define M_Sayed fast() 
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define RT(v) return cout<<v,0
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
const double EPS = (1e-7);
ll Ceil(ll x, ll y) { return (x + y - 1) / y; }
void run() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
#endif
}
ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }
ll power(ll x, ll y, ll mod) {
	if (y == 0) return 1;
	if (y == 1) return x % mod;
	ll r = power(x, y >> 1, mod);
	return (((r * r) % mod) * power(x, y & 1, mod)) % mod;
}
void fast() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }
ll n, m, t;
int main()
{
	//run();
	M_Sayed;
	ll n, a, b;
	cin >>n>> a >> b;
	ll k = (n+(a+b)) / (a + b);
	//cout << k << endl;
	k--;
	ll j = min(a, n % (a + b));
	cout << k * a + j;
	
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <cmath>
#include <functional>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main(){
	int B, A, C;
	string str;
	cin >> A >> B >> C;

	if (A < B && B < C){
		str = "Yes";
	}
	else{
		str = "No";
	}
	

	cout <<str<< endl;
	return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>
int main(){
int H,W;
int i,j;
while(1){
scanf("%d%d", &H, &W);
if(H==0 && W==0)
 break;

 for(i=0; i<H; i++){
  for(j=0; j<W; j++){
   printf("#");
   }
  printf("\n");
  }
 printf("\n");
} 

return 0;
}

 

Measured memory_bytes: 572
s = input()
t = input()

x = len(s)
y = len(t)
dp = [[0]*(y+1) for _ in range(x+1)]

for i in range(x):
    for j in range(y):
        if s[i]==t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])

res = ""
while x>0 and y>0:
    if dp[x][y] == dp[x-1][y]:
        x -= 1
    elif dp[x][y] == dp[x][y-1]:
        y -= 1
    else:
        res = s[x-1] + res
        x -= 1
        y -= 1
print(res)

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

int main(){
   int m,f,r;
   
   while(cin>>m>>f>>r,m!=-1||f!=-1||r!=-1){
       if(m==-1||f==-1)cout<<"F\n";
       else if(m+f>=80)cout<<"A\n";
       else if(80>m+f&&m+f>=65)cout<<"B\n";
       else if(65>m+f&&m+f>=50)cout<<"C\n";
       else if(50>m+f&&m+f>=30){
           if(r>=50)cout<<"C\n";
           else cout<<"D\n";
       }
       else cout<<"F\n";
   }
    
    return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

const int MOD = 1e9 + 7;



#define INPUT(x)                freopen(x,"r",stdin)
#define OUTPUT(x)               freopen (x,"w",stdout)



#define pb                      push_back
#define endl                    '\n'
#define LCM(a,b)                (a/__gcd(a,b))*b
#define GCD(a,b)                __gcd(a,b)
#define SP(x,y)                 fixed<<setprecision((y))<<(x)
#define PI                      acos(-1.0)
#define distance(x1,y1,x2,y2)   sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))

#define taratari                ios_base::sync_with_stdio(0);cin.tie(NULL);




int main()
{
    taratari

    ll a;
    cin>>a;

    ll sum=0;

    sum=a+(a*a)+(a*a*a);

    cout<<sum;



    return 0;


}



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

int main()
{
	string N;
	cin >> N;
	char num = N[N.length()-1];

	if (num == '3') {
		cout << "bon" << endl;
	}
	else if (num == '0' || num == '1' || num == '6' || num == '8') {
		cout << "pon" << endl;
	}
	else {
		cout << "hon" << endl;
	}


}


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

using namespace std;

#define ll long long

int main()
{
	int N;
	cin >> N;
	vector < ll > A(N), B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}

	vector < pair < ll, ll >> BA(N);
	for (int i = 0; i < N; i++) {
		BA[i] = make_pair(B[i], A[i]);
	}

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

	ll current = 0;
	for (int i = 0; i < N; i++) {
		if (current + BA[i].second > BA[i].first) {
			cout << "No" << endl;
			return 0;
		}
		current += BA[i].second;
	}

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


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int main(void){
   vector<int> A(5);
   int k;
   for(int i = 0; i < 5; i++) cin >> A[i];
   cin >> k;
   bool flag = true;
   for(int i = 0; i < 5; i++){
       for(int j = i+1; j < 5; j++){
           if(A[j] - A[i] > k){
               flag = false;
               break;
           }
       }
   }
    if(flag == true) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}


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

int main(void) {
    string s, t;
    cin >> s >> t;

    vector<long> ss(s.size()+1), tt(t.size()+1);
    for(long i=1; i<=s.size(); i++)
        ss[i] = ss[i-1] + (s[i-1] == 'A' ? 1 : 2);
    for(long i=1; i<=t.size(); i++)
        tt[i] = tt[i-1] + (t[i-1] == 'A' ? 1 : 2);

    long q;
    cin >> q;
    for(long i=0; i<q; i++) {
        long a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--, d--;

        cout << (((ss[b+1]-ss[a]) - (tt[d+1]-tt[c]))%3 ? "NO" : "YES") << endl;
    }
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
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; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) do{}while(0)
#endif




int main(){
	ll n;
	cin >> n;
	
	vector<ll> a(n);
	rep(i,n)
		cin >> a[i];
	
	ll money = 1000;
	for ( int i = 1; i < n; i++ ){
		if ( a[i-1] < a[i] ){
			ll stock = money / a[i-1];
			money -= stock * a[i-1];
			money += stock * a[i];
		}
	}
	
	cout << money << endl;
	
	return 0;
}




Measured memory_bytes: 3628
import sys

def solve(code):
    counter = {}
    for i in range(len(code)):
        if code[i] not in counter:
            counter[code[i]] = 0
        counter[code[i]] += 1

    v = counter.values()
    if len(v) == 2 and v[0] == 2 and v[1] == 2:
        return 'Yes'
    else:
        return 'No'


if __name__ == '__main__':
    code = sys.stdin.readline().strip()
    print solve(code)

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, n);
  Cin(string, s);

  int x = 0;
  int _max = 0;

  for (auto e : s) {
    if (e == 'I') x++;
    else x--;
    _max = max(_max, x);
  }

  cout << _max << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int gcd(int a, int b) {
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
int main() {
	long long int A, B, C, D;
	cin >> A >> B >> C >> D;
	long long int c, d, dc ,gc;
	gc = (C*D)/gcd(C, D);
	c = B / C - (A - 1) / C;
	d = B / D - (A - 1) / D;
	dc = B / (gc) - (A - 1) / (gc);
	cout << (B - A + 1) - (c + d - dc) << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = str(input())

dp = [[0]*(n+1) for i in range(n+1)]
#dp[n-1][n-1] = 1

for i in reversed(range(n)):
  for j in reversed(range(n)):
    if s[i] == s[j]:
      dp[i][j] = dp[i+1][j+1]+1

#print(dp)

ans = 0
for i in range(n-1):
  for j in range(i, n):
    ans = max(ans, min(dp[i][j], j-i))
    
print(ans)


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

int main(void){
    int N,M;
    cin>>N>>M;
    int K[N][M];
    int ans[M];
    int cnt=0;

    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        for(int j=0;j<a;j++){
            cin>>K[i][j];
        }
        for(int j=a;j<M;j++){
            K[i][j]=0;
        }
    }


    for(int i=0;i<M;i++)
        ans[i]=0;

    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            if(K[i][j]==0)
                continue;
            ans[K[i][j]-1]+=1;
        }
    }

    for(int i=0;i<M;i++){
        if(ans[i]==N)
            cnt+=1;
    }

    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin>>a;
  if(a==1 || a==2 || a==3 || a==4 || a==5 || a==6 || a==7 || a==8 || a==9 || a==2 || a==4 || a==6 || a==8 || a==10 || a==12 || a==14 || a==16 ||a==18 || a==3 || a==6 || a==9 || a==12 || a==15 || a==18 || a==21 || a==24 || a==27 || a==4 || a==8 || a==12 || a==16 || a==20 || a==24 || a==28 || a==32 || a==36 || a==5 || a==10 || a==15 || a==20 || a==25 ||a==30 || a==35 || a==40 || a==45 || a==6 || a==12 || a==18 || a==24 || a==30 || a==36 || a==42 || a==48 || a==54 || a==7 || a==14 || a==21 || a==28 || a==35 || a==42 || a==49|| a==56 || a==63 || a==8 || a==16|| a==24 || a==32 || a==40 || a==48 || a==56 || a==64 || a==72 || a==9 || a==18 || a==27 || a==36 || a==45 || a==54 || a==63 || a==72 || a==81){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

/*
 gcd : 最大公約数
 lcm : 最小公倍数
 */
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }

int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N; cin >> N;
    ll LCM = 1;
    for(int i = 0; i < N;i++){
        ll T; cin >> T;
        LCM = lcm(LCM,T);
    }
    cout << LCM << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
ll a[501][501];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),m=gi(),h=gi(),w=gi();
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			a[i][j]=1000;
	for(int i=h;i<=n;i+=h)
		for(int j=w;j<=m;j+=w)
			a[i][j]-=h*w*1000+1;
	ll sum=0;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			sum+=a[i][j];
	if(sum<0)return puts("No"),0;
	puts("Yes");
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j)printf("%lld ",a[i][j]);
		puts("");
	}
	return 0;
}


Measured memory_bytes: 3584
extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::f32::MAX;
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut, SubAssign, Range};
use std::collections::{BTreeMap, VecDeque, BinaryHeap, BTreeSet, HashMap};
use std::fmt::Display;

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
fn show2<T: Display>(vec: &Vec<Vec<T>>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        for l in vec {
            show(l);
        }
    }
}

macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! read_value{
    () => {
        read_line!().trim().parse().ok().unwrap()
    }
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}

macro_rules! let_mut_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let mut $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
fn main() {
    let name = vec!['A', 'B', 'C', 'D', 'E'];
    loop {
        let_all!(s1: i32, s2: i32);
        if s1 == 0 && s2 == 0 {return}
        let mut current = 0;
        let mut current_max = s1 + s2;
        for i in 1 .. 5 {
            let_all!(s1: i32, s2: i32);
            if current_max < s1 + s2 {
                current = i;
                current_max = s1 + s2;
            }
        }
        println!("{} {}", name[current], current_max);
    }
}



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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
//#define DEBUG(x) ;

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

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll N, Q; cin >> N >> Q;
	vector<ll> A(N); REP(i, N) cin >> A[i];

	while (Q--)
	{
		ll x; cin >> x;

		ll sum{0}, r{0}, res{0};
		REP(l, N)
		{
			while (r < N && sum + A[r] <= x)
				sum += A[r++];

			res += (r - l);

			if (r == l) ++r;
			else sum -= A[l];
		}

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



Measured memory_bytes: 3524
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}

int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin >> n >> m;
    priority_queue<int> pq;
    rep(i,1,n+1){
        int x;
        cin >> x;
        pq.push(x);
    }
    while(m){
        int x=pq.top();
        pq.pop();
        x/=2;
        pq.push(x);
        m--;
    }
    int ans=0;
    while(!pq.empty()){
        ans+=pq.top();
        pq.pop();
    }
    cout << ans;
    return 0;
}


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

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

    string ans = "APPROVED";
    for(auto x:a){
        if(x % 2 == 0){
            if(x % 3 != 0 and x % 5 != 0){
                ans = "DENIED";
                cout << ans << endl;
                return 0;
            }
        }
    }

    cout << ans << endl;
}

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

ll gcd(ll a, ll b){
  return (b != 0) ? gcd(b, a%b) : a;
}

int main(){
  int n;
  cin >> n;
  vector<ll> x(n);
  vector<ll> c(n);
  rep(i, n){
    cin >> x[i];
    c[i] = x[i];
  } 
  sort(x.begin(), x.end());
  rep(i, n){
    if(c[i] <= x[n/2-1]) cout << x[n/2] << endl;
    else  cout << x[n/2-1] << endl;
  }
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
vector<int>e[100005];
int i,m,n,u,v,ans[100005];
int main(){
	puts("Yes");
	cin>>n>>m;
	for(i=1;i<=m;i++){cin>>u>>v;e[u].push_back(v),e[v].push_back(u);}
	ans[1]=1;
	queue<int>Q;
	Q.push(1);
	while(Q.size()){u=Q.front();Q.pop();for(auto v:e[u])if(!ans[v])ans[v]=u,Q.push(v);}
	for(i=2;i<=n;i++)cout<<ans[i]<<endl;
}

Measured memory_bytes: 10400
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int k = sc.nextInt();
			if(n == 0 && m == 0 && k == 0)break;
			else calc(n, m, k);
			
		}
	}
	public void calc(int n, int m, int k){
		int[] memo = new int[1];
		for(int i = 0; i < n; i++){
			int[] me = new int[(int)Math.pow(m, i+1)];
			for(int j = 0; j < memo.length; j++){
				for(int t = 0; t < m; t++){
					me[m * j + t] = memo[j] + t + 1;
				}
			}
			memo = me;
		}
		
		double sum = 0;
		for(int i = 0; i < memo.length; i++){
			int t = memo[i] - k;
			if(t < 1) t = 1;
			sum += 1 / (Math.pow(m, n)) * t;
		}
		System.out.printf("%.8f\n",sum);
	}

	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 58756
/*
TEMPLATE
by.YXH_XianYu
   2018.7.21
*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LLI long long
#define DBL double
#define CHR char
#define BOL bool
#define REG register
#define rep(i, j, k) for(int i = j, lim = k; i <= lim; i++)
#define req(i, j, k) for(int i = j, lim = k; i >= lim; i--)
#define MXN 105

int n;
char s[MXN], t[MXN];

int main() {
	//freopen("TEMPLATE.in", "r", stdin);
	//freopen("TEMPLATE.out", "w", stdout);
	
	scanf("%s", s+1);
	scanf("%s", t+1);
	n = strlen(s+1);
	rep(i, 1, n)
		s[n+i] = s[i];
	rep(i, 1, n){
		bool Found = 1;
		rep(j, 1, n)
			if(s[i+j-1] != t[j]){
				Found = 0;
				break;
			}
		if(Found) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9

int a[100000];

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

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

	int ans = a[0];

	for (int i = 1; i < N && ans != 1; i++) {
		if (ans > a[i]) ans = gcd(ans, a[i]);
		else ans = gcd(a[i], ans);
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
        m: usize,
    }

    if n==m {
        println!("Yes");
    } else {
        println!("No");
    }

}

Measured memory_bytes: 4352
N = int(input())
Numbers = list(map(int, input().split()))
Flag = True
count = 0
while Flag:
    Flag = False
    for j in range(N - 1, 0, -1):
        if Numbers[j] < Numbers[j - 1]:
            Numbers[j], Numbers[j - 1] = Numbers[j - 1], Numbers[j]
            count += 1
            Flag = True
print(' '.join(list(map(str, Numbers))))
print(count)



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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int result = 0;
  int i, j;
  for (i = 0; i < 1000; i++) {
    // cout << i << ' ';
    int search_n = i;
    // cout << search_n << ' ';
    for (j = 0; j < n; j++) {
      // cout << j;
      // cout << "flag1 ";
      if (search_n % 10 == s.at(j) - '0') {
        j++;
        break;
      }
    }
    search_n /= 10;
    // cout << search_n << ' ';
    for (; j < n; j++) {
      // cout << j;
      if (search_n % 10 == s.at(j) - '0') {
        j++;
        break;
      }
    }
    search_n /= 10;
    // cout << search_n << ' ';
    for (; j < n; j++) {
      // cout << j;
      if (search_n % 10 == s.at(j) - '0') {
        result++;
        // cout << i << endl;
        break;
      }
    }
    // cout << endl;
  }
  cout << result << endl;
  return 0;
}


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



int main(){
    ll n,m; cin >> n >> m;
    if(n == 1 && m == 1) cout << 1 << endl;
    else if(n == 1) cout << m-2 << endl;
    else if(m == 1) cout << n-2 << endl;
    else cout << (n-2)*(m-2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>

using namespace std;

using ll = long long;

using P = pair<int, int>;
#define fi first
#define se second

set<int> G[100010];

int main() {
    int n, m;
    cin >> n >> m;
    if (m % 2) {
        cout << -1 << '\n';
        return 0;
    }
    for (int i=0, a, b; i<m; i++) {
        cin >> a >> b;
        a--; b--;
        G[a].insert(b);
        G[b].insert(a);
    }
    set<P> s;
    for (int i=0; i<n; i++) s.insert(P{G[i].size(), i});
    vector<P> ans;
    vector<int> erlist;
    int deg[n];
    fill(deg, deg+n, 0);
    for (int j; !s.empty(); ) {
        j = s.begin()->se;
        s.erase(s.begin());
        erlist.clear();
        for (auto &g:G[j]) {
            if ((deg[j] & 1) == 0) {
                ans.push_back(P{g+1, j+1});
                deg[g]++;
            } else {
                ans.push_back(P{j+1, g+1});
                deg[j]++;
            }
            erlist.push_back(g);
        }
        for (auto &e:erlist) {
            s.erase(P{G[e].size(), e});
            G[e].erase(j);
            s.insert(P{G[e].size(), e});
        }
        //cerr << j << ' ' << G[j].size() << '\n';
    }
    for (auto &ai:ans) cout << ai.fi << ' ' << ai.se << '\n';
    return 0;
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

int main() {
    string s;
    cin >> s;
    rep(i, 0, s.size()) { cout << 'x'; }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384

using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    vector<vector<P>> A(N);
    rep(i, N){
        int a;
        cin >> a;
        
        rep(j, a){
            int x, y;
            cin >> x >> y;
            A[i].push_back(P(--x, y));
        }
    }
    
    int ans=0;
    for(int bit=0; bit<(1<<N); bit++){
        bool ok=true;
        int res=0;
        for(int i=0; i<N; i++){
            if(bit>>i&1){
                for(int j=0; j<A[i].size(); j++){
                    int x = A[i][j].first;
                    int y = A[i][j].second;
                    
                    if(y==1&&!(bit>>x&1)) ok=false;
                    if(y==0&&(bit>>x&1)) ok=false;
                }
                if(ok) res+=1;
            }
        }
        if(ok) ans = max(ans, res);
    }
    
    cout << ans << endl;
    
    return 0;
}


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

int n, m;
string s;

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

    vector<int> res(0);
    int pos = n;
    
    while(pos)
    {
        for (int i = m; i >= 1; i--)
        {
            if(pos - i < 0) continue;

            if(s[pos - i] == '0')
            {
                res.emplace_back(i);
                pos -= i;
                break;
            }
            
            if(i == 1)
            {
               cout << -1 << endl;
               return 0;
            }
        }
    }

    for(int i = res.size() - 1; i >= 0; i--)
    {
        cout << res[i] << ((i == 0)? "\n" : " ");
    }

    return 0;
}

Measured memory_bytes: 1144
#include <algorithm>
#include <iostream>
#include "vector"
#include "stack"
#include "utility"
#include "bits/stdc++.h"

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

int main() {
    IOS

    ll n;
    cin >> n;
    string st;
    cin >> st;
    if (n % 2 == 1) {
        cout << "No\n";
        return 0;
    }
    ll off = n / 2;
    for (int i = 0; i < n / 2; ++i) {
        if (st[i] != st[i + off]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string t;
char c;
bool n,s,e,w;
int i,j,k,m;
int main()
{
	cin>>t;
	for(i=0;i<t.length();i++)
	{
		c=t[i];
		if(c=='N')n=true;
		if(c=='S')s=true;
		if(c=='E')e=true;
		if(c=='W')w=true;
		if(n&&s&&e&&w)break;
	}
	if(n==(not s)||w==(not e))printf("No\n");
	else printf("Yes\n");
}

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

//#define int long long

const int MAXN = 21;
const int INF = 2e9;
const int mod = 1e9 + 7;

int k;
int dp[MAXN][MAXN];
int sum[MAXN];
int ans[MAXN],pos = 1,tot;

signed main () {
	cin >> k;
	for(register int i = 0;i <= 9; ++i) dp[1][i] = 1;
	sum[1] = 9;
	for(register int i = 2;i <= 10; ++i) {
		for(register int p = 1;p <= 9; ++p)
			dp[i][p] = dp[i - 1][p - 1] + dp[i - 1][p] + dp[i - 1][p + 1];
		dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
		for(register int p = 1;p <= 9; ++p) sum[i] += dp[i][p]; 
	}
	while(tot + sum[pos] < k) tot += sum[pos++];
	assert(pos <= 10);
	k -= tot;
	for(register int i = pos;i >= 1; --i) {
		int tmp = 0;
		if(i == pos) {
			for(register int p = 1;p <= 9; ++p) {
				if(tmp + dp[i][p] >= k) {ans[i] = p; break;}
				tmp += dp[i][p];
			}
			k -= tmp;
			continue;
		}
		for(register int p = max(0,ans[i + 1] - 1);p <= min(9,ans[i + 1] + 1); ++p) {
			if(tmp + dp[i][p] >= k) {ans[i] = p; break;}
			tmp += dp[i][p];
		}
		k -= tmp;
	}
	for(register int i = pos;i >= 1; --i)
		cout << ans[i];
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int L[M], R[M];
  for (int i = 0; i < M; i++) {
    cin >> L[i] >> R[i];
    L[i]--;
    R[i]--;
  }
  int b[N + 2]{};
  for (int i = 0; i < M; i++) {
    b[L[i]]++;
    b[R[i] + 1]--;
  }
  for (int i = 0; i <= N; i++) {
    b[i + 1] += b[i];
  }
  int cnt = 0;
  for (int i : b) {
    if (i == M) cnt++;
  }
  cout << cnt << "\n";
  return 0;
}
//ヤマカサの競技プログラミングさんの

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
// Harshad Number
int main() {
  int N, c;
  cin >> N;

  for (int n = N; n != 0; n /= 10) {
    c += n % 10;
  }
  
  if (N % c == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>

int main(void)
{
    char S[100];
    fscanf(stdin, "%s", &S);
    int i,j,len,count=0;
    len=strlen(S);
    for(i=0,j=len-1; i<len/2; i++,j--)
    {
        if(S[i]!=S[j])
        {
            count++;
        }
        else
        {
            continue;
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt();
        int x = in.nextInt();
        int right = Math.min(1000000,x+k-1);
        for(int i=Math.max(-1000000,x-k+1); i<right; i++) {
            System.out.print(i);
            System.out.print(' ');
        }
        System.out.println(right);
    }
}


Measured memory_bytes: 23508
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1e9+7
#define INF 1e9
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;


int main(void){
    int N,ans=0;
    cin>>N;
    VI p(N);
    REP(i,N)cin>>p[i];
    sort(All(p));
    REPR(i,N-1){
        ans++;
        if(p[i]<ans){
            ans--;
            break;
        }
    }
    cout<<ans<<endl;
}





Measured memory_bytes: 3124
n=int(input())
x=[0]*(n+1)
a=2
q=10**9+7
if n==1:
    print(1)
    exit()

for i in range(2,n+1):
    a=i
    p=2
    while p*p<=i:
        if a%p==0:
            x[p]+=1
            a=a//p
        else:
            p+=1
    if a!=1:
        x[a]+=1

ans=1
for i in range(n+1):
    ans=ans*(x[i]+1)%q
print(ans%q)



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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)

const int mod = 1000000007;
class mint {
public:
	long long x;
	mint(long long x = 0) : x((x%mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};


mint Combination(mint n, mint r) {
	mint bunbo = r;
	mint bunshi = n;
	mint cnt = mint(1);
	while (1) {
		if (r.x == cnt.x)break;
		bunbo *= (r - cnt);
		bunshi *= (n - cnt);
		cnt += mint(1);
	}
	mint res;
	res = bunshi / bunbo;
	return res;
}

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	vector<ll> tin(n);
	vector<ll> tout(n);
	FOR(i, 0, n - 1) {
		cin >> a[i];
	}
	FOR(i, 0, n - 2) {
		FOR(j, i, n - 1) {
			if (a[i] > a[j]) {
				tin[i]++;
			}
		}
	}

	FOR(i, 0, n - 1) {
		FOR(j, 0, n - 1) {
			if (a[i] > a[j]) {
				tout[i]++;
			}
		}
	}

	mint res = mint(0);
	FOR(i, 0, n - 1) {
		res += mint(tin[i]) *mint(k) *mint(k + 1) / mint(2);
		res += mint(tout[i]-tin[i]) *mint(k) *mint(k - 1) / mint(2);
	}
	pv(res.x);
	return 0;
}

Measured memory_bytes: 3604
import sys

sys.setrecursionlimit(10 ** 7)

# ----------

INF = float("inf")
MOD = 10 ** 9 + 7
# ----------

A, B, C, K = map(int, input().split())

ans = 0
ans += min(K, A)
K -= min(K, A)
if K > 0:
    K -= min(K, B)
if K > 0:
    ans -= min(K, C)

print(ans)


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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

#define clr(a,i) memset((a), (i) ,sizeof(a))

vi x(50,0);

template <typename T>
inline std::string to_bin_str(T n, std::size_t digit_num) {
   std::string str;
   while (n > 0) {
       str.push_back('0' + (n & 1));
       n >>= 1;
   }
   str.resize(digit_num, '0');
   std::reverse(str.begin(), str.end());
   return str;
}

int main(){
  string num;
  std::cin >> num;

  string s;
  string tmp;
  tmp=num[0];
  long ans=0;
  rep(i,pow(2,num.size()-1)){
    s= to_bin_str(i,num.size()-1);
    rep(j,s.size()){
      if(s[j]=='0') tmp=tmp+num[j+1];
      else{
        ans+=stol(tmp);
        tmp=num[j+1];
      }
    }
    ans+=stol(tmp);
    tmp=num[0];
  }
  std::cout << ans << std::endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	
	string  s; cin>>s;
	bool flag = true;
	for(int i = 0; i < s.size(); i++){
		if((i+1)%2 == 0) {
			if(s[i] == 'R') flag = false;
		}
		if((i+1)%2 == 1) {
			if(s[i] == 'L') flag = false;
		}
	}
	if(flag) cout<<"Yes"<<"\n";
	else cout<<"No"<<"\n";
	
	
	
	
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;
const ll INF = 1e18L + 1;

int a[110000];
int b[110000];

int main()
{
  int A, B, M;
  cin >> A >> B >> M;
  int ans = 1e9 + 1;
  rep(i, A)
  {
    cin >> a[i];
    ans = min(ans, a[i]);
  }
  int minB = 1e9 + 1;
  rep(i, B)
  {
    cin >> b[i];
    minB = min(minB, b[i]);
  }
  ans += minB;
  rep(i, M)
  {
    int x, y, c;
    cin >> x >> y >> c;
    int price = a[x - 1] + b[y - 1] - c;
    ans = min(ans, price);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using i64 = long long;
using f64 = double;

#define FOR(i, s, n) for (size_t i = (s); i < (size_t)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

template <typename T, typename U>
inline bool chmax(T &a, U b)
{
  return a < b ? (a = b, true) : false;
}

template <typename T, typename U>
inline bool chmin(T &a, U b)
{
  return a > b ? (a = b, true) : false;
}

int fn(int x, int y, int z)
{
  return x * x + y * y + z * z + x * y + y * z + z * x;
}

int main()
{
  int n;
  cin >> n;
  auto ret = vector<int>(n, 0);
  int lm = (int)sqrt(n);
  for (auto x = 1; x <= lm; x++)
  {
    for (auto y = 1; y <= lm; y++)
    {
      for (auto z = 1; z <= lm; z++)
      {
        auto index = fn(x, y, z) - 1;
        if (index < n)
        {
          ret[index]++;
        }
      }
    }
  }
  for (auto x : ret)
  {
    cout << x << endl;
  }
  return 0;
}


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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back
#define mod 1000000007
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

const int N = 100005;

void solve() {
	int i, j, k, n, m, ans = 0, cnt = 0, sum = 0;
	cin >> n >> m;
	int a[n + 1];
	for (i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int dp[n + 1][m + 1] = {};
	dp[0][0] = 1;
	// for (i = 1; i <= n; i++) {
	// 	for (j = 0; j <= m; j++) {
	// 		for (k = 0; k <= min(a[i], j); k++) {
	// 			dp[i][j] += dp[i - 1][j - k];
	// 			dp[i][j] %= mod;
	// 		}
	// 	}
	// }
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
			dp[i - 1][j] += dp[i - 1][j - 1];
			dp[i - 1][j] %= mod;
		}
		for (j = 0; j <= m; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j - a[i] > 0) dp[i][j] -= dp[i - 1][j - a[i] - 1];
		}
	}
	// for (i = 0; i <= n; i++) {
	// 	for (j = 0; j <= m; j++) {
	// 		cout << dp[i][j] << " ";
	// 	} cout << '\n';
	// }
	cout << (dp[n][m] + mod) % mod;
	return ;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
int N,M,X,Y,maxx=-10000,miny=10000;
int main(){
    ios::sync_with_stdio(false);
    cin>>N>>M>>X>>Y;
    int a;
    for(int i=1;i<=N;i++){
        cin>>a;
        maxx = max(maxx,a);
    }
    for(int i=1;i<=N;i++){
        cin>>a;
        miny = min(miny,a);
    }
    for(int i=maxx+1;i<=miny;i++){
        if(i>X&&i<=Y){
            cout<<"No War";
            return 0;
        }
    }
    cout<<"War";
}



Measured memory_bytes: 256
from itertools import accumulate
N, K = map(int, input().split())
S = input()
nums = []
if S[0] == '0':
    nums.append(0)
i = 0
while i < N:
    j = i
    while j < N and S[i] == S[j]:
        j += 1
    nums.append(j - i)
    i = j
if S[-1] == '0':
    nums.append(0)

sums = [0] * (len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
ans = 0
left = 0
while left < len(nums):
    right = left + 2 * K + 1
    if right > len(sums):
        right = len(sums) - 1
    ans = max(ans, sums[right]-sums[left])
    left += 2

print(ans)

Measured memory_bytes: 8016
#include<iostream>
using namespace std;
int main() {
	string s;
	cin>>s;
	int p=0;
	for(int i=0;i<s.size();i++) {
		if(s[i]=='C') {
			p=1;
		}
		if(s[i]=='F' && p==1) {
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

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

using namespace std;
using ll = long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

ll ans = 0;

void solve() {
  int N;
  in(N);
  vi x(N);
  vi y(N);
  vi p;
  rep(i, 0, N) {
    in(x[i], y[i]);
    p.push_back(i);
  }

  double ans = 0;
  int div = 0;

  do {
    rep(i, 1, N)
      ans += sqrt(pow(x[p[i]] - x[p[i - 1]], 2) + pow(y[p[i]] - y[p[i - 1]], 2));
    div++;
  } while(next_permutation(all(p)));

  printf("%.10f", ans / div);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int mod=1000000007;
inline void add(int &x,int y){(x+=y)>=mod?x-=mod:0;}
inline int pl(int x,int y){return (x+=y)>=mod?x-mod:x;}
int n,m,x[100010],y[100010],p[100010];
vector<int>line[100010];
int len[100010];
struct seg
{
	int ch[5000000][2],sum[5000000],tot,rt;
	void ins(int &k,int l,int r,int p,int w)
	{
		if(!k)k=++tot;
		add(sum[k],w);
		if(l==r)return;
		if(p<=l+r>>1)ins(ch[k][0],l,l+r>>1,p,w);
		else ins(ch[k][1],(l+r>>1)+1,r,p,w);
	}
	int query(int k,int l,int r,int ll,int rr)
	{
		if(l>rr||r<ll||!k)return 0;
		if(l>=ll&&r<=rr)return sum[k];
		return pl(query(ch[k][0],l,l+r>>1,ll,rr),query(ch[k][1],(l+r>>1)+1,r,ll,rr));
	}
}l,r;
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%d",&x[i]);
	for(int i=1;i<=m;++i)scanf("%d",&y[i]);
	int last=1;
	while(last<=n&&x[last]<y[1])++last;
	for(int i=2;i<=m;++i)
	{
		int r=last;
		while(r<=n&&x[r]<y[i])line[i-1].push_back(x[r]-y[i-1]),++r;
		len[i-1]=y[i]-y[i-1];
		last=r;
	}
	for(int i=1;i<m;++i)p[i]=i;
	sort(p+1,p+m,[](int &x,int &y){return len[x]<len[y];});
/*	for(int i=1;i<m;++i)
	{
		printf("%d\n",len[p[i]]);
		for(auto x:line[p[i]])printf("%d ",x);
		printf("\n");
	}*/
	int now=0;
	l.ins(l.rt,0,1000000000,0,1);
	r.ins(r.rt,0,1000000000,0,1);
	for(int i=1;i<m;++i)
	{
		now=len[p[i]];
		for(auto x:line[p[i]])
		{
			int cur=pl(l.query(l.rt,0,1000000000,0,x-1),mod-r.query(r.rt,0,1000000000,now-x,1000000000));
			l.ins(l.rt,0,1000000000,x,cur);
			r.ins(r.rt,0,1000000000,now-x,cur);
		}
	}
	printf("%d",l.sum[1]);
	return 0;
}


Measured memory_bytes: 41980
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace::std;
using ll = long long;
int main() {
    ll A,B,C,X,Y,a,b,c;
    cin >> A >> B >> C >> X >> Y;
    ll price = 1e15;
    for (ll c=2*max(X,Y);c>=0;c--){
        a = max({X-(c/2),ll(0)}); 
        b = max({Y-(c/2),ll(0)});
        ll tmp = A*a+B*b+C*c;
        price = min(tmp,price);
    }
    cout << price << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	string a, b, c;
	cin >> n >> a >> b >> c;
	int answer = 0;
	for(int i = 0; i < n; ++i){
		array<int, 3> t = { a[i], b[i], c[i] };
		sort(t.begin(), t.end());
		if(t[0] == t[2]){
		}else if(t[0] == t[1] || t[1] == t[2]){
			answer += 1;
		}else{
			answer += 2;
		}
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 256
package main

import "fmt"


func draw(h int, w int) {
	for i := 0; i < h; i++ {
		tmp := ""
		for j := 0; j < w; j++ {
			tmp += "#"
		}
		fmt.Println(tmp)
	}
}
func main() {
	var H, W int
	var ans[10000][2] int
	var n int

	for n = 0; n != -1; n++ {
		fmt.Scan(&H, &W)

		if H == 0 && W == 0 {
			break
		}

		ans[n][0] = H
		ans[n][1] = W
	}

	for i := 0; i < n; i++ {
		draw(ans[i][0], ans[i][1])
		fmt.Println("")
	}
}


Measured memory_bytes: 4356
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


struct Node{
  int key;
  struct Node *l,*r,*p;
};

void insert(int );
void inorder(struct Node *);
void preorder(struct Node *);
struct Node *find(struct Node *,int);

struct Node *root,*NIL;

int main(){
  int n,i,h;
  struct Node *a;
  char x[10];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    strcpy(x,"");
    scanf("%s",x);
    if(0==(strcmp(x,"print"))){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(0==(strcmp(x,"insert"))){
      scanf("%d",&h);
      insert(h);
    }else if(0==(strcmp(x,"find"))){
      scanf("%d",&h);
      a=find(root,h);
     if(a==NIL) printf("no\n");
      else       printf("yes\n");
    }  
     }
    return 0;
  }


void insert(int k){
  struct Node *x=root,*y=NIL,*z;

  z=(struct Node *)malloc(sizeof(struct Node));

  z->key=k;
  z->l=NIL;
  z->r=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->l;
    else    x=x->r;
  }
  z->p=y;
  if(y==NIL) root=z;
  else{
    if(z->key < y->key) y->l=z;
    else  y->r=z;
  }
}

void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(struct Node *u){
  if(u==NIL) return ;
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

struct Node *find(struct Node *a,int k){
  while(1){
    if(a->key==k) break;
    if(k < a->key && a->l !=NIL) a=a->l;
    else if(k > a->key && a->r!=NIL)   a=a->r;
    else return NIL;
   }
  return a;
    }



Measured memory_bytes: 20448