akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, T) = Read2Longs();
            var c = new long[N];
            var t = new long[N];
            for (int i = 0; i < N; i++)
            {
                (c[i], t[i]) = Read2Longs();
            }

            var min = long.MaxValue;
            for (int i = 0; i < N; i++)
            {
                if (t[i] <= T)
                {
                    min = Math.Min(min, c[i]);
                }
            }

            return min == long.MaxValue ? "TLE" : min.ToString();
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28284
N = int(input())
A = [int(i) for i in input().split()]

import numpy as np
A = np.array(sorted(A))

while(True):
    A[1:] %= A[0]
    A = np.unique(A)
    A = np.delete(A, np.where(A == 0))
    if len(A) == 1:
        break

    A.sort()

print(A[0])


Measured memory_bytes: 21660
#include<iostream>
using namespace std;
/*
int SelctionSort(int a[],int n)
{
    int times=0;
    for(int i=0;i<n-1;i++)
        for(int j=i+1;j<n;j++)
                if(a[i]>a[j])
                {
                    swap(a[i],a[j]);
                    times++;
                }
    return times;
}
*/
int SelectionSort(int a[],int n)
{
	int times=0,minj,j;
	for(int i=0;i<n;i++)
	{
		minj=i;
		for(j=i;j<n;j++)
			if(a[j]<a[minj])
				minj=j;
		if(minj!=i)
		{
			swap(a[minj],a[i]);
			times++;
		}
	}
	return times;
}
int main()
{
    int a[100];
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int times = SelectionSort(a,n);
    for(int i=0;i<n-1;i++)
        cout<<a[i]<<' ';
    cout<<a[n-1]<<endl;
    cout<<times<<endl;
    return 0;
}

Measured memory_bytes: 3096
from collections import deque

n, qt = map(int, input().split())
que = deque()
for i in range(n):
    name, time = input().split()
    que.append((name, int(time)))

elapsedtime = 0
while que:
    name, time = que.popleft()
    if time <= qt:
        elapsedtime += time
        print(name, elapsedtime)
    else:
        elapsedtime += qt
        time -= qt
        que.append((name, time))

Measured memory_bytes: 14888
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pair<int,int>> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define ri(a) scanf("%d", &a)
#define rii(a,b) scanf("%d %d", &a, &b)
#define riii(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define rl(a) scanf("%lld", &a)
#define rll(a,b) scanf("%lld %lld", &a, &b)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second

const int INF = 0x3f3f3f3f;
const ll LLINF = 1e18;
const int maxN = 700; // CAMBIAR ESTE

// GJNM
int v,e;
int N;
vi g[maxN];
bool adj[maxN][maxN];

int color[maxN];
vector<pii> bvw;
bool ans;

void dfs(int v, int c, pii &cont){
	if ( c == 0 )
		cont.f++;
	else
		cont.s++;

	color[v] = c;
	for(int w : g[v]){
		if ( color[w] == -1 )
			dfs(w, 1-c, cont);
		else
			if ( color[v] == color[w] )
				ans = false;
	}
}


bool vis[maxN][2*maxN+1];
int dp[maxN][2*maxN+1];

int f(int i, int dif){
	if ( i == N )
		return abs(dif);
	if ( vis[i][dif+maxN] )
		return dp[i][dif+maxN];
	vis[i][dif+maxN] = true;
	int &ret = dp[i][dif+maxN];
	
	ret = min( f(i+1, dif+bvw[i].s-bvw[i].f), f(i+1, dif+bvw[i].f-bvw[i].s) );
	return ret;
}

int main(){
	rii(v,e);
	FOR(i,0,e){
		int v1, v2;
		rii(v1, v2);
		v1--;
		v2--;
		adj[v1][v2] = adj[v2][v1] = true;
	}

	FOR(i,0,v)
		FOR(j,0,v)
			if (!adj[i][j] && i!=j){
				g[i].pb(j);
				g[j].pb(i);
			}

	FOR(i,0,v)
		color[i] = -1;
	ans = true;

	FOR(i,0,v)
		if ( color[i] == -1 ){
			pii aux = {0,0};
			dfs(i, 0, aux);
			if ( !ans ){
				printf("-1\n");
				return 0;
			}
			bvw.pb(aux);
		}
	
	N = bvw.size();

	int ans = f(0,0);

	int v1 = ans;
	int v2 = 0;
	while( v1+v2 < v){
		v1++;
		v2++;
	}

	printf("%d\n",v1*(v1-1)/2 + v2*(v2-1)/2 );

	return 0;
	
}

Measured memory_bytes: 6016
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#include <map>
using namespace std;

map<int, int> bfs(int source, vector<vector<int>>& nei)
{
    deque<int> q;
    q.push_front(source);
    map<int, int> visited_dist;
    visited_dist[source] = 0;
    while (q.size())
    {
        int node = q[0];
        q.pop_front();
        for (auto& node2: nei[node])
        {
            if (visited_dist.find(node2) == visited_dist.end())
            {
                visited_dist[node2] = visited_dist[node] + 1;
                q.push_back(node2);
            }
        }
    }
    return visited_dist;
}


int main()
{
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> sol(n, 0);

    vector<vector<int> > nei(n+1, vector<int>());
    for  (int source = 2; source <= n; source++)
    {
        (nei[source]).push_back(source-1);
        nei[source-1].push_back(source);
    }
    nei[x].push_back(y);
    nei[y].push_back(x);
    for (int source = 1; source <= n; source++)
    {
        map<int, int> visited_dist = bfs(source, nei);
        for (auto& p: visited_dist)
        {
            sol[p.second]++;
        }
    }
    for (int k = 1; k < n; k++)
        cout << sol[k]/2 << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

int main()
{
    long long n, k;
    cin >> n >> k;
    long long ans = 0;
    if (k == 1) {
        ans = n * n * n;
    } else if (k % 2 == 1) {
        ans = (n / k) * (n / k) * (n / k);
    } else {
        ans += (n / k) * (n / k) * (n / k);
        if (n >= k / 2) {
            ans += ((n - (k / 2)) / k + 1) * ((n - (k / 2)) / k + 1) *
                   ((n - (k / 2)) / k + 1);
        }
    }
    cout << ans << endl;
}

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

typedef long long int ll;

int main()
{
    ll n;
    cin >> n;
    vector<ll> x(n), xt(n);
    for(ll i = 0;i < n;i++){
        cin >> x[i];
        xt[i] = x[i];
    }

    sort(xt.begin(),xt.end());
    ll t = xt[n / 2 - 1], t2 = xt[n / 2];

    for(ll i = 0;i < n;i++){
        if(x[i] > t){
            cout << t << "\n";
        }
        else{
            cout << t2 << "\n";
        }
    }
    
    return 0;
}

Measured memory_bytes: 5376
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; scanf("%d", &___T); for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr int mod = 1e9+7;
int n , a[maxn], b[maxn], c[maxn], dp[maxn][3];
int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[1][1] = a[1],dp[1][2] = b[1],dp[1][3]=c[1];
    for(int i = 2; i <= n; i++){
        dp[i][1] = a[i]+max(dp[i-1][2],dp[i-1][3]);
        dp[i][3] = c[i]+max(dp[i-1][2],dp[i-1][1]);
        dp[i][2] = b[i]+max(dp[i-1][1],dp[i-1][3]);
    }
    cout << max(max(dp[n][1],dp[n][2]),dp[n][3]) <<endl;
}

Measured memory_bytes: 7552
#ifndef __cplusplus
    cat << EOF
#endif
#include <bits/stdc++.h>
using namespace std;

#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()

template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if(lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if(lhs > rhs) { lhs = rhs; return 1; } return 0; }

int main() {

    cout << "square1001\n";

}



Measured memory_bytes: 2908
#include <iostream>

int num = 0;
int n=1,x=1;

void task();

int main(){
    while(1){
        std::cin >> n >> x;
        if(n!=0 || x!= 0){
            task();
        } else {
            break;
        }
    }
}

void task(){
    for(int a = 1;a <= n;a++){
        for(int b = a+1;b <= n;b++){
            for(int c = b+1;c<= n;c++){
                if (a+b+c == x){
                    num++;
                    //std::cout << a << " " << b << " " << c << std::endl;
                }
            }
        }
    }
    std::cout << num << std::endl;
    num=0;
}




Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
#define ls (rt << 1)
#define rs (rt << 1 | 1) 
typedef pair<int, int> pii; 
const ll mod = 1e9 + 7;
template <class T> T lowbit(T x){return ((x)&(-(x)));}
const int maxn = 2e5 + 10;
ll calc(ll x) { return x * x * x * x * x;}
ll x;
ll a[maxn];
int main()
{
	cin >> x;
	for(int i = -500; i <= 500; ++i) a[i + 500] = calc(i);
	for(int i = 1; i <= 1000; ++i)
		for(int j = i + 1; j <= 1000; ++j)
			if(a[j] - a[i] == x)
			{
				cout << j - 500 << ' ' << i - 500 << endl;
				return 0;
			}
	return 0;
}

Measured memory_bytes: 3632
import math

cook = []
for i in range (5):
    cook.append(int(input()))

times = 0
# mod10が最小のもの(0除く)を最後にすれば最小？
min_10 = []
for c in range(len(cook)):
    min_10.append((cook[c] - 1) % 10)  # 0覗いて最小になるように、cookから1引いたもののmod10を比較

min_index = min_10.index(min(min_10))
total_time = 0
for c in range(len(cook)):
    if min_index == c:
        continue
    else:
        total_time += int(math.ceil(cook[c] / 10) * 10)
total_time += cook[min_index]

print(total_time)


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll LL_MAX=LLONG_MAX;

struct In{
    template<typename T>
    operator T(){
        T x;
        cin >> x;
        return x;
    }
};
In in;

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

template <typename T>
void out(T x){
    cout << x << endl;
}

template <typename T>
T gcd(T x,T y){
    if (y == 0) return x;
    return gcd(y,x%y);
}

template <typename T>
T lcm(T x,T y){
    return x*y/gcd(x,y);
}

int main(){
    int h=in,n=in,a[n],b[n];
    for (int i=0;i<n;i++) {
        a[i]=in;
        b[i]=in;
    }
    int dp[h+1];
    for (int i=0;i<h+1;i++) dp[i]=INT_MAX/2;
    dp[0]=0;
    for (int i=1;i<h+1;i++){
        for (int i2=0;i2<n;i2++){
            dp[i]=min(dp[i],b[i2]+dp[max(i-a[i2],0)]);
        }
    }
    out(dp[h]);
}

Measured memory_bytes: 256
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	inputN = parseInt(input[0]);
	inputS = input[1].split("");

	cnt = 0;
	if(inputN > 0){
		cnt ++;
	}
	for(var i=0;i < inputN -1;i++){
		if (inputS[i] !== inputS[i + 1]){
			cnt ++;
		}
	}
	console.log(cnt);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 8268
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll n,k;
    cin>>n>>k;
    if((n+k)%2) cout<<"IMPOSSIBLE";
    else cout<<(n+k)/2;
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    string s;
    cin >> s;
    
    string res;
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) == '0') res += "0";
        else if (s.at(i) == '1') res += "1";
        else {
            if (s.size() != 0) res.pop_back();
        }
    }
    
    cout << res << endl;
    
    return 0;
}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

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

/*

	Optimizer

*/
//#pragma GCC optimize("Ofast")


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

  int A,B,C;
  cin >> A >> B >> C;

  if(A == B) {
    cout << C << endl;
  }
  else if (B == C) {
    cout << A << endl;
  }
  else {
    cout << B << endl;
  }
  

  return 0;
}


Measured memory_bytes: 256
count = 0
data = []
while True:
  count += 1
  h, x = map(int,(input().split()))
  data.append([h, x])
  if x == 0 and h == 0:
    break
for i in range(count-1):
  h, x = data[i]
  for j in range(1, h+1):
    ans = ""
    if j % 2 == 0:
      for k in range(1, x+1):
        if k % 2 == 0:
          ans += "#"
        else:
          ans += "."
    else:
      for k in range(1, x+1):
        if k % 2 == 0:
          ans += "."
        else:
          ans += "#"
    print(ans)
  print("")


Measured memory_bytes: 5628
n, x = (int(x) for x in input().split())
if x == 1 or x == 2 * n - 1:
    print("No")
    exit()

if n == 2:
    print("Yes")
    print(1)
    print(2)
    print(3)
    exit()

if x == 2:
    y = [3, 2, 1, 4]
else:
    y = [x - 1, x, x + 1, x - 2]

ANS = []
i = 1
while i < 2 * n:
    if len(ANS) == 2 * n - 1:
        break
    if i in y:
        i += 4
    if len(ANS) == n - 3:
        ANS += y
        if len(ANS) == 2 * n - 1:
            break
    ANS.append(i)
    i += 1

print("Yes")
for ans in ANS:
    print(ans)


Measured memory_bytes: 87252
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        char[] list=sc.nextLine().toCharArray();
        int n=list.length;
        while(n-->0) {
            System.out.print(list[n]);
        }
        System.out.println();
        sc.close();
    }
}


Measured memory_bytes: 26052
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=100000000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;
typedef pair<int,string> Q;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
//void swap(ll a,ll b){
//	ll d;
//	d=a;
//	a=b;
//	b=d;
//	return;
//}
ll mypow(ll x,int m){
	if(m==0)return 1;
	if(m%2==0){
		int x2=mypow(x,m/2);
		return x2*x2;
	}else{
		int x2=mypow(x,m/2);
		return x2*x2*x;
	}
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
//    	cout<<b<<endl;
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll total=0;
int a[200000],b[200000];
int n;
int m;
int c[100005]={};
string s;
vector<P> v[200001];
int ans[100005]={};
int main() {
	cin>>n>>m>>s;
	int si=1,x=1;
	rep(i,1,n+1){
		if(s[i]=='0'){
			c[si-1]=x;
			++si;
			x=1;
		}else{
			x++;
		}
	}
//	rep(i,0,si)cout<<c[i]<<" ";
//	cout<<endl;
	int i=si-1,ansi=0;
	x=0;
	while(i+1){

		if(c[i]>m){
			cout<<-1<<endl;
			return 0;
		}
		if(x+c[i]>m){
			ans[ansi]=x;
			x=c[i];
			ansi++;
		}else{
			x+=c[i];
		}
		i--;
	}
	ans[ansi]=x;
	for(int i=ansi;i>0;--i){
		cout<<ans[i]<<" ";
	}
	cout<<ans[0]<<endl;
	return 0;
}


Measured memory_bytes: 6784
def modpow(val, n, mod):
    ret = 1
    while n:
        if n & 1:
            ret = (ret * val) % mod
        val = (val * val) % mod
        n = n >> 1
    return ret


mod = 10 ** 9 + 7
n, k = map(int, input().split())

my_dict = dict()
ret = 0

for i in range(k, 0, -1):
    tmp = modpow(k // i, n, mod)
    cnt = 2
    while True:
        val = i * cnt
        if val > k:
            break
        else:
            cnt += 1
            tmp -= my_dict[val]
    my_dict[i] = tmp
    ret += tmp * i % mod

print(ret % mod)


Measured memory_bytes: 20596
from collections import Counter
N = int(input())
data = {num:x for num, x in Counter(map(int,input().split())).items() if x >= 2}
data_num = sorted(list(data.keys()), reverse=True)
if len(data) < 1:
    print(0)
elif data[data_num[0]] >= 4:
    print(data_num[0]**2)
elif len(data) < 2:
    print(0)
else:
    print(data_num[0]*data_num[1])


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 10000
i64 N;


int main() {
  cin >> N;
  i64 cnt = 0;
  i64 digit = 1;
  i64 base = 10;
  REPS(i, N) {
    if (i % base == 0) {
      digit++;
      base *= 10;
    }
    if (digit % 2 == 1) cnt++;
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 201
int n;
int a[MAX];

void init(int n){
int i;
for(i=0;i<2*n;i++){
a[i]=i+1;
}
}

void shaffle(){
    int i;
    int temp[MAX];
     
    for(i=0;i<n;i++){
        temp[i*2]=a[i];
    }
    for(i=0;i<n;i++){
        temp[i*2+1]=a[n+i];
    }
    for(i=0;i<2*n;i++){
        a[i]=temp[i];
    }
}
void cut(int k){
    int i;
    int temp[MAX];
    for(i=0;i<2*n-k;i++){
        temp[i]=a[k+i];
    }
    for(i=0;i<k;i++){
        temp[2*n-k+i]=a[i];
    }
    for(i=0;i<2*n;i++){
        a[i]=temp[i];
    }
}

int main(){
int m,k,i;
scanf("%d\n",&n);
init(n);
scanf("%d\n",&m);
for(i=0;i<m;i++){
scanf("%d\n",&k);
if(k==0)shaffle();else cut(k);
}
for(i=0;i<2*n;i++){
printf("%d\n",a[i]);
}
return 0;
}

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

int main(){
  string divide[4] = {"dream", "dreamer", "erase", "eraser"};
  string S;
  cin >> S;
  reverse(S.begin(), S.end());
  for (int i=0;i<4;i++){
    reverse(divide[i].begin(), divide[i].end());
  }

  int flg = 0;
  int cnt = 0;
  while (flg == 0){
    flg = 1;
    for (int i=0;i<4;i++){
      int size = divide[i].size();
      if (S.substr(0,size)==divide[i]){
        flg = 0;
        S = S.substr(size);
      }
    }
  }
  if (S.size() > 0){
    cnt = 1;
  }
  if (cnt == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
using namespace std;

int main(){
    int n;
    int r;
    int g;
    int b;
    cin >> r >> g >> b >> n;
    int res = 0;
    for (int i = 0; i < n/r+1; i++){
        for(int j = 0; j < (n-(i*r))/g+1; j++){
            if((n-(r*i)-(g*j))%b == 0){
                res++;
            }                     
        }
    }
    cout << res;
}
    // for (int i = 0; i < ; i++){
        
    // }


Measured memory_bytes: 256
#include "iostream"
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
string s,t;
std::cin >> s;
t=s;
int l=s.size();

for(int i=0; i<l; i++){
  for(int j=0; j<l; j++){
    if(s[i]==t[j] && i!=j) {printf("no\n"); return 0;}
  }
}

printf("yes\n");
  
  return 0;
}


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

long long n, a;
long long ans = 0;
long long x[55];
long long dp[55][55][3000];

int main() {
	cin >> n >> a;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < 55; i++) {
		for (int j = 0; j < 5; j++) {
			for (int k = 0; k < 3000; k++) {
				dp[i][j][k] = 0ll;
			}
		}
	}
	dp[0][0][0] = 1ll;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n*a; k++) {
				if (dp[i][j][k] == 0) {
					continue;
				}
				dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
				dp[i + 1][j][k] += dp[i][j][k];
			}
		}
	}
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		ans += dp[n][i+1][a*(i+1)];
	}
	cout << ans << endl;
	return 0;
}

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


Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <cstring>
#include <cctype>
#include <stdio.h>
using namespace std;

int main(){
    while(1){
        char word[1000] = "word";
        cin >> word;
        int check;
        check = word[0] - '0';
        if (check == 0) break;
        else{
            int total = 0, length = strlen(word);
            for(int i=0; i < length; i++){
                int num;
                num = word[i] - '0';
                total += num;
            }
            cout << total << endl;
        }
    }
    return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    // 累積和
    vector<ll> s(N+1, 0); // s[0] = 0 になる
    for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];
    ll res = INF;
    Rep(i, 1, N){
        res = min(res, abs(s[i] - (s[N]-s[i])));
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

using namespace std;

char room[25][25] = {'#'};

int walk(int x, int y) {
    int ret = 1;
    room[y][x] = '#';
    if (room[y-1][x] == '.') ret += walk(x, y-1);
    if (room[y+1][x] == '.') ret += walk(x, y+1);
    if (room[y][x-1] == '.') ret += walk(x-1, y);
    if (room[y][x+1] == '.') ret += walk(x+1, y);
    return ret;
}

int main() {
    int W, H;
    while (cin >> W >> H, W || H) {
        int x, y;
        for (int i=0; i<25; ++i) {
            for (int j=0; j<25; ++j) {
                room[i][j] = '#';
            }
        }
        for (int i=1; i<=H; ++i) {
            for (int j=1; j<=W; ++j) {
                cin >> room[i][j];
                if (room[i][j] == '@') {
                    room[i][j] = '.';
                    y = i, x = j;
                }
            }
        }
        cout << walk(x, y) << endl;
    }
    return 0;
}

Measured memory_bytes: 1176
import sys
sys.setrecursionlimit(10**7)
n = int(input())

def dfs(s, mx):
  if len(s) == n:
    print(s)
  else:
    for i in range(mx):
      dfs(s+chr(ord("a")+i), mx)
    dfs(s+chr(ord("a")+mx), mx+1)
    
dfs("a", 1)

Measured memory_bytes: 4404
while True: 
  a = int(input()) 
  if a == 0: 
    break 
  count = 0 
  while a != 1: 
    if a % 2 == 0: 
      a //= 2 
      count += 1 
    else: 
      a = (a * 3) + 1 
      count += 1 
  print(count) 

Measured memory_bytes: 7496
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
const ll MOD=1e9+7;
using namespace std;

// dp[a][b][c][d]
// a: 桁数
// b: 後ろから3文字目の値
// c: 後ろから2文字目の値
// d: 後ろから1文字目の値
ll dp[102][4][4][4] = {};

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

  //初期化
  for(int num=0;num<=2;num++){
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
        for(int k=0;k<4;k++){
          dp[num][i][j][k] = 0;
        }
      }
    }
  }
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      for(int k=0;k<4;k++){
        dp[3][i][j][k] = 1;
      }
    }
  }
  dp[3][0][1][2] = 0;
  dp[3][1][0][2] = 0;
  dp[3][0][2][1] = 0;

  for(int num=3;num<=N;num++){
    for(int a=0;a<4;a++){
      for(int b=0;b<4;b++){
        for(int c=0;c<4;c++){
          dp[num][a][b][c] %= MOD;
          for(int key=0;key<4;key++) {
            if(b==0 && c==1 && key == 2) continue;
            if(b==1 && c==0 && key == 2) continue;
            if(b==0 && c==2 && key == 1) continue;
            if(a==0 && c==1 && key == 2) continue;
            if(a==0 && b==1 && key == 2) continue;
            dp[num+1][b][c][key] += dp[num][a][b][c];
          }
        }
      }
    }
  }

  ll ans = 0;
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      for(int k=0;k<4;k++){
        ans += dp[N][i][j][k];
        ans %= MOD;
      }
    }
  }
  cout << ans << endl;
}


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

int main(){
	
	//fastio
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin>>n;
	int curr=0,prev,a,maxx=0;
	cin>>prev;
	for(int i=1;i<n;i++){
		cin>>a;
		if(a<=prev){
			curr++;
		}
		else {
			curr=0;
		}
		prev=a;
		maxx = max(curr, maxx);
	}
	cout<<maxx<<endl;
	return 0;
}

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

using namespace std;

void solve()
{
	int n;
	cin >> n;

	if (n % 2 == 0)
	{
		cout << (n / 2)*(n / 2) << endl;
	}
	else
	{
		cout << (n / 2 + 1)*(n / 2) << endl;
	}
}

int main()
{

	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define WHITE 0
#define GLAY 1
#define BLACK 2

// 頂点の個数
int n;
// 隣接行列
vector<vector<int> > M(100, vector<int>(100, 0));
// 頂点の状態を格納する配列
vector<int> color(100, WHITE);
// 発見時刻を格納する配列
vector<int> d(100);
// 完了時刻を格納する配列
vector<int> f(100);
// 時刻
int tt = 0;

// 再帰的にu(WHITEと仮定)をスタートして探索
void dfs_visit(int u)
{
  // uの状態を訪問済みにする
  color.at(u) = GLAY;
  // uの発見時刻を記録
  d.at(u) = ++tt;
  // uの隣接頂点(小さい順に)探索
  for (int v = 0; v < n; v++)
  {
    if (M.at(u).at(v) == 0)
    {
      // vがuの隣接頂点でないとき
      // このループをスキップ
      continue;
    }
    if (color.at(v) == WHITE)
    {
      // vがuの隣接頂点であり、かつ未発見のとき
      // vをスタートとして探索
      dfs_visit(v);
    }
  }
  // uの隣接頂点の状態が全て完了になっているのでuの状態も完了にする
  color.at(u) = BLACK;
  // uの完了時刻を記録
  f.at(u) = ++tt;
}

// 全ての頂点を探索
void dfs()
{
  for (int i = 0; i < n; i++)
  {
    if (color.at(i) == WHITE)
    {
      dfs_visit(i);
    }
  }
}

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    int u, k;
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; j++)
    {
      int v;
      cin >> v;
      v--;
      M.at(u).at(v) = 1;
    }
  }

  dfs();

  for (int i = 0; i < n; i++)
  {
    cout << i + 1 << " " << d.at(i) << " " << f.at(i) << endl;
  }
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<n;i++)
using namespace std;
using ll=long long;
using P = pair<int,int>;
int main(){
    int N;
    cin >> N;
    int ans=1000;
    for(int i=0;i<=N;i++){
        int a=0;
        int s=i;
        while(1){
            a+=s%9;
            s=s/9;
            if(s==0)break;
        }
        s=N-i;
        while(1){
            a+=s%6;
            s=s/6;
            if(s==0)break;
        }
        ans=min(ans,a);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
/**
   Solution by Abil
**/
# include <bits/stdc++.h>

# define fr first
# define sc second
# define pb push_back
# define mk make_pair
# define sz(s) s.size()
# define all(s) s.begin(),s.end()
# define int long long

using namespace std;

const long long N = (1e6 + 10);
const long long mod = (1e9 + 7);
const long long inf = (1e9 + 7);

int dp[1003][1003];
char arr[1003][1003];
main()
{
    ios_base::sync_with_stdio(0); 
    cin.tie(0);cout.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 1;i <= n; i++){
    	for(int j = 1;j <= m; j++){
    		cin >> arr[i][j];
    	}
    }
    dp[1][1] = 1;
    for(int i = 1;i <= n; i++){
    	for(int j = 1;j <= m; j++){
    		if(arr[i][j] != '#'){
    			dp[i][j] += dp[i - 1][j] + dp[i][j - 1];
    			dp[i][j] %= mod;
    		}
    	}
    }
    
    cout << dp[n][m];
}


Measured memory_bytes: 9088
IDENTIFICATION DIVISION.
PROGRAM-ID. 134B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP PIC X(10).
01 N   PIC S9(2).
01 D   PIC 9(2).
01 K   PIC 9(2).
01 OUT PIC Z9.
*>
PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO N D.
  MOVE 0 TO K.
  PERFORM UNTIL N <= 0
    COMPUTE N = N - (D * 2 + 1)
    ADD 1 TO K
  END-PERFORM.
*>
  MOVE K TO OUT.
  DISPLAY OUT.
*>
  STOP RUN.
      

Measured memory_bytes: 384
N,M=map(int,input().split());C=[[0]*-~N for _ in range(N+1)];D=list(map(list,C));S=[input()for _ in range(N)];r=0
for t in range(M-1):
	for i in range(1,N+1):
		for j in range(1,N+1):C[i][j]=C[i-1][j-1]+int(S[i-1][t]==S[j-1][t+1]);D[i][j]=min(D[i-1][j],D[i][j-1])+C[i][j]
	r+=D[N][N]
print(r)

Measured memory_bytes: 46572
#include <iostream>
#include <string>
#define optimizar_io ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int main()
{
    optimizar_io;
    int cont=0;
    string yolo;
    cin>>yolo;
    for(int i=0;i<(int)yolo.size()-1;++i){
        if( (yolo[i]=='W' && yolo[i+1]=='B') || (yolo[i]=='B' && yolo[i+1]=='W') ){cont++;}
    }
    cout<<cont<<endl;
    return 0;
}


Measured memory_bytes: 512
require 'pp'

# f = Fcational.new(max, MOD)
# f.at(10) #=> 10! (mod MOD)
# f.inv(10) #=> (10!)^(-1) (mod MOD)

class Fractional
    attr_reader :mod

    def initialize(max, mod)
        @max = max
        @mod = mod
        @frac     = { 0 => 1, 1 => 1 }
        @frac_inv = { 0 => 1, 1 => 1 }
        @inv      = {         1 => 1 }

        pre_calc(max)
    end

    def pre_calc(max)
        2.upto(max) do |i|
            @frac[i] = @frac[i - 1] * i % @mod;
            @inv[i] = @mod - @inv[@mod % i] * (@mod / i) % @mod
            @frac_inv[i] = @frac_inv[i - 1] * @inv[i] % @mod
        end
    end

    def at(i)
        @frac[i]
    end

    def inv_at(i)
        @frac_inv[i]
    end
end

# precalc_fraciotnalを使う前提
# f = Fcational.new(max, mod)
# c = Combination.new(f)
# c.calc(n, r)

class Combination
    def initialize(fraction)
        @fraction = fraction
    end

    def calc(n, r)
        return 0 if n < r
        return 0 if (n < 0 || r < 0)

        denom_inv = (@fraction.inv_at(r) * @fraction.inv_at(n - r) % @fraction.mod)
        return @fraction.at(n) * denom_inv % @fraction.mod
    end
end

MOD = 10 ** 9 + 7
s = gets.to_i

if s < 3
    puts 0
    exit 0
end

f = Fractional.new(10000, MOD)
c = Combination.new(f)

# 最高で軟膏つかえるか
x = s / 3
sum = 1 # i = 1は必ず1個

2.upto(x) do |i|
    t = s - i * 3
    #pp t
    # iHt = (t+i-1)Ct
    #pp c.calc(t+i-1, t)
    sum = (sum + c.calc(t+i-1, t)) % MOD
end

puts sum


Measured memory_bytes: 15848
#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;

int n;
int h[100010];

int dp[100010];


int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> h[i];
    for(int i = 0;i<n;i++) dp[i] = INT_MAX;
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for (int i = 1; i < n-1; ++i) {
        dp[i+1] = min(dp[i] + abs(h[i] - h[i+1]),dp[i-1] + abs(h[i-1] - h[i+1]));
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a) - 1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i -  1) * 10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}
 
struct IoSetup {
  	IoSetup() {
    	cin.tie(nullptr);
    	ios::sync_with_stdio(false);
    	cout << fixed << setprecision(15);
  	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

ll n, m, d;

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

	double ans = 0;
	if (d == 0) ans = (double)(m - 1) / n;
	else ans = (double)(2 * (n - d) * (m - 1)) / (n * n);
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3724
//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
//use 1LL<<i to for 64 bit shifting , (ll)2 because by default 2 is ll
//take care of precedence rule of operators 
//do not forget to change the sizes of arrays and value of contants and other things after debugging  
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define ld long double
#define pi acos(-1.0)
 
#define SZ(x)  (ll)(x.size())
 
//comment the below if not required
 
/*
 
#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second
*/
 
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main()
{

    string s;

    cin>>s;

    ll ans = 0;

    for(auto u : s)
    {
        ans += u-'0';
    }

    if(ans%9)
        cout<<"No";
    else
        cout<<"Yes";


    return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n),b(n);
	map<int,int> ma,mb;
	for(int i=0;i<n;i++){
		cin >> a[i];
		ma[a[i]]++;
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
		mb[b[i]]++;
	}
	vector<pair<int,int>> v;
	for(auto &p:mb){
		if(ma.count(p.first)){
			if(p.second+ma[p.first]>n){
				cout << "No" << endl;
				return 0; 
			}
			v.push_back({min(p.second,ma[p.first]),p.first});
			p.second-=v.back().first;
		}
	}
	sort(v.rbegin(), v.rend());
	int sum=0;
	for(int i=0;i<v.size();i++){
		sum+=v[i].first;
	}
	map<int,vector<int>> mv;
	if(v.size()&&v[0].first*2>sum){
		// cout << "No" << endl;
		// return 0;
		int cnt=0;
		for(auto p:mb){
			if(p.first==v[0].second)continue;
			cnt+=p.second;
		}
		if(2*v[0].first-sum>cnt){
			cout << "No" << endl;
		}
		else{
			cout << "Yes" << endl;
			int noko=2*v[0].first-sum;
			vector<int> free;
			for(auto &p:mb){
				if(p.first==v[0].second)continue;
				if(p.second)mv[v[0].second].push_back(p.first);
				p.second--;
				noko--;
				free.push_back(v[0].second);
				if(noko==0)break;
			}
			vector<int> vv;
			for(int i=0;i<v.size();i++){
				if(i==0){
					for(int j=0;j<sum-v[0].first;j++){
						vv.push_back(v[i].second);
					}
				}
				else{
					for(int j=0;j<v[i].first;j++){
						vv.push_back(v[i].second);
					}
				}
			}
			int uo=sum-v[0].first;
			for(int j=0;j<vv.size();j++){
				mv[vv[j]].push_back(vv[(j+uo)%vv.size()]);
			}
			for(auto p:mb){
				for(int j=0;j<p.second;j++){
					free.push_back(p.first);
				}
			}
			for(int i=0;i<n;i++){
				if(mv[a[i]].size()){
					cout << mv[a[i]].back() << " ";
					mv[a[i]].pop_back();
				}
				else{
					cout << free.back() << " ";
					free.pop_back();
				}
			}
			cout << endl;
		}
		return 0;
	}
	cout << "Yes" << endl;
	vector<int> free;
	vector<int> vv;
	if(v.size()){
		for(int i=0;i<v.size();i++){
			if(0){
				for(int j=0;j<sum-v[0].first;j++){
					vv.push_back(v[i].second);
				}
			}
			else{
				for(int j=0;j<v[i].first;j++){
					vv.push_back(v[i].second);
				}
			}
		}
		int uo=v[0].first;
		for(int j=0;j<vv.size();j++){
			mv[vv[j]].push_back(vv[(j+uo)%vv.size()]);
		}
	}
	for(auto p:mb){
		for(int j=0;j<p.second;j++){
			free.push_back(p.first);
		}
	}
	for(int i=0;i<n;i++){
		if(mv[a[i]].size()){
			cout << mv[a[i]].back() << " ";
			mv[a[i]].pop_back();
		}
		else{
			cout << free.back() << " ";
			free.pop_back();
		}
	}
	cout << endl;
}


Measured memory_bytes: 47860
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  lint n, l, t; cin >> n >> l >> t;
  V<lint> x(n), w(n); for (int i = 0; i < n; i++) cin >> x[i] >> w[i];
  V<lint> res(n);
  for (int i = 0; i < n; i++) res[i] = ((x[i] + (3 - 2 * w[i]) * t) % l + l) % l;
  sort(res.begin(), res.end());
  lint c = 0;
  for (int i = 1; i < n; i++) if (w[i] != w[0]) {
    c += 2 * t / l + (w[0] == 1 ? (x[i] - x[0] < 2 * t % l) : (l - x[i] + x[0] <= 2 * t % l));
  }
  c %= n;
  int s;
  for (int i = 0; i < n; i++) if (res[i] == ((x[0] + (3 - 2 * w[0]) * t) % l + l) % l) {
    s = i;
    break;
  }
  for (int i = 0; i < n; i++) cout << res[(w[0] == 1 ? i - c + s + n : i + c + s) % n] << '\n';
}

Measured memory_bytes: 3584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	static int max=200000;	//nCr の n の最大値?
	static long MOD=1000000007;
	static long[] fac=new long[max];
	static long[] finv=new long[max];
	static long[] inv=new long[max];
	public static void main(String[] args){
		COMinit();		//下ごしらえ
		SC sc=new SC(System.in);
		long sum=0;
		int H=sc.nextInt();
		int W=sc.nextInt();
		int A=sc.nextInt();
		int B=sc.nextInt();
		long[] wake=new long[H-A];
		for(int i=0; i<H-A; i++) {
			wake[i]=COM(B-1+i,i);
		}
		for(int i=0; i<H-A; i++) {
			wake[i]*=COM(W-B+H-2-i,H-1-i);
			wake[i]%=MOD;
		}
		for(int i=0; i<H-A; i++) {
			sum+=wake[i];
			sum%=MOD;
		}
		pl(sum);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	static void COMinit() {		//テーブルを作るみたい nCrの　または　階乗の？
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for (int i = 2; i < max; i++){
			fac[i] = fac[i - 1] * i % MOD;
			inv[i] = MOD - inv[(int)(MOD%i)] * (MOD / i) % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}
	static long COM(int n, int k){			//二項係数の計算
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}
}

Measured memory_bytes: 26964
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			if(i*j==n){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define re register
#define ull unsigned ll
using namespace std;
inline int read(){
	int s=0,t=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*t;
}
const int N=505;
int n,P,Ans,f[N][N],q[N];
struct Node{int l,r;}p[N];
bool cmp(int x,int y){
	if(p[x].l==p[y].l)return x>y;
	return p[x].l<p[y].l;
}
int Mod(int x){return x>=P?x-P:x;}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read(),P=read();
	for(int i=0,l=0,r=0;i<2*n;i++){
		for(l=0;i*i+l*l<n*n;l++);
		for(r=l;i*i+(r+1)*(r+1)<=4*n*n&&r+1<2*n;r++);
		if(i<n)p[i]=(Node){l-1,r};
		else p[i]=(Node){r,l};q[i+1]=i;
	}sort(q+1,q+2*n+1,cmp);
	for(int k=0;k<=n;k++){
		f[0][0]=1;
		for(int i=1,t=0;i<=2*n;i++){
			int l=p[q[i]].l,r=p[q[i]].r;
			if(l>r)swap(l,r);
			for(int j=0;j<=min(i,k);j++){
				if(q[i]>=n)f[i][j]=1ll*f[i-1][j]*max(0,r+1-(i-1-(t-j)))%P;
				else{
					int t1=1ll*f[i-1][j]*max(0,r+1-(2*n-1-q[i]+(k-j)))%P;
					int t2=1ll*(j>=1?f[i-1][j-1]:0)*max(0,l+1-(i-1-(t-(j-1))))%P;
					f[i][j]=Mod(t1+t2);
				}
			}t+=(q[i]<n);
		}
		Ans=Mod(Ans+1ll*(k&1?P-1:1)*f[2*n][k]%P);
	}printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 4724