akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <iostream>
//#include <string>
//#include <sstream>
//#include <vector>
//#include <algorithm>
//#include <map>
//#include <set>
//#include <math.h>
//#include <unordered_map>
//#include <queue>
//#include <stack>
//#include <iomanip>

using namespace std;

#define PI 3.141592653589793238462643383279502884
#define Max 100005
#define ll long long
#define mod 2
#define EPS 1E-9

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n,m;
	cin >> n >> m;
	int x,y;
	vector< pair<int,int> >points,check;
	for(int i=0;i<n;i++)
    {
        cin >> x >> y;
        points.push_back(make_pair(x,y));
    }
    for(int i=0;i<m;i++)
    {
        cin >> x >> y;
        check.push_back(make_pair(x,y));
    }
    vector<int>ans;
    int mn,res,index;
    for(int i=0;i<points.size();i++)
    {
        mn=INT_MAX;
        for(int j=0;j<check.size();j++)
        {

                res=abs(points[i].first-check[j].first)+abs(points[i].second-check[j].second);
                if(res<mn)
                {
                    mn=res;
                    index=j+1;
                }

        }
        ans.push_back(index);
    }
    for(int i=0;i<ans.size();i++)
        cout << ans[i] << endl;




	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define U [1<<17]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)d=I->first,!Z[d]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}L M(L i){return i?B[i]+M(i^i&-i):0;}L S(L a,L i){for(a=M(i++G i);i<1e5;i+=i&-i)B[i]+=a;}L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}

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

int main() {
	string S;
	stack<char> a;
	int ans = 0;

	cin >> S;

	int half;
	if (S.size() % 2 != 0) {
		half = (S.size() - 1) / 2;
	}
	else {
		half = S.size() / 2;
	}

	for (int i = 0; i < half; i++) {
		a.push(S.at(i));
	}

	if (S.size() % 2 != 0) {
		half++;
	}
	for (int i = half; i < S.size(); i++) {
		if (a.top() != S.at(i)) {
			ans++;
		}
		a.pop();
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map<pair<string, string>, int> g;
int n;
string s;
long long z;
int main() {
	cin >> n;
	cin >> s;
	for (int i = 0; i < 1 << n; i++) {
		string a, b;
		for (int j = 0; j < n; j++) {
			if (i >> j & 1) {
				a += s[j];
			} else {
				b += s[j];
			}
		}
		g[{a, b}]++;
	}
	for (int i = 0; i < 1 << n; i++) {
		string a, b;
		for (int j = 0; j < n; j++) {
			if (i >> j & 1) {
				a += s[2 * n - 1 - j];
			} else {
				b += s[2 * n - 1 - j];
			}
		}
		z += g[{a, b}];
	}
	cout << z << endl;
	return 0;
}

Measured memory_bytes: 91904
import bisect,copy,heapq,string
from collections import *
from math import *
from itertools import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
k = INT()
ans = 0
cnt = 1
s = s + s

for i in range(1, len(s)):
    if s[i] == s[i-1]:
        cnt += 1
    else:
        ans += cnt // 2
        cnt = 1
ans += cnt // 2

if ans % 2 == 0 or ans == len(s)//2:
    print(ans*k//2)
else:
    print(ans//2+(ans+1)//2*(k-1))

Measured memory_bytes: 10028
use proconio::input;

fn main() {
    input!(a: [u64]);

    let ans = a
        .iter()
        .scan(0, |p, &a| {
            let ret = Some(a.max(*p) - a);
            *p = a.max(*p);
            ret
        })
        .sum::<u64>();

    println!("{}", ans);
}


Measured memory_bytes: 5696
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	cout << a[0]*a[1]/2 << endl; 
 	return 0;
 }

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

int main() {
  int N;
  cin >> N;
  int A[2][100];
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < N; ++j) {
      cin >> A[i][j];
    }
  }
  int max_num = 0;
  for (int i = 0; i < N; ++i) {
    int total = 0;
    for (int j = 0; j <= i; ++j) {
      total += A[0][j];
    }
    for (int k = i; k < N; ++k) {
      total += A[1][k];
    }
    if (total > max_num) {
      max_num = total;
    }
  }
  cout << max_num << "\n";
  return 0;
}
    
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main()
{
    int n;
    cin >> n;
    set<string> s;
    string w, wp;
    rep(i,n) {
        cin >> w;
        if (i == 0) {
            s.insert(w);
            wp = w;
            continue;
        }

        if (w[0] != wp[wp.length()-1]) {
            cout << "No" << endl;
            return 0;
        }
        auto it = s.find(w);
        if (it != s.end()) {
            cout << "No" << endl;
            return 0;
        } else {
            s.insert(w);
        }
        wp = w;
    }
    cout << "Yes" << endl;
    return 0;
}


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

string S[30][30];
int main(){
  int H, W;
  cin >> H >> W;
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      cin >> S[i][j];
      if(S[i][j] == "snuke"){
        cout << (char)('A' + j) << i + 1 << endl;
      }
    }
  }
}

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

int used[105];
int main(){
    int n,k;
    cin>>n>>k;
    rep(i,k){
        int d;
        cin>>d;
        rep(j,d){
            int tmp; cin>>tmp;
            used[tmp-1]+=1;
        }
    }
    int ans=0;
    rep(i,n){
        if(used[i]==0) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

struct xyh
{
    int x, y, h;
};

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

    vector<xyh> v(N);
    for (int i = 0; i < N; i++)
    {
        cin >> v[i].x >> v[i].y >> v[i].h;
    }
    sort(v.begin(), v.end(), [](const xyh &a, const xyh &b) { return a.h > b.h; });

    // for (int i = 0; i < v.size(); i++)
    // {
    //     cout << v[i].x << ", " << v[i].y << ", " << v[i].h << endl;
    // }

    for (int px = 0; px <= 100; px++)
    {
        for (int py = 0; py <= 100; py++)
        {
            bool flag = true;
            int H;
            for (int i = 0; i < N; i++)
            {
                int dx = abs(px - v[i].x);
                int dy = abs(py - v[i].y);
                int d = dx + dy;

                if (i == 0)
                {
                    H = d + v[i].h;
                }
                else if (v[i].h > 0)
                {
                    if (H != v[i].h + d)
                    {
                        flag = false;
                        break;
                    }
                }
                else
                {
                    if (H > d)
                    {
                        flag = false;
                        break;
                    }
                }
            }

            if (flag)
            {
                printf("%d %d %d\n", px, py, H);
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define debug(x) cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

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

  return 0;
}


Measured memory_bytes: 256
def solve():
  n = int(input())
  query = []
  for i in range(n):
    tmp = input()
    s,p = tmp.split()
    p = str(90000000-int(p))
    s = s+p
    query.append((s,i+1))
  query.sort()
            
    
  for i in range(n):
    print(query[i][1])
solve()

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

int main(){
    int N,C;cin>>N>>C;
    vector<vector<int> >D(C,vector<int>(C,0));
    for(int i=0;i<C;i++)for (int j=0;j<C;j++)cin>>D[i][j];
    vector<vector<int> >fi(N,vector<int>(N,0));
    for(int i=0;i<N;i++)for (int j=0;j<N;j++)cin>>fi[i][j],fi[i][j]--;

    vector<vector<int> >cost(3,vector<int>(C,0));
    for(int c=0;c<C;++c){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                cost[(i+j)%3][c]+=D[fi[i][j]][c];
            }
        }
    }
    
    int res=1<<30;
    int c[3];
    for(c[0]=0;c[0]<C;c[0]++){
        for(c[1]=0;c[1]<C;c[1]++){
            if(c[1]==c[0]) continue;
            for(c[2]=0;c[2]<C;c[2]++){
                if(c[2]==c[0]||c[2]==c[1])continue;
                    int tmp=0;
                    for (int it=0;it<3;it++)tmp+=cost[it][c[it]];
                    res=min(res,tmp);
                
            }
        }
    }
    cout<<res<<endl;
}

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

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;
    ll lcm=c/__gcd(c,d)*d;
    ll ans=b-(b/c+b/d)+b/lcm+a/c+a/d-a/lcm-a;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<chrono>
#define ll long long
#define mod 1000000007
#define endl '\n'
#define tab ' '
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pi 3.141592653589793238460
#define F(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define RF(i,a,b) for(int i=(int)a;i>=(int)b;i--)
// a.exe < "C:/Users/Piyush Naithani/Desktop/Codechef/Testfiles/icpc2.txt"
using namespace std;

void solve()
{
    int n; 
    cin >> n;

    string s, t;
    cin >> s >> t;

    int m = n;

    
    int i = 0, j = 0;

    while(i<n and j<m)
    {
        if(i < n)
            cout << s[i++];

        if(j < m)
            cout << t[j++];
    }

    if(i < n)
        F(x,i,n-1) cout << s[x];

    if(j < m)
        F(x, j, m-1) cout << t[x];
}


int main(){
    fast;
    #ifndef ONLINE_JUDGE
      // freopen("C:\Users\Piyush Naithani\Desktop\Codechef\Testfiles\icpc2.txt","r",stdin);
    
    // freopen("file name","w",stdout);
    #endif

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <numeric>
#include <queue>
#include <set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  ll n;
  cin >> n;
  vector<pair<ll, ll>> job(n);
  REP(i, n)
  {
    ll a, b;
    cin >> a >> b;
    job[i] = {b, a};
  }
  sort(ALL(job));
  ll ji = 0;
  bool flag = true;
  REP(i, n)
  {
    if (ji + job[i].second <= job[i].first)
    {
      ji += job[i].second;
    }
    else
    {
      flag = false;
      break;
    }
  }
  if (flag)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}


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

int main() {
  while(true){
    int n;
    cin >> n;
    if(n == 0) return 0;
    double a = 0;
    double sum = 0;
    vector<int>data(n);
    for(int i = 0;i < n;i++){
      cin >> data[i];
      sum += data[i];
    }
    sum /= n;
    for(int i = 0;i < n;i++){
      a += (data[i]-sum)*(data[i]-sum)/n;
    }
    std::cout << std::fixed;
    std::cout << std::setprecision(6) << sqrt(a) << endl;;
  }
}



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

#define REP(i,k,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int func(vector<int> v, int k) {
	stringstream ss;
	rep(i, k) {
		ss << v[i];
	}

	int ret;
	ss >> ret;

	return ret;
}

int main() {
	int n;
	while(cin >> n) {
		if(n == 0) break;

		int k;
		cin >> k;
		
		vector<int> v(n);
		rep(i, n) cin >> v[i];

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

		set<int> ans;
		set<vector<int> > st;


		do {
			vector<int> ret(k);
			rep(i, k)  ret[i] = v[i];

			if(st.find(ret) == st.end()) {
				st.insert(ret);
				ans.insert(func(v, k));
			} else continue;
		}while(next_permutation(v.begin(), v.end()));

		cout << ans.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 1680
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <stack>
using namespace std;
#define ll int64_t
const long mod = 1e9 + 7;


const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}




int main() {

  long a,b;
  cin >> a >>b;




  long ans = 0;

  ans += max(a,b);

  long c,d;
  c = min(a,b);
  d = max(a,b)-1;

  ans += max(c,d);

  cout << ans <<endl;

}




















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x,n;
    cin >> x >> n;
    vector <int> p(n);
    for(int i = 0; i<n; i++){
        cin >> p[i];
    }
    int minDiff = -1;
    int ans = -1;
    for(int i = 0; i <= 200; i++){
        bool isFound = false;
        for(int j = 0; j<p.size(); j++){
            if(p[j]==i){
                isFound = true;
                break;
            }
        }
        if(isFound==false){
            if(minDiff==-1){
                minDiff=abs(x-i);
                ans = i;
            }else if(minDiff > abs(x-i)){
                minDiff=abs(x-i);
                ans = i;
            }else{

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

Measured memory_bytes: 3624
s=input()
n=len(s)
pool=[]
blue=[0]*n
final=[0]*n
for i in range(n-1):
    if s[i]=='R' and s[i+1]=='L':
        pool.append(i)
        pool.append(i+1)
        blue[i]=1
        blue[i+1]=1
        final[i]+=1
        final[i+1]+=1
counter=-1
for i in range(n):
    if blue[i]==1:
        counter+=1
    else:
        if s[i]=='L':
            index=pool[counter]
            if (i-index)%2==0:
                final[index]+=1
            else:
                final[index-1]+=1
        else:
            index=pool[counter+1]
            if (index-i)%2==0:
                final[index]+=1
            else:
                final[index+1]+=1
f=[str(i) for i in final]
print(' '.join(f)) 


Measured memory_bytes: 15612
import sys


def solve(inp):
    (N, K) = map(int, inp.readline().split(' '))
    A = map(int, inp.readline().split(' '))

    nums = {}
    num_kinds = 0
    for a in A:
        if a not in nums:
            num_kinds += 1
            nums[a] = 0
        nums[a] += 1

    values = sorted(nums.values())
    d = max(0, len(values) - K)
    s = sum(values[:d])

    return str(s)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41304
package main

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

func main() {
	N, D := ReadInt(), ReadInt()
	fmt.Println((N + 2*D) / (2*D + 1))
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 1e9 + 7;
const ll maxn = 200005;

int main(){  
	cin.tie(0);
    ios::sync_with_stdio(false);
	double a;
	scanf("%lf",&a);
	
	double ans=a*a*a/27.0;
	printf("%.12lf",ans);
    return 0;
}




Measured memory_bytes: 256
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  //入力値NとKを数値化して確保
  var N = Number.parseInt(inputStr[0]);
  var K = Number.parseInt(inputStr[1]);
  //入力値を配列に入れる
  var S = input[1];
  //入力値S_arrを、0と1の塊別に纏めて、配列A_arrに入れる。0はマイナス化する。
  var A_arr = [];
  var cnt = 1;
  var flg = 0;
  for( var i=0; i < N-1; i++){
    if( S.substr(i,1) !== S.substr(i+1,1) ){
      if(S.substr(i,1)==="0"){
        A_arr.push(cnt * -1);
        flg = 1;
      } else {
        A_arr.push(cnt);
      }
      cnt = 1;
    } else {
      cnt += 1;
    }
  }
  if(S.substr(i,1)==="0"){
    A_arr.push(cnt * -1);
    flg = 1;
  } else {
    A_arr.push(cnt);
  }
  
  //ループカウンタiとjを定義し、iとjの間にマイナス値がK個含んだ状態での尺取法を行う。
  var m_cnt = 0;
  var tmp = 0;
  var max = 0;
  var j=0;
  var lsat_j = -1;
  for( var i=0 ; i < A_arr.length ; i++){
    //マイナス値をK個含むか…で累積和。右端(j)の振る舞い制御に前回値を持つ。
    while( m_cnt < K && j < A_arr.length ){
      if(lsat_j !== j ){
        tmp += Math.abs(A_arr[j]);
        lsat_j = j;
      }
      if( A_arr[j] < 0 ){
        m_cnt +=1;
      }
      j++;
    }
    if(lsat_j !== j ){
      lsat_j = j;
      if( m_cnt >= K && j < A_arr.length ){
        tmp += Math.abs(A_arr[j]);
      }
    }
    //最大値比較
    max = Math.max(max,tmp);
    //左端(i)の移動。マイナス値の消しこみ
    if( A_arr[i] < 0 ){
      m_cnt -= 1;
    }
    tmp -= Math.abs(A_arr[i]);
  }
  console.log(max);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9908
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#define i64 long long
using namespace std;

const int mo = 1e9 + 7;
i64 n;
map <i64, int> mp;

int calc(i64 n) {
	if (mp.count(n)) return mp[n];
	return mp[n] = ((calc(n >> 1) + calc((n - 1) >> 1)) % mo + calc((n - 2) >> 1)) % mo;
}

int main() {
	scanf("%lld", &n);
	mp[0] = 1;
	mp[1] = 2;
	printf("%d", calc(n));
	return 0;
}


Measured memory_bytes: 256
gets
a = gets.split.map(&:to_i)
puts a.join(' ')
(1..(a.size - 1)).each do |i|
  tmp = a[i]
  j = i - 1
  while j >= 0 && a[j] > tmp
    a[j + 1] = a[j]
    j -= 1
  end
  a[j + 1] = tmp
  puts a.join(' ')
end

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


int main() {
  int N; cin >> N;
  vector<int> A(N);
  for(int& a:A) cin >> a;

  map<int, int>M;
  int ans = 0;

  for(int i=0; i<N; i++){
    if(M.find(A[i]) == M.end()){
      M.insert(make_pair(A[i], 1));
    }else{
      M[A[i]]++;
    }
  }

  for(auto i=M.begin(); i!=M.end(); i++){
    if(i->first > i->second) ans += i->second;
    else if(i->first < i->second) ans += i->second - i->first;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;
 
int n,k,c;
string s;
vector<int> L,R;
 
int main() {
    ios::sync_with_stdio(false);
    cin>>n>>k>>c>>s;
 
    for(int i=0;i<s.size();++i){
        if(s[i]=='o') L.pb(i),i+=c;
        if(L.size()==k) break;
    }
    for(int i=s.size()-1;i>=0;--i){
        if(s[i]=='o') R.pb(i),i-=c;
        if(R.size()==k) break;
    }
 
    for(int i=0;i<k;++i){
        if(L[i]==R[k-i-1])
            printf("%d\n",L[i]+1);
    }
 
    return 0;
}

Measured memory_bytes: 3468
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

map<ll, ll> m;
int main() {
	ll n; cin >> n;
	repe(i, 1, n) {
		ll a; cin >> a;
		m[a] = i;
	}

	for (map<ll, ll>::iterator it = m.begin(); it != m.end(); it++) {
		if (it != m.begin()) {
			cout << " " << it->second;
		}
		else {
			cout << it->second;
		}
	}
	cout << endl;

	return 0;
}

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

int main() {
    string S; cin>>S;
    ll ans=0;
    for(int bit=0;bit<(1<<S.size()-1);bit++){
        ll now=0;
        for(int i=0;i<S.size();i++){
            now=now*10+S[i]-'0';
            if(bit & 1<<i){
                ans+=now;
                now=0;
            }
        }
        ans+=now;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, ans = 0;
	cin >> nn;
	vector<int64> aa(nn + 1), memo(nn + 1, 0);
	for(int64 ii = 1;ii <= nn;ii++)
	{
		cin >> aa[ii];
		if(ii - aa[ii] > 0)
		{
			memo[ii - aa[ii]]++;
		}
	}
	for(int64 ii = 1;ii <= nn;ii++)
	{
		if(aa[ii] + ii <= nn)
		{
			ans += memo[aa[ii] + ii];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6332
#include<iostream>
using namespace std;
int main(){
  int x,y,esc;
  while(1){
    cin >> x >> y;
    if(x==0&&y==0){break;}
    if(x>y){
      esc = x;
      x = y;
      y = esc;
    }
    cout << x << " " << y <<endl;
  }
}



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

#define all(x) (x).begin(),(x).end()
#define init() \
  ios::sync_with_stdio(false); \
  cin.tie(0)

using namespace std;

using ll = long long;
using ull = unsigned long long;

template<typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) {
  return a == 0 ? b
    : b == 0 ? a
    : gcd(b, a % b);
}

template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) {
  return a * b / gcd(a, b);
}

const string table[4] = {"dream", "dreamer", "erase", "eraser"};

bool delete_end(string& s, const string& t) {
  if (s.size() < t.size()) {
    return false;
  }

  auto srb = s.rbegin();
  auto trb = t.rbegin();
  auto tre = t.rend();
  while (trb != tre) {
    if (*srb != *trb) {
      return false;
    }
    ++srb;
    ++trb;
  }
  s.erase(s.end() - t.size(), s.end());

  return true;
}

int main() {
  init();

  string s;
  cin >> s;

  while (!s.empty()) {
    bool ok = false;
    for (int i = 0; i < 4; i++){
      if (delete_end(s, table[i])) {
        ok = true;
        break;
      }
    }
    if (!ok) {
      cout << "NO" << '\n';
      return 0;
    }
  }

  cout << "YES" << '\n';

  return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    ll N, M; cin >> N >> M;
    vector<pll> P(N); REP(i, N) cin >> P[i].first >> P[i].second;
    sort(ALL(P));
    ll ans = 0;
    REP(i, N)
    {
        if(M <= P[i].second)
        {
            ans += M*P[i].first;
            cout << ans << endl;
            return;
        }
        ans += P[i].first*P[i].second;
        M -= P[i].second;
    }
} 
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 1792
//
// Created by yamunaku on 2019/09/15.
//

#include <bits/stdc++.h>

using namespace std;

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

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

int main(){
    int n;
    cin >> n;
    vl a(n);
    ll x=0;
    rep(i,n) cin >> a[i], x^=a[i];
    ll aa=x^((1ll<<61)-1);
    rep(i,n) a[i]&=aa;
    int r=0;
    per(i,61){
        bool ok=false;
        repl(j,r,n){
            if(a[j]&(1ll<<i)){
                swap(a[j],a[r]);
                ok=true;
                break;
            }
        }
        if(ok){
            rep(j,n){
                if(j!=r) if(a[j]&(1ll<<i)){
                    a[j]^=a[r];
                }
            }
            r++;
        }
    }
    ll ans=0;
    rep(i,n){
        ans^=a[i];
    }
    cout << (ans<<1)+x << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  int n;
  cin >> n;
  if(n%2==1) cout << n/2 + 1 << endl;
  else cout << n/2 << endl;
}


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

typedef long long ll;

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

  int n;
  cin >> n;

  vector<int> b(n-1);
  for (int i = 0; i < n - 1; i++){
    cin >> b.at(i);
  }

  vector<int> a(n);
  a.at(0) = b.at(0);
  a.at(n-1) = b.at(n-2);
  for (int i = 1; i < n-1; i++){
    a.at(i) = min(b.at(i-1), b.at(i));
  }

  int sum = std::accumulate(a.begin(), a.end(), 0);
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
		public static void main(String[] args){
    		Scanner sc = new Scanner(System.in);
        int a[] =new int [3];
				a[0] = sc.nextInt();
				a[1] = sc.nextInt();
				a[2] = sc.nextInt();
				Arrays.sort(a);
				if((a[2]-a[0]+a[2]-a[1]) % 2 ==0){
						System.out.println((a[2] - a[0] + a[2] - a[1]) / 2);
				}
				else{
						a[2] += 1;
						a[1] += 1;
						System.out.println((a[2] - a[0] + a[2] - a[1]) / 2 + 1);
				}
		}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
vector<string>v;
int main(){
    int n,l;cin>>n>>l;
    int tc=n;
    while(tc--){
        string s;cin>>s;
        v.push_back(s);
    }
    sort(v.begin(),v.end());
    for(auto &tp: v)
        cout<<tp;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#define MM 2100000000
using namespace std;
int main(void)
{
	int n,i,j,x,h[100000],dp[100001],k,a;
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++)	scanf("%d",&h[i]);
	for(i=0;i<=n;i++)	dp[i]=MM;
	dp[0]=0;
	for(i=0;i<n-1;i++)	{
		for(j=1;j<=k;j++)	{
			a=i+j;
			if(a<n)	{
				x=h[a]-h[i];
				if(x<0)	x=-x;
				dp[a]=min(dp[i]+x,dp[a]);
			}
		}
	}
	printf("%d\n",dp[n-1]);
	return 0;
}

Measured memory_bytes: 896
n = int(input())

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

count = 1
if 0 in a:
    print(0)
else:

    for i in a:
        count *= i
        if count > 10 ** 18:
            print(-1)
            break
    if count <= 10 ** 18:
        print(count)

Measured memory_bytes: 21580
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define setpre(a) cout.precision(a),cout<<fixed;
#define ALL(a) a.begin(),a.end()
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

ll n,a,b;
const ll MOD=1000000007;

ll mypow(ll a,ll b){
	ll re=1;
	while(b){
		if(b&1){
			re=re*a%MOD;
		}
		b>>=1,a=a*a%MOD;
	}
	return re;
}

ll rev(ll a){
	return mypow(a,MOD-2);
}

ll C(ll a,ll b){
	ll re=1;
	for(ll i=a,j=0;j<b;j++,i--){
		re=re*i%MOD;
	}
	for(ll i=1;i<=b;i++){
		re=re*rev(i)%MOD;
	}
	return re;
}

ll solve(ll a){
	return C(n,a);
}

int main(){Tie
	cin>>n>>a>>b;
	ll ans=mypow(2,n);
	ans=(ans-1+MOD)%MOD;
	ans=((ans-solve(a))%MOD+MOD)%MOD;
	ans=((ans-solve(b))%MOD+MOD)%MOD;
	cout<<ans<<'\n';
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int S(int n) {
  int res = 0;
  while (n > 0) {
    res += n % 10;
    n /= 10;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  if (n % S(n)) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)
struct T{
	ll y,x,id;
};
struct edge{
	ll to,cost;
};
struct A{
	ll cost,id,dir;
	bool operator<(const A& an)const{
		return cost<an.cost;
	}
	bool operator>(const A& an)const{
		return cost>an.cost;
	}
};
vector<edge> G[200002][2];
ll H,W,N;
ll d[200002][2];//0?????? 1??±?\?
T sw[200001];
const ll INF = 0xffffffffffffff;
bool start;
int main()
{
	cin>>W>>H>>N;
	rep1(i,N){
		cin>>sw[i].x>>sw[i].y;
		if(sw[i].x==W&&sw[i].y==H){
			N--;
			i--;
			continue;
		}
		if(sw[i].x==1&&sw[i].y==1) {
			start=1;
			N--;
			i--;
			continue;
		}
		sw[i].y--;
		sw[i].x--;
		sw[i].id=i;
	}
	sort(sw+1,sw+N+1,[](T a,T b){
			return a.x==b.x?a.y<b.y:a.x<b.x;
	});
	if(sw[N].x==W-1){
		G[sw[N].id][0].pb(edge{N+1,H-1-sw[N].y});
	}
	if(sw[1].x==0){
		G[0][0].pb(edge{sw[1].id,sw[1].y});
	}
	rep1(i,N-1){
		if(sw[i].x==sw[i+1].x){
			G[sw[i].id][0].pb(edge{sw[i+1].id,sw[i+1].y-sw[i].y});
			G[sw[i+1].id][0].pb(edge{sw[i].id,sw[i+1].y-sw[i].y});
		}
	}
	sort(sw+1,sw+N+1,[](T a,T b){
			return a.y==b.y?a.x<b.x:a.y<b.y;
	});
	if(start&&sw[1].y==0){
		G[0][1].pb(edge{sw[1].id,sw[1].x});
	}
	if(sw[N].y==H-1){
		G[sw[N].id][1].pb(edge{N+1,W-1-sw[N].x});
	}
	rep1(i,N-1){
		if(sw[i].y==sw[i+1].y){
			G[sw[i].id][1].pb(edge{sw[i+1].id,sw[i+1].x-sw[i].x});
			G[sw[i+1].id][1].pb(edge{sw[i].id,sw[i+1].x-sw[i].x});
		}
	}
	N++;//0st Ngoal
	fill(d[0],d[200002],INF);
	d[0][0]=0;
	priority_queue<A,vector<A>,greater<A> > q;
	q.push(A{0,0,0});
	if(start){
		d[0][1]=1;
		q.push(A{0,0,1});
	}
	while(!q.empty()){
		A p=q.top();
		q.pop();
		ll x=p.id;
		ll y=p.dir;
		if(d[x][y]<p.cost) continue;
		if(x!=0&&x!=N){
			if(d[x][!y]>d[x][y]+1){
				d[x][!y]=d[x][y]+1;
				q.push(A{d[x][!y],x,!y});
			}
		}
		rep(i,G[x][y].size()){
			edge e=G[x][y][i];
			if(d[e.to][y]>d[x][y]+e.cost){
				d[e.to][y]=d[x][y]+e.cost;
				q.push(A{d[e.to][y],e.to,y});
			}
		}
	}
	if(d[N][0]==INF&&d[N][1]==INF) cout<<"-1"<<endl;
	else cout<<min(d[N][0],d[N][1])<<endl;
}

Measured memory_bytes: 38988
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int N, sum, b;
    cin >> N;
    vector<int> vec(N);
    rep(i, N){
        cin >> vec.at(i);
        b = vec.at(i);
        for(int j = 0; j < i; j++){
            if(b == vec.at(j)){break;}
            if(j == i - 1){
                sum ++;
            }
        }
    }
cout << sum + 1 <<endl;
}

Measured memory_bytes: 256
N=int(input())
C=sorted(list(map(int,input().split())),reverse=True)
mod=10**9+7
def mpow(x,n):
    num=1
    while n > 0:
        if n&1:
            num=num*x%mod
        x=x*x%mod
        n=n>>1
    return(num)
count=0
for i, c in enumerate(C, 2):
    count += c * (i)
    count %= mod
print(count * mpow(2, N-1)*mpow(2, N-1) % mod)


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

int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a) cout<<k<<endl;
	else if(k<=a+b) cout<<a<<endl;
	else cout<<a-(k-(a+b))<<endl;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<iterator>
#include<stack>
#include<string>
#include<climits>
#include<bitset>
#include<queue>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<sstream>

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vl vector<long long int>
#define vvi vector<vector<int> >
#define vvl vector<vector<long long int> >
#define vp vector<pair<int, int> >
#define sc(n) scanf("%d", &n)
#define ssync ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

using namespace std;

vi subtreesize;
bool *visited;

string toBin(long long int a)
{
	return bitset<64>(a).to_string();
}

void printArr(int* a, int n)
{
	for(int i = 0; i < n; i++)
		printf("%d ", a[i]);
	printf("\n");
}

string intToString (ll a)
{
	ostringstream temp;
	temp<<a;
	return temp.str();
}

ll pow(ll base, ll exponent)
{
	ll result = 1;
	while(exponent > 0)
	{
		if (exponent % 2 == 1)
			result *= base;
		exponent = exponent >> 1;
		base *= base;
	}
	return result;
}

ll powerWithMod(ll base, ll exponent, ll modulus)
{
	ll result = 1;
	base %= modulus;
	while(exponent > 0)
	{
		if (exponent % 2 == 1)
			result = (result * base) % modulus;
		exponent = exponent >> 1;
		base = (base * base) % modulus;
	}
	return result;
}

class tree
{
	public:
		int n;
		vvi adjlis;

		tree(int a)
		{
			n = a;
			vi temp;
			for(int i=0; i<n; i++)
				adjlis.push_back(temp);
		}

		void addedge(int node1, int node2)
		{
			adjlis[node1-1].push_back(node2-1);
			adjlis[node2-1].push_back(node1-1);
		}
};

void ssize(tree& a, int curr)
{
	for(int i=0; i < a.adjlis[curr].size(); i++)
	{
		if(!visited[a.adjlis[curr][i]])
		{
			visited[a.adjlis[curr][i]] = true;
			ssize(a, a.adjlis[curr][i]);
			subtreesize[curr] += subtreesize[a.adjlis[curr][i]];
		}
	}
}

int main()
{
	ssync;
	ll n, x;
	cin>>n>>x;
	cout << (ll)3 * (n - __gcd(n, x)) << "\n";
	return 0;
}


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

int main()
{
    int n; cin>>n;
    vector<int> a(n);
    for(int& e: a) cin>>e;

    deque<int> b;
    for(int i=0; i<n; ++i) {
        if (i%2)
            b.push_front(a[i]);
        else
            b.push_back(a[i]);
    }
    while (b.size()) {
        if (n%2) {
            cout<<b.back()<<' ';
            b.pop_back();
        }
        else {
            cout<<b.front()<<' ';
            b.pop_front();
        }
    }
    cout<<endl;
}



Measured memory_bytes: 3840
//Nayeem Shahriar Joy ,Applied Physics And Electronic Engineering , University of Rajshahi.

  #include <iostream>
  #include <cstdio>
  #include <algorithm>
 
  using namespace std;
 
  char data[1000000];
 
  int main(void)
  {
    int n;
    int max = 0;
     
    while (scanf("%d", &n) != EOF){
        data[n]++;
    }
     
    for (int i = 0; i < 1000000; i++){
         
        if (data[i] > max){
            max = data[i];
        }
    }
    for (int i = 0; i < 1000000; i++){
        if (data[i] == max){
            printf("%d\n", i);
        }
    }
     
    return (0);
}

Measured memory_bytes: 3164
# = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = list(input())
# = [tuple(map(int, input().split())) for _ in range(n)]

n = int(input())
ab = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(n-1)]
m = int(input())
uv = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(m)]

e = [[] for _ in range(n)]
i = 0
for a, b in ab:
    e[a].append([b, i])
    e[b].append([a, i])
    i += 1

def func(x, g, p):
    #print(x, g, p, e[x])
    if len(e[x]) == 1 and p != -1:
        return -1
    for edge in e[x]:
        if edge[0] == p:
            continue
        elif edge[0] == g:
            #print(edge)
            return 1 << edge[1]
        temp = func(edge[0], g, x)
        #print(temp, x, g, p)
        if temp >= 0:
            #print(edge[1])
            return temp + (1 << edge[1])
    return -1

p = []
for u, v in uv:
    p.append(func(u, v, -1))

#print(p)
flag = -1
ans = 2 ** (n-1)
#print(ans)
base = 2 ** (n-1)
for i in range(1, 1 << m):
    temp = list(reversed(list(str(bin(i)))[2:]))
    c = 0
    #print(temp)
    for j, x in enumerate(temp):
        if x == '1':
            c = c | p[j]
    #print(bin(base + c))
    hoge = str(bin(base + c)).count('0') - 1
    if temp.count('1') % 2 == 0:
        flag = 1
    else:
       flag = -1
    ans += flag * (2 ** hoge)
    #flag *= -1
print(ans)


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

int main() {
  string S; cin >> S;
  if (S[0] != S[1] && S[1] != S[2] && S[2] != S[3])
    cout << "Good" << endl;
  else
    cout << "Bad" << endl;
}

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

int main()
{
	int n,k;
	cin>>n>>k;
	string a;
	cin>>a;
	int c=0;
	for (int i=1;i<n;i++)
	{
		c+=(a[i]!=a[i-1]);
	}
	cout<<min(n-1,n-1-c+2*k);
	return 0;
}


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

typedef long long ll;
const int MAX_M = 100000;

int main() {
	int N, M, X[MAX_M], dist[MAX_M - 1];

	std::cin >> N >> M;

	for(int i = 0; i < M; ++i) {
		std::cin >> X[i];
	}
	std::sort(X, X + M);

	for(int i = 0; i < M - 1; ++i) {
		dist[i] = std::abs(X[i + 1] - X[i]);
	}
	std::sort(dist, dist + M - 1, std::greater<int>());

	ll ans = X[M - 1] - X[0];
	for(int i = 0; i < N - 1; ++i) {
		ans -= dist[i];
	}

	std::cout << ans << std::endl;

}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        while(true){
        int n = sc.nextInt();
        if(n==0) break;
        int s[] = new int[n];
        int max = 0, min = 1000, sum = 0;
        for(int i=0; i<n; i++){
            s[i] = sc.nextInt();
            if(s[i] > max) max = s[i];
            if(s[i] < min) min = s[i];
            sum += s[i];
        }
        double score = (double)(sum - max - min) / (n-2);
        System.out.println((int)score);
    }
    }
}


Measured memory_bytes: 28748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,i;
    string a,b,c="";
    cin>>n;
    cin>>a>>b;
    for(i=0;a[i];i++)
    {
        c+=a[i];
        c+=b[i];
    }
    cout<<c<<endl;
    return 0;
}


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

int main(){
    string s;
    int q;
    
    cin >> s;
    cin >> q;
    vector<int> t(q);
    vector<int> f(q);
    vector<char> c(q);
    for(int i = 0; i < q; i++){
        cin >> t[i];
        if(t[i] == 2) cin >> f[i] >> c[i];
    }
    
    vector<string> fronts;
    vector<string> rears;
    string front = "";
    string rear = "";
    int revnum = 0;
    for(int i = 0; i < q; i++){
        if(t[i] == 1){
            if(i+1 < q && t[i+1] == 1){
                i++;
                continue;
            }else{
                revnum++;
                fronts.push_back(front);
                rears.push_back(rear);
                front = "";
                rear = "";
            }
        }else{
            if(f[i] == 1){
                front = c[i] + front;
            }else{
                rear += c[i];
            }
        }
    }
    fronts.push_back(front);
    rears.push_back(rear);
    string res;
    
    if(revnum % 2){
        for(int i = revnum; i >= 0; i--){
            if(i % 2){
                res += fronts[i];
            }else{
                reverse(rears[i].begin(), rears[i].end());
                res += rears[i];
            }
        }
        
        reverse(s.begin(), s.end());
        res += s;
        
        for(int i = 0; i <= revnum; i++){
            if(i % 2){
                res += rears[i];
            }else{
                reverse(fronts[i].begin(), fronts[i].end());
                res += fronts[i];
            }
        }
    }else{
        for(int i = revnum; i >= 0; i--){
            if(i % 2){
                reverse(rears[i].begin(), rears[i].end());
                res += rears[i];
            }else{
                
                res += fronts[i];
            }
        }
        
        res += s;
        
        for(int i = 0; i <= revnum; i++){
            if(i % 2){
                reverse(fronts[i].begin(), fronts[i].end());
                res += fronts[i];
            }else{
                res += rears[i];
            }
        }
    }
    
    
    
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 5240
def main():
    x = int(input())
    if x == 1:
        print(1)
        return

    m = 1
    for b in range(2, x):
        p = 2
        while True:
            e = b ** p
            if e > x:
                break
            if e > m:
                m = e
            p += 1

    print(m)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMarch solver = new CMarch();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMarch {
        static final String letterString = "MARCH";
        static final int L = letterString.length();
        static final char[] letters = letterString.toCharArray();

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            long[] count = new long[letters.length];

            for (int i = 0; i < n; i++) {
                String s = in.next();
                int index = letterString.indexOf(s.charAt(0));
                if (index >= 0)
                    count[index]++;
            }

            long s = 0, s2 = 0, s3 = 0;
            for (int i = 0; i < L; i++) {
                s += count[i];
                s2 += count[i] * count[i];
                s3 += count[i] * count[i] * count[i];
            }

            long answer = s * s * s - s * s2 * 3 + s3 * 2;
            answer /= 6;

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 34052
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
using namespace std;
 
const int maxn = 5e3 + 10;
const long long max_val = 1LL << 62;
 
long long dp[maxn * 2], dp_min[maxn * 2];
int p[maxn];
 
long long cost(int p1, int p2, int A, int B) {
    if (p1 == p2) return 0;
    else if (p1 > p2) return B;
    else return A;
}
 
int main()
{
    int N, A, B, x;
    cin >> N >> A >> B;
    for (int i = 1; i <= N; i++) {
        cin >> x;
        p[x] = i;
    }
    for (int i = 1; i <= N; i++) for (int j = 0; j <= N; j++) dp[j] = max_val;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <=  N; j++) {
            dp[j] = dp_min[j] + cost(p[i], j, A, B);
        }
        dp_min[0] = dp[0];
        for (int j = 1; j <=  N; j++) dp_min[j] = min(dp_min[j - 1], dp[j]);
    }
    cout << dp_min[ N] << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int IINF = INT_MAX;
const int MAX_N = int(1e5 + 5);
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
    int n, k, h[MAX_N], dp[MAX_N];
    cin >> n >> k;
    REP(i,n) cin >> h[i];
    fill(dp,dp+n+1,IINF);
    dp[0] = 0;
    REP(i,n-1){
        REP(j,k){
            if(i+j+1<n)dp[i+j+1] = min(dp[i+j+1],dp[i]+abs(h[i+j+1]-h[i]));
            else break;
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
dishes = [int(input()) for i in range(5)]

ans = 0
min_digits = 10
digits_idx = 0
for idx, dish in enumerate(dishes):
  if dish%10 == 0:
    ans += dish
  else:
    ans += dish + 10 - dish%10
  if dish%10 < min_digits and dish%10 !=0:
    digits_idx = idx
    min_digits = dish%10
if min_digits == 10:
  print(ans)
else:
  ans -= (10 - min_digits)
  print(ans)

Measured memory_bytes: 38256