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

using namespace std;

int n;
double dp[301][301][301];

double go(int c1, int c2, int c3) {
  if(dp[c1][c2][c3] != -1) return dp[c1][c2][c3];

  // Don't forget the base case :')
  if(c1 == c2 && c2 == c3 && c3 == 0) return 0;

  double p = (1.0 * n - c1 - c2 - c3) / (1.0 * n);
  double ret = p / (1-p);
  if(c1 != 0) {
    ret += (1.0 * c1) / (c1+c2+c3) * (1 + go(c1-1, c2, c3));
  }
  if(c2 != 0) {
    ret += (1.0 * c2) / (c1+c2+c3) * (1 + go(c1+1, c2-1, c3));
  }
  if(c3 != 0) {
    ret += (1.0 * c3) / (c1+c2+c3) * (1 + go(c1, c2+1, c3-1));
  }
  dp[c1][c2][c3] = ret;
  return ret;
}

int main() {
  // J: which dish has how many pieces isn't important,
  // the only thing that matters is the count of 1 pieces,
  // 2 pieces, and 3 pieces

  // so there's like 300^3 states, and 3 transitions to
  // worry about, which should be totally fine

  // the problem is that you have to deal with self-loops
  // so if there's a probability p of returning to the same
  // state (rolling a dish with no pieces on it), that'll
  // increase the expected rolls for sure
  // okay so E(rolls) = p*(1+E(rolls)) + (1-p)*(R)
  // where R is calculated by proceeding with the DP normally
  // E(rolls) * (1-p) = p + (1-p) * R
  // E(rolls) = p / 1-p + R
  // tada
  // let's see if this makes sense: if you've got 299 empty
  // and one dish with one sushi on it, then E(rolls) =
  // (299/300) / (1/300) + R = 299 + 1 = 300... I guess that makes
  // sense?  each time, there's a 1/300 chance, so you'd
  // expect about 300 rolls before you hit the one you want


  cin.tie(0);
  cin.sync_with_stdio(0);

  cin >> n;
  int c[4] = {0, 0, 0, 0};
  for(int i = 0; i<n; ++i) {
    int cc; cin >> cc;
    c[cc]++;
  }
  for(int i = 0; i<=300; ++i) {
    for(int j = 0; j<=300; ++j) {
      for(int k = 0; k<=300; ++k) {
        dp[i][j][k] = -1;
      }
    }
  }

  cout << fixed << setprecision(14) << go(c[1], c[2], c[3]) << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1000000000 + 7;
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n, l, q;
vector<int> x(100000 + 5, 1e10);
vector<vector<int>> step(100000+ 5, vector<int>(25, 1e10));

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n) cin >> x[i];
    cin >> l;
    rep(i, n - 1) {
        int nx = lower_bound(all(x), x[i] + l + 1) -1 - x.begin();
        step[i][0] = nx;
    }
    rep(j, 20)rep(i, n) {
        step[i][j + 1] = step[min(n - 1, step[i][j])][j];
    }
    cin >> q;
    rep(i, q) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if (a > b) swap(a, b);
        int ans = 0;
        int now = a;
        while (now < b) {
            int d = lower_bound(all(step[now]), b + 1) -1 - step[now].begin();
            if (d < 0) {ans++; break;}
            ans += (int)pow(2, d);
            now = step[now][d];
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 24320
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(vector<int>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

//CODE
int ASUM (int A)
{
  int res =0;
  for (int i = 1; i <= A; i++)
  {
    res += i;
  }
  return res;
}

void solve(void)
{
  int N;
  cin>>N;
  vector<int> data(N);
  for (int i = 0; i < N; i++)
  {
    cin>>data[i];
  }
  int prev = 0;
  int SUM = 0;
  int R = 0;
  int ANS = 0;
  int COUNT = 0;

  for (int L = 0; L < N; L++)
  {
    while((SUM + data[R]) == (prev^data[R])&&(R<N))
    {

      SUM += data[R];
      prev ^= data[R];
      R++;
    }
    
    if(L == R)
    {

      ANS++;
      SUM += data[R];
      prev ^= data[R];
      R++;
    }
    else
    {
      ANS += R - L;

      SUM -=data[L];
      prev ^=data[L];
    }
    // DEBUG("L R ANS SUM");
    // vector<int> temp = {L,R,ANS,SUM};
    // DEBUG(temp);
  }
  
  cout<<ANS<<endl;
  
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main(){
	
	while(true){
		int n;
		cin >> n;
		if (n == 0) break;
		int max_p = 0,max_d = 0;
		for (int i = 0; i < n; i++){
			int p,d1,d2;
			cin >> p >> d1 >> d2;
			
			if(max_d <= d1 + d2){
				max_d = d1 + d2;
				max_p = p;
			}

		}
		cout << max_p << " " << max_d << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val pairs = 1.until(n + 1).map {
        val nn = it.toString().map { it.toInt() }
        val s = nn[0]
        val e = nn[nn.size - 1]
        Pair(s, e)
    }.groupBy { it }
    val memo = hashMapOf<Pair<Int, Int>, Int>()
    val count = pairs.keys.map {
        val p = Pair(Math.min(it.first, it.second), Math.max(it.first, it.second))
        memo[p] ?: run {
            val a = pairs[it]?.size ?: 0
            val b = pairs[Pair(it.second, it.first)]?.size ?: 0
            memo[p] = a * b
            a * b
        }
    }.sum()
    println(count)
}

Measured memory_bytes: 53836
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#define inf 10e8
#define rep(i,n) for(long i=0;i<n;i++)
using namespace std;

int main(){
  int n,i;
  cin >> n >> i ;
  cout << n+1-i << endl;
}

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

typedef long long int ll;

int main(){
    string s;
    cin>>s;
    int c=0;
    for(int i=0;i<3;i++){
        if(s[i]==s[i+1]){
            ++c;
            break;
        }
    }
    if(c)
    cout<<"Bad"<<endl;
    else
    cout<<"Good"<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  string t = "";
  for (int i = 1; i * 2 < s.size(); i++)
    if (s.substr(0, i) == s.substr(i, i)) ans = i * 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


r, g = inpm(2)
print(r + (g - r) * 2)


Measured memory_bytes: 3572
using System;
using System.Linq;

namespace _072c
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int[] s = new int[a.Max()+2];
            foreach(int i in a){
                if(i!=0){
                    s[i-1]++;
                }
                s[i]++;
                s[i+1]++;
            }
            Console.WriteLine(s.Max());
        }
    }
}


Measured memory_bytes: 19424
A, B = map(int, input().split())
x = max(A, B)
y = min(A, B)
if x%y == 0:
  gcd = y
else:
  while x%y != 0:
    z = x%y
    x = y
    y = z
  else:
    gcd = z
lcm = int(A*B/gcd)

print(lcm)

Measured memory_bytes: 3060
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

ans = 0
(0..a).each{|ia|
    (0..b).each{|ib|
        (0..c).each{|ic|
            ans += 1 if 500*ia + 100*ib + 50*ic == x
        }
    }
}
puts ans


Measured memory_bytes: 1788
#include<iostream>
#include<cmath>


using namespace std;

int main(){
  int N,T,A;
  cin >> N;
  cin >> T;
  cin >> A;
  int H[N];
  for(int i = 0; i < N; i++){
    cin >> H[i];
  }
  
  double tmp[N];
  double minError = fabs(T - 0.006 * H[0] - A);
  int minIndex = 0;
  
  for(int i = 1; i < N; i++){
    tmp[i] = T - 0.006 * H[i];
    if(fabs(tmp[i] - A) < minError ){
      minError = fabs(tmp[i] - A);
      minIndex = i;
    }
  }  
  
  cout << minIndex + 1 << endl;
  
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int inf = 100000;
int w, h;
pair<int, int> ch(pair<int, int> a) {
	if (a.first == -1) {
		a.first = w - 1;
	}
	else if (a.first == w) {
		a.first = 0;
	}
	if (a.second == -1) {
		a.second = h - 1;
	}
	else if (a.second == h) {
		a.second = 0;
	}
	return a;
}
class point {
public:
	int fast, num;
	bool used;
	point() :fast(inf), num(0), used(false) {

	}
};
int main() {
	cin >> w >> h;
	vector<vector<point> > map(w, vector<point>(h));
	int mx[]{ 1,0,-1,0 }, my[]{ 0,1,0,-1 };
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	map[a][b].num = 1;
	map[a][b].fast = 0;
	queue<pair<int, int> >que;
	que.push(pair<int, int>(a, b));
	while (!que.empty()) {
		pair<int,int> du = que.front(); que.pop();
		pair<int, int> du2;
		for (int i = 0; i < 4; ++i) {
			du2 = ch(pair<int, int>(du.first + mx[i], du.second + my[i]));
			if (map[du2.first][du2.second].fast > map[du.first][du.second].fast) {
				map[du2.first][du2.second].num = (map[du2.first][du2.second].num + map[du.first][du.second].num) % 100000007;
				if (!map[du2.first][du2.second].used) {
					que.push(du2);
					map[du2.first][du2.second].fast = map[du.first][du.second].fast + 1;
					map[du2.first][du2.second].used = true;
				}
			}
		}
	}
	cout << map[c][d].num << endl;
	return 0;
}

Measured memory_bytes: 14596
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(val) cerr << "Value of " << #val << " : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll nax = 2e5+5;
unordered_map<ll, ll>cnt;

int main(){
	IOS	
	ll ans=0, n, arr[nax];
	cin >> n;
	for(int i=1;i<=n;++i){
		cin >> arr[i];
		cnt[arr[i]+i]++;
		ans+=cnt[i-arr[i]];
	}
	cout << ans << '\n';
}


Measured memory_bytes: 20292
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    long long n;
    long a[200005],b[200005],zh1,zh2;
    cin>>n;
    for(long long i=1;i<=n;i++)
    {
        cin>>a[i];b[i]=a[i];
    }
    sort(a+1,a+n+1);
    zh1=a[n/2];zh2=a[n/2+1];
    for(long long i=1;i<=n;i++)
    {
        if(b[i]<zh1) cout<<zh2<<endl;
        else if(b[i]>zh2) cout<<zh1<<endl;
        else if(b[i]==zh1) cout<<zh2<<endl;
        else if(b[i]==zh2) cout<<zh1<<endl;
    }
}


Measured memory_bytes: 5376
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }


template<typename T>T gcd(T x, T y){if(y==0)return x;else return gcd(y,x%y);}

long long nCr_saturated(long long n, long long k) {
	if(k > n) return 0;
	if(k > n / 2) k = n - k;
	if(k == 0) return 1;
	long long r = 1;
	for(int j = 1; j <= k; j ++) {
		ll a = n - k + j; int b = j;
		{	int g = gcd((int)((n - k) % j), j);
			a /= g, b /= g;
		}
		r /= b;
		if(r * 1. * a > 2e18)
			return (long long)1e18 + 1;
		r *= a;
	}
	return min(r, (long long)1e18 + 1);
}

long long solve(long long k, long long n) {
	if(k == 1) return n - 1;
	if(n == 1) return 0;
	int r = 0, i = 0; long long x = n - 1;
	while(true) {
		long long t = 0;
		for(int j = 0; j < k && j <= r; j ++) {
			t += nCr_saturated(r, j);
			if(t >= x) break;
		}
		if(t >= x) break;
		x -= t;
		++ r;
	}
	return r + 1;
}

int main() {
//	rer(n, 0, 100) rer(k, 0, n)
//		cerr << n << ", " << k << ": " << nCr_saturated(n, k) << endl;
	int T;
	scanf("%d", &T);
	rep(ii, T) {
		long long N, E;
		scanf("%lld%lld", &N, &E);
		long long ans = solve(E, N + 1);
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1192
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

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

typedef long long LL;
typedef long double LD;

bool compare_by_a(pair<int, int> a, pair<int, int> b)
{
    if (a.first != b.first) {
        return a.first < b.first;
    } else {
        return a.second < a.second;
    }
}

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main()
{
    int N, T, A;
    cin >> N >> T >> A;
    vector<int> H(N, 0);
    for (int i = 0; i < N; i++)
        cin >> H[i];

    vector<pair<int, int>> ans(N, {0, 0});
    for (int i = 0; i < N; i++) {
        ans[i].first = (abs)(1000*A - 1000*T + 6*H[i]);
        ans[i].second = i;
    }

    sort(all(ans), compare_by_a);
    cout << 1 + ans[0].second << endl;

    return 0;
}


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

// for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

// abbreviati
#define PB(v) push_back(v)
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

// constant
const int INF = 1<<30;
const ll INFLL = 1LL << 60;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet***************************************************
ifelse, isprime, torad, todeg, lcm, bfs,chmin,chmax
**************************************************************/

// adjacency list
vector<int> to[100005];

// Graph
using Graph = vector<vector<int>>;

// Grid
int H,W;
vector<vector<int>> field;

// 4方向への移動ベクトル
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int r,d,x; cin >> r >> d >> x;
    rep(i,0,10){
        x=r*x-d;
        cout << x ENDL;
    }
    
    return 0;
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FORr(i, j, 0)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

int main() {
	int N;
	string s;
	cin >> N >> s;
	int R_cnt = 0, L_cnt = 0;
	rep(i, s.size()) {
		if(s[i] == '(') ++L_cnt;
		else {
			if(L_cnt > 0) --L_cnt;
			else ++R_cnt;
		}
	}
	rep(i, R_cnt) printf("(");
	cout << s;
	rep(i, L_cnt) printf(")");
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int l = 0;
  scanf("%d",&l);
  int n = 1;
  int m = 0;

  int tmp = l;
  while(tmp > 1){
    if(tmp%2==1){
      m = m+1;
    }
    tmp = tmp/2;
    n = n+1;
    m = m+2;
  }
  printf("%d %d\n",n,m);

  int i = 1;
  tmp = l;
  for(i=1;i<n;i++){
    printf("%d %d %d\n",i,i+1,(tmp+1)/2);
    printf("%d %d %d\n",i,i+1,0);
    if(tmp%2==1){
      printf("%d %d %d\n",i,n,tmp/2);
    }
    tmp = tmp/2;
  }
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Text;


namespace AtCoderDotNetCore
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static void Exec()
		{
			var a = int.Parse(Console.ReadLine());
			var b = int.Parse(Console.ReadLine());
			var h = int.Parse(Console.ReadLine());
			Console.WriteLine($"{(a + b) * h / 2}");
		}
	}
}

Measured memory_bytes: 27396
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string s;
int l;
int main() 
{
    cin>>s;
    l=s.size();
    for(register int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(register int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int INF=(1<<22);
int dp[1000000],d[20],n,m;
int main(){
    cin>>n>>m;
    fill(dp,dp+n+1,INF);dp[0]=0;
    for(int i=0;i<m;++i)cin>>d[i];
    for(int i=0;i<m;++i)for(int j=d[i];j<=n;++j){
        dp[j]=min(dp[j],dp[j-d[i]]+1);
    }cout<<dp[n]<<endl;
}

Measured memory_bytes: 1356
#include <stdio.h>

int main(void){
   
   int n,i,c;
	char t[101];
	char h[101];
	int sum = 0;
	int sum2 = 0;

	scanf("%d", &n);

	for (i = 0; i<n; i++) {
		scanf("%s %s", t, h);
		c = strcmp(t, h);

		if (c>0) {
			sum += 3;
		}
		else if (c == 0) {
			sum += 1;
			sum2 += 1;
		}
		else {
			sum2 += 3;
		}

	}

	printf("%d %d\n", sum, sum2);

    
    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int main(){
int n,d;cin>>n>>d;int ans=0;
int x[n][d];
rep(i,n) {for(int j=0;j<d;j++)cin>>x[i][j];}
rep(i,n-1)  {for(int j=i+1;j<n;j++){
    int s=0;
    for(int k=0;k<d;k++){
        int t=abs(x[i][k]-x[j][k]);
        s+=t*t;
    }
    bool f=false;
    for(int k=0;k<=s;k++){
        if(k*k==s)f=true;
    }
    if(f)ans++;
}}
cout<<ans<<endl;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	ll n,m;cin>>n>>m;
	vi a(n),b(31),c(31);
	rep(i,n)cin>>a[i];
	sort(all(a));
	reverse(all(a));
	b[0]=1;
	for(int i=1;i<31;++i){
		b[i]=b[i-1]*2;
		c[i]=0;
	}
	for(int i=0;i<n;++i){
		for(int j=1;j<31;++j){
			if(a[i]/b[j]==0){
				c[j-1]++;
				break;
			}
		}
	}
	ll sum[31];
	sum[0]=0;
	for(int i=0;i<30;++i){
		sum[i+1]=sum[i]+c[i];
	}
	ll cnt=0,k,cnt2=0;
	for(int i=30;i>=1;--i){
		if(sum[30]-sum[i-1]==0)continue;
        cnt2++;
		cnt+=sum[30]-sum[i-1];
		if(cnt>=m){
			k=i-1;
            break;
		}
	}
	ll ans=0;
	if(cnt>m){
		cnt-=sum[30]-sum[k];
		cnt2--;
        ll cnt4=0;
		for(int i=0;i<n;++i){
            while(a[i]/b[cnt2]<b[k]&&cnt2>=1)cnt2--;
            a[i]=a[i]/b[cnt2];
            cnt4+=cnt2;
            if(cnt4==cnt)break;
		}
        
		sort(all(a));
		ll cnt3=0;
		for(int i=n-1;i>=0;--i){
			a[i]/=2;
			cnt3++;
			if(cnt3==(m-cnt))break;
        }
        rep(i,n){ans+=a[i];}
        cout<<ans<<endl;
	}
	else if(cnt==m){
        ll cnt3=0;
		for(int i=0;i<n;++i){
			while(a[i]/b[cnt2]<b[k-1])cnt2--;
			a[i]/=b[cnt2];
            cnt3+=cnt2;
            if(cnt3==m)break;
		}
		rep(i,n)ans+=a[i];
        cout<<ans<<endl;
	}
	else{
		cout<<0<<endl;
	}
}

Measured memory_bytes: 640
#include <stdio.h>
#define MAX 2000
int solve(int,int);
int A[MAX],n;
int main()
{
  int q,B[MAX],i,x;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }

  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&B[i]);
      x=solve(0,B[i]);  
      if(x==1) printf("yes\n");
      if(x==0) printf("no\n"); 
    }
  return 0;
}

int solve(int i,int m)
{  
  if(m==0) return 1;
  if(i>=n) return 0;
  int first=solve(i+1,m-A[i]);
  if(first==1)return 1;

  int second=solve(i+1,m);
  if(second==1)return 1;
  return 0;
}

Measured memory_bytes: 588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String op;
      String[] words;
      Tree tree = new Tree();

      for(int i=0,k=0; i<n; i++,k=0){
        words = br.readLine().split(" ");
        op  = words[k++];
        if ( op.equals("insert") ) { 
          tree.insert(Integer.parseInt(words[k++]));
        }
        else {
          tree.dispRoundPath();
        }
      }

    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}

class Tree {

  static final BTreeNode NIL = new BTreeNode(-1);
  BTreeNode root;
  StringBuilder buf;

  public Tree() {
    root = NIL;
    buf = new StringBuilder();
  }

  public void insert(int val) {
    BTreeNode y = NIL;
    BTreeNode x = root;
    BTreeNode z = new BTreeNode(val);

    while( !x.equals(NIL) ) {
      y = x;
      if( z.key < x.key )
        x = x.left;
      else
        x = x.right;
    }
    z.parent = y;

    if( y.equals(NIL) ){
      root = z;
    }
    else if( z.key < y.key )
      y.left = z;
    else
      y.right = z;
  } 
  void preParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      buf.append(" ").append(u.key);
      preParse(u.left);
      preParse(u.right);
    }
  }
  void inParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      inParse(u.left);
      buf.append(" ").append(u.key);
      inParse(u.right);
    }
  }

  void dispRoundPath() {

    inParse(root);
    buf.append("\n");
    preParse(root);
    buf.append("\n");

    System.out.print(buf);
    buf.setLength(0);
  }
}

class BTreeNode {
  int key;
  BTreeNode parent,left,right;

  public BTreeNode(int key) {
    this.key = key;
    this.parent =
    this.left =
    this.right = Tree.NIL;
  }

  @Override
  public boolean equals(Object o) {
    if(o == this) return true;
    if(o == null) return false;
    if(!(o instanceof BTreeNode)) return false;

    BTreeNode node = (BTreeNode)o;
    if(!(this.key == node.key)) return false;

    return true;
  }
}


Measured memory_bytes: 126592
# 毎回やってもたかがしれてそう -> 間に合いませんでした
# 素直に累積和+包除原理を使う

arr = [0 for _ in range(10 ** 5 + 1)]


def isPrime(x):
    if x == 1:
        return False
    for i in range(2, int(x ** 0.5) + 1):
        if x % i == 0:
            return False
    return True


for i in range(3, 10**5+1):
    if isPrime(i) and isPrime(int((i + 1) / 2)):
        arr[i] = 1
    arr[i] += arr[i-1]

q = int(input())


for _ in range(q):
    l, r = map(int, input().split())
    print(arr[r] - arr[l-1])


Measured memory_bytes: 6616
# coding: utf-8
# Your code here!

n,k=[int(i) for i in input().split()]

if n==0:
    if k==0:
        print("0 0")
    else:
        print(-1)
elif n==1:
    if k==0:
        print("0 0 1 1")
    else:
        print(-1)
else:
    if k >= 2**(n):
        print(-1)
    elif k==0:
        a = list(range(2**n))
        ans = a + list(reversed(a))
        print(*ans)
    else:
        a = [i for i in range(1,2**(n)) if i != k]
        ans = a + [k] + list(reversed(a)) + [0,k,0]
        print(*ans)

Measured memory_bytes: 16276
#include <iostream>

int main() {
    int A, B, X; //A:neko B:unknown C:neko(possible?)
    std::cin >> A >> B >> X;
    
    if (A + B < X) {
        std::cout << "NO" << std::endl;
    } else if (A > X) {
        std::cout << "NO" << std::endl;
    } else {
        std::cout << "YES" << std::endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;scanf("%d %d",&n,&m);
    priority_queue<int> que;
    for(int i=0;i<n;i++){
        int a;scanf("%d",&a);
        que.emplace(a);
    }
    while(m-- and que.size()){
        int q=que.top()/2;
        que.pop();
        if(q)que.emplace(q);
    }
    long long ans=0;
    while(que.size()){
        ans+=que.top();que.pop();
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 892
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String S = br.readLine();
        String S_[] = new String[S.length()];
        for (int i=0;i<S.length();i++){
            S_[i] = String.valueOf(S.charAt(i));
        }
        String cmp = "1";
        int zero = 0;
        int one = 0;
        for (int i=0;i<S.length();i++){
            if (S_[i].equals(cmp)){
                zero++;
            }
            if (cmp.equals("1")){
                cmp = "0";
            } else {
                cmp = "1";
            }
        }
        cmp = "0";
        for (int i=0;i<S.length();i++){
            if (S_[i].equals(cmp)){
                one++;
            }
            if (cmp.equals("1")){
                cmp = "0";
            } else {
                cmp = "1";
            }
        }
        System.out.println(Math.min(zero,one));
    }
}

Measured memory_bytes: 31444
// Copyright (C) 2016 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <cassert>
#include <ctime>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <string>

#define x first
#define y second
#define MP std::make_pair
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

typedef long long LL;
typedef std::pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
std::string procStatus()
{
    std::ifstream t("/proc/self/status");
    return std::string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        if (ch == '-')
            f = -1;
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 3e3 + 5;
const int MOD = 1e9 + 7;

int N, M;
int ub[MAXN];
int sum[MAXN];

void input()
{
    read(N); read(M);
    static char inp[MAXN];
    scanf("%s", inp + 1);
    for (int i = 1; i <= N; ++i) {
        sum[i] = sum[i - 1] + (inp[i] == '1');
    }
    for (int i = 1; i <= M; ++i) {
        int l, r;
        read(l); read(r);
        chkmax(ub[l], r);
    }
    for (int i = 1; i <= N; ++i) {
        chkmax(ub[i], std::max(i, ub[i - 1]));
    }
}

void solve()
{
    static int dp[MAXN][MAXN];

    dp[0][0] = 1;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= N; ++j) {
            if (!dp[i][j])
                continue;
            int s = sum[ub[i + 1]] - sum[ub[i]];
            if (j <= ub[i] - i) (dp[i + 1][j + s] += dp[i][j]) %= MOD;
            if (j - 1 <= ub[i] - i && j >= 1) (dp[i + 1][j - 1 + s] += dp[i][j]) %= MOD;
        }
    }
    int ans = (dp[N][0] + dp[N][1]) % MOD;

    write(ans); putchar('\n');
}

int main()
{
#ifdef __DEBUG
    freopen("F.in", "r", stdin);
    freopen("F.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

long power(long a, long b) {
    return b ? power(a*a%MOD, b/2) * (b%2?a:1)%MOD:1;
}

long perm(int N, int K) {
    long x = 1;
    for(int i = 1; i <= K; i++) x = x * (N-i+1) % MOD;
    return x % MOD;
}

long comb(int N,int K) {
    long x = 1, y = 1;
    for(int i = 1; i <= K; i++) {
        x = x * (N-i+1) % MOD;
        y = y * i % MOD;
    }
    return x * power(y, MOD-2) % MOD;
}

bool isprime(int n) {
    if(n < 2) return false;
    for(int i = 2; i*i <= n; ++i) {
        if (n % i ==  0) return false;
    }
    return true;
}

void dfs(const vector<vector<int> > &G, int v, vector<int> &seen) {
    seen[v] = true;

    for(int next_v : G[v]) {
        if(seen[next_v]) continue;
        dfs(G, next_v, seen);
    }
}

void yes() { cout << "Yes" << endl;}
void no() { cout << "No" << endl;}

int main() {
  char alpha;
  cin >> alpha;
  if(isupper(alpha)) {
    cout << "A" << endl;
  } else {
    cout << "a" << endl;
  }
}

Measured memory_bytes: 3572
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    char a[3],b[3];
    cin>>a>>b;
    if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])
        cout<<"YES"<<endl;
    else 
        cout<<"NO"<<endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
  // ifstream in("in.txt");
  // cin.rdbuf(in.rdbuf());
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;cin >> n;

  vector<int> odd(int(1e5));
  vector<int> even(int(1e5));
  int tmp;
  rep_i(i, n){
    cin >> tmp;
    if(i%2 == 0){
      even[tmp - 1]++;
    }else{
      odd[tmp - 1]++;
    }
  }

  int max_e = -1;
  int max_e_ind = 0;
  rep_i(i, even.size()){
    if(even[i] >= max_e){
      max_e = even[i];
      max_e_ind = i;
    }
  }
  
  int max_o = -1;
  int max_o_ind = 0;
  rep_i(i, odd.size()){
    if(odd[i] >= max_o){
      max_o = odd[i];
      max_o_ind = i;
    }
  }

  if(max_e_ind == max_o_ind){
    // if(max_e > max_o){
    //   d_sort_vi(odd);
    //   max_o = odd[1];
    // }else{
    //   d_sort_vi(even);
    //   max_e = even[1];
    // }
    d_sort_vi(even);
    int e1 = even[0];
    int e2 = even[1];
    d_sort_vi(odd);
    int o1 = odd[0];
    int o2 = odd[1];
    int ans = min(n - e1 - o2, n - e2 - o1);
    cout << ans << endl;
    return 0;
  }

  // int ans = min(n - e1 - o2, n - e2 - o1);
  // cout << ans << endl;
  // cout << max_e << endl;
  // cout << max_o << endl;
  cout << n - max_e - max_o << endl;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;


public class Main {

	private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1);

	private String inputData = null;

	public String[] data = null;

	public short num = 0;

	public short count = 0;

	public HashMap<Short, Short> humanData = new HashMap<Short, Short>();

	public ArrayList<Short> topId = new ArrayList<Short>();

	public ArrayList<Short> topLength = new ArrayList<Short>();

	public ArrayList<Long> mt = new ArrayList<Long>();
	public ArrayList<Long> mt2 = new ArrayList<Long>();
	public ArrayList<Long> mt3 = new ArrayList<Long>();
	public ArrayList<Long> mt4 = new ArrayList<Long>();
	public ArrayList<Long> mt5 = new ArrayList<Long>();
	public ArrayList<Long> mt6 = new ArrayList<Long>();
	public ArrayList<Long> mt7 = new ArrayList<Long>();
	public ArrayList<Long> mt8 = new ArrayList<Long>();

	public static void main(String[] args) {
		new Main().start();
		System.exit(0);
	}

	public void start() {
		while (true) {
			try {
				this.inputData = reader.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}

			this.data = this.inputData.split(" ");

			if (this.data.length == 1) {
				if (this.data[0].equals("0")) {
					break;
				}
				try {
					this.num = Short.parseShort(this.data[0]);
				} catch (Exception e) {
					continue;
				}

			}

			this.humanData.clear();

			for (int i = 0; i < this.num; i++) {
				try {
					this.inputData = reader.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (this.inputData != null) {
					this.data = this.inputData.split(" ");
				}

				this.humanData.put(Short.parseShort(data[0]),
						(short) (Short.parseShort(data[1]) + Short.parseShort(data[2])));

			}

			Iterator<Short> itId = this.humanData.keySet().iterator();
			int numCount = 0;
			while (itId.hasNext()) {
				short id = itId.next();
				if (numCount == 0) {
					this.topId.add(id);
					this.topLength.add(this.humanData.get(id));
				} else {
					if (this.topLength.get(count) <= this.humanData.get(id)) {
						this.topId.set(this.count, id);
						this.topLength.set(this.count, this.humanData.get(id));
					}
				}
				numCount++;
			}

			this.count++;

		}

		for (int i = 0; i < this.topId.size(); i++) {
			System.out.println(this.topId.get(i) + " " + this.topLength.get(i));
		}

	}

}

Measured memory_bytes: 100308
<?php
$N = (int)fgets(STDIN);
$A = array_map(function ($n) {
    return (int)$n;
}, explode(' ', fgets(STDIN)));

rsort($A);

if ($N % 2 === 0) {
    echo array_sum(array_slice($A, 0,  $N / 2)) * 2 - $A[0];
    return;
}

echo array_sum(array_slice($A, 0,  ($N - 1) / 2)) * 2 - $A[0] + $A[($N - 1) / 2];

Measured memory_bytes: 38288
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()



signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  int n;
  cin >> n;
  
  vector<int> a(n);  rep(i, 0, n) cin >> a[i];
  sort(allg(a));
  
  int ans = 0;
  rep(i, 0, n) {
    if(i%2==0) ans += a[i];
    else ans -= a[i];
  }
  
  cout << ans << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";
  
  //cout << fixed << setprecision(15) << n << "\n";

}

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

using namespace std;

int main(void) {
	int h, w, d, n, r;
	int s, m, l;
	int i;

	while(true) {
		cin >> h >> w >> d;
		if(h == 0 && w == 0 && d == 0) { break; }
		cin >> n;
		for(i = 0; i < n; i++) {
			cin >> r;
			s = min(min(h,w),d);
			l = max(max(h,w),d);
			if(s == min(h,w) && l == max(h,w)) { m = d; }
			else if(s == min(h,d) && l == max(h,d)) { m = w; }
			else if(s == min(w,d) && l == max(w,d)) { m = h; }
			if(sqrt(s*s+m*m)/2 < r) {
				cout << "OK" << endl;
			} else {
				cout << "NA" << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

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

int main() {
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	
	cout << max(a*b,c*d) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll N;
    cin>>N;
    VL A(N);
    VVL x(N, VL (N));
    VVL y(N, VL (N));
    rep(i, 0, N){
        cin >> A[i];
        rep(j, 0, A[i]){
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }

    ll ans = 0;
    for(int bit; bit<(1<<N); bit++){
        bool f=true;
        VL truth(N, -1);
        for(int i=0; i<N; i++){
            if(bit&(1<<i))truth[i]=1;
            else truth[i]=0;
        }

        ll cnt=0;
        for(int i=0; i<N; i++){
            if(bit&(1<<i)){
                cnt++;
                rep(j,0,A[i]){
                    if(truth[x[i][j]] != y[i][j]){
                        f = false; //矛盾
                    }
                }
            }
        }
        if(f) ans =max(cnt, ans);

    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/*He who forgives and acknowledges himself... that is what it truly means to be strong!*/
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
#include <list>
#include <deque>
#include <bitset>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <sstream>
#include <complex>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <climits>
#include <utility>
#include <ctime>
#include <tuple>
#include <fstream>
#define T int test_case; scanf("%d",&test_case); while(test_case--)
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORD(i,a,n) for(i=a;i>=n;i--)
#define FORS(i,a) for(i=0;a[i];i++)
#define si(x) scanf("%d",&x)
#define sc(x) cin>>x
#define sd(x) scanf("%lf",&x)
#define sll(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define prs(x) printf("%d ",x)
#define pls(x) printf("%lld ",x)
#define pc(x) printf("%c",x)
#define pi(x) printf("%d\n",x)
#define pd(x) cout.precision(10),cout<<fixed<<x<<endl;
#define pll(x) printf("%lld\n",x)
#define ps(x) printf("%s\n",x)
#define M 1000000007
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define pb push_back
#define fr first
#define se second
#define in insert
#define er erase
#define pii pair<int, int>
#define plll pair<long long, long long>
#define tr(x,it) for(auto it : x)
#define INF 1ll<<60
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230
#define bs(x,lo,hi,mid) cout<<x<<" "<<lo<<" "<<hi<<" "<<mid<<endl;
using namespace std;
ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n&1) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n&1) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
vector<int> prime;
bool primee[10000000];
void primegen(ll x) { for(ll i=2;i*i<=x;i++) if(!primee[i]) for(ll j=i*i;j<=x;j+=i) primee[j]=true; for(ll i=2;i<=x;i++) if(!primee[i]) prime.push_back(i);}


int main()
{
   int i,j;
   int a,b;
   si(a);
   si(b);
   pi((a+b)%24);
   return 0;
}


Measured memory_bytes: 256
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    import math
    A,B = LMIIS()
    print(math.ceil((B-A)/(A-1))+1)



if __name__ == '__main__':
    main()

Measured memory_bytes: 38512
#include<iostream>
#include<algorithm>
using namespace std;
int a[5][5];
int b[15];
int ans=0,t=0,teil=0,head=0;
int main()
{
	int n;
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++)
		{
			cin>>a[i][j];
		}
	}
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
	}
	for(int i=1;i<=3;i++)
	{
		ans=0;
		t=0;
		for(int j=1;j<=3;j++)
		{
			for(int k=1;k<=n;k++)
			{
				if(a[i][j]==b[k])
				{
					ans++;
				}
				if(a[j][i]==b[k])
				{
					t++;
				}
			}
		}
		if(ans==3||t==3) break;
	}
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(a[i][i]==b[j])
			{
				teil++;
			}
			if(a[4-i][i]==b[j])
			{
				head++;
			}
		}
	}
	if(teil==3||head==3||ans==3||t==3) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 760
#include<bits/stdc++.h>
using namespace std;
int ans,n,x,s,m=0x3f3f3f3f;
int a;
int main(){
	cin>>n>>x; ans=n;
	for(int i=1;i<=n;i++){
		cin>>a,s+=a;
		m=min(a,m);
	} 
	x-=s;
	ans+=x/m;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256