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

bitset<10000001> pr;
vector<int> primes;
int count=0;
void sieve()
{
    //cout<<pr[0];
    for(int i=2;i*i<10000001;i++)
    {
        if(pr[i])continue;
        for(int j=i*2;j<1000001;j+=i)
        {
            pr[j]=i;
        }
    }
    for(int i=2;i<=1000001;i++)
    {
        if(!pr[i])primes.push_back(i);
    }
}
vector<int> tl;
void primeFctorization(int n)
{
    set<int> th;
    vector<int> ans;
    int N=n;
    n=abs(n);
    for(int i=0;i<primes.size()&&primes[i]*primes[i]<=n;i++)
    {
        while(n%primes[i]==0)
        {
            th.insert(primes[i]);
            n/=primes[i];
            ans.push_back(primes[i]);
            //cout<<primes[i]<< " ";
        }
    }
    if(n>1){
        th.insert(n);
        //cout<<n;;
        ans.push_back(n);
    }
    if(th.size()>=3)
    {
        tl.push_back(N);
        ::count++;
        //cout<<N<<endl;
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int count=0;
    for(int i=0;i<n;i++)
    {
        bool x=true;
        for(int j=0;j<=i;j++)
        {
            if(a[j]>a[i])
            {
                x=false;
                break;
            }
        }
        if(x)count++;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
N = int(input())
Ri = [list(map(int, input().split())) for _ in range(N)]
Bi = [list(map(int, input().split())) for _ in range(N)]

Ri.sort(key=lambda x: x[0], reverse=True)
Bi.sort(key=lambda x: x[1])
found = [False for _ in range(N)]
count = 0

for b in Bi:
    for (i, r) in enumerate(Ri):
        if not found[i] and r[0] < b[0] and r[1] < b[1]:
            count += 1
            found[i] = True
            break
print(count)

Measured memory_bytes: 3064
import java.util.Scanner;

/**
 * @author Dell
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		in.close();
		System.out.println(n*n*n);// TODO Auto-generated method stub

	}

}


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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        
        var a = ab[0];
        var b = ab[1];
        var s = a * b;
        var t = a + b - 1;
        Console.WriteLine(s - t);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
signed main(void){
	long long n;
	cin>>n;
	long long x=100;
	for(long long i=1;i<=3760;i++){
		x+=(x/100);
		if(x>=n){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

int x[10][10];

int conv(int a, int b, int c, int d) {
  return x[x[x[x[0][a]][b]][c]][d];
}

int check(int a, int b, int c, int d, int e) {
  return x[conv(a, b, c, d)][e] == 0;
}

bool out(int a, int b, int c, int d, int e) {
  bool res = false;
  for (int i = 0; i < 10; i++) {
    if (i != a) res |= check(i, b, c, d, e);
    if (i != b) res |= check(a, i, c, d, e);
    if (i != c) res |= check(a, b, i, d, e);
    if (i != d) res |= check(a, b, c, i, e);
    if (i != e) res |= check(a, b, c, d, i);
  }
  if (a != b) res |= check(b, a, c, d, e);
  if (b != c) res |= check(a, c, b, d, e);
  if (c != d) res |= check(a, b, d, c, e);
  if (d != e) res |= check(a, b, c, e, d);
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> x[i][j];
    }
  }

  int ans = 0;
  for (int a = 0; a < 10; a++) {
    for (int b = 0; b < 10; b++) {
      for (int c = 0; c < 10; c++) {
        for (int d = 0; d < 10; d++) {
          if (out(a, b, c, d, conv(a, b, c, d))) ans++;
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
string s;
cin>>s;
ll W,S,N;
N=0;
W=15-s.size();
S=s.size();
rep(i,S){
if(s[i]=='o'){
N=N+1;}}
if(N+W>=8){
cout<<"YES"<<endl;}
else{cout<<"NO"<<endl;}



}



Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// input
	nums := inputLineAsNumArray(3)
	minIdx, midIdx, maxIdx := getOrder3(nums)

	// count
	count := 0

	// first step
	numFirstStep := nums[maxIdx] - nums[midIdx]

	for i := 0; i < numFirstStep; i++ {
		nums[minIdx]++
		nums[midIdx]++
		count++
	}

	// second step
	for nums[minIdx] < nums[maxIdx] {
		nums[minIdx] += 2
		count++
	}

	// third step (if required)
	if nums[minIdx] > nums[maxIdx] {
		nums[midIdx]++
		nums[maxIdx]++
		count++
	}

	fmt.Println(count)
}

func getOrder3(nums []int) (int, int, int) {
	max := nums[0]
	min := nums[0]
	var minIdx, midIdx, maxIdx int

	for i := 0; i < len(nums); i++ {
		if nums[i] > max {
			max = nums[i]
			maxIdx = i
		}
		if nums[i] < min {
			min = nums[i]
			minIdx = i
		}
	}
	switch minIdx + maxIdx {
	case 1:
		midIdx = 2
	case 2:
		midIdx = 1
	case 3:
		midIdx = 0
	default:
		midIdx = 0
	}

	return minIdx, midIdx, maxIdx
}

func inputLineAsNumArray(length int) []int {
	line := strings.Split(readLine(), " ")
	var nums []int
	for i := 0; i < length; i++ {
		num, _ := strconv.Atoi(line[i])
		nums = append(nums, num)
	}
	return nums
}

func readLine() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve(A));

        sc.close();
    }

    static String solve(int[] A) {
        int[] spots = new int[A.length + 2];
        for (int i = 1; i < spots.length - 1; ++i) {
            spots[i] = A[i - 1];
        }

        int total = IntStream.range(0, spots.length - 1).map(i -> Math.abs(spots[i + 1] - spots[i])).sum();

        return IntStream.range(1, spots.length - 1)
                .mapToObj(i -> String.valueOf(total - Math.abs(spots[i] - spots[i - 1])
                        - Math.abs(spots[i + 1] - spots[i]) + Math.abs(spots[i + 1] - spots[i - 1])))
                .collect(Collectors.joining("\n"));
    }
}

Measured memory_bytes: 63272
N = int(input())
A = list(map(int, input().split()))

ans = 1
MOD = 1000000007
cnt = [0 for _ in range(N+1)]
cnt[0] += 3

for a in A:
    ans = ans*cnt[a]%MOD
    if ans == 0:
        break
    cnt[a] -= 1
    cnt[a+1] += 1
print(ans)


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

//-------------------------------------------------------



int main()
{
    float n,t,a;
    float h[1001];
    scanf("%f%f%f\n",&n,&t,&a);
    float min=100000;
    int res=0;
    for (int i = 0; i < n; i++) {
        scanf("%f\n",&h[i] );
        float temp1,temp2;
        temp1=t-0.006*h[i];

        temp2=abs(temp1-a);
        if (min>temp2) {
            min=temp2;
            res=i;
        }
    }
    printf("%d\n",res+1 );
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
// #include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(register int i=a;i<=(int)b;i++)
#define All(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<int> VI;
typedef pair<int,int> PII;
const double PI=acos(-1.0);
const double eps=1e-6;
const long long mod=1e9+7;
const int inf=2147483647;
const int maxn=100005;
ll qpow(ll x,ll y,ll Mod) {ll ans=1,base=x%Mod; while(y){if(y&1)ans=(ans*base)%Mod;base=(base*base)%Mod;y>>=1;} return ans;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}

int n;

struct node
{
	int x,y;
};

vector<node> vec1,vec2;
bool cmp2(node x1,node x2){
	return x1.x>x2.x;
}
bool cmp1(node x1,node x2){
	return x1.y<x2.y;
}

int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	while(n--){
		string s;
		cin>>s;
		int a=0,b=0;
		for(int i=0;i<(int)s.size();i++){
			if(s[i]=='(') a++;
			else if(a>0) a--;
			else b++; 
		}
		if(a>=b) vec1.pb(node{a,b});
		else vec2.pb(node{a,b});
	}
	sort(All(vec1),cmp1);
	sort(All(vec2),cmp2);
	bool f=true;
	int giao=0;
	rep(i,0,vec1.size()-1){
		giao-=vec1[i].y;
		if(giao<0) f=false;
		giao+=vec1[i].x;
	}
	rep(i,0,vec2.size()-1){
		giao-=vec2[i].y;
		if(giao<0) f=false;
		giao+=vec2[i].x;
	}
	if(giao!=0) f=false;
	if(f) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;

	return 0;
}

Measured memory_bytes: 11276
#include<stdio.h>
int main(void){
  int N,l,i;
  scanf("%d",&N);
  int A,E[N+1];
  for(i=1;i<=N;i++){scanf("%d",&A);E[A]=i;}
  for(l=1;l<=N;l++)printf("%d ",E[l]);
  return 0;}

Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int n, growth;

		while (!(line = br.readLine()).equals("0")) {
			n = Integer.parseInt(line);
			line = br.readLine();
			growth = getGrowthRate(line);
			System.out.println(find(n, growth, line));
		}
	}

	// 成長率
	static int getGrowthRate(String progression) {
		int h1, h2, result = 0;
		int[] g = new int[4];
		StringTokenizer st = new StringTokenizer(progression);

		h1 = Integer.parseInt(st.nextToken());
		for (int i = 0; i < 4; i++) {
			h2 = Integer.parseInt(st.nextToken());
			g[i] = h2 - h1;
			h1 = h2;
		}
		Arrays.sort(g);
		for (int i = 0; i < 3; i++) {
			if (g[i] == g[i + 1])
				result = g[i];
		}
		return result;
	}

	// 雑草探し
	static int find(int n, int growth, String progression) {
		int h0, h1, h2, result = 0;
		StringTokenizer st = new StringTokenizer(progression);

		h1 = Integer.parseInt(st.nextToken());
		for (int i = 0; i < n; i++) {
			h2 = Integer.parseInt(st.nextToken());
			if (h1 + growth != h2) {
				if (i == n - 1) {
					result = h2;
					break;
				}
				h0 = h1;
				h1 = h2;
				h2 = Integer.parseInt(st.nextToken());
				if (h1 + growth != h2) {
					result = h1;
					break;
				} else {
					result = h0;
					break;
				}
			} else {
				h1 = h2;
			}
		}
		return result;
	}

}

Measured memory_bytes: 22072
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;
    A.sort();
    auto X = A.back;
    A.popBack;

    long y = X / 2;
    long z = X % 2 == 0 ? X / 2 : X / 2 + 1;

    long ans = -1;
    long min_dif = 1L << 59;

    foreach (a; A) {
        long c = abs(a - y);
        long d = abs(a - z);
        long e = min(c, d);
        if (e < min_dif) {
            min_dif = e;
            ans = a;
        }
    }

    writeln(X, " ", ans);
}


Measured memory_bytes: 4368
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pil pair<int,ll>
#define pii pair<int,int>
#define ull unsigned long long
#define base 1000000000000000000
#define fio ios::sync_with_stdio(false);cin.tie(0)

using namespace std;

const double g=10.0,eps=1e-12;
const int N=300000+10,maxn=100000+10,inf=0x3f3f3f3f,INF=0x3f3f3f3f3f3f3f3f;

int ans[N],bl[N];
int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&b,&a);
    bl[1]=a;
    if(b==1)
    {
        if(a!=n)
        {
            puts("-1");
            return 0;
        }
        for(int i=1; i<=n; i++)
            printf("%d ",n-i+1);
        puts("");
        return 0;
    }
    int te=(n-a)/(b-1);
    for(int i=2; i<=b; i++)
        bl[i]=te;
    te=(n-a)%(b-1);
    for(int i=2; te&&i<=b; te--,i++)
        bl[i]++;

    for(int i=1; i<=b; i++)
    {
        if(bl[i]>a || !bl[i])
        {
            puts("-1");
            return 0;
        }
    }
    int now=0;
    for(int i=1; i<=b; i++)
    {
//            printf("\n%d+++\n",bl[i]);
        te=now+bl[i];
        for(int j=1; j<=bl[i]; j++)
            printf("%d ",te--);
        now+=bl[i];
    }
    return 0;
}
/********************

********************/


Measured memory_bytes: 2944
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	cin>>n;
	vector<double> dp(101,-INF);
	dp[0] = 0;
	vint _t(n);
	vint _v(n);
	rep(i,n) cin>>_t[i];
	rep(i,n) cin>>_v[i];
	rep(_,n){
		int t=_t[_],v=_v[_];
		rep(__, t){
			vector<double> next(101,-INF);
			rep(j,v+1){
				if(j-1>=0) maxs(next[j-1], dp[j]+(j-0.5));
				maxs(next[j], dp[j]+j);
				if(j+1<=v) maxs(next[j], dp[j]+(j+0.25));
				if(j+1<=v) maxs(next[j+1], dp[j]+(j+0.5));
			}
			dp = next;
		}
		// rep(i,40){
		// 	cout<<i<<" "<<dp[i]<<endl;
		// }
		// cout<<endl;
	}
	cout<<dp[0]<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    cout << s.rfind("Z") - s.find("A") + 1 << endl;
}


Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int memo[20][20];
int dfs(int y, int x)
{
    if(y < 0 or x < 0) return 0;
    if(memo[y][x] == -1) return 0;
    if(memo[y][x]) return memo[y][x];
    if(y == 0 and x == 0) return memo[y][x] = 1;
    return memo[y][x] = dfs(y, x - 1) + dfs(y - 1, x);
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    while(cin >> a >> b, a | b)
    {
        a--, b--;
        memset(memo, 0, sizeof(memo));
        int n; cin >> n;
        for(int i = 0; i < n; i++)
        {
            int x, y; cin >> x >> y;
            x--, y--;
            memo[y][x] = -1;
        }
        cout << dfs(b, a) << endl;
    }
    return 0;
}




Measured memory_bytes: 2996
//tree distfromroot and calcparent
//tenka12016-B
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}

typedef struct{
int val;
int node;
}sd;

int sdsortfnc(const void *a,const void *b){
if(((sd*)a)->val > ((sd*)b)->val){return -1;}
if(((sd*)a)->val < ((sd*)b)->val){return 1;}
return 0;
}

typedef struct{
    long long st;
    long long fi;
    long long kr;
}rs;

typedef struct{
    long long st;
    long long kz;
}mkj;

int sortfnc(const void *a,const void *b){
if(((rs*)a)->st == ((rs*)b)->st){return 0;}
if(((rs*)a)->st < ((rs*)b)->st){return -1;}
return 1;
}

void makemkj(rs g[],mkj x[],long long n){
    long long i,ms=0,nst=g[0].st;
    for(i=1;i<n;i++){
        if(g[i].st!=g[i-1].st){
            x[nst].kz=i-ms;
            x[nst].st=ms;
            nst=g[i].st;ms=i;
        }
    }
    x[nst].kz=n-ms;
    x[nst].st=ms;
}

int dist[524288],par[524288];
void dfs(int t,int l,int bp,rs g[],mkj x[]){
  int i;
  if(dist[t]<=l){return;}
  dist[t]=l;
  par[t]=bp;
  for(i=x[t].st;i<x[t].st+x[t].kz;i++){
    dfs(g[i].fi,l+1,t,g,x);
  }
}

int main(void){
    int i,j,n,m,k,a,b,c,h,w,r=0,l,t;
    int res=0,num[524288];
    int v[524288],p[524288];
    int arr[524288],ac;
    rs g[524288];
    mkj x[524288];
    sd dat[524288];
    scanf("%d",&n);
    for(i=2;i<=n;i++){
      scanf("%d",&a);
      g[2*i-4].st=i;
      g[2*i-4].fi=a;
      g[2*i-4].kr=1;
      g[2*i-3].st=a;
      g[2*i-3].fi=i;
      g[2*i-3].kr=1;
    }
    qsort(g,2*(n-1),sizeof(g[0]),sortfnc);
    makemkj(g,x,2*(n-1));
    for(i=0;i<=n;i++){
      dist[i]=inf;
      num[i]=-1;
    }
    dfs(1,0,0,g,x);
    for(i=1;i<=n;i++){
      dat[i-1].node=i;
      dat[i-1].val=dist[i];
    }
    qsort(dat,n,sizeof(dat[0]),sdsortfnc);
    for(i=0;i<n;i++){
      w=dat[i].node;
      if(num[w]!=-1){continue;}
      ac=0;
      for(j=x[w].st;j<x[w].st+x[w].kz;j++){
        if(num[g[j].fi]==-1){continue;}
        arr[ac]=num[g[j].fi];
        ac++;
      }
      if(ac==0){
        num[w]=0;
        continue;
      }
      t=-inf;
      qsort(arr,ac,sizeof(int),sortfnckj);
      for(j=0;j<ac;j++){
        t=max(t,arr[j]+j+1);
      }
      num[w]=t;
    }
    printf("%d\n",num[1]);
    return 0;
}


Measured memory_bytes: 30008
let parent i = int_of_float (floor (float_of_int i) /. 2.)

let left i = 2*i

let right i = 2*i + 1

let build_max_heap (t : int array) h =
  let rec max_heapify i =
    let l = left i in
    let r = right i in
    let m = if l <= h && t.(l) > t.(i) then l else i in
    let m = if r <= h && t.(r) > t.(m) then r else m in
    if m <> i then begin
      let tmp = t.(i) in t.(i) <- t.(m); t.(m) <- tmp;
      max_heapify m
    end
  and doit i =
    if i > 0 then (max_heapify i; doit (i - 1))
  in doit (parent h)

let () =
  let h = read_int () in
  let t = Array.make (h + 1) 0 in
  let rec read i =
    if i <= h then (t.(i) <- Scanf.scanf "%d " (fun i -> i); read (i + 1))
  in read 1;
  build_max_heap t h;
  let rec doit i =
    if i <= h then (print_string " "; print_int t.(i); doit (i + 1))
  in doit 1;
  print_string "\n"

Measured memory_bytes: 8400
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <bitset>
using namespace std;
  
const double EPS = 1e-9;

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

void Fill(vector<string> &v, int x, int y, char c){
	if(v[y][x] == c){
		v[y][x] = '0';
		for(int i = 0; i < 4; i++){
			Fill(v, x+dx[i], y+dy[i], c);
		}
	}
}

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

int main(){
	int H, W;

	while(cin >> H >> W, H+W){
		vector<string> v(H+2);
		for(int i = 0; i < W+2; i++){
			v[0]+='0';
		}
		v[H+1] = v[0];
		string s;
		for(int i = 1; i <= H; i++){
			cin >> s;
			v[i] = '0'+s+'0';
		}
		int cnt = 0;

		for(int i = 1; i < W+1; i++){
			for(int j = 1; j < H+1; j++){
				if(v[j][i] != '0'){
					cnt++;
					Fill(v, i, j, v[j][i]);	
					//string a;
					//cin >> a;
					//print_vs(v);
				}
			}
		}

		cout << cnt << endl;
	}
  
    return 0;
}

Measured memory_bytes: 2020
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	vs := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&vs[i])
	}

	sort.Float64s(vs)
	cur := vs[0]
	for i := 1 ; i < n; i++ {
		cur = (cur +vs[i])/2.0
	}
	fmt.Println(cur)

}


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

int main() {
    int n, ac = 0, tle = 0, wa = 0, re = 0;
    cin >> n;
    string s[n];
    rep(i, n) { cin >> s[i]; }
    rep(i, n) {
        if (s[i] == "AC") {
            ac++;
        } else if (s[i] == "TLE") {
            tle++;
        } else if (s[i] == "WA") {
            wa++;
        } else if (s[i] == "RE") {
            re++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}

Measured memory_bytes: 6764
#include <bits/stdc++.h>
#define inchar			getchar
#define outchar(x)		putchar(x)
#define ll long long 
#define int long long //
#define all(v) v.begin(), v.end()
#define SP outchar(' ')
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
#define LN outchar('\n')
#define endl '\n'
using namespace std;

template<typename T> void inpos(T &x){x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=0; if(c=='-')neg=1;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}
template<typename T> void outpos(T n){if(n<0){outchar('-');n*=-1;}char snum[65];int i=0;do{snum[i++]=n%10+'0';n/=10;}while(n);i=i-1;while(i>=0)outchar(snum[i--]);}
inline void instr(char *str){register char c=0;register int i=0;while(c<33)c=inchar();while(c!='\n'&&c!=' '&&c!=EOF){str[i]=c;c=inchar();++i;}str[i]='\0';}
template <typename T, typename TT> inline void inpos(T &n, TT &m) { inpos(n); inpos(m);}
template <typename T, typename TT ,typename TTT> inline void inpos(T &n, TT &m, TTT &o) { inpos(n,m); inpos(o);}
template <typename T, typename TT ,typename TTT, typename TTTT> inline void inpos(T &n, TT &m, TTT &o , TTTT &p) { inpos(n,m); inpos(o,p);}
int N;
int MAT[22][22];
const int mod = 1e9+7;

// 0 matlab free 1 matlab empty

int DP[(1 << 22)][25];
int solve (int pairsC , int womenSet ) {
	// trace(N);
	// cerr << pairsC << " " <<womenSet<<endl;
	if (pairsC == N) {
		return 1;
	}
	// int & res = DP[womenSet][pairsC];
	if( DP[womenSet][pairsC] !=-1 ){return  DP[womenSet][pairsC];}

	// find unOccupied Man, find unoccupied woman // match them // call solve on new instances
	// int manx = 1 << pairsC;
	int ans = 0;
	for(int j = 0; j<N ; j++ ) {
		// trace(womenSet);
		if (((womenSet& (1<<j)) == 0) &&( MAT[pairsC][j] == 1)) { // compatible
			
			ans += solve(pairsC +1 , (1<<j)|womenSet );
			ans%=mod;
			
		}
	}
	 DP[womenSet][pairsC] = ans;
	return ans;
}




int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	// int n;
	cin>>N;

	// memset(MAT, -1, sizeof(MAT));
	memset(DP, -1, sizeof(DP));
	for (int i =0; i<N;i++){
		for (int j = 0; j<N;j++) {
			cin >> MAT[i][j];
			// trace(MAT[i][j]);
		}
	}
	int x = solve(0,0);
	cout<<x <<'\n';
	
}

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

using namespace std;

void swap(int tree[], int i, int j) {
    int temp = tree[i];
    tree[i] = tree[j];
    tree[j] = temp;
}

int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }
void maxHeapify(int tree[], int parent, int H) {
    int largest = -1;
    int l = left(parent);
    int r = right(parent);
    if(l <= H && tree[l] > tree[parent]) {
        largest = l;
    } else {
        largest = parent;
    }

    if(r <= H && tree[r] > tree[largest]) {
        largest = r;
    }

    if(largest != parent) {
        swap(tree, parent, largest);
        maxHeapify(tree, largest, H);
    }
}

void buildTree(int tree[],int H){
	for(int i=H/2;i>0;i--){
		maxHeapify(tree,i,H);
	}
}
int main() {
    int n;
	cin >> n;
    int tree[n];
    for(int i = 1; i <= n; i++) {
		scanf("%d",&tree[i]);		
    }
	buildTree(tree,n);

	for(int i = 1; i <= n ; i++){
		printf(" %d",tree[i]);	
	}
	printf("\n");
}


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

using namespace std;
using ll = long long;
using ld = long double;
using vec = vector<int>;


int main() {
    

string s;
cin>>s;

int k=s.size();
for(int i=0;i<k;i++){
    if(s[i]=='?'){
        s.replace(i,1,"D");
    }
}
cout<<s<<endl;



}

Measured memory_bytes: 3752
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<functional>
using namespace std;
int main() {
	vector<pair<int,string>> x(1000);
	string a;
	int j=1,s=0,m=0;
	while(cin >> a) {
		for (int i = 0; i <j ; i++) {
			if (x[i].second == a) {
				x[i].first++;
				break;
			}
			if (i == j - 1) {
				x[i].second = a;
				x[i].first = 1;
				j++;
				break;
			}
		}
	}
	sort(x.begin(), x.end(), greater<pair<int, string>>());
	for (int i = 0; i < j; i++) {
		if (x[i].second.size() > s) {
			s = x[i].second.size();
		}
	}
	for (int i = 0; i < j; i++) {
		if (x[i].first > m) {
			m = x[i].first;
		}
	}
	for (int i = 0; i < j; i++) {
		if (x[i].first == m) {
			cout << x[i].second << ' ';
		}
	}
	for (int i = 0; i < j; i++) {
		if (x[i].second.size() == s) {
			cout << x[i].second << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main() {
	int N;
	int C[500], S[500], F[500];
	
	cin >> N;
	REP(i, N - 1) scanf("%d %d %d", C + i, S + i, F + i);
	
	REP(i, N) {
		int ans = 0;
		FOR(j, i, N - 1) {
			if (ans <= S[j]) ans = S[j];
			else ans += (ans + F[j] - 1) / F[j] * F[j] - ans;
			ans += C[j];
		}
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define int long long
#define ld double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD =1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1LL;}return res%p;}
const int N=2*1e5+2,M=20;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ordered_set s;
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	// freopen("out10.txt","w",stdout);
	#endif
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	vector<pii> v;
	for(int i=0;i<n;i++)
	{
		v.pb({a[i],i});
	}
	sort(all(v));
	set<int> s;
	s.insert(-1);
	s.insert(n);
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int x=v[i].se;
		auto lol=s.upper_bound(x);
		int r=*lol;
		lol--;
		int l=*lol;
		ans+=(r-x)*(x-l)*v[i].fi;
		s.insert(v[i].se);
	}
	cout<<ans;
}

Measured memory_bytes: 15212
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int c[6],m=0;
	rep(i,0,6) cin>>c[i];
	m=c[0]+5*c[1]+10*c[2]+50*c[3]+100*c[4]+500*c[5];
	o((m>=1000?1:0));
}

Measured memory_bytes: 1164
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {
    int n,d,x ;
    cin >> n >> d >> x ;
    int a[n+1] ;
    for(int i=1;i<=n;i++){
       cin >> a[i] ;
    } 
    int ans = 0 ;

    for(int i=1;i<=n;i++){
        int s = 1 ;
        while(s<=d){
            ans+=1 ;
            s += a[i] ;
        }
    }
    
    cout << ans+x << endl ;

	return 0;
}



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

using namespace std;
const int N = 5e5 + 10;
const int MOD = 1e9 + 7;

int _sum (int, int);
int _mul (int, int);
int _pow (int, int);
int gcd (int, int);

int n, m, a[N], b[N], c[N], cnt[N];
vector <int> X;

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

	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		X.push_back(a[i]);
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i] >> c[i];
		X.push_back(c[i]);
	}

	sort(X.begin(), X.end());
	X.resize(unique(X.begin(), X.end()) - X.begin());

	for (int i = 0; i < n; i++) {
		int v = lower_bound(X.begin(), X.end(), a[i]) - X.begin();
		cnt[v]++;
	}
	for (int i = 0; i < m; i++)
		c[i] = lower_bound(X.begin(), X.end(), c[i]) - X.begin();

	int mn = 0;
	for (int i = 0; i < m; i++) {
		for (; mn < c[i] && b[i] > 0; mn++) {
			int carry = min(cnt[mn], b[i]);
			b[i] -= carry;
			cnt[mn] -= carry;
			cnt[c[i]] += carry;
			if (cnt[mn])
				mn--;
		}
	}

	long long sum = 0;
	for (int i = 0; i < X.size(); i++)
		sum += 1LL * cnt[i] * X[i];
	cout << sum << endl;
}

int gcd (int a, int b) {
	return !b? a : gcd (b, a % b);
}

// int choose (int r, int k) {
// 	return _mul (f[k], _mul(inv[r], inv[k - r]));
// }

int _sum (int a, int b) {
	return a + b - (a + b >= MOD? MOD : 0);
}

int _mul (int a, int b) {
	return 1LL * a * b % MOD;
}

int _pow (int a, int b) {
	if (!b) 
		return 1;
	int res = _pow (a, b >> 1);
	res = _mul (res, res);
	if (b & 1)
		res = _mul (res, a);
	return res;
}

// SamMHD :: Jun27-2019 :: Another Day with Shayan...

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


void solve(long long N, long long M, std::vector<long long> A){
    ll summ = accumulate(A.begin(),A.end(),0LL);
    if (N < summ) cout << -1 << endl;
    else cout <<  N-summ << endl;

}

// 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 N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define mp make_pair
#define _GLIBCXX_DEBUG
const int INF=1e15;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int MAX_DIGIT=50;
vector<vector<int>>dp(100,vector<int>(2,-1));

signed main(){
    int N,K;cin>>N>>K;
    int A[N];
    REP(i,N)cin>>A[i];
    dp[0][0]=0;
    REP(d,MAX_DIGIT){
        int mask=1ll<<(MAX_DIGIT-d-1);
        int num=0;
        for(int i=0;i<N;i++){
            if(A[i]&mask)num++;
        }
        int cost0=mask*num;
        int cost1=mask*(N-num);
        if(dp[d][1]!=-1){
            chmax(dp[d+1][1],dp[d][1]+max(cost0,cost1));
        }
        if(dp[d][0]!=-1){
            if(K&mask){
                chmax(dp[d+1][1],dp[d][0]+cost0);
            }
        }
        if(dp[d][0]!=-1){
            if(K&mask) chmax(dp[d+1][0],dp[d][0]+cost1);
            else chmax(dp[d+1][0],dp[d][0]+cost0);

        }
    }
    cout<<max(dp[MAX_DIGIT][0],dp[MAX_DIGIT][1])<<endl;
}

Measured memory_bytes: 1024
#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 ll inf=1e9+7;
const ll INF=1e18;

int prime_factor(ll x){
    int res=0;
    for(ll i=2;i*i<=x;i++){
        if(x%i==0)res++;
        while(x%i==0)x/=i;
    }
    if(x!=1)res++;
    return res;
}

int main(){
    ll a,b;cin>>a>>b;
    ll tmp=__gcd(a,b);
    cout<<prime_factor(tmp)+1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <queue>
using namespace std;

struct Node {
  int elm;
  Node* next;
  Node* prev;

  // Node() :
  //   elm(0), next(nullptr), prev(nullptr) {}
};

Node* nil;

void init() {
  nil = new Node();
  nil->next = nil;
  nil->prev = nil;
}

void insert(const int& key) {
  Node* x = new Node();
  x->elm = key;

  // 番兵の直後に要素を追加
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

Node* list_search(const int& key) {
  Node* current = nil->next; // 番兵の次の要素から辿る
  while(current != nil && current->elm != key) {
    current = current->next;
  }
  return current;
}

void delete_node(Node* t) {
  if(t == nil) return;

  t->prev->next = t->next;
  t->next->prev = t->prev;
  delete t;
}

void delete_first() {
  delete_node(nil->next);
}

void delete_last() {
  delete_node(nil->prev);
}

void print_list() {
  Node* cur = nil->next;
  int isf = 0;
  while(true) {
    if(cur == nil) break;
    if(isf++ > 0) printf(" ");
    printf("%d", cur->elm);
    cur = cur->next;
  }
  printf("\n");
}

int main() {
  int n;
  cin >> n;
  string command; int elm;
  init();

  for(int i = 0; i < n; i++) {
    cin >> command;
    if(command == "insert") {
      cin >> elm;
      insert(elm);
    } else if(command == "deleteFirst") {
      delete_first();
    } else if(command == "deleteLast") {
      delete_last();
    } else if(command == "delete") {
      cin >> elm;
      delete_node(list_search(elm));
    }
  }
  print_list();
}




Measured memory_bytes: 34436
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int n, ans = 0;
    cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; ++i) cin >> l.at(i);
    sort(l.begin(), l.end());
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            for(int k = j + 1; k < n; ++k){
                if(l.at(i) != l.at(j) && l.at(j) != l.at(k) && l.at(k) != l.at(i) && l.at(i) + l.at(j) > l.at(k)) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define endl "\n"

const int MOD = 1000000007;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	
	vector<int> v;
	v.push_back(a);
	v.push_back(b);
	v.push_back(c);
	
	sort(v.begin(),v.end());
	if(v[0] == 5 && v[1] == 5 && v[2] == 7) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i;
    scanf("%d %d",&n,&m);
    for(i=(m/n);i>=1;i--)
    {
        if(m%i==0 && (m/i)>=n)
        {
            printf("%d",i);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
using ll=long long;
using namespace std;
//const int INF = 7+(1e+9);
ll GCD(ll x, ll y)
{
    if (y == 0)
    {
        return x;
    }
    else
    {
        return GCD(y, x % y);
    }
}
ll LCM(ll x, ll y)
{
    return x / GCD(x, y) * y;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
vector<vector<char>> vec(12,vector<char>(12));

int dx[]={0,-1,0,1};
int dy[]={1,0,-1,0};
int dfs(int y,int x){
    vec[y][x]='5';
    for(int i=0;i<4;i++){
        if(x+dx[i]<12&&x+dx[i]>=0&&y+dy[i]<12&&y+dy[i]>=0&&vec[dy[i]+y][dx[i]+x]=='1'){
            dfs(y+dy[i],x+dx[i]);
        }
    }
    return 0;
}
int main(){
    int n;cin>>n;
    map<string,int> mp;
    for(int i=0;i<n;i++){
        string s;cin>>s;
        if(s=="insert"){
            string t;cin>>t;
            mp[t]=1;
        }else{
            string t;cin>>t;
            if(mp[t]==1){
                cout<<"yes"<<endl;
            }else{
                cout<<"no"<<endl;
            }
        }
    }
}


Measured memory_bytes: 52504
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		//int n=sc.I;
		int[] s=sc.Ia;
		int ans=0;
		var a=sc.Arr(s[0],()=>sc.Ia);
		for(int i = 0;i<s[0]-1;i++) {
			for(int j = i+1;j<s[0];j++) {
				double d=0;
				for(int k = 0;k<s[1];k++) {
					d+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
				}
				if(Sqrt(d)==(long)Sqrt(d)){
					ans++;
				}
			}
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int makechess(int h, int w){
    for ( int i = 0; i < h; i++ ){
        for ( int j = 0; j < w; j++ ){
            if ( (i+j) % 2 == 0 ) cout << "#";
            else cout << ".";
        }
        cout << endl;
    }
    return 0;
}

int main(){
    int a, c, d;
    a = 0, c = 1, d = 1;
    while ( c > 0 || d > 0 ){
        cin >> c >> d;
        if ( c > 0 || d > 0 ){
            makechess(c,d);
            cout << endl;
        }
       
    }
    
    return 0;
    
}



Measured memory_bytes: 3088
n, a, b = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp.split("")
rem1 = a + b
rem2 = b
s.each do |e|
  if e == "a" then
    if rem1 > 0 then
      puts "Yes"
      rem1 -= 1
    else
      puts "No"
    end
  elsif e == "b" then
    if rem1 > 0 && rem2 > 0 then
      puts "Yes"
      rem1 -= 1
      rem2 -= 1
    else 
      puts "No"
    end
  else
    puts "No"
  end
end


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

int main(void){
    int N,D,X,max=0;
    cin>>N>>D>>X;
    int A[N];
    for(int i=0;i<N;i++)
        cin>>A[i];

    for(int i=0;i<N;i++){
        int a=1;
        while(a<=D){
            max++;
            a+=A[i];
        }
    }

    cout<<max+X<<endl;

    return 0;
}


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

int main(){
    vector<int> a(3);
    for(int i = 0; i < 3; i++)
        cin >> a.at(i);
    int count5 = 0;
    int count7 = 0;
    for(int i = 0; i < 3; i++){
        if(a.at(i) == 5) count5++;
        if(a.at(i) == 7) count7++;
    }
    if(count5 == 2 && count7 == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

 



int main() {
	int N;
	string X;
	cin>> N ;
	vector<pair<string,int>>music(N);
	
	string tmp1;
	int tmp2;
	rep(0, N) {
		cin >> tmp1;
		cin >> tmp2;
		music.at(i) = make_pair(tmp1, tmp2);
			}
	cin >> X;
	
	bool flag = false;
	int ans = 0;
	rep(0, N) {
		if (music[i].first == X) {
			flag = true;
			continue;
		}
		if (flag == true) {
			ans += music[i].second;
		}
	}
	
	cout << ans<< endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((ll)(1e17+100))
#define MX ((ll)(1e5+100))
#define ARRS ((ll)(1e6+100))
#define ARS ((ll)(1e3+100))
#define HS ((ll)(233))
#define MOD ((ll)(1e9+7))
#define EP ((double)(1e-9))
#define LG 21
#define mul(a,b) a=((a)*(b))%MOD
using namespace std;

ll n;
ll a[ARRS];
ll p=0;

int main(){
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>a[i];
		a[i]-=i+1;
	}
	sort(a,a+n);
	ll x=a[n/2];
	for(int i=0; i<n; i++)
		p+=abs(a[i]-x);
	cout<<p;


}


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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  // ....#####という形にする
  // i番目まで., i+1から#
  // i番目までの.の個数
  // i番目までの#の個数を数えておく


  int N; cin >> N;
  string S; cin >> S;
  vector<int> a(N,0), b(N,0);
  for(int i = 0; i < N; i++){
    if(S[i] == '.'){
      a[i]++;
    } else { 
      b[i]++;
    }
    if(i > 0){
      a[i] += a[i-1];
      b[i] += b[i-1];
    }
  }

  int a_num = a[N-1];
  int b_num = b[N-1];
  // cerr << a_num << " " << b_num << endl;

  int min_num = a_num;
  for(int i = 0; i < N; i++){
    // 0   - i をすべて.に変えて、
    // i+1 - N をすべて#にかえる
    int tmp = 0;
    tmp += b[i];
    tmp += a_num - a[i];
    min_num = min(tmp, min_num);
  }
  cout << min_num << endl;
}


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

int main() {
    int n; cin >> n;
    map<int, int> mp;
    rep(i, 100) {
        rep(j, 100) {
            rep(k, 100) {
                int cal = i*i + j*j + k*k + i*j + j*k + k*i;
                mp[cal]++;
            }
        }
    }

    rep(i, n) {
        cout << mp[i] << endl;
    }
}

Measured memory_bytes: 5384
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
LCM = 1
for i in A:
    GCD = gcd(LCM,i)
    LCM = LCM*i//GCD
ans = 0
for i in A:
    ans += LCM//i
print(ans%mod)

Measured memory_bytes: 6112
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

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

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
string str;
int ans = 0;
int k = 0;
int main(){
  while(cin>>str){
    string num;
    for(int i = 0;i < str.length();i++){
      num ="\0";
      while(isdigit(str[i])){
	num +=str[i];
	i++;
      }
      int d = 0;
      for(int j = num.length()-1;j >=0;j--){
	ans +=(num[j]-'0')*pow(10.0,d);
	d++;
      }
    }
  }
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 1188