akhauriyash/Code-Regression huggingface dataset:
"""
AtCoder
    :author: vierbein
"""
from __future__ import absolute_import, division, print_function

# import itertools as it
# import collections
import sys


def pp(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


N = int(input())
A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]

ans = 0
rest = A[0]
for a, b in zip(A[1:], B):
    inc = min(a + rest, b)
    ans += inc
    rest = max(0, a - max(0, b - rest))
print(ans)

Measured memory_bytes: 19372
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
ll mod = 1000000007, INF = 10000000000000000;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
// for (ll i = 0; i < n; i++) {
// sort(.begin(),.end());
int main(){
  vll abc(3);
  for (ll i = 0; i < 3; i++) cin >> abc[i];
  for (ll i = 0; i <= 50; i++) {
    ll x = 0;
    for (ll j = 0; j < 3; j++) {
      if (abc[j] >= i) {
        x += abc[j] - i;
      }
      else {
        x += (i - abc[j]) / 2 + 2 * ((i - abc[j]) % 2);
      }
    }
    if (INF > x) {
      INF = x;
    }
  }
  cout << INF << endl;
}

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

int main(void){
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++){
    if(i*i > n){
      cout << (i-1)*(i-1) << endl;
      return 0;
    }
  }
  cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] card=new int[101];
		int a=0,b=0;
		for(int i=0;i<n;i++) {
			card[i]=sc.nextInt();
		}
		int max=0,task=0;
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				if(card[i]>card[j]) {
					task=card[j];
					card[j]=card[i];
					card[i]=task;
				}
			}
		}
		for(int i=0;i<n;i++) {
			if(i%2==0)	a+=card[i];
			else			b+=card[i];
		}
		System.out.println(a-b);

	}

}

Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;

#define __int64 long long
#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

bool isBroken[100001] = {false};
long ans[100001];

int main(){
    int n, m, a;
    cin >> n >> m;
    rep(i,m){
        cin >> a;
        isBroken[a] = true;
    }

    ans[0] = 1;
    ans[1] = (isBroken[1] ? 0 : 1);
    for(int i=2; i<=n; i++){
        if(isBroken[i]){
            ans[i] = 0;
        } else {
            ans[i] = (ans[i-1] + ans[i-2]) % Modd;
        }
    }

    cout << ans[n] % Modd << endl;
    
}

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

int main() {

int N;

cin >>N;

string W[N];
char ini[N];
char ter[N];

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

ini[i]=W[i][0];
ter[i]=W[i][W[i].size()-1];
}

string ans("Yes");//しりとりかどうか

for(int i=0; i<N-1;i++){
if(ter[i]!=ini[i+1]){ans="No";}
}

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

for(int j=0; j<N; j++){
if(W[i]==W[j]&&i!=j){ans="No";}
}

}

cout <<ans;


}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;


signed main()
{
	int a, b;
	cin >> a >> b;
	if (a + b == 15)
		cout << "+" << endl;
	else if (a * b == 15)
		cout << "*" << endl;
	else
		cout << "x" << endl;
}







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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    ll x, k, d; cin >> x >> k >> d;
    x = abs(x);

    ll c = abs(x)/d;
    if (c >= k) {
        cout << abs(x-k*d) << endl;
        return 0;
    } 

    ll m1 = abs(x - c*d);
    ll m2 = abs(x - (c+1)*d);

    if (m2 < m1) {
        ++c;
        swap(m1,m2);
    }
    if ((k-c)%2==0) {
        cout << m1 << endl;
    } else {
        cout << m2 << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<sstream>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF=0x3f3f3f3f;
const int MAX_N = 105;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};
char tr[MAX_N][MAX_N];
int H, W;
void dfs(int x, int y, char c){
    tr[x][y] = '.';
    for(int i = 0; i < 4; i++){
        int nx = x + dx[i], ny = y + dy[i];
       if(nx >= 0 && nx < H && ny >= 0 && ny < W && tr[nx][ny] == c){
            dfs(nx, ny, c);
        }
    }

}
int main()
{
	#ifdef LOCAL
		freopen("in.txt","r",stdin);
	//	freopen("out.txt","w",stdout);
	#endif
	//ios::sync_with_stdio(false);
	while(cin >> H >> W && (H || W)){
        for(int i = 0; i < H; i++)scanf("%s", tr[i]);
        int ans = 0;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++)
            if(tr[i][j] != '.'){
                ans++;
                dfs(i, j, tr[i][j]);
            }
        }
        cout << ans << endl;
	}
	return 0;
}

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

typedef long long ll;

ll K;

int main() {
  std::cin >> K;
  ll x = 0;

  int ans = -1, c = 0;

  std::set<int> vis;
  while (true) {
    x = (10*x + 7) % K;
    //std::cout << x << "\n";
    c++;
    if (vis.find(x) != vis.end())
      break;
    if (x == 0) {
      ans = c;
      break;
    }
    vis.insert(x);
  }

  std::cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 50440
import queue

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

G = [[] for _ in range(V)]
visited = [False] * V
indeg = [0] * V
out = []

for _ in range(E):
    s, t = map(int, input().split())
    G[s].append(t)

for i in range(V):
    for j in range(len(G[i])):
        indeg[G[i][j]] += 1

q = queue.Queue()
for i in range(V):
    if indeg[i] == 0 and not visited[i]:
        q.put(i)
        visited[i] = True
        while not q.empty():
            u = q.get()
            out.append(u)
            for j in range(len(G[u])):
                v = G[u][j]
                indeg[v] -= 1
                if indeg[v] == 0 and not visited[v]:
                    visited[v] = True
                    q.put(v)

for el in out:
    print(el)



Measured memory_bytes: 10252
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
ans=[]
xyz=[[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]
if(m==0):
    print("0")
    exit()
for j in xyz:
   x,y,z=j
   lst=[]
   for i in range(m):
      b=a[i][0]*x+a[i][1]*y+a[i][2]*z
      lst+=[b]
   for i in range(m,n):
     b=a[i][0]*x+a[i][1]*y+a[i][2]*z
     if(min(lst)<b):
        lst.remove(min(lst))
        lst+=[b]
   ans+=[sum(lst)]
print(max(ans))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  int n;
  cin >> n;
  vector<int> a(n);
  repr(i, n, 0) {
    cin >> a[i];
  }

  int ans = 0;
  for (int i = 0; i < n-1; ++i) {
    for (int j = i+1; j < n; ++j) {
      ans += a[i] * a[j];
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;

struct Node
{
	int parent, left, right;
public:
	Node() { parent = left = right = -1; }
};

Node T[30];
int D[30], H[30];

void setDepth(int u, int p)
{
	D[u] = p;

	if (T[u].left != -1)
		setDepth(T[u].left, p + 1);
	if (T[u].right != -1)
		setDepth(T[u].right, p + 1);
}

int setHeight(int u)
{
	int h1 = 0, h2 = 0;

	if (T[u].left != -1)
		h1 = setHeight(T[u].left) + 1;
	if (T[u].right != -1)
		h2 = setHeight(T[u].right) + 1;

	return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u)
{
	int x = T[u].parent;
	if (x == -1) return x;
	int ret = T[x].left == u ? T[x].right : T[x].left;
	return ret;
}

void show(int n)
{
	for (int i = 0; i < n; i++) {
		printf("node %d: ", i);
		printf("parent = %d, ", T[i].parent);
		printf("sibling = %d, ", getSibling(i));
				
		int deg;
		if (T[i].left == -1 && T[i].right == -1) deg = 0;
		else if (T[i].left == -1 || T[i].right == -1) deg = 1;
		else deg = 2;
        printf("degree = %d, ", deg);

		printf("depth = %d, ", D[i]);
		printf("height = %d, ", H[i]);	
		
		if (T[i].parent == -1) printf("root\n");
		else if (deg > 0) printf("internal node\n");
		else printf("leaf\n");
	}
}

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

	int v, l, r;
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &v, &l, &r);
		T[v].left = l;
		T[v].right = r;
		if (T[v].left != -1) T[l].parent = v;
		if (T[v].right != -1) T[r].parent = v;
	}

	int x;
	for (int i = 0; i < n; i++) {
		if (T[i].parent == -1) {
			x = i;
			break;
		}
	}
	setDepth(x, 0);
	setHeight(x);
	
	show(n);
	return 0;
}

Measured memory_bytes: 1196
#include<map>
#include<set>
#include<string>
#include<vector>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
char s[15];
int main() {
	scanf("%s",s+1);
	int len=strlen(s+1);
	if(s[1]!='A') {
		puts("WA");
		return 0;
	}
	bool f=0;int t=0;
	for(int i=1;i<=len;i++) {
		if(s[i]=='C') {
			t++;
			if(i<3||i>len-1)
				f=1;
		}
		if(s[i]!='C'&&s[i]!='A'&&('A'<=s[i]&&s[i]<='Z'))
			f=1;
	}
	if(t!=1) f=1;
	if(!f) puts("AC");
	else puts("WA");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vvi ans(N, vi(N, 0));
    
    int p = 0;
    while ((1 << p) < N) {
        p++;
    }
    
    rep(i, 0, p) {
        int mask = 1 << (p - i - 1);
        vector<int> LR(N, 0);
        rep(v, 0, N) {
            if (v & mask) {
                LR[v] = 1;
            } else {
                LR[v] = 0;
            }
        }
        rep(v, 0, N) {
            rep(w, 0, N) {
                if (LR[v] != LR[w]) {
                    if (ans[v][w] == 0) {
                        ans[v][w] = i + 1;
                    }
                }
            }
        }
    }

    rep(i, 0, N - 1) {
        rep(j, i + 1, N) {
            if (j > i + 1) {
                cout << " ";
            }
            cout << ans[i][j];
        }
        cout << endl;
    }
    return (0^_^0);
}



Measured memory_bytes: 2432
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/5/2018
 
 19:00-19:50 give up
 
 I tried to solve by imos. However it's hard to beat O(N^2) time.
 It was straighforward to reduce to interval problem.
 However I couldn't go out of first approach by imos 😡
 Sorting by end of interval is very typical approach to solve interval problem. Very stupid analsysi skill 😡😡
 
 Summary:
  - DO NOT STICK TO FIRST APPROACH!!!! ARE YOU CRAZY??????????? 😡😡😡😡
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5+1;
int N,M;
II A[MAX_N];
void solve() {
  sort(A,A+M,[&](II a, II b) {
    return a.second<b.second;
  });
  int res=0,maxr=0;
  REP(i,M) {
    int l,r; tie(l,r)=A[i];
    if(maxr<=l) {
      maxr=r;
      ++res;
    }
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>M;
  REP(i,M) {
    int a,b; cin>>a>>b;
    A[i]={a,b};
  }
  solve();
  return 0;
}


Measured memory_bytes: 1024
# we want to use total to subtract away, 10**n
# both 0 and 9 doesn't appear
# find those where 0 appear but not 9
# find those where 9 appear but not 0
mod = 10**9 + 7
n = int(input())

# focus on the computation where 9 doesn't appear and 0 doesn't appear
# exactly_one_appear = 9**n - 8**n
# 10**n-8**n-2*(9**n-8**n)

# neither in the sequence 8**n
# 0 in the sequence but 9 is not

ten, nine, eight = 1, 1, 1
for i in range(n):
    ten *= 10 
    nine *= 9
    eight *= 8
    ten %= mod
    nine %= mod
    eight %= mod
print((ten - 2*nine + eight)%mod)

Measured memory_bytes: 9036
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
const ll mod = 1e9+7;
const ll INF = 1e18;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;
using P = pair<ll,ll>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  V a(n);
  unordered_map<ll, ll> mp;
  rep(i,n) {
    cin >> a[i];
    mp[a[i]]++;
  }
  ll ans = 0;
  for (auto i : mp) {
    ll t = i.second;
    ans += t*(t-1)/2;
  }
  rep(i,n) {
    cout << ans - mp[a[i]] + 1 << '\n';
  }

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 11880
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n = ni()
s = list(ns())
count1 = 0
count2 = 0
lis1 = [0 for i in range(n)]
lis2 = [0 for i in range(n)]
for i in range(len(s)):
    if s[i] == '.':
        count1 += 1
        lis1[i] = count1
    if s[i] == '#':
        count1 -= 1
        lis1[i] = count1
idx1 = lis1.index(max(lis1))
for i in range(len(s)-1, -1, -1):
    if s[i] == '#':
        count2 += 1
        lis2[i] = count2
    if s[i] == '.':
        count2 -= 1
        lis2[i] = count2
idx2 = lis2.index(max(lis2))
ans1 = s[:idx1 + 1].count('#') + s[idx1 + 1:].count('.')
ans2 = s[:idx2].count('#') + s[idx2:].count('.')
print(min(ans1, ans2))


Measured memory_bytes: 22556
n,k=map(int,input().split())
A=list(map(int,input().split()))

l=0
r=max(A)+1
while r-l>1:
  m=(l+r)//2
  cut=0
  
  for i in range(n):
    cut+=((A[i]+m-1)//m)-1
  if cut>k:
    l=m
  else:
    r=m
print(r)
  

Measured memory_bytes: 103544
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){


    int n,k,ans=0,ans2=0,mx=0;
    while(1){
    scanf("%d%d",&n,&k);
    if(n==0&&k==0)break;
    int num[n];
    //for(int y=0;y<n;y++){
      //  scanf("%d",&num[y]);
    //}
        for(int a=0;a<k;a++){
                cin >> num[a];
        ans+=num[a];
        }
        mx=ans;
    for(int j=k;j<n;j++){
            cin >> num[j];
        ans2=ans-num[j-k]+num[j];
        if(mx<=ans2){
            mx=ans2;
        }
    ans=ans2;
    ans2=0;
    }
    printf("%d\n",mx);
    mx=0;
    ans=0;
    }

return 0;
}

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

int main(){
	double x1,x2,y1,y2;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	
	printf("%f\n",sqrt(pow((x2-x1),2)+pow((y2-y1),2)) );
	return 0;
}

Measured memory_bytes: 652
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.C_Challenge
{
    class ABC_091
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            var ab = new int[n][];
            var cd = new int[n][];
            for (int i = 0; i < n; i++)
            {
                int[] input = ReadInts();
                ab[i] = new int[2];
                ab[i][0] = input[0];
                ab[i][1] = input[1];
            }
            for (int i = 0; i < n; i++)
            {
                int[] input = ReadInts();
                cd[i] = new int[2];
                cd[i][0] = input[0];
                cd[i][1] = input[1];
            }
            Array.Sort(ab, (a, b) => a[0] - b[0]);
            Array.Sort(cd, (a, b) => a[0] - b[0]);
            int pairCnt = 0;
            for (int i = 0; i < n; i++)
            {
                int aIndex = n - 1;
                for (; aIndex >= 0; aIndex--)
                {
                    if (ab[aIndex][0] > cd[i][0])
                    {
                        continue;
                    }
                    else
                    {
                        break;
                    }
                }
                if (aIndex == -1)
                {
                    continue;
                }
                int redIndex = -1;
                for (int j = 0; j <=aIndex; j++)
                {
                    if (cd[i][1] < ab[j][1])
                    {
                        continue;
                    }
                    else if (redIndex == -1
                            || ab[redIndex][1] < ab[j][1])
                    {
                        redIndex = j;
                    }
                }
                if (redIndex != -1)
                {
                    pairCnt++;
                    ab[redIndex][1] = 3000;
                }
            }
            Console.WriteLine(pairCnt);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

struct Merchandice {
    string name;
    int weight;
    int price;

    Merchandice() {}
    Merchandice(const string &s, int w, int p) : name(s), weight(w), price(p) {}

};

struct Town {
    int x, y;
    vector<pair<int, int> > mers; //(weight, benefit)

    Town() {}
    Town(int x, int y) : x(x), y(y) {}
};

int main() {
    ios::sync_with_stdio(0);
    int N, M, W, T;
    cin >> N >> M >> W >> T;

    map<string, Merchandice> ms;
    for(int i = 0; i < M; ++i) {
        string name;
        int w, p;
        cin >> name >> w >> p;
        ms[name] = Merchandice(name, w, p);
    }

    vector<Town> towns;
    for(int i = 0; i < N; ++i) {
        Town t;
        int l;
        cin >> l >> t.x >> t.y;
        for(int j = 0; j < l; ++j) {
            string name;
            int q;
            cin >> name >> q;
            const Merchandice &m = ms[name];
            t.mers.push_back(make_pair(m.weight, m.price - q));
        }
        towns.push_back(t);
    }

    vector<int> dists(1<<N);
    vector<int> cost(1<<N);
    for(int pat = 0; pat < (1<<N); ++pat) {
        //cout << pat << endl;

        vector<int> order;
        vector<pair<int, int> > mers;
        for(int i = 0; i < N; ++i) {
            if(pat & (1<<i)) {
                order.push_back(i);
                const Town &t = towns[i];
                for(int j = 0; j < t.mers.size(); ++j) {
                    mers.push_back(t.mers[j]);
                }
            }
        }

        int mindist = 10000000;
        do {
            int d = 0;
            int prevx = 0, prevy = 0;
            for(int i = 0; i < order.size(); ++i) {
                d += abs(prevx - towns[order[i]].x) + abs(prevy - towns[order[i]].y);
                prevx = towns[order[i]].x;
                prevy = towns[order[i]].y;
            }
            d += abs(prevx) + abs(prevy);
            mindist = min(mindist, d);
        } while(next_permutation(order.begin(), order.end()));
        dists[pat] = mindist;

        sort(mers.begin(), mers.end());
        vector<int> dp(W+1, 0);
        int maxval = 0;
        for(int w = 1; w <= W; ++w) {
            for(int i = 0; i < mers.size(); ++i) {
                if(w - mers[i].first >= 0) {
                    dp[w] = max(dp[w], dp[w-mers[i].first] + mers[i].second);
                    maxval = max(maxval, dp[w]);
                }
            }
        }
        cost[pat] = maxval;
    }

    {
        vector<long long> dp(T+1, 0);
        long long maxval = 0;
        for(int t = 1; t <= T; ++t) {
            for(int i = 0; i < (1<<N); ++i) {
                if(t - dists[i] >= 0) {
                    dp[t] = max(dp[t], dp[t-dists[i]] + cost[i]);
                    maxval = max(maxval, dp[t]);
                }
            }
        }
        cout << maxval << endl;
    }
    
    return 0;
}

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

int top, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top+1];
}

int main() {
	int a,b;
	top = 0;
	char s[100];
	
	while( scanf("%s", s) != EOF ) {
		if ( s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		} else if ( s[0] == '-' ) {
			b = pop();
			a = pop();
			push(a - b);
		} else if ( s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		} else {
			push(atoi(s));
		}
	}
	
	printf("%d\n", pop());
	
	return 0;
}



Measured memory_bytes: 2772
#include<iostream>

using namespace std;
int main()
{
    int n,x=0;
    cin>>n;
    for(int i=2;i*i<=n;i+=1){
        if(n%i==0){
            x = 1;break;
        }
    }
    if(x==0){
        cout<<n<<endl;

        return 0;
    }
    else{
        int val = n;
        while(n--){
            int x1=0;val++;
            for(int j=2;j*j<=val;j+=1){
                if(val%j==0){
                    x1 = 1;break;
                }
            }
            if(x1==0){
                cout<<val<<endl;

                return 0;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
b = 0
for i in range(N):
    if i%2 == 0:
        b += A[i]
    else:
        b -= A[i]
print(b)
     
for i in range(N-1):
    b = A[i] - b//2
    b *= 2
    print(b)


Measured memory_bytes: 14032
#include <stdio.h>


int main()
{

  int n, i, j, u, k, a;
  
  scanf("%d",&n);
  int matrix[n][n];

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      matrix[i][j] = 0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&a);
      matrix[u-1][a-1] = 1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",matrix[i][j]);
      if(j == n-1) printf("\n");
      else printf(" ");
    }
  }

  return 0;
   
}
  



Measured memory_bytes: 2048
N = int(input())
X = list(map(int, input().split()))

X_sorted = sorted(X)
if N >= 4:
  bigger = X_sorted[N//2]
  smaller = X_sorted[N//2-1]

  for _ in X:
    if _ >= bigger:
      ans = smaller
    else:
      ans = bigger
    print(ans)

else:
  for n in range(2):
    if n == 0:
      print(X[1])
    else:
      print(X[0])
  

Measured memory_bytes: 25556
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

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;
}
using namespace std;

void solve(){
	int n;
    cin>>n;
    vector<ll>a(3*n);
    rep(i,3*n)cin>>a[i];
    sort(a.begin(),a.end());
    ll ans=0;
    for(int i=n;i<3*n;i+=2)ans+=a[i];
    cout<<ans<<"\n";
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 2560
def rec(i,j)
  @m[i][j]=0
  rec(i,j+1) if j<11 and @m[i][j+1]==1
  rec(i,j-1) if j>0 and @m[i][j-1]==1
  rec(i+1,j) if i<11 and @m[i+1][j]==1
  rec(i-1,j) if i>0 and @m[i-1][j]==1
end
loop do
  @m,c,t=[],0,12
  t.times{@m<<gets.split("").map(&:to_i)}
  t.times{|i|
    t.times{|j|
      if @m[i][j]==1
        rec(i,j)
        c+=1
      end
    }
  }
  p c
  break if !gets
end

Measured memory_bytes: 8792
n, W = map(int, input().split())
w = []
v = []
for i in range(n):
    vals = list(map(int, input().split()))
    w.append(vals[0])
    v.append(vals[1])

dp = [0] * (W + 1)
for i in range(n):
    for j in reversed(range(W - w[i] + 1)):
        dp[w[i] + j] = max(dp[w[i] + j], dp[j] + v[i])
print(dp[W])

Measured memory_bytes: 43772
N = int(input())
A = [int(x) for x in input().split()]
B = [0]*N
for n in range(N):
  B[A[n]-1] +=1
max_val = 0
for m in range(N):
  max_val+= B[m-1]*(B[m-1]-1)//2
result = [max_val]*N
for n in range(N):
  result[n] -= B[A[n]-1]-1
for n in range(N):
  print(result[n])

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

int main() {
	string s, t;
    cin >> s >> t;
    bool success = false;
    if (s != t){
        for (int i = 0; i < s.size(); i++){
            char temp = s.at(s.size() - 1);
            s = temp + s.substr(0, s.size() - 1);
            if (s == t){
                success = true;
                break;
            }
        }
    }
    else{
        success = true;
    }

    cout << (success ? "Yes" : "No") << endl;
}

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

using lint = long long;
using namespace std;

vector<pair<int, int>> edges[100000];
int colors[100000];
void init() {
  for (int i = 0; i < 100000; i++) {
    colors[i] = -1;
  }
}
void dfs(int u, int c) {
  colors[u] = c;
  for (auto p : edges[u]) {
    int v = p.first;
    int w = p.second;

    if (colors[v] == -1) {
      if (w % 2 == 0) {
        dfs(v, c);
      } else {
        if (c == 0) {
          dfs(v, 1);
        } else {
          dfs(v, 0);
        }
      }
    }
  }
}

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

  int n;
  cin >> n;

  for (int i = 0; i < n - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    edges[u - 1].push_back(make_pair(v - 1, w));
    edges[v - 1].push_back(make_pair(u - 1, w));
  }

  init();
  dfs(0, 0);

  for (int i = 0; i < n; i++) {
    cout << colors[i] << endl;
  }

  return 0;
}

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

int main() {
  vector<char>a(6);
  for(int i=0;i<6;i++) cin>>a[i];
  if(a[0]==a[5] && a[1]==a[4] && a[2]==a[3]) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define MOD 1000000007
 
typedef long long ll;
typedef pair<int, int> ii;

int main() {
	ll N, W;
	cin >> N >> W;
	
	vector<vector<ll>> item(4,vector<ll>());
	
	ll w, v;
	cin >> w >> v;
	ll mini = w;
	
	item[0].push_back(v);
	
	rep(i, N-1){
		cin >> w >> v;
		item[w-mini].push_back(v);
	}
	
	SORT(item[0]);
	reverse(item[0].begin(), item[0].end());
	SORT(item[1]);
	reverse(item[1].begin(), item[1].end());
	SORT(item[2]);
	reverse(item[2].begin(), item[2].end());
	SORT(item[3]);
	reverse(item[3].begin(), item[3].end());
	
	vector<ll> sum0(item[0].size()+1, 0);
	rep(i, item[0].size()) sum0[i+1] = sum0[i] + item[0][i];
	vector<ll> sum1(item[1].size()+1, 0);
	rep(i, item[1].size()) sum1[i+1] = sum1[i] + item[1][i];
	vector<ll> sum2(item[2].size()+1, 0);
	rep(i, item[2].size()) sum2[i+1] = sum2[i] + item[2][i];
	vector<ll> sum3(item[3].size()+1, 0);
	rep(i, item[3].size()) sum3[i+1] = sum3[i] + item[3][i];
	
	ll ans = 0;
	rep(i, item[0].size()+1){
		rep(j, item[1].size()+1){
			rep(k, item[2].size()+1){
				rep(l, item[3].size()+1){
					if(mini*i + (mini+1)*j + (mini+2)*k + (mini+3)*l > W) break;
					ans = max(ans, sum0[i] + sum1[j] + sum2[k] + sum3[l]);
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  ll k;
  cin >> n >> k;
  vector<bool> seen(n, false);
  vector<int> a(n);
  REP(i,n) cin >> a[i], a[i]--;
  int cur = 0;
  vector<int> path;
  while(!seen[cur] && k>0){
    path.push_back(cur);
    seen[cur] = true;
    k--;
    cur = a[cur];
  }
  if(k>0){
    int cy_size = 0;
    REPR(i,path.size()-1){
      cy_size++;
      if(path[i]==cur) break;
    }
    k %= ll(cy_size);
    cur = path[path.size()-cy_size+k];
  }
  cout << cur+1 << '\n';
  return 0;
}


Measured memory_bytes: 5088
#include <bits/stdc++.h>
#include <cctype>
using namespace std;
#define ll long long
ll mod =1000000007;


ll pow_mod(ll x,ll n) {
    ll res=1;
    while (n>0) {
        if ((n&1)==1) {
            res=res*x%mod;
        }
        x=x*x%mod;
        n>>= 1;
    }
    return res;
}
ll sa[100005];
ll	sc[100005];
ll sh[100005];
int main(){
	string s;cin>>s;
	int n=s.size();
	
	for(int i=0;i<n;++i){
		if(s[i]=='A')++sa[i+1];
		sa[i+1]+=sa[i];
		if(s[n-i-1]=='C')++sc[i+1];
		sc[i+1]+=sc[i];
		if(s[i]=='?')++sh[i+1];
		sh[i+1]+=sh[i];
		
		
	}
	ll ans=0;
	for(int i=0;i<n-1;++i){
		if(i==0)continue;
		if(s[i]=='A' || s[i]=='C')continue;

		int k=s[i]=='?';
		ans+=(sa[i])*(sc[n-i])%mod*pow_mod(3,sh[n]-k)%mod;
		ans%=mod;
		ans+=(sh[i])*(sc[n-i])%mod*pow_mod(3,sh[n]-1-k)%mod;
		ans%=mod;
		ans+=(sa[i])*(sh[n]-sh[i+1])%mod*pow_mod(3,sh[n]-1-k)%mod;
		ans%=mod;
		ans+=(sh[i])*(sh[n]-sh[i+1])%mod*pow_mod(3,sh[n]-2-k)%mod;
		ans%=mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2816
N, T, E = map(int, input().split())
x = list(map(int, input().split()))

a = []
for i in range(N):
    for j in range(T-E, T+E+1):
        if j % x[i] == 0:
            a.append(i+1)

if len(a) == 0:
    print(-1)
else:
    print(a[0])


Measured memory_bytes: 5604
n=int(input())
a=list(map(int,input().split()))
def gcd(a,b):
    if a==b:
      return a
    else:
      a,b=max(a,b),min(a,b)
      if a%b==0:
        return b
      else:
        return gcd(b,a%b)
R=[]
L=[]
for i in range(n):
  if i==0:
    L.append(a[i])
    R.append(a[-i-1])
  else:
    vl,vr=gcd(a[i],L[-1]),gcd(a[-i-1],R[-1])
    L.append(vl)
    R.append(vr)
ans=0
for i in range(n):
  if i==0:
    ans=max(ans,R[-i-2])
  elif i==n-1:
    ans=max(ans,L[i-1])
  else:
    ans=max(ans,gcd(L[i-1],R[-i-2]))
print(ans)

Measured memory_bytes: 14584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please



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

	
	int A, B;
	cin >> A >> B;

	int kotae = A * A - B;
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
x = [0 for i in range(100001)]
v = [0 for i in range(100001)]
v_sum_right = [0 for i in range(100001)]
v_sum_left = [0 for i in range(100001)]
g = [[0, 0] for i in range(100001)]
g2= [0 for i in range(100001)]
N = 0
C = 0
i = 0
ans = 0
t = 0

N, C = [int(i) for i in input().split(" ")]
for i in range(N):
    x[i], v[i] = [int(i) for i in input().split(" ")]


v_sum_right[0] = v[0]
for i in range(1, N):
    v_sum_right[i] = v_sum_right[i - 1] + v[i]

v_sum_left[N] = 0
for i in range(N - 1, -1, -1):
    v_sum_left[i] = v_sum_left[i + 1] + v[i]


# // g計算
g[0][0] = 0
g[0][1] = 0
g2[0] = 0
for i in range(1, N + 1):
    g[i][0] = max(g[i - 1][0], v_sum_right[i - 1] - x[i - 1])
    g2[i] = max(g2[i - 1], v_sum_right[i - 1] - 2 * x[i - 1])
    if g[i - 1][0] == g[i][0]:
        g[i][1] = g[i - 1][1]
    else:
        g[i][1] = x[i - 1]
    
# // 探査
ans = v_sum_left[0] - C + x[0]
for i in range(1, N):
    ans = max(ans, v_sum_left[i] + g[i][0] - 2 * (C +- x[i]), v_sum_left[i] - C + x[i] + g2[i])
ans = max(ans, g[N][0])

print(ans)

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

using namespace std;

int main()
{
    string S, T;
    cin >> S;
    cin >> T;

    const char* cS = S.c_str();
    const char* cT = T.c_str();

    int max_count = 0;
    for (size_t i = 0; i < (S.size() - T.size() + 1); ++i)
    {
        int count = 0;
        for (size_t j = 0; j < T.size(); ++j)
        {
            if (cS[i + j] == cT[j])
            {
                ++count;
            }
        }

        if (max_count < count)
        {
            max_count = count;
        }
    }

    cout << (static_cast<int>(T.size()) - max_count) << endl;

    return 0;
}


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

using namespace std;

int main() {
    int n = 0, a = 0, b = 0, temp = 0, tempans = 0, ans = 0;
    cin >> n >> a >> b;

    for (int i = 1; i <= n; ++i) {
        temp = i;
        tempans = 0;
        if (temp <= 9 && temp >= a && temp <= b) {
            ans += temp;
        }

        while (temp >= 10) {
            tempans += temp % 10;
            temp /= 10;
            if (temp / 10 <= 0) {
                tempans += temp;
                if (tempans >= a && tempans <= b) {
                    ans += i;
                    break;
                }
            }
        }
    }

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

Measured memory_bytes: 3616
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  int k, s;
  cin >> k >> s;
  int cnt = 0;
  REP(x, 0, k + 1) {
    REP(y, 0, k + 1) {
      int z = s - x - y;
      if (0 <= z && z <= k) {
	cnt++;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
open System

[<EntryPoint>]
let main _ =
    let n = stdin.ReadLine() |> int
    let a = stdin.ReadLine().Split() |> Array.map int
    a
    |> Array.sortDescending
    |> Array.indexed
    |> Array.sumBy (fun (id, x) -> if id % 2 = 0 then x else -x)
    |> stdout.WriteLine
    0


Measured memory_bytes: 11348
N, M = map(int, input().split())
PY = [list(map(int, input().split())) for i in range(M)]

convertedPY = [
    {'index': i,
     'city': py[0],
     'year': py[1]
     } for i, py in enumerate(PY)
]
'''
3 4
1 32
3 64
3 63
1 33

'''
convertedPY = sorted(convertedPY, key=lambda a: (a['city'], a['year']))
answer = []
cnt = 0
tmp = convertedPY[0]['city']
#print(convertedPY)
result = []
for py in convertedPY:
    #print(tmp)
    temp_dict = {}
    if tmp == py['city']:
        cnt += 1
        temp_dict['answer'] = '{:0=6}'.format(py['city']) + '{:0=6}'.format(cnt)
        temp_dict['index'] = py['index']
        result.append(temp_dict)
    else:
        cnt = 1
        temp_dict['answer'] = '{:0=6}'.format(py['city']) + '{:0=6}'.format(cnt)
        temp_dict['index'] = py['index']
        result.append(temp_dict)
        tmp = py['city']


result = sorted(result, key=lambda a: a['index'])
#print(result)
for r in result:
    print(r['answer'])

'''
3
21 -11
81234 52141 94124
'''

#print(PY)


Measured memory_bytes: 101340
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());



int main(){
	ll n;
	cin>>n;
	ll ans=1;
	ll cnt=1;
	while(3*ans<n){
		ans*=3;
		cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 1160
n = gets.to_i
a = gets.split.map(&:to_i)

h = Hash.new(0)
a.each{|x|h[x]+=1}
keys = h.keys.sort
min = keys[0]
max = keys[-1]

if (max==min && (max+1==n || n>=max*2)) ||
   (min+1==max && h[max]%2==0 && max+h[max]/2==n)
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 16896
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) "FUCK YOU"
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);

const int N=500006;
map<pair<int,int>,vector<pi>>diff;
void solve(){
	int n;
	cin>>n;
	vector<pi>points(n);
	cin>>points;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i!=j){
				diff[{points[j].F-points[i].F,points[j].S-points[i].S}].pb({i,j});
			}
		}
	}
	int val=0;
	for(auto i:diff){
		if(i.S.size()>val)val=i.S.size();
	}
	cout<<n-val;
			
}
	
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}


}

int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}

void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	if(a<0)a+=mod;
}

int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;	
}


Measured memory_bytes: 512
a = []
for i in range(3):
    a.append(list(map(int, input().split())))

n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                a[j][k] = 0

if (a[0][0] == a[0][1] == a[0][2] == 0) or (a[1][0] == a[1][1] == a[1][2] == 0) or (a[2][0] == a[2][1] == a[2][2] == 0)\
    or (a[0][0] == a[1][0] == a[2][0] == 0) or (a[0][1] == a[1][1] == a[2][1] == 0) or (a[0][2] == a[1][2] == a[2][2] == 0)\
    or (a[0][0] == a[1][1] == a[2][2] == 0) or (a[0][2] == a[1][1] == a[2][0] == 0):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

bool is_possible(const V<int>& a, int k) {
   int n = a.size();
   stack<P<int,int>> st;
   for (int i = 1; i < n; i++) {
      if (a[i-1] < a[i]) continue;
      while (!st.empty() && st.top().first > a[i]) {
         st.pop();
      }
      if (!st.empty() && st.top().first == a[i]) {
         st.top().second++;
      } else {
         st.push(make_pair(a[i], 1));
      }

      while (st.top().second == k) {
         int id = st.top().first;
         if (id == 1) {
            return false;
         }
         st.pop();
         if (!st.empty() && st.top().first == id - 1) {
            st.top().second++;
         } else {
            st.push(make_pair(id - 1, 1));
         }
      }
   }
   return true;
}

signed main()
{
   int n; cin >> n;
   V<int> a(n);
   for (int i = 0; i < n; i++) {
      cin >> a[i];
   }

   bool all_increacing = true;
   for (int i = 1; i < n; i++) {
      if (a[i] <= a[i-1]) {
         all_increacing = false;
         break;
      }
   }
   if (all_increacing) {
      cout << 1 << endl;
      return 0;
   }

   int l = 1, r = n;
   while (r - l > 1) {
      int m = (l + r) / 2;
      if (is_possible(a, m)) {
         r = m;
      } else {
         l = m;
      }
   }
   cout << r << endl;

   return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H,N;
    cin >> H >> N;

    int T = 0;
    for ( int i = 0; i < N; i++)
    {
       int x;
       cin >> x;
       T += x; 
    }
    
    if(T < H){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
T1,T2=map(int,input().split())
A1,A2=map(int,input().split())
B1,B2=map(int,input().split())
X=(B1-A1)*T1
Y=(B2-A2)*T2
if X>0:
    X=-X
    Y=-Y
if X+Y<0:
    print(0)
elif X+Y==0:
    print("infinity")
else:
    A=(-X)//(X+Y)
    B=(-X)%(X+Y)
    if B!=0:
        print(2*A+1)
    else:
        print(2*A)

Measured memory_bytes: 38624
#include<stdio.h>
int main()
{
    int a[100005],ans[100005],n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        ans[a[i]-1]=i+1;
    }
    for(int i=0;i<n;i++){
        printf("%d",ans[i]);
        if(i==n-1){
            break;
        }
        else{
            printf(" ");
        }
    }
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main() {
  	string s, t;
  cin >> s >> t;
  int ans = 0;
  if(s[0] == t[0]) ans++;
  if(s[1] == t[1]) ans++;
  if(s[2] == t[2]) ans++;
  cout << ans;
	return 0;
}

Measured memory_bytes: 256