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

using namespace std;

const int N = 1024;

int ans[N][N];

int main() {
  int n, m, a, b;
  scanf("%d %d %d %d", &n, &m, &a, &b);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < a; ++j) {
      ans[i][j] ^= 1;
    }
  }
  for (int i = 0; i < b; ++i) {
    for (int j = 0; j < m; ++j) {
      ans[i][j] ^= 1;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      printf("%d", ans[i][j]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
struct Edge {
    long long from;
    long long to;
    long long cost;
};
struct edge {
    long long to;
    long long cost;
};
typedef vector<vector<edge> > graph;
typedef pair<long long, long long> P;
const long long INF = 1e18;
void dijkstra(graph& G, long long start, vector<long long>& dis) {
    long long N = G.size();
    dis.resize(N, INF);
    priority_queue<P, vector<P>, greater<P> >Q;
    dis.at(start) = 0;
    Q.push(make_pair(dis.at(start), start));
    while (!Q.empty()) {
        P v = Q.top(); Q.pop();
        if (dis.at(v.second) < v.first) continue;
        for (long long i = 0; i < G[v.second].size(); i++) {
            edge next_v = G.at(v.second).at(i);
            if (dis.at(next_v.to) > dis.at(v.second) + next_v.cost) {
                dis.at(next_v.to) = dis.at(v.second) + next_v.cost;
                Q.push(make_pair(dis.at(next_v.to), next_v.to));
            }
        }
    }
    for (long long i = 0; i < dis.size(); i++) {
        if (dis.at(i) != INF) cout << dis.at(i) << endl;
        else cout << "INF" << endl;
    }
}
int main() {
    long long V, E; cin >> V >> E;
    long long start;
    cin >> start;
    graph G(V);
    vector<long long>D(V, INF);
    D.at(start) = 0;
    for (long long i = 0; i < E; i++) {
        Edge A;
        cin >> A.from >> A.to >> A.cost;
        edge B = { A.to, A.cost };
        G.at(A.from).push_back(B);
    }
    dijkstra(G, start, D);
}


Measured memory_bytes: 19444
# -*- coding:utf-8 -*-
from math import factorial
import bisect


def solve():
    N = int(input())
    As = list(map(int, input().split()))

    # ai > aj
    # C(ai, aj) とするとき、aiは大きければ大きいほどよいので、Asの最大値でよい
    # 問題はajをどう決めるか。
    """
    C(n,r) を毎回計算するのは計算が重い。なので計算させずに済む方法を考える。
    C(n,r) = n! / r!(n-r)! である。今、nはAsの最大値と決まっているので、定数とみなして良い。
    よって、C(n,r)が大きいとは、分子の r!(n-r)!ができるだけ小さいものである。
    r!(n-r)!を全探索で計算するのも処理が重いのでしたくない。
    ところで、n=10のとき、r!(n-r)!を、r = 1 ~ 10まで手書きで書いてみるとわかるが、

    1) 1* 9*8*7*6*5*4*3*2*1
    2) 1*2* 8*7*6*5*4*3*2*1
    3) 1*2*3* 7*6*5*4*3*2*1
    4) 1*2*3*4* 6*5*4*3*2*1
    5) 1*2*3*4*5* 5*4*3*2*1  <-これが一番小さい
    6) 1*2*3*4*5*6* 4*3*2*1  <-これは4)と同じ

    r = n//2のときが一番小さくなるっぽいことがわかる。

    そのようなrを、Asの中から探せば良い。これは二分探索で高速に探せる。
    """

    As.sort()
    n = As[-1]
    i = bisect.bisect_left(As[:-1], n//2)
    if i == 0:
        r = As[0]
    elif i == N-1:
        r = As[N-2]
    else:
        if abs(As[i-1] - n//2) < abs(As[i] - n//2):
            r = As[i-1]
        else:
            r = As[i]

    print(n, r)


if __name__ == "__main__":
    solve()


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

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

  ll A; cin >> A;
  ll B; cin >> B;
  ll C; cin >> C;
  ll X; cin >> X;
  ll Y; cin >> Y;


  ll ans = 1e15;
  for (int i = 0; i <= max(X * 2,Y * 2); i++) {
    ll temp = C * i;
    ll a = max(X - i / 2, 0ll) * A;
    ll b = max(Y - i / 2, 0ll) * B;
    ans = min(ans, temp + a + b);
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x,y;
  cin>>x>>y;
  if(abs(x-y)<=1) cout<<"Brown"<<endl;
  else cout<<"Alice"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

int main() {
  int k; cin >> k;

  if (k%2 == 0 || k%5 == 0) {
    cout << -1 << endl;
    return 0;
  }

  int n = 7;
  int i = 1;
  while (n % k != 0) {
    n = (n*10+7) % k;
    i++;
  }

  cout << i << endl;
}


Measured memory_bytes: 3624
#include <iostream>                                                                   
                                                                                      
using namespace std;                                                                  
                                                                                      
int circumference(int,int);                                                           
int area(int,int);                                                                    
                                                                                      
int main (void) {                                                                     
  int a,b;                                                                            
  cin >> a >> b;                                                                      
  cout << area(a,b) << ' ' << circumference(a,b) << endl;                             
}                                                                                     
                                                                                      
int area(int x,int y) {                                                               
                                                                                      
  return x*y;                                                                         
}                                                                                     
                                                                                      
int circumference(int x,int y) {                                                      
                                                                                      
  return 2*(x+y);                                                                     
}                                                                                     
                                             

Measured memory_bytes: 3068
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>
#include <random>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

random_device seed_gen;
mt19937 engine(seed_gen());
// 0, 1, 2 のどれかが得られる一様分布
// uniform_int_distribution<> dist(0, 2);
// cout << dist(engine) << endl;
// みたいに、先に確率分布を宣言して、そこにengineを与えて使う。

// =========ここまでテンプレ============
const int MOD = 1000000007;
ll modularPower(ll a, ll n, ll modulus)
{
    ll result = 1;
    while (n > 0)
    {
        if (n & 1)
            result = result * a % modulus;
        a = a * a % modulus;
        n >>= 1;
    }
    return result;
}
int main()
{
    ll n;
    cin >> n;
    ll result = ((modularPower(10, n, MOD) - 2 * modularPower(9, n, MOD) + modularPower(8, n, MOD)) % MOD);
    if (result < 0)
    {
        result += MOD;
    }
    cout << result << endl;
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 10000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

vint pos(5);
int k;
bool check=true;

int main(){
    rep(i,5)cin>>pos[i];
    cin>>k;
    rep(i,5){
        reps(j,i+1,5){
            if(abs(pos[i]-pos[j])>k){
                check=false;
                break;
            }
        }
    }
    cout<<(check? "Yay!" : ":(")<<endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_l

#include <bits/stdc++.h>
#include <limits.h>
#include <algorithm>  


#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long int ll;

const int precision = 16;
const int modulo =  1000000007; // 10^9 + 7
using ll = long long;
const double EPS = 1e-9;

pair<ll, ll> recSolve2(int l, int r, vector<int> & seq, bool player) {
	if(l > r) return {0,0};

	if(player == false) {  //taro

		auto fleft = recSolve2(l + 1, r, seq, true);
		auto fRight = recSolve2(l, r - 1, seq, true);

		if(seq[l] + fleft.first - fleft.second >
		seq[r] + fRight.first - fleft.second) {
			return {seq[l] + fleft.first, fleft.second};
		}  else {
			return {seq[r] + fRight.first, fRight.second};
		}
	} else {
		auto fleft = recSolve2(l + 1, r, seq, false);
		auto fRight = recSolve2(l, r - 1, seq, false);

		if(fleft.first - seq[l] - fleft.second <
		fRight.first - seq[r] - fRight.second) {
			return {fleft.first, seq[l] + fleft.second};
		} else {
			return {fRight.first, seq[r] + fRight.second};
		}
	}
}


ll recSolve(int l, int r, vector<int> & seq, vector<vector<ll>> & memo) {
	if(l > r) return 0;
	if(memo[l][r] != -1) return memo[l][r];

	ll leftTaken = seq[l] + min(recSolve(l + 2, r, seq, memo), 
		recSolve(l + 1, r - 1, seq, memo));
	ll rightTaken = seq[r] + min(recSolve(l + 1, r - 1, seq, memo), 
		recSolve(l, r - 2, seq, memo));

	memo[l][r] =  max(leftTaken, rightTaken);
	return memo[l][r];
}

ll solveDeque() {
	int n; cin >> n;
	vector<int> seq(n);
	for(auto & v : seq) {
		cin >> v;
	}
	
	//auto ret = recSolve2(0, n - 1, seq, false); // taro is the first
	
	vector<vector<ll>> memo(3000, vector<ll>(3000, -1));

	ll taroAcc = recSolve(0, n - 1, seq, memo);
	ll acc = accumulate(seq.begin(), seq.end(), 0l);
	ll jiroAcc = acc - taroAcc;

//	cout << acc << " " << taroAcc << " " << jiroAcc <<endl;
	return taroAcc - jiroAcc;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(precision);
	cout.setf(ios_base::fixed);

	auto ret = solveDeque();
	cout << ret << endl;
	
	return 0;
}


Measured memory_bytes: 70912
N = gets.to_i
array = gets.split(' ').map(&:to_i)

res = true
if array.any? {|a| a != 0 }
  if N % 3 != 0
    res = false
  else
    nums = {}
    array.each do |a|
      if nums[a].nil?
        nums[a] = 1
      else
        nums[a] += 1
      end
    end
    if nums.keys.length > 3 || nums.keys.length == 1
      res = false
    elsif nums.keys.length == 2
      key1, key2 = nums.keys
      count1, count2 = nums.values
      if count1 * 2 == count2 || count2 * 2 == count1
        31.times do |i|
          if key1[i] == 1 && key2[i] == 1
            res = false
            break
          end
        end
      else
        res = false
      end
    elsif nums.values.uniq.length > 1 #keys==3
      res = false
    else # keys==3
      array3 = nums.keys
      31.times do |i|
        ones = array3.map{|a| a[i]}.select{|a| a==1}.length
        # [000] [011] [101] [110] => OK
        unless ones == 0 || ones == 2
          res = false
          break
        end
      end
    end
  end
end

puts res ? 'Yes' : 'No'

Measured memory_bytes: 12556
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define push_back pb
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	vector<ll> A(3*N);
	rep(i,3*N)cin>>A[i];

	//最小値がtop,pop;
	priority_queue<ll,vector<ll>, greater<ll>> ql;
	//最大値がtop,pop;
	priority_queue<ll> qr;

	ll suml = 0,sumr = 0;
	rep(i,N){
		suml += A[i];
		ql.push(A[i]);
		sumr += A[2*N+i];
		qr.push(A[2*N+i]);
	}
	//境界を左側i個までとしたときの、左側の和の最大値
	//境界を右側i個としたときの、右側の和の最小値
	vector<ll> L(N+1), R(N+1);
	L[0] = suml;
	R[0] = sumr;
	rep1(i,N+1){
		suml += A[N-1+i];
		ql.push(A[N-1+i]);
		suml -= ql.top();
		L[i] = suml;
		ql.pop();

		sumr += A[2*N-i];
		qr.push(A[2*N-i]);
		sumr -=qr.top();
		R[i] = sumr;
		qr.pop();
	}
	ll ans = L[0] - R[N];
	rep(i,N+1){
		ans = max(ans,L[i] - R[N-i]);
	}
	cout<<ans<<endl;

	print(L);print(R);

}

Measured memory_bytes: 5996
#include<bits/stdc++.h>
/*#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iterator>*/


#define ll          long long
#define uint        unsigned int 
#define ld          long double
#define SAM         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define mod         1000000007
#define mxn         200005
#define pb          push_back
#define pii         pair<int,int>
#define f           first
#define s           second
#define sz(x)       (int)x.size()
#define all(x)      x.begin(),x.end()

using namespace std;

int main()
{
    SAM;
    int x,n;
    cin>>x>>n;
    vector<int> v;
    FOR(i,0,n)
    {
        int m;
        cin>>m;
        v.pb(m);
    }
    sort(all(v));
    int b=1000;
    int c;
    vector<int>::iterator it;
    for(int i=0;i<=101;i++)
    {
        it = find(all(v),i);
        if(it!=v.end())
            continue;
        else
        {
            int a=abs(x-i);
            if(a<b)
            {
                b=a;
                c=i;
            }
        }
    }
    cout<<c;
   
    
    return 0;
}




Measured memory_bytes: 3624
#include <iostream>
using namespace std;
#include <vector>
#include "math.h"

#define mp make_pair
#define fi first
#define se second
#define pi pair<int,int>
#include <queue>
vector<int> adj[1000006];
int par[1000006]; bool vis[1000006]={0};   int dist[1000006];

void dfs(int x){
    for(auto i: adj[x]){
        if(dist[i]==dist[x]+1 && !vis[i]){
            par[i]=x; vis[i]=1;
            dfs(i);
        }
    }
}


int main(){
    
    int n,k;
    cin>>n>>k;
    for(int i=0;i<k;++i) {
        int a,b; cin>>a>>b;
        adj[a].push_back(b), adj[b].push_back(a);
    }

    priority_queue<pi, vector<pair<int,int> >, greater<pi> > pq;
 
    for(int i=1;i<=n;++i) dist[i]=-1;
        dist[1]=0;
    pq.push(mp(0,1));
    while(!pq.empty()){
        int d = pq.top().fi, x = pq.top().se;
        pq.pop();
        for(auto i: adj[x]){
            if(dist[i]>d+1 || dist[i]==-1){
                dist[i]=d+1;
                pq.push(mp(d+1,i));
            }
        }
    }

    dfs(1);
    for(int i=1;i<=n;++i) if(dist[i]==-1) {cout<<"No"; return 0;}

        cout<<"Yes\n";
    for(int i=2;i<=n;++i)cout<<par[i]<<'\n';

}

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

using namespace std;

int a[101],cnt[101];

void no() { puts("Impossible"); }
void yes() { puts("Possible"); }

int main() {
    int n; scanf("%d",&n);
    for(int i = 0; i<n; ++i) {
        scanf("%d",&a[i]);
        ++cnt[ a[i] ];
    }
    sort(a,a+n,greater<int>());
    int len = a[0];
    for(int i = len; i>len/2; --i) {
        cnt[ i ] -= 2;
        if( cnt[i] < 0 ) {
            no();
            return 0;
        }
    }
    if( !(len&1) ) {
        --cnt[len/2];
        if( cnt[len/2] != 0 ) {
            no();
            return 0;
        }
    } else {
        if( cnt[ len/2 + 1 ] ) {
            no();
            return 0;
        }
    }
    yes();
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    bool canstop=false;
    vector<int> a(N);
    for(int i=0;i<N;i++) cin >> a.at(i);
    int now=0,cnt=0;
    for(int i=0;i<N;i++){
        if(now!=1){
            now = a.at(now)-1;//調整
            cnt++;
        }
        else{
            canstop = true;
            break;
        }
        
    }
    if(canstop) cout << cnt << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3788
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }

int main() {

	long res = 0;
	long N; cin >> N;

	vector<long> B(N - 1);

	for (int i = 0; i < N - 1; i++) cin >> B[i];

	res += *B.begin();
	res += *B.rbegin();

	for (int i = 0; i < N - 2; i++) res += min(B[i], B[i + 1]);

	cout << res << endl;

}

Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let x: i64 = read();
    let t: i64 = read();
    println!("{}", std::cmp::max(0, x - t));
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
#define yn(x) puts((x ? "Yes" : "No"))
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  ;
  cin>>N;
  cout<<(double)N*2*3.141592<<endl;
}
void solve() {
  ;
  ;
}
signed main() {
  cout << setprecision(12);
  input();
  solve();
  return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <utility>

using namespace std;

int main(){
  unsigned long long n,k;
  cin >> n >> k;
  unsigned long long comb = 0;
  if(k==0){
    std::cout << n*n << std::endl;
    return 0;
  }
  for(unsigned long long i=k+1;i<=n;++i){
    comb += n/i*(i-k);
    if(n%i >= k) {
      comb += (n%i-k+1);
    }
    // std::cout << i << " " << comb << std::endl;
  }
  std::cout << comb << std::endl;

  return 0;
}

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

int main(){
  int A,B;
  cin >> A >> B;
  if(A%3 == 0 || B%3 == 0){
    cout <<"Possible"<<endl;
  }
  else if((A+B)%3 == 0){
    cout <<"Possible"<<endl;
  }
  else {
  cout << "Impossible" <<endl;
  }
}

Measured memory_bytes: 256
s = input()
n = len(s)
ok = True
if s[0] != 'A': ok = False
c_counter = 0
p = -1
for i in range(2,n-1):
    if s[i] == 'C':
        c_counter += 1
        p = i
if c_counter != 1: ok = False
if ok == 0: 
    print('WA')
    exit()
for i in range(n):
    if i == 0 or i == p: continue
    if ord(s[i]) < 97: ok = False
if ok: print('AC')
else: print('WA')


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

int main(void){
  int num;
  cin >> num;
  string k;
  cin >> k;
  if(k.size()>num){
    string ans;
    for(int i = 0;i < num;i++){
      ans.insert(ans.begin()+i,k[i]);
    }
    cout << ans << "..." << endl;
  }else{
    cout << k << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    if(a >= 13)
        cout << b << "\n";
    else if(a < 13 && a >= 6)
        cout << b/2 << "\n";
    else 
        cout << "0\n";
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int a, b;
  cin >> a >> b;

  rep(i, 10000000) {
    int x = 8 * i / 100;
    int y = 10 * i / 100;
    if (x > a) break;
    if (y > b) break;
    if (x == a && y == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
num = gets.chomp.split(" ").map(&:to_i)
count = 0
num.sort!
while !num.all? {|i| num[2] == i}
    num.sort!
    if num[2] - num[0] >= 2
        num[0] += 2
    elsif num[2] -num[1] >= 2
        num[1] += 2
    else
        num[0] += 1
        num[1] += 1
    end
    count += 1
end
puts count

Measured memory_bytes: 1788
#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 repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;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<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
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<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans1=-1;
	int ans2=-1;
	cin >>n;
	Vi p(n),q(n),a(n);
	rep(i,n){
		a[i]=i+1;
	}
	rep(i,n)
	{
	cin>>p[i];

	}	
	rep(i,n){
		cin>>q[i];
	}
	int c=0;
	do{

		c++;
		if(a==p){
			ans1=c;
		}
		if(a==q){
			ans2=c;
		}
	}while(next_permutation(all(a)));
cout<<abs(ans1-ans2)<<endl;
}

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

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

  vector<int> v(n);
  int i;
  for(i=0;i<n;i++)
  cin>>v.at(i);

  int j,w;
  int ans=0;
  for(i=0;i<=k;i++){
    if(i>n)
    continue;
    for(j=0;j<=k-i;j++){
      if(i+j>n||(i==0)&&(j==0))
      continue;
      int ten=0;
      // cout<<"i "<<i<<" j "<<j<<endl;

      vector<int> a;
      for(w=0;w<i;w++){
        ten+=v.at(w);
        a.push_back(v.at(w));
      }
      for(w=0;w<j;w++){
        ten+=v.at(n-1-w);
        a.push_back(v.at(n-1-w));
      }
      int d=k-(i+j);
      sort(a.begin(),a.end());
      for(w=0;w<d;w++){
        if(w>=a.size())
        break;
        if(a.at(w)>0)
        break;
        ten-=a.at(w);
      }
      // cout<<"ten "<<ten<<endl;
      ans=max(ans,ten);
    }
  }

  cout<<ans<<endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef int ll;
inline char gc(){
	static char buf[1<<14],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<14,stdin),p1==p2)?EOF:*p1++;
}
inline ll read(ll &x){
	x=0;bool f=1;char c=gc();
	for(;!isdigit(c);c=gc()){if(c=='-')f^=1;if(c==-1)return-1;}
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);x=f?x:-x;
	return 1;
}
#define pc putchar
inline void wr(ll x){
	if(x<0)pc('-'),x=-x;
	if(x>9)wr(x/10);pc(x%10|48);
}
const ll N=1e5+10;
ll n,fa[N];
map<ll,ll>vis[N];
queue<pair<ll,ll> >Q;
set<ll>s[N];
inline ll fid(ll x){return fa[x]==x?x:fa[x]=fid(fa[x]);}
int main(){
	read(n);
	for (ll i=1,x,y;i<=2*n-2;++i){
		read(x),read(y);
		++vis[x][y],++vis[y][x];
		if (vis[x][y]==2) Q.push(make_pair(x,y));
		s[x].insert(y);
		s[y].insert(x);
	}
	for (ll i=1;i<=n;++i) fa[i]=i;
	while (!Q.empty()){
		pair<ll,ll>A=Q.front();Q.pop();
		ll x=fid(A.first),y=fid(A.second);
		if (x==y) continue;
		if (s[x].size()>s[y].size()) swap(x,y);
		s[x].erase(y);//s[y].erase(x);
		for (set<ll>::iterator it=s[x].begin();it!=s[x].end();++it){
			ll i=*it;
			s[i].erase(x);
			s[i].insert(y),s[y].insert(i);
			++vis[y][i],++vis[i][y];
			if (vis[y][i]==2) Q.push(make_pair(y,i));
		}
		s[x].clear();
		fa[x]=y;
	}
	for (ll i=1;i<=n;++i) if (fid(i)!=fid(1)) return puts("NO"),0;
	puts("YES");
	return 0;
}

Measured memory_bytes: 64796
import kotlin.math.PI
import kotlin.math.sqrt

fun main() {
    val (a, b, h, m) = readLine()!!.split(" ").map { it.toInt() }
    val rad = PI * 2 * ( ((h + (m / 60.0)) / 12.0) - (m / 60.0) )
    val rsq = (a * a + b * b) - (2 * a * b * Math.cos(rad))

    print(sqrt(rsq))
}

Measured memory_bytes: 36596
from collections import deque
S = input()
Q = int(input())
reverse_flag = False
sento = deque([])
matubi = deque([])

def add_s(f, c):
  if f == '1':
    # 先頭
    sento.appendleft(c)
  else:
    # 末尾
    matubi.append(c)

for _ in range(Q):
  q = input()
  if q == '1':
    reverse_flag = not reverse_flag
    continue
  _, f, c = q.split()
  #print(reverse_flag, f, c)
  if reverse_flag:
    add_s('1' if f == '2' else '2', c)
  else:
    add_s(f, c)
  #print('---', S)

_s = ''.join(sento)
_m = ''.join(matubi)
ans = ''.join([_s, S, _m])
if reverse_flag:
  ans = ans[::-1]
print(ans)

Measured memory_bytes: 6516
import java.util.*;
public class Main {
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args) {
 
    while(kbd.hasNext()){
        int h = kbd.nextInt();
        int w = kbd.nextInt();
        if(!(h==0 && w==0)){
        for(int i=h; i>0; i--){
            for(int j=w; j>0; j--){
            if(c(i, h, j, w))System.out.print("#");
            else System.out.print(".");
            }
            System.out.println();
        }
        System.out.println();
        }
    }
    }
 
    static boolean c(int i, int h, int j, int w){
    boolean a = i==h || i==1;
    boolean b = j==w || j==1;
    return a||b;
    }
}

Measured memory_bytes: 24872
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;


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

	
	pair<int, int> ans;
	ans.fi = ans.se = -1;
	rep (i, s.size() - 1) {
		if (s[i] == s[i + 1]) {
			ans.fi = i + 1;
			ans.se = i + 2;
		}
	}
	rep (i, s.size() - 2) {
		if (s[i] == s[i + 2]) {
			ans.fi = i + 1;
			ans.se = i + 3;
		}
	}

	cout << ans.fi << " " << ans.se << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#define REP(i, n) for (int i = 0; i < n; i++)

using namespace std;
using ll = long long int;

int main(void) {
    ll n, k; cin >> n >> k;
    ll sum = 0;
    for(ll i = k; i <= n + 1; i++) {
        ll mn = (i * (i - 1)) / 2, mx = (i * (2 * n - i + 1)) / 2;
        sum += mx - mn + 1;
    }
    cout << sum % 1000000007 << endl;
}

Measured memory_bytes: 3636
import sys
import resource

sys.setrecursionlimit(20000)
n=int(input())
edges=[list(map(int,input().split())) for i in range(n-1)]
e = [[] for i in range(n)]
for a,b in edges:
  a-=1;b-=1
  e[a].append(b);e[b].append(a)
c=sorted(list(map(int,input().split())))
print(sum(c[:-1]))
visited=[False for i in range(n)]
node=[0]*n
cnt=0
def dfs(pos):
  global cnt,node,c
  if visited[pos]:return
  visited[pos]=True
  for p in e[pos]:
    dfs(p)
  node[pos]=c[cnt]
  cnt+=1
dfs(0)
print(' '.join(map(str,node)))

Measured memory_bytes: 21032
#include <bits/stdc++.h>
#include <utility>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    ll h, w, n;
    cin >> h >> w >> n;
    set<P> s;
    vector<int> ans(10, 0);

    rep(i, n){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        P p = make_pair(a, b);
        for(int i = max(a-2, 0); i <= min((ll)a, h-3); i++){
            for(int j = max(b-2, 0); j <= min((ll)b, w-3); j++){
                int cnt = 0;
                rep(dx, 3)rep(dy, 3){
                    P pp = make_pair(i+dx, j+dy);
                    if(s.find(pp) != s.end())cnt++;
                }
                ans[cnt]--;
                ans[cnt+1]++;
            }
        }
        s.insert(p);
    }
    ll ans0 = (h - 2) * (w - 2);
    for(int i = 1; i < 10; i++) ans0 -= ans[i];
    cout << ans0 << endl;
    for(int i = 1; i < 10; i++)cout << ans[i] << endl;
}

Measured memory_bytes: 4992
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define set0(x) memset(x,0,sizeof(x))
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();int f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll dp[4][3030] = {0};
int main() {
	int r,g,b,n;
	cin>>r>>g>>b>>n;
	dp[0][0] = 1;
	for(int i=0;i<=n;i++){
		for(int j = i;j<=n;j+=r){
			dp[1][j]+=dp[0][i];
		}
	}
	for(int i=0;i<=n;i++){
		for(int j = i;j<=n;j+=g){
			dp[2][j]+=dp[1][i];
		}
	}
	for(int i=0;i<=n;i++){
		for(int j = i;j<=n;j+=b){
			dp[3][j]+=dp[2][i];
		}
	}
	cout<<dp[3][n]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x;cin>>x;
    if(x>=400&&x<=599)
    cout<<8<<endl;
    
     if(x>=600&&x<=799)
     cout<<7<<endl;
     
     if(x>=800&&x<=999)
      cout<<6<<endl;
      
     if(x>=1000&&x<=1199)
       cout<<5<<endl;
       
      if(x>=1200&&x<=1399)
         cout<<4<<endl;
         
     if(x>=1400&&x<=1599)
          cout<<3<<endl;
          
     if(x>=1600&&x<=1799)
           cout<<2<<endl;
           
      if(x>=1800&&x<=1999)
            cout<<1<<endl;
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    stack<char> st;
    int c = 0;
    for (int i = 0; i < s.size(); i++) {
        if (st.empty())
            st.push(s[i]);
        else if (st.top() != s[i])
            c++, st.pop();
        else
            st.push(s[i]);
    }
    cout << c * 2 << endl;
    return 0;
}


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

int a, b, c, d;
std::string s;

int main() {
    std::cin >> s;
    int a = std::stoi(s.substr(0, 1));
    int b = std::stoi(s.substr(1, 1));
    int c = std::stoi(s.substr(2, 1));
    int d = std::stoi(s.substr(3, 1));
    
    for (int i = 0; i <= 7; i++) {
        int ca = a;
        int cb = b;
        int cc = c;
        int cd = d;
        if (i & 1) {
            cb *= -1;
        }
        if ((i >> 1) & 1) {
            cc *= -1;
        }
        if ((i >> 2) & 1) {
            cd *= -1;
        }
        if (ca + cb + cc + cd == 7) {
            std::cout << std::noshowpos << ca;
            std::cout << std::showpos << cb;
            std::cout << std::showpos << cc;
            std::cout << std::showpos << cd;
            std::cout << std::noshowpos << "=7" << std::endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int p[256];
int main( void )
{
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  for( int i='a'; i<='z'; i++ ){
    p[i] = -100;
  }
  for( int i=0; i<s.size(); i++ ){
    if( p[s[i]] + 2 >= i ){
      if( p[s[i]] + 1 == i ){
        cout << i << ' ' << i+1;
      } else {
        cout << i-1 << ' ' << i+1;
      }
      return 0;
    }
    p[s[i]] = i;
  }
  cout << -1 << ' ' << -1;
}

Measured memory_bytes: 512
numbers = gets.chomp.chars.map(&:to_i)
if numbers[0] + numbers[1] + numbers[2] + numbers[3] == 7
  puts "#{numbers[0]}+#{numbers[1]}+#{numbers[2]}+#{numbers[3]}=7"
elsif numbers[0] - numbers[1] + numbers[2] + numbers[3] == 7
  puts "#{numbers[0]}-#{numbers[1]}+#{numbers[2]}+#{numbers[3]}=7"
elsif numbers[0] + numbers[1] - numbers[2] + numbers[3] == 7
  puts "#{numbers[0]}+#{numbers[1]}-#{numbers[2]}+#{numbers[3]}=7"
elsif numbers[0] + numbers[1] + numbers[2] - numbers[3] == 7
  puts "#{numbers[0]}+#{numbers[1]}+#{numbers[2]}-#{numbers[3]}=7"
elsif numbers[0] - numbers[1] - numbers[2] + numbers[3] == 7
  puts "#{numbers[0]}-#{numbers[1]}-#{numbers[2]}+#{numbers[3]}=7"
elsif numbers[0] + numbers[1] - numbers[2] - numbers[3] == 7
  puts "#{numbers[0]}+#{numbers[1]}-#{numbers[2]}-#{numbers[3]}=7"
elsif numbers[0] - numbers[1] + numbers[2] - numbers[3] == 7
  puts "#{numbers[0]}-#{numbers[1]}+#{numbers[2]}-#{numbers[3]}=7"
elsif numbers[0] - numbers[1] - numbers[2] - numbers[3] == 7
  puts "#{numbers[0]}-#{numbers[1]}-#{numbers[2]}-#{numbers[3]}=7"
end

Measured memory_bytes: 3836
#include <stdio.h>

int main(void)
{
	int a,b;
	scanf("%d %d", &a , &b);

	if (a < b)
	{
		printf("a < b\n");
		/* code */
	}else if(a > b)
	{
		printf("a > b\n");
	}else if (a == b)
	{
		printf("a == b\n");
		/* code */
	}
	return 0;
}

Measured memory_bytes: 580
def price_without_tax(tax_8, tax_10)
  return -1 unless tax_10.between?(1, 100)
  return -1 unless tax_8.between?(1, 100)

  avalil_tax_8 = [*(tax_8 / 0.08).ceil...((tax_8 + 1) / 0.08)]
  avalil_tax_10 = [*(tax_10 / 0.10).ceil...((tax_10 + 1) / 0.10)]

  (avalil_tax_8 & avalil_tax_10)[0] || -1
end

tax_8, tax_10 = gets.chomp!.split(' ').map(&:to_i)
puts price_without_tax(tax_8, tax_10)

Measured memory_bytes: 1788
S = input()

T = input()
count = 0

s=[]
t=[]
for i in S:
    s.append(i)
for j in T:
    t.append(j)


if s[0]==t[0]:
    count+=1
if s[1]==t[1]:
    count+=1
if s[2]==t[2]:
    count+=1

print(str(count))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

// ACL template
int main() {
    ll N, D;
    cin >> N >> D;
    two_sat ts(N);

    vvc<ll> A(N, vl(2));
    rep(i, N) cin >> A[i][0] >> A[i][1];

    rep(i, N) repe(j, i + 1, N){
        rep(ai, 2) rep(aj, 2){
            if(abs(A[i][ai] - A[j][aj]) < D)
                ts.add_clause(i, ai, j, aj);
        }
    }

    if(!ts.satisfiable()){
        cout << "No" << '\n';
    }else{
        cout << "Yes" << '\n';
        auto ans = ts.answer();
        rep(i, N) cout << (ans[i] ? A[i][0] : A[i][1]) << '\n';
    }
    
}

Measured memory_bytes: 3804
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, p: "List[int]"):
    print(sum(p) - max(p) // 2)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, p)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
try:
    s = input()

    f = int(s[:2])
    b = int(s[2:])

    if f == 00 or f > 12:
        if b == 00 or b > 12:
            print('NA')
        elif b < 13:
            print('YYMM')
    else:
        if b == 00 or b > 12:
            print('MMYY')
        elif b < 13:
            print('AMBIGUOUS')

except EOFError:
    pass

Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
#include<cstdlib>
#include<cassert>
using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> ans(N + 1, 0);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		ans[a]++;
		ans[b]++;
	}
	for (int i = 1; i <= N; i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 256
import sys
 
input = sys.stdin.readline()
N = int(input)
sum = N
if N % 2 == 0:
  halfN = N/2
else:
  halfN = N+1/2
divisors = []
for i in range(1, int(N**0.5)+1):
  if N % i == 0:
    divisors.append(i)
    if i != N // i:
      divisors.append(N//i)
for x in divisors:
  if N%x==0 and (N/x+x-2)<N:
    sum = N/x + x - 2
print(int(sum))

Measured memory_bytes: 3272
#include <iostream>
#include <stdio.h>

using namespace std;

int N;
int t[205], v[205];
int upper[40005];
int T;


int main(void)
{
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> t[i];
		t[i] *= 2;
	}
	for(int i = 0; i < N; i++){
		cin >> v[i];
		v[i] *= 2;
	}
	for(int i = 0; i < N; i++) T += t[i];
	
	for(int i = 0; i <= T; i++) upper[i] = min(i, T-i);
	int lb = 0;
	for(int i = 0; i < N; i++){
		for(int j = lb; j <= lb + t[i]; j++) upper[j] = min(upper[j], v[i]);
		for(int j = lb; j >= 0; j--) upper[j] = min(upper[j], v[i] + (lb-j));
		lb += t[i];
		for(int j = lb; j <= T; j++) upper[j] = min(upper[j], v[i] + (j-lb));
	}
	
	int ans = 0;
	for(int i = 0; i < T; i++){
		ans += upper[i] * 2;
		ans += upper[i] - upper[i+1];
	}
	printf("%.8f\n", ans / 8.0);
	return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


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


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B):
    return A*B - (A+B) + 1


def main():
    A, B = read_int_n()
    print(slv(A, B))


if __name__ == '__main__':
    main()


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

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();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
    	return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(long long n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(long long n, long long k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(void){
    ll n,k; cin >> n >> k;

    mint ans(1);
    if(k < n-1){
        combination C(n);
        ans.x = 0;
        REP(i,k+1){
            ans += C(n,i) * C(n-1, n-1-i);
        }
    }
    else{
        REP(i,n){
            ans *= 2*n-1-i;
            ans /= n-i;
        }
    }
    cout << ans.x << endl;
    return 0;
}

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

int main() {
	// your code goes here
	int n, k;
	cin >> n >> k;
	if(n <= 10) {
	    cout << k + 100 * (10 - n) << endl;
	} else {
	    cout << k << endl;
	}
	return 0;
}


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

char sstr[3010],tstr[3010];
int dp[3010][3010];
int pres[3010][3010];
void print(int i,int j){
	if (i==0 || j==0) return ;
	if (pres[i][j]==1){
		print(i-1,j-1);
		printf("%c",sstr[i]);
	}
	else if (pres[i][j]==0){
		print(i-1,j);
	}
	else{
		print(i,j-1);
	}
}
int main(){
	scanf("%s%s",sstr+1,tstr+1);
	int lens=strlen(sstr+1);
	int lent=strlen(tstr+1);
	for (int i=1;i<=lens;i++){
		for (int j=1;j<=lent;j++){
			if (sstr[i]==tstr[j]){
				if (dp[i-1][j-1]+1>dp[i][j]){
					dp[i][j]=dp[i-1][j-1]+1;
					pres[i][j]=1;
				}
			}
			if (dp[i-1][j]>dp[i][j]){
				dp[i][j]=dp[i-1][j];
				pres[i][j]=0;
			}
			if (dp[i][j-1]>dp[i][j]){
				dp[i][j]=dp[i][j-1];
				pres[i][j]=-1;
			}
		}
		/*
		printf("-------\n");
		for (int p=1;p<=lens;p++){
			for (int q=1;q<=lent;q++){
				printf("%d ",dp[p][q]);
			}
			printf("\n");
		}
		printf("--------\n");
		*/
	}
	print(lens,lent);
	return 0;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e2+5;
int GCD(int x, int y)
{
	return (y ? GCD(y, x % y) : x);
}
int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n;
	cin >> n;
	int gcd[n+1][n+1];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			gcd[i][j] = GCD(i, j);
	ll ans = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			for (int k = 1; k <= n; k++)
				ans += gcd[i][gcd[j][k]];
	cout << ans;
	return 0;
}


Measured memory_bytes: 3792
/** author: __nishad__ **/

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


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a) for(int i=0; i<a;i++)
#define loop2(i,a,b) for(int i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    ll x, i, j, p;
    vll v;
    cin>>x;

    if(x == 1)
        cout<<"1";
    else{
        for(i=1; i<=x; i++){
            for(j=2; j<=x; j++){
                p = pow(i, j);
                if(p == int(p) && (p <= x)){
                    v.pb(p);
                }
            }
        }
        sort(all(v));

        cout<<v[v.size()-1];
    }



}



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

int main(){
  int N; cin>>N;
  int a[100000];
  map<int,int> mp;
  for(int i=0;i<N;i++){
    cin>>a[i];
    mp[a[i]]++;
  }
  int ans=0;
  for(auto p:mp){
    int n=p.first;
    int x=p.second;
    if(n>x)ans+=x;
    else ans+=x-n;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5120