akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int D;
  cin >>D;
  
  if(D == 22){
    cout<<"Christmas Eve Eve Eve"<<endl;
  }else if(D==23){
    cout <<"Christmas Eve Eve"<<endl;
  }else if(D==24){
    cout << "Christmas Eve"<<endl;
  }else if(D==25){
    cout << "Christmas"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
#define INF 1000000007;
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; }

int dp[100010];
int cost[100010];
int main(){
    int n,K;
    cin >> n >> K;
    rep(i,n){
        cin >> cost[i];
        dp[i] = INF;
    }
    dp[0] = 0;
    rep(i,n){
        FOR(k,1,K+1){
            chmin(dp[i + k],dp[i] + abs(cost[i + k] - cost[i]));
        }
    }
    PRINT(dp[n-1]);
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second

typedef pair<lint, lint> P;
const lint MOD = 1e9+7;
const lint INF = MOD * MOD;
const int MAX = 100005;

int main(){
    int h, w, n; cin>>h>>w>>n; int ans = 100000;
    rep(i, h+1){
        rep(j, w+1){
            int b = h * w - (h - i)*(w - j);
            if(b >= n) ans = min(ans, i + j);
        }
    }
    cout << ans << endl;
}

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

using namespace std;

const int N = 105, MAX_K = 1e5 + 5;
int n, K, a[N], dp[MAX_K];

int main () {
    scanf("%d %d", &n, &K);
    for (int i = 1; i <= n; ++i) scanf("%d", a + i);

    for (int i = 1; i <= K; ++i) {
        for (int j = 1; j <= n; ++j) if (i >= a[j] && !dp[ i - a[j] ]) dp[i] = 1;
    }

    if (dp[K]) cout << "First";
    else cout << "Second";

    return 0;
}


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

using namespace std;

int main(){
	int N, K, X, Y;

	cin>>N>>K>>X>>Y;

	if(N<=K){
		cout<<X*N<<endl;
	}else{
		cout<<X*K+Y*(N-K)<<endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

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

  bool judge = true;

  std::string S, rev;
  std::cin >> S;
  ll N = S.length();

  // ------------------------------------------
  rev = S;
  std::reverse(rev.begin(), rev.end());
  if (S != rev) judge = false;

  // ------------------------------------------
  std::string S2 = S.substr(0, (N-1)/2);
  rev = S2;
  std::reverse(rev.begin(), rev.end());
  if (S2 != rev) judge = false;

  // ------------------------------------------
  std::string S3 = S.substr((N+3)/2 - 1);
  rev = S3;
  std::reverse(rev.begin(), rev.end());
  if (S3 != rev) judge = false;



  if (judge) print("Yes");
  else print("No");

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    string s;
    cin >> s;

    string r;
    for (auto& c : s) {
        if (c == 'B') {
            if (!r.empty()) r.pop_back();
        } else {
            r.push_back(c);
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
map<ll,ll>u;
int main()
{

    ll n,m,i,j,k,p,q,o,l,s,t;
    cin>>n>>m;
    u[n]++;
    u[m]++;
    if(u[3]!=1)
    {
        cout<<3<<endl;
    }
    else if(u[2]!=1)
    {
        cout<<2<<endl;
    }
    else
    {
        cout<<1<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(input())
B = list(input())
C = list(input())

counter = 0

for i in range(N):
  if A[i] == B[i] and B[i] == C[i]:
    pass
  elif (A[i] == C[i] and A[i] != B[i]) or (A[i] == B[i] and C[i] != B[i]) or (B[i] == C[i] and A[i] != B[i]):
    counter += 1
  elif (A[i] != B[i] and B[i] != C[i] and C[i] != A[i]):
    counter += 2

print(counter)

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

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  ll tot = m * 1900 + (n - m) * 100;
  for(int i = 1; i <= m; ++i) {
    tot *= 2;
  }
  printf("%lld\n", tot);
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//MIN

bool p_judge(ll p) {

	if (p == 1)return false;
	else if (p == 2)return true;
	else {

		bool flag = true;
		for (int i = 2; i <= sqrt(p); i++) {

			if (p%i == 0) {

				flag = false;
				break;

			}

		}
		return flag;

	}

}
//素数判定,素数=true,合成数=false

int main() {

	int N, F[105][20], P[105][20];
	ll ans = -10000000 * 100 - 1;

	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {

			cin >> F[i][j];

		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 11; j++) {

			cin >> P[i][j];

		}
	}

	for (int i = 1; i < 1024; i++) {

		ll p = 0;
		int cnt[105];
		for (int j = 0; j < N; j++)cnt[j] = 0;

		for (int j = 0; j < 10; j++) {

			if (i >> j & 1) {

				for (int k = 0; k < N; k++) {

					if (F[k][j] == 1)cnt[k]++;

				}

			}

		}

		for (int j = 0; j < N; j++) {

			p += P[j][cnt[j]];

		}
		ans = MAX(ans, p);

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/*
  ___    ___             ___    __                   _     _   _
 |   \  /   |           |   \  |  |                 | |   (_) | |
 |    \/    |  _ __     |    \ |  |   __ _   _____  | |_   _  | | __
 |  |\  /|  | | '__|    |  |\ \|  |  / _' | |  ___) | __| | | | |/ /
 |  | \/ |  | | |    _  |  | \    | | (_| | |___  | | \_  | | |   /
 |__|    |__| |_|   (_) |__|  \___|  \__,_| (_____|  \__| |_| |_|\_\

 */

 #include<bits/stdc++.h>
 using namespace std;
 #define ll long long
 #define M 1000000007
 #define endl "\n"

 int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    unsigned ll s;
    cin>>s;
    if(s&1) return cout<<0,0;
    s/=2;
    unsigned ll ans=0;
while(s>4)
{
    s=s/5;
    ans+=s;
}
    cout<<ans;
 }



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

#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;
vector<int>t;
int n,c,k;
bool good(int num)
{
    int cnt=1;
    int last=t[0];
    int numofPass=1;
    for(int i=1;i<n;i++)
    {
        if(numofPass==c)
        {
            last=t[i];
            cnt++;
            numofPass=1;
        }
        else if(t[i]<=last+k)
        {
            numofPass++;
        }
        else{
            cnt++;
            last=t[i];
            numofPass=1;
        }
    }
    return cnt<=num;
}
int32_t main() {
    nitin;
    cin>>n>>c>>k;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        t.push_back(a);
    }
    sort(t.begin(),t.end());
    int s=0;
    int e=n;
    while(s+1<e)
    {
        int mid=(s+e)/2;
        if(good(mid))
            e=mid;
        else
            s=mid;
    }
    cout<<e<<endl;
    return 0;
}

Measured memory_bytes: 4272
from math import factorial

def main():
    n, m = map(int, input().split())
    r = 0
    if n >= 2:
        r += factorial(n) / (2 * factorial(n - 2))
    if m>= 2:
        r += factorial(m) / (2 * factorial(m - 2))

    print(int(r))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}


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


	int N;
	cin >> N;
	pair<ull, ull> AB[200001];
	int a0 = 0, b0 = 0;
	int ab00 = 0;
	int ka = 0, kb = N - 1;
	rep(i, N) {
		ll a, b;
		cin >> a >> b;

		if (a == 0 && b == 0) {
			ab00++;
			continue;
		}
		if (a == 0) {
			a0++;
			continue;
		}
		if (b == 0) {
			b0++;
			continue;
		}

		if (a < 0) {
			a = -a;
			b = -b;
		}
		bool p = (b > 0);
		if (!p) {
			b = -b;
			swap(a, b);
		}

		int k = __builtin_clzll(a) - __builtin_clzll(b);
		if (k > 0) a <<= k;
		else b <<= -k;
		if (a > b) {
			b <<= 1;
			k--;
		}
		b -= a;
		b <<= 1;

		ull tmp1 = ull(k + 64) << 57, tmp2 = 0;
		for (int i = 56; i >= 0; i--) {
			if (b >= a) {
				tmp1 += (1ull << i);
				b -= a;
			}
			b <<= 1;
		}
		for (int i = 63; i >= 0; i--) {
			if (b >= a) {
				tmp2 += (1ull << i);
				b -= a;
			}
			b <<= 1;
		}
		if (p) AB[ka++] = { tmp1,tmp2 };
		else AB[kb--] = { tmp1,tmp2 };
	}
	auto BA = AB + kb + 1;
	kb = N - 1 - kb;
	ll kotae = 1;
	sort(AB, AB + ka);
	sort(BA, BA + kb);
	BA[kb] = { 100, 1ll << 63 };

	pair<ull, ull> mae = AB[0];
	int p = 0;
	int kA = 0;
	rep(i, ka) {
		if (mae != AB[i]) {
			int tmp = 0;

			pair<ull, ull> mae2 = BA[p];
			int kB = 0;
			while (p < kb && BA[p] <= mae) {
				if (mae2 != BA[p]) {
					kotae = kotae * modpow(2, kB) % mod;
					mae2 = BA[p];
					kB = 1;
				}
				else kB++;
				p++;
			}

			if (mae == mae2) {
				tmp = kB;
			}
			else {
				kotae = kotae * modpow(2, kB) % mod;
			}

			if (tmp) {
				kotae = kotae * (modpow(2, kA) + modpow(2, kB) - 1) % mod;
			}
			else {
				kotae = kotae * modpow(2, kA) % mod;
			}

			mae = AB[i];
			kA = 1;
		}
		else kA++;
	}

	int tmp = 0;
	pair<ull, ull> mae2 = BA[p];
	int kB = 0;
	while (p < kb) {
		if (mae2 != BA[p]) {
			if (AB[ka - 1] == mae2) {
				tmp = kB;
			}
			else {
				kotae = kotae * modpow(2, kB) % mod;
			}
			mae2 = BA[p];
			kB = 1;
		}
		else kB++;
		p++;
	}

	if (AB[ka - 1] == mae2) {
		tmp = kB;
	}
	else {
		kotae = kotae * modpow(2, kB) % mod;
	}

	if (tmp) {
		kotae = kotae * (modpow(2, kA) + modpow(2, kB) - 1) % mod;
	}
	else {
		kotae = kotae * modpow(2, kA) % mod;
	}

	kotae = kotae * (modpow(2, a0) + modpow(2, b0) - 1) % mod;

	co((kotae - 1 + ab00 + 2 * mod) % mod);

	Would you please return 0;
}

Measured memory_bytes: 6740
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)




using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll Nmax=1e9;
const ll INF=1e9;

int main(){
  int n,m;
  cin>>n>>m;
  if(n==m){
    cout<<"Yes"<<endl;

  }else{
    cout<<"No"<<endl;

  }


}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
char s[99];
int total;
void WA() {
	printf("WA\n");
	exit(0);
}
int main() {
	cin >> s;
	if (s[0] == 'A' && ((s[1] >= 'a' && s[1] <= 'z') || s[1] == 'A') && s[strlen(s) - 1] != 'C') {
		for (int i = 2; i < strlen(s); ++i) {
			if (s[i] == 'A') continue;
			if (s[i] == 'C' &&  i != strlen(s) - 1) total++;
			else if (s[i] < 'a' || s[i] > 'z' ) WA();
			if (total == 2) WA();
		}
		if (total == 1) printf("AC\n");
		else printf("WA\n");
	}
	else WA();
	return 0;
}

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

using namespace std;

using State = string::const_iterator;
             
int expression(State& s);

int number(State& s)
{
	int res = 0;
	while (isdigit(*s)) {
		res *= 10;
		res += *s - '0';
		s++;
	}
	return res;
}

int factor(State& s)
{
	if (*s == '(') {
		s++;
		int res = expression(s);
		s++;
		return res;
	} else {
		return number(s);
	}
}

int term(State& s)
{
	int res = factor(s);
	while (true) {
		if (*s == '*') {
			s++;
			res *= factor(s);
		} else if (*s == '/') {
			s++;
			res /= factor(s);
		} else {
			break;
		}
	}
	return res;
}

int expression(State& s)
{
	int res = term(s);
	while (true) {
		if (*s == '+') {
			s++;
			res += term(s);
		} else if (*s == '-') {
			s++;
			res -= term(s);
		} else {
			break;
		}
	}
	return res;
}

int main()
{
    int q;
    cin >> q;
    while (q--) {
        string st;
        cin >> st;
		State s = st.begin();
        cout << expression(s) << endl;
    }
}


Measured memory_bytes: 3160
def main():
    S = input()
    S_set = set(list(S))
    C_set = set([chr(ord("a") + i) for i in range(26)])

    if len(S_set) == len(C_set):
        S = list(S)
        p = None
        for i in range(len(S) - 2, -1, -1):
            if S[i] < S[i + 1]:
                p = i
                break
        else:
            print(-1)
            return

        ans = S[:p].copy()
        rest = C_set - set(S[: p + 1])
        rest = sorted(rest)
        for r in rest:
            if S[p] < r:
                ans.append(r)
                break
        print(*ans, sep="")
    else:
        diff = C_set - S_set
        diff = sorted(diff)
        print(S + diff[0])
        return


main()


Measured memory_bytes: 3064
/*
memo for solution
*/
#include <cstdlib> 
#include <numeric>
#include <cstring>
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <cmath> 
#include <climits> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <iomanip>
#include<sys/time.h>
using namespace std; 
double e_time(void){static struct timeval now;gettimeofday(&now, NULL);return (double)(now.tv_sec  + now.tv_usec/1000000.0);}
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
#define fe(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr != (c).end();itr++)
#define BITSHIFT(X)     ( (1<<(X)) )
#define CONTAIN(S,X) ( ((S)&BITSHIFT(X)) != 0)
typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
template<class T> T ceilUp(const T& a,const T& b){return (a+b-1)/b;}
const ll mod =   1000000009;
inline ll modadd(ll a,ll b){a %= mod;b %= mod;return (a+b)%mod;}
inline ll modsub(ll a,ll b){a %= mod;b %= mod;a-=b;a%=mod;if (a<0)a+=mod;return a;}
inline ll modmul(ll a,ll b){a %= mod;b %= mod;return (a*b)%mod;}
inline ll modeq(ll a,ll b,ll m){a = (a%m+m)%m; b = (b%m+m)%m;return a == b;}
//ll modpow(ll n,ll p){if (p == 0)return 1;if (p == 1)return n;ll ret=mypow(n,p/2);ret=ret*ret%mod;if (p&1)ret=ret*n%mod;return ret;}
//ll getinv(ll a){return mypow(a,mod-2);}


int cnt= 0 ;
int all;
void make(int n, int m, int d, int ar[]){
  if (m == -1){
    for(int i = 0;i < 2;i++){
      if (std::abs(ar[i] - ar[i+1]) == d){
	cnt++;
      }
    }
    all++;
    return;
  }
  for(int i = 1;i <= n;i++){
    ar[m] = i;
    make(n, m-1, d, ar);
  }
}

void compute(int d){
  int n = 9, m = 3;
  //int n = 2, m = 3, d = 1;
  int ar[m];
  cnt = 0;
  all = 0;
  make(n, m-1, d, ar);
  cout << "// " << n <<" " << m <<" " << d <<" " << cnt << " " << all <<" " << cnt / (double)all << endl;
}

// C3: n =10, m = 3, d = 6 -> 0.16
// C4: n=9, m=3, d= 6 -> 0.148148
// C5: n=9, m=3, d=3 -> 0.296296
// C6: n=9, m=3, d=0 -> 0.222222
// C7: 

// 9 3 0 162 729 0.222222
// 9 3 1 288 729 0.395062
// 9 3 2 252 729 0.345679
// 9 3 3 216 729 0.296296
// 9 3 4 180 729 0.246914
// 9 3 5 144 729 0.197531
// 9 3 6 108 729 0.148148
// 9 3 7 72 729 0.0987654
// 9 3 8 36 729 0.0493827

int main(){
  /*
  for(int i = 0;i <= 8;i++){
    compute(i);
  }
  return 0;
  */

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



Measured memory_bytes: 256
from collections import deque

N = int(input())
P = [[] for i in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    P[a - 1].append((b - 1, i))

q, ans = deque(), [0] * (N - 1)
q.append((0, 0))

while len(q) > 0:
    (c, n), ac = q.popleft(), 1
    for l, i in P[n]:
        if ac == c:
            ac += 1
        q.append((ac, l))
        ans[i] = ac
        ac += 1

print(max(ans))
for a in ans:
    print(a)


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
	cin >> S;
	cout << "2018" << S.substr(4, 6) << endl;
	return 0;
}

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

int main()
{
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D, 0));
    for (int i = 0; i < N; ++i){
        for (int j = 0; j < D;++j){
            cin >> X[i][j];
        }
    }

    double d = 0;
    int ans = 0;
    for (int i = 0; i < N; ++i)
    {
        for (int j = i+1; j < N; ++j){
            int sum = 0;
            for (int k = 0; k < D; ++k){
                sum += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            d = sqrt(sum);
            double div = ceil(d) - d;
            if( div == 0){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

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

ll pow_mod(ll x, ll y, ll mod)
{
	if (y == 0)
		return 1;

	if (y == 1)
		return x % mod;

	return (pow_mod(x, y - 1, mod) * x) % mod;
}

ll A,B,T;
ll ans;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	cin>>A>>B>>T;
	for(double i=A;i<(double)T+0.5;i+=A)ans+=B;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}


int main(){
	i64 A, B, K;
	cin >> A >> B >> K;
	

	rep(i, K){
		if(A%2) A--;
		B += A/2;
		A /= 2;
		swap(A, B);
	}

	if(K%2) swap(A,B);
	cout << A << " "  << B << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

const int MAXN = 100000;
int dp[MAXN+1];
int h[MAXN+1];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    int N;
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> h[i];
    }

    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);

    for (int i = 3; i <= N; ++i) {
        dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]));
    }

    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
bool alp[26];
int main(){
  string s;cin>>s;
  if(s.size() != 26){
    for(int i = 0; s.size() > i; i++){
      alp[s[i]-'a']=true;
    }
    for(int i = 0; 26 > i; i++){
      if(!alp[i]){
        cout << s << (char)(i+'a') << endl;
        return 0;
      }
    }
  }else if(s == "zyxwvutsrqponmlkjihgfedcba"){
    cout << -1 << endl;
  }else{
    bool up = s[0]<s[1];
    int prev = 0;
    for(int i = 1; 26 > i; i++){
      if(s[i-1]>s[i] && up){
        prev = i-1;
        up = false;
      }else if(s[i-1]<s[i] && !up){
        prev = i-1;
        up = true;
      }
    }
      if(up){
        s[s.size()-2] = s[s.size()-1];
        s.pop_back();
        cout << s << endl;
      }else{
        char k = s[prev-1];
        char kmn = 'z';
        for(int i = prev; 26 > i; i++){
          if(k < s[i]){
            kmn = min(kmn,s[i]);
          }
        }
        s[prev-1] = kmn;
        while(s.size() != prev)s.pop_back();
        cout << s << endl;
      }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll                      long long
#define ld                      long double
#define ull                     unsigned long long
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                     vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                     unordered_map
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define pll                     pair<ll,ll>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define MIN                     -1e9
#define pi                      3.1415926535897932384626433832795
 
using namespace std;
 
void INPUT()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
 
/*
----------------------------------------------------------------
 
   -> Check For Overflows
   -> Out of Bounds
   -> Initialisations of global arrays and variables
   -> Read the Question and the sample test cases carefully
   -> Its not Always Complex, Try to simplify
   -> write it down and try to solve
   -> Have Faith in urself and in ur approach
   -> If it seems totally out of reach, switch to next :)
   -> And Come Back later, if possible ..
 
----------------------------------------------------------------*/
 
 
int power(int x, unsigned int y, int p)  
{  
    int res = 1;  
  
    x = x % p; 
   
    if (x == 0) return 0; 
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
 
int main() {
 
  FIO
  INPUT();
  int n;
  cin>>n;
  ll a[n];
  fo(i,0,n-1)
  cin>>a[i];
  ll sumsq=0,sqsum=0,s=0,sumr[n]={0};
  // fo(i,0,n-1)
  // {
  //   sumsq+=a[i];
  //   sqsum+=a[i]*a[i];
  // }    
  rfo(i,n-1,0)
  {
    sumr[i]=s+a[i];
    s=sumr[i];
    sumr[i]%=mod;
  }
  ll ans=0;
  // fo(i,0,n-1)
  // {
  //   cout<<sumr[i]<<endl;
  // }
  fo(i,0,n-2)
  {
    ans+=(a[i]*sumr[i+1])%mod;
    ans %= mod;
  }
  cout<<ans%mod<<endl;
  // sqsum=sqsum;
  // sumsq=(sumsq*sumsq);
  // int res=power(2,mod-2,mod);
  // ll ans=(sumsq-sqsum);
  // ans=ans*res;
  // cout<<ans%mod<<endl;
}

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

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

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;

constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
class modint{
public:
  long long x;
  constexpr modint(long long x=0):x((x%MOD+MOD)%MOD){}
  constexpr modint operator-() const{return modint(-x);}
  constexpr modint& operator+=(const modint& a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  constexpr modint& operator-=(const modint& a){
    if((x+=MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  constexpr modint& operator*=(const modint& a){
    (x*=a.x)%=MOD;
    return *this;
  }
  constexpr modint operator+(const modint& a) const{return modint(*this)+=a;}
  constexpr modint operator-(const modint& a) const{return modint(*this)-=a;}
  constexpr modint operator*(const modint& a) const{return modint(*this)*=a;}
  constexpr bool operator==(const modint& a) const{return this->x==a.x;}
  constexpr bool operator!=(const modint& a) const{return this->x!=a.x;}
  constexpr modint pow(long long expo) const{
    if(expo==0)  return 1;
    modint a=pow(expo>>1);
    a*=a;
    if(expo&1)  a*=(*this);
    return a;
  }
  //for prime MOD
  constexpr modint inv() const{return pow(MOD-2);}
  constexpr modint& operator/=(const modint& a){return (*this)*=a.inv();}
  constexpr modint operator/(const modint& a) const{return modint(*this)/=a;}
};
istream& operator>>(istream& is,const modint& a){return is >> a.x;}
ostream& operator<<(ostream& os,const modint& a){return os << a.x;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  string S;
  cin >> N >> S;
  S='<'+S;

  vector<vector<modint>> dp(N+1,vector<modint>(N+1,0));
  dp.at(0).at(N)=1;
  for(int i=1;i<N+1;i++){
    vector<modint> sum(N+1);
    sum.at(0)=dp.at(i-1).at(0);
    for(int j=1;j<N+1;j++) sum.at(j)=sum.at(j-1)+dp.at(i-1).at(j);
    for(int j=0;j<=N-i;j++){
      if(S.at(i-1)=='<')  dp.at(i).at(j)=sum.at(N-i+1)-sum.at(j);
      else  dp.at(i).at(j)=sum.at(j);
    }
  }
  /*cout << S << endl;
  for(int i=0;i<N+1;i++){
    for(int j=0;j<N+1;j++){
      cout << dp.at(i).at(j) << " ";
    }
    cout << endl;
  }*/
  cout << dp.at(N).at(0) << endl;

  return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  string s,res;
  cin >> s;
  for (int i=0; i<s.size(); ++i) {
    if (s[i] == '1') {
      res += '9';
    } else {
      res += '1';
    }
  }
  cout << res << "\n";
}


Measured memory_bytes: 256
import bisect

N = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        insert_index = bisect.bisect_left(l, l[i] + l[j],j) #l[i] + l[j]を挿入できる点を探す。同じ者がlにすでにある時は、一番左になるようにする
        ans += (insert_index - j - 1)

print(ans)


Measured memory_bytes: 3188
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n];
			for(int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
			int m = sc.nextInt();
			int[] b = new int[m];
			for(int i = 0; i < m; i++) {
				b[i] = sc.nextInt();
			}

			int head = 0;
			int foot = n - 1;
			for(int i = 0; i < m; i++) {
				while(head <= foot) {
					int mid = (head + foot) / 2;
					if(a[mid] == b[i]) {
						head = mid + 1;
						foot = n - 1;
						if(i == m-1) {
							System.out.println(1);
							return;
						}
						break;
					}
					else if(a[mid] < b[i]) {
						head = mid + 1;
					}
					else {
						foot = mid - 1;
					}
				}
			}
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 105756
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n,d;
	cin>>n>>d;
	cout<<(n%(d+d+1) == 0?(n/(d+d+1)):(n/(d+d+1) + 1))<<endl; 
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  cout << max((ll)0,(n-2)*(b-a)+1) << endl;
return 0;}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll N;
string s;
ll sumb[200010];
ll sumw[200010];
int main() {
	cin >> N >> s;
	ll ans = inf;
	REP(i,0,N) {
		sumb[i+1] = sumb[i] + (s[i]=='#');
		sumw[i+1] = sumw[i] + (s[i]=='.');
	}
	REP(i,0,N+1){
		ans = min(ans, sumb[i] + (sumw[N] - sumw[i]));
	}

	p(ans);
	return 0;
}


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

using namespace std;

//ALDS1_11_B 深さ優先探索の問題
//再帰で解く

void dfs(vector<vector<int>> &G, int s, int &counter,vector<vector<int>> &res,vector<bool> &seen) {
	if (G[s].size() == 0) {
		counter++;
		res[s][1] = counter;
		counter++;
		res[s][2] = counter;
		return;
	}

	counter++;
	res[s][1] = counter;

	for (int i = 0; i < G[s].size(); i++) {
		if (seen[G[s][i]] == true) {
			continue;
		}
		seen[G[s][i]] = true;
		dfs(G, G[s][i],counter,res,seen);

	}
	counter++;
	res[s][2] = counter;
}

int main() {

	int n;
	cin >> n;
	vector < vector<int>> G(n + 1);

	//グラフ隣接リスト読み込み
	int a, b, c;
	for (int i = 1; i <= n; i++) {
		cin >> a >> b;
		for (int j = 0; j < b; j++) {
			cin >> c;
			G[a].push_back(c);
		}
	}

	vector<vector<int>> res(n+1,vector<int> (3));
	for (int i = 1; i <= n; i++) {
		res[i][0] = i;
	}
	
	int aa = 0;
	vector<bool> seen(n + 1,false);
	for (int i = 1; i<= n; i++) {
		if (seen[i]) { continue; }
		seen[i] = true;
		dfs(G, i, aa, res, seen);
	}

	for (int i = 1; i <= n; i++) {
		cout << res[i][0] << " " << res[i][1] << " " << res[i][2] << endl;
	}

	return 0;

}


Measured memory_bytes: 3168
#include<stdio.h>

int main(void){
  int rate[200000],n,i,max,min;
  scanf("%d",&n);

  for(i=0;i<n;i++) scanf("%d",&rate[i]);
  max=rate[1]-rate[0];
  min=rate[0];
    for(i=1;i<n;i++){
      if(max<rate[i]-min) max=rate[i]-min;
      if(min>rate[i]) min=rate[i];
    }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 1376
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

const ll mod=1e9+7;


int main(){
    ll m,k;
    cin >> m >> k;
    if(k==0){
        rep(i,(1<<m)){
            rep(j,2){
                if(i || j) cout << " ";
                cout << i;
            }
        }
        cout << endl;
        return 0;
    }
    if(k<(1<<m) && !(k==1 && m==1)){
        vector<ll> ans;
        ans.push_back(0);
        ans.push_back(k);
        ans.push_back(0);
        for(ll i=1;i<(1<<m);i++){
            if(i==k) continue;
            ans.push_back(i);
        }
        ans.push_back(k);
        for(ll i=(1<<m)-1;i>=1;i--){
            if(i==k) continue;
            ans.push_back(i);
        }
        rep(i,(1<<m+1)){
            if(i) cout << " ";
            cout << ans[i];
        }
        cout << endl;
    }
    else{
        cout << -1 << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007
#define iP pair<int,int>
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define inf 1e15
#define mod1 998244353
#define pi 3.141592653589793238
#define fi first
#define se second
int32_t main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
}

Measured memory_bytes: 256
n,m = map(int,input().split())

if n == 1 and m != 1:
    print(m-2)
elif m == 1 and n != 1:
    print(n-2)
elif n == 1 and m == 1:
    print(1)
else:
    print((m-2)*(n-2))
    
    

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

const int N = 2e5+1;
ll dp[N];
ll calc(int x) {
  if(dp[x]!=-1) return dp[x];
  return dp[x]=(1LL*x*(x-1))/2;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int n, a[N];
  cin >> n;
  memset(dp, -1, sizeof dp);
  unordered_map<int, int> s;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    (s.find(a[i])==s.end())? s[a[i]]=1 : s[a[i]]++;
  }
  ll ans = 0;
  for(auto p : s) ans += calc(p.second);
  for(int i=0; i<n; i++)
    cout << ans-calc(s[a[i]])+calc(s[a[i]]-1) << '\n';
  return 0;
}

Measured memory_bytes: 9928
#include <iostream>
#include <cstdio>
#include <cctype>

inline int readInt() {
	int s = 0, c, w = 1;
	while (!isdigit(c = getchar())) {
		if (c == '-') {
			w = -1;
		}
	}
	do s = s * 10 + c - '0';
	while (isdigit(c = getchar()));
	return s * w;
}

int a = readInt(), b = readInt();

int main() {
	if (a <= 0 && b >= 0 || a >= 0 && b <= 0) {
		printf("Zero\n");
	}
	else if (a > 0 && b > 0) {
		printf("Positive\n");
	}
	else {
		int flag = a - b + 1;
		if (flag % 2 == 0) {
			printf("Positive\n");
		}
		else {
			printf("Negative\n");
		}
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    
    vector<int64_t> b(n - 1);
    for(int i = 0; i < n - 1; i++) cin >> b[i];

    vector<int64_t> a(n);
    a[0] = b[0];
    for(int i = 1; i < n - 1 ; i++) {
        if(b[i - 1] > b[i]) a[i] = b[i];
        else                a[i] = b[i - 1];
    }
    a[n - 1] = b[n - 2];
/*
    for(int i = 0; i < n; i++) cout << a[i] << " ";
    cout << endl;
*/
    int64_t ans = 0;
    for(int i = 0; i < n; i++) ans += a[i];
    cout << ans << endl;

    return 0;
}

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

int main() {
	int a[3], b[3], c[3][3];
	rep(i, 3) {
		rep(j, 3) {
			cin >> c[i][j];
		}
	}
	rep(i, 100) {
		rep(j, 100) {
			rep(k, 100) {
				if (c[0][0] - i && c[0][1] == j && c[0][2] == k) a[0] = c[0][0] - i;
			}
		}
	}
	b[0] = c[0][0] - a[0];
	b[1] = c[0][1] - a[0];
	b[2] = c[0][2] - a[0];
	a[1] = c[1][0] - b[0];
	a[2] = c[2][0] - b[0];

	rep(i, 3) {
		rep(j, 3) {
			if (c[i][j] != a[i] + b[j]) goto exit_loop;
		}
	}
	cout << "Yes" << endl;
	return 0;
exit_loop:
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String[] st = s.split(" ");
		int[] in = new int[5];
		for (int i = 0; i < 5; i++) {
			in[i] = Integer.parseInt(st[i]);
		}
		
		if (0 <= in[2]-in[4] && in[2]+in[4] <= in[0] && 0 <= in[3]-in[4] && in[3]+in[4] <= in[1]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");

		}

	}

}

Measured memory_bytes: 26224
import Data.List (sort, unfoldr)
import qualified Data.Set as S
import Data.Array

main :: IO ()
main = do
  (x : y : z : k : _) <- map read . words <$> getLine :: IO [Int]
  as <- listArray (1, x) . reverse . sort . map read . words <$> getLine :: IO (Array Int Integer)
  bs <- listArray (1, y) . reverse . sort . map read . words <$> getLine :: IO (Array Int Integer)
  cs <- listArray (1, z) . reverse . sort . map read . words <$> getLine :: IO (Array Int Integer)
  let
    ds = unfoldr next (insert (as ! 1 + bs ! 1 + cs ! 1, (1, 1, 1)) Nothing, S.singleton (1, 1, 1))
    next (Just h, s) = let ((d, (i, j, k)), h') = viewMax h in Just (d, insert' h' [(succ i, j, k), (i, succ j, k), (i, j, succ k)])
      where
        insert' h = foldr step (h, s)
        step ijk@(i, j, k) hs@(h, s) = if S.member ijk s || i > x || j > y || k > z then hs else (insert (as ! i + bs ! j + cs ! k, ijk) h, S.insert ijk s)
  mapM_ print . take k $ ds

data PH a = PH a [PH a]

merge :: Ord a => PH a -> PH a -> PH a
merge u@(PH x us) v@(PH y vs) = if y < x then PH x (v : us) else PH y (u : vs)

insert :: Ord a => a -> Maybe (PH a) -> Maybe (PH a)
insert = (Just .) . (maybe <$> id <*> merge) . flip PH []

viewMax :: Ord a => PH a -> (a, Maybe (PH a))
viewMax = fmap (foldl ((Just .) . maybe id merge) Nothing . (maybe id (:) <$> fst <*> snd) . foldl step (Nothing, [])) . ph2tuple
  where
    ph2tuple (PH x us) = (x, us)
    step (Nothing, us) v = (Just v, us)
    step (Just u, us) v = (Nothing, merge u v : us)


Measured memory_bytes: 3452
//
// Created by yamunaku on 2019/08/30.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int n, q;
    cin >> n >> q;
    vl a;
    a.reserve(q);
    int sz = 1;
    a.push_back(n);
    rep(i, q){
        ll x;
        cin >> x;
        while(sz > 0){
            if(a[sz - 1] < x) break;
            a.pop_back();
            sz--;
        }
        a.push_back(x);
        sz++;
    }
    vector<ll> dp(sz, 0);
    vector<pair<int, int>> event(sz);
    vector<vector<pair<int, ll>>> edge(sz);
    event[0] = {a[0], 0};
    repl(i, 1, sz){
        ll len = a[i];
        while(len >= a[0]){
            int idx = lower_bound(all(a), len) - a.begin() - 1;
            if(idx==-1) break;
            edge[idx].push_back({i, len / a[idx]});
            len %= a[idx];
        }
        event[i] = {len, i};
    }
    ll ans = 0;
    dp[sz - 1] = 1;
    per(i, sz){
        for(auto p:edge[i]){
            dp[i] += dp[p.first] * p.second;
        }
        ans += dp[i];
    }
    sort(all(event));
    int j = 0;
    rep(i, n){
        for(; j < sz; j++){
            if(event[j].first > i) break;
            ans -= dp[event[j].second];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 20300
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int n=gi();
	    int m=gi();
	    
	    
        System.out.println(n+m/2);
//        if (n==1) {
//        	System.out.print("Hello World");
//        }else {
//        	System.out.print(gi()+gi());
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35608
N = input()
ans = ''
for i in range(len(N)):
  if(ans == '' and N[i] == "B"):
    pass
  elif(ans == '' and N[i] != "B"):
    ans = N[i]
  elif(N[i] == "B"):
    ans = ans[:-1]
  else:
    ans += N[i]

print(ans)


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

int main()
{
  int l;
  cin>>l;
  int x=pow(l,3);
  int d = x /27;  
    for (int i = 0; i <= 12; i++) { 
        cout << d; 
        x = x - (27 * d); 
        x = x * 10; 
        d = x / 27; 
        if (i == 0) 
            cout << "."; 
    } 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, ans;
  cin >> N;
  // num of 1~9 + 100~999 + 10000~99999
  ans = min(9,N) + min(900, max(0, N -99)) + min(90000, max(0, N - 9999));
  cout << ans << endl;                                       
}

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

#define DEBUG 0
#define NINF -1
#define PINF 1E9+1

#define JPY "JPY"
#define BTC "BTC"

int n;
double x;
char u[8];

int main(void)
{
	int i,j;
	double sum=0;
	scanf("%d",&n);
	for (i=0;i<n;i++) {
		scanf("%lf %s",&x,u);
		if (strcmp(u,JPY)==0) {
			// JPY
			sum += x;
		} else {
			// BTC
			sum += x * 380000;
		}
	}

	printf("%f\n",sum);
	
	return 0;
}


Measured memory_bytes: 128
n,k=map(int,input().split())
s=input()
cnt=1
siten=s[0]
onezero=[0]
for i in range(n-1):
    if s[i]!=s[i+1]:
        onezero+=[cnt]
    cnt+=1

onezero+=[cnt]

x=len(onezero)

if siten=='1':
    onezero+=[onezero[-1]]*2
    t=int(x/2-1)
    if k>=t:
        print(n)
    else:
        ans=[0]
        for i in range(t-k+2):
            ans+=[onezero[2*(i+k)+1]-onezero[2*i]]
        print(max(ans))

else:
    onezero+=[onezero[-1]]
    t=int(x/2)
    if k>=t:
        print(n)
    else:
        ans=[onezero[2*k]]
        for i in range(t-k):
            ans+=[onezero[2*(i+k+1)]-onezero[2*i+1]]
        print(max(ans))

Measured memory_bytes: 45552
n = int(input())
sl = []
for i in range(n):
  s = str(input())
  sl.append(s)
m = int(input())
tl = []
for i in range(m):
  t = str(input())
  tl.append(t)
al = sl + tl
setal = set(al)
lsetal = list(setal)
cl = []
for i in range(len(lsetal)):
  cp = sl.count(lsetal[i])
  cm = tl.count(lsetal[i])
  cl.append(cp - cm)
mcl = max(cl)
if mcl > 0:
  print(mcl)
else:
  print('0')

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

int main(){
  string s;
  cin >> s;
  
  if(s[s.length()-1]=='s')cout << s << "es" << endl;
  else cout << s << "s" << endl;
  return 0;
}


Measured memory_bytes: 3572
#include <stdio.h>
#include<stdlib.h>
#define N 1000

int main()
{
    int a,b,i,j;
    int A[N];
    int v;

    scanf("%d",&a);
    if(a > 100)exit(1);
    for(i = 0 ; i < a ; i++){
    scanf("%d",&A[i]);
    printf("%d",A[i]);
    if(i < a - 1)printf(" ");
    }
    printf("\n");
    for(i = 1 ; i < a ; i++){
        v = A[i];
        j = i - 1;
        while(v < A[j] && j >= 0){
            A[j + 1] = A[j];
            j--;
            A[j + 1] = v;
        }
        for(b = 0; b < a ; b++){
            printf("%d",A[b]);
            if(b < a - 1)printf(" ");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2044
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{

  int n , a, b;
  cin >> n >> a >> b;
  cout << min(n*a, b) << LF;

  return 0;
}



Measured memory_bytes: 256