akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    ll N,M;
    cin >>N>>M;
    vector<ll> a(N);
    bool flag = 0;
    rep(i,N){
        cin >> a[i];
    }
    ll pcnt;
    rep(i,N){
        ll cnt = 0;
        
        ll  now =a[i];
        
        while((now%2)==0){
            cnt++;
            now /=2;
        }
        if(cnt != pcnt && i != 0){
            flag = 1;
            break;
        }
        pcnt = cnt;
    }
    ll ans;
    if(flag == 0){
        ll LCM;
        if(N==1){
            LCM = a[0]/2;
        }else{
            LCM = lcm(a[0]/2,a[1]/2);
        }
        for(ll i = 2; i<N;i++){
            LCM = lcm(LCM,a[i]/2);
        }
        
     
            ans = (M/LCM+1)/2;

    }else{
        ans = 0;
    }
    
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 4028
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    REP(i,N){
        cin>>A[i];
    }
    int count=0;
    REP(i,N){
        while(A[i]%2==0){
            count+=1;
            A[i]/=2;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

/* http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=0032&lang=jp */

int main(void)
{
	int alpha=0;
	int beta=0; /*Óa,Ób,Îpüc*/
	int charley=0;
	int rect = 0;/*·û`Ì*/
	int rhom = 0;/*Ðµ`Ì*/


	while(1){
	if(scanf("%d",&alpha) == EOF)  /* EOFðüÍ·éÉÍACtrl+Z */
		break;
	scanf(",%d",&beta);
	scanf(",%d",&charley);

	if( charley*charley == alpha*alpha + beta*beta )
		rect++;

	if( alpha == beta )
		rhom++;

	}


	printf("%d\n",rect);
	printf("%d\n",rhom);

	return 0;
}

Measured memory_bytes: 0
n=int(input())
a=list(map(int,input().split()))
p=[]
m=[]
for i in range(n):
    p.append(i+a[i])
    m.append(i-a[i])
x=[0]*(2*n)
y=[0]*(2*n)
ans=0
for i in range(n):
    if 0<=p[i]<=(2*n)-1:
        x[p[i]]+=1
    if 0<=m[i]<=(2*n)-1:
        y[m[i]]+=1
for i in range(n):
    ans+=x[i]*y[i]
print(ans)

Measured memory_bytes: 115784
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define be(v) v.begin(), v.end()
#define ll long long
ll INF = 1e9;
ll mod = 1e9+7;

ll dp[10001];
int main() {
  int n,k; cin >> n >> k;
  string s; cin >> s;
  if(s[k-1]=='A') s[k-1]='a';
  else if(s[k-1]=='B') s[k-1]='b';
  else s[k-1]='c';
  cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair

using namespace std;

signed main() 
{
  int m, d, cnt=0;
  cin >> m >> d;
  for(int i = 1; i <= m; i++)
  {
    for(int j = 1; j <= d; j++)
    {
      if(j%10>=2 && j/10>=2 && (j/10) * (j%10)==i)
      {
        cnt++;
      }
    }
  }
  cout << cnt;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;
 
int main(){
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    double x = 0;
    int water = 100*A, suger = 0;
    
    for(int i = 0; i <= F; i += 100*A){
        for(int j = i; j <= F; j += 100*B){
            if(j == 0) continue;
            else{
                for(int k = j; k <= F; k += C){
                    for(int l = k; l <= F; l += D){
                        if(l-j <= E*j/100){
                            if(x < double(l-j)/double(l)){
                                x = double(l-j)/double(l);
                                water = l;
                                suger = l-j;
                            }
                        }
                    }
                }
            }
        }
    }
    cout << water << ' ' << suger << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define pb push_back
#define PI 3.14159265
int M = 1000000007;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  int x = 0;
  for (int i = 0; i < n; ++i)
  {
    cin >> a[i];
    x = x ^ a[i];
  }
  for (int i = 0; i < n; ++i)
  {
    int val = x ^ a[i];
    cout << val << " ";
  }

}

Measured memory_bytes: 5204
v[16],m[2][4][16],i,p,d,D[]={1,3,4,5},t,w;
main(){
	for(i=4,w='AN';read(0,v+i,1);){
		for(p=0;p<2;p++){
			for(d=0;d<4;d++){
				t=m[p][d][i]=v[i]=="bw"[p]?m[p][d][i-D[d]]+1:0;
				if(t==3)
					w=v[i];
			}
		}
		if(++i==16){
			puts(&w);
			i=4,w='AN';
		}
	}
}

Measured memory_bytes: 0
n = int(input())
s = [None for _ in range(n)]
t = [None for _ in range(n)]
for i in range(n):
    l = [i for i in input().split()]
    s[i] = l[0]
    t[i] = int(l[1])
x = input()

a = s.index(x)
res = 0
for i in range(a + 1, n):
    res += t[i]
print(res)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
//プロトタイプ宣言
int gcd(int , int);
void often(void);
int get_digent(int);


int main(){
  often();
  ll l,r;
  cin >> l >> r;
  ll ans = 100000000000;
  ll divide_l = l/2019;
  ll divide_r = r/2019;
  ll time;
  rep(i,r-l){
    for(int j=1;j<=r-l;j++){
      if(divide_l == divide_r){
        time = (l+i)*(l+j);
        ans = min(ans , (time%2019));
      }
      else{
        cout << 0 << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
}








































//以下、ライブラリ

int gcd(auto a, auto b) {
  return b ? gcd(b, a%b) : a;
}  //ユークリッドの互除法

void often(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int get_digent(int x){
  string s;
  s = to_string(x);
  int digent = s.size();
  return digent;
} 

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

const int MAX = 2*1e5+100;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void Main()
{
    LL n,k;cin>>n>>k;

    COMinit();

    LL result = 0;

    vector<LL> small(n+1);
    vector<LL> large(n+1);

    small[0] = 0;
    large[0] = n;

    FOR(i,1,n+1){
        small[i] = i + small[i-1];
        large[i] = (n-i) + large[i-1];
    }

    /*
    REP(i,n+1){
        cerr<<i<<" "<<small[i]<<" "<<large[i]<<endl;
    }
    */


    FOR(i,k,n+2){
        result += large[i-1]-small[i-1] + 1;
        result %= MOD;

    }
    cout<<result<<endl;




    
	return;
}

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

Measured memory_bytes: 11064
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve()
{
    int a[3];
    int i,c=0,d=0;
    for(i=0;i<3;i++){
        cin>>a[i];
        if(a[i]==5) c++;
        if(a[i]==7) d++;
    }
    if(c==2&&d==1){
        cout<<"YES"<<endl;return;
    }
    else{
        cout<<"NO"<<endl;return;
    }
}
int main()
{
    solve();
}

Measured memory_bytes: 3624
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from itertools import combinations
import math

IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]

N, D = IA()
X = IM(N)

ans = 0
for x, y in combinations(X, 2):
    t = sum((u - v)**2 for u,v in zip(x, y))
    ans += math.sqrt(t).is_integer()
print(ans)


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

#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long int

int main()
{
    ios::sync_with_stdio(0);// Input and output clearance
    cin.tie(0);
    ll t,n,cnt=0,temp;
    cin>>t;
    int a[t],b[t];
    int max=0;
    f(i,0,t)
    {
        cin>>a[i]>>b[i];
        if(a[i]==b[i])
        {
            if(cnt==0)
            {
                cnt++;
            }
            else if(a[i-1]==b[i-1])
            {
                cnt++;
            }
            else{
                cnt=1;
            }   
        }
        if(cnt>=3)
        {
            max=cnt;
        }
    }  
    if(max>=3)
    {
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

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

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

    int n;
    cin >> n;
    vector<int> a(n);
    
    int mx = -1;
    rep(i, n){
        cin >> a[i];
        mx = max(mx, a[i]);
    }

    vector<int> drop(mx+10, 0);
    rep(i, n){
        int num = a[i];

        int b = 1;
        while(num*b <= mx){
            ++drop[num*b];
            b++;
        }
    }

    int res = 0;
    rep(i, n){
        if(drop[a[i]] < 2){
            ++res;
        }
    }
    
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 7952
#include<bits/stdc++.h>
#define ChenChuLing main
#define INF 2001052800
using namespace std;
int a[4],ans=0;
int ChenChuLing(){
    scanf("%d%d%d",&a[1],&a[2],&a[3]);
    sort(a+1,a+4);
    ans+=a[3]-a[2];
    a[1]+=a[3]-a[2];
    a[2]=a[3];
    if((a[3]-a[1])&1){
        a[3]++;a[2]++;
        ans++;
        ans+=(a[3]-a[1])/2;
    }
    else{
        ans+=(a[3]-a[1])/2;
    }
    printf("%d\n",ans);
    return 0;
}



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

int main(void){

    vector<vector<char> > number(10);
    number[1].push_back('.');
    number[1].push_back(',');
    number[1].push_back('!');
    number[1].push_back('?');
    number[1].push_back(' ');

    number[2].push_back('a');
    number[2].push_back('b');
    number[2].push_back('c');

    number[3].push_back('d');
    number[3].push_back('e');
    number[3].push_back('f');

    number[4].push_back('g');
    number[4].push_back('h');
    number[4].push_back('i');

    number[5].push_back('j');
    number[5].push_back('k');
    number[5].push_back('l');

    number[6].push_back('m');
    number[6].push_back('n');
    number[6].push_back('o');

    number[7].push_back('p');
    number[7].push_back('q');
    number[7].push_back('r');
    number[7].push_back('s');

    number[8].push_back('t');
    number[8].push_back('u');
    number[8].push_back('v');

    number[9].push_back('w');
    number[9].push_back('x');
    number[9].push_back('y');
    number[9].push_back('z');    

    int n; cin >> n;
    for(int i = 0; i < n; i++){
        string str; cin >> str;
        int j = 0;
        while(str[j] != '\0'){
            int counter = 0;
            if(str[j] == '0'){ 
                j++;
                continue;
            }
            while(str[j] != '0'){
                counter++;
                j++;
            }
            //cout << j - 1 << endl;
            //cout << str[j - 1] << endl;
            //int a = str[j - 1];
            //cout << counter << endl;
            //cout << a << endl;
            //cout << number[ a ].size() << endl;
            //cout << number[2].size() << endl;
            //cout << counter / number[j - 1].size() << endl;
            //cout << counter << " " << str[j - 1] << endl;
            cout << number[(int)str[j - 1] - '0'][(counter-1) % number[(int)str[j - 1] - '0'].size()];
            j++;
        }

        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    int n;
    cin >> n;
    double dp[3000][3000],p[3000];
    rep(i,n) cin >> p[i];
    dp[0][0] = 1;
    rep(i,n){
        dp[i+1][0] = dp[i][0]*(1-p[i]); 
        rep(j,n){
            dp[i+1][j+1] = dp[i][j]*p[i]+dp[i][j+1]*(1-p[i]);
        }
    }
    double ans = 0;
    rep(i,n/2+1,n+1) ans += dp[n][i];
    printf("%0.10f\n",ans);
}

Measured memory_bytes: 70528
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define rep(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

int fe(int n){return n/2;}
int fo(int n){return 3*n+1;}

int main(void){
    int N,ans=0;
    cin>>N;
    VI p(N);
    rep(i,N){
        cin>>p[i];
        ans+=p[i];
    }
    sort(p.begin(),p.end());
    ans-=(p[N-1]/2);
    cout<<ans<<endl;
}




Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val A, B, C, D, E, F = sc.nextInt()
    // 砂糖の濃度を水 100g あたり Eg に近づけたい
    // 全体としてFg以下かつビーカーの中に佐藤と溶け残らせてはいけない
    // a + b <= F
    // b / (a + b) <= E / (100 + E)
    // 物質を抜く, という選択肢は無い
    // F <= 3000 なので, 全探索できそう <= 大嘘
    // 水の組み合わせだけ <= Fの範囲内で全列挙して
    // 入れれるだけのCを全列挙して
    // 残りのDは条件を見たすうち最も濃度が高くなるものを二分探索で探す
    // しかし, Cの時点でオーバーしている可能性があるのでそれを除去する

    def solve(): (Int, Int) = {
      val MAX = E.toDouble / (100F + E.toDouble)

      def upperBoundsD(water: Int, c: Int, upperD: Int): Int = {
        val base = (water + C * c).toDouble
        def loop(left: Int, right: Int): Int =
          if (right - left > 1) {
            val d = left + (right - left) / 2
            if (((C * c + D * d) / (base + D * d)) > MAX) loop(left, d)
            else loop(d, right)
          } else left
        loop(0, upperD + 1)
      }

      (for {
        a <- 0 to (F / (100 * A))
        b <- 0 to ((F - (100 * A * a)) / (100 * B))
        if !(a == 0 && b == 0)
        water = 100 * A * a + 100 * B * b
        maxC = (F - water) / C
        c <- 0 to maxC
        d = upperBoundsD(water, c, (F - water - C * c) / D)
        suger = C * c + D * d
        if (suger / (suger + water).toDouble) <= MAX
      } yield (suger + water, suger)).maxBy{ case (sugerWater, suger) => suger / sugerWater.toDouble }
    }

    val (a, b) = solve()
    println(s"$a $b")
  }

}


Measured memory_bytes: 29232
#include<stdio.h>
int main(void){
  char s[100000];
  scanf("%s",s);
  int i,count=0;
  if(s[0]=='0'){
      for(i=1;i<100000;i++){
          if(s[i]==NULL) break;
          if(i%2==1&&s[i]=='0')
             count++;
          if(i%2==0&&s[i]=='1')
            count++;
      }
  }
  if(s[0]=='1'){
      for(i=1;i<100000;i++){
          if(s[i]==NULL) break;
          if(i%2==1&&s[i]=='1')
             count++;
          if(i%2==0&&s[i]=='0')
            count++;
      }
  }
    printf("%d",count);
  return 0;
  }
  

Measured memory_bytes: 256
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
a = readInts()
a.sort(reverse=True)

ans = a[0]
n-=2

if n%2==0:
	t = n//2
	for i in range(t):
		ans+=a[i+1]*2
		#print(ans)
else:
	t = n//2
	for i in range(t):
		ans+=a[i+1]*2
	ans+=a[t+1]

print(ans)

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

int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double pi = 3.14159265358979;
  double theta = H*5+M/12.0-M;
  if (theta < 0) theta += 60;
  if (theta > 30) theta = 60-theta;
  
  
  theta = pi * theta / 30;
  
  double L2 = A*A+B*B-2*A*B*cos(theta);
  cout << setprecision(12) << fixed;
  cout << sqrt(L2) << endl;
}

Measured memory_bytes: 4228
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
int k, MXN = 1000000, x = 1, cnt = 1;
vector<int> pr;
bool np[1000001], v[1000001];

void seeve(){
	for(int i = 2; i<=MXN; i++){
		if(np[i]) continue;
		pr.pb(i);
		for(int j = i + i; j<=MXN; j+=i)
			np[j] = 1;
	}
}

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

	seeve();
	cin >> k;
	if(k%7 == 0) k/=7;
	if(k%2 == 0 || k%5 == 0){
		cout << -1 << endl;
		return 0;
	}

	if(k == 1){
		cout << 1 << endl;
		return 0;
	}

	x = 1;
	while(x != 0){
		if(v[x]){
			cout << -1 << endl;
			return 0;
		}
		v[x] = 1; 
		x *= 10;
		x++; x %= k;
		cnt++;
	}

	cout << cnt << endl;

	cout.flush();
	return 0;
}

Measured memory_bytes: 5656
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
cnt=0
for i in range(n):
    a=list(map(int,input().split()))
    s=0
    for j in range(m):
        s+=a[j]*b[j]
    if s+c>0:
        cnt+=1
print(cnt)


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}
	map<int,int> even,odd;
	for(int i = 0; i < n; i++){
		if(i%2==0) odd[v[i]]++;
		else even[v[i]]++;
	}

	int even_1=0,even_2=0,odd_1=0,odd_2=0;
	int e1=0,e2=0,o1=0,o2=0;
	int cnt = 0;
   
	for(auto itr = even.begin();  itr != even.end() ; ++itr){
		if(itr->second > cnt){
			cnt = itr->second;
			even_1 = itr->first;
		}
	}
	e1 = cnt;
	cnt = 0;
	for(auto itr = even.begin();  itr != even.end() ; ++itr){
		if(itr->second > cnt && itr->first != even_1){
			cnt = itr->second;
			even_2 = itr->first;
		}
	}
	e2 = cnt;

	cnt = 0;
	for(auto itr = odd.begin();  itr != odd.end() ; ++itr){
		if(itr->second > cnt){
			cnt = itr->second;
			odd_1 = itr->first;
		}
	}
	o1= cnt;
	cnt = 0;
	for(auto itr = odd.begin();  itr != odd.end() ; ++itr){
		if(itr->second > cnt && itr->first != odd_1){
			cnt = itr->second;
			odd_2 = itr->first;
		}
	}
	o2=cnt;

	if(even_1 == odd_1){
		cout << min(n-e1-o2, n-e2-o1) << endl;
	}else{
		cout << n-e1-o1 << endl;
	}

	return 0;
}


Measured memory_bytes: 5376
#include <algorithm>  // sort, 二分探索(lower_bound)など
#include <cmath>      // pow, logなど
#include <complex>    // 複素数
#include <deque>      // 両端アクセスのキュー
#include <iostream>   // 入出力
#include <iterator>
#include <map>
#include <numeric>  // iota(整数列の生成), gcd, lcm
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>  // 順序保持しないmap
#include <unordered_set>  // 順序保持しないset
#include <utility>        // pair
#include <vector>

#define REP(i, n) for (int i = (0); i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= (0); --i)
#define ALL(container) (container).begin(), (container).end()
#define MAX(x) *max_element(ALL(x))  // 最大値を求める
#define MIN(x) *min_element(ALL(x))  // 最小値を求める

using namespace std;
typedef long long ll;

constexpr int INF = 1e9;
constexpr int MOD = 1000000007;

int main() {
  string S, T;
  cin >> S >> T;
  size_t len   = S.length();
  size_t count = 0;

  for (size_t i = 0; i < len; ++i) {
    if (S[i] != T[i]) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}


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


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  ll sum=0;
  cin >> n >>k;
  vector<ll> a(n);
  rep(i,n)cin >> a[i];
  sort(a.begin(),a.end());
  rep(i,n-k) sum+=a[i];
  cout << sum << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#include <random>
#include <cstring>
#include <numeric>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define forn(i, n) for (int i = 0; i < n; ++i)
#define sz(a) (int)a.size()
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
template<class T> int gmax(T &a, T b) { if (b > a) { a = b; return 1; } return 0; }
template<class T> int gmin(T &a, T b) { if (b < a) { a = b; return 1; } return 0; }
using namespace std;

const int N = 1e5 + 5;
char seq[N];
int main() {
    while(~scanf("%s", seq)) {
        int ans1 = 0, ans2 = 0;
        for(int i = 0, len = strlen(seq); i < len; ++i) {
            char c = i % 2 ? '0' : '1';
            if(seq[i] == c)
                ans1 ++;
            else ans2 ++;
        }

        printf("%d\n", min(ans1, ans2));
    }
    return 0;
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

	static class E_OddSubrectangles {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			final int MOD = 998244353;
			int height = in.nextInt();
			int width = in.nextInt();
			BigInteger[] a = new BigInteger[height];
			for (int r = 0; r < height; r++) {
				a[r] = BigInteger.ZERO;
				for (int c = 0; c < width; c++) {
					int x = in.nextInt();
					if (x == 1) {
						a[r] = a[r].or(BigInteger.ONE.shiftLeft(c));
					}
				}
			}

			int rank = calcRank(a.clone());

			long[] p2 = new long[height + width + 1];
			p2[0] = 1;
			for (int i = 1; i < p2.length; i++) {
				p2[i] = 2 * p2[i - 1] % MOD;
			}
			long ans = p2[height + width - 1] - p2[height + width - 1 - rank];
			if (ans < 0) {
				ans += MOD;
			}
			out.println(ans);
		}

		private int calcRank(BigInteger[] rows) {
			diagonalize(rows);
			int res = 0;
			for (BigInteger row : rows) {
				if (!row.equals(BigInteger.ZERO)) {
					++res;
				}
			}
			return res;
		}

		private void diagonalize(BigInteger[] a) {
			int lastR = a.length - 1;
			int r = 0;
			while (r <= lastR) {
				if (a[r].equals(BigInteger.ZERO)) {
					BigInteger t = a[r];
					a[r] = a[lastR];
					a[lastR] = t;
					--lastR;
					continue;
				}

				int or = r;
				while (!a[r].testBit(or)) {
					++or;
				}
				if (or != r) {
					for (int i = 0; i <= lastR; i++) {
						boolean bitR = a[i].testBit(r);
						boolean bitOR = a[i].testBit(or);
						if (bitOR) {
							a[i] = a[i].setBit(r);
						} else {
							a[i] = a[i].clearBit(r);
						}
						if (bitR) {
							a[i] = a[i].setBit(or);
						} else {
							a[i] = a[i].clearBit(or);
						}
					}
				}
				for (int i = r + 1; i <= lastR; i++) {
					if (a[i].testBit(r)) {
						a[i] = a[i].xor(a[r]);
					}
				}

				++r;
			}
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

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

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

	}
}



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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;
#define INF 1e9
int N, A;

int main(){
  //cout << "a" << endl;
  cin >> N >> A;
  //cout << "hello" << endl;
  vector<int> x(N);
  REP(i, N){
    cin >> x[i];
  }
  //ll dp[52][52][50*50+10] = {0};
  ll dp[51][51][50*50+2]={0};
  dp[0][0][0] = 1;

  REP(i, N){
    REP(j, N){
      REP(k, N*A){
        dp[i+1][j+1][k+x[i]] += dp[i][j][k];
        dp[i+1][j][k] += dp[i][j][k];
      }
    }
  }
  ll ans = 0;
  FOR(i, 1, N+1){
    ans += dp[N][i][i*A];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 51072
import java.io.*;
import java.util.*;

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

		long n = in.nextLong();

		if (n%2 == 1) {
			System.out.println(0);
		} else {
			long count = 0;
			for (long i=10; i<=1000000000000000000L; i*=5)
				count += n/i;
			System.out.println(count);
		}
	}
}



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

const int maxn = 1e5+10;
int n,k;
int a[maxn];

int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	int s = 0;
	int e = k-1;
	int res = 1e9;
	int i=0;
	while(a[i]<=0){
		i++;
	}
	while(e<n){
		int sum1,sum2;
		if(s<i)
		sum1 = -a[s];
	else sum1 = a[s];
	if(e>=i)
		sum2 = a[e];
	else sum2 = -a[e];
	if(e>=i&&s<i)
		res = min(res,sum1+sum2+min(sum1,sum2));
	else if(e<i)res = min(res,sum1);
	else if(s>=i)res = min(res,sum2);
		e++;
		s++;
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

class Main {
   public static void main(String[] args)
   {
      Scanner scan = new Scanner(System.in);
      int     left = 0, right = 0;

      int[] array = new  int[4];
      for(int i = 0; i < 4; i++){
          array[i] = scan.nextInt();
          }
      left  += array[0] += array[1];
      right += array[2] += array[3];
      if(left - right == 0){
         System.out.println("Balanced");
         }
      else if(left - right > 0){
              System.out.println("Left");
              }
      else{
          System.out.println("Right");
          }
   }
}


Measured memory_bytes: 24020
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BSimilarArrays {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> A(N);
        REP(i, N) cin >> A[i];

        int ans = 1;
        REP(i, N) ans *= 3;

        int sub = 1;
        REP(i, N) {
            if (A[i] & 1) {
                sub *= 1;
            } else {
                sub *= 2;
            }
        }
        ans -= sub;

        cout << ans << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BSimilarArrays solver;
    solver.solve(in, out);
    return 0;
}


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

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int X, Y;
  cin>>X>>Y;
  for(int T = 0; T <= X; T++) {
    int K = X - T;
    if(T * 2 + K * 4 == Y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int min_index = 0;
    REP(i, n) {
        int a;
        cin >> a;
        if(a == 1) min_index = i;
    }

    int ans = 1001001001;
    FOR(middle_index, min_index - k + 1, min_index + k - 1) {
        int left_cnt = (middle_index + (k - 1) - 1) / (k - 1);
        int right_cnt = (n - middle_index - 1 + (k - 1) - 1) / (k - 1);
        ans = min(ans, left_cnt + right_cnt);
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define ll long long
ll a[200010];

int main(){
    int n;
    cin >> n;
    for(int i=0; i<n; i++)cin >> a[i];
    ll res = 0;
    int j = 0;
    ll now = 0;
    for (int i = 0; i < n; ++i) {
        while (j < n && (now ^ a[j]) == (now + a[j])) {
            now += a[j];
            ++j;
        }
        res += (j - i);
        if (j == i) ++j;
        else now -= a[i];
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 5168
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

struct Segtree {
    const int INF = numeric_limits<int>::max();
    int n;
    vector<int> dat;
    Segtree(int n_) : n(), dat(n_ * 4, INF) {
        int x = 1;
        while (n_ > x) {
            x *= 2;
        }
        n = x;
    }
 
    void update(int i, int x) {
        i += n - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }
 
    int query(int a, int b) { return query_sub(a, b, 0, 0, n); }
    int query_sub(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return INF;
        } else if (a <= l && r <= b) {
            return dat[k];
        } else {
            int vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            int vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
};


int main() {
    int n, q;
    cin >> n >> q;
    Segtree seg(n);
    rep(i, q){
        int c, x, y;
        cin >> c >> x >> y;
        if(c == 0){
            seg.update(x, y);
        }else{
            cout << seg.query(x, y+1) << endl;
        }
    }
}


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

#define mod 1000000007
#define MAX_N 200010
long long inv[MAX_N];
long long factorial[MAX_N];
long long inv_factorial[MAX_N];

void GetInv(){
    for (int i = 1; i < MAX_N; i++) {
        if (i == 1) inv[i] = 1;
        else {
            inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
            if (inv[i] < 0) inv[i] += mod;
        }
    }
}
void GetFactorial(){
    factorial[0] = 1; inv_factorial[0] = 1;
    for (int i = 1; i < MAX_N; i++) {
        factorial[i] = factorial[i-1] * i;
        factorial[i] %= mod;
        inv_factorial[i] = inv_factorial[i-1] * inv[i];
        inv_factorial[i] %= mod;
    }
}

long long combination(int n, int r) {
    long long ret = factorial[n] * inv_factorial[r];
    ret %= mod;
    ret *= inv_factorial[n-r];
    return ret % mod;
}

long long modpow(int n, int r) {
    long long ret = 1; long long tmp = (long long) n;
    while (r != 0) {
        if (r % 2) ret *= tmp;
        tmp *= tmp; tmp %= mod; ret %= mod;
        r /= 2;
    }
    return ret;
}


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    GetInv(); GetFactorial();
    int n; cin >> n;
    vector<long long> c(n);
    for (int i = 0; i < n; i++) cin >> c[i];
    sort(c.rbegin(), c.rend());
    long long ans = 0;
    for (int m = 0; m < n; m++) {
        long long curr = 0;
        curr += m * modpow(2, m) % mod;
        curr += modpow(2, m+1);
        curr %= mod;
        ans += curr * modpow(inv[2], m) % mod * c[m] % mod;
        ans %= mod;
    }
    ans = ans * modpow(4, n-1) % mod;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 6528
N=int(input())
A=input()
B=input()
C=input()
count=0
for i in range(N):
    if A[i]==B[i]==C[i]:
        count+=0
    elif (A[i]==B[i] and A[i]!=C[i]) or (A[i]==C[i] and A[i]!=B[i]) or (B[i]==C[i] and A[i]!=B[i]):
        count+=1
    elif (A[i]!=B[i]) and (B[i]!=C[i]):
        count+=2
print(count)


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

using LL = long long;

const int N = 200000;

int n, a[N];
std::vector<std::pair<LL, LL>> parts[2][N + 1];

void solve(int t)
{
    LL sum = a[0], sub = a[0];
    for (int i = 1, j = 1; i < n; ++ i) {
        sum += a[i];
        while (j + 1 <= i && sub + a[j] <= sum - (sub + a[j])) {
            sub += a[j ++];
        }
        parts[t][i + 1].emplace_back(sub, sum - sub);
        if (j + 1 <= i) {
            parts[t][i + 1].emplace_back(sub + a[j], sum - (sub + a[j]));
        }
    }
}

int main()
{
#ifdef LOCAL_JUDGE
    freopen("B.in", "r", stdin);
#endif
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i) {
        scanf("%d", a + i);
    }
    solve(0);
    std::reverse(a, a + n);
    solve(1);
    LL result = std::numeric_limits<LL>::max();
    LL tmp[4];
    for (int i = 2; n - i >= 2; ++ i) {
        for (auto&& u : parts[0][i]) {
            tmp[0] = u.first;
            tmp[1] = u.second;
            for (auto&& v : parts[1][n - i]) {
                tmp[2] = v.first;
                tmp[3] = v.second;
                auto ma = *std::max_element(tmp, tmp + 4);
                auto mi = *std::min_element(tmp, tmp + 4);
                result = std::min(result, ma - mi);
            }
        }
    }
    printf("%lld\n", result);
}

Measured memory_bytes: 29184
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  
  Q *= 4;
  H *= 2;
  int ichi = min({ Q, H, S });
  
  int ans = 0;
  if( ichi * 2 <= D ){
    ans = N*ichi;
    cout << ans << endl;
    return 0;
  }else{
    ans = ( N/2 )*D;
    ans += ( N % 2 )*ichi;
    cout << ans << endl;
    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();
		int time = sc.nextInt();
		int[] c = new int[n];
		int[] t = new int[n];
		int mincost = 1001;

		for (int i = 0; i < n; i++) {
			c[i] = sc.nextInt();
			t[i] = sc.nextInt();
		}

		for (int i = 0; i < n; i++) {
			if (t[i] <= time) {
				if (c[i] <= mincost) {
					mincost = c[i];
				}
			}
		}

		if (mincost == 1001) {
			System.out.println("TLE");
		} else {
			System.out.println(mincost);
		}
	}
}

Measured memory_bytes: 21844
n = int(input())
d = []

for i in range(n):
    d.append(int(input()))

d_sort = []
d_sort = sorted(d)
count = 0

for i in range(len(d_sort)-1):
    if(d_sort[i] == d_sort[i+1]):
        count += 1

print(len(d)-count)





Measured memory_bytes: 3060
import sys
import socket
from math import pi

hostnames = ['N551J', 'F551C', 'X553M']
input_file = 'a1.in'
if socket.gethostname() in hostnames:
    sys.stdin = open(input_file)


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    r = read_int()
    return 2 * pi * r


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9872
import numpy as np
H, W, K = map(int, input().split())
state = np.zeros((H, W), dtype=int)
for h in range(H):
  hlist = input()
  for w in range(W):
    if hlist[w] == "#":
      state[h][w]=1

startb = np.sum(state)
count = 0

if startb < K:
  print(0)
else:
  h_l = 2**H
  w_l = 2**W
  for h in range(h_l):
    for w in range(w_l):
      t1 = [int(i) for i in list(str(bin(h))[2:])]
      t2 = np.zeros(H-len(t1), dtype=int)
      wflag = np.append(t2, t1)
      state_t = state * np.array([wflag]*W).T

      t1 = [int(i) for i in list(str(bin(w))[2:])]
      t2 = np.zeros(W-len(t1), dtype=int)
      hflag = np.append(t2, t1)
      state_t = state_t * np.array([hflag]*H)

      if np.sum(state_t)==K:
        count=count+1
  print(count)

Measured memory_bytes: 27240
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

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



int main(){

    int n;
    cin >> n;
    int a[n];
    inrep(n,a);

    int ans = inf;

    rep(i,0,101){
	int t = 0;
	rep(j,0,n){
	    t += (a[j]-i)*(a[j]-i);
	}
	ans = min(ans,t);
    }
    P(ans);
    return  0;
}


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

ans = 0
for i in range(n):
    a[i] -= 1
    ans += b[a[i]]
    if i>0 and a[i-1]+1 == a[i]:
        ans += c[a[i-1]]
print(ans)


Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    bool takahashi = true;
    bool takahashiWin = true;
    while (true) {
        if (takahashi) {
            C -= B;
            takahashi = false;
            if (C <= 0) {
                takahashiWin = true;
                break;
            }
        }
        else {
            A -= D;
            takahashi = true;
            if (A <= 0) {
                takahashiWin = false;
                break;
            }
        }
    }

    cout << (takahashiWin ? "Yes" : "No") << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3632
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val H, W = sc.nextInt()
  val squares = Array.fill(H)(sc.next().toCharArray).filterNot(_.forall(_ == '.'))
  val rotated = 0.until(W).map(i => squares.map(_ (i))).toArray.filterNot(_.forall(_ == '.'))
  rotated.head.indices.map(i => rotated.map(_ (i))).foreach(line => println(new String(line)))
}


Measured memory_bytes: 56368
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i];
	}
	
	int ans = 0;
	for(int i = 0; i < n - 1; i++) {
		int tmp = 1;
		while(v[i] == v[i + 1]) {
			tmp++;
			i++;
			
			if(i == n) {
				break;
			}
		}
		
		ans += tmp / 2;
	}
	
	cout << ans << endl;
	
    return 0;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())
res = []
i = 1
while True:
    r = (a * i) % b
    if r == c:
        print("YES")
        break
    else:
        if r in res:
            print("NO")
            break
        else:
            res.append(r)
    i += 1

Measured memory_bytes: 2940
'use strict'

const main = input => {
	const args = input.trim().split(' ')
	const a = parseInt(args[0], 10)
	const b = parseInt(args[1], 10)
	const c = parseInt(args[2], 10)
	if (c >= a && c <= b) console.log('Yes')
	else console.log('No')
}

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


Measured memory_bytes: 7372
n=input().split('\n')
N=int(n[0])
A=input().split('\n')
A=A[0].split()
B=input().split('\n')
B=B[0].split()
answer=0
for i in range(0,N):
  if int(A[i])>int(B[i]):
    answer=answer+int(A[i])-int(B[i])
print(answer)

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

int main(){
  int n;

  cin >> n;

  int a, ans;
  for(int i = 0;i < n;i++){
    cin >> a;
    ans += a % 2;
  }

  if(ans & 1){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }

  return 0;
}

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

ll modinv(ll a,ll m){
   ll b=m,u=1,v=0;
   while(b){
      ll t=a/b;
      a-=t*b; 
      swap(a,b);
      u-=t*v; 
      swap(u,v);
   }
   u%=m;
   if(u<0) u+=m;
   return u;
}

ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



int main(){
   vector<int> a(5);
   rep(i,5){
      cin>>a[i];
   }
   int ans=1000000000;
   do{
      int kari=0;
      rep(i,5){
         kari+=a[i];
         if(i==4) {
            ans=min(kari,ans);
            break;
         }
         else {
            if(kari%10!=0) kari+=(10-kari%10);
         }
      }

   }while(next_permutation(a.begin(),a.end()));
   cout<<ans;
   return 0;
}



Measured memory_bytes: 256