akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  string s; cin >> s;
  s[3] = '8';
  cout << s << endl;
}


Measured memory_bytes: 256
/*********************
*  Author: xuziyuan  * 
*********************/
 
#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;

LL n,t,a[200010];
vector <LL> v,v2,v3,v4;

LL check(LL mid)
{
	LL ret=0;
	for(LL i=0,j=v.size()-1;i<v2.size();i++)
	{
		while(j>=0&&v2[i]*v[j]>=mid) j--;
		ret+=j+1;
	}
	return ret;
}

void solve10(LL tt)
{
	LL lb=0,ub=1e18,mid;
	while(lb<ub)
	{
		mid=(lb+ub+1)/2;
		if(check(mid)<tt) lb=mid;
		else ub=mid-1;
	}
	cout<<-lb<<endl;
}

LL check2(LL mid)
{
	LL ret=0;
	//if(v.size()>1)
	for(LL i=0,j=v.size()-1;i<v2.size();i++)
	{
		while(j>=0&&v2[i]*v[j]>=mid) j--;
		ret+=j+1-(j>=i);
	}
	//if(v3.size()>1)
	for(LL i=0,j=v3.size()-1;i<v4.size();i++)
	{
		while(j>=0&&v4[i]*v3[j]>=mid) j--;
		ret+=j+1-(j>=i);
	}
	return ret;
}

void solve11_00(LL tt)
{
	LL lb=0,ub=1e18,mid;
	while(lb<ub)
	{
		mid=(lb+ub+1)/2;
		if(check2(mid)<tt) lb=mid;
		else ub=mid-1;
	}
	cout<<lb<<endl;
}

int main()
{
	cin>>n>>t;
	LL num0=0;
	rep(i,n)
	{
		cin>>a[i];
		if(a[i]>0) v.pb(a[i]);
		else if(a[i]<0) v2.pb(-a[i]);
		else num0++;
	}
	sort(v.begin(),v.end());
	sort(v2.begin(),v2.end());
	if(t<=v.size()*v2.size()) solve10(v.size()*v2.size()-t+1);
	else
	{
		t-=v.size()*v2.size();
		if(t<=num0*(v.size()+v2.size())+num0*(num0-1)/2) cout<<0<<endl;
		else
		{
			t-=num0*(v.size()+v2.size())+num0*(num0-1)/2;
			v3=v4=v2;
			v2=v;
			solve11_00(t*2);
		}
	}
	return 0;
}

Measured memory_bytes: 6000
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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



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



Measured memory_bytes: 3632
N = int(input())
dp = [0] * (N+1)
for i in range(1,N+1):
    dp[i] = float('inf')
    power = 1
    while power <= i:
        dp[i] = min(dp[i], dp[i-power] +1)
        power *= 6
    power = 9
    while power <= i:
        dp[i] = min(dp[i], dp[i-power] + 1)
        power *= 9
print(dp[N])

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

    long long int n,ans=0,i,j,k;
    cin>>n;
    long long int a[n+1][n+1];
    bool p[n+1][n+1];
    memset(p,0,sizeof(p));
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            cin>>a[i][j];
    for(k=1;k<=n;k++)      
        for(i=1;i<=n;i++)
            for(j=1;j<=n;j++){
                if(k!=j&&k!=i&&i!=j){
                    if(a[i][j]==a[i][k]+a[k][j])
                        p[i][j]=1; 
                    if(a[i][j]>a[i][k]+a[k][j]){
                        cout<<"-1"<<endl;  
                        return 0;
                    }
                }
            }


    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            if(p[i][j]==0)
                ans+=a[i][j]; 
    cout<<ans/2<<endl;

    return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int n,m;
	map<string, int> mp;
	cin >> n;
	string s;
	REP(i,n){
		cin >> s;
		mp[s]++;
	}
	cin >> m;
	string t;
	REP(i,m){
		cin >> t;
		mp[t]--;
	}
	int ans = 0;
	for(auto a : mp){
		ans = max(ans, a.second);
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
import sys
mod=10**9+7
n=int(input())
s=input()

count=0
ans=1
for i in range(2*n):
    if s[i]=="B": p=1
    else: p=0
    if (count+p)%2==0:
        ans=ans*count%mod
        count-=1
    else: count+=1
    if count<0: print(0);sys.exit()
if count!=0: print(0);sys.exit()
for i in range(1,n+1):
    ans=ans*i%mod
print(ans)

Measured memory_bytes: 3572
s = str(input())
t = str(input())
cnt = 0
s_len = len(s)
t_len = len(t)
sa = s_len - t_len
Max = 0
for i in range(len(s) - len(t) + 1):
    ss = s[i:i+len(t)]
    for j in range(len(t)):
        if ss[j] == t[j]:
            cnt += 1
    Max = max(Max,cnt)
    cnt = 0
print(len(t) - Max)


Measured memory_bytes: 9052
#include <iostream>
#include <string>
using namespace std;
#define rp(i, s, e) for(int i = s; i < e; i++)

int main() {
	int n;
	string s;
	cin >> n >> s;
	if(n%2 != 0){
		cout << "No" << endl;
	}
	else if (n%2 == 0 && s.substr(0, s.length()/2) == s.substr(s.length()/2, s.length()/2)){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
/* ex 9_2
   kanon */

#include <stdio.h>
#include <stdlib.h>

//リストのノード（スタック内の各データ）の定義
typedef struct node
{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem)
{
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if (new == NULL)
        exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first)
{
    char elem;
    node *tmp = *first;
    if (tmp == NULL)
        exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}

int main(void)
{
    int ans = 0;
    char input_char, temp;

    //最初のノードの指す先
    node *first = NULL;

    while (1)
    {
        scanf("%c", &input_char);

        if (input_char == '\n')
            break;


        if(first==NULL){
            push(&first, input_char);
            continue;
        }
        //現在のスタックの一番上を取り出す
        temp = pop(&first);

        //もし文字が一致していれば新しい文字を追加
        //一致していなければansに除去した分加える
        if (input_char == temp)
        {
            //スタックにノードを追加
            push(&first, temp);
            push(&first, input_char);

        }else ans+=2;
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 4760
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

char C;

int main() {
	cin >> C;
	cout << char(C + 1) << "\n";
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define For(i,a,b)	for(int i=a;i<=b;i++)
int a,b,c,x,ans=0;
int main(){
	scanf("%d%d%d%d",&a,&b,&c,&x);
	For(i,0,a){
		For(j,0,b){
			For(k,0,c){
				if(i*500+j*100+k*50==x)
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
#define P pair<int,int>
ll n, k,a,b,c,i,j,x,y,z=0;

int main() {
	cin >>n;
	a = 1;
	rep(i, 8) {
		if (n >= a && n < a * 10) {
			b = i+1; break;
		}
		a = a * 10;
	}
	//cout << b << "\n";
	c = b / 2;
	x = 1;
	rep(i, c) {
		z = z + x*9;
		x = x * 100;
		
	}

	if (b % 2 == 1)z = z + n - x + 1;

	
	cout << z;
	return 0;
}


Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    A, B, C, D = li_input()
    L = [0] * 101

    for i in range(101):
        if A <= i < B:
            L[i] += 1

        if C <= i < D:
            L[i] += 1

    ans = 0

    for l in L:
        if l == 2:
            ans += 1

    print(ans)


main()


Measured memory_bytes: 4628
def one_card_poker(A: int, B: int) -> str:
    if A == B:
        return 'Draw'
    if A == 1:
        return 'Alice'
    if B == 1:
        return 'Bob'
    if A > B:
        return 'Alice'
    return 'Bob'


if __name__ == "__main__":
    A, B = map(int, input().split())
    ans = one_card_poker(A, B)
    print(ans)


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

int solve() {
  int N; cin >> N;
  vector<int> A(N), B(N);
  map<int, int> mp;
  rep(i, 0, N) {
    cin >> A[i];
    mp[A[i]] = i;
  }
  sort(A.begin(), A.end());
  rep(i, 0, N) {
    int n = lower_bound(A.begin(), A.end(), A[i]) - A.begin();
    B[mp[A[i]]] = n;
  }
  int ans = 0;
  rep(i, 0, N) {
    if(i%2 && B[i]%2 == 0) ans++;
  }
  return ans;
}

int main() {
  cout << solve() << endl;
  return 0;
}


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

int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      if (X + Y <= S && S - (X + Y) <= K) ans++;
    }
  }
  cout << ans << endl;
return 0;
}

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

typedef long long ll;

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

	ll ans = -1;
	for(ll i = 1; i*i<=m; i++){
		if(m % i != 0) continue;

		ll tmp = m/i;
		if(n * i <= m) ans = max(ans, i);
		if(n * tmp <= m) ans = max(ans, tmp);
	}

	cout << ans << endl;
}

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


int main(){
    int N,K;
    cin >> N >> K;
    string new_S;
    string S;
    cin >> S;

    if (S.substr(K - 1, 1) == "A"){
        new_S = S.substr(0, K -1) + "a" + S.substr(K);
    } else if (S.substr(K - 1, 1) == "B"){
        new_S = S.substr(0, K -1) + "b" + S.substr(K);
    } else if (S.substr(K - 1, 1) == "C"){
        new_S = S.substr(0, K -1) + "c" + S.substr(K);
    }

    cout << new_S << endl; 
    
}

Measured memory_bytes: 256
import bisect

N = int(input())
L = sorted(map(int, input().split(' ')))

ans = 0
for i in range(len(L)):
    for j in range(i + 1, len(L)):
        a = L[i]
        b = L[j]
        ans += max(0, bisect.bisect_right(L, a + b - 1) - (j + 1))

print(ans)


Measured memory_bytes: 9236
//ツ環ョツ青ャ
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int strThat(char str[],int a,int b){
	int j;
	for(j=0;str[j]!='\n';j++){
		if(str[j]==' ')continue;
		str[j]=((str[j]-'a')*a+b)%26+'a';
	}
	if(strstr(str,"that")!=NULL)return 1;
	if(strstr(str,"this")!=NULL)return 1;
	return 0;
}
int nextA(int a){
	int i;
	for(i=1;1;i++){
		if(a+i%2==0 ||a+i%13==0 || a+i%26==0)continue;
		return a+i;
	}
}
int main(){
	int i,j,k,n,a=1;
	int b=0;
	char buf[270];
	char str[270];
	scanf("%d\n",&n);
	for(i=0;i<n;i++,a=1){
		fgets(buf,256,stdin);
		for(b=0,j=0;1;j++,b++){
			strcpy(str,buf);
			if(strThat(str,a,b))break;
			if(b==26){
				a=nextA(a);
				b=-1;
			}
		}
	//	printf("(a:%d b:%d)\n",a,b);
		for(k=0;buf[k]!='\n';k++){
			if(buf[k]==' ')printf("%c",buf[k]);
			else if(buf[k]>='a' && buf[k] <='z')printf("%c",((buf[k]-'a')*a+b)%26+'a');
		}
		printf("\n");
	}
	exit(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int ans;
  for(int i=1;i<=5;++i)
  {
    int x;
    cin>>x;
    if(x==0) 
    {
      ans=i;
    }
  }
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<vector<int>> ab(n,vector<int>(2));
  for(int i=0;i<n;i++)
    cin>>ab[i][0]>>ab[i][1];
  sort(ab.begin(),ab.end(),[](vector<int>i,vector<int>j){return i[1]<j[1];});
  bool f=1;
  int s=0;
  for(int i=0;i<n;i++){
    s+=ab[i][0];
    f=(s>ab[i][1]?0:f);
  }
  cout<<(f?"Yes":"No")<<endl;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

vector<vector<P>> G;
vector<vector<P>> G2;
int dist[1000];
int visit[1000];

void dfs(int node,int cost){
  dist[node] = cost;
  visit[node] = 1;
  for(int i = 0;i < (int)G2[node].size();++i){
    int to = G2[node][i].first;
    int len = G2[node][i].second;
    if(!visit[to])dfs(to,cost+len);
  }
}

void solve(int n){
  G.clear();G.resize(n);
  G2.clear();G2.resize(n);
  vector< int > p;
  vector< int > d;
  p.resize(n);d.resize(n);
  for(int i = 1;i < n;++i){
    cin >> p[i];
    --p[i];
  }
  int sum = 0;
  for(int i = 1;i < n;++i){
    cin >> d[i];
    sum += d[i];
  }
  for(int i = 1;i < n;++i){
    G[i].push_back(P(p[i],d[i]));
    G[p[i]].push_back(P(i,d[i]));
  }
  int ledge = 0;
  int start;
  for(int i = 0;i < n;++i){
    if(G[i].size() == 1){
      ledge += G[i][0].second;
      continue;
    }
    start = i;
    for(int j = 0;j < (int)G[i].size();++j){
      int to = G[i][j].first;
      if(G[to].size() != 1){
	G2[i].push_back(G[i][j]);
      }
    }
  }
  fill(visit,visit+1000,0);
  fill(dist,dist+1000,0);
  dfs(start,0);
  int ndist = dist[0];
  int nnode = 0;
  for(int i = 0;i < n;++i){
    //cout << dist[i] << " ";
    if(i != start && dist[i] > ndist){
      ndist = dist[i];
      nnode = i;
    }
  }
  //cout << endl;
  //cout << nnode << endl;;
  fill(visit,visit+1000,0);
  fill(dist,dist+1000,0);
  dfs(nnode,0);
  int dia = 0;
  for(int i = 0;i < n;++i){
    //cout << dist[i] << " ";
    dia = max(dia,dist[i]);
  }
  //cout << endl;
  /*
  puts("G2");
  for(int i = 0;i < n;++i){
    for(int j = 0;j < (int)G2[i].size();++j){
      printf("(%d,%d) ",G2[i][j].first,G2[i][j].second);
    }
    cout << endl;
  }
  */
  /*
  cout << sum << endl;
  cout << dia << endl;
  cout << ledge << endl;
  */
  cout << sum*3 - dia - ledge*2 << endl;
}

int main(void){
  int n;
  while(cin >> n,n){
    solve(n);
  }
  return 0;
}

Measured memory_bytes: 3200
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func main() {
	defer writer.Flush()
	var S string
	fmt.Fscanf(reader, "%s", &S)
	answer := strings.Replace(S, ","," ", -1)
	fmt.Fprintf(writer, "%s\n", answer)
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <algorithm>

using namespace std;

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		(1000000)
#define Rep(i,n) for(int i = 0; i < (n); i++ )

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define	show(x)	 copy( (x).begin(), (x).end(), ostream_iterator<int>(cout, ",") );	// container<int>を全て表示

using namespace std;

typedef long long ll;

//constant
//--------------------------------------------
const double EPS = 1e-10;

int main()
{
	ll K = 0;

	cin >> K;

	cout << (K / 2) * (K - K / 2) << endl;

	return 0;
}


Measured memory_bytes: 256
N=int(input())
array=[int(x) for x in input().split()]
currentsum=0
counter=0
for i in range(N):
	currentsum+=array[i]
	if i%2==0 and currentsum<=0:
		counter+=abs(1-currentsum)
		currentsum+=(1-currentsum)
	if i%2==1 and currentsum>=0:
		counter+=abs(currentsum+1)
		currentsum-=(currentsum+1)
currentsum1=0
counter1=0
for i in range(N):
	currentsum1+=array[i]
	if i%2==1 and currentsum1<=0:
		counter1+=abs(1-currentsum1)
		currentsum1+=(1-currentsum1)
	if i%2==0 and currentsum1>=0:
		counter1+=abs(currentsum1+1)
		currentsum1-=(currentsum1+1)
		
print(min(counter,counter1))

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

typedef vector<int> vi;
#define ll long long
#define loop(i,n) for(int i=0; i<n; i++)
#define loop1(i,n) for(int i=1; i<=n; i++)
#define loopi(i,s,e) for(int i=s; i < e; i++)
#define loopiRev(i,s,e) for(int i=s; i >= e; i--)
#define PI 3.14159265359
//#define x first
//#define y second
#define point pair<double,double>
#define len(s)   (int)s.length()
#define sz(v)    (int)v.size()
#define all(a)   a.begin(),a.end()
#define clr(x, val)	memset((x), (val), sizeof(x))

void initialize(vector<int> &F, int n){
    F = vector<int> (n+1, 0);

    for(int i=2; i*i  <= n; i++){
        if(F[i] == 0)
            for(int k=i*i; k <=n ; k+= i)
                if(F[k] == 0) F[k] = i;
    }
}

//you don't know math, unless you can do math!
int n,m;
vector<vector<int>> adjList;
int dp[110000];

int solve(int node){
    
    int &ret= dp[node];
    if(ret != -1)
        return ret;

    ret=0;
    for(int i=0; i < adjList[node].size(); i++){
        int child= adjList[node][i];
        ret= max(ret, solve(child) + 1);
    }

    return ret;
}
int main() {
    //freopen("input.txt" , "r" , stdin) ;
    //freopen("output.txt" , "w" , stdout) ;

    cin.tie(0);
    cin.sync_with_stdio(0);

    clr(dp, -1);

    cin>>n>>m;
    adjList= vector<vector<int>> (n);

    int from, to;
    loop(i,m){
        cin>>from>>to;
        adjList[from-1].push_back(to-1);
    }

    int mx=0;
    loop(i, n) mx= max(mx, solve(i));

    cout<<mx;
}


Measured memory_bytes: 7552
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main(){
	int n,m;
	int p;
	int ws=0,as=0;
	int aced[100001]={};
	int waed[100001]={};
	string s;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>p>>s;
		if(s=="WA"){
			waed[p]++;
		}else{
			if(aced[p]!=1){
				aced[p]=1;
				as++;
				ws+=waed[p];
			}
		}
	}
	cout<<as<<" "<<ws<<endl;
	return 0;
}

Measured memory_bytes: 1024
n = int(raw_input())
a = [map(int, raw_input().split()) + [0] for _ in range(2)]
for x in range(n-1,-1,-1):
    a[1][x] += a[1][x+1]
    a[0][x] += max(a[1][x], a[0][x+1])
print a[0][0]


Measured memory_bytes: 2692
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N,H;
	cin >> N >> H;
	vector<int>A(N);
	vector<int>B(N);
	for (int i = 0;i<N;++i) {
		cin >> A[i] >> B[i];
	}
	sort(A.rbegin(),A.rend()); 
	sort(B.rbegin(), B.rend());
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		if (H>0 &&B[i] > A[0]) {
			ans++;
			H -= B[i];
		}
	}
	if (H>0) {
		ans += H / A[0];
		if (0!= H%A[0]) {
			ans++;
		}
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> V(N);
	for (int i = 0; i < N; i++) cin >> V[i];
	int ans = 0;
	vector<int> Minus;
	for (int l = 0; l <= N; l++) {
		if (l > K) break;
		Minus = {};
		int sum = 0;
		for (int i = 0; i < l; i++) {
			if (V[i] >= 0) sum += V[i];
			else Minus.push_back(V[i]);
		}
		for (int r = 0; r <= N - l; r++) {
			if (l + r > K) break;
			if (r > 0) {
				if (V[N - r] > 0) sum += V[N - r];
				else Minus.push_back(V[N - r]);
			}
			int m = 0;
			if (Minus.size() > K - l - r) {
				sort(Minus.begin(), Minus.end(),greater<int>());
				int num = Minus.size() - (K - l - r);
				for (int i = 0; i < num; i++) m += Minus[i];
			}
			ans = max(ans, sum + m);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}
fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}

fn main() {
    let v = read_vec::<i64>();
    println!("{}", v[0] * v[1] / gcd(v[0], v[1]));
}

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()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

public class Main {

    void run() {
        while (true) {
            int N = readInt();
            int M = readInt();
            if (N == 0 && M == 0) break;
            boolean[] virus = new boolean[N];
            Arrays.fill(virus, false);
            virus[0] = true;
            ArrayList<Packet> p = new ArrayList<Packet>();
            for (int i = 0; i < M; i++) {
                int t = readInt();
                int s = readInt() - 1;
                int d = readInt() - 1;
                p.add(new Packet(t, s, d));
            }
            Collections.sort(p);
            for (int i = 0; i < M; i++) {
                if (virus[p.get(i).src]) {
                    virus[p.get(i).dst] = true;
                }
            }
            int ans = 0;
            for (int i = 0; i < N; i++) {
                if (virus[i]) ++ans;
            }
            sysout.println(ans);
        }
    }

    class Packet implements Comparable<Packet> {
        public int time, src, dst;

        public Packet(int time, int src, int dst) {
            this.time = time;
            this.src = src;
            this.dst = dst;
        }

        @Override
        public int compareTo(Packet o) {
            return time - o.time;
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }

    // flush automatically iff you call `println` or `printf` or `format`.
    PrintWriter sysout = new PrintWriter(System.out, true);

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer buffer = new StringTokenizer("");

    String read() {
        if (!buffer.hasMoreTokens()) {
            try {
                buffer = new StringTokenizer(in.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return buffer.nextToken();
    }

    int readInt() {
        return Integer.parseInt(read());
    }

    long readLong() {
        return Long.parseLong(read());
    }

    double readDouble() {
        return Double.parseDouble(read());
    }

    String readLine() {
        buffer = new StringTokenizer("");
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

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

int tanku[5] = {5,7,5,7,7};

int main(){
    int n;
    while(scanf("%d",&n), n != 0){
        string w[40];
        for(int i=0;i<n;++i)cin >> w[i];
        for(int i=0;i<n;++i){
            int k=0, cnt=0, j=i;
            while(k < 5 && j < n){
                cnt += w[j].size();
                if(cnt > tanku[k])break;
                if(cnt == tanku[k]){
                    ++k;
                    cnt = 0;
                }
                ++j;
            }
            if(k == 5){
                printf("%d\n",i+1);
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
vector<string> s(2);
for(int i=0;i<2;i++)cin>>s[i];
ll ans=1;
int cnt=1;
bool ok=true;
for(int i=0;i<n-1;i++){
    if(s[0][i+1]==s[0][i]){cnt++;}
    else{
        if(ans==1){
            if(cnt==1){
                ans*=3;
                ok=false;
            }
            else {ans*=6;ok=true;}
        }
      else   if(cnt==1&&ok){
           ok=false;
        }
      else   if(cnt==2&&!ok){
            ans*=2;
            ok=true;
        }
        else if(cnt==1&&!ok)ans*=2;
        else if(cnt==2&&ok)ans*=3;
        cnt=1;
    }
    ans%=mod;
}
if(ans==1){
            if(cnt==1){
                ans*=3;
                ok=false;
            }
            else {ans*=6;ok=true;}
        }
 else if(cnt==2&&!ok){
            ans*=2;
  }
 else if(cnt==1&&!ok)ans*=2;
  else if(cnt==2&&ok)ans*=3;
    ans%=mod;
cout<<ans<<endl;
}

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

int main() {
    int A,B;
    cin >> A >> B;
    int count = 0;
    int k;
    k = B-A+1;
    for(int i = 0;i < k; i++){
        int a1,a2,a3,a4,a5,C;
        C = A;
        a1 = C % 10;
        C = C / 10;
        a2 = C % 10;
        C = C / 10;
        a3 = C % 10;
        C = C / 10;
        a4 = C % 10;
        C = C / 10;
        a5 = C % 10;
        if(a1 == a5 && a2 == a4){
            count++;
        }
        A++;
    }
    cout << count << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>
#include <cmath>
#include <queue>

#define DEBUG 0

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


int main(){
  ll A,B,Q;
  cin >> A >> B >> Q;

  vector <ll> s(A+2);
  vector <ll> t(B+2);
  vector <ll> x(Q);
  for(ll i = 1; i <= A; ++i)cin >> s[i];
  for(ll i = 1; i <= B; ++i)cin >> t[i];
  for(ll i = 0; i < Q; ++i)cin >> x[i];

  s[0] = -INF;
  t[0] = -INF;

  s[A+1] = INF;
  t[B+1] = INF;

  for(ll q = 0; q < Q; ++q)
  {
      ll res = INF;

      //最初にs(最寄りの前か後ろ)
      for(int i = 0; i < 2; ++i)
      {
          ll first,second;
          ll pos;
          if(i == 0)
          {
            //自分を含めた右側
            pos = upper_bound(s.begin(),s.end(), x[q]) - s.begin() - 1;
          }
          else
          {
            //自分を含めた左側
            pos = lower_bound(s.begin(),s.end(), x[q]) - s.begin();
          }
          first = s[pos];

          for(int j = 0; j < 2; ++j)
          {
            if(j == 0) pos = upper_bound(t.begin(),t.end(), x[q]) - t.begin() - 1;
            else pos = lower_bound(t.begin(),t.end(), x[q]) - t.begin();
              
            second = t[pos];
            res = min(res, abs(x[q] - first) + abs(first - second));
          }
      }

      //最初にtのパターン(最寄りの前か後ろ)
      for(int i = 0; i < 2; ++i)
      {
          ll first,second;
          ll pos;
          if(i == 0)
          {
            //自分を含めた右側
            pos = upper_bound(t.begin(),t.end(), x[q]) - t.begin() - 1;
          }
          else
          {
            //自分を含めた左側
            pos = lower_bound(t.begin(),t.end(), x[q]) - t.begin();
          }
          first = t[pos];

          for(int j = 0; j < 2; ++j)
          {
            if(j == 0) pos = upper_bound(s.begin(),s.end(), x[q]) - s.begin() - 1;
            else pos = lower_bound(s.begin(),s.end(), x[q]) - s.begin();
              
            second = s[pos];
            res = min(res, abs(x[q] - first) + abs(first - second));
          }
      }
      cout << res << endl;
  }

  return 0;    
}



Measured memory_bytes: 3712
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define iter2(c) for(auto it2=c.begin(); it2!=c.end(); it2++)
#define vec(x) vector< x >
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define sqr(x) 1LL*(x)*(x)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define debug
#endif

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int a[100005];

int32_t main()
{
    #ifdef DEBUG
    freopen("B.txt","r",stdin);
    //freopen("","w",stdout);
    #endif
    
    int n;
    cin >> n;
    for0(i,n) {
        read(a[i]);
        a[i]--;
    }
    
    int cnt = 0;
    for (int i=0; i<n; i++) {
        if (a[i] == i) {
            if (i == n-1)
                swap(a[i],a[i-1]);
            else
                swap(a[i],a[i+1]);
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

#define rep(i,N) repv(i,0,N)
#define reps(i,N) repvs(i,0,N)
#define repv(i,a,b) for(int i=a;i<b;i++)
#define repvs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define debug(a) if(isDebugMode) cout<<#a<<"="<<a<<","
#define debug2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b
#define debug3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c
#define debug4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d
#define debugarr(arr,N){if(isDebugMode){ rep(i,N+1)\
	{if(arr[i]==INF)printf("INF ");\
		else cout<<arr[i]<<" ";} cout<<endl;}}
#define debugarr2(arr,N,M){if(isDebugMode) rep(i,N+1){rep(j,M+1)\
	{if(arr[i][j]==INF)printf(" INF");\
		else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define show(a) cout<<a<<endl;

auto chmax =[](int &a,int b){a=max(a,b);};
auto chmin =[](int &a,int b){a=min(a,b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF=100000000;
const int MOD = 100000007;
const int dx[4]={ 0, 1, 0,-1};
const int dy[4]={ 1, 0,-1, 0};

bool isDebugMode=true;
//--------------------------------------//
int n;
int a[100003];

void solve(){
	int ans=0;
	rep(i,100003){
		chmax(ans,a[i]);
	}
	show(ans);
}

int main(){
	cin>>n;
	rep(i,n){
		int s;
		cin>>s;
		a[s]++;
		a[s+1]++;
		a[s+2]++;
	}
	solve();
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int h, w, g[505][505];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> h >> w;
    rep(i, 0, h) rep(j, 0, w) cin >> g[i][j];
    vector<Pii> cur, nx;
    rep(i, 0, h) {
        rep(j, 0, w) {
            if (g[i][j] % 2) {
                if (i + 1 < h) {
                    g[i+1][j]++, g[i][j]--;
                    cur.pb(mp(i+1, j+1)); nx.pb(mp(i+2, j+1));
                }
                else if (j + 1 < w) {
                    g[i][j+1]++, g[i][j]--;
                    cur.pb(mp(i+1, j+1)); nx.pb(mp(i+1, j+2));
                }
            }
        }
    }
    cout << cur.size() << endl;
    rep(i, 0, cur.size()) {
        cout << cur[i].first << " " << cur[i].second << " " << nx[i].first << " " << nx[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 5228
#include<stdio.h>

int n,a[105],i,x=0;

int main(){
	for(i=1;i<=100;i++)a[i]=0;
	while(scanf("%d",&n)!=EOF){
		a[n]++;
		if(a[n]>x)x=a[n];
	}
	for(i=0;i<100;i++)if(a[i]==x)printf("%d\n",i);
	return 0;
}

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

    typedef long long int ll;

    #define MOD (ll)(1e9+7)
    #define endl "\n"
    #define pb push_back
    #define TEST_CASES  ll t;cin>>t;while(t--)
    #define forn(i,a,n) for (int i = a; i < n; ++i)
    #define f first
    #define s second
    #define all(x) x.begin(), x.end()
    
    ll powD(ll x,ll y){
      ll res = 1;
      while(y > 0){
        if(y & 1)
          res = (res*x)%MOD;
        x = (x*x)%MOD;
        y = y>>1;
      }
      return res;
    }


    int main()
    {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n,k;
      cin>>n>>k;
      vector<ll> a(n),pos,neg;
      forn(i,0,n){
        int x;
        cin>>x;
        a[i] = x;
        if(x >= 0)
          pos.push_back(x);
        else
          neg.push_back(x);
      }
      sort(all(a));
      sort(all(pos));
      sort(all(neg));
      if(pos.size() == 0 || k == n){
        if(k%2){
          ll maxm = 1;
          forn(i,0,k){
            maxm *= a[n-i-1];
            maxm = (maxm%MOD+MOD)%MOD;
          }
          cout<<maxm<<endl;
        }
        else{
          ll maxm = 1;
          forn(i,0,k){
            maxm *= a[i];
            maxm = (maxm%MOD+MOD)%MOD;
          }
          cout<<maxm<<endl;
        }
        return 0;
      }
      else if(neg.size() == 0){
        ll maxm = 1;
        forn(i,0,k){
          maxm *= a[n-i-1];
          maxm = (maxm%MOD+MOD)%MOD;
        }
        cout<<maxm<<endl;
        return 0;
      }
      stack<ll> poss,negs,ansp,ansn;
      forn(i,0,neg.size()){
        negs.push(neg[neg.size()-i-1]);
      }
      forn(i,0,pos.size()){
        poss.push(pos[i]);
      }
      forn(i,0,k){
        if(poss.empty()){
          ansn.push(negs.top());
          negs.pop();
        }
        else if(negs.empty()){
          ansp.push(poss.top());
          poss.pop();
        }
        else if(abs(poss.top()) > abs(negs.top())){
          ansp.push(poss.top());
          poss.pop();
        }
        else{
          ansn.push(negs.top());
          negs.pop();
        }
      }

      if(ansn.size()%2){
        if(ansp.empty()){
          ansn.pop();
          ansp.push(poss.top());
          poss.pop();
        }
        else{
          ll candip = -1,candin = -1;
          if(!poss.empty()){
            candip = poss.top()*ansp.top();
          }
          if(!negs.empty()){
            candin = negs.top()*ansn.top();
          }
          if(candip > candin){
            ansp.push(poss.top());
            ansn.pop();
          }
          else{
            ansn.push(negs.top());
            ansp.pop();
          }
        }
      }
      ll maxm = 1;
      while(!ansn.empty()){
        maxm *= ansn.top();
        maxm = (maxm%MOD+MOD)%MOD;
        ansn.pop();
      }  
      while(!ansp.empty()){
        maxm *= ansp.top();
        maxm = (maxm%MOD+MOD)%MOD;
        ansp.pop();
      }        
      cout<<maxm<<endl;
    } 
    

Measured memory_bytes: 8192
#include "bits/stdc++.h"
using namespace std;

const long long MXN = 100005;
vector<long long> adj[MXN];
long long MOD = 1000 * 1000 * 1000 + 7;
long long dp[MXN][2];

long long solve(long long node, long long last, long long colour) {
	if (dp[node][colour] != -1) return dp[node][colour];
	if (colour == 1) {
		// cant colour adj
		long long ways = 1;
		for (int i=0; i<adj[node].size(); i++) {
			int ot = adj[node][i];
			if (ot == last) continue;
			ways *= solve(ot, node, 0);
			ways = ways % MOD;
		}
		return dp[node][colour] = ways;
	}
	else {
		long long ways = 1;
		for (int i=0; i<adj[node].size(); i++) {
			int ot = adj[node][i];
			if (ot == last) continue;
			long long how = (solve(ot, node, 0) + solve(ot, node, 1)) % MOD;
			ways *= how;
			ways = ways % MOD;
		}
		return dp[node][colour] = ways;
	}
}

int main() {
	
	for (int i=0; i<MXN; i++) dp[i][0] = dp[i][1] = -1;
	
	int n;
	cin >> n;
	for (int i=0; i<n-1; i++) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	cout << (solve(1, -1, 0) + solve(1, -1, 1)) % MOD << endl;
	
}



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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
	

ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b%2 == 1) tmp = mulMod(tmp,a);
	return tmp;
}

ll GCD(ll a, ll b){
	if(a > b) return GCD(b,a);
	if(a == 0) return b;
	return GCD(b%a,a);
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

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

const int N = 1e5;

int n,m;
ll arr[N + 5];
priority_queue < pair < ll , pii > > pq;
ll pw[35];
ll solve(){
	ll ret = 0;
	while(m-- && !pq.empty()){
		int id = pq.top().SE.FI;
		int us = pq.top().SE.SE;
		pq.pop();
		if(arr[id] / pw[us+1] != 0){
			pq.push(MP(arr[id]/pw[us+1], MP(id, us+1)));
		}
		
	}
	while(!pq.empty()){
		int id = pq.top().SE.FI;
		int v = pq.top().FI;
		pq.pop();
		ret += (ll)v;
	}
	return ret;
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	pw[0] = 1;
	REP(i,1,33) pw[i] = pw[i-1] * (ll)2;
	
	cin >> n >> m;
	REP(i,1,n){
		cin >> arr[i];
		pq.push(MP(arr[i], MP(i,0)));
	}
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 2932
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int count_same(string S, int sep) {
  string X, Y;
  set<int> sx, sy, result;
  X = S.substr(0, sep);
  Y = S.substr(sep);
  sx = set<int>(X.begin(), X.end());
  sy = set<int>(Y.begin(), Y.end());
  set_intersection(sx.begin(), sx.end(), sy.begin(), sy.end(), inserter(result, result.end()));
  return result.size();
}

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int ans = 0;
  rep1(i, N - 1) {
    ans = max(ans, count_same(S, i));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  int c = 1;
  for (int i = 0; i < a; i++) {
    if (c < b) c *= 2;
    else c += b;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 


int main(){

	int res=1e8;

	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];

	for(int b=-200;b<=200;b++){
		int cost=0;
		for(int i=0;i<n;i++){
			cost+=(a[i]-b)*(a[i]-b);
		}
		res=min(res,cost);
	}
	cout<<res<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define x() real()
#define y() imag()

typedef complex<double> point; // 2D point only
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldob;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef pair<ii, ll> ii_i;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<iii> viii;

// OST
template <typename T>
using ordered_set = __gnu_pbds::tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// from: https://codeforces.com/blog/entry/62393
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

const int INF = ~(1<<31);
const ll LINF = (1LL << 60);
const long double EPS = 1e-9;
const long double PI = acos(-1);

const int N = 100001;
const int NN = 1001;
const int MOD = 1e9+7;
const int IMAX = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int n, m, vis[N]; 
vector<int> adj[N];

int main () {
	ios_base::sync_with_stdio(false); cin.tie(0);
	// cout.precision(3); cout << fixed;
	
	memset(vis, -1, sizeof vis);
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int u, v; cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	vis[1] = 0;
	queue<int> bfs;
	bfs.push(1);
	while (not bfs.empty()) {
		int u = bfs.front(); bfs.pop();
		for (int v : adj[u]) {
			if (vis[v] == -1) {
				vis[v] = u;
				bfs.push(v);
			}
		}
	}

	if (*min_element(vis+1,vis+n+1) == -1) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
		for (int i = 2; i <= n; ++i)
			cout << vis[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 10600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
signed main(){
  int N,ans=0;
  cin>>N;
  rep(i,0,N){
    int X,count=0;
    cin>>X;
    while(1){
      if(X%2==1){
        ans+=count;
        break;
      }
      count++;
      X/=2;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long t = 1;
    long a = 1;
    for(int i = 0; i < n; i++){
      long tt = sc.nextLong();
      long aa = sc.nextLong();
      long max = Math.max(gaus(t, tt), gaus(a, aa));
      t = max * tt;
      a = max * aa;
    }
    System.out.println(a + t);
  }
  
  public static long gaus(long t, long tt){
    if(t % tt == 0){
      return t / tt;
    }
    return t / tt + 1;
  }
}

Measured memory_bytes: 23892
/* 
 * Project: AtCoder Beginners Contest 158 C - Tax Increase
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/03/07
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int a, b;

void solve() {

    bool condition = false;

    for (int i=1;i<=1250;i++) {
        if ((int)(i * 0.08) == a && (int)(i * 0.1) == b) {
            cout << i << endl;
            condition = true;
            break;
        }
    }
    if (!condition)
        cout << -1 << endl;

    
}

int main() {

    cin >> a >> b;

    solve();

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {
	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Stack<Integer> stack = new Stack<Integer>();
		
		while(true){
			String tmp = br.readLine();
			
			if(tmp == null){
				break;
			}
			
			int n = Integer.parseInt(tmp);
			
			if(n != 0){
				stack.push(n);
			}
			if(n == 0){
				System.out.println(stack.pop());
			}
		}
	}
}

Measured memory_bytes: 24276
n, x, y = map(int, input().split())
A = [0 for i in range(n)]
for i in range(1, n):
    for j in range(i+1, n+1):
        t = min(j-i, abs(x-i) + abs(y-j) + 1)
        A[t] += 1
print(*A[1:], sep="\n")

Measured memory_bytes: 3444
public class Main {
	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		//StringBuilder sb = new StringBuilder();

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

		int mini = a[0];
		for (int i:a) { mini = Math.min(mini, i);}

		int maxi = a[0];
		for (int i:a) { maxi = Math.max(maxi, i);}

		long goukei = 0;
		for (int i:a) { goukei = goukei + i;}

		System.out.println(mini + " " + maxi + " " + goukei);
	}
}

Measured memory_bytes: 42720
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
using namespace std;
int main() {
	long long int ans = 1,num = 1;
	int n;
	int a;
	cin >> n;
	for (int i = 0; i < n;i++) {
		cin >> a;
		if (a%2 == 0) {
			num *= 2;
		}
		ans *= 3;
	}
	cout << ans - num << endl;
	return 0;
}

Measured memory_bytes: 256