akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXSIZE 10000000;

const int MAX = 510000;
const int MOD = 1000000007;
ll dp[100001][101] = {0};

int main(){
    int N,W;
    int w[101];
    int v[101];

    cin >>N>>W;

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

    for(int i = 0; i < 100001; i++){
        dp[i][0] = 0;
    }

    dp[0][0] = 0;

    for(int i = 0; i <= W;i++){
        for(int j = 0; j < N; j++){
            if(i >= w[j])dp[i][j+1] = max(dp[i][j], dp[i-w[j]][j] + v[j]);
            else dp[i][j+1] = dp[i][j];
        }
    }

    cout <<dp[W][N]<<endl;

    return 0;
}

/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;

bool comp(const pair<int,int> a, const pair<int,int> b) {
    return a.second < b.second;
}

ll gcd(ll a,ll b){
  if(a%b == 0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}


*/


Measured memory_bytes: 79104
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define has_str(s, c)	((s).find(c) != string::npos)
typedef long long ll;
int main() {
#ifdef online_judge
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n;
    cin >> n;
    cout << (n - 2) * 180 << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, j, a=0, ab=0, b=0, ab_d=0, ans;
    string s[10001];

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> s[i];
    }

    for(i=1; i<=N; i++){
        if(s[i][0]=='B' && s[i][s[i].size()-1]=='A') ab_d++;
        else if(s[i][0]=='B') b++;
        else if(s[i][s[i].size()-1]=='A') a++;
        
        if(s[i].size() >= 2){
            for(j=0; j<s[i].size()-1; j++){
                if(s[i][j]=='A' && s[i][j+1]=='B'){
                    ab++;
                }
            }
        }
    }

    ans = ab;

    if(ab_d == 0){
        ans += min(a,b);
    }

    else{
        if(a+b>0){
            ans += ab_d+min(a,b);
        }

        else{
            ans += ab_d-1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int fmxbit(ll B){
    int cnt = 0;
    while(B!=0){
        B/=2;
        cnt++;
    }
    return cnt;
}


int main (){
    ll A, B; cin >> A >> B;
    int mxbit = fmxbit(B);
    
    vector<int> each_bit(mxbit);
    for(int i=1; i<=mxbit; i++){
        ll num = 0;
        if(i==1){
            if(A%2==0){
                if((B-A+1)/2%2==0) num = 0;
                else num = 1;
            }else{
                if((B-A)/2%2==0) num = 1;
                else num = 0;
            }
            
            
            
        }else{
            
            if(A%(ll)pow(2, i) < (ll)pow(2, i-1)){
                
            }else{
                num += (ll)pow(2, i) - A%(ll)pow(2, i);
            }
            if(B%(ll)pow(2, i) < (ll)pow(2, i-1)){
                
            }else{
                num += B%(ll)pow(2, i) % (ll)pow(2, i-1) + 1;
            }
            
        }

        if(num%2) each_bit[i-1] = 1;
    }
    
    ll ans = 0;
    for(int i=0; i<mxbit; i++){
        if(each_bit[i]) ans += (ll)pow(2, i);
    }
    cout << ans << endl;
    return 0;
}



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

class Dice{
  int T,S,E,W,N,D;

  public:
  Dice(int T, int S, int E,
      int W, int N, int D)
    : T(T), S(S), E(E),
    W(W), N(N), D(D) {}

  int get_top() { return T; }
  int get_south(){ return S; }
  int get_east() { return E; }
  int get_west() { return W; }
  int get_down() { return D; }

  void rot(char c){
    int tmp;
    tmp = T;
    switch(c){
      case 'N':
        T = S; S = D; D = N; N = tmp;
        break;
      case 'S':
        T = N; N = D; D= S; S = tmp;
        break;
      case 'E':
        T = W; W = D; D = E; E = tmp;
        break;
      case 'W':
        T = E; E = D; D = W; W = tmp;
        break;
    }
  }

  void twist(char c){
    int tmp;
    tmp = S;
    switch(c){
      case 'R':
        S = E; E = N; N=W; W=tmp;
        break;
      case 'L':
        S = W; W = N; N=E; E=tmp;
        break;
    }
  }

  bool operator==(Dice &other)
  {
    if(T==other.T &&
       S==other.S &&
       E==other.E &&
       W==other.W &&
       N==other.N &&
       D==other.D)
    {
      return true;
    }else
    {
      return false;
    }
  }
};

int main(){
  int num[6];
  for(int i=0;i<6;i++) cin>>num[i];
  Dice dice(num[0],num[1],num[2],num[3],num[4],num[5]);
  for(int i=0;i<6;i++) cin>>num[i];
  Dice dice2(num[0],num[1],num[2],num[3],num[4],num[5]);

  bool eq=false;

  for(int i=0;i<4;i++)
  {
    for(int j=0;j<4;j++)
    {
      dice2.rot('E');
      if(dice==dice2) eq=true;
    }
    dice2.rot('S');
  }
  for(int i=0;i<4;i++)
  {
    for(int j=0;j<4;j++)
    {
      dice2.rot('E');
      if(dice==dice2) eq=true;
    }
    dice2.twist('R');
  }
  
  if(eq)
  {
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  return 0;

}

Measured memory_bytes: 3100
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

s = input()
cnt1 = 0
for i, j in enumerate(s):
    if (i+1)&1:
        if j=='1':
            cnt1 += 1
    else:
        if j=='0':
            cnt1 += 1

print(min(cnt1, len(s)-cnt1))

Measured memory_bytes: 9132
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a*b % 2 == 0) {
			System.out.println("Even");
		}else {
			System.out.println("Odd");
		}

	}

}


Measured memory_bytes: 21844
/*
* @Author: patan
* @Date:   2019-08-10 17:49:12
* @Last Modified by:   patan
* @Last Modified time: 2019-08-10 20:29:50
*/
import java.io.*;
import java.util.*;
 
public class Main {
	static class Pair{
		public int a,b;
		public Pair(int x,int y)
		{
			a=x;b=y;
		}
	}
	public static void main(String[] args)throws IOException {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
		int n = in.nextInt();
		int m = in.nextInt();
		Pair arr[] = new Pair[n];
		int a,b;
		for(int i=0;i<n;i++)
		{
			a=in.nextInt();
			b=in.nextInt();
			arr[i]=new Pair(a,b);
		}
		Arrays.sort(arr,(x,y)->x.a-y.a);
		PriorityQueue<Pair> pq = new PriorityQueue<Pair>((x,y)->y.b-x.b);
		int pos=m-1;
		long ans=0;
		int i=0;
		while(pos>=0)
		{
			// if(i<n)
			// 	pos=Math.min(pos,m-arr[i].a);
			// if(pos<0)
			// 	break;
			while(i<n)
			{
				if(m-(arr[i].a)<pos)
					break;
				pq.add(arr[i]);
				i++;
			}
			pos--;
			// if(pq.size())
			if(pq.size()!=0)
				ans+=pq.poll().b;
		}
		out.println(ans);
        out.close();
	}
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }

}

Measured memory_bytes: 44904
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  x=I()
  a=100

  ans=1
  while True:
    a*=1.01
    a=int(a)
    if a>=x:
      return ans
    ans+=1

# main()
print(main())


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

struct Edge{int node, id;};//Edge(辺)のノードと  Edge(辺)の色
vector<vector<Edge>> tree;
//↑↑nodeの1次元目にノード番号1,2,3,...N(1次元目はスカラーでもよいか??)
//↑↑nodeの2次元目に各ノードに接続するノード番号のベクトルを追加していく
//↑↑idはedge(枝)の色情報をfpsの順で決定していく(2次元目にしか値は入らないかな??)つまりnodeの2次元目とセットで入る
vector<int> ans2;//i番目の辺の色を表す整数c_iのベクトル

void dfs(int arg_node1, int arg_color = -1, int arg_node2 = -1){//arg_colorはarg_node1とarg_node2のedge(辺)の色
  int painting_color = 1;//edge(辺)の色を1から塗っていく
  for(int i=0; i < tree.at(arg_node1).size(); i++){//edge(辺)に色を塗っていくループ
    int node2 = tree.at(arg_node1).at(i).node, id = tree.at(arg_node1).at(i).id;
    if(node2 == arg_node2) continue;
    if(painting_color == arg_color) painting_color++;//親の辺と同じ色は塗れないので+1
    ans2.at(id) = painting_color;         painting_color++;
    //↑↑i番目の辺の色を表す整数を確定したので代入  //↑↑同じ色は塗れないので+1
    
    //ans2.at(id) = painting_color;//i番目の辺の色を表す整数を確定したので代入
    //painting_id++;//同じ色は塗れないので+1

    dfs(node2, ans2.at(id), arg_node1);//dfsでどんどん下を見ていく
  }
}

int main() {
  int N;
  cin >> N;
  tree.resize(N);
  for(int id=0; id<N-1; id++){//木の情報を取得するためにN-1回ループ 
    int a, b;
    cin >> a >> b;
    a--, b--; //0から開始にするためにマイナス1
    tree.at(a).push_back((Edge){b, id});//ノードaはノードbとくっついている
    tree.at(b).push_back((Edge){a, id});//ノードbはノードaとくっついている
  }
  /*//nodeが取得できているか確認
  for(int i=0; i<tree.size(); i++){
    cout << endl;
    cout << i+1 << " :  " ;
    for(int j=0; j<tree.at(i).size() ; j++){
       cout << tree.at(i).at(j).node+1 << " ";
    }
  }
  cout << endl;
  */
  int ans1 = 0;//使用する色の数K
  for(int i=0; i<tree.size(); i++) ans1 = max(ans1, (int)tree.at(i).size());
  cout << ans1 << endl;
  
  ans2 = vector<int>(N-1);//これやらないと、dfsの中でout_of_rangeが出る
  dfs(0);//木の根(0)からdfsで色を塗っていく
  for(int i=0; i<ans2.size(); i++) cout << ans2.at(i) << endl;
}


Measured memory_bytes: 8320
#include<stdio.h>
#define LEN 100
void print(int N,int A[]){
  for(int i = 0; i < N; i++){
    if(i < (N - 1) ){
      printf("%d ",A[i]);
    }else{
      printf("%d",A[i]);
    }
  }
  putchar('\n');
}
int bubble(int N,int A[]){
  int flag = 1;
  int cnt = 0;
  while(flag==1){
    flag = 0;
    for(int j = N - 1; j > 0; j--){
      if(A[j] < A[j - 1]){
        cnt++;
        int temp = A[j];
        A[j] = A[j - 1];
        A[j - 1] = temp;
        flag = 1;
      }
    }
  }
  return cnt;
}

int main(){
  int N;
  scanf("%d",&N);
  int A[LEN];
  for(int i = 0; i < N; i++){
    scanf("%d",&A[i]);
  }

  int cnt = bubble(N,A);
  print(N,A);
  printf("%d\n",cnt);
}



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

int n, a[1000005], b, ans;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> b;
        a[b]++;
    }
    for (int i = 1; i <= 1000000; i++){
        if (a[i] == 0) continue;
        for (int j = i*2; j <= 1000000; j += i){
            a[j] = 0;
        }
        if (a[i] == 1) ans++;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 7536
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
vector<int> et[100000];
vector<int> ec[100000];
int color[100000];

void dfs(int p, int v, int dep) {
	color[v] = dep % 2;
	int i;
	rep(i, et[v].size()) {
		int nv = et[v][i];
		if (nv == p) continue;
		dfs(v, nv, dep + ec[v][i]);
	}
}

signed main() {
	int i;
	
	cin >> n;
	rep(i, n - 1) {
		int u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		et[u].push_back(v);
		ec[u].push_back(w);
		et[v].push_back(u);
		ec[v].push_back(w);
	}
	
	dfs(-1, 0, 0);
	
	rep(i, n) {
		cout << color[i] << endl;
	}
	return 0;
}

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

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

  string S;
  int N = 0;

    for(int i = A; i < B+1; i++){
        S = to_string(i);
        reverse(S.begin(), S.end());
        if (to_string(i) == S){
            N += 1;
        }
    }

    cout << N << endl; 
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 998244353;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, A;
    cin >> H >> A;
    if(H%A!=0)cout << (H / A)+1 << endl;
    else cout << H / A << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

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

		final int n = sc.nextInt();

		for (int i = 0; i < n; i++) {
			char[] order = new StringBuilder(sc.next()).reverse().toString()
					.toCharArray();
			StringBuilder input = new StringBuilder(sc.next());

			for (char o : order) {
				//System.out.println(input);

				if (o == 'J') {
					if (input.length() != 1) {
						input.insert(0, input.charAt(input.length() - 1))
								.deleteCharAt(input.length() - 1);
					}
				} else if (o == 'C') {
					if (input.length() != 1) {
						input.append(input.charAt(0)).deleteCharAt(0);
					}
				} else if (o == 'E') {
					if (input.length() != 1) {
						CharSequence sb1 = input.subSequence(input.length()
								- input.length() / 2, input.length());
						CharSequence sb2 = input.subSequence(0,
								input.length() / 2);

						StringBuilder s = new StringBuilder();
						if (input.length() % 2 == 1) {
							s.append(input.charAt(input.length() / 2));
						}
						s.insert(0, sb1);
						s.append(sb2);

						input = s;
					}
				} else if (o == 'A') {
					input.reverse();
				} else if (o == 'P') {
					StringBuilder tmp = new StringBuilder();
					char[] array = input.toString().toCharArray();
					for (char c : array) {

						if ('0' <= c && c <= '9') {
							tmp.append((char) ((c - 1) < '0' ? '9' : (c - 1)));
						} else {
							tmp.append(c);
						}
						// System.out.println(tmp);
					}
					input = tmp;
				} else if (o == 'M') {
					StringBuilder tmp = new StringBuilder();
					char[] array = input.toString().toCharArray();
					for (char c : array) {
						if ('0' <= c && c <= '9') {
							tmp.append((char) ((c + 1) > '9' ? '0' : (c + 1)));
						} else {
							tmp.append(c);
						}
					}
					input = tmp;
				}
			}

			System.out.println(input);
		}
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N, K;
  cin >> N >> K;
  
  f80 ans = 0;
  rep(i,1,N+1){
    i64 score = i;
    i64 count = 0;
    while(score<K){
      score *= 2;
      count++;
    }
    ans += pow(0.5,count)/N;
  }
  cout << ans << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 384
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = input()
k = int(input())
ans = []
for i in range(1, k + 1):
    memo = []
    for j in range(len(s) - i + 1):
        memo.append(s[j:j + i])
    ans += list(set(memo))
print(sorted(ans)[k - 1])


Measured memory_bytes: 4208
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;

deque<pair<int, int>> deq;

bool checker(vector<string>& grid, vector<vector<bool>>& visit, pair<int, int> posi) {
    int H = grid.size(), W = grid[0].size();
    if (posi.first<0 || posi.first>H - 1 || posi.second<0 || posi.second>W - 1)
        return false;
    if (visit[posi.first][posi.second])
        return false;

    return true;

}

void dis_deci(vector<string>& grid, vector<vector<int>>& cost, vector<vector<bool>>& visit) {
    pair<int, int> x = deq.front();
    deq.pop_front();
    int H = grid.size(), W = grid[0].size();
    int flag = 0;
    vector<int> tate = { 0,1 }, yoko = { 1,0 };
    for (int i = 0; i < 2; i++) {
        pair<int, int> y = make_pair(x.first + tate[i], x.second + yoko[i]);
        if (checker(grid, visit, y)) {
            
            if (grid[x.first][x.second] == '.') {
                if (grid[y.first][y.second] == '#') {
                    cost[y.first][y.second] = min(cost[y.first][y.second],cost[x.first][x.second] + 1);
                    deq.push_back(y);
                }
                else {
                    visit[y.first][y.second] = true;
                    cost[y.first][y.second] = min(cost[y.first][y.second],cost[x.first][x.second]);
                    deq.push_front(y);
                }
            }

            else {
                visit[y.first][y.second] = true;
                cost[y.first][y.second] = min(cost[y.first][y.second],cost[x.first][x.second]);
                deq.push_front(y);
            }
        }
        if (y.first == H - 1 && y.second == W - 1) {
            flag = 1;
            break;
        }
    }
    //cout << x.first << "  " << x.second;
    //cout << "  " << cost[x.first][x.second] << endl;
    if (flag) {
        while (!deq.empty()) {
            deq.pop_back();
        }
        return;
    }
    else dis_deci(grid, cost, visit);
}

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

    vector<string> grid(H);
    vector<vector<int>> cost(H, vector<int>(W,1e7));
    vector<vector<bool>> visit(H, vector<bool>(W));
    for (int i = 0; i < H; i++)
        cin >> grid[i];

    cost[0][0] = 0;
    deq.push_back(make_pair(0, 0));
    dis_deci(grid, cost, visit);
    
    int add = 0;
    if (grid[0][0] == '#')add++;
    cout << cost[H - 1][W - 1] + add << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }
ll s(ll x, ll c, ll d)
{
    return x - x/ c - x/d + x/(lcm(c, d));
}
void solve()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << s(b, c, d) - s(a-1, c, d);
}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


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

struct node{
    ll x,y;
}a[N];

void solve()
{
    ll n; scanf("%lld",&n);
    for(int i=1;i<=n;i++) scanf("%lld%lld",&a[i].x,&a[i].y);
    ll mx1,mx2,mi1,mi2;
    mx1=mi1=a[1].x-a[1].y;
    mx2=mi2=a[1].x+a[1].y;
    for(int i=2;i<=n;i++)
    {
        mx1=max(a[i].x-a[i].y,mx1);
        mi1=min(a[i].x-a[i].y,mi1);
        mx2=max(a[i].x+a[i].y,mx2);
        mi2=min(a[i].x+a[i].y,mi2);
    }
    printf("%lld\n",max(mx1-mi1,mx2-mi2));
}

int main()
{
    int TTT=1; //scanf("%d",&TTT);
    while(TTT--){solve();}
    return 0;
}

Measured memory_bytes: 6944
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int f(int n) {
    if(n % 2 == 0) {
        return (int)(n / 2);
    }
    else{
        return 3 * n + 1;
    }
}

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

    int a[1000000] = {0};
    a[1] = s;
    int hist[1000000] = {0};
    hist[a[1]] = 1;

    int i = 2;
    int j;
    while(1){
        a[i] = f(a[i-1]);
        if(hist[a[i]] == 1) {
            printf("%d\n", i);
            return 0;
        }
        else{
            hist[a[i]] = 1;
        }
        i++;
    }
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

signed main() {
    ll N;
    cin>>N;
    vector<ll> X(N), Y(N);
    bool even=false, odd=false;
    rep (i,0,N) {
        cin>>X[i]>>Y[i];
        if (abs(X[i]+Y[i])%2 == 0) {
            even=true;
        } else {
            odd=true;
        }
    }
    if (odd && even) {
        cout<<-1<<endl;
        return 0;
    }
    vector<ll> d;
    for (ll i=31; i>=0; i--) {
        d.push_back(1ll << i);
    }
    if (even) {
        d.push_back(1);
    }

    cout<<d.size()<<endl;
    for (auto e : d) {
        cout<<e<<endl;
    }

    rep(i,0,N){
        string ans="";
        for (auto e: d){
            if (abs(X[i]) > abs(Y[i])) {
                if (X[i] > 0) {
                    // Right
                    ans += "R";
                    X[i] -= e;
                } else {
                    // Left
                    ans += "L";
                    X[i] += e;
                }
            } else {
                if (Y[i] > 0) {
                    // Up
                    ans += "U";
                    Y[i] -= e;
                } else {
                    // Down
                    ans += "D";
                    Y[i] += e;
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void){
    int a[100][100];
    int b[100][100];
    long c[100][100];
    char buf[601];
    char* p_buf;
    int i,j,k,n,m,l;

    scanf("%d %d %d",&n,&m,&l);
    getchar();

    for(i=0;i<n;i++){
        gets(buf);
        p_buf=strtok(buf," ");

        for(j=0;j<m;j++){
            a[i][j]=atoi(p_buf);
            p_buf=strtok(NULL," ");
        }
    }

    for(i=0;i<m;i++){
        gets(buf);
        p_buf=strtok(buf," ");

        for(j=0;j<l;j++){
            b[i][j]=atoi(p_buf);
            p_buf=strtok(NULL," ");
        }
    }

    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            c[i][j]=0;
            for(k=0;k<m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
        }
    }

    for(i=0;i<n;i++){
        printf("%lu",c[i][0]);
        for(j=1;j<l;j++){
            printf(" %lu",c[i][j]);
        }
        putchar('\n');
    }

    return 0;
}

Measured memory_bytes: 760
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

int N, Q;

int main() {
	cin >> N >> Q;
	vector<vector<int> > e(N);
	vector<int> par(N, -1);//親
	for (int i = 0; i < N - 1; i++) {
		int from, to;
		cin >> from >> to;
		from--; to--;
		e[from].push_back(to);
		e[to].push_back(from);
		par[to] = from;
	}
	vector<int> cnt(N, 0);
	for (int i = 0; i < Q; i++) {
		int p, x;
		cin >> p >> x;
		p--;
		cnt[p] += x;
	}
	par[0] = -1;
	vector<int> ans(N);
	ans[0] = cnt[0];
	cout << ans[0] << " " << flush;
	for (int i = 1; i < N; i++) {
		ans[i] = cnt[i] + ans[par[i]];
		cout << ans[i] << " " << flush;
	}
	cout << endl;
}

Measured memory_bytes: 16244
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Prog
    {
        const int MOD = 1000000007;
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Prog().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var l = cin.ReadInt;

            var sum = 0;

            for (int i = 0; i < n; i++)
            {
                sum += l + i;
            }

            var ans = 0;
            var diff = int.MaxValue;

            for (int i = 0; i < n; i++)
            {
                var lsum = 0;
                for (int j = 0; j < n; j++)
                {
                    if (i == j) continue;
                    lsum += l + j;
                }
                if (Math.Abs(sum - lsum) < diff)
                {
                    ans = lsum;
                    diff = Math.Abs(sum - lsum);
                }
            }
            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } }
    }
}


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

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> h(N);
    for(int i=0; i<N; i++)  cin >> h[i];

    ll left = 0, right = 1000000001;
    while(right-left > 1){
        ll m = left + (right-left)/2;
        ll nExtra = 0;
        for(int i=0; i<N; i++){
            if(h[i] > B*m){
                nExtra+=(h[i]-B*m-1)/(A-B)+1;
            }
        }
        if(nExtra <= m){
            right = m;
        }else{
            left = m;
        }
    }
    cout << right << endl;
}


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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) != t.at(i)) ans++;
  }
  cout << ans;
  return 0;
}


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


int main(void){
    
    int N;
    int temp;
    vector<int> a;
    
    scanf("%d",&N);
    
    for(int i = 0 ; i < N ; i++ ){
        scanf("%d",&temp);
        temp--;
        a.push_back(temp);
    }
    
    int count =0;
    
    for(int i = 0 ; i < N ; i++ ){
        temp = a[i];
        if( temp < i )continue;
        
        if( a[temp] == i )count++;
    }
    
    printf("%d\n",count);
    
    return 0;
}


Measured memory_bytes: 892
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[]) {
	
	int h, n;
	int c = 0;
	cin >> h >> n;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		c += t;
	}
	if (c >= h)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}









Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define rep(i,n)        for(int i=0;i<n;i++)
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define Sort(v)         sort(v.begin(), v.end(), sortbysec)
#define setbits(x)      __builtin_popcountll(x)
#define rightmostbit(x) __builtin_ffsll(x)
#define leftzeros(x)    __builtin_clzll(x)
#define rightzeros(x)   __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout << fixed; cout << setprecision(x); cout << y;
#define pi              3.141592653589793238
#define mk(a,n)         int n;cin>>n;vi a(n);for(int i=0;i<n;i++) cin>>a[i]
#define w(x)            int x; cin>>x; while(x--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{	return (a.second < b.second);
	// sorted by 2nd element in ascending order
}
void g_b()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
int32_t main()
{
	// g_b();
	int n; cin >> n;
	if (n % 1000 == 0) cout << 0 << "\n";
	else {
		int x = n % 1000;
		cout << abs(1000 - x) << '\n';
	}
	return 0;

}

Measured memory_bytes: 3632
//E.H//
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
ll n,arr[100005],ps[100005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    sort(arr+1,arr+n+1);
    for(int i=1;i<=n;i++){
        ps[i]=ps[i-1] + arr[i];
    }
    for(int i=n-1;i>=1;i--){
        if(ps[i]*2>=arr[i+1]){
            continue;

        }
        else {
            cout<<n-i<<endl;
            return 0;
        }
    }
    cout<<n<<endl;
}

Measured memory_bytes: 5180
#include <iostream>
using namespace std;
int main(){
int p,q, r,ans;
cin>>p>>q>>r;
int max = p;
if(max<q){
  max = q;
}
if(max<r){
  max = r;
}
  ans = p + q + r - max;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n, k = map(int,input().split())
x = list(map(int,input().split()))
time = 10**9
x_k = [0, 0]
for i in range(n - k + 1):
    x_k[0] =  x[i] 
    x_k[1] =  x[i+k-1] 
    #print(x_k)
    
    if x_k[0] >= 0:
        t = x_k[1]
            
    elif x_k[1] <= 0:
        t = -x_k[0]
    
    else:
        t = min(-x_k[0] + x_k[1] *2,-x_k[0] * 2 + x_k[1])

    time = min(t, time)
    
print(time)


Measured memory_bytes: 14224
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

char s[105];
char s1[105];
char s2[105];
char s3[105];
int dp[105][2];
int cal(char s[])
{
	int n=strlen(s+1),res=0,ans=0;
	s[++n]='A';
	for(int i=1;i<=n;i++)
	{
		if(s[i]!=s[i-1])
		{
			ans+=res/2;
			res=1;
		}
		else res++;
	}
	return ans;
}
int main()
{
	int k,flg=true;
	scanf("%s",s+1);
	scanf("%d",&k);
	int n=strlen(s+1);
	for(int i=1;i<=n;i++) if(s[i]!=s[1]) flg=false;
	if(flg) return !printf("%lld\n",1LL*n*k/2);
	if(k==1) return !printf("%lld\n",1LL*cal(s));
	int s1len=0,s2len=0,s3len=0;
	for(int i=2;i<=n;i++)
	{
		if(s[i]!=s[i-1])
		{
			for(int j=1;j<i;j++) s1[++s1len]=s[j];
			for(int j=i;j<=n;j++) s2[++s2len]=s[j];
			for(int j=i;j<=n;j++) s3[++s3len]=s[j];
			for(int j=1;j<i;j++) s3[++s3len]=s[j];
			break;
		}
	}
	printf("%lld\n",1LL*cal(s1)+1LL*(k-1)*cal(s3)+cal(s2));
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head

int main(void){
    ll ans=0,n;
    cin>>n;
    ans=n*(n+1)/2;
    ans-=(n/3)*(n/3+1)/2*3;
    ans-=(n/5)*(n/5+1)/2*5;
    ans+=(n/15)*(n/15+1)/2*15;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3632
MOD = 10**9+7
def inv_mod(a,p=MOD):
    def inv_mod_sub(a,p):
        if a == 1:
            return 1,0
        else:
            d,r = p//a,p%a
            x,y = inv_mod_sub(r,a)
            return y-d*x,x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n,k):
    if k < 0 or k > n:
        return 0
    else:
        c = 1
        for i in range(k):
            c *= n-i
            c %= MOD
        return c*f_mod_inverse[k] % MOD
f_mod=[1]*(10**6)
f_mod_inverse=[1]*(10**6)
for i in range(1,10**6):
  f_mod[i]=f_mod[i-1]*i%MOD
  f_mod_inverse[i]=f_mod_inverse[i-1]*inv_mod(i)%MOD
n,a,b = map(int,input().split())
print((pow(2,n,MOD)-comb_mod(n,a)-comb_mod(n,b)-1)%MOD)

Measured memory_bytes: 107736
o = input()
e = input()

l_o = len(o)
l_e = len(e)

PW = ""

if l_o == l_e:
    for i in range(l_e):
        PW += o[i]
        PW += e[i]
    print(PW)
else:
    for i in range(l_e):
        PW += o[i]
        PW += e[i]
    print(PW + o[l_o - 1])

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

using namespace std;

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

void solve() {
  int n, m;
  cin >> n >> m;
  map<int, int> dp;
  for(int i = 0; i < n; i++) {
    int t;
    cin >> t;
    while(t--) {
      int a;
      cin >> a;
      dp[a]++;
    }
  }
  int ret = 0;
  for(auto out: dp) {
    if(out.second == n) ret++;
  }
  cout << ret << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>

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

int main (void) {
    int R, C, i, j, c, n, l, count, min_count;
    int bit_less[1024];
    int col[10000];

    while (scanf("%d%d", &R, &C) == 2 && R && C) {
        for (i = 0, l = pow(2, R); i < l; i++) {
            for (n = i, c = 0; n > 0; n >>= 1) {
                c += n & 1;
            }
            bit_less[i] = min(c, R-c);
        }
        memset(col, 0, sizeof(int) * C);
        for (i = 0; i < R; i++) {
            for (j = 0; j < C; j++) {
                scanf("%d", &n);
                col[j] |= n << i;
            }
        }

        for (i = 0, l = pow(2, R), min_count = R * C;
             i < l; i++) {
            for (j = 0, count = 0; j < C; j++) {
                count += bit_less[col[j] ^ i];
            }
            if (count < min_count) min_count = count;
        }
        printf("%d\n", R * C - min_count);
    }
    return 0;
}

Measured memory_bytes: 688
def submit():
    s = input()
    t = input()

    # dp[i][j] : sをi、tをjまで見た時のlcs長
    # dp[i + 1][j + 1] = {
    #   dp[i][j] + 1, 
    #   dp[i + 1][j] or dp[i][j + 1]のいずれか
    # }

    dp = [[0 for _ in range(len(t) + 1)] for _ in range(len(s) + 1)]

    for i in range(len(s)):
        for j in range(len(t)):
            if s[i] == t[j]:
                dp[i + 1][j + 1] = dp[i][j] + 1
            else:
                dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])
    
    # 再構成する
    i = len(s)
    j = len(t)
    ans = ""
    while dp[i][j]:
        if s[i - 1] == t[j - 1]:
            ans = s[i - 1] + ans
            i -= 1
            j -= 1
        else:
            if dp[i][j] == dp[i - 1][j]:
                i -= 1
            else:
                j -= 1
    print(ans)


submit()

Measured memory_bytes: 121180
#include<bits/stdc++.h>
using namespace std;
int n;
pair<int,int> p[60];
bool vis[60];
map<pair<int,int>,int> mp;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>p[i].first>>p[i].second;
	}
	sort(p+1,p+n+1);
	for(int i=1;i<=n;i++){
		mp[make_pair(p[i].first,p[i].second)]=i;
	}
	int res=n;
	for(int i=1;i<n;i++){
		for(int k=i+1;k<=n;k++){
			int pp=p[k].first-p[i].first;
			int qq=p[k].second-p[i].second;
			int tot=n;
			memset(vis,false,sizeof(vis));
			for(int j=1;j<=n;j++){
				vis[j]=true;
				if(mp.count(make_pair(p[j].first-pp,p[j].second-qq))){
					if(vis[mp[make_pair(p[j].first-pp,p[j].second-qq)]]){
						vis[mp[make_pair(p[j].first-pp,p[j].second-qq)]]=false;
						tot--;
					}
				}
			}
			res=min(res,tot);
			pp=-1*pp;
			qq=-1*qq;
			tot=n;
			memset(vis,false,sizeof(vis));
			for(int j=n;j>=1;j--){
				vis[j]=true;
				if(mp.count(make_pair(p[j].first-pp,p[j].second-qq))){
					if(vis[mp[make_pair(p[j].first-pp,p[j].second-qq)]]){
						vis[mp[make_pair(p[j].first-pp,p[j].second-qq)]]=false;
						tot--;
					}
				}
			}
			res=min(res,tot);
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long LL;
struct Node
{
    int x;
    LL y;
};
/*struct cmp
{
    bool operator () (Node a , Node b)
    {
        return a.x == b.x ? a.y < b.y : a.x > b.x;
    }
};
*/
bool cmp(Node a , Node b)
{
    return a.x == b.x ? a.y > b.y : a.x < b.x;
}
static const int MAXN = 1e6;
Node data[MAXN];
//priority_queue<Node , vector<Node> , cmp> q;
int main()
{
    int n ;
    LL k;
    scanf("%d%llu" , &n , &k);
    LL sum = 0;
    int pos = 0;
    for(int i = 1 ; i <= n ; ++i)
    {
        int a ;
        LL b;
        scanf("%d%llu" , &a , &b);
        //q.push((Node){a , b});
        data[++pos].x = a;
        data[pos].y = b;
    }

    sort(data + 1 , data + 1 + pos , cmp);
    for(int i = 1 ; i <= pos ; ++i)
    {
        Node p = data[i];
        if(k - sum <= p.y)
        {
            printf("%d" , p.x);
            return 0;
        }
        sum += p.y;
    }
    /*while(!q.empty())
    {
        Node p = q.top();
        q.pop();
        if(k - sum <= p.y)
        {
            printf("%d" , p.x);
            return 0;
        }
        sum += p.y;
    }*/
}


Measured memory_bytes: 1792
INF = 10**10


def rec(l:int, r:int) -> int:
    if dp[l][r] != INF:
        return dp[l][r]
    elif r - l == 1:
        dp[l][r] = 0
        return 0
    elif r - l == 2:
        dp[l][r] = M[l][0] * M[l][1] * M[l+1][1]
        return dp[l][r]
    else:
        for i in range(l+1, r):
            dp[l][r] = min(dp[l][r], rec(l, i) + rec(i, r) + M[l][0] * M[i-1][1] * M[r-1][1])
    return dp[l][r]


if __name__ == "__main__":
    N = int(input())
    M = [tuple(map(int, input().split())) for _ in range(N)]
    dp = [[INF]*(N+1) for _ in range(N+1)]
    print(rec(0, N))


Measured memory_bytes: 5728
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int a;
  cin >> n;
  int prev = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      cin >> prev;
    } else {
      cin >> a;
      if (prev == a) {
        ans++;
        prev = 101;
      } else {
        prev = a;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(ll n,k;cin>>n>>k&&n|k;){
		vl f(100001),g(100002);
		rep(i,n){
			int a,b; cin>>a>>b;
			f[a]+=b;
		}
		rep(i,f.size()) g[i+1]=g[i]+f[i];
		int res=upper_bound(all(g),k-1)-begin(g)-1;
		cout<<res<<endl;
	}
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	string s;
	cin >> s;
	int n1 = (s[0]-'0')*10+s[1]-'0',n2 = (s[2]-'0')*10+s[3]-'0';
	int flag1 = 0,flag2 = 0;
	if(n2 != 0 && n2 <= 12) flag1 = 1;
	if(n1 != 0 && n1 <= 12) flag2 = 1;

	if(flag1 && flag2) cout << "AMBIGUOUS" << endl;
	else if(flag1) cout << "YYMM" << endl;
	else if(flag2) cout << "MMYY" << endl;
	else cout << "NA" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<math.h>
using namespace std;
int main()
{
	long long n,k,mi;	cin>>n>>k;
	n%=k , mi=n;
	map<long long , long long>mp;
	for(;;)
	{
		n%=k;
		n-=k;
		n=abs(n);
		mp[n]++;
		mi=min(mi , n);
		if(mp[n]==2)
			break;
	}
	cout<<mi<<endl;
}

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

int main() {
  int N;
  cin >> N;
  int l, r;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    ans += (r - l) + 1;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
# coding:utf-8


_ = input()
ans = 0

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

flag = True

while 1:
    for v in a:
        if v % 2 == 0:
            pass
        else:
            flag = False
            break
    
    if flag == False:
        break
    
    a = [i/2 for i in a]
    ans += 1

print(ans)


Measured memory_bytes: 2940