akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long ll;

int main() {
	int n, q;
	scanf("%d%d", &n, &q);
	vector<ll> w;
	w.push_back(n);
	while(q--) {
		ll x;
		scanf("%lld", &x);
		while(!w.empty() && w.back() >= x) w.pop_back();
		w.push_back(x);
	}
	// increasing
	map<ll,ll> mapka;
	mapka[w.back()-1] = 1;
	w.pop_back();
	reverse(w.begin(), w.end());
	for(ll nowy : w) {
		while(true) {
			auto it = prev(mapka.end());
			ll i = it -> first;
			if(i < nowy) break;
			ll cale = i / nowy;
			mapka[nowy-1] += cale * (it -> second);
			mapka[i%nowy] += it -> second;
			mapka.erase(it);
		}
	}
	ll so_far = 0;
	for(int i = 0; i < n; ++i) so_far += mapka[i];
	for(int i = 0; i < n; ++i) {
		printf("%lld\n", so_far);
		so_far -= mapka[i];
	}
}


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

constexpr int mod = 1e9 + 7, inv2 = 500000004;
int dp[5050][5050];

int main() {
  int N;
  string s;

  cin >> N >> s;

  dp[0][0] = 1;

  for (int i = 0; i < N; ++i) {
    (dp[i + 1][1] += 2 * dp[i][0] % mod) %= mod;
    (dp[i + 1][0] += dp[i][0]) %= mod;
    for (int j = 1; j < N; ++j) {
      (dp[i + 1][j + 1] += 2 * dp[i][j] % mod) %= mod;
      (dp[i + 1][max(0, j - 1)] += dp[i][j]) %= mod;
    }
  }

  int64_t ans = dp[N][s.size()];
  for (int i = 0; i < s.size(); ++i) {
    (ans *= inv2) %= mod;
  }

  cout << ans << endl;
}


Measured memory_bytes: 98944
n = gets.to_i
s = gets.chomp!

array = s.split('')

i_j_k_sum = array.count('R') * array.count('G') * array.count('B')
count = 0

for i in 0...n do
  for j in (i+1)...n do
    k = 2 * j - i
    next if k >= n

    if array[i] != array[j] && array[i] != array[k] && array[j] != array[k]
      count += 1
    end
  end
end

puts i_j_k_sum - count


Measured memory_bytes: 14444
#include<stdio.h>

#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

void dijk(){

  int sum,i,u,min;
  int d[MAX],c[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    c[i]=WHITE;
  }

  d[0]=0;

  while(1){
    min=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(min>d[i] && c[i]!=BLACK){
	u=i;
	min=d[i];
      }
    }

    if(u==-1) break;
    c[u]=BLACK;
    
    for(i=0;i<n;i++){
      if(c[i]!=BLACK && M[u][i]!=INFTY){
	if(d[i]>d[u]+M[u][i]){
	      d[i]=d[u]+M[u][i];
	      c[i]=GRAY;
	    }
      }
    }
  }

  for(i=0;i<n;i++){
    printf("%d ",i);
    if(d[i]==INFTY){ printf("-1\n");
    } else printf("%d\n",d[i]);
  }
}


int main(){

  int i,j,a,b,c,d;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }

for(i=0;i<n;i++){
  scanf("%d%d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d%d",&c,&d);
      M[a][c]=d;
    }
  }

 dijk();

  return 0;
}

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

#define ll long long
#define pb push_back
#define fs first
#define se second
#define M 1000000007


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

bool check(int x,int y)
{
	return x>=0 && y>=0 && x<=2000 && y<=2000;
}
int fun()
{
	static int num = 16;
	return num--;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n,k;
	cin>>n>>k;
	vector<ll>arr(n+1,0);
	for(ll i=1;i<=n;i++)
		cin>>arr[i];
	vector<ll>order(n+1,0);
	order[1]=1;
	ll s=1;
	ll ans=0;
	if(k>n)
	while(1)
	{
		// cout<<s<<" ";
		if(order[arr[s]]==0)
		order[arr[s]]=order[s]+1;
		else
		{
			ll h=order[arr[s]]-1;
			h=k-h;
			ll c=order[s]-order[arr[s]]+1;
			// cout<<"c: "<<c<<endl;
			h=h%c;

			ll u=arr[s];
			// cout<<u<<endl;
			// ll ans=0;
			for(ll i=0;i<h;i++)
				u=arr[u];
			// cout<<u<<endl;
			ans=u;
			// cout<<"ans; "<<ans<<endl;
			break;
		}

		s=arr[s];
	}
	else
	{
		while(k--)
		{
			s=arr[s];
		}
		ans=s;
	}

	cout<<ans<<endl;
	
}



Measured memory_bytes: 6332
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define M 1000000
using namespace std;

//vector<ll> ;

void answer(){
    ll n,m,k,ans=0;
    cin>>n>>m>>k;
    ll a=0;
    ans = n/(m+k);
    a = ans*m;
    ll b = n%(m+k);
    if (b>=m)
        a+=m;
    else
        a+=b;
    cout<<a;
}

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

Measured memory_bytes: 256
n = gets.to_i
while n != 0
	cnt = 0
	sum = 0
	sum_cnt = 0
	n.times do |i|
		j = 1 + i
		loop do
			sum += j
			sum_cnt += 1
			j += 1
			#puts sum
			if sum == n  && sum_cnt >= 2
				cnt += 1
				#print("sum = ",sum,"\n")
				break
			elsif sum > n
				break
			end
		end
		sum = 0
		sum_cnt = 0
	end
	puts cnt
	n = gets.to_i 
end

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

int main(){
  int a,b,k;
  cin>>a>> b>> k;
  int n = min(a,b);
  int buf = 0;
  int ans = 1;
  rep(i,n-1){
    if(a%(n-i)==0 && b%(n-i)==0) buf++;
    if(buf == k){
      ans = (n-i); 
      break;
    }
  }
  cout<<ans<<endl;
}



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

  while(500 <= N){
    N = N - 500;
  }
  
  if(N <= A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;
int main(void)
{
    int n,d;
    int x;
    int a,count=0;
    cin >> n >> d >> x;

    for(int i=1;i<=n;i++){
        cin >> a;
        int j = 0;
        while(a * j < d){
            count++;
            j++;
        }
    }
    cout << x+count;
    return 0;
}

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

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

    std::vector<int> boxes(N, 0);
    int M = 0;
    for (int i = N - 1; i >= 0; i--) {
        int count = 0;
        for (int j = N / (i + 1); j > 1; j--) {
            count += boxes[j * (i + 1) - 1];
        }
        if (count % 2 != a[i]) {
            boxes[i] = 1;
            M++;
        }
    }
    std::cout << M << std::endl;
    for (int i = 0; i < N; i++) {
        if (boxes[i] == 1) {
            std::cout << i + 1;
            M--;
            if (M > 0) {
                std::cout << " ";
            }
        }
    }
    std::cout << std::endl;
}


Measured memory_bytes: 4760
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int, int> P;

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


int main() {
	int N, a = 0;
	cin >> N;
	int min = 1000, max = 0;
	REP(i, N) {
		cin >> a;
		if (a <= min)min = a;
		if (a>= max)max = a;
	}
	cout << max - min << endl;
}


Measured memory_bytes: 380
#include <iostream>
#include <math.h>

#include <stdio.h>

using namespace std;

int main(){

   double x1, y1, x2, y2;

   cin >> x1 >> y1 >> x2 >> y2;

   printf("%.8lf\n",sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));

   return 0;
}


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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define dbg(x) std::cerr<<#x<<" = " << (x) << std::endl
#define pnl(x) std::cout << x << "\n"

typedef	std::vector<int>	vi;
typedef std::pair<int,int>	ii;
typedef std::vector<std::string>	vs;
typedef std::vector<ii>	vii;
typedef std::vector<long long>	vl;
typedef	long long ll;


const int	NB_D = 4;
const int	DY[] = {-1, 1, 0, 0};
const int	DX[] = {0, 0, -1, 1};

int		main(void)
{
	std::ios_base::sync_with_stdio(false);
	unsigned long long l, r;
	std::cin >> l >> r;
	int		cnt = 0;
	while (l <=	r)
		l *= 2, cnt++;
	pnl(cnt);
}



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

using ll = long long;
using ld = long double;

const int MOD = 1e9 + 7;
const int N = 1e5;

int fact[N + 69];
int n, m;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);

  fact[0] = 1;
  for(int i = 1; i <= N; i++) {
    fact[i] = (1LL * fact[i - 1] * i) % MOD;
  }

  cin >> n >> m;
  int ans = 1;
  ans = (1LL * ans * fact[n]) % MOD;
  ans = (1LL * ans * fact[m]) % MOD;

  if(abs(n - m) > 1) {
    ans = 0;
  } else if(n == m) {
    ans = (1LL * ans * 2) % MOD;
  }

  cout << ans << '\n';
  
  return 0;
}

Measured memory_bytes: 4048
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		output ();
	}
	
	private static void output(){
		int d;
		int e;
		int a = 0;
		int i = 0;
		Scanner cin = new Scanner(System.in);
		
		while (cin.hasNext()){
			d = cin.nextInt();
			for (e = 0; e <= 600 - d; e = d * i){
				a += e * e * d;
				i++;
			}
			System.out.println(a);
			a = 0;
			i = 0;
		}
	}
}

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

int main()
{
    int n, r;
    cin >> n >> r;
    int ans = 0;
    if (n >= 10)
        ans = r;
    else
        ans = 100 * (10 - n) + r;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double EPS = 1e-7;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define X real()
#define Y imag()
#define cross(a,b) (conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define dist(a,b) ( pow(a.X - b.X, 2) + pow( a.Y - b.Y, 2 ) )
typedef tuple <int, int, int> line;
typedef complex <double> point;
typedef vector <point> polygon;
int main()
{
    Hello
    int n, arr[100000], x, h[100000];
    cin >> n  >> x;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    h[0] = 0;
    h[1] = abs( arr[0] - arr[1] );
    for (int i = 2; i < n; i++)
    {
        h[i] = 1e9;
        for (int j = i - 1;  j >= max(0, i - x); j--)
        {
            h[i] = min( h[i], h[j] + abs(arr[i] - arr[j]) );
        }
    }
    cout << h[ n - 1 ];
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

LL calc(vector<LL> x, vector<LL> y)
{
  LL maxim = x[0] + y[0];
  LL minim = maxim;
  int N = x.size();
  for (int i = 0; i < N; i++)
  {
    chmax(maxim, x[i] + y[i]);
    chmin(minim, x[i] + y[i]);
  }
  return maxim - minim;
}

void solve(long long N, std::vector<long long> x, std::vector<long long> y)
{

  LL ans = calc(x, y);
  for (int i = 0; i < N; i++)
    y[i] = -y[i];
  chmax(ans, calc(x, y));
  cout << ans << endl;
}

int main()
{
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  std::vector<long long> x(N);
  std::vector<long long> y(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &x[i]);
    scanf("%lld", &y[i]);
  }
  solve(N, std::move(x), std::move(y));
  return 0;
}


Measured memory_bytes: 9592
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

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

  int abs_max = 0;
  int max_idx = 0;
  bool max_sgn = true;
  rep(i, 0, n) {
    if (abs(a[i]) > abs_max) {
      abs_max = abs(a[i]);
      max_idx = i;
      max_sgn = a[i] > 0;
    }
  }

  cout << (n - 1) * 2 << '\n';
  rep(i, 0, n) if (i != max_idx) cout << max_idx + 1 << ' ' << i + 1 << '\n';
  if (max_sgn)
    rep(i, 1, n) cout << i << ' ' << i + 1 << '\n';
  else
    rrep(i, 1, n) cout << i + 1 << ' ' << i << '\n';

  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int a,ans,n;
string s;
int main(){
  cin>>s;
  for(int i=0;i<s.length();i++){
    if(s[i]!='1'){a=i;break;}
  }
  cin>>n;
    if(n<=a)cout<<1<<endl;
    else if(s[0]=='1')cout<<s[a]<<endl;
    else cout<<s[0]<<endl;


}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    int a[N];
    REP(i, N) {
        cin >> a[i];
    }

    int res[H][W];

    int index = 0;
    REP(i, H) {
        if(i%2 == 0) {
            REP(j, W) {
                if(a[index] == 0) {
                    index++;
                }
                a[index]--;
                res[i][j] = index + 1;
            }
        }else{
            for(int j = W - 1;0 <= j;j--) {
                if(a[index] == 0) {
                    index++;
                }
                a[index]--;
                res[i][j] = index + 1;
            }
        }
    }

    REP(i, H) {
        REP(j, W) {
            cout << res[i][j];
            if(j != W - 1) {
                cout << " ";
            }
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)

#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N, M;
const int MAX_M = 200000;
int p[MAX_M], q[MAX_M], c[MAX_M];

// set V in main
// d[MAX_V] shows the answer

const int MAX_V = 1000000;

struct edge{int to; ll cost;};
typedef pair<ll, int> P;

int V;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>  > que;
    fill(d, d + V, INFll);
    d[s] = 0;
    que.push(P(0,s));

    while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(int i = 0; i < G[v].size(); i++){
        edge e = G[v][i];
        if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
        }
    }
    }
}

ll ct;

struct edge2{int to, company;};
vector<edge2> G2[MAX_V];

int main(){
  cin >> N >> M;
  REP(i, M) cin >> p[i] >> q[i] >> c[i];

  map<int, int> mp[N];
  REP(i, M) {
    G2[p[i] - 1].pb(edge2{q[i] - 1, c[i]});
    G2[q[i] - 1].pb(edge2{p[i] - 1, c[i]});
  }
  ct = N;
  REP(i, N) {
    for (auto itr : G2[i]) {
      int t = itr.to;
      int c = itr.company;
      if(!mp[i][c]) mp[i][c] = ct++;
      if(!mp[t][c]) mp[t][c] = ct++;
      G[i].pb(edge{mp[i][c], 1});
      G[mp[i][c]].pb(edge{i, 1});
      G[mp[i][c]].pb(edge{mp[t][c], 0});
      G[mp[t][c]].pb(edge{mp[i][c], 0});
      G[mp[t][c]].pb(edge{t, 1});
      G[t].pb(edge{mp[t][c], 1});
    }
  }
  V = ct;
  dijkstra(0);
  if(d[N - 1] == INFll) {
    cout << -1 << endl;
  } else {
    cout << d[N - 1] / 2 << endl;
  }
  


  return 0;
}


Measured memory_bytes: 140780
#include<iostream>
#include<iomanip>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>


#define rep(i,n) for(int i = 0; i < n; ++i)
#define all(x) x.begin(),x.end()
using namespace std;

int main(void){
  int n;
  vector<int> a;
  cin >> n;
  n = pow(2,n);
  a.resize(n);
  for(auto &b : a) cin >>b;

  while(n != 1){
    int index = 0;
    for(int i = 0; i < n; i+=2, ++index){
      a[index] = abs(a[i]-a[i+1]);
    }
    n/=2;
  }
  cout << a[0] << endl;

  return 0;
}



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

const int maxn = 1e6 + 10;
bool vis[maxn];

signed main() {
  int n, ans = 0;
  scanf("%d", &n);
  for (int i = 1; i < n; ++ i) {
    if (vis[i]) continue;
    if (i + i == n) continue;
    vis[i] = 1, vis[n - i] = 1, ans ++;
  }
  printf("%d", ans);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC omodtimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long ,long> ii; 	
typedef complex<long double> com;
 
const ll mod = 998244353;

struct lol{
	ii coor;
	ll depth;
};

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll k,n;
	cin >> k >> n;
	vector <ll> arr(n);
	for (int z=0;z<n;z++){
		cin >> arr[z];
		arr[z] %= k;
	}
	sort(arr.begin(),arr.end());
	ll ans = LLONG_MAX;
	for (int z=0;z<n;z++){
		if (z < n-1)
		ans = min(ans,arr[z]+k-arr[z+1]);
		else ans = min(ans,arr[z]-arr[0]);
		if (z > 0)
		ans = min(ans,k-arr[z]+arr[z-1]);
		else ans = min(ans,arr[n-1]-arr[0]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
n = int(input())
a = list(map(int, input().split()))
count = 0

x = [i for i in a if i % 2 == 0]
for i in x:
    if i % 3 == 0 or i % 10 == 0:
        count += 1

if len(x) == count:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n, K;
    cin >> n >> K;
    vector<ll> x(n), y(n);
    vector<ll> X(n), Y(n);
    for(int i = 0; i < n; ++i){
        cin >> x[i] >> y[i];
        X[i] = x[i], Y[i] = y[i];
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    ll ans = 1e+18;
    ans <<= 2;
    for(int i = 0; i < n - 1; ++i){
        for(int j = i + 1; j < n; ++j){
            for(int k = 0; k < n - 1; ++k){
                for(int l = k + 1; l < n; ++l){
                    int cnt = 0;
                    for(int m = 0; m < n; ++m){
                        if(X[i] <= x[m] && x[m] <= X[j] && Y[k] <= y[m] && y[m] <= Y[l])    ++cnt;
                    }
                    if(cnt >= K)    chmin(ans, (X[j] - X[i]) * (Y[l] - Y[k]));
                }
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long int lli;

int main(int argc, char const *argv[]) {
  lli n;
  cin >> n;
  vector<lli> a(n);
  for (size_t i = 0; i < n; i++) cin >> a[i];
  vector<lli> vodd, v2, v4;
  for (size_t i = 0; i < n; i++) {
    if (a[i]%4 == 0) v4.push_back(a[i]);
    else if (a[i]%2==0) v2.push_back(a[i]);
    else vodd.push_back(a[i]);
  }
  if (v4.size()+1>=(vodd.size()+v2.size()%2)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 2296
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    
    if (n % 2 == 0) {
      System.out.println(n);
    } else {
      System.out.println(n * 2);
    }
  }
}

Measured memory_bytes: 22100
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int l = 0;
        int r = 0;
        int n = s.length();
        int count = 0;
        while (l < n - 1 - r) {
            if (s.charAt(l) == s.charAt(n - 1 - r)) {
                l++;
                r++;
            } else {
                if (s.charAt(l) == 'x') {
                    l++;
                    count++;
                } else if (s.charAt(n - 1 - r) == 'x') {
                    r++;
                    count++;
                } else {
                    System.out.println(-1);
                    return;
                }
            }
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 25044
//
//  C - Median Sum.cpp
//  atcoder grand contest 020
//
//  Created by Huang,Zhiqiang on 2018/2/21.
//  Copyright © 2018年 Huang,Zhiqiang. All rights reserved.
//

#include <iostream>
#include <bitset>
using namespace std;

typedef long long ll;

int main() {
    int a[2025], n;
    cin >> n;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    bitset<4444444> dp;
    dp[0] = 1;
    for (int i = 0; i < n; i++) dp = dp | (dp << a[i]);
    ll ans = (1 + sum) / 2;
    while (dp[ans] == 0) ans++;
    cout << ans << endl;
}


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

int main() {
  string s;
  cin>>s;
  string t;
  cin >>t;
  
  bool alle_buchstaben_gleich = true;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) {
      alle_buchstaben_gleich = false;
    }
  }
  
  if(alle_buchstaben_gleich == true) {
    cout <<"Yes";
  } else {
    cout<<"No";
  }
	return 0;
}


Measured memory_bytes: 3616
#include<iostream>
using namespace std;
template<typename T>
class stack
{
  T elements[10000];
  int index=-1;
public:
  void push(T num)
  {
    index++;
    elements[index]=num;
  }
  void pop()
  {
    index--;
  }
  T peep()
  {
    if(index==-1)return 0;
    else
    return elements[index];
  }
  bool empty()
  {
    return index==-1;
  }
  int size()
  {
    return index+1;
  }
};
//  stack definition ...............................................................??
typedef long long ll;
int main()
{ 
   int t=1;
   //cin >> t;
   while(t--)
   {
     // int size;
     // cin >> size;
     // int arr[size];
     // for(int i=0;i<n;i++)
     // {

     // }
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans=0;
    ans=max(a*1ll*c,a*1ll*d);
    ans=max(ans,b*1ll*c);
    ans=max(ans,b*1ll*d);
    cout << ans << endl;
   }
   
return 0;
}



Measured memory_bytes: 3628
n = gets.to_i
cnt = Hash.new(0)
n.times do
  cnt[gets.chomp] += 1
end
puts 'AC x ' + cnt['AC'].to_s
puts 'WA x ' + cnt['WA'].to_s
puts 'TLE x ' + cnt['TLE'].to_s
puts 'RE x ' + cnt['RE'].to_s


Measured memory_bytes: 14308
import std.stdio;
import std.array;
import std.conv;
import std.range;
import std.algorithm;
import std.string;
import std.numeric;
void solve(){
        string s = readln().strip();
        foreach(a;0..26){
                if(gcd(a,26)!=1) continue;
                foreach(b;0..26){
                        char[30] m;
                        foreach(i;0..26){
                                m[(i*a+b)%26] = cast(char)(i+'a');
                        }
                        auto ns = s.map!(c=>(c!=' ')?m[c-'a']:' ').array();
                        if(ns.split().any!(w=>w=="that"||w=="this")){
                                writeln(ns);
                                return;
                        }
                }
        }
}
void main() {
        int n=to!int(readln().strip());
        foreach(_;0..n)solve();
}

Measured memory_bytes: 2848
#include<bits/stdc++.h>
using namespace std;
int main() {
  int sx,sy,tx,ty;
  cin >>sx>>sy>>tx>>ty;
  
  
  for(int i=0;i<ty-sy;i++){
  	cout<<"U";
  }
  for(int i=0;i<tx-sx;i++){
  	cout<<"R";
  }
  for(int i=0;i<ty-sy;i++){
  	cout<<"D";
  }
  for(int i=0;i<tx-sx+1;i++){
  	cout<<"L";
  }

   for(int i=0;i<ty-sy+1;i++){
  	cout<<"U";
  }
  for(int i=0;i<tx-sx+1;i++){
  	cout<<"R";
  }
  cout<<"DR";
  for(int i=0;i<ty-sy+1;i++){
  	cout<<"D";
  }
  for(int i=0;i<tx-sx;i++){
  	cout<<"L";
  }
  cout<<"LU";
  return 0;}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
 
public static void main(String[] args) {
 
int count = 0;
int H;
int N;
String message = "No";
 
Scanner scanner = new Scanner(System.in);
H = scanner.nextInt();
N = scanner.nextInt();
  
int u[] = new int[N];
  
for(int i = 0; i<N; i++){
  u[i] = scanner.nextInt();
  if(H>0){
    H = H - u[i];
  }
  
}
if(H <= 0){
  message = "Yes";
}
  
System.out.println(message);
  
}
  
}

Measured memory_bytes: 52212
def main():
    n = int(input())
    h_lst = list(map(int,input().split()))
    zero_count = 0
    count = 0

    for i in range(n):

        if h_lst[i] == 0:
            zero_count += 1


    while zero_count < n:

        flag = False
        tmp_count = 0

        for i in range(n):

            if h_lst[i] > 0:
                flag = True
                h_lst[i] -= 1

                if h_lst[i] == 0:
                    zero_count += 1

            else:
                if flag:
                    tmp_count += 1   ## 0でもプラスする必要があるときは、それ以前に0以外の数字があるとき　→　flagで管理
                    flag = False

        if flag:
            tmp_count += 1

        count += tmp_count  ## 一回ごとに足していく

        
    print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9140
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
#define __ %=Mod
using namespace std;

const int maxn = 1100000;
const ll Mod = 1e9+7;

int n;
ll f[maxn],sum;

int main()
{
	scanf("%d",&n);
	f[0]=1ll; sum=1ll;
	for(int i=1;i<=n;i++) 
	{
		(f[i]+=sum-(i-2>=0?f[i-2]:0))__;
		(sum+=f[i])__;
	}
	ll re=0,N=(ll)(n-1)*(n-1)%Mod;
	for(int i=0;i<n-1;i++) (re+=f[i]*N%Mod)__;
	(re+=f[n-1]*(n-1)%Mod)__;
	(re+=f[n]%Mod)__;
	for(int i=n-2;i>=0;i--) (re+=f[i]*(i+1)%Mod)__;
	printf("%lld\n",re);
	
	return 0;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    
    string s;
    cin >> s;
    
    int totalE = 0;
    int totalW = 0;
    
    for (int i = 0; i < (int)s.size(); i++){
        if (s[i] == 'E')totalE++; // Eが合計何個あるかを数える
        else totalW++; // Wが合計何個あるかを数える
    }
    
    int ans = (int)s.size();
    
    int tempE = 0; // 現在地点より西にいる人のうち, 東を向いている人の数を表す
    int tempW = 0; // 現在地点より西にいる人のうち, 西を向いている人の数を表す
    
    for (int i = 0; i < (int)s.size(); i++){
        
        int reverseE = totalE - tempE; // リーダーより東にいて、東を向いている人を求める
        if (s[i] == 'E') reverseE--; // 現在地の人の向きを考慮する（この実装の場合）
        
        // reverseE + tempW
        // リーダーより西にいて、西を向いている人 + リーダーより東にいて、東を向いている人
        // これら２種類のパターンの人数が、reverseE + tempWである
        ans = min(ans, reverseE + tempW); 
        
        if (s[i] == 'W') tempW++;
        else tempE++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
/*
DP[i]={
	0							i>n
	a[i]+min(DP[i+1],DP[i+2]);	i<n
}
*/
int main() {
	vector<int> cost;
	int x;
	cin >> x;
	for(int i=0;i<x;i++)
	{
		int a;cin>>a;
		cost.push_back(a);
	}
	vector<long long unsigned int> DP (x);
	DP[0] = 0;
	DP[1] = abs(cost[0]-cost[1]);
	for (int i = 2; i < x; i++){
		DP[i] = min(abs(cost[i]-cost[i-1])+DP[i-1], abs(cost[i]-cost[i-2])+DP[i-2]);
	}
	cout << DP[x-1];
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct UnionFindTree{
    vector<int>par,sz;
    UnionFindTree(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool areSame(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int N,M;
int H[222];
int A[111111],B[111111],C[111111];


void solve(){
    rep(i,N)cin>>H[i];
    rep(i,M)cin>>A[i]>>B[i]>>C[i],A[i]--,B[i]--;

    vint lis;
    rep(i,N)lis.pb(H[i]);

    lis.pb(0);

    int latte=INT_MAX;
    for(auto t:lis){
        UnionFindTree uf(N);
        int cnt=0;
        rep(i,N)if(H[i]>t)cnt++;
        rep(i,M){
            if(H[A[i]]<=t||H[B[i]]<=t)continue;
            uf.unite(A[i],B[i]);
        }

        bool ok=false;
        rep(i,N)if(H[i]>t&&uf.size(i)==cnt)ok=true;
        if(!ok)chmin(latte,t);
    }

    if(latte==0){
        cout<<0<<endl;
        return;
    }


    rep(i,N)chmin(H[i],latte);

    vector<tuple<int,int,int>>es;
    rep(i,M){
        es.pb(make_tuple(-min(H[A[i]],H[B[i]]),C[i],i));
    }
    sort(all(es));
    UnionFindTree uf(N);
    int ans=0;
    for(auto &w:es){
        int k=get<2>(w);
        if(uf.areSame(A[k],B[k]))continue;
        uf.unite(A[k],B[k]);
        ans+=C[k];
    }

    cout<<ans<<endl;
}
signed main(){
    while(cin>>N>>M,N||M)solve();
    return 0;
}

Measured memory_bytes: 4664
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B;
	
	for(i=1;i<=10000000;i++) {
		x=i*8/100;
		y=i*10/100;
		
		if(A==x && B==y) return _P("%d\n",i);
	}
	cout<<-1<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
/*
  Author: @yash_31
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#define ll long long int
#define eb emplace_back
#define fatafat ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define ft first
#define sd second
#define mkpr make_pair
#define deb(x) std::cout<<#x<<":"<<x<<endl;
#define whole(x) (x).begin(),(x).end()
#define revwhole(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define fbo find_by_order
#define ook order_of_key
#define init0(x) memset(x,0,sizeof(x));

using namespace std; 
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> gharKaSet;
 
const int maxlimit=2e5+2;
const ll inf=1e18;
//TTBDC

bool vis[100005];
int dp[100005];
int ans=0;

void dfs(int s,vector<int> g[]){
  vis[s]=true;
  for(int x:g[s]){
    if(!vis[x])dfs(x,g);
    dp[s]=max(dp[s],1+dp[x]);
    ans=max(ans,dp[s]);
  }
}

int main()
{
  fatafat
  int n,m,u,v;
  cin>>n>>m;
  vector<int> gx[n+1];
  for(int i=0;i<m;i++){
    cin>>u>>v;
    gx[u].eb(v);
  }
  for(int i=1;i<=n;i++){
    if(!vis[i])dfs(i,gx);
  }
  // for(int i=1;i<=n;i++){
  //   cout<<dp[i]<<" ";
  // }
  // cout<<endl;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 12944
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	ll S;
	cin >> S;
    ll x1 = 1e9;
    ll y1 = 1;
    ll y2 = (S +(x1-1)) / x1;
    ll x2 = x1 * y2 - S;

	cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << 0 << ' ' << 0 << endl;
	return 0;
}


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

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

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

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

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 DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	cout << ((c >= a && c <= b) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <assert.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
using namespace std;

// #define __DEBUG__

#ifdef __DEBUG__
bool debug_disabled = false;
#else
bool debug_disabled = true;
#endif

#define dbg if (debug_disabled) {} else cerr

void solve() {
    int N, K;
    cin >> N >> K;
    set<int> snukes;
    for (int i = 0; i < K; ++i) {
        int d;
        cin >> d;
        for (int j = 0; j < d; ++j) {
            int a;
            cin >> a;
            snukes.insert(a);
        }
    }
    cout << N - snukes.size() << endl;
}

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.setf(ios::showpoint);
    cout.precision(12);
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int T = 1;
    // cin >> T;
    for (int i = 1; i <= T; ++i) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3624
package main

import "fmt"

func min(a, b int) int{
     if a < b {
     	  return a
     } else {
       	  return b
     }
}

func main() {
     var a, b, c, d int
     fmt.Scan(&a, &b, &c, &d)
     fmt.Println(min(a,b) + min(c,d))
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,m;
  cin >> n >> m;
  vec a(n);
  map<ll,ll> cnt;
  for(ll i=0;i<n;i++) {
    cin >> a[i];
    cnt[a[i]%m]++;
  }
  sort(a.begin(),a.end());
  ll ans=0;
  for(auto p:cnt) {
    if(p.first==(m-p.first)%m) {
      ans+=p.second/2;
      cnt[p.first]=p.second%2;
    }
    else {
      ll tmp=min(p.second,cnt[m-p.first]);
      ans+=tmp;
      cnt[p.first]-=tmp;
      cnt[m-p.first]-=tmp;
    }
  }
  for(ll i=0;i<n-1;i++) {
    if(a[i]==a[i+1]) {
      if(cnt[a[i]%m]>1) {
        ans++;
        cnt[a[i]%m]-=2;
        i++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
int main()
{
    double n, m, d;
    cin >> n >> m >> d;
    if (d != 0) {
        cout << setprecision(20) << 2 * (n - d) * (m - 1) / (n * n) << endl;
    } else {
        cout << setprecision(20) << (m - 1) / n << endl;
    }
    return 0;
}

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

    int target; cin >> target;
    int head = target/100;
    int tail = target%100;

    if(1 <= head && head <= 12){
        if(1 <= tail && tail <= 12){
            cout << "AMBIGUOUS" << endl;
        }else cout << "MMYY" << endl;
    }else if(1 <= tail && tail <= 12) cout << "YYMM" << endl;
    else cout << "NA" << endl;

    
}



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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

constexpr long long INF = 1LL << 60;

struct UnionFind {
  vector<int> parent;
  vector<int> num_node;

  UnionFind(int N) : parent(N), num_node(N, 1) {
    for (int i = 0; i < N; i++) {
      parent[i] = i;
    }
  }

  // 根を求める
  int root(int x) {
    if (parent[x] == x) {
      return x;
    }

    // 経路圧縮
    parent[x] = root(parent[x]);
    return parent[x];
  }

  // 同一判定
  bool is_same(int x, int y) {
    return this->root(x) == this->root(y);
  }

  // 併合
  void unite(int x, int y) {
    x = this->root(x);
    y = this->root(y);

    // すでに一緒ならなにもしない
    if (x == y) {
      return;
    }
    parent[x] = y;
    num_node[y] += num_node[x];
  }

  // 同一グループのノード数
  int size(int x) {
    return num_node[root(x)];
  }
};

template <typename T>
struct Edge {
  int to;
  T cost;
  Edge(int _to, T _cost) : to(_to), cost(_cost) {
  }
};

template <typename T>
using Graph = vector<vector<Edge<T>>>;

template <typename T>
T MinimumSpanningTree(const Graph<T>& g) {
  priority_queue<pair<T, int>, std::vector<pair<T, int>>, std::greater<pair<T, int>>> que;

  const int n = g.size();
  for (const auto& e : g[0]) {
    que.emplace(e.cost, e.to);
  }

  T ans = 0;
  vector<bool> united(n);
  united[0] = true;

  while (!que.empty()) {
    auto edge = que.top();
    que.pop();

    T co = edge.first;
    int t = edge.second;

    if (united[t]) {
      continue;
    }
    united[t] = true;
    ans += co;

    for (const auto& e : g[t]) {
      if (!united[e.to])
        que.emplace(e.cost, e.to);
    }
  }

  return ans;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll v, e;
  cin >> v >> e;

  Graph<ll> g(v);

  rep(i, e) {
    int s, t;
    ll w;
    cin >> s >> t >> w;
    g[s].emplace_back(t, w);
    g[t].emplace_back(s, w);
  }

  ll ans = MinimumSpanningTree<ll>(g);
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 10276
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main() {
    double x, h;
    while (cin >> x >> h && x != 0) {
        printf("%f\n", x*x + 2*x*sqrt(x*x/4 + h*h));
    }

    return 0;
}

Measured memory_bytes: 1228
N = int(input())
S = input()
A = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
SS = list(S)
for i in range (len(S)):
  if A.index(S[i]) + N >= 26:
    SS[i] = A[int(A.index(S[i])+N-26)]  
  else:
    SS[i] = A[int(A.index(S[i])+N)]
SS = "".join(SS)
print(SS)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>

int main(){
  int N, M, a[50], b[50], c[50], d[50], i, j, min, p;
  
  scanf("%d %d", &N, &M);
  
  for (i = 0; i < N; i++){
    scanf("%d %d", &a[i], &b[i]);
  }
  for (i = 0; i < M; i++){
    scanf("%d %d", &c[i], &d[i]);
  }
  
  for (i = 0; i < N; i++){
    min = 300000000;
    for (j = 0; j < M; j++){
      if(min > fabs(a[i] - c[j]) + fabs(b[i] - d[j])){
        min = fabs(a[i] - c[j]) + fabs(b[i] - d[j]);
        p = j + 1;
      }
    }
    printf("%d\n", p);
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
typedef unsigned long long ll;

ll gcd(ll a, ll b){
        ll tmp;
        if(a<b){
                tmp = a;
                a = b;
                b = tmp;
        }
        while(b){
                tmp = a;
                a = b;
                b = tmp%b;
        }
        return a;
}

ll lcm(ll a, ll b){
        return a / gcd(a, b) * b;
}


ll main(void){
        ll n; scanf("%llu", &n);
        ll a[n], i;
        for(i=0; i<n; i++) scanf("%llu", &a[i]);

        ll ans = 0;
        for(i=1; i<(1<<n); i++){
                ll tmp=1, j;
                for(j=0; j<n; j++){
                        if((i>>j)&1) tmp = lcm(tmp, a[j]);
                }
                ll can = 1;
                for(j=0; j<n; j++){
                        if(((i>>j)&1)==0 && tmp%a[j]==0) can = 0;
                }
                ans += can;
        }

        printf("%llu\n", ans);
        return 0;
}



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

const int MOD = (int)1e9+7;

int main(){
	long long N;
	cin >> N;
	vector<string> s(N);
	for(long long i=0;i<N;i++)	cin >> s.at(i);
	
	long long countBandA=0;
	long long countA=0;
	long long countB=0;
	long long ans=0;
	for(long long i=0;i<N;i++){
		string S=s.at(i);
		if(S.at(0)=='B' && S.at(S.size()-1)=='A')	countBandA++;
		else if(S.at(0)=='B')	countB++;
		else if(S.at(S.size()-1)=='A')	countA++;
		for(int j=0;j<S.size()-1;j++){
			if(S.at(j)=='A' && S.at(j+1)=='B')	ans++;
		}
	}
	
	if(countBandA>0){
		if(countA==0 && countB==0)	cout << ans+countBandA-1 << endl;
		//else if(countA==countB)	cout << ans+countBandA-1+countA << endl;
		else	cout << ans+countBandA+min(countA,countB) << endl;
	}
	else	cout << ans+min(countA,countB) << endl;
	
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const int MAXN=100100;
vector<int> arr[MAXN];
char ch[MAXN];
int col[MAXN],deg[MAXN],val[MAXN],can[MAXN];
int f[MAXN],g[MAXN];
int n,root,sum,rest;
inline void dfs(register int now,register int pre)
{
	can[now]=col[now];
	for(register int i=0;i<(int)arr[now].size();i++)
		if(arr[now][i]!=pre)
		{
			dfs(arr[now][i],now);
			can[now]&=can[arr[now][i]];
			if(!can[arr[now][i]]) deg[now]++,deg[arr[now][i]]++;
		}
	return;
}
inline void solve(register int now,register int pre)
{
//	cout<<now<<" "<<pre<<endl;
	sum+=deg[now];
	if((deg[now]+col[now])&1) val[now]=0;
	else val[now]=2,sum++;
	register int fmax=0,gmax=0,flag=0;
	for(register int i=0;i<(int)arr[now].size();i++)
		if(arr[now][i]!=pre&&!can[arr[now][i]])
		{
			flag=1,solve(arr[now][i],now);
			rest=max(rest,max(f[arr[now][i]]+gmax,g[arr[now][i]]+fmax)+val[now]);
			fmax=max(fmax,f[arr[now][i]]),gmax=max(gmax,g[arr[now][i]]);
		}
	f[now]=fmax+val[now];
	if(flag) g[now]=gmax+val[now];
	else g[now]=-INT_MAX;
	return;
}
int main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n;
	for(register int i=1,x,y;i<n;i++) cin>>x>>y,arr[x].push_back(y),arr[y].push_back(x);
	cin>>(ch+1);
	for(register int i=1;i<=n;i++)
	{
		col[i]=((ch[i]=='W')?0:1);
		if(!col[i]) root=i;
	}
	dfs(root,0);
	solve(root,0);
	cout<<(root?sum-rest:0)<<endl;
	return 0;
}

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

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

    vector<int> num(3);
    REP(i, 3) cin>> num[i];
    sort(num.begin(), num.end());

    int ans = 0;
    if (abs(num[0] - num[1]) % 2 == 0) {
        ans += abs(num[0] - num[1]) / 2;
        if (num[0] < num[1]) num[0] = num[1];
        else num[1] = num[0];
        cout << ans + (num[2] - num[0]) << '\n';
        return 0;
    } else if (abs(num[1] - num[2]) % 2 == 0) {
        ans += abs(num[1] - num[2]) / 2;
        if (num[1] < num[2]) num[1] = num[2];
        else num[2] = num[1];
        if ((num[2] - num[0]) % 2 == 0) {
            cout << ans + (num[2] - num[0]) / 2 << '\n';
            return 0;
        } else {
            cout << ans + (num[2] - num[0]) / 2 + 2 << '\n';
            return 0;
        }
    } else if (abs(num[2] - num[0]) % 2 == 0) {
        ans += abs(num[2] - num[0]) / 2;
        if (num[2] < num[0]) num[2] = num[0];
        else num[0] = num[2];
        if ((num[2] - num[1]) % 2 == 0) {
            cout << ans + (num[2] - num[1]) / 2 << '\n';
            return 0;
        } else {
            cout << ans + (num[2] - num[1]) / 2 + 2 << '\n';
            return 0;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256