akhauriyash/Code-Regression huggingface dataset:
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int,input().split()))
    mod = 10**9+7
    
    from collections import defaultdict
    D = defaultdict(int)
    for i in A:
        D[i] += 1
    flag = 0
    for i in D:
        if i==0 and D[i] != 1:
            flag = 1
            break
        if i!=0 and D[i] != 2:
            flag = 1
            break
    if flag == 1:
        print(0)
    else:
        print(pow(2,N//2,mod))
    
    
main()

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

int main() {
  char a, b;
  cin >> a >> b;
  if (a == 'H') {
    cout << b << endl;
  } else if (a == 'D') {
    if (b == 'H') {
      cout << 'D' << endl;
    } else if (b == 'D') {
       cout << 'H' << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  ll n;
  cin >> n;
  //cout << n << endl;
  string s;
  cin >> s;
  // rep(i,n) {
  //   cout << s.at(i) << endl;
  // }

  ll count_leftclose = 0, count_rightclose = 0;

  rep(i,n) {
    if(s.at(i) == '(') count_leftclose++;
    else {
      if(count_leftclose == 0) {
        count_rightclose++;
      }
      else {
        count_leftclose--;
      }
    }
  }

  rep(i,count_rightclose) {
    cout << '(';
  }
  rep(i,n) {
    cout << s.at(i);
  }
  rep(i,count_leftclose) {
    cout << ')';
  }
  cout << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
unordered_map<long long, long long> M;

int A, B, C, D;
long long dfs(long long N)
{
	if(N == 0)
		return 0;
	if(M.count(N))
		return M[N];
	long long ret = 1e18;
	ret = min((__int128)ret, (__int128)N * D);
	ret = min(ret, dfs(N/5) + (N%5) * D + C);
	if(N % 5 >=3 && N/5 + 1 < N)
		ret = min(ret, dfs(N/5 + 1) + (5 - N % 5) * D + C);
	ret = min(ret, dfs(N/3) + (N%3) * D + B);
	if(N % 3 >=2 && N/3 + 1 < N)
		ret = min(ret, dfs(N/3 + 1) + (3 - N % 3) * D + B);
	ret = min(ret, dfs(N/2) + (N%2) * D + A);
	if(N/2 + 1 < N)
		ret = min(ret, dfs(N/2 + 1) + (2 - N%2) * D + A);
	M[N] = ret;
	return ret;
}

int main()
{
	int T;
	scanf("%d", &T);
	while(T--)
	{
		long long N;
		scanf("%lld%d%d%d%d", &N, &A, &B, &C, &D);
		M.clear();
		printf("%lld\n", dfs(N));
	}
	return 0;
}

Measured memory_bytes: 4372
#include <iostream>

using namespace std;

struct pt{
    int x, y;
};

int main()
{
    const pt figure[][3] = {{{ 1, 0}, { 0, 1}, { 1, 1}},
                            {{ 0, 1}, { 0, 2}, { 0, 3}},
                            {{ 1, 0}, { 2, 0}, { 3, 0}},
                            {{-1, 1}, { 0, 1}, {-1, 2}},
                            {{ 1, 0}, { 1, 1}, { 2, 1}},
                            {{ 0, 1}, { 1, 1}, { 1, 2}},
                            {{ 1, 0}, {-1, 1}, { 0, 1}},
    };
    char s[8][10];
    do{
        int i=0;
        for(i=0; i<8; i++) cin.getline(s[i], 10);
        int x=0, y=0;
        for(y=0; y<8; y++){
            for(x=0; x<8; x++){
                if(s[y][x]=='1') goto found;
            }
        }
        found:
        
        for(i=0; i<7; i++){
            bool match=true;
            for(int j=0; j<3; j++){
                int tx=x+figure[i][j].x;
                int ty=y+figure[i][j].y;
                if(tx<0||7<tx||ty<0||7<ty){
                    match=false;
                    break;
                }
                if(s[ty][tx]=='0'){
                    match=false;
                    break;
                }
            }
            if(match) break;
        }
        cout<<(char)('A'+i)<<'\n';
    }while(cin.getline(s[0], 10));
    return 0;
}

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

char s[102][102];

void DFS(char t,int y,int x){
    if(s[y][x]!=t)  return;
    s[y][x] = '.';
    DFS(t,y-1,x);
    DFS(t,y,x+1);
    DFS(t,y+1,x);
    DFS(t,y,x-1);
}

int main(){
    while(1){
        int x,y,ans(0);
        cin >> x >> y;
        if(x==0,y==0)   break;
        for(int i=1;i<=x;i++){
            for(int j=1;j<=y;j++){
                cin >> s[i][j];
            }
        }
        for(int i=1;i<=x;i++){
            for(int j=1;j<=y;j++){
                if(s[i][j]=='#'||s[i][j]=='*'||s[i][j]=='@'){
                    ans++;
                    DFS(s[i][j],i,j);
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b>c+d) cout<<"Left"<<endl;
  else if(a+b==c+d) cout<<"Balanced"<<endl;
  else cout<<"Right"<<endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define Intmax 1000000007
int arr[100001];
 int dp[100001];
 int fun(int n)
 {
     if(n==1 )
         return 0;
         if(n==2)
             return abs(arr[2]-arr[1]);
         if(dp[n]!=Intmax)
             return dp[n];
             
             if(n-2>=0)
              dp[n]=min(fun(n-1)+abs(arr[n]-arr[n-1]),fun(n-2)+abs(arr[n]-arr[n-2]));
              return dp[n];
 }
int main()
{
  int n;
  cin>>n;

  for(int i=1;i<=n;i++)
  {
      cin>>arr[i];
  }
  for(int i=0;i<n+1;i++)
      dp[i]=Intmax;  
      cout<<fun(n)<<endl;
	return 0;
}


Measured memory_bytes: 6688
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
l=list(Counter(lmp()).items())
ans=0
for q in l:
    if q[0]>q[1]:
        ans+=q[1]
    elif q[0]<q[1]:
        ans+=q[1]-q[0]
print(ans)

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

int main()
{
    int H, W;
    cin >> H >> W;

    vector<vector<bool>> g(H + 1, vector<bool>(W + 1));
    string S;
    for (int i = 1; i <= H; i++)
    {
        cin >> S;
        for (int j = 1; j <= W; j++)
        {
            g[i][j] = S[j - 1] == '#';
        }
    }

    vector<vector<int>> h_l(H + 2, vector<int>(W + 2, 0));
    vector<vector<int>> h_r(H + 2, vector<int>(W + 2, 0));

    for (int i = 1; i <= H; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            if (g[i][j])
            {
                h_l[i][j] = 0;
            }
            else
            {
                h_l[i][j] = h_l[i][j - 1] + 1;
            }
        }
        for (int j = W; j > 0; j--)
        {
            if (g[i][j])
            {
                h_r[i][j] = 0;
            }
            else
            {
                h_r[i][j] = h_r[i][j + 1] + 1;
            }
        }
    }

    vector<vector<int>> w_u(H + 2, vector<int>(W + 2, 0));
    vector<vector<int>> w_l(H + 2, vector<int>(W + 2, 0));
    for (int j = 1; j <= W; j++)
    {
        for (int i = 1; i <= H; i++)
        {
            if (g[i][j])
            {
                w_u[i][j] = 0;
            }
            else
            {
                w_u[i][j] = w_u[i - 1][j] + 1;
            }
        }
        for (int i = H; i > 0; i--)
        {
            if (g[i][j])
            {
                w_l[i][j] = 0;
            }
            else
            {
                w_l[i][j] = w_l[i + 1][j] + 1;
            }
        }
    }

    int ans = 0;
    for (int i = 1; i <= H; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            ans = max(ans, h_r[i][j] + h_l[i][j] + w_u[i][j] + w_l[i][j] - 3);
        }
    }
    cout << ans << endl;
}


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

int main(){
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int> ());

    if(s < t){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
}

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

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      int N;
      string S;
      cin >> N >> S;
      int ans = 1;
      for(int i = 1;i < N;i++){
          if(S.at(i) != S.at(i-1))ans++;
      }
      cout << ans << endl;
}


Measured memory_bytes: 512
a,b = map(int,input().split())
if 0 < a and 0 < b:
    print('Positive')
elif a < 0 and 0 < b:
    print('Zero')
else:
    if (b - a + 1) % 2 == 0:
        print('Positive')
    else:
        print('Negative')

Measured memory_bytes: 9176
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String s = scanner.next();
        
        if (n % 2 == 0) {
            String half = s.substring(0, n / 2);
            if (s.equals(half + half)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } else {
                System.out.println("No");
        }
    }
}

Measured memory_bytes: 21588
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	s, w := io.NextInt(), io.NextInt()
	if s <= w {
		io.Println("unsafe")
	} else {
		io.Println("safe")
	}
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1780
#include<iostream>
using namespace std;
int main(void) {
	char a[256];
	int i;
	int j;
	int b = 0;
	scanf("%s", a);
	for (i = 0; a[i] != '\0'; i++) {}

	if (i % 2 == 0) {
		for (j = 0; j < i / 2; j++) {
			if (a[j] != a[i - j - 1]) {
				b++;

			}
		}
	}
	else{
		for (j = 0; j < (i - 1) / 2; j++) {

			if (a[j] != a[i - j - 1]) {
				b++;

			}
		}
	}
	cout << b << "\n";

	return 0;
}

Measured memory_bytes: 888
import copy

h, w, k = map(int,input().split())

maze = [0]*h
for i in range(h):
    maze[i] = list(input())
    
ans = 0
for row in range(2**h):
    redr = []
    for maskr in range(h):
        if row&(1<<maskr):
            redr.append(maskr)
    ma = copy.deepcopy(maze)
    for r in redr:
        for i in range(w):
            ma[r][i] = "$"
    for col in range(2**w):
        check = copy.deepcopy(ma)
        redc = []
        for maskc in range(w):
            if col&(1<<maskc):
                redc.append(maskc)
        for c in redc:
            for i in range(h):
                check[i][c] = "$"
        tmp = 0
        for r in range(h):
            for c in range(w):
                if check[r][c] == "#":
                    tmp += 1
        if tmp == k:
            ans += 1
print(ans)

Measured memory_bytes: 72644
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(void) {
  int n;
  cin >> n;
  vector<vector<int>> a(2, vector<int>(n));
  rep(i, 2) {
    rep(j, n) {
      cin >> a[i][j];
    }
  }
  
  vector<int> a1(n);
  a1[0] = a[0][0];
  for (int i = 1; i < n; ++i) {
    a1[i] = a1[i - 1] + a[0][i];
  }
  vector<int> a2(n);
  a2[n - 1] = a[1][n - 1];
  for (int i = n - 2; i >= 0; --i) {
    a2[i] = a2[i + 1] + a[1][i];
  }

  int ans = 0;
  rep(i, n) {
    int num = a1[i] + a2[i];
    ans = max(ans, num);
  }

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

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a;
    long double b;
    cin >> a >> b;
    cout << ll(a * b);
    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;
typedef pair<int,int>P;

int main() {

  ll n;cin>>n;
  ll a[n+10],b[n+10],c[n+10];
  rep(i,0,n)cin>>a[i];
  rep(i,0,n)cin>>b[i];
  rep(i,0,n)cin>>c[i];

  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);

  ll l,r;ll ans=0;
  rep(i,0,n){
    l=lower_bound(a,a+n,b[i])-a;
    r=upper_bound(c,c+n,b[i])-c;
    ans+=l*(n-r);
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> h(n);
  REP(i,n){
    int x;
    cin >> x;
    h[i].first = x;
    h[i].second = 1;
  }

  REP(i,m){
    int a, b;
    cin >> a >> b;
    --a; --b;

    if(h[a].first > h[b].first){
      h[b].second = 0;
    }
    if(h[a].first < h[b].first){
      h[a].second = 0;
    }

    if(h[a].first == h[b].first){
      h[a].second = 0;
      h[b].second = 0;
    }

  }

  int ans = 0;
  REP(i,n) ans += h[i].second;

  // cout << endl;
  // 
  // REP(i,n) cout << h[i].first << " " << h[i].second << endl;


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


Measured memory_bytes: 3944
#include <iostream>

using namespace std;

int main(){
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    if((b-a <= k) && (c-a <= k) && (d-a <= k) && (e-a <= k) && (c-b <= k) && (d-b <= k) && (e-b <= k) && (d-c <= k) && (e-c <= k) && (e-d <= k)){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }

    return 0;
}

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

vector<int> g[100001];
long long int dp[100001][2];
long long int mod=1000000007;

void dfs(int u,int prev){
	long long int t1=1,t2=1;
	for(auto i:g[u]){
		if(i!=prev){
			dfs(i,u);
			t1 = (t1*(dp[i][1]+dp[i][0]))%mod;
			t2 = (t2*(dp[i][0]))%mod;
		}
	}
	dp[u][0]=t1;
	dp[u][1]=t2;
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif

	int n;
	cin >> n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1,-1);
	cout << (dp[1][0]+dp[1][1])%mod;

	
	




	
	




	

}


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

int main() {
	int n; cin >> n;
	set<string> s;
	string tmp;
	int l = 0;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		s.insert(tmp);
		if (l < int(s.size())) l++;
	}
	cout << l << endl;
	return 0;
}


Measured memory_bytes: 19200
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T>
void dump(vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		cout << vec[i];
		if(i+1<vec.size())cout << ' ';
		else cout << endl;
	}
	return;
}
int N;
int x[505];
int pos = 0;
vi ans;
void nxt(){
	while(pos<ans.size()&&ans[pos]!=-1)pos++;
}
int main(){
	cin >> N;
	ans = vi(N*N,-1);
	vector<P> vec;
	for(int i=0;i<N;i++){
		cin >> x[i];
		x[i]--;
		vec.pb(P(x[i],i+1));
	}
	sort(all(vec));
	for(int i=0;i<N;i++){
		int tar = vec[i].fi;
		int num = vec[i].sec;
		ans[tar] = num;
		for(int j=0;j<num-1;j++){
			nxt();
			ans[pos] = num;
		}	
		// cout << pos << ' ' << tar << endl;
		if(pos>tar){
			cout << "No" << endl;
			return 0;
		}
		// dump(ans);
	}
	for(int i=0;i<N;i++){
		int tar = vec[i].fi;
		int num = vec[i].sec;
		for(int j=num+1;j<=N;j++){
			nxt();
			if(pos<tar){
				cout << "No" << endl;
				return 0;
			}
			ans[pos] = num;
		}
	}
	cout << "Yes" << endl;
	dump(ans);
	return 0;
}



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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    string s;
    cin >> s;
    char x = s[s.size() - 1];
    if (x == '2' || x == '4' || x == '5' || x == '7' || x == '9')
        cout << "hon\n";
    else if (x == '0' || x == '1' || x == '6' || x == '8')
        cout << "pon\n";
    else
        cout << "bon\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3644
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		
		HashMap<String,Integer> map=new HashMap<>();
		
		for(int i=0;i<n;i++)
		{
			String str=s.next();
			
			map.put(str,1);
		}
		
		System.out.println(map.size());
		
	}
	
}

Measured memory_bytes: 78220
import sys
s = int(input())
a = [s]
x = 0
for i in range(1000000):
    if a[i] % 2 == 0:
        x = a[i] / 2
        if x in a:
            print(a.index(x) + 4)
            sys.exit(0)
        else:
            a.append(x)
    else:
        x = 3 * a[i] + 1
        if x in a:
            print(a.index(x) + 4)
            sys.exit(0)
        else:
            a.append(x)

Measured memory_bytes: 3060
import sys
import numpy as np


class Bit:
    def __init__(self, n, arr):
        self.size = n
        self.tree = np.array([0] + arr)
        for i in range(1, n+1):
            if i + (i & -i) < n + 1:
                self.tree[i + (i & -i)] += self.tree[i]

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def range_sum(self, l, r):
        return self.sum(r) - self.sum(l)


def main():
    n, q = map(int, sys.stdin.buffer.readline().split())
    bit = Bit(n, list(map(int, sys.stdin.buffer.readline().split())))
    for x in sys.stdin.buffer.readlines():
        q, p, x = map(int, x.split())
        if q:
            print(bit.range_sum(p, x))
        else:
            bit.add(p+1, x)


if __name__ == "__main__":
    main()


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

int main() {
	string str;
	string alpha="abcdefghijklmnopqrstuvwxyz";
	int c[26]={0};
	while(1) {
		getline(cin,str);
		if(str=="") break;
		for(int i=0; i<(int)str.length(); ++i) {
			if(str[i]>='a' && str[i]<='z') {
				++c[str[i]-'a'];
			} else if (str[i]>='A' && str[i]<='Z') {
				++c[str[i]-'A'];
			}
		}
	}
	for(int i=0; i<26; ++i) {
		cout << alpha[i] << " : " << c[i] << endl;
	}
	return 0;
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define INF 100000

int main()
{
  int n,cs;cin>>n>>cs;
  vector<int> s(n);
  vector<int> t(n);
  vector<int> c(n);
  int i,j;
  rep(i,n)cin>>s[i]>>t[i]>>c[i];
  vector<vector<bool>> tt(cs,vector<bool>(100010,false));
  int ans=0;
  rep(i,n)for(j=s[i]-1;j<=t[i]-1;j++)tt[c[i]-1][j]=true;
  rep(i,100010)
  {
    int count=0;
    rep(j,cs)if(tt[j][i])count++;
    ans=max(ans,count);
  }
  cout<<ans<<endl;
}


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

int main(void){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];
  long long ans = 0;
  for(int i = 0; i < n; i++) ans += a[i] - 1;
  cout << ans << endl;
  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)
typedef long long ll;

bool G[10][10];

int main(){
    int N, M; cin >> N >> M;
    rep(i,M){
        int a, b; cin >> a >> b; a--, b--;
        G[a][b] = G[b][a] = true;
    }

    vector<int> permutation(N);
    iota(begin(permutation), end(permutation), 0);

    int res = 0;
    do{
        if(permutation[0] != 0) break;

        bool ok = true;
        for (int i = 0; i+1 < N; i++)
        {
            int from = permutation[i];
            int to = permutation[i+1];
            if(!G[from][to]) ok = false;
        }
        if(ok) ++res;
    }while(next_permutation(begin(permutation), end(permutation)));

    cout << res << endl;
}

Measured memory_bytes: 256
number = int(input())

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

count = 0

for i in range(number):
    if array[i] % 2 == 0:
        if (array[i] % 3 != 0) & (array[i] % 5 != 0):
            count += 1

if count == 0:
    print('APPROVED')

else:
    print('DENIED')

            

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

typedef long long ll;

int main(int argc, char* argv[])
{
  std::string A, B, C;
  std::cin >> A >> B >> C;

  if (A[A.size()-1] == B[0] && B[B.size()-1] == C[0]) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }

  return 0;
}


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

string s;
int ssize, ans = 0;

int main() {
  cin >> s;
  ssize = s.size();
  for(int i = 0; i < ssize / 2; ++i)
    if(s[i] != s[ssize - 1 - i]) ++ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())

ps = list(map(lambda x: int(x) + 1, input().split()))



from collections import deque

q = deque()

tmp = sum(ps[:k])

q.append(tmp)



ps

for i in range(n-k):
    tmp = tmp - ps[i] + ps[k+i]
    q.append(tmp)



q

print(max(q)/2)

Measured memory_bytes: 72048
#include <iostream>
#define N 100

using namespace std;

main(){
  double dp[N+1][N+1];
  int n, t, l, b;
  bool L[N+1];
  bool B[N+1];

  while(1){
    cin >> n >> t >> l >> b;
    if(n==0 && t==0 && l==0 && b==0) break;

    for(int i=0;i<=t;i++){
      for(int j=0;j<=n;j++){
	dp[i][j]=0;
	L[j]=false;
	B[j]=false;
      }
    }

    for(int i=0;i<l;i++){
      int tmp;
      cin >> tmp;
      L[tmp]=true;
    }
    for(int i=0;i<b;i++){
      int tmp;
      cin >> tmp;
      B[tmp]=true;
    }
    dp[0][0]=1;
    for(int i=1;i<=t;i++){
      for(int j=0;j<=n;j++){
	if(j==n){
	  dp[i][n]+=dp[i-1][n];
	  continue;
	}
	for(int l=1;l<=6;l++){
	  int pos=j+l;
	  if(pos>n){
	    int tmp=pos-n;
	    pos=n-tmp;
	  }
	  if(L[pos] && i!=n) dp[i+1][pos]+=dp[i-1][j]/6.0;
	  else if(B[pos]) dp[i][0]+=dp[i-1][j]/6.0;
	  else dp[i][pos]+=dp[i-1][j]/6.0;
	}
      }
    }

    printf("%.6f\n", dp[t][n]);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>
 
using namespace std;
  
/********** TEMPLATE STARTS HERE ***********/
    
#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define test int t; cin >> t; while(t--)
#define skip continue
#define stop break
#define sz(v) (int)v.size()
#define endl '\n'
#define PI 3.1415926535897932384626433832795
#define EPS 1e-9
#define gcd __gcd 
#define mp make_pair
#define FO(i, a) for(auto & i : a)
#define debug(a) cout << #a << ": " << a << endl
#define debug1(a, l, r) FR(i, l, r) cout << a[i] << " "; cout << endl
#define SET(a, b) memset(a, b, sizeof(a));
#define refresh fflush(stdout);
#define digits(n) (int)(log10(n) + 1)
  
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pii> vii;
typedef vector <pll> vll;
    
const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;
    
template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
   
/*********** TEMPLATE ENDS HERE *************/

vi x;
vi y;

main() 
{
	IOS
	
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    
	x.resize(n);
	y.resize(m);
	
    for(int i = 0; i < n; i++) 
		cin >> x[i];
	
	for(int i = 0; i < m; i++)
		cin >> y[i];
	
    x.pb(X);
    y.pb(Y);
    
	sort(all(x));
	sort(all(y));
    
    if(x[n] < y[0]) 
        cout << "No War";
    else
        cout << "War";
}

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

int main(){
  /*ll a,ans,c;long double b;cin>>a>>b;
  c=(ll)(b*100);//cout<<c<<endl;
  ans=a*c;//cout<<ans<<endl;
  ans/=100;
  cout<<ans;*/

  ll ans;long double a,b;cin>>a>>b;
  ans=a*b;
  cout<<ans;
}


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

int main() {
	vector<int> A(3);
	cin >> A[0] >> A[1] >> A[2];
	sort(A.begin(), A.end());
	cout << A[2] - A[0] << endl;
	return 0;
}

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

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))

int main()
{
	int h, w, counter = 0;
	cin >> h >> w;
	vector<string> a(h);
	rep(i, 0, h - 1)
	{
		cin >> a[i];
	}
	queue<pair<int, int>> q;
	int dx[] = { 1,0,-1,0 };
	int dy[] = { 0,1,0,-1 };
	vector<string> checker(h);
	rep(i, 0, h - 1)
	{
		string s = "";
		rep(j, 0, w - 1)
		{
			s += "#";
		}
		checker[i] = s;
	}
	rep(i, 0, h - 1)rep(j, 0, w - 1)
	{
		if (a[i][j] == '#')q.push({ i,j });
	}
	while (!q.empty())
	{
		if (a == checker)
		{
			break;
		}
		vector<pair<int, int>> vec;
		while (!q.empty())
		{
			int y = q.front().first;
			int x = q.front().second;
			vec.push_back({ y,x });
			q.pop();
		}
		rep(i, 0, vec.size() - 1)
		{
			rep(j, 0, 3)
			{
				int ny = vec[i].first + dy[j];
				int nx = vec[i].second + dx[j];
				if (0 <= ny && ny < h && 0 <= nx && nx < w && a[ny][nx] == '.')
				{
					a[ny][nx] = '#';
					q.push({ ny,nx });
				}
			}
		}
		++counter;
	}
	cout << counter << endl;
}

Measured memory_bytes: 16364
program wlw;
var
    k, i, a, b : longint;
    found : boolean;
begin
    readln(k);
    readln(a, b);
    found := false;
    for i := a to b do begin
        if i mod k = 0 then
            found := true;
    end;
    if not(found) then
        writeln('NG')
    else 
        writeln('OK')
    
end.

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

int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	int cnt=0,i;
	do{
		for(i=0;i<n;i++)
		if(a[i]%2==1){
			cout<<cnt;
			return 0;
		}
		else
		a[i]=a[i]/2;
		cnt++;
	}while(1);
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<map>
#include<cassert>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
typedef long long ll;
const ll mod = 1000000009;
const int N = 200000;

int deg[N];
int size[N];
bool isdel[N];
int f[N],t[N];

main(){
  int n,m;
  while(cin>>n>>m){
    ll ans=0,num=1;
    rep(i,n)isdel[i]=false,deg[i]=0,size[i]=1;
    rep(i,m){
      cin>>f[i]>>t[i];
      f[i]--;t[i]--;
      deg[f[i]]++;
      deg[t[i]]++;
      if (f[i] > t[i])swap(f[i],t[i]);
    }
    rep(i,m){
      int &now=f[i],&next=t[i];//now < next
      if (deg[now] > deg[next])isdel[now]=true;
      else if (deg[now] == deg[next])isdel[next]=true,size[now]++;
      else if (deg[now] < deg[next])isdel[next]=true;
    }
    rep(i,n){
      if (isdel[i])continue;
      else ans++,num=(num*size[i])%mod;
    }
    cout << ans <<endl << num<<endl;
#ifdef DEBUG
    cout << "end"<< endl;
#endif
  }
}

Measured memory_bytes: 3280
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from collections import deque
from collections import Counter
import bisect
def main():
    S_ = S()
    if S_[-1] == 's':
        S_ += 'es'
    else:
        S_ += 's'
    print(S_)
if __name__ == "__main__":
    main()



Measured memory_bytes: 68384
import sys,collections
input = sys.stdin.readline

s = input().rstrip()
K = int(input())
ls = len(s)
cs = collections.deque()
for i in range(ls):
    for j in range(i+1,i+1+K):
        cs.append(s[i:j])
os = sorted(cs)
count = 0
lis = []
for i in os:
    if i not in lis:
        lis.append(i)
        count +=1
    else:
        continue
    if count == K:
        print(i)
        exit()
    

Measured memory_bytes: 76136
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int result = 1;
        if (a+b == 3) {
           result = 3;
        } else if (a+b == 4) {
           result = 2;
        }
        
        System.out.println(result);
    }
}


Measured memory_bytes: 35876
#include<stdio.h>

int main (void){

  int n,i;
  int year,month,day;
  int countd;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d",&year,&month,&day);
    countd = 0;
    
    if(999-year == 0){
      countd += 0;
    }else if(999-year !=0){
             if((999-year)%3 == 1){
	       countd += 590*((999-year)/3)+200;
	     }else if((999-year)%3 == 2){
	       countd += 590*((999-year)/3)+395;
	     }else if((999-year)%3 == 0){
	       countd += 590*((999-year)/3);
	     }
    }
    
    if(year%3 != 0){
      if((10-month)%2 == 1){
	countd += 39*((10-month)/2)+20;
      }else if((10-month)%2 == 0){
	countd += 39*((10-month)/2);
      }
      
      if(month%2 == 1){
	countd += 20-day;
      }else if(month%2 == 0){
	countd += 20-day;
      }
    }else{
      countd += 20*(10-month);
    
      countd += 21-day;
    }

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

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#include <set>

using namespace std;

string s[5000];
int n, l;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> l;
    for (int i = 0; i < n; i++) cin >> s[i];
    sort(s, s + n);
    for (int i = 0; i < n; i++) cout << s[i];
}


Measured memory_bytes: 384
n = int(input())
s = input()
MOD = 10 ** 9 + 7

t = [0 for i in range(26)]

for i in range(n):
    t[ord(s[i]) - ord("a")] += 1

ans = 1
for i in range(26):
    if t[i] == 0:
        continue
    if t[i] == 1:
        ans *= 2
    elif t[i] > 1:
        ans *= t[i] + 1

print((ans-1) % MOD)
    

Measured memory_bytes: 3188
N = int(input())
A = [int(x) for x in input().split()]
B = [0] * N
x = sum(A)
y = 0
ret = abs(sum(A)- A[0] - A[0] )
for i, a in enumerate(A[:-1]):
  y += a
  x -= a
  ret = min(ret, abs(x - y))
print(ret)

Measured memory_bytes: 23800
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a,b;
  cin >> a >> b;
  int C=0;
  for(int i=0;i<a.size();i++){
    if(a[i] != b[i]){
      C++;
    }
  }
  cout << C << endl;
}


Measured memory_bytes: 3848
#include<bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
unsigned long long int a,b,x;
int main(){
    speed;
    cin >> a >> b >> x;
    if(a == 0 && b == 0) cout << 1 << endl;
    else if(a == 0) cout << b / x + 1 << endl;
    else cout << b / x - (a - 1) / x << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using ll = unsigned long long int;
using namespace std;

int main() {
    fastIO;
    int n;
    cin >> n;

    do {
        double t = (int)sqrt(n);
        if (t * t == n) {
            cout << n << endl;
            return 0;
        }
    } while (n--);
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	int x = n * 800;
	int y = (n / 15) * 200;
	cout << x - y << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n;cin>>n;
    int res=INF;
    for(int i=0;i<n;i++){
        ll a;cin>>a;
        int cnt=0;
        while(true){
            if(a%2) break;
            cnt++;
            a/=2;
        }
        res=min(res,cnt);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    string t = "CODEFESTIVAL2016";
    for (int i = 0; i < 16; i++) {
        if (s[i] != t[i]) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
/* "It's okay if you hate me. I hate me too." */

#include <bits/stdc++.h>

using namespace std;

char a[102], b[102];
int lenA, lenB;

int main() {
	scanf(" %s %s", a, b);
	lenA = strlen(a);
	lenB = strlen(b);
	if (lenA < lenB) { puts("LESS"); return 0; }
	if (lenA > lenB) { puts("GREATER"); return 0; }

	for (int i = 0; i < lenA; ++i) {
		if (a[i] < b[i]) { puts("LESS"); return 0; }
		if (a[i] > b[i]) { puts("GREATER"); return 0; }
	}
	puts("EQUAL");
	return 0;
}

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

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1) - 1e9*300-1;
const int inf = -1*((1<<31)+1);

using namespace std;

ll A[303][303];
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<vector<bool>> A_n(N,vector<bool>(N));
	rep(i,N)rep(j,N){
		cin >> A[i][j];
	}
	rep(k,N)rep(i,N)rep(j,N){
		if(A[i][j] > A[i][k] + A[k][j]){
			cout << -1 << endl;
			return 0;
		}
		if(A[i][j] == A[i][k] + A[k][j] && A[i][k] > 0 && A[k][j] > 0){
			A_n[i][j] = true;//辺(i,j)と(j,i)は使わなくてok
		}
	}
	ll ans = 0;
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			if(A_n[i][j] == false){
				ans += A[i][j];
			}
		}
	}
	cout << ans/2LL << endl;
	
}

Measured memory_bytes: 1024
n=int(input())


L=[3,5,7]

def dfs(s):
    count=0
    for i in L:
        p=s*10+i
        if p<=n:
            if set([int(j) for j in str(p)])==set(L):
                count+=dfs(p)+1 #条件を満たしているので+1
            else:
                count+=dfs(p)
    return count

print(dfs(0))

Measured memory_bytes: 3064
#include <iostream>

int main() {
	int x=1;
	int y=0;
	while (true){
		std::cin>>x;
		std::cin>>y;
		if (x==0 && y==0){
			break;
		}
		if ( x > y ){
			std::swap(x,y);
		}
		std::cout << x <<" " << y << std::endl;
		
	}
	return 0;
}

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

int main()
{
  int n;
  cin>>n;
  int s[110];
  for (int i = 0; i < n;i++){
    cin >> s[i];
  }
  int res[110] = {0};
  for(int i=0;i<n;i++){
    res[s[i]]++;
  }
  int count = 0;
  for (int i = 1; i <= 100;i++){
    if(res[i])
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
N, C = [int(_) for _ in input().split()]

MT = (10 ** 5 + 10)

memo = [[0] * C for _ in range(MT)]

stc = sorted([[int(_) for _ in input().split()] for _ in range(N)])
for s, t, c in stc:
    if memo[s][c - 1] < 0:
        memo[s][c - 1] = 0
    else:
        memo[s - 1][c - 1] += 1
    memo[t][c - 1] -= 1
ans = 0
cnt = 0
for i in range(MT):
    cnt += sum(memo[i])
    ans = max(ans,cnt)
print(ans)


Measured memory_bytes: 124012
import sys

sys.setrecursionlimit(200000)

v, e = map(int, input().split())

edges = [set() for _ in range(v)]

for _ in range(e):
    s, t = map(int, input().split())
    edges[s].add(t)
    edges[t].add(s)

prenum = [None] * v
parent = [None] * v
lowest = [None] * v
counter = 0
bridges = set()

def dfs(cur, prev):
    global counter
    prenum[cur] = lowest[cur] = counter
    counter += 1
    for edge in edges[cur]:
        if prenum[edge] is not None:
            if edge != prev:
                lowest[cur] = min(lowest[cur], prenum[edge])
            continue
        parent[edge] = cur
        dfs(edge, cur)
        lowest[cur] = min(lowest[cur], lowest[edge])
    if prenum[cur] == lowest[cur]:
        bridges.add((cur, prev) if cur < prev else (prev, cur))
 
 
dfs(0, -1)
 
for bridge in sorted(bridges)[1:]:
    print(*bridge)

Measured memory_bytes: 25168
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()
    X = [0] * N
    Y = [0] * N
    for i in range(N):
        x, y = MI()
        X[i], Y[i] = x, y

    dct = defaultdict(int)
    for i in range(N):
        for j in range(N):
            if i == j: continue
            xi, yi = X[i], Y[i]
            xj, yj = X[j], Y[j]

            dct[(xi-xj, yi-yj)] += 1
    # print(dct)
    mx = 0
    for d in dct.values():
        mx = max(mx, d)
    print(N - mx)


if __name__ == '__main__':
    solve()



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

int main(){
   int N,result = 0;
   cin>>N;
   int A[N];
   for(int i = 0;i < N;i++)cin>>A[i];
   for(int i = 0;i < N;i++){
       for(int j = i+1;j < N;j++)result += A[i]*A[j];
   }
   cout<<result;
}



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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int x, y, z; cin >> x >> y >> z;

    int x_a = x - 2 * z;

    if (x_a < y) {
        puts("0");
    } else {
        int ans = 0;

        int x_b = x_a - y;
        ++ans;

        ans += x_b / (y + z);

        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    deque<int> d;
    rep(i, n) {
        if (i % 2)
            d.push_front(a[i]);
        else
            d.push_back(a[i]);
    }
    if (n % 2)
        reverse(d.begin(), d.end());
    rep(i, n) cout << d[i] << endl;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	char s;
	int f=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>s;
		if (s=='Y')
		{
			f=1;
		}
	}
	if (f)
	{
		cout<<"Four\n";
	}
	else
	{
		cout<<"Three\n";
	}
	return 0;
}


Measured memory_bytes: 256
from heapq import *
import sys
input = sys.stdin.buffer.readline
n, m, s = map(int, input().split())
lim = 2510
di = [[float("inf")] * lim for _ in range(n)]
di[0][min(s,lim-1)] = 0
con = [[] for _ in range(n)]
for _ in range(m):
	u, v, a, b = map(int, input().split())
	con[u - 1].append((v - 1, a, b))
	con[v - 1].append((u - 1, a, b))
q = [(0, min(s,lim-1), 0)]
cd = [list(map(int, input().split())) for _ in range(n)]
while q:
	time, have, cur = heappop(q)
	if di[cur][have] < time:
		continue
	c, d = cd[cur]
	if have + c < lim and di[cur][have + c] > time + d:
		di[cur][have + c] = time + d
		heappush(q, (time + d, have + c, cur))
	for nxt, dh, dt in con[cur]:
		if have >= dh and di[nxt][have - dh] > time + dt:
			di[nxt][have - dh] = time + dt
			heappush(q, (time + dt, have - dh, nxt))
for p in di[1:]:
	print(min(p))


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

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

    if( A%3==0 or B%3==0 or (A+B)%3==0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,int> mp;
int pos=0;
int back=0; 
int dfs(int i, vector<int> adj[]){
    
    if(adj[i].size()==0)
        return 0;
    
    int maximumdepth=0;
    for(int j=0;j<adj[i].size();j++){

            if(mp.find(adj[i][j]) != mp.end() )
            {
                maximumdepth = max(maximumdepth, 1 + mp[adj[i][j]]);
            }
            else{
                maximumdepth = max(maximumdepth, 1+dfs(adj[i][j],adj));
            }
          
     
    }
    mp[i]=maximumdepth;
    return maximumdepth;
    
}
int main(){
    
    int n,m; cin>>n>>m;
    vector<int> adj[n];
    int visited[n]={0};
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        adj[a-1].push_back(b-1);
    }
    int globmax=0;
    for(int i=0;i<n;i++){
      if(mp.find(i) == mp.end() ){
          dfs(i,adj);
      }
    }
    for(int i=0;i<n;i++)
        globmax=max(globmax,mp[i]);
    cout<<globmax<<endl;
}

Measured memory_bytes: 14208
#include <iostream>
#include <vector>
using namespace std;
int n,m;
const int maxn = 100010;
int a[maxn];
vector<int> g[maxn];
bool vis[maxn];
int group[maxn],nGroup;
void dfs(int u)
{
	vis[u] = 1; 
	group[u] = nGroup;
	for(int i = 0;i < g[u].size(); ++i)
	{
		int v = g[u][i];
		if(!vis[v]) 
		{
			dfs(v);
		}
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i = 1;i <= n; ++ i) 
	{
		cin>>a[i];
	}
	for(int i = 1;i <= m; ++i)
	{
		int x,y; 
		cin>>x>>y;
		g[x].push_back(y); 
		g[y].push_back(x);
	}
	for(int i = 1;i <= n; ++i)
	{
		if(!vis[i]) 
		{
			nGroup++;
			dfs(i);
		}
	}
	int ans = 0;
	for(int i = 1;i <= n; ++i) 
	{
		if(group[i] == group[a[i]]) 
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0 ;
}

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

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

const long long INF = 1LL << 60;

int main() {
	int n, k;
	cin >> n >> k;
	vector<long long> h(100010);
	vector<long long> dp(100010);

	for (int i = 0; i < n; i++) cin >> h[i];
	for (int i = 0; i < 100010; i++) dp[i] = INF;

	dp[0] = 0;

	for (int i = 1; i < n; i++) {
		for (int j = 1; j <= k; j++) {
			if (i >= j) {
				chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
			}
		}
	}
	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1792
ab =[0,0,0,0]
for i in range(3):
    a,b = map(int,input().split())
    for j in range(1,5):
        if a == j or b == j:
            ab[j-1] += 1
ab.sort()
if ab[2] == 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 38384
main = do
  [n, x] <- map read . words <$> getLine :: IO [Int]
  ls <- map read . words <$> getLine :: IO [Int]
  print $ f 1 0 x ls

f :: Int -> Int -> Int -> [Int] -> Int
f answer d x ls
  | ls == [] = answer
  | d + head ls <= x = f newAns newD x newLs
  | otherwise = answer
  where
    newAns = answer + 1
    newD = d + head ls
    newLs = tail ls


Measured memory_bytes: 892