akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <tuple>

#define llong long long
#define rep(i,l,n) for(llong (i)=(l);(i)<(n);(i++))
#define _min(a,b) ((a)<(b)?(a):(b))
#define _max(a,b) ((a)>(b)?(a):(b))
#define _abs(a) ((a)>0?(a):(-(a)))

using namespace std;

// ��Ԃ�����

class interval{
	private:
		int MIN,MAX;
	public:
		interval(int min,int max){
			if( min > max ) std::swap(min,max);
			MIN = min; MAX = max;
		}
		bool operator ==(const interval &s) const{
			return (MIN==s.MIN)&&(MAX==s.MAX);
		}
		int min(){ return MIN; }
		int max(){ return MAX; }
		void output(){
			std::cout << MIN << " " << MAX << std::endl;
		}
		bool in(int x){ return (MIN<=x)&&(x<=MAX); }
};


// �L�E��Ԃ��Ԃœh��B
// �㏑�����邩, ���̏����œh��ς�邩��paint(int)�Q��

class interval_paint{
	private:
		int MIN,MAX;
		// ��ԓ��ɈႤ�F������ꍇ��-1
		int data;
		// ��ԓ��ɑ��݂���ő�l
		int max_data;
		interval_paint *left,*right,*up;
	public:
		interval_paint(int,int);
		interval_paint(int,int,interval_paint*);
		void paint(int,int,int);
		void paint(int);
		int color(int);
		int max(){
			if( data!=-1 ) return data;
			int ans = data;
			ans = _max(ans,left->max());
			ans = _max(ans,right->max());
			return ans;
		}
};

interval_paint::interval_paint(int min,int max){
	if( min > max ) std::swap(min,max);
	MIN = min; MAX = max; max_data = data = -1;
	if( MIN!=MAX ){
		left = new interval_paint(min,(min+max)/2,this);
		right = new interval_paint((min+max)/2+1,max,this);
	}
	up = 0;
}

interval_paint::interval_paint(int min,int max,interval_paint *UP){
	if( min > max ) std::swap(min,max);
	MIN = min; MAX = max; max_data = data = -1;
	if( MIN!=MAX ){
		left = new interval_paint(min,(min+max)/2,this);
		right = new interval_paint((min+max)/2+1,max,this);
	}
	up = UP;
}

// [min,max]��data��color�œh��ւ���
void interval_paint::paint(int min,int max,int color){
	// ���ɓ����F�ɓh���Ă���Ȃ�I���
	// �ݒ�ɂ���Ă͏����Ă��ǂ�
	if( data >= color ) return;
	if( max_data <= color && min<=MIN && MAX<=max ){
		paint(color);
		return;
	}
	max_data = _max(max_data,color);
	// ��ԓ��ɈႤ�F������
	if( data!=-1 ){
		left ->data = data;
		right->data = data;
	}
	data = -1;
	if( min<=(MIN+MAX)/2 ){
		left->paint(min,max,color);
	}
	if( max> (MIN+MAX)/2 ){
		right->paint(min,max,color);
	}
	return;
}

// this�̋�Ԃ�h��ւ���
void interval_paint::paint(int color){
	if( data < color ) max_data = data = color;
	// �h��ւ�����, ���傫���͈͂œh���Ă���Ȃ珑��������.
	interval_paint *temp = up;
	while( temp!=0 && temp->left->data == temp->right->data && temp->data==-1 ){
		temp->data = color;
		temp = temp->up;
	}
}

// ���Wx�̐F��Ԃ�
int interval_paint::color(int x){
	if( data!=-1 ) return data;
	else if( x <= (MIN+MAX)/2 ) return left->color(x);
	else return right->color(x);
}

int main(){
	int N,K;
	cin >> N >> K;
	interval_paint data(1,300000);
	data.paint(1,300000,0);
	rep(i,0,N){
		int a;
		cin >> a;
		int k = data.color(a);
		data.paint(a-K,a+K,k+1);
	}
	cout << data.max();
}


Measured memory_bytes: 31716
program main

  implicit none
  integer(8) :: h, w
  integer(8) :: i, j, k

  
  read(*,*) h, w

  if( mod(h,2) == 0 ) then 
    i = h/2 
    j = w 
    k = i*j
  else
    i = h/2 + 1 
    j = w
    k = i*j - w/2
  end if
  if( h == 1 .or. w == 1 )then 
    print*, 1
  else
    print*, k
  end if
  

end program main


Measured memory_bytes: 640
n,k = map(int,input().split())
abl = []
for _ in range(n):
   a,b = map(int,input().split())
   abl.append((a,b))

abl = sorted(abl)
for a,b in abl:
    k -= b
    if k <= 0:
        print(a)
        import sys
        sys.exit()


Measured memory_bytes: 17792
N, X = map(int, input().split())
b = [1]
p = [1] 
for i in range(N + 1):
  b.append(b[i] * 2 + 3)
  p.append(p[i] * 2 + 1)
def solve(n, x):
  if n <= 0:
    return 0 if x <= 0 else 1
  elif x <= 1 + b[n - 1]:
    return solve(n - 1, x - 1)
  else:
    return p[n - 1] + 1 + solve(n - 1, x - 2 - b[n - 1])
print(solve(N, X))

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

ll gcd(ll a,ll b){if(!b)return abs(a);return (a%b==0)?abs(b):gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}


int main(){
  startupcpp();
  int codeforces;cin>>codeforces;while(codeforces--){
  ll A,B,C,D;
  cin>>A>>B>>C>>D;
  if(min(A,D)<B){
    printno;
    continue;
  }
  if(B<=C){
    printyes;
    continue;
  }
  D=gcd(B,D);
  if(B-C>D||A%D>C%D)printno;
  else printyes;
  }return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, H, W;

ll fact[MAXN];
ll inv[MAXN];
pii forb[MAXN];
ll bp(ll a, ll b){
    ll res = 1;
    while(b){
        if(b % 2) res = (res * a) % mod;
        a = (a*a) %mod;
        b = b / 2;
    }
    return res;
}
bool cmp(pii a, pii b){
    return a.ff + a.ss < b.ff + b.ss;
}
int tree[MAXN];
ll dp[MAXN];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>H>>W;
    cin>>n;
    fact[0] = 1;
    inv[0] = 1;
    for(ll i = 1; i <= 2e5; i++){
        fact[i] =  (fact[i - 1]*i)%mod;
        inv[i] = bp(fact[i], mod - 2);
    }
    ll ans = fact[H + W - 2]*inv[H - 1]%mod*inv[W - 1]%mod;
    for(int i = 0; i < n; i++){
        int h, w;
        cin>>h>>w;
        forb[i] = {h, w};
    }
    sort(forb, forb + n, cmp);

    for(int i = 0; i < n; i++){
        ll x = forb[i].ff, y = forb[i].ss;
        dp[i] = fact[x + y - 2]*inv[x - 1]%mod*inv[y - 1]%mod;
        for(int j = 0; j < i; j++){
            ll x2 = forb[j].ff, y2 = forb[j].ss;
            if(x2 > x || y2 > y)
                continue;
            ll dx = (x - x2), dy = (y - y2);
            dp[i] = (dp[i] - (dp[j]*fact[dx + dy]%mod*inv[dx]%mod*inv[dy])%mod + mod)%mod;
        }
        //cout<<x<<" "<<y<<" "<<((dp[i]*fact[H + W - x - y])%mod*inv[H - x])%mod*inv[W - y]%mod <<endl;
        ans = ans - (((dp[i]*fact[H + W - x - y])%mod*inv[H - x])%mod*inv[W - y])%mod + mod;
        ans %= mod;
    }
    cout<<ans<<endl;


    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb emplace_back
#define fi first
#define se second
const int mod = 1e9 + 7;
#define int long long int
#define pii pair<int,int>

signed main(){
    //freopen("inp.txt", "r", stdin);
    int n, p;
    scanf("%lld %lld", &n, &p);
    int e = 0, o = 0;
    for(int i = 1;i <= n; i++){
        int x;
        scanf("%lld", &x);
        if(x & 1)
            o++;
        else
            e++;
    }
    int ans;
    if(p & 1){
        if(o == 0)
            ans = 0;
        else
            ans = pow(2, e) * pow(2, o - 1);
    }
    else{
        if(o == 0)
            ans = pow(2, e);
        else
            ans = pow(2, e) * pow(2, o - 1);
    }
    printf("%lld", ans);
    return 0;
} 

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

int main(){
    int n, m;
    cin >> n >> m;
    int ans=1;
    for(int a = 1; a * a < m; a++)
    {
        int b = m/a;
        if(m%a!=0) continue;
        if(m/a>=n) ans = max(ans, a);
        if(m/b>=n) ans = max(ans, b);
    }
    

    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import collections
import itertools

input = sys.stdin.readline


def main():
    N = int(input())
    C = collections.Counter()
    for _ in range(N):
        S = input().strip()
        C[S[0]] += 1

    ans = 0
    for x, y, z in itertools.combinations("MARCH", 3):
        ans += C[x] * C[y] * C[z]

    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>

main()
{
	int a,b,c,o,sum;
	a=getchar();
	b=getchar();
	c=getchar();
	sum=700;
	if (a=='o'){
	sum+=100;
	}
	if (b=='o'){
	sum+=100;
	}
	if (c=='o'){
	sum+=100;
	}
	printf("%d",sum);
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, r;
  cin >> n >> r;
  if (n >= 10) {
    cout << r << endl;
  } else {
    cout << r + 100 * (10 - n) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

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

    int k,n; cin >> k >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int admax = 0;
    rep(i,n-1) admax = max(a[i+1] - a[i],admax);
    cout << min(a[n-1]-a[0], k-admax) << endl;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var cnt, ans int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	M, _ := strconv.Atoi(read())
	AB := make([][]int, 1e5+5)
	for i := 0; i < N; i++ {
		t, _ := strconv.Atoi(read())
		v, _ := strconv.Atoi(read())
		AB[t] = append(AB[t], v)
	}
	pq := &PriorityQueue{}
	heap.Init(pq)
	for i := 1; i <= M; i++ {
		for j := 0; j < len(AB[i]); j++ {
			heap.Push(pq, AB[i][j])
		}
		if pq.Len() != 0 {
			ans += heap.Pop(pq).(int)
		}
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i][0] == a[j][0] {
		return a[i][1] > a[j][1]
	}
	return a[i][0] < a[j][0]
}

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] > h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


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

typedef long long ll;
ll n, ans, num[10][10];

void add(ll x) {
	ll a;
	a = x % 10;
	while (x > 9)
		x /= 10;
	num[a][x]++;
} 
int main() {
	cin >> n;
	for (ll i = 1; i <= n; i++)
		if (i % 10)
			add(i);
	for (ll i = 1; i <= 9; i++)
		for (ll j = 1; j <= 9; j++)
			ans += (num[i][j] * num[j][i]);
	cout << ans << endl;
}
	


Measured memory_bytes: 256
import Data.List

main = do
  _ <- getLine
  ss <- return . (map sort) . lines =<< getContents

  putStrLn $ foldl1 f ss

  where
    f [] _ = []
    f _ [] = []
    f (x:xs) y =
      if i == Nothing then
        f xs y
      else
        let Just j = i
        in (y!!j) : (f xs (drop (j+1) y))
      where
        i = elemIndex x y


Measured memory_bytes: 1020
#include <map>
#include <cstdio>
using namespace std;
map<int,int> mp;
int main(){
	int n,now,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&now);
		mp[now]++;
	}
	map<int,int>::iterator it;
	for(it=mp.begin();it!=mp.end();it++){
		if((it->first)!=(it->second)){
			if((it->first)<(it->second)){
				ans+=(it->second)-(it->first);
			}
			else{
				ans+=(it->second);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 4736
#![allow(non_snake_case, unused_imports, deprecated)]

// Input macros
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,VecDeque,BinaryHeap};
// Module for v1.15.1
use std::ascii::AsciiExt; // deprecated since 1.26.0: use inherent method instead

// Functions
fn dfs(n:usize, color:usize, A:&Vec<Vec<(usize,i64)>>, ans:&mut Vec<usize>){
    ans[n] = color;
    for &(next_n, length) in A[n].iter(){
        if ans[next_n] == 9{
            let next_color = if length%2==0{color}else{1-color};
            dfs(next_n, next_color, A, ans);
        }
    }
}
// Main
fn main(){

    input!{
        N: usize,
        UVW: [(usize,usize,i64); N-1]
    }

    let mut A = vec![vec![]; N];
    for (u,v,w) in UVW{
        A[u-1].push((v-1, w));
        A[v-1].push((u-1, w));
    }

    let mut ans = vec![9; N];
    // current node, color(0 or 1), adjacency list, ans vec
    dfs(0, 0, &A, &mut ans);

    for i in 0..N{
        println!("{}", ans[i]);
    }

}

Measured memory_bytes: 18684
N = int(input())
K = 0
for i in range(1, 500):
    if i * (i + 1) == 2 * N:
        K = i
        break
if K == 0:
    print("No")
    exit()

A = [[0] * K for _ in range(K)]
count = 1
for i in range(K):
    for j in range(i + 1):
        A[i][j] = count
        count += 1

print("Yes")
print(K + 1)
ans = []
for i in range(K):
    tmp = A[i][:i + 1]
    for y in range(i + 1, K):
        tmp.append(A[y][i])
    ans.append(tmp)
ans.append([A[i][i] for i in range(K)])
for a in ans:
    print(K, *a)

Measured memory_bytes: 15396
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    long long int t,x,y,num,flag = 0;
    double dis;
    cin>>t>>num;
    for(int i =1 ; i<=t; i++){
        cin>>x>>y;
        dis = (double)sqrt((x*x)+(y*y));
        if(dis<=num){
            flag++;
        }
    }
    cout << flag << endl;
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>

using namespace std;

int main(){
	
	while(1){
		int n;
		cin>>n;
		
		if(n==0)break;
		
		int ans = 0;
		for(int i=0;i<20;i++){
			ans += n/5;
			n/=5;
		}
		
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1160
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k==x:
                ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define vi vector<int>
#define pb push_back
#define w(t)   int t;cin>>t;while(t--)
#define show(ar) for(int i=0;i<ar.size();i++) cout<<ar[i]<<" "; cout<<endl;
#define mod 1e9+7
#define ff first
#define ss second
#define fio ios::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
#define all(x) (x.begin(),x.end())
#define inf 1e9+7
#define MAX 90000000
#define ll unsigned long long 

 
int main()
{
	string s,t; cin>>s>>t;
	int n=s.size()+1,m=t.size()+1;
	int dp[n][m];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++) dp[i][j]=0;
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<m;j++){
			if(s[i-1]==t[j-1]) dp[i][j]=1+dp[i-1][j-1];
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	int maxa=0;
	for(int i=1;i<n;i++){
		for(int j=1;j<m;j++){
			if(maxa<dp[i][j]) maxa=dp[i][j]; 
		} 
	}
	string ans="";
	for(int i=1;i<n;i++){
		for(int j=1;j<m;j++){
			if(maxa<dp[i][j]) maxa=dp[i][j]; 
		} 
	}
	int i=n-1,j=m-1;
	while(i>=1 && j>=1){ 
		if(dp[i][j]==dp[i-1][j]) i--;
		else if(dp[i][j]==dp[i][j-1]) j--;
		else{
			ans+=s[i-1];
			i--; j--;
		}
	}
	if(maxa==0) ans="";
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl; 
	return 0;
}



Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define ll long long
inline int read(){
    int num=0,w=0;
    char ch=0;
    while(!isdigit(ch)){
        w|=ch=='-';
        ch=getchar();
    }
    while(isdigit(ch)){
        num=(num<<3)+(num<<1)+(ch^48);
        ch=getchar();
    }
    return w?-num:num;
}

//快速写
inline void write(int x)
{
    if(x<0){
        putchar('-');
        x=-x;
    }
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
vector<vector<int> >v(15,vector<int>(15,-1));
int main()
{
   int n=read();
   //int kk =1;
   for(int i=0;i<n;i++){
       int a =read();
       for(int j=0;j<a;j++){
           int b,c;cin >>b>>c;
           v[i][--b] = c;
       }
      // kk++;
   }
   int ma =0 ;
   for(int i = (1<<n)-1;i>0;i--){
       bitset<16> bit(i);
        vector<int> vv(n,-1);
        for(int j=0;j<n;j++){
            if(bit[j]==1)vv[j] =1;
            else vv[j]=0;
        }
        bool ok =1;
        for(int j=0;ok&&j<n;j++){
            if(bit[j]==0)continue;
            for(int k =0;ok&&k<n;k++){
                if(v[j][k]==-1)continue;
                if(vv[k]!=v[j][k])ok = false;//前提说明k是假的情况下，冲突
            }
        }
        if(ok){
            int cnt =0 ;
            for(int i=0;i<n;i++){
                if(bit[i])cnt++;
            }
            ma = max(cnt,ma);
        }

   }

cout<<ma<<endl;
    return 0;
}/* 6
  1 2 0
  1 1 0
  1 2 0
 1 1 0
1 2 0
  1 1 0*/

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

int main() {
  uint32_t N = 0;
  uint64_t K = 0;
  std::cin >> N >> K;
  std::vector<uint32_t> A(N + 1, 0);
  for (size_t i = 1; i < A.size(); i++) std::cin >> A[i];

  std::vector<uint32_t> path;
  std::vector<int32_t> flag(N + 1, -1);
  uint32_t town = 1, idx = 0;
  while (flag[town] == -1) {
    flag[town] = idx;
    path.push_back(town);
    town = A[town];
    idx++;
  }

  if ((uint32_t)flag[town] > K) {
    std::cout << path[K] << std::endl;
  } else {
    std::cout
        << path[flag[town] + (K - flag[town]) % (path.size() - flag[town])]
        << std::endl;
  }

  return 0;
}

Measured memory_bytes: 5828
counter = 0
judge = False
N = int(input())
a_list = input().split()

for i in range(N):
    a_list[i] = int(a_list[i])


while True:
    for i in range(N):
        if not a_list[i]/2 == int(a_list[i] / 2):
            judge = True
            break
        a_list[i] = a_list[i] / 2
    if judge == True:break
    counter += 1


print(counter)
    

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

void dfs(int &res, int now, const int n, const vector<int> &ng) {
	if( now >= n ) {
		res = min(res, now);
		return;
	}
	
	for(int i = 0; i < 10; ++i) {
		if( !ng[i] ) {
			if( now == 0 && i == 0 ) continue;
			
			dfs(res, 10 * now + i, n, ng);
		}
	}
}

int main(void) {
	int n, k;
	cin >> n >> k;
	
	vector<int> ng(10, 0);
	for(int i = 0; i < k; ++i) {
		int d;
		cin >> d;
		ng[d] = 1;
	}

	int ans = 1 << 29;
	dfs(ans, 0, n, ng);

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


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-7
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main() {
	speed;
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b);
}

Measured memory_bytes: 892
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
// #define INF 100000000
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
string stin() {string s;cin>>s;return s;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}


int n,m,k;
vec a;
void get(){
    rep(i,n)a.pb(in());
}
int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);cout<<fixed<<setprecision(15);
    n=in();
    int x=in(),y=in();
    vec ans(n);
    rep2(i,1,n){
        rep2(j,i+1,n){
            ll ma=j-i;
            chmin(ma,abs(i-x)+abs(j-y)+1);
            chmin(ma,abs(i-x)+abs(j-x));
            chmin(ma,abs(i-y)+abs(j-y));
            chmin(ma,abs(i-y)+abs(j-x)+1);
            ans[ma]++;
        }
    }
    rep2(i,1,n-1)cout<<ans[i]<<endl;
}





Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main {
  

    public static long frog(long[] arr){
        long[] dp = new long[arr.length];
      
        for(int i = 1; i < arr.length; i++){
            long option1 = Long.MAX_VALUE;
            long option2 = Long.MAX_VALUE;
            option1 = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
            if(i-2 >= 0){
                option2 = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
            }

            dp[i] = Math.min(option1,option2);
        
        }

        return (dp[dp.length-1]);
    }
    
    public static void main(String[] args) throws Exception{
        StringTokenizer str;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine().trim());
        long[] arr = new long[n];
        int i = 0;
           str = new StringTokenizer(br.readLine().trim()," ");   
            while(str.hasMoreTokens()){
                arr[i]=Long.parseLong(str.nextToken());
                i++;
            }
       
         System.out.println(frog(arr));
     
    }
}

Measured memory_bytes: 33712
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n=0,k=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	for(int j=0;j<n;j++)
	{
		k=(k+a[j]-1);
	}
	cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++){for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << p.first << " " << p.second;}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){for(auto &z:v)os << z << " ";cout<<"|"; return os;}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  ll lim=1000005;
  vector<ll>x(lim);
  rep(i,0,n)x[a[i]]++;
  rep(i,1,lim){
    for(ll j=i+i;j<lim;j+=i)x[i]+=x[j];
  }
  rep(i,0,lim)x[i]*=x[i];
  rrep(i,1,lim){
    for(ll j=i+i;j<lim;j+=i)x[i]-=x[j];
  }
  rep(i,0,n)x[a[i]]--;
  if(x[1]==n*(n-1))cout<<"pairwise coprime"<<endl;
  else{
    ll g=0;
    rep(i,0,n)g=gcd(g,a[i]);
    if(g==1)cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
  }
  return 0;
}

Measured memory_bytes: 18772
#include<stdio.h>
#include<math.h>
#include<stdbool.h>
bool flag[31630];

void seive(int n)
{
    int i,j;
    flag[0]=flag[1]=true;
    for(i=3; i<=n/i; i+=2)
    {
        if(!flag[i])
        {
            for(j=i*i; j<=n; j+=(i<<1))flag[j]=true;
        }
    }
}

int main()
{
    int n,i,root;
    scanf("%d",&n);
    root=sqrt(n);
    seive(root);
    printf("%d:",n);
    while(!(n&1))
    {
        n=n>>1;
        printf(" 2");
    }
    root=sqrt(n);
    for(i=3; i<=root; i+=2)
    {
        while(n%i==0 && !flag[i])
        {
            printf(" %d",i);
            n/=i;
        }
    }
    if((sqrt(n)==root && n>1) || (n>1))printf(" %d",n);
    printf("\n");
    return 0;
}



Measured memory_bytes: 2136
#include <cstdio>
#include <map>

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

  std::map<int, int> D;
  for (int i=0; i<N; ++i) {
    int d;
    scanf("%d", &d);
    ++D[d];
  }

  int M;
  scanf("%d", &M);
  for (int i=0; i<M; ++i) {
    int t;
    scanf("%d", &t);
    if (--D[t] < 0)
      return !printf("NO\n");
  }

  printf("YES\n");
  return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>

#define INF 9999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int>pi;

/*---------------------------------------------------*/

int main(){
  int a,b,c,ans;
  cin>>a>>b>>c;
  ans=a*100+b*10+c;
  if(ans%4==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

long long POW(long long x,long long n,long long mod){
  long long ans = 1;
  while(n){
    if(n%2)ans *= x;
    x *= x;
    x %= mod;
    ans %= mod;
    n >>= 1;
  }
  return ans;
}
 
signed main(){
  ll m,n;
  cin >> m >> n;
  cout << POW(m,n,INF) << endl;
}


Measured memory_bytes: 3096
import java.util.Scanner;

public class Main{
public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
long K = sc.nextLong();
long A = sc.nextLong();
long B = sc.nextLong();
long bis =1;
if((B-A)>=2){
    if(bis+K<=A){
        System.out.println(K+1);
    }else{
        K-=(A-1);
        bis += (A-1);
        long trade = K/2;
        bis += trade*(B-A);
        if(K%2==1) bis += 1;
        System.out.println(bis);
    }
}else{
    System.out.println(K+1);
}

}
}


Measured memory_bytes: 23252
n = gets.chomp.split("")
a = n.size
souko = []
(0..a-1).each do |iii|
    if n[iii] == "P" ||  n[iii] == "D"
        
        souko << n[iii]
    else
        souko << "D"
    end
end
kirei = souko.join
puts kirei

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

long long N, K, a[200005];
long long tmp[200005];
long long ans;

long long msort(long long A[], long long B[], long long l, long long r) {
	if (l >= r) return 0;
	long long m = (l + r) >> 1;
	long long tot = msort(A, B, l, m) + msort(A, B, m + 1, r);
	long long i = l, j = m + 1, k = l;
	while (i <= m && j <= r)
		if (A[i] <= A[j]) B[k++] = A[i++];
		else B[k++] = A[j++], tot += m - i + 1;
	while (i <= m) B[k++] = A[i++];
	while (j <= r) B[k++] = A[j++];
	for (long long i = l; i <= r; ++i) A[i] = B[i];
	return tot;
}

int main() {
    scanf("%lld%lld", &N, &K);
    for (int i = 1; i <= N; ++i)
        scanf("%lld", &a[i]), a[i] -= K;
    for (int i = 1; i <= N; ++i) a[i] += a[i - 1];
    ans = ((N + 1) * N >> 1) - msort(a, tmp, 0, N);
    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  vector<int> a(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long low = 2, high = 1e18;
  auto cal = [&](long long K) {
    for (auto x : a) {
      K -= K % x;
    }
    return K;
  };
  while (low <= high) {
    long long mid = (low + high) / 2;
    if (cal(mid) < 2) low = mid + 1;
    else high = mid - 1;
  }
  long long x = low;
  low = 2, high = 1e18;
  while (low <= high) {
    long long mid = (low + high) / 2;
    if (cal(mid) <= 2) low = mid + 1;
    else high = mid - 1;
  }
  long long y = high;
  if (cal(x) == 2) {
    cout << x << " " << y << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 640
<?php

    $alphabets   = range('a','z');
    $stdin       = file_get_contents('php://stdin');
    $word_counts = array_count_values(str_split(strtolower($stdin)));
    foreach($alphabets as $alphabet) {
        echo $alphabet, ' : ', isset($word_counts[$alphabet]) ? $word_counts[$alphabet] : 0, PHP_EOL;
    }

Measured memory_bytes: 6784
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;

typedef long long ll;
const int INF = 1e+9;

int main() {
	static int dp[3010][3010], ma = 0, me[3010][3010];
	string s, t, ans;
	cin >> s >> t;
	for (int i = 0; i < s.length(); ++i) {
		for (int j = 0; j < t.length(); ++j) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
				me[i + 1][j + 1] = 1;
			}
			else if (dp[i + 1][j] > dp[i][j + 1]) {
				dp[i + 1][j + 1] = dp[i + 1][j];
				me[i + 1][j + 1] = 2;
			}
			else {
				dp[i + 1][j + 1] = dp[i][j + 1];
				me[i + 1][j + 1] = 3;
			}
		}
	}
	for (int i = s.length(); i >= 0;) {
		for (int j = t.length(); j >= 0;) {
			if (me[i][j] == 3) i--;
			else if (me[i][j] == 2) j--;
			else if (me[i][j] == 1) {
				i--;
				j--;
				ans.push_back(s[i]);
			}
			else {
				i = -1;
				j = -1;
				break;
			}
		}
		
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll modinv(ll a, ll m) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    unordered_map<unsigned long long,bool> fac5;
    unordered_map<ll, ll> p;
    ll x;
    cin >> x;
    ll stt = pow(LLONG_MAX-x,1/5.0);
    REP(i, stt) { 
        fac5[pow(i, 5)] = true;
        p[pow(i, 5)] = i;
    }
    FOR(i,-1 * stt,stt){
        if(fac5[abs((ll)pow(i,5) + x)]){
            if(pow(i,5) + x < 0){
                 cout << -1*p[abs(pow(i,5)+x)] << " " << i << endl;
            }
            else{
                cout << p[abs(pow(i,5)+x)] << " " << i << endl;
            }
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 4940
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++){
    int b, e, t;
    cin >> b >> e >> t;
    for (int j = b; j < e; j++){
      swap(a[j], a[t + j - b]);
    }
  }
  for (int i = 0; i < n; i++){
    cout << a[i];
    if (i < n - 1){
      cout << ' ';
    }
  }
  cout << endl;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n ; 
  cin >> n ;
  
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n){
    cin>>a[i];
    cin>>b[i];
  }
  
  map<pair<int,int>,int> cnt;
  
  rep(i,n)
    rep(j,n)
      if(i!=j) cnt[make_pair(a[i]-a[j],b[i]-b[j])]++;
  
  int sum=1;
  
  for(auto v : cnt){
    sum=max(sum,v.second);
  }                                   
  
  cout<<max(n-sum,1)<<endl;
  
}



Measured memory_bytes: 384
N=int(input())
p=list(map(int,input().split()))

ss=[1]*(N+1)
ss2=[-1]*(N+1)
ss[0]=0
ss2[0]=0
for i,x in enumerate(p[1:]):
  x-=1
  ss[x]+=i+1
  ss2[x+1]-=i+1

ac=[0]*(N+1)
ac2=[0]*(N+1)
ac[0]=1
ac2[0]=N**2
for i in range(N):
  ac[i+1]=ac[i]+ss[i]
  ac2[i+1]=ac2[i]+ss2[i]
print(*ac[1:])
print(*ac2[1:])

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, m;
    cin >> n >> m;
    vector<bool> b(n+1);
    rep(i, m) {
        int a;
        cin >> a;
        b[a] = true;
    }
    vi dp(n+2);
    const int mod = 1e9 + 7;
    dp[n+1] = 0, dp[n] = 1;
    repr(i, n) {
        if (b[i]) continue;
        dp[i] = (dp[i+1] + dp[i+2]) % mod;
    }
    cout << dp[0] << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;
using ll = int64_t;

int main(){
    int q; cin >> q;
    rep(qi, q){
        string x, y; cin >> x >> y;
        int xsize = x.size(), ysize = y.size();
        int dp[xsize+1][ysize+1];
        memset(dp, 0, sizeof(dp));
        loop(i, 1, xsize+1)loop(j, 1, ysize+1){
            if(x[i-1] == y[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
        cout << dp[xsize][ysize] << endl;
    }

    return 0;
}


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

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

const int MN = 5010;

int N;
pii S[MN];
int L[MN];
ll psum[MN];

bool cmp(pii a, pii b) {
    return a.first + a.second < b.first + b.second;
}

ll dp[2][MN][2];

void prop() {
    for(int i = 0; i <= N; i++) for(int j = 0; j < 2; j++) dp[N & 1][i][j] = 1e18;
    dp[N & 1][0][0] = 0;
    for(int i = N - 1; i >= 0; i--) {
        int c = i & 1;
        int p = c ^ 1;
        for(int j = 0; j <= N; j++) {
            for(int k = 0; k < 2; k++) {
                ll &ret = dp[c][j][k];
                ret = 1e18;

                ret = min(ret, dp[p][j][k] + S[i].second + 1LL * L[i] * (N - 1 - i - j - k));
                if(j) ret = min(ret, dp[p][j - 1][k] + S[i].first + 1LL * L[i] * (j - 1));
                if(k) ret = min(ret, dp[p][j][0] + 1LL * L[i] * (N / 2));
            }
        }
    }
}

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

    for(int i = 0; i < N; i++) {
        scanf("%d %d", &S[i].first, &S[i].second);
    }

    sort(S, S + N, cmp);

    ll ans = 1e18;

    for(int i = 0; i < N; i++) {
        L[i] = S[i].first + S[i].second;
        psum[i] = L[i];
        if(i) psum[i] += psum[i - 1];
    }

    prop();
    for(int i = 0; i <= N; i++) {
        ans = min(ans, dp[0][i][0]);
    }

    if(N % 2) {
        ans = min(ans, dp[0][N / 2][1]);
    }

    printf("%lld", ans);
}


Measured memory_bytes: 512
import sys

def solve():
    N, M = map(int, input().split())
    S = input()
    Ans_rev = []
    current_id = N
    while True:
        length = 0
        for i in range(M):
            if current_id - i - 1 >= 0:
                if S[current_id - i - 1] == "0":
                    length = i + 1
            else: break
        if length > 0: 
            Ans_rev.append(length)
            current_id -= length
        else:
            break
    if current_id > 0: print(-1)
    else:
        Ans = []
        for i in reversed(range(len(Ans_rev))):
            Ans.append(Ans_rev[i])
        print(" ".join(map(str, Ans)))
            

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 11252
T = int(input())
    
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

for _ in range(T):
    A, B, C, D = map(int, input().split())
    #print("----", _, A, B, C, D)
    if A < B:
        print("No")
        continue
    
    if C < A%B < B:
        print("No")
        continue
    
    if D % B == 0:
        print("Yes")
        continue
    
    if D < B:
        print("No")
        continue
    
    if C+(gcd(B,D)) < B:
        print("No")
        continue
    
    print("Yes")

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

int main(){
  int n,s=0,a;
  cin >> n; a=n;
  while(n>0){
    s+=n%10;
    n/=10;
  }
  if(a%s==0){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = map(int, input().split())
h = list(map(int, input().split()))

dp = [float("inf")]*n
dp[0] = 0
for i in range(1,n):
    for j in range(1,min(k+1, i+1)):
        dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]))
print(dp[-1])

Measured memory_bytes: 85572
n, x = map(int, input().split())
x -= 1

size = [1]
np = [1]

for i in range(n):
    size.append(size[-1] * 2 + 3)
    np.append(np[-1] * 2 + 1)
np.append(0)

l = 0
r = size[-1]
lv = n

ans = 0

while True:
    # print(lv, l, r, (l+r) // 2)
    mid = (l + r) // 2
    if x == mid:
        ans += np[lv-1] + 1
        break
    elif x == l:
        break
    elif x == r:
        ans += np[lv]
        break
    
    if x < mid:
        l += 1
        r = mid - 1
    else:
        ans += np[lv-1] + 1
        l = mid + 1
        r -= 1

    lv -= 1

print(ans)
    



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

using namespace std;

int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  if (a + b < b + c && a + b < a + c) {
    printf("%d", a + b);
  } else if (b + c < b + a && b + c < a + c) {
    printf("%d", c + b);
  } else {
    printf("%d", a + c);
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static int[] s;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        s = new int[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int c = 0;
        for (int i = 0; i < q; i++) {
            int t = sc.nextInt();
            if (binarySearchContains(t)) {
                c++;
            }
        }
        System.out.println(c);
    }

    public static boolean binarySearchContains(int v) {
        int l = 0; // left
        int r = s.length - 1; // right
        while (l <= r) {
            int m = (r + l) / 2;
            if (s[m] == v) {
                return true;
            }
            if (s[m] > v) {
                r = m - 1;
            } else {
                l = m + 1;
            }
        }
        return false;
    }
}

Measured memory_bytes: 67372
#include<stdio.h>
int main()
{
    int a,b;
    char op;
    scanf("%d %c %d",&a,&op,&b);
    if(op=='+'){
        printf("%d\n",a+b);
    }
    else if(op=='-'){
        printf("%d\n",a-b);
    }
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,w,h) rep(j,h)rep(i,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> a(n);rep(i,n)std::cin >> a[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
  int n;
  std::cin >>n;
  std::vector<string> a(n);
  rep(i,n)std::cin >> a[i];
  rep(i,n){
    sort(all(a[i]));
  }
  sort(all(a));
  int c=1;
  std::vector<ll> cc;
  rrep(i,1,n){
    if(a[i]==a[i-1]){
      c++;
    }
    else{
      cc.pb(c);
      c=1;
    }
  }
  cc.pb(c);
  ll ans=0;
  rep(i,cc.size()){
    ans+=cc[i]*(cc[i]-1)/2;
  }
  std::cout << ans << std::endl;
  
}

Measured memory_bytes: 8444