akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	H, W := sc.nextInt(), sc.nextInt()
	table := make([][]rune, H)
	for i := 0; i < H; i++ {
		arr := sc.nextRuneSlice()
		table[i] = arr
	}
	for i := 0; i < H; i++ {
		all := true
		for j := 0; j < W; j++ {
			if table[i][j] == '#' {
				all = false
			}
		}
		if all {
			for j := 0; j < W; j++ {
				table[i][j] = 'x'
			}
		}
	}
	for i := 0; i < W; i++ {
		all := true
		for j := 0; j < H; j++ {
			if table[j][i] == '#' {
				all = false
			}
		}
		if all {
			for j := 0; j < H; j++ {
				table[j][i] = 'x'
			}
		}
	}
	for i := 0; i < H; i++ {
		exist := false
		for j := 0; j < W; j++ {
			if table[i][j] != 'x' {
				fmt.Fprint(wtr, string(table[i][j]))
				exist = true
			}
		}
		if exist {
			fmt.Fprintln(wtr)
		}
	}

	wtr.Flush()
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <unordered_map>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(int argc, char const *argv[])
{
    ll h;
    cin >> h;
    ll k = (ll)floor(log2(h));

    ll ret = 1;
    for (int i = 0; i < k + 1; i++)
    {
        ret *= 2;
    }
    ret -= 1;

    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
#set
k,s = gets.chomp.split(" ").map(&:to_i)
x = 0
y = 0
z = 0
count = 0

#main
if k <= s then
  0.upto(k) do |i|
    x = i
    0.upto(k) do |j|
      y = j
      z = s - (x + y)
      if z < 0 || z > k then
        next
      else
        count += 1
      end
    end
  end
else
  0.upto(s) do |i|
    x = i
    0.upto(s) do |j|
      y = j
      z = s - (x + y)
      if z < 0 || z > k then
        next
      else
        count += 1
      end
    end
  end
end

print ("#{count}\n")

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d[300][300],n;
string so;
int main()
{
//	freopen("2519.in","r",stdin);
//	freopen("2519.out","w",stdout);
	cin>>a>>n;
	for(int s=0;s<a;s++)
	{
		cin>>so;
		for(int v=0;v<n;v++)
		{
			if(so[v]=='#')
			{
				d[s+1][v+1]=-1;
			}
		}
		
	}
	for(int s=1;s<=a;s++)
	{
		for(int v=1;v<=n;v++)
		{
			if(d[s][v]==0)
			{
				if(d[s-1][v-1]==-1)d[s][v]++;
				if(d[s-1][v]==-1)d[s][v]++;
				if(d[s-1][v+1]==-1)d[s][v]++;
				if(d[s][v-1]==-1)d[s][v]++;
				if(d[s][v+1]==-1)d[s][v]++;
				if(d[s+1][v-1]==-1)d[s][v]++;
				if(d[s+1][v]==-1)d[s][v]++;
				if(d[s+1][v+1]==-1)d[s][v]++;
			}
		}
	}
	for(int s=1;s<=a;s++)
	{
		for(int v=1;v<=n;v++)
		{
			if(d[s][v]==0)
			cout<<0;
			else
			if(d[s][v]==-1)
			cout<<"#";
			else
			cout<<d[s][v];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
import heapq
N,M=map(int,input().split())
A=[-int(i) for i in input().split()]
heapq.heapify(A)
for i in range(M):
  taisho = heapq.heappop(A)
  heapq.heappush(A,-((-taisho)//2))
print(-sum(A))

Measured memory_bytes: 72088
#include <bits/stdc++.h>
using namespace std;
long long n,m;
long long sum;
int main()
{
    while(~scanf("%d%d",&n,&m))
    {
        sum=0;
        sum=n*m;
        long long ans1,ans2;
        if(n==1 && m==1) sum=1;
        else if(m==1 && n!=1)  sum=n-2;
        else if(n==1 && m!=1) sum=m-2;
        else
        {
            if(n-2<=0) ans1=0;
            else ans1=n-2;
            if(m-2<=0) ans2=0;
            else ans2=m-2;
            sum=ans1*ans2;
        }
        printf("%lld\n",sum);
    }
}


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

int L;

vector<int> a;

struct I {
	int amax;
	unordered_map<int,int> pref, suff;
	bool tot_okay;
	int tot_num;
	I() {
		amax = 0;
		pref[0] = 1; suff[0] = 1;
		tot_okay = true;
		tot_num = 0;
	}
};

void level_up(I& v, int a){
	assert(a >= v.amax);
	while(v.amax < a){
		v.amax += 1;
		bool did_something = false;
		unordered_map<int,int> newpref, newsuff;
		for(auto q : v.pref){
			if(q.first == 0){
				newpref[0] += q.second;
			} else if(q.first < L){
				did_something = true;
			} else {
				did_something = true;
				newpref[q.first / L] += q.second;
			}
		}
		for(auto q : v.suff){
			if(q.first == 0){
				newsuff[0] += q.second;
			} else if(q.first < L){
				did_something = true;
			} else {
				did_something = true;
				newsuff[q.first / L] += q.second;
			}
		}
		v.pref = newpref;
		v.suff = newsuff;
		if(v.tot_okay){
			if(v.tot_num == 0){
			} else if(v.tot_num < L){
				did_something = true;
				v.tot_okay = false;
				v.tot_num = 0;
			} else {
				did_something = true;
				v.tot_num /= L;
			}
		}
		if(!did_something) break;
	}
	v.amax = a;
}

long long ans = 0;

vector<int> arr(const unordered_map<int, int> f){
	vector<int> a(f.size(), -1);
	for(pair<int,int> x : f){
		a[x.first] = x.second;
	}
	return a;
}

I combine(I& l, int a, I& r){
	level_up(l, a);
	level_up(r, a);
	assert(a == l.amax);
	assert(a == r.amax);
	I res;
	res.amax = a;
	res.pref = res.suff = {};
	if(l.tot_okay && r.tot_okay){
		res.tot_okay = true;
		res.tot_num = l.tot_num + 1 + r.tot_num;
	} else {
		res.tot_okay = false;
		res.tot_num = 0;
	}
	res.pref = move(l.pref);
	if(l.tot_okay){
		for(auto q : r.pref){
			res.pref[q.first + l.tot_num + 1] += q.second;
		}
	}
	res.suff = move(r.suff);
	if(r.tot_okay){
		for(auto q : l.suff){
			res.suff[q.first + r.tot_num + 1] += q.second;
		}
	}
	vector<int> la = arr(l.suff);
	vector<int> ra = arr(r.pref);
	long long cur = 0;
	cur += 1;
	long long tot = 0;
	int j = (int)ra.size();
	for(int i = 0; i < (int)la.size(); i++){
		while(j > 0 && (j-1) + 1 + i >= L){
			j -= 1;
			tot += ra[j];
		}
		cur += la[i] * tot;
	}
	ans += cur;
	return res;
}


int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n >> L;
	a.resize(n);
	for(int i = 0; i < n; i++) cin >> a[i];

	vector<int> b(n+2);
	vector<int> f(n+2);
	for(int i = 0; i <= n+1; i++){
		b[i] = i-1;
		f[i] = i+1;
	}
	vector<I> data(n+2);
	mt19937 mt(48);
	vector<pair<long long, int> > apos;
	for(int i = 0; i < n; i++){
		apos.push_back({1ll * a[i] * (1e8) + mt() % 100000, i+1});
	}
	sort(apos.begin(), apos.end());
	for(auto _x : apos){
		int x = _x.second;
		f[b[x]] = f[x];
		b[f[x]] = b[x];
		data[b[x]] = combine(data[b[x]], a[x-1], data[x]);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 124400
#include <stdio.h>

int main(void) {

  int sx,sy,tx,ty;
  scanf("%d %d %d %d", &sx, &sy, &tx, &ty);
  for (int i = sy; i < ty; i++) {
    printf("%c", 'U');
  }
  for (int i = sx; i < tx; i++) {
    printf("%c", 'R');
  }
  for (int i = sy; i < ty; i++) {
    printf("%c", 'D');
  }
  for (int i = sx; i <= tx; i++) {
    printf("%c", 'L');
  }
  for (int i = sy; i <= ty; i++) {
    printf("%c", 'U');
  }
  for (int i = sx; i <= tx; i++) {
    printf("%c", 'R');
  }
  printf("%c%c", 'D', 'R');
  for (int i = sy; i <= ty; i++) {
    printf("%c", 'D');
  }
  for (int i = sx; i <= tx; i++) {
    printf("%c", 'L');
  }
  printf("U\n");

  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main (void) {
    int n;
    int v[25], c[25];
    int sum = 0;

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

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

    for (int i=0; i<n; i++) {
       if (v[i] - c[i] > 0) {
           sum += v[i] - c[i];
       }

    }

    cout << sum << endl;

}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
int main(){
  long long int n,k;
  cin>>n>>k;
  long long int s=0,mod=1000000007;
   while (k <= n + 1) {
        s = (s + ((2 * n - k + 1) * k / 2 - (k - 1) * k / 2 + 1) % mod) % mod;
        k++;
    }
  cout<<s;
  return 0;}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
const int maxn=100005,tt=1e9+7;
int hsh[maxn],n,ans;
char s[maxn];
int main(){
    scanf("%d",&n);
    scanf("%s",s+1);
    for (int i=1;i<=n;i++) hsh[s[i]-'a'+1]++;
    ans=1;
    for (int i=1;i<=26;i++) ans=1ll*ans*(hsh[i]+1)%tt;
    ans=(ans+tt-1)%tt;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

ll rui5(ll x) {
    return x*x*x*x*x;
}

int main() {
    ll X;
    ll A, B;
    B = 0;
  	cin >> X;
    while(X + rui5(B-1) > 0) {
        B--;
    }
    while(X + rui5(B) != rui5(A)) {
        A = 1;
        while (X + rui5(B) >= rui5(A)) {
            if (rui5(A) == X + rui5(B)) {
                cout << A << " " << B << endl;
                return 0;
            }
            A++;
        }
        B++;
    }
    cout << A << " " << B << endl;
}


Measured memory_bytes: 3596
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a == b){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35672
from collections import Counter
def main():
    mod=2019
    S=input().strip()
    l=len(S)
    M=[0]*(l+1)
    p=1
    for i in range(1,l+1):
        x=int(S[l-i])
        M[i]=(M[i-1]+x*p)%mod
        p*=10
        p%=mod
    C=Counter(M)
    ans=0
    for m in C.values():
        ans+=m*(m-1)//2
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 70444
#include <iostream>
using namespace std;
#define SIZE 100003

int main() {

	int n;
	int tmp;
	int max1;
	int max2;
	int second1;
	int second2;
	int index1;
	int index2;
	int count1[SIZE] = {0};
	int count2[SIZE] = {0};
	int ans = 0;

	cin >> n;
	for (int i = 0; i < n / 2; i++) {
		cin >> tmp;
		count1[tmp]++;
		cin >> tmp;
		count2[tmp]++;
	}

	// for (int i = 0; i < 10; i++) {
	// 	cout << count1[i] << endl;
	// }
	// cout << endl;
	// for (int i = 0; i < 10; i++) {
	// 	cout << count2[i] << endl;
	// }

	max1 = 0;
	index1 = 0;
	for (int i = 1; i < SIZE; i++) {
		if (max1 < count1[i]) {
			max1 = count1[i];
			index1 = i;
		}
		ans += count1[i];
	}
	count1[index1] = 0;
	second1 = 0;
	for (int i = 1; i < SIZE; i++) {
		if (second1 < count1[i]) {
			second1 = count1[i];
		}
	}

	max2 = 0;
	index2 = 0;
	for (int i = 1; i < SIZE; i++) {
		if (max2 < count2[i]) {
			max2 = count2[i];
			index2 = i;
		}
		ans += count2[i];
	}
	count2[index2] = 0;
	second2 = 0;
	for (int i = 1; i < SIZE; i++) {
		if (second2 < count2[i]) {
			second2 = count2[i];
		}
	}

	if (index1 == index2) {
		// if (max1 > max2) {
		// 	ans -= max1;
		// 	ans -= second2;
		// }
		// else {
		// 	ans -= second1;
		// 	ans -= max2;
		// }
		int tmp1 = max1 + second2;
		int tmp2 = second1 + max2;
		if (tmp1 < tmp2) {
			ans -= tmp2;
		}
		else {
			ans -= tmp1;
		}
	}
	else {
		ans -= max1;
		ans -= max2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,start,end) for(int i=start;i<(int)(end);i++)
#define FORE(i,start,end) for(int i=start;i<=(int)end;i++)
#define RFORE(i,start,end) for(int i = start; i>=end; i--)
#define all(a) a.begin(), a.end()
#define v vector
#define mp make_pair
typedef long long ll;
typedef pair<int, int > pii;
template<class T> void minn(T &a, T b) { a = min(a, b); }
template<class T> void maxx(T &a, T b) { a = max(a, b); }
#define ok(a) 1<=a && a<=12
// B
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	string s;
	cin >> s;
	int a = stoi(s.substr(0,2));
	int b = stoi(s.substr(2,2));
	if(ok(b) && ok(a))
		cout << "AMBIGUOUS\n";
	else if (ok(b))
		cout << "YYMM\n";
	else if (ok(a))
		cout << "MMYY\n";
	else
		cout << "NA\n";
}



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

int main(){
  string s;
  int count;
  cin >> s;
  if(s[0]=='1'){
    count ++;
  }
  if(s[1]=='1'){
    count ++;
  }
  if(s[2]=='1'){
    count ++;
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int X[8][8] =
{
{1,0,1,0,1,0,1,0},
{1,1,1,1,1,1,1,1},
{1,0,1,0,1,0,1,0},
{1,1,1,1,1,1,1,1},
{1,0,1,0,1,0,1,0},
{1,1,1,1,1,1,1,1},
{1,0,1,0,1,0,1,0},
{1,1,1,1,1,1,1,1},
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int a, b, c, d;
	for (int i = 0; i < N; i++) {
		cin >> a >> b >> c >> d;
		int res = 0;
		for (int x = a - 1; x < c; x++) {
			for (int y = b - 1; y < d; y++) {
				res += X[x][y];
			}
		}


		cout << res << endl;
	}
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;

int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        string a,b;
        cin >>a  >> b;
        int n=stoi(a);
        int m=stoi(b);
        string x="";
        string y="";
        for(int i=1; i<=n; i++){
            x=x+b;
        }
        for(int i=1; i<=m; i++){
            y=y+a;
        }
        if(x<y){
            cout << x;
        }
        else{
            cout << y;
        }
     //   trace2(x,y);

        

}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll x=0;
    if(k<a)
    cout<<k;
    else
    {
        ll x=a;
        k=k-a;
        if(k<=b)
        x=x;
        else
        {
            k=k-b;
            x=x-k;
        }
        cout<<x;
    }}

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

int main() {
  	int N;
  	cin >> N;
  	string A[N];
  	for (int i = 0; i < N; i++){
      	cin >> A[i];
    }
  
  	int AC = 0, WA = 0, TLE = 0, RE = 0;
  	for (int i = 0; i < N; i++){
      	if (A[i] == "AC") AC++;
      	if (A[i] == "WA") WA++;
      	if (A[i] == "TLE") TLE++;
      	if (A[i] == "RE") RE++;
    }
  
  	cout << "AC x " << AC << endl;
  	cout << "WA x " << WA << endl;
  	cout << "TLE x " << TLE << endl;
  	cout << "RE x " << RE << endl;
}

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

using namespace std;
using ll = long long;
const int MOD = 1e9+7;


int main(){
    ll N,K;cin >> N >> K;
    ll ans = 0;
    vector<int> vec;
    for(int i = 0;i < N;i++){
        int a;cin >> a;
        vec.push_back(a);
    }
    for(int i = 0;i < N;i++){
        for(int j = 0;j < N;j++){
            if(i == j || vec.at(i) <= vec.at(j))continue;
            //i > j
            if(i < j){
                ans += (K)*(K+1)/2;
            }else{
                ans += (K-1)*(K)/2;
            }
            ans %= MOD;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();

    String ans = "No";
    LABEL:for (int i = 1; i < 10; i++) {
      for (int j = 1; j < 10; j++) {
        if (i * j == n) {
          ans = "Yes";
          break LABEL;
        }
      }
    }
    System.out.println(ans);
  }
}


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

int main() {
  int n; cin >> n;
  int sum = 0;
  vector<int> v(n);
  for (int i=0; i<n; i++){
    cin >> v[i];
  }
  vector<int> c(n);
  for (int i=0; i<n; i++){
    cin >> c[i];
  }
  
  for (int i=0; i<n; i++){
    if(v[i]>c[i]){
      sum += v[i]-c[i];
    }
  }
  cout << sum << endl;
  
    

}

    


Measured memory_bytes: 256
N = input()
digit = len(N)
N = int(N)
cnt=0
if digit == 1:
    cnt = N
elif digit == 2:
    cnt = 9
elif digit == 3:
    cnt = 9
    cnt += N-100+1
elif digit == 4:
    cnt = 909
elif digit == 5:
    cnt = 909
    cnt += N-10000+1
elif digit == 6:
    cnt = 90909
    
print(cnt)

Measured memory_bytes: 3060
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------
 
signed main() {
	tezz

	int l,r,n;
	cin >> l >> r >> n;
	cout << (r/n-(l-1)/n);
 
	return 0;
}  

Measured memory_bytes: 3612
#include <stdio.h>

int main()
{
    int n,m,min=0;
    scanf("%d %d",&n,&m);
    int r[m];
    int l[m];
    int max=n;
    for(int i=0;i<m;i++){
        scanf("%d %d",&l[i],&r[i]);
        min = (min > l[i])?min:l[i];
        max = (max < r[i])?max:r[i];
    }
    int ans = max-min+1;
    if(ans<0) ans = 0;
    printf("%d",ans);
}



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

int main(){
    string S,T;
    cin >> S >> T;
    bool judge = true;
    for(int i = 0; i < S.size(); i++){
        if(S.at(i) != T.at(i)) judge = false; 
    }
    if(judge){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <bitset>

using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	// Absolute
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	// GCD: a > b
	ul gcd(ul a,ul b) { return (!b) ? a : gcd(b,a%b); }
}

int main(int argc,char *argv[])
{
	ll n,m;
	std::cin >> n >> m;

	bool out = false;
	std::vector<ll> arr(n,-1);
	for(ll i = 0;i < m;++i)
	{
		ll s, c;
		std::cin >> s >> c;
		if(arr[s-1] == -1) arr[s-1] = c;
		else if(arr[s-1] != c) out = true;
	}

	if(n != 1 && arr[0] == 0) out = true;
	if(out){ std::cout << -1 << std::endl; return 0; }

	if(n == 1 && m == 0){ std::cout << 0 << std::endl; return 0; }

	for(ll i = 0;i < n;++i)
	{
		if(i == 0 && arr[i] == -1) std::cout << 1;
		else if(arr[i] == -1) std::cout << 0;
		else std::cout << arr[i];
	}
	std::cout << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, a[200010], b[200010];
int ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++)cin >> b[i];
	b[n] = 10000000000;
	for (int i = 28; i >= 0; i--) {
		for (int j = 0; j < n; j++)a[j] %= (1 << (i + 1)), b[j] %= (1 << (i + 1));
		sort(b, b + n);
		int cnt = 0;
		for (int j = 0; j < n; j++) {
			int p = lower_bound(b, b + n + 1, (1 << i) - a[j]) - b;
			int q = lower_bound(b, b + n + 1, 2 * (1 << i) - a[j]) - b;
			cnt += q - p;
			p = lower_bound(b, b + n + 1, 3 * (1 << i) - a[j]) - b;
			q = lower_bound(b, b + n + 1, 4 * (1 << i) - a[j]) - b;
			cnt += q - p;
		}
		if (cnt % 2)ans += (1 << i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
import sys
input = sys.stdin.readline

n, d = map(int,input().split())
C = [list(map(int,input().split())) for i in range(n)]

ans = 0
for i in range(n):
    if C[i][0]**2 + C[i][1]**2 <= d**2:
        ans += 1
print(ans)

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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            Console.WriteLine(str[0] + str[1] / 2);
        }
    }
}


Measured memory_bytes: 13140
# https://abc113.contest.atcoder.jp/tasks/abc113_c

temp = gets.chomp.split(" ").map{|x| x.to_i}
prefecture_count = temp[0]
city_count = temp[1]
prefecture_city_array_database = Array.new().map{Array.new()}

#p prefecture_city_array_database

# 問題文の順番を保存
city_count.times do |i|
   prefecture_city_array_database[i] = gets.chomp.split(" ").map{|x| x.to_i}
   prefecture_city_array_database[i].push(i)
end

#p prefecture_city_array_database

prefecture_city_array_database.sort_by! {|x| [x[0],x[1]]}

#p prefecture_city_array_database

prefecture_number = 1
push_number = 1

# ソート時の順番を保存
city_count.times do |i|

    loop do
        if prefecture_number != prefecture_city_array_database[i][0]
            push_number = 1
            prefecture_number += 1
        else
            break
        end
    end

    prefecture_city_array_database[i].push(push_number)
    push_number += 1
end


prefecture_city_array_database.sort_by! {|x| x[2]}

#p prefecture_city_array_database

city_count.times do |i|
    puts prefecture_city_array_database[i][0].to_s.rjust(6,"0") + prefecture_city_array_database[i][3].to_s.rjust(6,"0")
end

Measured memory_bytes: 37728
let () =
  let rec loop () =
    let a = Scanf.scanf "%d %d %d\n" (fun x y z -> x, y, z) in
    match a with
      | -1, -1, -1 -> []
      | -1, _, _ | _, -1, _ -> 'F' :: loop ()
      | m, f, r -> if m + f >= 80 then 'A' :: loop ()
                   else if m + f >= 65 then 'B' :: loop ()
                   else if m + f >= 50 then 'C' :: loop ()
                   else if m + f < 30 then 'F' :: loop ()
                   else if r >= 50 then 'C' :: loop ()
                   else 'D' :: loop ()
    in
  loop ()
    |> List.map (String.make 1)
    |> String.concat "\n"
    |> Printf.printf "%s\n"

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

arr = []
arr.append(map(int,raw_input().split()))
arr.append(map(int,raw_input().split()))

dp = [[0 for i in range(n)] for j in range(2)]

dp[0][0] = arr[0][0]
for i in range(1,n):
	dp[0][i] = dp[0][i-1] + arr[0][i]

dp[1][0] = dp[0][0] + arr[1][0]

for i in range(1,n):
	dp[1][i] = max(dp[1][i-1] + arr[1][i],dp[0][i] + arr[1][i])

print dp[1][n-1]

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (a > 0) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
    }
  }
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define MOD 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n;
    cin >> n;
    string data;
    cin >> data;
    int r = 0, w = 0;
    int i, j;
    i = 0;
    j = n - 1;
    int count = 0;
    while (i < j)
    {
        if (data[i] != 'W')
            i++;
        if (data[j] != 'R')
            j--;

        if (data[i] == 'W' && data[j] == 'R')
        {
            data[i] == 'R';
            data[j] == 'W';
            i++;
            j--;
            count++;
        }
    }
    cout<<count<<endl;

}


Measured memory_bytes: 3740
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		int count =0;
		String tmp = "0";
		while(in.hasNext())
		{
			char ch[]=in.nextLine().toCharArray();
			for(int i=0; i<ch.length; i++)
			{
				while(i<ch.length&&(ch[i]=='0'||ch[i]=='1'||ch[i]=='2'||ch[i]=='3'||ch[i]=='4'||ch[i]=='5'||ch[i]=='6'||ch[i]=='7'||ch[i]=='8'||ch[i]=='9'))
				{
					tmp+=ch[i];
					i++;
				}
				count+=Integer.valueOf(tmp);
				tmp="0";
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 12000
#!/usr/bin/env python3
import sys
import itertools
import collections
import functools
import math
from queue import Queue
INF = float("inf")

MOD = 1000000007  # type: int

d = {}


def thpow(q):
    if q < 0:
        return 0
    if q == 0:
        return 1
    if q in d:
        return d[q]
    else:
        d[q] = (3*thpow(q-1)) % MOD
        return d[q]


def solve(S: str):
    dp = [0, 0, 0]
    q = 0
    for ch in S:
        a, b, c = dp
        if ch == "A":
            dp = [(a+thpow(q)) % MOD, b, c]
        elif ch == "B":
            dp = [a, (b+a) % MOD, c]
        elif ch == "C":
            dp = [a, b, (c+b) % MOD]
        elif ch == "?":
            dp = [((a*3 % MOD)+thpow(q)) % MOD,
                  ((b*3) % MOD+a) % MOD,
                  ((c*3)+b) % MOD]
            q += 1
        # print(dp)
    # print(dp)

    # print(d)
    print(dp[2])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19096
#include<bits/stdc++.h>
#include<cstdio>
#define MAX 110

int main(){
    int card[4][13] ={{}};// カード種類
    int n=0;
    char mark;
    int number;
    int num = 0;

    scanf("%d",&n);
    num = n;
    for(int i=0;i<num;i++){
        scanf("%s %d", &mark,&number);
        if(mark == 'S'){
            card[0][number-1] = 1;
            
        }else if(mark == 'H'){
            card[1][number-1] = 1;
            
        }else if(mark == 'C'){
            card[2][number-1] = 1;
            
        }else if(mark == 'D'){
            card[3][number-1] = 1;
            
        }
    }
    for(int m=0;m<4;m++){
        for(int n=0;n<13;n++){
            if(card[m][n] == 0){
                if(m == 0){
                    printf("S %d\n",n+1);
                }else if(m == 1){
                    printf("H %d\n",n+1);
                }else if(m == 2){
                    printf("C %d\n",n+1);
                }else if(m == 3){
                    printf("D %d\n",n+1);
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 100000000;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    int k = a[2]-a[1];
    a[0] += k;
    if ((a[2]-a[0])%2){
        PRINT(k+(a[2]-a[0])/2+2);
    }
    else{
        PRINT(k+(a[2]-a[0])/2);
    }
}


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

int main()
{
	int N=100;
	vector<int> v;
	
	cin >> N;
	
	while(1)
	{
		if(N==0)
		{
			if(v.size()==0)v.push_back(0);
			break;
		}
		if(N==1)
		{
			v.push_back(1);
			break;
		}
		v.push_back(abs(N)%2);
		N=((N-(abs(N)%2))/(-2));
	}
	
	for(auto itr=v.rbegin();itr!=v.rend();++itr)
		cout << *itr;
	cout << endl;
	return 0;
}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/a.in", "r", stdin);
//  freopen("../IO/a.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}


void solve(std::istream &in, std::ostream &out) {
  vector<string> vs {"AC", "WA", "TLE", "RE"};
  map<string, int> mp;
  int n;
  in >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    in >> s;
    mp[s]++;
  }
  for (auto str : vs) {
    out << str << " x " << mp[str] << '\n';
  }
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        String[] nums = new String[n];
        if (k <= n) {
            for (int i = 0; i < n; i++) {
                if (i < k) {
                    nums[i] = Integer.toString(s);
                } else {
                    nums[i] = s != 1000000000 ? Integer.toString(s + 1) : "1";
                }
            }
        }

        String result = String.join(" ", nums);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 38364
import itertools
import math

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
p_no, q_no = 0, 0

per = [c+1 for c in range(n)]
per_list = list(itertools.permutations(per))

for i in range(math.factorial(n)):
    if p == per_list[i]:
        p_no = i
    if q == per_list[i]:
        q_no = i

print(abs(p_no - q_no))

Measured memory_bytes: 13768
import sys

def main():
    input = sys.stdin.readline
    S = str(input().strip())

    a = int(S[:2])
    b = int(S[2:])

    if (a > 12 and 0 < b <= 12) or (a == 0 and 0 < b <= 12):
        return 'YYMM'
    elif (0 < a <= 12 and b > 12) or (0 < a <= 12 and b == 0):
        return 'MMYY'
    elif 0 < a <= 12 and 0 < b <= 12:
        return 'AMBIGUOUS'
    else:
        return 'NA'


if __name__ == '__main__':
    print(main())


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

int main() {
  int N;
  cin >> N;
  vector<int> T(N);
  for (int i = 0; i < N; i++) {
    cin >> T.at(i);
  }
  int SUM = 0;
  for (int i = 0; i < N; i++) {
    SUM += T.at(i);
  }
  int M;
  cin >> M;
  for (int i = 0; i < M; i++) {
    int P, X;
    cin >> P >> X;
    cout << SUM - T.at(P - 1) + X << endl;
  }
}


Measured memory_bytes: 256
//atcoder 151 DS
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
using ll = long long int;
//typedef pair<int,int> P;
 
int main(void){
	int K,A,B;
	cin >> K;
	cin >> A>>B;
	int a=0;
	while(a*K<=B){
		if(a*K>=A){
			if(a*K<=B){
				cout << "OK";
				return 0;
			}
		}
		a++;
	}
	cout << "NG";
	return 0;
}

Measured memory_bytes: 3564
//https://ideone.com/x8zpRc
#include<queue>
#include<map>
#include <string>
#include<bits/stdc++.h>
#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
//#define x real()
//#define y imag()
using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=100000,M=100000;

ll n,l;
ll ans=1e18;
 main()
{

//cout<<Pow((ll)1000000,(ll)110);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//    char input[15];
//    scanf("%s", &input);  array of char
//  gets(c+1);  array of char
//printf("%s, ",name[k[i]].c_str());  printf of string
//priority_queue<ll,vector<ll>,greater<ll>>y;
input;

cin>>n>>l;
ll sum=0,y;

forr(i,1,n)
    sum+=l+i-1;


forr(i,1,n)
{
    ll d=sum-(l+i-1);
    if(abs(sum-d)<ans)ans=abs(sum-d),y=d;
}

cout<<y;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define fi first
#define se second
#define For(i,a,b) for(int i=a;i<b;i++)
#define RFor(i,b,a) for(int i = b;i>=a;i--)
#define sz size()
#define PQ priority_queue
#define len length()
#define mll map<ll,ll>
#define mpll map<pll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pair<ll,ll> >
#define mp(x,y)  make_pair(x,y)
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define ALL(v) v.begin(),v.end()
#define LAPAK ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

const ll MOD = 2*(1e9 + 7);
const ll INF = 2e18;
const ll MAX = 1e6 + 2;


int main() {
    LAPAK
    
    int n;
    cin>>n;
    int a;
    int freq[MAX] = {};
    int g = 0;
    For(i,0,n){
        cin>>a;
        g = __gcd(g,a);
        if(a%2==0)freq[2]++;
        while(a%2==0)a/=2;
        for(int j = 3;j<=sqrt(a);j+=2){
            if(a%j==0){
                freq[j]++;
                while(a%j==0)
                    a/=j;
            }
        }
        if(a>2)freq[a]++;
    }
    
    bool pairwise = true;
    For(i,2,MAX){
        pairwise &= (freq[i]<=1);
    }
    if(pairwise)cout<<"pairwise coprime";
    else if(g==1)cout<<"setwise coprime";
    else cout<<"not coprime";
    
    return 0;
}


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

/*
 <url:https://beta.atcoder.jp/contests/soundhound2018-summer-qual/tasks/soundhound2018_summer_qual_c>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

double solve(){
    double res = 0;
    ll n,m,d; cin >> n >> m >> d;
    if(d == 0) res = (m-1)/(double)n;
    else res = (m-1)*2*(n-d)/(double)(n*n);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12) << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;
typedef long long  ll;
typedef long double ld;
typedef pair<ll,ll> pp;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> super_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> multi_set;
#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
const ll DIM = 1000+7;
const ll INF = 1e9;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());

ll A[15][DIM],cnt[15];
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,m,k;
    cin>>n>>m>>k;
    forn(i,n){
        forn(j,m){
            char ch;
            cin>>ch;
            A[i][j] = ch-'0';
        }
    }
    ll sz = po(n-1);
    ll res = INF;
    for(ll mask = 0;mask<sz;++mask){
        ll p = 0;
        ll r = 0;
        ll can = 0;
        for(ll i = 0;i<=n;i++)cnt[i] = 0;
        for(ll j = 1;j<=m;j++){
            ll flag = 0;
            p = 0;
            for(ll i = 1;i<=n;i++){
                if (A[i][j]==1)cnt[p]++;
                if (cnt[p]>k){
                    flag = 1;
                    break;
                }
                if (po(i-1)&mask)p++;
            }
            if (flag==1){
                for(ll i = 0;i<=n;i++){
                    cnt[i] = 0;
                }
                p = 0;
                ll ff = 0;
                for(ll i = 1;i<=n;i++){
                    if (A[i][j]==1)cnt[p]++;
                    if (cnt[p]>k){
                        ff = 1;
                        break;
                    }
                    if (po(i-1)&mask)p++;
                }
                if (ff==1){
                    can = 1;
                    break;
                }
                r++;
            }
        }
        r+=__builtin_popcount(mask);
        if (!can)
        res = min(res,r);
    }
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 384
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>


int main(){
	long double a,b,c;
	cin >> a >> b >> c;
    long double eps=1.0E-14;
	if(sqrt(a)+sqrt(b)+eps<sqrt(c))cout << "Yes";
	else cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define num(a) a-'0'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define debug(x) cerr<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define vl vector<long long int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF=1e9+7;
ll INF=1e11;

void solve(){
	int n;
	cin>>n;
	vi a(n);
	rep(i,0,n){
		cin>>a[i];
	}
	sort(all(a));
	ll ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				if(i!=j && j!=k && i!=k){
					if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k]){
						if(a[i]>a[j] && a[i]>a[k]){
							if(a[i]<a[j]+a[k]){
								ans++;
							}
						}
						else if(a[j]>a[k]){
							if(a[j]<a[i]+a[k]){
								ans++;
							}
						}
						else{
							if(a[k]<a[i]+a[j]){
								ans++;
							}
						}
					}
				}
			}
		}
	}
	ans/=6;
	cout<<ans<<ln;
}	

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


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

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

int main() {
  ll N; cin >> N;
  map<int,int> pos;
  rep(i,N) { int tmp; cin >> tmp; pos[tmp]=1; }
  rep(i,N) { int tmp; cin >> tmp; pos[tmp]=-1; }
  ll result = 1, count = 0;
  for (auto x: pos) {
    count += x.second;
    if (count*x.second>0) {
      result *= abs(count);
      result %= MOD; 
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 9600
N = int(input())
h = list(map(int, input().split()))

dp = [0] * N
dp[1] = abs(h[1] - h[0])
for i in range(2, N):
    dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]))
print(dp[-1])

Measured memory_bytes: 13928
#include <iostream>
#include <map>

using namespace std;

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

	map<int,int> A;

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

	for (int i = 0; i < M; i++) {
		int b, c;
		cin >> b >> c;
		A[c] += b;
	}

	auto i = A.rbegin();
	long long ans = 0;
	int count = 0;
	for (; i != A.rend();i++) {
		if (count + i->second > N) {
			ans += (long long)i->first * (N - count);
			break;
		}
		count += i->second;
		ans += (long long)i->first * i->second;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main() {
    int a , b, c , d ;
    cin >> a >> b >> c >> d ;
    if (a+b == c+d) {
            cout << "Balanced" ;
    }
    if (a+b < c+d) {
            cout << "Right" ;
    }
    if (a+b > c+d) {
            cout << "Left" ;
    }
    return 0 ;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const ll mod=1000000007;

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}

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

    if(n==1){
        cout << "Hello World" << endl;
    }
    else{
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }

   

}


Measured memory_bytes: 3588
#include<stdio.h>
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}
int partition (int array[], int left, int right,int a[]) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { 
      swap(&array[i], &array[j]);
      swap(&a[i], &a[j]);
               }
  } while (i < j);

  swap(&array[pivot], &array[j]); 
  swap(&a[pivot], &a[j]);//pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right,int a[]) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right,a);
    quick_sort(array, left, pivot-1,a);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right,a);
  }
}
int main(){
  int i,a[1000000],b[1000000],n,s=0,q=0;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d %d",&a[i],&b[i]);
  quick_sort(b,0,n-1,a);
  for(i=0;i<n;i++){
    s+=a[i];
    if(s>b[i]){
      q=1;
      break;
    }
  }
  if(q==1)printf("No");
  else printf("Yes");
  return 0;
}
    


Measured memory_bytes: 6912
#include <stdio.h>

int main()
{
 int a, b ,c;
 scanf("%d %d %d", &a, &b, &c);
 if(a <= b) {
  if(b <= c) {
   printf("%d %d %d\n", a, b, c);
  }
  if(c < b && a <= c) {
   printf("%d %d %d\n", a, c, b);
  }
  if(c < b && c < a) {
   printf("%d %d %d\n", c, a, b);
  }
 }
 if(b < a) {
  if(c <= b) {
   printf("%d %d %d\n", c, b, a);
  }
  if(b < c && a <= c) {
   printf("%d %d %d\n", b, a, c);
  }
  if(b < c && c < a) {
   printf("%d %d %d\n", b, c, a);
  }
 }
 return 0;
}

Measured memory_bytes: 596
H,W,K=map(int,input().split())
C=[input() for _ in range(H)]
ans=0
for i in range(2**H):
  for j in range(2**W):
    c=0
    for ii in range(H):
      for jj in range(W):
        if i>>ii&1 and j>>jj&1:
          if C[ii][jj]=='#':
            c+=1
    if c==K:
      ans+=1
print(ans)

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

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

int main(void){
    int num[5];
    rep(i,5){
        cin >> num[i];
        if(num[i] == 0){
            cout << i + 1;
            break;
        }
    }
}

Measured memory_bytes: 3620