akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 0, b = 0, c, d, n, k = 0, ans = 0;
string s, t;

int main()
{
	cin >> a >> b >> c;
	cout << c << " "<<a <<" "<< b<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	long a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k <= a + b)
		cout << min(a, k) << "\n";
	else
		cout << a - (k - (a + b)) << "\n";
	return 0;
}


Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
N = int(input())
A = list(input().rstrip())

def two_num(x):
    res = 0
    while x%2==0:
        x //= 2
        res += 1
    return res

C_twos = [0]*N
for i in range(1, N):
    res = C_twos[i-1] + two_num(N-i) - two_num(i)
    C_twos[i] = res

if '2' in A:
    ans = 0
    for i in range(N):
        ans ^= (int(A[i])-1)&1 * (C_twos[i]==0)
    print(ans)
else:
    ans = 0
    for i in range(N):
        ans ^= (int(A[i])-1)//2 * (C_twos[i]==0)
    print(ans*2)


Measured memory_bytes: 125512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int N, SN;
		N = Integer.parseInt(S);
		SN = 0;
		int N2 = N;
		for (int i = 0; i < S.length(); i++) {
			SN += N2 % 10;
			N2 /= 10;
		}
		System.out.println(N % SN == 0 ? "Yes" : "No");
	}
}

Measured memory_bytes: 23892
n, k = map(int, input().split())
x = list(map(int, input().split()))

min_time = 10**10
for i in range(n-k+1):
    time = abs(x[i] - x[i+k-1]) + min(abs(x[i]), abs(x[i+k-1]))
    min_time = min(time, min_time)

print(min_time)

Measured memory_bytes: 14384
H, W = map(int, input().split())
s = []
s.append(['.' for _ in range(W+2)])
for i in range(H):
    si = list(input())
    si = ['.'] + si + ['.']
    s.append(si)
s.append(['.' for _ in range(W+2)])
flag = True
for h in range(1,H+1):
    for w in range(1,W+1):
        if s[h][w] == '#':
            if s[h-1][w]=='.' and s[h+1][w]=='.' and s[h][w+1]=='.' and s[h][w-1]=='.' :
                flag = False

if flag:
    print('Yes')
else:
    print('No')


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

int main(int argc, char const *argv[])
{
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  cout << (r<=x && x<=W-r && r<=y && y<=H-r ? "Yes" : "No") << endl;
  return 0;
}

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

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    long[] a = new long[n];
    long[] b = new long[n];
    for (int i = 0; i < n; i++) {
      a[i] = scanner.nextLong();
      b[i] = scanner.nextLong();
    }
    scanner.close();
    long allB = 0;
    for (long l : b) {
      allB += l;
    }
    long[] ab = new long[n];
    for (int i = 0; i < n; i++) {
      ab[i] = a[i] + b[i];
    }
    Arrays.sort(ab);
    long p = 0;
    for (int i = 0; i < n; i += 2) {
      p += ab[ab.length - i - 1];
    }
    System.out.println(-allB + p);
  }

}


Measured memory_bytes: 91512
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 1000000007
#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define cd complex<double>
#define ull unsigned long long
#define base 1000000000000000000
#define fio ios::sync_with_stdio(false);cin.tie(0)

using namespace std;

const double g=10.0,eps=1e-12;
const int N=200000+10,maxn=200000+10,inf=0x3f3f3f3f,INF=0x3f3f3f3f3f3f3f3f;

int a[N];
int main()
{
    int n;scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    sort(a,a+n);
    double minn=1e9+10;
    int id;
    for(int i=0;i<n-1;i++)
    {
        if(fabs(1.0*a[n-1]/2-a[i])<minn)
        {
            minn=fabs(1.0*a[n-1]/2-a[i]);
            id=a[i];
        }
    }
    printf("%d %d\n",a[n-1],id);
    return 0;
}
/***********************

***********************/


Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long H, long long N, std::vector<long long> A){
  ll sum = 0;
  for(ll x : A)
    sum+=x;
  if(sum<H)
    std::cout << NO << std::endl;
  else
    std::cout << YES << std::endl;
}

int main(){
  long long H;
  scanf("%lld",&H);
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(H, N, std::move(A));
  return 0;
}



Measured memory_bytes: 1024
def f(nc, nt, nq):
    dp = [[0] * (nc + 1) for _ in range(nc + 1)]
    for _ in range(nt):
        l, r = map(int, input().split())
        dp[l][r] += 1
    for i in range(1, nc + 1):
        dpi = dp[i]
        s = dpi[0]
        for j in range(1, nc + 1):
            dpi[j] = s = dpi[j] + s
    for j in range(1, nc + 1):
        s = dp[0][j]
        for i in range(1, nc + 1):
            dp[i][j] = s = dp[i][j] + s
    for _ in range(nq):
        l, r = map(int, input().split())
        print(dp[r][r] - dp[l - 1][r] - dp[r][l - 1] + dp[l - 1][l - 1])


nc, nt, nq = map(int, input().split())
f(nc, nt, nq)


Measured memory_bytes: 13300
using System;

public class AtCoder
{
    public static void Main()
    {
        string[] s;
        s = NextS();
        int n = int.Parse(s[0]);
        s = NextS();
        int c = s[0].Length;
        const int p = 1000000007;

        if (c > n)
        {
            Console.WriteLine(0);
            return;
        }

        Mod mod = new Mod(5010);

        long[][] dp = new long[n+1][];
        dp[0] = new long[n + 2];
        dp[0][0] = 1;
        for(int i=1; i<=n; i++)
        {
            dp[i] = new long[n+2];
            dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
            dp[i][0] %= p;
            for(int j = 1; j<=i; j++)
            {
                dp[i][j] = dp[i - 1][j - 1] * 2 + dp[i - 1][j + 1];
                dp[i][j] %= p;
            }         
        }

        long bin = 1;
        for (int i = 0; i < c; i++) bin = bin * 2 % p;
        Console.WriteLine(dp[n][c] * mod.Pow((int)bin, p - 2) % p);

    }

    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
    public static string[] NextS() { return Console.ReadLine().Trim().Split(' '); }
}

// Mod(int n)
// int[] fac: factors (1-indexed)
// int n: the length of fac

// int .Ncr(n,r): nCr
// int .Fac(n): n!%p
// int .Pow(n,m): n^m%p

public class Mod
{
    const int p = 1000000007;
    int[] fac;

    public Mod(int n)
    {
        fac = new int[n + 1];
        for (int i = 1; i <= n; i++) fac[i] = -1;
        fac[0] = 1;
    }

    public int Ncr(int n, int r)
    {
        if (n < r) return 0;
        if (r == 0 | n == r) return 1;
        long a = Fac(n);
        a = a * Pow(Fac(n - r), p - 2) % p;
        a = a * Pow(Fac(r), p - 2) % p;
        return (int)a;
    }

    public int Fac(int n)
    {
        if (fac[n] >= 0) return fac[n];
        long k = 1;
        for (long i = 1; i <= n; i++)
        {
            k = k * i % p;
        }
        fac[n] = (int)k;
        return fac[n];
    }

    public int Pow(int n, int m)
    {
        if (m == 0) return 1;
        if (m == 1) return n;
        long a = 1;
        if (m % 2 == 0)
        {
            a = Pow(n, m / 2);
            a = a * a % p;
        }
        else
        {
            a = Pow(n, m / 2);
            a = a * a % p;
            a = a * n % p;
        }
        return (int)a;
    }
}

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

ll N,D;
ll ans=0;
// *********************************************************
int main(){

    cin >> N >> D ;

    for(ll i=0; i<N; ++i){
        ll X,Y;
        cin >> X >>Y;
        if(D*D - X*X >= Y*Y){
            ++ans;
        }

    } 

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;
class dice
{
private:
  int men[10];
  int times;
  int hint[24][2];
public:
  void set_num();
  void throw_dice(const char c);
  void try_dice();
  void show_dice();
};
void dice::throw_dice(const char c)
{
  int buf;
  switch(c)
  {
    case 'N':
    {
      buf = men[0];
      men[0] = men[1];
      men[1] = men[5];
      men[5] = men[4];
      men[4] = buf;
      break;
    }
    case 'S':
    {
      buf = men[0];
      men[0] = men[4];
      men[4] = men[5];
      men[5] = men[1];
      men[1] = buf;
      break;
    }
    case 'W':
    {
      buf = men[0];
      men[0] = men[2];
      men[2] = men[5];
      men[5] = men[3];
      men[3] = buf;
      break;
    }
    case 'E':
    {
      buf = men[0];
      men[0] = men[3];
      men[3] = men[5];
      men[5] = men[2];
      men[2] = buf;
      break;
    }
    case 'L':
    {
      buf = men[1];
      men[1] = men[3];
      men[3] = men[4];
      men[4] = men[2];
      men[2] = buf;
      break;
    }
  }
}
void dice::set_num()
{
  for(int i = 0; i< 6; i++)
  {
    cin >> men[i];
  }
  cin >> times;
  for(int i = 0 ; i < times; i++)
  {
    cin >> hint[i][0] >> hint[i][1];
  }
}
void dice::try_dice()
{
  for(int i = 0; i < times ; i++ )
  {
    if(hint[i][0] == men[2] || hint[i][0] == men[3])throw_dice('E');
    while(hint[i][0] != men[0])throw_dice('S');
    while(hint[i][1] != men[1])throw_dice('L');
    show_dice();
  }
}
void dice::show_dice()
{
  cout << men[2] << endl;
}
int main()
{
  dice dice1;
  dice1.set_num();
  dice1.try_dice();
  return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include <cmath> 
using namespace std;
const int p=31;
const int m=1e9+9;
typedef long long ll;
ll INF=1e18;
//return res.empty() ? "0" : res;

static auto speedup = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return nullptr;
}();

int main (){

    #ifndef ONLINE_JUDGE                    
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ll t;
    cin>>t;
    while(t--){
        ll n,a,b,c,d;
        cin>>n>>a>>b>>c>>d;
        vector<ll> mu={2,3,5};
        vector<ll> cs={a,b,c};
        map<ll,ll> mp;
       // ll cost=1e18;

        function<long long(long long)> f=[&](ll x){
            if(x==0) return((ll)0);
            if(x==1) return((ll)d);
            ll ans=INF;
                if(d<INF/x)
                    ans=x*d;
            if(mp.find(x)!=mp.end())return mp[x];
            for(ll i=0;i<3;i++){
                if(x%mu[i]==0){
                    ans=min(ans,f(x/mu[i])+cs[i]);
                }
                else{
                    ans=min( {ans,f(x/mu[i])+d*(x%mu[i])+cs[i],f(x/mu[i] +1)+d*(mu[i]-x%mu[i])+cs[i]} );
                }
            }
            return(mp[x]=ans);
        };
        cout<<f(n)<<"\n";

    }



}


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

int gcd(int a, int b) {
  while(b!=0) {
    if(a < b) {
      swap(a, b);
    }
    if(b==0) {
      break;
    }
    a %= b;
  }
  return a;
}

int main() {
  int N, X, tmp, GCD;
  
  cin >> N >> X >> tmp;
  GCD = abs(X-tmp);
  for(int i=1; i<N; i++) {
    cin >> tmp;
    GCD = gcd(abs(X-tmp),GCD);
  }
  
  cout << GCD << endl;
  
  return 0;
}

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

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926

typedef long long int ll;

ll num[50];
//ll num2[50];
//ll num[10][10];
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<string,ll>::iterator iter;


int main(void)
{
    long long int sum=0,range=0,ceiling;
    double ans=0.0,d;
    long long int m,n,o,i,j,k=1,money;
    long long int a,a1=0,a2=0,a3=0,ar=1,as=1,at1;
    string s;
    char c;
    a=a1=a2=a3=0;
    //vector <int> v;
    //float f,g,h;
    //int c,d,big=0;
    cin>>n;
    if(n%2==0) cout<<n/2;
    else cout<<n/2+1;
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 100011
typedef struct{
	int to,nxt;
}edge; 
edge e[N<<1];
queue<int> q;
int cnt,head[N<<1],dep[N],fa[N],siz[N],vis[N],ans,a,b,n,st,ed,sta[N],top;
int p1[N],p2[N],np[N],val[N];
void add(int a,int b){
	cnt++;
	e[cnt].to=b;
	e[cnt].nxt=head[a];
	head[a]=cnt;
}
void bfs(int s){
	dep[s]=1;
	q.push(s);
	while(!q.empty()){
		int o=q.front();q.pop();
		for(int i=head[o];i!=-1;i=e[i].nxt){
			int v=e[i].to;
			if(!dep[v]){
				dep[v]=dep[o]+1;
				q.push(v);
			}
		}
	}
}
void dfs(int u,int f){
	fa[u]=f;
	for(int i=head[u];i!=-1;i=e[i].nxt){
		int v=e[i].to;
		if(v==f) continue;
		dfs(v,u);
	} 
}
int main(){
	memset(head,-1,sizeof(head));
	scanf("%d",&n);
	for(int i=1;i<=n-1;i++){
		scanf("%d%d",&a,&b);
		add(a,b);add(b,a);
	}
	bfs(1);int mx=0;
	for(int i=1;i<=n;i++)
	  if(mx<dep[i]){
	  	mx=dep[i];
	  	st=i;
	  }
	memset(dep,0,sizeof(dep));
	bfs(st);mx=0;
	for(int i=1;i<=n;i++)
	  if(mx<dep[i]){
	  	mx=dep[i];ed=i;
	  }
	dfs(st,0);
	int x=ed;
	while(x){
		vis[x]=2;
		for(int i=head[x];i!=-1;i=e[i].nxt){
			int v=e[i].to;
			if(v==fa[x]) continue;
			if(!vis[v]) vis[v]=1;
		}
		x=fa[x];
	}
	for(int i=1;i<=n;i++)
	  if(!vis[i]){
	  	printf("-1\n");
	  	return 0;
	  }
	for(int i=1;i<=n;i++){
		if(vis[i]==1){
			val[fa[i]]++;
		}
	}
	x=ed;
	while(x){
		sta[++top]=val[x]+1;
		x=fa[x];
	}
	int ccnt=0;
	for(int i=1;i<=top;i++){
		np[ccnt+1]=ccnt+sta[i];
		for(int j=1;j<=sta[i]-1;j++)
		  np[ccnt+1+j]=ccnt+j;
		ccnt+=sta[i];
	}
	for(int i=1;i<=n;i++) p1[np[i]]=i;
	ccnt=0;
	for(int i=top;i>=1;i--){
		np[ccnt+1]=ccnt+sta[i];
		for(int j=1;j<=sta[i]-1;j++)
		  np[ccnt+1+j]=ccnt+j;
		ccnt+=sta[i];
	}
	for(int i=1;i<=n;i++) p2[np[i]]=i;
	for(int i=1;i<=n;i++)
	  if(p1[i]>p2[i]){
	  	for(int j=1;j<=n;j++)
	  	  printf("%d ",p2[j]);
	  	printf("\n");
	  	return 0;
	  }else
	  if(p1[i]<p2[i]){
	  	for(int j=1;j<=n;j++)
	  	  printf("%d ",p1[j]);
	  	printf("\n");
	  	return 0;
	  }
	for(int i=1;i<=n;i++)
	  printf("%d ",p1[i]);
	printf("\n");
}

Measured memory_bytes: 9472
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
n,q = map(int, input().split())
e = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    e[a-1].append(b-1)
    e[b-1].append(a-1)

ans = [0]*n

for i in range(q):
    p,x = map(int,input().split()) 
    ans[p-1] += x

def dfs(i = 0, r = -1):
    for j in e[i]:
        if j != r:
            ans[j] += ans[i]
            dfs(j, i)

dfs()

print(*ans)

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

int main() {
  int n;
  cin>>n;
  vector<int> a(n+10,0);
  rep(i,n-1){
    int b;
    cin>>b;
    a[b]++;
  }
  rep(i,n){
    cout<<a[i+1]<<endl;
  }
}


Measured memory_bytes: 4052
N = int(input())
A = []
dicA = {}

for i in range(N):
    tmp = int(input())
    dicA[tmp] = dicA.get(tmp, 0) + 1
    A.append(tmp)

sortA = sorted(dicA.items(), key=lambda x: x[0], reverse=True)

for ai in A:
    if ai != sortA[0][0] or sortA[0][1] != 1:
        print(sortA[0][0])
    else:
        print(sortA[1][0])

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

int main(){
  int n, m;
  cin >> n >> m;
  int ans_n=1,ans_m=1;
  ans_n = n * (n-1);
  ans_m = m * (m-1);
  cout << (ans_n + ans_m)/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define lint long long
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	if (!b)return T(1);
	if (b & 1)return mypow(a, b - 1) * a;
	T memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
lint t,n,a[100010];
std::string s;
std::vector<lint> vec;
void basis(){
	int now=0;
	for(int i=60;i>=0;i--){
		for(int j=now;j<vec.size();j++){
			if(vec[j]&((lint)1<<i)){
				std::swap(vec[now],vec[j]);
				break;
			}
		}
		if(vec[now]&((lint)1<<i)){
			for(int j=now+1;j<vec.size();j++){
				if(vec[j]&((lint)1<<i))vec[j]^=vec[now];
			}
			now++;
		}
	}
}
bool check(lint x){
	for(lint i:vec){
		chmin(x,x^i);
	}
	return x==0;
}
int main(){
	std::cin>>t;
	rep(_,t){
		vec.clear();
		std::cin>>n;
		rep(i,n)std::cin>>a[i];
		std::cin>>s;
		for(int i=n-1;i>=0;i--){
			if(s[i]=='0'){
				vec.push_back(a[i]);
				basis();
			}
			else if(!check(a[i])){
				std::cout<<1<<std::endl;
				goto end;
			}
		}
		std::cout<<0<<std::endl;
		end:;
	}
	return 0;
}

Measured memory_bytes: 3632
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++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 all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define VECV(a,n,m) vector<vector<int>> a(n, vector<int>(m));
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin>>N;
  int a=N/100;
  int b=(N-a*100)/10;
  int c=N%10;
  if(a==7||b==7||c==7)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

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

int main() {
  int D, T, S;
  cin >> D >> T >> S;
  
  if ( D > S * T) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
  
  return 0;
}


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

int main() {
  int N, Count=1, Dia;
  cin >> N;
  vector<int> mochi(N);
    for(int i=0; i<N; i++){
    cin >> mochi.at(i);
    }
  sort(mochi.begin(), mochi.end());
  Dia= mochi.at(0);
  for(int i=0; i<N; i++){
   if(mochi.at(i) > Dia){Count++; Dia=mochi.at(i) ;}
  }
    cout << Count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i, n) cin >> l[i];
	sort(all(l));
	int res = 0;
	rep(i, n - 1) res += l[i];
	if (l.back() < res) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="KIHBR"||s=="AKIHBR"||s=="KIHABR"||s=="KIHBAR"||s=="KIHBRA"||
		s=="AKIHABR"||s=="AKIHBAR"||s=="AKIHBRA"||s=="KIHABAR"||s==""||s=="KIHABRA"	||s=="KIHBARA"||
		s=="AKIHABAR"||s=="AKIHABRA"||s=="AKIHBARA"||s=="KIHABARA"||s=="AKIHABARA"){
			cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 256
h,w,k=gets.chomp.split.map(&:to_i)
dp=Array.new(h+1).map{Array.new(w)}

MOD = 1000000007

nn = [1,2,3,5,8,13,21,34]

dp[0][0] = 1
1.upto(w-1) do |i|
    dp[0][i] = 0
end

if w == 1
    puts 1
    exit
end

1.upto(h) do |i|
    0.upto(w-1) do |j|
        dp[i][j] = 0
        if(j==0)
            dp[i][j] += dp[i-1][j] * nn[w-2]
            dp[i][j] += dp[i-1][j+1] * nn[[0,w-3].max]
        elsif(j==w-1)
            dp[i][j] += dp[i-1][j] * nn[w-2]
            dp[i][j] += dp[i-1][j-1] * nn[[0,w-3].max]
        else
            n = nn[[0,j-2].max]
            n *= nn[[0,w-2-j].max]
            dp[i][j] += dp[i-1][j-1] * n

            n = nn[j-1]
            n *= nn[[0,w-2-j].max]
            dp[i][j] += dp[i-1][j] * n

            n = nn[j-1]
            n *= nn[[0,w-3-j].max]
            dp[i][j] += dp[i-1][j+1] * n
        end
        dp[i][j] = dp[i][j] % MOD
    end
end

#p dp
puts dp[h][k-1] % MOD




Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>
#include<bits/stdc++.h>
using namespace std;

const long long mod=1e9+7;
int main() {
    int N,M;cin>>N>>M;
    vector<int>oks(N+1,true);
    for(int i = 0;i<M;i++){
      int a;cin>>a;
      oks[a] = false;
    }
    vector<long long int>dp(N+1);
    dp[0] = 1;
	for(int i = 0;i<N;i++){
    	for(int j = i+1;j<=min(N,i+2);j++){
          if(oks[j]){
          	dp[j]+=dp[i];
            dp[j] = dp[j]%mod;
          }
        }
    }
    cout<<dp[N];
    return 0;
}

Measured memory_bytes: 1408
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
using namespace std;
//--------------------

int main() {
	long N, M; cin >> N >> M;
	long k[100], s[100][100]; for (int i = 1; i <= M; i++) { cin >> k[i]; for(int j = 1; j <= k[i]; j++) cin >> s[i][j]; }
	long p[100]; for (int i = 1; i <= M; i++) cin >> p[i];

	bool b[100]; 
	long oncount = 0;
	long res = 0;
	for (int mybit = 0; mybit < (1 << N); mybit++) {
		for (int i = 1; i <= N; i++) b[i] = false;

		for (int keta = 0; keta < N; keta++) if (mybit & (1 << keta )) b[keta + 1] = true;
        
		for (int i = 1; i <= M; i++) {//i球目
            oncount = 0;
			for (int j = 1; j <= k[i]; j++) if (b[s[i][j]]) oncount++;
			if (oncount % 2 != p[i]) break;
			if (i == M) res++;
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"encoding/json"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

type Program struct {
	Start   float64 `json:"start"`
	End     float64 `json:"end"`
	Channel int     `json:"channel"`
}

type Programs []*Program

func (p Programs) Len() int {
	return len(p)
}

func (p Programs) Less(i, j int) bool {
	return p[i].Start < p[j].Start
}

func (p Programs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p *Program) String() string {
	d, _ := json.Marshal(p)
	return string(d)
}

type Recorder struct {
	ID      int
	Current *Program
}

func (r *Recorder) CanRecord(p *Program) bool {
	start := p.Start
	if r.Current.Channel != p.Channel {
		start -= 0.5
		return r.Current.End < start
	}
	return r.Current.End <= start
}

func (r *Recorder) String() string {
	return fmt.Sprintf("recorder:%d", r.ID)
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	row := strings.Split(sc.Text(), " ")
	n, _ := strconv.Atoi(row[0])
	// c, _ := strconv.Atoi(row[1])
	programs := make([]*Program, n, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		row = strings.Split(sc.Text(), " ")
		s, _ := strconv.ParseFloat(row[0], 64)
		t, _ := strconv.ParseFloat(row[1], 64)
		c, _ := strconv.Atoi(row[2])
		programs[i] = &Program{
			Start:   s,
			End:     t,
			Channel: c,
		}
	}

	sort.Sort(Programs(programs))

	recorders := []*Recorder{}

	for _, p := range programs {
		var nextRecorders []*Recorder
		for _, r := range recorders {
			if r.CanRecord(p) {
				nextRecorders = append(nextRecorders, r)
			}
		}
		if len(nextRecorders) == 0 {
			r := &Recorder{ID: len(recorders) + 1}
			recorders = append(recorders, r)
			nextRecorders = append(nextRecorders, r)
		}
		var nextRecorder *Recorder
		// if len(nextRecorders) > 1 {
		//   for i, r := range nextRecorders {
		//     if r.Current.Channel == p.Channel {
		//       nextRecorder = r
		//       break
		//     }
		//     skipped := false
		//     for j := 1; j <= c && j < n; j++ {
		//       if programs[i+j].Channel == r.Current.Channel && p.End >= programs[j+j].Start-0.5 {
		//         skipped = true
		//         break
		//       }
		//     }
		//     if !skipped {
		//       nextRecorder = r
		//       break
		//     }
		//   }
		// }
		if nextRecorder == nil {
			nextRecorder = nextRecorders[0]
		}
		nextRecorder.Current = p
	}

	fmt.Println(len(recorders))
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define bitcnt(a) (ll) __builtin_popcount((a))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

ll n, k, q;
vector<ll> v, lis;
int main() {
  cin >> n >> k >> q;
  REP(i, n) {
    ll h;
    cin >> h;
    v.push_back(h);
    lis.push_back(h);
  }
  sort(v.begin(), v.end());
  ll ans = 93119198109319399;
  REP(basis, (signed)v.size() - k + 1) {
    vector<ll> grid[100000], can;
    ll itr = 0;
    for (auto &i : lis) {
      if (i < v[basis]) {
        itr++;
        continue;
      }
      grid[itr].pb(i);
    }
    REP(i, itr + 1) {
      sort(grid[i].begin(), grid[i].end());
      REP(j, (signed)grid[i].size() - k + 1) { can.pb(grid[i][j]); }
    }
    sort(can.begin(), can.end());
    if (q > (signed)can.size())
      break;
    ans = min(ans, can[q - 1] - can[0]);
    // cout << can[q - 1] << " " << can[0] << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2688
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
        
        int m = in.nextInt();
        int n = in.nextInt();
        int ans=0;
        for(int i=0;i<n;i++) ans+=in.nextInt();
        out.println(m-ans>=0?m-ans:-1);
        
        in.close();out.flush();out.close();
    }
}

Measured memory_bytes: 46368
de = false
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n,k = gets.chomp.split.map(&:to_i)
h = {}
td = []
n.times do
  tmp = gets.split.map(&:to_i)
  td.push tmp
  t,d = tmp
  h[t] ||= []
  h[t].push d
end

k_values = {}
used_t = Set.new
td.sort_by{|t,d| -d}.slice(0,k).each do |t,d|
  k_values[t] ||= []
  k_values[t].push d
  used_t.add t
end
current = k_values.values.flatten.inject(&:+)

k_values = k_values.map do |k,values|
  index = values.each_with_index.max[1]
  values.delete_at(index)
  values
end
k_values.flatten!.sort!.reverse!
p ['h',h] if de
p ['k_values', k_values] if de

max_values = []
(h.keys - used_t.to_a).each do |key|
  max_values.push h[key].max
end
p ['max_values', max_values] if de

kcount = used_t.size

current += kcount ** 2
p current if de
ans = current
max_values.sort.reverse.each do |max_v|
  k_values_min = k_values.pop
  break if k_values_min.nil?
  current = current - k_values_min + max_v - kcount ** 2 + (kcount+1) ** 2
  ans = current if ans < current
  kcount += 1
  # p [k_values, kcount**2, current] if de
end

puts ans


Measured memory_bytes: 46580
#include<iostream>
#include<vector>
#include<utility>
#include<cstdlib>

using namespace std;

void InputHeader(int &num_students, int &num_checkpoints){
    cin >> num_students >> num_checkpoints;
}

void InputContent(
        vector<pair <int, int> > &students,
        vector <pair <int, int> > &checkpoints,
        int num_students,
        int num_checkpoints)
{
    int student_x, student_y;
    pair<int, int> student;
    for (int i = 0; i < num_students; i++){
        cin >> student_x >> student_y;
        student = make_pair(student_x, student_y);
        students.push_back(student);
    }

    int checkpoint_x, checkpoint_y;
    pair<int, int> checkpoint;
    for (int i = 0; i < num_checkpoints; i++) {
        cin >> checkpoint_x >> checkpoint_y;
        checkpoint = make_pair(checkpoint_x, checkpoint_y);
        checkpoints.push_back(checkpoint);
    }
}

void CalcurateDistance(pair<int, int> student, vector<pair <int, int> > checkpoints){
    int distance[checkpoints.size()];
    int Min;
    int min_checkpoint;
    for (int i = 0; i < checkpoints.size(); i++){
        distance[i] = abs(student.first - checkpoints[i].first) + abs(student.second - checkpoints[i].second);
        if (i == 0){
            Min = distance[i];
            min_checkpoint = i+1;
        }
        else if (distance[i] < Min){
            Min = distance[i];
            min_checkpoint = i+1;
        }
    }
    cout << min_checkpoint << endl;
}

int main(){
    int num_students, num_checkpoints;
    cin >> num_students >> num_checkpoints;

    vector<pair <int, int> > students;
    vector<pair <int, int> > checkpoints;
    InputContent(students, checkpoints, num_students, num_checkpoints);

    for (int i = 0; i < num_students; i++){
        CalcurateDistance(students[i], checkpoints);
    }
}


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 = sc.nextInt();
		int M = sc.nextInt();
		long K = sc.nextLong();
		int[] A = new int[N];
		int[] B = new int[M];
		
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		for (int i = 0; i < M; i++) {
			B[i] = sc.nextInt();
		}
		
		
		//aから始まる場合
		long minute = 0;
		int countA = 0;
		int countB = 0;
		
		//事前準備
		for (int i = 0; i < N; i++) {
			if(minute + A[i] > K) break;
			minute += (long)A[i];
			countA++;
		}
		
		//Bに置き換えていく
		long maxNum = countA;
		for (int i = 0; i < M; i++) {
			while(minute + B[i] > K) {
				if(countA == 0) {
					break;
				}
				minute -= A[countA - 1];
				countA--;
			}
			if(minute + B[i] > K) {
				break;
			}
			minute += B[i];
			countB++;
			if(countA + countB >= maxNum) {
				maxNum = countA + countB;
			}
			
		}
		
		System.out.println(maxNum);
	}

}


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

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll t,i,x,j,y,z,k,n;

cin>>x>>y;
z=0;

while(x>0){
	x-=y;
	z++;
}
ce(z)
}


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

using namespace std;
using ll = long long;

int main(void) {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  vector<bool> iro;
  for (int i = 0; i < 8; i++) {
    iro.push_back(false); 
  }
  int r;
  int t = 0;
  for (int i = 0; i < n; i++) {
    r = vec[i];
    r = r / 400;
    if (r >= 8) {
      t++;
      continue;
    }
    iro[r] = true;
  }
  if (t == n) {
    cout << 1 << " ";
    cout << t << endl;
    return 0;
  }
  int ans = 0;
  for (int i = 0; i < 8; i++) {
    if (iro[i]) {
      ans++;
    }
  }
  cout << ans << " ";
  ans += t;
  cout << ans << endl;
    return 0;
}

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

int main() {
	// your code goes here
	int n,i,j,k;
	cin>>n>>k;
	int a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	long long dp[n+1];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(i=2;i<n;i++){
		dp[i]=abs(a[i]-a[i-1])+dp[i-1];
		for(j=2;j<=k && (i-j)>=0;j++){
			dp[i]=min((abs(a[i]-a[i-j])+dp[i-j]),dp[i]);
		}
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int h,w,k;
  cin >> h >> w >> k;
  vector<vector<int>> c(h,vector<int>(w,0));

  for(int i=0;i<h;i++){
    string s;
    cin >> s;
    for(int j=0;j<w;j++){
      if(s[j]=='#') c[i][j]=1;
    }
  }

  int ans=0;
  for(ll i=0;i<(1<<(h+w));i++){
    int ki=0;
    for(int hi=0;hi<h;hi++){
      for(int wi=0;wi<w;wi++){
        if(((i>>hi)&1)==0 && ((i>>(h+wi))&1)==0) ki+=c[hi][wi];
      }
    }
    if(k==ki) ans++;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3624
//changing a charactor
#include<stdio.h>
#define NUM 50
int main(){
    int n,k;
    char s[NUM];

    //文字数 変換する文字
    scanf("%d %d",&n,&k);

    scanf("%s",s);
    for(int i=0;i<n;i++){
        if(i==k-1){
            s[i]+=0x20;
        }
    }
    printf("%s",s);
    putchar('\n');
    return 0;
}

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


int main()
{
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n - 1);
  rep(i, n)
  {
    cin >> a[i];
    a[i]--;
  }
  rep(i, n)
    cin >> b[i];
  rep(i, n - 1)
    cin >> c[i];
  int ans = b[a[0]];
  for (int i = 1; i < n; i++)
  {
    ans += b[a[i]];
    if (a[i] == a[i-1] + 1)
      ans += c[a[i-1]];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
using namespace std;
int main()
{
    long int a, b, W, c,d;
    scanf("%ld %ld %ld", &W, &a, &b);
    if(W>=1 && a>=1 && b >=1){
            if(a>b){
                d=a;
                a=b;
                b=d;
            }
            if((a+W) >= b){
                c=0;
            }
            else{
                c=b-(a+W);
            }
    }
    printf("%d\n",c);
   return 0;
}


Measured memory_bytes: 128
package main
  
import (
    "fmt"
)

func main() {
    var a, b int
    fmt.Scan(&a, &b)
    fmt.Println(max(a*b, max(a+b, a-b)))
}

func max(a, b int) int {
    if a > b {
        return a
    }
    return b
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <vector>
#include <numeric>
#include<string>
#include <map>
#include <chrono>
#include <cstdlib>
#include <ctime>
#include <list>

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ
#define vector2(type,name,a,b) vector<vector<type>> name(a, vector<type>(b))
#define PI 3.141592653589793





int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(cnt,0,n) {
        cin >> a.at(cnt);

    }
    ll max = 0;
    ll ans = 0;
    rep(cnt, 0, n) {
        if (max < a.at(cnt)) {
            max = a.at(cnt);
        }
        if (max > a.at(cnt)) {
            ans += max - a.at(cnt);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4840
import java.util.Scanner;
import java.util.Vector;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int inputBinary[] = new int[n];
		int numZero = 0;
		for(int i = 0; i < n; i++) {
			inputBinary[i] = sc.nextInt();
			if(inputBinary[i] == 0) {
				numZero++;
			}
		}
		
		int inputSegment[] = new int[m];
		
		for(int i = 0; i < m; i++) {
			inputSegment[i] = sc.nextInt();
		}
		
		boolean isZero = true;
		Vector<Integer> vec1 = new Vector<Integer>();
		Vector<Integer> vec2 = new Vector<Integer>();
		
		int index = 0;
		for(int i = 0; i < m; i++) {
			for(int j = 0; j < inputSegment[i]; j++) {
				if(isZero) {
					vec1.add(index);
				}
				else {
					vec2.add(index);
				}
				
				index++;
			}
			isZero = !isZero;
		}
		
		int vecIndex = 0;
		int result1 = Integer.MAX_VALUE;
		if(numZero == vec1.size()) {
			result1 = 0;
			for(int i = 0; i < n; i++) {
				if(inputBinary[i] == 0) {
					result1 += Math.abs(i - vec1.get(vecIndex));
					vecIndex++;
				}
			}
		}
		vecIndex = 0;
		int result2 = Integer.MAX_VALUE;
		if(numZero == vec2.size()) {
			result2 = 0;
			for(int i = 0; i < n; i++) {
				if(inputBinary[i] == 0) {
					result2 += Math.abs(i - vec2.get(vecIndex));
					vecIndex++;
				}
			}
		}		
		System.out.println(Math.min(result1, result2));
	}

}



Measured memory_bytes: 26440
#include <bits/stdc++.h>
#define  MOD 1000000007

using namespace std;
typedef long long ll;

double arr[3003],mem[3003][3003];
int n;

double dp(int pos, int h, int t){
    if(pos==n){
        if(h>t)return 1;
        else return 0;
    }
    if(mem[h][t]!=-1)return mem[h][t];
    return mem[h][t]=dp(pos+1,h+1,t)*arr[pos]+dp(pos+1,h,t+1)*(1.0-arr[pos]);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    cin>>n;
    for(int i=0;i<n;i++)cin>>arr[i];
    for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)mem[i][j]=-1.0;
    cout<<fixed<<setprecision(9)<<dp(0,0,0);
}

Measured memory_bytes: 70912
from sys import stdin
input = stdin.readline

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

iro=[0]*8
free=0
for i in range(n):
    if a[i]>=3200:
        free+=1
    else:
        iro[a[i]//400]+=1
print(max(1,8-iro.count(0)),8-iro.count(0)+free)


Measured memory_bytes: 3060
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

template<class T>
void print(const T &value) {
    std::cout << value << std::endl;
}

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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

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

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);

ll gcd(ll a, ll b) {
    if (a < b) {
        ll tmp = a;
        a = b;
        b = tmp;
    }
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

//番号ズレ注意！！
int main() {
    string S;
    cin >> S;
    int N = S.size();
    stack<int> X;
    int ans = 0;
    REP(i, N) {
        if (X.empty()) { X.push(S[i]); }
        else {
            if (X.top() == S[i]) { X.push(S[i]); }
            else {
                X.pop();
                ans += 2;
            }
        }
    }
    print(ans);
}


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

int n;

void solve(){
    cin >> n;
    ll s=0,ans=0;
    for(int i=0;i<n;++i) {
        ll t;
        cin >> t;
        ans += (t * s)%mod , ans%=mod;
        s += t%mod , s%=mod;
    }
    cout << ans << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    while(t--)
        solve();
    return  0;
}


Measured memory_bytes: 3644
def abc126c():
    import math
    n, k = map(int, input().split())
    ans = 0.0
    for i in range(1, n + 1):
        v = max(0, math.ceil(math.log2(k / i)))
        ans += math.pow(0.5, v)
    print(ans/n)


abc126c()

Measured memory_bytes: 64616
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  int j = 0;
  rep(i,n)
  {
    string s;
    cin >> s;
    if (mp[s] == 0) {
      mp[s] = 1;
      j = max(j, 1);
    } else {
      mp[s] = mp[s] + 1;
      j = max(j, mp[s]);
    }
  }
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    if (itr->second == j) {
      cout << itr->first << endl;
    }
  }
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = (to) - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define all(v) v.begin(), v.end()
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  unordered_map<int, int> count;

  int n;
  cin >> n;

  rep(i, n) {
    int d;
    cin >> d;
    count[d]++;
  }

  cout << count.size() << endl;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;
int main(){
    string A;
    cin >> A;
    if (A=="A"){
        cout << "T" << endl;
    }
    if (A=="T"){
    cout << "A" << endl;
    }
    if (A=="G"){
cout << "C" << endl;
    }
    if (A=="C"){
cout << "G" << endl;
    }
}

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

int main() {

  long long N,C,K;
  cin >> N >> C >> K;

  vector<long long> T(N),k(N);
  for(int i = 0;i < N;i++) {
    cin >> T.at(i);
    k.at(i) = T.at(i)+K;
  }

  sort(T.begin(),T.end());
  sort(k.begin(),k.end());

  int i = 0,top = 0,ans = 0;
  while(N > 0) {
    int m = k.at(i);
    int sum = 0;
    while(T.at(top) <= k.at(i) && sum < C) {
      sum++;
      top++;
      N--;
      if(N==0) break;
    }
    ans++;
    i = top;
  }

  cout << ans << endl;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VII vector< vector<int> >
#define VLL vector< vector<LL> >
#define VS vector<string>
#define PII pair<int,int>
#define PIS pair<int,string>
#define PSI pair<string,int>
#define PLL pair<ll,ll>
LL facctorialMethod(int k);
int main(){
    LL n,count;
    string s,s_tmp;
    cin >> n;
    cin >> s;
    count = 0;
    s_tmp = s;

//    cout << "s_tmp.size() :" << s_tmp.size() << endl;

    while(s_tmp.find("ABC") != string::npos){
        count++;
        s_tmp = s_tmp.substr(s_tmp.find("ABC")+3,s_tmp.size());
    }
    

    cout << count << endl;

    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


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

int x[40],y[40],k[40],a[40];
ll n;

void bin_ex(ll x, int a[40])
{
  ll tmp = 0;
  for (int i = 0; i < 40; i++)
  {
    if(x%2==1) tmp = 1;
    else tmp = 0;
    a[i] = tmp;
    x = (x-tmp) / 2;
  }
}

void add_bin_ex(ll x, int a[40])
{
  ll tmp = 0;
  for (int i = 0; i < 40; i++)
  {
    if(x%2==1) tmp = 1;
    else tmp = 0;
    a[i] += tmp;
    x = (x-tmp) / 2;
  }
}

ll func(int x[40])
{
  ll tmp = 0, cur = 1;
  for (int i = 0; i < 40; i++)
  {
    if(x[i]==1){
      tmp += cur * (n-a[i]);
    } else {
      tmp += cur * a[i];
    }
    cur *= 2;
  }
  return tmp;
}

void print_array(int x[40])
{
  for (int i = 0; i < 40; i++)
  {
    cout << x[i] << " ";
  }
  cout << endl;
}

int main()
{
  // input
  ll tmp;
  cin >> n >> tmp;
  bin_ex(tmp+1,k);
  for (ll i = 0; i < n; i++)
  {
    cin >> tmp;
    add_bin_ex(tmp,a);
  }

  for (int i = 0; i < 40; i++)
  {
    x[i] = k[i];
    y[i] = k[i];
  }
  
  // main loop
  if(k[0]==1){
    x[0] = 0;
    tmp = func(x);
  } else {
    tmp = 0;
  }

  for (int i = 1; i < 40; i++)
  {
    x[i] = 0;
    if(a[i-1] > n-a[i-1]) x[i-1] = 0;
    else x[i-1] = 1;
    if(k[i]==0) continue;
    tmp = max(tmp,func(x));
  }

  cout << tmp << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxN = 2e5 + 10;

int main(){
//  freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  string s;
  cin >> s;
  int sum = 0;
  for (int i = 0; i < s.size(); ++i) {
    sum = sum + s[i] - '0';
  }
  cout << (sum % 9 == 0 ? "Yes" : "No");
return 0;
}


Measured memory_bytes: 3740