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

#define io(F) string t_="";ifstream fin(t_+F+".in");ofstreamfout(t_+F+".out")
#define qio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
#define graph unordered_map<int, unordered_set<int>>
typedef long long ll;

graph G;

int main() {
	qio; int n; cin >> n;
	forl(i, 2, n+1) {
		int p; cin >> p;
		G[p].insert(i);
	}
	forl(i, 1, n+1) {
		println(G[i].size());
	}
}


Measured memory_bytes: 33420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[100002];
int main() {
	ll n,k;
	cin>>n>>k;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
	}
	ll ans=0;
	for(ll i=0;i<=n-1;i++){
		ll sum=a[i]+a[i+1];
		ll now=max(sum-k,ll(0));
		a[i+1]=a[i+1]-now;
		ans+=now;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    ll n, p;
    cin >> n >> p;
    ll ans = 0;
    string s;
    cin >> s;
    if (p==2 || p==5) {
        rep(i, n) {
            int v = s[i]-'0';
            if (v%p==0) {
                ans += (i+1);
            }
        }
        cout << ans << endl;
        return 0;
    }
    reverse(s.begin(), s.end());
    vector<ll> sum(n);
    ll temp = 1;
    
    

    rep(i, n) {
        int v = s[i] - '0';
        
        if (i==0) {
            sum[i] = v % p;
        }
        else {
            sum[i] = (sum[i-1] + (temp * v) % p) % p;
        }
        temp = (temp * 10) % p;
    }
    
    sum.push_back(0);
    sort(sum.begin(), sum.end());
    
    ll l = 0;
    rep(i, sum.size()) {
        if (i==0) continue;
        if (sum[i] != sum[i-1]) {
            ll v = i - l;
            ans += v*(v-1)/2;
            l = i;
        }
    }
    ll v = n+1-l;
    ans += v*(v-1)/2;
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4996
#include <iostream>
using namespace std;
bool is(string s){
    int n=s.length();
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1])return false;
    }
    return true;
}
int main(void){
string s;
cin>>s;
int n=s.length();
//cout<<ispalindrom(s);
    string t=s.substr(0,(n-1)/2);
    int pos=n-(n+3)/2+1;
    string t1=s.substr((n+3)/2-1,pos);
if(is(s) and is(t) and is(t1))cout<<"Yes";
else cout<<"No";
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
int main() {
  int n, d, i;
  cin >> n;
  d = 0;
  vector<int> vec(n);
  for (int i = 0;i<n;i++)
    cin >> vec.at(i);
  sort(vec.begin(),vec.end());
  for (int i = 0;i < n; i++){
    if (i >= 1 && vec.at(i) == vec.at(i - 1)){
      d++;
    }
  
  }
  cout << vec.size() - d << endl;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int lower = max({a,b,c})*3;
    int sum = a+b+c;
    int ans = 0;
    if((lower-sum)%2 == 0){
        ans = (lower-sum)/2;
    }
    else{
        ans = (lower+3-sum)/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int N, M, R, r[11], a, b, c, d[209][209];
int main() {
	cin >> N >> M >> R;
	for (int i = 0; i < R; i++) cin >> r[i], r[i]--;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) d[i][j] = inf;
		d[i][i] = 0;
	}
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> c; a--, b--;
		d[a][b] = d[b][a] = c;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
			}
		}
	}
	sort(r, r + R);
	int ret = inf;
	do {
		int sum = 0;
		for (int i = 1; i < R; i++) sum += d[r[i - 1]][r[i]];
		ret = min(ret, sum);
	} while (next_permutation(r, r + R));
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);

		double sum=0;

		double BTC=380000.0;

		int N=sc.nextInt();

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

			double money=sc.nextDouble();
			String money_type=sc.next();

			if(money_type.equals("JPY")) sum+=money;
			else sum+=money*BTC;

		}

		System.out.println(sum);

		sc.close();

	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
#define ll  long long 
#define ull unsigned long long int
#define boost ios_base::sync_with_stdio(false);    cin.tie(NULL);    cout.tie(NULL)
#define vi vector<int>
#define P push_back
#define F first
#define S second
#define debug(x) cout<<x<<" "
#define pi vector<pair<int,int> >
#define all(a) a.begin(),a.end()
#define int ll
using namespace std;
// using namespace __gnu_pbds;
// typedef tree <int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll const mod=1e9+7;
int powi(int i,int b){
    int res=1;
    while(b){
        if(b&1)res*=i,res%=mod;
        b>>=1;
        i*=i;
        i%=mod;
    }
    return res;
}
// map<int,int> m;
// ll fact(int n){
//     //if(n==0)return 0;
//     if(n<=1)return 1;
//     if(m[n]!=0)return m[n];
//     return m[n]=(n*fact(n-1))%mod;
// }
// int ncr(int n,int r){
//     int h=fact(n);
//     int v=fact(r);
//     int j=fact(n-r);
//     v*=j;
//     v%=mod;
//     v=powi(v,mod-2);
//     return (h*v)%mod;
// }
// vi ar(2002);
// int root(int a){
//     if(ar[a]==a)return a;
//     return ar[a]=root(ar[a]);
// }
// void merge(int a,int b){
//     int h=root(a),j=root(b);
//     if(h!=j){
//         ar[h]=j;
//     }
// }
void solve(){
    int n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0){
        cout<<(b-a)/2;return;
    }
    int ans=0;
    ans=b-1;
    ans=min(ans,n-a);
    if(b-a>1){
        int g=n-b+1;
        g=((n-a-g)/2)+g;
        ans=min(ans,g);
        g=a;
        g=((b-g-1)/2)+g;
        ans=min(ans,g);
    }

    cout<<ans;
}
signed main(){
    //boost;
    int t=1;
    //cin>>t;
    for(int _=1;_<=t;_++){
        //cout<<"Case #"<<_<<": ";
        solve();
        cout<<"\n";
    }
    
    return 0;
}

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

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n;
  cin >> n;
  ll x[n],y[n],h[n];
  for(ll i=0;i<n;i++)cin >> x[i] >> y[i] >> h[i];

  ll m,X,Y;
  for(ll i=0;i<=100;i++){
    for(ll j=0;j<=100;j++){
      ll ans;
      bool ok=true;
      for(ll k=0;k<n;k++){
        if(h[k]!=0){
          ans=abs(x[k]-i)+abs(y[k]-j)+h[k];
          break;
        }
      }
      for(ll k=0;k<n;k++){
        if(h[k]==0){
          if(ans-abs(x[k]-i)-abs(y[k]-j)>0){
            ok=false;
            break;
          }
        }
        else{
          if(ans!=abs(x[k]-i)+abs(y[k]-j)+h[k]){
            ok=false;
            break;
          }
        }
      }
      if(ok){
        X=i;
        Y=j;
        m=ans;
      }
    }
  }

  cout << X << " " << Y << " " <<  m << endl;

}

Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int D, G;
  cin >> D >> G;
  vector<pair<int, int>> p(D);
  for (int i = 0; i < D; i++) {
    cin >> p[i].first >> p[i].second;
  }

  int ans{1000};
  for (int i = 0, n = 1 << D; i != n; ++i) {
    int maxr = -1, score = 0, solved = 0;
    for (int d = 0; d != D; ++d) {
      if (i & (1 << d)) {
        score += (d+1) * p[d].first * 100 + p[d].second;
        solved += p[d].first;
      } else {
        maxr = d;
      }
    }

    if (score < G) {
      if (maxr > -1 && (G - score < p[maxr].first * (maxr+1) * 100)) {
        solved += 1 + (G - score - 1) / ((maxr+1) * 100);
      } else {
        continue;
      }
    }
    
    ans = min(ans, solved);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, m, a;
	while (cin >> n >> m >> a, n) {
		pair<int, pair<int, int>>s[1010];
		for (int i = 0; i < m; i++)cin >> s[i].first >> s[i].second.first >> s[i].second.second;
		sort(s, s + m);
		int ans = a;
		for (int i = m - 1; i >= 0; i--) {
			if (s[i].second.first == ans)ans = s[i].second.second;
			else if (s[i].second.second == ans)ans = s[i].second.first;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3084
class UnionFind(object):

    def __init__(self, size):
        self.table = [-1 for _ in xrange(size)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        self.table[x] = self.find(self.table[x])
        return self.table[x]

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

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 == s2:
            return False
        if self.table[s1] > self.table[s2]:
            s1, s2 = s2, s1
        self.table[s1] += self.table[s2]
        self.table[s2] = s1
        return True


def main():
    n, q = map(int, raw_input().split())
    uf = UnionFind(n)
    for _ in xrange(q):
        com, x, y = map(int, raw_input().split())
        if com == 0:
            uf.union(x, y)
        else:
            print 1 if uf.same(x, y) else 0

if __name__ == "__main__":
    main()

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

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define REP2(i,n) for(int i=0;i<(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP4(i,m,n,s) for(int i=m;(s>0 and i<(int)(n)) or (s<0 and i>(int)(n));i+=s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define PIS(x) printf("%d ",x)
#define PN() putchar('\n')
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define MT make_tuple

using PII = pair<int, int>;
using TI3 = tuple<int, int, int>;
using LL = long long;
using ULL =  unsigned long long;
using MAT = array<array<LL, 2>, 2>;

void RI() {}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d", &head);
    RI(tail...);
}
void RLL() {}
template<typename... T>
void RLL( LL& head, T&... tail ) {
    scanf("%lld", &head);
    RLL(tail...);
}
void print() {putchar('\n');}
template<typename T, typename... U>
void print(T head, U... tail) {
    cout << head << " ";
    print(tail...);
}

const int MOD = 1000000007;
#define MAX_N 300005


int main()
{
    int N, A, B;
    RI(N, A, B);
    if((A - B - 1) % 2 == 0) {
        printf("Borys\n");
    } else {
        printf("Alice\n");
    }
    return 0;
}


Measured memory_bytes: 256
a = input()
b = input()
c = input()

t = 'a'
while True:
    if t == 'a':
        if a == '':
            print('A')
            exit()
        t = a[0]
        a = a[1:]
    elif t == 'b':
        if b == '':
            print('B')
            exit()
        t = b[0]
        b = b[1:]
    else:
        if c == '':
            print('C')
            exit()
        t = c[0]
        c = c[1:]


Measured memory_bytes: 9140
#include<stdio.h>
int main(void)
{
int N,i;
long long a=0;
  scanf("%d",&N); 
  for(i=1;i<=N;i++){
	if(i%3!=0 && i%5!=0)
	a+=i;
  }	
  printf("%ld",a);
return 0;	
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf=1e9;
int main(void)
{
    int N,K,ans=0,h;
    cin >> N >> K;
    for(int i=0;i<N;i++)
    {
        cin >> h;
        if(h>=K) ans++;
    }
    cout << ans << endl;    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
# include <algorithm>
using namespace std;
int main() {
    string s;
    int c1=0,c2=0;
    cin>>s;
    if(s[0]=='A'){
        for(int i=0;i<s.size();i++){
            if(islower(s[i])){
                c1++;
            }
        }
        for(int i=2;i<s.size()-1;i++){
            if(s[i]=='C'){
                c2++;
            }
        }
    }
    if(c1==s.size()-2&&c2==1){
        cout<<"AC";
    }
    else{
        cout<<"WA";
    }
}

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

int n,ans;
char s[1000010],t[1000010];
deque<int> q;

int main(){
    scanf("%d%s%s",&n,s+1,t+1);
    q.push_back(n+1);
    for(int i=n,j=n+1,tmp=0,pre;i;i--){
        for(pre=j;j&&(i<j||s[j]!=t[i]);j--);
        if(!j){
            puts("-1");
            return 0;
        }
        if(pre==j){
            while(!q.empty()&&q.back()-tmp>=i)
                q.pop_back();
            q.push_back(i+tmp);
        }
        else{
            tmp++;
            if(i!=j){
                ans=max(ans,(int)q.size());
                q.push_front(j+tmp);
            }
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 6272
/*
      author : nishi5451
      created: 11.08.2020 21:51:03
*/

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


int main(){
    int a,p;
    cin >> a >> p;
    cout << (3*a+p)/2 << endl;
    return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

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

        if (s.equals("AAA") || s.equals("BBB")) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


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

using namespace std;

int main(void){
    long long X;
    cin>>X;
    for(long long i=-200;i<=200;i++){
        for(long long j=-200;j<=200;j++){
            if(i*i*i*i*i-j*j*j*j*j==X){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
    return 0;
}



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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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;
    cin >> n;
    vi a(n), b(n), c(n-1);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n-1) cin >> c[i];
    rep(i, n) a[i]--;
    int ans = 0;
    rep(i, n) ans += b[a[i]];
    rep(i, n-1) {
        if (a[i]+1 == a[i+1]) ans += c[a[i]];
    }
    cout << ans << endl;
    return 0;
}


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

int E=1000000007;
int main() {
   int N;
   cin >> N;
   long long a=1,b=1,c=1;
   for (int i=0; i<N; i++) {
       a*=10;a%=E;
       b*=9;b%=E;
       c*=8;c%=E;
   }
   long long count=a-b*2+c;
   count%=E;
   if (count<0) count+=E;
   cout << count << endl;
}

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

int main() {
  int N = 0;
  cin >> N ;
  int Di , Dj;
  int i = 0;
  int renzorosu = 0;
  while(i < N){
    cin >> Di >> Dj;
    if(Di == Dj){
      renzorosu++;
      if (renzorosu >= 3){
      	break;
      }
    }
     else {
      renzorosu = 0;
    }
    i++;
  }
  if(renzorosu >= 3){
    cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << H*W-H*w-W*h+h*w;
}

Measured memory_bytes: 256
import sys
import itertools

sys.setrecursionlimit(1000000)
input = lambda: sys.stdin.readline().rstrip()

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

p = itertools.permutations([i + 1 for i in range(N)])

for i, j in enumerate(p):
    if all(x == y for x, y in zip(j, P)):
        a = i
    if all(x == y for x, y in zip(j, Q)):
        b = i

print(abs(a - b))
        

Measured memory_bytes: 47836
#include <iostream>
#include <set>

using namespace std;

int n;
set<string> ss;
string s,str;

int main(){
  ios::sync_with_stdio(false);

  cin >> n;
  while(n--){
    cin >> str;

    if(str[0] == 'i'){
      cin >> s;      
      ss.insert(s);
    }else{
      cin >> s;
      if(ss.find(s) == ss.end()){
	cout << "no" << endl;
      }else{
	cout << "yes" << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 27812
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;
typedef pair<int, int> crd;
typedef pair<crd, int> live;

int mx[] = {-1, 0, 1, 2, 2, 2, 1, 0, -1, -2, -2, -2};
int my[] = {2, 2, 2, 1, 0, -1, -2, -2, -2, -1, 0, 1};

vector<string> f(10);

int main() {
    int fx, fy, n;

    while( cin >> fx >> fy , fx && fy ) {
        cin >> n;

        // cout << "fx:" << fx << " fy:" << fy << " n:" << n << endl;

        int cnt = 0;

        vector<crd> sprinc;
        queue<live> life;

        // 入力
        for ( int i = 0; i < n; i++ ) {
            int x, y;
            cin >> x >> y;
            sprinc.push_back( make_pair(x, y) );
        }

        // 初期位置をpush
        crd a = make_pair(fx, fy);
        life.push( make_pair(a , 0) );

        int flg = 0;
        while(!life.empty()) {
            live tmp = life.front();
            int x = tmp.first.first,
                y = tmp.first.second,
                z = tmp.second;
            life.pop();

            if ( z == n ) {
                flg = 1;
                break;
            }

            for ( int j = 0; j < 12; j++ ) {
                int nx = x + mx[j],
                    ny = y + my[j];

                if ( !(0 <= nx && nx < 10 && 0 <= ny && ny < 10) ) continue;

                if ( abs(nx-sprinc[z].first) <= 1 && abs(ny-sprinc[z].second) <= 1 ) {
                    life.push( make_pair( make_pair(nx, ny), z+1 ) );
                }
            }
        }

        if ( flg ) {
            cout << "OK";
        } else {
            cout << "NA";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i :c)
#define pii pair< int,int >
#define Fast_IO() ios_base::sync_with_stdio(false);cin.tie(0)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x,y) cout << x << " "<<y
const int MOD = 1000 * 1000 * 1000 + 7;
const int N = 100;
using namespace std;
clock_t time_p=clock();
void dem()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int main()
{
    Fast_IO();
    ll n , l ;
    cin >> n >>l ;
    ll flavour = l * n + ( n * (n+1) / 2 ) - n ;
    ll res = 1000* 1000 * 1000 ,g=0;
    for ( int i = 1 ; i <= n ; ++i)
       if( res >  abs( ( l + i -1 ) ))g = l+i -1 ,res = abs( ( l + i -1 ));

    cout << flavour - g ;
    return 0 ;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int a[2][3][2];    // (x/y)(-/0/+)(min/max)



int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    int i,j;
    for(i=0; i<2; i++) {
        for(j=0; j<3; j++) {
            a[i][j][0]=INF;  a[i][j][1]=-INF;
        }
    }

    for(i=0; i<n; i++) {
        int x,y;
        char str[3]={0};
        scanf("%d%d%s", &x, &y, str);
        if(str[0]=='R') {
            a[0][2][0]=MIN(a[0][2][0], x);
            a[0][2][1]=MAX(a[0][2][1], x);
            a[1][1][0]=MIN(a[1][1][0], y);
            a[1][1][1]=MAX(a[1][1][1], y);
        }
        else if(str[0]=='L') {
            a[0][0][0]=MIN(a[0][0][0], x);
            a[0][0][1]=MAX(a[0][0][1], x);
            a[1][1][0]=MIN(a[1][1][0], y);
            a[1][1][1]=MAX(a[1][1][1], y);
        }
        else if(str[0]=='U') {
            a[0][1][0]=MIN(a[0][1][0], x);
            a[0][1][1]=MAX(a[0][1][1], x);
            a[1][2][0]=MIN(a[1][2][0], y);
            a[1][2][1]=MAX(a[1][2][1], y);
        }
        else {
            a[0][1][0]=MIN(a[0][1][0], x);
            a[0][1][1]=MAX(a[0][1][1], x);
            a[1][0][0]=MIN(a[1][0][0], y);
            a[1][0][1]=MAX(a[1][0][1], y);
        }
    }

    double ans = (double)INF * (double)INF;
    int t;
    for(t=0; t<=400000000; t++) {
        double range[2][2]={{a[0][1][0], a[0][1][1]}, {a[1][1][0], a[1][1][1]}};
        double delta=(double)t/2;

        range[0][0]=MIN(range[0][0],(a[0][0][0]-delta));
        range[0][0]=MIN(range[0][0],(a[0][2][0]+delta));
        range[0][1]=MAX(range[0][1],(a[0][0][1]-delta));
        range[0][1]=MAX(range[0][1],(a[0][2][1]+delta));
        range[1][0]=MIN(range[1][0],(a[1][0][0]-delta));
        range[1][0]=MIN(range[1][0],(a[1][2][0]+delta));
        range[1][1]=MAX(range[1][1],(a[1][0][1]-delta));
        range[1][1]=MAX(range[1][1],(a[1][2][1]+delta));

        double val = (range[0][1]-range[0][0])*(range[1][1]-range[1][0]);
        ans = MIN(ans, val);
    }
    printf("%.10lf\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>

using namespace std;

// お菓子を持っていないAの数を出力

int main() {
  int passenger_num;
  int sweets_num;
  map<int, bool> is_having_sweets_passenger;

  cin >> passenger_num >> sweets_num;

  // init
  for(int i = 1; i <= passenger_num; i++) {
    is_having_sweets_passenger[i] = false;
  }

  for(int i = 0; i < sweets_num; i++) {
    int victimus_with_swetts_num;
    cin >> victimus_with_swetts_num;

    for(int j = 0; j < victimus_with_swetts_num; j++) {
      int victim_label;
      cin >> victim_label;
      is_having_sweets_passenger[victim_label] = true;
    }
  }

  int victimus_num = 0;
  for(int i = 1; i <= passenger_num; i++) {
    if(!is_having_sweets_passenger[i]) {
      victimus_num++;
    }
  }

  cout << victimus_num << endl;

  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using P = pair<int,int>;
using Graph =vector<string>;
Graph field;
queue<P> q;

int main() {
ll x,k,d;
cin>>x>>k>>d;
ll a;
x=abs(x);
if(x==0){
  if(k%2==0)x=0;
  else x=d;
  cout<<x<<endl;
  return 0;
}
a=x/d;
if(a>=k){
  if(x<0){
    x=x+k*d;
  }else{
    x=x-k*d;
  }
}else{
  if((k+a)%2!=0){

  x=abs(abs(x%d)-d);
  }else{
  x=abs(x%d);
  }
}
cout<<x<<endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int N, M;
vector<int> G[1005];
vector<int> ret;

void solve(int st){
  vector<int> path;
  
  vector<int> parent(1005, -1);
  parent[st] = st;
  queue<int> que;
  que.push(st);
  while(!que.empty()){
    int v = que.front(); que.pop();
    rep(i,G[v].size()){
      if(G[v][i] == st){
        int x = v;
        while(x != st){
          path.push_back(x);
          x = parent[x];
        }
        path.push_back(st);
        break;
      }else{
        if(parent[G[v][i]] != -1){
        }else{
          parent[G[v][i]] = v;
          que.push(G[v][i]);
        }
      }
      if(path.size() > 0) break;
    }
  }

  if(path.size() == 0) return;
  if(ret.size() == 0 || path.size() < ret.size()){
    ret = path;
  }
}

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


  
  REP(i,1,N+1){
    solve(i);
  }

  if(ret.size() == 0) cout << -1 << endl;
  else {
    cout << ret.size() << endl;
    rep(i,ret.size()){
      cout << ret[i] << endl;
    }
  }
  return 0;
}



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

using namespace std;

#define ll long long
#define F first
#define S second
#define ii pair < int , int >

const int N=120;
int a[N];
int main()
{   int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
    }
    sort(a,a+n);
    int cnt=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(a[i]==a[j] || a[j]==a[k])
                    continue;
                if(a[i]+a[j] > a[k]){
                    cnt++;
                }
            }
        }
    }
    cout<<cnt;

}


Measured memory_bytes: 3752
import java.util.ArrayList;
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> x = new ArrayList<Integer>();
        ArrayList<Integer> y = new ArrayList<Integer>();
        int count = 0;
        while(true){
            x.add(count,sc.nextInt());
            y.add(count,sc.nextInt());
            if((x.get(count)==0)&&(y.get(count)==0))
                break;
            count += 1;
        }
        for(int i = 0; i < count ; i++){
            System.out.println(Math.min(x.get(i),y.get(i))+" "+Math.max(x.get(i),y.get(i)));
        }
    }
}

Measured memory_bytes: 37496
#n , m , l = map(int , input().split())

# list_n = list(map(int , inpuut().split()))<Paste>

#n = input()
# list = [input() for i in range(N)

#list = [[i for i in range(N)] for _ in range(M)]


N = int(input())
K = int(input())

List_x = list(map(int, input().split()))

ans = 0
for x in List_x:
    ans += 2 * min(x, K - x)
print(ans)


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N, x;
    cin >> N >> x;

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

    ll ans = LLONG_MAX;
    for (int sp = 0; sp < N; sp++) {
        ll cand = ll(sp) * x;
        for (int v : b)
            cand += v;
        ans = min(ans, cand);

        for (int i = 0; i < N; i++) {
            b[i] = min(b[i], a[(i - sp - 1 + N) % N]);
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
n=int(input())
x=[]
y=[]
for i in range(n):
    a,b=map(int,input().split())
    x.append(a)
    y.append(b)

p=1
for i in range(n):
    p*=i+1

def D(a,b):
    a=a-1
    b=b-1
    return ((x[a]-x[b])**2+(y[a]-y[b])**2)**(0.5)

def f(x):
    ans=0
    while x>0:
        ans+=x%2
        x=x//2
    return ans

def r(x):
    ans=1
    for i in range(x):
        ans*=(i+1)
    return ans

dp=[[0]*(n+1) for _ in range(2**n)]
for i in range(1,2**n):
    for j in range(1,n+1):
        for k in range(1,n+1):
            if (i>>(j-1))&1 and not (i>>(k-1)&1):
                dp[i+2**(k-1)][k]+=dp[i][j]+r((f(i)-1))*D(j,k)

print(sum(dp[2**n-1])/p)



Measured memory_bytes: 74808
#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
using namespace std;

const int maxn = 10010;
const int INF = 1<<29;
struct edge {
    int to,cost,distance;
    edge(){}
    edge( int x,int y,int z ) {
        to=x;
        distance=y;
        cost=z;
    }
};

typedef pair<int,int>P;
vector<edge>G[maxn];
int d[maxn];
int N;

void dijkstra(int s) {
    priority_queue<P,vector<P>,greater<P> >que;
    for(int i=1;i<=N;i++) d[i]=INF;
    d[s]=0;
    que.push(P(0,s));

    while(!que.empty()) {
        P p=que.top(); que.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        for(int i=0;i<G[v].size();i++) {
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.distance) {
                d[e.to]=d[v]+e.distance;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

int main()
{
   //freopen("a.txt","r",stdin);
    int M;
    while(~scanf("%d%d",&N,&M)&&(N+M)) {
        for(int i=1;i<=N;i++) G[i].clear();
        int a,b,c,v;
        for(int i=0;i<M;i++) {
            scanf("%d%d%d%d",&a,&b,&c,&v);
          //  printf("%d %d %d %d\n",a,b,c,v);
            G[a].push_back(edge(b,c,v));
            G[b].push_back(edge(a,c,v));
        }
        dijkstra(1);
       // for(int i=1;i<=N;i++) printf("%d\n",d[i]);
        int sum=0;
        for(int i=2;i<=N;++i) {
            int min_cost=INF;
            for(int j=0;j<G[i].size();++j) {
                edge &e=G[i][j];
               // printf("%d %d %d\n",e.to,d[e.to],e.distance);
                if(d[e.to]+e.distance==d[i]&&e.cost<min_cost)
                {
                    min_cost=e.cost;
                }
            }
            sum+=min_cost;
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 5080
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        string[] cin = Console.ReadLine().Split();
        int n = int.Parse(cin[0]);
        int m = int.Parse(cin[1]);

        // 始点からの距離dist（初期値は無限。後でdist[始点]だけ0にする）
        // 配列やListは参照型なので普通に引数にした場合(値渡し)
        // 引数にしたdistは戻り値にしなくても結果を受け取れる
        long[] dist = new long[n];
        for (int i = 0; i < n; i++)
            dist[i] = long.MaxValue;

        // Bellman_ford(頂点数,始点,辺の数,dist)
        // 戻り値はbool[n]で始点→各頂点の途中に負閉路が存在するか(存在すればtrue)
        int s = 0; // 今回の始点は固定で0
        bool[] negative = Bellman_ford(n, s, m, dist);

        // 今回の目的地は固定でn-1
        // n-1までの経路に負閉路が存在すれば答えはinf
        // また、本問題ではコストの正負を反転させてるので元に戻す
        if (negative[n - 1]) Console.WriteLine("inf");
        else Console.WriteLine(-dist[n - 1]);
    }

    static bool[] Bellman_ford(int n, int s, int m, long[] dist)
    {
        // グラフの受け取りはこっちでやる
        // 頂点a→頂点b(コストc)
        string[] cin;
        int[] a = new int[m];
        int[] b = new int[m];
        long[] c = new long[m];
        for (long i = 0; i < m; i++)
        {
            cin = Console.ReadLine().Split();
            // 本問題では
            // ・入力のインデックスが1スタートなので0スタートに変更
            // ・コストの正負を反転させる
            a[i] = int.Parse(cin[0]) - 1;
            b[i] = int.Parse(cin[1]) - 1;
            c[i] = -long.Parse(cin[2]);

            //a[i] = int.Parse(cin[0]);
            //b[i] = int.Parse(cin[1]);
            //c[i] = long.Parse(cin[2]);
        }

        // 始点から始点の距離は0
        dist[s] = 0;

        // 第一ステップ：最短距離の算出
        // 始点を除くn-1個の頂点と全ての辺について貪欲的に最短距離を算出
        for (int i = 1; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                // dist[a[j]]がlong.MaxValueだと桁あふれするのでその場合を除外
                if (dist[a[j]] != long.MaxValue && dist[b[j]] > dist[a[j]] + c[j])
                {
                    dist[b[j]] = dist[a[j]] + c[j];
                }
            }
        }

        // 第二ステップでdistの値が変化する場合、それは最短距離では無いので
        // 作業用にdist2作ったりする必要はない

        // 第二ステップ：負閉路の検出
        // 負閉路が無い場合はここまでで最短距離が出てるはず
        // 全ての辺について再計算して最短距離が変わるならそれは負閉路の存在を示す
        bool[] negative = new bool[n];

        for (int j = 0; j < m; j++)
        {
            if (dist[a[j]] != long.MaxValue && dist[b[j]] > dist[a[j]] + c[j])
            {
                dist[b[j]] = dist[a[j]] + c[j];
                negative[b[j]] = true;
            }
            // 負閉路を経由してきたやつはその先も負閉路経由となるので
            if (negative[a[j]]) negative[b[j]] = true;
        }
        return negative;
    }
}

Measured memory_bytes: 13268
N = int(input())
result = "Yes"
if N == 1:
    t,x,y = map(int,input().split())
    if (x+y+t) % 2 == 0 and x+y<=t and x+y+t>=0:
        pass
    else:
        result = "No"
else:
    S = [[int(i) for i in input().split()] for i in range(N)]
    for i in range(N-1):
        a,b = S[i],S[i+1]
        dt = b[0]-a[0]
        dx = b[1]-a[1]
        dy = b[2]-a[2]
        if (dx+dy+dt) % 2 == 0 and dx+dy<=dt and dx+dy+dt>=0:
            pass
        else:
            result = "No"
            break
print(result)

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

#define rep(x, y) for (int i = (x); i < (y); i++)

typedef long long ll;

using namespace std;

void solve() {
    int n;
    cin >> n;

    int v[n], c[n];
    rep(0, n) cin >> v[i];
    rep(0, n) cin >> c[i];

    int x, y, diff = 0;
    for (int bit = 0; bit < (1<<n); bit++) {
        vector<int> select;
        for (int i = 0; i < n; i++) {
            if (bit & (1<<i)) {
                select.push_back(i);
            }
        }

        x = y = 0;
        for (int s : select) {
            x += v[s];
            y += c[s];
        }

        diff = max(diff, x - y);
    }

    cout << diff << endl;
}

int main() {
    solve();

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,m,ans=1;cin>>n>>m;
  lvector v;
  for(ll i=1;i<=sqrt(m);++i) {
    if(m%i==0) {
      if(i<=m/n) ans=max(ans,i);
      if(i>=n) ans=max(ans,m/i);
    } 
  }
  print(ans);
  return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  int ans=0;
  while(N!=0){
    N /= K;
    ans++;
  }
  cout << ans;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    int A, B, C, times;
    string S; 
    cin >> A >> B >> C;
    times = 0;
    times = B / A;
    if (times > C) {
        cout << C << endl;
    } else {
        cout << times << endl;
    }
    
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<queue>
using namespace std;
int main()
{
	int x;
	cin>>x;
	if(x==1)
	{
		cout<<0;
	}
	if(x==0)
	{
		cout<<1;
	}
 } 


Measured memory_bytes: 3560
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>
#include <fstream> 
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <math.h>
#include <cmath>
using namespace std;
int main(){
    int N,ave;
    int sum = 0;
    int ans = 0;
    double ave2;
    cin >> N;
    int a[N];
    for(int i=0;i<N;i++){
    cin >> a[i];
    sum += a[i];	
    }
    ave = sum/N;
    ave2 = (double)sum/N;
    if(ave2 - ave >= 0.5){
    ave += 1;
    }
    for(int j=0;j<N;j++){
    ans += pow(a[j] - ave,2);
    }
    cout << ans << endl;
    }    		 
       

Measured memory_bytes: 256
#include <stdio.h>
int i,j,a[5];
int main()
{
	int nazo;
	for(;5-i&&scanf("%d",a+i);i++);
	for(i=0;i<5;i++){
	for(j=i+1;j<5;j++){
	if(a[j]>a[i])
	{ nazo=a[i];a[i]=a[j];a[j]=nazo; }
	}
	}
	for(i=0;i<5;i++){
	if(i==4)printf("%d\n",a[i]);
	else printf("%d ",a[i]);
	}
	return 0;
}

Measured memory_bytes: 596
def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))

x = int(input())
num = []
for i in range(1000):
    num.append(i)
    num.append(-i)
for i in range(len(num)):
    for j in range(len(num)):
        if num[i]**5 - num[j]**5 == x:
            print(num[i],num[j])
            exit()



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

int pai[300000], sz[300000];
int degree[300000], re[300000];
int ans[300000];

int find(int x)
{
	if(pai[x] == x) return x;
	return pai[x] = find(pai[x]);
}

void join(int x, int y)
{
	x = find(x);
	y = find(y);
	if(x == y) return;
	if(sz[x] > sz[y]) swap(x, y);
	pai[x] = y;
	sz[y] += sz[x];
}

int32_t main()
{   
	map<pair<int, int>, bool> cor;
	int n, m, k;
	
	cin >> n >> m >> k;
	
	for(int i = 0; i < n; i++)
		pai[i] = i, sz[i] = 1;
		
	for(int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v; u--; v--;
		
		if(u > v) swap(u, v);
		
		cor[{u, v}] = true;
		
		degree[u]++; degree[v]++;
		
		join(u, v);
	}
	
	for(int i = 0; i < n; i++)
		ans[i] = sz[ find(i) ] - degree[i] - 1;
	
	for(int i = 0; i < k; i++)
	{
		int u, v;
		cin >> u >> v; u--; v--;
		
		if(u > v) swap(u, v);
		
		if(cor.count({u, v})) continue;
		
		if(find(u) == find(v))
		{
			ans[u]--;
			ans[v]--;
		}
	}	
	
	for(int i = 0; i < n; i++)
		cout << ans[i] << ' ';
	puts("");
	
	
	
    return 0;
}

Measured memory_bytes: 9856
#include<iostream>
#include<vector>
#include<complex>
#include<algorithm>

using namespace std;

typedef complex<int> C;

int main() {
    int n, x, y, m, l;
    char d;
    C pos;
    vector<C> jewels;
    while (true) {
        jewels.clear();
        pos = C(10, 10);
        cin >> n;
        if (n == 0) {
            break;
        }
        for (int i=0; i<n; i++) {
            cin >> x >> y;
            jewels.push_back(C(x, y));
        }
        cin >> m;
        for (int i=0; i<m; i++) {
            cin >> d >> l;
            for (int j=0; j<l; j++) {
                switch (d) {
                    case 'N':
                        pos += C(0, 1);
                        break;
                    case 'E':
                        pos += C(1, 0);
                        break;
                    case 'W':
                        pos += C(-1, 0);
                        break;
                    case 'S':
                        pos += C(0, -1);
                        break;
                }
                for (vector<C>::iterator iter=jewels.begin(); iter!=jewels.end();) {
                    if (*iter == pos) {
                        jewels.erase(iter);
                    }
                    else {
                        iter++;
                    }
                }
            }
        }
        if (jewels.empty()) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int A[N];

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

    sort(A, A+N);

    cout << A[N-1] - A[0];    

    cout << endl;
    return 0;
}

Measured memory_bytes: 384
import collections
N = int(input())

S = [input() for i in range(N)]
table = collections.defaultdict(int)
for x in S:
    table[x] += 1

table = list(table.items())
table.sort(key=lambda x: x[1], reverse=True)
ans = []
k = table[0][1]
for x, i in table:
    if i == k:
        ans.append(x)
ans.sort()
for x in ans:
    print(x)


Measured memory_bytes: 43504
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

 
int main()
{
    int n;
    map<string, int> m;
    int cnt = 0;
    cin >> n;
    string s;
    while (n--) {
        cin >> s;
        if (!m.count(s)) {
            cnt++;
            m[s] = 1;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 19100
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABC0613
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            int ans = 0;

            if (400 <= x && x < 600) { ans = 8; }
            else if (600 <= x && x < 800) { ans = 7; }
            else if (800 <= x && x < 1000) { ans = 6; }
            else if (1000 <= x && x < 1200) { ans = 5; }
            else if (1200 <= x && x < 1400) { ans = 4; }
            else if (1400 <= x && x < 1600) { ans = 3; }
            else if (1600 <= x && x < 1800) { ans = 2; }
            else { ans = 1; }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27464
#include<iostream>
#include <vector> 
#include<string>
#include <algorithm>
#include<math.h>
#include<iomanip>
#include<time.h>
#include<stdio.h>
#include<sstream>
using namespace std;

string s;
long long a, ans;
long long N, K, n, m;
bool b;
int main(){
	cin >> N >> K;
	if (K % 2 == 1){
		n = N / K;
		cout << n*n*n << endl;
		return 0;
	}
	else{
		n = N / K;
		m = N / (K / 2);
		m -= n;
		cout << (n*n*n)+(m*m*m) << endl;
		return 0;
	}

	return 0;
}



Measured memory_bytes: 256
base1 = 1009
base2 = 1013
mask = (1 << 32) - 1
def calc_hash(f, r, c):
    global ph, pw, h
    tmp = [[0] * c for _ in range(r)]
    dr, dc = r - ph, c - pw
    t1 = 1
    for _ in range(pw):
        t1 = (t1 * base1) & mask
    for i in range(r):
        e = 0
        for j in range(pw):
            e = e * base1 + f[i][j]
        for j in range(dc):
            tmp[i][j] = e
            e = (e * base1 - t1 * f[i][j] + f[i][j + pw]) & mask
        tmp[i][dc] = e
    t2 = 1
    for _ in range(ph):
        t2 = (t2 * base2) & mask
    for j in range(dc + 1):
        e = 0
        for i in range(ph):
            e = e * base2 + tmp[i][j]
        for i in range(dr):
            h[i][j] = e
            e = (e * base2 - t2 * tmp[i][j] + tmp[i + ph][j]) & mask
        h[dr][j] = e
th, tw = map(int, input().split())
t = tuple(tuple(ord(c) for c in input()) for _ in range(th))
ph, pw = map(int, input().split())
p = tuple(tuple(ord(c) for c in input()) for _ in range(ph))
if th >= ph and tw >= pw:
    h = [[0] * tw for _ in range(th)]
    calc_hash(p, ph, pw)
    key = h[0][0] & mask
    calc_hash(t, th, tw)
    for i in range(th - ph + 1):
        for j in range(tw - pw + 1):
            if h[i][j] & mask == key:
                print(i, j)



Measured memory_bytes: 92000
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, k = LI()
    a = n - k
    if k == 1:
        print(0)
        return
    print(a)
    return

#B
def B():
    n = II()
    xy = LIR(n)
    if n == 1:
        print(1)
        return
    ans = inf
    for i in range(n):
        for k in range(n):
            if i != k:
                b = 1
                check = []
                check.append((i,k))
                p = xy[i][0] - xy[k][0]
                q = xy[i][1] - xy[k][1]
                for l in range(n):
                    for m in range(n):
                        if not((l,m) in check) and p == xy[l][0] - xy[m][0] and q == xy[l][1] - xy[m][1]:
                            b += 1
                            check.append((l, m))
                ans = min(ans, n-b)
    print(ans)

    return

#C
def C():
    m = II()
    a = LI()
    a.sort()
    check = [0] * m
    anslis = []
    ans = 0
    if m % 2:
        ans += a[m // 2]
        for i in range(m//2):
            anslis.append((a[i], a[-1 - i]))
            anslis.append((ans,-a[-1 - i]+a[i]))
            ans += a[-1 - i] - a[i]
    else:
        ans += a[m//2] - a[m//2-1]
        for i in range(m//2-1):
            anslis.append((a[i], a[-1 - i]))
            anslis.append((ans,-a[-1 - i]+a[i]))
            ans += a[-1 - i] - a[i]
    print(ans)
    for a, b in anslis:
        print(a,b)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 45960
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition) cout << "Yes" << '\n'; else{ cout << "No" << '\n'; }
#define YES(condition) if(condition) cout << "YES" << '\n'; else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition) cout << "yes" << '\n'; else{ cout << "no" << '\n'; }



int main() {
    ll n;
    cin >> n;
    for(ll i = n; i <= 999; i++){
        if(i / 100 == i / 10 % 10 && i / 100 == i % 10){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import Counter
N = int(input())
A = tuple(map(int, input().split()))

c0 = Counter()
c1 = Counter()
c2 = Counter()
for a in A:
    c0[(a+0)//3] += 1
    c1[(a+1)//3] += 1
    c2[(a+2)//3] += 1
    
print(max(max(c0.values()),
          max(c1.values()),
          max(c2.values()))) 

Measured memory_bytes: 16308