akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.ascii;

void main() {
    int n;
    scan(n);

    foreach (i ; 0 .. n) {
        string s1,s2;
        scan(s1, s2);
        writeln(i2m(m2i(s1) + m2i(s2)));
    }
}

int m2i(string s) {
    int res;
    int[char] t = ['m':1000, 'c':100, 'x':10, 'i':1];

    while (!s.empty) {
        if (s[0].isDigit) {
            res += (s[0] - '0') * t[s[1]];
            s.popFrontN(2);
        }
        else {
            res += t[s[0]];
            s.popFront;
        }
    }

    return res;
}

string i2m(int x) {
    char[] res;
    char[int] t = [3:'m', 2:'c', 1:'x', 0:'i'];

    int d;

    while (x > 0) {
        int r = x % 10;

        if (r > 0) {
            res ~= t[d];
        }
        if (r > 1) {
            res ~= r + '0';
        }

        x /= 10;
        d++;
    }

    res.reverse();

    return res.to!string;
}

void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

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

  ll N;
  std::cin >> N;
  std::string s;
  std::cin >> s;

  ll cnt = 0LL;
  for (auto c : s) {
    cnt += c == 'R' ? +1 : -1;
  }

  std::string judge = cnt > 0 ? "Yes" : "No";
  std::cout << judge << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i, n, count = 0;
    char s[50];
    
    scanf("%d", &n);
    scanf("%s", s);
    
    for( i = 0; i < n; i++ ){
        if( s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C' ){
            count++;
        }
    }
    
    printf("%d\n", count);
    return 0;
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


using Graph = vector<vector<int>>;

template< typename G >
struct SCC {
    const G &g;
    Graph gg, rg;
    vector< int > comp, order, used;

    SCC(G &g) : g(g), gg(g.size()), rg(g.size()), comp(g.size(), -1), used(g.size()) {
        for (int i = 0; i < g.size(); i++) {
            for (auto e : g[i]) {
                gg[i].emplace_back((int) e);
                rg[(int) e].emplace_back(i);
            }
        }
    }

    int operator[](int k) {
        return comp[k];
    }

    void dfs(int idx) {
        if (used[idx]) return;
        used[idx] = true;
        for (int to : gg[idx]) dfs(to);
        order.push_back(idx);
    }

    void rdfs(int idx, int cnt) {
        if (comp[idx] != -1) return;
        comp[idx] = cnt;
        for (int to : rg[idx]) rdfs(to, cnt);
    }

    void build(Graph &t) {
        for (int i = 0; i < gg.size(); i++) dfs(i);
        reverse(begin(order), end(order));
        int ptr = 0;
        for (int i : order) if (comp[i] == -1) rdfs(i, ptr), ptr++;

        t.resize(ptr);
        for (int i = 0; i < g.size(); i++) {
            for (auto &to : g[i]) {
                int x = comp[i], y = comp[to];
                if (x == y) continue;
                t[x].push_back(y);
            }
        }
    }
};

int main() {
    int V, E, Q;
    cin >> V >> E;
    Graph g(V), buff;
    for (int i = 0; i < E; i++) {
        int a, b; cin >> a >> b;
        g[a].emplace_back(b);
    }
    SCC<Graph> scc(g);
    scc.build(buff);
    cin >> Q;
    while (Q--) {
        int a, b; cin >> a >> b;
        puts(scc[a] == scc[b] ? "1" : "0");
    }
}


Measured memory_bytes: 5044
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define ft first
#define sd second
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)


using edge = struct {int to; ll cost;};
vector<edge> tree[100010];
ll depth[100010];

void dfs(int v, int p, ll d){
    depth[v] = d;
    for(auto &e : tree[v]){
        if(e.to == p) continue;
        dfs(e.to, v, d + e.cost);
    }
}

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

    fr(i,n-1){
        int a,b,c;cin>>a>>b>>c;
        a--;b--;
        tree[a].pb({b, c});
        tree[b].pb({a, c});
    }

    int q,k;cin>>q>>k;
    k--;

    dfs(k,-1,0);
    fr(i,q){
        int x,y;
        cin>>x>>y;
        x--;y--;
        cout<< depth[x]+depth[y] <<endl;
    }

}

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

using namespace std;

const int N=20,M=33005,inf=0x3F3F3F3F;

int n,m,ec[N][N],ans=inf,U;
int dp[M][N],sc[N][M],g[M];
bool ok[N][M];

int find(int*fa,int x){return fa[x]==x?x:fa[x]=find(fa,fa[x]);}
bool judge(int u,int S){
	if(S>>u&1)return -1;
	static int fa[N];
	static bool vi[N],ok[N];
	for(int i=0;i<n;i++)fa[i]=i,vi[i]=ok[i]=0;
	for(int i=0;i<n;i++)if(S>>i&1)for(int j=i+1;j<n;j++)if(S>>j&1)fa[find(fa,i)]=find(fa,j);
	for(int i=0;i<n;i++)if(S>>i&1){int k=find(fa,i);vi[k]=true;if(!ec[u][i])continue;ok[k]=true;}
	for(int i=0;i<n;i++)if(vi[i]&&!ok[i])return false;
	return true;
}

inline void upd(int&x,int y){x<y?:x=y;}

inline int sumcost(int S,int T){
	int res=0;
	for(int i=0;i<n;i++)if(S>>i&1)res+=sc[i][T];
	return res;
}

// O(3^n * n^2)

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,u,v,c;i<=m;i++)scanf("%d%d%d",&u,&v,&c),u--,v--,ec[u][v]=ec[v][u]=c;
	U=(1<<n)-1;
	for(int i=0;i<n;i++)for(int j=0;j<=U;j++)ok[i][j]=judge(i,j);
	for(int i=0;i<n;i++)for(int j=0;j<=U;j++)for(int k=0;k<n;k++)if(j>>k&1)sc[i][j]+=ec[i][k];
	memset(dp,0x3F,sizeof(dp));
	for(int S=1;S<=U;S+=2)if(ok[0][S^1])dp[S][0]=0;
	for(int S=0;S<=U/2;S++)for(int u=0;u<n;u++)if(dp[S][u]!=inf){
		for(int K=U-S,T=K;T;T=(T-1)&K)g[T]=sumcost(S,T);
		for(int v=0;v<n;v++)if(~S>>v&1){
			if(!ec[u][v])continue;
			int T=U-S-(1<<v),cur=sc[v][S^(1<<u)];
			for(int z=T;z;z=(z-1)&T)if(ok[v][z])
				upd(dp[S|1<<v|z][v],dp[S][u]+cur+g[z]);
			upd(dp[S|1<<v][v],dp[S][u]+cur);
		}
	}
	for(int S=U/2+1;S<=U;S++)if(dp[S][n-1]!=inf)upd(ans,dp[S][n-1]+sumcost(S,U^S));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6016
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>
#include <cmath>
#include <cstdio>

int main(void)
{
  int w, n;

  std::cin >> w >> n;

  std::vector<int> base;
  for (int i = 0; i < w; i++) {
    base.push_back(i + 1);
  }

  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d,%d", &a, &b);
    std::swap(base[a - 1], base[b - 1]);
  }

  for (int i = 0; i < w; i++) {
    std::cout << base[i] << std::endl;
  }

  return 0;
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;

int all,n,now,w;

int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>all>>n;
  for(int i = 1;i <= n;i++){
    cin>>now;
    w += now;
  }
  int ans = all - w;
  if(ans < 0) cout<<"-1"<<endl;
  else cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3652
fn main() {
    loop {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.trim().split_whitespace();
        let h: i32 = iter.next().unwrap().parse().unwrap();
        let w: i32 = iter.next().unwrap().parse().unwrap();

        if h == 0 && w == 0 {
            break;
        }
        for line_h in 0..h {
            for line_w in 0..w {
                if (line_h + line_w) % 2 == 0 {
                    print!("#");
                } else {
                    print!(".");
                }
            }
            println!();
        }
        println!();
    }
}



Measured memory_bytes: 5020
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

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

// template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
#define int ll

const int N = 2e5 + 5;
const int oo = 1e9 + 5;

void solve() {
	unsigned long long n, m;
	cin >> n >> m;
	if (n == 1 || m == 1) {
		cout << 1;
		return;
	}
	cout << (n * m) - ((n * m) / 2);
}

 main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	while (tt --) {
		solve();
	}
	return 0;
}
/*
	If you only do what you can do, 
	You will never be more than you are now!
*/

Measured memory_bytes: 256
<?php
list($n, $k) = ints();
$d = ints();
for ($i = $n; true; ++$i) {
    foreach ($d as $dd) if (strpos((string) $i, (string) $dd) !== false) continue 2;
    break;
}
echo $i;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  if(N==10||N==100||N==1000||N==10000||N==100000)
  {
    cout << 10 << endl;
    return 0;
  }
  int ans = 0;
  while(N>0)
  {
    ans += N%10;
    N /= 10;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main()
{
	char c;
	scanf("%c",&c);

	switch(c)
	{
		case 'a':
		case 'e':
		case 'i':
		case 'o':
		case 'u':
			printf("vowel");
			break;
		default:
			printf("consonant");
			break;
	}

	return 0;
}

Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=1e5+20;

int n,k;
vector<int>p,q,invp,invq;

inline vector<int> Get_Inversion(vector<int>p)
{
	static vector<int>invp(n+1);
	REP(i,1,n)invp[p[i]]=i;
	return invp;
}

inline vector<int> operator *(vector<int>p,vector<int>q)
{
	REP(i,1,n)p[i]=q[p[i]];
	return p;
}

inline void init()
{
	n=read();k=read(); p.resize(n+1); q.resize(n+1);
	REP(i,1,n)p[i]=read();
	REP(i,1,n)q[i]=read();
	invp=Get_Inversion(p); invq=Get_Inversion(q);
}

inline vector<int>power(vector<int>a,int b)
{
	static int vis[maxn];
	memset(vis,0,sizeof(int)*(n+1));
	REP(i,1,n)if(!vis[i])
	{
		static int st[maxn]; int top=0;
		for(int j=i;!vis[j];j=a[j])vis[j]=1,st[top++]=j;
		//int turn=b%top;
		REP(j,0,top-1)a[st[j]]=st[(j+b)%top];
	}
	return a;
}

inline void doing()
{
	vector<int>A=invq*p*q*invp,invA=Get_Inversion(A);
	vector<int>f[8];
	f[1]=p; f[2]=q;
	REP(i,3,6)f[i]=Get_Inversion(f[i-2])*f[i-1];
	int tk=(k-1)/6,rest=k-tk*6;
	A=power(A,tk); invA=power(invA,tk);
	vector<int>debug=Get_Inversion(A);
	vector<int>ans=A*f[rest]*invA;
	REP(i,1,n)printf("%d ",ans[i]);
}

int main()
{
	init();
	doing();
	return 0;
}


Measured memory_bytes: 8184
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;

char inp[5005];
int K;
int cnt[200];
map<string,bool> mp;
vector<string> v;
int main(){
    scanf("%s %d",inp+1,&K); 
    int N=strlen(inp+1);
    for(int i=1;i<=N;i++){
        string x="";
        for(int j=i;j<=N;j++){
            x+=inp[j];
            if(mp.size()<K || (mp.size() && mp.rbegin()->first > x)){
                mp[x]=1;
            }
            if(mp.size()>K) mp.erase(prev(mp.end()));
        }
    }
    printf("%s",mp.rbegin()->first.data());
}

Measured memory_bytes: 256
H,W = map(int, input().split())
S = [input() for _ in range(H)]

dp = [[10**6]*(H*W) for _ in range(H*W)]
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            continue
        p = W*i+j
        if i > 0 and S[i-1][j] == ".":
            dp[p][p-W] = 1
            dp[p-W][p] = 1
        if i < H-1 and S[i+1][j] == ".":
            dp[p][p+W] = 1
            dp[p+W][p] = 1
        if j > 0 and S[i][j-1] == ".":
            dp[p][p-1] = 1
            dp[p-1][p] = 1
        if j < W-1 and S[i][j+1] == ".":
            dp[p][p+1] = 1
            dp[p+1][p] = 1

for i in range(H*W):
    dp[i][i] = 0
for k in range(H*W):
    for i in range(H*W):
        for j in range(H*W):
            dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j])

ans = 0
for i in range(H*W):
    for j in range(H*W):
        if dp[i][j] == 10**6:
            continue
        ans = max(ans, dp[i][j])
            
print(ans)

Measured memory_bytes: 74836
import math
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
p1 = p2 = p3 = p = 0
for x,y in zip(x,y):
    d = abs(x-y)
    p1 += d
    p2 += d**2
    p3 += d**3
    if d>p: p = d
print('{0:.5f}\n{1:.5f}\n{2:.5f}\n{3:.5f}'.format(p1,math.sqrt(p2),math.pow(p3,1/3),p))



Measured memory_bytes: 5700
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b>=c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3612
#include   <stdio.h>

int   main(void)

{

   int a,b,c,x=0;

   scanf("%d %d %d",&a,&b,&c);

   if(a>b){

      x=a;

      a=b;

      b=x;

   }

   if(a>c){

      x=a;

      a=c;

      c=x;

   }

   if(b>c){

      x=b;

      b=c;

      c=x;

   }

   printf("%d %d %d\n",a,b,c);

   return 0;

}

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

const int MAX = 1010101;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(auto &e : A) cin >> e;
    sort(A.begin(), A.end());
    vector<bool> ok(MAX, true);
    vector<int> cnt(MAX);
    for(auto &a : A) {
        if(!ok[a]) continue;
        if(cnt[a]) ok[a] = false;
        for(int i = a * 2; i < MAX; i += a) {
            ok[i] = false;
        }
        cnt[a]++;
    }
    int ans = 0;
    for(auto &a : A) {
        if(ok[a]) ans++;
    }
    cout << ans << '\n';
    return 0;
}


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

using namespace std;
using ll = long long int;
#define long ll

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

    ll n;
    cin >> n;
    ll px = 0, py = 0, pt = 0;
    while(n--) {
        ll t, x, y;
        cin >> t >> x >> y;
        ll dt = t - pt;
        ll tt = abs(y - py) + abs(x - px);
        if(dt < tt || (tt^dt)&1) {
            cout << "No" << endl;
            return 0;
        }
        px = x, py = y, pt = t;
    }
            cout << "Yes" << endl;
            return 0;
}


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

int main(void){
    long n;
    int i;
    vector <long> L_number;
    long x;
    long l0 = 2;
    long l1 = 1;
    L_number.push_back(l0);
    L_number.push_back(l1);
    
    cin >> n;
    
    for(i = 2; i <= n; i++){
        x = L_number[i - 2] + L_number[i - 1];
        L_number.push_back(x);
    }
    
    cout << L_number[n] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define llinf 1e17
#define nllinf -4e18
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll,ll> 
#define vpll vector<pair<ll,ll > > 
#define repup(a,b,i) for(i=a;i<=b;i++)
#define repdown(a,b,i) for(i=b; i>=a; i--)
#define repit(v,it) for(it=v.begin(); it!=v.end(); it++)
#define itall(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
#define err(n) cout<<n<<" ";
#define t1 cout<<",";

void err_mask(ll n){
	if(n==0)return;
	while(n){
		cout<<n%2;
		n/=2;
	}
	cout<<" ";
}
ll MOD= 98244353;

void add_self (ll& a, ll b){
	a+= b;
	a%=MOD;
}

void sub_self (ll& a, ll b){
	a-=b;
	a= ((a%MOD)+MOD)%MOD;
}

ll mul(ll a, ll b){
	a*=b;
	a%=MOD;
	return a;
}

void min_self(double& a, double b){
	a= min(a,b);
}


bool conflict(pll a, pll b){
	if(b.fr> a.sc)return 0;
	else return 1;
}


int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll i,j;

ll n;cin>>n;

ll cnt[1005]={0};
repup(0,n-1,i){
	ll x; cin>>x;
	cnt[x]++;
}
ll pre_cnt[1005];
pre_cnt[0]=cnt[0];
repup(1,1004,i){
	pre_cnt[i]=pre_cnt[i-1]+cnt[i];
}

ll ans=0;
repup(1,1004,i){
	repup(1,i,j){
		ll temp_ans;
		if(i==j){
			temp_ans= cnt[i]*(cnt[i]-1)/2;
			if(j-1>0)ans+= (temp_ans*pre_cnt[i-1]);
			if(cnt[i]>2)ans+= cnt[i]*(cnt[i]-1)*(cnt[i]-2)/6;
			continue;
		}
		temp_ans= cnt[i]*cnt[j];
		
		if(j-1> i-j)ans+= (temp_ans*(pre_cnt[j-1]-pre_cnt[i-j]));
		//if(cnt[i]&&cnt[j]&& j-1> i-j){err(pre_cnt[j-1]-pre_cnt[i-j])err(temp_ans)err(i)err(j)err(temp_ans*(pre_cnt[j-1]-pre_cnt[i-j]))}
		ll temp_2ans=0;
		if(2*j > i){
		ll temp_2ans= cnt[j]* (cnt[j]-1);
		temp_2ans/=2;
		temp_2ans*= cnt[i];
		ans+= temp_2ans;
		}
		
	}
}
cout<<ans<<'\n';
}
	

Measured memory_bytes: 256
import java.util.*;


class Main{
  
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    
    int k = sc.nextInt();
    int s = sc.nextInt();
    int count = 0;
    int z = 0;
    for(int i=0;i<=k;i++){
      for(int j=0;j<=k;j++){
        z = s - i - j;
          if(z>=0&&z<=k){
          	count++;
          }
        }
      }
    System.out.println(count);
  }
}

Measured memory_bytes: 23124
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;

int main(){
	int n,m,x;
	int ans=MOD;
	int c[20];
	int a[20][20];
	cin>>n>>m>>x;
	for(int i=0;i<n;i++)
	{
		cin>>c[i];
		for(int j=0;j<m;j++)
		{
			cin>>a[i][j];
		}
	}
	
	for(int i=0;i<(1 << n);i++)
	{
		vector<int> v;
		bool flag=true;
		int cost=0;
		for(int j=0;j<n;j++)
		{
			if(i & (1 << j))v.push_back(j);
		}
		
		for(int j=0;j<m;j++)
		{
			int rikai=0;
			for(int k=0;k<v.size();k++)
			{
				    rikai+=a[v[k]][j];
			}	
			if(rikai<x){flag=false;break;}
		}
		if(flag)
		{
			for(int j=0;j<v.size();j++)cost+=c[v[j]];
			ans=min(ans,cost);
		}
		
	}
	if(ans==MOD)cout<<-1<<"\n";
	else cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3632
//
// Created by 伊東麻沙美 on 2019/10/22.
//

#include<iostream>
#include<algorithm>
using namespace std;


int main(){

    int a,b;
    cin>>a>>b;

    if(a>b){
        cout<<a+(a-1);
    }
    if(a<b){
        cout<<b+(b-1);
    }
    if(a==b){
        cout<<a+b;
    }


    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
# int(input()) # 入力が1つ
a, b, c = map(int, input().split()) # 入力が複数
nums = sorted([a, b, c])

ans = 0
if (nums[1] - nums[0]) % 2 != 0:
    nums[2] += 1
    nums[1] += 1
    ans += 1
ans += (nums[1] - nums[0]) // 2
ans += nums[2] - nums[1]
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}


//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;

int main(){
 ll A,B,N;cin>>A>>B>>N;
  ll maxr=0;
  if(N/B==0)maxr=N%B;
  else maxr=B-1;
  cout<<(A*maxr)/B<<endl;
  
}






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

using namespace std;

//#define double long double

typedef pair<int,int> ii;
typedef pair<int,long long> il;
typedef pair<long long,long long> ll;
typedef pair<ll,int> lli;
typedef pair<long long,int> li;
typedef pair<double,double> dd;
typedef pair<ii,int> iii;
typedef pair<double,int> di;
typedef pair<int,ii> iii2;
typedef pair<ii,ii> iiii;
long long mod = 1000000007LL;
long long large = 2000000000000000000LL;



int main(){

	int n;
	cin>>n;
	vector<int> c(n,0);
	for(int i=0;i<n;i++){
		scanf("%d",&c[i]);
		c[i]--;
	}

	vector<int> cnt(2000010,0);

	vector<int> dp(n,0);

	cnt[c[0]] = 1;
	for(int i=0;i<n;i++){
		dp[i] = cnt[c[i]];
		dp[i]%=mod;
		if(i+1<n&&c[i]!=c[i+1]){
			cnt[c[i+1]]+=dp[i];
			cnt[c[i+1]]%=mod;
		}
	}
	//for(int i=0;i<n;i++) cout<<i<<" "<<dp[i]<<endl;

	cout<<dp[n-1]<<endl;





	return 0;
}


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

struct Data{
  int x;
  int y;
  int d;

  bool operator<(const Data& right) const{
    return d < right.d;
  }
} ;

int segTree[4][600000];
int segSize;

vector<Data> data;

void init(int n){

  segSize = 1;
  while(segSize < n){
    segSize *= 2;
  }

  for(int i = 0;i < segSize;i++){
    if(i < n){
      segTree[0][segSize+i-1] = data[i].x;
      segTree[1][segSize+i-1] = data[i].x;
      segTree[2][segSize+i-1] = data[i].y;
      segTree[3][segSize+i-1] = data[i].y;
    }else{
      segTree[0][segSize+i-1] = INT_MIN;
      segTree[1][segSize+i-1] = INT_MAX;
      segTree[2][segSize+i-1] = INT_MIN;
      segTree[3][segSize+i-1] = INT_MAX;
    }
  }

  for(int i = segSize-2;i >= 0;i--){
    segTree[0][i] = max(segTree[0][i*2+1],segTree[0][i*2+2]);
    segTree[1][i] = min(segTree[1][i*2+1],segTree[1][i*2+2]);
    segTree[2][i] = max(segTree[2][i*2+1],segTree[2][i*2+2]);
    segTree[3][i] = min(segTree[3][i*2+1],segTree[3][i*2+2]);
  }

  return;
}

int x_max(int a,int b,int l, int r, int k){
  if(r <= a || b <= l){
    return INT_MIN;
  }

  if(a <= l && r <= b){
    return segTree[0][k];
  }

  return max(x_max(a,b,l,(l+r)/2,k*2+1),x_max(a,b,(l+r)/2,r,k*2+2));
}

int x_min(int a,int b,int l, int r, int k){
  if(r <= a || b <= l){
    return INT_MAX;
  }

  if(a <= l && r <= b){
    return segTree[1][k];
  }

  return min(x_min(a,b,l,(l+r)/2,k*2+1),x_min(a,b,(l+r)/2,r,k*2+2));
}

int y_max(int a,int b,int l, int r, int k){
  if(r <= a || b <= l){
    return INT_MIN;
  }

  if(a <= l && r <= b){
    return segTree[2][k];
  }

  return max(y_max(a,b,l,(l+r)/2,k*2+1),y_max(a,b,(l+r)/2,r,k*2+2));
}

int y_min(int a,int b,int l, int r, int k){
  if(r <= a || b <= l){
    return INT_MAX;
  }

  if(a <= l && r <= b){
    return segTree[3][k];
  }

  return min(y_min(a,b,l,(l+r)/2,k*2+1),y_min(a,b,(l+r)/2,r,k*2+2));
}


int main(){

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

  int n,d;

  cin >> n >> d;
  data.resize(n);
  for(int i = 0;i < n;i++){
    cin >> data[i].x >> data[i].y >> data[i].d;
  }

  sort(data.begin(),data.end());

  init(n);

  int mini = 0;
  long long ans = 0;
  for(int i = 1;i < n;i++){
    if(data[i].d - data[mini].d > d){
      ans = max(ans,(long long)(x_max(mini,i,0,segSize,0)-x_min(mini,i,0,segSize,0))
          *(long long)(y_max(mini,i,0,segSize,0)-y_min(mini,i,0,segSize,0)));
      int j;
      for(j = mini+1;j < i;j++){
        if(data[i].d-data[j].d <= d){
          break;
        }
      }
      mini = j;
    }
  }
  ans = max(ans,(long long)(x_max(mini,n,0,segSize,0)-x_min(mini,n,0,segSize,0))
      *(long long)(y_max(mini,n,0,segSize,0)-y_min(mini,n,0,segSize,0)));

  cout << ans << endl;
  return 0;

}


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

int main(){
    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

ll N, K;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> K;
  if (K == 0) {
    cout << N * N << endl;
    return 0;
  }
  ll ans = N * N - K * N;
  for (int i = K + 1; i <= N; i++) {
    ans -= (N / i) * K + min(K - 1, N % i);
  }
  cout << ans << endl;

  return 0;
}

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

int main() {
  ll n,m; cin >> n >> m;
  vector<ll> h(n);
  rep(i, n)
    cin >> h[i];
  
  vector<bool> l(n, true);
  ll cnt = 0;
  rep(i, m){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    
    if(h[a] < h[b]){
      if(l[a] == true){
        l[a] = false;
        cnt++;
      }
    }
    
    else if(h[a] > h[b]){
      if(l[b] == true){
        l[b] = false;
        cnt++;
      }
    }
    
    else{
      if(l[a] == true){
        l[a] = false;
        cnt++;
      }
      if(l[b] == true){
        l[b] = false;
        cnt++;
      }
    }
  }
  
  cout << n - cnt << endl;
}

Measured memory_bytes: 4012
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
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; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    ll H,A;
    cin >> H >> A;

    if(H%A==0) cout << H/A << endl;
    else cout << H/A + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = "hi";
		boolean f = false;
		for(int i = 0 ; i < 10 ; ++i){
			if(S.equals(T)){
				f = true;
			}
			T += "hi";			
		}
		if(f){
			System.out.println("Yes");
		}else{
			System.out.println("No");			
		}
	}
}


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

int main() {
  int A, B, sum = 0;
  cin >> A >> B;
  if (A >= B) {
    sum += A--;
  } else {
    sum += B--;
  }
  if (A >= B) {
    sum += A--;
  } else {
    sum += B--;
  }
  cout << sum;
  return 0;
}

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

using ll = long long;

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    ll a[n]; for (auto &ai:a) cin >> ai;
    for (int i=0; i<n-k; i++) {
        cout << (a[i] < a[i+k] ? "Yes" : "No") << '\n';
    }
    return 0;
}

Measured memory_bytes: 5192
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll h;
	cin >> h;
	ll num = 1;
	ll ans = 0;
	while(h > 0){
		ans += num;
		num *= 2;
		h /= 2;
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
/* *	Argorithms and Data Structures
 *	Lectuire 8 
 *	Binary Search Tree I
 */

#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>

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

void insert (Node *, int);
void print (Node *);
void printInorderTree (Node *);
void printPreorderTree (Node *);

struct Node *NIL, *root;

int main (void) {
	int i, m, k;
	char order[10];

	scanf("%d", &m);
	
	for (i=0; i<m; i++) {
		scanf("%s ", order);
		if( !strcmp ( order, "insert") ){
			scanf("%d", &k);
			insert (root, k);
		}
		else
			print(root);
	}
	return 0;
}

void insert ( Node *T, int key){
	Node *x = root,
		*y = NIL,
		*z;

	z = (Node*) malloc( sizeof(Node) );
	z->key = key;
	z->left = z->right = NIL;

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

	if ( y == NIL)
		root = z;
	else if (z->key < y->key)
		y->left = z;
	else
		y->right = z;
}

void print(Node *T){
	printInorderTree (T);
	printf("\n");
	printPreorderTree (T);
	printf("\n");
}

void printInorderTree (Node* x) {
	if (x != NIL){
		printInorderTree (x->left);
		printf(" %d", x->key);
		printInorderTree (x->right);
	}
}

void printPreorderTree (Node* x) {
	if (x != NIL){
		printf(" %d", x->key);
		printPreorderTree (x->left);
		printPreorderTree (x->right);
	}
}

Measured memory_bytes: 24044
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    string S;
    cin >> S;
    int64_t len = S.size();
    int64_t count = 0;
    int64_t b_count = 0;
    for (int64_t i=0; i<len; i++) {
        if (S[i] == 'W') {
            count += b_count;
        } else {
            b_count += 1;
        }
    }

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

Measured memory_bytes: 3700
n,m = map(int,input().split())
graph = [[] for _ in range(n)]
h = list(map(int,input().split()))
for _ in range(m):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
cnt = 0
for i in range(n):
    if graph[i] == []:
        cnt += 1
        continue
    if max([h[j] for j in graph[i]]) < h[i] : cnt += 1
print(cnt)

Measured memory_bytes: 31072
#include <iostream>



using namespace std;
int main(void){
    int N;
    scanf("%d",&N);
    int ans=0;
    for(int i=0;i<N;i++){int po;
        scanf("%d",&po);
        ans+=po-1;
    }
    printf("%d\n",ans);
    
    return 0;
}


Measured memory_bytes: 256
from collections import deque

n = int(input())
e = [[] for i in range(n)]
for i in range(n-1):
    a, b, c = map(int,input().split())
    a -= 1
    b -= 1
    e[a].append([b, c])
    e[b].append([a, c])

m, k = map(int,input().split())
k -= 1

d = [-1] * n
d[k] = 0
q = deque()
q.append([k, 0])
while q:
    f, cc = q.pop()
    for t, nc in e[f]:
        if d[t] == -1:
            d[t] = cc + nc
            q.append([t, d[t]])

for i in range(m):
    f, t = map(int,input().split())
    f -= 1
    t -= 1
    print(d[f] + d[t])

Measured memory_bytes: 54968
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

int N;
set<string>st;

int main() {
	cin>>N;
	for(int i=0;i<N;i++){
		string s;
		cin>>s;
		st.insert(s);
	}
	cout<<(int)st.size()<<endl;
	return 0;
}



Measured memory_bytes: 19252
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int X,A;
  cin>>X>>A;
  cout<<(X<A?0:10)<<endl;
  return 0;
}


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

using namespace std;

const int N = (int) 1e5 + 10;

int n;
int p[N], p1[N];

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i], p1[i] = p[i];;
  int ans = 0, ans1 = 0;
  for (int i = 1; i <= n - 1; i++) 
    if (p[i] == i) {
      ans++;
      swap(p[i], p[i + 1]);
    }
  if (p[n] == n) ans++;
  cout << ans;
  return 0;
}

Measured memory_bytes: 1024
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#define rep(i, x) for (int i = 0; i < (x); ++i)
#define rng(i, x, y) for (int i = (x); i < (y); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

// Main Code
int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    
    auto f = [&](double X) -> double {
        double left = -2000, right = 2000;
        rep(_, 200) {
            double mid1 = left + (right - left) / 3, mid2 = right - (right - left) / 3;
            double res1 = 0, res2 = 0;
            rep(i, n) {
                chmax(res1, sqrt((X - x[i]) * (X - x[i]) + (mid1 - y[i]) * (mid1 - y[i])));
                chmax(res2, sqrt((X - x[i]) * (X - x[i]) + (mid2 - y[i]) * (mid2 - y[i])));
            }
            if (res1 < res2) right = mid2;
            else left = mid1;
        }
        double res = 0;
        rep(i, n) chmax(res, sqrt((X - x[i]) * (X - x[i]) + (right - y[i]) * (right - y[i])));
        return res;
    };
    
    double left = -2000, right = 2000;
    rep(_, 200) {
        double mid1 = left + (right - left) / 3, mid2 = right - (right - left) / 3;
        if (f(mid1) < f(mid2)) right = mid2;
        else left = mid1;
    }
    
    cout << fixed << setprecision(10) << f(right) << "\n";
    return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    string s;
    cin >> s;
    rep(i,s.size())cout << 'x';
    cout << endl;
    return 0;
}
 
 


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

typedef long long int ll;

const int N = 444;
const ll inf = 1e18;

vector<ll> a;
ll dp[N][N], w[N];

inline ll qry(int i, int j)
{
  ll l = 0;
  if(i > 0) l = w[i-1];
  return w[j] - l;
}

ll f(int i, int j)
{
  //~ cerr << i << ' ' << j << endl;
  if(~dp[i][j]) return dp[i][j];
  
  ll& ans = dp[i][j];
  
  if(i >= j) return ans = 0;
  
  ans = inf;
  for(int k=i;k<j;++k)
  {
    ans = min(ans, f(i, k) + f(k+1, j) + qry(i, j));
  }
  
  return ans;
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  
  int n;
  cin >> n;
  a = vector<ll> (n);
  for(ll& i: a) cin >> i;
  
  w[0] = a[0];
  for(int i=1;i<n;++i)
    w[i] = w[i-1] + a[i];
  memset(dp, -1, sizeof dp);
  
  cout << f(0, n-1) << endl;
  
  return 0;
}


Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt(), H = sc.nextInt(), N = sc.nextInt();
		int[][] map = new int[W][H];
		for(int i = 0; i < W; i++) Arrays.fill(map[i], 0);
		for(int i = 0; i < N; i++) {
			int x = sc.nextInt(), y = sc.nextInt(), a = sc.nextInt();
			if(a == 1) {
				for(int j = 0; j < x; j++) {
					for(int k = 0; k < H; k++) map[j][k] = -1;
				}
			}else if(a == 2) {
				for(int j = x; j < W; j++) {
					for(int k = 0; k < H; k++) map[j][k] = -1;
				}
			}else if(a == 3) {
				for(int j = 0; j < W; j++) {
					for(int k = 0; k < y; k++) map[j][k] = -1;
				}
			}else {
				for(int j = 0; j < W; j++) {
					for(int k = y; k < H; k++) map[j][k] = -1;
				}
			}
		}
		int cnt = 0;
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(map[j][i] == 0) cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=5001;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 
 
 
 
int main()
{
  int k;
  cin>>k;
  ll int an=0;
  fo(i,1,k+1)
  fo(j,1,k+1)
  fo(z,1,k+1)
  {
	  int u=__gcd(j,z);
	  an+=__gcd(i,u);
  }
  cout<<an;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int x = 0,ans = 0;
  rep(i,0,n){
    if(s[i] == 'I') x++;
    else x--;
    ans = max(ans,x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3532
#include <iostream>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>

#define rep(i,n)	for(int i = 0;i < n;i++)
#define rep2(i,n)	for(int i = 1;i <= n;i++)
#define each(i,x)	for(auto & i : x)

using namespace std;

int main()
{
	vector<vector<int>> ary;
	while(!feof(stdin))
	{
		vector<int> vec(4);
		rep(i,4)
		{
			cin >> vec[i];
		}
		ary.push_back(vec);
	}
	int len = ary.size()/2;
	rep(i,len)
	{
		vector<int> a = ary[i*2];
		vector<int> b = ary[i*2+1];
		int hit = 0;
		rep(j,4)
		{
			if(a[j] == b[j])
				hit++;
		}
		sort(b.begin(),b.end());
		int blow = -hit;
		rep(j,4)
		{
			auto it = find(b.begin(),b.end(),a[j]);
			if(it != b.end())
			{
				blow++;
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
//
//  main.cpp
//  ABC_169_E
//
//  Created by Joe Mori on 2020/06/02.
//  Copyright © 2020 Joe Mori. All rights reserved.
//

#include <iostream>
#include<vector>
#include<algorithm>
//#include<bits/stdc++.h>

int main() {
    long long int N;
    long long int count=0;
    std::cin>>N;
    std::vector<long long int>a(N),b(N);
    for(long long int i=0;i<N;i++){
        std::cin>>a[i]>>b[i];
    }
    std::sort(a.begin(),a.end());
    std::sort(b.begin(),b.end());
//    std::cout<<b[N/2]<<std::endl;
   /* for(long long int i=0;i<N;i++){
        std::cout<<"a:"<<a[i]<<" b:"<<b[i]<<std::endl;
    }*/
    if(N%2==0){
        if((b[N/2]-b[N/2-1])%2!=0){
            b[N/2]=b[N/2]+1;
            count--;
//            std::cout<<b[N/2]<<std::endl;
        }
        if((a[N/2]-a[N/2-1])%2!=0){
            a[N/2]=a[N/2]+1;
            count++;
        }
        count=count+2*((b[N/2]+b[N/2-1])/2-(a[N/2]+a[N/2-1])/2)+1;
    }else{
        count=1+(b[(N-1)/2]-a[(N-1)/2]);
    }
 /*   for(long long int i=0;i<N;i++){
        std::cout<<"a:"<<a[i]<<" b:"<<b[i]<<std::endl;
    }
    std::cout<<(b[N/2]+b[N/2-1])/2<<std::endl;
    std::cout<<(a[N/2]+a[N/2-1])/2<<std::endl;*/
    std::cout<<count<<std::endl;
    return 0;
}


Measured memory_bytes: 6420
#include<bits/stdc++.h>
using namespace std;
#define N 1000000
#define pb push_back
#define mp make_pair
#define int long long
 
int32_t main()
{
    int n,k,x;
    cin>>n;
    int v[n+1];
    v[0]=0;
    for(int i=1;i<=n;i++) {cin>>v[i];}
    int dp[n+1];
    memset(dp,N,sizeof(dp));
    dp[0]=0;
    dp[1]=0;
    for(int i=1;i<=n;i++)
    {
    	for(int j:{i+1,i+2})
    	{
    		if(j<=n)
    		{
    			dp[j]=min(dp[j],dp[i]+abs(v[j]-v[i]));
    		}
    	}
    	
      }
    cout<<dp[n];
    return 0;
 
}

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

int main(){
    long long a,b,c,k,ans = 0;
    cin >> a >> b >> c >> k;
    long long total = a + b + c;
  	if(k >= total)cout << a - c << endl;
    else{
        int some = 0;
        some = k - a;
        if(some > 0){
          	ans = a;
            for(long long i = 0; i < some;i++){
                if(b != 0)b--;
              	else if(b == 0 && c != 0){
                    ans--;
                    c--;
                }
            }
        }
      	else ans = k;
        cout << ans  << endl;
    }
}

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

#define pb push_back
#define F first
#define S second
#define y1 dasdasfasfas
#define x1 wqdadfasfasfas
#define All(c) c.begin(), c.end()
#define SZ(A) (int((A).size()))
#define umap unordered_map
#define __ fflush(stdout)
#define FILENAME ""

typedef long long ll;
typedef long double ld;    

using namespace std;

void FREOPEN() {
	#ifdef LOCAL
		freopen(".in", "r", stdin);
		freopen("1.out", "w", stdout);
	#else
		//freopen(FILENAME".in", "r", stdin);
		//freopen(FILENAME".out", "w", stdout);
	#endif
}

inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; }             

const int N = 3001, inf = 1e9 * 2;

const ll MOD = 1e9 + 7ll, INF = 1e18;

const int dx[] = {1, -1, 0, 0, -1, 1, -1, 1};
const int dy[] = {0, 0, 1, -1, -1, 1, 1, -1};

ll dp[N][N];

bool was[N][N];

int a[N];

ll solve(int l, int r, int player) {
	if (was[l][r]) return dp[l][r];
	was[l][r] = 1;
	if (l == r) {
		if (player) return dp[l][r] = -a[l];
		else return dp[l][r] = a[l];
	}
	if (!player) {
		dp[l][r] = max(solve(l + 1, r, 1) + a[l], solve(l, r - 1, 1) + a[r]);
	}
	else {
		dp[l][r] = min(solve(l + 1, r, 0) - a[l], solve(l, r - 1, 0) - a[r]);
	}
	return dp[l][r];
}

int main() {
	FREOPEN();
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) scanf("%d ", &a[i]);
	printf("%lld ", solve(1, n, 0));
	return 0;
}


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

int main() {
  int n, q;
  cin >> n >> q;
  string s ;
  cin >> s;
  vector<int> dp(n+1);
  for (int i = 0; i < n; i++) {
    int tmp;
    if (s.substr(i,2)=="AC") tmp = 1;
    else tmp = 0;
    dp[i+1] = dp[i] + tmp;
  }

  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    cout << dp[r-1] - dp[l-1] << endl;;
  }
  return 0;
}

Measured memory_bytes: 3852