akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

struct mint {
    constexpr static int mod = 1000000007;
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    ll p = (n + 999) / 1000;
    mint a;
    a = p * 1000 - n;
    cout << a.x << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <complex>
#include <cmath>


using namespace std;

const int  MAXN=55;
#define eps 1e-8

using point=complex<double>;

int N;
point P[MAXN];

bool cover_all(double r){

    for(int i=0;i<N;i++){
        for(int j=1;j<N;j++){
            auto mid=(P[i]+P[j])/2.,dir=(P[j]-P[i]);
            auto len=abs(dir/2.);
            len=sqrt(r*r-len*len);
            dir=dir/abs(dir);
            auto rot=point(dir.imag(),-dir.real());
            auto fst=mid+len*rot,snd=mid-len*rot;

            bool Ok=true;
            for(int i=0;i<N;i++) Ok=Ok&&(abs(P[i]-fst)<((eps)+r));

            if (Ok) return true;

            bool OK=true;
            for(int i=0;i<N;i++) OK=OK&&(abs(P[i]-snd)<((eps)+r));

            if (OK) return true;

            // Ok=true;
            // for(int i=0;i<N;i++) Ok=Ok&&(abs(P[i]-mid)<((eps)+r));
            // if (Ok) return true;
        }
    }

    return false;

}

int main() {
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        P[i]=point(x,y);
    }
    
    double l=0.,r=1000.;
    while(r-l>=1e-6){
        auto mid=(l+r)/2.;
        if (cover_all(mid)) r=mid;
        else l=mid;
    }

    printf("%.8lf\n",l);

    return 0;
}

		



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

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

	ll w, h;
	cin >> h >> w;

	if (h == 1 || w == 1) {
		cout << 1 << '\n';
		return 0;
	}
	cout << ((h/2) + (h%2)) * ((w/2) + (w%2)) + (w/2) * (h/2) << '\n';
}


Measured memory_bytes: 256
h,w = map(int,input().split())

al = []

for _ in range(h):
   a = list(input())
   al.append(a)

i,j = 0,0
while True:
    al[i][j] = "."
    if j + 1 < w and al[i][j+1] == "#":
        al[i][j+1] = "."
        j += 1
    elif i + 1 < h and al[i+1][j] == "#":
        al[i+1][j] = "."
        i += 1
    else:
        print("Impossible")
        exit()
    if j == w-1 and i == h-1:
        break

for i in range(h):
    for j in range(w):
        if al[i][j] == '#':
            print("Impossible")
            exit()
print("Possible")

        

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

int main (){
	int min = 10000;
	int a[3];
	cin >> a[0] >> a[1] >> a[2];

	if( min > (a[0] + a[1])){
		min = a[0] + a[1];
	}
	if( min > (a[0] + a[2])){
		min = a[0] + a[2];
	}
	if( min > (a[1] + a[2])){
		min = a[1] + a[2];
	}

	cout << min << endl;

}


Measured memory_bytes: 888
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
mod = 10**9 + 7


def perm(n, k):
    if k == 0:
        return 1
    return n * perm(n-1, k-1) % mod


n, k = map(int, input().split())
child = [0] * n

for _ in range(n-1):
    a, b = map(lambda x: int(x)-1, input().split())
    child[a] += 1
    child[b] += 1

ans = k
for i in range(n):
    if i == 0:
        color = k - 1
        num = child[i]
    else:
        color = k - 2
        num = child[i] - 1
    ans = ans * perm(color, num) % mod

print(ans)

Measured memory_bytes: 92916
import sys
input = sys.stdin.readline

sys.setrecursionlimit(10000000)

N, Q = [int(x) for x in input().split()]
# V = [set() for _ in range(N)]
V = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = [int(x) for x in input().split()]
    a -= 1
    b -= 1
    # V[a].add(b)
    V[a].append(b)

C = [0] * N

for _ in range(Q):
    p, x = [int(x) for x in input().split()]
    p -= 1
    C[p] += x

ANS = [0] * N


def dfs(n, val):
    ANS[n] += (val + C[n])
    for next in V[n]:
        dfs(next, val + C[n])


def main():
    dfs(0, 0)
    print(" ".join([str(x) for x in ANS]))


if __name__ == '__main__':
    main()


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

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(),  (c).end()

const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};

int h, w, c;
vector<vector<int> > p, vis;
vector<int> col(6, 0);

bool inrect(int x, int y){
    return 0 <= x && x < h && 0 <= y && y < w;
}

void flip(int x, int y, int k){
    vis[x][y] = 1;
    rep(i, 4){
        int nx = x + dx[i], ny = y + dy[i];
        if(!inrect(nx, ny) || vis[nx][ny] || p[nx][ny] != p[0][0])continue;
        flip(nx, ny, k);
    }
    p[x][y] = col[k];
}

int solve(int k){
    int res = 0;
    if(k == 6){
        vector<vector<int> > tmp(all(p));
        for(int i=k-1; i>=0; --i){
            vis.assign(h, vector<int>(w, 0));
            flip(0, 0, i);
        }
        rep(i, h)res += count(all(vis[i]), 1);
        p.swap(tmp);
    }else{
        for(int co=1; co<=6; ++co){
            if(co == col[k-1])continue;
            col[k] = co;
            res = max(res, solve(k+1));
        }
    }
    return res;
}

int main(){
    while(cin >> h >> w >> c, h|w|c){
        col[0] = col[1] = c;
        p.assign(h, vector<int>(w, 0));
        rep(i, h)rep(j, w)cin >> p[i][j];
        cout << solve(2) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>

int bit(int x)
{
	int r = 0;
	while (x){
		r |= 1 << (x % 10);
		x /= 10;
	}
	return r;
}

int main()
{
	int N,K,b = 0;
	scanf ("%d %d",&N,&K); while (K--){
		int x; scanf ("%d",&x); b |= 1 << x;
	}

	while (bit(N)&b)N++;
	printf ("%d\n",N);

	return 0;
}

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

void solve(long long N, std::vector<long long> L)
{
    sort(L.begin(), L.end());
    long long cnt = 0LL;

    for (size_t i = 0; i < N; i++)
    {
        for (size_t j = i + 1; j < N; j++)
        {
            long long r = lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin();
            long long l = j + 1;
            cnt += max(0LL, r - l);
        }
    }

    cout << cnt << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> L(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# define MOD 1000000000+7
using namespace std;

int main() {
	int w, a, b;
	cin >> w >> a >> b;
	if (a > b) {
		swap(a, b);
	}
	if (b - a <= w) {
		cout << 0 << endl;
	}
	else {
		cout << b - a - w << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
    #include<string>
    #include<algorithm>
    #include<cmath>
     
    using namespace std;
     
    int main() {
    	long long int n,a,b;
    	cin >> n;
    	a = b = 0;
    	double m = sqrt(n);
    	for (int i = 1; i <=m ; i++) {
    		if (n % i == 0) {
    			a = i;
    			b = n / a;
    		}
    	}
    	cout << a + b - 2 << endl;
    }

Measured memory_bytes: 384
#include <cstdio>

int main() {
	bool f[10] = {};
	int n, k;
	scanf("%d%d", &n, &k);
	for(auto i = 0; i < k; i++) {
		int d;
		scanf("%d", &d);
		f[d] = true;
	}
	for(; ; n++) {
		auto m = n;
		while(m > 0) {
			auto d = m % 10;
			if(f[d]) break;
			m /= 10;
		}
		if(m == 0) break;
	}
	printf("%d\n", n);
	return 0;
}

Measured memory_bytes: 128
def myAnswer(N:int,S:list) -> int:
   MIN = 0
   total = sum(S)
   S.sort()

   for s in S:
      if(s % 10 != 0):
         MIN = s
         break
   if(total % 10 == 0):
      if(MIN != 0):
         return total - MIN
      else:
         return 0
   else:
      return total

def modelAnswer():
   return
def main():
   N = int(input())
   S = [int(input()) for _ in range(N)]
   print(myAnswer(N,S[:]))
if __name__ == '__main__':
   main()

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

int main() {
  int A,B,C,D,E;
  cin >> A>>B;
  C=A+B;
  D=A-B;
  E=A*B;
  if (C <= D){
    if(D <= E){
    cout << E << endl;
    }
    else {
    cout << D << endl;
    }
  }
  else if(C > D){
    if(C <= E){
    cout << E << endl;
    }
    else {
    cout << C << endl;
    }
  }
}

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

void fnInput(vector<string>& rvsBoard)
{
  int nHigh, nWide;
  cin >> nHigh >> nWide;

  rvsBoard.resize(nHigh);
  for (int i = 0; i < nHigh; i++)
    cin >> rvsBoard[i];
}

int fnCountBomb(int nx, int ny, const vector<string>& cnrvsBoad)
{
  if (   nx >= 0  && nx < cnrvsBoad.size()
      && ny >= 0  && ny < cnrvsBoad[nx].size())
    if (cnrvsBoad[nx][ny] == '#')  return 1;
    else;

  return 0;
}

void fnMinesweeper(vector<string>& rvsBoard)
{
  const vector<int> cnvnDx = {-1, -1, -1,  0,  0,  1,  1,  1};
  const vector<int> cnvnDy = {-1,  0,  1, -1,  1, -1,  0,  1};
  for (int nx = 0; nx < rvsBoard.size(); nx++)
  {
    for (int ny = 0; ny < rvsBoard[nx].size(); ny++)
    {
      if (rvsBoard[nx][ny] == '.')
      {
        int nCount = 0;
        for (int i = 0; i < cnvnDx.size(); i++)
          nCount += fnCountBomb(nx + cnvnDx[i], ny + cnvnDy[i], rvsBoard);

        rvsBoard[nx][ny] = char('0' + nCount);
      }
    }
  }
}

void fnResult(const vector<string>& cnrvsBoard)
{
  for (string sBoard : cnrvsBoard)
    cout << sBoard << endl;
}

int main()
{
  vector<string> vsBoard;

  fnInput(vsBoard);
  fnMinesweeper(vsBoard);
  fnResult(vsBoard);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)



int main() {
	int n,m;
	cin >> n >> m;

	vector<int> d(n, -1);

	rep(i, m) {
		int s, c;
		cin >> s >> c;
		s--;
		if (d[s] == -1) {
			d[s] = c;
		} else if (d[s] != c) {
			cout << -1 << endl;
			return 0; 
		}
	}
	if ((d[0] ==0 || d[0] == -1) && n == 1) {
		cout << 0 << endl;
		return 0;
	}
	if (d[0] == 0) {
		cout << -1 << endl;
		return 0;
	}
	if (d[0] == -1) {
		d[0] = 1; 
	}

	int ans = 0;
	rep(i, n) {
		ans *= 10;
		if (d[i] != -1) {
			ans += d[i];
		}
		//cout << "i:" << i << ":" << ans << endl;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    vi A(N),B(N),C(N);
    for(auto &a:A) cin >> a;
    for(auto &a:B) cin >> a;
    for(auto &a:C) cin >> a;
    sort(all(A));
    sort(all(B));
    sort(all(C));
    vi CB(N,0);
    rep(i,N){
        int pos=C.end()-upper_bound(all(C),B[i]);
        CB[i]=pos;
    }
    per(i,N-1){
        CB[i]+=CB[i+1];
    }
    int ans=0;
    rep(i,N){
        int pos=upper_bound(all(B),A[i])-B.begin();
        if(pos<N) ans+=CB[pos];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,m,n) for(int i=(m);i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  string S;
  cin >> S;
  int res=0,ans=0;
  rep(i,0,S.size()){
    rep(j,i+1,S.size()+1){
      res=0;
      rep(k,i,j){
        if(S[k]=='A' || S[k]=='G' || S[k]=='C' || S[k]=='T') res++;
        else{
          res=0;
          break;
        }
        chmax(ans,res);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

  queue<ll> q;
  rep(i, 9){
    q.push(i+1);
  }

  ll x = 0;
  for(int i = 0; i < k; ++i){
    x = q.front();
    q.pop();
    ll tmp = x % 10;
    for(ll j = -1; j <= 1; ++j){
      if(tmp == 0 && j == -1) continue;
      if(tmp == 9 && j == 1) continue;
      ll xx = x*10 + j + tmp;
      q.push(xx);
    }
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 1792
pf=[]
m=int(input())
for i in range(1,int(m**0.5)+1):
    if m % i == 0:
        pf.append(i)
        pf.append(m//i)

pf.sort()

t = len(pf)
print(pf[t//2 - 1] + pf[t//2] -2)

Measured memory_bytes: 3264
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 1e3 + 17;
ll cnt, ans, lnt, sum, n, l1, x, y, a[N], mx, b[N];
pair<ll,ll>pr[N];
vector<ll>v,v2,v3;
map<ll,ll>mp;
bool used[N], t1, t2;
vector<string>sv;

int main()
{
    vector<pair<pair<string,ll>, ll>> og;
    cin >> n;
    string s;
    for(ll i = 0; i < n; i ++)
    {
        cin >> s >> x;
        og.push_back(make_pair(make_pair(s,-x), i + 1));
    }
    sort(og.begin(), og.end());
    for(auto c : og)
    {
        cout << c.second << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
 long long int i,j,n,m,ans=0;
 map<string,int> p;
 string s;
 cin>>n;
 while(n--){
    cin>>s;
    sort(s.begin(),s.end());
    ans+=p[s]++;
 }
 cout<<ans;
}


Measured memory_bytes: 11136
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]
x,y = map(int,input().split())
if (x in A and y in A) or (x in B and y in B) or (x in C and y in C):
  print("Yes")
else:
  print("No")

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(n);
  rep(i,k) {
    int m;
    cin >> m;
    rep(j,m) {
      int a;
      cin >> a;
      d[a-1] = 1;
    }
  }
  int ans = 0;
  rep(i,n) if (d[i] == 0) ++ans;
  cout << ans << endl;
  return 0;
}

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

typedef long long LL;

string tostr(LL x){
	if( x % 15 == 0 ) return "FizzBuzz";
	if( x % 3 == 0 ) return "Fizz";
	if( x % 5 == 0 ) return "Buzz";

	char buf[25];
	sprintf(buf, "%lld", x);
	return buf;
}

LL countlen(LL x){
	if( x % 15 == 0 ) return 8;
	if( x % 3 == 0 || x % 5 == 0 ) return 4;
	
	LL c = 0;
	for(; x > 0; x /= 10) ++c;
	return c;
}

int main(){
	LL s;
	cin >> s;
	--s;

	LL a = 10;
	LL c = 0;
	LL x = 0;

	while(true){
		LL b = a - 10;
		LL len = countlen(b + 1);
		LL d = 8 * len + 32;
		
		LL t = (b - x) / 15;
		if( c + t * d > s ){
			LL u = (s - c) / d;
			c += u * d;
			x += u * 15;
			break;
		}
		else{
			x = b;
			c += t * d;
			bool f = true;
			while(x < a + 5 && f){
				len = countlen(x + 1);
				if( c + len > s ){
					f = false;
					break;
				}
				else{
					c += len;
					++x;
				}
			}
			if( !f ) break;
			a *= 10;
		}
	}

	string str;
	str.reserve(400);
	
	while( str.size() < s - c + 25 ){
		str += tostr(++x);
		if( str.size() > s - c + 25 ) break;
	}
	
	cout << str.substr(s - c, 20) << '\n';
}

Measured memory_bytes: 1228
#include "bits/stdc++.h"
using namespace std;
int main() {
	string s, ss;
	int n, m;
	while (true) {
		cin >> s;
		if(s=="-"){return 0;}
		cin >> n;
		for (int i = 0; i < n; ++i) {
			cin >> m;
			s.insert(s.length(), s.substr(0, m));
			s.erase(0,m);
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 3196
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){

    int n;
    cin >> n;
    ll x[n],y[n];
    
    rep(i,0,n)cin >> x[i] >> y[i];

    map<pair<ll,ll>,int> m;
    
    rep(i,0,n){
	rep(j,0,n){
	    if(i != j){
		//if(x[i]-x[j] >= 0 &&  y[i]-y[j] >= 0)
		    m[make_pair(x[i]-x[j], y[i]-y[j])]++;
	    }
	}
    }
    pair<ll,ll> p;
    int c = 0;
    for(auto i : m){
	if(i.sd > c){
	    c = i.sd;
	    p = i.ft;
	}
    }

    //  P(c);
    //  PS(p.ft);P(p.sd);
  


    P(n - c);
    return  0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef long double ld;

void faster(){
  	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
	cout.tie(NULL);
}

const int MAXN = 5e1 + 1;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll n, A, B, C, cnt;

int main(){
	faster();

	cin >> A >> B >> C;

	if((A == B && A == C && A % 2 == 0)){
		cout << -1;
		return 0;
	}

	ll Q, W, E;
	while(A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
		Q = (B + C) / 2;
		W = (A + C) / 2;
		E = (A + B) / 2;
		A = Q;
		B = W;
		C = E;
		cnt++;
	}

	cout << cnt;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var s = Console.ReadLine();
        Console.WriteLine(s.Substring(0, 3).Distinct().Count() == 1 || s.Substring(1, 3).Distinct().Count() == 1 ? "Yes" : "No");
    }
}



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

using namespace std;

struct Point
{
	int x;
	int y;
};
int dotProduct(Point a, Point b)
{
	return a.x*b.x+a.y*b.y;
}
int lengthSquared(Point a)
{
	return pow(a.x,2)+pow(a.y,2); 
}
int main()
{ int q; int p1x,p1y,p2x,p2y;
	int q1x,q1y;
	cin>>p1x>>p1y>>p2x>>p2y;
	cin>>q;
	struct Point p = {p2x-p1x, p2y-p1y};

	for(int i=0;i<q;i++)
	{
		cin>>q1x>>q1y;
		struct Point q = {q1x-p1x, q1y-p1y};
		double val;
		if(lengthSquared(p)==0) val = 0.0f;
		else val = double(dotProduct(p,q))/double(lengthSquared(p));
		double x = val*p.x+p1x;
		double y = val*p.y+p1y;
		if(x==0) x=0.0f;
		if(y==0) y=0.0f;
		cout<<fixed<<setprecision(10)<<x<<" "<<y<<endl;
	}
}



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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend()
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

int main(){
  ll D; cin >> D;
  cout << "Christmas";
  REP(i, 25 - D) cout << " Eve";
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	if(char(a[0])==char(a[1])&&char(a[1])==char(a[2])&&char(a[0])==char(a[2]))cout<<"No";
	else
	cout<<"Yes";
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

class combination
{
public:
  vector<ll> fac, finv, inv;

  combination(ll M)
  {
    fac = vector<ll>(M, 1);
    finv = vector<ll>(M, 1);
    inv = vector<ll>(M, 1);

    for (ll i = 2; i < M; i++)
    {
      fac.at(i) = fac.at(i - 1) * i % MOD;
      inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
      finv.at(i) = finv.at(i - 1) * inv.at(i) % MOD;
    }
  }

  ll P(ll N, ll K)
  {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * finv.at(N - K) % MOD;
  }

  ll C(ll N, ll K)
  {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * (finv.at(K) * finv.at(N - K) % MOD) % MOD;
  }

  ll H(ll N, ll K)
  {
    return C(N + K - 1, K);
  }
};

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N + 1);
  vector<ll> B(N + 1, -1);
  ll X, Y;
  for (ll i = 0; i < N + 1; i++)
  {
    cin >> A.at(i);
    if (B.at(A.at(i)) != -1)
      X = B.at(A.at(i)) + 1, Y = i + 1;
    else
      B.at(A.at(i)) = i;
  }

  combination com(N + 10);

  for (ll k = 1; k <= N + 1; k++)
  {
    ll ans = (com.C(N + 1, k) + MOD - com.C(X + N - Y, k - 1)) % MOD;
    cout << ans << endl;
  }
}

Measured memory_bytes: 5120
#include <iostream>

using namespace std;

const int INF = 1 << 28;

int main() {
    int n;
    while (cin >> n, n != 0) {
		int page[n+1];
		for (int i = 0; i < n; i++) cin >> page[i];
		page[n] = INF;
		int from_idx = 0;
		bool flag = false;
		for (int i = 1; i <= n; i++) {
			if (page[i] != page[i-1] + 1) {
				if (i-1 == from_idx) {
					if (!flag) {
						cout << page[i-1];
						flag = true;
					} else {
						cout << ' ' << page[i-1];
					}
				} else {
					if (!flag) {
						cout << page[from_idx] << '-' << page[i-1];
						flag = true;
					} else {
						cout << ' ' << page[from_idx] << '-' << page[i-1];
					}
				}
				from_idx = i;
			}
		}
		cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
ans = 1
n = int(input())
arr = sorted(list(map(int , input().split())))
f  = 1
for i in range(n):
	ans*=arr[i]
	#print(ans)
	if ans > 10**18:
		f = 0
		break
#print(ans)
if f: print(ans)
else: print(-1)





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

int main()
{
	double t, u;
	string s;

	while (cin >> t >> u) {
		if (t < 35.5 && u < 71)
			s = "AAA";
		else if (t < 37.5 && u < 77)
			s = "AA";
		else if (t < 40 && u < 83)
			s = "A";
		else if (t < 43 && u < 89)
			s = "B";
		else if (t < 50 && u < 105)
			s = "C";
		else if (t < 55 && u < 116)
			s = "D";
		else if (t < 70 && u < 148)
			s = "E";
		else
			s = "NA";

		cout << s << endl;
	}

	return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define con_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define con_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);

int main(){
    long long int a,b;
    cin>>a>>b;
    cout<<a*b/__gcd(a,b)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 100100
#define ll long long
struct DSU
{
    int fa[maxn],m;
    void init(int x)
    {
        m=x;
        for(int i=0;i<=m;++i)
            fa[i]=i;
    }
    int find(int x)
    {
        if(fa[x]==x) return x;
        else return fa[x]=find(fa[x]);
    }
    void unite(int x,int y)
    {
        x=find(x);
        y=find(y);
        if(x==y) return;
        fa[x]=y;
    }
}dsu;
struct edge
{
    int from,to;
    int w;
    bool operator <(const edge& ee) const
    {
        return w<ee.w;
    }
}g[maxn<<2];
int cnt;
struct poi
{
    int x,y;
    int id;
    bool operator <(const poi& pp) const
    {
        return x<pp.x;
    }
}p[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
    {
        p[i].id=i;
        scanf("%d%d",&p[i].x,&p[i].y);
    }
    dsu.init(n);
    sort(p+1,p+1+n);
    for(int i=1;i<n;++i)
    {
        g[cnt].from=p[i].id;
        g[cnt].to=p[i+1].id;
        g[cnt].w=p[i+1].x-p[i].x;
        cnt++;
    }
    for(int i=1;i<=n;++i) swap(p[i].x,p[i].y);
    sort(p+1,p+1+n);
    for(int i=1;i<n;++i)
    {
        g[cnt].from=p[i].id;
        g[cnt].to=p[i+1].id;
        g[cnt].w=p[i+1].x-p[i].x;
        cnt++;
    }
    sort(g,g+cnt);
    ll ans=0;
    for(int i=0;i<cnt;++i)
    {
        int u=g[i].from,v=g[i].to;
        int fu=dsu.find(u);
        int fv=dsu.find(v);
        if(fu==fv) continue;
        dsu.unite(fu,fv);
        ans+=g[i].w;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 6528
import queue

n,m=map(int,input().split())

fri=[[] for i in range(n)]

for i in range(m):
  ai,bi=map(int,input().split())
  fri[ai-1].append(bi-1)
  fri[bi-1].append(ai-1)

seen=[0 for i in range(n)]



ans=0
for i in range(n):
  if seen[i]==1:
    continue
  cnt=1
  q=queue.Queue()
  q.put(i)
  seen[i]=1
  while not q.empty():
    p=q.get()
    for pnext in fri[p]:
      if seen[pnext]==0:
        q.put(pnext)
        seen[pnext]=1
        cnt+=1
  ans=max(ans,cnt)

print(ans)

Measured memory_bytes: 120280
use std::io::*; //Not mine.
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let n: i64 = read();
    let k: i64 = read();
    let mut ans: i64 = 0;
    if k == 0 {
        println!("{}", n * n);
    } else {
        for i in 1..n + 1 {
            let mut d: i64 = n / i;
            ans += d * std::cmp::max(i - k, 0);
            if n % i > 0 {
                ans += std::cmp::max(0, n % i - k + 1);
            }
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 2108
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;


namespace atPra95a
{
    class Class1
    {
        static void Main()
        {

            string str = Console.ReadLine();
            char a = str[0];
            char b = str[1];
            char c = str[2];
            int count = 0;
            if (a == 'o') count++;
            if (b == 'o') count++;
            if (c == 'o') count++;
            Console.WriteLine("{0}", 700 + count * 100);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
int main(){

	int k, a, b,c, d, e;
	cin >> a;
	cin >> b; 
	cin >> c;
	cin >> d;
	cin >> e;
	cin >> k;

	if (e - a > k){
		cout << ":(" << endl;
}
	else {
		cout << "Yay!" << endl;
	}

}


Measured memory_bytes: 256
import math

A,B,DEGREE = map(int,input().split())
 
rad = math.radians(DEGREE)
 
S = A*B*math.sin(rad)/2.0
C = math.sqrt(A*A+B*B-2*A*B*math.cos(rad))
h = 2*S/A
 
print("%.10f %.10f %.10f"%(S,A+B+C,h))


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

int main(){
    int n;
    cin >> n;
    cout << (n*(n-1))/2-n/2 << endl;
    for(int i = 1;i <= n;i ++){
        for(int j = i+1;j <= n;j ++){
            if(j==n-i+(n%2==0)) continue;
            cout << i << " " << j << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> edges_beg(N, 0);
    vector<int> edges_end(N, 0);
    vector<int> edges_w(N, 0);
    vector<int> nodes_color(N, -1);
    unordered_map<int, vector<int>> connected_nodes;
    unordered_map<int, vector<int>> connected_node_weights;

    int beg, end, weight;
    for (int i = 0; i < N - 1; i++) {
        cin >> beg >> end >> weight;
        edges_beg[i] = beg - 1;
        edges_end[i] = end - 1;
        edges_w[i] = weight;

        connected_nodes[edges_beg[i]].push_back(edges_end[i]);
        connected_node_weights[edges_beg[i]].push_back(edges_w[i]);
        connected_nodes[edges_end[i]].push_back(edges_beg[i]);
        connected_node_weights[edges_end[i]].push_back(edges_w[i]);
    }

    queue<int> que_node;
    queue<int> que_color;
    unordered_set<int> nodes_set;
    for (int i = 0; i < N; i++) {
        nodes_set.insert(i);
    }
    int node, color;
    while (!nodes_set.empty()) {
        // for (auto node_color: nodes_color) {
        //     cout << node_color;
        // }
        // cout << endl;

        if (que_node.size() == 0) {
            // pop
            node = *nodes_set.begin();
            color = 0;

            nodes_set.erase(nodes_set.begin());
        } else {
            node = que_node.front();
            que_node.pop();
            color = que_color.front();
            que_color.pop();

            nodes_set.erase(nodes_set.find(node));
        }
        if (nodes_color[node] != -1) {
            continue;
        }
        // colorize
        nodes_color[node] = color;

        // add adjcents
        for (int j = 0; j < connected_nodes[node].size(); j++) {
            int con_node = connected_nodes[node][j];
            int con_node_weight = connected_node_weights[node][j];
            if (nodes_color[con_node] == -1) {
                // cout << "(" << node << ", " << con_node << ") :" << con_node_weight << endl;

                // odd: change color with its pair node
                if (con_node_weight % 2 == 1) {
                    que_color.push(1 - color);
                } else {
                    que_color.push(color);
                }
                que_node.push(con_node);
            }
        }
    }

    for (auto node_color: nodes_color) {
        cout << node_color << endl;
    }

    return 0;
}



Measured memory_bytes: 23880
S = input()
if S=="SUN":
  print(7)
elif S=="MON":
  print(6)
elif S=="TUE":
  print(5)
elif S=="WED":
  print(4)
elif S=="THU":
  print(3)
elif S=="FRI":
  print(2)
else:
  print(1)

Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int		stack[100]	= {};
	char	number[7]	= {};
	int		degit		= 0;
	int		p			= 0;
	int		stop_flag	= 0;
	char	input		= '\0';
	int		i			= 0;
	
	while ( 1 ) {
		scanf("%c", &input);
		switch ( input ) {
			case ' ':
				if ( number[0] != '\0' ) {
					p++;
					stack[p] = atoi(number);
					for ( i = 0 ; i < degit+1; i++ ) {
						number[i] = '\0';
					}
					degit = 0;
				}
				break;
			case '+':
				stack[p-1] = stack[p] + stack[p-1];
				p--;
				break;
			case '-':
				stack[p-1] = stack[p-1] - stack[p];
				p--;
				break;
			case '*':
				stack[p-1] = stack[p] * stack[p-1];
				p--;
				break;
			case '\n':
				stop_flag = 1;
				break;
			default:
				number[degit] = input;
				degit++;
				break;
		}
		
		if ( stop_flag == 1 ) {
			break;
		}
	}
	
	printf("%d\n", stack[p]);
	
	return 0;
}


Measured memory_bytes: 2052
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

#define cin_desync()                      \
	do {                                  \
		ios_base::sync_with_stdio(false); \
		cin.tie(0);                       \
	} while (0)                           \

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

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

    int mx = N / 2 + N % 2;
    if (K <= mx) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

using namespace std;

#define LIMIT 100
#define PLIMIT 10000010
#define MOD 1000000007ll
#define INF 1e9
typedef long long ll;
typedef pair<ll, ll> ii;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }
int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n; cin >> n;
  int tot = 0;
  int a[100003] = {0};

  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    tot += abs(a[i]-a[i-1]);
  }

  tot+= abs(a[n]);

  for (int i = 1; i <= n; ++i) {
    std::cout << tot- abs(a[i]-a[i-1]) - abs(a[i+1]-a[i])+ abs(a[i+1]-a[i-1]) << std::endl;
  }

  return 0;
}



Measured memory_bytes: 1664
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn func(t1: i64, t2: i64, a1: i64, a2: i64, b1: i64, b2: i64) -> String {
    let inter1 = a1 * t1 + a2 * t2;
    let inter2 = b1 * t1 + b2 * t2;
    if inter1 == inter2 {
        return "infinity".to_string();
    }

    if (a1 > b1 && inter1 > inter2) || (a1 < b1 && inter1 < inter2) {
        return 0.to_string();
    }
    if a1 > b1 && inter1 < inter2 {
        let ans =  (a1- b1) * t1 / (inter2 - inter1);
        if (a1 - b1) * t1 % (inter2 - inter1) == 0 {
            return (ans * 2).to_string();
        } else {
            return (ans * 2 + 1).to_string();
        }
    } else {
        let ans =  (b1- a1) * t1 / (inter1 - inter2);
        if (b1 - a1) * t1 % (inter1 - inter2) == 0 {
            return (ans * 2).to_string();
        } else {
            return (ans * 2 + 1).to_string();
        }
    }

}


fn main() {
    let line: Vec<i64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let t1 = line[0];
    let t2 = line[1];
    let line: Vec<i64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let a1 = line[0];
    let a2 = line[1];
    let line: Vec<i64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let b1 = line[0];
    let b2 = line[1];

    println!("{}", func(t1,t2,a1,a2,b1,b2));
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int front;
		int upper;

		String command = "W";
		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			//?????????????????????
			String line = sc.nextLine();
			Dice di = new Dice(line);
			int[] dice = di.surface;

			//????????°???????????????
			int loop = sc.nextInt();
			for (int i = 0; i < loop; i++) {

				//?????¢??¨?????¢???????????????
				upper = sc.nextInt();
				front = sc.nextInt();

				//?????????????????????????????¢???

				for (int j = 0; j < 4; j++) {

					for (int k = 0; k < 4; k++) {
						if (dice[0] != upper || dice[1] != front) {
							command = "N";
							dice = Dice.diceroll(dice, command);
							command = "W";

							for (int l = 0; l < 4; l++) {
								dice = Dice.diceroll(dice, command);
								if (dice[0] == upper && dice[1] == front) {
									break;
								}
							}

						}else{
							break;
						}
					}
					if (dice[0] != upper || dice[1] != front) {
						command = "W";
						dice = Dice.diceroll(dice, command);
					}else{
						break;
					}
				}
				int output = dice[2];
				System.out.println(output);

			}

		} finally {
			sc.close();
		}
	}

}

//?????????????????????
class Dice{

	int[] surface;

	public Dice(String s){

		String[] work;

		work = s.split(" ");

		surface = new int[work.length];

		for (int i = 0; i < work.length; i++) {
			surface[i] = Integer.parseInt(work[i]);
		}
	}

	//?????????????????????
	public int[] dicemake(String s) {
		int[] dice;
		String[] work;

		work = s.split(" ");
		dice = new int[work.length];

		for (int i = 0; i < work.length; i++) {
			dice[i] = Integer.parseInt(work[i]);
		}

		return dice;

	}

	//????????????????????????????????????
	public static int[] diceroll(int[] di , String com){
		int n = 0;
		int[] dice = di;

		//???????????????
			switch (com) {
			case "N":
				n = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[4];
				dice[4] = n;
				break;

			case "S":
				n = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[1];
				dice[1] = n;
				break;

			case "W":
				n = dice[0];
				dice[0] = dice[2];
				dice[2] = dice[5];
				dice[5] = dice[3];
				dice[3] = n;
				break;

			case "E":
				n = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[2];
				dice[2] = n;
				break;

			default:
				System.out.println("other");
				break;
			}
		return dice;

	}
}

Measured memory_bytes: 26156
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

#なお、任意の整数 M に対して M の −2 進数表現が一意に定まることが証明できます。
#2桁ごとに見るとよかった（もう実験したよ）
def resolve():
    n,=pin()
    D=lispin()
    D.sort()
    #print(D)
    print(D[(n//2)]-D[n//2-1])            
    
#%%submit!
resolve()

Measured memory_bytes: 52680
import java.io.IOException;
import java.util.Scanner;

class Main {
	static final int INF = 1000000001;

	static int changecount;
   public static void main(String args[]) throws IOException{

      Scanner sc = new Scanner(System.in);

	   int n = Integer.parseInt( sc.next()  );

	   Cood p1 = new Cood(0 , 0);
 	   Cood p2 = new Cood(100 , 0);

 	   p1.printCood();
	   kock(n , p1, p2);
       p2.printCood();

	   sc.close();
   }


   public static void kock(int n, Cood p1, Cood p2){

      if( n == 0){
    	  return;
      }

      Cood s = new Cood( (2*p1.x + 1*p2.x)/3    ,   (2*p1.y + 1*p2.y)/3  );
      Cood t = new Cood( (1*p1.x + 2*p2.x)/3    ,   (1*p1.y + 2*p2.y)/3  );
      Cood u = new Cood( (t.x - s.x)*Math.cos(Math.toRadians(60)) - (t.y - s.y)*Math.sin( Math.toRadians(60) )+s.x  ,  (t.x - s.x)*Math.sin( Math.toRadians(60) ) + (t.y - s.y)*Math.cos( Math.toRadians(60) )+s.y  );

      kock(n-1, p1, s);
      //System.out.println("s ");
      s.printCood();
      kock(n-1, s, u);
      //System.out.println("u ");
      u.printCood();
      kock(n-1, u, t);
      //System.out.println("t ");
      t.printCood();
      kock(n-1, t, p2);
   }




}



class Cood{

	double x;
	double y;

    Cood(double X, double Y){
    	x = X;
    	y = Y;
    }

	void printCood(){
		System.out.print(String.format("%.8f ", x) );
		System.out.println(String.format("%.8f", y) );
		//System.out.println( x + " " +y);

	}

}

Measured memory_bytes: 42756
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std

Jehian Norman Saviero;

// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;

// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")

// MACROS FOR ATTRIBUTE
#define fi first
#define se second

// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) fill_n(x, sizeof(x)/sizeof(x[0]), y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))

// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scf(x) scanf("%f", &x)
#define scd(x) scanf("%lf", &x)
#define scld(x) scanf("%Lf", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main() {
	int A, B;
	cin >> A >> B;
	cout << max(max(A + A - 1, A + B), max(B + B - 1, B + A)) << endl;
	return 0;
}

Measured memory_bytes: 256