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

using namespace std;

#define MAXN 150

int rx[MAXN], ry[MAXN];
int bx[MAXN], by[MAXN];


class MCMF {
public:
	struct Edge
	{
		int t, c, w, r;
		Edge(int _t, int _c, int _w, int _r): t(_t), c(_c), w(_w), r(_r) {};
	};

	const int inf;
	int n, s, t;
	vector<int> pot, prv, dist, vis;
	vector<vector<Edge> > edge;
	// n number of nodes (0..n-1)
	MCMF(int n, int s, int t)
	:n(n), s(s), t(t), pot(n), prv(n), dist(n), vis(n), edge(n), inf(numeric_limits<int>::max())
	{
	}
	// u -> v, c cap, w cost (0 <= u, v < n)
	void add_edge(int u, int v, int c, int w)
	{
		Edge a(v,c,w,edge[v].size()), b(u,0,-w,edge[u].size());
		edge[u].push_back(a);
		edge[v].push_back(b);
	}
	pair<int, int> solve()
	{
		fill(pot.begin(), pot.end(), 0);
		int mf = 0, mc = 0;

		// node potential initialization for negative cycle
		fill(pot.begin(), pot.end(), inf);
		pot[s] = 0;
		for (int rnd = 0; rnd < n-1; rnd++) {
			for (int v = 0; v < n; v++) {
				for (int i = 0; i < edge[v].size(); i++) {
					Edge e = edge[v][i];
					if (e.c == 0)
						continue;
					int u = e.t;
					int ndist = pot[v] + e.w;
					if (pot[u] > ndist) {
						pot[u] = ndist;
					}
				}
			}
		}

		while (true) {
			priority_queue<pair<int, int> > pq;
			fill(dist.begin(), dist.end(), inf);
			fill(vis.begin(), vis.end(), 0);
			pq.push(make_pair(0, s));
			dist[s] = 0;
			while (!pq.empty()) {
				pair<int, int> top = pq.top();
				pq.pop();
				int v = top.second, c = -top.first;
				if (vis[v]) continue;
				vis[v] = 1;
				for (int i = 0; i < edge[v].size(); ++i) {
					Edge &e = edge[v][i];
					int u = e.t;
					if (e.c == 0) continue;
					int ndist = dist[v] + e.w + pot[v]-pot[u];
					if (ndist < dist[u]) {
						dist[u] = ndist;
						prv[u] = e.r;
						pq.push(make_pair(-ndist, u));
					}
				}
			}
			int v = t;
			if (dist[t] == inf) break;
			int flow = inf;
			for (int i = 0; i < n; ++i) pot[i] += dist[i];
			while (v != s) {
				Edge &r = edge[v][prv[v]], &e = edge[r.t][r.r];
				flow = min(flow, e.c);
				v = r.t;
			}
			mf += flow;
			v = t;
			while (v != s) {
				Edge &r = edge[v][prv[v]], &e = edge[r.t][r.r];
				e.c -= flow;
				r.c += flow;
				mc += e.w * flow;
				v = r.t;
			}
		}
		return make_pair(mf, mc);
	}
};

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &rx[i], &ry[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &bx[i], &by[i]);
	}
	int s = 2*n, t = 2*n+1;
	MCMF mcmf(2*n+2, s, t);
	for (int i = 0; i < n; i++) {
		mcmf.add_edge(s, i, 1, 0);
		mcmf.add_edge(n+i, t, 1, 0);
		for (int j = 0; j < n; j++) {
			if (rx[j] < bx[i] && ry[j] < by[i])
				mcmf.add_edge(i, n+j, 1, 0);
		}
	}
	printf("%d\n", mcmf.solve().first);
	return 0;
}


Measured memory_bytes: 384
x, k, d = map(int, input().split())

n = abs(x) // d
if k - n <= 0:
    print(abs(x)-k*d)
elif (k-n) % 2 == 0:
    print(abs(x) - n * d)
else:
    print(abs(abs(x)-n*d-d))


Measured memory_bytes: 9072
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) 
{ v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i]; }
template<class T, class U> void read_n(vector<pair<T, U>>& v, size_t n)
{ v = vector<pair<T, U>>(n); 
  for (lli i=0; i<n; ++i) cin >> v[i].first >> v[i].second; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n;
vector<lli> a[2];
vector<lli> sum[2];
int main() {
  cin >> n;
  read_n(a[0], n); read_n(a[1], n);
  init_n(sum[0], n); init_n(sum[1], n);
  sum[0][0] = a[0][0]; sum[1][n-1] = a[1][n-1];
  for (lli i=1; i<n; ++i) sum[0][i] = a[0][i] + sum[0][i-1];
  for (lli i=n-2; i>=0; --i) sum[1][i] = a[1][i] + sum[1][i+1];
  lli ans = 0;
  for (lli i=0; i<n; ++i) {
    ans = max(ans, sum[0][i] + sum[1][i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    ll n,a,b;cin>>n>>a>>b;
    ll x;cin>>x;
    ll tmp=x;ll sum=0;
    rep(i,n-1){
        cin>>x;
        sum+=min(b,a*(x-tmp));
        tmp=x;
    }
    cout<<sum<<endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int x;

int main() {
	cin >> x;
	if (x<1200) cout << "ABC" << ln;
	else cout << "ARC" << ln;
}

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

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

struct UnionFind {
    vector<ll> par;

    UnionFind(ll N) : par(N) {
        Rep (i, N) par[i] = i;
    }

    ll root (ll x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite (ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same (ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

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

    ll N;
    cin >> N;
    vector<pair<ll, ll>> point(N);
    Rep (i, N) {
        cin >> point[i].first >> point[i].second;
    }

    ll ans = 1e3;

    Rep (i, N) {
        Rep (j, N) {
            if (i == j) continue;
            ll p = point[i].first - point[j].first;
            ll q = point[i].second - point[j].second;
            UnionFind tree(N);
            Rep (k, N) {
                Rep (j, N) {
                    ll yk = point[k].second;
                    ll xk = point[k].first;
                    ll yj = point[j].second;
                    ll xj = point[j].first;
                    if (yk - yj == q && xk - xj == p) {
                        tree.unite(k, j);
                    }
                }
            }
            set<ll> s;
            Rep (k, N) s.insert(tree.root(k));
            ans = min((size_t)ans, s.size());
        }
    }

    if (N == 1) ans = 1;

    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef vector<int> vi;

void rotate(vi& x, vi& y){
    for(int i = 0; i < x.size(); i++){
        swap(x[i], y[i]);
        y[i] *= -1;
    }
}

bool same(vi ax, vi ay, vi bx, vi by){
    for(int i = 0; i < ax.size(); i++){
        if(ax[i] != bx[i])  return false;
        if(ay[i] != by[i])  return false;
    }
    return true;
}

int main(){
    int n, x[10], y[10];

    while(cin >> n, n){
        int t;
        cin >> t;

        for(int i = 0; i < t; i++)  cin >> x[i] >> y[i];

        vi tx, ty;
        for(int i = 1; i < t; i++){
            tx.push_back(x[i]-x[i-1]);
            ty.push_back(y[i]-y[i-1]);
        }

        int m;
        for(int i = 1; i <= n; i++){
            cin >> m;
            for(int j = 0; j < m; j++)  cin >> x[j] >> y[j];
            if(m != t)  continue;

            vi nx, ny;
            for(int j = 1; j < m; j++){
                nx.push_back(x[j]-x[j-1]);
                ny.push_back(y[j]-y[j-1]);
            }

            bool judge = false;
            for(int i = 0; i < 4; i++){
                if(same(tx, ty, nx, ny))    judge = true;
                rotate(nx, ny);
            }
            reverse(nx.begin(), nx.end());
            reverse(ny.begin(), ny.end());
            for(int i = 0; i < 4; i++){
                if(same(tx, ty, nx, ny))    judge = true;
                rotate(nx, ny);
            }

            if(judge) cout << i << endl;
        }

        cout << "+++++" << endl;
    }
    return 0;
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int K;
 int S;
  cin >>K>>S;
  int count=0;
  rep(X,K+1) {
rep(Y,K+1) {
  int Z=S-X-Y;
  if((Z>=0) &&(Z<=K)) {
    count++;
  }
}
  }
cout<<count<< endl;
}
  

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = ReadInts();
            if (a[0] == a[1]) WriteLine(a[2]);
            if (a[1] == a[2]) WriteLine(a[0]);
            if (a[0] == a[2]) WriteLine(a[1]);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VI a,b;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  a=b=VI(n);
  forn(z,n){
    cin>>a[z]>>b[z];
  }
  in sm=0;
  for(in i=n-1;i>=0;--i){
    a[i]+=sm;
    a[i]%=b[i];
    if(a[i])
      sm+=b[i]-a[i];
  }
  cout<<sm<<endl;
  return 0;
}

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

typedef long long ll;

// (a^b)%m
ll exp(ll a, ll b, ll m) {
	ll r=1;
	while(b) {
		if(b%2) r=(r*a)%m;
		a=(a*a)%m;
		b/=2;
	}
	return r;
}

// a^-1 %m, prime m
ll invp(ll a, ll m) {
	return exp(a, m-2, m);
}

const int mx=1e6+777;
const int mod=1e9+7;

vector<int> prime(mx,0);
unordered_map<int, int> max_map;

void sieve() { 
	prime[0] = prime[1] = 1; 
	for (int i = 2; i < mx; i++) { 
		if (prime[i] == 0) { 
			for (int j = i * 2; j < mx; j += i) { 
				if (prime[j] == 0) { 
					prime[j] = i; 
				} 
			} 
			prime[i] = i; 
		} 
	} 
} 

ll get_lcm(vector<ll>& a, int mod) { 
	int n=a.size();
	for (int i = 0; i < n; i++) { 
		ll num = a[i]; 
		unordered_map<int, int> temp; 
		while (num > 1) { 
			int factor = prime[num]; 
			temp[factor]++; 
			num /= factor; 
		} 
		for (auto it : temp)
			max_map[it.first] = max(max_map[it.first], it.second); 
	} 

	ll ans = 1; 
	for (auto it : max_map)
		ans = (ans * exp(it.first, it.second, mod)) % mod; 
	return ans; 
} 

int main() {
	int n; cin>>n;
	sieve();
	vector<ll> a(n);
	ll invsum=0;
	for (int i=0; i<n; i++)
		cin>>a[i], invsum=(invsum+invp(a[i],mod))%mod;
	cout<<(get_lcm(a,mod)*invsum)%mod<<endl;
	return 0;
}

Measured memory_bytes: 4608
#include<iostream>
#include<cstdio>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<utility>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef pair<int,int> pll;
const int maxn= 1e5+10;
const int mod =1e9+7;
const double EPS = 1e-6;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin >> x;
    int num1=x/500;
    int num2=x%500;
    int num3=num2/5;
    cout << (LL)num1*1000+5*num3 << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	int a,b,c,d,e,f,k,l,r,m,n,x,y,z;
	int ans;
	String[] S;

	Main(){
		// 整数の入力
		k = sc.nextInt();
		x = sc.nextInt();

		l = Math.max(x-k+1,-1000000);
		r = Math.min(x+k-1, 1000000);

		// 出力
		for(int i=l;i<=r;i++)
			System.out.print(i+" ");
	}

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

Measured memory_bytes: 21588
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner) = {
    val x, y, z, s = sc.nextInt
    var count = 0
    for (i <- Range(0, x + 1); j <- Range(0, y + 1); k <- Range(0, z + 1)) (if (i * 500 + j * 100 + 50 * k == s) (count += 1))
    println(count)
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}



Measured memory_bytes: 27808
H,W=map(int,input().split())
A=[[int(i) for i in input().split()] for j in range(H)]
B=[[int(i) for i in input().split()] for j in range(H)]
dp=[[0 for j in range(W)] for i in range(H)]
M=161*161
dp[0][0]|=1<<(A[0][0]-B[0][0]+M)
dp[0][0]|=1<<(-A[0][0]+B[0][0]+M)

for i in range(H):
    for j in range(W):
        dij=abs(A[i][j]-B[i][j])
        if i>0:
            dp[i][j]|=dp[i-1][j]<<dij
            dp[i][j]|=dp[i-1][j]>>dij
        if j>0:
            dp[i][j]|=dp[i][j-1]>>dij
            dp[i][j]|=dp[i][j-1]<<dij
ans=[]
for k in range(2*M+1):
    if (1<<k)&dp[-1][-1]!=0:
        ans.append(abs(k-M))
print(min(ans))


Measured memory_bytes: 100728
#include <iostream>
#include <string>

int main() {
  std::string S;
  std::cin >> S;
  int cnt0=0;
  int cnt1=0;
  for(auto &c:S){
    if(c=='0')
      cnt0++;
    else
      cnt1++;
  }
  std::cout << std::min(cnt0,cnt1)*2 << std::endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define N 300010
using namespace std;
typedef unsigned long long ull;
const ull B = 1777771;
string str;
ull H[N],Pow[N];
ull get(int l,int r){return H[r] - H[l]*Pow[r-l];}


int main(){
  Pow[0] = 1;
  for(int i=1;i<N;i++) Pow[i] = Pow[i-1]*B;

  int n,m;
  cin>>n>>m>>str;
  for(int i=0;i<n;i++) H[i+1] = H[i]*B + str[i]-'a'+1;
  
  set<ull> S;
  int l=0,r=0;
  char s[10];
  while(m--){
    scanf("%s",s);
    if(s[0]=='L')l+= s[1]=='+'? 1:-1;
    else r+= s[1]=='+'? 1:-1;
    S.insert(get(l,r+1));
  }

  cout<<S.size()<<endl;
  return 0;
}

Measured memory_bytes: 21968
import java.util.Scanner;

// ALDS1_2_B
public class Main {
        void selectionSort(int[] array, int n) {
                int tmp, minj, count = 0;
                for (int i = 0; i < n; i++) {
                        minj = i;
                        for (int j = i; j < n; j++) {
                                if (array[j] < array[minj]) minj = j;
                        }
                        if (minj != i) {
                                tmp = array[i]; array[i] = array[minj]; array[minj] = tmp;
                                count++;
                        }
                }
                for (int i = 0; i < n; i++) {
                        System.out.print(array[i]);
                        if (i < n - 1) System.out.print(" ");
                }
                System.out.println();
                System.out.println(count);
        }
        
        void run() {
        		Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] array = new int[n];
            for (int i = 0; i < n; i++) {
                    array[i] = sc.nextInt();
            }
            selectionSort(array, n);
        }

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


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

int main() {
	int x,y,i,d;
	int a[1000];
	for(i=0;i<1001;i++)
	{
	    if(i==0)
	    a[i]=300000;
	    else if(i==1)
	    a[i]=200000;
	    else if(i==2)
	    a[i]=100000;
	    else
	    a[i]=0;
	}
	cin>>x>>y;
	if(x==1&&y==1)
	cout<<2*a[0]+400000<<"\n";
	else
	{
	    d=a[x-1]+a[y-1];
	    cout<<d<<"\n";
	}
	return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    ll A[N];
    rep(i, N) {
        cin >> A[i];
    }

    rep(i, N - K) {
        if (A[i] < A[i + K]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5208
def init():
    global factorial
    MOD = 10 ** 9 + 7
    factorial = [0] * 200001
    factorial[0] = 1
    for i in range(1, 200001):
        factorial[i] = (factorial[i - 1] * i) % MOD

def main():
    init()
    n, m, k = map(int, input().split())
    s = 0
    MOD = 10 ** 9 + 7
    for i in range(n):
        s += (((((n - 1 - i) * (n - i)) // 2) % MOD) * ((m * m) % MOD)) % MOD
    for i in range(m):
        s += (((((m - 1 - i) * (m - i)) // 2) % MOD) * ((n * n) % MOD)) % MOD
    print((((s * ((factorial[n * m - 2] * pow(factorial[k - 2], MOD - 2, MOD)) % MOD)) % MOD) * pow(factorial[n * m - k], MOD - 2, MOD)) % MOD)

main()

Measured memory_bytes: 40304
#include <bits/stdc++.h>	
#define pb push_back
typedef long long ll;
const int inf = 2e9;
using namespace std;



int main(){
  int a,b,c,na,nb;
  scanf("%d%d%d%d%d",&a,&b,&c,&na,&nb);
  ll mi=1000000000000000001;
  int ca,cb;
  int tope=max(na,nb);
  for(int i=0; i<=tope; i++){

  	ca=na-i; cb=nb-i;

  	if(na-i < 0)ca=0;
  	if(nb-i < 0)cb=0;


  	mi=min(mi,ll(ll(i*c*2)+ll(ca*a)+ll(cb*b)));
  }

	return !printf("%lld",mi);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,t;
    cin >> x >> t;
    print(max(0LL, x-t));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define Vi vector<vector<int>>
#define Vl vector<vector<ll>>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vp vector<pair<int,int>>
#define mod 1000000007
using namespace std;
int main(){
	string str;
	cin>>str;
	int year=stoi(str.substr(0,4));
	int mm=stoi(str.substr(5,2));
	int day=stoi(str.substr(8,2));
	if(year<2019 || (year==2019 && mm<4) || (year==2019 && mm==4 && day<=30)){
		cout<<"Heisei\n";
	}else{
		cout<<"TBD";
	}
	return 0;
}

Measured memory_bytes: 256
from itertools import permutations
from math import sqrt

N = int(input())
xy = []
for _ in range(N):
    x, y = map(int, input().split())
    xy.append((x, y))


_sum = 0
for p in permutations(range(N)):
    s = p[0]
    x, y = xy[s]
    for i, pi in enumerate(p):
        if i == 0:
            continue
        nx, ny = xy[pi]
        d = (nx-x)**2 + (ny-y)**2
        _sum += sqrt(d)

a = 1
for i in range(1, N+1):
    a *= i
print(_sum/a)


Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 110
#define MAXM 32800
#define MO 1000000007
int f[MAXM],pow2[MAXN],n,m,tot,G[20];
int Count(int x)
{
	int ret=0;
	while(x)
	{
		ret+=x&1;
		x>>=1;
	}
	return ret;
}
int main()
{
	int x,y;
	scanf("%d%d",&n,&m);
	tot=1<<n;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		x--,y--;
		G[x]|=(1<<y);
	}
	f[0]=1;pow2[0]=1;
	for(int i=1;i<=m;i++)
		pow2[i]=2LL*pow2[i-1]%MO;
	for(int S=1;S<tot;S++)
		if((S&1)==((S>>1)&1))
		{
			for(int U=S;U;U=(U-1)&S)
				if((U&1)==((U>>1)&1))
				{
					int w=1;
					for(int i=0;i<n;i++)
						if((S>>i)&1)
						{
							if((U>>i)&1) w=1LL*w*pow2[Count(G[i]&(S^U))]%MO;
							else w=1LL*w*(pow2[Count(G[i]&U)]-1)%MO;
						}
					f[S]=(f[S]+1LL*w*f[S^U]%MO)%MO;
				}
		}
	int ans=((pow2[m]-f[tot-1])%MO+MO)%MO;
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    while (1) {
        int n;
        cin>>n;
        if (n == 0) break;

        double mean = 0;
        vector<int> score(n);
        rep(i, n) {
            cin>>score[i];
            mean += score[i];
        }
        mean /= n;

        double std = 0;
        rep(i, n) {
            std += pow(score[i] - mean, 2);
        }
        std = sqrt(std / n);
        printf("%.10f\n", std);
    }
}


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

int main(){
  int n; cin >> n;
  vector<pair<int,int>> red(n);
  vector<pair<int,int>> blue(n);
  int a,b;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    red.at(i) = make_pair(-b,a);
  }
  sort(red.begin(),red.end());
  for(int i=0;i<n;i++){
    cin >> a >> b;
    blue.at(i) = make_pair(a,b);
  }
  sort(blue.begin(),blue.end());
  int ans = 0;
  vector<bool> use_red(n,true);
  vector<bool> use_blue(n,true);
  for(int i=0; i<n; i++){
    if(use_blue.at(i)){
      for(int j=0; j<n; j++){
        if(use_red.at(j)){
          if((-red.at(j).first)<blue.at(i).second&&red.at(j).second<blue.at(i).first){
            //cout << red.at(j).first << ' ' << blue.at(i).second << endl;
            use_blue.at(i) = false;
            use_red.at(j) = false;
            ans++;
            break;
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
#define ll long long
#define mod 1000000007;

int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8)cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
}

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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c && a % 2 == 0){
		cout << -1 << endl;
		return 0;
	}
	for (int i = 0; 1; i++) {
		if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
			cout << i << endl;
			return 0;
		}
		int A = a, B = b, C = c;
		a = B / 2 + C / 2;
		b = A / 2 + C / 2;
		c = A / 2 + B / 2;
	}

	return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

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

	int flag[30] = {};

	for(int i = 0; i < s.size(); i++){
		flag[s[i]-'a']++;
	}
	for(int i = 0; i < 26; i++){
		if(!flag[i]){
			cout << char(i+'a') << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const ll INF=1e9;
const double PI=acos(-1);
const int MAX=100010;

ll fac[MAX], finv[MAX], inv[MAX];

void cmbInit() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}


ll cmb(int n, int k){
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}


int main() {
    ios_base::sync_with_stdio(false); 

    int n;
    cin >> n;
    vector<ll> x(n),p(n);
    rep(i,n) cin >> x[i];
    cmbInit();
    rep(i,n-1) p[i+1]=((fac[n-1]*inv[i+1])%MOD+p[i])%MOD;
    ll ans=0;
    rep(i,n-1) ans=(ans+((x[i+1]-x[i])*p[i+1])%MOD)%MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7192
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    string s, s1 = "";
    cin >> n >> s;
    for (char i : s)
    {
        int p1, p2, t;
        t = n;
        p1 = (int)i;
        p2 = min(90, p1 + t);
        t -= (p2 - p1);
        if (t > 0)
            p2 = 65 + t - 1;
        s1.push_back((char(p2)));
    }
    cout << s1;
    return 0;
}


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

#define MAX_N 1120
#define MAX_K 15

int main(){
  bool p[MAX_N+1];
  memset(p, true, sizeof(p));
  p[0] = p[1] = false;
  for(int i = 2 ; i*i <= MAX_N ; i++){
    if(p[i]){
      for(int j = i*i ; j <= MAX_N ; j += i){
	p[j] = false;
      }
    }
  }
  vector<int> prime;
  for(int i = 0 ; i <= MAX_N ; i++){
    if(p[i]) prime.push_back(i);
  }
  
  int dp[MAX_N+1][MAX_K];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for(int i = 0 ; i < prime.size() ; i++){
    for(int j = MAX_N - prime[i] ; j >= 0 ; j--){
      for(int k = 0 ; k <= 13 ; k++){
	dp[ j + prime[i] ][k + 1] += dp[j][k];
      }
    }
  }
  
  int n, m;
  while(cin >> n >> m, n|m){
    cout << dp[n][m] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1288
#include"bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0;i < N;++i) {
		cin >> a[i];
	}
	int max = a[0], min = a[0];
	for (int i = 0;i < N;++i) {
		if (a[i] > max)max = a[i];
		if (a[i] < min)min = a[i];
	}
	cout << max - min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;

class xy{
public:
  int x, y;
  xy() {x = y = 0;}
};

int main(){
  int W, H, N; cin >> W >> H >> N;
  vector<pair<xy, int>> V(N);
  for(int i = 0; i < N; i++) cin >> V[i].first.x >> V[i].first.y >> V[i].second;
  vector<vector<int>> C(H, vector<int>(W, 0));
  for(int i = 0; i < N; i++){
    switch(V[i].second){
      case 1:
        for(int y = 0; y < H; y++){
          for(int x = 0; x < V[i].first.x; x++){
            C[y][x] = 1;
          }
        }
        break;
      case 2:
        for(int y = 0; y < H; y++){
          for(int x = W - 1; x >= V[i].first.x; x--){
            C[y][x] = 1;
          }
        }
        break;
      case 3:
        for(int y = 0; y < V[i].first.y; y++){
          for(int x = 0; x < W; x++){
            C[y][x] = 1;
          }
        }
        break;
      case 4:
        for(int y = H - 1; y >= V[i].first.y; y--){
          for(int x = 0; x < W; x++){
            C[y][x] = 1;
          }
        }
        break;
    }
  }
  int res = 0;
  for(int y = 0; y < H; y++){
    for(int x = 0; x < W; x++){
      if(C[y][x] == 0) res++;
    }
  }
  cout << res << endl;  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()

vector<int> adj[200005];
int32_t main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int t1,t2;
		cin>>t1>>t2;
		adj[t1].push_back(t2);
		adj[t2].push_back(t1);
	}
	for(auto x:adj[1]){
		for(auto y:adj[x]){
			if(y==n){
				cout<<"POSSIBLE";
				return 0;
			}
		}
	}
	cout<<"IMPOSSIBLE";
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;
const double PI = 3.14159265359;

int n;
int a[N];

int main() {

	FAST;

	int r;
	cin >> r;
	double ans = 2 * PI * r;
	cout << setprecision(9) << fixed << ans << '\n';
	return 0;
}

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

#define int long long
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define pb push_back
#define all(A) A.begin(),A.end()
#define allr(A) A.rbegin(),A.rend()
#define MOD 1000000007
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int32_t main(){
	
	int n,k,a;
	cin >> n >> k;
	vector<double> A(n);
	for(auto &c:A){
		cin >> a;
		c = ((double)a+1.0)/2.0;
	}
	double x = 0.0,ans = 0.0;
	int l=0;
	for(int i=0;i<n;i++){
		if(i>=k)
			x-=A[l++];
		x+=A[i];
		ans = max(ans,x);
	}
	cout <<fixed << setprecision(8)<< ans << '\n';
#ifdef LOCAL_DEFINE
	cerr << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}







Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
#include<ios>
#include<iomanip>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int H,W,A,B;

void dbg(vector<vector<int>> c)
{
	for(int i=0;i<c.size();i++)
	{
		for(int j=0;j<c[i].size();j++)
			cout<<c[i][j];
		cout<<endl;
	}
}

vector<vector<int>>fill(int rowOneCnt,int colOneCnt)
{
	vector<vector<int>>res;
	vector<int>colcnt(W,0);

	for(int i=0;i<H;i++)
	{
		int one=0;
		vector<int>row;
		for(int j=0;j<W;j++)
		{
			if(one<rowOneCnt&&colcnt[j]<colOneCnt)
			{
				row.push_back(1);
				one++;
				colcnt[j]++;
			}
			else
			{row.push_back(0);
			}
		}
		res.push_back(row);
	}
	return res;

}

bool check(vector<vector<int>> r)
{
	vector<int> rowOne(H,0),colOne(W,0);
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
		{
			if(r[i][j]==1)
			{
				rowOne[i]++;
				colOne[j]++;
			}
		}
	for(int i=0;i<rowOne.size();i++)
	{
		if(min(rowOne[i],W-rowOne[i])!=A)return false;
	}
	for(int i=0;i<colOne.size();i++)
	{
		if(min(colOne[i],H-colOne[i])!=B)return false;
	}
	return true;
}

int main()
{
	
	cin>>H>>W>>A>>B;
	vector<P>x={make_pair(A,B),
		make_pair(W-A,B),
		make_pair(A,H-B),
		make_pair(W-A,H-B)};
	for(P p : x)
	{
		auto r=fill(p.first,p.second);
		if(check(r))
		{
			dbg(r);
			return 0;
		}
	}
	cout<<"No"<<endl;
}

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

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int kyori[] = new int[3];
        kyori[0] = stdIn.nextInt();
        kyori[1] = stdIn.nextInt();
        kyori[2] = stdIn.nextInt();
        
        Arrays.sort(kyori);
        
        System.out.println(kyori[0] + kyori[1]);
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
int n,k;
long long w[101],a[101],pre[4][101],ans;
vector<int> v[4];
bool comp(int a,int b) {return (a>b);}
int main() {
    cin>>n>>k;
    for (int i=0; i<4; i++) v[i].push_back(0);
    for (int i=1; i<=n; i++) {
        cin>>w[i]>>a[i];
        v[w[i]-w[1]].push_back(a[i]);
    }
    for (int i=0; i<4; i++) sort(v[i].begin()+1,v[i].end(),comp);
    for (int i=0; i<4; i++) {
        for (int j=1; j<v[i].size(); j++) pre[i][j]=pre[i][j-1]+v[i][j];
    }
    for (int i=0; i<=n; i++) {
        for (int j=0; j<=n; j++) {
            for (int l=0; l<=n; l++) {
                if (i+j+l>n) continue;
                if (w[1]*i+(w[1]+1)*j+(w[1]+2)*l>k) continue;
                long long x=k-(w[1]*i+(w[1]+1)*j+(w[1]+2)*l);
                int m=min((long long)(n-i-j-l),x/(w[1]+3));
                ans=max(ans,pre[0][i]+pre[1][j]+pre[2][l]+pre[3][m]);
            }
        }
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 3644
#include<stdio.h>
 
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if((a+b)%2==0)
	{
		printf("%d\n",(a+b)/2);
	}
	else
	{
		printf("%d\n",((a+b)/2)+1);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> X(n), Y(n);
  vector<ll> H(n);
  rep(i, n) cin >> X[i] >> Y[i] >> H[i];
  for(int i=0; i<=100; i++) {
    for(int j=0; j<=100; j++) {
      ll h = -1;
      bool ok = true;
      rep(k, n) {
        int dx = abs(i-X[k]);
        int dy = abs(j-Y[k]);
        if(H[k] == 0) continue;
        if(h == -1) h = H[k]+dx+dy;
        else if(h != H[k]+dx+dy) {
          ok = false;
          break;
        }
      }
      if(!ok) continue;
      if(h != -1) {
        rep(k, n) {
          int dx = abs(i-X[k]);
          int dy = abs(j-Y[k]);
          if(H[k] != 0) continue;
          if(h > H[k]+dx+dy) {
            ok = false;
            break;
          }
        }
      } else {
        h = longinf;
        rep(k, n) {
          int dx = abs(i-X[k]);
          int dy = abs(j-Y[k]);
          if(H[k] != 0) continue;
          chmin(h, H[k]+dx+dy);
        }
      }
      if(!ok) continue;
      cout << i << ' ' << j << ' ' << h << endk;
      return 0;
    }
  }
  return 0;
}


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

template<typename ...> static inline int gc(void) { return getchar(); }
static inline void read(long long int &x){int k,m=0;x=0;for(;;){k=gc();if(k==45){m=1;break;}if(48<=k&&k<=57){x=k-48;break;}}for(;;){k=gc();if(k<48||k>57)break;x=x*10+k-48;}if(m)x=-x;}
static inline void uread(long long int &x){int k;x=0;for(;;){k=gc();if(48<=k&&k<=57){x=k-48;break;}}for(;;){k=gc();if(k<48||k>57)break;x=x*10+k-48;}}

long long int par[114514], rnk[114514];
long long int N, a, b;
pair<long long, long long> x[114514], y[114514], c[114514];
vector<pair<long long, pair<long long, long long>>> v;

void uf(long long int n){
    iota(par, par + n, 0);
}

long long int fnd(long long int i){
    if(par[i] == i)return i;
    return par[i] = fnd(par[i]);
}

void unon(long long int x, long long int y){
    x = fnd(x);
    y = fnd(y);
    if(!(x ^ y)) return;
    if(rnk[x] < rnk[y])par[x] = y;
    else par[y] = x;
    if(rnk[x] == rnk[y])++rnk[x];
}

int main(){
    uread(N);
    uf(N);
    for(int i = 0; i < N; ++i){
        uread(a);
        uread(b);
        c[i] = make_pair(a, b);
        x[i] = make_pair(a, i);
        y[i] = make_pair(b, i);
    }
    a = 0;
    sort(x, x + N);
    sort(y, y + N);
    for(int i = 0; i < N - 1; ++i){
        v.push_back(make_pair(x[i + 1].first - x[i].first, make_pair(x[i + 1].second, x[i].second)));
        v.push_back(make_pair(y[i + 1].first - y[i].first, make_pair(y[i + 1].second, y[i].second)));
    }
    sort(v.begin(), v.end());
    for(auto P : v){
        if(fnd(P.second.first) != fnd(P.second.second)){
            a += P.first;
            unon(P.second.first, P.second.second);
        }
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 15088
#include <iostream>

using namespace std;

int main()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int vx = x2 - x1;
	int vy = y2 - y1;
	int x3 = x2 - vy;
	int y3 = y2 + vx;
	int x4 = x3 - vx;
	int y4 = y3 - vy;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define N 5005
using namespace std;

typedef long long ll;

ll n, A, B, a[N], yer[N], dp[N][N];

ll f(ll ind, ll x){
	ll &r = dp[ind][x];
	if(r != -1)
		return r;
	if(ind == n + 1)
		return 0;
	ll ek = (yer[ind] > x)? B : (yer[ind] < x) ? A : 0;
	r = f(ind + 1, x) + ek;
	if(yer[ind] > x)
		r = min(r, f(ind + 1, yer[ind]));
	// cout << ind << " " << x << " = " << r << endl;
	return r;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);

	memset(dp, -1, sizeof dp);

	scanf("%lld %lld %lld",&n ,&A ,&B);

	for(ll i = 1; i <= n; i++){
		scanf("%lld",a + i);
		yer[a[i]] = i;
	}

	printf("%lld\n", f(1, 0));
	return 0;
}

Measured memory_bytes: 196352
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

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

	string ret;
	if(b-a == c-b)
		ret = "YES";
	else
		ret = "NO";

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,M = MI()


class WarshallFloyd():
    def __init__(self,N):  # Nは頂点の個数
        self.N = N
        self.d = [[float('inf')]*N for i in range(N)]  # d[i][j] = iからjへの最短距離,0-indexed
    def add(self,u,v,c,directed = False):
        if directed is False:  # 無向グラフの場合
            self.d[u][v] = c
            self.d[v][u] = c
        else:  # 有向グラフの場合
            self.d[u][v] = c
    def WarshallFloyd_search(self):
        for k in range(self.N):
            for i in range(self.N):
                for j in range(self.N):
                    self.d[i][j] = min(self.d[i][j],self.d[i][k] + self.d[k][j])
        return self.d


W = WarshallFloyd(N)
edges = [0]*M
for i in range(M):
    a,b,c = MI()
    W.add(a-1,b-1,c,directed=False)
    edges[i] = (a-1,b-1,c)
for i in range(N):
    W.add(i,i,0)

W.WarshallFloyd_search()

ans = 0
for i in range(M):
    a = 0
    for j in range(N):
        if W.d[edges[i][0]][edges[i][1]] == edges[i][2]:
            a = 1
    if a == 0:
        ans += 1

print(ans)


Measured memory_bytes: 74188
#include <algorithm>
#include <iostream>

using namespace std;

int n, a, b;
int p[10], q[10];

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> q[i];
  }
  
  while(next_permutation(p, p+n)) {
    a++;
  }
  while(next_permutation(q, q+n)) {
    b++;
  }
  
  cout << abs(a-b) << endl;
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    string RestrunStr[255];
    int RestrunNum[255];
    
    for(int i = 1; i<=N; i++){
        int P;
        string S;
        cin >> S >> P;
        RestrunStr[i] = S;
        RestrunNum[i] = P;
    }

    map<int,int> ans;
    int i =1;
    int num = 1;
    for(i = 1; i <= N; i++){
        num = 1;        
        for(int j = 1; j <= N; j++) {
            if(RestrunStr[i] < RestrunStr[j]){
            }
            else if(RestrunStr[i] == RestrunStr[j]){
                if(RestrunNum[i] > RestrunNum[j]){
                }
                else if(RestrunNum[i] == RestrunNum[j]){
                }
                else{
                    num++;
                }
            }
            else{
                num++;
            }
        }
        ans[num] = i;
    }

    for(int aa = 1; aa <= N ;aa++)
    {
        cout << ans[aa] << endl;
    }

}

Measured memory_bytes: 256
a,b = map(int,input().split())
n = 1
ans = 0
while True:
    n += 1
    if (int(n*0.08) == a and int(n*0.10) == b):
        print(n)
        break
    if n >= (a+1)*10 and n >= (b+1)*10:
        print(-1)
        break

Measured memory_bytes: 3060
def comparing_strings():
    # 入力
    a, b = input().split()
    # 初期処理
    str_a = ''
    str_b = ''
    # 文字列作成
    for _ in range(int(b)):
        str_a = str_a + a
    for _ in range(int(a)):
        str_b = str_b + b
    # 大小比較
    if str_a <= str_b:
        return str_a
    else:
        return str_b

result = comparing_strings()
print(result)

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

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

    int maxx=0;
    bool jdg=false;

    if(x==1){
            cout<<1<<endl;
    }

    else {
    for(int i=1;i<=x;i++){
        for (int j=2;j<=x;j++) {
            if(pow(i,j)>x){
                break;
            }
            int answer=pow(i,j);
            maxx=max(maxx,answer);
        }

        if(jdg){
            break;
        }
    }
    cout<<maxx<<endl;

    }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N=len(v)
    size=len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列


    import math
    H=int(input())
    W=int(input())
    N=int(input())
    m=max(H,W)
    print(math.ceil(N/m))



if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)

a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input().rstrip())
dis=abs(a-b)
if a<b:
    if b+t*w<=a+v*t:
        print("YES")
    else:
        print("NO")
else:
    if b-t*w>=a-t*v:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 9192
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main() {
  int x,y,z;
  int p[100];
  int i;
  int a,b;
  scanf("%d %d", &x,&y);

  for(i = 0; i< 100; i++) p[i] = i+1;
  for(i = 0; i < y; i++) {
    if(i == y-1) {
      scanf("%d", &z);
      p[z-1] = 0;
    } else {
      scanf("%d ", &z);
      p[z-1] = 0;
    }
  }

  for(i=x-1;; i--) {
    if(p[i] != 0 || i < 0) {
      break;
    }
  }
  if(i >= 0) a = p[i];
  else a = 0;

  for(i=x-1;; i++) {
    if(p[i] != 0 || i == 100) {
      break;
    }
  }
  if(i != 100) b = p[i];
  else b = 101;

  if(abs(x-a) == abs(x-b)) {
    printf("%d\n",a);
  } else if(abs(x-a) > abs(x-b)) {
    printf("%d\n",b);
  } else if(abs(x-a) < abs(x-b)) {
    printf("%d\n",a);
  }
  return 0;
}


Measured memory_bytes: 1732
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

enum{N=100023};
int vis[N],cnt[N];

int main(){
	ci();
	int m=ci();
	char opt[100];
	int ans1=0, ans2=0;
	rep(i,1,m){
		int x= ci();
		scanf("%s",opt);
		if( opt[0]=='A' ){
			if( vis[x]==0 ){
				vis[x]= 1;
				ans1++;
				ans2+= cnt[x];
			}
		}else{
			cnt[x]++;
		}
	}
	printf("%d %d\n",ans1,ans2);
	return 0;
}


Measured memory_bytes: 896