akhauriyash/Code-Regression huggingface dataset:
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, K = getlist()
	A = getlist()
	B = [0]
	for i in range(N):
		B.append(B[-1] + A[i])
	# print(B)
	S = []
	for i in range(N + 1):
		for j in range(i + 1, N + 1):
			S.append(B[j] - B[i])
	# print(S)

	z = 0
	for i in range(41):
		z += 2 ** (40 - i)
		cnt = 0
		for j in S:
			if z & j == z:
				cnt += 1
		if cnt < K:
			z -= 2 ** (40 - i)

	print(z)

if __name__ == '__main__':
	main()

Measured memory_bytes: 65788
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int n, i;
  cin >> n >> i;
  cout << n-i+1 << endl;
  return 0;
}

Measured memory_bytes: 256
def sums(n):
    ans = 0
    while n > 0:
        a = n%10
        n = n//10
        ans += a
    return(ans)

N, A, B = map(int, input().split())
ans = 0
for i in range(1, N+1):
    sum = sums(i)
    if A <= sum <= B:
        ans += i
print(ans)


Measured memory_bytes: 2940
n = int(input())
x = []
u = []
for _ in range(n):
    xi, ui = list(input().split())
    x.append(float(xi))
    u.append(ui)
    
yen = 0
for i in range(n):
    if u[i] == 'JPY':
        yen += x[i]
    else:
        yen += x[i] * 380000.0

print(yen)

Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {
    int N;
    cin >>N;
    VI v;
    REP(i,N){
        double vi;
        cin >>vi;
        v.push_back(vi);
    }
    SORT(v);

    double sum;
    double div = 1.0/2.0;
    REP(i,N){
        if(i >= N-2){
            sum += v[N-i-1] *div;
            continue;
        }
        sum += v[N-i-1] *div;
        div /= 2.0;
    }
    cout << sum << endl;
}

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

using namespace std;

   

int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
     int x,y;
    long long ans = 1;
    long long ans2 = 1;

    bool ab = a <= 0 && b >= 0;
    bool cd = c <= 0 && d >= 0;

    if(b < 0 && c > 0)
    {   x = b;
        y = c;
         ans = ans* x;
         ans = ans * y;
        cout << ans << endl;
    }

    if(b < 0 && cd )
    {   x = a;
        y = c;
        ans = ans* x;
    ans = ans * y;
        cout << ans << endl;
    }

    if(b < 0 && d < 0)
    {   x = a;
        y = c;
        ans = ans* x;
    ans = ans * y;
        cout << ans << endl;
    }

    if(ab && c > 0)
    {   x = b;
        y = d;
        ans = ans* x;
    ans = ans * y;
        cout << ans << endl;
    }

    if(ab && cd)
    {   x = b;
        y = d;
        ans = ans* x;
    ans = ans * y;
        x = a;
        y = c;
        ans2 = ans2* x;
    ans2 = ans2 * y;
        if(ans >= ans2)
        {
        cout << ans << endl;
        }
        else{
            cout << ans2 << endl;
        }
    }

    if(ab && d < 0)
    {   x = a;
        y = c;
        ans = ans* x;
    ans = ans * y;
        cout << ans << endl;
    }

    if(a > 0 && c > 0)
    {   x = b;
        y = d;
       ans = ans* x;
    ans = ans * y;
        cout << ans << endl;
    }

    if(a > 0 && cd)
    {   x = b;
        y = d;
        ans = ans* x;
    ans = ans * y;
        cout << ans << endl;
    }

    if(a > 0 && d < 0)
    {   x = a;
        y = d;
       ans = ans* x;
    ans = ans * y;
        cout << ans << endl;
    }


    
}

Measured memory_bytes: 3624
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    val a = Array(3) { Array(3) { it -> sc.nextInt() } }

    val n = sc.nextInt()

    for (i in 0 until n) {
        val b = sc.nextInt()
        for (j in 0 until 3) {
            for (k in 0 until 3) {
                if (a[j][k] == b) a[j][k] = 0
            }
        }
    }

    var bingo = false
    if (a[0][0] == a[0][1] && a[0][1] == a[0][2]) bingo = true
    if (a[1][0] == a[1][1] && a[1][1] == a[1][2]) bingo = true
    if (a[2][0] == a[2][1] && a[2][1] == a[2][2]) bingo = true
    if (a[0][0] == a[1][0] && a[1][0] == a[2][0]) bingo = true
    if (a[0][1] == a[1][1] && a[1][1] == a[2][1]) bingo = true
    if (a[0][2] == a[1][2] && a[1][2] == a[2][2]) bingo = true
    if (a[0][0] == a[1][1] && a[1][1] == a[2][2]) bingo = true
    if (a[2][0] == a[1][1] && a[1][1] == a[0][2]) bingo = true

    if (bingo) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 31388
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    string S;
    cin >> S;
    int n = 0, w = 0, s = 0, e = 0;
    int len = (int)S.size();
    rep(i, len){
        switch(S.at(i)){
            case 'N':
            n = 1;
            break;
            case 'W':
            w = 1;
            break;
            case 'S':
            s = 1;
            break;
            case 'E':
            e = 1;
            break;
        }
    }
    if((n + s != 1) && (w + e != 1)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

const int inf = 1001001001;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
template<typename T> bool chmin(T &a, T b) { if (a > b) a = b; return a > b; }
inline int in() { int x; cin >> x; return x; }

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

  vector<int> r(R);
  for (auto &i : r) i = in() - 1;

  vector<vector<int>> d(n, vector<int>(n, inf));
  for (int i = 0; i < m; ++i) {
    int u = in() - 1, v = in() - 1, c = in();
    d[u][v] = d[v][u] = c;
  }

  rep(k, n) rep(i, n) rep(j, n) chmin(d[i][j], d[i][k] + d[k][j]);

  int ans = inf;
  sort(r.begin(), r.end());
  do {
    int sum = 0;
    for (int i = 1; i < R; ++i) {
      sum += d[r[i - 1]][r[i]];
    }
    chmin(ans, sum);
  } while (next_permutation(r.begin(), r.end()));

  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>
using namespace std;
using ll = long long int;

int main() {
	int A, B, C;
	ll K;
	cin >> A >> B>> C >> K;

	if (K % 2 == 0) {
		cout << A - B;
	}
	else {
		cout << B - A;
	}

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var s string
	var k int
	fmt.Scan(&s, &k)

	l := map[string]struct{}{}
	for start := range s {
		for end := start + 1; end <= len(s); end++ {
			if end-start > k {
				break
			}
			l[s[start:end]] = struct{}{}
		}
	}
	ss := make([]substring, 0)
	for key, _ := range l {
		ss = append(ss, substring{val: key})
	}

	sort.Sort(substrings(ss))
	fmt.Println(ss[k-1].val)
}

type substring struct {
	val string
}

type substrings []substring

func (s substrings) Len() int {
	return len(s)
}

func (s substrings) Less(i, j int) bool {
	if strings.HasPrefix(s[i].val, s[j].val) {
		return false
	}
	for k := range s[i].val {
		if s[i].val[k] == s[j].val[k] {
			continue
		}
		return s[i].val[k] < s[j].val[k]
	}
	return true
}

func (s substrings) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

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

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

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

vector<bool> seen;
int ans = 0;

void dfs(Graph &G, int v){
    seen[v] = true;
    int test = 0;
    rep(i, seen.size())if(seen[i] == true) test++;
    if(test == seen.size())ans++;
    for(auto x: G[v]){
        if(seen[x] == true)continue;
        dfs(G, x);
        seen[x] = false;
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    Graph g(N);
    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(auto x: g[0]){
        seen.assign(N, false);
        seen[0] = true;
        dfs(g, x);
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
/* ****TUSHAR_SEN IITR**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
	{
		ll s,w;
		cin>>s>>w;
		if(w>=s) cout<<"unsafe";
		else cout<<"safe";		


	}
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

int main(){
    lli n,ans=N,east,west,all;
    char s;
    map<char,int> map;
    vector<int> vec,rui;
    lli i,j,k;
    rui.push_back(0);
    cin>>n;
    rep(i,0,n){
        cin>>s;
        if(s=='W'){
            vec.push_back(1);
        }
        else{
            vec.push_back(0);
        }
        if(i>0){
            rui.push_back(rui[i-1]+vec[i-1]);
        }
    }
    if(s=='W'){
        rui.push_back(rui[n-1]+1);
    }
    else{
        rui.push_back(rui[n-1]);
    }
    all=rui[n];
    rep(i,0,n-1){
        west=rui[i];
        east=n-1-i-(all-rui[i+1]);
        ans=min(ans,west+east);
    }
    all=rui[n-1];
    ans=min(ans,all);
    cout<<ans<<endl;
}


Measured memory_bytes: 3564
for _ in range(int(input())):
    n, c = map(int, input().split()), input().split()
    c = list(zip(c, n))
    c.sort(key = lambda x:x[1])
    c.sort(key = lambda x:x[0])
    while c != []:
        if c[-1] == c[-2] == c[-3]:
            c = c[:-3]
        elif (c[-1][0], c[-1][1] -1) in c and (c[-1][0], c[-1][1] -2) in c :
            c.remove((c[-1][0], c[-1][1] -1))
            c.remove((c[-1][0], c[-1][1] -2))
            c.pop()
        else:print(0);break
    else:print(1)


Measured memory_bytes: 5612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0059
{
	class Program
	{
		static void Main(string[] args)
		{
			var	s	= "";
			while( (s = Console.ReadLine()) != null ) {
				var	p	= Array.ConvertAll( s.Split( new char[ 1 ]{ ' ' }, StringSplitOptions.RemoveEmptyEntries ), ss => double.Parse( ss ) );
				if( p[ 0 ] <= p[ 6 ] ) {
					if( p[ 2 ] >= p[ 4 ] ) {
						if( p[ 1 ] <= p[ 7 ] ) {
							if( p[ 3 ] >= p[ 5 ] ) {
								Console.WriteLine( "YES" );
								continue;
							}
						}
					}
				}
				Console.WriteLine( "NO" );
			}
		}
	}
}

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

int main() {
    ll N; cin >> N;
    map<ll, ll> m;
    for (int i = 0; i < N; ++i) {
        ll num; cin >> num;
        if (m.count(num)) {
            cout << "NO" << endl;
            return 0;
        }
        else {
            m[num] = 1;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
int i,j,k,n,m,x,y,t;
#define mp make_pair
map<pair<string,string>,int>Map;
string s,s1,s2;
int b[19];
long long ans;
int main(){
	scanf("%d\n",&n);
	cin>>s;
	for (int P=0;P<1<<n;P++){
		s1="";s2="";
		x=P;
		for (i=n;i>=1;i--)b[i]=x&1,x>>=1;
		for (i=1;i<=n;i++)
			if (b[i]){
				s1+=s[i+n-1];
			}
			else s2+=s[i+n-1];
		Map[mp(s1,s2)]++;
	}
	for (int P=0;P<1<<n;P++){
		x=P;
		for (i=n;i>=1;i--)b[i]=x&1,x>>=1;
		s1="";s2="";
		for (i=1;i<=n;i++)if (b[i])s1=s[i-1]+s1;else s2=s[i-1]+s2;
		ans+=Map[mp(s1,s2)];
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 87040
/**
* @author Ashini Singha
* IIT,Jahangirnagar University
*/
#include<bits/stdc++.h>
using namespace std;
#define     ll          long long int
#define     fo(i,b,n)   for(int i=(b); i<(n) ; i++)
#define     xx          first
#define     yy          second
#define     pb          push_back
#define     sz(n)       int(n.size())
#define     pii         pair
#define     MP          make_pair
#define     PI          acos(-1.0)

#define read(x)         scanf("%d",&x)
#define read2(x,y)      scanf("%d%d",&x,&y)
#define readl(x)        scanf("%lld",&x)
#define readl2(x,y)     scanf("%lld%lld",&x,&y)
#define readd(x)        scanf("%lf",&x)
#define readd2(x,y)     scanf("%lf%lf",&x,&y)

#define pr(n)           printf("%d",n)
#define prn(n)          printf("%d\n",n)
#define prl(n)          printf("%lld",n)
#define prln(n)         printf("%lld\n",n)
#define prd(x)          printf("%lf",x)
#define prdn(x)         printf("%lf\n",x)
#define TC(n) printf("Case %d: ",n)
/*_____________E_N_D______________*/

const int N=100;
int ax[N],ay[N];
int bx[N],by[N];


int main()
{

      int n,m;
      cin>>n>>m;

      fo(i,0,n){
            cin>>ax[i]>>ay[i];
      }

      fo(i,0,m){
            cin>>bx[i]>>by[i];
      }
      vector<int>v;
      fo(idx,0,n){
            int val=1;
            ll sum=999999999999;

            fo(i,0,m){
                  ll temp= abs(ax[idx]-bx[i])+abs(ay[idx]-by[i]);
                  if(temp<sum){
                        val=i+1;
                        sum=temp;
                  }
            }
            v.pb(val);
      }
      fo(i,0,sz(v)){
            cout<<v[i]<<endl;
      }



      return 0;
}



















Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;

ll pow2019(ll n) {
	if (n == 0)return 1;
	ll t = pow2019(n / 2);
	t *= t;
	t %= 2019;
	if (n % 2 == 1)t *= 10;
	return t % 2019;
}

int main() {
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	int n = s.size();
	vector<int>p(n + 1);
	p[0] = 0;
	vector<int>count(2019);
	count[0]++;
	for (int i = 0; i < n; i++) {
		int c = s[i] - '0';
		int tmp = c * pow2019(i);
		tmp %= 2019;
		p[i + 1] = (p[i] + tmp) % 2019;
		//cout << p[i + 1] << endl;
		count[p[i + 1]]++;
	}
	int ans = 0;
	for (int i = 0; i < 2019; i++) {
		ans += (count[i] * (count[i] - 1)) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4340
//
// Created by egor http://github.com/chermehdi/egor
// 
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

pair<int, int> get_min(vector<int> &v) {
  pair<int, int> best = make_pair(0, v[0]);
  for(int i = 0; i < v.size(); ++i) {
    if(v[i] < best.second) {
     best.second = v[i];
     best.first = i;
    } 
  }
  return best;
}
int main() {
  int a, b, m; cin >> a >> b >> m;
  vector<int> ca(a), cb(b);
   
  for(int i = 0; i < a; ++i) {
    cin >> ca[i];
  }
  for(int j = 0; j < b; ++j) {
    cin >> cb[j];
  }
  int best = 2e9;
  map<pair<int, int>, int> dis;
  for(int i = 0; i < m; ++i) {
    int x, y, c; cin >> x >> y >> c;
    best = min(best, ca[x - 1] + cb[y - 1] - c);
    dis[make_pair(x - 1, y - 1)] = c;
  }
  auto pa = get_min(ca);
  auto pb = get_min(cb);
  best = min(best, pa.second + pb.second - dis[make_pair(pa.first, pb.first)]);
  cout << best << endl;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FASTIO ios::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, n) for(int (i) = 0; (i) < (int)(n); ++(i))
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

int main() {
	FASTIO;
	ll a, b, c, d, ans = -1000000000000000000;
	cin >> a >> b >> c >> d;
	vector<ll> x;
	x.eb(a*c);
	x.eb(a*d);
	x.eb(b*c);
	x.eb(b*d);
	for(auto i : x){
	    ans = max(ans, i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
numbers = gets.split(" ")
n = numbers[0].to_i
k = numbers[1].to_i

trees = []
n.times do
  trees.push(gets.to_i)
end

trees.sort!
trees.reverse!

diffs = []
(n - k + 1).times do |i|
  diffs.push trees[i] - trees[i + k - 1]
end

puts diffs.min

Measured memory_bytes: 4640
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;
// C以降はintじゃなくてllを使え
// これかな？は確証なくても5分で考えられなさそうなら出せ
// 極端なテストケースも試せ
int main(){
    int X;
    cin >> X;

    if(X>=30) cout << "Yes";
    else cout << "No" << endl;
    return 0;
}

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

int n,a,b,c;
int l[10];

int ans=10000000;

void dfs(int ptr, int mp, int ta, int tb, int tc){
  if(ptr>=n){
    if(ta==0 || tb == 0 || tc == 0)return;
    mp += abs(ta-a);
    mp += abs(tb-b);
    mp += abs(tc-c);
    ans=min(mp,ans);
    return;
  }

  dfs(ptr+1, mp, ta, tb, tc);
  dfs(ptr+1, mp + (ta ? 10 : 0), ta+l[ptr], tb, tc);
  dfs(ptr+1, mp + (tb ? 10 : 0), ta, tb+l[ptr], tc);
  dfs(ptr+1, mp + (tc ? 10 : 0), ta, tb, tc+l[ptr]);
}

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  cin>>n>>a>>b>>c;
  for(int i=0;i<n;i++)cin>>l[i];

  dfs(0, 0, 0, 0, 0);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3632
def c_rally():
    import numpy as np
    import math
    N = int(input())
    X = [int(i) for i in input().split()]
    m = np.average(X)
    ans = float('inf')
    for j in (math.floor(m), math.ceil(m)):
        ans = min(ans, sum([(x - j)**2 for x in X]))
    return ans

print(c_rally())

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <pair <int, long long>> robots(n);
    for (int i = 0; i < n; ++i) {
        int x, l;
        cin >> x >> l;
        robots[i] = {x - l, x + l};
    }
    sort(robots.begin(), robots.end());
    int ans = 0;
    long long mx = -3e9;
    for (int i = 0; i < n; ++i) {
        if (robots[i].first >= mx) {
            ans++;
            mx = robots[i].second;
        } else {
            mx = min(mx, robots[i].second);
        }
        //cout << mx << " " << ans << "\n";
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define lop(i,n) for(i=0;i<n;i++)
#define lop1(i,n) for(ll i=1;i<=n;i++)
#define lopr(i,n) for(i=n-1;i>=0;i--)
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define IOS  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl "\n"
#define F first
#define S second
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define LCM(a,b) (a*b)/__gcd(a,b)
#define mii map<int,int>
#define mll map<ll,ll>
#define ub upper_bound
#define lb lower_bound
#define sz(x) (ll)x.size()
#define ld long double
#define pcnt(x) __builtin_popcountll(x)
const long long I1 = 1e9;
const long long I2 = 1e18;
const long long MAXM = 1e5 + 5;

template<typename T, typename T1>T maxn(T &a, T1 b) {if (b > a)a = b; return a;}
template<typename T, typename T1>T minn(T &a, T1 b) {if (b < a)a = b; return a;}

ll arr[MAXM];
bool isPrime(int n)
{
  if (n <= 1) return false;
  if (n <= 3) return true;

  if (n % 2 == 0 || n % 3 == 0) return false;

  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0)
      return false;

  return true;
}

int least_prime(int n) {
  int i;
  lop(i, 32) {
    if (isPrime(i) && n % i == 0)
      return i;
  }
}
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
//#ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
//#endif
  ll n, i;
  cin >> n;
  mll m;
  ll temp;
  lop(i, n) {
    cin >> temp;
    if (m.find(temp) == m.end())
      m[temp] = 1;
    else
      m[temp]++;
  }
  ll sum = 0;
  for (auto it : m) {
    if (it.first != it.second) {
      if (it.first > it.second)
        sum += it.second;
      else
        sum += it.second - it.first;
    }

  }
  cout << sum << endl;
}


Measured memory_bytes: 9612
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int ret = 1;
  for (int i = 1; i < n; ++i) {
    bool found = false;
    for (int j = 0; j < i; ++j) {
      if (a[j] > a[i]) found = true;
    }
    ret += !found;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#coding: utf-8
s=gets().chomp()
k=gets().chomp().to_i
i=0
while(i<s.length && k>0)
	if(s[i]!="a"&&"z".ord - s[i].ord + 1<= k)
		k -= ("z".ord - s[i].ord + 1)
		s[i]="a"
	end
	i+=1
end
if(k != 0)
	k= k%26
	s[-1] = ((s[-1].ord + k) <= "z".ord ? (s[-1].ord + k).chr : (s[-1].ord + k - 26).chr)
end
puts(s)


Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <functional>
#include <math.h>

using namespace std;
const int mod = 1000000007;
const double pi = 3.141592653589793238462643382795028841971;

int main() {
	int n;
	cin >> n;
	if (n == 7 || n == 5 || n == 3) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N,M;
ll a[59], b[59];
ll c[59], d[59];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>M;
    rep(i,N) cin>>a[i]>>b[i];
    rep(i,M) cin>>c[i]>>d[i];
    
    rep(i,N){
        ll best, mind=LLINF;
        rep(j,M){
            ll dist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            if(dist<mind){
                mind=dist;
                best=j;
            }
        }
        cout1(best+1)
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;

int main(void) {
	ll i, j, k, ans = 1;
	ll N;
	scanf("%lld", &N);
	for (i = 1; i <= N; i++) {
		ans *= i;
		if (100000000 + 7 >= N) {
			ans %= 1000000000 + 7;
		}
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 256
import math
a,b,C = map(float,input().split())
h = b*math.sin(math.radians(C))
c = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(C)))
# a2=b2+c2−2bccosA
r = a+b+c
print(a*h/2)

print(r)
print(h)


Measured memory_bytes: 5696
s = input()
t = input()
def check(a,b):
  l = []
  for c in a:
    if c in l:
      continue
    l.append(c)
    if a.count(c) > 1:
      m = [i for i, x in enumerate(a) if x == c]
      for i in range(1,len(m)):
        if b[m[i]] != b[m[0]]:
          return "No" 
  return "Yes"
ans = check(s,t)
if ans == "Yes" : ans = check(t,s)
print(ans)

Measured memory_bytes: 11560
H,W,N = list(map(int,input().split()))
h,w = list(map(int,input().split()))
h2 = h
w2 = w

S = input()
T = input()

result = "YES"

#左上を目指す
for i in range(N):
    if S[i] == "L":
        w -= 1
        if w < 1:
            result = "NO"
            break
    elif S[i] == "U":
        h -= 1
        if h < 1:
            result = "NO"
            break
    
    if T[i] == "R":
        w += 1
        if w > W:
            w -= 1
    elif T[i] == "D":
        h += 1
        if h > H:
            h -= 1


#右下を目指す
if result == "YES":
    for i in range(N):
        if S[i] == "R":
            w2 += 1
            if w2 > W:
                result = "NO"
                break
        elif S[i] == "D":
            h2 += 1
            if h2 > H:
                result = "NO"
                break
        
        if T[i] == "L":
            w2 -= 1
            if w2 < 1:
                w2 += 1
        elif T[i] == "U":
            h2 -= 1
            if h2 < 1:
                h2 += 1
        


print(result)

Measured memory_bytes: 3888
#include<iostream>
#include<algorithm>
using namespace std;
int a[100][100];
int sum[101][101];
main()
{
	int n;cin>>n;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>a[i][j];
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)
	{
		sum[i][j]=a[i-1][j-1]+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
	}
	int ans=-2e9;
	for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)for(int k=i+1;k<=n;k++)for(int l=j+1;l<=n;l++)ans=max(ans,sum[k][l]+sum[i][j]-sum[k][j]-sum[i][l]);
	cout<<ans<<endl;
}


Measured memory_bytes: 3168
from collections import deque

n, q = map(int, input().split())
procs = deque([])

for i in range(n):
    name, time = input().split()
    time = int(time)
    procs.append([name, time])

total = 0

while procs:
    procs[0][1] -= q

    if procs[0][1] > 0:
        total += q
        procs.append(procs.popleft())
    else:
        total += q + procs[0][1]
        print(procs[0][0], total)
        procs.popleft()

Measured memory_bytes: 16164
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef vector<P> vecP;

const double eps=1e-8;

bool eq(double a,double b){
  return (-eps<a-b&&a-b<eps);
}

P getCrossLL(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}
 
int m,n;
P s[100],t[100];
vector<int> X;

double getW(P s[100],int m,double x){
  P a=P(x,0);
  P b=P(x,1);
  double maxm=-1e9;
  double mini=1e9;
  
  for(int i=0;i<m;i++){
    P c=s[i];
    P d=s[(i+1)%m];
    
    if( eq( c.real() , d.real() ) ){
      continue;
    }
    
    if( min(c.real(),d.real()) < x && x < max(c.real(),d.real()) ){
      P p=getCrossLL(a,b,c,d);
      maxm=max(maxm, p.imag());
      mini=min(mini, p.imag());
    }
  }

  return max(0.0, maxm-mini);
}

double f(double x){
  return getW(s,m,x)*getW(t,n,x);
}

int main(){
  while(1){
    cin>>m>>n;
    if(m==0&&n==0)break;

    X.clear();
    for(int i=0;i<m;i++){
      int x,y;
      scanf("%d %d",&x,&y);
      s[i]=P(x,y);
      X.push_back(x);
    }
    for(int i=0;i<n;i++){
      int x,y;
      scanf("%d %d",&x,&y);
      t[i]=P(x,y);
      X.push_back(x);
    }
    sort(X.begin(),X.end());
    X.erase( unique(X.begin(),X.end()) , X.end() );

    double ans=0;
    for(int i=0;i+1<(int)X.size();i++){
      
      
      double a=X[i], b=X[i+1], mid=(a+b)*0.5;


      double Sa=f(a+eps);
      double Sb=f(b-eps);
      double Smid=f(mid);
      
      if( eq(Smid,0) )continue;
      
      double dis= (b-a)*(Sa + 4*Smid + Sb)/6.0;
      //            cout<<a<<' '<<b<<' '<<Sa<<' '<<Sb<<endl;
      ans+= dis;
      
    }
    printf("%.10f\n",ans);
  }

  
  return 0;
}

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

int main() {
	
	int n,W;
	cin >> n >> W;
	vector<int> v(n),w(n);
	for(int i=0; i<n; i++) cin >> v.at(i) >> w.at(i);
	vector<vector<int>> dp(n+1,vector<int>(W+1));
	for(int i=1; i<=n; i++){
		for(int j=0; j<=W; j++){
			dp.at(i).at(j) = max(dp.at(i).at(j),dp.at(i-1).at(j));
			if(j-w.at(i-1)>=0){
				dp.at(i).at(j) = max(dp.at(i).at(j),dp.at(i-1).at(j-w.at(i-1))+v.at(i-1));
			}
		}
	}
	cout << dp.at(n).at(W) << endl;
}



Measured memory_bytes: 6848
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
  string s,t;
  cin>>s>>t;
  t.erase(t.length()-1,1);
  if(s==t)
    cout<<"Yes";
  else
  {
    cout<<"No";
  }
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 2e5+5;
int N, a[MAX], b[MAX];

int main(int argc, char ** argv) {
	scanf("%d", &N);
	rep(i, 0, N) scanf("%d", &a[i]);
	rep(i, 0, N) b[i] = a[i];
	sort(a, a + N);
	rep(i, 0, N) {
		if(b[i] == a[N-1]) printf("%d\n", a[N-2]);
		else printf("%d\n", a[N-1]);
	}
	return 0;
}


Measured memory_bytes: 3200
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
V<int> dx = {-1, 1,  0, 0};
V<int> dy = { 0, 0, -1, 1};

char c[1010][1010];
int d[1010][1010];
const int INF = 1e9;

int main () {
    int h, w; cin >> h >> w;
    int sy, sx; cin >> sy >> sx; sy--; sx--;
    int gy, gx; cin >> gy >> gx; gy--; gx--;
    rep(i, h) rep(j, w) cin >> c[i][j];
    rep(i, h) rep(j, w) d[i][j] = INF;
    d[sy][sx] = 0;
    queue<P> que, nxt;
    que.push({sx, sy});

    int now = 0;
    bool flag = true;
    while (flag) {
        flag = false;
        while (!que.empty()) {
            P p = que.front(); que.pop();
            int x = p.first, y = p.second;
            nxt.push({x, y});
            rep(i, 4) {
                int nx = x+dx[i], ny = y+dy[i];
                if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
                if (c[ny][nx] == '#') continue;
                if (d[ny][nx] != INF) continue;
                d[ny][nx] = d[y][x];
                que.push({nx, ny});
                flag = true;
            }
        }
        while (!nxt.empty()) {
            P p = nxt.front(); nxt.pop();
            int x = p.first, y = p.second;
            for (int dx = -2; dx <= 2; dx++) {
                for (int dy = -2; dy <= 2; dy++) {
                    if (dx == 0 && dy == 0) continue;
                    int nx = x+dx, ny = y+dy;
                    if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
                    if (c[ny][nx] == '#') continue;
                    if (d[ny][nx] != INF) continue;
                    d[ny][nx] = d[y][x] + 1;
                    que.push({nx, ny});
                    flag = true;
                }
            }
        }
        now++;
    }
    if (d[gy][gx] != INF) cout << d[gy][gx] << endl;
    else cout << -1 << endl;

    /*
    rep(i, h) {
        rep(j, w) {
            if (d[i][j] == INF) cout << 'a' <<  " ";
            else cout << d[i][j] << " ";
        }
        cout << endl;
    }
    cout << now << endl;
    */
    
    return 0;
}

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

int count_and_compress (vector<long long> &a) {
    vector<long long> b = a;
    sort(b.begin(), b.end());
    b.erase(unique(b.begin(), b.end()), b.end());
    for (auto& e : a) {
        e = (lower_bound(b.begin(), b.end(), e) - b.begin());
    }
    return b.size();
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<long long> t(n), d(n);
    for (int i = 0; i < n; i++) {
        cin >> t[i] >> d[i];
    }
    
    int sz = count_and_compress(t);
    vector<vector<long long>> g(sz);
    for (int i = 0; i < n; i++) {
        g[t[i]].emplace_back(d[i]);
    }
    for (auto &v : g) {
        sort(v.begin(), v.end(), greater<long long>());
    }
    
    vector<long long> f(1, 0), s(1, 0);
    for (int i = 0; i < sz; i++) {
        for (int j = 0; j < (int)g[i].size(); j++) {
            if (j == 0) f.emplace_back(g[i][j]);
            else s.emplace_back(g[i][j]);
        }
    }
    
    sort(f.begin()+1, f.end(), greater<long long>());
    sort(s.begin()+1, s.end(), greater<long long>());
    for (long long i = 1; i < (int)f.size(); i++) {
        f[i] += (2 * i - 1);
    }
    
    for (int i = 0; i+1 < (int)f.size(); i++) {
        f[i+1] += f[i];
    }
    for (int i = 0; i+1 < (int)s.size(); i++) {
        s[i+1] += s[i];
    }
    
    long long ans = 0;
    for (int i = 1; i <= k; i++) {
        int j = k - i;
        if (i < f.size() and j < s.size()) {
            long long res = f[i] + s[j];
            ans = max(ans, res);
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9072
n = gets.chomp.to_i
s = []
n.times do
  s.push(gets.chomp)
end
m = gets.chomp.to_i
t = []
m.times do
  t.push(gets.chomp)
end

ans = 0
s.each do |word|
  tmp = s.count(word) - t.count(word)
  ans = tmp if tmp > ans
end
p ans


Measured memory_bytes: 1788
#include<iostream>
#include<queue>

using namespace std;

struct State{
  int x,y,t,dir;
  State(int a, int b, int c, int d):x(a),y(b),t(c),dir(d){}
  bool operator < (const State& s) const{
    return t > s.t;
  }
};
const int MAX = 31;
const int INF = (1<<25);
int M[MAX][MAX],h,w;
int cost[4],T[4][MAX][MAX];
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

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


void init(){
  for(int i = 0; i < 4; i++)
    for(int j = 0; j < MAX; j++)
      for(int k = 0; k < MAX; k++) T[i][j][k] = INF;
}

void input(){

  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++) cin >> M[i][j];

  for(int i = 0; i < 4; i++) cin >> cost[i];
}

void solve(){

  priority_queue<State> Q;
  Q.push(State(0,0,0,0));
  T[0][0][0] = 0;

  while(!Q.empty()){
    State s = Q.top();
    Q.pop();

    if(T[s.dir][s.y][s.x] < s.t) continue;

    //obey
    if(M[s.y][s.x] != 4){
      State tmp = s;
      tmp.dir = (tmp.dir+M[tmp.y][tmp.x])%4;
      tmp.x += dx[tmp.dir];
      tmp.y += dy[tmp.dir];
      if(isInside(tmp.x,tmp.y) && T[tmp.dir][tmp.y][tmp.x] > tmp.t){
	T[tmp.dir][tmp.y][tmp.x] = tmp.t;
	Q.push(tmp);
      }
    }
    //order
    for(int i = 0; i < 4; i++){
      State tmp = s;
      tmp.dir = (tmp.dir+i)%4;
      tmp.t += cost[i];
      tmp.x += dx[tmp.dir];
      tmp.y += dy[tmp.dir];
      if(isInside(tmp.x,tmp.y) && T[tmp.dir][tmp.y][tmp.x] > tmp.t){
	T[tmp.dir][tmp.y][tmp.x] = tmp.t;
	Q.push(tmp);
      }
    }
  }

  int ans = INF;
  for(int i = 0; i < 4; i++)
    ans = min(ans,T[i][h-1][w-1]);
  cout << ans << endl;
}    

int main(){

  while(cin >> w >> h && w+h){
    init();
    input();
    solve();
  }

  return 0;
}

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

int main(){
    int num;
    bool ans = true;
    string w;
    vector<int> moji(26);
    cin >> w;

    for (int i = 0; i < w.size(); i++){
        num = w.at(i) - 'a';
        moji.at(num)++;
    }

    for (int i = 0; i < 23; i++){
        if((moji.at(i) % 2) == 1){
            ans = false;
            break;
        }
    }

    if(ans) cout << "Yes";
    else cout << "No";
    return 0;
}

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

int main(){
  int a,b,x;
  cin >> a >> b >> x;
  
  if(2*x<a*a*b){
    double l=0,r=90;   
    for(int i=0;i<10000;i++){
      double m=(l+r)/2;
      if(a*b*b*tan((90-m)/180*M_PI)/2<x) r=m;
      else l=m;
    }
    cout << fixed << setprecision(10);
    cout << r << endl;
        
      
  }
  else{
    double l=0,r=90;
    for(int i=0;i<10000;i++){
      double m=(l+r)/2;
      if(a*a*b-a*a*a*tan(m/180*M_PI)/2<x) r=m;
      else l=m;
    }
    cout << fixed << setprecision(10);
    cout << r << endl;
  }
}

Measured memory_bytes: 4092
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
unordered_map<ll, ll> marked;

int main() {
	ll cnt = 0;
	scanf("%lld", &N);
	for(int i = 1; i < N; i++) {
		if(!marked[i] && !marked[N - i]) {
			if(i == N - i) {
				continue;
			}
			marked[i] = 1;
			marked[N - i] = 1;
			cnt++;
		}
	}
	printf("%lld\n", cnt);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 39696
n = int(input())
x = input()

x_1 = x.count('1')
flag = 0
if(x_1 == 0):
    flag = 1
if(x_1 == 1):
    flag = 2

data = [0 for i in range(n+1)]
data[0] = 0
for i in range(1,n+1):
    i_str = format(i,'b')
    ne = i % (i_str.count('1'))
    data[i] = data[ne] + 1

up = [0 for i in range(n)]
do = [0 for i in range(n)]

d = 1
upp = 0
for i in range(n):
    up[i] = d
    if(x[n-i-1] == '1'):
        upp += d
        upp %= (x_1+1)
    d *= 2
    d %= (x_1 + 1)
d = 1
dow = 0
if(flag == 0):
    for i in range(n):
        do[i] = d
        if(x[n-i-1] == '1'):
            dow += d
            dow %= (x_1-1)
        d *= 2
        d %= (x_1 - 1)


for i in range(n):
    if(x[i] == '0'):
        sam = upp + up[n-i-1]
        sam %= (x_1+1)
        print(data[sam]+1)
    elif(flag == 0):
        sam = dow - do[n-i-1]
        sam %= (x_1-1)
        print(data[sam]+1)
    elif(flag == 2):
        print('0')

Measured memory_bytes: 26968
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,m,a[100010],li[100010],li2[100010];

int main(){
	cin >> n >> m;
	REP(i,0,n) cin >> a[i],li[a[i]%m]++;
	sort(a,a+n);
	REP(i,0,n-1) if(a[i]==a[i+1]) i++,li2[a[i]%m]++;
	int pos=li[0]/2;
	REP(i,1,m/2+1){
		if(i==m-i){pos+=li[i]/2; continue;}
		int mi=min(li[i],li[m-i]);
		pos+=mi; li[i]-=mi; li[m-i]-=mi;
		pos+=min(li2[i],li[i]/2);
		pos+=min(li2[m-i],li[m-i]/2);
	}
	cout << pos << endl;
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> d[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        for (int j = i + 1; j < n; ++j)
        {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;
int main(){
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    double theta1=(h+m/60.0)/12.0*2*3.1415926535897932384;
    double theta2=m/60.0*2*3.1415926535897932384;
    double x1 = a * sin(theta1);
    double y1 = a * cos(theta1);
    double x2 = b * sin(theta2);
    double y2 = b * cos(theta2);
    double dist = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
    cout << setprecision(20)<< dist << endl;
    return 0;
}

Measured memory_bytes: 4100
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define P pair
#define X first
#define Y second
#define VSORT(v) sort(v.begin(), v.end())
#define VREV(v) reverse(v.begin(), v.end())
#define VMAX_P(v) max_element(v.begin(), v.end())
#define VMIN_P(v) min_element(v.begin(), v.end())
#define VMAX_IDX(v) distance(v.begin(), VMAX_P(v))
#define VMIN_IDX(v) distance(v.begin(), VMIN_P(v))
#define VCOPY(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define SUPPER(src, dst) transform(src.begin(), src.end(), dst.begin(), toupper);
#define SLOWER(src, dst) transform(src.begin(), src.end(), dst.begin(), tolower);

using namespace std;
using ll = long long;

int main(int argc, const char *argv[])
{
    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int i = 0; i < n; i++)
    {
        if (s.substr(i, n - i) == t.substr(0, n - i))
        {
            cout << n + i << endl;
            return 0;
        }
    }
    cout << n * 2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstddef>
#include<cstdint>
#include<vector>
#include<algorithm>
#include<set>
using usize=std::size_t;
using i64 = std::int_fast64_t;

int main(){
  usize n;
  std::cin>>n;
  std::vector<i64> a(n);
  for(auto &e:a)std::cin>>e;
  i64 cur=std::numeric_limits<i64>::max();
  usize id=n;
  for(usize i=0;i<n;++i){
    if(cur>a[i]){
      cur=a[i];
      id=i;
    }
  }
  std::cout<<id+1<<std::endl;
}



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

int main() {
  int a, b;
  cin >> a >> b;
  string s(b, '0'+a);
  string t(a, '0'+b);
  cout << min(s,t) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        String S = sc.nextLine();

        int count0 = 0;
        int count1 = 0;
        boolean flg = true;
        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) == (flg ? '0' : '1')) {
                count0++;
            } else {
                count1++;
            }
            flg = !flg;
        }

        System.out.println(Math.min(count0, count1));
    }
}


Measured memory_bytes: 25548
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <cstdio>
#include <deque>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <stdlib.h>
#include <stack>

using namespace std;
long long n, k;
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> n >> k;
	long long ans = 1;
	for (long long i = 1; i *i <= k; i++) {
		if (k % i == 0) {
			if (i == k / i) {
				long long temp = i;
				if (n <= k / temp)ans = max(ans, temp);
			}
			else {
				long long temp = i;
				long long temp1 = k / i;
				if (n <= k / temp)ans = max(ans, temp);
				if (n <= k / temp1)ans = max(ans, temp1);
			}
		}
	}
	cout << ans << '\n';



	


}


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

int main() {
  string a;
  cin >> a;
  if(a.at(0)!=a.at(1)&&a.at(1)!=a.at(2)&&a.at(0)!=a.at(2))
    cout << "Yes" << endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
use std::io::{stdin, Read};

struct UnionFind {
    parents: Vec<usize>,
}
impl UnionFind {
    pub fn new(n: usize) -> Self {
        let par = (0..n).collect();
        UnionFind { parents: par }
    }
    pub fn root(&mut self, x: usize) -> usize {
        if self.parents[x] == x {
            return x;
        }
        let par = self.parents[x];
        self.parents[x] = self.root(par);
        self.parents[x]
    }
    pub fn union(&mut self, x: usize, y: usize) {
        let rx = self.root(x);
        let ry = self.root(y);
        if rx == ry {
            return;
        }
        self.parents[rx] = ry;
    }
    pub fn is_same(&mut self, x: usize, y: usize) -> bool {
        let rx = self.root(x);
        let ry = self.root(y);
        rx == ry
    }
}

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, m): (usize, usize) = parse!(it, 2);
    let mut g = vec![vec![]; m];

    for i in 0..n {
        let k: usize = parse!(it);
        for _ in 0..k {
            let li: usize = parse!(it);
            g[li - 1].push(i)
        }
    }

    let mut uf = UnionFind::new(n);
    for i in 0..m {
        if g[i].len() == 0 {
            continue;
        }
        for j in 0..(g[i].len() - 1) {
            uf.union(g[i][j], g[i][j + 1]);
        }
    }

    if (1..n).all(|i| uf.is_same(0, i)) {
        println!("YES");
    } else {
        println!("NO")
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 15612