akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

vector <P> ans;
string str;


int main(){
  ll anssum=0,anssize=0;
  ll maxH,nowH,cnt,maxW;
  cin>>str;
  maxH=nowH=20000LL;
  cnt=0;

  for(int i=0;i<(int)str.size();i++){

    if(str[i]=='/'){

      nowH++;
      if(maxH==nowH){
	cnt++;
	ans.push_back(P(i,cnt/2));

	cnt=0;
      }else if(maxH<nowH){
	maxH=nowH;
      }else{
	cnt+=(maxH-nowH)*2+1;
      }
      
    }else if(str[i]=='_'){

      if(maxH>nowH){
	cnt+=(maxH-nowH)*2;

      }
    }else{

      nowH--;
      if(maxH>nowH){
	cnt+=(maxH-nowH)*2-1;
      }

    }
  }
  
  maxH=nowH=20000LL;
  maxW=(int)str.size()-1;

  cnt=0;

  for(int i=(int)str.size()-1;i>=0;i--){
    // cout<<maxW<<endl;
    if(str[i]=='\\'){

      nowH++;
      if(maxH==nowH){
	cnt++;
	//if(i==0||str[i-1]=='/'||(str[i-1]=='_'&&)){
	//}else {
	ans.push_back(P(maxW,cnt/2));
	  //}
	cnt=0;
      }else if(maxH<nowH){
	maxH=nowH;
	maxW=i;
      }else{
	cnt+=(maxH-nowH)*2+1;
      }
      
    }else if(str[i]=='_'){

      if(maxH>nowH){
	cnt+=(maxH-nowH)*2;

      }else if(maxH==nowH){
	maxW=i;
      }
      
    }else{
      if(nowH==maxH)maxW=i;
      nowH--;
      if(maxH>nowH){
	cnt+=(maxH-nowH)*2-1;
      }
      

    }
  }

  
  sort(ans.begin(),ans.end());
  anssum=anssize=0;
  for(int i=0;i<(int)ans.size();i++){
    if(i>0&&ans[i-1]==ans[i])continue;
    anssum+=ans[i].second;
    anssize++;
  }

  cout<<anssum<<endl;
  cout<<anssize;
  for(int i=0;i<(int)ans.size();i++){
    if(i>0&&ans[i-1]==ans[i])continue;
    cout<<' '<<ans[i].second;
  }
  cout<<endl;
  /*
  cout<<ans.size();
  for(int i=0;i<(int)ans.size();i++){
    cout<<' '<<ans[i].first;
  }
  cout<<endl;
  */
}

Measured memory_bytes: 1304
#include <iostream>
#include <string.h>
using namespace std;

int main () {
  int n;
  string h;
  cin >> n >> h;
  if (n % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i < n / 2; i++) {
    if (h[i] != h[n / 2 + i]){ 
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;




int main(void) {
  double A, B;
  cin >> A >> B;
  
  
  for(ll i=1; i<MAX; i++) {
    ll a=i*0.08;
    ll b=i*0.10;
    
    if(a==A&&b==B) {
      pt(i);
      return 0;
    }
    
    
  }
  
  
  pt(-1);
  
  
}






Measured memory_bytes: 256
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

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

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

const size_t N = 2e5 + 5;
const int MOD = 1e9 + 7;

int qpow(int base, int e) {
    int ret = 1;
    for (; e; e >>= 1) {
        if (e & 1) {
            ret = (LL) ret * base % MOD;
        }
        base = (LL) base * base % MOD;
    }
    return ret;
}

void iadd(int &dp, const int &val) {
    dp += val;
    if (dp >= MOD) {
        dp -= MOD;
    }
}

void ladd(int &dp, const LL &val) {
    dp = (dp + val) % MOD;
}

int n, ans;
vector<int> g[N];
int siz[N];

int dfs(int u = 1, int p = 0) {
    vector<int> vc;
    siz[u] = 1;
    for (int v : g[u]) {
        if (v != p) {
            vc.emplace_back(dfs(v, u));
            siz[u] += siz[v];
        }
    }
    vc.emplace_back(n - siz[u]);
    int y = 0, z = n;
    for (int x : vc) {
        z -= x;
        ladd(ans, (LL) (MOD + 1 - qpow(2, MOD - 1 - x)) *
                       (MOD + 1 - qpow(2, MOD - 1 - y)) % MOD *
                                  qpow(2, MOD - 1 - z));
        y += x;
    }
    return siz[u];
}

int main() {
    n = read();
    for (int i = 1; i < n; ++i) {
        int a = read(), b = read();
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    dfs();
    cout << ans;
    return 0;
}


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

int main() {
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<int> P(M), Y(M);
	vector<vector<uint64_t>> child(N);

	for (int i = 0; i < M; i++) {
		cin >> P.at(i) >> Y.at(i);
		child.at(P.at(i) - 1).push_back((uint64_t(Y[i])<<32) | uint64_t(i));
	}

	vector<int> Cnt(M);

	for (auto&i : child) {
		sort(i.begin(), i.end());
		int cnt = 0;
		for (auto&j:i) {
			Cnt[j & 0xffffffff] = ++cnt;
		}
	}

	for (int i = 0; i < M; i++) {
		printf("%06d%06d\n", P.at(i), Cnt.at(i));
	}

	return 0;
}


Measured memory_bytes: 8192
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Comparing Strings
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  if (a > b) swap(a, b);

  for (int i = 0; i < b; i++) printf("%d", a);
  putchar('\n');
  return 0;
}


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

int Rotation(string Direction){
	int Dice[6];
	for(int i = 0; i < 6; i++){
		Dice[i] = i;
	}
	for(int i = 0; i < Direction.size(); i++){
		if(Direction[i] == 'N'){
			int M = Dice[0];
			Dice[0] = Dice[1];
			Dice[1] = Dice[5];
			Dice[5] = Dice[4];
			Dice[4] = M;
		}
		if(Direction[i] == 'W'){
			int M = Dice[0];
			Dice[0] = Dice[2];
			Dice[2] = Dice[5];
			Dice[5] = Dice[3];
			Dice[3] = M;
		}
		if(Direction[i] == 'S'){
			int M = Dice[0];
			Dice[0] = Dice[4];
			Dice[4] = Dice[5];
			Dice[5] = Dice[1];
			Dice[1] = M;
		}
		if(Direction[i] == 'E'){
			int M = Dice[0];
			Dice[0] = Dice[3];
			Dice[3] = Dice[5];
			Dice[5] = Dice[2];
			Dice[2] = M;
		}
	}
	return Dice[0];
}

int main(){
	//?????????????????°???????????????
	int Surface[6];
	for(int i = 0; i < 6; i++) cin >> Surface[i];
	//?????¢?????????????????????
	string Direction;
	cin >> Direction;
	//?????¢?????????????¨??????????
	int Top;
	Top = Rotation(Direction);
	//?????¢???????????????
	cout << Surface[Top] << endl;
}

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

int main(void) {
    int n;
    cin >> n;
    vector<P> times;
    ll a, b;
    for (int i=0; i<n; i++) {
        cin >> a >> b;
        times.emplace_back(make_pair(b, a));
    }
    
    sort(times.begin(), times.end());
        
    ll cumsum = 0;
    bool flag = true;
    for (auto x : times) {
        cumsum += x.second;
        if (cumsum > x.first) {
            flag = false;
            break;
        }
    }
    
    cout << (flag ? "Yes" : "No") << endl;
    
    return 0;
}

Measured memory_bytes: 7456
//Create Time: 2018-04-15 16:38:10
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <functional>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <ctime>
#include <utility>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
#define snuke(i,x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,n,a) for (int i=(n)-1;i>=(a);i--)
#define OUT(x) std::cout<<(#x)<<":"<<(x)<<std::endl
#define TST(x) std::cout<<(#x)<<":"<<(x)<<" "
#define SZ(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define unq(x) sort(all(x)),(x).erase(unique(all(x)),(x).end())
#define mem(f,x) memset((f), (x), sizeof(f))
#define clr(f) mem(f,0)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define DEBUG
template<class T> void rd(T&ret){ret=0;bool ok=0,u=0;for(;;){int c=getchar();if(c>='0'&&c<='9')ret=(ret<<3)+(ret<<1)+c-'0',ok=1;else if(c=='-')u=1;else if(ok){if(u)ret*=-1;return;}}}
long long powmod(long long p,long long n,long long mod){long long ret=1;for(;n;n>>=1){if(n&1)ret=ret*p%mod;p=p*p%mod;}return ret;}
template <class T> bool chmin(T& a, const T &b) {return b < a? a = b, 1: 0;}
template <class T> bool chmax(T& a, const T &b) {return b > a? a = b, 1: 0;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii > vii;
/****head****/
int main(){
    string s;cin>>s;
    set<int> has;
    for(char c:s)has.insert(c-'a');
    rep(i,0,26)if(has.find(i)==has.end()){
        s.pb(i+'a');cout<<s<<endl;return 0;
    }
    per(i,SZ(s),0){
        rep(j,s[i]-'a'+1,26)if(has.find(j)==has.end()){
            s[i]=j+'a';
            s.resize(i+1);
            cout<<s<<endl;
            return 0;
        }
        has.erase(s[i]-'a');
    }
    puts("-1");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
#define el putchar('\n')
#define ta putchar('	')
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
//	sprintf(str,"%s.out",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=200010;
int n,cnt;
char s[N];

int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	ll ans=0;
	fo(i,1,n)if(s[i]=='A'){
		while(s[i]=='A'){++i;++cnt;if(i==n)break;}
		int hh=0;
		while(i<n&&s[i]=='B'&&s[i+1]=='C'){
			++hh;++i;++i;if(i==n)break;
		}--i;
		ans+=1ll*cnt*hh;
	}
	else{cnt=0;}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
//ABC077B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int n;
	cin >> n;
	for(int i=0;i<=n+1;i++){
		if(i*i > n){
			cout << (i-1)*(i-1) << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<u32>();
    if n == 1 {
        println!("Hello World");
    } else if n == 2 {
        let a = read::<u32>();
        let b = read::<u32>();

        println!("{}", a+b);
    }
}


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

int main() {
  int N,K;
  cin >> N >> K;
  int Sum = 1;
  for(int i=0; i< N; i++){
  	if(Sum + K > Sum * 2){
    	Sum = Sum * 2;
    }else{
    	Sum = Sum + K;
    }
  }
  cout << Sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
#define ll long long
#define ull unsigned long long
#define ms(a) memset(a,0,sizeof(a))
#define pi acos(-1.0)
#define INF 0x7f7f7f7f
#define lson o<<1
#define rson o<<1|1
const double E=exp(1);
const int maxn=1e6+10;
const int mod=1e9+7;
using namespace std;
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	int a,b,c;
	cin>>a>>b>>c;
	if(c>=a&&c<=b)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		string s,q,u;
      int a,b;
      cin>>s>>q>>a>>b>>u;
      if(s==u)
        a--;
      else
        b--;
      cout<<a<<" "<<b;
	}
	return 0;
}

Measured memory_bytes: 256
P=[]
C=[]
point=1001    #全問題数
 
D,G=map(int,input().split())
for i in range(D):
    p,c= map(int,input().split())
    P.append(p)
    C.append(c)
 
#とりあえず全部解くor解かないで目標スコアを超えるか超えないかを考える
 
 
for i in range(2**D) :
    score=0
    solve=0
    needproblem=0
    for j in range(D) :                  #全正解した大問をスコアに変換
        if (i>>j) & 1 :
            score+=P[j]*100*(j+1)+C[j]
            solve+=P[j]
        if (~i>>j) & 1 :                  #1問も解かなかった問題の中で最も一題あたりの点が高い問題
            needproblem=j+1
    if score>=G :
        point=min(point,solve)
 
#ぎりぎりスコアが届いていない場合、1問も解かなかった問題の中で最も一題あたりの点が高い問題だけ解いてみる
#中途半端に大問を解ききるのが１種類以下でも目標に届く場合もあるという予想
 
    elif score<G :                
        rest=G-score
        sum=(P[needproblem-1]-1)*needproblem*100
        if rest>sum :            #1問も解かなかった問題の中で最も一題あたりの点が高い問題を解いても届かないのでやり直し
            continue
        elif rest<=sum :
            resolve=solve+(rest//(needproblem*100)+(rest%(needproblem*100)>0))
            point=min(point,resolve)
 
print(point)

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

using namespace std;

const int N = 1e5 + 7;

int v[N], x[N];
long long _s[2];

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
    int n;
    long long s(0);
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> v[i], s += v[i], _s[i&1] += v[i];
    x[0] = 2 * _s[0] - s;
    cout << x[0] << ' ';
    for (int i = 1; i < n; ++i) {
        x[i] = 2 * v[i - 1] - x[i - 1];
        cout << x[i] << ' ';
    }
    return 0;
}


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

int main(){
  int n,ans;
  cin >> n;
  ans = 0;
  vector<int> a(n,0);
  for(int i = 0;i < n;i++){
    int tmp;
    cin >> tmp;
    if(tmp % 2 != 0){
      cout << 0 << endl;
      return 0;
    }else{
      while(tmp > 1){
        if(tmp % 2 == 0){
          a.at(i)++;
          tmp /= 2;
        }else{
          break;
        }
      }
    }
  }
  sort(a.begin(),a.end());
  ans = a.at(0);   
    
  cout << ans << endl;
    
  return 0;
}

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

using namespace std;

typedef long long ll;
#define SWAP(x,y,z) {if ( y > z ) swap(y,z); if ( x > y ) swap(x,y); if (y > z) swap(y,z);}


double const eps = 1e-10;
ll const mod = 1e9+7;

int a[200];
int b[200];

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

    string s1,s2;
    cin >> s1 >> s2;
    for ( int i = 0; i < s1.size(); i++ )  a[i] = (int)s1[i]-48;
    for ( int i = 0; i < s2.size(); i++ )  b[i] = (int)s2[i]-48;

    if ( s1[0] != '-' && s2[0] == '-' ) cout << "GREATER";
    else if ( s1[0] == '-' && s2[0] != '-' ) cout << "LESS";
    else
    {
        if ( s1[0] != '-' && s2[0] != '-' )
        {
            if ( s1.size() > s2.size() ) cout << "GREATER";
            else if ( s2.size() > s1.size() ) cout << "LESS";
            else
            {
                for ( int i = 0; i < s1.size(); i++ )
                {
                    if ( a[i] > b[i] )
                    {
                        cout << "GREATER";
                        return 0;
                    }
                    else if ( b[i] > a[i] )
                    {
                        cout << "LESS";
                        return 0;
                    }
                }
                cout << "EQUAL";
            }
        }
        else
        {
            if ( s1.size() > s2.size() ) cout << "LESS";
            else if ( s2.size() > s1.size() ) cout << "GREATER";
            else
            {
                for ( int i = 1; i < s1.size(); i++ )
                {
                    if ( a[i] > b[i] )
                    {
                        cout << "LESS";
                        return 0;
                    }
                    else if ( b[i] > a[i] )
                    {
                        cout << "GREATER";
                        return 0;
                    }
                }
                cout << "EQUAL";
            }
        }
    }

    return 0;

    // 274751WM
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=5e2+10,maxm=1e5+10;
int u[maxm],v[maxm],f[maxn][maxn],p[maxn],ans,n,m;
int main(){
	cin>>n>>m;
	for(register int i=1;i<=m;++i)scanf("%d%d",&u[i],&v[i]);
	for(register int i=1;i<=n;++i){
		f[i][i]=1;
		for(register int j=m;j;--j){
			if(f[i][u[j]]&&f[i][v[j]])break;
			if(f[i][u[j]]||f[i][v[j]])f[i][u[j]]=f[i][v[j]]=1;
			if(j==1)p[i]=1;
		}
	}for(register int i=1;i<=n;++i)if(p[i])for(register int j=i+1;j<=n;++j)if(p[j]){
		int tmp=1;
		for(register int k=1;k<=n;++k)if(f[i][k]&&f[j][k]){tmp=0;break;}
		ans+=tmp;
	}cout<<ans<<endl;
	return 0;
}

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

int main(){
  int cnt = 0;
  string s, t;
  
  cin >> s >> t;
  
  for(int i = 0; i < 3; i++){
    if(s.at(i) == t.at(i)){
      cnt++;
    }
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))
Q = P.copy()
cnt1 = 0
for i in range(N-1):
    if P[i] == i+1:
        tmp = P[i]
        P[i] = P[i+1]
        P[i+1] = tmp
        cnt1 += 1
if P[-1] == N:
    cnt1 += 1

cnt2 = 0
for i in range(N-1, 0, -1):
    if Q[i] == i+1:
        tmp = Q[i]
        Q[i] = Q[i-1]
        Q[i-1] = tmp
        cnt2 += 1
if Q[0] == 1:
    cnt2 += 1
print(min(cnt1, cnt2))


Measured memory_bytes: 14008
class Solution:

    def solve(self, N: int):

        def dfs(prev_str: str, max_search_char: str):
            if len(prev_str) == N:
                print(prev_str)
                return
            else:

                for i in range(ord('a'), ord(max_search_char) + 1):
                    c = chr(i)
                    if i == ord(max_search_char):
                        dfs(prev_str + c, chr(i+1))
                    else:
                        dfs(prev_str + c, max_search_char)

        dfs('', 'a')


if __name__ == '__main__':

    # standard input
    N = int(input())
    # solve
    solution = Solution()
    answer = solution.solve(N)


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

using namespace std;

typedef long long lol;

const int M = 63;
const int N = 2e2 + 5;
int _w;

struct BASE {
  lol v[M];
  void init( void ) { memset( v , 0 , sizeof v ); }
  bool chk( lol x ) {
    for( int i = M - 1 ; ~i ; --i )
      if( ( x >> i ) & 1 ) {
        if( !v[i] ) return true;
        x ^= v[i];
      }
    return false;
  }
  void ins( lol x ) {
    for( int i = M - 1 ; ~i ; --i )
      if( ( x >> i ) & 1 ) {
        if( !v[i] ) return v[i] = x , void();
        x ^= v[i];
      }
  }
} bs[N] , Bs;

int n , idx; lol dat[N];
char S[N];

void solve( void ) {
  _w = scanf("%d",&n);
  for( int i = 1 ; i <= n ; ++i )
    _w = scanf("%lld",dat+i);
  _w = scanf("%s",S+1) , idx = 0;
  if( S[n] == '1' ) return puts("1"),void();
  for( int i = 1 , r ; i <= n ; i = r + 1 ) {
    r = i;
    while( r < n && S[r + 1] == S[i] ) ++r;
    ++idx;
    bs[idx].init();
    for( int j = i ; j <= r ; ++j ) 
      bs[idx].ins( dat[j] );
  }
  Bs.init();
  for( int i = n , l ; i ; i = l - 1 ) {
    l = i;
    while( l > 1 && S[l - 1] == S[i] ) --l;
    if( S[i] == '1' ) {
      for( int j = 0 ; j < M ; ++j )
        if( Bs.chk( bs[idx].v[j] ) )
          return puts("1"),void();
    } else {
      for( int j = 0 ; j < M ; ++j )
        Bs.ins( bs[idx].v[j] );
    }
    --idx;
  }
  puts("0");
}

int main( void ) {
  int T;
  _w = scanf("%d",&T);
  while( T-- ) solve();
  return 0;
}


Measured memory_bytes: 3680
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_2_C&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    numbers = [int(x) for x in input().split()]
    numbers.sort()
    print(*numbers)


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7752
#include <stdio.h>

int main(void){

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

 if(a < b){
  printf("a < b\n");
 } else if(a > b){
  printf("a > b\n");
 }else{
  printf("a == b\n");
 }
 return 0;

}

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

// @@ !! LIM(mod)
// --> f:gcd mod
// ---- inserted function gcd from util.cc
// g = eGCD(a, b, s, t)  --->  sa + tb = g
ll eGCD(ll a, ll b, ll& s, ll& t) {
  if (a == 0) {
    s = 0;
    t = 1;
    return b;
  }
  ll u = 0;
  ll g = eGCD(b % a, a, t, u);
  s = u - (b / a) * t;
  return g;
}

// gcd(0, x) = x, gcd(-x, y) = gcd(x, y)
ll gcd(ll a, ll b) {
  ll dummy1 = 0;
  ll dummy2 = 0;
  return eGCD(abs(a), abs(b), dummy1, dummy2);
}
// ---- end gcd
// ---- inserted library file mod.cc

ll MOD = 1e9 + 7;
// ll MOD = 998244353;

struct Fp {
  ll val;

  Fp(ll t = 0) {
    if      (t >= MOD)  val = t % MOD;
    else if (t >= 0)    val = t;
    else if (t >= -MOD) val = t + MOD;
    else {
      ll v = t % MOD;
      if (v == 0) val = 0;
      else        val = v + MOD;
    }
  }

  Fp& operator +=(const Fp& t) {
    val += t.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }

  Fp& operator -=(const Fp& t) {
    val -= t.val;
    if (val < 0) val += MOD;
    return *this;
  }

  Fp& operator *=(const Fp& t) {
    val = (val * t.val) % MOD;
    return *this;
  }

  Fp inv() const {
    if (val == 0) {
      cerr << "inv() is called for zero." << endl;
      exit(1);
    }
    ll u = 0;
    ll v = 0;
    eGCD(val, MOD, u, v);
    return Fp(u);
  }

  Fp& operator /=(const Fp& t) {
    return (*this) *= t.inv();
  }

  Fp operator +(const Fp& t) const { return Fp(val) += t; }
  Fp operator -(const Fp& t) const { return Fp(val) -= t; }
  Fp operator *(const Fp& t) const { return Fp(val) *= t; }
  Fp operator /(const Fp& t) const { return Fp(val) /= t; }
  Fp operator -() const { return Fp(-val); }

  bool operator ==(const Fp& t) const { return val == t.val; }
  bool operator !=(const Fp& t) const { return val != t.val; }
  
  operator ll() const { return val; }

};

class Comb {
  int nMax;
  vector<Fp> vFact;
  vector<Fp> vInvFact;
public:
  Comb(int nm) : nMax(nm), vFact(nm+1), vInvFact(nm+1) {
    vFact.at(0) = 1;
    for (int i = 1; i <= nMax; i++) vFact.at(i) = i * vFact.at(i-1);
    vInvFact.at(nMax) = vFact.at(nMax).inv();
    for (int i = nMax; i >= 1; i--) vInvFact.at(i-1) = i * vInvFact.at(i);
  }
  Fp fact(int n) { return vFact.at(n); }
  Fp comb(int n, int r) {
    return vFact.at(n) * vInvFact.at(r) * vInvFact.at(n-r);
  }
  // The number of permutation extracting r from n.
  Fp perm(int n, int r) {
    return vFact.at(n) * vInvFact.at(n-r);
  }
};

// ---- end mod.cc
// @@ !! LIM  -- end mark --

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

  MOD = 998244353;
  ll N, A, B, K; cin >> N >> A >> B >> K;
  Comb cb(N+1);
  Fp cnt(0);
  for (ll x = 0; x <= N; x++) {
    ll r = K - x * A;
    if (r < 0) break;
    if (r > N * B) continue;
    if (r % B != 0) continue;
    ll y = r / B;
    cnt += cb.comb(N, x) * cb.comb(N, y);
  }
  cout << ll(cnt) << endl;


  return 0;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define p(x) cout << x << endl;

#define MOD 1000000007
#define PI 3.14159265359

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

    string s;
    cin >> s;

    for(int i = 0; i < s.size(); i++){
        if(i % 2 == 0){
            cout << s[i];
        }
    }

    cout << endl;
}


Measured memory_bytes: 592
h, w = map(int, input().split())
alphcnt = [0] * 26
for _ in range(h):
    a = list(input())
    for x in a:
        alphcnt[ord(x) - 97] += 1
p1, p2, p4 = 0, 0, 0
for i in range(26):
    x = alphcnt[i] // 4
    alphcnt[i] -= 4 * x
    p4 += x
for i in range(26):
    x = alphcnt[i] // 2
    alphcnt[i] -= 2 * x
    p2 += x
for i in range(26):
    x = alphcnt[i]
    alphcnt[i] -= x
    p1 += x
t = 0
if h % 2 == w % 2 == 0:
    if p1 == p2 == 0:
        t = 1
elif h % 2 == w % 2 == 1:
    if p1 == 1 and p4 >= (h // 2) * (w // 2):
        t = 1
else:
    if p1 == 0 and p4 >= (h // 2) * (w // 2):
        t = 1
print("Yes" if t == 1 else "No")

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

int main(){
	ll N, X, ans = 0;
	cin >> N >> X;
	ll two[N+2];
	two[0] = 1;
	for(int i=1; i<N+2; i++){
		two[i] = two[i-1]*2;
	}
	while(N >= 0){
		if(X == 2*two[N+1] - 3){
			ans += two[N+1] - 1;
			cout << ans << endl;
			return 0;
		}else if(X > two[N+1]-1){
			ans += two[N];
			X = X - two[N+1] + 1;
			N--;
		}else if(X == two[N+1]-1){
			ans += two[N];
			cout << ans << endl;
			return 0;
		}else if(X == 0){
			cout << ans << endl;
			return 0;
		}else{
			X--;
			N--;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){

  string S, T;
  cin >> S >> T;
  int n = S.size();
  string ans = "No";
  for(int i=0; i < n; i++){
    bool flag = false;
    for(int j=i; j < i+n; j++){
      if(S[j % n] != T[j-i]){
        flag = true;
        break;
      }
    }
    if(!flag){
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;

}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int m = (1 << n);
    vector<ll> s(m);
    for (int i = 0; i < m; i++) cin >> s[i];
    sort(s.begin(), s.end(), greater<>());

    vector<int> itr(n, 0);
    vector< vector<ll> > hoge(n + 1);
    for (int i = 0; i <= n; i++) {
        hoge[i].push_back(s[0]);
    }

    int cur = 1;
    for (int i = 0; i < n; i++) {
        int num = (1 << i);
        if (hoge[i].size() != num) {
            cout << "No\n";
            return 0;
        }

        /*
        for (ll x : hoge[i]) {
            cerr << x << " ";
        } 
        cerr << endl;//*/

        int& j = itr[i];
        while (j < num) {
            if (cur == m) {
                break;
            }

            if (hoge[i][j] > s[cur]) {
                for (int k = i + 1; k <= n; k++) {
                    hoge[k].push_back(s[cur]);
                }
                cur++;
                j++;
            } else {
                bool f = false;
                for (int k = i + 1; k < n; k++) {
                    if (itr[k] < hoge[k].size() && hoge[k][itr[k]] > s[cur]) {
                        for (int l = k + 1; l <= n; l++) {
                            hoge[l].push_back(s[cur]);
                        }
                        itr[k]++;
                        cur++;
                        f = true;
                        break;
                    }
                }
                if (!f) {
                    cout << "No\n";
                    return 0;
                }
            }
        }

        if (cur == m) break;
    }

    if (hoge[n].size() != m) {
        cout << "No\n";
        return 0;
    }

    cout << "Yes\n";

    return 0;
}

Measured memory_bytes: 6884
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
using namespace std;
typedef long long ll;

string S;
int N,K;
int D[10];

bool check(int ans) {
	while (ans) {
		int n = ans % 10;
		for (int i = 0; i < K; i++)
			if (D[i] == n)
				return true;
		ans /= 10;
	}
	return false;
}

int main(void)
{
	cin >> N >> K;

	for (int i = 0; i < K; i++) {
		cin >> D[i];
	}

	int ans = N;
	while (check(ans))
		++ans;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include<iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

struct UF
{
	vector<int> par; // 親
	vector<int> sz; // 数
	// 初期化
	UF(int n):par(n),sz(n) {
		for(int i = 0; i < n; i++){
			par[i] = i;sz[i] = 1;
		}
	}
	// 木の根を求める
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	// xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		par[x] = y;
		sz[y] += sz[x];
	}
	// xとyが同じ集合ならtrue
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int n){return sz[find(n)];}
};

bool non[111111];
int ka[111111];

int main()
{
	ll n,m;
	cin >> n >> m;
	
	UF uf(n);
	
	vector<pair<ll,ll> > v;
	
	REP(i,n)
	{
		ll tmp;cin >> tmp;
		v.PB(MP(tmp,0));
	}
	
	REP(i,m)
	{
		ll a,b;cin >> a >> b;
		uf.unite(a,b);
	}
	
	set<int> s;
	
	REP(i,n)
	{
		v[i].SE = uf.find(i);
		s.insert(v[i].SE);
	}
	
	if(s.size() == 1)
	{
		cout << 0 << endl;
		return 0;
	}
	
	sort(ALL(v));
	
	ll cou = 2*(s.size() -1);
	
	if(n < cou)
	{
		cout << "Impossible" << endl;
		return 0;
	}
	
	ll ans = 0;
	set<int> mem;
	
	REP(i,n)
	{
		if(ka[v[i].SE])
		{
			if(cou - s.size() + mem.size())
			{
				ans += v[i].FI;
				cou--;
			}
		}
		else
		{
			ka[v[i].SE]++;
			ans += v[i].FI;
			mem.insert(v[i].SE);
			cou--;
		}
	}

	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 7664
#include<cstdio>
using namespace std;
const long long Mod=1e9+7;
int n,c,l[405],r[405];
long long G[405][405],f[405][405],a[405][405];
int main()
{
	//freopen("candies.in","r",stdin);
	//freopen("candies.out","w",stdout);
	scanf("%d%d",&n,&c);
	for(int i=1;i<=n;i++) scanf("%d",&l[i]);
	for(int i=1;i<=n;i++) scanf("%d",&r[i]);
	for(long long i=1;i<=400;i++){G[i][0]=1;for(int j=1;j<=400;j++) G[i][j]=(G[i][j-1]*i)%Mod;}
	for(int i=1;i<=n;i++) for(int j=0;j<=c;j++) for(int u=l[i];u<=r[i];u++) f[i][j]=(f[i][j]+G[u][j])%Mod;
	a[0][0]=1;
	for(int i=1;i<=n;i++) for(int j=0;j<=c;j++) for(int k=0;k<=j;k++) a[i][j]=(a[i][j]+a[i-1][j-k]*f[i][k])%Mod;
	printf("%lld",a[n][c]);
}

Measured memory_bytes: 3968
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

template <typename T>
class SegmentTree {
    const T unit;
    const function<T(const T&, const T&)> op;
    vector<T> container;

public:
    template <typename Op>
    SegmentTree(int size, const T& identity, const Op& operation)
        : unit(identity)
        , op(operation)
        , container(msb(size * 2 - 1))
    {
        fill(container.begin(), container.end(), unit);
    }
    void update(size_t index, T value)
    {
        int n = container.size() / 2;
        container[index + n] = value;

        int node = (index + n) >> 1;
        while (node > 0) {
            container[node] = op(container[node << 1], container[(node << 1) + 1]);
            node >>= 1;
        }
    }
    T find(size_t s, size_t t)
    {
        if (s >= t) {
            return unit;
        }
        return find_inner(s, t, 0, container.size() / 2);
    }

private:
    T find_inner(size_t s, size_t t, size_t lb, size_t ub)
    {
        if (s == lb && t == ub) {
            int n = container.size() / 2;
            return container[lca(n + s, n + t - 1)];
        }

        T result = unit;
        size_t mid = (lb + ub) / 2;
        if (mid > s) {
            result = op(result, find_inner(s, min(mid, t), lb, mid));
        }
        if (mid < t) {
            result = op(result, find_inner(max(s, mid), t, mid, ub));
        }

        return result;
    }
    int lca(int n0, int n1)
    {
        int a = n0 ^ n1;
        return n0 / msb(a);
    }
    int msb(int x)
    {
        x |= x >> 1;
        x |= x >> 2;
        x |= x >> 4;
        x |= x >> 8;
        x |= x >> 16;

        return x + 1;
    }
};

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

    using E = tuple<int, int, int>;
    vector<E> event;
    vector<int> cost(m);
    rep(i, m)
    {
        int l, r, c;
        cin >> l >> r >> c;
        l--;
        r--;
        cost[i] = c;
        event.push_back(E(l, 1, i));
        event.push_back(E(r, 0, i));
    }

    sort(event.begin(), event.end());

    const int64_t DMAX = 1'000'000'000L * 100'000L + 1;
    vector<int64_t> dist(n, DMAX);
    SegmentTree<int64_t> seg(m, DMAX, [](const int64_t& lh, const int64_t& rh) {
        return min(lh, rh);
    });
    int k = 0;
    rep(i, event.size())
    {
        int j, t, idx;
        tie(j, t, idx) = event[i];

        while (k <= j) {
            dist[k] = (k == 0 ? 0 : seg.find(0, m));
            k++;
        }
        if (t == 1) {
            seg.update(idx, dist[j] + cost[idx]);
        } else {
            seg.update(idx, DMAX);
        }
    }
    if (dist[n - 1] >= DMAX) {
        cout << -1 << endl;
    } else {
        cout << dist[n - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int64_t N,M=0,ans=0; cin>>N;
  vector<int64_t> A(N),B(N),C(N);
  rep(i,N) cin>>A.at(i);
  rep(i,N) cin>>B.at(i);
  rep(i,N){
    auto a=A.at(i),b=B.at(i);
    auto c=a-b;
    if(c<0){
      ans++;
      M+=-1*c;
    }
    else C.push_back(c);
  }
  sort(C.begin(),C.end());
  reverse(C.begin(),C.end());
  int64_t i=0,t=C.size();
  while(M>0&&i<t){
    M-=C.at(i);
    ans++;
    i++;
  }
  if(M>0) cout<<-1;
  else cout<<ans;
}


Measured memory_bytes: 6432
#include <stdio.h>

int main(void){
    int i, n;
    int h[200] = {0};
    int count = 0;
    int flag = 0;

    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &h[i]);
    }

    while(1){
        for(i = 0; i < n; i++){
            if(h[i] != 0 && h[i+1] == 0) count++;
        }
        
        for(i = 0; i < n; i++){
            if(h[i] > 0) h[i]--;
        }

        for(i = 0; i < n; i++){
            if(h[i] > 0) flag = 1;
        }

        if(flag == 0) break;

        flag = 0;
    }

    printf("%d\n", count);

    return 0;

}

Measured memory_bytes: 128
def eval_shifts(s)
    s.split(">>").map(&:to_i).inject(:>>)
end

loop.with_index do |_, i|
    e = gets.chomp
    break if e =~ /#/ 
    e.gsub!(/\s/, "") 
    while i = e.rindex(?S)
        e[i] = ?T
        e.sub!(/T<\d+(>>\d+)*>/){|s| (eval_shifts(s[2..-2]) ** 2 % 1_000_000_007).to_s}
    end 
    p eval_shifts(e)
end

Measured memory_bytes: 117492
#include<stdio.h>
int main(void) {
	int i, j, tmp, high[10];
	for (i = 0; i<10; i++)scanf("%d", &high[i]);
	for (i = 0; i<10; i++) {
		for (j = i+1; j<10; j++) {
			if (high[i]<high[j]) {
				tmp = high[i];
				high[i] = high[j];
				high[j] = tmp;
			}
		}
	}
	for (i = 0; i<3; i++)printf("%d\n", high[i]);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
 #define mod 1000000007
 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
    cin>>n;
    double a[n];
    double sum=0;
    for(int x=0;x<n;x++){
        cin>>a[x];
        double z=1/a[x];
        sum+=z;
    }
    double ans=1/sum;
    cout<<fixed<<setprecision(10)<<ans;









	
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val k = scanner.nextInt()
    val a = Array<Int>(k, { 0 })
    for (i in (0..(k - 1))) {
        a[i] = scanner.nextInt()
    }
    if (a[k - 1] >= 3) {
        println("-1")
        return
    }
    var ansMax: Long = 2
    var ansMin: Long = 2
    for (j in (1..k)) {
        val i = k - j
        ansMax += (a[i] - 1)
        if (j == k) {
            println("$ansMin $ansMax")
            return
        }
        ansMax = ansMax / a[i - 1] * a[i - 1]
        ansMin = ((ansMin - 1) / a[i - 1] + 1) * a[i - 1]
        if (ansMin > ansMax) {
            println("-1")
            return
        }
    }
}

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

int main(){
  int N,M;
  cin >> N >> M;
  int quo=M/N;
  int mod=M%N;
  for(int i=quo;i>=1;i--){
    if(mod%i==0){
      cout << i << endl;
      break;
    }
    mod+=N;
  }
  return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
int main() {
int64_t N,K;
cin>>N>>K;
vector <int64_t> H(N);
for(int i=0; i<N; i++){
    cin>>H[i];
}
sort(H.begin(),H.end());
reverse(H.begin(), H.end());
if(N<=K){
    cout<<"0"<<endl;
    return 0;
}else{
    int64_t at=0;
    for(int64_t i=K; i<N; i++){
        at+=H[i];
    }
    cout<<at<<endl;
}
}

Measured memory_bytes: 1792
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353

const string ANS="RBRBRBRBRB";

bool isRed(const vector<int> &v){
	int n=v.size();
	if(0){
		int cnt=0;
		rep(i,n)if(ANS[i+v[i]*n]=='R') ++cnt;
		return cnt*2>n;
	}
	cout<<"?";
	rep(i,n) cout<<" "<<i+1+v[i]*n; cout<<endl;
	string s;
	cin>>s;
	if(s=="-1") exit(0);
	return s=="Red";
}
bool isRed2(const vector<int> &v){
	vector<int> re;
	rep(i,v.size())if(v[i]) re.pb(i);
	if(0){
		int cnt=0;
		rep(i,re.size())if(ANS[re[i]]=='R') ++cnt;
		out(v,re,cnt,1);
		return cnt*2>ANS.size()/2;
	}
	cout<<"?";
	rep(i,re.size()) cout<<" "<<1+re[i]; cout<<endl;
	string s;
	cin>>s;
	if(s=="-1") exit(0);
	return s=="Red";
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	int n;
	cin>>n;
	// n=ANS.size()/2;
	int zero=isRed(vector<int>(n,0));
	int l=0,r=n;
	while(r-l>1){
		int m=(l+r)/2;
		vector<int> fs(m,1);
		fs.resize(n);
		(zero==isRed(fs)?l:r)=m;
	} //9
	out(l,r,1);
	vector<int> v_(2*n);
	rep(i,l) v_[i+n]=1;
	reps(i,l,n) v_[i]=1;
	out(v_,1);
	string re(2*n,'?');
	re[l]='R';
	re[l+n]='B';
	rep(i,2*n)if(i!=l && i!=l+n){
		auto v=v_;
		if(v[i]){
			v[i]=0;  //? out
			v[l+n]=1;//B in
			out(i,zero,isRed2(v),1);
			re[i]=((isRed2(v)==zero)?'B':'R');
		}else{
			v[i]=1; //? in
			v[l]=0; //R out
			out(i,zero,isRed2(v),1);
			re[i]=((isRed2(v)==zero)?'R':'B');
		}
	}
	out(re,1);
	if(!zero) rep(i,2*n) re[i]^='R'^'B';
	cout<<"! "<<re<<endl;
  return 0;
}


Measured memory_bytes: 724
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t=0;
  cin>>n;
  int a[n][3],count[200]={0};
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<3;i++){
    for(int k=0;k<n-1;k++){
      t=0;
    for(int j=k+1;j<n;j++){
      if(a[k][i]==-1){
	break;
      }
      if(a[k][i]==a[j][i]){
	a[j][i]=-1;
	t++;
      }
    }
    if(t!=0){
      a[k][i]=-1;
    }
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      if(a[i][j]!=-1){
	count[i]+=a[i][j];
      }
    }
  }
  for(int i=0;i<n;i++){
    cout<<count[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3112
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vll = vector<vector<ll> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;
using lthe = pair<ll, ll>;

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

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };


priority_queue<the> p[200000];
const int MAXP = 2 * 1e5;

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

	Vi A(100001, 0);
	ll tt = 0;
	rep(i, n) {
		int t;
		cin >> t;
		A[t]++;
		tt +=t;
	}
	int q;
	cin >> q;

	rep(i, q) {
		//ll sum = 0;
		int t1, t2;
		cin >> t1 >> t2;
		if (A[t1] == 0) {
			cout << tt << endl;
			continue;
		}
		tt += (t2 - t1) * A[t1];
		A[t2] += A[t1];
		A[t1] = 0;
		cout << tt << endl;
	}
}


Measured memory_bytes: 9768
#include <bits/stdc++.h>
using namespace std;
#define pb push_back

int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res; }

int gcd(int a,int b){
    if(b==0) return a;
    else return gcd(b,a%b);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
       int n;
       cin>>n;
       int v[n];
       int c[n];
       for(int i=0;i<n;i++){
           cin>>v[i];
       }
       for(int i=0;i<n;i++){
           cin>>c[i];
       }
       int sum=0;
       for(int i=0;i<n;i++){
           sum+=max(0,v[i]-c[i]);
       }
       cout<<sum;
    }
}
    

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int64_t> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  for(int i=0;i<N;i++){
    if(i>=K){
      if(A.at(i-K)<A.at(i)){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4756
from collections import deque

h, w = map(int, input().split())
sy, sx = map(int, input().split())
gy, gx = map(int, input().split())
field = [["#"] * (w + 4)] + \
        [["#"] * (w + 4)] + \
        [list("##" + input() + "##") for i in range(h)] + \
        [["#"] * (w + 4)] + \
        [["#"] * (w + 4)]
sy += 1
sx += 1
gy += 1
gx += 1          
          
dxy1 = [(0,1), (0,-1), (1,0), (-1,0)]
dxy2 = [(1,1), (1,-1), (-1,1), (-1,-1), \
        (-2,-2), (-1,-2), (0,-2), (1,-2), (2,-2), \
        (-2,-1), (2,-1), (-2,0), (2,0), (-2,1), (2,1), \
        (-2,2), (-1,2), (0,2), (1,2), (2,2)]


goal = False
INF = 10**9
cnt = [[INF]*(w+4) for i in range(h+4)]

q = deque()
q.append([sy, sx])
cnt[sy][sx] = 0

while goal == False and q:
    y, x = q.pop()
    now = cnt[y][x]
    flg = False
    for dy, dx in dxy1:
        ny, nx = y + dy, x + dx
        if ny == gy and nx == gx:
            cnt[ny][nx] = now
            goal = True
            flg = True
            break
        if field[ny][nx] == '#':
            continue
        if field[ny][nx] == '.' and cnt[ny][nx] > now:
            q.append([ny, nx])
            cnt[ny][nx] = now
            flg = True
    if goal:
        break
    for dy, dx in dxy2:
        ny, nx = y + dy, x + dx
        if field[ny][nx] == '#':
            continue
        if field[ny][nx] == '.' and cnt[ny][nx] > now + 1:
            q.appendleft([ny, nx])
            cnt[ny][nx] = now + 1
print(cnt[gy][gx]) if cnt[gy][gx] < INF else print(-1)

Measured memory_bytes: 131252
using System;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			// 整数の入力
			long x = long.Parse(Console.ReadLine());
			long a = long.Parse(Console.ReadLine());
			long b = long.Parse(Console.ReadLine());

			long remain = x - a;
			while (remain >= b) {
				remain -= b;
			}

			Console.WriteLine(remain.ToString());

			Console.Out.Flush();

			Console.ReadLine();
		}
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define MAXN 101
using namespace std;
int n, A[2][MAXN], V[2][MAXN];
int main() {
    cin >> n;
    for(int i = 0; i < 2; ++i) {
        for(int j = 0; j < n; ++j) {
            cin >> A[i][j];
        }
    }
    
    V[0][0] = A[0][0];
    for(int j = 1; j < n; ++j) {
        V[0][j] = A[0][j] + V[0][j-1];        
    }

    V[1][n-1] = A[1][n-1];
    for(int j = n-2; j >= 0; --j) {
        V[1][j] = A[1][j] + V[1][j+1];        
    }

    
    int max = 0;
    for(int j = 0; j < n; ++j) {
        int r = V[0][j] + V[1][j];
        if(r > max) {
            max = r;
        }
    }
    cout << max;
    
    

    
}

Measured memory_bytes: 256