akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long i=0; i<n; i++)

void solve(){
    int n;
    cin >> n;
    vector<long long> a;
    rep(i,n+1){
        int tmp;
        cin >> tmp;
        a.emplace_back(tmp);
    }
    vector<long long> b;
    rep(i,n){
        int tmp;
        cin >> tmp;
        b.emplace_back(tmp);
    }
    /*
    配列xを用意し、x[n+1]=a[n+1]
    x[n] = a[n]-max(b[n]-x[n+1],0)
    count += min(a[n]+x[n+1], b[n])
    x[n-1] = max(x[n]+a[n-1]-b[n-1],0)
    ...
    x[1] = max(x[2]+x[1]-b[1], 0)
    count += min(a[1])+x[2], b[1])
    まで繰り返す。
    */
    long long zero = 0;
    long long x[n+10];
    rep(i,n+1){
        x[i] = zero;
    }
    x[n] = a[n];
    long long count = 0;

    for(int i=n-1; i>=0; i--){
        x[i] = max(a[i]-max(b[i]-x[i+1],zero),zero);
        count += min(a[i]+x[i+1], b[i]);
    }
    cout << count << endl;
}

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

Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

 ll h,n;
 cin>>n>>h;
 ll a[n];
 ll sum=0;
 for(ll i=0;i<n;i++)
 {
    cin>>a[i];
 }
 sort(a,a+n);
 for(ll i=0;i<n-h;i++)
 {
     sum+=a[i];
 }
 cout<<sum<<endl;

}


Measured memory_bytes: 1792
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        n: usize,
        s: chars
    }
    let mut res = 1;
    for i in 0..n-1 {
        if s[i] != s[i+1] {
            res+=1;
        }
    }
    println!("{}", res);
}
/* vim:set foldmethod=marker: */


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

int main() {
    int n, m;
    cin >> n >> m;
    dsu d(n);
    vector<pair<int, int>> a(m);
    rep(i, m) {
        cin >> a[i].first >> a[i].second;
    }
    rep(i, m) {
        d.merge(a[i].first - 1, a[i].second - 1);
    }
    vector<vector<int>> ch = d.groups();
    int ans = ch.size() - 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9060
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat 
using namespace std;
typedef long long LL;
typedef double ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const LL INF=1LL<<60;
const int SIZE=3*1e5;
const int BITSIZE=1<<20;
const int TIMES=40;
const LL p=7+1e9;
LL N,M,K,H,W,A,B;
string S;
LL fact[SIZE];
LL factrial(LL x){
	cat;
	if(x==0) return 1;
	if(fact[x]) return fact[x];
	return fact[x]=factrial(x-1)*x%p;
}
LL power(LL x,LL r){
	cat;
	if(r==0) return 1;
	if(r==1) return x;
	LL half=power(x,r/2);
	return half*half%p*power(x,r&1)%p;
}
LL gyaku(LL x){
	cat;
	return power(x,p-2);
}
LL nCr(LL n,LL r){
	cat;
	return factrial(n)%p*gyaku(factrial(r))%p*gyaku(factrial(n-r))%p;
}
int main(){
	cin >> H >> W >> A >> B;
	LL ans=0;
	REP(i,H-A){
		ans+=nCr(i+B-1,i)*nCr(H+W-i-B-2,H-i-1)%p;
		ans%=p;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
using namespace std;


typedef long long       ll;
struct edge { ll to; ll cost; };
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<ve>      vve;
typedef vector<vc>		vvc;

// マクロ
#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX 9223372036854775807
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}

// ***<ここから>****************************************************************

long long Pow(long long a, long long n) {
	long long x = 1;
	while (n > 0) {
		if (n & 1) x = x * a;
		a = a * a;
		n = n >> 1;
	}
	return x;
}

int main(void) {

	int D, G;
	cin >> D >> G;
	vi p(D), c(D);
	rep(i, D) cin >> p[i] >> c[i];

	int ans = 1e9;
	rep(i, Pow(2, D)) {
		ll score = 0;
		int num = 0;
		int last = -1;

		rep(j, D) {
			if (i >> j & 1) {
				score += (j + 1) * p[j] * 100 + c[j];
				num += p[j];
			}
			else {
				last = j;
			}
		}

		if (score < G) {
			int s1 = (last + 1) * 100;
			int need = (G - score + s1 - 1) / s1;
			if (need >= p[last]) continue;
			num += need;
		}
		ans = min(ans, num);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
N,M,X=map(int,input().split())
Ai=list(map(int,input().split()))

goto_0=0
goto_N=0

for i in range(X,0,-1):
    if i in Ai:
        goto_0 += 1

for i in range(X,N):
    if i in Ai:
        goto_N += 1

print(min(goto_0,goto_N))

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

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

int main() {
    ll x, current = 100;;
    cin >> x;
    ll ans = 0;
    while (current < x) {
        current += (current * 0.01);
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define pii pair<int,int>
#define mp make_pair
#define fir first
#define sec second
using namespace std;
queue<pii> q;
//map<int,bool> mp; 
int main()
{
	int x,wz,ti,i,tot;
	scanf("%d",&x);
	tot=0;
	for(i=1;;i++)
	{
		tot+=i;
		if(tot>=x)break;
	}
	printf("%d",i);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char  s[100100];
    int f,i;
    while(~scanf("%s",s))
    {
        f=0;
    int len =strlen(s);
    if(len==2)
    {
        if(s[0]==s[1])
            printf("1 2\n");
        else
            printf("-1 -1\n");
    }
    if(len>2)
    {
    for(i=2;i<len;i++)
    {
        if(s[i-2]==s[i-1]||s[i-2]==s[i]||s[i-1]==s[i])
        {
            f=1;
            break;
        }
    }
    if(f==1)
        printf("%d %d\n",i-1,i+1);
    else
        printf("-1 -1\n");
        memset(s,0,sizeof(0));
    }
    }
        return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int prime[100010];
int pre[100010];
void init_prime(){
	for(int i=2;i*2<=100010;++i){
		if(!prime[i])
			for(int j=2;j*i<=100010;++j){
				prime[i*j]=true;
			}
	}
}
bool is_liked(int x){
	if(prime[x] || prime[(x+1)/2])
		return false;
	return true;
}
void init(){
	init_prime();
	int now=0;
	for(int i=3;i<=100010;i+=2){
		if(is_liked(i))++now;
		pre[i]=pre[i+1]=now;
	}
}
int q,l,r;
int main(){
	init();
	scanf("%d",&q);
	while(q--){
		scanf("%d%d",&l,&r);
		printf("%d\n",pre[r]-pre[l-1]);
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <stdint.h>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main()
{
  uint32_t N;
  cin >> N;
  vector<uint64_t> A;
  A.reserve(N);
  
  for (int ii=0; ii<N; ++ii) {
    uint64_t a;
    cin >> a;
    A.push_back(a);
  }

  uint64_t count = 0;

  vector<uint64_t> fl(N,1);

  uint64_t l=0,r=0;
  uint64_t DPXOR, DPSUM;
  DPXOR = DPSUM = A[0];

  bool check_prev, check_now;
  
  while ( r < N ) {
    // cerr << l << ' ' << r << endl;;
    
    check_now = (DPXOR==DPSUM);

    // if (check_now)
    //   cerr << "OK" << endl;

    if (!check_now && check_prev)
      for (int ll = l; ll < r; ++ll)
	fl[ll] = r-ll;
    
    if (check_now) {
      ++r;
      DPXOR ^= A[r];
      DPSUM += A[r];
    } else {
      DPSUM -= A[l];
      DPXOR ^= A[l];
      ++l;
    }

    check_prev = check_now;
  }

  for (int ll = l; ll < r; ++ll)
    fl[ll] = r-ll;


  for (int l = 0; l<N; ++l) {
    uint64_t x = fl[l];
    cerr << l << ':' << x << endl;
    count += x;
  }

  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define BPhuong ""
#define maxn 505
#define maxm
#define fi(i,a,b) for(int i = a; i<= b; i++)
#define fid(i,a,b) for(int i = a; i>= b; i--)
#define se second
#define f first
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define bit(x, i) ((x>>i)&1)
#define oo 1e9
struct data{
    int x, y, z;
};
using namespace std;
int n, a[maxn], cl[maxn][maxn];
ll s[maxn], ans[maxn][maxn];
ll solve(int x, int y)
{
    if(x == y)
    {
        return 0;
    }
    if(cl[x][y]) return ans[x][y];
    cl[x][y] = 1;
    ans[x][y] = 1e18;
    fi(i, x, y-1)
    {
        ans[x][y] = min(ans[x][y], solve(x, i) + solve(i+1, y) + s[y] - s[x-1]);
    }
    return ans[x][y];
}
void nhap(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    //freopen(BPhuong".inp","r",stdin);
    //freopen(BPhuong".out","w",stdout);
    cin >> n;
    fi(i, 1, n)
    {
        cin >> a[i];
        s[i] = s[i-1] + a[i];
    }
}

void xuli(){
    cout << solve(1, n);
}

int main(){
    nhap();
    xuli();
}


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

#define task "C"
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define pb push_back
#define F first
#define S second

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;

// Variables
int n,a[100004];
ll res;
//
// Function

//

int main()
{
	//freopen(task".in","r",stdin);
	//freopen(task".out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	cin >> n;
	rep(i,1,n+1) cin >> a[i];
	rep(i,1,n)
	{
	    int x;
        cin >> x;
        if (x>=a[i])
        {
            x-=a[i];
            res+=a[i];
            a[i]=0;
        } else
        {
            res+=x;
            a[i]-=x;
            x=0;
        }
        if (x>=a[i+1])
        {
            x-=a[i+1];
            res+=a[i+1];
            a[i+1]=0;
        } else
        {
            res+=x;
            a[i+1]-=x;
        }
	}

	cout << res;
}


Measured memory_bytes: 640
#!/usr/bin/ruby
h={[1,2]=>6,[1,3]=>10,[1,4]=>12,[1,5]=>14,[1,6]=>27,[1,7]=>33,[2,3]=>7,[2,4]=>9,[2,5]=>12,[2,6]=>23,[2,7]=>30,[3,4]=>5,[3,5]=>8,[3,6]=>20,[3,7]=>27,[4,5]=>5,[4,6]=>17,[4,7]=>26,[5,6]=>12,[5,7]=>23,[6,7]=>10}
while(a=gets.to_i)>0
	x,y=gets.split.map(&:to_i)
	y+=x*60
	b=gets.to_i
	x,z=gets.split.map(&:to_i)
	z+=x*60
	c=h[[a,b]]
	c/=2.0 if c<27&&((1050<=y&&y<=1170)||(1050<=z&&z<=1170))
	p c.ceil*50
end

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

int main (){
  int W, H, x, y, r;
  scanf ("%d %d %d %d %d", &W, &H, &x, &y, &r);
  if (W*x < 0 || H*y < 0){
    printf("No\n");
  } else if (abs(x) >= r &&  abs(W)-abs(x) >= r && abs(y) >= r && abs(H)-abs(y) >= r){
    printf ("Yes\n");
  } else  {
    printf ("No\n");
  }
  return 0;
}

Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n; cin>>n;
  string s; cin>>s;
  int res=1;
  for(int i=0; i<n-1; ++i) if(s[i]!=s[i+1]) ++res;
  cout<<res;
  return 0;
}

Measured memory_bytes: 3696
#include "bits/stdc++.h"
//#define int long long
#define range(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14

signed main(){
	int n, m;
	cin >> n >> m;

	vi v(n), w(n);
	rep(i, n)cin >> v[i] >> w[i];

	vi dp(m + 1, -1);
	dp[0] = 0;

	rep(i, n){
		rep(j, m + 1){
			if(dp[j] >= 0 && j + w[i] <= m)
				dp[j + w[i]] = max(dp[j] + v[i], dp[j + w[i]]);
			}
	}

	auto itr = max_element(all(dp));
	cout << *itr << endl;
}

Measured memory_bytes: 3120
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map> 
#include<iostream>
#include<time.h>
using namespace std;
typedef long long ll;
const double pi=acos(-1.0);
const ll mod=1e9+7;
const int inf=0x3f3f3f3f;
//ll begin_time=clock();
//ll end_time=clock();printf("time=%lldms\n",end_time-begin_time);

int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c;
	if(c>=b)c=b-1;
	cout<<floor(a*c/b)-a*floor(c/b)<<endl;
}




Measured memory_bytes: 3784
#include <stdio.h>

#define REP(i,a,n) for(i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define DEB 0

const int dx[] = {0,1,0,-1}; // up,right,down,left
const int dy[] = {-1,0,1,0};

int w,h;
int field[20][20];
int ans,sx,sy,gx,gy;

void dfs(int x, int y, int cnt){
  int tx,ty,i,j,k;
  int *p;
  if( cnt>=ans ) return;
  
#if DEB
  printf("(%d,%d)  cnt:%d\n",x,y,cnt);
  rep(i,h){
    rep(j,w){
      printf("%d ",field[i][j]);
    }
    puts("");
  }
#endif

  // goal only search
  int dir = -1;
  if( x==gx || y==gy ){
    if( x==gx ){
      if( y<gy ){
	// down = 2
	dir = 2;
      }else{
	// up = 0
	dir = 0;
      }
    }else{
      if( x<gx ){
	// right = 1
	dir = 1;
      }else{
	// left = 3
	dir = 3;
      }
    }
  }
  if( dir!=-1 ){
    // goal only search
    for(j=1; ;j++){
      tx = x + dx[dir]*j;
      ty = y + dy[dir]*j;
      if( tx<0 || ty<0 || tx>=w || ty>=h || field[ty][tx]==1 )break;
      if( field[ty][tx]==3 ){
	ans = cnt+1;
	return;
      }
    }
  }

  // other search
  rep(k,4){
    for(j=1;;j++){
      tx = x + dx[k]*j;
      ty = y + dy[k]*j;
      if( tx<0 || ty<0 || tx>=w || ty>=h || (j==1&&field[ty][tx]==1) ) break;
      p = &field[ty][tx];
      if( *p==1 ){
	*p = 0;
	dfs(tx-dx[k], ty-dy[k], cnt+1);
	*p = 1;
	break;
      }
    }
  }
}

int main(){
  int i,j;
  while(scanf("%d%d",&w,&h),w|h){
    ans = 11;
    rep(i,h){
      rep(j,w){
	scanf("%d",&field[i][j]);
	if( field[i][j]==2 ){
	  sx=j; sy=i;
	}else if( field[i][j]==3 ){
	  gx=j; gy=i;
	}
      }
    }
    dfs(sx,sy,0);
    printf("%d\n",ans==11?-1:ans);
  }
  return 0;
}

Measured memory_bytes: 416
package main

import (
	"fmt"
	"io"
	"os"
)


// n factorial (mod M)
// return: array of factorial of 0-n
func mfactorial(n, M uint64) []uint64 {
	fact := make([]uint64, n+1)
	fact[0] = 1
	for i := uint64(1); i <= n; i++ {
		fact[i] = (fact[i-1] * i) % M
	}
	return fact
}

// x^n (mod M)
// See https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
func mpow(x, n, M uint64) uint64 {
	ans := uint64(1)
	for n != 0 {
		if n&1 == 1 {
			ans = ans * x % M
		}
		x = x * x % M
		n = n >> 1
	}
	return ans
}

// nCk (mod M)
// @see https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
func combi(n, k, M uint64) uint64 {
	if n == 0 && k == 0 {
		return 1
	} else if n < k || n < 0 {
		return 0
	}
	fact := mfactorial(n, M)

	ans := fact[n] * mpow(fact[k], M-2, M) % M
	ans *= mpow(fact[n-k], M-2, M) % M

	return ans % M
}

func answer(reader io.Reader, writer io.Writer) {
	var n,m,k uint64
	_, _ = fmt.Fscan(reader, &n, &m, &k)

	mod := uint64(1000000007)
	var sumX, sumY uint64
	c := uint64(1)
	if k > 2 {
		//c = combination(n*m-2, k-2, mod)
		c = combi(n*m-2, k-2, mod)
		c %= mod
	}
	for i := uint64(1); i < n; i++ {
		sumX += i * (n - i)
		sumX %= mod
	}
	sumX = sumX * m * m
	sumX %= mod
	for i := uint64(1); i < m; i++ {
		sumY += i * (m - i)
		sumY %= mod
	}
	sumY = sumY * n * n
	sumY %= mod
	sum := (sumX + sumY) * c
	sum %= mod
	_, _ = fmt.Fprintf(writer, "%d", sum)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


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

int main()
{
    //データ定義
    int w_data;
    int data_cnt;
    int max_data = -1000001;
    int min_data = 1000001;
    long long total_data = 0;

    //データの数を取得
    cin >> data_cnt;
       
    //
    for(int i = 0; i < data_cnt; i++){
        //データ読み込み
        cin >> w_data;
        //最小値更新
        if(w_data < min_data){
            min_data = w_data;
        }
        //最大値更新
        if (w_data > max_data)
        {
            max_data = w_data;
        }
        //合計値更新
        total_data += w_data;
    }

    //結果出力
    cout << min_data << " " << max_data << " " << total_data << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    long double a, b, h, m;
    cin >> a >> b >> h >> m;

//    long double hs = 360.0 * h / 12.0 + 30.0 * m / 60.0;
//    long double ms = 360.0 * m / 60.0;
    long double hs = 360.0 * h * 5.0 + 30.0 * m;
    long double ms = 360.0 * m;

    long double t;
    if (hs >= ms) {
        t = hs - ms;
    } else {
        t = ms - hs;
    }

//    if ((int)t > 180) {
//        t = 360.0 - t;
//    }

    long double ans;
    if ((int)t == 0) {
        ans = abs(a - b);
    } else if ((int)t == 180) {
        ans = a + b;
    } else {
        //余弦定理
        long double res = a * a + b * b - 2.0 * a * b * cos(t * M_PI / (180.0 * 60.0));
        ans = sqrt(res);
    }

    cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 4156
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

struct Unionfind {
  vector<int> d;

  Unionfind(int n) : d(n,-1) {}

  int root(int x) {
    if(d[x] < 0) return x;
    return d[x] = root(d[x]);
  }

  bool unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if(rx==ry) return false;
    if(d[rx] < d[ry]) swap(rx,ry);
    d[rx] += d[ry];
    d[ry] = rx;
    return true;
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  int size(int x) {
    return -d[root(x)];
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  vi p(n);
  rep(i,n) {
    cin >> p[i];
    p[i]--;
  }
  Unionfind tree(n);
  rep(i,m) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    tree.unite(x,y);
  }
  int ans = 0;
  rep(i,n) if(tree.same(i,p[i])) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4036
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
  string s;
  string t="";
  cin>>s;
  int n=s.length();
  t+=s[0];
  t+=to_string(n-2);
  t+=s[n-1];
  cout<<t<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vll = vector<ll>;
using vvll = vector<vll>;

int main()
{
  int H, W,inf=100000000,ans=0;
  cin>>H>>W;
  vvc field(H, vc(W));
  vvi d(H, vi(W, inf));
  queue<PAIR> que;
  rep(i,H)
  {
    rep(j,W)
    {
      cin >> field[i][j];
      if (field[i][j]=='#')
      {
        que.push(PAIR(i, j));
        d[i][j] = 0;
      }
    }
  }

  while(que.size())
  {
    int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
    PAIR p = que.front();
    que.pop();

    rep(i, 4)
    {
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if(0<=nx&&nx<H&&0<=ny&&ny<W&&field[nx][ny]=='.'&&d[nx][ny]==inf)
        {
          d[nx][ny] = d[p.first][p.second] + 1;
          que.push(PAIR(nx, ny));
          ans = max(ans, d[nx][ny]);
        }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 16108
using System;

namespace AOJ.Volume0
{
    public class RailwayLines
    {
        public static void Main()
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                var data = input.Split(',');
                var dist = new int[10];
                int sum_dist = 0;
                int v1, v2;
                for (int i = 0; i < 10; i++)
                {
                    dist[i] = int.Parse(data[i]);
                    sum_dist += dist[i];
                }
                v1 = int.Parse(data[10]);
                v2 = int.Parse(data[11]);

                // ある時間tに電車がすれ違う→電車1と電車2の走った距離の合計が
                // 駅間の距離合計になる
                // (v1 * t) + (v2 * t) = sum_dist
                // t = sum_dist / (v1 + v2)

                // 電車1についてどこの駅間にいるのか判定
                int tmp = 0;
                decimal dist_1 = v1 * sum_dist / (v1 + v2);
                for (int i = 0; i < 10; i++)
                {
                    tmp += dist[i];
                    if (tmp >= dist_1)
                    {
                        Console.WriteLine(i + 1);
                        break;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 9080
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
	int W,H,x,y,r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if ((x - r) >= 0 && (y - r) >= 0 && (x + r) <= W && (y + r) <= H) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}




	return 0;
}

Measured memory_bytes: 1012
import sys
sys.setrecursionlimit(1000000)


def power6(n, memo, s):
    memo[n] = min(memo[n], memo[n - s] + 1)
    if n - s * 6 < 0:
        return memo
    return power6(n, memo, s * 6)


def power9(n, memo, s):
    memo[n] = min(memo[n], memo[n - s] + 1)
    if n - s * 9 < 0:
        return memo
    return power9(n, memo, s * 9)


def search(n, memo, s):
    memo = power6(s, memo, 1)
    memo = power9(s, memo, 1)
    if s + 1 == n + 1:
        return memo
    return search(n, memo, s + 1)


n = int(input())
max_n = 110000
dp = [n] * max_n

# 初期化
dp[0] = 0
memo = search(n, dp, 0)
print(memo[n])


Measured memory_bytes: 89696
//#include<bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <list>
#include <climits>
#include <bitset>

/*
Not easy to be successful,Dont give up
*/

using namespace std;
#define all(v)          ((v).begin()), ((v).end())
#define pb push_back
#define Compiler_Beso ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define clr(v,d)        memset(v, d, sizeof(v))
#define endl '\n'
const double EPS = 1e-12;
typedef long long ll;
const double PI = 3.14159265359;
enum dir       { DOWN = 0, UP, RIGHT, LEFT, DOWN_RIGHT, DOWN_LEFT, UP_RIGHT, UP_LEFT };
int  dir_r[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int  dir_c[] = { 0, 0, 1, -1, 1, -1, 1, -1 };

int main()
{
	Compiler_Beso


		int a, b;
	cin >>  a >> b;
	cout << max(a*b, max(a - b, a + b));
	return 0;
}

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

using namespace std;

typedef long long ll;

ll N, K, L, R;
ll a[40];

decltype(auto) enumerate(int sidx, int size) {
  vector<pair<ll, ll>> ret;
  for(int i=0; i<1<<size; i++) {
    int cnt = 0; ll sum = 0;
    for(int j=0; j<size; j++)
      if(i >> j & 1) cnt++, sum += a[sidx + j];
    ret.emplace_back(cnt, sum);
  }
  return ret;
}

ll solve() {
  decltype(auto) v0 = enumerate(0, N / 2);
  decltype(auto) v1 = enumerate(N / 2, (N + 1) / 2);
  sort(v0.begin(), v0.end());
  ll ret = 0;
  for(int i=0; i<(int)v1.size(); i++)
    ret +=  upper_bound(v0.begin(), v0.end(), make_pair(K - v1[i].first, R - v1[i].second))
          - lower_bound(v0.begin(), v0.end(), make_pair(K - v1[i].first, L - v1[i].second));
  return ret;
}

int main() {
  cin >> N >> K >> L >> R;
  for(int i=0; i<N; i++) cin >> a[i];
  cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 43736
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
    BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
    String str=buf.readLine();
    String[] j=str.split(" ");
    
     int w=Integer.parseInt(j[0]);
     int h=Integer.parseInt(j[1]);
     int x=Integer.parseInt(j[2]);
     int y=Integer.parseInt(j[3]);
     int r=Integer.parseInt(j[4]);
     
     if(0<=(x-r) && (x+r)<=w && 0<=(y-r) && (y+r)<=h)
         System.out.println("Yes");
     else
         System.out.println("No");
    }
    
}

Measured memory_bytes: 24320
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

ll CONS = 1e9 + 7;

using namespace std;

//69D

int main(void) {
	ll h, w,n;
	cin >> h >> w >> n;
	vector<vector<ll>> tile = vector<vector<ll>>(h,vector<ll>(w,-1));
	vector<ll> color = vector<ll>(n);
	rep(i, 0, n) cin >> color[i];
	ll hIndex = 0;
	ll wIndex = 0;
	ll direction = 0; // 0 left, 1 down, 2 right, 3 up
	rep(i, 0, n) {
		while (color[i] > 0) {
			tile[hIndex][wIndex] = i+1;
			color[i]--;
			switch(direction) {
			case 0: //left
				if (wIndex == w - 1 || tile[hIndex][wIndex + 1] != -1) {
					direction = 1;
					hIndex++;
				}
				else {
					wIndex++;
				}
				break;
			case 1: //down
				if (hIndex == h - 1 || tile[hIndex + 1][wIndex] != -1) {
					direction = 2;
					wIndex--;
				}
				else {
					hIndex++;
				}
				break;
			case 2: //right
				if (wIndex == 0 || tile[hIndex][wIndex - 1] != -1) {
					direction = 3;
					hIndex--;
				}
				else {
					wIndex--;
				}
				break;
			case 3:
				if (hIndex == 0 || tile[hIndex - 1][wIndex] != -1) {
					direction = 0;
					wIndex++;
				}
				else {
					hIndex--;
				}
				break;
			}
			
		}
	}
	rep(i, 0, h) {
		rep(j, 0, w) {
			if (j == w - 1) cout << tile[i][j] << endl;
			else cout << tile[i][j] << " ";
		}
	}
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
using namespace std;

int main(void){
    string str;
    long long int k;
    cin >> str >> k;
    string temp;
    for(int i=0; i<k; i++){
        temp = str[i];
        if(temp!="1"){
            cout << temp << endl;
            return 0;
        }
    }
    cout << "1" << endl;
    return 0;
}

Measured memory_bytes: 256
//標準関数をすべてインクルードする。
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

const int_least64_t INF = 10000000;

int main(){
    //cin coutを高速化
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

    int a, b, c =0;
    cin >> a >> b >> c;

    swap(a, b);
    swap(a, c);


    cout << a << ' ' << b << ' ' << c << endl;

    return 0;
}



Measured memory_bytes: 256
/*
            _ _  ___            __ _ _  _       _     
 _   _  ___| | |/ _ \__      __/ _| | || |  ___| |__  
| | | |/ _ \ | | | | \ \ /\ / / |_| | || |_/ __| '_ \ 
| |_| |  __/ | | |_| |\ V  V /|  _| |__   _\__ \ | | |
 \__, |\___|_|_|\___/  \_/\_/ |_| |_|  |_| |___/_| |_|
 |___/                 

 */

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 300005


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

	int ans;
	if(n>99999){
		ans=90909;
	}else if(n>9999){
		ans=909 + (n-9999);
	}else if(n>999){
		ans=909;
	}else if(n>99){
		ans=9 + (n-99);
	}else if(n>9){
		ans=9;
	}else{
		ans= n;
	}

	cout<<ans<<endl;

    return 0;
}
    



Measured memory_bytes: 256
n,yy = map(int,input().split())
ans=-1,-1,-1

for x in range(n+1):
  for y in range(n+1-x):
    z=n-x-y
    if x*10000+y*5000+z*1000 == yy:
      ans=x,y,z
      break
    else:
      continue
print(*ans)

Measured memory_bytes: 66140
#include<stdio.h>
int main(void)
{
	char s[4];
	int n=0;
	int m=0;
	scanf("%s",s);
	
	for(int i=0; i<3; i++){
		if(s[i]=='A')
		n++;
		if(s[i]=='B')
		m++;
	}
	
	if(m==1&&n==2)
	puts("Yes");
	
	else if(m==2&&n==1)
	puts("Yes");
	
	else
	puts("No");
	

	return 0;
}

Measured memory_bytes: 1644
import java.util.Scanner;
import java.util.Formatter;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Formatter fm = new Formatter();
        String str1 = sc.nextLine();
        String str2 = "";
        for(int i=0;i<str1.length();i++){
            char c = str1.charAt(i);
            char d;
            if(Character.isLowerCase(c)){
                d = Character.toUpperCase(c);
            }else{
                d = Character.toLowerCase(c);
            }
            fm.format(str2 + "%c", d);
        }
        System.out.println(fm);
    }
}


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

namespace D2019PC2B
{
    class Program
    {
        struct point
        {
            public int x;
            public int y;
        }
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            if (N > 1)
            {
                point ball = new point();
                List<point> space = new List<point>();
                point vector = new point();

                for (int i = 0; i < N; i++)
                {
                    string[] input = Console.ReadLine().Split();
                    ball.x = int.Parse(input[0]);
                    ball.y = int.Parse(input[1]);
                    space.Add(ball);
                }
                Dictionary<point, int> dict = new Dictionary<point, int>();
                for (int i = 0; i < N; i++)
                {
                    for (int j = i + 1; j < N; j++)
                    {
                        vector.x = space[j].x - space[i].x;
                        vector.y = space[j].y - space[i].y;
                        if (dict.ContainsKey(vector))
                        {
                            dict[vector]++;
                        }
                        else
                        {
                            dict.Add(vector, 1);
                        }
                    }
                }

                Dictionary<point, int> dict2 = new Dictionary<point, int>();
                foreach (var item in dict)
                {
                    dict2.Add(item.Key, item.Value);
                    point r_P = new point();
                    r_P.x=-item.Key.x;
                    r_P.y=-item.Key.y;
                    if (dict.ContainsKey(r_P))
                    {
                        dict2[item.Key] += dict[r_P];
                    }
                }
                /*
                foreach (var item in dict2)
                {
                    Console.WriteLine(item.Key.x + " " + item.Key.y + ":" + " " + item.Value);
                }
                */
                Console.WriteLine(N - dict2.Values.Max());
            }
            else
            {
                Console.WriteLine(1);
            }
        }
    }
}
/*
point vecter_Reverse = new point();
point vecter_Reverse_Make = new point();

vecter_Reverse = dict.First(x => x.Value == dict.Values.Max()).Key;
vecter_Reverse_Make.x=-vecter_Reverse.x;
vecter_Reverse_Make.y=-vecter_Reverse.y;
int ans_R;
if (dict.ContainsKey(vecter_Reverse_Make))
{
    ans_R = dict[vecter_Reverse_Make];
}
else
{
    ans_R = 0;
}
Console.WriteLine(N - dict.Values.Max()-ans_R);
*/


Measured memory_bytes: 13396
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){

int n;
int a[200000][3];
int dp[200000][3];

cin >> n;

for(int i = 0; i < n; i++) for(int j = 0; j < 3; j++) cin >> a[i][j];

for(int i = 0; i < n; i++){
    if(i == 0) for(int j = 0; j < 3; j++) dp[i][j] = a[i][j];
    else{
        int an[2];
        int bn[2];
        int cn[2];
        
        for(int j = 0; j < 2; j++) an[j] = dp[i - 1][j + 1] + a[i][0];
        for(int j = 0; j < 2; j++) bn[j] = dp[i - 1][2 * j] + a[i][1];
        for(int j = 0; j < 2; j++) cn[j] = dp[i - 1][j] + a[i][2];
        
        sort(an, an + 2);
        sort(bn, bn + 2);
        sort(cn, cn + 2);
        
        dp[i][0] = an[1];
        dp[i][1] = bn[1];
        dp[i][2] = cn[1];
        
        }
    }
int ans[3];    
for(int i = 0; i < 3; i++){
    ans[i] = dp[n - 1][i];
    }
sort(ans, ans + 3);

cout << ans[2] << "\n";
}        

Measured memory_bytes: 4480
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ll X;
	cin >> X;

	auto ans = 0ll;
	auto num = 100ll;
	while (num < X)
	{
		++ans;
		num = (ll)(num * 1.01);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
AB=[LIST() for i in range(N)]

AB.sort()
print(AB[-1][0]+AB[-1][1])


Measured memory_bytes: 27888
#include <iostream>
#include<vector>
#include<algorithm>
#define r(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;





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

  vector<int> a[100001];
  int p[100000],y[100000];
  r(i,m){
    cin>>p[i]>>y[i];
    a[p[i]].push_back(y[i]);
  }

  r(i,n){
    sort(a[i+1].begin(),a[i+1].end());
  }

  r(i ,m){
    printf("%012lld\n",ll(p[i])*1000000+int(lower_bound(a[p[i]].begin(),a[p[i]].end(),y[i])
    -a[p[i]].begin())+1);
  }


  return 0;
}


Measured memory_bytes: 7808
import java.util.Scanner;

class Main {

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

        int n = stdIn.nextInt();
        int[] num = new int[n];
        
        for (int i = 0; i < n; i++) {
            num[i] = stdIn.nextInt();  
        }

        int min = num[0];
        int max = num[0];

        for (int j = 0; j < n; j++) {
            if (max < num[j]) {
                max = num[j];
            }
        }
        for (int k = 0; k < n; k++) {
            if (min > num[k]) {
                min = num[k];
            }
        }
        System.out.println(max - min);
    }
}


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

#define ll long long int
#define absdiff(a,b) (a>b)?a-b:b-a
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"
const ll ll_MAX = 19223372036859;
const ll MOD = 1000000007;
ll fast_expo(ll x,ll p){if(p==0) return 1;
    else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} 
    else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
ll gcd(ll a,ll b){if(a==0||b==0) return a+b;  
    else return gcd(b%a,a); }

ll arr[3001];
ll dp[3001][3001];
ll n;

ll solve(ll i,ll j)
{
    if(i == j && n%2 == 1) return arr[i];
    else return -arr[i];
    if(dp[i][j] != ll_MAX) return dp[i][j];

    ll turn = (n-j+i)%2;
    if(turn == 1) return dp[i][j] = max(solve(i+1,j)+arr[i],solve(i,j-1)+arr[j]);
    else return dp[i][j] = min(solve(i+1,j)-arr[i],solve(i,j+1)-arr[j]);

}

int main()
{
    ll t_c; t_c = 1;
    // cin >> t_c;
    for(ll t_i=0; t_i<t_c; ++t_i){
        ll n,k; cin >> n >> k;
        ll dp[n+1][k+1];
        ll pre[n+1][k+1];
        memset(dp,0,sizeof(dp));
        memset(pre,0,sizeof(pre));

        ll arr[n+1];
        for(ll i=1; i<=n; ++i)
            cin >> arr[i];

        dp[0][0] = pre[0][0] = 1;
        for(ll i=1; i<=k; ++i) pre[0][i] = 1;

        for(ll i=1; i<=n; ++i){
            dp[i][0] = pre[i][0] = 1;
            for(ll j=1; j<=k; ++j){
                dp[i][j] = (pre[i-1][j]-pre[i-1][max(0ll,j-arr[i]-1)]+MOD)%MOD;
                if(j-arr[i] <= 0) dp[i][j] = (dp[i][j]+1)%MOD;
                pre[i][j] = (pre[i][j-1]+dp[i][j])%MOD;
            }
        }
        cout << dp[n][k];
    }   
    return 0;
}

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

using namespace std;

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

    map<string, int> dupa;
    int mx = 0;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        dupa[s]++;
        mx = max(mx, dupa[s]);
    }

    set<string> ans;
    for (auto it : dupa) {
        if (it.second == mx) {
            ans.insert(it.first);
        }
    }

    for (string s : ans) {
        cout << s << "\n";
    }

    return 0;
}


Measured memory_bytes: 33280
arrays = []

r, c = gets.split.map(&:to_i)

r.times do
  arr = gets.split.map(&:to_i)
  puts arr.push(arr.inject(:+))*" "
  arrays.push(arr)
end

sumarr = []

c.times do |i|
  tmp = 0
  r.times do |j|
    tmp += arrays[j][i]
  end
  sumarr.push(tmp)
end

puts sumarr.push(sumarr.inject(:+))*" "



Measured memory_bytes: 7028
import math
EPS = 10**-8


class P2():
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.norm2 = (self.x**2 + self.y**2)**0.5

    def __add__(self, other):
        return P2(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return P2(self.x - other.x, self.y - other.y)

    def smul(self, a):
        return P2(self.x * a, self.y * a)

    def dot(self, other):
        return self.x * other.x + self.y * other.y

    def det(self, other):
        return self.x * other.y - self.y * other.x


n = int(input())
p = [P2(*map(int, input().split())) for _ in range(n)]

dist = [[(p[i] - p[j]).norm2 for j in range(n)] for i in range(n)]


def check(r):
    # 最小包含円の半径がr以下であるか

    # 半径rの円２つの交点の列挙
    cand = []
    for i in range(n - 1):
        for j in range(i + 1, n):
            c_ij = (p[i] + p[j]).smul(0.5)
            d_ij = p[i] - p[j]
            # cand.append(c_ij)

            if dist[i][j] < r * 2:
                # 点iと点jを中心とする半径rの円は交点を持つ時
                h = (r**2 - (dist[i][j] / 2)**2)**0.5
                v = P2(-d_ij.y, d_ij.x).smul(h / d_ij.norm2)
                cand.append(c_ij + v)
                cand.append(c_ij - v)
            else:
                return False

    for cand_p in cand:
        is_in = True
        for i in range(n):
            if (p[i] - cand_p).norm2 > r + EPS:
                is_in = False
                break
        if is_in:
            # print(r, cand_p.x, cand_p.y)
            return True
    return False
    # return any(all((pi - ci).norm2 <= r + EPS for pi in p) for ci in cand)


lb = 0.0  # False
ub = 2000  # True
while ub - lb > EPS:
    mid = (ub + lb) / 2
    if check(mid):
        ub = mid
    else:
        lb = mid

print(ub)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
//union by size + path having
class UnionFind{
	public:
	vector<long long> par; // 各元の親を表す配列
	vector<long long> siz; // 素集合のサイズを表す配列(1 で初期化)


	// Constructor
	UnionFind(long long sz_) : par(sz_), siz(sz_,1LL){
		for (long long i = 0; i < sz_; ++i)
		par[i] = i; // 初期では親は自分自身
	}
	void init(long long sz_){
		par.resize(sz_);
		siz.assign(sz_,1LL); // resize だとなぜか初期化されなかった
		for (long long i = 0; i < sz_; ++i)
			par[i] = i; // 初期では親は自分自身
	}
	// Member Function


	// Find
	long long root(long long x){ // 根の検索
		while (par[x] != x){
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}
	// 結合(Unite, Merge)
	bool merge(long long x, long long y){
		x = root(x);
		y = root(y);
		if (x == y){
			return false;
		}
		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]){
			swap(x, y);
		}
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}


	// 連結判定(つながっているときはture,つながっていなければfalse)
	bool issame(long long x, long long y){ 
		return root(x) == root(y);
	}


	// 素集合のサイズ
	long long size(long long x){ 
		return siz[root(x)];
	}
};
int main(){
	int n,q;
	int ans=0;
	cin >>n>>q;
	int id,x,y;
	UnionFind str(n);
	rep(i,q){
		cin>>id>>x>>y;
	
		if(id==0){
			str.merge(x,y);
		}else{
			cout<<(int)str.issame(x,y)<<endl;
		}

	}
//	cout<<ans<<endl;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int ans = 0;
    ans += min(a, k);
    k = max(k - a - b, 0);
    ans -= k;
    cout << ans << '\n';
}


Measured memory_bytes: 3608
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


int main(){
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int64 n, m;
    vector<int64> q;
    cin >> n >> m;
    q.resize(n);
    rep(i, n) cin >> q[i];
    make_heap(all(q));

    rep(mi, m) {
        pop_heap(all(q));
        q.back() /= 2LL;
        push_heap(all(q));
    }

    cout << accumulate(all(q), 0LL) << '\n';

    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <map>
#define int long long

using namespace std;

const int mod=1000000007;

char str[12][100];

signed main(){
    int n;
    scanf("%lld",&n);
    for(int i=0;i<2;i++){
        scanf("%s",str[i]);
    }
    bool flag=false;
    int f=0;
    int t=1;
    for(int i=0;i<n;i++){
        if(str[0][i]==str[0][i+1]){
            if(f==0){
                t*=3;
                t*=2;
                f=1;
            } else {
                if(flag){
                    t*=2;
                    t*=1;
                } else {
                    t*=3;
                }
            }
            flag=false;
            i++;
        } else {
            if(str[0][i]==str[1][i]){
                if(f==0){
                    t*=3;
                    f=1;
                } else {
                    if(flag) t*=2;
                    else t*=1;
                }
                flag=true;
            }
        }
        t%=mod;
    }
    cout<<t<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fo(x, y) for (int i = x; i < y; i++)
using namespace std;

void solve()
{
	int a,b;
	cin>>a>>b;

	int c=a*b;
	cout<<c;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	/*int x;
	cin>>x;
	while(x--){
		solve();
		cout<<"\n";
	}

    /*if(solve(x))
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}*/
}

Measured memory_bytes: 3644