akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;

/*
各寿司には、ネタと美味しさのパラメータがある
満足ポイント：美味しさの総和＋ネタの種類の二乗
N個の寿司の中からK個の寿司を選ぶとき、満足ポイントの最大値を求めよ。

k個のお寿司について、p種類のネタを選んだ時の美味しさの総和の最大値をf(p)とする。
求める最大値は、f(p)+p*p
美味しさの高いものからK個お寿司を選ぶとする。(このお寿司の集合をSとする)
この時、このK個のお寿司の種類をxとする。
この場合の美味しさの総和はf(x)となる。

xより小さいiについて、美味しさの総和だけでなく種類も少ないので、i<xなるiについては考えなくていい。
xより大きいiについて、美味しさの総和は確実に減る(または等しいまま)。しかし種類が多くなれば、
満足ポイントは逆転しうる。
x+1,x+2,...,Nまで、以下の手続きで計算できる。
1. Sから、取り除いてもネタの種類が減らないお寿司の中でもっとも美味しさの小さいものを取り出す。
2. Sに存在しないネタを持つ、もっとも美味しさの大きいお寿司を加える。
この操作をNまで繰り返す。

値の挿入および最小値の取り出しは、プライオリティキューを用いる。
プライオリティキューには、取り除いてもネタの種類が減らないお寿司の、美味しさが2番目以降の
お寿司を入れていく。

*/

void solve(){
  ll n,k;
  cin >> n >> k;
  vector<pair<ll,ll>> v;
  rep(i,n){
    ll t,d;
    cin >> t >> d;
    v.emplace_back(make_pair(d,t));
  }
  sort(v.rbegin(),v.rend());
  ll sum = 0;
  
  
  
  priority_queue<ll, vector<ll>, greater<ll>> sushi;
  set<ll> sushitabetai;

  rep(i,k){
    sum += v[i].first;
    if(sushitabetai.find(v[i].second) != sushitabetai.end()){
      sushi.push(v[i].first);
    }
    else{
      sushitabetai.insert(v[i].second);
    }
  }
  ll siz = sushitabetai.size();
  //sum += siz*siz;

  ll ans = sum + siz*siz;
  for(int i = k; i<n; i++){
    //cout << "queue top:" << sushi.top() << endl;
    //cout << "v[i]:" << v[i].first << " " << v[i].second << endl;
    //各お寿司v[k],v[k+1],...,v[n-1]について、
    //ネタが同じならsumには加えない、
    //ネタが同じ出ない時に、プライオリティキューの先頭要素qと比較し、
    //sum-q-siz*siz+(siz+1)*(siz+1)+v[i].first>sumならキューからポップしてsumを更新。
    //ちなみにこの不等式は、2*siz+1+v[i].first>qの時に成立する
    if(sushitabetai.find(v[i].second) == sushitabetai.end() && sushitabetai.size() != k){
      ll q = sushi.top();
      //if(2*siz+1+v[i].first>q){
      //上の評価は実は要らない。なぜなら道中で得られた全てのsumの最大値を計算するため
        sushitabetai.insert(v[i].second);
        sushi.pop();
        sum -= q;
        sum += v[i].first;
        ll t = sushitabetai.size();
        ans = max(ans,sum + t*t);
      //}
    }
  }
  cout << ans << endl;
}

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

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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);

int main() {
    ll a, c;
    double b;
    cin >> a >> b;
     ll d = (b * 100) + 0.99;
    c = a * d;
    cout << c/100 << endl;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int in(){
    int x=0;bool f=0;char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
int res[100005],n;
char ch;
inline int getans(int x){
	printf("%d\n",x);fflush(stdout);
	ch=getchar();while (ch!='M'&&ch!='F'&&ch!='V') ch=getchar();
	if (ch=='V') return -1;return (ch=='F');
}
int main()
{
	n=in();int l=0,r=n;
	res[0]=getans(0);if (res[0]<0) return 0;
	while (l<=r){
		int mid=(l+r)>>1;
		res[mid]=getans(mid%n);if (res[mid]<0) return 0;
		if ((res[mid]^res[0])==(mid&1)) l=mid+1;
		else r=mid-1;
	}return 0;
}

Measured memory_bytes: 852
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        long a = long.Parse(input[0]);
        long b = long.Parse(input[1]);
        long c = long.Parse(input[2]);
//        long d = long.Parse(input[3]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
//        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
//        string[] input = ReadLine().Split(' ');
//        string ko = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        for(int i=0;i<c;i++){
            if(i%2==0){
            b += a/2;
            a /= 2;
            }else{
            a += b/2;
            b /= 2;
            }
        }
        WriteLine("{0} {1}",a,b);
    }
}

Measured memory_bytes: 11220
package main

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

const maxBuf = 300100

var buf []byte = make([]byte, maxBuf)
var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Buffer(buf, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	b, _ := strconv.Atoi(sc.Text())

	if b >= a {
		fmt.Println(a)
	} else {
		fmt.Println(a - 1)
	}
}


Measured memory_bytes: 640
n, k = map(int, input().split())
half_list = [k]

half = k / 2
while True:
  half_list.append(half)
  half = half / 2
  if half < 0.5:
    break

half_list.reverse()
# print(half_list)
ans = 0

for i in range(1, n+1):
  # i が出る確率
  i_prob = 1 / n
  # k を超えるまでに連続して表を出す回数
  half_i = 0
  for j in range(len(half_list)):
    if i >= half_list[j]:
      half_i = j
    else:
      break
  omote_count = len(half_list) - (half_i + 1)
  # print(omote_count, half_i)
  ans += i_prob * ((1 / 2) ** omote_count)
  

print(round(ans, 12))

Measured memory_bytes: 40940
#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<climits>
#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++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	long long x;
	cin >> x;
	if(x%11==0){
		cout << x/11*2 << endl;
	}
	else{
		if(x<=((x/11)*5+(x/11+1)*6)){
			cout << x/11*2+1 << endl;
		}
		else{
			cout << x/11*2+2 << endl;
		}
	}
	return 0;
}



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

using namespace std;

void solve(void)
{
	int x, n;
	cin >> n >> x;
	int p = 0, cnt = 0;
	while(n--)
	{
		cnt++;
		int l;
		cin >> l;
		p += l;
		if (p > x)
		{
			break;
		}
	}
	if (p <= x)
	{
		cnt++;
	}
	cout << cnt << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,t,a[200005];
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=0;i<n;i++)if(a[i]==t+1)t++;
    printf("%d",t?n-t:-1);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int N;
  cin >> N;
  vector<int> H(N);
  REP(i, N) cin >> H[i];
  
  int cnt = 0;
  int MAX = 0;
  REP(i,N-1){
    if(H.at(i)>=H.at(i+1)){
      cnt++;
    }else{
      cnt = 0;
    }
    MAX = max(MAX,cnt);
  }
  cout << MAX << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <stack>
#include <cmath>
#include <functional>
#include <set>
#include <string>
#include <stdlib.h>
#include <iomanip>
#include <utility>
 
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i = a;i<=b;i++)
#define ll long long int
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define iii pair<ii,int >
#define ff first
#define ss second
#define vi vector<int>
#define vc vector<char>
 
using namespace std;


int main(){
	int n;
	cin >> n;
	int k;
	cin >> k;
	int arr[n];
	FOR(i,n)cin >> arr[i];
	ll dp[n][k+1];
	FOR(i,n)FOR(j,k+1)dp[i][j] = 0;
	FOR(i,k+1){
		if(i <= arr[0])dp[0][i] = 1;
	}
	const int MOD = 1000000007;
	FORE(i,1,n-1){
		ll sum = 0;
		FOR(j,k+1){
			sum += dp[i-1][j];
			if(j-arr[i]-1 >=0)sum -= dp[i-1][j-arr[i]-1];
			dp[i][j] = sum%MOD;
		}
	}
	cout << dp[n-1][k] << endl;
	return 0;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    ll N;  cin >> N;
    vector<ll> vec(5);
    rep(i, 5) {
        cin >> vec[i];
    }

    sort(all(vec));
    ll ans;
    if (N % vec[0] != 0) {
        ans = (N / vec[0]) + 5; 
    } else {
        ans = (N / vec[0]) + 4;
    }
    print(ans);
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a;
	while((scanf("%d",&a))!=EOF){
		int n,m,b,c;
		int t;
		t=0;

		for(n=0;n<10;n++)
			for(m=0;m<10;m++)
				for(b=0;b<10;b++)
					for(c=0;c<10;c++){
						if(n+m+b+c==a)
							t++;
					}
					printf("%d\n",t);
	}
	return 0;
}

Measured memory_bytes: 596
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

#define MAX_N 200000

int par[MAX_N];
int rnk[MAX_N];
long long int sz[MAX_N];

// 初期化
void init(int n){
	for(int i = 0; i < n; i++){
		par[i] = i;
		rnk[i] = 0;
		sz[i] = 1;
	}
}

// x の親を返す
int find(int x){
	if(par[x] == x){
		return x;
	}
	return par[x] = find(par[x]);
}

// x と y を併合する
void unite(int x, int y){
	int x_par = find(x);
	int y_par = find(y);
	if(x_par == y_par){
		return;
	}
	
	if(rnk[x_par] < rnk[y_par]){
		sz[y_par] = sz[x_par] + sz[y_par];
		par[x_par] = y_par;
	}else{
		sz[x_par] = sz[x_par] + sz[y_par];
		par[y_par] = x_par;
		if(rnk[x_par] == rnk[y_par]){
			rnk[x_par]++;
		}
	}
}

// x, y が同じグループか判定
bool same(int x, int y){
	return (find(x) == find(y));
}

int main(){
	
	long long int N, M;
	cin >> N >> M;

	vector<P> v;
	
	for(int i = 0; i < M; i++){
		int A, B;
		cin >> A >> B;
		v.push_back(P(A, B));
	}
	reverse(v.begin(), v.end());
	vector<long long int> hoge;
	init(MAX_N);
	long long int ans = N * (N - 1) / 2;
	for(int i = 0; i < M; i++){
		hoge.push_back(ans);
		int A = v[i].first, B = v[i].second;
		if(find(A) != find(B)){
			ans -= sz[find(A)] * sz[find(B)];
		}
		unite(A, B);
	}
	reverse(hoge.begin(), hoge.end());
	for(int i = 0; i < M; i++){
		cout << hoge[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 7792
#include<cstdio>
#include<algorithm>
using namespace std;
#define maxm 10010
#define maxn 1010
struct node 
{
	int u,v,w;
	bool ed;
	bool operator < (const node &rhs)const 
	{
		return w<rhs.w;
	}
}edge[maxm];
int fa[maxn],n,m;
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int main()
{
	while(~scanf("%d%d",&n,&m))
	{
		if(n==0&&m==0)break;
		for(int i=1;i<=n;i++)
			fa[i]=i;
		for(int i=1;i<=m;i++)
		{
			scanf("%d%d%d",&edge[i].u,&edge[i].v,&edge[i].w);
			edge[i].ed=0;
		}
		sort(edge+1,edge+m+1);
		int cnt=0,tmp=0,ans=0;
		for(int i=1;i<=m;i++)
		{
			int x=find(edge[i].u),y=find(edge[i].v);
			if(x==y)continue;
			fa[x]=y;
			edge[i].ed=1;
			cnt++;
		}
		for(int i=1;i<=m;i++)
		{
			if(edge[i].ed)
			{
				tmp++;
				if((cnt&1)&&tmp==(cnt+1)/2)
				{
					ans=edge[i].w;
					break;
				}
				if(cnt%2==0&&(tmp==cnt/2||tmp==cnt/2+1))
					ans+=edge[i].w;
				if(tmp>(cnt+1)/2+1)
					break;
			}
		}
		printf("%d\n",(cnt&1)?ans:ans/2);
	}
}

Measured memory_bytes: 2900
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a % 2 == b % 2) {
			System.out.println((a + b) / 2);
		} else {
			System.out.println("IMPOSSIBLE");
		}

		sc.close();
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define fin(ans) cout << ans << endl

int main(void) {
  int num, bor, ans = 0;
  cin >> num >> bor;
  vector<int> vec(num);
  for (int i = 0; i < num; i++) {
    cin >> vec.at(i);
  }

  for (int i = 0; i < num; i++) {
    if (vec.at(i) >= bor)
      ans++;
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 640
/**
 * lenを固定してキャッシュ自体やめてみる
 */
#include <iostream>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <unordered_set>

using namespace std;

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

  int result = 0;

  for (int len = n-1; len > 0; len--) {
    int match_length = 0;

    for (int i = 0; i+len < n; i++) {
      int j = i+len;

      if (s[i] == s[j] && match_length < len) {
        match_length++;
      } else {
        result = max(result, match_length);
        match_length = 0;
      }
    }

    result = max(result, match_length);
  }

  cout << result << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,ans=0,cnt=0;
  cin >> n;
  for(int i=1; i<=n; i+=2) {
    for(int j=1; j*j<=i; j++) {
      if(i%j==0) {
        cnt++;
        if(j*j!=i) {
          cnt++;
        }
      }
    }
    if(cnt==8) {
      ans++;
    }
    cnt=0;
  }
  cout << ans << endl;
}

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

int main(){
  int n, k, sum=1;
  cin >> n >> k;
  
  for(int i=0; i < n; i++){
    if((sum * 2) < (sum + k)){
      sum *= 2;
    }else{
      sum += k;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3512
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;
import java.lang.Object;
 
public class Main {
    Scanner sc = new Scanner(System.in);
   
    public static void main(String[] args) {
        new Main(); 
    }
   
    public Main() {
        new E().doIt();
    }
    class E{
    	void doIt(){
    		int max = (1 << 15) + 1;
    		int[][] dp = new int[5][max];
            dp[0][0] = 1;
            for(int j=1; j*j<max; j++){
                for(int i=1; i<5; i++){
                    for(int k=j*j; k<max; k++){
                        dp[i][k] += dp[i-1][k-j*j];
                    }
                }
            }
    		while(true){
    			int n = sc.nextInt();
    			if(n == 0)break;
    			int sum = dp[0][n] + dp[1][n] +dp[2][n] + dp[3][n] + dp[4][n];
    			System.out.println(sum);
    		}
    	}
    }
}

Measured memory_bytes: 27908
#include <bits/stdc++.h>
 
#define ff first
#define ss second
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
 
const int MOD = 1e9+7;
int n, dp[22][(1<<21)+1], v[22][22];
bool mark[22][(1<<21)+1];
 
int f(int man, int mask) {
  if(mask == (1<<n)-1) return 1;
  if(mark[man][mask]) return dp[man][mask];
  mark[man][mask] = true;
  
  int ret = 0;
  for(int i = 0; i < n; i++) {
	if(mask&(1<<i) or v[man][i] == 0) continue;
    ret += f(man+1, mask | (1<<i));
    if(ret >= MOD) ret -= MOD;
  }
  
  return dp[man][mask] = ret;
}
 
int main() {
	scanf("%d", &n);
  	
  	for(int i = 0; i < n; i++)
      for(int j = 0; j < n; j++)
      	scanf("%d", &v[i][j]);
 
	printf("%d\n", f(0,0));
	
    return 0;
}

Measured memory_bytes: 207104
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool isprime(int x)
{
	for(int j=2;j*j<=x;++j)
	{
		if(x%j==0 || x%(x/j)==0)
		return false;
	}
	return true;
}
void solve()
{
	int x;cin>>x;
	for(int j=x;;j++)
	{
		if(isprime(j)){
		cout<<j;
		break;
		}
	}
}
int main()
{
	//int t;cin>>t;
//	while(t--)
	solve();
}


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

#define ll long long
#define pi 2*acos(0.0)

const int maxn = 1e5+7;

ll h[maxn], dp[maxn], n, k;

ll call(int pos)
{
    if(pos > n)
    {
        return INT_MAX;
    }
    if(pos == n)
    {
        return 0;
    }
    if(dp[pos] != -1)
    {
        return dp[pos];
    }

    ll ret = INT_MAX;

    for(int i = 1; i <= k; i++)
    {
        ret = min(ret, (abs(h[pos] - h[pos+i]) + call(pos+i)));
    }


    dp[pos] = ret;
    return dp[pos];
}

int main()
{
  
    scanf("%lld %lld", &n, &k);

    memset(dp, -1, sizeof dp);

    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &h[i]);
    }

    cout << call(1) << endl;

    return 0;
}


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

struct UnionFind{
  vector<ll> d;
  UnionFind( ll n=0 ) : d(n,-1) {}
  ll find( ll x ){
    if( d.at(x) < 0 ) return x;
    return d.at(x) = find( d.at(x) );
  }
  bool unite( ll x, ll y ){
    x = find(x);y = find(y);
    if( x == y ) return false;
    if( -d.at(x) < -d.at(y) ) swap(x,y);
    d.at(x) += d.at(y);
    d.at(y) = x;
    return true;
  }
  bool same( ll x, ll y ){ return find(x) == find(y); }
  ll size( ll x ){ return -d.at( find(x) ); }
};
typedef struct UnionFind UnionFInd;

int main(){
  ll n,m;cin >> n >> m;
  UnionFind uf(n);
  rep(i,m){
    ll a,b;cin >> a >> b;
    --a;
    --b;
    uf.unite(a,b);
  }
  set<ll> s;
  rep(i,n) s.insert(uf.find(i));
  cout << s.size()-1 << endl;
  return 0;
} 

Measured memory_bytes: 7788
#include<iostream>
#include<vector>

using Int =long long;
const Int INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b)a = b; return true;
	return false;
}

int main() {

	Int N;
	std::cin >> N;

	std::vector<Int> dp( 200000,INF);
	dp[0]=0;

	std::vector<Int> h{ 1,6,36,216,1296,7776,46656,9,81,729,6561,59049 };

	for (Int i = 0; i < N; i++) {

		for (int j = 0; j < 12; j++) {

			chmin(dp[i + h[j]], dp[i] + 1);
		}

	}

	std::cout << dp[N] << std::endl;

}

Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
   int n;
   cin>>n;
   string s;
   cin>>s;
   int q;
   cin>>q;
   while(q--){
       int k;cin>>k;
       ll d=0,m=0,dm=0,ans=0;//オーバーフロー注意
       for(int i=0;i<n;i++){
            if(i-k>=0){
               if(s[i-k]=='D'){
                   d--;
                   dm-=m;
               }
               if(s[i-k]=='M'){
                   m--;
               }
           }
           if(s[i]=='D')d++;
           if(s[i]=='M'){
               dm+=d;
               m++;
           }
           if(s[i]=='C')ans+=dm;
       }
       cout<<ans<<"\n";
   }
}

Measured memory_bytes: 4248
n,m=map(int,input().split())
h=[int(x) for x in input().split()]
gd=[1]*n
for i in range(m):
  a,b=[int(x)-1 for x in input().split()]
  if h[a] >= h[b]:
    gd[b]=0
  if h[a] <= h[b]:
    gd[a]=0
print(sum(gd))

Measured memory_bytes: 20104
N = int(input())
ans = 0

if N < 3:
    print(N)
    exit()

for i in range(1, N + 1):
    tmp = (i * (i - 1)) //  2
    if tmp >= N:
        ans = i - 1
        break

anslst = [i for i in range(ans, 0, -1)]
tmp = N - anslst[0]
print(anslst[0])
for i in anslst[1:]:
    if tmp - i < 0:
        continue
    if tmp == 0:
        break
    print(i)
    tmp -= i

Measured memory_bytes: 3572
import java.util.*;
import java.util.Arrays;

public class Main {
    class Node {
        int id, parent = -1, depth = -1, height = -1, bro = -1;
        int left = -1, right = -1, deg = 0;
        String nodeType = null;
        Node(int id, int left, int right) {
            this.id = id;
            this.left = left;
            this.right = right;
            if (left != -1) deg++;
            if (right != -1) deg++;
        }
        void print() {
            StringBuilder sb = new StringBuilder();
            sb.append("node ");
            sb.append(id);
            sb.append(": parent = ");
            sb.append(parent);
            sb.append(", sibling = ");
            sb.append(bro);
            sb.append(", degree = ");
            sb.append(deg);
            sb.append(", depth = ");
            sb.append(depth);
            sb.append(", height = ");
            sb.append(height);
            sb.append(", ");
            sb.append(nodeType);
            System.out.println(new String(sb));
        }
    }
int findRoot(boolean[] rs) {
        for (int i = 0; i < rs.length; i++) {
            if (!rs[i]) return i;
        }
        System.out.println("could not find root.");
        return -1;
    }

    int search(Node[] nodes, int id, int depth, int parent, int bro) {
        nodes[id].depth = depth;
        nodes[id].parent = parent;
        nodes[id].bro = bro;

        int left_id  = nodes[id].left;
        int right_id = nodes[id].right;

        int left_height = 0, right_height = 0;
        if (left_id != -1) {
            left_height  = search(nodes, left_id, depth+1, id, right_id);
        }
        if (right_id != -1) {
            right_height = search(nodes, right_id, depth+1, id, left_id);
        }
        nodes[id].height = Math.max(left_height, right_height);
        if (parent == -1) {
            nodes[id].nodeType = "root";
        } else if (left_id == -1 && right_id == -1) {
            nodes[id].nodeType = "leaf";
        } else {
            nodes[id].nodeType = "internal node";
        }
        return nodes[id].height + 1;
    }
 void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Node[] nodes = new Node[n];
        boolean[] couldNotRoot = new boolean[n];
        for (int i = 0; i < n; i++) {
            int id = sc.nextInt();
            int left = sc.nextInt();
            int right = sc.nextInt();
            //Arrays.sort(childs);
            nodes[id] = new Node(id, left, right);
            if (left != -1) couldNotRoot[left] = true;
            if (right != -1) couldNotRoot[right] = true;
        }
        int root = findRoot(couldNotRoot);
        search(nodes, root, 0, -1, -1);
        for (int i = 0; i < nodes.length; i++) {
            nodes[i].print();
        }
    }
    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 26348
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main() 
{
	double x1, x2, y1, y2, a;
	cin >> x1 >> x2 >> y1 >> y2 >> a;
	a = sqrt((y1 - x1) * (y1 - x1) + (y2 - x2) * (y2 - x2));
	cout << fixed << setprecision(8) << a << endl;
	return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int A,B;

int main(){
	cin>>A>>B;
	if(B==100) B++;
	cout<<B;
	for(int i=0;i<A;i++) cout<<"00";
	cout<<endl;
}

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

using namespace std;

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

Measured memory_bytes: 256
import java.util.*;

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

if(1<=A && A<=9 && 1<=B && B<=9){

System.out.println(A*B);

} else {
System.out.println(-1);
}
} 
}

Measured memory_bytes: 23636
import java.io.PrintStream;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        doit(args, new Scanner(System.in), System.out);
    }

    static void doit(String[] args, Scanner scanner, PrintStream out) {
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int result = 0;
            for (int a = 0; a < 10; a++) {
                if (a > n) {
                    break;
                }
                for (int b = 0; b < 10; b++) {
                    int ab = a + b;
                    if (ab > n) {
                        break;
                    }
                    for (int c = 0; c < 10; c++) {
                        int abc = ab + c;
                        if (abc > n) {
                            break;
                        }
                        for (int d = 0; d < 10; d++) {
                            if (abc + d == n) {
                                result++;
                                break;
                            }
                        }
                    }
                }
            }
            out.println(result);
        }
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }






int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<vector<pii>> a(n);
	rep(i,n){
		int b;cin >> b;
		rep(j,b){
			int x,y;cin >> x >> y;
			x--;
			a[i].ep(x,y);
		}
	}
	int ans = 0;
	rep(mask,(1 << n)){
		int cnt = 0;
		vector<bool> b(n);
		rep(i,n){
			if((1 << i) & mask){
				cnt++;
				b.at(i) = true;
			}
		}
		bool ok = true;
		rep(i,n){
			if(b.at(i)){
				rep(j,a[i].size()){
					if((a[i][j].second && !b.at(a[i][j].first)) || (a[i][j].second == 0 && b.at(a[i][j].first))) ok = false;
				}
			}
		}
		if(ok) chmax(ans, cnt);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main(void)
{
     int i,j,k,n,m,a,b,c;
     scanf("%d%d%d",&a,&b,&c);
     if(a==b)
     {
          printf("%d\n",c);
     }
     else
     {
          if(a==c)
               printf("%d\n",b);
          else
               printf("%d\n",a);
     }
     return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


template <class T> std::vector<T> enum_div(const T &n) {
  std::vector<T> ret;
  T i = static_cast<T>(1);
  while (i * i < n) {
    if (n % i == static_cast<T>(0)) {
      ret.push_back(i);
      ret.push_back(n / i);
    }
    ++i;
  }
  if (i * i == n) {
    ret.push_back(i);
  }
  std::sort(ret.begin(), ret.end());
  ret.shrink_to_fit();
  return std::move(ret);
}

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

  ll n;
  cin >> n;

  ll ans = 0;
  for(ll i : enum_div(n)){
    if(i == 1) continue;
    ll a = n;
    while(1){
      if(a % i == 0) a /= i;
      else break;
    }
    if(a % i == 1) ans++;
  }
  ans += enum_div(n-1).size()-1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <random>
#include <set>
#include <sstream>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-9;
const double PI = acos(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 100005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
bool is_palin(const string& s) {
    int sz = s.size();
    int l = sz / 2 - 1, r = sz / 2;
    if (sz & 1) {
        r++;
    }
    while (l >= 0 && r < sz) {
        if (s[l] != s[r]) return false;
        l--, r++;
    }
    return true;
}
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    string s;
    cin >> s;
    n = s.size();
    bool b = is_palin(s) && is_palin(s.substr(0, (n - 1) / 2)) &&
             is_palin(s.substr((n + 3) / 2 - 1, (n - 1) / 2));
    printf("%s", b ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args){
		final Scanner sc = new Scanner(System.in);
		
		final int[] coins = {1000, 500, 100};
		
		while(true){
			final int price = sc.nextInt(), pay = sc.nextInt();
			
			if(price == 0 && pay == 0){
				break;
			}
			
			int diff = pay - price;
			
			int count[] = new int[3];
			
			for(int i = 0; i < 3; i++){
				while(diff >= coins[i]){
					diff -= coins[i];
					count[i]++;
				}
			}
			
			System.out.println(count[2] + " " + count[1] + " " + count[0]);
			
		}
		
	}
}	

Measured memory_bytes: 12000
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   : combinatorics NCR
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("graphs_as_a_service.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 2e3 + 10, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
vl X, Y;
vii v;
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	int n, k;
	cin >> n >> k;
	lp(i,1,n)
	{
		int x, y;
		cin >> x >> y;
		X.pb(x);
		Y.pb(y);
		v.pb( { x, y });
	}
	X.resize(unique(all(X)) - X.begin());
	Y.resize(unique(all(Y)) - Y.begin());
	sort(all(X));
	sort(all(Y));
	ll ans = INFL;
	lp(i,0,X.size()-1)
	{
		lp(j,i,X.size()-1)
		{
			lp(f1,0,Y.size()-1)
			{
				lp(f2,f1,Y.size()-1)
				{
					int cnt = 0;
					for (auto u : v)
						if (u.F >= X[i] && u.F <= X[j] && u.S >= Y[f1]
								&& u.S <= Y[f2])
							cnt++;
					if (cnt >= k)
						ans = min(ans, (X[j] - X[i]) * (Y[f2] - Y[f1]));
				}
			}
		}
	}
	f(ans);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
test_s = ''

for i in range(n-1):
  if s[i] == s[i+1]:
    # print('同じ')
    test_s += '0'
  else:
    # print('違う')
    test_s += '1'

result = int(test_s.count('1')) + 1
if result == 0:
    print(1)
else:
	print(result)



Measured memory_bytes: 3316
str = input()
q = int(input())

for _ in range(q):
    lst = list(input().split())
    command = lst[0]
    a = int(lst[1])
    b = int(lst[2])
    
    if command == "print":
        print(str[a:b+1])
    elif command == "reverse":
        str = str[:a] + str[a:b+1][::-1] + str[b+1:]
    else:
        str = str[:a] + lst[3] + str[b+1:]


Measured memory_bytes: 5616
n = int(input())
ab_list = []
for i in range(n):
    a, b = map(int, input().split())
    ab_list.append([a, b])
cnt = 0
for a, b in ab_list[::-1]:
    tmp_cnt = b - ((cnt + a) % b if (cnt + a) % b != 0 else b)
    cnt += tmp_cnt
print(cnt)

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

int n, m, ans[100002];
vector<int>adjl[100002];

int main(){
	cin >> n >> m;
	for (int i=0;i<m;i++){
		int u, v;
		cin >> u >> v;
		adjl[u].push_back(v);
		adjl[v].push_back(u);
	}
	memset(ans,-1,sizeof ans);
	queue<pair<int,int>>bfs; // now, prev
	bfs.push({1,0});
	while (!bfs.empty()){
		int now=bfs.front().first;
		int prev=bfs.front().second;
		bfs.pop();
		if (ans[now]!=-1) continue;
		ans[now]=prev;
		for (int next : adjl[now]) bfs.push({next,now});
	}
	cout << "Yes\n";
	for (int i=2;i<=n;i++) cout << ans[i] << "\n";
}

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

#define double long double

const double INF = 1e9;


struct P {
	double x, y, z;
};

struct S {
	P p, v;
	double r, vr;
	double vanish(){
		return r / vr;
	}
};

void f(double p1, double p2, double v1, double v2, double& a, double& b, double &c){
	a += (v1 - v2) * (v1 - v2);
	b += 2 * (p1 - p2) * (v1 - v2);
	c += (p1 - p2) * (p1 - p2);
}

void g(double r1, double r2, double v1, double v2, double& a, double& b, double &c){
	a += -(v1 + v2) * (v1 + v2);
	b += +2 * (v1 + v2) * (r1 + r2);
	c += -(r1 + r2) * (r1 + r2);
}

double collision(S s1, S s2){
	double T = min(s1.vanish(), s2.vanish());
	double a = 0, b = 0, c = 0;
	double p1[3] = { s1.p.x, s1.p.y, s1.p.z };
	double p2[3] = { s2.p.x, s2.p.y, s2.p.z };
	double v1[3] = { s1.v.x, s1.v.y, s1.v.z };
	double v2[3] = { s2.v.x, s2.v.y, s2.v.z };
	for(int i = 0; i < 3; i++) {
		f(p1[i], p2[i], v1[i], v2[i], a, b, c);
	}
	g(s1.r, s2.r, s1.vr, s2.vr, a, b, c);

	double D = b * b - 4 * a * c;
	if(D < 0) return INF;
	double t = (-b - sqrt(D)) / (2 * a);
	if(0 <= t && t <= T) return t;
	t = (-b + sqrt(D)) / (2 * a);
	if(0 <= t && t <= T) return t;
	return INF;
}

struct Event {
	double t;
	int i, j;

	bool operator <(const Event& x) const{
		return t < x.t;
	}
};

S s[200];
double ans[200];

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

	int N;
	while(cin >> N, N) {
		double ans[200];

		for(int i = 0; i < N; i++) {
			cin >> s[i].p.x >> s[i].p.y >> s[i].p.z;
			cin >> s[i].v.x >> s[i].v.y >> s[i].v.z;
			cin >> s[i].r >> s[i].vr;
		}

		vector<Event> es;
		for(int i = 0; i < N; i++) {
			for(int j = i + 1; j < N; j++) {
				double t = collision(s[i], s[j]);
				if(t >= INF) continue;
				es.push_back({ t, i, j });
			}
		}
		sort(es.begin(), es.end());

		vector<int> dead(N);
		for(auto e : es) {
			if(dead[e.i] || dead[e.j]) continue;
			dead[e.i] = dead[e.j] = 1;
			ans[e.i] = ans[e.j] = e.t;
		}

		for(int i = 0; i < N; i++) {
			if(!dead[i]) ans[i] = s[i].vanish();
		}

		for(int i = 0; i < N; i++) {
			cout << fixed << setprecision(15) << ans[i] << endl;
		}
	}
}

Measured memory_bytes: 3348
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	vector<int> v(3);
	cin >> v.at(0) >> v.at(1) >> v.at(2);

	sort(v.begin(), v.end());
	cout << v.at(0) + v.at(1) << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}

// 最小公倍数
ll lcm(ll a, ll b){
	
	ll x = a * b;
	  if(a<b){
    ll tmp = a;
    a = b;
    b = tmp;
  }
	  /* ユークリッドの互除法 */
  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
	return x/b;

}

void mainsolve(){

	ll n,m;
	cin >> n >> m;
	vector<ll> a(n);
	rep(i,n){
		ll tmp;
		cin >> tmp;
		a[i] = tmp/2; // あらかじめ奇数にして公倍数を考える
	}

	ll lcma = a[0];
	rep(i,n-1) lcma = lcm(lcma, a[i+1]);

	bool isAllOdd = true;
	rep(i,n){
		if((lcma/a[i])%2 == 0) isAllOdd = false;
	}

	if(!isAllOdd){
		cout << 0 << endl;
		return;
	}

	ll res = m/lcma;
	if(res%2 == 0) cout << res/2 << endl;
	else cout << (res/2)+1 << endl;

	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  ll n;
  cin >> n;
  vector<pp> a(n);
  rep(i,n){
    ll b,c;
    cin >> b >> c;
    a[i] = pp(b,c);
  }
  map<pp,ll> hhh;
  rep(i,n)for(ll j = i+1;j<n;j++){
    ll dx = a[i].first-a[j].first;
    ll dy = a[i].second-a[j].second;
    hhh[pp(dx,dy)] ++;
    hhh[pp(-dx,-dy)] ++;
  }
  ll ans = 0;
  for(auto i:hhh) ans = max(ans, i.second);
  cout << n - ans << endl;
    
  return 0;
}





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

int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  
  if(n < 3){
    cout << 0 << endl;
    return 0;
  }
  
  ll r=0, g=0, b=0;
  for(int i = 0; i < n; i++){
    if(s[i] == 'R') r++;
    if(s[i] == 'G') g++;
    if(s[i] == 'B') b++;
  }
  ll ans = r*g*b;
  
  for(int j = 0; j < n; j++){
    for(int i = 0; i < j; i++){
      int k = j+j-i;
      if(k < n){
        if(s.at(i) != s.at(j) && s.at(j) != s.at(k) && s.at(k) != s.at(i)) ans--;
      }
    }
  }
  
  cout << ans << endl; 
  return 0;
}


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

int main() {
	long long N, A[100000], SUM = 0, X;
	cin >> N;
	X = N * (N + 1) / 2;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		SUM += A[i];
	}
	if (SUM % X != 0) {
		cout << "NO";
		return 0;
	}
	long long COUNT = SUM / X;
	for (int i = 0; i < N; i++) {
		long long S = A[(i - 1 + N) % N] - A[i];
		if ((S + COUNT) % N != 0 || (S + COUNT) / N < 0) {
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
}

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

unsigned long long int gcd(unsigned long long int a, unsigned long long int b){
  
  if (b == 0)
	return a;
  
  return gcd(b,a%b);
}

unsigned long long int lcm(unsigned long long int a,unsigned long long int b){
  
  if (a > b) { 
    return b * (a / gcd(a,b));
  } else {
    return a * (b / gcd(a,b)); 
  }
}

int main (void){
  
  int n;
  cin >> n;
  unsigned long long int a[n];
  
  for(int i = 0; i< n; ++i){
    cin >> a[i];
  }
  
  sort(&a[0],&a[n]);
  unsigned long long int ans = 1;
  
  for(int i = 0; i < n; ++i){
    ans = lcm(ans,a[i]);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 764
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

int main(){
    char s[15]; scanf("%s", s);
    int res = 1; FOR(i,3) res &= s[i] != s[i+1];
    puts(res ? "Good" : "Bad");
    return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * 1390.cc: Arithmetic Progressions
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 5000;
const int MAX_M = MAX_N * MAX_N / 2;

/* typedef */

typedef pair<int,int> pii;

/* global variables */

int vs[MAX_N];
pii ps[MAX_M];
bool used[MAX_M];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", vs + i);
  sort(vs, vs + n);

  int m = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      ps[m++] = pii(vs[j] - vs[i], vs[i]);
  sort(ps, ps + m);

  int maxc = 0;
  for (int i = 0; i < m; i++)
    if (! used[i]) {
      used[i] = true;
      int c = 2, j = i;
      for (;;) {
	pii pj(ps[j].first, ps[j].first + ps[j].second);
	j = lower_bound(ps, ps + m, pj) - ps;
	if (j >= m || ps[j] != pj) break;
	c++;
	used[j] = true;
      }

      if (maxc < c) maxc = c;
    }
  printf("%d\n", maxc);
  return 0;
}



Measured memory_bytes: 113156
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e6 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	int a[n];
	map<int, int> m;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		m[a[i]]++;
	}
	int ans = 0;
	for(auto it : m) {
		ans += it.se * (it.se - 1) / 2;
	}
	for(int i = 0; i < n; i++) {
		int cur = ans - (m[a[i]] * (m[a[i]] - 1) / 2);
		cur += ((m[a[i]] - 1) * (m[a[i]] - 2) / 2);
		cout << cur << endl;
	}

	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


/*
int N;
Graph G;

int main() {
  cin >>N;
  rep(i, N-1){
    int a,b; cin >>a >>b; a--; b--;
    G[a].push_back(b); G[b].push_back(a);
  }
}
*/

int main() {
  string s; cin >>s;
  rep(i, 4) cout <<s[i];
  cout <<" ";
  rep(i, 8) cout <<s[i+4];
  cout <<endl;
}

Measured memory_bytes: 256