akhauriyash/Code-Regression huggingface dataset:
#ifdef _LOCAL
#	include <dbg_print.h>
#else
#	define NDEBUG
#	define dprint(...)
#endif

#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <assert.h>
using namespace std;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);
	
	int h, a;
	cin >> h >> a;

	int ans = (h+a-1) / a;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  int H,W,N;
  cin>>H; cin>>W;cin>>N;
  vector<int> vec;
  vec.push_back(H);
  vec.push_back(W);
  sort(vec.begin(),vec.end());
  int count=0,sum=0;
  for(int i=1; i<=vec[0]; i++){
    	int ans=vec[1]*i;
    	count++;
    	if(ans>=N){
          cout<<count<<endl;
          return 0;
        }
  }
}
          
          
          
          
          
    
    
    
    
  

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	int n;
	int a[20];
	int sum;
	while(scanf("%d",&n)!=EOF)
	{
		sum=1;
		for(int i=0;i<n;i++) scanf("%d",&a[i]);
		for(int i=0;i<n;i++)
		{
			if(a[i]%2==0) sum*=2;
		}
		int k=(int)pow(3,n);
		printf("%d\n",k-sum);
	}
	return 0;
}

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


using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e3 + 5;
bool isPrime[MAXN];
void sevie() {
    memset(isPrime, 1, sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for (ll i = 2; i * i <= MAXN; i++) {
        if (isPrime[i]) {
            for (ll j = i * 2; j <= MAXN; j += i) {
                isPrime[j] = 0;

            }
        }
    }
}
ll fastPow(ll x, ll b) {
    if (b == 0)
        return 1;
    else if (!(b & 1)) {
        return fastPow(x * x, b / 2);
    } else
        return x * fastPow(x * x, (b - 1) / 2);
}
//__builtin_popcount ();
bool isPrim(int n) {
    if (n == 1 || n == 0)
        return false;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0)
            return false;
    }
    return true;
}



int main() {
    FAST
int a,b;
    cin>>a>>b;
    if(b>=a)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

pll operator+(pll a,pll b){
  return pll(a.first+b.first,a.second+b.second);
}
pll operator-(pll a,pll b){
  return pll(a.first-b.first,a.second-b.second);
}
pll operator*(ll a,pll b){
  return pll(b.first*a,b.second*a);
}
const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const long long MOD = 998244353;
ll dp[3001][3001];
void solve(long long A, long long B, long long C, long long D){
  dp[A][B]=1;
  FOR(i,A,C+1){
    FOR(j,B,D+1){
      if(i==A&&j==B)continue;
      dp[i][j]=(dp[i-1][j]*j%MOD+dp[i][j-1]*i%MOD-dp[i-1][j-1]*(i-1)%MOD*(j-1)%MOD+MOD)%MOD;
    }
  }
  cout<<dp[C][D]<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}


Measured memory_bytes: 73832
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000000;
int main(){
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  long long tv = 0;
  long long fv = INF;
  while (fv - tv > 1){
    long long mid = (tv + fv) / 2;
    vector<long long> b(N);
    for (int i = 0; i < N; i++){
      b[i] = a[i] + mid;
    }
    long long cnt = 0;
    for (int i = 0; i < N; i++){
      cnt += b[i] / (N + 1) - 1;
    }
    if (cnt >= mid){
      tv = mid;
    } else {
      fv = mid;
    }
  }
  long long ans = tv;
  while (1){
    vector<long long> b(N);
    for (int i = 0; i < N; i++){
      b[i] = a[i] + ans;
    }
    long long cnt = 0;
    for (int i = 0; i < N; i++){
      cnt += b[i] / (N + 1);
    }
    if (cnt < ans){
      break;
    }
    ans++;
  }
  cout << ans - 1 << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    s64 ans = 1;
    vs64 a(n);
    rep (i, n)
    {
        cin >> a[i];
        if (a[i] == 0)
        {
            cout << "0\n";
            return 0;
        }
    }

    s64 lim = 1e18;
    rep (i, n)
    {
        if (ans <= lim / a[i])
        {
            ans *= a[i];
        }
        else
        {
            cout << "-1\n";
            return 0;
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 4000
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

const long long MOD = (long long)1e9 + 7;

long long mod_pow(long long x_, long long y_){
    if(y_ == 0) return 1;
    long long res = mod_pow(x_ * x_ % MOD, y_ / 2);
    if(y_ & 1) res =  x_ * res % MOD;
    return res;
}

long long inv(long long x){
    return mod_pow(x, MOD - 2);
}

int main(){
    ll x, y;
    cin >> x >> y;
    ll a, b;
    a = 2 * y - x;
    b = 2 * x - y;
    ll ans = 0;
    if(a < 0 || b < 0 || a % 3 != 0 || b % 3 != 0){
        ans = 0;
    }else{
        a /= 3;
        b /= 3;
        vector<ll> f(a + b + 1);
        f[0] = 1;
        for(int i = 1; i <= a + b; i++){
            f[i] = (i * f[i - 1]) % MOD;
        }
        ans = ((f[a + b] * inv(f[a])) % MOD * inv(f[b])) % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5504
#include <stdio.h>
#include <math.h>

main() {
  int i, step, angle, theta=90;
  double x=0, y=0;
  while(1) {
    scanf("%d,%d", &step, &angle);
    if(step == 0 && angle == 0) break;
    x += step * cos(theta*acos(-1)/180);
    y += step * sin(theta*acos(-1)/180);
    theta -= angle;
  }
  printf("%d\n%d\n", (int)x, (int)y);

  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

const ll M = 1e9 + 7;

string s;
ll pw = 1;
ll a[100005][13];

int main()
{
//    freopen("input.txt", "r", stdin);
    cin>>s;
    reverse(s.begin(), s.end());
    s = ' ' + s;
    a[0][0] = 1;
    for(ll i = 1; i < s.size(); i++)
    {
        if(s[i] == '?')
        {
            for(ll j = 0; j < 13; j++)
            {
                for(ll ii = 0; ii <= 9; ii++)
                {
                    a[i][j] += a[i - 1][(j - ii * pw % 13 + 13) % 13];
                    a[i][j] %= M;
                }
            }
        }
        else
        {
            for(ll j = 0; j < 13; j++)
            {
                ll ii = s[i] - '0';
                a[i][j] += a[i - 1][(j - ii * pw % 13 + 13) % 13];
                a[i][j] %= M;
            }
        }
        pw *= 10;
        pw %= 13;
    }
    printf("%lld", a[s.size() - 1][5]);
    return 0;
}


Measured memory_bytes: 10620
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i,cn=0,j;
char ch[100];
cin>>n>>ch;
for(i=0;i<n-2;i++)
{
    if(ch[i]=='A')
    {
        if(ch[i+1]=='B'&&ch[i+2]=='C'){
            cn++;
            i+=2;
        }
    }
}
cout<<cn<<"\n";

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/


int n;
double ans = 0;
vector<pair<double, double>>v(105);
signed main() {
  	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(-100, 100);
	cin >> n;
	rep(i, n)cin >> v[i].first >> v[i].second;
	clock_t start = clock();
	int cnt = 0;
	while (1000. * (clock() - start) / CLOCKS_PER_SEC <= 1950) {
		double x = 0, y = 0;
		int xx = engine(mt64), yy = engine(mt64);
		for (auto p : v) {
			if (p.first * xx + p.second * yy >= 0) {
				x += p.first; y += p.second;
			}
		}
		chmax(ans, sqrt(pow(x, 2) + pow(y, 2)));
		cnt++;
	}
	printf("%.12lf\n", ans);
  	cerr << cnt << endl;
}

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

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

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < l; ++j){
            long c = 0;
            for(int k = 0; k < m; ++k){
                c += a[i][k] * b[k][j];
            }
            printf("%ld", c);
            char ch = j == l - 1 ? '\n' : ' ';
            printf("%c", ch);
        }
    }
    return 0;
}

Measured memory_bytes: 1108
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define N 100010
#define M 1000000007
inline int read(){
    char ch=getchar(); int x=0;
    for (;ch>'9'||ch<'0';ch=getchar());
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x;
}
struct node{
    int le,ri;
    node(){}
    node(int le,int ri):le(le),ri(ri){}
    bool operator<(const node &a) const{
        return le<a.le || le==a.le && ri>a.ri;
    }
}P[N];
int n,m,a[N],b[N],bit[N],dp[N],tot,dic[N];
int query(int x){int res=0;for (;x;x-=x&-x) (res+=bit[x])%=M;return res;}
void add(int x,int p){for (;x<=n;x+=x&-x) (bit[x]+=p)%=M;}
signed main(){
    n=read(),m=read();
    for (int i=1;i<=n;i++) a[i]=read();
    for (int i=1;i<=m;i++) b[i]=read();
    for (int i=1;i<=n;i++){
        if (a[i]>b[m]) continue;
        if (a[i]<b[1]) continue;
        int t=lower_bound(b+1,b+1+m,a[i])-b;
        if (b[t]==a[i]) continue;
        P[++tot]=node(a[i]-b[t-1],b[t]-a[i]);
        dic[tot]=b[t]-a[i];
    }
    sort(dic+1,dic+1+tot);
    int num=unique(dic+1,dic+1+tot)-dic-1;
    sort(P+1,P+1+tot);
    for (int i=1;i<=tot;i++) P[i].ri=lower_bound(dic+1,dic+1+num,P[i].ri)-dic;
    for (int i=1;i<=tot;i++){
        if (P[i].le==P[i-1].le && P[i].ri==P[i-1].ri) dp[i]=0;
        else dp[i]=(query(P[i].ri-1)+1)%M;
        add(P[i].ri,dp[i]);
    }
    int ans=1;
    for (int i=1;i<=tot;i++) (ans+=dp[i])%=M;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 5760
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

using ll = long long;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end()

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.fst << "," << p.snd << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
    return a * a;
}

template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    string a, b;
    cin >> a >> b;
    int n = stoi(a + b);
    for (int i = 1; i <= n; ++i) {
        if (i * i == n) {
            cout << "Yes" << endl;
            return 0;
        }
        if (n / i < i) break;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
# list(map(int, input().split()))

class UnionFind(object):
    def __init__(self, n = 1):
        self.link = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.link[x] == x:
            return x

        # re-connect union find to make the height of tree lower
        # you can use while, but recursion makes it easier to reconnect
        self.link[x] = self.find(self.link[x])
        return self.link[x]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.size[x] < self.size[y]:
            x, y = y, x
        self.link[y] = x
        self.size[x] += self.size[y]
    
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]


V, E = map(int, input().split())

edges = [0] * E
for i in range(E):
    s, t, w = map(int, input().split())
    edges[i] = (w, s, t)

u = UnionFind(V)

edges = sorted(edges)

ans = 0
for e in edges:
    w, s, t = e
    if u.is_same(s, t):
        continue
    u.unite(s, t)
    ans += w
print(ans)



Measured memory_bytes: 24892
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val alphabets = sc.nextLine.split("").toSet
    val allAlphabets = "abcdefghijklmnopqrstuvwxyz".split("").toSet
    if ((allAlphabets diff alphabets).isEmpty) println("None")
    else println((allAlphabets diff alphabets).toList.min)
  }
}


Measured memory_bytes: 41716
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
typedef long long ll;
inline void Fail(){printf("0");exit(0);}
inline void debug(int x){cerr<<"debug: "<<x<<"\n";}
inline void debug(int n,int x[]){cerr<<"debug "<<"\n";rep(i,n)cerr<<x[i]<<" ";cerr<<"\n";}
inline void debug(string x){cerr<<"debug: "<<x<<"\n";}

const int maxn=2005;
const int maxm=maxn*maxn/63+5;
int n,sum;
int a[maxn];
class Bitset{
public:
	ll b[maxm];
	Bitset(){
		memset(b,0,sizeof(b));
	}
	void OR(Bitset other){
		rep(i,maxm)b[i]=b[i]|other.b[i];
	}
	Bitset Move(int offset){
		Bitset res=Bitset();
		int u=offset/63,v=offset%63;
		rep(i,maxm){
			if(i+u+1>=maxm)break;
			res.b[i+u]|=(b[i]&((1LL<<(63-v))-1))<<v;
			res.b[i+u+1]|=b[i]>>(63-v);
		}
		return res;
	}
	bool Query(int pos){
		return b[pos/63]&(1LL<<(pos%63));
	}
	void debug(){
		rep(i,63)printf("%d ",b[0]&(1LL<<i)?1:0);
		puts("");
	}
}dp;

int main(){
	scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]),sum+=a[i];
	dp.b[0]=1;
//	dp.debug();
	rep(i,n){
		Bitset cur=dp.Move(a[i]);
		dp.OR(cur);
//		dp.debug();
	}
	for(int i=(sum+1)/2;i<=sum;i++)if(dp.Query(i)){
		printf("%d",i);
		return 0;
	}
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 1792
let N = stdin.ReadLine() |> int
let A = stdin.ReadLine().Split() |> Array.map int64

let d = Array.zeroCreate<int64> N
let s = Array.zeroCreate<int64> N

let calc ope cond (a : int64 []) =
    A
    |> Array.indexed
    |> Array.filter (fun x -> cond ((ope) (fst x) (snd x |> int)))
    |> Array.map (fun x -> (ope) (fst x) (snd x |> int))
    |> Array.groupBy id
    |> Array.map (fun x -> (fst x, Array.length (snd x)))
    |> Array.map (fun x -> a.[fst x] <- snd x |> int64)
    |> ignore

calc (-) (fun x -> x >= 0) d
calc (+) (fun x -> x < N) s

Array.zip d s
|> Array.map (fun x -> fst x * snd x)
|> Array.sum
|> stdout.WriteLine


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

using namespace std;

int main(void){
    string s;
    int ans=0;
    bool finished = false;
    
    cin >> s;
    int l=s.size()-1;
    
    for(int i=l-2;i>=0;i-=2)
    {
        int tmp=0;
        // cout<<"---\n";
        for(int j=(i-1)/2;j>=0;j--)
        {
            // cout<<j<<i-tmp;
            // cout<<s[j]<<"_"<<s[i-tmp]<<"\n";
            if(s[j] != s[i-tmp]){
                break;
            } else if (j==0){
                // cout<<i;
                if(s[j] == s[i-tmp]){
                    ans = i+1;
                    finished = true;
                    break;    
                }
            }
            tmp++;
        }
        if (finished) {
          break;
        }
    }

    cout << ans;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<string> s(n+1);
  FOR(i,1,n+1) cin>>s[i];
  FOR(i,1,n+1) s[i]=' '+s[i];
  int ans=0;
  rep(b,n){
    vector<string> now(s);
    FOR(i,1,n+1)FOR(j,1,n+1){
      if(j+b<=n) now[i][j]=s[i][j+b];
      else now[i][j]=s[i][j+b-n];
    }
    bool flag=true;
    FOR(i,1,n+1)FOR(j,1,n+1){
      if(now[i][j]!=now[j][i]){
        flag=false;
        break;
      }
    }
    if(flag) ans++;
  }
  cout<<ans*n<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
#define pii pair <int , int > 
#define pll pair < ll , ll >
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
    int n , k ;
    cin >> n >> k ;
    ll c[n + 1][n + 1] , mod = 1000000007;
    memset(c , 0 , sizeof(c)) ;
    c[0][0] = 1 ;
    for(int i = 1; i <= n ; i++) {
        c[i][0] = 1; 
        for(int j = 1; j <= i; j++) {
            c[i][j] = (c[i - 1][j - 1] + c[i - 1][j])%mod;
            // cout << i << " " << j << " " << c[i][j] << '\n';
        }
    }
    for(int i = 1 ; i <= k ; i++){
        cout << (c[n - k + 1][i]*c[k-1][i - 1])%mod << '\n';
    }
}

Measured memory_bytes: 31616
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
 	
 	int n,m;
 	scanf("%d %d",&n,&m);

 	if(n==m)printf("Yes\n");
 	else	printf("No\n");
}		


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

int main(){
  int n,z,x; 
  string s;
  cin >> s ;
  vector<int> a(n);
  vector<int> sum(n);
  z=0;

  z=s.size();
  for(int i=0;i<z;i++){cout<<"x";}
          }



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

int main() {
  int k, x;
  cin >> k >> x;
  for (int i = x - k + 1; i <= x + k - 1; i++) {
    if (i < -1000000 || i > 1000000) continue;
    cout << i << " ";
  }
  cout << endl;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a, Ts... ts) {return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int n = s.size();

    set<int> l, r;
    REP(i, n)
    {
        if(s[i] == 'L') l.insert(i);
        else r.insert(i);
    }

    vector<int> ans(n);
    REP(i, n)
    {
        if(s[i] == 'L')
        {
            auto itr = r.upper_bound(i);
            itr--;
            ((i - *itr) % 2 == 0 ? ans[*itr] : ans[*itr+1]) += 1;
        }
        else 
        {
            auto itr = l.upper_bound(i);
            ((*itr - i) % 2 == 0 ? ans[*itr] : ans[*itr-1]) += 1;
        }
    }
    REP(i, n) cout << ans[i] << " \n"[i == n-1];
}

Measured memory_bytes: 5584
# -*- coding: utf-8 -*-
from sys import setrecursionlimit
setrecursionlimit(100000)

class Cake():

    def __init__(self, N, W, D):
        self.P = [-1]*2*(N+1)
        self.L = [-1]*2*(N+1)
        self.R = [-1]*2*(N+1)
        self.W = [0]*2*(N+1)
        self.W[1] = W
        self.D = [0]*2*(N+1)
        self.D[1] = D

    def find(self, target):
        count = 0
        for i in range(1, 2*N+2):
            count += (self.L[i] == -1)
            if count == target:
                return i

    def cut(self, target, s, l):
        w = self.W[target]
        d = self.D[target]
        L = w+d
        s %= L
        if s <= w:
            nw, nW = s, w-s
            if nw > nW:
                nw, nW = nW, nw
            nd, nD = d, d
        else:
            s -= w
            nd, nD = s, d-s
            if nd > nD:
                nd, nD = nD, nd
            nw, nW = w, w
        assert 0 < nw
        assert 0 < nd
        r = l + 1
        self.L[target], self.R[target] = l, r
        self.P[l], self.P[r] = target, target
        self.W[l], self.W[r] = nw, nW
        self.D[l], self.D[r] = nd, nD

    def show(self):
        tmp = []
        for i in range(1, len(self.L)):
            if self.L[i] == -1:
                tmp.append(self.W[i] * self.D[i] )
        print(" ".join(map(str, sorted(tmp))))

N, W, D = map(int, input().split())
while W:
    cake = Cake(N, W, D)
    for i in range(N):
        p, s = map(int, input().split())
        target = cake.find(p)
        cake.cut(target, s, 2*(i+1))
    cake.show()
    N, W, D = map(int, input().split())



Measured memory_bytes: 5640
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
typedef long long ll;
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

int n;
ll k, a[200010], f[200010];

int main() {
    cin >> n >> k;
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(a, a+n, greater<ll>());
    sort(f, f+n);

    ll left = -1, right = 1e13;
    while (right - left > 1) {
        ll mid = (left + right) / 2;
        ll temp = 0;
        rep(i, n) {
            if (a[i] * f[i] >= mid) {
                temp += (a[i] - mid / f[i]);
            }
        }
        if (temp <= k) right = mid;
        else left = mid;
    }
    cout << right << endl;
}


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


int main() {
  int a,b,i,min_n,min_sa;
  cin >> a >> b ;
  int n[201];
  int sa[201];
  int su[201];

  for(i=0;i<=200;i++){
    su[i]=i;
  //  cout <<su[i];
  }
  for (i=0;i<b;i++){
    cin >>n[i];
    su[n[i]]=1000;
  }
 /* for(i=0;i<=100;i++){
    cout <<su[i] <<endl;
  }*/  
  
  for(i=0;i<=200;i++){
    sa[i]=abs(su[i]-a);
//    cout <<su[i] <<"-" <<a<<endl;
//    cout << i <<":"<<sa[i]<<endl;
  }
  
  min_n=0;
  min_sa=a;
  for(i=1;i<=200;i++){
    if(sa[i]<min_sa){
      min_sa=sa[i];
      min_n=su[i];
    }else if(sa[i]==min_sa){
      if(min_n > su[i]){
        min_n=su[i];
      }
    }
  }
  cout << min_n;
}
    




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

int A, B, C, now, ans = 1e9;

int main() {
	scanf("%d%d%d", &A, &B, &C);
	for (int i=-50; i<=100; i++) {
		now = 0;
		if (i < A) now += A - i;
		else {
			now += (i - A + 1) / 2;
			if ((i-A)&1) now++;
		}
		// printf("%d %d\n", i, now);
		if (i < B) now += B - i;
		else {
			now += (i - B + 1) / 2;
			if ((i-B)&1) now++;
		}
		// printf("%d %d\n", i, now);
		if (i < C) now += C - i;
		else {
			now += (i - C + 1) / 2;
			if ((i-C)&1) now++;
		}		
		// printf("%d %d\n", i, now);
		ans = min(ans, now);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
public class Main {

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

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

		System.out.println(Math.max(a*b, c*d));
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
using namespace std;
typedef pair<int, int> pi32;
typedef pair<ll, ll> pi64;
typedef vector<int> vi32;
typedef vector<ll> vi64;
typedef vector<pi32> vp32;
typedef vector<pi64> vp64;
const ll mod = 1e9 + 7;
const ll sz = 1e7, inf = 1e9 + 7;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int s,w;cin>>s>>w;
    if(w>=s)cout<<"unsafe\n";
    else cout<<"safe\n";

	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>

int main(){

    std::string s;

    std::cin >> s;

    for(size_t i = 0; i < s.size() - 1; i++){
        if(s.at(i) == s.at(i + 1)){
            std::cout << "Bad" << std::endl;
            return 0;
        }
    }

    std::cout << "Good" << std::endl;
    
    return 0;
}


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

long long GCD(long long x, long long y){
    if(x<y)swap(x,y);
    if(x%y==0){
        return y;
    }else{
        return GCD(y,x%y);
    }
}
long long num(long long n,long long c,long long d){
    long long G=GCD(c,d);
    long long L=c/G*d;
    return n-n/c-n/d+n/L;
}

int main(){
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<num(b,c,d)-num(a-1,c,d)<<endl;
}


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

int main() {
  int N;
  cin >> N;

  vector<int> A(N + 1), B(N);
  rep(i, N + 1) cin >> A[i];
  rep(i, N) cin >> B[i];

  ll ans = 0;
  rep(i, N) {
    int l = min(A[i], B[i]);
    int r = min(A[i + 1], B[i] - l);
    ans += l + r;
    A[i + 1] -= r;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
n,z,w=map(int,input().split())
a_list=list(map(int,input().split()))
dp_m=[0]*n
for i in range(n-2,-1,-1):
    temp=10**10
    for j in range(i+1,n):
        if j==n-1:
            temp=min(temp,abs(a_list[i]-a_list[n-1]))
        else:
            temp2=max(abs(a_list[j]-a_list[n-1]),dp_m[j+1])
            temp=min(temp,temp2)
    dp_m[i]=max(dp_m[i+1],temp)
ans=max(dp_m[0],abs(a_list[n-1]-w))
print(ans)
                    
                   


Measured memory_bytes: 44140
using System;
using System.Collections.Generic;
using System.Linq;
class P{
    static void Main(){
        string[] s = Console.ReadLine().Split();
        int n = int.Parse(s[0]);
        int T = int.Parse(s[1]);
        List<int> costs = new List<int>();
        for (int i = 0;i < n;i++){
            s = Console.ReadLine().Split();
            int c = int.Parse(s[0]);
            int t = int.Parse(s[1]);
            if (t <= T)
                costs.Add(c);
        }
        if (costs.Count() == 0)
            Console.WriteLine("TLE");
        else
            Console.WriteLine(costs.Min());
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <cmath>
#define rep(i, a) for(auto i=0; i<a; i++)
#define rep1(i, a, b) for(auto i=a; i<b; i++)
#define pbb push_back
using namespace std;
typedef int64_t ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;

void bfs(vector<vector<pii>> &g, vi &d, int s){
    d[s] = 0;
    queue<int> q;
    q.push(s);
    while(!q.empty()){
        int x = q.front();
        q.pop();
        for(auto i:g[x])
            if(d[i.first] == -1){
                d[i.first] = d[x] + i.second;
                q.push(i.first);
            }
    }
}

int main(){
    int n;
    cin>>n;
    vector<vector<pii>> g(n);
    rep(i, n-1){
        int x, y, w;
        cin>>x>>y>>w, x--, y--;
        g[x].pbb({y, w}), g[y].pbb({x, w});
    }
    int q, k;
    cin>>q>>k;
    vi d(n, -1);
    bfs(g, d, --k);
    // rep(i, n)
    //     cout<<d[i]<<" ";
    // cout<<endl;
    rep(i, q){
        int x, y;
        cin>>x>>y;
        x--, y--;
        cout<<d[x]+d[y]<<endl;
    }
    return 0;
}

Measured memory_bytes: 9984
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


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


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    s = S()
    d = deque(s)
    ans = 0

    while len(d) > 1:
        l = d.popleft()
        r = d.pop()

        if l == r:
            continue
        elif l == 'x':
            ans += 1
            d.append(r)
        elif r == 'x':
            ans += 1
            d.appendleft(l)
        else:
            print(-1)
            return

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4596
#include <iostream>

using namespace std;

int main()
{
    int a,f=0;
    cin >> a;
    while(a)
    {
        if(a%10 == 7)
            f = 1;
        a = a/10;
    }
    if(f == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
int fn[10][10]={};
int flag[10]={};
int n;
int ans=0;
 
int check(int num){
    int flaga=1;
    for(int i=1;i<=n;i++){
        if(flag[i]==0) flaga=0;
    }
    return flaga;
}
 
void route(int j,int i,int num){
    if (fn[j][i]==1&&flag[i]==0){
        flag[i]=num;
        int a=check(num);
        ans+=a;
        for (int k=2;k<=n;k++){
            route(i,k,num+1);
        }
        flag[i]=0;
    }
}
 
int main(){
    int m,i,j;
    scanf("%d %d",&n,&m);
    for (int k=0;k<m;k++){
        scanf("%d %d",&i,&j);
        fn[i][j]=1;
        fn[j][i]=1;
    }
    for (i=2;i<=n;i++){
        flag[1]=1;
        route(1,i,2);
        for (j=1;j<=n;j++)flag[j]=0;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 1000000007;

lld add(lld x, lld y)
{
    x =((x%MOD)+(y%MOD))%MOD;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

lld mul(lld x, lld y)
{
    return ((x%MOD)*(y%MOD))% MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}

lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    //cin>>t;
    t=1;
    while(t--)
    {
        lld n;
        cin>>n;
        vector<lld>ar(n);
        for(i=0;i<n;i++)
            cin>>ar[i];
        lld ans=0;
        // j-i=A[j]+A[i]
        map<lld,lld>br;
        map<lld,lld>cr;
        for(i=0;i<n;i++)
            br[i+ar[i]+1]++,cr[i+1-ar[i]]++;
        ans=0;
        for(auto x:br)
            ans+=x.second*cr[x.first];
        cout<<ans<<endl;
    }
}





Measured memory_bytes: 38892
#include <iostream>
#include <stdio.h>
#include <stdlib.h>


int main()
{
  int n;
  std::cin>>n;
  double a = n/2.0;
  int a1 = n/2;
  if (a == a1)
  std::cout<<a1;
  else
  std::cout<<(a1+1);
    return 0;
}


Measured memory_bytes: 888
from collections import defaultdict, deque

INF = float('inf')
K = int(input())

def zero_one_bfs_shortest_path(s, K):
    G = defaultdict(list)
    for v in range(K):
        G[v].append((0, (v * 10) % K))
        G[v].append((1, (v + 1) % K))
    d = [INF] * K
    d[s] = 0
    dq = deque()
    dq.appendleft(s)
    while len(dq) != 0:
        u = dq.popleft()
        for w, v in G[u]:
            if d[v] > d[u] + w:
                d[v] = d[u] + w
                if w == 0: dq.appendleft(v)
                else: dq.append(v)
    return d

print(zero_one_bfs_shortest_path(1, K)[0] + 1)

Measured memory_bytes: 43808
import java.util.*;

class Main {

	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		for(;;){
			int n=in.nextInt(), a=in.nextInt(), b=in.nextInt(),c=in.nextInt(), x=in.nextInt();
			if(n==0) return ;
			int i, pos=0;
			int xs[] = new int[n];
			for(i=0;i<n;i++) xs[i] = in.nextInt();
			for(i=0;i<=10000;i++){
				if(xs[pos] == x) pos++;
				if(pos==n) break;
				x = (a*x+b)%c;
			}
			System.out.println(i<=10000?i:-1);
		}
	}
	
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, x[60], y[60];
int ma;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> x[i] >> y[i];
	for (int i = 0; i < n; i++)for (int j = 0; j < n; j++) {
		if (i == j)continue;
		int s = x[j] - x[i], t = y[j] - y[i];
		int cnt = 0;
		for (int k = 0; k < n; k++)for (int l = 0; l < n; l++)if (x[l] - x[k] == s && y[l] - y[k] == t)cnt++;
		ma = max(ma, cnt);
	}
	cout << n - ma << endl;
}


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

int main() {
  int N , A , B , x;
  cin >> N >> A >> B;

  if (A * N < B) {
    x = A * N;
  }
  else if (A * N >= B) {
    x = B;
  }
  cout << x << endl;
}


Measured memory_bytes: 256
N = gets.to_i
S = gets.strip.split(//)

counts_l = []
counts_r = []

count = 0
N.times{|i|
	counts_l[i] = count
	if S[i] == '#'
		count += 1
	end
}
counts_l << count

count = 0
N.times{|j|
	i = N - 1 - j
	counts_r[i + 1] = count
	if S[i] == '.'
		count += 1
	end
}
counts_r[0] = count

#p counts_l
#p counts_r

counts = []
(N + 1).times{|i|
	counts << counts_l[i] + counts_r[i]
}

#p counts
puts counts.min


Measured memory_bytes: 21628
#include <bits/stdc++.h>
using namespace std;
long long a = 1000000000;
int main() {
	long long s;
	cin >> s;
	long long x1, y1, x2, y2, x3, y3;
	x2 = (s + a - 1) / a;
	y3 = a;
	y2 = 1;
	x3 = x2 * y3 - s;
	x1 = y1 = 0;
	printf("%lld %lld %lld %lld %lld %lld\n", x1, y1, x2, y2, x3, y3);
	return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=200000+19;
const int oo=(1<<30)-1;

struct Edge{
	int y,nxt;
} E[N*2];
Vi V[N];
int D[N],U[N],top[N],low[N],A[N],B[N];
int n;
char s[N];
ll ans;

void Link(int x,int y){
	V[x].pb(y);
	V[y].pb(x);
}
void dfs(int x,int fa){
	int y;
	A[x]=(s[x]=='1');
	For(i,0,V[x].size()) if ((y=V[x][i])!=fa){
		dfs(y,x);
		D[x]=max(D[x],D[y]+1);
		A[x]|=A[y];
	}
}
void dfs2(int x,int fa){
	int mx=U[x],tmp=B[x]|(s[x]=='1');
	for (int y:V[x]) if (y!=fa){
		B[y]|=tmp;
		U[y]=max(U[y],mx+1);
		mx=max(mx,D[y]+1);
		tmp|=A[y];
	}
	mx=U[x],tmp=B[x]|(s[x]=='1');
	for (int i=int(V[x].size())-1,y;~i;i--) if ((y=V[x][i])!=fa){
		B[y]|=tmp;
		U[y]=max(U[y],mx+1);
		mx=max(mx,D[y]+1);
		tmp|=A[y];
	}
	for (int y:V[x]) if (y!=fa) dfs2(y,x);
}
void calc(int x,int fa){
	Vi T;
	top[x]=max(D[x],U[x])-1;
	low[x]=n;
	T.pb(-1);
	if (~fa){
		T.pb(U[x]-1);
		if (B[x]) low[x]=min(low[x],U[x]);
	}
	for (int y:V[x]) if (y!=fa){
		T.pb(D[y]);
		if (A[y]) low[x]=min(low[x],D[y]+1);
		calc(y,x);
	}
	sort(T.begin(),T.end(),greater<int>());
	top[x]=min(top[x],T[1]+2);
}

int main(){
	n=IN();
	For(i,1,n) Link(IN(),IN());
	scanf("%s",s+1);
	if (n==1){
		puts("1");
		return 0;
	}
	dfs(1,-1);
	dfs2(1,-1);
	calc(1,-1);
	For(i,1,n+1)
		if (s[i]=='1'){
			ans+=max(top[i]+1,0);
		} else{
			ans+=max(top[i]-max(low[i],1)+1,0);
		}
	ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 40576
#include<stdio.h>

#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))

int main(void){
    int n,m;
    scanf("%d %d",&n,&m);
    int ar[m],al[m];
    for(int i = 0;i < m;i++)scanf("%d %d",&al[i],&ar[i]);
    int ml_r = 1000002,mr_l = 0;
    for(int i = 0;i < m;i++){ml_r = min(ml_r,ar[i]);mr_l = max(mr_l,al[i]);}
    printf("%d",max(min(n,ml_r) - mr_l + 1,0));
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
using namespace std;
int main()
{
        int n,exist=0;
        vector<int> ans;
        for (int i = 1; i < 10; i ++) 
                for (int j = 1; j < 10; j++)
                        ans.push_back(i*j);
        cin >> n;
        for (int i = 0; i < ans.size(); i++)
                if (ans[i] == n)
                        exist = 1;
        if (exist)
                cout << "Yes" << endl;
        else
                cout << "No" << endl;
        return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.p = [i for i in range(n)]
        self.rank = [1]*n
    
    def root(self, x):
        if x == self.p[x]:
            return x
        self.p[x] = y = self.root(self.p[x])
        return y
    
    def unite(self, x, y):
        px = self.root(x); py = self.root(y)
        if px == py:
            return 0
        rx = self.rank[px]; ry = self.rank[py]
        if ry < rx:
            self.p[py] = px
        elif rx < ry:
            self.p[px] = py
        else:
            self.p[py] = px
            self.rank[px] += 1
        return 1

    def same(self, x, y):
        px = self.root(x); py = self.root(y)
        return px == py

n,q = list(map(int,input().split()))
COMXY = [list(map(int,input().split())) for _ in range(q)]
union_find = UnionFind(n)
for comxy in COMXY:
    if comxy[0] == 0:
        union_find.unite(comxy[1],comxy[2])
    if comxy[0] == 1:
        if union_find.same(comxy[1],comxy[2]):
            print(1)
        else:
            print(0)


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

long long A[100005], pre[100005];

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

    for(int i=1; i<=N; i++)
        scanf("%lld", &A[i]);

    int ans = 1;
    sort(A+1, A+1+N);

    for(int i=1; i<=N; i++)
        pre[i] = A[i] + pre[i-1];

    for(int i=N; i>1; i--)
    {
        if(A[i]<=pre[i-1]*2)
            ans++;
        else
            break;
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1792
n, m = map(int, input().split(" "))
ss = []
cs = []
for i in range(n):
    ss.append(list(map(int, input().split(" "))))
for i in range(m):
    cs.append(list(map(int, input().split(" "))))

for i in range(n):
    md = 0
    for j in range(m):
        d = abs(cs[j][0] - ss[i][0]) + abs(cs[j][1] - ss[i][1])
        if d < abs(cs[md][0] - ss[i][0]) + abs(cs[md][1] - ss[i][1]):
            md = j
    print(md + 1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define N 100005
int seg[4*N];
int mul(int a, int b)
{
    return a*b%mod;
}
int mypower(int a, int b)
{
    int ans = 1;
    while(b)
    {
        if(b%2)
            ans = mul(ans, a);
        b=b/2;
        a=mul(a,a);
    }
    return ans;
}
void update(int st, int l, int r, int idx, int arr[], int val)
{
    if(l == r)
    {
        seg[st] = arr[l] = val;
        return;
    }
    int mid = (l+r)/2;
    if(idx <= mid)
        update(2*st+1, l, mid, idx, arr, val);
    else
        update(2*st+2,mid+1, r, idx, arr,val);
    seg[st] = min(seg[2*st+1],seg[2*st+2]);    
}
int query(int st, int l, int r, int ql, int qr)
{
    if(l > qr || r < ql)
    {
        return 0;
    }
    if(l >= ql && r <= qr)
        return seg[st];
    int mid = (l+r)/2;
    return min(query(2*st+1, l, mid, ql, qr), query(2*st+2, mid+1, r, ql, qr));
}

signed main() {
    int n;
    cin >> n;
    int arr[n];
    int i;
    for(i=0;i<n;i++)
        cin >> arr[i];
    int k=0;
    for(i=0;i<n;i++)
        k=k^arr[i];
    for(i=0;i<n;i++)
    {
        arr[i] = arr[i]^k;
        cout << arr[i] << " ";
    }
}

Measured memory_bytes: 5028
#include <stdio.h>

long GetGCD(long x, long y);

int main(void){
    long  n,m,gcd,lcm;
    
    while (scanf("%ld %ld", &n, &m)!=EOF){
        gcd = GetGCD(n,m);
        lcm = n * m / gcd;
        printf("%ld %ld\n", gcd, lcm);
    }
    return 0;
}

long GetGCD(long x, long y){
    return y%x ? GetGCD(y%x, x) : x;
}

Measured memory_bytes: 1024