akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head
int n, k;
vector<int> a;

bool ok(ll len) {
    ll s = 0;
    ll logs = 0;
    for(int i = 0; i < n; i++) {
        if(a[i] > len) {
            if(a[i] - len <= len) {
                s++;
            } else {
                s += a[i] / len;
            }
        }
    }
    return s <= k;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;
    a.resize(n);
    rep(i,0,n) cin >> a[i];

    ll low = 0;
    for(ll x = 1 << 30; x >= 1; x /= 2) {
        while(!ok(x + low)) low += x;
    }
    cout << low + 1 << endl;
    return 0;
}


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

static const int MAX = 200000;

int main() {
  int a,b;
  cin >> a >> b;
  // long long でキャストしないと答えが合わない
  ll num = ll(a)*b / gcd(a,b);
  cout << num << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;
const int INF = 1e9;
int n;
int p[51];

int main() {
  cin >> n;
  rep(i, n) cin >> p[i];
  int count = 0;
  string ans = "YES";
  for (int i = 0; i < n; ++i) {
    if (p[i] != i + 1) {
      count++;
    }
    if (count >= 3) {
      ans = "NO";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int ans = 0;
		for (char c : S.toCharArray()) {
			ans += c == '-' ? -1 : 1;
		}
		
		System.out.println(ans);
	}
	
}

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

int main() {
  char buf[16] = { 0 };
  int H = 0;
  int W = 0;
  char	*tok = NULL;
  char *input = NULL;
  char *output = NULL;
  
  // H, Wの取得
  fgets(buf, sizeof(buf), stdin);
  tok = strtok(buf, " ");
  H = atoi(tok);
  tok = strtok(NULL, " ");
  W = atoi(tok);
  
  input = (char*)malloc(sizeof(char) * (H + 1) * (W + 2));
  
  for(int i = 0; i < H; i++){
    fgets(input + i * (W + 2), sizeof(char) * (W + 2), stdin);
  }
  
  for(int i = 0; i < W + 2; i++){
    putc('#', stdout);
  }
  putc('\n', stdout);
  
  for(int i = 0; i < H; i++){
    putc('#', stdout);
    output = strtok(input + i * (W + 2), "\n");
    printf("%s", output);
    putc('#', stdout);
    putc('\n', stdout);
  }
  
  for(int i = 0; i < W + 2; i++){
    putc('#', stdout);
  }
  putc('\n', stdout);
  
  free(input);
  return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#define ll long long
using namespace std;

ll Xor(ll a, ll b){
  ll ans=0; int c=0; ll abit,bbit,p,x,y;
  while(a!=0 || b!=0){
    p=pow(2,c); x=a%(2*p); y=b%(2*p);
    abit=x/p; bbit=y/p;
    a = a-x; b = b-y;
    ans = ans + p*((abit+bbit)%2);
    c++;
  }
  return ans;
}

ll convert(ll a){
  if(a%4==0){a=a;}
  else if(a%4==1){a=1;}
  else if(a%4==2){a++;}
  else{a=0;}
  return a;
}

int main(){
  ll A,B; cin >> A >> B;
  
  cout << Xor(convert(A-1),convert(B));
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	ll len=s.length();
	
	vector< pair<ll, pair<ll,ll > > > vecl,vecr;
	
	ll l=0,r=0;
	if(s[0]=='R') r++;
	else l++;
	ll i=1;
	for(i=1;i<n;i++){
		if(s[i]!=s[i-1]){
			if(r>0){
				vecr.push_back({r,{i-1,i-1-r+1}});
				r=0;
			}
			else if(l>0){
				vecl.push_back({l,{i-1,i-1-l+1}});
				l=0;
			}
			if(s[i]=='R') r++;
			else l++;
		}
		else{
			if(s[i]=='R') r++;
			else l++;
		}
	}
	if(r>0){
		vecr.push_back({r,{i-1,i-1-r+1}});
		r=0;
	}
	else if(l>0){
		vecl.push_back({l,{i-1,i-1-l+1}});
		l=0;
	}
	
	vector< pair<ll, pair<ll,ll > > > vecll,vecrr;
	vecll=vecl;vecrr=vecr;
	string u11=s;
	for(ll i=0;i<vecrr.size()&&i<k;i++){
		for(ll j=vecrr[i].second.second;j<=vecrr[i].second.first;j++){
			if(u11[j]=='L') u11[j]='R';
			else u11[j]='L';
		}
	}
	
	ll ans3=0;
	for(ll i=1;i<n-1;i++){
		if(u11[i]=='R'&&u11[i+1]=='R'){
			ans3++;
		}
		else if(u11[i]=='L'&&u11[i-1]=='L'){
			ans3++;
		}
	}
	
	if(u11[0]=='R'&&u11[1]=='R') ans3++;
	if(u11[n-1]=='L'&&u11[n-2]=='L') ans3++;
	
	
	string u22=s;
	for(ll i=0;i<vecll.size()&&i<k;i++){
		for(ll j=vecll[i].second.second;j<=vecll[i].second.first;j++){
			if(u22[j]=='L') u22[j]='R';
			else u22[j]='L';
		}
	}
	
	ll ans22=0;
	for(ll i=1;i<n-1;i++){
		if(u22[i]=='R'&&u22[i+1]=='R'){
			ans22++;
		}
		else if(u22[i]=='L'&&u22[i-1]=='L'){
			ans22++;
		}
	}
	
	if(u22[0]=='R'&&u22[1]=='R') ans22++;
	if(u22[n-1]=='L'&&u22[n-2]=='L') ans22++;
	cout<<max(ans3,ans22)<<endl;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    set<int> s = {1, 2, 3, 4, 5, 0};
    for (int i=0; i<5; i++) {
        int num;
        cin >> num;
        s.erase(num);
    }
    cout << *s.begin() << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

ll lcm(ll u, ll v) {
  return u*v/gcd(u,v);
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll a,b,c;
  cin >> a >> b >> c;
  printf("%lld",a+b+c-max({a,b,c}));
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a, b;
    while (true) {
        cin >> a >> b;
        if (a == 0 && b == 0) {
            break;
        }
        if (a > b) {
            swap(a, b);
        }
        cout << a << " " << b << endl;
    } 
    
    return 0;
}


Measured memory_bytes: 3000
def 解():
    iN = int(input())
    sS = input().rstrip()

    aE= [0]*iN #東向かされる人
    aW= [0]*iN #西向かされる人
    for i in range(1,iN):
        if sS[i-1] == "W":
            aE[i] = aE[i-1]+1
        else:
            aE[i] = aE[i-1]
    for i in range(iN-2,-1,-1):
        if sS[i+1]=="E":
            aW[i] = aW[i+1]+1
        else:
            aW[i] = aW[i+1]

    print(min(map(lambda x,y:x+y,aW,aE)))
解()


Measured memory_bytes: 17612
<?php
    list($width, $height, $num) = explode(" ", trim(fgets(STDIN)));
//    $width = 10;
//    $height = 10;

    $map = array();

    for($i = 0; $i < $width; $i++){
        for($k = 0; $k < $height; $k++){
            $map[$i][$k] = 1;
        }
    }
    
//    $testcase = array(array(1,6,1), array(4,1,3), array(6,9,4), array(9,4,2), array(3,1,3));
    
/*
    for($i = 0; $i < $width; $i++){
        for($k = 0; $k < $height; $k++){
            echo $map[$i][$k];
        }
        echo PHP_EOL;
    }
*/

    for($i = 0; $i < $num; $i++){
//    for($ite = 0; $ite < 5; $ite++){
        list($x, $y, $a) = explode(" ", trim(fgets(STDIN)));
//        $x = $testcase[$ite][0];
//        $y = $testcase[$ite][1];
//        $a = $testcase[$ite][2];

        switch ($a) {
            case '1':
                for($n = 0; $n < $height; $n++){
                    for($m = 0; $m < $x; $m++){
                        $map[$m][$n] = 0;
                    }
                }
                break;

            case '2':
                for($n = 0; $n < $height; $n++){
                    for($m = $width - 1; $m >= $x; $m--){
                        $map[$m][$n] = 0;
                    }
                }
                break;
            
            case '3':
                for($n = 0; $n < $width; $n++){
                    for($m = 0; $m < $y; $m++){
                        $map[$n][$m] = 0;
                    }
                }
                break;

            case '4':
                for($n = 0; $n < $width; $n++){
                    for($m = $height - 1; $m >= $y; $m--){
                        $map[$n][$m] = 0;
                    }
                }
                break;
            default:
                break;
        }
/*
    for($k = $height - 1 ; $k >= 0; $k--){
        for($i = 0 ; $i < $width; $i++){
            echo $map[$i][$k];
        }
        echo PHP_EOL;
    }
    echo PHP_EOL;
*/        
    }
    
    $ans = 0;

    for($k = $height - 1 ; $k >= 0; $k--){
        for($i = 0 ; $i < $width; $i++){
            $ans += $map[$i][$k];
        }
    }
    echo $ans;
?>


Measured memory_bytes: 5240
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))

e = [(1+p[i]) / 2 for i in range(n)]
#print(e)

s = sum(e[:k])
ans = [s]
for i in range(n-k):
    s = s-e[i] + e[i+k]
    ans.append(s)

#print(ans)
print(max(ans))

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

int main() { 
  int N;
  ll C, K;
  cin >> N >> C >> K;
  vector<ll> T(N);
  rep(i, N) cin >> T[i];
  sort(T.begin(), T.end());
  int ans = 0;
  rep(i, N) {
    int index = upper_bound(T.begin(), T.end(), T[i]+K) - T.begin();
    ans++;
    if (index - i <= C) {
      i = index - 1;
    } else {
      i += (C - 1);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4020
#include<bits/stdc++.h>
#define INF 50000
#define FOR(i,a,b) for(int i = (a);i<(b);i++)
using namespace std;

int k,t,ax=0,ans;
int a[INF];

int solve(void){
	if((k+1)/2>ax)return 0;
	return(ax*2-(k+1));
}

int main(){
	cin>>k>>t;
	FOR(i,0,t){
		cin>>a[i];
		ax=fmax(ax,a[i]);
	}
	
	ans=solve();
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define REP(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 

int B[5001][26];
int main() {
    int N, Q;
    string S;
    cin >> N;
    cin >> S;
    
    rep(i, N){
        B[i/1000][S[i] - 'a']++;
    }
    cin >> Q;
    int l, r, i;
    string c;
    rep(q, Q){
        int aa;
        cin >> aa;
        if (aa == 1){
            cin >> i >> c;
            //cout << i << " " << c << endl;
            B[i/1000][S[i - 1] - 'a']--;
            B[i/1000][c[0] - 'a']++;
            S[i - 1] = c[0];
        } else {
            int j, k;
            cin >> l >> r;
            l--;
            r--;
            int s = l/1000;
            int f = r/1000;
            int cnt[26];
            
            rep(i, 26)cnt[i] = 0;

            //cout << s << " " << f << endl;
            if (s + 1 >= f){
                for (k = l; k <= r; k++){
                    cnt[S[k] - 'a'] ++;
                }
            } else {
                for (j = s + 1; j < f; j++){
                    rep(i, 26)
                        cnt[i] += B[j][i];
                }

                //rep(i, 26)
                //    cout << i <<  " " << cnt[i] << endl;
                for (k = l; k < (s + 1) * 1000; k++){
                    cnt[S[k] - 'a'] ++;
                }
                for (k = f * 1000; k <= r; k++){
                    cnt[S[k] - 'a'] ++;
                }
            }
            int ans = 0;
            rep(i, 26)if (cnt[i])ans++;
            cout << ans << endl;
        }
        //cout << q << " " << S << endl;
    }
        
    
    
}


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

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

    string s;
    map<string, int> ans;
    for (auto i = 0; i < n; i++) {
        cin >> s;
        ans[s]++;
    }

    cin >> m;
    for (auto i = 0; i < m; i++) {
        cin >> s;
        ans[s]--;
    }

    int max = 0;
    for (const auto& elm : ans) {
        if(elm.second > max) max = elm.second;
    }

    cout << max << endl;
    return 0;
}

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

fn run_length_encoding<T: Clone + Eq>(a: &[T]) -> Vec<(T, usize)> {
    if a.len() == 0 {
        return vec![];
    }
    let mut x = a[0].clone();
    let mut cnt = 1;
    let mut ans = vec![];
    for y in &a[1..] {
        if x == *y {
            cnt += 1;
        } else {
            ans.push((x, cnt));
            x = y.clone();
            cnt = 1;
        }
    }
    ans.push((x, cnt));
    ans
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let s: Vec<char> = it.next().unwrap().chars().collect();
    let k: usize = it.next().unwrap().parse().unwrap();
    let mut s = run_length_encoding(&s);
    let ans = if s.len() == 1 {
        s[0].1 * k / 2
    } else if s[0].0 == s.last().unwrap().0 {
        let mut ans = 0usize;
        let b = s.pop().unwrap();
        let f = s.remove(0);
        ans += b.1 / 2 + f.1 / 2 + (b.1 + f.1) / 2 * (k - 1);
        for (_, c) in s {
            ans += c / 2 * k;
        }
        ans
    } else {
        let mut ans = 0;
        for (_, c) in s {
            ans += c / 2 * k;
        }
        ans
    };
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>
#include <complex>
#include <vector>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
typedef complex<double> P;
#define EPS (1e-10)

double cross(const P& a, const P& b) { return imag(conj(a)*b); }
double dot(const P& a, const P& b) { return real(conj(a)*b); }
int ccw(const P& a, P b, P c) {
    b -= a; c -= a;
    if(cross(b, c)>0) return 1;
    if(cross(b, c)<0) return -1;
    if(dot(b, c)<0) return 2;
    if(norm(b)<norm(c)) return -2;
    return 0;
}
P crosspoint(const P& l0, const P& l1, const P& m0, const P& m1) {
    const double a = cross(l1-l0, m1-m0);
    const double b = cross(l1-l0, l1-m0);
    if(abs(a)<EPS && abs(b)<EPS) return m0;
    return m0 + b/a*(m1-m0);
}
double polygon_size(const vector<P>& v) {
    double s = 0;
    rep(i, v.size()-2) s += cross(v[i+1]-v[0], v[i+2]-v[0]);
    return fabs(s)/2;
}
vector<P> convex_cut(const vector<P>& v, const P& l0, const P& l1) {
    vector<P> r;
    rep(i, v.size()) {
        const P &a(v[i]), &b(v[(i+1)%v.size()]);
        if(ccw(l0, l1, a)!=-1) r.push_back(a);
        if(ccw(l0, l1, a)*ccw(l0, l1, b)<0) {
            r.push_back(crosspoint(l0, l1, a, b));
        }
    }
    return r;
}

int main() {
    for(;;) {
        int n;
        scanf("%d", &n);
        if(n==0) return 0;
        vector<P> ps;
        rep(i, n) {
            int x, y;
            scanf("%d%d", &x, &y);
            ps.push_back(P(x, y));
        }
        vector<P> v;
        const int Z = 100000;
        v.push_back(P(-Z, -Z));
        v.push_back(P(Z, -Z));
        v.push_back(P(Z, Z));
        v.push_back(P(-Z, Z));
        rep(i, n) v = convex_cut(v, ps[i], ps[(i+1)%n]);
        printf("%d\n", polygon_size(v)>EPS);
    }
}

Measured memory_bytes: 0
#include <stdio.h>

int main(){

  int a,n,s4=0,s2=0,s0=0;

  scanf("%d",&n);
  int i;
  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(a%4==0)s4++;
    else if(a%2==0)s2++;
    else s0++;
  }

  int res=0;
  if(s2>0)s2=1;

  if(s0==0)res=1;
  else if(s0==0 && s4==0)res=1;
  else if(s4==n)res=1;
  else if(s2+s0-1<=s4)res=1;

  if(res>0)printf("Yes\n");
  else printf("No\n");

  return 0;

}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define reps(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define pb push_back

ll n, t, a, b;
string s;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    rep (i, 4) cout << s[i];
    cout << ' ';
    rep(i, 8) cout << s[i+4];
    cout << '\n';
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;

ll choose(ll n){
    return n * (n-1) / 2;
}

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n) a[i]--;
    vector<int> cnt(n);
    rep(i,n) cnt[a[i]]++;
    ll sum = 0;
    rep(i,n){
        sum += choose(cnt[i]);
    }
    rep(i,n){
        ll ans = sum;
        ans -= choose(cnt[a[i]]);
        ans += choose(cnt[a[i]]-1);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4096
int main(){
    int N;
    scanf("%d",&N);
    int num = 0;
    int max = 1;
    for(int i=1;i<=N;i++){
        int j=i;
        int count = 0;
        while(j%2==0&&j!=0)
        {
            j /= 2;
            count++;
        }
        if(count>=num){num=count;max=i;}
    }
    printf("%d",max);
    return 0;
}


Measured memory_bytes: 128
Ss = list(map(int, input()))

n = len(Ss)
ans = 0
for pat in range(1 << (n - 1)):
    num = 0
    temp = Ss[0]
    mask = 1
    for i in range(n - 1):
        if pat & mask:
            num += temp
            temp = Ss[i + 1]
        else:
            temp = temp * 10 + Ss[i + 1]
        mask <<= 1
    num += temp
    ans += num

print(ans)


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define debug(v) {for (auto x : v) cerr << x << ' '; cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int a, b;
	cin >> a >> b;
	if (b % a == 0)
		cout << (a + b) << endl;
	else
		cout << (b - a) << endl;
}


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

int main(){
  int n;
  cin>>n;
  vector<string> a(n);
  for(int i=0;i<n;i++){
      cin >>a[i];
  }
  sort(a.begin(),a.end());
  vector<pair<int,string> > b(1);
  for(int i=0;i<n;i++){
      if(i==0||a[i]!=a[i-1]){
          pair<int,string> v(1,a[i]);
          b.push_back(v);

      }
      else{
          b[b.size()-1].first++;
      }
  }
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  int i=0;
  vector<string> c(0);
  while(b[i].first==b[0].first){
      c.push_back(b[i].second);
      i++;
  }
  reverse(c.begin(),c.end());
  for(int i=0;i<c.size();i++){
    cout<<c[i]<<endl;
  }

}  


  

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

using namespace std;

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

int main(){
  int n;
  cin >> n;
  vector<vector<int> > a(n);
  REP(i, n){
    a[i].resize(n - 1);
    REP(j, n - 1){
      int d;
      cin >> d;
      --d;
      a[i][j] = d;
    }
  }
  vector<int> d(n * n);
  vector<vector<int> > e(n * n);
  REP(i, n){
    REP(j, n - 1){
      int p = max(i, a[i][j]);
      int q = min(i, a[i][j]);
      int x = q * n + p;
      if(j > 0){
        ++d[x];
      }
      if(j < n - 2){
        int p = max(i, a[i][j + 1]);
        int q = min(i, a[i][j + 1]);
        int y = q * n + p;
        e[x].push_back(y);
      }
    }
  }
  priority_queue<pair<int, int> > q;
  REP(i, n){
    REP(j, n) if(j > i){
      int x = i * n + j;
      if(d[x] == 0) q.push({-1, x});
    }
  }
  int c = 0;
  int r = -1;
  while(!q.empty()){
    int b, x;
    tie(b, x) = q.top();
    q.pop();
    ++c;
    for(auto& k: e[x]){
      --d[k];
      if(d[k] == 0){
        q.push({b - 1, k});
      }
    }
    r = b;
  }
  if(c == n * (n - 1) / 2){
    cout << -r << endl;
  }else{
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 47104
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int a[5];
    rep(i,5){cin>>a[i];}
    int res=0;
    int aa=10;
    rep(i,5){
        if(a[i]%10==0){
            res += a[i];
        }else{
            res += (a[i]/10+1)*10;
            aa = min(aa,a[i]%10);
        }
    }
    if(aa!=10){
        res += aa;
        res -=10;
    }
    cout << res << endl;
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll M;
    cin >> M;
    cout << 24 - M + 24 << endl;
    return 0;
}


Measured memory_bytes: 3528
#include <stdio.h>

// バブルソートを行う関数
int* bubbleSort(int* u, int N){
  int i,j;
  int temp;

  for(i=0; i<N; i++){
    for(j = N-1; j>i; j--){
      if(u[j] < u[j-1]){
        temp = u[j];
        u[j] = u[j-1];
        u[j-1] = temp;
      }
    }
  }
  return u;
}

int main(){
  int N;
  long int ans1; // ans1はans2に2の(N-1)乗を掛けたもの
  double ans2; // 答え
  scanf("%d",&N); 
  int u[N];
  long int pow[N]; // pow[n]は2のn乗の値を返す。まずは0で初期化。
  pow[0] = 1;
  scanf("%d",&u[0]); 
	for (int i = 1; i < N; i++){
	  scanf("%d",&u[i]); 
    pow[i] = pow[i - 1] * 2;
	}

  bubbleSort(u, N); // 小さいもの順に並べる
  
  ans1 = u[0];
	for (int i = 1; i < N; i++){
	  ans1 += u[i] * pow[i - 1];
	}
  ans2 = (double)ans1 / pow[N - 1];
  printf("%f", ans2);
}

Measured memory_bytes: 128
def test():
    s = input()
    a = []
    count = 0
    if s[0] == "A":
        for i in range(2,len(s)-1):
            if s[i] == "C":
                a.append(i)
                count += 1

    s2 = list(s)
    for i in a:
        s2.remove(s[i])

    s3 = "".join(s2[1:])

    if count == 1 and s3.islower():
        print("AC")
    else:
        print("WA")


if __name__ == "__main__":
    test()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


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

///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}

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

int n,m,q;
int r[510][510];
signed main(){
  cin>>n>>m>>q;
  rep(i,m){
    int l, rr;cin>>l>>rr;
    repd(i,1,l+1)r[i][rr]++;
  }
  repd(i,1,n+1)repd(j,2,n+1)r[i][j] += r[i][j-1];
  rep(i,q){
    int p, q;cin>>p>>q;cout << r[p][q] << endl;
  }
}




Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a) cout<<k;
    else if(k>a&&k<=a+b) cout<<a;
    else cout<<a-(k-a-b);
    return 0;
}


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

using namespace std;

#define allof(x) (x).begin(), (x).end()

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

const int MAXN = 2005;

int N, K, Q;
int arr[MAXN];

pii sorted[MAXN];

struct BIT {
    int data[MAXN];
    void update(int pos, int val){
        while(pos < MAXN){
            data[pos] += val;
            pos += pos & -pos;
        }
    }

    int query(int pos){
        int ans = 0;
        while(pos){
            ans += data[pos];
            pos -= pos & -pos;
        }
        return ans;
    }
}ds;

int solve(int lowv){
    memset(ds.data, 0, sizeof ds.data);

    for(int a = 1; a <= N; a++){
        ds.update(a, 1);
    }

    set<int> illegal;
    illegal.insert(0);
    illegal.insert(N + 1);

    int used = 0;

    for(int a = 1; a <= N; a++){
        if(sorted[a].first < lowv){
            illegal.insert(sorted[a].second);
            ds.update(sorted[a].second, -1);
        } else {
            auto iter = illegal.lower_bound(sorted[a].second);
            int lft = *prev(iter);
            int rht = *iter;
            if(ds.query(rht) - ds.query(lft) >= K){
                //good
                used++;
                if(used == Q) {
                    return sorted[a].first - lowv;
                }
            }
            ds.update(sorted[a].second, -1);
        }
    }
    return 1e9;
}

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

    cin >> N >> K >> Q;
    for(int a = 1; a <= N; a++){
        cin >> arr[a];
        sorted[a] = pii(arr[a], a);
    }

    sort(sorted + 1, sorted + N + 1);

    int ans = 1e9;
    for(int a = 1; a <= N; a++){
        ans = min(ans, solve(arr[a]));
    }
    cout << ans;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<iomanip>
using namespace std;


int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int w[n], e[n];
    if (s[0] == 'E'){
        e[0] = 1;
        w[0] = 0;
    }
    else{
        e[0] = 0;
        w[0] = 1;
    }
    for (int i = 1; i < n; i++){
        if (s[i] == 'E') {
            e[i] = e[i-1]+1;
            w[i] = w[i-1];
        }
        else {
            w[i] = w[i-1]+1;
            e[i] = e[i-1];
        }
    }
    int d[n];
    d[0] = 1000000;
    int val = 1000000;
    for (int i = 0; i < n; i++){
        if (i > 0){
            val = w[i-1]+(e[n-1]-e[i]);
        }
        if (i == 0) {
            val = (e[n-1]-e[i]);
        }
        if (i == n-1) {
            val = w[i-1];
        }
        if (i == 0) d[i] = val;
        else if (val < d[i-1]) d[i] = val;
        else d[i] = d[i-1];
    }
    cout << d[n-1];
    return 0;
}

Measured memory_bytes: 4228
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# a->b, possible with using at most c as max
T = [[[None] * 51 for _ in range(51)] for _ in range(51)]

def dp(a, b, c):
  if T[a][b][c] is not None:
    return T[a][b][c]
  if a == b:
    T[a][b][c] = True
    return T[a][b][c] 
 # if c == 0:
 #   T[a][b][c] = b == 0
 #   return T[a][b][c] 
  if b >= c or a < b:
    T[a][b][c] = False
    return T[a][b][c] 
  if dp(a, b, c-1):
    T[a][b][c] = True
    return T[a][b][c] 
  else:
    T[a][b][c] = dp(a % c, b, c-1)
    return T[a][b][c]

T2 = [[None] * 51 for _ in range(51)]
def min_c(a, b):
  if T2[a][b] is not None:
    return T2[a][b]
  for c in range(51):
    if dp(a,b,c):
      T2[a][b] = c
      return T2[a][b]
  T2[a][b] = 51
  return T2[a][b]

#print(min_c(14,0))
#print(min_c(14,4))
  
def solve():
  count = 0
  for a, b in zip(A,B):
    if a < b:
      print(-1)
      return
    if a > b:
      count += 1
#  print(count)
#  print(list(zip(A, B)))
 # return
  
  cost = 0
  ABs = [{(a, b)} if a > b else set() for a, b in zip(A,B)]
  while count:
    # min->max
    mm = [min(min_c(a, b) for a, b in s) if s else 0 for s in ABs]
    m = max(mm)
    if m > 50:
      print(-1)
      return
    
    cost += 2 ** m
    for i in range(len(ABs)):
      if mm[i] == m:
        new_s = set()
        done = False
        for a, b in ABs[i]:
          if min_c(a % m, b) == 0:
            done = True
            break
          elif min_c(a, b) == m:
            new_s.add((a % m, b))
        if done:
          count -= 1
          ABs[i] = set()
        else:
          ABs[i] = new_s
      else:  # optional
        new_s = set()
        done = False
        for a, b in ABs[i]:
          if min_c(a % m, b) == 0:
            done = True
            break
          elif min_c(a % m, b) < m:
            new_s.add((a % m, b))
        if done:
          count -= 1
          ABs[i] = set()
        else:
          ABs[i].update(new_s)
        
  print(cost)
    
    
    

solve()
  


Measured memory_bytes: 10304
#include<iostream>
#include<vector>
#include<cstdlib>
#include<algorithm>
#include<functional>

using namespace std;

int main() {
	int N, M;
	typedef pair<long, long> p;
	vector<p> n, m;
	vector<int> res;

	cin >> N >> M;

	for (int i = 0;i < N;i++) {
		long a, b;
		cin >> a >> b;
		n.push_back(make_pair(a, b));
	}

	for (int i = 0;i < M;i++) {
		long c, d;
		cin >> c >> d;
		m.push_back(make_pair(c, d));
	}

	for (int i = 0;i < n.size();i++) {
		int near = 51;
		long min = 1000000000;
		for (int j = 0;j < m.size();j++) {
			long d = abs(n[i].first - m[j].first) + abs(n[i].second - m[j].second);

			if (d < min) {
				near = j;
				min = d;
			}
		}
		cout <<near+1 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#define z 10
ptr[20],c,d,e,s,i,j;
main(){
#if 1
	for(i=0;i*z<128;i++)ptr[i]=i*z;
	for(i=0;i<z;i++)putchar('+');
	putchar('[');
	for(i=0;i*z<128;i++)for(putchar('>'),j=0;j<i;j++)putchar('+');
	for(i=0;i*z<128;i++)putchar('<');
	putchar('-'),putchar(']');
	for(e=-1;~(c=getchar())&&c!='\n';putchar('.')){
		if(s='>',d=c/z-e,d<0)d=-d,s='<';
		for(i=0;i<d;i++)putchar(s);
		e=c/z;
		if(s='+',d=c-ptr[c/z],d<0)d=-d,s='-';
		for(i=0;i<d;i++)putchar(s);
		ptr[c/z]=c;
	}
#else
	putchar('>');
	for(e=0;~(c=getchar())&&c!='\n';putchar('.')){
		if(s='+',d=c-e,d<0)d=-d,s='-';
		if(d/z){
			putchar('<');
			for(i=0;i<d/z;i++)putchar('+');
			putchar('['),putchar('>');
			for(i=0;i<z;i++)putchar(s);
			putchar('<'),putchar('-'),putchar(']'),putchar('>');
		}
		for(i=0;i<d%z;i++)putchar(s);
		e=c;
	}
#endif
exit(0);}

Measured memory_bytes: 524
//#pragma GCC optimize("O-fast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma comment(linker, "/STACK:367077216")

#include <iostream>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

#define pii pair<int, int>
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define pop pop_back

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; long long k;
	cin >> n >> k;
	vector <int> a(n + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	vector <int> used(n + 1, false);
	vector <int> cycle;
	int i = 1;
	while (!used[i]) {
		used[i] = true;
		i = a[i];
	}
	fill(all(used), false);
	while (!used[i]) {
		used[i] = true;
		cycle.push_back(i);
		i = a[i];
	}
	i = 1;
	while (k > 0 && i != cycle[0]) {
		--k;
		i = a[i];
	}
	if (k == 0) {
		cout << i;
	}
	else {
		cout << cycle[k % (int)cycle.size()];
	}
	return 0;
}

Measured memory_bytes: 5740
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

const int MX = 1001001;

int n, a, b, c;
vector<int> l;

int dfs(int cur, int a0, int b0, int c0) {
    if (cur == n) {
        if (a0 > 0 && b0 > 0 && c0 > 0)
            return abs(a-a0) + abs(b-b0) + abs(c-c0) - 30;
        else
            return MX;
    }
    int ret0 = dfs(cur + 1, a0, b0, c0);
    int ret1 = dfs(cur + 1, a0 + l[cur], b0, c0) + 10;
    int ret2 = dfs(cur + 1, a0, b0 + l[cur], c0) + 10;
    int ret3 = dfs(cur + 1, a0, b0, c0 + l[cur]) + 10;
    return min(min(min(ret0, ret1), ret2), ret3);
}

int main()
{
    cin >> n >> a >> b >> c;
    l = vector<int>(n);
    rep(i,n) cin >> l[i];
    cout << dfs(0, 0, 0, 0) << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int n=sc.nextInt();
	  long[] a=new long[n];
	  for(int i=0;i<n;i++)a[i]=sc.nextLong();
	  Arrays.sort(a);
	  long sum=1;
	  for(int i=0;i<n;i++) {
		  try{
			  sum=Math.multiplyExact(sum, a[i]);
		  }catch(ArithmeticException e){
			  System.out.println(-1);
			  System.exit(0);
		  }
		  if(sum>1000000000000000000L) {
			  System.out.println(-1);
			  System.exit(0);
		  }
	  }
	  System.out.println(sum);
  }
}



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

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

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

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

    sort(A.begin(), A.end());
    int ans = 0;
    for(int i = 0; i < q; i++){
        int idx = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        if(idx < n && B[i] == A[idx]){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3400
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main() {
    double N, T, A;
    cin >> N >> T >> A;
    vector<int> H(N);
    double diff = 1e9;
    int site = 0;

    for (int i = 1; i <= N; ++i) {
        cin >> H[i];
        double temp = T - H[i] * 0.006;
        if (fabs(A - temp) < diff) {
            diff = fabs(A - temp);
            site = i;
        }
    }
    cout << site << endl;
    return 0;
}

Measured memory_bytes: 256
color = [0 for i in range(8)]

n = int(input())
al = list(map(int,input().split()))

p = 0
for a in al:
    if a < 3200:
        color[a//400] = 1
    else:
        p += 1
print(max(sum(color), 1))
print(sum(color) + p)

Measured memory_bytes: 3060
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int h, w, i, j;
	char s[50][51];
	scanf("%d%d", &h, &w);
	for(i=0; i<h; i++){
		scanf("%s", s[i]);
	}
	for(i=0; i<h; i++){
		for(j=0; j<w; j++){
			if(s[i][j]!='#') continue;
			if(i!=0 && s[i-1][j]=='#') continue;
			if(i!=h-1 && s[i+1][j]=='#') continue;
			if(j!=0 && s[i][j-1]=='#') continue;
			if(j!=w-1 && s[i][j+1]=='#') continue;
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static class Node {
        int parent, left, right;
        Node() {
            this.left = -1;
            this.right = -1;
        }
    }
    public static int MAX = 100005;
    public static int n;
    public static Node[] T = new Node[MAX];
    static int[] D = new int[MAX];
    static int[] H = new int[MAX];

    static void setDepth(int u, int d) {
        if(u == -1) return;
        D[u] = d;
        setDepth(T[u].left, d+1);
        setDepth(T[u].right, d+1);
    }

    static int setHeight(int u) {
        int h1 = 0, h2 = 0;
        if(T[u].left != -1)
            h1 = setHeight(T[u].left) + 1;
        if(T[u].right != -1)
            h2 = setHeight(T[u].right) + 1;
        return H[u] = (h1 > h2 ? h1 : h2);
    }

    static int getSibling(int u) {
        if(T[u].parent == -1) return -1;
        if(T[T[u].parent].left != u && T[T[u].parent].left != -1)
            return T[T[u].parent].left;
        if(T[T[u].parent].right != u && T[T[u].parent].right != -1)
            return T[T[u].parent].right;
        return -1;
    }

    static void print(int u) {
        System.out.print("node " + u + ": ");
        System.out.print("parent = " + T[u].parent + ", ");
        System.out.print("sibling = " + getSibling(u) + ", ");
        int deg = 0;
        if(T[u].left != -1) deg++;
        if(T[u].right != -1) deg++;
        System.out.print("degree = " + deg + ", ");
        System.out.print("depth = " + D[u] + ", ");
        System.out.print("height = " + H[u] + ", ");

        if(T[u].parent == -1) {
            System.out.println("root");
        } else if(T[u].left == -1 && T[u].right == -1) {
            System.out.println("leaf");
        } else {
            System.out.println("internal node");
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int v = 0, l = 0, r = 0, root = 0;
        n = sc.nextInt();

        for(int i = 0; i < n; i++) {
            T[i] = new Node();
            T[i].parent = -1;
        }

        for(int i = 0; i < n; i++) {
            v = sc.nextInt();
            l = sc.nextInt();
            r = sc.nextInt();

            T[v].left = l;
            T[v].right = r;
            if(l != -1) T[l].parent = v;
            if(r != -1) T[r].parent = v;
        }
        for(int i = 0; i < n; i++) if(T[i].parent == -1) root = i;

        setDepth(root, 0);
        setHeight(root);

        for(int i = 0; i < n; i++) print(i);
    
    }
}



Measured memory_bytes: 27464
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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")
    };
}

macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
        t: [i64; n],
        m: usize,
        px: [(usize1,i64); m],
    }
    for d in px {
        let mut sum: i64 = 0;
        for (i,y) in t.iter().enumerate() {
            if i == d.0 {
                sum += d.1
            } else {
                sum += *y
            }
        }
        println!("{}", sum);
    }
}


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

long long gcd(long long a, long long b) {
	if (!a) return 0;
	if (b%a==0) return 2LL*(b/a)*a-a;
    return 2LL*a*(b/a)+gcd(b%a,a);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long N, X;
	cin>>N>>X;
	cout << N+gcd(X,N-X) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main () {
    int x;
    int a;
    int b;
    int total1;
    int total2;
    scanf("%d%d%d", &x, &a, &b);
    total1 = x-a;
    total2 = x-b;

    if(total1<0){
        total1 = total1 * -1;
}

    if(total2<0){
        total2 = total2 * -1;
    }

    if (total1>total2){
        printf("B");
    }
    if (total1<total2) {
        printf("A");
    }
        return 0;


}

Measured memory_bytes: 3156
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  a*=b;
  printf("%.20f\n",a/3.305785);
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define nline printf("\n")
#define space printf(" ")
using namespace std;
 
void read(int &x)
{ scanf("%d", &x); }
void write(int &x)
{ printf("%d", x); }
 
const int N = 100000 * 2 + 10;
 
int n;
int a[N];
int b[N];
 
bool check(int val){
    for (int i = 1; i <= 2 * n - 1; i++)
        b[i] = (a[i] >= val);
   
    bool flag = 1;
    for (int i = 2; i <= 2 * n - 1; i++)
        flag &= (b[i] != b[i - 1]);
    if (flag) // all flip bit
        return (n % 2 == 0 ? !b[n] : b[n] );
   
    int posL = 0, posR = 0;
    for (int i = n; i <= 2 * n - 1; i++)
        if (b[i] == b[i + 1]) {posL = i; break; }
    for (int i = n; i >= 1; i--)
        if (b[i] == b[i - 1]) {posR = i; break; }
    if (!posL) return b[posR];
    if (!posR) return b[posL];
    return (abs(posR - n) < abs(posL - n) ? b[posR] : b[posL]);
}
 
main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("pyramid.inp", "r", stdin);
    //freopen("pyramid.out", "w", stdout);
   
    read(n);
    for (int i = 1; i <= 2 * n - 1; i++)
        read(a[i]);
   
    int d = 1, c = 2 * n - 1, ans = -1;
    while (d <= c){
        int m = (d + c) / 2;
        if (check(m) )
            ans = max(ans, m),
            d = m + 1;
        else c = m - 1;
    }
    cout << ans;
}


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

int main(){
    char s[100005];
    cin >> s;

    int ans1=0, ans2=0;
    int n;
    for(int i=0; i<strlen(s); ++i){
        if(s[i] == '1')
            n = 1;
        else
            n = 0;

        if(n == i%2)
            ans1++;
        else
            ans2++;
    }

    cout << min(ans1, ans2) << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#define INF 1<<30
#define FinishFunction return 0
#define MAX 1000000
using namespace std;
 
 
struct edge {
  int from,to,cost,k;
};
 
edge es[MAX];
 
 
 
int main(){
  int n,u,k,E,c,v;
  E = 0;
  scanf("%d",&n);
 
  for(int i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    
    for(int j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      es[E].from = u;
      es[E].to = v;
      es[E++].cost = c;
    }
  }
 
   
  int d[MAX];
  for(int i=0;i<n;i++)d[i] = INF;
  d[0] = 0;
  while(true){
    bool update = false;
    for(int i=0;i<E;i++){
      edge e = es[i];
      if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
    d[e.to] = d[e.from] + e.cost;
    update = true;
      }
    }
    if(!update)break;
 
 
  }
 
  for(int i=0;i<n;i++)cout << i << " " << d[i] << endl;
 
  FinishFunction;
}

Measured memory_bytes: 8644