akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(){
  int a,b,i;
  for(i=0;i<3000;i++){
    scanf("%d%d",&a,&b);
    if(a==0 && b==0)break;
    if(a>b)printf("%d %d\n",b,a);
    else {printf("%d %d\n",a,b);}
  }

  return 0;
}

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

#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair


int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin>>n;
    cout<<n*n*n;

    return 0;  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int a[4];
  cin>>a[0]>>a[1]>>a[2];
  int cnt=3;
  if(a[0]==a[1]&&a[1]==a[2]){
    cout<<1<<endl;
    return 0;
  }
  for(int i=0;i<3;i++){
    if(a[i]==a[(i+1)%3])cnt--;
  }
  cout<<cnt<<endl;
}

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

using namespace std;

typedef long long ll;

const ll M = 1e9 + 7;

ll n, k;
ll x;
ll d[105][40005];
ll e[105][40005];
ll ds[105][40005];
ll es[105][40005];
ll a[40005];
ll b[40005];

int main()
{
    scanf("%lld%lld", &n, &k);
    x = sqrt(n);
    if(x * x > n) x++;
    for(ll i = 1; i <= x; i++)
    {
        a[i] = n / i;
    }
    a[x + 1] = x;
    for(ll i = 1; i <= x; i++)
    {
        b[i] = a[i] - a[i + 1];
    }
    for(ll j = 1; j <= x; j++) d[0][j] = 1, e[0][j] = b[j];
    for(ll j = x; j >= 1; j--) es[0][j] = es[0][j + 1] + e[0][j];
    for(ll j = 1; j <= x; j++) ds[0][j] = ds[0][j - 1] + d[0][j];
    for(ll i = 1; i <= k - 1; i++)
    {
        for(ll j = 1; j <= x; j++)
        {
            d[i][j] += ds[i - 1][x];
            d[i][j] += es[i - 1][j];
            e[i][j] += ds[i - 1][j];
            e[i][j] *= b[j];
            d[i][j] %= M;
            e[i][j] %= M;
        }
        for(ll j = x; j >= 1; j--)
        {
            es[i][j] = es[i][j + 1] + e[i][j];
            es[i][j] %= M;
        }
        for(ll j = 1; j <= x; j++)
        {
            ds[i][j] = ds[i][j - 1] + d[i][j];
            ds[i][j] %= M;
        }
    }
    printf("%lld\n", (ds[k - 1][x] + es[k - 1][1]) % M);
    return 0;
}


Measured memory_bytes: 130944
#include <bits/stdc++.h>
#define ll      long long int
#define INF2    ((ll)1e18)
#define pii     pair<ll,ll>
#define x       first
#define y       second
#define vi      vector<ll>
#define pb      push_back
#define sz(a)   (ll)((a).size())
#define all(x)  (x).begin(), (x).end()
#define FIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define W(x)    cout<<#x<<": "<<x<<"\n";
#define SzOf(x) sizeof((x))/1048576;
using namespace std;
template<typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& p){os<<"("<<p.x<<","<<p.y<<") "; return os;}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){for(auto i: v) os<<i<<" "; return os;}

const ll mxN = 1e5;
const ll mod = 1e9+7;

int main(){
    FIO;
	//freopen("input.txt", "r", stdin);
    ll n;
    cin>>n;
    set<string> s;
    string str;
    for(ll i=0;i<n;i++) cin>>str, s.insert(str);
    cout<<s.size();
}




Measured memory_bytes: 19236
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) > (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max();
constexpr long long int mod = 1000000007;

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

    int tmp, result = 0,min_notten=inf;

    REP(i,n){
        cin >> tmp;
        result += tmp;
        if(tmp%10){
            min_notten = min(min_notten, tmp);
        }
    }
    cout << max(0, max((result % 10 > 0) * result, result - min_notten)) << endl;
    

    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

s = set()
for i in range(2, 10**5+5):
    if i in s:
        continue
    cnt = 2
    while i*cnt<=10**5+5:
        s.add(i*cnt)
        cnt += 1

from itertools import accumulate

lis = [0]*(10**5+5)
for i in range(3, 10**5+5, 2):
    if not i in s and not (i+1)//2 in s:
        lis[i] = 1

lis = list(accumulate(lis))
Q = int(input())
for _ in range(Q):
    l, r = mapint()
    print(lis[r]-lis[l-1])

Measured memory_bytes: 89696
# C - Lamps
# imos法, 累積和

N, K = map(int, input().split())
A = list(int(a) for a in input().split())

for _ in range(K):
    B = [0] * (N+1)
    for i, a in enumerate(A):
        left = max(0, i-a)
        right = min(i+a+1, N)
        B[left] += 1
        B[right] -= 1
    for i in range(N):
        B[i+1] += B[i]
    B.pop()
    if A == B:
        break
    else:
        A = B

print(' '.join(map(str, A)))


Measured memory_bytes: 147836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int D, T, S;
    cin >> D >> T >> S;
    cout << (S*T >= D? "Yes" : "No") << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second
#define f(x, y) (y*w+x)

using namespace std;

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

const int N = 100;

const int INF = 1e9;

int dist[N][N];
int field[N][N];

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

int main(){
	int w, h;
	while (cin >> w >> h, w | h){
		int start, goal;
		set<int> s;
		rep(i, h) rep(j, w){
			cin >> field[i][j];
			if (field[i][j] >= 2) s.insert(f(j, i));
			if (field[i][j] == 2) start = f(j, i);
			if (field[i][j] == 3) goal = f(j, i);
		}

		rep(i, h*w) rep(j, h*w) dist[i][j] = INF;
		rep(i, h) rep(j, w) rep(d, 4){
			int nx = j + dx[d];
			int ny = i + dy[d];
			if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
			if (!field[i][j] || !field[ny][nx]) continue;
			dist[f(j, i)][f(nx, ny)] = 1;
		}
		rep(i, h*w) rep(j, h*w) rep(k, h*w) dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);

		rep(i, h*w) rep(j, h*w){
			int x = 0;
			if (s.count(i) && s.count(j)) x = 5;
			if (dist[i][j] > x) dist[i][j] = INF;
		}
		rep(i, h*w) rep(j, h*w) rep(k, h*w) dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);

		int ans = dist[start][goal];
		if (ans == INF) ans = -1;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
K, S = map(int, input().split())

counter = 0

#すべての値が等しい場合 i = j = k
if S%3 == 0:
    counter += 1

for i in range(K):
    yz = S - i
    #2つの値が等しい場合 i < j = k
    if yz%2 == 0 and yz/2 <= K and yz/2 > i:
        counter += 3
    # 2つの値が等しい場合 i = j < k
    if yz - i <= K and yz - i > i:
        counter += 3
    #すべての値が異なる場合 i < j < k
    for j in range(i+1, K):
        k = S - i - j
        if k > j and k <= K:
            counter += 6

print(counter)
print("\n")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
const int T = 1000000001;
int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll tmp = a + b;
	ll ans = n / tmp * a;
	n %= tmp;
	ans += min(a, n);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int main() {
 int n,m;
  cin >> n;
  cout << "ABC" << n << endl;
}

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

class Sample
{
    static void Main()
    {

        // Listの作成
        List<int> list = new List<int>();

        //変数numberに0を入れておく
        int number;
        for (int i = 0; i < 10; i++) 
        {
            number = int.Parse(Console.ReadLine());
            list.Add(number);
        }

        // 降順にソートし、上から3つだけ表示
        foreach (int val in list.OrderByDescending(val => val).Take(3))
        {
            Console.WriteLine(val);
        }
    }


}


Measured memory_bytes: 20264
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io
    
    int n, q;
    cin>>n;
    vector<int> A(n);
    map<int, int> mp;
    rep(i,n) {
        cin>>A[i];
        mp[A[i]]++;
    }
    cin>>q;
    vector<int> B(q), C(q);
    rep(i,q) cin>>B[i]>>C[i];
    ll ans=0;
    rep(i,n){
        ans+=A[i];
    }

    rep(i,q){
        if(mp[B[i]]==0){
            cout<<ans<<endl;
            continue;
        } 
        ans+=(C[i]-B[i])*mp[B[i]];
        mp[C[i]]+=mp[B[i]];
        mp[B[i]]=0;
        cout<<ans<<endl;
    }
    
    return 0;
    
}


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

int a[1000005];
int main() {
  int n; cin >>n;
  long long wa=0;
  for(int i=0;i<n;i++){
    int atai;
    cin>>atai;
    a[atai]++;
    wa+=atai;
  }
  int m;cin>>m;
  for(int i=0;i<m;i++){
    int atai,henka,kazu;
    long long sa;
    cin>>atai>>henka;
    kazu=a[atai];
    sa=(henka-atai)*kazu;
    wa+=sa;
    cout<<wa<<endl;
    a[atai]-=kazu;
    a[henka]+=kazu;
  }
  return 0;
}

Measured memory_bytes: 3984
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;


int main()
{
	int n,k;
	ll ans=0;
	cin>>n>>k;
	if(k>1)
	{
		int m=1;
		int s=n-k+1;
		cout<<s-m<<endl;
	}else
		cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int n, yi, er, k;
vector<int>v[100005];
main() {
	cin >> n;
	int sq;
	sq = sqrt(n * 2);
	if(sq * (sq + 1) != n * 2) {
		puts("No");
		return 0;
	} 
	yi = 1, er = 2;
	k = sq + 1;
	int i;
	for(i = 1; i <= n; ++i) {
		v[yi].push_back(i);
		v[er].push_back(i);
		if(er < k) ++er;
		else ++yi, er = yi + 1;
	}
	puts("Yes");
	cout << k << endl;
	int j;
	for(i = 1; i <= k; ++i) {
		cout << v[i].size() << " " ;
		for(j = 0; j < v[i].size(); ++j) cout << v[i][j] << " " ;
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int N,K;
  cin>>N;
  string S;
  cin>>S;
  cin>>K;
  rep(i,N){
    if(S[i]!=S[K-1]) cout<<"*";
    else cout<<S[i];
  }
  cout<<endl;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

//constexpr int inf = 2147483647;
//constexpr int64_t inf64 = 9223372036854775807;
//constexpr int mod = 1e9+7;

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

  int64_t a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;

  if(v < w) cout << "NO" << endl;
  else if(abs(a-b) <= (v-w)*t) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 3600
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>

//T1: Give you a tree.
//You can delete all of the leaves or save one leave when it's your turn.
//The person who can't do anything will lose the game.

const int N=200005;

int n,head[N];

struct Edge
{
	int next,to;
};
Edge E[N<<1];
int tot;
void add(int u,int v)
{
	E[++tot].next=head[u];
	E[tot].to=v;
	head[u]=tot;
}

namespace subtask3
{

int main()
{
	if(n%3==2)puts("Second");
	else puts("First");
	return 0;
}

}//namespace subtask3

int dis[N];
void dfs(int u,int fa)
{
	for(int i=head[u];i;i=E[i].next)
	{
		int v=E[i].to;
		if(v==fa)continue;
		dis[v]=dis[u]+1;
		dfs(v,u);
	}
}

int rho()
{
	dis[1]=0;
	dfs(1,0);
	int res=0;
	for(int i=1;i<=n;++i)
	{
		if(dis[i]>dis[res])res=i;
	}
	dis[res]=0;
	dfs(res,0);
	for(int i=1;i<=n;++i)
	{
		if(dis[i]>dis[res])res=i;
	}
	return dis[res]+1;
}

int main()
{
	int T=1;
	while(T--)
	{
		bool s3_flag=1;
		tot=0;
		memset(head,0x00,sizeof(head));
		scanf("%d",&n);
		for(int i=1;i<n;++i)
		{
			int u,v;
			scanf("%d%d",&u,&v);
			add(u,v);
			add(v,u);
			if(u!=i||v!=i+1)s3_flag=0;
		}
		if(s3_flag)
		{
			subtask3::main();
			continue;
		}
		n=rho();
		subtask3::main();
	}
}


Measured memory_bytes: 14208
void main() {
	auto ip = readAs!(long[]), N = ip[0], M = ip[1];
	
	alias Pair = Tuple!(long, "a", long, "b");
	Pair[] paths;
	
	foreach(i; 0..M) {
		auto ip2 = readAs!(long[]), A = ip2[0], B = ip2[1];
		paths ~= Pair(A-1, B-1);
	}
	
	auto uf = new UnionFind!long(N);
	long[] arr;
	long[] res = [N*(N-1)/2];
	long tmp = N*(N-1)/2;
	foreach_reverse(i; paths) {
		if(!uf.same(i.a, i.b)) tmp -= uf.size(i.a) * uf.size(i.b);
		uf.unite(i.a, i.b);
		res ~= tmp;
	}
	
	foreach_reverse(i; res[0..$-1]) i.writeln;
}

class UnionFind(T) {
	T[] arr;
	this(ulong n) {
		arr.length = n;
		arr[] = -1;
	}
	T root(T x) {
		return arr[x] < 0 ? x : root(arr[x]);
	}
	bool same(T x, T y) {
		return root(x) == root(y);
	}
	bool unite(T x, T y) {
		x = root(x);
		y = root(y);
		if(x == y) return false;
		if(arr[x] > arr[y]) swap(x, y);
		arr[x] += arr[y];
		arr[y] = x;
		return true;
	}
	T size(T a) {
		return -arr[root(a)];
	}
}
// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 6268
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n), b(n); 
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	int suma = 0; int sumb = 0;
	rep(i, n) {
		suma += a[i], sumb += b[i];
	}
	if (suma < sumb) { COUT(-1); return 0; }
	int ans = 0;
	int cnt = 0;
	VE tmp(n);
	int tmp2 = 0;
	rep(i, n) {
		if (a[i] < b[i]) {
			ans++;
			cnt += b[i] - a[i];
		}
		else {
			tmp[tmp2] = a[i] - b[i]; tmp2++;
		}
	}
	if (ans == 0) {
		cout << 0 << endl; return 0;
	}
	sort(ALLR(tmp));
	rep(i, n) {
		if (cnt <= tmp[i]) {
			ans++; break;
		}
		else {
			ans++;
			cnt -= tmp[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
# -*- coding: utf-8 -*-
from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
def inpl(): return tuple(map(int, input().split()))
 
N, M = inpl()
A = inpl()
tree = [[-1, 1]  for _ in range(N)] # [next, rank]
 
def find(i):
    if tree[i][0] == -1:
        group = i
    else:
        group = find(tree[i][0]) 
        tree[i][0] = group
    return group
  
def unite(x, y):
    px = find(x)
    py = find(y)
      
    if tree[px][1] == tree[py][1]: # rank is same
        tree[py][0] = px
        tree[px][1] += 1
    else:
        if tree[px][1] < tree[py][1]:
            px, py = py, px
        tree[py][0] = px
  
for _ in range(M):
    x, y = tuple(map(int, input().split()))
    if not int(find(x) == find(y)):
        unite(x, y)
 
D = defaultdict(list)
for n in range(N):
    D[find(n)].append(A[n])
 
H = []
res = 0 

for k, v in D.items():
    v = sorted(v)
    res += v[0]
    H.extend(v[1:])
 
if N < 2*(N-M-1):
    print("Impossible")
elif M == N-1:
    print(0)
else:
    res += sum(sorted(H)[:2*(N-M-1) - len(D.keys())])
    print(res)

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

int main() {
    int n;
    cin>>n;
    string s;
    ll ans=0;
    vector<ll> a(5,0);
    rep(i,n) {
        cin>>s;
        if (s[0]=='M') a[0]++;
        else if(s[0]=='A') a[1]++;
        else if(s[0]=='R') a[2]++;
        else if(s[0]=='C') a[3]++;
        else if(s[0]=='H') a[4]++;
    }
    for (int i=0; i<3; i++) {
        for (int j=i+1; j<4; j++) {
            for (int k=j+1; k<5; k++) {
                ans+=a[i]*a[j]*a[k];
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        int[] list = new int[n];
        for (int i = 0; i < n; i++) {
            list[i] = sc.nextInt();
            ans += list[i];
        }
        Arrays.sort(list);
        System.out.println(ans - (list[n-1] / 2));
    }
}

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

int main(){
	int r,w,c,R;
	while(1){
		int count = 0;
		cin >> r >> w >> c >> R;
		if(r == 0)break;
		if(w*c<=r){
		}
		else if((w*c-r)%R == 0){
			count = (w*c-r)/R;
		}
		else count = (w*c-r)/R + 1;
		cout << count << endl;
	}	
	return 0;
}

Measured memory_bytes: 3068
#encoding utf-8

n = int(input())
m=n
answer = []

def kenzan(ans):
    val = 0
    ans.reverse()
    for i in range(len(ans)):
        val += answer[i]*(-2)**i
    return int(val)

i = 1
while(n != 0):
    # print(n)
    if n % (2**i) == 0:
        answer.append(0)
    else:
        answer.append(1)
        n = n-((-2)**(i-1))
    i += 1
answer.reverse()
if answer == []:
    answer.append(0)
print("".join(str(i) for i in answer))
# print(kenzan(answer))


Measured memory_bytes: 3064
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define ull unsigned long long
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;
const int MOD=1e9+7;

int main()
{
    int w,a,b;
    in w>>a>>b;
    if(abs(b-a)<=w)cout<<0<<endl;
    else cout<<abs(b-a)-w<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    int n;
    cin >> n;
    string s;
    cin >> s;
   // int run = 1;
    int ans = 0;
    FOR(i, 0, n) {
        if (i + 1 < n && s[i] == s[i + 1]) {
          //  run++;
        } else {
            ans++;
          //  run = 1;
        }
    }
    cout << ans;
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting, graph is not a tree/connected
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 512
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cassert>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define ff first
#define ss second
typedef long long ll;
#define dforn(i, n) for(int i = n - 1; i >= 0; i--)

const int MAXN = 256;

string s;
int n;
bool used[MAXN];

int main() {
    //~ freopen("A.in", "r", stdin);
    while(cin >> s){
        if(s == "zyxwvutsrqponmlkjihgfedcba"){
            printf("-1\n");
            continue;
        }

        memset(used, false, sizeof used);
        
        if(s.size() == 26){
            string old = s;
            next_permutation(s.begin(), s.end());
            string t;
            forn(i, s.size()){
                t.pb(s[i]);
                if(t > old){
                    cout << t << endl;
                    break;
                }
            }
        }
        else {
            forn(i, s.size()){
                used[ s[i] - 'a' ] = true;
            }
            forn(i, 30){
                if(!used[i]){
                    cout << s << (char) (i + 'a') << endl;
                    break;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
typedef struct{
  int id;
  int left;
  int right;
  int parent;
} node;
 
node tree[25];
 
void inorder(int);
void preorder(int);
void postorder(int);
 
int main(){
 
  int n,i,j,count,k,m,l,r;
 
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++) tree[i].parent = -1;
   
  for(i=0;i<n;i++){
    scanf("%d",&m);
    tree[m].id = m;
    scanf("%d%d",&tree[m].left,&tree[m].right);
    tree[tree[m].left].parent = tree[m].id;
    tree[tree[m].right].parent = tree[m].id;
  }
 
   
   
  for(i=0;tree[i].parent != -1;i++);
  printf("Preorder\n");
  preorder(i);
  printf("\n");
  printf("Inorder\n");
  inorder(i);
  printf("\n");
  printf("Postorder\n");
  postorder(i);
  printf("\n");
   
  return 0;
}    
     
     
void preorder(int x){
   printf(" %d",tree[x].id);
   if(tree[x].left != -1) preorder(tree[x].left);
   if(tree[x].right != -1) preorder(tree[x].right);
}
void inorder(int x){
   if(tree[x].left != -1) inorder(tree[x].left);
   printf(" %d",tree[x].id);
   if(tree[x].right != -1) inorder(tree[x].right);
}
void postorder(int x){
   if(tree[x].left != -1) postorder(tree[x].left);
   if(tree[x].right != -1) postorder(tree[x].right);
   printf(" %d",tree[x].id);
}

Measured memory_bytes: 616
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static double weight;
	public static void main(String[] args) {
		while(read()){
		slove();
		}
	}

	static boolean read(){
		if(!sc.hasNextDouble())return false;
		
		weight = sc.nextDouble();
		return true;
	}
	static void slove(){
		//System.out.println(weight);
		if(weight <= 48.00){
			System.out.println("light fly");
		}else if(weight <= 51.00){
			System.out.println("fly");
		}else if(weight <= 54.00){
			System.out.println("bantam");
		}else if(weight <= 57.00){
			System.out.println("feather");
		}else if(weight <= 60.00){
			System.out.println("light");
		}else if(weight <= 64.00){
			System.out.println("light welter");
		}else if(weight <= 69.00){
			System.out.println("welter");
		}else if (weight <= 75.00){
			System.out.println("light middle");
		}else if (weight <= 81.00){
			System.out.println("middle");
		}else if(weight <= 91.00){
			System.out.println("light heavy");
		}else{
			System.out.println("heavy");
		}
	}
}

Measured memory_bytes: 11000
#include <iostream>
#include <vector>

int judg(std::vector<std::vector<int>> a, int i){
    int tmp = 0;
    for(auto j = 0; j < a.size(); j++){
        for(auto k = 0; k < a.at(j).size(); k++){
            if(a.at(j).at(k) == i){
                tmp++;
                break;
            }
        }
    }

    if(tmp == a.size()){
        return 1;
    }
    return 0;
}

int main(){
    int N, M, ans = 0;
    std::cin >> N >> M;
    std::vector<std::vector<int>> A(N);
    std::vector<int> K(N);
    for(auto i = 0; i < N; i++){
        std::cin >> K.at(i);
        A.at(i).resize(K.at(i));
        for(auto j = 0; j < K.at(i); j++){
            std::cin >> A.at(i).at(j);
        }
    }

    for(auto i = 1; i <= M; i++){
        ans += judg(A, i);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
//llじゃなく

int main(){
  string s;cin>>s;
  int size = s.length();
  int diff = INF;
  rep(i,size-2){
    int ss = abs(753-stol(s.substr(i,3)));
    if(diff>ss){
      diff = ss;
    }
  }
  cout << diff << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
  string a, b;
  cin >> a >> b;
  
  int answer = 0;
  for(int i = 0; i < 3; i++){
    if(a[i] == b[i]) answer++;
  }
  
  cout << answer << '\n';
  
  return 0;
}

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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
constexpr int loose = 0;
constexpr int tight = 1;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

Matrix mIdentity(ll n) {
 Matrix A(n, Array(n));
 for (int i = 0; i < n; ++i) A[i][i] = 1;
 return A;
}

Matrix mMul(const Matrix& A, const Matrix& B) {
 Matrix C(A.size(), Array(B[0].size()));
 for (int i = 0; i < C.size(); ++i)
  for (int j = 0; j < C[i].size(); ++j)
   for (int k = 0; k < A[i].size(); ++k)
    (C[i][j] += (A[i][k] % MOD) * (B[k][j] % MOD)) %= MOD;
 return C;
}
// O( n^3 log e )
Matrix mPow(const Matrix& A, ll e) {
 return e == 0 ? mIdentity(A.size()) :
  e % 2 == 0 ? mPow(mMul(A, A), e / 2) : mMul(A, mPow(A, e - 1));
}

void solve(){
	ll n,k;
	cin>>n>>k;
	Matrix a(n,Array(n,0));
	REP(i,n) REP(j,n) cin>>a[j][i];

	Matrix f=mPow(a,k);
	Matrix x(n,Array(1,1));
	Matrix y = mMul(f,x);

	ll ans=0;
	REP(i,n) (ans+=y[i][0])%=MOD;
	cout<<ans<<en;
}

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

    solve();
    return 0;
}

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

#define MAX 1000000001
long long CNT = 0;

void merge(long long a[], int begin, int end, int mid) {
	queue<long long> left;
	queue<long long> right;
	for (int i = begin; i < mid; i++)left.push(a[i]);
	for (int i = mid; i < end; i++)right.push(a[i]);
	left.push(MAX);
	right.push(MAX);

	int cnt = left.size() - 1;
	for (int i = begin; i < end; i++) {
		if (left.front() < right.front()) {
			a[i] = left.front();
			left.pop();
			cnt--;
		}
		else {
			a[i] = right.front();
			right.pop();
			CNT += cnt;
		}
	}
}

void m_sort(long long a[], int begin, int end) {
	if (begin >= end - 1)return;
	int mid = (begin + end) / 2;
	
	m_sort(a, begin, mid);
	m_sort(a, mid, end);

	merge(a, begin, end, mid);
}

int main() {
	long long ary[200000];
	int n;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ary[i];
	}

	m_sort(ary, 0, n);

	cout << CNT << endl;
	return 0;
}

Measured memory_bytes: 5928
def Check(A) :
    Set = 0
    if len(A) < 3 :
        return False
    else :
        a = 0
        while True :
            if a >= len(A)-2 :
                break
            if A[a] == A[a+1] and A[a] == A[a+2] :
                Set += 1
                youso = A[a]
                A.remove(youso)
                A.remove(youso)
                A.remove(youso)
                a = 0
            elif A[a]+1 in A and A[a]+2 in A :
                Set += 1
                youso = A[a]
                A.remove(youso)
                A.remove(youso+1)
                A.remove(youso+2)
                a = 0
            else :
                a += 1
        return Set

n = int(input())
for i in range(n) :
    card = list([0, "X"] for i in range(9))
    R = []
    G = []
    B = []
    tmp = list(map(int,input().split()))
    for j in range(9) :
        card[j][0] = tmp[j]
    tmp = list(input().split())
    for j in range(9) :
        card[j][1] = tmp[j]
        if tmp[j] == "R" :
            R.append(card[j][0])
        elif tmp[j] == "G" :
            G.append(card[j][0])
        else :
            B.append(card[j][0])
    
    R.sort()
    G.sort()
    B.sort()
    if Check(R) + Check(G) + Check(B) == 3 :
        print(1) 
    else :
        print(0)


Measured memory_bytes: 5616
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mp make_pair
# define P pair<int, int>
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
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; }

static const ll INF = 1e15;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main(){
  int n, m; cin >> n >> m;
  UnionFind tree(n);
  rep(i, m){
    int a, b; cin >> a >> b;
    --a; --b;
    tree.unite(a, b);
  }

  int ans = 0;
  vector<int> roots(n, 0);
  rep(i, n){
    int x = tree.root(i);
    ++roots[x];
    chmax(ans, roots[x]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 11172
#include<stdio.h>
int main()
{
	char b;
	scanf("%c",&b);
	if(b=='A'){
		printf("T\n");
	}
	if(b=='C'){
		printf("G\n");
	}
	if(b=='G'){
		printf("C\n");
	}
	if(b=='T'){
		printf("A\n");
	}
	return 0;
}


Measured memory_bytes: 128
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

mod = 998244353

for i in range(n):
    for j in range(m):
        a[i][j] = a[i][j] % 2

# 掃き出し法
rank = 0
for i in range(n):
    target = -1
    for j in range(rank, m):
        if a[i][j]:
            target = j
            break

    if target == -1:
        continue

    if target != rank:
        for k in range(rank, n):
            a[k][rank], a[k][target] = a[k][target], a[k][rank]

    for k in range(i+1, n):
        if a[k][rank]:
            for j in range(m):
                a[k][j] ^= a[i][j]

    rank += 1


def modpow(a, n, mod=mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res

print(modpow(2, m-1) * (modpow(2, n) - modpow(2, n-rank)) % mod)


Measured memory_bytes: 3956
<?php
fscanf(STDIN, "%d", $a);
fscanf(STDIN, "%s", $b);

if ($a % 2 != 0) {
  echo 'No';
} else {
  $b1 = substr($b, 0, $a/2);
  $b2 = substr($b, $a/2, $a/2);

  if ($b1 == $b2) {
    echo 'Yes';
  } else {
    echo 'No';
  }
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

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


int main(){
	
	ll n,m,d;cin >> n >> m >> d;
	
	long double seica;
	if(d == 0){
		seica = 1. / n;
	}
	else{
		seica = 2. * (n - d) / (n * n);
	}
	
	cout << Decimal << seica * (m - 1) << endl;
	

	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n = 0; string s; cin >> s;
	for (int h = 0; h < s.size(); h++) {
		if (s[h] == 'o') {
			n++;
		}
	}
	if (15 - s.size() + n >= 8) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	cin >> n;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int, int> P;
int main(){
  int n, i, j, ans=0, kari=0;
  cin >> n;

  if(n==1){
    cout << 1;
    return 0;
  }

  
  P z[n], a[n*n];

  for(i=0; i<n*n; i++){
    a[i].first=0;
    a[i].second=0;
  }
  
  for(i=0; i<n; i++)
    cin >> z[i].first >> z[i].second;
  sort(z, z+n);
  for(i=0; i<n; i++)
    for(j=i+1; j<n; j++){
      a[i*n+j].first=z[i].first-z[j].first;
      a[i*n+j].second=z[i].second-z[j].second;
    }
  sort(a, a+n*n);
  for(i=0; i<n*n-1; i++)
    if(a[i].first!=0||a[i].second!=0){
      if(a[i].first==a[i+1].first&&a[i].second==a[i+1].second){
	kari++;
	if(kari>ans) ans=kari;
      }
      else{
	kari=0;
      }
    }
  cout << n-1-ans;
  return 0;
}


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

using namespace std;

static constexpr int MAX_S = 3;

string a = {}, b = {};

void input()
{
  cin >> a;
  cin >> b;
}

void solve()
{
  reverse(a.begin(), a.end());
  printf(a == b ? "YES" : "NO");
}

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

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

using namespace std;
using ll = long long;


int main()
{
    int n; cin >> n;
    vector<vector<int>> unit;

    if(n & 1) {
        for(int i = 0; i < n / 2; i++) {
            unit.push_back({i + 1, n - i - 1});
        }
        unit.push_back({n});
    } else {
        for(int i = 0; i < n / 2; i++) {
            unit.push_back({i + 1, n - i});
        }
    }


    int m = unit.size();
    vector<pair<int,int>> edge;

    for(int i = 0; i < m; i++) {
        for(int j = i + 1; j < m; j++) {

            for(auto k : unit[i]) {
                for(auto l : unit[j]) {
                    edge.push_back({k, l});
                }
            }
        }
    }

    cout << edge.size() << endl;
    for(auto i : edge)cout << i.first << " " << i.second << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(11);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int a, b;
  cin >> a >> b;
  int h;
  cin >> h;
  cout << (a + b) * h / 2 << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	 
	static String str;
	
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		int a=cin.nextInt(),b=cin.nextInt(),C=cin.nextInt();
		System.out.println(a*b*Math.sin(Math.toRadians(C))/2);
		System.out.println((a+b+Math.sqrt(Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*Math.cos(Math.toRadians(C)))));
		System.out.println(b*Math.sin(Math.toRadians(C)));
	}
	
	
	
}


Measured memory_bytes: 26184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	ll n,k;
	cin >> n >> k;

	if(n>=k){
		n %= k;
	}
	ll x = k-n;
	if(x < 0) x = -1*x;
	ll ans = min(n,x);
	cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

ll N;
string s;
vector<ll> v[3];

int main(){
    cin >> N;
    cin >> s;
    for(int i=0;i<N;i++){
        if(s[i] == 'R') v[0].push_back(i);
        if(s[i] == 'G') v[1].push_back(i);
        if(s[i] == 'B') v[2].push_back(i);
    }
    ll sum = 0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(s[i] == s[j]) continue;
            ll diff = j - i;
            ll index = -1;
            if((s[i] == 'R' || s[i] == 'G') && (s[j] == 'R' || s[j] == 'G')){
                index = 2;
            }
            if((s[i] == 'R' || s[i] == 'B') && (s[j] == 'R' || s[j] == 'B')){
                index = 1;
            }
            if((s[i] == 'B' || s[i] == 'G') && (s[j] == 'B' || s[j] == 'G')){
                index = 0;
            }
            auto itr = upper_bound(v[index].begin(),v[index].end(),j);
            sum += v[index].end() - itr;
            if(binary_search(v[index].begin(),v[index].end(),j + diff)) sum--;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3724