akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    // プログラムのエントリポイント
    public static void main(String[] args) {
        // 入力ストリームの生成
        Scanner sc = new Scanner(System.in);

        char[] iremono = { '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' };
        int[] cou = new int[26];
        int j = 0;


        while (sc.hasNext()) {
            String stralf = sc.nextLine();

            for (int i = 0; i < stralf.length(); i++) {
                char chalf = stralf.charAt(i);
                chalf = Character.toLowerCase(chalf);
                for (j = 0; j < 26; j++) {
                    if (iremono[j] == chalf) {
                        cou[j]++;
                    }
                }
            }
        }
        for (int k = 0; k < 26; k++) {
            System.out.print(iremono[k]);
            System.out.println(" : " + cou[k]);
        }
    }
}

Measured memory_bytes: 18020
package main

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

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	N := nextInt()

	fmt.Println(math.Ceil(float64(N) / 2.0))
}


Measured memory_bytes: 640
#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 ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
int V, E;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> V >> E;
    ll dp[V][V];
    for(int i = 0; i < V; i++) for(int j = 0; j < V; j++) dp[i][j] = INF;
    for(int i = 0; i < V; i++) dp[i][i] = 0;
    for(int i = 0; i < E; i++)
    {
        ll s, t, d; cin >> s >> t >> d;
        dp[s][t] = d;
    }
    for(int k = 0; k < V; k++)
    {
        for(int i = 0; i < V; i++)
        {
            for(int j = 0; j < V; j++)
            {
                if(dp[i][k] == INF or dp[k][j] == INF) continue;
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    bool negative = false;
    for(int i = 0; i < V; i++) if(dp[i][i] != 0) negative = true;
    if(negative)
    {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    for(int i = 0; i < V; i++)
    {
        for(int j = 0; j < V; j++)
        {
            if(j) cout << " ";
            if(dp[i][j] >= INF) cout << "INF";
            else cout << dp[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3232
// AOJ 1307 Towns along a Highway
// 2019.2.28 bal4u

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

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()   // 正整数の入力
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n)
{
	int i;
	char ob[20];

	i = 0; while (n) ob[i++] = n % 10 + '0', n /= 10;
	while (i--) pc(ob[i]);
}

void outs(char *s) { while (*s) pc(*s++); }
#define ABS(x) ((x)>=0?(x):-(x))

int N;
int d[200], dsz, max;
char f[402];     // 入力した値の個数を記録する
int ans[20][20], asz;
int try[20];     // ansの候補

int check(int id, int val)
{
	int i, k;
	char ff[402];

	memcpy(ff, f, 1+max);
	for (i = 0; i < id; i++) {
		k = ABS(try[i]-val);
		if (ff[k] == 0) return 0;
		ff[k]--;
	}
	return 1;
}

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

void combi(int id)
{
	int i, k;
	char ff[402];

	if (id == N) {
		memcpy(ans[asz], try, N * sizeof(int));
		qsort(ans[asz], N, sizeof(int), cmp);
		for (i = 0; ; i++) {
			if (i == asz) { asz++; break; }
			if (!memcmp(ans[i], ans[asz], N * sizeof(int))) break;
		}
		return;
	}

	for (k = max; !f[k]; k--);
	memcpy(ff, f, 1+max);
	if (check(id, max-k)) {
		try[id] = max - k;
		for (i = 0; i < id; i++) f[ABS(try[i] - try[id])]--;
		combi(id + 1);
		memcpy(f, ff, 1+max);
	}

	if (check(id, k)) {
		try[id] = k;
		for (i = 0; i < id; i++) f[ABS(try[i] - try[id])]--;
		combi(id + 1);
		memcpy(f, ff, 1+max);
	}
}

int main()
{
	int i, j;

	while (N = in()) {
		dsz = N * (N - 1) >> 1;
		memset(f, 0, sizeof(f));
		for (i = 0; i < dsz; i++) {
			d[i] = in(), f[d[i]]++;
		}
		if (dsz == 1) out(d[0]), pc('\n');
		else {
			max = d[0];
			try[0] = 0, try[1] = max, f[max]--;  // 最左端と最右端の距離が最大
			asz = 0;
			combi(2);

			// 結果表示
			for (i = 0; i < asz; i++) {
				out(ans[i][1]);
				for (j = 2; j < N; j++) pc(' '), out(ans[i][j] - ans[i][j - 1]);
				pc('\n');
			}
		}
		outs("-----\n");
	}
	return 0;
}



Measured memory_bytes: 1996
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Dhanin Gupta
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AABCSwap solver = new AABCSwap();
        solver.solve(1, in, out);
        out.close();
    }

    static class AABCSwap {
        public void solve(int testNumber, InputReader in, PrintWriter w) {

            int x = in.nextInt();
            int y = in.nextInt();
            int z = in.nextInt();

            w.println(z + " " + x + " " + y);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=44;
#define MP make_pair
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline int read(){
    int x=0,f=0;char ch=getchar();
    while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
    while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
    return f?-x:x;
}
int n,a[maxn][maxn];
char s[maxn];
ll f[maxn][maxn][maxn],fs[maxn][maxn][maxn],ans;
int main(){
	n=read()*2;
	FOR(i,1,n){
		scanf("%s",s+1);
		FOR(j,1,n) a[i][j]=s[j]-'0';
	}
	if(n==2) return printf("%d\n",a[1][2]),0;
	FOR(i,2,n) f[i][i][i]=1;
	FOR(len,3,n-1) if(len%2==1) FOR(l,2,n-len+1){
		int r=l+len-1;
		FOR(i,l,r) FOR(j,l,i-1) FOR(k,i+1,r) if(a[j][k]) FOR(p,j,i-1) FOR(q,i+1,k)
			f[l][i][r]+=f[l][j][p]*f[q][k][r]*f[p+1][i][q-1];
	}
	FOR(i,2,n) if(a[1][i]) ans+=f[2][i][n];
	printf("%lld\n",ans);
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	int x=sc.nextInt();
	int sum=0;
	while(x>=5)
	{
		if(x>=500)
		{
			sum+=1000;
			x=x-500;
		}
		else
		{
			sum+=5;
			x=x-5;
		}
	}
	System.out.println(sum);
}
}


Measured memory_bytes: 21844
def main():
  import sys
  from scipy.sparse.csgraph import floyd_warshall
  n,m,l,*t=map(int,sys.stdin.buffer.read().split())
  d=[[0]*(n+1)for _ in range(n+1)]
  for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c
  d=floyd_warshall(floyd_warshall(d,0)<=l)-1
  d[d>n]=-1
  print('\n'.join(map(str,map(int,[d[i]for i in zip(*[iter(t[m*3+1:])]*2)]))))
main()

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

#define mod 1000000007
#define INF (ll)9999999999999999

#define add emplace
#define eb emplace_back
#define len(x) ((int)(x).size())
#define exist(a, x) (a.find(x) != end(a))
#define log(x) cout << (x) << endl
#define rep(i, n) for (int i = 0; i < (int)n; ++i)

int main() {
	int n, x;
	cin >> n;
	unordered_set<int> s;

	rep (i, n) {
		cin >> x;
		if (exist(s, x)) s.erase(x);
		else s.add(x);
	}

	log(len(s));

	return 0;
}




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

int main(){
	unsigned q, s;
	for(scanf("%u", &q); q--; ){
		scanf("%x", &s);
		int x = (s & 0x7fffffffu) >> 7;
		int y = (s & 0x7fu) * 78125;
		int d = 7;
		while(d > 1 && y % 10 == 0){
			y /= 10;
			--d;
		}

		if(s >> 31) putchar('-');
		printf("%d.%0*d\n", x, d, y);
	}
}

Measured memory_bytes: 3164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
	
	static final long MOD = 1000000007;
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		int[] parent = new int[N];
		List<Integer>[] adj = new List[N];
		for (int i = 0; i < N; i++) {
			adj[i] = new ArrayList<>();
		}
		for (int i = 0; i < N; i++) {
			parent[i] = sc.nextInt();
			if (parent[i] >= 1) {
				parent[i]--;
				adj[parent[i]].add(i);
				adj[i].add(parent[i]);
			}
		}
		
		int[] cc = new int[N];
		int[] count = new int[N];
		int tot = 0;
		Arrays.fill(cc, -1);
		for (int i = 0; i < N; i++) if (cc[i] == -1) {
			int tmp = 1;
			cc[i] = tot;
			Deque<Integer> queue = new ArrayDeque<>();
			queue.addLast(i);
			while (!queue.isEmpty()) {
				int cur = queue.pollFirst();
				for (int vec : adj[cur]) {
					if (cc[vec] == -1) {
						cc[vec] = tot;
						queue.addLast(vec);
						tmp++;
					}
				}
			}
			count[tot] = tmp;
			tot++;
		}
		List<Integer> sizes = new ArrayList<>();
		for (int i = 0; i < N; i++) if (parent[i] == -1) {
			sizes.add(count[cc[i]]);
		}
		
		int pending = sizes.size();
		long[] pots = new long[pending + 1];
		pots[0] = 1;
		for (int i = 1; i <= pending; i++) {
			pots[i] = (pots[i-1] * (N - 1)) % MOD;
		}
		long[][] table = new long[pending][pending + 1];
		for (int pos = 0; pos < pending; pos++) {
			table[pos][0] = (sizes.get(pos) - 1);
			table[pos][1] = sizes.get(pos) + (pos > 0 ? table[pos - 1][1]: 0);
		}
		for (int pos = 0; pos < pending; pos++) {
			for (int cicles = 2; cicles <= pending; cicles++) {
				table[pos][cicles] = pos > 0 ? table[pos - 1][cicles] : 0;
				long tmp = pos > 0 ? (table[pos - 1][cicles - 1] * (cicles - 1) * sizes.get(pos)) % MOD : 0;
				table[pos][cicles] += tmp;
				table[pos][cicles] %= MOD;
			}
		}
		int rem = tot - pending;
		long ans = ((N - rem) * pots[pending]) % MOD;
		if (pending > 0) {
			ans -= (table[pending - 1][1] - pending) * pots[pending - 1];
			ans %= MOD; ans += MOD; ans %= MOD;
			for (int cicles = 2; cicles <= pending; cicles++) {
				ans += (MOD - (table[pending - 1][cicles] * pots[pending - cicles]) % MOD);
				ans %= MOD;
			}
		}
		out.println(ans);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


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

class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String numbers[] = br.readLine().split(" ");
		int x = Integer.parseInt(numbers[0]);
		int a = Integer.parseInt(numbers[1]);
		if (x >= a) {
			System.out.println(10);
		} else
			System.out.println(0);
	}

}

Measured memory_bytes: 21076
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int n = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        for(int i = 0; i < n; i++){
            String s = sc.next();
            map.put(s, map.getOrDefault(s,0) + 1);
        }
        System.out.println("AC x " + map.getOrDefault("AC",0));
        System.out.println("WA x " + map.getOrDefault("WA",0));
        System.out.println("TLE x " + map.getOrDefault("TLE",0));
        System.out.println("RE x " + map.getOrDefault("RE",0));
    }
}

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

int main() {
  long N;
  cin>>N;
  vector<long> a(N);
  long as=0;
  for(int i=0;i<N;i++) cin>>a[i],as+=a[i];
  vector<long> b(N);
  long bs=0;
  for(int i=0;i<N;i++) cin>>b[i],bs+=b[i];
  long ms=bs-as;
  if(ms<0){
    cout<<"No"<<endl;
    return 0;
  }
  long am=0,bm=0;
  for(int i=0;i<N;i++){
    if(a[i]>b[i]) bm+=a[i]-b[i];
    else{
      long tmp=(b[i]-a[i])/2;
      am+=tmp;
      a[i]+=tmp*2;
      if(a[i]<b[i]) am++,bm++;
    }
  }
  //cout<<ms<<am<<bm<<endl;
  if(ms>=am) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  }


Measured memory_bytes: 3788
from bisect import bisect_left
n=int(input())
L=sorted((map(int,input().split())))
t=0
for i in range(n-2):
	for j in range(i+1,n-1):
		l=j
		r=n
		while l+1<r:
			c=(l+r)//2
			if L[i]+L[j]>L[c]:
				l=c
			else:
				r=c
		t+=l-j
print(t)

Measured memory_bytes: 42220
#include <bits/stdc++.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef int32_t i32;

#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>=b;i--)
#define FILL(a,b,c) for(ll i=0;i<c;i++) a[i]=b;

#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()

#define endl "\n"
#define setpri(x) setprecision(x)
#define vp(x) cout<<#x<<" : "<< (x)<<" | "
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define forf(i,a,b) for(int i=a;i<b;i++)

#define INF 1e17+4
#define MINF 
#define MAX_INT 100000
#define MOD 1000000007
ll mod(ll n) { n %= MOD; if (n < 0) return n + MOD; else return n;}
// vector<int> adj[1000002];
// int vis[1000002],dep[1000002],siz[1000002];

// void dfs(ll cur,ll par)
// {
//     vis[cur]=1;siz[cur]=1;
//     for(auto x:adj[cur])
//     {
//         if(vis[x]!=1)
//         {
//             dep[x]=dep[cur]+1;
//             dfs(x,cur);
//             siz[cur]+=siz[x];
//         }    
//     }
// }

// bool sortfunc(const pair<int,int> &a, const pair<int,int> &b) 
// { 
//     return ;
// }

void solve()
{
    int n;cin>>n;
    int a,b;
    cin>>a>>b;
    int d=a/n;
    if(a%n!=0)
        d++;
    if(d*n<=b && d*n>=a)
        cout<<"OK";
    else
        cout<<"NG";
    
}




signed main()
{
    FAST;
    
    // ll t;cin>>t;while(t--)
        solve();
 
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i=j;i<k;i++)
int n;int A[50];
bool solve(int i,int m){
    if(m==0)return true;
    if(i>=n)return false;
    else {
        bool res=solve(i+1,m)||solve(i+1,m-A[i]);
        return res;
    }
}
int main(){
    cin>>n;
    rep(i,0,n)cin>>A[i];
    int q;cin>>q;
    rep(i,0,q){
        int m;cin>>m;
        if(solve(0,m))cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

pll A[100005];

int main() {
    ll N, M;
    cin >> N >> M;
    REP(i, N) {
        cin >> A[i].first >> A[i].second;
    }
    sort(A, A + N, [](pll a, pll b) {
        return a.first < b.first;
    });

    ll ans = 0;
    REP(i, N) {
        ans += A[i].first * A[i].second;
        M -= A[i].second;
        if (M <= 0) {
            ans -= abs(M) * A[i].first;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
  string s1,s2,s3;
  char ss1,ss2,ss3;
  cin >> s1 >> s2 >> s3;
  ss1 = toupper(s1[0]);
  ss2 = toupper(s2[0]);
  ss3 = toupper(s3[0]);
  cout << ss1 << ss2 << ss3 << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    int b = sc.nextInt();
    if (a==1){
      a+=13;
    }
    if (b==1){
      b+=13;
    }
    if (a==b){
      System.out.println("Draw");
    } else if (a>b){
      System.out.println("Alice");
    } else {
      System.out.println("Bob");
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int N,M;
    long long int tmpl;
    int tmp=0,flag=0,tmp2=0;
    vector <long long int> A,C,D;
    vector <pair <long long int,int>> BC;
    pair <long long int,int> ptmp;
    cin >> N >> M;
    FOR(i,0,N){
        cin >> tmpl;
        A.push_back(tmpl);
    }
    sort(A.begin(),A.end());
    FOR(i,0,M){
        cin >> tmp >> tmpl;
        ptmp.first = tmpl;
        ptmp.second = tmp;
        BC.push_back(ptmp);
    }
    sort(BC.begin(),BC.end());
    FORR(i,M-1,-1){
        for(int (j) = 0;j<BC[i].second && tmp2 < N;j++,tmp2++){
            if(A[tmp2] <= BC[i].first){
                A[tmp2] = BC[i].first;
            }else{flag =1; break;}
        }
        if (flag ==1) break;
    }
    long long int sum=0;
    FOR(i,0,N){
        sum += A[i];
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
const int maxn=1e5+5;
int n,tot;
int head[maxn],des[maxn<<1],nxt[maxn<<1];
void adde(int x,int y){
	des[++tot]=y;nxt[tot]=head[x];head[x]=tot;
}
int dfs(int x){
	int res=0;
	vector<int>q;
	Rep(p,x)q.pb(dfs(des[p]));
	sort(All(q));
	rep2(i,0,SZ(q))res=max(res,q[i]),res++;
	return res;
}
int main(){
	read(n);
	rep(i,2,n){
		int x;read(x);
		adde(x,i);
	}
	printf("%d\n",dfs(1));
	return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	ll n,ret;
	cin >> n;
	ret = n*(n-1)/2;
	printf("%lld",ret);
	return 0;
}


Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    io.Source.stdin.getLines foreach (n => println(pi(n.toInt)))
  }
  val primes: IndexedSeq[Int] = prime_sieve(10000)
  val pi_cache: collection.mutable.Map[Int, Int] = collection.mutable.Map.empty
  val phi_cache: collection.mutable.Map[(Int, Int), Int] = collection.mutable.Map.empty

  def prime_sieve(x: Int): IndexedSeq[Int] = {
    val n = x - x % 6 + 6
    val correction = if (x % 6 > 1) 1 else 2
    val sieve = Array.fill(n/3)(true)
    for (i <- 1 to (Math.sqrt(n) / 3).toInt if sieve(i)) {
      val k = (3 * i + 1) | 1
      for (j <- (k * k) / 3 until sieve.length by 2*k) sieve(j) = false
      for (j <- (k*(k-2*(i&1)+4))/3 until sieve.length by 2*k) sieve(j) = false
    }
    2 +: 3 +: (for (i <- 1 until n / 3 - correction if sieve(i)) yield (3*i+1)|1)
  }
  def bisect(n: Int): Int = {
    def loop(left: Int, right: Int): Int = {
      val mid = (left + right) / 2
      if (primes(mid) <= n && n < primes(mid+1)) mid+1
      else if (n < primes(mid)) loop(left, mid)
      else loop(mid+1, right)
    }
    if (n < primes.head) 0
    else if (n >= primes.last) primes.length
    else loop(0, primes.length)
  }
  def pi(x: Int): Int =
    pi_cache.getOrElseUpdate(x,
      if (x <= primes.last) bisect(x)
      else {
        val a = pi(Math.sqrt(Math.sqrt(x)).toInt)
        val b = pi(Math.sqrt(x).toInt)
        val c = pi(Math.cbrt(x).toInt)
        var result = phi(x, a) + ((b + a - 2) * (b - a + 1)) / 2
        for (i <- a + 1 to b) {
          val w = x / primes(i - 1)
          val b_i = pi(Math.sqrt(w).toInt)
          result -= pi(w)
          if (i <= c)
            for (j <- i to b_i)
              result = result - pi(w / primes(j - 1)) + j - 1
        }
        result
      }
    )
  def phi(x: Int, a:Int): Int =
    phi_cache.getOrElseUpdate(
      (x,a),
      {
        if (a == 1) (x + 1) / 2
        else phi(x, a - 1) - phi(x / primes(a - 1), a - 1)
      }
    )
}

Measured memory_bytes: 45492
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define N_MAX 100001
#define MOD 1000000007

void solv()
{
	int N; scanf("%d", &N);

	int sum[3];
	sum[0] = sum[1] = sum[2] = 0;
	long long int ret = 1;
	for (int i = 0; i < N; i++){
		int a;  scanf("%d", &a);
		int cnt = 0;
		for (int i = 0; i < 3; i++){
			if (a == sum[i]){
				cnt++;
			}			
		}

		ret = (ret*cnt) % MOD;

		for (int i = 0; i < 3; i++){
			if (a == sum[i]){
				sum[i]++;
				break;
			}
		}
	}

	printf("%lld", ret);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

a,b,t=MAP()

print(int((t+0.5)/a)*b)


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

char c[110][110];

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

    int h,w;
    cin>>h>>w;

    for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>c[i][j];

    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)cout<<c[i][j];
        cout<<"\n";
        for(int j=0;j<w;j++)cout<<c[i][j];
        cout<<"\n";
    }

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void){
    int X;
    cin >> X;
    if(X == 7 || X == 5 || X == 3){
        cout << "YES";
    } else {
        cout << "NO";
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n, c[505], s[505], f[505];
int main() {
	int i, j, t, r;
	cin>>n;
	for(i=0; i<n-1; i++) cin>>c[i]>>s[i]>>f[i];
	for(i=0; i<n; i++) {
		t = 0;
		for(j=i; j<n-1; j++) {
			if(t<s[j]) t = s[j];
			else {
				r = t%f[j];
				if(r) t += f[j]-r;
			}
			t += c[j];
		}
		cout<<t<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef long long ll;

int main(){
  ll s = 2; ll cnt = 1;
ll X, Y; cin >> X >> Y;

for(int i = 0 ; i <= 60; i++)
{ if( X * s <= Y ){ cnt++; s *= 2;}
 else{break;}}
 
 cout << cnt << endl;
 return 0;
}
  
 

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

double r;
double m,s;

int main(){
    cin >> r;
    m = r * r * 3.14159265358979;
    s = r * 2.0 * 3.14159265358979;
    printf("%.8lf %.8lf", m, s);
    return 0;
}

Measured memory_bytes: 1240
/*
    Competitive programming template
    Author: Aswin Sampath

    */


    #include<bits/stdc++.h>

    using namespace std;


    typedef long long ll;
    typedef long double ld;
    typedef pair<ll,ll> pll;
    typedef vector<ll>vl;
    typedef vector<int>vi;
    typedef priority_queue<ll,vl,greater<ll>()> pq_ll_min;
    typedef priority_queue<ll> pq_ll_max; 
    typedef stack<ll> s;
    typedef queue<ll> q;


    #define pi 3.141592653589793
    #define PI  acos(-1.0)
    #define space " "
    #define endl '\n'
    #define F first
    #define S second
    #define pb(x) push_back(x)
    #define mp(a,b) make_pair(a,b)

    #define FAST {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
    #define testcase ll t;cin>>t;while(t--)
    #define dbxstl(x){for(auto ele:x)cout<<ele<<space; cout<<endl;}
    #define dbxval(x){cout<<x<<endl;}

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

    void solve(){
        printf("Hello\n");
    }

    int main(int argc, char const *argv[])
    {
        ll n;
        cin>>n;
        vector<ll>dp(3,0);
        for(ll days=0;days<n;days++){

            vector<ll>a(3);
            vector<ll>temp(3);

            for(ll i=0;i<3;i++)cin>>a[i];

            for(ll i=0;i<3;i++){ // i stands for previous days 
                for(ll j=0;j<3;j++){  // j stands = current day
                    if(i!=j){
                        temp[j]= max(temp[j],a[j]+dp[i]);
                    }
                }
            }
            dp=temp;
        }
        cout<<max({dp[0],dp[1],dp[2]})<<endl;
        return 0;
    }



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

using namespace std;

int main(){
  int n;
  cin>>n;
  int tmp[1001];
  memset(tmp,0,sizeof(tmp));
  for(int i = n;i > 0;i--){
    int t_n = i;
    for(int j = 2;j * j<=t_n;j++){
      while(t_n % j == 0){
	++tmp[j];
	t_n /= j;
      }
    }
    if(t_n != 1) tmp[t_n]++;
    //tmp[i]--;
  }
  long ans = 1;
  for(int i = 2;i<=n;i++){
    ans *= (tmp[i]+ 1);
    ans %= 1000000007;
  }
  cout<<ans % 1000000007<<endl;
  return 0;
}


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

int main() {
    long long N, K, cnt = 0;
    cin >> N >> K;
    vector<long long> vec(N);

    for (int i = 0; i < N; i++) {
        cin >> vec[i];
    }

    for (auto i = 0; i < vec.size(); i++) {
        cnt += min((K - vec[i]) * 2, vec[i] * 2);
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3608
#include <stdio.h>
int main ()
{
	int n,i,j,k,t,a,b,c,d;
	scanf ("%d%d%d%d",&a,&b,&c,&d);
	if (a>=d||c>=b)
	{
		printf ("0\n");
	}
	else {
		     if ((a>c&&b<d)||(a==c&&b<d)||(a>c&&b==d))
	        {
	        	  	printf ("%d\n",b-a);
	        }
	        if ((a<c&&b>d)||(a==c&&b>d)||(a<c&&b==d)||(a==c&&b==d))
	        {
	        	printf ("%d\n",d-c);
	        }
	        if (a<c&&b<d)
	        {
	        	printf ("%d\n",b-c);
	        }
	        if (a>c&&b>d)
	        {
	        	printf ("%d\n",d-a);
	        }
	}
	  return 0;
}
	

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
typedef long long ll;
int n,m,q;
vector<int>g[100005];
pair<int,int>dp[100005];
#define F first
#define S second
int ci[100005],di[100005],vi[100005];
void dfs(int v,int d,int c){
    if(dp[v].S==0)dp[v].S=c;
    if(dp[v].F<d){
        dp[v].F=d;
        for(int i=0;i<g[v].size();i++)dfs(g[v][i],d-1,c);
    }
}
int main(void){
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        g[--a].push_back(--b);
        g[b].push_back(a);
    }
    scanf("%d",&q);
    for(int i=0;i<q;i++)scanf("%d%d%d",vi+i,di+i,ci+i);
    for(int i=q-1;i>=0;i--){
        dfs(vi[i]-1,di[i],ci[i]);
    }
    for(int i=0;i<n;i++){
        printf("%d\n",dp[i].S);
    }
}


Measured memory_bytes: 8440
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
char str[100010] = {0};
int main()
{
	int l;
	scanf("%s",str);
	l = strlen(str);
	int s=0;
	int h=0,e = l-1;
	while(h < e)
	{
		if(str[h] == str[e])
		{
			h++;
			e--;
		}
		else
		{
			if(str[h] == 'x')
			{
				h++;
				s++;
			}
			else if(str[e] == 'x')
			{
				e--;
				s++;
			}
			else
				break;
		}
	}
	if(h < e)
		printf("-1\n");
	else
		printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000007;
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int N;
  string S;
  cin >> N >> S;
  bool A[30], B[30];
  int ans = 0;
  for(int i=0;i<30;i++){
    A[i] = false;
    B[i] = false;
  }
  for(int i=1;i<N-1;i++){
    for(int j=0;j<30;j++){
      A[j] = false;
      B[j] = false;
    }
    for(int j=0;j<i;j++){
      A[S[j] - 'a'] = true;
    }
    for(int j=i;j<N;j++){
      B[S[j] - 'a'] = true;
    }
    int a = 0;
    for(int j=0;j<30;j++){
      if(A[j] && B[j]){
        a++;
      }
    }
    ans = max(ans, a);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int X, Y;
	cin >> X >> Y;

	Int temp = X;
	Int count = 0;
	while (temp <= Y) {
		count++;
		temp *= 2;
	}

	cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
  
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
  
Node root;
  
Node treeMinimum(Node x){
  while(x->left != NIL)
    x = x->left;
   
  return x;
}
 
Node treeMaximum(Node x){
  while(x->right != NIL)
    x = x->right;
   
  return x;
}
  
Node treeSearch(Node x, int k){
  if(x==NIL || k==x->key){
    return x;
  }
  if(k<x->key){
    return treeSearch(x->left,k);
  }
  else{
    return treeSearch(x->right,k);
  }
}

Node treeSuccessor(Node x){
  if(x->right!=NIL)
    return treeMinimum(x->right);
  Node y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
 
}
 
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
 
  if(z->left==NIL || z->right==NIL)
    y=z;
  else
    y=treeSuccessor(z);
 
  if(y->left!=NIL)
    x=y->left;
  else
    x=y->right;
 
  if(x!=NIL)
    x->parent=y->parent;
 
  if(y->parent==NIL)
    root=x;
  else if(y==y->parent->left)
    y->parent->left=x;
  else
    y->parent->right=x;
   
  if(y!=z)
    z->key=y->key;
 
}


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else{
    if(z->key < y->key) y->left = z;
    else y->right = z;
  }
}
  
void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
  
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'd' ){
      scanf("%d",&x);
      treeDelete(treeSearch(root,x));
    }
    }
  return 0;
}


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

vector<int>prime(999999,0);
//vector<int>prime1(1000001,0);
vector<int>mark(9999999,0);
int nprime;

void sieve(int n)///FINDING PRIME
{
    int limit=sqrt(n*1.0)+1,s=0;nprime=0;
    mark[1]=1;///1 if not prime.
    mark[2]=0;prime[nprime++]=2;//cout<<2<<endl;
    //for(int i=4;i<=n;i+=2)mark[i]=1;
    for(int i=3;i<=n;i+=2){
        if(!mark[i]){prime[nprime++]=i;//cout<<i<<endl;
        if(i<=limit){///karon limit er upor theke n porjonto not prime gula already cuta hoise.
            for(int j=i*i;j<=n;j+=i*2){
                mark[j]=1;
            }
        }}
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=1,nn;//while(n<=1000000000000001){
    string s;nn=n;
    cin>>n;
    while(n>26){
        if(n%26!=0)s+=(96+(n%26));
        else {s+=(96+26);n-=1;}
        //cout<<(n%26)<<endl;
        n/=26;
    }
    s+=(96+n);//cout<<nn<<"->";
    for(int i=s.size()-1;i>=0;i--)cout<<s[i];
    cout<<endl;
    //nn++;n=nn;
    //}
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  int GCD = A[0];
  for(int i = 1; i < N; i++){  
    GCD = __gcd(GCD, A[i]);
  }
  for(int i = 0; i < N; i++){  
    int dif = A[i] - K;
    if(dif == 0 || (dif > 0 && dif % GCD == 0)){  
      cout << "POSSIBLE" <<endl; 
      return 0;
    }
  }
  cout << "IMPOSSIBLE" <<endl;
}


Measured memory_bytes: 3672
D = [[1, 3, 4, 2], [5, 3, 0, 2], [5, 1, 0, 4], [5, 4, 0, 1], [2, 0, 3, 5], [1, 2, 4, 3]]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
count = 0
for i, j in enumerate(a):
    if a.count(j) > 1:
        count += 1
        continue
    A = [a[k] for k in D[i]]
    B = [b[k] for k in D[b.index(j)]]
    if A != B:
        B = B[B.index(A[0]):] + B[:B.index(A[0])]
    if A == B:
        count += 1
if count == 6:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 5608
import numpy as np

N, M = map(int,input().split())
AC = np.array([0 for i in range(N)])
WA = np.array([0 for i in range(N)])

for _ in range(M):
  p, S = map(str,input().split())
  p = int(p)
  if AC[p-1] == 0 and S == 'AC':
    AC[p-1] += 1
  elif AC[p-1] == 0 and S == 'WA':
    WA[p-1] += 1
    
for i in range(N):
  if AC[i] == 0:
    WA[i] = 0
    
print(AC.sum(),WA.sum())
    
    

Measured memory_bytes: 29008
inf = 10 ** 9

n, k, q = map(int, input().split())
a = tuple(map(int, input().split()))

ans = inf
for min_ in sorted(set(a)):
    res = []  # 最小値min_としたとき、取り除ける要素全て
    seq = 0
    for ind, a_ in enumerate(a):
        if a_ >= min_:
            seq += 1
        else:
            if seq >= k:
                sequence_le_k = a[ind - seq:ind]  # 長さk以上の数列
                pick = seq - k + 1  # この個数だけ取り除く
                res.extend(sorted(sequence_le_k)[:pick])
            seq = 0
    else:
        if seq >= k:
            sequence_le_k = a[-seq:]  # 長さk以上の数列
            pick = seq - k + 1  # この個数だけ取り除く
            res.extend(sorted(sequence_le_k)[:pick])
    if len(res) < q:
        continue
    res.sort()
    ans = min(ans, res[q - 1] - min_)  # q回目に取り除いた要素 = 取り除く最大値
print(ans)


Measured memory_bytes: 3316
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long inf = 1e12;

int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	long long l, r;
	cin >> l >> r;
	long long res = LLONG_MAX;
	for (long long i = l; i < min(l + 2019, r); i++)
	{
		for (long long j = i + 1; j <= min(l + 2019, r); j++)
		{
			res = min(res, (i * j) % 2019);
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int calculate(vector<int>& points, int meetingPoint)
{
		int total = 0;
		for(auto& p : points)
		{
			 total += pow(p - meetingPoint, 2);
		}
		return total;
}

int main()
{
	int n; cin>>n;
	vector<int> points(n); 
	for(int i = 0; i < n; ++i)
		cin>>points[i];

	sort(points.begin(), points.end());
	
	int mini = 100*100*100*100;
	for(int i = points[0]; i <= points[n-1]; ++i)
	{
			int dist = calculate(points, i);
			if(dist < mini)
				mini = dist;
	}

	cout<< mini;

	return 0;
}


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

using namespace std;

int main() {
	string s;
	cin >> s;
	// bit全探索 0は+ 1は-とする
	for (int i = 0; i < (1 << s.length()-1); i++) {
		string ssum;
		string enzan = "";
		ssum = s[0];
		int sum = stoi(ssum);
		
		for (int j = 0; j < s.length() - 1; j++) {
			ssum = s[j + 1];
			if (i&(1 << j)) {
				enzan += "-";
				sum -= stoi(ssum);
			} else {
				enzan += "+";
				sum += stoi(ssum);
			}
		}
		if (sum == 7) {
			cout << s[0] << enzan[0] << s[1] << enzan[1] << s[2] << enzan[2] << s[3] << "=7" << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
  ll a,b,c;
  ll k;
  cin >> a >> b >> c >> k;
  ll ans=0;
  // rep(i,k){
  //   if(a > 0){
  //     ans++;
  //     ans++;
  //     a--;
  //   }else if(b > 0){
  //     k+b;
  //     b=0;
  //   }else if(c>0){
  //     c--;
  //     ans--;
  //   }
  // }
  int nokori;
  if(k>=a){
    ans += a;
    nokori = k - a;
    if(abs(nokori - b) <= c && nokori > b){
      ans = ans - (nokori - b);
    }
  }else if(k<a){
    ans = k;
  }
  cout << ans << endl;
  return 0;
}


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

int n;
long long int t[200];

int main(){
  cin >> n;
  rep(i, n){
    cin >> t[i];
  }
  long long int res = 1;
  rep(i, n - 1){
    long long int a = t[i], b = t[i + 1];
    long long int lcm = a / __gcd(a, b) * b;
    res = lcm / __gcd(lcm, res) * res;
  }
  if(n == 1) res = t[0];
  cout << res << endl;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
ll gcd(ll a,ll b){
	return (b==0?a:gcd(b,a%b));
}
int main(){
	int n,x;
	cin>>n>>x;
	ll out=0;
	rep(i,n){
		int a;
		cin>>a;
		out=gcd(out,abs(x-a));
	}
	cout<<out<<endl;
}







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

using namespace std;

#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;

const int mn=2e5+5;

int n,k;

int c[mn];

int main() {
#ifdef LOCAL
    freopen("../1.txt","r",stdin);
#endif
    scanf("%d%d",&n,&k);
    ll ans=0;
    for(int i=1;i<=n;i++) c[i%k]++;
    for(int a=1;a<=n;a++){
        int u=a%k;
        int b=k-a%k;
        if (b==k) b=0;
        if (b*2%k==0) ans+=1ll*c[b]*c[b];
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 640
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>

using namespace std;

typedef long long ll;
const ll nmax = 1e9 + 7;
const ll mod = 998244353;
const double PI = 2 * asin(1);


int main(){
  int N; ll M, V, P;
  cin >> N >> M >> V >> P;

  vector <ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end(), greater<ll>());

    
  int L = P - 1, R = N;
  while ((L + 1) < R){
    int now = (L + R) / 2;

    if (A[now] + M < A[P - 1]){
      R = now;
      continue;
    }

    ll rest = max(0ll, V - (N - now) - (P - 1));

    ll C = A[now] + M, sum = 0;
    for (int i = P - 1; i < now; i++){
      sum += C - A[i];
    }
    
    if (sum >= rest * M) L = now;
    else R = now;
  }

  cout << L + 1 << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

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

int main() {
    std::ios::sync_with_stdio(false);
    int N;
    std::cin >> N;
    std::cout << (N/100==N%10?"Yes":"No") << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int main(){
    int n,k;
    int sum=0;
    cin >> n >> k;
    vector<int> v;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;

        sum+=std::min(x,std::abs(k-x))*2;
        v.push_back(x);
    }

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



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

class union_find {
    private:
        vector<int> par;
        vector<int> ran;
        vector<ll> size;
    public:
        union_find(int n);
        int find(int x);
        void unite(int x, int y);
        bool same(int x, int y);
        ll show_size(int x);
};

union_find::union_find(int n){
    par.resize(n);
    ran.resize(n);
    size.resize(n);
    rep(i,n) par[i] = i;
    rep(i,n) ran[i] = 0;
    rep(i,n) size[i] = 1;
};

int union_find::find(int x) {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
};

void union_find::unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    ll t = show_size(x)+show_size(y);
    size[x] = size[y] = t;
    if(ran[x] < ran[y]){
        par[x] = y;
        //size[y] += size[x];
    }
    else{
        par[y] = x;
        //size[x] += size[y];
        if(ran[x] == ran[y]) ran[x]++;
    }
};

ll union_find::show_size(int x) {
    if(par[x] == x) return size[x];
    return show_size(par[x] = find(par[x]));
}

bool union_find::same(int x, int y) {
    return (find(x) == find(y));
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	union_find uf(n);
	rep(i,m){
		int x, y, z;
		cin >> x >> y >> z;
		uf.unite(x-1, y-1);
	}
	set<int> s;
	rep(i,n){
		s.insert(uf.find(i));
	}
	cout << s.size() << endl;
	return 0;
}

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

int main(){
	int tc[3];
	int sh, sm, ss, eh, em, es, sts, ets; //sts = start total second
	int h, m, s;
	for(int i = 0; i < 3; i++){
		cin >> sh >> sm >> ss >> eh >> em >> es;
		sts = sh * 3600 + sm * 60 + ss;
		ets = eh * 3600 + em * 60 + es;
		tc[i] = ets - sts;
	}
	
	for(int i = 0; i < 3; i++){
		s = tc[i] % 60;
		m = (tc[i] / 60 )% 60;
		h = tc[i] / 3600;
		cout << h << ' ' << m << ' ' << s << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160