akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
using db = double;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
数値型から文字列に変換　to_string(number);これは簡単
文字列から数値型に変換　stoi(number)
文字列からllに変換　stoll(number)
__gcd(a,b)は最大公約数を取ってくれる、aとb
の大きい方をNとしたとき、計算量は log(N);
*/
const int mod = 1e9 + 7;

//ここから書き始める
int main(){

	ll n ;// nは整数
	//cin >> n; // 毎回入力するのをテンプレートに
	vector<ll> v(n); //使うならrepで入力すること
	string s ;
	cin >> s;
	string k = s;
	//10101
	n =  s.size();
	int wans = 0 , bans = 0;
	rep(i,n){
		if(i%2==0&&s[i]=='0'){
			wans ++;
		}
		else if(i%2==1&&s[i]=='1'){
			wans ++;
		}
	}
	rep(i,n){//01010
		if(i%2==0&&s[i]=='1'){
			bans++;
		}
		else if(i%2==1&&s[i]=='0'){
			bans ++;
		}
	}
	int ans = min(wans,bans);
	cout<<ans<<endl;

	
		
}


Measured memory_bytes: 512
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n;
  cin >> n;

  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  vsort(a);

  ll low = a[0];
  ll top = a[n - 1];

  ll ans = LLONG_MAX;

  if(low == top)
    ans = 0;
  else
  {
    for(ll i = low; i <= top; i++)
    {
      ll buf = 0;
      for(auto itr = a.begin(); itr != a.end(); ++itr)
      {
        buf += abs(*itr - i) * abs(*itr - i);
      }
      ans = min(ans,buf);
    }  
  }
  

  cout << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

int main() {
  int N;
  vector<int> W(N+100);
  cin >> N;
  for (int i; i < N; i++) cin >> W.at(i);
  int Sum = accumulate(W.begin(), W.end(), 0);
  int PrefixSum = 0, mini = Sum;
  for (int i; i < N; i++) {
    PrefixSum += W.at(i);
    mini = min(abs(PrefixSum-(Sum-PrefixSum)), mini);
  }
  cout << mini << endl;
    
}
  
   
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 500005
using namespace std;
inline int read()
{
	char x = getchar();
	int lin = 0, f = 1;
	while(x < '0' || x > '9')
	{
		if(x == '-') f = -1;
		x = getchar();
	}
    while(x >= '0' && x <= '9')
	{
		lin = lin * 10 + x - '0';
		x = getchar();
	}
	return lin * f;
}
#define PII pair<int,int>
#define fir first
#define sec second
#define ma(a,b) make_pair(a,b)
long long a,b,c;
int main(){
	a = read(); b = read(); c = read();
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
	{
		cout << 0;
		return 0;
	}
	cout << min(a * b,min(b * c,a * c));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
ll power(ll x,ll n)
{
	ll res =1;
	while(n>0)
	{
		if(n%2==1)
	res=((res%mod)*(x%mod))%mod;
	x=((x%mod)*(x%mod))%mod;
	n=n/2;
	}
	return res%mod;
	
}
ll ncr(ll n,ll r)
{
	ll i;
	ll x=1;
	for(i=0;i<r;i++)
	{
		x=((x%mod)*(n-i)%mod)%mod;
	}
	
	for(i=0;i<r;i++)
	{
		x=((x%mod)*(power(r-i,mod-2))%mod)%mod;
	}
	return x%mod;
	
	
}

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,a,b;
    cin>>n>>a>>b;
    ll x=power(2,n)%mod;
    ll y=(ncr(n,a)%mod+ncr(n,b)%mod+1)%mod;
    cout<<(x-y+mod)%mod;
    
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " <<
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int n,m;
  cin >> n >> m;
  mat a(n);
  REP(i, n){
    int k;
    cin >> k;
    REP(j,k){
      int b;
      cin >> b;
      b--;
      a[i].push_back(b);
    }
  }

  vec memo(m, 0);
  REP(i,n)REP(j,a[i].size()){
    memo[a[i][j]]++;
  }

  int ans = 0;
  REP(i,m){
    if(memo[i] == n) ans++;
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;
 int main() {
   int N;
   cin>> N;
     int data[100003][3];

    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++)cin>>data[i][j];
    }
      int dp[10003][3];
   
   
   for(int i=0;i<N;i++){
        for(int j=0;j<3;j++)
     
      
      
      dp[i+1][j]=data[i][j]+max(dp[i][(j+2)%3], dp[i][(j+1)%3]);
       }
 
      
   
  sort(dp[N],dp[N]+3);
      cout << dp[N][2]<< endl;
    }
   
   

Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>

int main(){
	int n;
	int *card = NULL;
	int i,j,k;
	int temp;

	scanf("%d",&n);
	card = (int *)malloc(4*n);
	for(i=0;i<n;i++){
		scanf("%d",&card[i]);
	}
	for(i=0;i<n-1;i++){
		printf("%d ",card[i]);
	}
	printf("%d\n",card[n-1]);
	for(i=1;i<n;i++){
		temp = card[i];
		j = i - 1;
		while(j>=0 && card[j] > temp){
			card[j+1] = card[j];
			j--;
			card[j+1] = temp;
		}
		for(k=0;k<n-1;k++){
			printf("%d ",card[k]);
		}
		printf("%d\n",card[n-1]);
	}
	free(card);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	int s = accumulate(all(a), 0);
	int m = (s + 1) / 2;
	
	bitset<2000001> dp;
	dp[0] = 1;
	rep(i, n){
		dp |= dp << a[i];
	}
	for(int i = m; ; i++) if(dp[i]){
		cout << i << endl;
		break;
	}
	
	return 0;
}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;

namespace ForAtcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine().Split(" ");
            var n = long.Parse(x[0]);
            var k = long.Parse(x[1]);
            var hs = new HashSet<long> {};
            for (var i = 0; i < k; i++)
            {
                var d = long.Parse(Console.ReadLine());
                var y = Console.ReadLine().Split(" ");
                for (var j = 0; j < d; j++)
                {
                    hs.Add(long.Parse(y[j])); 
                }
            }
            Console.WriteLine(n - hs.Count);
        }
    }
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll h,w,n;
    cin >> h >> w >> n;
    ll sr,sc;
    cin >> sr >> sc;
    --sr;   --sc;
    string s,t;
    cin >> s >> t;
    ll ltan = 0;
    ll rtan = w-1;
    for(i = n-1;i >= 0;--i){
        if(t.at(i) == 'L') rtan = min(w-1, rtan + 1);
        if(t.at(i) == 'R') ltan = max(0ll,ltan - 1);
        if(s.at(i) == 'L') ltan += 1;
        if(s.at(i) == 'R') rtan -= 1;
        if(rtan < ltan){
            cout << "NO" << endl;
            return 0;
        }
    }
    if(sc < ltan || sc > rtan){
        cout << "NO" << endl;
        return 0;
    }
    ll utan = 0;
    ll dtan = h-1;
    for(i = n-1;i >= 0;--i){
        if(t.at(i) == 'U') dtan = min(h-1, dtan + 1);
        if(t.at(i) == 'D') utan = max(0ll, utan - 1);
        if(s.at(i) == 'U') utan += 1;
        if(s.at(i) == 'D') dtan -= 1;
        if(dtan < utan){
            cout << "NO" << endl;
            return 0;
        }
    }
    if(sr < utan || sr > dtan){
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <algorithm>
using namespace std;
int n, x, a[109];
int main() {
	cin >> n >> x;
	int sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	bool eq = (sum == x);
	sort(a, a + n);
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (x >= a[i]) {
			x -= a[i];
			++cnt;
		}
	}
	cout << (cnt == n && !eq ? n - 1 : cnt) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N, D;
    cin >> N >> D;
    int cnt = 0;
    vector<vector<int>> X(N, vector<int>(D, 0));
    REP(i, N) {
        REP(j, D) { cin >> X[i][j]; }
    }
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            long long diff = 0;
            REP(k, D) { diff += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]); }
            int s = sqrt(diff);
            if(s * s == diff) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC optimize("Ofast")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T1, typename T2>
T2 sum_mod(T1 x, T2 MOD) {
	if (x < 0)
		x += MOD;
	if (x >= MOD)
		x -= MOD;
	return x;
}

template <typename T1, typename T2>
T2 mul_mod(T1 x, T2 MOD) {
	if (x < 0)
		return (abs(x) % MOD == 0 ? 0 : MOD - abs(x) % MOD);
	return x % MOD;
}

template <typename T>
bool uax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T>
bool uin(T& a, const T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 18;
const int N = (int)2e3 + 7;
const int MAXN = (int)2e6 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e17;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

int n;
LL dp[N][N];
pair <int, int> a[N];

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i].first;
		a[i].second = i;
	}
	sort(a, a + n);
	reverse(a, a + n);
	for (int i = 0; i < n; i++) {
		for (int l = 0; l <= i; l++) {
			int r = i - l;
			uax(dp[l + 1][r], dp[l][r] + 1LL * a[i].first * abs(l - a[i].second));
			uax(dp[l][r + 1], dp[l][r] + 1LL * a[i].first * abs(n - r - 1 - a[i].second));
		}
	}
	LL ans = 0;
	for (int i = 0; i <= n; i++)
		uax(ans, dp[i][n - i]);
	cout << ans;

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

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

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))

int main() {
    int N, D, X;
    scnd3( N, D, X);
    
    int v;
    rep( i, N) {
        scnd1(v);
        X += 1 + (D-1)/v;
    }
    cout1(X);
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




















 
int main(){
    ll n, ga, sa, ba, gb, sb, bb;
    cin >> n >> ga >> sa >> ba >> gb >> sb >> bb;
    vector<ll> dp(n + 1);
    for(ll i = 1; i <= n; i++){
        if(i >= ga) dp[i] = max(dp[i], dp[i - ga] + gb);
        if(i >= sa) dp[i] = max(dp[i], dp[i - sa] + sb);
        if(i >= ba) dp[i] = max(dp[i], dp[i - ba] + bb);
    }
    ll m = 0;
    for(ll i = 0; i <= n; i++){
        m = max(m, dp[i] + n - i);
    }
    vector<ll> dp2(m + 1);
    for(ll i = 1; i <= m; i++){
        if(i >= gb) dp2[i] = max(dp2[i], dp2[i - gb] + ga);
        if(i >= sb) dp2[i] = max(dp2[i], dp2[i - sb] + sa);
        if(i >= bb) dp2[i] = max(dp2[i], dp2[i - bb] + ba);
    }
    ll ans = 0;
    for(ll i = 0; i <= m; i++){
        ans = max(ans, dp2[i] + m - i);
        // cerr << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 195584
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const int INF = INT_MAX;


int main() {
  ll n,m,d;
  cin >> n>>m >>d;
  double ans;
  if(d==0){
    ans = (double)n*(m-1)/n/n;
  } else{
    ans = (double)2*(n-d)*(m-1)/n/n;
  }
  printf("%.10lf\n",ans);
  return 0;
}


Measured memory_bytes: 256
#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 all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    int N, K;
    cin >> N >> K;
    vint h(N);
    rep(i, N)
    {
        cin >> h[i];
    }
    sort(all(h));
    int Min = h[N - 1];
    rep(i, N)
    {
        if (i + K - 1 < N)
            Min = min(Min, h[i + K - 1] - h[i]);
    }
    cout << Min;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const int INF=0x3f3f3f3f,max_n=100005,mod=19260817;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll lcm(ll a,ll b)
{
	return a*b/gcd(a,b);
}
ll LCM;
int x;
int a[max_n];
signed main()
{
	int n,m;cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		a[i]=x/2;
	}
	LCM=a[1];
	for(int i=2;i<=n;i++)
	{
		LCM=lcm(LCM,a[i]);
		if(LCM>m)
		{
			cout<<"0";return 0;
		}
	}
	int flag=0;
	for(int i=1;i<=n;i++)
	{
		if((LCM/a[i])%2==0)
		{
			flag=1;
		}
	}
	if(flag)
	{
		cout<<"0";return 0;
	}
	if(m>=LCM)
	cout<<(m/LCM-1)/2+1;
	else
	cout<<"0";
}

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

int main(){
  int N,sum=0;
  string S;
  cin >> N >> S;
  for(int i=0;i<N-2;i++){
    if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C'){
      sum ++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <type_traits>
#include <vector>

// lib/to_signed.hpp
#ifndef TO_SIGNED_HPP
#define TO_SIGNED_HPP


/*
usage:

std::uint_fast64_t i;
decltype(tools::to_signed(i)) // => std::int_fast64_t
*/

namespace tools {
  template <typename T>
  constexpr typename std::make_signed<T>::type to_signed(const T x) noexcept {
    return x;
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  std::string S;
  std::cin >> S;
  std::unordered_multiset<char> symbols(S.begin(), S.end());
  std::cout << tools::to_signed(symbols.count('+')) - tools::to_signed(symbols.count('-')) << std::endl;
  return 0;
}

Measured memory_bytes: 256
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
bool vis[102];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  fore(i, 0, k) {
    int d;
    cin >> d;
    while (d--) {
      int num;
      cin >> num;
      num--;
      vis[num] = true;
    }
  }
  int ans = 0;
  fore(i, 0, n) if (!vis[i]) ans++;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int n, k, s;
int a[5020], f[5020];
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		a[i] = min(a[i], k);
		s += a[i];
	}
	sort(a, a + n + 1);
	f[0] = 1;
	for (int i = n; i >= 0; i--) {
		bool v = true;
		for (int j = k - 1; j >= k - s && j >= 0; j--) {
			if (f[j]) {
				v = false;
			}
		}
		if (v) {
			printf("%d\n", i);
			return 0;
		}
		for (int j = k; j >= a[i]; j--) {
			f[j] |= f[j - a[i]];
		}
		s -= a[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
#define repr(i,s,t) for (i64 i = (s); i >= (t); --i)

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a ? (a=b,1) : 0;}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}

template <class T>
void _trace(const char *s, T&& x)
{
    clog << '{';
    while(*s != '0' && *s != ',') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail)
{
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}} End Header

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    int x;
    cin >> x;

    puts(x < 1200 ? "ABC" : "ARC");

    return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def main():
    N, W = map(int, readline().split())
    wv = map(int, read().split())
    dp = np.full(10 ** 5 + 1, W + 1, np.int64)
    dp[0] = 0

    for w, v in zip(wv, wv):
        np.minimum(dp[v:], dp[:-v] + w, out=dp[v:])

    print(np.where(dp <= W)[0].max())


if __name__ == '__main__':
    main()

Measured memory_bytes: 14020
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=(j); i<=(k); i++)
#define FFOR(i, j, k) for(int i=(j); i<(k); i++)
#define DFOR(i, j, k) for(int i=(j); i>=(k); i--)
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
#define pb push_back
#define mp make_pair
#define setbit(s, i) (s|=(1LL<<(i)))
#define bit(s, i) (((s)>>(i))&1LL)
#define mask(i) ((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "A"
vector <int> g[101];
int n;
int a[101];
int b[101];
int c[101];
int d[101];
int t;
int match[101];
int done[101];
bool dfs(int u){
    if(done[u]==t) return 0;
    done[u]=t;
    for(int v: g[u]) if(!match[v]){
        match[v]=u;
        return 1;
    }
    for(int v: g[u]) if(dfs(match[v])){
        match[v]=u;
        return 1;
    }
    return 0;
}
int main(){
    #ifdef Kanikou
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Kanikou
    read(n);
    FOR(i, 1, n){
        read(a[i]);
        read(b[i]);
    }
    FOR(i, 1, n){
        read(c[i]);
        read(d[i]);
    }
    FOR(i, 1, n) FOR(j, 1, n) if(a[i]<c[j]&&b[i]<d[j]) g[i].pb(j);
    int ans=0;
    FOR(i, 1, n){
        t++;
        if(dfs(i)) ans++;
    }
    writeln(ans);
}

Measured memory_bytes: 256
X=int(input())


for A in range(120):
    B5=abs(A**5-X)
    Bfugou=A**5>X
    B=B5**0.2
    B=int(B)
    if Bfugou==False:
        B=-B
    if A**5-B**5==X:
        print(A,B)
        break
    A+=1


Measured memory_bytes: 9432
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		sc.close();
		String ans="Yes";
		while(true) {
			if (c-b>0) {
				c= c-b;
				if (a-d>0) {
					a=a-d;
				} else {
					ans = "No";
					break;
				}
			} else {
				break;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26936
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i < (int)n;i++)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int N,K;
    cin >> N >> K;
    long long sum = K;
    for(int i = 1;i < N;i++)sum*=(K-1);
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double p = acos(-1);

double solve(double a,double b,double x)
{
    double h,l,Cos,y;
    h = 2*x/(a*b);
    if(h>a)
    {
        y = (2*x-b*a*a)/(a*a);
        b-=y;
        h = a;
    }
    l = sqrt(h*h+b*b);
    Cos = h/l;
    Cos = acos(Cos);
    Cos = Cos*180/p;
    return Cos;
}
int main(){
    double a,b,x,h,l,Cos;
    cin>>a>>b>>x;

    printf("%.8f\n",solve(a,b,x));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge{int to, cost;};
typedef pair<int,int> P;
const int INF = 1e9;
int n, m;
int G[110][110];
bool used[110][110];
int d[110][110], f[110][110];

int main(){
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    G[a][b] = G[b][a] = c;
  }
  /*
  puts("***********************");
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cout << G[i][j] << " ";
    }
    cout << endl;
  }
  puts("***********************");
  */
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      d[i][j] = INF;
      f[i][j] = INF;
    }
  }
  for (int i = 1; i <= n; i++) {
    d[i][i] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, i));
    while (!que.empty()) {
      P p = que.top(); que.pop();
      int v = p.second;
      if (d[i][v] < p.first) continue;
      for (int j = 1; j <= n; j++) {
        if (G[v][j] == 0) continue;
        if (d[i][j] > d[i][v] + G[v][j]) {
          d[i][j] = d[i][v] + G[v][j];
          f[i][j] = v;
          que.push(P(d[i][j], j));
        }
      }
    }
/*
    cout << "****************************" << endl;
    cout << "d[" << i << "][j]" << endl;
    for (int j = 1; j <= n; j++) cout << d[i][j] << endl;
    cout << "****************************" << endl;
    cout << "f[" << i << "][j]" << endl;
    for (int j = 1; j <= n; j++) cout << f[i][j] << endl;
    cout << "****************************" << endl;
*/
    for (int j = 1; j <= n; j++) {
      if (j == i) continue;
      int a = f[i][j], b = j;
      used[a][b] = used[b][a] = 1;
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (G[i][j] != 0 && !used[i][j]) cnt++;
    }
  }
  cout << cnt / 2 << endl;
  return 0;
}


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

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int N; cin>>N;
  int X[N],Y[N],H[N];
  int ind=-1;
  rep(i,N){
    cin>>X[i]>>Y[i]>>H[i];
    if(H[i]!=0) ind=i;
  }
  int CX,CY,HH;
  rep(cx,101) rep(cy,101){
    int h=H[ind]+abs(X[ind]-cx)+abs(Y[ind]-cy);
    bool flag=1;
    rep(i,N){
      if(H[i]==0){
        if((h-abs(X[i]-cx)-abs(Y[i]-cy))<=0) continue;
        else flag=0;
      }else{
        int hh=H[i]+abs(X[i]-cx)+abs(Y[i]-cy);
        if(h!=hh){
          flag=0;
          break;
        }
      }
    }
    if(flag){
      CX=cx,CY=cy,HH=h;
      break;
    }
  }
  cout<<CX<<" "<<CY<<" "<<HH<<endl;
  return 0;
}


Measured memory_bytes: 256
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_4-C: Dictionary

#include <cstdio>
#include <cstring>

#define NDEBUG
#include <cassert>

template <unsigned int N>
class Dictionary {
  char** data_;
  unsigned int size_ = 0; // for assert
public:
  Dictionary()
  {
    data_ = new char*[N];
    for (auto i = 0u; i < N; ++i) {
      data_[i] = nullptr;
    }
  }

  ~Dictionary()
  {
    for (auto i = 0u; i < N; ++i) {
      delete_chars(data_[i]);
    }
    delete[] data_;
  }

  void insert(const char* cp)
  {
    assert(size_ < N-1); // at least one vacancy entry needed for not found
    auto i = find_index(cp);
    if (data_[i]) return; // cp was already inserted
    data_[i] = new_chars(cp);
    ++size_;
  }

  bool find(const char* cp) const
  {
    auto i = find_index(cp);
    return data_[i] ? true : false;
  }
private:
  unsigned int find_index(const char* cp) const
  {
    auto h1 = hash1(cp), h2 = hash2(h1);
    auto h = h1 % N;
    for (auto i = 0U; ; ++i) {
      if (data_[h] == nullptr || std::strcmp(data_[h], cp) == 0) {
        return h;
      }
      h = (h+h2) % N; // (h + i*h2(h)) % N;
    }
  }

  unsigned int hash1(const char* cp) const
  {
    auto h = 0U;
    for (; *cp; ++cp) {
      h = 31*h + *cp;
    }
    return h % N;
  }

  unsigned int hash2(int h1) const
  {
    return h1 ? (N-h1) : 1;
  }

  char* new_chars(const char* cp) const
  {
    auto buf = new char[std::strlen(cp)+1];
    std::strcpy(buf, cp);
    return buf;
  }

  char* delete_chars(const char* cp) const
  {
    delete[] cp; // delete nullptr is ok!
  }

};

int main()
{
  const unsigned int M = 1250437; // (prime number) * 0.8 > 1000000
  Dictionary<M> dict;

  int n;
  std::scanf("%d", &n);
  
  for (auto i = 0; i < n; ++i) {
    char buf1[6+1]; // "insert".size() + 1('\0')
    char buf2[12+1]; // 12(max)+1('\0')
    std::scanf("%6s %12s", buf1, buf2);
    if (buf1[0] == 'i') { // insert ...
      dict.insert(buf2);
    } else { // find ...
      bool found = dict.find(buf2);
      puts(found ? "yes" : "no");
    }
  }
}

// eof

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

int main()
{
	int r,g,b;
	cin >> r >> g >> b;
	if((10*g+b) % 4 == 0){
		cout << "YES\n";
	}else{
		cout << "NO\n";
	}

	return 0;
}


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

#define int long long

#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 INF (3e9)

using namespace std;

int A, B, C, X, Y;

int solve(int x, int y)
{
    if (A+B >= 2*C)
    {
        if (X > Y)
        {
            int ans = Y*2*C;
            ans += (X-Y) * min(A, 2*C);
            return ans;
        }
        else
        {
            int ans = X*2*C;
            ans += (Y-X) * min(B, 2*C);
            return ans;
        }
    }

    return X*A + Y*B;
}

signed main()
{
    cin >> A >> B >> C >> X >> Y;

    int ans = solve(X, Y);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
a,b,c,d = map(int, input().split())

flg = 0
loop = 0

while loop==0:
#  print(a,c)
  if flg ==0:
    c = c - b
    if c <= 0:
      loop = 1
    flg = 1
  else:
    a = a -d
    if a <= 0:
      loop = 1
    flg = 0

if flg == 1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp41 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());

            int remain = N % 1000;

            if (remain == 0) {
                Console.WriteLine(0);
            } else {
                Console.WriteLine(1000 - remain);
            }
            
        }
    }
}


Measured memory_bytes: 27532
// luogu-judger-enable-o2
// luogu-judger-enable-o2
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <numeric>
#include <functional>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;


int main() {
//	freopen("brackets.in", "r", stdin);
//	freopen("brackets.out", "w", stdout);
	
	int n;
	ll ans, ans2;
	bool f = false;
	ll csum = 0;
	scanf("%d%lld", &n, &ans);
	ans2 = -1LL << 60;
	
	while (--n) {
		char op;
		int x;
		scanf(" %c%d", &op, &x);
		if (op == '+') {
			if (!f) {
				ans += x;
			} else {
				csum += x;
				ans2 += x;
			}
		} else if (op == '-') {
			if (!f) {
				f = true;
				ans -= x;
			} else {
				ans2 = max(ans2 + x, ans - csum + x);
				ans += csum - x;
				csum = 0;
			}
		}
	}
	printf("%lld\n", max(ans + csum, ans2));
	
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

ll dfs(vvl &G, ll now, ll par) {
  ll po = 0;
  ll count = 0;
  AUTO(g, G[now]) {
    if (g == par)
      continue;
    po ^= dfs(G, g, now) + 1;
    count++;
  }
  // cout << now + 1 << po << endl;
  return po;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vector<vector<ll>> G(N);
  REP(i, N - 1) {
    ll x, y;
    cin >> x >> y;
    G[x - 1].push_back(y - 1);
    G[y - 1].push_back(x - 1);
  }
  if (dfs(G, 0, -1))
    cout << "Alice" << endl;
  else
    cout << "Bob" << endl;
  return 0;
}


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Point{
	double x,y;
	Point(){}
	Point(double x,double y):x(x),y(y){}
};
Point operator+(Point a,Point b){return Point(a.x+b.x,a.y+b.y);}
Point operator-(Point a,Point b){return Point(a.x-b.x,a.y-b.y);}
double abs(Point p){return sqrt(p.x*p.x+p.y*p.y);}

int dfs(double t,Point cur,Point devil,const vector<Point>& cs,int flg)
{
	int n=cs.size();
	rep(i,n) if(!(flg>>i&1)){
		double spend=abs(cs[i]-cur);
		if(abs(cs[i]-devil)<t+spend+EPS) return 0;
	}
	int res=0;
	rep(i,n) if(!(flg>>i&1)){
		double spend=abs(cs[i]-cur);
		res=max(res,1+dfs(t+spend,cs[i],devil,cs,flg|1<<i));
	}
	return res;
}

int main()
{
	for(int n;cin>>n && n;){
		Point h,d; cin>>h.x>>h.y>>d.x>>d.y;
		vector<Point> cs(n);
		for(auto& c:cs) cin>>c.x>>c.y;
		cout<<(dfs(0,h,d,cs,0)==n?"YES":"NO")<<endl;
	}
}

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

int main(){
  int N,K;cin >> N >> K;
  vector<bool> ans(N,false);
  for(int i=0;i<K;i++){
    int d;cin >> d;
    for(int j=0;j<d;j++){
      int A;cin >> A;
      ans[A-1] = true;
    }
  }
  int count = 0;
  for(int i=0;i<N;i++){
    if(!ans[i]){
      count ++;
    }
  }
  cout << count << endl;
}

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

int main(int argc, const char * argv[]) {
    
    int pasta[3],juuce[2],min;
    int sum;
    
    min=100000000;
    
    for(int i=0;i<3;i++){
        cin >> pasta[i];
    }
    for(int i=0;i<2;i++){
        cin >> juuce[i];
    }
    
    for(int i=0;i<3;i++){
        for(int j=0;j<2;j++){
            sum=pasta[i]+juuce[j];
            if(sum<min){
                min=sum;
            }
        }
    }
    
    cout << min-50 << endl;
    
    return 0;
}

Measured memory_bytes: 3048
/* Coached by rainboy */
#include <stdio.h>

#define N 100000

int oo[1 + (N - 1) * 2], oh[1 + (N - 1) * 2];

int link(int o, int h) {
	static int _ = 1;

	oo[_] = o, oh[_] = h;
	return _++;
}

int ij[N - 1], cc[N - 1], ae[N];

void dfs(int p, int i, int c) {
	int o, c_;

	c_ = 1;
	for (o = ae[i]; o; o = oo[o]) {
		int h = oh[o], j = i ^ ij[h];

		if (j != p) {
			if (c_ == c)
				c_++;
			dfs(i, j, c_);
			cc[h] = c_++;
		}
	}
}

int main() {
	int n, h, i, i_, j, o, a, k;

	scanf("%d", &n);
	for (h = 0; h < n - 1; h++) {
		scanf("%d%d", &i, &j), i--, j--;
		ij[h] = i ^ j;
		ae[i] = link(ae[i], h);
		ae[j] = link(ae[j], h);
	}
	k = 0;
	i_ = -1;
	for (i = 0; i < n; i++) {
		a = 0;
		for (o = ae[i]; o; o = oo[o])
			a++;
		if (k < a) {
			k = a;
			i_ = i;
		}
	}
	dfs(-1, i_, -1);
	printf("%d\n", k);
	for (h = 0; h < n - 1; h++)
		printf("%d\n", cc[h]);
	return 0;
}


Measured memory_bytes: 6400
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct T{int w,l;string s;}t[10];
bool f(T l,T r){return l.w!=r.w?l.w>r.w:l.l<r.l;}
int main()
{
	int n,i,j,a;
	while(cin>>n,n)
	{
		for(i=0;i<n;++i)
		{
			cin>>t[i].s;
			t[i].w=t[i].l=0;
			for(j=1;j<n;++j)scanf("%d",&a),a==0?t[i].w++:(a==1?t[i].l++:0);
		}
		stable_sort(t,t+n,f);
		for(i=0;i<n;++i)cout<<t[i].s<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
def qn(n)
  _qn = 0
  d = 1
  while 0 < n
    mq = n % 4
    _qn += mq*d
    d *= 10
    n /= 4
  end
  _qn
end

while n = gets.to_i
  break if n == -1
  puts qn(n)
end

Measured memory_bytes: 6092
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <utility>
#include <algorithm>
using namespace std;


int main(){
    
    int r, d;
    long long int x[11];
    cin>>r>>d>>x[0];
    for(int i=1; i<11; i++){
        x[i]=r*x[i-1]-d;
    }
    
    for(int i=1; i<11; i++){
        cout<<x[i]<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define MAX_N 10000000
struct UnionFind{
	int par[MAX_N+100];
	void init(){
		for(int i=0;i<MAX_N+5;i++){
			par[i] = i;
		}
	}
	int find(int x){
		if(par[x]==x)return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x,int y){
		x = find(x);
		y = find(y);
		if(x==y)return;
		par[x] = y;
		return;
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
}uf;
const ll mod = 1000000007ll;

ll mypow(ll x, ll n) {
	if (n == 0ll) return 1ll;
	if (n == 1ll) return x % mod;
	if (n % 2ll == 0ll) {
		return mypow(x * x % mod, n / 2ll);
	} else {
		return mypow(x, n - 1ll) * x % mod;
	}
}
string O,Z;
string rO,rZ;
int N;
bool pali(string s){
	string t = s;
	reverse(all(t));
	return (s==t);
}
bool is_pre(string& s,string& t){
	return (s==t.substr(0,s.size()));
}
string suf(string s,int n){
	return s.substr(s.size()-n);
}
bool check(){
	if(Z.size()>=O.size()){
		if(!is_pre(O,Z))return false;
		if(!pali(suf(Z,Z.size()-O.size())))return false;
	}else{
		if(!is_pre(Z,O))return false;
		if(!pali(suf(O,O.size()-Z.size())))return false;
	}
	return true;
}	
struct node{
	char x;
	int id;
	node(){}
};
node str[MAX_N*2+200100];
char pos[MAX_N+100];
int main(){
	uf.init();
	cin >> Z;
	cin >> O;
	cin >> N;
	rO = O;
	reverse(all(rO));
	rZ = Z;
	reverse(all(rZ));
	if(N<=1000000){
		for(int i=0;i<N;i++){
			pos[i] = '$';
		}
		int offset = 0;
		for(int i=0;i<N;i++){
			str[offset+i].id = i;
		}
		offset += N;
		for(int i=0;i<Z.size();i++){
			str[offset+i].id = -1;
			str[offset+i].x = Z[i];
		}
		offset += Z.size();
		for(int i=0;i<N;i++){
			str[offset+i].id = i;
		}
		offset += N;
		for(int i=0;i<O.size();i++){
			str[offset+i].id = -1;
			str[offset+i].x = O[i];
		}
		offset += O.size();
		for(int i=0;i<offset/2;i++){
			int j = offset-1-i;
			if(str[i].id==-1&&str[j].id==-1){
				if(str[i].x!=str[j].x){
					cout << 0 << endl;
					return 0;
				}
			}else if(str[i].id==-1){
				int id = str[j].id;
				id = uf.find(id);
				if(pos[id]=='$'){
					pos[id] = str[i].x;
				}else{
					if(str[i].x!=pos[id]){
						cout << 0 << endl;
						return 0;
					}
				}
			}else if(str[j].id==-1){
				int id = str[i].id;
				id = uf.find(id);
				if(pos[id]=='$'){
					pos[id] = str[j].x;
				}else{
					if(str[j].x!=pos[id]){
						cout << 0 << endl;
						return 0;
					}
				}
			}else{
				int I = str[i].id;
				int J = str[j].id;
				I = uf.find(I);
				J = uf.find(J);
				if(pos[I]=='$'||pos[J]=='$'){
					if(pos[I]!='$')pos[J]=pos[I];
					if(pos[J]!='$')pos[I]=pos[J];
					uf.unite(I,J);
				}else{
					if(pos[I]!=pos[J]){
						cout << 0 << endl;
						return 0;
					}
					uf.unite(I,J);
				}
			}
		}
		ll ans = 1ll;
		for(int i=0;i<N;i++){
			if(uf.find(i)!=i)continue;
			if(pos[i]=='$'){
				ans = (ans*26ll)%mod;
			}
		}
		cout << ans << endl;
	}else{
		if(!check()){
			cout << 0 << endl;
			return 0;
		}
		if(Z.size()>=O.size()){
			cout << mypow(26ll,(N-O.size()+1)/2) << endl;
		}else{
			cout << mypow(26ll,(N-O.size()+1)/2) << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 45732