akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
num = 0
x = 0
y = []
n.times do |i|
  if a[i] < b[i]
    num += 1
    x += b[i] - a[i]
  else
    y << a[i] - b[i]
  end
end

if num > 0
  y.sort.reverse.each do |z|
    num += 1
    x -= z
    break if x <= 0
  end
end
if x > 0
  puts "-1"
else
  puts num
end

Measured memory_bytes: 25740
N = int(input())
P = [int(p) for p in input().split()]
Q = [int(q) for q in input().split()]

import itertools

if P == Q:
    print(0)
else:
    perm = [i for i in range(1, N+1)]

    count = 0
    numlst = []
    for v in itertools.permutations(perm, N):
        count += 1
        if tuple(P) == v or tuple(Q) == v:
            numlst.append(count)

    print(abs(numlst[1] - numlst[0]))

Measured memory_bytes: 9112
while True:
    a,l = input().split()
    if a==l=='0': break
    nl,i = [a],0
    while True:
        mx = int(''.join(sorted(list(a.zfill(int(l))),reverse=True)))
        mn = int(''.join(sorted(list(a))))
        a = str(mx-mn)
        if a in nl:
            print(nl.index(a),a,i-nl.index(a)+1)
            break
        nl += [a]
        i += 1

Measured memory_bytes: 7668
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

map<int,int>rows,cols;

int32_t main() {

    fast

    int r,c,m;
    cin>>r>>c>>m;
    int x,y;
    set<pair<int,int>>st;
    for(int i=0;i<m;i++){
        cin>>x>>y;
        st.insert({x,y});
        rows[x]++;
        cols[y]++;
    }

    int maxRow,maxCol;
    maxCol=maxRow=INT_MIN;
    vector<int>candidateRows,candidateCols;
    for(auto i:rows){
        if(i.second>maxRow){
            maxRow=i.second;
        }
    }
    for(auto i:cols){
        if(i.second>maxCol){
            maxCol=i.second;
        }
    }
    for(auto i:rows){
        if(i.second==maxRow){
            candidateRows.push_back(i.first);
        }
    }
    for(auto i:cols){
        if(i.second==maxCol){
            candidateCols.push_back(i.first);
        }
    }

    int ans=maxRow+maxCol-1;
    bool flag=false;
    for(int i=0;i<candidateRows.size();i++){
        for(int j=0;j<candidateCols.size();j++){
            if(!st.count({candidateRows[i],candidateCols[j]})){
                ans++;
                flag=true;
                break;
            }
        }
        if(flag)break;
    }
    cout<<ans<<endl;



    return 0;
}



Measured memory_bytes: 67824
/**
 * 
 */
import java.util.*;
/**
 * @author akira
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int x, h;
		while(true){
			x = scan.nextInt();
			h = scan.nextInt();
			if(x == 0 && h == 0){
				break;
			}
			System.out.println("" + (x * x + 2 * Math.sqrt(Math.pow(x / 2.0,2.0) + Math.pow((double)h,2.0)) * x));
		}
	}

}

Measured memory_bytes: 17188
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
    //#ifndef ONLINE_JUDGE
      //  freopen("input.txt", "r", stdin);
     //   freopen("output.txt", "w", stdout);
    //#endif
    lli n;cin>>n;
    lli a[n];loop(i,0,n)cin>>a[i];
    lli ans=0;
    for(lli i=0;i<n;i++){
    	bool at=true;
    	for(lli j=0;j<i;j++)
    		if(a[j]>a[i])at=false;
    	if(at)ans++;
    	//cout<<ans;
    }
    cout<<ans;
    return 0;
 }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int redcount=0,whitecount=0;
    int leftcount=0,rightcount=0;
    REP(i,n){
        if(s[i]=='W')whitecount++;
        else redcount++;
    }
    REP(i,redcount){
        if(s[i]=='R')leftcount++;
    }
    REP(i,whitecount){
        if(s[s.length()-i-1]=='W'){
            rightcount++;
        }
    }
    cout << min(whitecount-rightcount,redcount-leftcount) << endl;

    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll n, k;
	long double ans = 0;
	cin >> n >> k;

	repeq(i, 1, n) {
		long double tmp = (long double)1/n;
		ll m = i;
		while (m < k) {
			tmp /= 2;
			m *= 2;
		}
		ans += tmp;
	}

	cout << std::setprecision(10) << ans << endl;
	return 0;

}


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

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

    if((a*100+b*10+c)%4==0){
        cout<<"YES"<<endl;
    }
    else {
        cout<<"NO"<<endl;
    }
}



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

using namespace std;

using ld = long double;

const ld EPS = 1e-8;

vector<pair<ld, ld>> circlesCenter(ld x1, ld y1, ld x2, ld y2, ld r) {
    vector<pair<ld, ld>> res;
    ld dx = x2 - x1;
    ld dy = y2 - y1;
    ld d = sqrt(dx*dx + dy*dy);
    ld l = d/2;
    ld hsq = r*r - l*l;
    if (hsq < 0.0) {
        return res;
    }
    ld h = sqrt(hsq);
    ld vx1 = l*dx/d;
    ld vx2 = h*dy/d;
    ld vy1 = l*dy/d;
    ld vy2 = h*dx/d;
    res.push_back({vx1+vx2+x1, vy1-vy2+y1});
    res.push_back({vx1-vx2+x1, vy1+vy2+y1});
    return res;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    vector<pair<ld, ld>> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    ld l = 0.0, r = 1000.0;
    while (r - l > EPS) {
        auto mid = (l+r)/2.0;
        auto ok = false;
        vector<pair<ld, ld>> cs;
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                for (auto pr: circlesCenter(a[i].first, a[i].second, a[j].first, a[j].second, mid)) {
                    cs.push_back(pr);
                }
            }
        }
        for (auto center: cs) {
            auto all = true;
            for (auto pr: a) {
                ld dx = pr.first - center.first;
                ld dy = pr.second - center.second;
                if (dx*dx + dy*dy >= mid*mid + EPS) {
                    all = false;
                }
            }
            if (all) {
                ok = true;
            }
        }
        if (ok) {
            r = mid;
        } else {
            l = mid;
        }
    }
    cout.precision(10);
    cout << fixed << r << endl;
}



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

int main()
{
  int n;
  cin >> n;
  
  string a, b, c;
  cin >> a;
  cin >> b;
  cin >> c;
  
  // all combination = 2 * n;
  
  int min = 2*n;
  int diffCount = 0;
  
  for( int i = 0; i < n; i++ )
  {
    int tempDiffCount = 0;
    if( a[i] != b[i] ) tempDiffCount++;
    if( a[i] != c[i] ) tempDiffCount++;
    if( b[i] != c[i] ) tempDiffCount++;
    
    if( tempDiffCount == 2 )
      	diffCount += 1;
    if( tempDiffCount == 3 )
    	diffCount += 2;
  }

  
  int retCount = diffCount;
  
  cout << retCount << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
using namespace std;


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

	sort(h.begin(), h.end(), std::greater<long long>());

	int ng = 0, ok = h[0] / B + 1;
	while (ok - ng != 1) {
		int mid = (ng + ok) / 2;
		long long sum = 0, counter = 0;
		for (int i = 0; i < N; i++) {
			long long diff = h[i] - B * mid;
			if (diff > 0) {
				sum += diff;
				if (diff % (A - B) == 0)
					counter += diff / (A - B);
				else 
					counter += diff / (A - B) + 1;
			}
			else
				break;
		}
		if (sum <= (A - B) * mid && counter <= mid) {
			ok = mid;
		} else {
			ng = mid;
		}
	}

	printf("%d\n", ok);

}

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

int main() {
  string T;
  cin >> T;
  for (int i = 0; i < T.size(); ++i) {
    if (T.at(i) == '?') {
      T.at(i) = 'D';
    }
  }
  cout << T << endl;
  return 0;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];

  Int l=__builtin_ctz(as[0]);
  for(Int a:as) if(l!=__builtin_ctz(a)) drop(0);

  Int lcm=1;
  for(Int a:as){
    a>>=l;
    lcm=lcm/__gcd(lcm,a)*a;
    if(lcm>m) break;
  }
  cout<<((m/lcm+(1<<(l-1)))>>l)<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
const int MAXN=(int)1e5+10;
struct edge{
	int to,nxt;
}ed[MAXN<<1]
;
int head[MAXN],cnt;
void addedge(int u,int v){
	ed[cnt].to=v;
	ed[cnt].nxt=head[u];
	head[u]=cnt++;
}
int sz[MAXN],fa[MAXN],dep[MAXN];
void dfs(int u,int pre){
	sz[u]=1;
	dep[u]=dep[pre]+1;
	fa[u]=pre;
	for(int i=head[u];i!=-1;i=ed[i].nxt){
		int v=ed[i].to;
		if(v!=pre){
			dfs(v,u);
			sz[u]+=sz[v];			
		}
	}
}
int main()
{
	memset(head,-1,sizeof(head));
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		addedge(u,v);
		addedge(v,u);
	}
	dfs(1,0);
	int d=(dep[n]-2)/2;
	int ans=n;
	while(d){
		d--;
		ans=fa[ans];
	}
	if(sz[ans]*2>=n)printf("Snuke\n");
	else printf("Fennec\n");
	return 0;
}

Measured memory_bytes: 8064
fn main() {
    let (price, haved_money, satisfaction) = {
        let input_value = get_read_line();
        let values : Vec<i32> = input_value
                                    .split(" ")
                                    .map(|value| value.trim().parse::<i32>().unwrap())
                                    .collect();
        (values[0], values[1], values[2])
    };

    let can_buy_count = haved_money / price;
    if can_buy_count >= satisfaction {
        println!("{:?}", satisfaction);
    } else {
        println!("{:?}", can_buy_count);
    }
}

fn get_read_line() -> String {
    let mut result = String::new();
    std::io::stdin().read_line(&mut result).unwrap();
    result
}


Measured memory_bytes: 4352
def bubble_sort(array):
    i_n_srt = 0
    counter = 0
    flg = True
    while flg:
        flg = False
        for j in range(len(array) - 1, i_n_srt, -1):
            # print(f"i_Not_sort: {i_n_srt}, j: {j}")
            if array[j] < array[j - 1]:
                array[j], array[j - 1] = array[j - 1], array[j]
                # print(array, "\n")
                counter += 1
                flg = True
        i_n_srt += 1
    return counter, array        

N = int(input())
A = list(map(int, input().split()))
# print(f'array(start): {A}')
ans, array_new = bubble_sort(A)
print(" ".join(map(str, array_new)))
print(ans)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
	ll n;
	cin >> n;
	ll nn=n;
	//桁数調べる
	int x=0;
	while(n>0){
		x++;
		n-=pow(26,x);
		if(n>0)
			nn = n;
	}	
	nn--;
	// cout << nn << endl;
	// cout << nn/26/26 << endl;
	// cout << nn/26%26 << endl;
	// cout << nn%26 << endl;
	// cout << x << endl;
	vector<char> table(x);
	for(int i=0;i<x;i++){
		// cout << nn << endl;
		// cout << nn%26 << endl;
		// cout << char(nn%26+'a') << endl;
		table[i] = char(nn%26+'a');
		nn/=26;
	}
	for(int i=table.size()-1;i>=0;i--){
		cout << table[i];
	}
	cout << endl;
	return 0;
}



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

int main(void) {
    int n, l;
    scanf("%d %d", &n, &l);
    int sum=0, min = abs(l);
    for(int i=1; i<=n; i++){
        sum += l+i-1;
        if(min > abs(l+i-1)) min = abs(l+i-1);
    }
    printf("%d\n", sum>=0?sum-min:sum+min);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder src = new StringBuilder(sc.nextLine());
		int count = 0;

		int len = src.length();
		for (int i = 0; i < ((Integer) len / 2); i++ ) {
			if (src.charAt(i) != src.charAt(len - (i+1))) {
				src.replace(len - (i+1), len - i, String.valueOf(src.charAt(i)));
				count++;
			}
		}

		System.out.println(count);
	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <climits>
#include <cfloat>

using namespace std;
using ll = long long int;

const ll MOD = 1000000007;

template <typename T>
int cin_vec(vector<T> &vec) {
    for (auto &i : vec) {
        cin >> i;
    }
    return 0;
}

template <typename T>
int cout_vec(vector<T> vec, bool insertNewLine = true) {
    if (insertNewLine) {
        for (const auto &i : vec) {
            cout << i << endl;
        }
    } else {
        for (const auto &i : vec) {
            cout << i << flush;
        }
    }
    return 0;
}

template <typename T>
ll min_vec(std::vector<T> vec) {
    auto iter = min_element(vec.begin(), vec.end());
    ll index = distance(vec.begin(), iter);
    return index;
}

template <typename T>
ll max_vec(std::vector<T> vec) {
    auto iter = max_element(vec.begin(), vec.end());
    ll index = distance(vec.begin(), iter);
    return index;
}

int main() {
    int n;
    string s;
    cin >> n >> s;
    int red = 0, blue = 0;
    for (int i = 0; i < n; ++i) {
        if (s.at(i) == 'R') ++red;
        if (s.at(i) == 'B') ++blue;
    }
    if (red > blue) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
     
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
 
N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N-1)]

# graph[i]: 頂点iの親と子の集合
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

# 根
root = 1
# parent[i]: 頂点iの親
parent = [0]*(N+1)
# トポロジカル順序
order = []
# 未探索の頂点
stack = [root]

# dfsでparentを求める
while stack:
    # n: 探索する頂点
    n = stack.pop()
    order.append(n)
    for j in graph[n]:
        # jがnの親の場合
        if j == parent[n]:
            continue
        parent[j] = n
        stack.append(j)

# color[i]: 頂点iと親を繋ぐ辺の色
color = [-1] * (N+1)
# dfsで頂点iから出る辺の色を塗る
for i in order:
    # 既に使用した色
    ng = color[i]
    # 色
    c = 1
    for j in graph[i]:
        # jがiの親の場合(塗装済みなのでcontinue)
        if j == parent[i]:
            continue
        if c == ng:
            c += 1
        # 頂点iと頂点jの辺に色を塗る
        color[j] = c
        c += 1

# 入力順に辺の色を出力する
answer = [color[a] if parent[a]==b else color[b] for a,b in AB]
print(max(answer))
print("\n".join(map(str,answer)))

Measured memory_bytes: 42848
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;

template <int mod>
struct ModInt
{
    int x;

    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p)
    {
        if ((x += p.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p)
    {
        if ((x += mod - p.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p)
    {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p)
    {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const
    {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0)
        {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    ModInt pow(int e)
    {
        long long a = 1, p = x;
        while (e > 0)
        {
            if (e % 2 == 0)
            {
                p = (p * p) % mod;
                e /= 2;
            }
            else
            {
                a = (a * p) % mod;
                e--;
            }
        }
        return ModInt(a);
    }

    friend ostream &operator<<(ostream &os, const ModInt<mod> &p)
    {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a)
    {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

using modint = ModInt<mod>;
modint f[d5];

void makef()
{
    f[0] = 1;
    for (int i = 1; i < d5; i++)
        f[i] = f[i - 1] * i;
}

modint nCr(int n, int r)
{
    if (n < r || r < 0)
        return 0;
    return f[n] / (f[r] * f[n - r]);
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    if(abs(n-m)>1){
        cout<<0<<endl;
        return 0;
    }
    makef();
    modint res=1;
    if(n!=m){
        res*=f[n];
        res*=f[m];
    }else{
        res*=f[n];
        res*=f[n];
        res*=2;
    }
    cout<<res<<endl;

}

Measured memory_bytes: 1024
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn()
  let ar=asc(tnn(n))
  let ans=ar[0]
  for(let i=1;i<n;i++){
    ans=(ans+ar[i])/2
  }
  to(ans)
}
main()


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

#define MAX 51
int N,M,Q,a[MAX], b[MAX], c[MAX], d[MAX];

int ans;
void dfs(deque<int> &deq, int cur) {
  if( cur >= N ) {
    int sum = 0;
    rep(i,Q) {
      if( deq[b[i]] - deq[a[i]] == c[i] ) {
	sum += d[i];
      }
    }
    ans = max(sum,ans);
    return;
  }
  int sp = 1;
  if( deq.size() ) sp = deq.back();
  REP(i,sp,M+1) {
    deq.pb(i);
    dfs(deq,cur+1);
    deq.pop_back();
  }
}

int main() {
  cin >> N >> M >> Q;
  rep(i,Q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    --a[i], --b[i];
  }
  deque<int> deq;
  dfs(deq,0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REP1(i, n) for (ll i = 1; i <= n; i++)
#define RREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define RREP1(i, n) for (ll i = n; i >= 1; i--)
#define FOR(i, a, b, c) for (ll i = a; i <= b; i += c)
#define RFOR(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)
#define INF 1145141919
typedef long long ll;

int main() {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    printf("%d\n", MAX(a * b, c * d));
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int n, m, cnt;
char map[10][10];
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> map[i][j];
			if (map[i][j] == '#') cnt++;
		}
	}
	if (n + m - 1 == cnt) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	
	return 0;
}

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

int main (void){
	int n;
	int sum = 0;
	cin >> n;
	int a[n+10];
	a[0] = 0;
	int flag = 0;
	for(int i = 1; i < n+1; i++){
		cin >> a[i];
		if(a[i] == a[i-1]){
			if(flag == 0){
				flag = 1;
				sum++;
			}else{
				flag =0;
			}
		}else{
			flag = 0;
		}

	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 888
while True:
    n,m = map(int,input().split())
    if n==0: break
    mapp = []
    for _ in range(n):
        mapp.append(int(input()))
    mas = 0
    ans = 0
    for dice in range(m):
        mas += int(input())
        if mas >= n-1 and ans == 0: ans = dice+1
        if mas < n-1 : mas += mapp[mas]
        if mas >= n-1 and ans == 0: ans = dice+1
    print(ans)

Measured memory_bytes: 7660
function Main( ) {
  var fs = require( 'fs' );
  var fileName='/dev/stdin';

  var input = fs.readFileSync( fileName ).toString();
  var data = input.split( " " ).map( Number );
  var a = data[0];
  var b = data[1];
  var C = data[2]*(Math.PI/180);
  
  var h = Math.sin( C )*b;
  var ta = Math.cos( C )*b;
  var c = Math.sqrt( Math.pow( (a-ta), 2 )+Math.pow( h, 2 ) );
  
  var S = (a*h)/2;
  var L = a+b+c;
  console.log( S+'\n'+L+'\n'+h );
};

Main();

Measured memory_bytes: 15616
n,m=gets.split.map(&:to_i)

p gets.split.map(&:to_i)
  .each_with_object([0]){|ai,o|o<<((o[-1]+ai)%m)}
  .group_by(&:itself)
  .values
  .map(&:size)
  .map{|i|i*(i-1)/2}
  .inject(:+)

Measured memory_bytes: 17156
x, y = map(int, input().split())

no_flag = -1

if y - (4 * x) == 0:
    print("Yes")
elif y - (2 * x) == 0:
    print("Yes")
else:
    for cnt in range(x):
        if y >= 4 and y - (2 * (x-(cnt))) != 0:
            y -= 4
        elif y >= 2:
            y -= 2

        if y == 0 and cnt == x-1:
            no_flag = 0
        elif y == 0 and cnt != x-1:
            no_flag = 1
            break
        else:
            no_flag = 1

    if no_flag == 0:
        print("Yes")
    elif no_flag == 1:
        print("No")


Measured memory_bytes: 9120
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define mp(a,b)	make_pair(a,b)
#define fst	first
#define scn second

const ll inf = (ll)1e9 + 7;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;

class segtree {
public:
	vint big, sml;
	int N=1;
	segtree(int n,vint dat) {
		while (N < n)	N <<= 1;
		big.resize(2 * N);	sml.resize(2 * N);
		rep(i, 2 * N) {
			big[i] = 0;
			sml[i] = inf;
		}
		rep(i, n)	big[N - 1 + i] = sml[N - 1 + i] = dat[i];
		rrep(i, N - 1) {
			big[i] = max(big[2 * i + 1], big[2 * i + 2]);
			sml[i] = min(sml[2 * i + 1], sml[2 * i + 2]);
		}
	}
	int getmin(int l, int r, int a, int b, int k) {
		if (r <= a || b <= l)	return inf;
		if (a <= l&&r <= b)	return sml[k];
		return min(this->getmin(l, (l + r) / 2, a, b, 2 * k + 1), this->getmin((l + r) / 2, r, a, b, 2 * k + 2));
	}
	int getmax(int l, int r, int a, int b, int k) {
		if (r <= a || b <= l)	return 0;
		if (a <= l&&r <= b)	return big[k];
		return max(this->getmax(l, (l + r) / 2, a, b, 2 * k + 1), this->getmax((l + r) / 2, r, a, b, 2 * k + 2));
	}
};

int x[200010], y[200010];
int n;

ll solve1() {//different colored
	vint r(n,0), b(n,0);
	rep(i, n) {
		r[i]=max(x[i], y[i]);
		b[i]=min(x[i], y[i]);
	}
	sort(r.begin(), r.end());
	sort(b.begin(), b.end());
	return (ll)(r[n - 1] - r[0])*(b[n - 1] - b[0]);
}

ll solve2() {//same colored
	vector<pii> dat(n);
	rep(i, n)	dat[i] = mp(min(x[i], y[i]), max(x[i], y[i]));
	sort(dat.begin(), dat.end());
	vint r(n), b(n);
	rep(i, n)	r[i] = dat[i].fst, b[i] = dat[i].scn;
	segtree red(n, r), blue(n, b);
	ll ret = 1e18;
	rep(i, n) {//[0,i)をreverseする
		ll rbig = max(red.getmax(0, red.N, 0, i, 0), blue.getmax(0, blue.N, i, n, 0));
		ll rsml = min(red.getmin(0, red.N, 0, i, 0), blue.getmin(0, blue.N, i, n, 0));
		ll bbig = max(blue.getmax(0, blue.N, 0, i, 0), red.getmax(0, red.N, i, n, 0));
		ll bsml = min(blue.getmin(0, blue.N, 0, i, 0), red.getmin(0, red.N, i, n, 0));
		ret = min(ret, (bbig - bsml)*(rbig - rsml));
	}
	return ret;
}

int main() {
	cin >> n;
	rep(i, n)	cin >> x[i] >> y[i];
	ll ret1 = solve1();
	ll ret2 = solve2();
	cout << min(ret1,ret2) << endl;
	return 0;
}

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

int solve(vector<int >& arr , int N, int K) {
	if (N < 2)return 0;	
	vector<int> DP(N,INT_MAX);
    DP[N-1] = 0 ;
	for (int i = N-2; i >=0; i--) {
	    for(int j = 1 ; i+j < N && j <= K ; j++){
	         DP[i] = min (DP[i],DP[i + j] + abs(arr[i] - arr[i + j]));
	    }
	}
	return DP[0];
}

int main()
{
	int N , K;
	cin >> N >> K;
	vector<int> arr(N);
	for (int i = 0 ; i< N ; i++) {
		cin >> arr[i];
	}
    
	cout << solve(arr , N , K) << endl;
	return 0 ;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int r;
    cin >> r;
    if (r < 1200) {
        cout << "ABC" << endl;
    }else if (r < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n, k;
    cin >> n >> k;
    int arr[n + 1];
    for (int i = 1; i <= n; i++)
    {
        cin >> arr[i];
    }
    int dp[n + 1];
    memset(dp, 0, (n + 1) * sizeof(int));
    dp[1] = 0;
    for (int i = 2; i <= n; i++)
    {
        // =INT_MAX;
        dp[i] = INT_MAX;
        for(int j=i-1;j>=i-k && j>0;j--)
        {
          //  int temp = dp[j]+abs(arr[i]-arr[j]);
           // if(temp<=min)
           // {
             //   min = temp;
            //}
            dp[i] = min(dp[i] , dp[j]+abs(arr[i]-arr[j]));

        }
      //  dp[i] = min;
 
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1024
info = [int(i) for i in input().split()]
_min = max(int(info[0]*12.5), int(info[1]*10))
_max = min(int((info[0]+1)*12.5), int((info[1]+1)*10))
for i in range(_min, _max):
    if int(0.1*i)==info[1] and info[0]== int(0.08*i):
        print(i)
        break
else:
    print(-1)

Measured memory_bytes: 3064
# 2019/11/23
# DISCO presents ディスカバリーチャンネル コードコンテスト2020 予選 - B

# Binary Search
def binSearch (tlis, tval):
    lf = 0
    rg = len(tlis)
    while(lf <= rg):
        ct = int((lf + rg) / 2)
        if tlis[ct] < tval:
            lf = ct + 1
        elif tlis[ct] > tval:
            rg = ct - 1
        else:
            return ct
    return ct

# Input
n = int(input())
a = list(map(int,input().split()))
acm_a = list()
acm_a.append(0)

# Sum
for i in range(len(a)):
    acm_a.append(a[i] + acm_a[i])

acm_a.append(acm_a[len(a)])
# Calc Center
center = acm_a[len(a)] / 2
ctidx = binSearch(acm_a, center)

ans = min(abs((acm_a[len(a)] - acm_a[ctidx-1]) - acm_a[ctidx-1]), abs((acm_a[len(a)] - acm_a[ctidx]) - acm_a[ctidx]), abs((acm_a[len(a)] - acm_a[ctidx+1]) - acm_a[ctidx+1]))

# Output
print(ans)


Measured memory_bytes: 26220
import java.util.Scanner;
public class Main{
	int a;
	public void input(){
		Scanner scan = new Scanner(System.in);
		a = scan.nextInt();
	}
	public void output(){
		System.out.println(a*a*a);
	}
	public static void main(String[] args){
		Main p = new Main();
		p.input();
		p.output();
	}
}

Measured memory_bytes: 17156
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

// c1 を c2に変えるのに必要な操作の回数
int kaisu[30][30];
bool changed[100010];

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

    int n = s.size();
    rep(i, 26) rep(j, 26) {
        kaisu[i][j] = (j - i) % 26;
        if (kaisu[i][j] < 0) kaisu[i][j] += 26;
    }

    rep(i, n) {
        int c = s[i] - 'a';
        if (kaisu[c][0] <= k) {
            s[i] = 'a';
            k -= kaisu[c][0];
            changed[i] = true;
        }
    }
    k %= 26;
    s[n-1] = (char)(((s[n-1] - 'a') + k) % 26 + 'a');
    cout << s << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
    	int a = 0,b = 0,k;
    	Scanner in = new Scanner(System.in);
    	while(true){
    		int cnt = 0;
    		try{
    			a = in.nextInt();
    			b = in.nextInt();
    		}
    		catch (Exception e){
    			System.exit(0);
    		}
    		k = a + b;
    		while(k > 0){
    			k = k / 10;
    			cnt = cnt + 1;
    		}
    		System.out.println(cnt);
    	}
    }
}

Measured memory_bytes: 20364
#include<stdio.h>
int main()
{
    char a,b;
    scanf("%c %c",&a,&b);



        if(a=='H')
            printf("%c\n",b);
        else if(a=='D')
        {
            if(b=='H')
                printf("D\n");
            else if(b=='D')
                printf("H\n");
        }

    return 0;

}

Measured memory_bytes: 128
n = int(input())
s1 = list(input())
s2 = list(input())
mod = int(1e9+7)

def ranl(lst):
    ans = []
    cnt = 1
    ini = lst[0]
    for i in range(1, len(lst)):
        if ini == lst[i]:
            cnt += 1
        else:
            ans.append((ini, cnt))
            cnt = 1
            ini = lst[i]
    ans.append((ini, cnt))
    return ans

lst = ranl(s1)
ans = 1
if lst[0][1] == 1:
    ans *= 3
else:
    ans *= 6

for i in range(1, len(lst)):
    if lst[i-1][1] == 1 and lst[i][1] == 1:
        ans *= 2
        ans %= mod
    elif lst[i-1][1] == 1 and lst[i][1] == 2:
        ans *= 2
        ans %= mod
    elif lst[i-1][1] == 2 and lst[i][1] == 1:
        ans *= 1
    else:
        ans *= 3
        ans %= mod
print(ans)





Measured memory_bytes: 38256
#include <stdio.h>

#define MAX 10000
#define NIL -1

typedef struct{
  int parent;
  int left;
  int right;
}Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
  if(u==NIL) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right, d+1);
}

int setHeight(int u){
  int h1=0, h2=0;
  if(T[u].left != NIL) h1=setHeight(T[u].left)+1;
  if(T[u].right != NIL) h2=setHeight(T[u].right)+1;

  if(h1>h2) H[u]=h1;
  else if(h2>=h1) H[u]=h2;

  return H[u];
}

int getSibling(int u){
  if(T[u].parent==NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL) return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL) return T[T[u].parent].right;

  return NIL;
}

void print(int u){
  int deg =0;

  printf("node %d: parent = %d, sibling = %d, ", u, T[u].parent, getSibling(u));
  if(T[u].left != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, depth = %d, height = %d, ", deg, D[u], H[u]);
  if(T[u].parent == NIL){
    printf("root\n");
  }
  else if(T[u].left == NIL && T[u].right == NIL){
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}

int main(){
  int i, v, l, r, root=0;

  scanf("%d", &n);

  for(i=0; i<n; i++) T[i].parent=NIL;

  for(i=0; i<n; i++){
    scanf("%d%d%d", &v, &l, &r);
    T[v].left=l;
    T[v].right=r;
    if(l!=NIL) T[l].parent=v;
    if(r!=NIL) T[r].parent=v;
  }
  for(i=0; i<n; i++){
    if(T[i].parent == NIL) root = i;
  }

  setDepth(root,0);
  setHeight(root);

  for(i=0; i<n; i++) print(i);

  return 0;
}

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

if a > b:
    d = a
    a = b
    b = d
    
if b > c:
    d = b
    b = c
    c = d
   
if a > b:
    d = a
    a = b
    b = d 


if (b-a) % 2 == 1:
    ans = c-b+int((b-a)/2)+2
else:
    ans = c-b+int((b-a)/2)

print(ans)


Measured memory_bytes: 38384
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  3 23:44:02 2020

@author: Kanaru Sato
"""

N=int(input())
A = list(map(int, input().split()))

deny = 0

for i in range(0,N):
    if A[i]%2 == 0 and (A[i]%3 != 0 and A[i]%5 != 0):
        deny = 1

if deny == 1:
    print("DENIED")
else:
    print("APPROVED")



Measured memory_bytes: 3060
// Lec09-D Transformation
#include<iostream>
#include<string>
#include<algorithm>
int main(){
  static const std::string pri="print", rev="reverse", rep="replace";
  std::string str, comm, p;
  std::cin >> str;
  int q, a, b;
  for(std::cin >> q; q; q--){
    std::cin >> comm >> a >> b;
    if(pri == comm){
      for(; a<=b; a++) std::cout << str[a];
      std::cout << std::endl;
    }
    else if(rev == comm) std::reverse(str.begin()+a, str.begin()+b+1);
    else if(rep == comm){
      std::cin >> p;
      str.replace(a, b-a+1, p);
    }
  }
  return 0;
}

Measured memory_bytes: 3192
# your code goes here
N = int(input())

text = input()

ans = -1
for i in range(N-1):
	X = text[0:i+1]
	Y = text[i+1:N]
	X_alpha = [0]*27
	Y_alpha = [0]*27
	for x in X:
		X_alpha[ord(x)-ord("a")] = 1
	for y in Y:
		Y_alpha[ord(y)-ord("a")] = 1
		
	for j in range(27):
		X_alpha[j] = X_alpha[j] * Y_alpha[j]
	
	ans = max(ans,sum(X_alpha))
print(ans)
	

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;
struct Point {
    double x, y;
}p[N];
const double eps = 1e-9;
double Sgn(double x) {
    if(fabs(x) < eps) return 0;
    return x < 0 ? -1 : 1;
}
/*最小圆覆盖*/
/*给定n个点, 让求半径最小的圆将n个点全部包围,可以在圆上*/
double dist(const Point a, const Point b) { //两点之间的距离
    return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
Point get_circle_center(const Point a, const Point b, const Point c) { //得到三角形外接圆的圆心
    Point center;
    double a1 = b.x - a.x;
    double b1 = b.y - a.y;
    double c1 = (a1 * a1 + b1 * b1) / 2.0;
    double a2 = c.x - a.x;
    double b2 = c.y - a.y;
    double c2 = (a2 * a2 + b2 * b2) / 2.0;
    double d = a1 * b2 - a2 * b1;
    center.x = a.x + (c1 * b2 - c2 * b1) / d;
    center.y = a.y + (a1 * c2 - a2 * c1) / d;
    return center;
}
//p表示定点, n表示顶点的个数, c代表最小覆盖圆圆心, r是半径
//找最小覆盖圆(这里没有用全局变量p[], 因为是为了封装一个函数便于调用)
void min_cover_circle(Point *p, int n, Point &c, double &r) { 
    random_shuffle(p, p + n);//随机函数,使用了之后使程序更快点
    c = p[0];
    r = 0;
    for (int i = 1; i < n; i++) {
        if (Sgn(dist(p[i], c) - r) > 0) { //如果p[i]在当前圆的外面, 那么以当前点为圆心开始找
            c = p[i];//圆心为当前点
            r = 0;//这时候这个圆只包括他自己.所以半径为0
            for (int j = 0; j < i; j++) { //找它之前的所有点
                //如果之前的点有不满足的, 那么就是以这两点为直径的圆
                if (Sgn(dist(p[j], c) - r) > 0) { 
                    c.x = (p[i].x + p[j].x) / 2.0;
                    c.y = (p[i].y + p[j].y) / 2.0;
                    r = dist(p[j], c);
                    for (int k = 0; k < j; k++) {
                        //找新作出来的圆之前的点是否还有不满足的, 如果不满足一定就是三个点都在圆上了
                        if (Sgn(dist(p[k], c) - r) > 0) { 
                            c = get_circle_center(p[i], p[j], p[k]);
                            r = dist(p[i], c);
                        }
                    }
                }
            }
        }
    }
}
int main() {
    int n, x, y;
    Point c;
    double r;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> p[i].x >> p[i].y;
    min_cover_circle(p, n, c, r);
    printf("%.10f\n", r);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

int main()
{
    int n, k;
    int h[100000];
    cin >> n >> k;
    rep(i, n) cin >> h[i];

    int ans = 0;
    rep(i, n) {
        if (h[i] >= k) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
from decimal import Decimal
import math

if __name__ == "__main__":
    a, b, h, m = map(float, input().split())
    #d = Decimal(7/3)
    pi = Decimal(math.pi)
    a = Decimal(a)
    b = Decimal(b)
    h = Decimal(h)
    m = Decimal(m)
    ang = pi / 30 * (m) - pi / 6 * ((h) + (m)/60)
    c = ( a**2 + b**2 - 2*a*b*Decimal(math.cos(ang)) )**Decimal(0.5)
    print(c)

Measured memory_bytes: 10396
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

struct arm{
    int x;
    int l;
};

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

    int n;
    cin >> n;
    vector<arm> arms(n);
    for(int i=0; i<n; i++){
        cin >> arms[i].x >> arms[i].l;
    }

    sort(ALL(arms), [](arm a1, arm a2){ return a1.x < a2.x; });

    int mark = 0;
    int cnt = 0;
    for(int i=1; i<n; i++){
        if(arms[i].x - arms[i].l < arms[mark].x + arms[mark].l){
            cnt++;
            if(arms[mark].x + arms[mark].l > arms[i].x + arms[i].l){
                mark = i;
            }
        }else{
            mark = i;
        }
    }

    COUT(n - cnt);

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
int x1,x2;
scanf("%d %d",&x1,&x2);
if(x1>x2){
	printf("%d\n",x1-x2);
}
if(x2>x1){
	printf("%d\n",x2-x1);
}
if(x1==x2)
	printf("0\n");
return 0;
}



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

using namespace std;

using ll = long long;

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

    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for (int i = 0; i < n; ++i) cin >> s[i];
    sort(s.begin(), s.end());

    for (int i = 0; i < n; ++i) cout << s[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(int x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
const int maxn=1e5,maxk=2000;
int n,kk;
int B[maxk+5][maxk+5],W[maxk+5][maxk+5];
int S(int x, int y, int c)
{
    int x1=max(x-kk+1,1),y1=max(y,1);
    int x2=min(x,kk*2),y2=min(y+kk-1,kk*2);
    if(x1>x2||y1>y2) return 0;
    if(c==0) return B[x2][y2]-B[x1-1][y2]-B[x2][y1-1]+B[x1-1][y1-1];
    return W[x2][y2]-W[x1-1][y2]-W[x2][y1-1]+W[x1-1][y1-1];
}
int main()
{
    n=ri(),kk=ri();
    char str[5];
    int i,k,ans=0,x,y,ti,tj,ii,jj,tmp1,tmp2;
    for(i=1;i<=n;++i)
    {
	x=ri(),y=ri();
        scanf("%s",str);
        ++x,++y;
        x%=kk*2, y%=kk*2;
        if(x==0) x+=kk*2;
        if(y==0) y+=kk*2;
        if(str[0]=='B') ++B[x][y];
        else ++W[x][y];
    }
    for(i=1;i<=kk*2;++i)
        for(k=1;k<=kk*2;++k)
        {
            W[i][k]+=W[i-1][k]+W[i][k-1]-W[i-1][k-1];
            B[i][k]+=B[i-1][k]+B[i][k-1]-B[i-1][k-1];
        }
    ans=0;
    for(i=1;i<=kk+1;++i)
    {
        for(k=1;k<=kk+1;++k)
        {
            tmp1=0,tmp2=0;
            ti=i-kk,tj=k-kk*2;
            for(ii=0;ii<4;++ii)
                for(jj=0;jj<4;++jj)
		{
                    tmp1+=S(ti+kk*ii,tj+kk*jj,(ii+jj)&1);
                    tmp2+=S(ti+kk*ii,tj+kk*jj,((ii+jj)&1)^1);
                }
            ans=max(ans,max(tmp1,tmp2));
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 31616
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from functools import lru_cache
from heapq import heappop,heappush
import time
import sys
input=readline = sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s

#main
s=input()
Q=int(input())
l=""
r=""
count=0
for a in range(Q):
    tmp=input().split()
    if tmp[0]=="1":
        count+=1
    else:
        if tmp[1]=="1":
            if(count%2==0):l=tmp[2]+""+l
            else:r+=tmp[2]
        else:
            if(count%2==0):r+=tmp[2]
            else:l=tmp[2]+""+l
s=l+s+r
s=s.replace("\n","")
if(count%2==1):
    s=s[::-1]
print(s)



Measured memory_bytes: 6672