akhauriyash/Code-Regression huggingface dataset:
import java.math.BigInteger;
import java.util.Scanner;

class Main {

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

            int num = -1;
            while (sc.hasNextInt() && (num = sc.nextInt()) != 0) {
                BigInteger factorial = calc(num);

                char[] c = String.valueOf(factorial).toCharArray();
                int count = 0;
                for (int i = c.length - 1; i > 0; i--) {
                    if ('0' != c[i]) {
                        break;
                    }
                    count++;
                }

                System.out.println(count);
            }
        } finally {
            sc.close();
        }
    }

    public static BigInteger calc(int num) {
        BigInteger result = new BigInteger("1");
        BigInteger original = new BigInteger(String.valueOf(num));
        for (int i = 0; i < num; i++) {
            result = result.multiply(original.subtract(new BigInteger(String
                    .valueOf(i))));
        }
        return result;
    }
}

Measured memory_bytes: 162588
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
   int a,b;
   char t;
   
   while(cin>>a>>t>>b)
   {
   	int s=t;
   	if(s=='?') return 0;
   	else
	   	{

		   switch(s)
		   {
		   	case '+':cout<<a+b<<endl;break;
		   	case '-':cout<<a-b<<endl;break;
		   	case '*':cout<<a*b<<endl;break;
		   	case '/':cout<<a/b<<endl;break;
		   }
		}
	}
   return 0;
}



Measured memory_bytes: 3076
#二分ヒープ
class BinaryHeap
  def initialize(n, &b)
    @heap = Array.new(n)
    @size = 0
    #ex) |parent, child| parent <= child
    @b = b
  end
  def push(x)
    me = @size
    @size += 1
    while 0 < me do
      parent = (me - 1) >> 1
      break if @b.call(@heap[parent], x)
        @heap[me] = @heap[parent]
        me = parent
    end
    @heap[me] = x
  end
  def shift
    wk = @heap[0]
    me = 0
    @size -= 1
    x = @heap[@size]
    while me < @size do
      child = (me << 1) + 1
      break if child >= @size
      if (child + 1) < @size && @b.call(@heap[child + 1], @heap[child]) then
        child += 1
      end
      break if @b.call(x, @heap[child])
      @heap[me] = @heap[child]
      me = child
    end
    @heap[me] = x
    wk
  end
  def empty?
    @size == 0
  end
end

N, M = gets.chomp.split(" ").map(&:to_i)
W = []
N.times{
  W << gets.chomp.split(" ").map(&:to_i)
}

W.sort!{|a, b| a[0] <=> b[0]}
lst = BinaryHeap.new(N){|parent, child| parent >= child}

ans = 0
(1..M).each{|m|
  while (not W.empty?) && W.first[0] <= m do
    a, b = W.shift
    lst.push(b)
  end
  ans += lst.shift if not lst.empty?
}

puts ans


Measured memory_bytes: 12564
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
const int size=4000;
bool visited[size][size];
int distances[size][size];
vector<int> graph[size];
int amount, diameter;
void fillingGraph()
{
	cin>>amount>>diameter;
	int vertex0, vertex1;
	for(int i=1; i<=amount; ++i)
	{
		cin>>vertex0>>vertex1;
		graph[vertex0].push_back(vertex1);
		graph[vertex1].push_back(vertex0);
	}
	return;
}
void dfs(int root, int first, int distance)
{
	stack<int> stack;
	stack.push(first);
	distances[root][first]=distance;
	while(!stack.empty())
	{
		first=stack.top();
		stack.pop();
		visited[root][first]=true;
		for(int second : graph[first])
		{
			if(!visited[root][second])
			{
				stack.push(second);
				distances[root][second]=distances[root][first]+1;
			}
		}
	}
	return;
}
void usingDFS()
{
	for(int point=1; point<=amount; ++point)
	{
		dfs(point, point, 0);
	}
	if(diameter%2==0)
	{
		int counterEven, minimumEven=4000;
		for(int i=1; i<=amount; ++i)
		{
			counterEven=0;
			for(int j=1; j<=amount; ++j)
			{
				if(distances[i][j]>diameter/2)
				{
					++counterEven;
				}
			}
			minimumEven=min(minimumEven, counterEven);
		}
	cout<<minimumEven<<endl;
	}
	if(diameter%2!=0)
	{
		int counterOdd, minimumOdd=4000, temporary;
		for(int i=1; i<=amount; ++i)
		{
			for(int j=1; j<=amount; ++j)
			{
				if(distances[i][j]==1)
				{
					counterOdd=0;
					for(int k=1; k<=amount; ++k)
					{
						temporary=min(distances[k][i], distances[k][j]);
						if(temporary>diameter/2)
						{
							++counterOdd;
						}
					}
					minimumOdd=min(minimumOdd, counterOdd);
				}
			}
		}
	cout<<minimumOdd<<endl;
	}
	return;
}
int main()
{
	fillingGraph();
	usingDFS();
	return 0;
}

Measured memory_bytes: 41344
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int a,b,c;
int main(){
	cin>>a>>b>>c;
	if(a+b+c<22)
	cout<<"win";
	else
	cout<<"bust";
	re 0;
}


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if ((A==7&B==5&C==5) ||  
        (A==5&B==7&C==5) ||
        (A==5&B==5&C==7)) {
            cout << "YES" << endl;
        }

    else cout << "NO" << endl;
}    

Measured memory_bytes: 256
import sys

n, *l = map(int, sys.stdin.read().split())

def main():
    l.sort(reverse=True)

    a = b = 0
    i = 0
    while i <= n - 2:
        if l[i] == l[i+1]:
            if a:
                b = l[i]
                break
            else:
                a = l[i]
                i += 2
                continue
        i += 1
    
    return a * b

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 14052
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<vector>
#include<cmath>
#include<algorithm>
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rrep(i, a, b) for(int i=b-1; i>=a; i--)
#define REP(i, n) for(int i=0; i<n; i++)
#define rREP(i, n) for(int i=n-1; i>=0; i--)
#define MAX 100001
typedef long long ll;
using namespace std;

int main(void){
  int n, k; cin >> n >> k;
  cout << (n%k==0? 0:1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define MAX_COUNT 200005
#define LL long long
using namespace std;
LL health[MAX_COUNT] = {0};

int partition(int start, int end)
{
	int p = start;
	LL pivot = health[end];
	for (int j = start; j < end; ++j)
	{
		if (health[j] < pivot)
		{
			LL t = health[j];
			health[j] = health[p];
			health[p] = t;
			p ++;
		}
	}
	health[end] = health[p];
	health[p] = pivot;
	return p;
}

void quicksort(int start, int end)
{
	if (start < end)
	{
		LL p = partition(start, end);
		quicksort(start, p - 1);
		quicksort(p + 1, end);
	}
}

int main(int argc, char const *argv[])
{
	int count, specials;
	cin >> count >> specials;
	LL res  = 0;
	for (int i = 0; i < count; ++i)
	{
		cin >> health[i];
	}
	if (count <= specials)
	{
		cout << 0;
		goto end;
	}
	if (specials == 0)
	{
		for (int i = 0; i < count; ++i)
		{
			res += health[i];
		}
		cout << res;
		goto end;
	}
	quicksort(0, count - 1);
	for (int i = 0; i < count - specials; ++i) res += health[i];
	cout << res;
end:
	return 0;
}

Measured memory_bytes: 2424
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n;
        cin>>n;
        ll x, sum =0 ;
        vl freq(MAX, 0);    
        rep(i, n){
            cin>>x;
            freq[x]++; sum += x;
        }
        ll q;
        cin>>q;
        ll a, b;
        rep(i, q){
            cin>>a>>b;
            sum += freq[a]*(b - a);
            freq[b] += freq[a];
            freq[a] = 0;
            cout<<sum<<endl;
        }
    }
}

Measured memory_bytes: 11060
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

map<long long, int> primeFact(long long n) {
  map<long long, int> ret;
  for(long long i = 2; i * i <= n; i += (i > 2 ? 2 : 1)) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

const int MOD = 1000000007;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void Comb() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long nCr(int n, int r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

int main(){
  Comb();
  int n, m;
  cin >> n >> m;
  map<ll, int> a;
  a = primeFact(m);
  ll ans = 1;
  for(auto itr=a.begin(); itr != a.end(); itr++){
    ans *= nCr(n+itr->second-1, itr->second);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12288
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
    card: [[usize; 3]; 3],
    n: usize,
    b: [usize; n]
    }
    let mut h = [0; 3];
    let mut w = [0; 3];
    let mut s = [0; 2];

    for (i, row) in card.iter().enumerate() {
        for (j, num) in row.iter().enumerate() {
            if b.contains(&num) {
                h[i] += 1;
                w[j] += 1;
                if i == j { s[0] += 1;}
                if i == (2 - j) { s[1] += 1;}
            }
        }
    }
    if h.contains(&3) || w.contains(&3) || s.contains(&3) {
        println!("Yes");
    } else { println!("No"); }
}



Measured memory_bytes: 4352
import static java.lang.System.out;
import java.lang.Math;
import java.io.InputStream;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Collections;

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

    MyInput in = new MyInput();
    public void run() {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        if(a + b >= c)
            out.println("Yes");
        else 
            out.println("No");
    }
}

class MyInput {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr= 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if(ptr < buflen) {
            return true;
        }else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch(IOException e) {
                e.printStackTrace();
            }
            if(buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    public int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <=126;
    }

    private void skipUnprintable() {
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    public boolean hasNext() {
        skipUnprintable();
        return hasNextByte();
    }

    public String next() {
        if(!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if(!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if(b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true) {
        if('0' <= b && b <= '9') {
            n *= 10;
            n += b - '0';
        }else if(b == -1 || !isPrintableChar(b)) {
            return minus ? -n : n;
        }else {
            throw new NumberFormatException();
        }
            b = readByte();
        }
  }

    public int nextInt() {
        long nl = nextLong();
        if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21332
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int x,y;
    cin>>x>>y;
    cout<<x+y/2<<endl;
}

Measured memory_bytes: 256
import "dart:io";
import 'dart:async';
import 'dart:convert';
import 'dart:math' as Math;

void main() async {
  int N = int.parse(stdin.readLineSync());
  var lines = stdin.transform(utf8.decoder).transform(LineSplitter());
  List<int> A = [];
  await for (var line in lines) {
    A = line.split(' ').map((x) => int.parse(x)).toList();
  }
  for (int i = 0; i < N; i++) {
    if (A[i] == 0) {
      print(0);
      return;
    }
  }
  final M = Math.pow(10, 18);
  int r = 1;
  for (int i = 0; i < N; i++) {
    if (A[i] <= M / r && r * A[i] <= M) {
      r *= A[i];
    } else {
      print(-1);
      return;
    }
  }
  print(r);
}


Measured memory_bytes: 28576
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    // Failed to predict input format
    ll H, W, K;
    cin >> H >> W >> K;
    vec<string> mp(H);
    REP(i, H){
        cin >> mp[i];
    }
    ll cnt = 0;
    REP(i, 1ll<<12){
        ll hb = i&0x3f;
        ll wb = (i>>6)&0x3f;
        ll cnt_s = 0;
        if(hb>=(1<<H) || wb>=(1<<W))
            continue;
        REP(j, H){
            if(hb & (1<<j))
                continue;
            REP(k, W){
                if(wb & (1<<k))
                    continue;
                if(mp[j][k] == '#')
                    cnt_s++;
            }
        }
        if(cnt_s == K){
            cnt++;
        }
    }
    cout << cnt << el;
}




Measured memory_bytes: 3624
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;


        cin>>n;

        for(i=0; i<n; i++)
        {
            cin>>a;

            sum+=a;

            cnt=max(cnt,a);
        }

        sum-=cnt;

        sum+=(cnt/2);

        cout<<sum<<endl;












}



Measured memory_bytes: 3588
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 998244353LL;;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

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

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

int solve() {
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	vector<vector<ll>> results = vector<vector<ll>>(C - A + 1, vector<ll>(D - B + 1));

	ll rd, lu, ld, res;
	results[0][0] = 1;
	for (ll k = 1; k <= C - A + D - B; ++k) {
		for (ll e = max(k - (D - B), 0LL); e <= C - A && 0 <= k - e; ++e) {
			ll f = k - e;

			rd = (e - 1 >= 0 ? results[e - 1][f] : 0);
			lu = (f - 1 >= 0 ? results[e][f - 1] : 0);
			ld = (e - 1 >= 0 && f - 1 >= 0 ? results[e - 1][f - 1] : 0);
			res = rd * (f + B) % MOD +
				lu * (e + A) % MOD -
				ld * (e + A - 1) % MOD * (f + B - 1) % MOD;
			res = (res + MOD) % MOD;

			results[e][f] = res;
		}
	}

	cout << results[C - A][D - B] << endl;

	return 0;
}

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

	solve();

	return 0;
}


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

using namespace std;

#define Vi vector<int>
#define FOR(i,s,e) for (int i=s; i<e; i++)
#define ITER(v) v.begin(), v.end()

constexpr int N_MAX = 10000;
constexpr int INF   = 1<<30;

using IPAIR = pair<int, int>;

vector<IPAIR> weight[N_MAX];
int dis[N_MAX];

void set_shortest_distance(const int n) {
    FOR(i,0,n) {
        dis[i] = INF;
    }

    bool ismember[n] = { false };

    priority_queue<IPAIR, vector<IPAIR>, greater<IPAIR>> pq;
    pq.push(make_pair(0, 0));

    while (!pq.empty()) {
        IPAIR top = pq.top(); pq.pop();
        const int top_i = top.second;
        if (ismember[top_i]) { continue; }
        ismember[top_i] = true;
        const int top_d = top.first;
        dis[top_i] = top_d;
        for (const IPAIR& next : weight[top_i]) {
            const int next_i = next.second;
            if (ismember[next_i]) { continue; }
            const int next_w = next.first;
            const int d = top_d + next_w;
            pq.push(make_pair(d, next_i));
        }
    }
}

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

    int n;
    cin >> n;

    int u, k, v, c;
    FOR(i,0,n) {
        cin >> u >> k;
        FOR(j,0,k) {
            cin >> v >> c;
            weight[u].push_back(make_pair(c,v));
        }
    }

    set_shortest_distance(n);

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

    return 0;
}

Measured memory_bytes: 9792
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int S[200005], T[200005], D[200005];
set<int> st;
map<int, int> m;
queue<int> q;
vector<P> X;

int main(void) {
  int N, Q;
  cin >> N >> Q;
  rep(i, 0, N) {
    int x;
    cin >> S[i] >> T[i] >> x;
    X.pb(mp(x, i));
  }
  rep(i, 0, Q) {
    cin >> D[i];
    st.insert(D[i]);
    m[D[i]] = -1;
  }
  
  sort(all(X));
  
  rep(i, 0, N) {
    int x = X[i].first, idx = X[i].second;
    auto b = st.lower_bound(S[idx]-x);
    auto e = st.lower_bound(T[idx]-x);
    vector<int> v;
    while (b!=e) {
      int t = *b;
      q.push(t);
      m[t] = x;
      b++;
    }
    
    while(!q.empty()) {
      st.erase(q.front());
      q.pop();
    }
  }
  
  rep(i, 0, Q) {
    cout << m[D[i]]<< endl;
  }
  
  //cout << ans << endl;

    return 0;
}



Measured memory_bytes: 26468
// #include<iostream>
// #include<vector>
// #include<algorithm>
// #include<map>
// #include<cstring>
// #include<math.h>
// #include<bitset>
// #include<queue>
// #include<set>
// #include<iomanip>
// #include<math.h>
// #include<assert.h>
// #include<string>
// #include<cstdlib>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans=0;
  for(int i=0; i<N-2; i++){
    if(S.substr(i,3) == "ABC"){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def compute_lcm(x, y):
   if x > y:
       greater = x
   else:
       greater = y
   while(True):
       if((greater % x == 0) and (greater % y == 0)):
           lcm = greater
           break
       greater += 1
   return lcm
n=int(input())
if(n%360==0):
  print(n//360)
else:
  print(compute_lcm(n,360)//n)

Measured memory_bytes: 9184
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public int[] A;

        public void Run()
        {
            {
                N = Input.ReadInt();
                A = Input.ReadIntArray();
            }

            Dictionary<int, int> count = new Dictionary<int, int>();

            for (int i = 0; i < N; i++)
            {
                if(!count.ContainsKey(A[i])) count.Add(A[i], 0);
                count[A[i]]++;
            }

            long ret = 0;
            foreach (var kv in count)
            {
                if (kv.Value < kv.Key) ret += kv.Value;
                else ret += kv.Value - kv.Key;
            }

            Console.WriteLine(ret);

        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 28380
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;

int n,m;
string s;
map<int,int> mp;
                   
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>n;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    mp[a]++;
  }
  cin>>m;
  for(int i=0;i<m;i++){
    int a;cin>>a;
    if(mp[a]>0){
      mp[a]--;
    }else{
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

char s[210000];

int nx2[26];
int nx[210000][26];
int dp[210000];
int nl[210000];

int main() {
	scanf("%s", s);
	int n = strlen(s);
	for (int i = 0; i < 26; ++i)
		nx2[i] = -1;
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j)
			nx[i + 1][j] = nx2[j];
		nx2[s[i] - 'a'] = i + 1;
	}
	for (int i = 0; i < 26; ++i)
		nx[0][i] = nx2[i];
	for (int i = n; i >= 0; --i) {
		int go = n + 1;
		int bst = -1;
		for (int j = 0; j < 26; ++j) {
			int gg = 0;
			if (nx[i][j] != -1)
				gg = dp[nx[i][j]] + 1;
			if (gg < go)
				go = gg, bst = j;
		}
		dp[i] = go;
		nl[i] = bst;
	}
	int now = 0;
	string ans;
	while (now != -1) {
		ans += char('a' + nl[now]);
		now = nx[now][nl[now]];
	}
	cout << ans << "\n";
	return 0;
}





Measured memory_bytes: 22912
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <numeric>

using namespace std;

int main()
{
  long sum=0;
  int n,m;
  cin >> n >> m;
  priority_queue<int,vector<int>,greater<int> >q;
  for(int i=0 ;i<n ;i++){
    int a;
    cin >> a;
    q.push(a);
    sum+=a;
  }


  vector<pair<int,int> > v(m);
  for(int i=0;i<m;i++)
  {
    int b,c;
    cin >> b >> c;
    v[i]=make_pair(b,c);
  }
  sort(v.begin(),v.end(),
       [](pair<int,int> l,pair<int,int> r){return l.second > r.second;});

  for(auto y:v){
    for(int i=0;i<y.first;i++){
      if(q.top() >= y.second)
        goto end;
      sum-=q.top();
      q.pop();
      q.push(y.second);
      sum+=y.second;
    }
  }

end:

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 1528
N,M=input().split()
N = int(N)
M = int(M)

L_max = 0
R_min = N

for i in range(M):
    L_x,R_x=input().split()
    L_x = int(L_x)
    R_x = int(R_x)
    
    if L_x > L_max:
        L_max = L_x
    if R_x < R_min:
        R_min = R_x

        
if R_min < L_max:
    print(0)
else:
    print(R_min - L_max + 1)

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

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n, m, d; cin >> n >> m >> d;

	double ans = ((d == 0 ? 1.0 : 2.0) * (n - d)) * (m - 1) / n / n;
	printf("%.10f\n", ans);

	return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: u32) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n:usize = read();
    let a:Vec<u64> = read_vec();

    let mut ans:u64 = 0;
    for i in 0..((n/2)+1){
        ans += a[i*2];
    }
    for i in 0..(n/2){
        ans -= a[i*2+1];
    }
    print!("{}", ans);
    for i in 0..(n-1){
        ans = 2*a[i] - ans;
        print!(" {}", ans);
    }
    println!("");
}


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

using namespace std;

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

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    int n;
    cin >> n;

    vector<ll> a(n);
    for (auto &a_i : a) cin >> a_i;

    ll num_neg = 0, abs_sum = 0, idx_neg = -1, idx_pos = -1;
    for (int i = 0; i < n; ++i) {
        if (a[i] < 0) {
            ++num_neg;
            if (idx_neg == -1 || a[i] < a[idx_neg])
                idx_neg = i;
        }
        else {
            if (idx_pos == -1 || a[i] < a[idx_pos])
                idx_pos = i;
        }
        abs_sum += abs(a[i]);
    }

    if (num_neg % 2 == 0) cout << abs_sum << endl;
    else if (num_neg == n) {
        for (int i = 0; i < n; ++i)
            if (a[idx_neg] < a[i]) idx_neg = i;
        cout << abs_sum + 2 * a[idx_neg] << endl;
    }
    else {
        int idx = idx_neg;
        for (int i = 0; i < n; ++i)
            if (a[i] < 0 && a[idx_neg] < a[i]) idx_neg = i;
        cout << max({abs_sum + 2 * a[idx_neg],
                    abs_sum - 2 * a[idx_pos],
                    abs_sum + 2 * a[idx]}) << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl
#define YORN(f) cout<<((f)?"YES":"NO")<<endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl
using namespace std;
int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x -a) < abs(x - b)) {
        println("A");
    }
    else {
                println("B");

    }
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>

int isHamming(int n)
{
	while (n%2==0) n/=2;
	while (n%3==0) n/=3;
	while (n%5==0) n/=5;
	return (n==1) ? 1 : 0;
}

int main()
{
	int m, n;
	while (true) {
		std::cin >> m;
		if (m==0) break;
		std::cin >> n;
		int res = 0;
		for (int i=m; i<=n; i++) {
			res += isHamming(i);
		}
		std::cout << res << std::endl;
	}
	return 0;
}



Measured memory_bytes: 3060
H,W = map(int,input().split())
S = []
S.append('.'*(2+W))
for i in range(H):
    S.append('.'+input()+'.')
S.append('.'*(2+W))
Sans = []
for i in range(1,H+1):
    S1 = ''
    for j in range(1,W+1):
        ans = 0
        if S[i][j] == '.':
            if S[i-1][j-1] == '#':
                ans +=1
            if S[i-1][j] == '#':
                ans +=1
            if S[i-1][j+1] == '#':
                ans +=1
            if S[i][j-1] == '#':
                ans +=1
            if S[i][j+1] == '#':
                ans +=1
            if S[i+1][j-1] == '#':
                ans +=1
            if S[i+1][j] == '#':
                ans +=1
            if S[i+1][j+1] == '#':
                ans +=1
        if S[i][j] == '#':
            ans = '#'
        S1 += str(ans)
    Sans.append(S1)

for i in range(H):
    print(Sans[i])


Measured memory_bytes: 9076
#include <iostream>
int main(){
    int a,b,c;
    std::cin >> a >> b >> c;
    if(a==b){
        std::cout << c << std::endl;
    }else if(b==c){
        std::cout << a << std::endl;
    }else if(a==c){
        std::cout << b << std::endl;
    }
    return 0;
}

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

using namespace std;
int main(){
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    int i=0;
    bool flag;
    while (i<=S.size()){
        if('m' == S[i] && 'a' == S[i+1] && 'e' == S[i+2] && 'r' == S[i+3] && 'd' == S[i+4]) i+=5;
        else if('r' == S[i] && 'e' == S[i+1]  && 'm' == S[i+2] && 'a' == S[i+3] && 'e' == S[i+4] && 'r' == S[i+5] && 'd' == S[i+6]) i+=7;
        else if('e' == S[i] && 's' == S[i+1] && 'a' == S[i+2] && 'r' == S[i+3] && 'e' == S[i+4]) i+=5;
        else if('r' == S[i] && 'e' == S[i+1] && 's' == S[i+2] && 'a' == S[i+3] && 'r' == S[i+4] && 'e' == S[i+5]) i+=6;
        else if(i==S.size()) {
            flag = true;
            break;
        }
        else{
            flag = false;
            break;
        }
    }
    if(flag) cout << "YES" << "\n";
    else cout << "NO" << "\n";
    return 0;
}

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

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


Measured memory_bytes: 3632
N,n=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

ans=0
i=0
while A[i]<=n:
  if i==N-1:
    if n==A[i]:
      ans+=1
    break
  else:
    ans+=1
    n-=A[i]
    i+=1  
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

string s;
ll sig[100010],ans[100010];

ll prof( ll p ){
    if( sig[p]!=-1 ) return sig[p];
    if( s[p]=='R' ) return sig[p] = prof( p+1 );
    return sig[p] = prof( p-1 );
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> s;
    for(ll i=0; i<s.size(); i++) sig[i]=-1;
    for(ll i=0; i<s.size()-1; i++){
        if( s[i]=='R' && s[i+1]=='L' ) sig[i] = i , sig[i+1] = i+1;
    }

    for(ll i=0; i<s.size(); i++) prof( i );

    for(ll i=0; i<s.size(); i++){
        if( s[i]=='R' ){
             if( (sig[i]-i)%2==0 ){
                 ans[ sig[i] ]++;
             }else{
                ans[ sig[i]+1 ]++;
             }
        }else{
            if( (i-sig[i])%2==0 ){
                 ans[ sig[i] ]++;
            }else{
                ans[ sig[i]-1 ]++;
            }
        }
    }

    for(ll i=0; i<s.size(); i++) cout << ans[i] << " ";

    return 0;
}


Measured memory_bytes: 3024
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    T, A = list(map(int,_in[1].split(' ')))  # type:list(int)
    H_arr = list(map(int,_in[2].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    x = (T-A)/0.006
    diff = [abs(h-x) for h in H_arr]
    cnt = diff.index(min(diff))+1
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 38256
#include<iostream>
#include<complex>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>

#define fs first
#define sc second
#define pb push_back
#define sz size()

using namespace std;

typedef complex<double> P;

typedef pair<P,double> C;

const double EPS = 1e-8;
const double PI = acos(-1);


//for vector
P unit(P p){return p / abs(p);}
double dot(P x,P y){return real(conj(x)*y);}

//rotate a point counter-clockwise on the origin
P rotate(P v,double s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

//return seta A
double arg(double a,double b,double c){return acos( (b*b+c*c-a*a)/(2*b*c) );}

//for circle

//circle position relation
int cpr(C a,C b){
  double d = abs(a.fs-b.fs);
  if(a.sc+b.sc + EPS < d)return -1;      //no cross point (outside)
  if(b.sc+d + EPS < a.sc)return 1;       //no cross point (inside,B in A)
  if(a.sc+d + EPS < b.sc)return 2;       //no cross point (inside,A in B)
  return 0;                              //two cross point
}

vector<P> cp_cir_to_cir(C a, C b){
  vector<P> v;
  int pos = cpr(a,b);
  if(pos==0){
    double s = arg(b.sc,abs(b.fs-a.fs),a.sc);
    P x = a.sc * unit(b.fs - a.fs);
    v.pb(a.fs + rotate(x,s));
    v.pb(a.fs + rotate(x,-s));
  }else if(abs(pos) >= 3){
    v.pb(a.fs + a.sc * unit(b.fs-a.fs));
  }
  return v;
}

int n;
double x[10],y[10],l[10];

bool check(double h){
  C c[10];
  for(int i=0;i<n;i++){
    c[i] = make_pair( P(x[i],y[i]), sqrt(l[i]*l[i] - h*h) );
  }

  vector<P> v,tmp;
  for(int i=0;i<n;i++){
    v.pb(c[i].fs);
    for(int j=i+1;j<n;j++){
      tmp = cp_cir_to_cir(c[i],c[j]);
      for(int k=0;k<tmp.size();k++)v.pb(tmp[k]);
    }
  }

  for(int i=0;i<v.size();i++){
    bool f = true;
    for(int j=0;j<n;j++){
      if(abs(v[i]-c[j].fs) > c[j].sc + EPS){
	f = false;
	break;
      }
    }
    if(f)return true;
  }
  return false;
}
  
int main(){
  while(cin >> n,n){
    double a=0, b=1e10;
    for(int i=0;i<n;i++){
      cin >> x[i] >> y[i] >> l[i];
      b = min(b,l[i]);
    }

    for(int i=0;i<100;i++){
      double mid = (a+b)/2;
      if(check(mid))a = mid;
      else b = mid;
    }
    cout << fixed << setprecision(10) << a << endl;
  }
}

Measured memory_bytes: 1416
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}

int main(){
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a+b)*h*0.5 << endl;
}   



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B,a=0,b=0;string S;cin>>N>>A>>B>>S;
  for(int i=0;i<N;i++){
    if(S.at(i)=='c')cout<<"No"<<endl;
    else{
      if(A+B>a){
        if(S.at(i)=='a'){
          a++;cout<<"Yes"<<endl;
        }
        else{
          if(B>b){
            a++;b++;cout<<"Yes"<<endl;
          }
          else cout<<"No"<<endl;
        }
      }
      else cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>

using namespace std;

int main(){
	
	string str;
	
	while(true){
		
		getline(cin, str);
		
		if(str.size() == 1){
			break;
		}
		
		stack<int> sta;
		
		bool flag = true;
		
		for(int i = 0; i < str.size(); i++){
			if(str[i] == '('){
				sta.push(0);
			}else if(str[i] == '['){
				sta.push(1);
			}else if(str[i] == ')'){
				if(sta.empty()){
					flag = false;
					continue;
				}
				if(sta.top() != 0){
					flag = false;
				}
				sta.pop();
			}else if(str[i] == ']'){
				if(sta.empty()){
					flag = false;
					continue;
				}
				if(sta.top() != 1){
					flag = false;
				}
				sta.pop();
			}
		}
		
		if(!sta.empty()){
			flag = false;
		}
		
		if(flag){
			cout << "yes" << endl;
		}else{
			cout << "no" << endl;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 3000
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
#define lp(k,a) for(int k=1;k<=a;k++)
#define lp0(k,a) for(int k=0;k<a;k++)
#define lpn(k,n,a) for(int k=n;k<=a;k++)
#define lpd(k,n,a) for(int k=n;k>=a;k--)
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d %d",&a,&b)
#define ll long long
#define mod 1000000007

using namespace std;

int n,m;

char s1[60],s2[60];

ll x,y;

int main()
{
  //  freopen("in.txt","r",stdin);
    ll re=1;
    cin>>n;
    cin>>s1>>s2;
    int pre=0;
    lp0(i,n)
    {
        if(s1[i]==s2[i])
        {
            //cout<<"**"<<endl;
            if(pre==0)
            {
                re*=3;
                re%=mod;
                pre=1;
            }
            else
            if(pre==1)
            {
                re*=2;
                re%=mod;
                pre=1;
            }
            else if(pre==2)
            {
                pre=1;
            }

        }
        else
        {
            i++;
            if(pre==0)
            {
                re*=6;
                re%=mod;
                pre=2;
            }
            else if(pre==1)
            {
                re*=2;
                re%=mod;
                pre=2;
            }
            else if(pre==2)
            {
                re*=3;
                re%=mod;
                pre=2;
            }
        }


    }

  cout<<re%mod<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x)(x)*(x)
#define fz1(i,n) for (i=1;i<=n;i++)
#define fd1(i,n) for (i=n;i>=1;i--)
#define fz0g(i,n) for (i=0;i<=n;i++)
#define fd0g(i,n) for (i=n;i>=0;i--)
#define fz0k(i,n) for (i=0;i<n;i++)
#define fd0k(i,n) for (i=(long long)(n-1);i>=0;i--)
#define fz(i,x,y) for (i=x;i<=y;i++)
#define fd(i,y,x) for (i=y;i>=x;i--)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){char ss[len];scanf("%s",ss);(st)=ss;}
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
int n,m,i,j,num[500005],cnt1[500005],cnt2[500005],ans,p[500005],s[500005];
string st;
int main()
{
	scanf("%d",&n);
	ans=p[0]=s[500001]=n;
	fz1(i,n)
	{
		scanf("%d",&num[i]);
		if (i&1) cnt1[num[i]]++; else cnt2[num[i]]++;
	}
	fz1(i,500000)
	{
		p[i]=min(p[i-1],(n+1)/2-cnt1[i]);
	}
	fd1(i,500000)
	{
		s[i]=min(s[i+1],(n+1)/2-cnt1[i]);
	}
	fz1(i,500000) ans=min(ans,min(p[i-1],s[i+1])+n/2-cnt2[i]);
	printf("%d\n",ans);
	return 0;
}

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

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

Measured memory_bytes: 3596