akhauriyash/Code-Regression huggingface dataset:
class UnionFind():
    def __init__(self, n):
        self.parents = [-1 for _ in range(n)]  # 各要素の親 自分が根の場合は -1 * (木の要素数)

    def find(self, x):  # xが属する木の根を返す
        if self.parents[x] < 0:  # 自分が根の場合
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # xが属する木とyが属する木を合体する
        x_root = self.find(x)  # xの根
        y_root = self.find(y)  # yの根

        if x_root == y_root:  # 同じ木に属する
            return

        if abs(self.parents[x_root]) >= abs(self.parents[y_root]):  # 要素数の比較
            self.parents[x_root] += self.parents[y_root]
            self.parents[y_root] = x_root
        else:
            self.parents[y_root] += self.parents[x_root]
            self.parents[x_root] = y_root

    def size(self, x):  # xが属する木の要素数
        return -self.parents[self.find(x)]


def main():
    n, m = map(int, input().split())
    uf = UnionFind(n)

    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        uf.union(a, b)

    ans = 0
    for i in range(n):
        ans = max(ans, uf.size(i))

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 87016
#include <stdio.h>

int main() {
    int a[4][13];
    int n, i, j;
    char b;
    int c;
    
    for (i=0; i<4; i++) {
        for (j=0; j<13; j++) {
            a[i][j] = 0;
        }
    }
    
    scanf("%d", &n);

    for (i=0; i<n; i++) {
        scanf("%s %d", &b, &c);
        if (b=='S') {
            a[0][c-1]=1;
        }else if(b=='H'){
            a[1][c-1]=1;
        }else if(b=='C'){
            a[2][c-1]=1;
        }else if(b=='D'){
            a[3][c-1]=1;
        }
    }
    for (i=0; i<4; i++) {
        for (j=0; j<13; j++) {
            if(a[i][j] == 0){
            if(i == 0){
                printf("S %d\n", j+1);
            }
            if(i == 1){
                printf("H %d\n", j+1);
            }
            if(i == 2){
                printf("C %d\n", j+1);
            }
            if(i == 3){
                printf("D %d\n", j+1);
                }
            }
        }
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N); 
  vector<int> B(N); 
  vector<int> C(N-1); 
  for(int i=0;i<N;i++)cin >> A.at(i);
  for(int i=0;i<N;i++)cin >> B.at(i);
  for(int i=0;i<N-1;i++)cin >> C.at(i);
  int ans=0;
  for(int i=0;i<N;i++){
    ans+=B.at(A.at(i)-1);
    if(i>0){
    if((A.at(i)-A.at(i-1))==1)ans+=C.at(A.at(i-1)-1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
input();a=list(map(int,input().split()));d={}
for i in a:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1
d={i:j for i,j in d.items() if j>1}
if len(d)<2:
  print(0)
else:
  d=sorted(d.items(),key=lambda x:(-x[0],-x[1]))
  print(d[0][0]*d[1][0] if d[0][1]<4 else d[0][0]*d[0][0])

Measured memory_bytes: 22180
#create date: 2020-04-19 21:04

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = na()
    ans = [0] * n
    for ai in a:
        ans[ai-1] += 1
    for i in ans:
        print(i)

if __name__ == "__main__":
    main()


Measured memory_bytes: 91300
N=int(input())
R=[[int(x) for x in input().split()] for _ in range(N)]
B=[[int(x) for x in input().split()] for _ in range(N)]

import operator
R.sort(key=operator.itemgetter(1),reverse=True)
B.sort()

ans=0
for b in B:
    xb,yb=b
    for r in R:
        xr,yr=r
        if xr<xb and yr<yb:
            ans+=1
            R.remove(r)
            break
print(ans)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func gcd(a, b int) int {
	if b > a {
		a, b = b, a
	}
	// 書き換え可能なパターンの計算簡略化のため
	if b == 0 {
		return a
	}
	var r int
	for {
		r = a % b
		if r == 0 {
			return b
		}
		a, b = b, r
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}

	l := make([]int, n+1)
	l[0] = 0
	for i := 0; i < n; i++ {
		l[i+1] = gcd(l[i], a[i])
	}
	r := make([]int, n+1)
	r[n] = 0
	for i := n - 1; i >= 0; i-- {
		r[i] = gcd(r[i+1], a[i])
	}

	max := 0
	for i := 0; i < n; i++ {
		if v := gcd(l[i], r[i+1]); v > max {
			max = v
		}
	}

	fmt.Println(max)
}


Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
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; }
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//AtCoder以外ではコメントアウトを忘れずに！
//#include <atcoder/all>
//using namespace atcoder;
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
ll i, j, k, l; ll N, M, K, H, W, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vll path; vs S;
ll Npow(ll x, ll n) {
	if (n == 0) return 1;
	if (n % 2 == 0) return Npow(x * x % MOD, n / 2);
	else return x * Npow(x, n - 1) % MOD;
}

int main() {
	cin >> N;
	if (N == 1) cout << 0 << endl;
	else {
		ll pre1 = Npow(10, N);
		ll pre2 = (Npow(9, N)*2)%MOD;
		ll pre3 = Npow(8, N);
		ans = (pre1 - pre2 + pre3 + MOD*2) % MOD;
		co(ans);
	}
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int a, b;
	char x;
	cin >> a >> x >> b;
	if (x == '+')
	{
		cout << a + b << endl;
	}
	else
	{
		cout << a - b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
def f(j, a):
    if j == 2:
        return 1 - a%2
    if j % 2:
        return a % 2 if a else 2
    else:
        return a

L = int(input())
A = [0] + [int(sys.stdin.readline()) for _ in [0]*L]
B = [a%2 if a else 2 for a in A]
dp = [[0]*5 for _ in [0]*(L+1)]

for i in range(L):
    for j in range(5):
        dp[i+1][j] = min(dp[i][:j+1]) + f(j, A[i+1])
print(min(dp[-1]))


Measured memory_bytes: 71680
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int AS = 1 << 17;
ll dat[2 * AS];
const ll are = 1 << 30;
void modify(int p) {
	for (dat[p += AS] -= are; p > 1; p >>= 1) dat[p >> 1] = max(dat[p], dat[p ^ 1]);
}
void modify0(int p) {
	for (dat[p += AS] = 0; p > 1; p >>= 1) dat[p >> 1] = max(dat[p], dat[p ^ 1]);
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = ' ';
}

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


	int N = getint();
	int A[100000];
	rep(i, N) {
		A[i] = getint() - 1;
		dat[AS + A[i]]++;
	}
	rep(i, N) dat[AS + i] = (dat[AS + i] << 30) + i;
	for (int i = AS - 1; i > 0; i--) dat[i] = max(dat[i << 1], dat[i << 1 | 1]);

	if (N == 2) {
		printf("-1");
		return 0;
	}

	int dame = -1;
	int j = 0;
	const int m = (1 << 30) - 1;
	bool used[100000] = {};
	rep(i, N - 3) {
		int kotae;
		ll tmp = dat[1];
		if (N - i - 1 == tmp >> 30) kotae = tmp & m;
		else {
			int k = j;
			while (used[k] || k == dame) k++;
			kotae = k;
		}
		putint(kotae + 1);
		used[kotae] = 1;
		dame = A[kotae];
		while (used[j]) j++;
		modify(dame);
		//modify0(kotae);

		//これを入れないと正しくなさそうだけど
		//嘘でも通るならいいかなって・・・
		//5
		//2 3 1 1 1
		//とか壊れてる
	}

	int kouho[3];
	int k = 0;
	for (int i = j; i < N; i++) {
		if (!used[i]) kouho[k++] = i;
	}
	while (1) {
		if (dame != kouho[0] && A[kouho[0]] != kouho[1] && A[kouho[1]] != kouho[2]) break;
		next_permutation(kouho, kouho + 3);
	}
	putint(kouho[0] + 1);
	putint(kouho[1] + 1);
	putint(kouho[2] + 1);

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 3712
N, A, B, C = (int(x) for x in input().split())
L = [int(input()) for _ in range(N)]
INF = 10**9
def magic(cur, a, b, c):
    if cur == N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF
    ret0 = magic(cur+1, a, b, c)
    ret1 = magic(cur+1, a+L[cur], b, c) + 10
    ret2 = magic(cur+1, a, b+L[cur], c) + 10
    ret3 = magic(cur+1, a, b, c+L[cur]) + 10
    return min(ret0,ret1,ret2,ret3)
print(magic(0,0,0,0))


Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <iomanip>
using namespace std;
int main(){
	int n;
	cin >> n;
	cin.ignore();
	while(n-->0){
		string s;
		getline(cin,s);
		int ans;
		for(int i=1;i<26;i++){
		for(int k=0;k<26;k++){
			string w = s;
			for(int j=0;j<s.size();j++) if(w[j]!=' ') w[j] = ((w[j]-'a')*i+k)%26+'a';
			istringstream is(w);
			string t;
			bool a = false;
			while(is >> t){ if(t=="that" or t=="this"){ a = true; break; } }
			if(a) s = w;
			if(a) break;
		}}
		cout << s << endl;
	}
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

int main()
{
    ll N, ans = 1;
    cin >> N;
    rep1(i, N + 1)
    {
        ans *= i;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3584
//MADE BY Y_is_sunshine;
//#include <bits/stdc++.h>
//#include <memory.h>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define INF 0x3f3f3f3f
#define MAXN 20004

typedef long long ll;

const ll mod = 1e9 + 7;
const double PI = acos(-1);

using namespace std;

int N, M, K;

struct node {
	ll at;
	ll cost;
	double ave;
	bool operator < (const node a) const {
		return this->ave > a.ave;
	}
}p[MAXN];

ll _min = INF;
ll solve(int HP, int now) {
	if (now == N + 1) {
		if (HP > 0)
			return _min;
		else
			return 0;
	}
	if (HP <= p[now].at)
		return min(p[now].cost, solve(HP, now + 1));
	else
		return solve(HP % p[now].at, now + 1) + HP / p[now].at * p[now].cost;
}

ll dp[MAXN];

int main(void)
{
#ifdef Sunshine
	freopen("data.txt", "r", stdin);
#endif

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

	int HP;
	cin >> HP >> N;
	
	for (int i = 1; i <= N; i++) {
		cin >> p[i].at >> p[i].cost;
		p[i].ave = 1.0 * p[i].at / p[i].cost;
		//_min = min(_min, p[i].cost);
	}

	sort(p + 1, p + 1 + N);

	
	//cout << solve(HP, 1) << '\n';

	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = p[i].at; j <= 2e4; j++) {
			dp[j] = min(dp[j], dp[j - p[i].at] + p[i].cost);
		}
	}

	for (int i = HP; i <= 2e4; i++) {
		_min = min(_min, dp[i]);
	}

	cout << _min << '\n';



#ifdef Sunshine
	freopen("CON", "r", stdin);
	system("pause");
#endif
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e9+10;
struct Edge{int to,weight;};

/*----------------------------------------------*/
string s[50];


signed main(){
  int h,w;
  cin>>h>>w;
  rep(i,h) cin>>s[i];
  
  rep(i,h)rep(j,w){
    if(s[i][j]=='#') continue;
    int count=0;
    rep(k,8){
      if(i+dx[k]<0||i+dx[k]>h-1||j+dy[k]<0||j+dy[k]>w-1) continue;
      if(s[i+dx[k]][j+dy[k]]=='#') count++;
    }
    s[i][j]='0'+count;
  }

  rep(i,h){
    rep(j,w) cout<<s[i][j];
    cout<<endl;
  }
  return 0;
}

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


long long solve(long long K){
    long long ans = 0;
    for (int a = 1; a < K + 1; a++)
    {
        for (int b = 1; b < K + 1; b++)
        {
            int gab = gcd(a, b);
            for (int c = 1; c < K + 1; c++)
            {
                ans += gcd(gab, c);
            }
                }
    }
    return ans;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    long long res = solve(K);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;


ll memo[100010];
bool done[100010];
vector<ll> edge[100010];


ll dp(ll v){
    ll ans = 0;
    if (done[v]) return memo[v];
    for (ll to : edge[v]){
        ans = max(ans, dp(to) + 1);
    }
    done[v] = true;
    memo[v] = ans;
    return ans;
}


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

    rep(i, m){
        ll x, y;
        cin >> x >> y;
        edge[x].push_back(y);
    }

    ll ans = 0;
    for (ll v = 1; v <= n; v++){
        ans = max(ans, dp(v));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
 
using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;


int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int l=s.length();
    if(l<=n){
        cout<<s;
    }
    else{
        for(int i=0;i<n;i++)
            cout<<s[i];
        cout<<"...";;
    }
    return 0;
}
    

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

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

mint fact(long long n) {
  mint res = 1;
  for (long long i=n; i>0; i--) res*=i;
  return res;
}

int main() {
  long long x,y;
  cin >> x >> y;

  if ((x+y)%3 != 0) {
    puts("0");
    return 0;
  }

  long long a = (2*x-y)/3;
  long long c = (2*y-x)/3;

  if (a<0 || c<0) {
    puts("0");
    return 0;
  }

  mint ans = fact(a+c);
  ans /= fact(a);
  ans /= fact(c);
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 888
/* ex2_3
    nnasy   */

#include <stdio.h>

int main(void) {
    int length_N, white;

    //入力の受け取り（N, A）
    scanf("%d%d", &length_N, &white);

    //黒色のマスの個数(N*N-A)の出力
    printf("%d\n", length_N*length_N-white);

    return 0;
}

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

int main(){
  int a, b, k;
  cin >> a >> b >> k;
  int f = 1;
  while (k--) {
    if (f == 1) {
      if (a&1) {
        a--;
      }
      a /= 2;
      b += a;
      f = 2;
    } else {
      if (b & 1) {
        b--;
      }
      b /= 2;
      a += b;
      f = 1;
    }
  }
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];

    ll ans = 0, sum = 0;
    rep(i, n) sum += a[i];
    rep(i, n - 1) {
        sum -= a[i];
        sum = (sum % MOD + MOD) % MOD;
        ans = (ans + a[i] * sum) % MOD;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5148
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false; cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
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> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n;
vector<lli> a;
int main() {
  cin >> n; read_n(a, n);
  lli ans = 0;
  for (lli x : a) {
    ans += x-1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define up(l,r,i) for(int i=l;i<=r;i++)
#define dn(l,r,i) for(int i=l;i>=r;i--)
using namespace std;

typedef long long LL;
const int INF =2147483647;
int qread(){
	int w=1,c,ret;
	while((c=getchar())> '9'||c< '0')
	w=(c=='-'?-1:1); ret=c-'0';
	while((c=getchar())>='0'&&c<='9')
	ret=ret*10+c-'0';
	return ret*w;
}
int n;
stack <char> s;
string ans,pre,scc;
int main(){
	n=qread(),s.push('#');
	up(1,n,i) switch(getchar()){
		case '(': s.push('('),ans+='('; break;
		case ')':
			ans+=')';
			if(s.top()!='#') s.pop(); else pre+='(';
	}
	while(s.top()!='#') scc+=')',s.pop();
	cout<<pre+ans+scc<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;


class Program
{
    static void Main(string[] args)
    {
        var a = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();

        var ret = (a >= 3200) ? s : "red";

        Console.Write(ret);
    }
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int a[N];
int n, s;
unordered_set<int> seen;

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    int cur = 1;
    while (1) {
        if (cur == 2) {
            cout << s << endl;
            exit(0);
        }
        if (seen.count(cur)) {
            cout << -1 << endl;
            exit(0);
        }
        seen.insert(cur);
        cur = a[cur];
        ++s;
    }
    return 0;
}


Measured memory_bytes: 7544
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

string s;
cin >> s;

int N = s.size();
int ans = N;

//abaababaab
for( int i = 1 ; i < (N/2) ; i++) {
    s.pop_back();
    s.pop_back();
    ans = s.size();
    string u = s.substr(0, ans/2);
    string v = s.substr(ans/2, ans/2);
    if(u == v) break;
}

cout << ans << endl;

return 0;
}

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

int main(void){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    double r = 0.0;
    pair<int,int> ans;

    for(int i=0; i*a*100<=f; i++){
        for(int j=0; i*a*100+j*b*100<=f; j++){
            if(i == 0 && j == 0){
                continue;
            }
            int w = i*a*100 + j*b*100;
            for(int k=0; w+k*c<=f; k++){
                for(int l=0; w+k*c+l*d<=f; l++){
                    int s = k*c + l*d;
                    double m = (double)s/(w+s);
                    if(m <= (double)e/(100+e) && m >= r){
                        ans.first = w+s;
                        ans.second = s;
                        r = m;
                    }
                }
            }
        }
    }

    cout << ans.first << " " << ans.second << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

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

int main()
{
	int d, n;
	scanf("%d %d", &d, &n);
	if(n<100){
		for(int i=0; i<d; i++){
			n*=100;
		}
		printf("%d\n", n);
	}else{
		n=101;
		for(int i=0; i<d; i++){
			n*=100;
		}
		printf("%d\n", n);
	}
	return 0;
}

Measured memory_bytes: 256
s = list(str(input()))
t = list(str(input()))


s.sort()
t.sort()


al = ['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']

arr1 = [0] * 26
arr2 = [0] * 26


for i in range(len(s)):
    arr1[ord(s[i]) - 97] += 1

for i in range(len(t)):
    arr2[ord(t[i]) - 97] += 1

arr1.sort()
arr2.sort()

if arr1 == arr2:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 7448
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string.h>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>

#define ll long long
#define INF 0x3f3f3f3f
#define clr(x) memset(x,0,sizeof(x))
#define clr2(x) memset(x,INF,sizeof(x))
#define clr3(x) memset(x,-INF,sizeof(x))
#define clr4(x) memset(x,-1,sizeof(x))
#define pb(x) push_back(x)
//#define debug

using namespace std;
const ll mod=1e9+7;

char s[12345];
char s1[12345],s2[12345];
void solve()
{
    scanf("%s%s%s",s1,s,s2);
    printf("A%cC",s[0]);
}
int main()
{
    #ifdef debug
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif


        solve();


    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;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end(), greater<int>());
  int ans = 0;
  rep(i, k) ans += l[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main()
{
int h,n,sum=0;
cin>>h>>n;
int a[100010];
for(int i=0;i<n;i++)
{
    cin>>a[i];
    sum+=a[i];
}
if(sum>=h)cout<<"Yes";
else cout<<"No";
return 0;
}


Measured memory_bytes: 640
package main
import(
  "fmt"
)

func main(){
  var a1, a2, a3 int
  fmt.Scan(&a1, &a2, &a3)
  if a1+a2+a3 <= 21 {
    fmt.Print("win")
  } else if a1+a2+a3 >= 22 {
    fmt.Print("bust")
  }
}


Measured memory_bytes: 512
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    a.erase(unique(all(a)), a.end());
    rep(i, sz(a)) cout << a[i] << (i == sz(a) - 1 ? '\n' : ' ');
}



Measured memory_bytes: 3244
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = n - 1; i>= 0; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<ll> vll;

const int MAXN = 100005;
ll mod=1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	switch(n%10){
		case 0: 
		case 1:
		case 6:
		case 8:
				cout<<"pon"<<nl;
				break;
		case 2:
		case 4:		
		case 5:		
		case 7:		
		case 9:		
				cout<<"hon"<<nl;
				break;
		default:
				cout<<"bon"<<nl;
				break;
	}
	return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

int main(){
	ll n;
	cin>>n;
	ll sum = 0;
	for( ll  i  = 1; i <= n; i++){
		 if(((i%5)!=0) and ((i%3)!=0)){
		 	 sum += i;
		 }
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	ll s;
	ll num[10];
	bool pp[10];//pp[1]=trueのときnum[0]とnum[1]の間に+
	ll ans=0;
	
	cin>>s;
	int index=0;
	while(s!=0)
	{
		num[index]=s%10;
		s/=10;
		index++;
	}
	for(ll bit=0;bit<pow(2,index-1);bit++)
	{
		for(int i=0;i<index-1;i++)
		{
			ll t=(bit&(ll)pow(2,i));
			if(t>0)
				pp[i+1]=true;
			else
				pp[i+1]=false;
		}

		ll temp=0;
		for(int i=index-1;i>-1;i--)
		{
			temp*=10;
			temp+=num[i];
			if(pp[i])
			{
				ans+=temp;
				temp=0;
			}
		}
		ans+=temp;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n,a,b,A;
	cin>>n>>a>>b;
	A=a*n;
	if(A>b)
	{
		cout<<b;
	} 
	if(A<b)
	{
		cout<<A;
	}
	if(A==b)
	{
		cout<<A;
	}
	return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}
 
template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	int N, K; cin >> N >> K;
	string s; cin >> s;
	int la = -1;
	int cnt = 0;

	vector<pii> vec;
	rep(i, N) {
		int c = s[i] - '0';
		if (c == la) {
			++cnt;
		} else {
			if (la != -1) {
				vec.eb(la, cnt);
			}
			cnt = 1;
			la = c;
		}
	}
	vec.eb(la, cnt);//把所有的01离散化之后，k就是翻转k次0就好
	 //求前缀和之后，如果当前是0，那么就是2*k+i的那个减去i
	 //当前是1，就是2*k+1+i 
	//cout<<s<<endl;
	rep(i,vec.size())
	{
	//	cout<<vec[i].fi<<" "<<vec[i].se<<endl;
	 } 
	vector<int> acm(vec.size() + 1);
	rep(i, vec.size()) {
		acm[i+1] = acm[i] + vec[i].se;
	}
	rep(i,vec.size())
	{
	//	cout<<acm[i]<<" ";
	}
	//cout<<endl;
	int ans = 0;
	rep(i, vec.size()) {
		int r = i + (vec[i].fi == 0 ? K * 2 : K * 2 + 1);
		int t = acm[min(r, (int)vec.size())] - acm[i];
		ans = max(ans, t);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1652
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	int A[200010] = {}; 
	int B[200010] = {}; 
	for(int i = 0; i < N; i++){
		cin >> A[i]; 
		B[A[i]] = i; 
	}
	int m = 1; 
	int M = 1; 
	for(int i = 2; i <= N; i++){
		if(B[i-1] < B[i]){
			m ++; M = max(m, M); 
		}
		else{
			m = 1;
		}
	}
	cout << N - M << endl; 
}

Measured memory_bytes: 1920
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		sc.close();

		int ansCount = N - K;
		int tmp = K;
		for(int i = 0; i < ansCount; i++) {
			int checkA = list.get(i);
			int checkB = list.get(tmp);
			if(checkA < checkB) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
			tmp++;
		}

	}

}

Measured memory_bytes: 65912
nmx = input().split()
n = int(nmx[0])
m = int(nmx[1])
x = int(nmx[2])

a = input().split()
numl = 0
numr = 0
a = [int(x) for x in a]

for i in range(m):
    if a[i] <= x:
        numl += 1
    else:
        numr += 1

if numl > numr:
    print("%d"%numr)
else:
    print("%d"%numl)
    

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++ 
signed main() {
	int a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b))<<endl;
}


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

int main(){
  int N;
  cin >> N;
  int T , A;
  cin >> T >> A;
  vector <int> H(N);
  for(int i = 0; i < N; i++){
    cin >> H.at(i);
  }
  int ok = 0;
  double answer = abs(1.0 * A - (1.0 * T - H.at(0) * 0.006));
  for(int i = 1; i < N; i++){
    if(abs(1.0 * A - (1.0 * T - H.at(i) * 0.006)) < answer){
      answer = abs(1.0 * A - (1.0 * T - H.at(i) * 0.006));
      ok = i;
    }
  }
  cout << ok + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
//#define ivorysi
#define MAXN 100005
typedef long long int64;
using namespace std;
template<class T>
void read(T &res) {
	res = 0;char c = getchar();T f = 1;
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
int N;
int64 D[MAXN],L[MAXN],dep[MAXN],C[MAXN];
int id[MAXN],s[MAXN],t[MAXN],tot,siz[MAXN];

struct node {
    int to,next;
}E[MAXN * 2];
int head[MAXN],sumE;
void add(int u,int v) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    head[u] = sumE;
}
bool cmp(int a,int b) {
    return D[a] < D[b];
}
void dfs(int u,int fa) {
    siz[u] = 1;
    for(int i = head[u] ; i ; i = E[i].next) {
        int v = E[i].to;
        if(v != fa){
            dep[v] = dep[u] + 1;
            dfs(v,u);
            siz[u] += siz[v];
        }
    }
}
bool dfs1(int u,int fa) {
    if(C[u] != D[u]) return false;
    for(int i = head[u] ; i ; i = E[i].next) {
        int v = E[i].to;
        if(v != fa) {
            C[v] = C[u] - siz[v] + N - siz[v];
            if(!dfs1(v,u)) return false;
        }
    }
    return true;
}
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {
        read(D[i]);id[i] = i;siz[i] = 1;
    }
    sort(id + 1,id + N + 1,cmp);
    for(int i = 1 ; i <= N ; ++i) L[i] = D[id[i]];
    for(int i = N ; i > 1 ; --i) {
        s[++tot] = id[i];
        int p = lower_bound(L + 1,L + i,L[i] + 2 * siz[s[tot]] - N) - L;
        if(L[p] != L[i] + 2 * siz[s[tot]] - N) {puts("-1");return;}
        t[tot] = id[p];
        siz[id[p]] += siz[id[i]];
    }
    for(int i = 1 ; i <= tot ; ++i) {add(s[i],t[i]);add(t[i],s[i]);}
    dfs(1,0);
    for(int i = 1 ; i <= N ; ++i) C[1] += dep[i];
    if(!dfs1(1,0)) {puts("-1");return;}
    for(int i = 1 ; i <= tot ; ++i) {
        out(s[i]);space;out(t[i]);enter;
    }
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
    Solve();
	return 0;
}


Measured memory_bytes: 12672
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;


int main(){
    int a, b; cin >> a >> b;
    if(a <= 5){
        cout << 0 << endl;
        return 0;
    }else if(a >= 13){
        cout << b << endl;
    }else{
        cout << b/2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    char x,y;
    cin >> x >> y;
    char a;
    if(x > y)a = '>';
    else if(x < y)a = '<';
    else a = '=';
    cout << a << endl;
    return 0;
}

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

int main(){
	int N,M;
	vector<int> L,R;

	cin >> N >> M;
	for(int i=0;i<M;i++){
		int l,r;
		cin >> l >> r;
		L.push_back(l);
		R.push_back(r);
	}
	int card_min=*max_element(L.begin(),L.end());
	int card_max=*min_element(R.begin(),R.end());
	if(card_max<=N){
		if(card_max>=card_min){
			cout << card_max-card_min+1 << endl;
		}else{
			cout << 0 << endl;
		}
	}else{
		if(N>=card_min){
			cout << N-card_min+1 << endl;
		}else{
			cout << 0 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1276
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC146_E___Rem_of_Sum_is_Num
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solver());
        }
        static long solver()
        {
            var NK = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NK[0]; var K = NK[1];
            if(K==1)return 0;

            var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var minus1A = A.Select(n => n - 1).ToArray();
            var accumA = new long[N + 1];
            accumA[0] = 0;
            for (int i = 1; i < N + 1; i++) accumA[i] = accumA[i - 1] + minus1A[i - 1];
            accumA = accumA.Select(n => n % K).ToArray();

            var dic = new Dictionary<long, long>();
            for (int i = 1; i < Math.Min(K, N + 1); i++)
            {
                if (dic.ContainsKey(accumA[i])) dic[accumA[i]] += 1;
                else dic.Add(accumA[i], 1);
            }

            var result = 0L;
            result += dic.ContainsKey(0) ? dic[0] : 0;
            for (int i = 1; i < N + 1; i++)
            {
                if (dic.ContainsKey(accumA[i])) dic[accumA[i]] -= 1;
                if (N >= i + K - 1)
                {
                    if (dic.ContainsKey(accumA[i + K - 1])) dic[accumA[i + K - 1]] += 1;
                    else dic.Add(accumA[i + K - 1], 1);
                }
                result += dic.ContainsKey(accumA[i]) ? dic[accumA[i]] : 0;
            }
            return result;
        }
    }
}


Measured memory_bytes: 53860
#tuple -> float
def dst(point_a, point_b):
    return ((point_a[0]-point_b[0])**2 + (point_a[1]-point_b[1])**2)**(0.5)
   

def main():
    #N!通りの経路を構成しても間に合うので構成する
    n = int(input()) 
    towns = []
    for _ in range(n):
        x, y = map(int, input().split())
        towns.append((x, y))
    cnt = 0 
    s = 0
    from itertools import permutations
    for i in permutations(towns):
        cnt += 1
        for j in range(n-1):
            s += dst(i[j], i[j+1])

    ans = s/cnt
    print(ans)
main()

Measured memory_bytes: 3188
s = list(input())
cnt = 0
cnt_1=0
s_even = s[0::2]
s_odd = s[1::2]
for i in range(0,len(s_even)):
    if 'L' in s_even:
        cnt+=1
    else:
        cnt+=0
        
        
for i in range(0,len(s_odd)):
        if 'R' in s_odd:
            cnt_1+=1
            
        else:
            cnt_1+=0
            
      
            
if cnt ==0   and  cnt_1 ==0:
    print('Yes')
else:
    print('No')

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


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll Q,H,S,D;
    cin>>Q>>H>>S>>D;
    ll ans = 0;
    ll N;
    cin>>N;
    v a = {8*Q,4*H,2*S,D};
    ans += (N/2)*(*min_element(a.begin(),a.end()));
    N%=2;
    ans += (N/1)*(*min_element(a.begin(),a.end()-1))/2;
    N%=1;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int h,w;
  cin>>h>>w;
  string s[h];
  for(int i=0;i<h;i++) cin>>s[i];
  bool e[h+10][w+10];
  memset(e,0,sizeof(e));
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      e[h-i-1][j]=s[i][j]=='#';
  /*//
    for(int i=h-1;i>=0;i--)
    for(int j=0;j<w;j++)
    cout<<e[i][j]<<" \n"[j==w-1];
  //*/
  int ans=2;
  
  time_t start=clock();
  srand((unsigned)time(NULL));
  int k=0;
  while((double)(clock()-start)/CLOCKS_PER_SEC<1.8){
    k++;
    for(int i=1;i<=h+k;i++){
      int x=0,y=0,tmp=e[0][0],p;
      while(x<=w&&y<=h){
	//if(i==4&&k==2) cout<<y<<" "<<x<<endl;
	p=e[y][x];
	if((i*(x+1))%(w+k)==0) x++,y++;
	if((i*(x+1))/(w+k)==y) x++;
	else y++;
	if(!p&&e[y][x]) tmp++;
      }
      //cout<<i<<":"<<tmp<<endl;
      //if(i==4&&k==2) cout<<tmp<<endl;
      ans=max(ans,tmp+1);
    }
    for(int j=1;j<=w+k;j++){
      int x=0,y=0,tmp=e[0][0],p;
      while(x<=w&&y<=h){
	p=e[y][x];
	if((j*(y+1))%(h+k)==0) x++,y++;
	else if((j*(y+1))/(h+k)==x) y++;
	else x++;
	if(!p&&e[y][x]) tmp++;
      }
      //cout<<j<<" "<<tmp<<endl;
      ans=max(ans,tmp+1);
    }
  }
  //cout<<k<<endl;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4028
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop int t;cin>>t;while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod (1e9+7)
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
signed main()
{
    crap;
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    
    sort(a,a+n);
    int mn=INT_MAX;
    for(int i=0;i<n;i++)
    {
        if(i+k-1<n){
            if(a[i+k-1]-a[i]<mn)
            mn=a[i+k-1]-a[i];
        }
    }
    cout<<mn<<endl;
}

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

#define ll long long
#define sz(x) (int)x.size();
#define go ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

const ll N=1e5+5;
ll cnt[N];

int main(){
	go;
	ll n;
	cin>>n;
	vector<ll> a(n);
	ll sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cnt[a[i]]++;
		sum+=a[i];
	}
	ll q;
	cin>>q;
	while(q--){
		ll x,y;
		cin>>x>>y;
		sum=sum-cnt[x]*x+cnt[x]*y;
		cnt[y]+=cnt[x];
		cnt[x]=0;
		cout<<sum<<'\n';
	}
	
}

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

int main(){
 string word;
 int count;

 int h;
 char first;
 while( cin >> word && word != "-" ){
  cin >> count;
  for( int i=0; i<count; i++ ){
   cin >> h;
   for( int j=0; j<h; j++ ){
    first = word[0];
    for( int k=0; k<word.size()-1; k++ ){
      word[k]=word[k+1];
    }
    word[word.size()-1]=first;
   }
  }

   cout << word << endl;
 }

 return 0;
}


Measured memory_bytes: 3092