akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn adder (i: usize, j: usize) -> isize{
    let mut pow: usize = 1;
    for k in 1..i {
        pow *= 10;
    }
    (pow * j) as isize
}

fn main(){
    input!{
        n: usize,
        m: usize,
        s: [(usize, usize); m]
    }
    let mut new = s;
    new.sort();
//    new.sort_by(|&(x, y), &(a, b)| x.cmp(&a) && y.cmp(&b));
    let mut a: usize = 0;
    let mut b: usize = 0;
    let mut result: isize = 0;
    for (i, j) in new {
        if i == 1 && j == 0 && n > 1 {result = -1; break}
        if i == a && j != b {result = -1; break;}
        else if i == a && j == b {}
        else {
            result += adder(n-i+1, j);
        }
        a = i;
        b = j;
    }
    print!("{}", if n < 2 {result} else if result == -1 {-1} else if adder(n, 1) <= result && result < adder(n+1, 1){result} else {result + adder(n, 1)})
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int n,cnt,x,c[1010],a[1010];
int main()
{
  //freopen("1.in","r",stdin);freopen("1.out","w",stdout)
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>x;
    c[x]++;
    if(c[x]==1) a[++cnt]=x; 
  } 
  cout<<cnt<<endl;
  return 0;
}


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

#define ll long long int
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)

using namespace std;
using mii=map<int, int>;
using mll=map<ll, ll>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int mod = 1000000007;

ll desc(ll x, ll y)
{
    return x > y;
}

bool isPerfectSquare(long double x)
{
    // Find floating point value of
    // square root of x.
    long double sr = sqrt(x);

    // If square root is an integer
    return ((sr - floor(sr)) == 0);
}

int main() {
    fastIO
    int i, n, d1;
    cin >>  n >> d1;
    vector<vector<int>> arr(n, vector<int>(d1));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d1; j++) {
            cin >> arr[i][j];
        }
    }

/*
    for(const auto x: arr) {
        vector<int> temp = x;
        for(auto x1: temp)
            cout << x1 << " ";
        cout << endl;
    }
*/
    ll c = 0;
    fo(i, n)
    {

        for(int j = i+1; j<n ;j++)
        {
            long double d = 0;
            for(int k = 0; k < arr[j].size(); k++)
            {
                d += pow(arr[i][k] - arr[j][k] ,2);
            }
            if(isPerfectSquare(d))
                c += 1;
        }
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
s = str(input())
n = len(s)-1

for i in range(2**n):
  op = ['-']*n
  for j in range(n):
    if (i >> j) & 1:
      op[j] = '+'

  formula = ''
  op = op + ['']
  for s_, p_ in zip(list(s), op):
      formula += s_ + p_
  if eval(formula) == 7:
      print(formula+'=7')
      exit()

Measured memory_bytes: 3064
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! {
        x: i64,
        k: i64,
        d: i64
    }

    let x_abs = x.abs();
    let num = (x_abs / d).abs();
    if num >= k {
        println!("{}", x_abs - d * k);
    } else {
        let a = (x_abs - d * num).abs();
        let b = (x_abs - d * (num + 1)).abs();
        if (k - num) % 2 == 0 {
            println!("{}", a);
        } else {
            println!("{}", b);
        }
    }
}

// x / d + 1 または x / d または k 回移動した後の位置となる


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

long long MOD = 1e9+7;

template <typename T>
T modMinus(T a, T b, T mod) {
  return (a>b)? (a-b)%mod: modMinus(mod+a, b, mod);
}

template <typename T>
T modPow(T base, T e, T mod) {
  if(e==0) return 1;
  if(e==1) return base%mod;
  if(e%(T)2==1) return (base * modPow(base, e-(T)1, mod)) %mod;
  
  T tmp = modPow(base, e/(T)2, mod);
  return (tmp * tmp) % mod;
}

template <typename T>
T primeModDiv(T num, T den, T primeMod){
  return (num*modPow(den, primeMod-(T)2, primeMod)) % primeMod;
}

template <typename T>
T modComb(T n, T k, T mod) {
  T num = (T)1; //numerator
  T den = (T)1; //denominator
  for (T i = (T)1; i <= k; i++) {
    num *= (n-i+1);
    num %= mod;
    den *= i;
    den %= mod;
  }
  return primeModDiv(num, den, mod);
}

int main(){
  long long n, a, b;
  cin >> n >> a >> b;

  long long ans = modPow(2LL, n, MOD)-1LL;
  ans = modMinus(ans,modComb(n,a,MOD),MOD);
  ans = modMinus(ans,modComb(n,b,MOD),MOD);
  
  cout << ans << endl;
  
}


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

ll N;
int main(){
    cin >> N;
    ll ans = 0;
    for(ll i = 1;i*i <= N; ++i){
        if(N%i==0){
            ll div1 = i - 1;
            ll div2 = N / i - 1;
            if(div1!=0 && N / div1 == N % div1) ans += div1;
            if(div2!=0 && N / div2 == N % div2) ans += div2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define lint long long

int N = 301 ;
double dp[301][301][301] ;
int n ;

double solve(int cnt1, int cnt2, int cnt3)
{
    int total = cnt1 + cnt2 + cnt3 ;
    if(total <= 0) return 0.0 ;
    double ans = dp[cnt1][cnt2][cnt3] ;
    if(ans != -1.0) return ans ;
    double EV = (double)n/(total);
    double child = 0 ;
    int moves = 0 ;
    if(cnt1 > 0)
    {
        moves += cnt1 ;
        child += cnt1 * solve(cnt1 - 1, cnt2, cnt3);
    }
    if(cnt2 > 0)
    {
        moves += cnt2 ;
        child += cnt2 * solve(cnt1 + 1, cnt2 - 1, cnt3);
    }
    if(cnt3 > 0)
    {
        moves += cnt3 ;
        child += cnt3 * solve(cnt1, cnt2 + 1, cnt3 - 1);
    }
    ans = EV + (child)/(double) moves ;
    return dp[cnt1][cnt2][cnt3] = ans ;
}

int main()
{
    int x, i = 0, j = 0, k = 0 ;
    for(i = 0; i < N; i++)
        for(j = 0; j < N; j++)
            for(k = 0; k < N; k++)
                dp[i][j][k] = -1 ;

    scanf("%d", &n); int cnt1 = 0, cnt2 = 0, cnt3 = 0 ;
    for(i = 0; i < n; i++)
    {
        scanf("%d", &x);
        if(x == 1) cnt1++ ;
        else if(x == 2) cnt2++ ;
        else cnt3++ ;
    }
    printf("%0.9f", solve(cnt1, cnt2, cnt3)) ;
}


Measured memory_bytes: 213376
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Collection;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Deque;
import java.util.LinkedList;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int K = in.nextInt();
            boolean[] marked = new boolean[K];
            Deque<TaskD.State> bfs = new LinkedList<>();
            bfs.add(new TaskD.State(1, 1 % K));
            while (!bfs.isEmpty()) {
                TaskD.State st = bfs.pollFirst();
                if (st.rem == 0) {
                    out.println(st.sum);
                    return;
                }
                marked[st.rem] = true;

                TaskD.State ns = new TaskD.State(st.sum + 1, (st.rem + 1) % K);

                if (!marked[ns.rem]) {
                    bfs.addLast(ns);
                }

                ns = new TaskD.State(st.sum, 10 * st.rem % K);

                if (!marked[ns.rem]) {
                    bfs.addFirst(ns);
                }
            }
        }

        static class State {
            int sum;
            int rem;

            public State(int sum, int rem) {
                this.sum = sum;
                this.rem = rem;
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

    }
}



Measured memory_bytes: 42708
#include<bits/stdc++.h>
using namespace std;
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long

void lol(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif	
}

void solve(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto &x: a) cin >> x;
	vector<int> dp(n,0);
	for(int i=n-2; i>=0;i--){
		// cout << i << " "; 
		dp[i] = dp[i+1] + abs(a[i] - a[i+1]);
		if(i != n-2) dp[i] = min(dp[i], dp[i+2] + abs(a[i] - a[i+2]));
	}
	cout << dp[0];
}

int main(){
	FAST(); 
	// lol();
	int t; t = 1; while(t--) solve();
	return 0;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int h, w;
bool a[1005][1005];
int main() {
	std::cin >> h >> w;

	std::queue<std::pair<int, int>> que[2];
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j) {
			char tmp;
			std::cin >> tmp;
			a[i][j] = tmp == '#';
			if (a[i][j])
				que[0].emplace(i, j);
		}


	int turn = 0;
	int next = 1;
	ll ans = 0;
	const int dirx[] = { 1,0,-1,0 };
	const int diry[] = { 0,1,0,-1 };
	while (true) {

		bool check = false;
		while (!que[turn].empty()) {
			auto p = que[turn].front();
			que[turn].pop();

			for (int i = 0; i < 4; ++i) {
				int posx = p.first + dirx[i];
				int posy = p.second + diry[i];
				if (posx < 0 || posx >= h || posy < 0 || posy >= w || a[posx][posy])
					continue;
				a[posx][posy] = true;
				que[next].emplace(posx, posy);
				check = true;
			}
		}

		if (check)
			++ans;
		else
			break;
		turn = (turn + 1) % 2;
		next = (next + 1) % 2;
	}

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


Measured memory_bytes: 9360
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1e9;
const double PI = acos(-1.0);

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

	string W;
	cin >> W;
	transform(W.begin(), W.end(), W.begin(), ::toupper);

	int count = 0;
	string T;
	while(cin >> T) {
		if(T == "END_OF_TEXT") break;
		transform(T.begin(), T.end(), T.begin(), ::toupper);
		if(T == W) count++;
	}

	cout << count << "\n";

	return 0;
}

Measured memory_bytes: 1196
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> inline T GCD_L(T a,T b){
  T r;
  while(a){
    r=b;
    b=a;
    a=r%a;
  }
  return b;
}
template<class T> inline T LCM_L(T a,T b){
  return a/GCD_L(a,b)*b;
}
int N;
int M;
int A[100000];
int main(){
  int i;
  long long g = 1;
  rd(N);
  rd(M);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  M *= 2;
  while(A[0]%2==0){
    int i;
    M /= 2;
    for(i=(0);i<(N);i++){
      if(A[i]%2){
        wt_L(0);
        wt_L('\n');
        return 0;
      }
      A[i] /= 2;
    }
  }
  for(i=(0);i<(N);i++){
    if(A[i]%2==0){
      wt_L(0);
      wt_L('\n');
      return 0;
    }
  }
  for(i=(0);i<(N);i++){
    g =LCM_L(g, (long long)A[i]);
    if(g > M){
      wt_L(0);
      wt_L('\n');
      return 0;
    }
  }
  wt_L((M+g)/(2*g));
  wt_L('\n');
  return 0;
}
// cLay varsion 20191229-1 [beta]

// --- original code ---
// int N, M, A[1d5];
// {
//   ll g = 1;
//   rd(N,M,A(N));
//   M *= 2;
//   while(A[0]%2==0){
//     M /= 2;
//     rep(i,N){
//       if(A[i]%2) wt(0), return 0;
//       A[i] /= 2;
//     }
//   }
//   rep(i,N) if(A[i]%2==0) wt(0), return 0;
//   rep(i,N){
//     g = lcm(g,(ll)A[i]);
//     if(g > M) wt(0), return 0;
//   }
//   wt((M+g)/(2g));
// }


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define txt                        \
    freopen("ip.txt", "r", stdin); \
    freopen("op.txt", "w", stdout)
#define a3 INT_MAX
#define i3 INT_MIN
#define a6 INT64_MAX
#define i6 INT64_MIN
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define quickie                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define div2(a) (!(a & 1))
#define deb(x) cout << (#x) << " " << (x) << "\n";
#define newl cout << "\n"
#define pi 3.14159265358979323846
#define mod 1000000007
#define all(s) s.begin(), s.end()
#define fp(x) fixed << setprecision(x) <<
template <class T>
int sumAllInts(T n)
{
    int a = 1;
    int su = 0;
    while (n)
    {
        su += n % 10;
        n /= 10;
    }
    return su;
}
template <class T>

int digit(T a)
{
    vector<long long> dig = {
        0,
        9,
        99,
        999,
        9999,
        99999,
        999999,
        9999999,
        99999999,
        999999999,
        9999999999,
        99999999999,
        999999999999,
        9999999999999,
        99999999999999,
        999999999999999,
        9999999999999999,
        99999999999999999,
        999999999999999999,
        INT64_MAX};
    auto it = lower_bound(dig.begin(), dig.end(), a);
    int idx = (it - dig.begin());
    return idx;
}
template <class T>
void split(char c, T s)
{
    int n = s.size();
    int i = 0;
    while ((cout << s[i], i += 1) && (i < n) && (cout << c << ' '))
        ;
}
int digit(int a)
{
    int r;
    r = (a >= 1000000000) ? 9 : (a >= 100000000) ? 8 : (a >= 10000000) ? 7 : (a >= 1000000) ? 6 : (a >= 100000) ? 5 : (a >= 10000) ? 4 : (a >= 1000) ? 3 : (a >= 100) ? 2 : (a >= 10) ? 1 : 0;
    return r + 1;
}
int main()
{
    quickie;
    //txt;
    int a,b; cin>>a>>b;

    if (a == 1)
    {
        a = 14;
    }
    if (b == 1)
    {
        b = 14;
    }
    if (a > b)
    {
        cout << "Alice";
    }
    else if (a < b)
    {
        cout << "Bob";
    }
    else
    {
        cout << "Draw";
    }

    return 0;
}

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

int coin[]{ 500,100,50,10,5,1 };
int n[6];

int main() {
	int p;
	while (scanf("%d", &p), p) {
		rep(i, 6)scanf("%d", &n[5 - i]);
		int Min = INT_MAX;
		for (int i = 0; i <= 500; i++) {
			int cnt = 0, k = i, d = i + p;
			rep(j, 6) {
				int t = min(k / coin[j], n[j]), y = min(d / coin[j], n[j]);
				cnt += t; cnt += y;
				k -= coin[j] * t;
				d -= coin[j] * y;
			}
			Min = min(Min, cnt);
		}
		printf("%d\n", Min);
	}
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
}

ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}

ll mod = 1000000007;

ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
} 

int main()
{
	ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.length();
    ll dp[n][13];
    for(int i=0;i<n;i++){
        for(int j=0;j<13;j++){
            dp[i][j] = 0;
        }
    }
    if(s[0]!='?'){
        dp[0][s[0]-'0'] = 1;
    }
    else{
        for(int i=0;i<=9;i++){
            dp[0][i] = 1;
        }
    }
    for(int i=1;i<n;i++){
        if(s[i]!='?'){
            for(int j=0;j<13;j++){
                dp[i][((j*10)%13+(s[i]-'0'))%13] =(dp[i][((j*10)%13+(s[i]-'0'))%13]+dp[i-1][j])%mod;
            }
        }
        else{
             for(int j=0;j<13;j++){
               for(int k=0;k<=9;k++){
                    dp[i][((j*10)%13+(k))%13] =(dp[i-1][j]%mod + dp[i][((j*10)%13+k)%13]%mod)%mod;
                }
            }
        }
    }
    cout << dp[n-1][5] << endl;
    return 0;
}

Measured memory_bytes: 10704
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
const double PI = acos(-1.0), EPS = 1e-9;
const int MX=3*1e5+10;
int N, M, k;
int arr[MX];
ll f(ll x, ll y)
{
    int s=0;
    while(x <= y)
    {
        s++;
        x*=2;
    }
    return s;
}
int main()
{
    ll x, y;
    cin>>x>>y;
    int ans=f(x, y);
    for(ll xx=x;xx<min(10LL, y);xx++)
        ans=max(ans, (int)f(xx, y));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int N = 9;

int main() {
  REP(i, N){
    string s;
    int a, b;
    cin >>s >>a >>b;
    cout <<s <<" " <<a + b <<" " <<a * 200 + b * 300 <<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
n = int(input())
nums = list(map(int, input().split()))

nums.sort()

ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if nums[i] != nums[j] and nums[j] != nums[k] and nums[k] < (nums[i]+nums[j]):
                ans += 1

print(ans)


Measured memory_bytes: 9184
#include<iostream>
using namespace std;
int main()
{
    int r,c,sum=0;
    cin>>r>>c;
    int box[r][c],sum2[r]={0},sum3[c]={0};
    for(int R=0;R<r;R++){
        for(int C=0;C<c;C++){
            cin>>box[R][C];
            sum3[C]+=box[R][C];
            sum2[R]+=box[R][C];
            sum+=box[R][C];
        }
    }
    for(int h=0;h<r;h++){
        for(int w=0;w<c;w++){
            cout<<box[h][w]<<" ";
            if(w==c-1)cout<<sum2[h]<<endl;
        }
    }
    for(int u=0;u<c;u++){
        cout<<sum3[u]<<" ";
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3124
#![allow(non_snake_case, unused_imports)]

// Input
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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        S: chars,
    }
    let mut ans = 0;
    for s in S{
        if s == '+'{
            ans += 1;
        }else{
            ans -= 1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
N = int(input())
A = list(map(int,input().split()))
d = dict()
for i in range(N):
    d[A[i]]=0
for n in range(N):
    
    if d[A[n]] == 1:
        print("NO")
        break
    if n == N-1:
        print("YES")
    d[A[n]] = 1






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

int main() {

	ll x, k, d; cin >> x >> k >> d;
	if (x < 0) x *= -1;
	ll quo = x / d;
	ll mod = x % d;
	ll ans;

	if (d == x) {
		if (k % 2 == 0) {
			ans = x;
		}
		else {
			ans = 0;
		}
	}
	else {
		if (quo <= k) {
			if (k % 2 == quo % 2) {
				ans = mod;
			}
			else {
				ans = abs(d - mod);
			}
		}
		else if (k < quo) {
			ans = d * (quo - k) + mod;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3548
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n = int(input())
    s = input()

    res = s.count('R') * s.count('G') * s.count('B')
    if res == 0:
        print(0)
        sys.exit()
    for i1 in range(n):
        for i2 in range(i1+1, n):
            i3 = i2 * 2 - i1
            if i3 <= n - 1:
                if s[i1] != s[i2] and s[i1] != s[i3] and s[i2] != s[i3]:
                    res -= 1
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9216
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    int a, b, sum1 = 0, sum2 = 0, avg, p = 0;
    while(scanf("%d,%d", &a, &b) != EOF) {
        if (a == 0) break;
        sum1 += a*b;
        sum2 += b;
        p++;
    }
    avg = (sum2 % p) ? sum2 / p + 1 : sum2 / p;
    printf("%d\n%d\n", sum1, avg);

    return 0;
}



Measured memory_bytes: 2612
import java.util.Scanner;

public class Main {

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

		if (x < a) {
			System.out.println(0);
		} else {
			System.out.println(10);

			// TODO Auto-generated method stub

		}

	}
}

Measured memory_bytes: 20820
N,M=map(int,input().split())
A=list(map(int,input().split()))
P=[i for i in range(N)]
size=[1 for i in range(N)]

def find(a):
    if a==P[a]:
        return a
    else:
        return find(P[a])
        
def union(b,c):
    B=find(b)
    C=find(c)
    if size[B]>=size[C]:
        P[C]=P[B]
        size[B]+=size[C]
    else:
        P[B]=P[C]
        size[C]+=size[B]
for i in range(M):
    x,y=map(int,input().split())
    if find(x)!=find(y):
        union(x,y)
        
p=[]
for i in range(N):
    p.append([A[i],find(P[i])])
#print(p)
p.sort()
ANS1=[]
ANS2=[]
d={}
for i in range(N):
    if p[i][1] in d:
        ANS2.append(p[i][0])
    else:
        d[p[i][1]]=1
        ANS1.append(p[i][0])
#print(ANS1,ANS2)
if (len(ANS1)+len(ANS1)-2)>N:
    print("Impossible")
elif len(ANS1)==1:
    print(0)
else:
    ANS=sum(ANS1)+sum(ANS2[:len(ANS1)-2])
    print(ANS)

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

int main(){
    int n,m;
    cin>>n>>m;
    int lb=0,ub=n;
    for(int i=0;i<m;i++){
        int l,r;
        cin>>l>>r;
        l--;
        lb=max(lb,l);
        ub=min(ub,r);
    }
    cout<<max(ub-lb,0)<<endl;
    return 0;
}

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

int main(void)
{
    int L;
    cin >> L;

    double x = L / 3.0;
    cout << fixed << setprecision(30) << x * x*x << endl;

    //double ans = 0;
    //for (int i = 1; i <= L; i++) {
    //    for (int j = 1; j <= L; j++) {
    //        int k = L - i - j;
    //        if (k <= 0)
    //            continue;

    //        ans = max(ans, 1.0*i*j*k);
    //    }
    //}

    //cout << fixed << setprecision(30) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
 
int main() {
    int h, w;
    int sy, sx;
    int gy, gx;
    char field[51][51];
    int ans[51][51];

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

    cin >> h >> w;

    int i, j;
    int count = 0; //白の個数を数える
    for(i = 0; i < h; i++){
        for(j = 0; j < w; j++){
            cin >> field[i][j];
            if(field[i][j] == '.'){
                count++;
            }
            ans[i][j] = 1000000;
        }
    }
    
    sy = 1; sx = 1; gy = h; gx = w;

    queue<pair<int, int>> q;
    q.push(make_pair(sy, sx));
    ans[sy-1][sx-1] = 1;
    int change;
    while(!q.empty()){
        pair<int, int> p = q.front();
        q.pop();
        if(p.first == gy && p.second == gx){
              change = ans[p.first-1][p.second-1];
              break;
        }
        for(i = 0; i < 4; i++){
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(nx >= 1 && nx <= w && ny >= 1 && ny <= h && field[ny-1][nx-1] != '#' && ans[ny-1][nx-1] == 1000000){
                q.push(make_pair(ny, nx));
                ans[ny-1][nx-1] = ans[p.first-1][p.second-1] + 1;
            }
        }
    }

    if(change == 0){//たどり着けない
        cout << -1 << endl;
    }else{
        cout << count - change << endl;
    }

}

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

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    string s;
    cin>>s;
    int oa=0,ob=0;
    for(int i=0;i<n;i++){
        if(s[i]=='c')cout<<"No"<<endl;
        else if(s[i]=='a'){
            if(oa+ob<a+b){
                cout<<"Yes"<<endl;
                oa++;
            }else{cout<<"No"<<endl;}
        }else if(s[i]=='b'){
            if(oa+ob<a+b&&ob<b){
                cout<<"Yes"<<endl;
                ob++;
            }else{cout<<"No"<<endl;}
        }
    }
    return 0;
}

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

void solve(long long N, long long M){
	std::vector<int> divisors;
	for(int i = sqrt(M); i >= 1; i--) {
		if(M % i == 0) {
			divisors.emplace_back(i);
			divisors.emplace_back(M/i);
		}
	}

	std::sort(divisors.begin(), divisors.end(), greater<int>());

	for(int i : divisors) {
		if(M/N >= i) {
			cout << i << endl;
			return;
		}
	}

	cout << 1 << endl;
}

int main(){	
	long long N;
	long long M;
	scanf("%lld",&N);
	scanf("%lld",&M);
	solve(N, M);
	return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:268435456")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#ifndef _MSC_VER
#pragma GCC target ("sse4.2")
#endif
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <random>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;



int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif

	int x, n;
	cin >> x >> n;
	set<int> a;
	for (int i = 0; i < n; i++)
	{
		int p;
		cin >> p;
		a.insert(p);
	}
	int res = INT_MAX, rv = 0;
	for (int i = -200; i <= 200; i++)
	{
		if (a.count(i))
			continue;
		if (abs(i - x) < res)
		{
			res = abs(i - x);
			rv = i;
		}
	}
	cout << rv;
	return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

#define PI 3.14159265359

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double th = atan2(b, a), area = x / a;
    double l = 0, r = PI / 2;
    for (int i = 0; i < 1000; ++i) {
        double ang = (l + r) / 2, maxa;
        if (ang < th) {
            maxa = a * b - a * a * 0.5 * tan(ang);
        }
        else {
            maxa = b * b * 0.5 / tan(ang);
        }
        if (maxa < area) {
            r = ang;
        }
        else {
            l = ang;
        }
    }
    cout << fixed << setprecision(10);
    cout << l * 180 / PI << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;

int main(){
    int N, X, Y; cin >> N >> X >> Y;
    X--;Y--;
    vector<vector<int>> V(N, vector<int>(N));
    for(int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; j++) V[i][j] = j-i;
    }
    map<int, int> M;
    for(int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; j++){
            if(i <= X){
                if(j < Y) V[i][j] = min(V[i][j], X-i + 1 + Y-j);
                else V[i][j] = X-i+1+abs(Y-j);
                
            }
            else {
                V[i][j] = min(V[i][j], i - X + 1 + abs(Y-j));
            }
            M[V[i][j]]++;
        }
    }
    for(int i = 1; i < N; i++) cout << M[i] << endl;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  if (S.at(K - 1) == 'A') {
    S.at(K - 1) = 'a';
  }
  if (S.at(K - 1) == 'C') {
    S.at(K - 1) = 'c';
  }
  if (S.at(K - 1) == 'B') {
    S.at(K - 1) = 'b';
  }
  cout << S << endl;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long n,a,b,c;
    cin >> n;
    
    a = n / 500;
    n %= 500;
    b = n/5;
        
    cout << a*1000 + b*5 << endl;

    return 0;
    
}


Measured memory_bytes: 256
a,b,c = map(int, input().split())
k = int(input())


cnt = 0
# let b > a
while a >= b:
  b *= 2
  cnt += 1

# let c > b
while b >= c:
  c *= 2
  cnt += 1

if k < cnt:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 61584
<?php
$n=intval(trim(fgets(STDIN)));
$ds=explode(' ',trim(fgets(STDIN)));
$sum = 0;
for ($i=0;$i<$n-1;$i++) {
  for ($j=$i+1;$j<$n;$j++) {
    $sum += $ds[$i] * $ds[$j];
  }
}
echo $sum;

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

const int MAX = 100000;
const int INF = 1e9;
int dp[MAX];

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

    int n, k;
    cin >> n >> k;
    vector<int> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    for(int i = 0; i <= n; i++){
        dp[i] = INF;
    }
    dp[0] = dp[1] = 0;

    for(int i = 1; i < n; i++){
        for(int j = 1; j <= k; j++){
            if(i + j > n) continue;
            dp[i + j] = min(dp[i + j], dp[i] + abs(A[i - 1] - A[i + j - 1]));
        }
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.io.*;
    import java.util.*;
    import java.util.LinkedList;

    public class Main {

        public static void main(String[] args) throws IOException {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            InputReader in = new InputReader(inputStream);
            InputReader.OutputWriter out = new InputReader.OutputWriter(outputStream);
            BufferedReader reader = new BufferedReader(new InputReader(System.in));

            int n = in.nextInt();
            int [] a = new int[n];
            for (int i = 0; i < a.length; i++) {
                a[i] = in.nextInt();
            }
            int [] dp = new int[n];
            int max = 0;
            Arrays.fill(dp,1);
            int k = 1;
            for (int i = 0; i < n; i++) {
                if(a[i] == k) {
                    k++;
                }
            }
            k--;
            if(k == 0) {
                out.println(-1);
            }
            else {
                out.println(n - k);
            }
            out.flush();
        }
        private static int gcd(int a, int b) {
            return b == 0 ? a : gcd(b,a%b);
        }
    }

    class InputReader extends BufferedReader {
        StringTokenizer tokenizer;

        public InputReader(InputStream inputStream) {
            super(new InputStreamReader(inputStream), 32768);
        }

        public InputReader(String filename) {
            super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
        }

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

        public Integer nextInt() {
            return Integer.valueOf(next());
        }
        public Long nextLong() {
            return  Long.valueOf(next());
        }
        public Double nextDouble () {
            return Double.valueOf(next());
        }


        static class OutputWriter extends PrintWriter {
            public OutputWriter(OutputStream outputStream) {
                super(outputStream);
            }

            public OutputWriter(Writer writer) {
                super(writer);
            }

            public OutputWriter(String filename) throws FileNotFoundException {
                super(filename);
            }

            public void close() {
                super.close();
            }
        }
    }


Measured memory_bytes: 48324
#include<bits/stdc++.h>
using namespace std;
struct A{
	int num,score;
}a[55];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].score;
		a[i].num=i;
	}
	int sum=0;
	for(int i=1;i<=n;i++){
		if(a[i].score!=a[i].num){
			sum++;
		}
	}
	if(sum==2||sum==0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
} 

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

namespace ConsoleApp1
{
    static class CBuildStairs
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var hList = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();

            bool error = false;
            for (int i = 0; i < n - 1; i++)
            {
                if (hList[i + 1] - hList[i] < 0)
                {
                    error = true;
                    break;
                }
                if (1 <= hList[i + 1] - hList[i])
                {
                    hList[i + 1]--;
                }
            }

            Console.WriteLine(error ? "No" : "Yes");
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 28380
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll power(ll x,ll y,ll m){            //power(x,y)=x^y  %m;
if(y==0)return 1;
int ll a=power(x,y/2,m);
if(y%2){
return (a*((a*x)%m))%m;
}
else{
return (a*a)%m;
}
}
ll mod_inverse(ll x,ll m){
return power(x,m-2,m);
}
ll fact(ll n,ll m){
if(n<=1)return 1;
return (fact(n-1,m)*n)%m;
}
ll ncr(ll n,ll r,ll m){
ll n1=1,d1=1,d2=1;
n1=fact(n,m);d1=fact(r,m);d2=fact(n-r,m);
ll ans=mod_inverse((d1*d2)%m,m);
ans=(ans*n1)%m;
return ans;
}
// tyu tiouyiioiu
string lcs(string s,string t,ll n,ll m)
{
	int LCS[n+1][m+1];
	int i,j,k;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=m;j++)
		{
			if(i==0||j==0)
			LCS[i][j]=0;
			else if(s[i-1]==t[j-1])
			LCS[i][j]=LCS[i-1][j-1]+1;
			else
			LCS[i][j]=max(LCS[i-1][j],LCS[i][j-1]);
			
		}
	}
	string temp;
	for(i=n,j=m;i&&j;)
	{
		if(LCS[i][j]==LCS[i-1][j])
		i--;
		else if((LCS[i][j]==LCS[i][j-1]))
		j--;
		else
		{temp.push_back(s[i-1]);i--;j--;
		}
	}
	//temp.reverse();
	reverse(temp.begin(),temp.end());
	return temp;
}
int main()
{
	string a,b;
	cin>>a;
	cin>>b;
	string c=lcs(a,b,a.size(),b.size());
	cout<<c<<endl;
	return 0;
	
}



Measured memory_bytes: 35456
n = int(input())
h = list(map(int, input().split()))
ans = 0
# 水やり = (l<=i<=r)区間のh[i]を-1すると考える
# hの要素が全て0になるまで繰り返す
while sum(h) != 0:
    # 初期化
    left = float("inf")
    right = float("inf")
    # 連続した自然数の区間を見つける
    # 左端番号leftの設定
    for i in range(n):
        if h[i] > 0:
            left = i
            break
    # 右端番号rightの設定
    for j in range(i + 1, n):
        if h[j] <= 0:
            right = j
            break
    if right == float("inf"):
        right = n
    # 見つけた区間の全ての要素を-1
    for i in range(left, right):
        h[i] -= 1
    ans += 1
print(ans)

Measured memory_bytes: 3064
'use strict'

const main = input => {
	const args = input.trim().split('\n')
	const n = parseInt(args[0], 10)
	const a = args[1].split(' ').map(Number)
	let cnt = 0

	while (true) {
		let isOdd = false 

		for (let i = 0; i < n; i++) {
			if (a[i] % 2 === 1) isOdd = true
		}

		if (isOdd) break

		for (let i = 0; i < n; i++) {
			a[i] = Math.floor(a[i] / 2)
		}

		cnt++
	}

	console.log(cnt)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ll k;
	cin >> k;
	ll rem = 7%k;
	arep(1,i,1000000){
		if(rem==0){
			cout << i << endl;
			return 0;
		}
		rem = (rem*10+7)%k;
	}
	cout << "-1" << endl;
}

Measured memory_bytes: 3536
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int, int> P;
struct edge {
	int to, cost;
	edge(int t, int c):to(t), cost(c) {}
};

vector<vector<edge> > es;
vector<int> d;
const int INF = 0xfffffff;

int dijkstra(int s, int t) {
	priority_queue<P, vector<P>, greater<P> > que;
	que.push(P(0, s));
	d[s] = 0;
	
	while(!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;

		if(v == t)
			return d[t];

		if(d[v] < p.first)
			continue;

		for(int i=0; i<es[v].size(); i++) {
			edge e = es[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

inline int dist(const P& a, const P& b) {
	return abs(a.first - b.first) + abs(a.second - b.second);
}

int stoi(string s) {
	istringstream is(s);
	int res;
	is >> res;
	return res;
}

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

	for(int w, h; cin >> w >> h, w | h;) {
		int layer = 0;
		int num = 2;
		P g;
		vector<vector<pair<int, P> > > m(1);

		for(int i = 0; i < h; ++i) {
			for(int j = 0; j < w; ++j) {
				string in;
				cin >> in;

				if(in == "S")
					m[0].push_back(make_pair(0, make_pair(i, j)));

				else if(in == "G")
					g = make_pair(i, j);

				else if(isdigit(in[0])) {
					int digit = stoi(in);
					while(layer < digit) {
						m.push_back(vector<pair<int, P> >());
						++layer;
					}

					m[digit].push_back(make_pair(num++, make_pair(i, j)));
				}
			}
		}

		m.push_back(vector<pair<int, P> >(1, make_pair(1, g)));

		es.clear();
		es.resize(num);

		for(int i = 0; i + 1 < m.size(); ++i) {
			for(int j = 0; j < m[i].size(); ++j) {
				int from = m[i][j].first;
				P fpos = m[i][j].second;
				for(int k = 0; k < m[i + 1].size(); ++k) {
					int to = m[i + 1][k].first;
					P tpos = m[i + 1][k].second;
					es[from].push_back(edge(to, dist(fpos, tpos)));
				}
			}
		}

		d.clear();
		d.resize(num, INF);
		cout << dijkstra(0, 1) << endl;
	}


	return EXIT_SUCCESS;
}

Measured memory_bytes: 4860
import java.util.*;

public class Main{
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt();
	    int m=sc.nextInt();
	    int k=sc.nextInt();
	    long[] a=new long[n+1];
	    long[] b=new long[m+1];
	    
	    long[] ac=new long[n+1];
	    long[] bc=new long[m+1];
	   
	    for(int i=1;i<=n;i++) {
	    	a[i]=sc.nextInt();
	    	ac[i]=ac[i-1]+a[i];
	    }
	    
	    for(int i=1;i<m+1;i++) {
	    	b[i]=sc.nextInt();
	    	bc[i]=bc[i-1]+b[i];
	    }
	    
	  
	    int ans=0;
	    int ind=m;
		for(int i=0;i<=n;i++) {
			if(ac[i]>k)break;
			long rest=k-ac[i];
			
			while(bc[ind]>rest) {
				ind--;
				//System.out.println(ind);
			}
				ans=Math.max(i+ind, ans);
				
		}
		    
		
		System.out.println(ans);
	}

}
	

Measured memory_bytes: 68024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N;
  cin >> N;
  vector<ll> D(N);
  for (ll i = 0; i < N; i++) {
    cin >> D[i];
  }
  sort(begin(D), end(D));
  const auto diff = D[N / 2] - D[N / 2 - 1];
  cout << diff << endl;

  return 0;
}


Measured memory_bytes: 1024
N = int(input())
S = input()
l = 0
r = S[1:].count('E')
ans = l+r

for i in range(1, N):
    if S[i-1] == 'W':
        l += 1
    
    if S[i] == 'E':
        r -= 1
    ans = min(ans, r+l)

print(ans)

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

using namespace std;
int main()
{
    string g;
    cin >> g;
    int n;
    cin >> n;
    for(int w=0;w<g.size();w+=n)
    {
        cout << g[w];
    }
    cout << "\n";
    return 0;//ww
}


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

using namespace std;

#define INF 1001000100010001000
#define int long long 
#define rep(i, N) for (int i = 0; i < N; i++)
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define vi vector<int>
#define vvi vector< vi >

string funami_yui(int n)
{
    string ret;
    while (n) {
        ret.push_back((n % 2) + '0');
        n /= 2;
    }
    //reverse(ret.begin(), ret.end());
    return ret;
}


signed main()
{
    int n;
    cin >> n;

    string st = funami_yui(n);
//    cout << st << endl;

    rep(i, st.size()) {
        if (st[i] == '0') {
            std::cout << (int)pow(2LL, i) << std::endl;
            //printf("%lld\n", (int)pow(2LL, i)); 
            return 0;
        }
    }
    std::cout << (int)pow(2LL, st.size()) << std::endl;
    //printf("%lld\n", (int)pow(2LL, st.size())); 

    return 0;
}

Measured memory_bytes: 3336
# -*- coding: utf-8 -*-

a, b, k = map(int, input().split())
if k > b - a:
    for i in range(a, b+1):
        print(i)
else:
    low = [i for i in range(a, a+k)]
    high = [i for i in range(b-k+1, b+1)]
    high_removed = [i for i in high if i not in low]
    for l in low:
        print(l)
    for h in high_removed:
        print(h)

Measured memory_bytes: 3064
N,_ = gets.split(" ").map{|i| i.to_i}
A = gets.split("")
B = gets.split("")
C = gets.split("")

def add(h,a)
	h[a].nil? ? h[a]=1 : h[a]+=1
end
sum = 0
for i in 0..(N-1)
	h = {}
	add(h,A[i])
	add(h,B[i])
	add(h,C[i])
	num = h.max{|m1,m2| m1[1] <=> m2[1]}[1]
	sum += 3-num
end
puts sum



Measured memory_bytes: 1788