akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

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

    long long N;

    cin >> N;

    long long x = 1;
    long long y = N;

    long long z = sqrt(N) + 1;

    for(long long i = 2; i < z; i++) {
        if(N % i == 0) {
            x = i;
            y = N / i;
        }
    }

    cout << x + y - 2 << endl;
}

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

#define nmax 100000
int main() {
    int n, m;
    cin>>n>>m;
    vector<vector<int>> arrowright(nmax+1);
    vector<vector<int>> arrowleft(nmax+1);
    int x, y;
    for (int i=0;i<m;i++) {
        cin>>x>>y;
        arrowright[y].push_back(x);
        arrowleft[x].push_back(y);
    }
    int countNum[nmax+1]={0};
    for (int i = 1; i<=n; ++i) {
        countNum[i] = arrowright[i].size();
    }
    int a[nmax +1];
    int flag[nmax+1]={0};
    
    int count = 0;
    
    deque<int> de;
    while ( count != n) {
        while (!de.empty()) {
            int num = de.front();
            a[count] = num;
            count++;
            de.pop_front();
            for (auto ele : arrowleft[num]) {
                --countNum[ele];
                if (countNum[ele] == 0 &&!flag[ele]) {
                    de.push_back(ele);
                    flag[ele] = 1;
                }
            }
        }
        for (int i = 1; i <= n; ++i) {
            if (countNum[i] == 0 && !flag[i]){
                de.push_back(i);
                flag[i]=1;
            }
        }
    }
    int num[nmax]={0};
    for (int i = 0; i < n; ++i) {
        for (auto ele: arrowright[a[i]]) {
            num[a[i]] = max(num[a[i]], num[ele] + 1);
        }
    }
    int maxnumber = 0;
    for (int i = 1; i<= n; ++i) {
        maxnumber = max(maxnumber, num[i]);
    }
    cout<<maxnumber<<endl;
    return 0;
}

Measured memory_bytes: 12800
#include <stdio.h>
#define MAX_NUM 100000

int main(void){
    int N;
    int num[MAX_NUM] = {0};
    int i, count =0;
    
    scanf("%d", &N);
    for(i=0; i<N; i++)
         scanf(" %d", &num[i]);

    for(i=0; i<N; i++){
        if(num[i] == i+1){
            count++;
            i++;
        }
    }
    
    printf("%d", count);
    return 0;
}

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

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = 998244353;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll n, a, b, k, f[300300], res;

ll c(int n, int r) {
	return f[n] * mop(f[n-r],mod-2) %mod * mop(f[r],mod-2) %mod;
}

signed main() {
	cin >> n >> a >> b >> k;
	f[0] = 1;
	reps(i,1,300300) f[i] = f[i-1]*i %mod;
	rep(i,n+1) {
		if (k<i*a || (k-i*a)%b) continue;
		int j = (k-i*a)/b;
		if (j<=n) (res += c(n,i) * c(n,j)) %= mod;
	}
	cout << res;
}

Measured memory_bytes: 2560
N = int(input())
pos = []
for _ in range(N):
    x,y = [int(v) for v in input().split()]
    pos.append((x,y))

path = []
def dfs(state):
    if len(state) == N:
        path.append(state)
        return
    for i in range(N):
        if i not in state:
            nstate = state[:]
            nstate.append(i)
            dfs(nstate)

dfs([])
ans = 0
for p in path:
    n = p[0]
    tmp = 0
    for nn in p[1:]:
        tmp += (abs(pos[n][0] - pos[nn][0]) ** 2 + abs(pos[n][1] - pos[nn][1]) ** 2) ** (1/2)
    ans += (tmp / len(path))
print(ans)


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

long long power(long long a, long long b) {
    //a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
    }
   
    
   int binomial(int n, int k)  
{  
    // Base Cases  
    if (k == 0 || k == n)  
        return 1;  
  
    // Recur  
    return binomial(n - 1, k - 1) + binomial(n - 1, k);  
}   

bool Sieve(ll int n) 
{ 
    
    bool prime[n+100000]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    return prime[n];
}
  
    
vector<long long> factor;  
vector<long long>prime(long long n) {
 for (long long d = 2; d * d <= n; d++) {
     while (n % d == 0) {
         factor.push_back(d);
            n /=d;
        }
    }
 if (n > 1)
    factor.push_back(n);
    return factor;
}




//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}


  
int main() 
{
    int x,y;
    cin>>x>>y;
    int k=2*x,p=4*x;
    if(y%2==0 && y>=k && y<=p)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}





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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

string s;
int dp[81111][11];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>s;
		if(s[0]=='0')break;
		memset(dp,0,sizeof(dp));
		int n=s.length();
		int res=0;
		rep(i,n){
			int num=(s[i]-'0')%11;
			rep(r,11){
				int nextr=(r*10+num)%11;
				dp[i+1][nextr]+=dp[i][r];
			}
			if(num>0)dp[i+1][num]++;
			res+=dp[i+1][0];
		}
		cout<<res<<endl;
	}
	return 0;
}

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

xyh = [list(map(int,input().split())) for _ in range(N)]
xyh.sort(key=lambda x:-x[2])

def ok(cx,cy,H):
    res = True
    for i in range(1,N):
        x,y,h = xyh[i]
        if max(H-abs(x-cx)-abs(y-cy),0) != h:
            res = False
            break
    return res

x,y,h = xyh[0]
for cx in range(101):
    for cy in range(101):
        H = h+abs(x-cx)+abs(y-cy)
        if ok(cx,cy,H):
            ans = '{} {} {}'.format(cx,cy,H)

print(ans)

Measured memory_bytes: 45404
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
//#define int long long
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0)

int32_t main(){
	IOS;
	string s;
	cin >> s;
	int n = s.size();
	int ans = 9 * (n - 1);
	int sum = 0;
	for(int i=0; i<n; i++)
		sum += s[i] - '0';
	ans = max(ans, sum);
	for(int i=0; i<s.size(); i++){
		int x = s[i] - '0';
		if(x == 1 && i == 0 || x == 0) continue;
		int sm = 0;
		for(int j=0; j<i; j++)
			sm += s[j] - '0';
		sm += x-1;
		for(int j=i+1; j<n; j++)
			sm += 9;
		ans = max(ans, sm);
	}
	cout << ans << endl;
}


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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}

ll ncm(ll n, ll m, ll mod){
  ll ans = 1;
  rep(i, m){
    ans *= (n-i);
    ans %= mod;
  }

  rep(i, m){
    ans *= pow(i+1, mod - 2, mod);
    ans %= mod;
  }

  return ans;
}


void solve(){
  const ll mod = 1000000007;
  ll n, a, b;
  cin >> n >> a >> b;
  cout << (((pow(2, n, mod) - 1 - ncm(n, a, mod) - ncm(n, b, mod)) % mod) + mod) % mod << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef long double LD;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))


const int N=1000001;
const int INF = 1e9+7;

int main()
{
    string s;
    cin>>s;
    bool flag[4];
    CLR(flag);
    REP(i,s.size())
    {
        switch(s[i])
        {
            case 'N':
                flag[0]=1;
                break;
            case 'S':
                flag[1]=1;
                break;
            case 'E':
                flag[2]=1;
                break;
            case 'W':
                flag[3]=1;
                break;
        }
    }
        if((flag[0]^flag[1])||flag[2]^flag[3])
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		int ans = 1;
		for (int i = 0; i < n; i++)
			if (ans * 2 < ans + k)
				ans *= 2;
			else
				ans += k;
		System.out.println(ans);
	}
}

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


#define INF 1000000000000


signed main()
 {
    //初めて正になる場所
    int n,k;
    cin>>n>>k;
    vector<int> x(n);
    rep(i,n){cin>>x[i];}
    int saisyou=INF;
    rep(i,n-k+1){
      int temp;
      if(x[i]<=0&&x[i+k-1]<=0){temp=-x[i];}
      if(x[i]<=0&&x[i+k-1]>=0){temp=min(x[i+k-1]-x[i]*2,x[i+k-1]*2-x[i]);}
      if(x[i]>=0&&x[i+k-1]>=0){temp=x[i+k-1];}
      saisyou=min(temp,saisyou);
    }
    cout<<saisyou;
 }


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    array<vector<ll>, 3> p;
    for(int i = 0; i < 3; ++i){
        p.at(i).resize(n, 0);
        for(int j = 0; j < n; ++j){
            cin >> p.at(i).at(j);
        }
        sort(p.at(i).begin(), p.at(i).end());
    }

    vector<ll> count(n, 0);
    for(int i = 0; i < n; ++i){
        auto it = upper_bound(p.at(2).begin(), p.at(2).end(), p.at(1).at(i));
        count.at(i) = p.at(2).end() - it;
    }
    vector<ll> cumsum(n, 0);
    for(int i = n - 1; i >= 0; --i){
        cumsum.at(i) = count.at(i);
        if(i < n - 1){
            cumsum.at(i) += cumsum.at(i + 1);
        }
    }

    ll ans = 0;
    for(int i = 0; i < n; ++i){
        auto it = upper_bound(p.at(1).begin(), p.at(1).end(), p.at(0).at(i));
        if(it != p.at(1).end()){
            ans += cumsum.at(it - p.at(1).begin());
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4224
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <cstdio>

using namespace std;

int n;

void dfs(int b, int i, string s) {
	if (i >= n) {
		printf("%s\n", s.c_str());
		return;
	}
	for (int j = 0; j < 10; ++j) {
		if (j == 0 || (b & (1 << (j - 1))) != 0) {
			dfs(b | (1 << j), i + 1, s + string(1, 'a' + j));
		}
	}
}

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		n = -1;
		cin >> n;
		if (n < 0) return 0;
		dfs(1, 1, "a");
	}
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
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;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int N,H;
  cin>>N>>H;
  vector<int> a;
  vector<int> b;

  rep(i,N){
    int aa,bb;
    cin>>aa>>bb;
    a.emplace_back(aa);
    b.emplace_back(bb);
  }

  sort(ALL(a),greater<int>());
  sort(ALL(b),greater<int>());
  int ans=0;
  int i=0;
  rep(i,N){
    if(H<=0) break;
    if(a[0]<b[i]) {
      H-=b[i];
      ++ans;
    }
    else break;
  }

  ans+=max(0,(H+a[0]-1)/a[0]);

  cout<< ans<<"\n";

}

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


Measured memory_bytes: 1276
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
    double w;
    while(scanf("%lf",&w)!=EOF){
        if(w<=48) cout<<"light fly"<<endl;
        else if(w<=51) cout<<"fly"<<endl;
        else if(w<=54) cout<<"bantam"<<endl;
        else if(w<=57) cout<<"feather"<<endl;
        else if(w<=60) cout<<"light"<<endl;
        else if(w<=64) cout<<"light welter"<<endl;
        else if(w<=69) cout<<"welter"<<endl;
        else if(w<=75) cout<<"light middle"<<endl;
        else if(w<=81) cout<<"middle"<<endl;
        else if(w<=91) cout<<"light heavy"<<endl;
        else cout<<"heavy"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <cmath>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, T, A, H;
    cin >> N >> T >> A >> H;
    int ans = 0, diff = abs(1000 * (A - T) + H * 6);
    FOR(i, 1, N) {
        cin >> H;
        if (abs(1000 * (A - T) + H * 6) < diff) {
            ans = i;
            diff = abs(1000 * (A - T) + H * 6);
        }
    }
    cout << ans + 1 << endl;
    return 0;
}

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

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

    int n; cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        mp[a]++;
    }

    if (mp[0] == n) {
        cout << "Yes" << endl;
        return 0;
    }
    if (n % 3) {
        cout << "No" << endl;
        return 0;
    }

    vector<int> lst;
    for (auto &e: mp) {
        for (int i = 0; i < e.second / (n / 3); i++) lst.push_back(e.first);
    }
    if (lst.size() == 3 && (lst[0] ^ lst[1] ^ lst[2]) == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3840
from collections import Counter


def getinputdata():
    # 配列初期化
    array_result = []

    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            array_temp = []

            if (data != ""):

                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

a = int(arr_data[0][0])
b = int(arr_data[0][1])
x = int(arr_data[0][2])

# print(a, b, x)

print(b // x - (a-1)//x)

Measured memory_bytes: 3316
N, T = list(map(int,input().split()))
AB = [(0,0) for _ in range(N)]

for i in range(N):
    AB[i] = tuple(map(int,input().split()))

AB.sort()

dp = [[0]*(T+1) for _ in range(N+1)]

for t in range(T+1):
    dp[0][t] = 0

for i in range(N):
    for t in range(T+1):
        if t >= AB[i][0]:
            dp[i+1][t] = max(dp[i][t - AB[i][0]] + AB[i][1], dp[i][t])
        else:
            dp[i+1][t] = dp[i][t]

b_max = 0
for i in range(N):
    b_max = max(b_max, dp[i][T-1] + AB[i][1])

print(b_max)

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  vector<set<ll>> ss(m);
  rep(i,m){
    ll k; cin>>k;
    rep(j,k){
      ll s; cin>>s; s--;
      ss[i].insert(s);
    }
  }
  vll p(m);
  rep(i,m) cin>>p[i];
  
  ll ans=0;
  for(ll bit=0; bit<(1<<n); bit++){
    vll cnts(m);
    rep(i,n){
      if(bit&(1<<i)){
        rep(j,m){
          if(ss[j].count(i)) cnts[j]++;
        }
      }
    }
    bool ok=true;
    rep(i,m){
      if(cnts[i]%2!=p[i]) ok=false;
    }
    if(ok) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
from itertools import accumulate

n, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

w1 = wv[0][0]
weights = [[] for _ in range(4)]

for w, v in wv:
    w_diff = w - w1
    weights[w_diff].append(v)

for i in range(4):
    weights[i].sort(reverse=True)

acc = [[0] + list(accumulate(li)) for li in weights]

ans = 0
for i, e1 in enumerate(acc[0]):
    for j, e2 in enumerate(acc[1]):
        for k, e3 in enumerate(acc[2]):
            for l, e4 in enumerate(acc[3]):
                if w1 * i + (w1 + 1) * j + (w1 + 2) * k + (w1 + 3) * l <= W:
                    ans = max(ans, e1 + e2 + e3 + e4)

print(ans)


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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;
}

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    const i64 mod = 1'000'000'007;

    string L;
    cin >> L;

    reverse(begin(L),end(L));

    vector<vector<i64>> dp(100001,vector<i64>(2));
    dp[L.length()-1][0]=1;
    dp[L.length()-1][1]=2;
    for(i64 i=L.length()-1; i>0; --i){
        {
            if(L[i-1]=='1'){
                dp[i-1][1]+=dp[i][1]*2%mod;
                dp[i-1][1]%=mod;
                print(dp[i-1][1]);

                dp[i-1][0]+=dp[i][1];
                dp[i-1][0]%=mod;
                print(dp[i-1][0]);
            }else{
                dp[i-1][1]+=dp[i][1];
                dp[i-1][1]%=mod;
                print(dp[i-1][1]);
            }
        }
        {
            dp[i-1][0]+=dp[i][0]*3%mod;
            dp[i-1][0]%=mod;
            print(dp[i-1][0]);
        }
    }

    print(dp[0][0]);
    print(dp[0][1]);
    cout << (dp[0][0]+dp[0][1])%mod << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 5840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    double a,b,x;
    cin >> a >> b >> x;
    double ans;
    double pi=3.14159265258979;
    if(a*a*b/2.0<=x){
        ans=atan(2*(a*a*b-x)/(a*a*a));
        ans=(180*ans)/pi;
    }else {
        ans=pi/2-atan(2*x/(a*b*b));
        ans=(180*ans)/pi;
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 4108
/*
我的心脏怦怦跳，监管者就在附近
name:B - Count ABC
Algorithm:字符串 模拟 
writer:Lxs(cdx)
place:Atcoder
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	int n;
	cin>>n;
	string st;
	cin>>st;
	int i;
	int g=0;
	for(i=0;i<st.size();i++){
		if(st[i]=='A'&&st[i+1]=='B'&&st[i+2]=='C'){
			g++;
		}
	}
	cout<<g;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 500000

void maxHeapify(int i, int h);

int g_A[MAX+1];

int main(){
  int h;
  scanf("%d",&h);

  for(int i = 1; i <= h; i++) scanf("%d",&g_A[i]);

  for(int i = h / 2; i >= 1; i--) maxHeapify(i, h);

  for(int i = 1; i <= h; i++) printf(" %d",g_A[i]);
  printf("\n");
  
  return 0;
}

void maxHeapify(int i, int h){
  int l, r, largest;
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= h && g_A[l] > g_A[i]) largest = l;
  else largest = i;
  if(r <= h && g_A[r] > g_A[largest]) largest = r;

  if(largest != i){
    int temp;
    temp = g_A[i];
    g_A[i] = g_A[largest];
    g_A[largest] = temp;
    maxHeapify(largest, h);
  }
}




Measured memory_bytes: 3668
#include <iostream>
using namespace std;
int main(){
     int K,A,B,flag=0;
     cin >> K >> A >> B;
     for (int i=0;i<=B-A;i++)if ((A+i)%K==0)flag++;
     if(flag!=0){
          cout <<"OK"<<endl;
     }else{
          cout <<"NG"<<endl;
     }
}


Measured memory_bytes: 3596
import sys
input = sys.stdin.readline

def main():
    A, B = map(int, input().split())
    if A == 1:
        A = 14
    if B == 1:
        B = 14
    
    if A > B:
        print("Alice")
    elif B > A:
        print("Bob")
    else:
        print("Draw")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

int main() {
  int n;
  std::cin >> n;

  std::vector<int> a(n);
  for (auto&& ai : a) std::cin >> ai;

  double sum = 0;
  for (auto&& ai : a) sum += 1.0 / ai;
  std::cout << 1.0 / sum << std::endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, c, d = map(int, input().split())
    if a <= c <= d <= b:
        print(d - c)
    elif a <= c <= b <= d:
        print(b - c)
    elif c <= a <= d <= b:
        print(d - a)
    elif c <= a <= b <= d:
        print(b - a)
    else:
        print(0)


if __name__ == '__main__':
    resolve()


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

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) 
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) 
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i)
#define deb(x) cout << #x << "= " << x << endl
#define pb push_back
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define tr(x) for(auto it = x.begin(); x != x.end(); it++)
#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int main() {
    fast;
    int t=1;
    while(t--){
        //begin code here
        int x;
        cin>>x;
        cout<<1-x;
    }
}

Measured memory_bytes: 3632
#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++)
#define EPS (1e-7)

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

int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;

int n;
int a[2][105];

int main(){
	cin>>n;
	for(int i=0;i<2;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	int res=0;
	REP(i,n){
		int sum=0;
		for(int j=0;j<=i;j++){
			sum+=a[0][j];
		}
		for(int j=i;j<n;j++){
			sum+=a[1][j];
		}
		res=max(res,sum);
	}
	cout<<res<<endl;
	return 0;
}

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

using namespace std;

int H, W, D, Q;
int Ro[101010];
int C[101010];
long long Re[90000];
int main(void){
	scanf("%d %d %d", &H, &W, &D);
	for(int i = 0;i < H;++i){
		for(int j = 0;j < W;++j){
			int t;
			scanf("%d", &t);
			Ro[t] = i;
			C[t] = j;
		}
		getchar();
	}

	for(int i = D;i <= H*W;++i){
		Re[i] = Re[i-D] + abs(Ro[i] - Ro[i-D]) + abs(C[i] - C[i-D]);
	}

	scanf("%d", &Q);
	for(int i = 0;i < Q;++i){
		int L, R;
		scanf("%d %d", &L, &R);
		int t = L;
		long long s = 0;
		s = Re[R] - Re[L];
		printf("%lld\n", s);
	}

	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod=1e9+7;
ll add(ll a, ll b)
{
    return ((a%mod)+(b%mod))%mod;
}
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        ll sum=0;
        for(int i=k;i<=(n+1);i++)
        {
            sum=add(sum,(n+2-i)+(n+1-i)*(i-1));
           // cout<<(n+2-i)+(n+1-i)*(i-1)<<"\n";
        }
        cout<<sum<<"\n";
    }
}



Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

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

int main() {
	int a, b, c;
	int k;
	cin >> a >> b >> c;
	cin >> k;
	int i = 0, x = 0;
	int flag = 0;
	while(i < k){
		if(x == 0){
			if(b <= a){
				b *= 2;
				i++;
			}
			if(b > a){
				x = 1;
			}
		}
		else if(x == 1){
			if(c <= b){
				c *= 2;
				i++;
			}
			if(c > b){
				flag = 1;
				break;
			}
		}
	}
	if(flag == 1) cout << "Yes";
	else cout << "No";
	
	return 0;
}

Measured memory_bytes: 3616
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define int long long int
using namespace std;

void desperate_optimization(bool submitting=true,int precision=10)
{
  if(!submitting) return;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(precision);
}
const int mod=1e9+7;
int32_t main()
{
  desperate_optimization(true);
  int n,k;
  cin>>n>>k;
  vector<int> ways(k+1);
  ways[0]=1;

  for(int i=0;i<n;i++)
  {
    int up_to;
    cin>>up_to;
    int fake_prefix[k+1]={0};
    for(int used=k;used>=0;used--)
    {
      int l=used+1;
      int r=used+min(up_to,k-used);
      fake_prefix[l]+=ways[used];
      if(fake_prefix[l]>=mod) fake_prefix[l]-=mod;
      if(r+1<=k)
      {
        fake_prefix[r+1]-=ways[used];
        if(fake_prefix[r+1]<0) fake_prefix[r+1]+=mod;
      }
    }
    int prefix=0;
    for(int i=0;i<=k;i++)
    {
      prefix+=fake_prefix[i];
      if(prefix>=mod) prefix-=mod;
      ways[i]+=prefix;
      if(ways[i]>=mod) ways[i]-=mod;
    }
  }
  cout<<ways[k];

  return 0;
}


Measured memory_bytes: 1792
ans :: [[Int]] -> [Int]
ans ([0]:_) = []
ans ([k]:l:xs) =
  let d = k - 1
      a = sum l
  in
    (a`div`d):ans xs

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  mapM_ print o
                                                  

Measured memory_bytes: 5668
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
#include <vector>
#include<cstdio>
#include <numeric>
#include <queue>
#include <list>
#include <math.h>
#include <stdio.h>
#include <math.h>
#include <errno.h>
#include <fenv.h>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
long long mod=1000000007;
int main()
{
 
  /* 文字 */
  char moji; cin>>moji;
 
  /* A to Zを出力 */
  for(char i='A'; i<='Z'; ++i)
    if(i==moji)cout<<'A'<<endl;

for(char i='a'; i<='z'; ++i)
    if(i==moji)cout<<'a'<<endl;
 
 
  
}


Measured memory_bytes: 3636
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String n = sc.next();
    char a[] = new char[3];
    for(int i=0 ; i<3 ; i++){
      a[i] = n.charAt(i);
    }
    if(a[0]==a[2]){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lop ios; ll t; cin>>t; while(t--)
#define pb push_back
#define vi vector<ll>
#define vivi vector<vector<ll>> 
#define vipa vector<pair<ll,ll>>
#define F first
#define S second
#define M 1000000007
#define kl "\n"
typedef long long ll;
ll lcm(ll x, ll y){ll k=x*y; k/=(__gcd(x,y)); return k;}
ll power(ll x,ll y){ ll r= 1;x = x % M;if(x==0) return 0; while(y>0) {if(y&1) r=(r*x)%M; y=y>>1; x=(x*x)%M;} return r;}  
void solve()
{ 
   int n,k;cin>>n>>k;
   int a[n+1];
   for(int i=0;i<n;i++)cin>>a[i];
   int l=1,r=M,ans=M;
   while(l<=r)
   {
   		int mid=(l+r)/2,cnt=0;
   		for(int i=0;i<n;i++)cnt+=(a[i]-1)/mid;
   		if(cnt<=k) ans=mid,r=mid-1;	
		else l=mid+1;
   }
    cout<<ans;
}
int main() 
{ 
    // lop
    solve();
	return 0; 
} 




Measured memory_bytes: 4416
//
// Created by yamunaku on 2019/11/05.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

ll gcd(ll x, ll y){
    while(x % y){
        ll tmp = x % y;
        x = y;
        y = tmp;
    }
    return y;
}

int main(){
    ll a, b;
    cin >> a >> b;
    a = gcd(a, b);
    set<ll> st;
    st.insert(1);
    for(ll i = 2; i <= sqrt(a) + 1; i++){
        if(a % i == 0){
            st.insert(i);
            while(a % i == 0) a /= i;
        }
    }
    if(a > 1) st.insert(a);
    cout << st.size() << endl;
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  
  int n; cin >> n;
  vector<int> sites(n + 2, 0);
  for (int i = 1; i < n + 1; i++) cin >> sites.at(i);
  
  int budget = 0;
  for (int i = 0; i < n + 1; i++) budget += abs(sites.at(i) - sites.at(i + 1));
  
  for (int i = 1; i < n + 1; i++) {
    int answer = budget - abs(sites.at(i - 1) - sites.at(i)) 
                        - abs(sites.at(i) - sites.at(i + 1))
                        + abs(sites.at(i - 1) - sites.at(i + 1));
    cout << answer << "\n";
  }
}

Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<fstream>
#include<algorithm>
#include<assert.h>
#include<stack>
#include<queue>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<random>
#include<string>
#include<numeric>
#include<list>
#include<unordered_set>
#include<ctime>
#include<sstream>
#include<vector>
#include<array>
#include <bitset>
#include<functional>
#include<string>
#pragma warning(disable:4996)
#include<iostream>
#include<string>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include <iostream>
using namespace std;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>

#include <stdio.h>
#pragma warning(disable:4996)
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	for (int i = b; i <= c; i++)
	{
		if (i % a == 0)
		{
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
	return 0;

}



Measured memory_bytes: 3648
'use strict'

function main(s) {

  s = s.split('\n');

  const n = Number(s[0].split(' ')[0]);
  const m = Number(s[0].split(' ')[1]);

  const a = s.slice(1, 1 + n).map(l => l.split(''));
  const b = s.slice(1 + n, -1).map(l => l.split(''));

  const dx = [];
  const dy = [];
  for (let i = 0; i < m; i++) {
    for (let j = 0; j < m; j++) {
      dx.push(i);
      dy.push(j);
    }
  }

  let ans = false;

  for (let i = 0; i < n; i++) {
    for (let j = 0; j < n; j++) {
      
      for (let k = 0, len = Math.pow(m, 2); k < len; k++) {
        const ni = i + dx[k];
        const nj = j + dy[k];

        if (ni < 0 || n <= ni) break;
        if (nj < 0 || n <= nj) break;
        if (a[ni][nj] !== b[dx[k]][dy[k]]) break;

        if (k === (len - 1)) ans = true;
      }
    }
  }

  console.log(ans ? 'Yes' : 'No');
}

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


Measured memory_bytes: 7500
#include<iostream>
using namespace std;
int main()
{
    int K,A,B,s=1,t=0;
    cin>>K>>A>>B;
    s=1;
    for(int i=1;i<=A;i++)
    {
        s=K*i;
        if(s>=A&&s<=B)
       {
        t++;
        break;

        }

    }
    if(t==0)
    {
        cout<<"NG";
    }
    else
    {
        cout<<"OK";
    }

}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long L;
#define mx 1000006
/// 1e8 3.069
/// 1e7 0.281
/// 1e6 0.031
L mark[mx],idx,a,d,n;
void sieve(){
    mark[1]=1;mark[2]=2;
    L lim=sqrt(mx)+2;
    for(L i=3;i<=mx;i+=2){
        if(!mark[i]){
            mark[i]=2;
            if(i<=lim){
                for(L j=i*i;j<=mx;j+=i*2){
                    mark[j]=1;
                }
            }
        }
    }
}
int main(){


    sieve();
    while(scanf("%lld%lld%lld",&a,&d,&n)){
        if(a==0&&d==0&&n==0)return 0;
        L v=a,idx=1;
        if(mark[v]==2){
            n--;
        }
        while(1){
            if(n==0)break;
            v=a+(idx*d);
            if(mark[v]==2){
                n--;
            }
            idx++;
        }
        cout<<v<<"\n";
    }
    return 0;
}



Measured memory_bytes: 10944
from collections import Counter

n, *v = map(int, open(0).read().split())
vo = Counter(v[::2])
ve = Counter(v[1::2])
vo_mc = vo.most_common()[0]
ve_mc = ve.most_common()[0]
if vo_mc[0] == ve_mc[0]:
    if vo_mc[1] > ve_mc[1]:
        ans = n//2 - vo_mc[1]
        if ve_mc[1] != n//2:
            ans += n//2 - ve.most_common()[1][1]
        else:
            ans += n//2
    elif vo_mc[1] < ve_mc[1]:
        ans =  n//2 - ve_mc[1]
        if vo_mc[1] != n//2:
            ans += n//2 - vo.most_common()[1][1]
        else:
            ans += n//2
    else:
        ans = n
        if ve_mc[1] != n//2:
            ans = min(n//2 - vo_mc[1] + n//2 - ve.most_common()[1][1], ans)
        if vo_mc[1] != n//2:
            ans = min(n//2 - vo.most_common()[1][1] + n//2 - ve_mc[1], ans)
        ans = min(n//2 - vo_mc[1] + n//2, ans)
else:
    ans = n//2 - vo_mc[1] + n//2 - ve_mc[1]
print(ans)

Measured memory_bytes: 22800
N = int(input())
A = list(map(int, input().split()))

sm=0
current=0

for a in A:
    sm+=abs(current - a)
    current=a

sm+=abs(current)

A.insert(0,0)
A.append(0)

for i in range(1,len(A)-1):
    if A[i-1] <= A[i] and A[i] <= A[i+1]: # no effect to total cost
        print(sm)
    elif A[i+1] <= A[i] and A[i] <= A[i-1]: # no effect to total cost
        print(sm)
    else:
        mx = max(A[i-1],A[i+1])
        mn = min(A[i-1],A[i+1])

        if mx < A[i]:
            print(sm - 2*(A[i] - mx))
        else:
            print(sm - 2*(mn - A[i]))

Measured memory_bytes: 14172
#include <cstdio>
#include <string>
#include <iostream>

using namespace std;

int main()
{
	int n, i;
	string o, e, s;

	cin >> o >> e;

	n = o.size() + e.size();

	for (i = 0; i < n; i++) {
		if (i % 2 == 0) {
			s += o[i / 2];
		}
		else {
			s += e[(i - 1) / 2];
		}
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a[9]={0};
    int n;
    for(int i=0;i<9;i++)scanf("%d",&a[i]);
    scanf("%d",&n);
    int b[n];
    for(int i=0;i<n;i++){
        scanf("%d",&b[i]);
    }
    for(int k=0;k<n;k++)for(int j=0;j<9;j++)if(a[j]==b[k]){
            a[j]=0;
            break;
        }
    if(a[4]==a[0]&&a[4]==a[8]){
        printf("Yes");
    }else if(a[4]==a[2]&&a[4]==a[6]){
        printf("Yes");
    }else if(a[4]==a[1]&&a[4]==a[7]){
        printf("Yes");
    }else if(a[4]==a[3]&&a[4]==a[5]){
        printf("Yes");
    }else if(a[1]==a[0]&&a[1]==a[2]){
        printf("Yes");
    }else if(a[3]==a[0]&&a[3]==a[6]){
        printf("Yes");
    }else if(a[7]==a[6]&&a[7]==a[8]){
        printf("Yes");
    }else if(a[5]==a[2]&&a[5]==a[8]){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

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

template<typename F, typename T>
struct lazy_segment_tree {
        F merge;
        T identity;
        vector<T> data, lazy;
        int n;
        lazy_segment_tree(int len, F _merge, T _identity) : merge(_merge), identity(_identity) {
                n = pow(2, ceil(log2(len)));
                data.resize(2 * n - 1, identity);
                lazy.resize(2 * n - 1, 0);
        }
        // init k-th value to p
        void init(int k, T p) {
                k += n - 1;
                data[k] = p;
                while (k > 0) {
                        k = (k - 1) / 2;
                        data[k] = merge(data[k * 2 + 1], data[k * 2 + 2]);
                }
        }
        // [l, r)
        void add(int l, int r, T x) { return add(l, r, x, 0, 0, n); }
        void add(int a, int b, T x, int k, int l, int r) {
                if (r <= a || b <= l) return;
                if (a <= l && r <= b) {
                        lazy[k] += x;
                        return;
                }
                int m = (l + r) / 2;
                add(a, b, x, k * 2 + 1, l, m);
                add(a, b, x, k * 2 + 2, m, r);
                data[k] = merge(data[k * 2 + 1] + lazy[k * 2 + 1], data[k * 2 + 2] + lazy[k * 2 + 2]);
        }
        // [l, r)
        T query(int l, int r) { return query(l, r, 0, 0, n); }
        T query(int a, int b, int k, int l, int r) {
                if (r <= a || b <= l) return identity;
                if (a <= l && r <= b) return data[k] + lazy[k];
                int m = (l + r) / 2;
                T left = query(a, b, k * 2 + 1, l, m);
                T right = query(a, b, k * 2 + 2, m, r);
                return merge(left, right) + lazy[k];
        }
};

int main() {
        int n, d, a;
        scanf("%d%d%d", &n, &d, &a);
        vector<pair<long long, int>> p;
        rep(i, n) {
                long long x;
                int h;
                scanf("%lld%d", &x, &h);
                p.emplace_back(x, h);
        }
        sort(p.begin(), p.end());
        auto f = [&](auto a, auto b) { return max(a, b); };
        lazy_segment_tree<decltype(f), long long> segtree(n, f, -1e18);
        rep(i, n) { 
                segtree.init(i, p[i].second);
        }
        long long ans = 0;
        rep(i, n) {
                long long v = segtree.query(i, i + 1);
                if (v <= 0) continue;
                int c = (v + a - 1) / a;
                ans += c;
                long long pos = p[i].first + 2ll * d;
                auto pop = make_pair(pos, (int) 1e9);
                auto j = upper_bound(p.begin(), p.end(), pop) - p.begin();
                segtree.add(i, j, (long long) - a * c);
        }
        printf("%lld\n", ans);
        return 0;
}



Measured memory_bytes: 12524
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

x=int(input())
a=make_divisors(x)
a.sort()
for i in range(len(a)):
    if a[i]>=x**0.5:
        print(a[i]+(x//a[i])-2)
        exit()
        
    





Measured memory_bytes: 39280
'use strict'

class Main {
  solve() {
    console.log(_.max(input.nextLine().replace(/[^ATGC]/g,'*').split('*').map((e) => e.length)));
  }
}

/* Underscore.js の移植および便利メソッド群 */
class Underscore {
  sum(arr) { return arr.reduce((a,b)=>a+b); }
  min(arr, func) { if (func == null) {func = (a,b) => a - b} return arr.reduce((a,b) => func(a,b) < 0 ? a : b); }
  max(arr, func) { if (func == null) {func = (a,b) => a - b} return arr.reduce((a,b) => func(a,b) > 0 ? a : b); }

  range(start, stop, step) {
	if (stop == null) {
	  stop = start || 0;
	  start = 0;
	}
	if (!step) {
	  step = stop < start ? -1 : 1;
	}
	const length = Math.max(Math.ceil((stop - start) / step), 0);
	const range = Array(length);

	for (var idx = 0; idx < length; idx++, start += step) {
	  range[idx] = start;
	}
	return range;
  }

  first (array, n) {
    if (array == null || array.length < 1) return n == null ? void 0 : [];
    if (n == null) return array[0];
    return this.initial(array, array.length - n);
  };

  initial (array, n) { return array.slice.call(array, 0, Math.max(0, array.length - (n == null ? 1 : n))); }

  tail(array, n) { return array.slice.call(array, n == null ? 1 : n); }

  last (array, n) { 
    if (n == null) return array[array.length - 1];
    return this.tail(array, Math.max(0, array.length - n)); 
  }

  sumArray (arr) { return this.tail(arr.reduce(((a,b,i) => {a.push(b + a[i]); return a}), [0])); }

  binarySearch (array, key, iteratee) {
	const itr = (obj) => (typeof obj === 'object') ? obj[iteratee] : obj;
	const value = itr(obj);
	let low = 0, high = array.length;
	while (low < high) {
	  let mid = Math.floor((low + high) / 2);
	  if (itr(array[mid]) < value) low = mid + 1; else high = mid;
	}
	return low;
  };
}
const _ = new Underscore();

class Input {
  constructor() {
	this.cursor = 0;
	this.inputAll();
  }

  inputAll() {
	this.data = (require("fs").readFileSync("/dev/stdin", "utf8")).split('\n');
	return this.data;
  }

  /* 1行 or 複数行文字列 */
  nextLine(n) {
	if (n) {
	  const ret = this.data.slice(this.cursor, this.cursor + n);
	  this.cursor += n;
	  return ret;
	}
	return this.data[this.cursor++];
  }
  /* 一行文字配列 */
  nextStrArr() { return this.nextLine().split(' '); } 
  /* 一行整数配列 */
  nextIntArr() { return this.nextStrArr().map((e) => parseInt(e)); }
  /* 一行浮動小数点配列 */
  nextFloatArr() { return this.nextStrArr().map((e) => parseFloat(e)); }
  /* 複数行整数配列 */
  nextIntLine(n) { return this.nextLine(n).map((e) => parseInt(e)) }
  /* 複数行浮動小数点配列 */
  nextFloatLine(n) { return this.nextLine(n).map((e) => parseFloat(e)) }
  /* 複数行文字列二次元配列 */
  nextStrRange(n) { return this.nextLine(n).map((line) => line.split(' ')); }
  /* 複数行整数二次元配列 */
  nextIntRange(n) {
	return this.nextLine(n).map((line) => line.split(' ').map((e) => parseInt(e)));
  }
  /* 複数行浮動小数点数二次元配列 */
  nextFloatRange(n) {
	return this.nextLine(n).map((line) => line.split(' ').map((e) => parseFloat(e)));
  }
} 
const input = new Input();
(new Main()).solve();


Measured memory_bytes: 7500
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
using namespace std;
const int MAXN=200000+5;
int sum[MAXN],n,K;
map<int,int>hs;
long long ans;
int main()
{
    scanf("%d%d",&n,&K);
    for(int i=1;i<=n;i++)
    scanf("%d",&sum[i]),sum[i]=(sum[i-1]+sum[i])%K;
    // sum[i]-sum[j]+t*K==i-j
   //i-j<k
   //j>i-k
   //sum[i]-i==sum[j]-j
    hs[0]++;
    for(int i=1;i<=n;i++)
    {
        if(i-K>=0)
            hs[(sum[i-K]-(i-K)%K+K)%K]--;
        ans+=hs[(sum[i]-i%K+K)%K];
        hs[(sum[i]-i%K+K)%K]++;
    }
    printf("%lld\n",ans);


    return 0;
}


Measured memory_bytes: 10368