akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int n;
int a[1000000];
int b[1000000];
int main (){
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    for(int i=n;i>=1;i--){
        int quo = n/i;
        int sum = 0;
        for(int j=2;j<=quo;j++){
            sum += b[j*i];
        }
        //cout << "sum[" << i << "]=" << sum << endl;
        int surplus ;
        if(sum != 0){
            surplus = sum%2;
        } 
        else{
            surplus = 0;
        }

        if(surplus == a[i]){
            b[i] = 0;
        }
        else{
            b[i] = 1;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(b[i] == 1){
            ans ++;
        }
    }
    cout << ans << endl;
    if(ans == 0){
        return 0;
    }
    for(int i=1;i<=n;i++){
        if(b[i] == 1){
            cout << i << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5888
import sys
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # xの根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # xとyを統合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    # xとyが同じグループかどうか判定する
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xのメンバーの要素を返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = map(int, input().split())
XYZ = [list(map(int, input().split())) for _ in range(M)]

uf = UnionFind(N)

for x, y, z in XYZ:
    uf.union(x-1, y-1)

ans = uf.group_count()

print(ans)


Measured memory_bytes: 32224
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MOD=int(1e9)+7;

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int N;
	string S;
	cin>>N>>S;
	map<int,int> cnt;
	for (char c:S) cnt[c]++;

	ll res=1;
	rep(i,'a','z'+1) res=(res*(cnt[i]+1))%MOD;
	cout<<res-1<<"\n";
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int h1,m1,h2,m2,k;

int main()
{
	cin>>h1>>m1>>h2>>m2>>k;
	int t=(h2-h1)*60+m2-m1;
	cout<<t-k<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
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); }
int solve(){
  int n,m;
  cin>>n>>m;
  vector<int>s(m),c(m);
  rep(i,m)cin>>s[i]>>c[i];
  rep(i,10000){
    bool ans = true;
    string tmp = to_string(i);
    if(tmp.size()==n){
    rep(j,m){
      int nn = tmp[s[j]-1] - '0';
      if(nn != c[j])ans = false;
    }
    if(ans){
      cout << i << endl;
      return 0;
    }
    }
    
  }
  cout << -1 << endl;
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

int a, b;

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

    if (b % a == 0) {
        printf("%d\n", a + b);
    } else {
        printf("%d\n", b - a);
    }

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

k = int(input())

g = [[] for _ in range(k)]
for i in range(k):
    g[i].append(((i+1)%k,1))
    if i: g[i].append((10*i%k,0))
#print(g)

from collections import deque
q = deque([(1,1)])
res = [float("inf")]*k
res[1] = 1
while q:
    dd,v = q.popleft()
    if res[v] < dd: continue
    if v==0: break
    for c,d in g[v]:
        if res[c] <= res[v] + d: continue
        res[c] = res[v] + d
        if d: q.append((res[c],c))
        else: q.appendleft((res[c],c))

print(res[0])




Measured memory_bytes: 38424
#include<bits/stdc++.h>
#define rep(i,n) fore(int i=0; i<n; i++)

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a*b > c*d) cout << a*b << endl;
  else cout << c*d << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;string s;
  cin>>n>>s;
  if (n&1)
    return puts("No"),0;
  for (int i=0;i<n/2;i++)
    if (s[i]!=s[i+n/2])
      return puts("No"),0;
  puts("Yes");
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << (a - b) * (k & 1 ? -1 : 1) << '\n';
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n;
int t[200005];
int dp[200005];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> t[i];
	}
	int mx = 0;
	for (int i = 1; i <= n; ++i) {
		dp[t[i]] = dp[t[i]-1]+1;
		mx = max(mx, dp[t[i]]);
	}
	cout << n-mx << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::cout << (N - 2) * 180 << std::endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque

def make_DAG(s,n,g):
    newg=[[] for _ in xrange(n)]
    dist=[float("inf")]*n
    dist[s]=0
    dq=deque([s])
    visited=[False]*n
    visited[s]=True
    indeg=[0]*n
    while len(dq)>0:
        now=dq.popleft()
        for nx in g[now]:
            if dist[nx]>=dist[now]+1:
                if not visited[nx]:
                     visited[nx]=True
                     dq.append(nx)
                newg[now].append(nx)
                dist[nx]=dist[now]+1
                indeg[nx]+=1
    return newg,dist,indeg

def bfs_count(s,DAG,indeg):
    indeg[s]-=1
    if indeg[s]!=0:return 0
    dq=deque([s])
    cnt=1
    while len(dq)>0:
        now=dq.popleft()
        for nx in DAG[now]:
            if ok.has_key((now,nx)):continue
            ok[(now,nx)]=True
            indeg[nx]-=1
            if indeg[nx]==0:
                cnt+=1
                dq.append(nx)
    return cnt

n,m,q=map(int,raw_input().split())
e=[]
g=[[] for _ in xrange(n)]
for i in xrange(m):
    u,v=map(int,raw_input().split())
    u-=1;v-=1
    g[u].append(v)
    g[v].append(u)
    e.append((u,v))
DAG,dist,indeg=make_DAG(0,n,g)
ans=0
ok={}
for i in xrange(q):
    r=int(raw_input())
    r-=1
    u,v=e[r]
    if abs(dist[u]-dist[v])==0:
        print ans
        continue
    if dist[u]<dist[v]:
        if not ok.has_key((u,v)):
            ok[(u,v)]=True
            ans+=bfs_count(v,DAG,indeg)
    else:
        if not ok.has_key((v,u)):
            ok[(v,u)]=True
            ans+=bfs_count(u,DAG,indeg)
    print ans

Measured memory_bytes: 79032
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll w, a, b;
  cin >> w >> a >> b;

  cout << max(max(a,b) - (min(a,b) + w), 0ll) << endl;

  return 0;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string s;
  cin >> s;
  ll ans = 0;
  ll count = 0;
  ll from = 0;
  ll N = s.size();
  while(from<N-1){
    string a =  s.substr(from, 2);
    if(s[from]=='A'){
      count++;
      from+=1;
    }else if(a=="BC"){
      ans += count;
      from+=2;
    }else{
      count = 0;
      from +=1;
    }
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 640
/* long long or int & the MAX_INT or MIN_INT */
/* the size of a[] & inline */
/* xx 396 */

#include<bits/stdc++.h>
using namespace std;

const int MAX_N=1e5+10;

int N,K;
string S;
vector < pair<int,pair<int,int> > > vL,vR;

signed main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>N>>K; cin>>S;
	int at=0,sum=0;
	for(int i=0;i<N;i++){
		if(S[i]=='R') sum++;
		else{
			if(sum) vR.push_back(make_pair(1,make_pair(sum,i))); at=i;
			break;
		}
	}
	sum=0;
	for(int i=at;i<N;i++){
		if(S[i]=='R') sum++;
		else if(sum) vR.push_back(make_pair(2,make_pair(sum+1,i))),sum=0; 
	}
	if(sum) vR.push_back(make_pair(1,make_pair(sum,N-1)));
	at=0; sum=0;
	for(int i=0;i<N;i++){
		if(S[i]=='L') sum++;
		else{
			if(sum) vL.push_back(make_pair(1,make_pair(sum,i))); at=i;
			break;
		}
	}
	sum=0;
	for(int i=at;i<N;i++){
		if(S[i]=='L') sum++;
		else if(sum) vL.push_back(make_pair(2,make_pair(sum+1,i))),sum=0;
	}
	if(sum) vL.push_back(make_pair(1,make_pair(sum,N-1)));
	sort(vL.begin(),vL.end());    sort(vR.begin(),vR.end());
	reverse(vL.begin(),vL.end()); reverse(vR.begin(),vR.end());
	string LL=S,RR=S;
	for(int i=0;i<min(K,(int)vL.size());i++){
		int len=vL[i].second.first,ed=vL[i].second.second;
		while(len--) LL[ed--]='R';
	}
	for(int i=0;i<min(K,(int)vR.size());i++){
		int len=vR[i].second.first,ed=vR[i].second.second;
		while(len--) RR[ed--]='L';
	}
	int Max=0; sum=0;
	for(int i=0;i<N-1;i++) if(LL[i]==LL[i+1]) sum++; Max=max(Max,sum);
	sum=0;
	for(int i=0;i<N-1;i++) if(RR[i]==RR[i+1]) sum++; Max=max(Max,sum);
	cout<<Max<<endl;
	return 0;
}

Measured memory_bytes: 2120
#include<stdio.h>
#define MAX 101

static const int INF = (1 << 21);
 
int n;
int d[MAX],key1[MAX],key2[MAX],G[MAX][MAX];
 
void SingleSourceShortestPathI(void){
 
  int i,j;
  int min,yoso;
 
  for(i = 0;i < n;i++){
    d[i] = INF;
   key1[i] = 0; 
   key2[i] = -1;
  }
 
  d[0] = 0;
 
  while(1){
    min = INF;
    yoso = -1;
 
    for(i = 0;i < n;i++){
      if(!key1[i] && d[i] < min){
    yoso = i;
    min = d[i];
      }
    }
    if(yoso == -1){
      break;
    }
    key1[yoso] = 1;
 
    for(j = 0;j < n;j++){
      if(d[j] > d[yoso]+G[yoso][j]){
    d[j] = d[yoso] + G[yoso][j];
    key2[j] = yoso;
      }
    }
  }
}
 
int main(){
  int i,j;
  int u,k,v,c;
 
  scanf("%d",&n);
 
  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      G[i][j] = INF;
    }
  }
 
  for(i = 0;i < n;i++){
    scanf("%d%d",&u,&k);
    for(j = 0;j < k;j++){
      scanf("%d%d",&v,&c);
      G[u][v] = c;
    }
  }
  SingleSourceShortestPathI();
 
 for(i = 0;i < n;i++){
    printf("%d %d\n",i,(d[i] == INF?-1:d[i]));
  }
  return 0;
}

Measured memory_bytes: 640
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<ll> a(n);
	map<ll, int> mp;
	rep(i, n)
	{
		cin >> a[i];
		++mp[a[i]];
	}
	sort(all(a), greater<ll>());
	int res = 0;
	rep(i, n)
	{
		if (!mp[a[i]])continue;
		--mp[a[i]];
		ll tmp = 1;
		while (tmp <= a[i])tmp = tmp << 1;
		if (mp[tmp - a[i]])
		{
			--mp[tmp - a[i]];
			++res;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 26752
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {
	public static class Pair implements Comparable<Pair> {
		public final int first;
		public final int second;
	
		public Pair(int first, int second) {
			this.first = first;
			this.second = second;
		}
	
		@Override
		public int compareTo(Pair o) {
			int ord = Integer.compare(this.first, o.first);
			if (ord != 0) return ord;
			ord = Integer.compare(this.second, o.second);
			return ord;
		}
	}
	
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static String joinInt(int[] a, String separator) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if (i > 0) {
				sb.append(separator);
			}
			sb.append(a[i]);
		}
		return sb.toString();		
	}

	static int[] nextIntArray(Scanner sc, int N) {
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		return arr;
	}

	static void reverseArray(int[] array) {
		for (int i = 0; i < array.length / 2; i++) {
			int tmp = array[i];
			array[i] = array[array.length - 1 - i];
			array[array.length - 1 - i] = tmp;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] S = nextIntArray(sc, 1 << N);
		Arrays.sort(S);
		TreeSet<Pair> set = new TreeSet<>();
		for (int i = 0; i < S.length - 1; i++) {
			set.add(new Pair(S[i], i));
		}
		assert set.size() == (1 << N) - 1;
		int[] oks = new int[1 << N];
		oks[0] = S[S.length - 1];

		boolean ok = true;
		outer: for (int i = 0; i < N; i++) {
			int lim = 1 << i;
			for (int j = 0; j < lim; j++) {
				int v = oks[j];
				// System.out.println("--" + v);
				Pair pop = set.lower(new Pair(v, 0));
				if (pop == null) {
					ok = false;
					break outer;
				}
				set.remove(pop);
				oks[j + lim] = pop.first;
			}
		}
		if (ok) {
			assert set.isEmpty();
		}

		System.out.println(ok ? "Yes" : "No");
	}
}


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

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

  std::vector<long long> A(N);
  std::vector<long long> S(N + 1, 0);

  for (int i = 0; i < N; i++) {
    std::cin >> A[i];
  }

  for (int i = 1; i <= N; i++) {
    S[i] = S[i - 1] + A[i - 1];
  }

  // sum of [l, r] = S[r+1] - S[l]
  long long ans = 0;
  int mod = 1000000007;

  for (int i = 0; i < N; i++) {
    ans += A[i] * ((S[N] - S[i + 1]) % mod);
    ans %= mod;
  }
  
  ans = (ans + mod) % mod;
  std::cout << ans << "\n";

  return 0;
}

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

int main() {
	int a,b;
	cin>>a;
	cin>>b;
	if(a>b){
		cout<<"a > b"<<endl;
	}
	if(a<b){
		cout<<"a < b"<<endl;
	}
	if(a==b){
		cout<<"a == b"<<endl;
	}
}

Measured memory_bytes: 3088
n = int(input())
a = list(map(int, input().split()))

result = 0
i = 0
x = 0
for j in range(n):
    while x < n and (i & a[x]) == 0:
        i += a[x]
        x += 1
    result += x-j
    i -= a[j]
print(result)

Measured memory_bytes: 24840
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque

parent_node = []

def union_find(ele):
    global parent_node
    if parent_node[ele] != ele:
        parent_node[ele] = union_find(parent_node[ele])
    return parent_node[ele]

def main():
    num, lang_num = map(int, input().split())

    graph_data = defaultdict(set)
    for i in range(num):
        data = list(map(int, input().split()))
        for ele in data[1:]:
            graph_data[ele].add(i + 1)

    global parent_node
    parent_node = [i for i in range(num + 1)]




    for key, value in graph_data.items():
        min_set = set([union_find(ele) for ele in value])
        min_ind = min(list(min_set))
        for ele in min_set:
            parent_node[ele] = min_ind

    for i in range(num + 1):
        a = union_find(i)

    # print(parent_node)

    if max(parent_node) == 1:
        print('YES')
    else:
        print('NO')









if __name__ == '__main__':
    main()



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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component


// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code
int n, m;
ll dist[2005];
ll neg[2005];
ll a[2005], b[2005], c[2005];
int main()
{

  cin>>n>>m;
  repn(i, 0, n)
    dist[i] = LONG_MAX;
  dist[0] = 0;
  rep(i, 0, m)
  {
    cin>>a[i]>>b[i]>>c[i];
    c[i] = -c[i];
  }
  rep(l, 0, n)
  {
    rep(i, 0, m)
    {
      if(dist[a[i] - 1] == LONG_MAX) continue;
      if(dist[b[i]-1] > (dist[a[i] - 1] + c[i]))
        dist[b[i]-1] = dist[a[i]-1] + c[i];
    }
  }
  rep(l, 0, n)
  {
    rep(i, 0, m)
    {
      if(dist[a[i] - 1] == LONG_MAX) continue;
      if(dist[b[i]-1] > (dist[a[i]-1] + c[i])){
        neg[b[i] -1] = 1;
        dist[b[i]-1] = dist[a[i]-1] + c[i];
      }
      if(neg[a[i]-1]) neg[b[i]-1] = 1;
    }
  }
  if(neg[n-1]) puts("inf");
  else cout<<(-dist[n-1])<<endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for(int i = 0; i < N; i++){
    int A;
    cin >> A;
    vec[i] = A;
  }
  sort(vec.begin(), vec.end());
    
    cout << vec[N-1] - vec[0] << endl;

}

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

if n%2 == 0:
    left = list(reversed(a[1::2]))
    right = a[::2]
    ans = left + right
else:    
    left = list(reversed(a[2::2]))
    right = a[1::2]
    ans = left +[a[0]]+ right
    
print(' '.join(map(str,ans)))
    
    


Measured memory_bytes: 31268
#include<bits/stdc++.h>
#pragma optimize("Ofast")
using namespace std;

using ll = long long;
const int N = 1e6+5;

vector<int> p;
bool vis[N];
void prime() {
    p.push_back(2);
    for(int i = 3; i < N; i += 2) {
        if(!vis[i]) {
            p.push_back(i);
            for(int j = i; j < N; j += i)
                vis[j] = true;
        }
    }
    return;
}

int main()
{
    ios_base::sync_with_stdio(0);

    prime();

    ll n;
    cin >> n;

    map<ll,int> primeFact;
    for(int i = 0; i < p.size(); ++i) {
        if(p[i] > n) break;
      
        if(n%p[i] == 0) {
            int cnt = 0;
            while(n%p[i] == 0) {
                ++cnt;
                n /= p[i];
            }
            primeFact[p[i]] = cnt;
        }
    }
    if(n > 1) primeFact[n]++;

    vector<ll> sum(N);
    for(int i = 1; i < N; ++i)
        sum[i] += (sum[i-1] + i);

    int ans = 0;
    for(auto it : primeFact) {
        int idx = lower_bound(sum.begin(),sum.end(), it.second+1) - sum.begin();
        --idx;
        ans += idx;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 12452
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int a = kb.nextInt();
		int b = kb.nextInt();
		String c = "";
		int count = 0;
		if (a >= b) {
			while (count < a) {
				count++;
				c += Integer.toString(b);
			}
		} else {
			while (count < b) {
				count++;
				c += Integer.toString(a);
			}
		}
		System.out.println(c);
		kb.close();
	}
}


Measured memory_bytes: 23764
def main():
    N, T, *AB = map(int, open(0).read().split())

    dp = [0] * (T + max(AB[::2]))
    for w, v in sorted(zip(*[iter(AB)] * 2)):
        for i in reversed(range(T)):
            dp[i + w] = max(dp[i + w], dp[i] + v)

    print(max(dp))

main()

Measured memory_bytes: 41836
# -*- coding: utf-8 -*-

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

A_RANGE = range(0, 10 ** 5)

num_of = [0] * 10 ** 5
for ai in a:
    num_of[ai] += 1

max_X = 0
max_count = max(num_of)
max_count_indexes = [i for i, x in enumerate(num_of) if x == max_count]
for i in A_RANGE:
    if (i + 1 in A_RANGE) and (i + 2 in A_RANGE):
            max_X = max(num_of[i] + num_of[i + 1] + num_of[i + 2], max_X)
    if (i - 1 in A_RANGE) and (i + 1 in A_RANGE):
            max_X = max(num_of[i - 1] + num_of[i] + num_of[i + 1], max_X)
    if (i - 2 in A_RANGE) and (i - 1 in A_RANGE):
            max_X = max(num_of[i - 2] + num_of[i - 1] + num_of[i], max_X)
print(max_X)


Measured memory_bytes: 14008
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  ll S;
  cin >> S;

  ll x[3], y[3];
  x[0] = 0;
  y[0] = 0;
  x[1] = 1000000000;
  y[1] = 1;

  y[2] = (S + x[1] - 1) / x[1];
  x[2] = x[1] * y[2] - S;

  for(int i = 0; i < 3; i++){
    cout << x[i] << " " << y[i] << " ";
  }
  cout << endl;
  return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  string a,b;cin>>a>>b;
  if(a==b)cout<<"EQUAL"<<endl;
  else if(a.size()>b.size()){
    cout<<"GREATER"<<endl;
  }else if(a.size()<b.size()){
    cout<<"LESS"<<endl;
  }else{
    for(int i=0;i<a.size();i++){
      if(a[i]>b[i]){cout<<"GREATER"<<endl;break;}
      else if(a[i]<b[i]){cout<<"LESS"<<endl;break;}
    }
  }
  return 0;
}


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

#ifndef __TOPCYBERFLOWER
#define debug(...) 0
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

#define TYPEMAX(type)   numeric_limits<type>::max()
#define TYPEMIN(type)   numeric_limits<type>::min()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
ll myf(ll x, ll y){
    if(x<y) return min(x,y-x);
    else return myf(x%y,y);
}
int main(void){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll x,y; cin>>x>>y;
    cout<<myf(x,y);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    unsigned long long n;
    cin >> n;
    string s[n];
    for(int i=0;i<n;i++)cin >> s[i];

    unsigned long long num[5];
    for(int i=0;i<5;i++)num[i] = 0;
    for(int i=0;i<n;i++){
        if(s[i][0]=='M')num[0]++;
        if(s[i][0]=='A')num[1]++;
        if(s[i][0]=='R')num[2]++;
        if(s[i][0]=='C')num[3]++;
        if(s[i][0]=='H')num[4]++;
    }

    unsigned long long ans = 0;
    ans += num[0]*num[1]*num[2];
    ans += num[0]*num[1]*num[3];
    ans += num[0]*num[1]*num[4];
    ans += num[0]*num[2]*num[3];
    ans += num[0]*num[2]*num[4];
    ans += num[0]*num[3]*num[4];
    ans += num[1]*num[2]*num[3];
    ans += num[1]*num[2]*num[4];
    ans += num[1]*num[3]*num[4];
    ans += num[2]*num[3]*num[4];

    cout << ans << endl;
}


Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

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

int main() {
    long long n;
    cin >> n;

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

    vector<long long> a(n, 0);
    long long count = 0;

    rep(i, n) {
        cin >> a[i];
    }

    long long sub;
    for(int i = 0; i < n-1; i++) {
        sub = 0;
        if(a[i] > a[i+1]) {
            sub = a[i] - a[i+1];
            count += sub;
            a[i+1] += sub;
        }
    }

    cout << count << endl;
    return 0;
}

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

int main(){
  int n,m,keta[3] = {0},ans;
  int c[5],s[5];
  bool hantei = true; //入力の矛盾を判定
  /*入力*/
  cin >> n;
  cin >> m;
  for(int i = 0;i < m;i++){
    cin >> s[i] >> c[i];
    keta[n - s[i]] = c[i]; //keta[x] = y 右からx桁目にy
    for(int j = 0;j < i;j++){
      if((s[j] == s[i])&&(c[j] != c[i])){ /*同じ桁に違う指定が来たらfalse*/
	hantei = false;
      }
    }
    if((s[i] == 1)&&(c[i] == 0)&&(n != 1)){ /*1桁目が0だったらfalse*/
      hantei = false;
    }
  }

  /*答えの導出*/
  if((keta[n - 1] == 0)&&(hantei)&&(n != 1)){ /*1桁目に指定がなかったら*/
    keta[n - 1] = 1;
  }
 
  ans = keta[2]*100 + keta[1]*10 + keta[0];

  /*答え*/
  if(hantei){
    cout << ans << endl;
  }
  else{
    cout << -1 << endl;
  }
  
  return 0;
}


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

int gcd(int a, int b) {
  if (!b) {
    return a;
  }

  return gcd(b, a % b);
}

int main() {
  int a, b;
  cin >> a >> b;
  cout << gcd(a, b) << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
int N, AX, AY, BX, BY;
vector<int> UX, UY;
int F[200][200];
vector<pair<int, int>> wd, cr;
vector<int> wdirs;

void input() {
  
  wd.clear();
  UX.clear();
  UY.clear();
  cr.clear();
  wdirs.clear();
  
  int px, py;
  rep(i, N) {
    int x, y; cin >> x >> y;
    wd.push_back({x, y});
    UX.push_back(x);
    UY.push_back(y);
    if(i) {
      if(x < px) wdirs.push_back(0);
      if(y < py) wdirs.push_back(1);
      if(px < x) wdirs.push_back(2);
      if(py < y) wdirs.push_back(3);
    }
    px = x, py = y;
  }

  if(wd[0].first < px) wdirs.push_back(0);
  if(wd[0].second < py) wdirs.push_back(1);
  if(px < wd[0].first) wdirs.push_back(2);
  if(py < wd[0].second) wdirs.push_back(3);
  
  AX = AY = 1e9, BX = BY = -1e9;
  
  rep(i, 4) {
    int x, y; cin >> x >> y;
    AX = min(AX, x);
    AY = min(AY, y);
    BX = max(BX, x);
    BY = max(BY, y);
    cr.push_back({x, y});
    UX.push_back(x);
    UY.push_back(y);
  }
}

int main() {
  
  while(cin >> N && N) {
    
    input();

    sort(UX.begin(), UX.end());
    sort(UY.begin(), UY.end());
    
    UX.erase(unique(UX.begin(), UX.end()), UX.end());
    UY.erase(unique(UY.begin(), UY.end()), UY.end());
    
    map<int, int> X, Y;
    rep(i, UX.size()) X[UX[i]] = i;
    rep(i, UY.size()) Y[UY[i]] = i;
    
    memset(F, 0, sizeof F);
    
    rep(i, N) {
      if(wdirs[i] == 0 || wdirs[i] == 2) {
      	F[Y[wd[i].second]][X[wd[i].first]] ++;
      	F[Y[wd[(i+1)%N].second]][X[wd[(i+1)%N].first]] --;
      }
    }
    
    rep(j, N) rep(i, N) F[i+1][j] += F[i][j];
    rep(i, N) rep(j, N) F[i][j+1] += F[i][j];
    
    REP(i, Y[AY], Y[BY]) REP(j, X[AX], X[BX]) F[i][j] = 0;
    
    long long ans = 0;

    rep(i, N) rep(j, N) if(F[i][j])
      ans += (UX[j+1] - UX[j]) * (UY[i+1] - UY[i]);
    
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3264
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC119A
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            int y = int.Parse(s.Substring(0, 4));
            int m = int.Parse(s.Substring(5, 2));
            int d = int.Parse(s.Substring(8, 2));

            if (y > 2019 || (y == 2019 && m >= 5) || (y == 2019 && m == 4 && d > 30))
            {
                Console.WriteLine("TBD");
            }
            else
            {
                Console.WriteLine("Heisei");
            }
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


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

int main(){
	int N;
  cin>>N;
  if(N<18){
	if(N==1||N==2||N==3||N==5||N==6||N==9||N==10||N==13||N==17)
      cout<<"No"<<endl;
    else
      cout<<"Yes"<<endl;
  }
  else
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <map>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int N, K, a[200009]; map<int, int> d;
int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> a[i], d[a[i]]++;
	vector<int> v;
	for (pair<int, int> i : d) {
		v.push_back(i.second);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	int ret = N;
	for (int i = 0; i < v.size() && i < K; i++) ret -= v[i];
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 11516
#include<stdio.h>
#include<string.h>

int main(void){
  char str[512],stack[512];
  int i,j,sp,l;
  fgets(str,sizeof(str),stdin);
  l=strlen(str);
  
  if(str[0]!='m') puts("Rabbit");
  else{
    sp=0;
    for(i=0;i<l-1;i++){
      stack[sp]=str[i];
      if(i>=2&&stack[sp-2]=='m'&&stack[sp-1]=='e'&&stack[sp]=='w'){
	for(j=sp;j>=sp-2;j--) stack[j]=' ';
	sp-=2;
	if(i!=l-2&&sp==0){
	  break;
	}
      }else sp++;
    }
    if(sp==0&&i==l-1) puts("Cat");
    else puts("Rabbit");
  }   
  return 0;
}

Measured memory_bytes: 524
#include"bits/stdc++.h"
// #include "prettyprint.hpp"

using namespace std;

#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, n) for(ll i=n; i>=0; i--)
#define reps(i, s, e) for(ll i=s; i<e; i++)
#define all(x) x.begin(),x.end()

typedef long long ll;

int main(){
	// int N;
	// cin >> N;

	// vector<int> A(N);
	// vector<int> x(pow(N,N));
	// vector<int> y(pow(N,N));
	// sum = 0;

	// rep(i,N){
	// 	cin >> A[i];
		
	// 	rep(j,A[i]){
	// 		cin >> x[j+sum] >> y[j+sum];
	// 	}

	// 	sum += A[i];
	// }



	// ll value = 11;
	// string bit(bitset<5>(value).to_string<char, char_traits<char>, allocator<char> >());

	// cout << bit << endl;

	// ll len = bit.length();

	// // rep(i,len){
	// // 	cout << bit[i] << endl;
	// // }

	// // rep(i,len){
	// // 	cout << bit[len-1-i] << endl;
	// // }

	// cout << "A" << endl;

	// rep(i,len){
	// // 	cout << *(bit.end()-1-i) << endl;
	// }


	ll N;

	cin >> N;

	vector<ll> A(N);

	rep(i,N){
		cin >> A[i];
	}

	vector<string> B(N);

	rep(i,N){
		B[i] = bitset<60>(A[i]).to_string<char, char_traits<char>, allocator<char> >();
	} 

	// cout << B << endl;

	ll ans = 0;

	ll number_zero = 0;
	ll number_one = 0;

	rep(i,60){
		rep(j,N){
			// cout << B[j][59-i] << endl;

			if(B[j][59-i] == '0')	number_zero ++; 
			
			else if(B[j][59-i] == '1') number_one ++;

			// cout << number_zero << " " << number_one << endl;
		}
		
		// cout << number_zero << " " << number_one << endl;

		ans += (((number_zero*number_one)%((ll)pow(10,9)+7))*((ll)pow(2,i)%((ll)pow(10,9)+7)));
		ans %= (ll)(pow(10,9)+7);

		number_zero = 0;
		number_one = 0;		
	}
	

	cout << ans << endl;

	return 0;

}





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

#define SE second
#define FI first
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int) (x).size())

#define _ << " " <<
#define TR(x) cout << #x _ x << endl

using namespace std;
const int INF = (int) 1e9 + 5;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = n - 1; i >= 0; i-=2) {
        cout << a[i] << " ";
    }
    for (int i = (n & 1); i < n; i+=2) {
        cout << a[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int n, k;
    cin >> n >> k;

    if (n >= 2 * k - 1)
        cout << "YES";
    else
        cout << "NO";
}

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

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main() {
  string a;
  cin >> a;
  int ans = 0;
  int did = -1;
  string tmp = "";
  rep(i, a.length()) {
    if (a.substr(did+1,i-did) != tmp) {
      ans++;
      tmp = a.substr(did + 1, i - did);
      //cout << did << "/" << tmp << endl;
      did = i;
      
    }
    
  }
  cout << ans;
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);


*/



Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	a %= p;
	return a >= 0 ? a : a + p;
}

int power(int a, int N){
	if(N == 0){
		return 1;
	}
	else if(N % 2 == 0){
		return power(MOD(a * a), N / 2);
	}
	else{
		return MOD(a * power(a, N - 1));
	}
}

signed main(){
	int N, i, j;
	char *S = (char *)malloc(sizeof(char) * 100002);
	scanf("%s", &S[1]);
	for(N = 1; S[N] != '\0'; N++){}
	N--;
	int *dpA = (int *)malloc(sizeof(int) * (N + 1));
	int *dpAB = (int *)malloc(sizeof(int) * (N + 1));
	int *dpABC = (int *)malloc(sizeof(int) * (N + 1));
	dpA[0] = 0;
	dpAB[0] = 0;
	dpABC[0] = 0;
	for(i = 1, j = 0; i <= N; i++){
		if(S[i] == 'A'){
			dpA[i] = MOD(dpA[i - 1] + power(3, j));
		}
		else if(S[i] == '?'){
			dpA[i] = MOD(3 * dpA[i - 1] + power(3, j));
			j++;
		}
		else{
			dpA[i] = MOD(dpA[i - 1]);
		}
	}
	for(i = 1; i <= N; i++){
		if(S[i] == 'B'){
			dpAB[i] = MOD(dpAB[i - 1] + dpA[i - 1]);
		}
		else if(S[i] == '?'){
			dpAB[i] = MOD(3 * dpAB[i - 1] + dpA[i - 1]);
		}
		else{
			dpAB[i] = MOD(dpAB[i - 1]);
		}
	}
	for(i = 1; i <= N; i++){
		if(S[i] == 'C'){
			dpABC[i] = MOD(dpABC[i - 1] + dpAB[i - 1]);
		}
		else if(S[i] == '?'){
			dpABC[i] = MOD(3 * dpABC[i - 1] + dpAB[i - 1]);
		}
		else{
			dpABC[i] = MOD(dpABC[i - 1]);
		}
	}
/*	printf("dpA:\n");
	for(i = 0; i <= N; i++){
		printf("%lld ", dpA[i]);
	}
	printf("\n");
	printf("dpAB:\n");
	for(i = 0; i <= N; i++){
		printf("%lld ", dpAB[i]);
	}
	printf("\n");
	printf("dpABC:\n");
	for(i = 0; i <= N; i++){
		printf("%lld ", dpABC[i]);
	}
	printf("\n");
*/	printf("%lld\n", dpABC[N]);
	return 0;
}

Measured memory_bytes: 2560
n=int(input(""))
a={}
for i in range(n):
    s=input("")
    if (s in a):
        a[s]+=1
    else:
        a[s]=1
maxs=0
lists=[]
for i in a:
    t=a[i]
    if(t>maxs):
        lists=[i]
        maxs=t
    elif(t==maxs):
        lists+=[i]
lists.sort()
for i in lists:
    print(i)
    
        
    
    


Measured memory_bytes: 35428
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int n,k,left,right;
    long long total(0);
    cin >> n;

    vector<int> v_a(n+1);
    vector<int> v_b(n);
    for(int i=0; i<n+1; i++) cin >> v_a[i];
    for(int j=0; j<n; j++) cin >> v_b[j];

    for(int k = 0; k < n; k++){
        left = min(v_a[k], v_b[k]);
        total += left;
        v_b[k] -= left;
        
        right = min(v_a[k+1], v_b[k]);
        total += right;
        v_a[k+1] -= right;
    }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 1024
N = int(input())
S = list(map(int, input()))
A1 = [False] * 10
A2 = [False] * 100
A3 = [False] * 1000
for c in S:
    for i, a in enumerate(A2):
        A3[i*10+c] |= a
    for i, a in enumerate(A1):
        A2[i*10+c] |= a
    A1[c] = True
print(sum(A3))


Measured memory_bytes: 3492
//Bismillahir Rahmanir Rahim
//In the name of Allah the Most Merciful
//Astagfirullahil laji Rabbi Minkulli Jamio
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
int i,j,k;
main()
{
    int n;cin>>n;int a[n];
    for(i=0;i<n;i++) cin>>a[i];
    set<int> s;
    int sm=0;
    for(i=0;i<n;i++)
    {
        s.insert(a[i]);
        sm=sm+a[i];
    }
    sort(a,a+n);
    if(s.size()==1) cout<<0<<endl;
    else
    {
        //int k=sm/2;
        int ans1=1e12;
        int k=a[0];
        int ans=0;
        while(k<a[n-1]){
                int ans=0;
        for(i=0;i<n;i++)
        {
            ans=ans+((k-a[i])*(k-a[i]));
        }
        k++;
        //cout<<ans<<endl;
        ans1=min(ans1,ans);
        }
        cout<<ans1<<endl;
    }
}


Measured memory_bytes: 3616
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

//AC

int main(void){
	int D,N,a;
	cin>>D>>N;
	a=(ll)pow(100,D);
	if(N==100){
		cout<<a*(N+1)<<endl;
	}else{
		cout<<a*N<<endl;
	}
	return 0;
}

Measured memory_bytes: 384