akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int T,A,B,C,D,K;
inline bool check(int x)
{
	if(x==0)return 1;
	if(x%(K+1)==0)x--;
	int Nb=x/(K+1);
	int Na=x-Nb;
	return B-Nb<=1ll*(A-Na+1)*K;
}
int main()
{
	file();
	read(T);
	while(T--)
	{
		read(A),read(B),read(C),read(D);
		K=(max(A,B)-1)/(min(A,B)+1)+1;
		int l=0,r=A+B,ans=0;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if(check(mid))ans=mid,l=mid+1;
			else r=mid-1;
		}
		l=ans;
		For(i,C,D)
		if(i<=l)putchar(i%(K+1)?'A':'B');
		else putchar((A+B+1-i)%(K+1)?'B':'A');
		puts("");
	}
	return 0;
}


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

int main(void){
   int N;
   cin>>N;
   vector<long long> A(N);
   for(int i=0;i<N;i++){
      cin>>A[i];
   }
   int Q;
   cin>>Q;
   vector<long long> B(Q),C(Q);
   for(int i=0;i<Q;i++){
      cin>>B[i]>>C[i];
   }
   map<long long,long long> cnt;
   for(int i=0;i<N;i++){
      cnt[A[i]]++;
   }
   long long sum=0;
   for(int i=0;i<N;i++){
      sum+=A[i];
   }
   for(int i=0;i<Q;i++){
      sum+=C[i]*cnt[B[i]]-B[i]*cnt[B[i]];
      cnt[C[i]]=cnt[C[i]]+cnt[B[i]];
      cnt[B[i]]=0;
      cout<<sum<<endl;
   }
   return 0;
}


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

struct pyst {
    int no;
    int p;
    int y;
    char ans[13];
};

bool comp1(const pyst& a, const pyst& b) {
    if (a.p != b.p) {
        return(a.p < b.p);
    }
    return(a.y < b.y);
}

bool comp2(const pyst& a, const pyst& b) {
    return(a.no < b.no);
}

int main()
{
    int n,m;
    int ans1, ans2;

    cin >> n >> m;
    vector<pyst> py(m);
    rep(i, m) {
        py[i].no = i;
        cin >> py[i].p >> py[i].y;
    }
    sort(py.begin(), py.end(), comp1);
    ans1 = ans2 = 0;
    rep(i,m) {
        if (py[i].p != ans1) {
            ans1 = py[i].p;
            ans2 = 1;
        }
        else {
            ++ans2;
        }
        sprintf(py[i].ans, "%06d%06d", ans1, ans2);
    }
    sort(py.begin(), py.end(), comp2);
    rep(i, m) {
        printf("%s\n", py[i].ans);
    }

    return(0);
}


Measured memory_bytes: 5884
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n,x;
  cin >> n >> x;
  vector<LL> a(n);
  for(LL &x:a) cin >> x;
  vector<LL> b(a.begin(),a.end());
  b.insert(b.begin(),0);
  REP(i,n) b[i+1] += b[i];
  cout << upper_bound(b.begin(),b.end(),x) - b.begin() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cins(int, 3, a);
    Cout((a[0] + a[1] >= a[2]) ? "Yes" : "No");
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>
#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

//#define solvsh
//#define multi
#ifdef solvsh

void solve(){

}

#else


bool is_palin(string s){
    int n = s.length();
    for (int i = 0; i < n; ++i){
        if (s[i] != s[n - 1 - i])
            return false;
    }

    return true;
}

void solve() {

    string s;
    cin >> s;

    int n = s.length();
    int ln = (n - 1)/2;

    if (is_palin(s) && is_palin(s.substr(0, ln)) && is_palin(s.substr(1 + n/2, ln)))
    {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case #" << (i++)  << ": ";
        solve();
//        cout << "\n";
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif

#ifdef LOCAL
    //cout << '\n' << (double)clock() / CLOCKS_PER_SEC << '\n';
#endif
}

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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll 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;
	}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint power(ll x, ll n) {
	mint ret = 1;
	while(0 < n){
		if((n % 2) == 0){
			x *= x;
			n >>= 1;
		}else{
			ret *= x;
			--n;
		}
	}
	return ret;
}

vector<pair<ll, int>> prime_factorization(ll n) {
	vector<pair<ll, int>> res;
	for(ll i = 2; i * i <= n; i++){
		if(n % i) continue;
		res.emplace_back(i, 0);
		while(n % i == 0){
			n /= i;
			res.back().second++;
		}
	}
	if(n != 1) res.emplace_back(n, 1);
	return res;
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	map<int, int> m;
	rep(i, n) {
		auto now = prime_factorization(a[i]);
		
		for(auto t: now) {
			int x = t.first;
			int p = t.second;
			if(m[x] < p) m[x] = p;
		}
	}
	mint ans = 0;
	mint mx = 1;
	for(auto t: m) {
		int x = t.first;
		int p = t.second;
		mx *= power(x, p);
	}
	
	rep(i, n) {
		ans += mx/a[i];
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include <cstdio>

int min(int a, int b) { return (a > b ? b : a); }
int max(int a, int b) { return (a > b ? a : b); }

int main() {
    int n, t;
    scanf("%d", &n);
    int arr[9] = { 0 };
    for (auto i = 0; i < n; i++) {
        scanf("%d", &t);
        arr[min(t / 400, 8)]++;
    }
    t = 0;
    for (auto i = 0; i < 8; i++) if (arr[i]) t++;
    printf("%d %d\n", max(t, 1), t + arr[8]);

    return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	double width = scan.nextDouble();	
      	double height = scan.nextDouble();
      	double x = scan.nextDouble();
      	double y = scan.nextDouble();
      	int mi = 0;
      	System.out.print(width * height / 2.0);
      	if(width == 2 * x && height == 2 * y) {
        	mi = 1;
        }
      	System.out.print(" " + mi);
    
    }
 
 
}

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

int main(){
    int A, B, C, K;
    std::cin >> A >> B >> C >> K;
    
    int cnt = 0;
    if(A >= K){
        cnt = K;
        K = 0;
    }else{
        cnt = A;
        K -= A;
    }
    
    if(B >= K){
        K = 0;
    }else{
        K -= B;
    }
    
    cnt -= K;
    
    
    std::cout << cnt << std::endl;
    
    
    return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <stdio.h>
#define ff(i,x,y)for(int i=x;i<y+1;i++)
#define fs(i,x,y)for(int i=x;i>y-1;i--)
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
using namespace std;
long long pre[200010],ans=1e16;
int main()
{
    int n;
    scanf("%d",&n);
    ff(i,1,n)
    scanf("%lld",&pre[i]);
    ff(i,1,n)
    pre[i]+=pre[i-1];
    ff(i,1,n-1)
    {
        long long d;
        d=pre[i]-(pre[n]-pre[i]);
        if(d<0)
        d=-d;
        ans=min(d,ans);
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int zero=0, one=0;
  string s;
  cin >> s;
  
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '0') zero++;
    else one++;
  }
  
  cout << min(zero,one)*2;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#define INF 1000000013
using namespace std;
typedef long long ll;
ll mod=1e9+7;
ll dp[102][100010];
ll sum[102][100010];

int main(){
  ll n,k;
  cin >> n >> k;
  ll a[n];
  for(ll i=0;i<n;i++) cin >> a[i];
  dp[0][0]=1;
  for(ll i=0;i<=k;i++) sum[0][i]=1;
  for(ll i=1;i<=n;i++){
    for(ll j=0;j<=k;j++){
      dp[i][j]+=sum[i-1][j];
      if(j-a[i-1]>0) dp[i][j]-=sum[i-1][j-a[i-1]-1];
      dp[i][j]=(dp[i][j]+mod)%mod;
      sum[i][j]=(sum[i][j-1]+dp[i][j])%mod;
    }
  }
  cout << dp[n][k] << endl;
}

Measured memory_bytes: 158976
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n,k = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	chk = zeros(Int,n)
	now = 1
	ct = 0
	cs = 0
	cl = 0
	while chk[now]==0
		chk[now]=1
		now=a[now]
		ct+=1
	end
	cs = now
	now = a[now]
	cl += 1
	while now!=cs
		now=a[now]
		cl+=1
	end
	if k<ct
		now = 1
		for i in 1:k
			now=a[now]
		end
		println(now)
	else
		k=(k-ct)%cl
		now = cs
		for i in 1:k
			now=a[now]
		end
		println(now)
	end
end

main()

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

int main() {
    string S; cin >> S;
    vector<string> pat = {"erase", "eraser", "dream", "dreamer"};
    for(auto &s : pat) {
        reverse(s.begin(), s.end());
    }

    int piv = 0, N = S.length();
    reverse(S.begin(), S.end());
    while(piv < N) {
        bool ok = false;
        for(auto p : pat) {
            int len = p.length();
            string T = S.substr(piv, len);
            if(T == p) {
                ok = true;
                piv += len;
                break;
            }
        }

        if(!ok) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define INF 999999999
using namespace std;

int main(){
    int n; cin >> n;
    int a[n];
    rep(i, 0, n) cin >> a[i];

    SORT(a, n);

    //rep(i, 0, n) cout << "sort" << a[i] << endl;

    int A = 0;
    int B = 0;

    if(n % 2 == 0){
        rep(i, 0, n){
            if(i % 2 == 1) A += a[i];
            else B += a[i];
        }
    }
    else{
        rep(i, 0, n){
            if(i % 2 == 1 and i != 0) B += a[i];
            else A += a[i];
        }
    }

    cout << A - B << 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 pair<int, int> P;

int n, q, cnt[202020];
vector<vector<int>> tree(202020, vector<int>(0));
bool visited[202020];

void dfs(int i){
  visited[i] = true;
  for(int x : tree.at(i)){
    if(visited[x]) continue;
    cnt[x] += cnt[i];
    dfs(x);
  }
  return;
}

int main(){
  cin >> n >> q;
  rep(i, n - 1){
    int a, b;
    cin >> a >> b;
    tree.at(a).push_back(b);
    tree.at(b).push_back(a);
  }
  for(int i = 1; i <= n; i++){
    for(int x : tree.at(i)){
      cerr << x << " ";
    }
    cerr << endl;
  }
  
  rep(i, n + 1) cnt[i] = 0;
  rep(i, q){
    int p, x;
    cin >> p >> x;
    cnt[p] += x;
  }
  rep(i, n) cerr << cnt[i + 1] << " "; cerr << endl;
  
  dfs(1);
  
  for(int i = 1; i < n; i++){
    cout << cnt[i] << " ";
  }
  cout << cnt[n] << endl;
  return 0;
}


Measured memory_bytes: 20608
# frozen_string_literal: true

n, k, s = gets.split.map(&:to_i)

if k == n
  puts ([s] * n).join(' ')
  exit
end

if s == 1
  a = [s] * k + [1000000000] * (n - k)
  puts a.join(' ')
  exit
end
p = s / 2
q = s - p

a = [p]

1.upto(k) do |i|
  if i.odd?
    a.push q
  else
    a.push p
  end
end

max = 1000000000

max = 1 if s == max

(n - k - 1).times do
  a.push max
end

puts a.join(' ')


Measured memory_bytes: 4860
fun main(args: Array<String>) {
    /*readLine()で一行分の入力をString型として受け取り（"!!"でnull非許容に）
    split()で空白区切りにパースし
    map{}でInt型に変換して各変数に代入する
    */
    val (a) = readLine()!!.split(" ").map{ it.toInt() }
    
    print(a * 2 * 3.141592)
}


Measured memory_bytes: 36588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

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

/**
 * エラストテネスのふるい(n以下の素数を列挙する)
 */
vector<int> sieve(int n) {
    vector<int> res;
    vector<bool> is_prime(n + 1, true);
    // 0と1は素数ではない
    is_prime[0] == false; is_prime[1] == false;

    for (int i = 2; i <= n; i++) {
        if (!is_prime[i]) continue;
        res.push_back(i);
        for (int j = 2 * i; j <= n; j += i) {
            is_prime[j] = false;
        }
    }

    return res;
}

vector<int> generateMiniFactor(int n) {
    vector<int> res(n + 1, -1);
    vector<bool> is_prime(n + 1, true);
    is_prime[0] == false; is_prime[1] == false;

    for (int i = 2; i <= n; i++) {
        if (!is_prime[i]) continue;
        res[i] = i;
        for (int j = i * 2; j <= n; j += i) {
            if (!is_prime[j]) continue;
            is_prime[j] = false;
            res[j] = i;
        }
    }
    return res;
}

int main() {
    const int A_MAX = 1000005;

    int N; cin >> N;
    vi A(N); rep(i, N) cin >> A[i];
    bool ok = true;

    // 1
    vi mf = generateMiniFactor(A_MAX);

    map<int, int> G;
    rep(i, N) {
        int x = A[i];

        set<int> ss;

        while (x != 1) {
            ss.insert(mf[x]);
            x /= mf[x];
        }
        for (auto sss : ss) {
            G[sss]++;
        }
    }

    for (auto x : G) {
        if (x.second > 1) {
            ok = false;
            break;
        }
    }

    if (ok) {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    // 2
    ok = true;
    int y = A[0];
    rep(i, N - 1) {
        y = gcd(y, A[i + 1]);
        if (y == 1) break;
    }
    if (y != 1) ok = false;
    if (ok) {
        cout << "setwise coprime" << endl;
        return 0;
    }

    cout << "not coprime" << endl;
}


Measured memory_bytes: 14660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        System.out.println(s.next().charAt(0)+""+s.next().charAt(0)+""+s.next().charAt(0));


    }



}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25372
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int mx = 0;
    int g = a[0];
    rep(i, n) {
        if (a[i] == k) {
            puts("POSSIBLE");
            return 0;
        }
        chmax(mx, a[i]);
        g = gcd(g, a[i]);
    }
    if (k <= mx && k % g == 0) puts("POSSIBLE");
    else puts("IMPOSSIBLE");
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int x = 0, ans = 0;
  for (auto &i : s) {
    if (i == 'I') x++;
    else x--;
    ans = max(ans, x);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 3600
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  rrep(i, 1, n + 1) {
    if (i % 2 == 0) continue;
    cnt = 0;
    rrep(j, 1, i + 1) {
      if (i % j == 0) cnt++;
    }
    if (cnt == 8) ans++;
  }
  Cout(ans);
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    
    int answer = 0;

    for(int i=0; i<3; i++) {
        
        if(s.at(i) == '1')
        answer++;
    }

    cout << answer << endl;
    
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <map>
#include <set>
#include <queue>

#define LL long long

using namespace std;

const int MOD = 1000000007, N = 100000+10;

bool prime[N];
int sum[N];

void gg()
{
	puts("No");
	exit(0);
}

int main()
{
	//freopen("test_in.txt", "r", stdin);
	//freopen("test_out.txt", "w", stdout);
	prime[2] = true;;
	for(int i = 3; i <= 100000; i++)
	{
		prime[i] = true; 
		for(int j = 2; j*j <= i; j++)
			if(i%j==0)	prime[i] = false;
	}
	sum[0] = 0;
	for(int i = 1; i <= 100000; i++)
		if(prime[i] && prime[(i+1)/2])
			sum[i] = sum[i-1]+1;
		else
			sum[i] = sum[i-1];
	int n;
	scanf("%d", &n);
	while(n--)
	{
		int l, r;
		scanf("%d%d", &l, &r);
		printf("%d\n", sum[r]-sum[l-1]);
	}
	return 0;
}


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

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  double sum = 0.0;
  for (int i = 0; i < n; i++) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY") {
      sum += x;
    } else {
      sum += x * 380000.0;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++)
       cin >> v[i];
    int dp[n];
    dp[0] = 0;
    for(int i = 1; i < n; i++)
    {
        if(i == 1)
            dp[i] = dp[i-1] + abs(v[i]-v[i-1]);
        else
        {
            dp[i] = min( dp[i-1] + abs(v[i] - v[i-1]) , dp[i-2] + abs(v[i] - v[i-2]) );
        }
    }
    cout << dp[n-1];
}


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

int main() {
    int r, g, b, n; cin >> r >> g >> b >> n;
    int ans = 0;
    for(int i = 0; i <= 3000; ++i) {
        for(int j = 0; j <= 3000; ++j) {
            const int m = n - i * r - j * g;
            if(m >= 0 && m % b == 0) {
                ans += 1;
            }
        }
    }
    cout << ans << endl;
}


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

const long long INF = 1LL << 60;
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; }

typedef long long ll;
#define vl vector<ll>
#define vll vector< vector<ll> >
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)

int N, W;
ll w[110], v[110];
ll dp[110][110000];

int main() {
	cin >> N >> W;
	rep1(i, N+1) cin >> w[i] >> v[i];

	rep1(i, N+1) {
		rep(j, W+1) {
			chmax(dp[i][j], dp[i - 1][j]);
			if (j - w[i] >= 0)
				chmax(dp[i][j], dp[i - 1][j - w[i]] + v[i]);

		}
	}

	cout << dp[N][W] << endl;

}


Measured memory_bytes: 87424
#include<iostream>
using namespace std;
int main(){
    int m, f, r;
    
    while(1){
        cin >> m >> f >> r;
        if(m==-1 && f==-1 && r==-1){
            break;
        }else if(m==-1 || f==-1){
            cout << "F" << endl;
        }else if(m+f>=80){
            cout << "A" << endl;
        }else if(m+f>=65){
            cout << "B" << endl;
        }else if(m+f>=50){
            cout << "C" << endl;
        }else if(m+f>=30){
            if(r>=50){
                cout << "C" << endl;
            }else{
                cout << "D" << endl;
            }
        }else{
            cout << "F" << endl;
        }
    }
    
    return 0;
}


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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> an(N);
    for (int i = 0; i < N; i++) {
        cin >> an[i];
    }
    sort(an.begin(), an.end());
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (i == 0 && an[i] > 0) ans -= an[0];
        else if (i == N-1 && an[i] < 0) ans += an[N-1];
        else ans += abs(an[i]);
    }
    cout << ans << endl;
    for (int i = N-2; an[i] >= 0 && i > 0; i--) {
        cout << an[0] << " " << an[i] << endl;
        an[0] -= an[i];
    }
    for (int i = 1; an[i] < 0 && i < N-1; i++) {
        cout << an[N-1] << " " << an[i] << endl;
        an[N-1] -= an[i];
    }
    cout << an[N-1] << " " << an[0] << endl;
}


Measured memory_bytes: 3768
w,h,x,y = map(int, input().split())

side = (x == 0 or x == w or y == 0 or y == h \
    or y/x == h/w or y == -h/w * x + h \
    or x != w/2 or y != h/2) \
    and not (x == w/2 and y == h/2)
area = w * h

print(area/2, int(not side))


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

int main(){
    int W,H,x,y;
    cin >> W >> H >> x >> y;
    double w = W;
    double h = H;
    cout << (w * h) / 2 << ' ';

    if (W % 2 == 0 && H % 2 == 0){
        if(x == W/2 && y == H/2){
            cout << 1 << endl;
        }
        else{
            cout << 0 << endl;
        }
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>

#define int long long

using namespace std;

const int N = 2e5 + 10;

int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
    char c;
    cin >> c;
    if (c >= 'A' && c <= 'Z') cout << "A";
    else cout << "a";
    return 0;
}

Measured memory_bytes: 3648
N = int(input())
H = list(map(int, list(input().split())))

count_best, count_tmp = 0, 0

for i in range(N-1):                                                                                                                                                                                        
    if H[i] >= H[i+1]:                                                                                                                                                                                      
        count_tmp += 1                                                                                                                                                                                      
    else:                                                                                                                                                                                                   
        if count_tmp > count_best:                                                                                                                                                                          
            count_best = count_tmp                                                                                                                                                                          
                                                                                                                                                                                                            
        count_tmp = 0                                                                                                                                                                                       

if count_tmp > count_best:                                                                                                                                                                                  
    count_best = count_tmp                                                                                                                                                                                  

print(count_best)

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

int main()
{
	int N;
	string W;
	cin >> N >> W;
	set<string> used = { W };
	char c = W.back();
	bool ok = true;
	for (int i = 1; i < N; i++) {
		cin >> W;
		ok &= !(W.front() != c || used.count(W));
		c = W.back();
		used.insert(W);
	}
	puts(ok ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int w, n, ans[31];
	cin >> w >> n;
	for (int i = 0; i <= 30; i++)
		ans[i] = i;
	for (int i = 0; i < n; i++) {
		int a, b;
		char c;
		cin >> a >> c >> b;
		swap(ans[a], ans[b]);
	}
	for (int i = 1; i <= 30; i++)
		cout << ans[i] << endl;
}


Measured memory_bytes: 3088
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#define ll long long
#define ull unsigned long long
#define mp make_pair

using namespace std;
int n,k;
int main()
{
    cin >> n >> k;
    if(n%k==0)
        cout << 0 << endl;
    else
        cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> Pa;
typedef pair<int, pair<int, int> > PP;
//const int MAX=;

int N, K;
int R, S, P;
string T;

void input(){
	cin>>N>>K;
	cin>>R>>S>>P;
	cin>>T;
}

void solve(){
	int ans = 0;
	rep(i ,K){
		int lr=0, ls=0, lp=0;
		for(int j = i; j<N; j+=K){
			if(T[j]=='r'){
				int tr, ts, tp;
				tr = max(ls, lp);
				ts = max(lp, lr);
				tp = P + max(lr, ls);
				lr = tr;
				ls = ts;
				lp = tp;
			}
			if(T[j]=='s'){
				int tr, ts, tp;
				tr = R + max(ls, lp);
				ts = max(lp, lr);
				tp = max(lr, ls);
				lr = tr;
				ls = ts;
				lp = tp;
			}
			if(T[j]=='p'){
				int tr, ts, tp;
				tr = max(ls, lp);
				ts = S + max(lp, lr);
				tp = max(lr, ls);
				lr = tr;
				ls = ts;
				lp = tp;
			}
		}
		int t = max(lr, max(ls, lp));
		ans += t;
	}
	cout<<ans<<endl;
}

void output(){
  
}

int main(){
  input();
  solve();
  output();
}

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



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

  bool flag=true;
  for(int k=0;k<K && flag;++k){
    flag=false;

    for(int i=0;i<N;++i){
      ++ch[max(i-A[i],0)];
      --ch[min(i+A[i]+1,N)];
    }

    for(int j=1;j<N;++j){
      ch[j] = min(N,ch[j]+ch[j-1]);
    }

    for(int i=0;i<N;++i){
      if(A[i]!=ch[i]) flag=true;
      A[i]=ch[i];
      ch[i]=0;
    }

    //if(!flag) cout<<k<<endl;
  }

  for(int i=0;i<N;++i) cout<<A[i]<<" ";
}


Measured memory_bytes: 4844
from collections import defaultdict, deque, Counter
def inpl(): return list(map(int, input().split()))

R, G, B, N = inpl()
ans = 0
for r in range(N//R + 1):
    for g in range(N//G + 1):
        tmp = N - R*r - G*g
        if tmp < 0:
            break
        if (tmp%B == 0):
            ans += 1
print(ans)


Measured memory_bytes: 3316
import sys
from collections import deque,defaultdict

I=sys.stdin.readline

def ii():
	return int(I().strip())
def li():
	return list(map(int,I().strip().split()))

def mi():
	return map(int,I().strip().split())


def main():
	ans=""
	n,k=mi()
	arr=li()
	a=0
	for i in range(n-k):
		tmp=arr[k+i]
		if tmp>arr[a]:
			ans+="Yes\n"
		else:
			ans+="No\n"
		a+=1
	print(ans)








		


		










		






if __name__ == '__main__':
	main()

Measured memory_bytes: 32512
la = 10**5+10
#la = 100

A = [1 for i in range(la)]
A[0] = 0
A[1] = 0
for i in range(2, int(la**0.5) + 2) :
    j = 2
    while j*i <= len(A)-1 :
        A[j*i] = 0
        j += 1
#print(A)

q = int(input())
L = [list(map(int, input().split())) for i in range(q)]

B = [0 for i in range(la)]

for i in range(3, la) :
    if A[i] == 1 and A[(i+1)//2] == 1 :
        B[i] += 1
#print(B)

for i in range(1, len(B)) :
    B[i] += B[i-1]


for i in range(q) :
    print(B[L[i][1]] - B[L[i][0]-1])


Measured memory_bytes: 31956
#include<iomanip>
#include<iostream>
using namespace std;
int main(){   
    string s;
    cin>>s;
    for(int i=0;s[i]!='\0';i++){
        if(s[i]=='A'&&s[i+1]=='C'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
n, k = map(int,input().split())
p_l = list(map(int,input().split()))

expected = []
for val in p_l:
    expected.append((val+1)/2)

tmp = 0
for i in range(k):
    tmp += expected[i]
ans = tmp

for i in range(k,n):
    tmp -= expected[i-k]
    tmp += expected[i]
    ans = max(ans, tmp)

print(ans)

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int>> PP;


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

const ll MOD = 1000000007;
const ll INF = 1000000000;

int h[105];
ll ans = 0;



int main(void){
    int n, m;
    int x[100010], s[100010];
    ll ans = 0;
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        cin >> x[i];
    }
    sort(x, x + m);
    for (int i = 0; i < m - 1; i++){
        s[i] = x[i + 1] - x[i];
        ans += s[i];
    }
    m--;
    sort(s, s + m);
    n--;
    for (int i = m; i >= max(0, m - n); i--) ans -= s[i];
    cout << ans << endl;

}



Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>
#include<map>
#include<queue>

bool Three()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		char s;
		scanf(" %c", &s);
		if (s == 'Y') return false;
	}
	return true;
}

int main()
{
	if (Three()) printf("Three\n");
	else printf("Four\n");

	return 0;
}

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

#define num_max(p,q)((p)>(q)?(p):(q))
#define num_min(p,q)((p)<(q)?(p):(q))
int cmp(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;//昇順
	 //降順ならreturn *(int*)b - *(int*)a;
}
double kaijou(int n)
{
	int x=1;
	while (n > 1) { x *= n;n--; }
	return x;
}
int main()
{
	int N;
	int x[10],y[10];
	double ans=0.0;
	scanf("%d",&N);
	for (int i = 0;i < N;i++)scanf("%d%d", &x[i], &y[i]);
	double d = kaijou(N);
	for (int i = 0;i < N;i++)
	{
		for (int j = i+1;j < N;j++)
		{
			ans+=2*d/N* sqrt(pow((x[i] - x[j]), 2) + pow((y[i] - y[j]), 2));
			 
		}
	}
	
	printf("%.10lf\n", ans / d);
	return 0;
}

Measured memory_bytes: 128
import math

def factor(N):
    ans = []
    for i in range(1,int(math.sqrt(N))+1):
        if N%i == 0:
            ans.append(i)
            if N//i != i:
                ans.append(N//i)
    return ans

A,B,N = map(int,input().split())


print(min(N,B-1)*A//B)

Measured memory_bytes: 9188
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::*;
use std::collections::HashSet;

fn main() {
    input! {
        h: usize,
        w: usize,
        target: [(Usize1, Usize1)]
    }

    let mut cnt_h = vec![0; h];
    let mut cnt_w = vec![0; w];
    let mut set: HashSet<(usize, usize)> = HashSet::new();

    for &(y, x) in target.iter() {
        cnt_w[x] += 1;
        cnt_h[y] += 1;
        set.insert((x, y));
    }

    let max_w = cnt_w.iter().max().unwrap();
    let max_h = cnt_h.iter().max().unwrap();
    let mut xs = Vec::new();
    let mut ys = Vec::new();
    for (index, &x) in cnt_w.iter().enumerate() {
        if x == *max_w {
            xs.push(index);
        }
    }
    for (index, &x) in cnt_h.iter().enumerate() {
        if x == *max_h {
            ys.push(index);
        }
    }
    let mut ans = max_w + max_h - 1;
    'exit: for &x in &xs {
        for &y in &ys {
            if !set.contains(&(x, y)) {
                ans += 1;
                break 'exit;
            }
        }
    }

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


Measured memory_bytes: 26336
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<set>
#include<sstream>
#include<cstdlib>
#include<time.h>
#include<math.h>
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define repp(i,n,a) for(int i=n;i>=a;i--)
#define ll long long
#define ull unsign long long
#define ms(x,a) memset(x,a,sizeof(x))
#define lowbit(x) ((x)&(-x))
#define gcd(a,b) __gcd(a,b)
#define inf 0x3f3f3f3f
#define eps 1e-8
#define mod 1e9+7
#define sd(x) scanf("%d",&x)
#define pd(x) printf("%d\n",x)
using namespace std;
const int maxn=1e5+10;
const double pi=acos(-1.0);


ll a[maxn],b[maxn];
ll ans;
int main() {
	ll c1,d1;
	ll a,b,c,d;
	while(scanf("%lld%lld%lld%lld",&a,&b,&c,&d)!=EOF)
	{
		ll t=c*d/gcd(c,d);
		c1=b/c-(a-1)/c;
		d1=b/d-(a-1)/d;
		ans=b-a+1-c1-d1+(b/t-(a-1)/t);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <iomanip>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int n, m, d;
  cin >> n >> m >> d;
  double res;
  if (d == 0) res = (double) (m - 1) / n;
  else res = (double)(m - 1) * 2 * (n - d) / n / n;
  cout << fixed << setprecision(10) << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,a[100004],b[100004],ans;
vector<int> v[100004];
signed main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        if (a[i]>m) {
            continue;
        }
        v[m-a[i]].emplace_back(b[i]);
    }
    priority_queue<int> q;
    for(int i=m-1;i>=0; i--){
        for(int j=0;j<v[i].size();j++){
            q.push(v[i][j]);
        }
        if(q.size()){
            ans+=q.top();
            q.pop();
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9704
using System;

public class Program
{
    private int N;
    private int Ga, Sa, Ba;
    private int Gb, Sb, Bb;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        Ga = sc.NextInt();
        Sa = sc.NextInt();
        Ba = sc.NextInt();
        Gb = sc.NextInt();
        Sb = sc.NextInt();
        Bb = sc.NextInt();
        Console.WriteLine(Calc(Calc(N, Ga, Sa, Ba, Gb, Sb, Bb), Gb, Sb, Bb, Ga, Sa, Ba));
    }

    private long Calc(long n, int ga, int sa, int ba, int gb, int sb, int bb)
    {
        long[] dp = new long[n + 1];
        for (int i = 1; i <= n; i++)
        {
            dp[i] = dp[i - 1] + 1;
            if (i - ga >= 0)
            {
                dp[i] = Math.Max(dp[i], dp[i - ga] + gb);
            }

            if (i - sa >= 0)
            {
                dp[i] = Math.Max(dp[i], dp[i - sa] + sb);
            }

            if (i - ba >= 0)
            {
                dp[i] = Math.Max(dp[i], dp[i - ba] + bb);
            }
        }

        return dp[n];
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 206304
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn min (a: &i64, b: &i64)-> i64{
    if *a <= 0i64 {*b}
    else if *b <= 0i64  {*a}
    else if *a < *b {*a}
    else {*b}
}

fn abs (a: &i64, b: &i64) -> i64{
    if *a - *b <= 0 {*b - *a} else {*a - *b}
}

fn main(){
    input!{
        s: [u64; 5]
    }
    let base = s[0] * s[3] + s[1] * s[4];
    let aba = s[2] * s[3] * 2 + s[1] * (if s[4] < s[3] {0} else {s[4] - s[3]});
    let abb = s[0] * (if s[3] < s[4] {0} else {s[3] - s[4]}) + s[2] * s[4] * 2;
    print!("{}", min(&(base as i64), &min(&(aba as i64), &(abb as i64))));
}


Measured memory_bytes: 4352
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from itertools import permutations

N, M, R = map(int, input().split())
r = list(map(int, input().split()))

g = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    A, B, C = map(int, input().split())
    g[A][B] = C
    g[B][A] = C
g = floyd_warshall(csgraph_from_dense(g))

result = 1000000000
for p in permutations(r):
    t = 0
    for i in range(R - 1):
        t += g[p[i]][p[i + 1]]
    result = min(result, t)
print(int(result))


Measured memory_bytes: 19944
fn main() {
    let s: u64 = read();
    let div = 1000000000;
    let a = (s - 1) / div + 1;
    println!("0 0 {} 1 {} {}", a, a * div - s, div);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352