akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5+10;
typedef long long ll;

const int mod = 1e9+7;
const int maxn =2e5+500;
int pre[maxn];
int n,m,k,d;
void _init(){
	for(int i=0;i<=n;i++)
		pre[i] = i;
}
int _find(int x){
	if(x==pre[x]) return x;
	else {
		int z = _find(pre[x]);
		return pre[x] = z;
	}
}
void _union(int x,int y){
	x = _find(x);
	y = _find(y);
	if(x!=y) pre[y] = pre[x];
}
vector<int>p1[maxn],p2[maxn];
int num[maxn];
int main(){
	cin>>n>>m>>k;
	_init();
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		_union(a,b);
		p1[a].push_back(b);
		p1[b].push_back(a);
	}
	for(int i=0;i<k;i++){
		int a,b;
		cin>>a>>b;
		p2[a].push_back(b);
		p2[b].push_back(a);
	}
	for(int i=1;i<=n;i++){
		num[_find(i)]++; 
	}
//	for(int i=1;i<=n;i++){
//		cout<<_find(i)<<endl;
//	}
	for(int i=1;i<=n;i++){
		int ans = num[_find(i)]-1;
		//cout<<ans<<" ";
		for(int j=0;j<p1[i].size();j++){
			if(_find(i)==_find(p1[i][j])){
			//	cout<<p1[i][j]<<"    ";
				ans--;
			}
		}
		//cout<<ans<<" ";
		for(int j=0;j<p2[i].size();j++){
			if(_find(i)==_find(p2[i][j])){
				ans--;
			}
		}
		cout<<ans<<" ";
		
	}
	return 0;
}

Measured memory_bytes: 17528
#include<stdio.h>

#define LIMIT 1000000007


/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae
/*wefhaeiofhajifehfiwae*/



int main(void){
    long long i,m,n,ans=1;
    scanf("%lld %lld",&m,&n);
    for(i=0;(1<<i)<=n;i++){
        if((1<<i)&n){
            ans*=m;
            if(ans>=LIMIT){
                ans%=LIMIT;
            }
        }
        m*=m;
        if(m>=LIMIT){
            m%=LIMIT;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    string s; cin >> s;
    ll res = INF;
    rep(i, s.size()-2){
        ll tmp = (s[i] - '0')*100 + (s[i+1] - '0')*10 + s[i+2]-'0';
        res = min(res, abs(tmp - 753));
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static int merge(int left, int mid, int right, int[] arr) {
		int n1 = mid - left;
		int n2 = right - mid;
		int[] l = new int[n1 + 1];
		for (int i = 0; i < l.length - 1; i++) {
			l[i] = arr[left + i];
		}
		int[] r = new int[n2 + 1];
		for (int i = 0; i < r.length - 1; i++) {
			r[i] = arr[mid + i];
		}
		l[n1] = Integer.MAX_VALUE;
		r[n2] = Integer.MAX_VALUE;
		int i = 0;
		int j = 0;
		for (int k = left; k < right; k++) {
			if(l[i] > r[j]) {
				arr[k] = r[j];
				j++;
			} else {
				arr[k] = l[i];
				i++;
			}
		}
		return n1 + n2;
	}
	public static int mergeSort(int left, int right, int[] arr) {
		int count = 0;
		if (left + 1 < right) {
			int mid = (left + right) / 2;
			count += mergeSort(left, mid, arr);
			count += mergeSort(mid, right, arr);
			count += merge(left, mid, right, arr);
		}
		return count;
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] arr = new int[n];
		String[] str = br.readLine().split(" ");
		for (int i = 0; i < str.length; i++) {
			arr[i] = Integer.parseInt(str[i]);
		}
		int count = mergeSort(0, n, arr);
		for (int i = 0; i < arr.length; i++) {
			if (i == arr.length - 1) {
				System.out.println(arr[i]);
			} else {
				System.out.print(arr[i] + " ");
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 173796
def gcd(a, b):
    if b==0:
        return a
    while b>0:
        a, b = b, a%b
    return a
N = int(input())
A = list(map(int, input().split()))
S_left = [0 for _ in range(N+1)]
S_right = [0 for _ in range(N+1)]
for i in range(N):
    S_left[i+1] = gcd(S_left[i], A[i])
    S_right[i+1] = gcd(S_right[i], A[-i-1])
S_right = S_right[::-1]
S_left = S_left + [0]
S_right = [0] + S_right
ans = 0
for i in range(1, N+1):
    ans = max(ans, gcd(S_left[i-1], S_right[i+1]))
print(ans)

Measured memory_bytes: 14436
#include <stdio.h>

int main(void)
{
	int i = 1;
	int num[10000];
	int j = 0;
	int n;
	
	while(i != 0){
		scanf("%d",&i);
		if(i != 0){	
			num[j] = i;
			j++;
		}
	}
	for(n = 0;n < j;n++){
		printf("Case %d: %d\n",n+1,num[n]);
	}
	
	return(0);
}

Measured memory_bytes: 636
#include<iostream>
using namespace std;
int main(){
  long long int h,a=0;
  cin>>h;
  for(int i = 0; i < 41; i++) {
      h >>= 1;
      a += 1LL << i;
    if(h==0) {
      cout<<a<<endl;
      return 0;
    }
  }
  return 0;
}


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

int main() {
    long long s, ss, div, ans = 0;
    cin >> s;
    int num = log10(s), ii;
    for (int bit = 0; bit < (1 << num + 1); bit += 2) {
        ss = s;
        ii = 0;
        for (int i = 1; i <= num; i++) {
            if (bit & (1 << i)) {
                div = pow(10, i - ii);
                ans += ss % div;
                ss /= div;
                ii = i;
            }
        }
        ans += ss;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3904
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll N;
ll A[201010];
map<ll, ll> cnt;

int main()
{
    cin >> N;
    rep(i, 0, N)
    {
        cin >> A[i];
        cnt[A[i]]++;
    }

    ll total = 0;
    for (auto e : cnt)
    {
        ll k = e.first;
        ll v = e.second;
        if (v >= 2)
        {
            total += v * (v - 1) / 2;
        }
    }

    for (int i = 0; i < N; i++)
    {
        ll c = cnt[A[i]];
        if (c <= 1)
        {
            cout << total << endl;
        }
        else
        {
            ll diff = c * (c - 1) / 2 - (c - 1) * (c - 2) / 2;
            cout << total - diff << endl;
        }
    }
}

Measured memory_bytes: 11008
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const A = ~~arg[0];
    const B = ~~arg[1];
    const C = ~~arg[2];
    
    const X = ~~arg[3];
    let answer = 0;
    
    for(let i=0; i<=A; i++) {
        for(let j=0; j<=B; j++) {
            for(let k=0; k<=C; k++) {
                if(500 * i + 100 * j + 50 * k === X) {
                   answer++; 
                }
            }
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<cstdio>
#include<algorithm>
#define maxn 20005
#define maxl 1000
using namespace std;
int a,b,c,n,ans;
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&n);
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)
				if(500*i+100*j+50*k==n) ans++;
	printf("%d\n",ans);
}

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

const double EPS = 1e-9;

int main() {
	double theta, phi, rad;
	double a, b, c, d;

	while(1) {
		cin >> a >> b >> c >> d;
		if(fabs(4 + (a + b + c + d)) < EPS)
			break;

		double x0, y0, z0, x1, y1, z1;
		z0 = sin(a * M_PI / 180.0);
		x0 = cos(a * M_PI / 180.0) * cos(b * M_PI / 180.0);
		y0 = cos(a * M_PI / 180.0) * sin(b * M_PI / 180.0);
		z1 = sin(c * M_PI / 180.0);
		x1 = cos(c * M_PI / 180.0) * cos(d * M_PI / 180.0);
		y1 = cos(c * M_PI / 180.0) * sin(d * M_PI / 180.0);

		double dist = ((x1 - x0)*(x1 - x0) + (y1 - y0)*(y1 - y0) + (z1 - z0)*(z1 - z0));
		double rad;
		double r = 6378.1;

		rad = acos(max(1.0 - dist / 2.0, -1.0));
		cout << (int)(r * rad + 0.5) << endl;
	}
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
const int INF = INT_MAX/5;
const double EPS = 1e-14;

template<typename U, typename T>
void chmin(U &x, T y) { x = min(x, y); }

template<typename U, typename T>
void chmax(U &x, T y) { x = max(x, y); }

typedef long long int lli;
typedef long double ld;

const int RMAX = 32, CMAX = 32;
char field[RMAX][CMAX];
int dp[RMAX][CMAX];
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
int R, C;

typedef pair<int,int> P;
typedef tuple<int, P, P> Dat;

bool outof_range(P p) {
  int y = p.first, x = p.second;
  return y < 0 || R <= y || x < 0 || C <= x || field[y][x] == '#';
}

P None = make_pair(-1, -1);

int main() {
  REP(r, RMAX) REP(c, CMAX) { dp[r][c] = INF; }
  cin >> R >> C;
  REP(h, R) {
    string s; cin >> s;
    REP(w, C) { field[h][w] = s[w]; }
  }
  
  P st, gl;
  REP(h, R) REP(w, C) {
    if (field[h][w] == 'S') {st = make_pair(h, w); field[h][w] = '.';}
    if (field[h][w] == 'G') {gl = make_pair(h, w); field[h][w] = '.';}
  }

  priority_queue<Dat, vector<Dat>, greater<Dat>> que;
  que.push(Dat(0, st, None));

  while (!que.empty()) {
    Dat d = que.top(); que.pop();
    int y = get<1>(d).first, x = get<1>(d).second, dist = get<0>(d);
    if (dp[y][x] <= dist) continue;
    dp[y][x] = dist;
/*    cout << dist << ", " << "(" << y << ", " << x << ")";
    if (get<2>(d) != None) {
      cout << " " << get<2>(d).first << "-" << get<2>(d).second;
    }
    cout << endl;*/
    REP(dir, 4) {
      int ny = y + dy[dir], nx = x + dx[dir]; P np = make_pair(ny, nx);
      if (outof_range(np)) continue;
      else if (field[ny][nx] == 'o') que.push(make_tuple(dist + 1, np, None));
      else if (field[ny][nx] == '.') que.push(make_tuple(dist + 2, np, None));
      if (field[ny][nx] == 'x' || field[ny][nx] == '.') {
        for (int i = 1; i <= 3; ++i) {
          int py = y + dy[dir] * i, px = x + dx[dir] * i; P p = make_pair(py, px);
          if (outof_range(p)) { break; }
/*          printf("(%d, %d)[%d] -> (%d, %d)[%d]\n",
              y, x, dist, py, px, dist + 2 + i);*/
          que.push(Dat(dist + 2 + i, p, get<1>(d)));
        }
      }
    }
  }

  cout << dp[gl.first][gl.second] << endl;
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const double PI = acos(-1);

int main() {
  double a,b;
  double h,m;
  cin>>a>>b>>h>>m;
  double c;
  c = a*a + b*b;
  double A = h*PI/6.0;
  A += m*PI/360.0;
  double B = m*PI/30.0;
  if (A>B) swap(A,B);
  c -= 2*a*b*cos(B-A);
  printf("%.20f\n",sqrt(c));

  return 0;
}

Measured memory_bytes: 4200
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;

typedef pair<double,double>pd;
double EPS=1e-5;
double sq(double a){
    return a*a;
}
double dis(pd p1,pd p2){
    return sqrt(sq(p1.first-p2.first)+sq(p1.second-p2.second));
}
pd add(pd p1,pd p2){
    return make_pair(p1.first+p2.first, p1.second+p2.second);
}
pd minu(pd p1,pd p2){
    return make_pair(p1.first-p2.first, p1.second-p2.second);
}
double inter(pd p1,pd p2){
    return sqrt(sq(p1.first-p2.first)+sq(p1.second-p2.second));
}
int main(){
    double n;
    while(cin>>n,n){
        double x,y;
        int ans=1;
        char c;
        vector<pd>vec;
        for(int i=0;i<n;i++){
            cin>>x>>c>>y;
            vec.push_back(make_pair(x, y));
        }
        for(int i=0;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                if(dis(vec[i],vec[j])<=2){
                    double pm=sqrt(1-sq(dis(vec[i],vec[j])/2));
                    double lam=pm/dis(vec[i],vec[j]);
                    pd m=add(vec[i], vec[j]);
                    m.first/=2;
                    m.second/=2;
                    pd pt=make_pair(lam*(vec[i].second-vec[j].second),lam*(vec[j].first-vec[i].first));
                    pd p1=add(m,pt);
                    pd p2=minu(m,pt);
                    int cou=0;
                    if(p1.first>=0-EPS&&p1.second>=0-EPS&&p1.first<=10+EPS&&p1.second<=10+EPS)
                        for(int a=0;a<n;a++){
                            if(dis(vec[a],p1)<=1+EPS){cou++;}
                        }
                    if(ans<cou)ans=cou;
                    cou=0;
                    if(p2.first>=0-EPS&&p2.second>=0-EPS&&p2.first<=10+EPS&&p2.second<=10+EPS)
                        for(int a=0;a<n;a++){
                            if(dis(vec[a],p2)<=1+EPS)cou++;
                        }
                    if(ans<cou)ans=cou;
                }
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;

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

    vi p(N), q(N);

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

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

    vi per(N);

    for (int i = 0; i < N; i++)
    {
        per[i] = i + 1;
    }

    int pi = 0, qi = 0, i = 0;

    do
    {
        i++;

        if (equal(p.begin(), p.end(), per.begin()))
            pi = i;

        if (equal(q.begin(), q.end(), per.begin()))
            qi = i;

    } while (next_permutation(per.begin(), per.end()));

    cout << abs(pi - qi) << endl;
}


Measured memory_bytes: 256
from itertools import permutations
h, w = map(int, input().split())
c = []
for _ in range(10):
    c.append(list(map(int, input().split())))
a = [0]*10
for _ in range(h):
    for i in map(int, input().split()):
        if i<0:
            continue
        a[i] += 1
ans = 0    
for i in range(10):
    if i==1 or a[i]==0:
        continue
    mi = c[i][1]
    li = [k for k in range(10) if k!=1 and k!=i]
    for j in range(1, 9):
        for p in permutations(li, j):
            pre = i
            tmp = 0
            for now in p:
                tmp += c[pre][now]
                pre = now
            tmp += c[pre][1]
            if tmp < mi:
                mi = tmp
    ans += mi*a[i]
print(ans)

Measured memory_bytes: 42332
/*
* @author:  liangxianfeng
* @mail: liangxianfeng96@qq.com
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <ctime>

using namespace std;
#define ll long long
#define rep(i,n) for(int i =0; i < n; ++i)
#define repp(i,n,x) for(int i =x; i < n+x; ++i)
#define CLR(x) memset(x,0,sizeof x)
#define MEM(a,b) memset(a,b,sizeof a)
#define pr(x) cout << #x << " = " << x << " ";
#define prln(x) cout << #x << " = " << x <<  endl;
const int MOD = 1e9+7;
const int maxn = 1e5+100;
int getnum(long long x){
	int ans = 0;
	while(x){
		x /= 10;
		ans++;
	}
	return ans;
}
int main(){
#ifdef LOCAL
    freopen("C:\\Users\\liangxianfeng\\Desktop\\in.txt","r",stdin);
    //freopen("C:\\Users\\liangxianfeng\\Desktop\\out.txt","w",stdout);
#endif
    ll n;
    cin >> n;
    int ma = sqrt(n+0.5);
    int ans = getnum(n);
    for(int i = 1; i <= ma; ++i){
    	if(n%i==0)
    	ans = min(ans, max(getnum(i), getnum(n/i)));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    string S;
    cin >> S;
    int N = S.size();

    for (int i = 1; i < N; i++) {
        if (S[i] == S[i-1]) {
            cout << i << " " << i + 1 << endl;
            return 0;
        }

        if (i >= 2 && S[i] == S[i-2]) {
            cout << i - 1 << " " << i + 1 << endl;
            return 0;
        }
    }

    cout << "-1 -1" << endl;

    return 0;
}

Measured memory_bytes: 512
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, d, x = map(int, read().split())

def main(N, d, x):
    ret = 0
    while N:
        ret += d + (N-0.5) * x
        d = d + (d/N) + (5*x)/(2*N)
        x += 2*x/N
        N -= 1
    return ret

print(main(N, d, x))

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

int main()
{
    int n;
    int num =0 ;
    int cnt = 0 ;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> num ;
        if(i%2==0&&num%2)
            cnt++;
    }cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3596
from collections import defaultdict
it = lambda: list(map(int, input().strip().split()))
INF = float('inf')


if __name__ == '__main__':
    N = int(input())
    ans = ''
    while N:
        if N % 26 == 0:
            ans = chr(ord('a') + 25) + ans
            N //= 26
            N -= 1
        else:
            ans = chr(ord('a') + N % 26 - 1) + ans
            N //= 26
    print(ans)


Measured memory_bytes: 9384
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f40;
const long long mod=1e9+7;
const long double PI = acos(0);
template <class T>void UNIQUE(vector<T> &x){
	sort(all(x));
	x.erase(unique(all(x)), x.end());
}

// }}} End Header
int main() {
	ll n, y;
	cin >> n >> y;

	rep(i, n+1){
		rep(j, n+1){
			int k = n-(i+j);
			if(k >= 0){
				if(i*10000+j*5000+k*1000 == y){
					cout << i << " " << j << " " << k << endl;
					return 0;
				}
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 3005, MOD = 998244353;
int dp[N][N], a[N], n, s;
main(){
	dp[0][0] = 1;
	cin >> n >> s;
	for(int i = 1; i <= n; ++i)cin >> a[i];
	for(int i = 1; i <= n; ++i){
		for(int j = 0; j <= s; ++j){
			if(a[i] <= j){
				dp[i][j] = dp[i - 1][j - a[i]];
			}
			dp[i][j] += dp[i - 1][j] * 2;
			dp[i][j] %= MOD;
		}
	}
	cout << dp[n][s] << endl;
}

Measured memory_bytes: 74020
#include <stdio.h>
#define Num 500050

int S[Num];
int Left[Num / 2] , Right[Num / 2];
int count = 0;

/*統合*/
void Merge(int S[] , int left , int mid ,int right){
    int i , j , k;
    
    int n1 = mid - left;
    int n2 = right - mid;
    
    
    for(i = 0 ; i < n1 ; i++)
        Left[i]  = S[left + i];
    for(j = 0 ; j < n2 ; j++)
        Right[j] = S[mid + j];
    
    /*番兵*/
    Left[n1]  = 2000000000;
    Right[n2] = 2000000000;

    i = 0;
    j = 0;
    k = 0;
    for(k = left ; k < right ; k++) {
        count++;
        if(Left[i] <= Right[j]) {
            S[k] = Left[i];
            i++;
        }
        else {
            S[k] = Right[j];
            j++;
        }
    }
}


void Merge_Sort(int S[] , int left , int right) {
    
    if(left + 1 < right) {
        int mid = (left + right) / 2;
        Merge_Sort(S , left , mid);
        Merge_Sort(S , mid , right);
        Merge(S , left , mid , right);
    }
}

int main(void)
{
    int n;
    int i , j;
    
    scanf("%d" , &n);
    
    for(i = 0 ; i < n ; i++)
        scanf("%d" , &S[i]);
    
    Merge_Sort(S , 0 , n);
    
    for(j = 0 ; j < n - 1; j++)
        printf("%d " , S[j]);
    printf("%d" , S[j]);
    printf("\n%d\n" , count);
    
    return 0;
}



Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  int n;
  cin >> n;
  vl a(n);
  rep(i,n) cin >> a[i];
  ll ans = 0;
  rep(i,n) {
    ll x = a[i];
    while(x % 2 == 0) {
      x /= 2;;
      ans++;
    }
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 384
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s: Vec<char> = iterator.next().unwrap().chars().collect();

    if s.len() == 1 {
        return s[0].to_string()
    }

    let mut ans: usize = 0;
    for i in 0..(1 << s.len() - 1) {
        let bin: Vec<char> = binary_string(i, s.len() - 1).chars().collect();
        let mut current = 0;
        for j in 0..s.len() {
            current += s[j].to_digit(10).unwrap() as usize;
            if j == s.len() - 1 || bin[j] == '1' {
                ans += current;
                current = 0;
            } else {
                current *= 10;
            }
        }
    }
    ans.to_string()
}

fn binary_string(n: usize, keta: usize) -> String {
    return format!("{:0>1$b}", n, keta);
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n ;
	vi d(n); rep(i,n) cin >> d[i];
	SORT(d);
	int mid = n/2;
	int ans = d[mid]-d[mid-1];
	cout << ans << endl;
}




Measured memory_bytes: 640
// ARC099F.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 501000, mod = 998244353;

int fpow(int bas, int tim)
{
    int ret = 1;
    while (tim)
    {
        if (tim & 1)
            ret = 1LL * ret * bas % mod;
        bas = 1LL * bas * bas % mod;
        tim >>= 1;
    }
    return ret;
}

const int base[4] = {133, 233, 911, 691}, base_inv[4] = {fpow(base[0], mod - 2), fpow(base[1], mod - 2), fpow(base[2], mod - 2), fpow(base[3], mod - 2)};

struct node
{
    int val[4];

    bool operator<(const node &rhs) const
    {
        for (int i = 0; i < 4; i++)
            if (val[i] != rhs.val[i])
                return (val[i] < rhs.val[i]);
        return false;
    }

    bool operator==(const node &rhs) const
    {
        for (int i = 0; i < 4; i++)
            if (val[i] != rhs.val[i])
                return false;
        return true;
    }
} prefix[MAX_N], base_pre;

map<node, int> cnt;
int n, base_pow[MAX_N][4], base_invs[MAX_N][4], pos[MAX_N];
char str[MAX_N];

int getPow(int idx, int j) { return idx >= 0 ? base_pow[idx][j] : base_invs[-idx][j]; }

node calc(node x, node y, int idx)
{
    for (int i = 0; i < 4; i++)
        x.val[i] = (0LL + x.val[i] + 1LL * y.val[i] * getPow(idx, i) % mod) % mod;
    return x;
}

int main()
{
    scanf("%d%s", &n, str + 1);
    for (int j = 0; j < 4; j++)
        for (int i = base_pow[0][j] = base_invs[0][j] = 1; i <= n; i++)
            base_pow[i][j] = 1LL * base_pow[i - 1][j] * base[j] % mod, base_invs[i][j] = 1LL * base_invs[i - 1][j] * base_inv[j] % mod;
    for (int j = 0; j < 4; j++)
        for (int i = 1, ptr = 0; i <= n; i++)
        {
            if (str[i] == '+')
                base_pre.val[j] = (0LL + base_pre.val[j] + getPow(ptr, j)) % mod;
            else if (str[i] == '-')
                base_pre.val[j] = (0LL + base_pre.val[j] + mod - getPow(ptr, j)) % mod;
            else if (str[i] == '<')
                ptr--;
            else
                ptr++;
            prefix[i].val[j] = base_pre.val[j], pos[i] = ptr;
        }
    cnt[base_pre]++;
    long long ans = 0;
    for (int i = 1; i <= n; i++)
        ans += cnt[prefix[i]], cnt[calc(prefix[i], base_pre, pos[i])]++;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 49152
import math
import numpy as np

def f(x,y,z):
  return x**2+y**2+z**2+x*y+y*z+z*x

N = int(input())
f_list = np.zeros((N,1), dtype=int)

for x in range(1,math.floor((N//6)**0.5)+10):
  for z in range(1,math.floor(N**0.5)+10):
# for x in range(1,math.floor((N//6)**0.5)+1):
#   for z in range(1,math.floor(N**0.5)+1):
    for y in range(x,z+1):
      if f(x,y,z)<=N:
        if((x-y)*(y-z)*(z-x)==0): # 少なくとも2つが等しい
          if(x==y and y==z):
            f_list[f(x,y,z)-1] = f_list[f(x,y,z)-1] + 1
          else:
            f_list[f(x,y,z)-1] = f_list[f(x,y,z)-1] + 3
        else:
          f_list[f(x,y,z)-1] = f_list[f(x,y,z)-1] + 6

for i in range(N):
  print(f_list[i][0])

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

int main() {
  int h, w;
  cin >> h >> w;
  char a[h][w], b[h+2][w+2];
  
  for (int i = 0; i < h+2; i++) {
    for (int j = 0; j < w+2; j++) {
      b[i][j] = '#';
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
      b[i+1][j+1] = a[i][j];
    }
  }
  for (int i = 0; i < h+2; i++) {
    for (int j = 0; j < w+2; j++) {
      cout << b[i][j];
    }
    cout << endl;
  }
      

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<climits>
#include<algorithm>
#include<string>

int main(){
	int n;
	std::string s;

	std::cin>>n; 
	std::cin>>s;

	int ans=1;
	char prev= s[0];

	for(int i=1; i<n; i++){
		if(prev!=s[i])
			ans++;

		prev= s[i];
	}

	std::cout<<ans<<std::endl;

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin >> a;
	priority_queue<double, vector<double>, greater<double> > Q;
	for(int i=0; i<a; i++)
	{
		double temp;
		cin >> temp;
		Q.push(temp);
	}
	for(int i=0; i<a - 1; i++)
	{
		double top1 = Q.top();
		Q.pop();
		double top2 = Q.top();
		Q.pop();
		double ans = (double) (top1 + top2) / 2;
		Q.push(ans);
	}
	double ans = Q.top();
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
/*
ID: alec3
LANG: C++14
PROG: concom
*/

#include <bits/stdc++.h>

#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define FOR(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
typedef unsigned long long ull;

int pct(int x) { return __builtin_popcount(x); }

using namespace std;

ifstream fin("concom.in");
ofstream fout("concom.out");
const int N = 2e6 + 1;
int n, q;
int c[N], p[N], f[N], ans[N], lz[N];
vector<pair<int, int> > qr[N];

void push(int id){
    lz[id * 2] += lz[id];
    lz[id * 2 + 1] += lz[id];
    lz[id] = 0;
}
void upd(int id, int l, int r, int ql, int qr, int v){
    if (l > qr || r < ql)
        return;
    if (ql <= l && r <= qr){
        lz[id] += v;
        return;
    }

    push(id);
    int mid = (l + r) /2;
    upd(id * 2, l, mid, ql, qr, v);
    upd(id * 2 + 1, mid + 1, r, ql, qr, v);
}

int qry(int id, int l, int r, int p){
    if (l == r)
        return lz[id];
    push(id);
    int mid = (l + r) /2;
    if (p <= mid)
        return qry(id * 2, l, mid, p);
    else
        return qry(id * 2 +1, mid + 1, r, p);

}

int main()
{
    io;
    cin >> n >> q;
    for (int i = 1; i <= n; i++){
        cin >> c[i];
        p[i] = f[c[i]];
        f[c[i]] = i;
    }
    for (int i = 1; i <= q; i++){
        int l, r;
        cin >> l >> r;
        qr[r].push_back({l, i});
    }
    for (int i = 1; i <= n; i++){
        upd(1, 1, n, p[i] + 1, i, 1);
        for (auto c : qr[i]){
            ans[c.ss] = qry(1, 1, n, c.ff);
        }
    }
    for (int i = 1; i <= q; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


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


int satisfication(int a[],int b[],int c[], int n)
{
	int count = 0, prev=0;
	
	for(int i=0;i<n;i++)
	{
		if(prev+1==a[i])
		{
			count += b[a[i]-1] +c[prev-1];
			prev = a[i];
		}
		else
		{
			count += b[a[i]-1];
			prev = a[i];
		}
	}
	
	cout<<count<<endl;
	
}

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

	int a[n],b[n],c[n-1];
	
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
	}
	
	for(int i=0;i<n-1;i++)
	{
		cin>>c[i];
	}
	
	satisfication(a,b,c,n);

 
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApplication1
{

    class Program
    {

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            var data = new HashSet<int>();
            
            for(int i = 0; i < n; i++)
            {
                data.Add(int.Parse(Console.ReadLine()));
            }


            Console.WriteLine(data.Count);


        }

    }

}
    


Measured memory_bytes: 13396
#include<iostream>
using namespace std;
int main()
{
	int n, k = 0;
	cin >> n;
	int arr[2*n];
	for(int i = 0;i < 2*n;i++)
		cin >> arr[i];
	int temp,i,j;
	for(i = 0;i < 2*n;i++)
	{
		temp = -9999;
		for(j = i;j < 2*n;j++)
		{
			if(temp < arr[j])
			{
				temp = arr[j];
				arr[j] = arr[i];
				arr[i] = temp;
			}
		}
	}
	for(int i = 0;i + 1 < 2*n;i = i + 2)
		k += arr[i+1];
	cout << k << endl;
	return 0;
}

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

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

    int N, T;
    cin >> N >> T;
    vector<int> t(N);
    for (int i = 0; i < N; i++) {
        cin >> t[i];
    }
    long long ans = T;
    for (int i = 1; i < N; i++) {
        ans += min(T, t[i] - t[i - 1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

####
from collections import defaultdict as ddic, Counter, deque
import heapq, bisect, itertools
MOD = 10 ** 9 + 7

class DSU:
    def __init__(self, N):
        self.par = list(range(N))
        self.sz = [1] * N

    def find(self, x):
        if self.par[x] != x:
            self.par[x] = self.find(self.par[x])
        return self.par[x]

    def union(self, x, y):
        xr, yr = self.find(x), self.find(y)
        if xr == yr:
            return False
        if self.sz[xr] < self.sz[yr]:
            xr, yr = yr, xr
        self.par[yr] = xr
        self.sz[xr] += self.sz[yr]
        self.sz[yr] = self.sz[xr]
        return True

    def size(self, x):
        return self.sz[self.find(x)]
N,M=rrm()
A= [ rrm() for _ in xrange(M)]

dsu = DSU(N)
for u,v in A:
    u-=1;v-=1
    dsu.union(u, v)

from collections import Counter
count = Counter(dsu.find(u) for u in xrange(N))
print max(count.values())


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

int main() {
  double w, h, x, y;
  cin >> w >> h >> x >> y;

  cout << w * h / 2 << endl;
  if (x == w/2 && y == h/2) {
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <queue>
#include <iostream>
#include <algorithm>

using namespace std;

const int maxn = 2333;

struct pii
{
	int x, y, dep;
	
	pii(int _x, int _y, int _d)
	{
		x = _x, y = _y, dep = _d;
	}
};

int dirx[] = {0, 0, 1, -1};
int diry[] = {1, -1, 0, 0};

int h, w, k;
char xxx[maxn][maxn];
bool vis[maxn][maxn];
int anss[maxn];

inline int get(int x, int y)
{
    return min(min(x - 1, h - x), min(y - 1, w - y));
}

int main()
{
//	freopen("a.in", "r", stdin);
    scanf("%d%d%d", &h, &w, &k);
    queue<pii> q;
    int ans = 2333333;
    for (int i = 1; i <= h; ++i)
    {
        scanf("%s", xxx[i] + 1);
        for (int j = 1; j <= w; ++j)
        {
            if (xxx[i][j] == 'S')
            {
                q.push(pii(i, j, 0));
                vis[i][j] = true;
            }
        }
    }
    while (!q.empty())
    {
        pii now = q.front();
        q.pop();
        int too = get(now.x, now.y);
        int tmpans = max(1, int (ceil((double) now.dep / k)));
        int oth = ceil((double) too / k);
        ans = min(ans, tmpans + oth);
        for (int i = 0; i < 4; ++i)
        {
            int xx = now.x + dirx[i];
            int yy = now.y + diry[i];
            if (xx && yy && xx <= h && yy <= w && !vis[xx][yy] && xxx[xx][yy] == '.')
            {
                vis[xx][yy] = true;
                q.push(pii(xx, yy, now.dep + 1));
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

int main() {
	ll n;
	scanf("%lld", &n);
	int ans = 0;
	for (int i = 1; i * 1ll * i <= n - 1; ++i) {
		if ((n - 1) % i == 0) {
			if (i > 1) ans++;
			if ((n - 1) / i != i) ans++;
		}
	}
	auto check = [&](ll v) {
		ll x = n;
		while (x % v == 0) x /= v;
		if (x % v == 1) {
			ans++;
		}
	};
	for (int i = 1; i * 1ll * i <= n; ++i) {
		if (n % i == 0) {
			if (i > 1) check(i);
			if (i != n / i) check(n / i);
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
N = int(input().strip())
 
A = list(map(int, input().strip().split()))
 
c = 0
if not all([a // 2 == 1 for a in A]):
  binA = [bin(a) for a in A]
  for a in binA:
    c += len(a) - a.rindex('1') - 1
print(c)


Measured memory_bytes: 4404
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
const int INF=INT_MAX;


int main(){
  string s,t;cin>>s;
  reverse(s.begin(),s.end());
  bool ok=true;
  int tmp=0;
  while(tmp<s.size()){
    string t5=s.substr(tmp,5),t7=s.substr(tmp,7),t6=s.substr(tmp,6);
    if(t5=="maerd"||t5=="esare"){tmp+=5;}
    else if(t7=="remaerd"){tmp+=7;}
    else if(t6=="resare"){tmp+=6;}
    else{ok=false;break;}
  }
  if(ok){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,k;
  cin>>n>>k;
  int a,ans=0;
  rep(i,n){
    cin>>a;
    ans+=min(2*a,2*(k-a));
  }
  cout<<ans<<endl;

  return 0;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=999999999;

int main() {
   char A,B;
   cin>>A>>B;
   if(A<B){cout<<'<'<<endl;}
   else if(A>B){cout<<'>'<<endl;}
   else{cout<<'='<<endl;}
return 0;}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int h,w,i,j;
  
  while(1){
    scanf("%d %d",&h,&w);
    if (h==0 && w ==0)
      break;
    else{
      for(i=0;i<=h-1;i++){
	for (j=0;j<=w-1;j++){
	  if (i==0 ||i ==h-1){
	  printf("#");
	  }
	  else if(j==0 || j==w-1){
	    printf("#");
	  }
	  else {
	    printf(".");
	  }
	}
	printf("\n");
      }
      printf("\n");
    }
  }
  return 0;
}

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

int main() {
    int x;
    cin >> x;
    if(x) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std ; 
#define ll long long
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
#define test  ll int tcase ; cin>>tcase ; while(tcase--) 
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define N  2000005

int arr[N] ; 

int main(){
    io ; 
    int n ; cin>>n ; 
    
    int a[n] ; 
    
    for(int i = 0; i<n ; i++){
         cin>>a[i] ;
    }
     memset(arr,0,sizeof(arr)) ; 
    
    sort(a,a+n) ; 
    for(int i = 0 ; i<n ; i++){
    if(a[i]==a[i+1]){
        arr[a[i]]=1 ; //therefore they are divisble by some other . 
    }
  }
int count = 0 ;
    for(int i=0 ; i<n; i++){
        if(!arr[a[i]]){
            count++ ; 
        }
        if(a[i]!=a[i+1]){
            for(int j=2*a[i] ; j<=N ; j+=a[i]){
                arr[j]=1 ; 
            }
        }
    }
    
     cout<<count ; 
     

}


Measured memory_bytes: 12260
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>
 
#define INFINITY 2000000000
 
using namespace std;
 
int main(){
 
    int V,E,from,to,dist;
 
    scanf("%d %d",&V,&E);
    long long int table[V][V];
 
    for(int i = 0; i < V; i++){
        for(int k = 0; k < V; k++){
            if(i != k){
                table[i][k] = INFINITY;
            }else{
                table[i][k] = 0;
            }
        }
    }
 
    for(int i = 0; i < E; i++){
        scanf("%d %d %d",&from,&to,&dist);
        table[from][to] = dist;
    }
 
    for(int k = 0; k < V; k++){
        for(int i = 0; i < V; i++){
            if(table[i][k] == INFINITY)continue;
            for(int j = 0; j < V; j++){
                if(table[k][j] == INFINITY)continue;
                table[i][j] = min(table[i][j],table[i][k]+table[k][j]);
            }
        }
    }
 
    bool FLG = true;
 
    for(int i = 0; i < V; i++){
        if(table[i][i] < 0){
            FLG = false;
            break;
        }
    }
 
    if(!FLG)printf("NEGATIVE CYCLE\n");
    else{
        for(int i = 0; i < V; i++){
            if(table[i][0] == INFINITY)printf("INF");
            else{
                printf("%lld",table[i][0]);
            }
 
            for(int k = 1;k < V; k++){
                if(table[i][k] == INFINITY)printf(" INF");
                else{
                    printf(" %lld",table[i][k]);
                }
            }
            printf("\n");
        }
    }
 
    return 0;
}


Measured memory_bytes: 2772
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<random>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,r=0,b=0;
    string s;
    cin>>n>>s;
    rep(i,n){
        if(s[i]=='R') r++;
        else b++;
    }
    if(r>b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll dp[105][100005];

void Main() {
    ll N, W;
    cin >> N >> W;
    vector<P> items(N);
    rep(i, N) cin >> items[i].first >> items[i].second;

    rep(i, N) {
        P p = items[i];
        rep(j, W + 1) {
            if (j - p.first >= 0) {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - p.first] + p.second);
            }
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
    }
    cout << dp[N][W] << '\n';
}

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


Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
#define rep(i, t) for (int i = 0; i < t; i++)
const int INF = (1 << 30);

int main()
{
    int R;
    cin >> R;
    if (R < 1200) cout << "ABC" << endl;
    else if (R < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

if __name__ == "__main__":
	N = int(input())
	A = [[int(i) for i in input().split()] for i in range(2)] 

	SUM = [0 for i in range(N)]

	for i in range(N):
		for j in range(i+1):
			SUM[i] = SUM[i] + A[0][j]
		for j in range(i, N):
			SUM[i] = SUM[i] + A[1][j]
	print(max(SUM))

Measured memory_bytes: 3064