akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

int n, m;
int cnt[55];
int main()
{
	while(scanf("%d %d", &n, &m) != EOF)
	{
		for(int i = 1; i <= m; i++)
		{
			int u, v;
			scanf("%d %d", &u, &v);
			cnt[u]++;
			cnt[v]++;
		}
		for(int i = 1; i <= n; i++)
			printf("%d\n", cnt[i]);
		memset(cnt, 0, sizeof(cnt));
	}
	return 0;
}

Measured memory_bytes: 128
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=15,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

int n,m,t,ans,c[N],a[N][N],b[N];

void dfs(int x,int s) {
	if(s>=ans) return ;
	if(x>n) {
		for(int i=1;i<=m;i++) if(b[i]<t) return ;
		ans=s; 
		return ;
	}
	dfs(x+1,s);
	for(int i=1;i<=m;i++) b[i]+=a[x][i];
	dfs(x+1,s+c[x]);
	for(int i=1;i<=m;i++) b[i]-=a[x][i];
}

int main() {
	qr(n); qr(m); qr(t);
	for(int i=1;i<=n;i++) {
		qr(c[i]);
		for(int j=1;j<=m;j++) qr(a[i][j]),b[j]+=a[i][j];
	}
	for(int j=1;j<=m;j++) if(b[j]<t) puts("-1"),exit(0);
	ans=1e9; memset(b,0,sizeof b); dfs(1,0); pr2(ans);
	return 0;
}



Measured memory_bytes: 3548
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
const int N=1e6+5,M=2e6+5,mo=1e9+7;
int n,K,i,j,k,ans,f[2005][2005][2];
int main()
{
	scanf("%d %d",&n,&K);
	f[n+1][0][0]=1;
	fd(i,n+1,2)
	{
		fd(j,n,0) (f[i][j][0]+=f[i][j+1][0])%=mo;
		fo(j,0,n)
			fo(k,0,1)
			{
				(f[i-1][j+1][1]+=f[i][j][k])%=mo;
				(f[i-1][j][0]+=f[i][j][k])%=mo;
			}
	}
	ans=f[1][n-K][0];
	fo(i,1,n-K-1) 
		ans=ans*2%mo;
	printf("%d",ans);
}

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

using namespace std;

#define long long long
#define INF 1e18
#define MOD (long) (1e9 + 7)

int main()
{
    long n, k;
    cin >> n >> k;

    vector<long> a(n);
    for (auto &x : a) cin >> x;

    for (long i = k; i < n; i++) {
        long first = a[i-k];
        long next = a[i];
        if (next > first) {
            puts("Yes");
        } else {
            puts("No");
        }
    }
}


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

using namespace std;

const int kMaxN = 1001;

struct E {
  int x, y;
};

int n, m, x, y, h, w;
vector<vector<int>> a(kMaxN, vector<int>(kMaxN, -1));

queue<E> q, e;

int ne[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

void Change(int i, int j, int v) {
  a[i][j] = v;
  E note = {i, j};
  q.push(note);
  e.push(note);
}

int main() {
  cin >> n >> m >> x >> y >> h >> w;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      if (c == '#') {
        a[i][j] = -2;
      }
    }
  }
  Change(x, y, 0);
  while (!q.empty()) {
    while (!q.empty()) {
      x = q.front().x, y = q.front().y;
      e.push(q.front());
      q.pop();
      for (int i = 0; i < 4; i++) {
        int nx = x + ne[i][0], ny = y + ne[i][1];
        if (nx > 0 && nx <= n && ny > 0 && ny <= m && a[nx][ny] == -1) {
          Change(nx, ny, a[x][y]);
        }
      }
    }
    while (!e.empty()) {
      x = e.front().x, y = e.front().y;
      e.pop();
      for (int i = -2; i <= 2; i++) {
        for (int j = -2; j <= 2; j++) {
          int nx = x + i, ny = y + j;
          if (nx > 0 && nx <= n && ny > 0 && ny <= m && a[nx][ny] == -1) {
            a[nx][ny] = a[x][y] + 1;
            E note = {nx, ny};
            q.push(note);
          }
        }
      }
    }
  }
  cout << a[h][w];
  return 0;
}

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

void matmul_assign(valarray<int>& A, const valarray<int>& B, int N, int mod) {
    valarray<int> C(N * N);
    rep(i, N) {
        const auto Ai = A[slice(i * N, N, 1)];
        rep(j, N) C[i * N + j] = (Ai * B[slice(j, N, N)]).sum() % mod;
    }
    A.swap(C);
}

void matpow_assign(valarray<int>& A, int N, int e, int mod) {
    valarray<int> B(N * N);
    rep(i, N) B[i * N + i] = 1;
    for (; e > 0; e >>= 1, matmul_assign(A, A, N, mod)) if (e & 1) matmul_assign(B, A, N, mod);
    A.swap(B);
}

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

    for (int N, M, A, B, C, T;
         cin >> N >> M >> A >> B >> C >> T, N | M | A | B | C | T;) {
        valarray<int> S(N);
        for (int& e : S) cin >> e;
        valarray<int> R(N * N);
        rep(i, N) {
            if (i > 0) R[i * N + i - 1] = A;
            R[i * N + i] = B;
            if (i < N - 1) R[i * N + i + 1] = C;
        }
        matpow_assign(R, N, T, M);
        rep(i, N) {
            if (i) cout << ' ';
            cout << (valarray<int>(R[slice(i * N, N, 1)]) * S).sum() % M;
        }
        cout << endl;
    }
}

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

typedef vector<int> V;

bool any(V v){
    for(V::iterator it = v.begin(); it != v.end(); it++){
        if( *it ) return true;
    }
    return false;
}

int main(){
    int n, p, q, m, i, j, k, b, e;
    while(cin >> n >> p >> q, n){
        V cm(2400, 0);
        for(i=0;i<n;i++){
            cin >> m;
            for(j=0;j<m;j++){
                cin >> b >> e;
                for(k=b;k<e;k++){
                    cm[k] += 1<<i;
                }
            }
        }
        int mt = 0, current = 0;
        for(i=p;i<q;i++){
            if( cm[i] < (1<<n)-1 ){
                current++;
            }else{
                mt = max(mt, current);
                current = 0;
            }
            if( i%100 == 59 ) i += 40;
        }
        mt = max(mt, current);
        cout << mt << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define vec vector
typedef int64_t intl;
#define fi first
#define se second
#define pushb push_back
#define popb pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
vec<int> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};



int main(){
  intl N,K;
  cin >>N>>K;
  vec<int> A(N+1);
  Rep(i,N){
    cin >>A.at(i+1);
  }
  int count=1;
  int now = 1;
  vec<pair<int,int>> FP(N+1,pair<bool,int>(0,0));
  FP.at(1).fi=1;
  FP.at(1).se=0;
  if (A.at(1) == 1){cout <<1;return 0;}
  now = A.at(now);
  while(FP.at(now).fi == 0){
    if(count == K){cout << now; return 0;}
    FP.at(now).fi=1;
    FP.at(now).se=count;
    count ++;
    now = A.at(now);
  }
  int roop = count - FP.at(now).se;
  int nokori = (K - FP.at(now).se ) % roop;
  Rep(i,nokori){
    now = A.at(now) ;
  }
  cout <<now;
}

Measured memory_bytes: 5636
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <limits>
#include <set>
#include <map>

int main()
{
    int n{};
    std::cin >> n;
    std::string s(n, 'a');
    std::vector<std::string> result = { s };

    for (int i = 1; i < n; i++) {
        const auto tmp = result;
        for (auto x : tmp) {
            const auto c = *std::max_element(x.begin(), x.end()) + 1;
            while (x[i] < c) {
                x[i]++;
                result.emplace_back(x);
            }
        }
    }
    std::sort(result.begin(), result.end());
    for (auto&& x : result) {
        std::cout << x << std::endl;
    }
    return 0;
}

Measured memory_bytes: 7884
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main(){
    input!{
        h:usize,
        w:usize,
        h1:usize,
        w1:usize,
    }
    let ans = (h-h1) * (w-w1);
    println!("{}",ans);
}

Measured memory_bytes: 4352
M = 10**9 + 7
a = [1] + [0] * 12
p = 1
for c in input()[::-1]:
    r = range(0, p * 10, p) if c == '?' else (p * int(c),)
    a = [sum(a[(i - j) % 13] for j in r) % M for i in range(13)]
    p = p * 10 % 13
print(a[5])


Measured memory_bytes: 46316
#include<bits/stdc++.h>
using namespace std;
const int Max_N=15,Max_S=1<<15;
int N,M,Sum=0,A[Max_N+5][Max_N+5]={},f[Max_S+5][Max_N+5]={},P[Max_S+5]={};
int main(){
	scanf("%d%d",&N,&M);
	for(int i=1;i<=M;i++){
		int x,y,v; 
		scanf("%d%d%d",&x,&y,&v);
		Sum+=v; A[x][y]=A[y][x]=v;
	}
	for(int i=0;i<1<<N;i++){
		for(int j=1;j<=N;j++)
		 if((1<<(j-1))&i){
		 	for(int k=j+1;k<=N;k++)
		 	 if((1<<(k-1))&i)
		 	  P[i]+=A[j][k];
		 }
	}
	for(int i=1;i<=N;i++)
	 for(int j=0;j<1<<N;j++)
	  f[j][i]=-(1<<30);
	f[1][1]=0;
	for(int i=0;i<1<<N;i++){
		for(int j=1;j<=N;j++){
			if((1<<(j-1))&i)
			for(int k=1;k<=N;k++)
			 if(((1<<(k-1))&i)&&k!=j&&A[j][k]>0)
			  f[i][j]=max(f[i][j],f[i^(1<<(j-1))][k]+A[j][k]);
			for(int k=i;k;k=(k-1)&i)
			 if(k&(1<<(j-1)))
			  f[i][j]=max(f[i][j],f[(i^k)|(1<<(j-1))][j]+P[k]);
		}
	}
	printf("%d\n",Sum-f[(1<<N)-1][N]);
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <array>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


int main() {
	int r, g, b, n; CI r >> g >> b >> n;

	int ans = 0;
	int rMax = n / r, gMax = n / g, bMax = n / b;

	for (int i = 0; i <= rMax; i++) {
		for (int j = 0; j <= gMax; j++) {
			int memo = (i * r + g * j);
			if(n>=memo and (n-memo)%b==0){
				ans++;
			}
		}
	}

	CO ans EN;
}

Measured memory_bytes: 256
use std::io::*;
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: u32 = read();
    let x: u32 = read();
    let mut ms = vec![];
    for _ in 0..n {
        ms.push(read::<u32>());
    }
    let min_m = ms.iter().min().unwrap();
    let sum = ms.iter().fold(0, |a, b| a + b);
    let ans = n + (x - sum) / min_m;
    println!("{}", ans);

}


Measured memory_bytes: 4352
s = input()
alphabets = [chr(i) for i in range(ord("a"), ord("a")+26)]

ans = float('inf')
for alphabet in alphabets:
    if alphabet not in s:
        continue
    oldS = s
    newS = ""
    cnt = 0
    while len(set(list(oldS))) > 1:
        for i in range(len(oldS)-1):
            if oldS[i] == alphabet or oldS[i+1] == alphabet:
                newS += alphabet
            else:
                newS += oldS[i]
        cnt += 1
        oldS = newS
        newS = ""

    ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)

typedef long long ll;

using namespace std;

const int MOD = 1000000007;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	int now = 0;
	while (1) {
		if (now == 0) {
			if (a.length() == 0)break;
			if (a[0] == 'a')now = 0;
			else if (a[0] == 'b')now = 1;
			else if (a[0] == 'c')now = 2;
			a.erase(a.begin());
		}
		else if (now == 1) {
			if (b.length() == 0)break;
			if (b[0] == 'a')now = 0;
			else if (b[0] == 'b')now = 1;
			else if (b[0] == 'c')now = 2;
			b.erase(b.begin());
		}
		else {
			if (c.length() == 0)break;
			if (c[0] == 'a')now = 0;
			else if (c[0] == 'b')now = 1;
			else if (c[0] == 'c')now = 2;
			c.erase(c.begin());
		}
	}
	if (now == 0) {
		cout << 'A' << endl;
	}
	else if (now == 1) {
		cout << 'B' << endl;
	}
	else {
		cout << 'C' << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007
 
#A
"""
a, b = LI()
print((a+b+1)//2)
"""
 
#B
a = S()
a = a[:-1]
b = S()
b = b[:-1]
a.sort()
b.sort(reverse=True)
if a < b:
    print("Yes")
else:
    print("No")

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

using namespace std;

using ll=long long ;

ll dp[60][2];

void solve() {
    int n; ll x;
    cin >> n >> x;
    const int P = 0, B = 1;
    dp[0][P] = 1; dp[0][B] = 0;
    for (int i = 0; i < 51; i++) {
        dp[i+1][P] = 2*dp[i][P] + 1;
        dp[i+1][B] = 2*dp[i][B] + 2;
    }
    ll res = 0;
    while (x) {
        if (!n) {res+=1; break;}
        x--; if (!x) break;
        ll y = dp[n-1][P] + dp[n-1][B];
        if (x <= y) {
            n--; continue;
        }
        res += dp[n-1][P] + 1; x -= y + 1; if (!x) break;
        if (x <= y) {
            n--; continue;
        }
        res += dp[n-1][P]; break;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	vi a(5);
	rep(i,5){cin>>a[i];}
	int k; cin>>k;
	sort(a);
	if(a[4]-a[0]<=k){
		cout<<"Yay!";
		return 0;
	}
	cout<<":( ";
	return 0;
}

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

struct UnionFind{
    vector<ll> data;
    UnionFind(ll n): data(n, -1){}
    bool unite(ll a, ll b){
        a = root(a); b = root(b);
        if(a == b) return 1;
        if(data[a] > data[b]) swap(a, b);
        data[a] += data[b];
        data[b] = a;
        return 0;
    }
    bool find(ll a, ll b){ return root(a) == root(b); }
    ll root(ll a){ return data[a] < 0 ? a : data[a] = root(data[a]); }
    ll size(ll a){ return -data[root(a)]; }
    ll operator[](ll a){ return root(a); }
};
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n), b(n);
  for(auto& i : a) cin >> i;
  for(auto& i : b) cin >> i;
  vector<ll> c(n);
  iota(c.begin(), c.end(), 0);
  sort(c.begin(), c.end(), [&a](ll x, ll y){ return a[x] < a[y]; });
  vector<ll> A(n), B(n);
  for(ll i = 0; i < n; i++){
    A[i] = a[c[i]];
    B[i] = b[c[i]];
  }
  sort(b.begin(), b.end());
  for(ll i = 0; i < n; i++) if(A[i] > b[i]) return puts("No") & 0;
  for(ll i = 0; i < n - 1; i++) if(A[i + 1] <= b[i]) return puts("Yes") & 0;
  vector<ll> d(n);
  iota(d.begin(), d.end(), 0);
  sort(d.begin(), d.end(), [&B](ll x, ll y){ return B[x] < B[y]; });
  UnionFind uf(n * 2);
  for(ll i = 0; i < n; i++){
    uf.unite(i, d[i] + n);
    uf.unite(i, i + n);
  }
  if(uf.size(0) == n * 2) return puts("No") & 0;
  puts("Yes");
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=1<<18,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll A,B;cin>>A>>B;
    
    ll sum=0;
    
    for(int i=61;i>=0;i--){
        if((A&(1LL<<i))==(B&(1LL<<i))){
            if(A&(1LL<<i)){
                A-=(1LL<<i);
                B-=(1LL<<i);
            }
            continue;
        }
        
        ll a=A,b=B-(1LL<<i);
        
        ll plus=0;
        for(int j=61;j>=0;j--){
            if(b&(1LL<<j)){
                plus+=(1LL<<(j+1));
                break;
            }
        }
        if(b==0) plus++;
        
        if(a<=plus){
            sum+=1LL<<i;
            A=a;
            B=(1LL<<i)-1;
        }else{
            sum+=(1LL<<i)-a;
            sum+=plus;
            
            A=a;
            B=(1LL<<i)-1;
        }
    }
    
    if(A==B) sum++;
    
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

LL L, R;
int main(){
	cin >> L >> R;
	if(R-L >= 2019) cout << 0 << endl;
	else{
		LL tmp = 2019;
		for(LL i=L; i<=R; i++){
			for(LL j=i+1; j<=R; j++){
				tmp = min(tmp, (i*j)%2019LL);
			}
		}
		cout << tmp << endl;
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());
		sc.close();

		int train = Math.min(A, B);
		int bus = Math.min(C, D);
		System.out.println(train + bus);
	}
}

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

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    double th = M_PI * 90 / 180;
    int x3, y3, x4, y4;
    x3 = -(y1 - y2) * (-1) + x2;
    y3 = (x1 - x2) * (-1) + y2;
    x4 = -(y2 - y1) + x1;
    y4 = (x2 - x1) + y1;

    printf("%d %d %d %d\n", x3, y3, x4, y4);
   
    return 0;

}



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

int main(){
    int n; cin>>n;
    vector<int> x(n),y(n);
    for(int i=0;i<n;i++) cin>>x[i];
    y=x;
    sort(y.begin(),y.end());
    for(int i=0;i<n;i++){
        if(x[i]<y[n/2]) cout<<y[n/2]<<endl;
        else cout<<y[n/2-1]<<endl;
    }
}

Measured memory_bytes: 3712
import java.util.*;

public class Main {
    private static final int MOD = (int) (1e9+7);

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        double[] arr = new double[n+1];
        arr[0] = 1;
        for(int i =0;i<n ; ++i){
            double p = scanner.nextDouble();
            for(int r = i+1 ; r>0;--r){
                arr[r] = arr[r]*(1-p) + arr[r-1]*p;
            }
            arr[0] = arr[0]*(1-p);
        }
        double ans = 0;
        for(int i = 0 ; i<=n ; ++i){
            if(i>n-i) ans+=arr[i];
        }
        System.out.println(ans);
    }
}

























/*
*         double[] arr = new double[n+1];
        arr[0] = 1;
        for(int i=0;i<n ; ++i){
            double p = scanner.nextDouble();
            for(int r = i+1 ; r>=1 ; --r){
                arr[r] = arr[r]*(1-p) + arr[r-1]*p;
            }
            arr[0] = arr[0]*(1-p);
        }
        double ans=0;
        for(int i = 0 ; i <=n ; ++i){
            if(i>n-i) ans+=arr[i];
        }
        System.out.println(ans);
*/

Measured memory_bytes: 53408
import sys

readline = sys.stdin.buffer.readline

ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))

def solve():
  s = list(ns())
  ls = len(s)
  lk = ni()
  dp = [[[0]*ls for _ in range(ls)] for i in range(2)]
  ans = 0
  for i in range(ls):
    dp[0][i][i] = 1
  for k in range(lk+1):
    v = k & 1
    for dis in range(1, ls):
      for i in range(ls - dis):
        j = i + dis
        dp[v][i][j] = 0
        if s[i] == s[j]:
          dp[v][i][j] = dp[v][i+1][j-1] + 2
        elif k:
          dp[v][i][j] = dp[v^1][i+1][j-1] + 2
        dp[v][i][j] = max(dp[v][i][j], dp[v][i+1][j], dp[v][i][j-1])
    ans = max(ans, dp[v][0][-1])

  print(ans)
  return

solve()

Measured memory_bytes: 44428
def solve(w_list, sort_list):
    ans = 0
    min_num = sort_list[0]
    for i in range(len(w_list)):
        x = sort_list.index(w_list[i])
        if x == i:
            continue
        sum_cost = 0
        min_loop_n = 10**4 + 1
        j = i
        loop_count = 0
        while True:
            loop_count += 1 
            sum_cost += w_list[j]
            min_loop_n = min(min_loop_n, w_list[j])
            if x == i:
                break
            w_list[x], w_list[j] = w_list[j], w_list[x]
            x = sort_list.index(w_list[j])
        ans += min(sum_cost + (loop_count-2)*min_loop_n, sum_cost + min_loop_n + (loop_count+1)*min_num)
    return ans
        
            
            
n = int(input())
w_list = list(map(int, input().split()))
sort_list = sorted(w_list)
print(solve(w_list, sort_list))
        
        
        
    


Measured memory_bytes: 5620
#include <stdio.h>

int main(void){
	int n;
	while(1){
		scanf("%d",&n);
		if(n==0)
			break;
		int a[7]={0};
		int i,num;
		for(i=0;i<n;i++){
			scanf("%d",&num);
			if(num>=70)
				a[6]++;
			else
				a[num/10]++;
		}
		for(i=0;i<7;i++){
			printf("%d\n",a[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 596
def main():
    n = int(input())
    money = sorted([6 ** i for i in range(7)] + [9 ** i for i in range(1, 6)], reverse=True)
    dp = [0] + [1000000] * n
    for i in range(1, n + 1):
        dp[i] = min(dp[i], *[dp[i - j] + 1 for j in money if i - j >= 0])
    print(dp[n])

if __name__ == '__main__':
    main()

Measured memory_bytes: 4596
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define cross(a,b) (conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define vec(a,b) b-a
#define Reka ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int w[101];
ll p[101];
int l,n;
ll c[101][999999];
ll solve(int ind , int sum)
{
    if(ind == n || sum == l )
        return c[ind][sum] = 0;
     ll r,rr,ans;
     if(c[ind][sum]!=-1)
        return c[ind][sum];
     if(w[ind]+sum>l){
        ans = solve(ind+1,sum);
     }
    else {
     ans = max(solve(ind+1,sum+w[ind])+p[ind],solve(ind+1,sum));
    }
    return c[ind][sum] = ans;
}

int main()
{
    Reka
    memset(c,-1,sizeof(c));
   cin>>n>>l;
   for(int i=0;i<n;i++)
   {
     cin>>w[i]>>p[i];
   }
   cout<<solve(0,0);
   return 0;
}


Measured memory_bytes: 789376
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int get_digit_sum(int a){
  int sum = 0;
  rep(i, 5){
    sum += a%10;
    a /= 10;
  }
  return sum;
}

int main() {
  int N, a, b, m, ans = 0;
  cin >> N >> a >> b;
  rep(i, N){
    m = get_digit_sum(i+1);
    if(a <= m && m <= b) {
      ans += (i+1);
    }
  }
  print(ans);
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int ans=0;
		for(int i=0;i!=a+1;i++) {
			for(int j=0;j!=a+1;j++) {
				if(b-i-j>=0&&b-i-j<=a) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22996
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    char[] s = scanner.next().toCharArray();
    int x = scanner.nextInt();
    int y = scanner.nextInt();

    List<Integer>[] a = new List[2];
    for (int i = 0; i < 2; i++) a[i] = new ArrayList<>();

    int i = 0;
    while (i < s.length && s[i++] == 'F') x--;

    int j = 1;
    for (; i < s.length; i++) {
      int c = i;
      while (i < s.length && s[i] == 'F') i++;
      if (i > c) a[j].add(i - c);
      j = 1 - j;
    }

    if (solve(a[0], Math.abs(x)) && solve(a[1], Math.abs(y))) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

  private static boolean solve(List<Integer> a, int x) {
    final int MAX = 16001;
    boolean[][] dp = new boolean[a.size() + 1][MAX];
    dp[0][0] = true;
    for (int i = 1; i <= a.size(); i++) {
      for (int j = 0; j < MAX; j++) {
        dp[i][j] = false;
        int v = a.get(i - 1);
        if (j - v >= 0) dp[i][j] |= dp[i - 1][j - v];
        if (j + v < MAX) dp[i][j] |= dp[i - 1][j + v];
      }
    }
    return dp[a.size()][x];
  }
}


Measured memory_bytes: 122448
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    Int n; cin >> n;
    string ans = "";
    while(n > 0)
    {
        n--;
        Int p = n % 26LL;
        n /= 26LL;
        char ch = 'a' + p;
        ans += ch;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int num1, num2,num3;
            int result;

            num1 = int.Parse(input[0]);
            num2 = int.Parse(input[1]);
            num3 = int.Parse(input[2]);

            if(num1<=num2*num3)
            {

            }

            Console.WriteLine(num1<=num2*num3 ? "Yes":"No");
        }
    }
}


Measured memory_bytes: 27516
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}

fn main() {
  let s: String = read();
  let len = s.len();

  let zo = ['0', '1'];
  let oz = ['1', '0'];

  let a: Vec<&char> = zo.iter().cycle().take(len).collect();
  let b: Vec<&char> = oz.iter().cycle().take(len).collect();

  let cs: Vec<char> = s.chars().collect();

  let mut an = 0;
  let mut bn = 0;

  for (i, c) in cs.iter().enumerate() {
    if c != a[i] { an += 1 };
    if c != b[i] { bn += 1 };
  }

  let ans = if an < bn { an } else { bn };

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


Measured memory_bytes: 6396
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<stdlib.h>
//#include<string.h>
//#include<algorithm>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)

#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pLL pair<long long,long long>
#define pDB pair<double,double>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
//#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
#define popcountL __builtin_popcountll
#define popcount __builtin_popcount
/// int other=mask^((1<<n)-1);
typedef long long ll;
typedef long long int lln;
typedef pair<int,int> pii;
ll INF=1<<28;
//typedef long long lld;
const double PI=acos(-1.0);
//int fx[]={1,-1,0,0}; //direction array
//int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
int knight[8][2]={1,2,1,-2,2,1,2,-1,-1,2,-1,-2,-2,1,-2,-1};
const long double EPS=1e-7;
//#define INF 10000

struct compare
{
  bool operator()(const pair<int,pii>& l, const pair<int,pii>& r)
  {
      if(l.ff==r.ff)
      {
          return l.sn.ff>r.sn.ff;
      }
      return l.ff<r.ff;
  }
};
// bool operator<(pair<int,pii> l, pair<int,pii> r)
//  {
//      if(l.ff==r.ff)
//      {
//          cout<<"ok "<<endl;
//          return l.sn.ff<r.sn.ff;
//      }
//      return l.ff>r.ff;
//  }

/////////////////////////////////////template sesh/////////////////////////////////////////////////////

///code goes from here
const int mx=300150;
///
int mod=1000000007;


int main()
{
//    SPEED;
//    mem(dp,-1);
    int t,tc=1;
//    sf(t);
    t=1;

    while(t--)
    {
        int n;
        ll d;
        sf(n);
        sl(d);
        ll p,q;
        d*=d;
        int ans=0;
        for(int i=0;i<n;i++)
        {
            sl2(p,q);
            p*=p;
            q*=q;
            p+=q;
            if(p<=d)
                ans++;
        }
        cout<<ans<<endl;
    }


    return 0;
}



Measured memory_bytes: 3684
#include <iostream>

int main()
{
	int a, b, c, d;
	int cont = 0;

	std::cin >> a >> b >> c;
	d = c / 2;

	while (a <= b && a <= d) {
		if (c % a == 0) {
			cont++;
		}
		a++;
	}

	if (a <= c && c <= b) {
		cont++;
	}

	std::cout << cont << std::endl;
}

Measured memory_bytes: 1164
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int inf = 1000000007;
int a[100010];
int b[100010] = {};
signed main() {
	int n;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		b[a[i] - 1]++;
		b[a[i]]++;
		b[a[i]+1]++;
	}
	sort(a, a + n);
	sort(b, b + a[n - 1]+1);
	reverse(b, b + a[n - 1] + 1);
	cout << b[0] << endl;
}


Measured memory_bytes: 1792
while True:
  h, w = [int(n) for n in input().split()]

  if h == 0 and w == 0:
    quit()

  for i in range(0, h):
    for j in range(0, w):
      if i%2 == 0 and j%2 == 1 or i%2 == 1 and j%2 == 0:
        print(".", end='')
      else:
        print("#", end='')
    print()
  print()

Measured memory_bytes: 9164
#include <stdio.h>
#include <string.h>

int main(void) {
  int i;
  char s[100];
  scanf("%s", s);

  for(i=0; i<(int)strlen(s); i++) {
    s[i] = 'x';
  }

  printf("%s\n", s);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <bitset>
using namespace std;
int main(){
  const size_t FIELD = 20001;
  const size_t CENTER = FIELD/2 + 1;

  string s;
  int x,y;
  cin >> s;
  cin >> x>>y;

  vector<int> xquery;
  vector<int> yquery;

  bool xdir = true;
  int fsize = 0;
  s += "T";
  for (char q : s) {
    if (q == 'F') {
      fsize++;
    } else if (q == 'T') {
      //if (fsize == 0) continue;
      if (xdir) {
        xquery.push_back(fsize);
      } else {
        yquery.push_back(fsize);
      }
      xdir = !xdir;
      fsize = 0;
    }
  }
  // cout << "x:" << endl;
  // for (auto e : xquery) cout << e << endl;
  // cout << "y:" << endl;
  // for (auto e : yquery) cout << e << endl;


  bitset<FIELD> xa{1};
  bitset<FIELD> ya{1};
  xa=xa<<(CENTER+xquery[0]);
  ya=ya<<CENTER;

  //for(int i=CENTER-10;i<CENTER+10;i++)cout<<ya[i];
  // cout<<xa<<endl;
  // cout<<ya<<endl;
  xquery.erase(xquery.begin());
  for(int xqi:xquery){
    xa=(xa<<xqi)|(xa>>xqi);
  }

  for(int yqi:yquery){
    ya=(ya<<yqi)|(ya>>yqi);
  }
  // cout<<xa<<endl;
  // cout<<ya<<endl;
  if(xa[CENTER+x]&&ya[CENTER+y])cout<<"Yes\n";
  else cout<<"No\n";


  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    string s;
    cin >> s;
    int a[26] = {};
    REP(i,s.length()){
        a[s[i]-'a']++;
    }
    bool f = 1;
    REP(i,26){
        if (a[i] % 2 == 1) f = 0;
    }
    if (f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
local mma, mmi = math.max, math.min
local n = io.read("*n", "*l")
local t = {}
local tmap = {}
for i = 1, 2 * n do tmap[i] = 0 end
for i = 1, 2 * n do
  local str = io.read()
  local tp, num = str:match("(%w) (%d+)")
  num = tonumber(num)
  if tp == "B" then num = num + n end
  t[i] = num
  tmap[num] = i
end

local wcnt, bcnt = {}, {}
for i = 1, n do
  wcnt[i] = {}
  bcnt[i] = {}
  local wc, bc = 0, 0
  for j = 1, 2 * n do
    if t[j] <= i then
      wc = wc + 1
    end
    if n < t[j] and t[j] - n <= i then
      bc = bc + 1
    end
    wcnt[i][j] = wc
    bcnt[i][j] = bc
  end
end

local d = {}
for i = 1, n + 1 do
  d[i] = {}
  for j = 1, n + 1 do
    d[i][j] = 1000000007
  end
end
d[1][1] = 0
for j = 1, n do
  d[1][j + 1] = d[1][j] + tmap[j] - wcnt[j][tmap[j]]
end
for i = 1, n do
  d[i + 1][1] = d[i][1] + tmap[n + i] - bcnt[i][tmap[n + i]]
  for j = 1, n do
    local sub1 = wcnt[j][tmap[n + i]]
    local sub2 = bcnt[i][tmap[n + i]]

    local sub3 = wcnt[j][tmap[j]]
    local sub4 = bcnt[i][tmap[j]]
    d[i + 1][j + 1] = mmi(d[i][j + 1] + tmap[n + i] - sub1 - sub2, d[i + 1][j] + tmap[j] - sub3 - sub4)
  end
end
print(d[n + 1][n + 1])


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

#define int long long int 

int32_t main()
{
    int n;
    cin>>n;
    set<string>s ;
    vector<string> v;
    for(int i=0;i<n;i++)
    {
        string str;
        cin>>str;
        v.push_back(str);
        s.insert(str);
    }
    if(s.size()!=n)
    {
    cout<<"No"<<endl;
    exit(0);
    }
    for(int i=1;i<n;i++)
        if(v[i-1][v[i-1].size()-1]!=v[i][0])
        {
            cout<<"No"<<endl;
            return 0;
        }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#define MAX 100005
#define NIL -1
int n;
struct Node{
  int p; //parent
  int l; //left-child
  int r; //right sibiling
};
struct Node T[MAX];
void preorder(int i){
  printf(" %d", i);
  if(T[i].l!=NIL) preorder(T[i].l);
  if(T[i].r!=NIL) preorder(T[i].r);
}
void inorder(int i){
  if(T[i].l!=NIL) inorder(T[i].l);
  printf(" %d",i);
  if(T[i].r!=NIL) inorder(T[i].r);
}
void postorder(int i){
  if(T[i].l!=NIL) postorder(T[i].l);
  if(T[i].r!=NIL) postorder(T[i].r);
  printf(" %d",i);
}
int main(void){
  int i;
  int d;
  scanf("%d", &n);
  for ( i=0; i<n; i++ ) T[i].p=T[i].l=T[i].r=NIL;
  for ( i=0; i<n; i++ ){
    scanf("%d", &d);
    scanf("%d %d", &T[d].l, &T[d].r);
    T[T[d].l].p=T[T[d].r].p=d;
  }
  for ( i=0; i<n; i++ ) if(T[i].p==NIL) break;
  printf("Preorder\n");
  preorder(i);
  printf("\nInorder\n");
  inorder(i);
  printf("\nPostorder\n");
  postorder(i);
  printf("\n");
  return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main()
{
    string s;
    cin >> s;
    if(s[0]=='9' || s[1] == '9'){
      cout << "Yes" << endl;
      return 0;
    }
    cout << "No" << endl;
    return 0;
}


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

int main(){
    int n;  cin>>n;
    double t,a; cin>>t>>a;
    double h[n];    for(int i=0;i<n;i++)cin>>h[i];

    int ans;
    double min=1000;

    for(int i=0;i<n;i++){
        double temp=t-h[i]*0.006;
        if(abs(temp-a)<min){
            min=abs(temp-a);
            ans=i+1;
        }
    }

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100000];
int main()
{
	int n,ma=0,m=1000000000,i,t;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	ma=a[n-1];
	printf("%d",ma);
	for(i=0;i<n-1;i++)
	{
		if(abs(a[i]-ma/2)<=m)
		{
			m=abs(a[i]-ma/2);
			t=i;
		}
	}
	printf(" %d",a[t]);
	return 0;
}

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

using namespace std;

const int MAXN = 55 , MAXK = 110 ;

int dp[MAXN][MAXN][MAXK] ;

int n , k ;
int arr[MAXN] ;

int solve(int l , int r , int x)
{
    if(x < 0)
        return (-1e9) ;
    if(x == 0 || l > r)
        return 0 ;
    int &ret = dp[l][r][x] ;
    if(ret != -1)
        return ret ;
    int choice1 = solve(l+1 , r , x-1) + arr[l] ;
    int choice2 = solve(l , r-1 , x-1) + arr[r] ;
    int choice3 = solve(l+1 , r , x-2) ;
    int choice4 = solve(l , r-1 , x-2) ;
    int choice5 = 0 ;
    ret = max(choice1 , choice2) ;
    ret = max(ret , choice3) ;
    ret = max(ret , choice4) ;
    ret = max(ret , choice5) ;
    return ret ;
}

int main()
{
    memset(dp , -1 , sizeof(dp)) ;
    cin>>n>>k ;
    for(int i = 0 ; i < n ; ++i)
        cin>>arr[i] ;
    return cout<<solve(0 , n-1 , k)<<"\n" , 0 ;
}


Measured memory_bytes: 1536
#include <stdio.h>

int main(void) {
	int a,b,i,j,k,n,m,now,ans = 10000,c[64][4] = {0};
	char s[64];
	scanf("%d%d",&n,&m);
	for(i = 1;i <= n;i++){
		scanf("%s",s);
		for(j = 0;j < m;j++){
			if (s[j] == 'W'){c[i][0]++;}
			else if(s[j] == 'B'){c[i][1]++;}
			else if(s[j] == 'R'){c[i][2]++;}
		}
	}
	for(i = 1;i <= n-2;i++){
		for(j = i+1;j <= n-1;j++){
			now = 0;
			for(k = 1;k <= i;k++){
				now+=(c[k][1] + c[k][2]);
			}
			for(k = i + 1;k <= j;k++){
				now+=(c[k][0] + c[k][2]);
			}
			for(k = j + 1;k <= n;k++){
				now+=(c[k][0] + c[k][1]);
			}
			if(now < ans){ans = now;}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
map<pair<int, int>, bool> w;
bool win(int x, int y) {
	if (w.count({x, y})) return w[{x, y}];
	for (int i = 1; 2 * i <= x; ++i) {
		if (!win(x - 2 * i, y + i)) return w[{x, y}] = true;
	}
	for (int i = 1; 2 * i <= y; ++i) {
		if (!win(x + i, y - 2 * i)) return w[{x, y}] = true;
	}
	return w[{x, y}] = false;
}
int main() {
//	for (int i = 0; i <= 20; ++i)
//		for (int j = 0; j <= 20; ++j)
//			if (!win(i, j)) printf("w[%d,%d] = %d\n", i, j, (int)win(i, j));
	ll x, y;
	scanf("%lld%lld", &x, &y);
	printf(abs(x - y) <= 1 ? "Brown\n" : "Alice\n");
}


Measured memory_bytes: 256
import java.io.*;
  
class Main
{
     static InputStreamReader isr;
     static BufferedReader br;
     static String str;
     static String[] data = new String[2];
  
     static void initialize ()
     {
          isr = new InputStreamReader(System.in);
          br = new BufferedReader(isr);
          str = null;
          for (String d : data)
          {
               d = null;
          }
     }
  
     public static void main (String[] args)
     {
           initialize();
           try {
                str = br.readLine();
                data = str.split(" ");
                System.out.println((Integer.parseInt(data[0])*Integer.parseInt(data[1])) + " " + (2*(Integer.parseInt(data[0])+Integer.parseInt(data[1]))));
           } catch (IOException e) {
           } finally {
                try {
                      br.close();
                } catch (IOException e) {
                }
           }
     }
}

Measured memory_bytes: 24416
#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;

// ?????¬???????????¬??????
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), c.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<long, long> pil;

// ??°?????????????????¬??????
typedef int Weight;

struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) {}
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;


int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  printf("%d %d %f\n", a/b, a%b, (double)a/b);

  return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>

using namespace std;
const int N = 1e6 + 10;
typedef pair <int, int> pii;

int n;
pii a[N];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i].first;
		a[i].second = i;
	}

	int ans = 0;
	sort (a, a + n);
	for (int i = 0; i < n; i += 2)
		if ((i % 2) != (a[i].second % 2))
			ans ++;

	cout << ans << endl;
}

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

def make_divisors(n):
    divisors = []
    hei = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort()
    return divisors

m_n = make_divisors(N)
m_n.remove(1)
ans = len(make_divisors(N - 1)) - 1

for i in range(len(m_n)):
  x = N
  y = m_n[i]
  while x % y == 0:
    x = x // y
  if x % y == 1:
    ans += 1
    
print(ans)






  
  

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

#define MAX 12
#define MAX_ORDER 16777216

char dec[MAX_ORDER][MAX];

int getChar_ID(char c){
  if(c == 'A'){
    return 1;
  }else if(c == 'C'){
    return 2;
  }else if(c == 'G'){
    return 3;
  }else if(c == 'T'){
    return 4;
  }else return -1;
}

long analysis(char *str){
  int len = strlen(str);
  int i;
  int id=0;
  int k=1;
  //printf("in to analysis\n" );
  for(i=0; i<len; i++){
    id += k * getChar_ID(str[len-i-1]);
    k *= 4;
    //printf("len-i=%d\n",len-i );
    //printf("Now ID: %d\n", id);
  }
  return id;
}

void insert(int id, char *str){
  strcpy(dec[id],str);
}

void find(int id,char *str){
  if(0==strcmp(dec[id],str)){
    printf("yes\n" );
  }else printf("no\n" );
}

int main() {
  int n;
  char str[MAX];
  char com[7];
  int i;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s %s",com,str);
    if(com[0]=='i'){
      insert(analysis(str),str);
    }else if(com[0]=='f'){
      find(analysis(str),str);
    }else printf("Command is illegal\n");
  }
  return 0;
}



Measured memory_bytes: 18116
def resolve():
    n = int(input())
    a = sorted(map(int, input().split()))

    cost = float("INF")
    mn = 0
    mx = a[-1]
    for aa in a[:-1]:
        tmp = abs(mx - aa * 2)
        if tmp < cost:
            cost = tmp
            mn = aa
    print(mx, mn)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 19980
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;

typedef vector<int> vi;
typedef vector<ui> vui;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vui> vvui;
typedef vector<vll> vvll;
typedef vector<vull> vvull;
typedef vector<vs> vvs;

typedef string ss;
#define forr(i,b) for(int i = 0; i < b; i++)
#define ford(i,b) for(int i = b; i >= 0; i--)
#define ff for(;;)

template<typename T> int sgn(T val) { return (T(0) < val) - (val < T(0)); }
int gcd(int a, int b) { if(a == 0) return b; return gcd(b % a, a); }
int ncr(int n, int k) { int r = 1; if(k > n - k) k = n - k; for(int i=0;i<k;i++) { r *= n - i; r /= i + 1; } return r; }
template<typename T> void printa(vector<T> arr) { for(ui i = 0; i < arr.size(); i++) if(i != arr.size() - 1) cout << arr[i] << ' '; else cout << arr[i] << '\n'; }

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

    int n;
    cin >> n;

    vs s(n);
    unordered_set<string> z;
    forr(i,n) {
        cin >> s[i];
        z.insert(s[i]);
    }
    
    printf("%d\n",z.size());

    return 0;
}



Measured memory_bytes: 23968