akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n; 
	string s;
	cin>>n>>s;
	ll b_cnt=0, w_cnt=0;
	for(const char& ch:s){
		if(ch=='.')
			b_cnt++;
	}
	ll res=b_cnt;
	for(const char& ch:s){
		if(ch=='.')
			b_cnt--;
		else
			w_cnt++;
		res=min(res,b_cnt+w_cnt);
	}
	cout<<res<<'\n';
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll>v;
void bfs(ll x, ll num)
{
    queue<ll> q;
    q.push(num);
    v.push_back(num);
    while (!q.empty()) {
        num = q.front();
        q.pop();
        if (num <= x) {
           // cout << num << " ";
            ll last_dig = num % 10;
            if (last_dig == 0)
            {


                q.push((num * 10) + (last_dig + 1));
                v.push_back((num * 10) + (last_dig + 1));
                q.push((num * 10));
                v.push_back((num * 10));
            }
            else if (last_dig == 9)
            {


                q.push((num * 10) + (last_dig - 1));
                    v.push_back((num * 10) + (last_dig - 1));
                    q.push((num * 10) + (last_dig));
                    v.push_back((num * 10) + (last_dig));
            }


            else {
                q.push((num * 10) + (last_dig - 1));
                q.push((num * 10) + (last_dig + 1));
                v.push_back((num * 10) + (last_dig - 1));
                v.push_back((num * 10) + (last_dig + 1));
                q.push((num * 10) + (last_dig));
                 v.push_back((num * 10) + (last_dig ));
            }
        }
    }
}
void Jumping(ll x)
{
    //cout << 0 << " ";
    for (ll i = 1; i <= 9 && i <= x; i++)
        bfs(x, i);
}
int main()
{
    ll x = 3234566667;
    Jumping(x);
    sort(v.begin(),v.end());
    int k;
    cin>>k;
    cout<<v[k-1]<<"\n";
    return 0;
}


Measured memory_bytes: 6732
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  string s, t;
  cin >> s >> t;

  s += s;

  REP(i,t.size()){
    bool ok = true;
    REP(j,t.size()){
      if(s[i+j] != t[j]) ok = false;
    }
    if(ok) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
from collections import Counter

s = input().rstrip()
n = len(s)
cnt = Counter(s)

for i in range(97, 97 + 26):
    key = chr(i)
    if key not in s:
        print(s + key)
        exit()

largest = s[-1]
seen = []
for i, ch in enumerate(s[::-1]):
    if ch < largest:
        for item in seen:
            if ch < item:
                s = s[:n-i-1] + item
                print(s)
                exit()
    largest = max(largest, ch)
    seen.append(ch)
    seen.sort()

print(-1)

Measured memory_bytes: 3316
#include <stdio.h>

int main(){
    char st[5];
    scanf("%s",st);
    int i;
    char tmp[2];
    tmp[0] = st[0];
    int a = 1,b = 0;
    for(i = 1;i<5;i++){
        if(st[i] == tmp[0]) a++;
        else if(b == 0){
            tmp[1] = st[i];
            b++;
        }else if(st[i] == tmp[1]) b++;
    }
    if(a == 2 && b==2) printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 128
function Main(input) {
  line = input.split(" ");
  W = +line[0]; 
  H = +line[1]; 
  x = +line[2]; 
  y = +line[3]; 
  
  //小さい方の面積の最大値は常に、W*Hを半分にしたもの（小さい部分＝大きい部分）
  area = W * H / 2;
  
  //ちょうどxとyがWとHの半分になるときにしか１の状況にはならない
  //なので、それ以外の状況は全て０
  if (x === W / 2 && y === H / 2) {
    console.log(area,1);
  } else {
    console.log(area,0);
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 7628
/**
*    author:  boutarou
*    created: 28.06.2020 20:54:48
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

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

const double PI = 3.1415926535897932;
const int INF = 1e9;

int d;
int c[26];
int s[365][26];
vector<int> previous(26);

int score(int day, int contest, vector<int> before) {
    int cnt = 0;
    cnt += s[day][contest];
    before[contest] = day;
    rep(k, 26) {
        cnt -= c[k] * (day - before[k]);
    }
    return cnt;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> d;
    rep(i, 26) cin >> c[i];
    rep(i, d) {
        rep(j, 26) cin >> s[i][j];
    }

    rep(i, 26) previous[i] = -1;

    int now = 0;
    rep(i, d) {
        int ma = -INF;
        rep(j, 26) {
            ma = max(ma, score(i, j, previous));
        }
        rep(j, 26) {
            if (ma == score(i, j, previous)) {
                cout << j + 1 << endl;
                now += score(i, j, previous);
                previous[j] = i;
                break;
            }
        }
    }
    
    return 0;
}

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

using namespace std;
using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    i64 N;
    cin >> N;
    i64 sum = 0;
    for (int x = 1; (i64)x * x <= N && x < N - x; ++x) {
        if ((N - x) % x == 0) {
            i64 m = (N - x) / x;
            sum += m * (N / m == N % m);
            //sum += m;
        }
    }
    cout << sum << "\n";

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt(); // bad
        int b = sc.nextInt(); //good
        int c = sc.nextInt(); //good
        if (a + b >= c) {
            System.out.println(b + c); // all ok
        } else {
            System.out.println(b + (b + a) + 1);
        }


        sc.close();
    }
}



Measured memory_bytes: 22996
//============================================================================
// Name        : template.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <vector>
#include <string.h> // for memset in CF judge.
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int main() {
	int k; string s; cin >> k >> s;
	char arr[k]; int n = s.length();
	if(n <= k) {
		cout << s << endl;
		return 0;
	}
	string ans = s.substr(0, k);
	cout << ans+"..." << endl;
return 0;
}


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

using ll = long long int;
const ll maxs = 1e5+5;

ll n,k;
ll arr[maxs],dp[maxs];

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

    for(ll i=0;i<n;i++) {
        cin >> arr[i];
        dp[i] = 0;
    }
    dp[n-1] = 0;
    dp[n-2] = abs(arr[n-2] - arr[n-1]);

    for(ll i=n-3;i>=0;i--)
    {
        ll mn = INT_MAX;
        ll lim = i + k + 1;
        for(ll j=i+1;j<min(n,lim);j++)
            mn = min(mn,dp[j] + abs(arr[i] - arr[j]));
        dp[i] = mn;
    }

    cout << dp[0];
    
    return 0;
}

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

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

    int a, b; cin >> a >> b;
    int ans = max({a+b, a-b, a*b});
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.math.*  

fun main(args: Array<String>) {

  val arr = readLine()!!.split(" ")
  val a:Int = Integer.parseInt(arr[0])
  val b:Int = Integer.parseInt(arr[1])
  
  val num1 = a + b
  val num2 = a - b
  val num3 = a * b

  val num4 = Math.max(num1, num2);
  val num5 = Math.max(num3, num4);

  println(Integer.toString(num5));
}

Measured memory_bytes: 36020
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner cin = new Scanner(System.in)) {
			final int num1 = cin.nextInt();
			final int num2 = cin.nextInt();
			final int num3 = cin.nextInt();

			if ((num1 * 100 + num2 * 10 + num3) % 4 == 0) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		} finally {
		}
	}
}


Measured memory_bytes: 20820
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

const int N = 1e5 + 1;
int n, mod;
vi adj[N];
ll up[N], down[N], sibling[N];

void dfs(int u, int p) {
	down[u] = 1;
	vector<pair<int, ll>> child;
	for (int v : adj[u]) if (v != p) {
		dfs(v, u);
		down[u] = down[u] * (1 + down[v]) % mod;
		child.emplace_back(v, down[v] + 1);
	}

	int m = child.size();
	if (m) {
		vll prefix(m+1), suffix(m+1);
		prefix[0] = suffix[m] = 1;
		for (int i = 1; i <= m; i++)
			prefix[i] = prefix[i-1] * child[i-1].second % mod;
		for (int i = m-1; i >= 0; i--)
			suffix[i] = suffix[i+1] * child[i].second % mod;
		for (int i = 0; i < m; i++)
			sibling[child[i].first] = prefix[i] * suffix[i+1] % mod;
	}
}

void dfs2(int u, int p) {
	up[u] = 1 + up[p] * sibling[u] % mod;
	for (int v : adj[u]) if (v != p)
		dfs2(v, u);
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	scanf("%d%d", &n, &mod);
	for (int i = 0; i < n-1; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	for (int i = 1; i <= n; i++) sibling[i] = 1;
	dfs(1, 0);
	dfs2(1, 0);
	//for (int u = 1; u <= n; u++) printf("%lld %lld %lld\n", up[u], down[u], sibling[u]);
	for (int u = 1; u <= n; u++)
		printf("%lld\n", up[u] * down[u] % mod);
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


int32_t main(){
	ios::sync_with_stdio(false);
    int n, m;
    cin>>n>>m;
    int M=m/2;
    if(n>=M){
        cout<<M<<"\n";
    }
    else{
        int ans=n+(m-2*n)/4;
        cout<<ans<<"\n";
    }



	return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 9999999

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;


bool shortestPath(const Graph &g,
    Matrix &dist, vector<vector<int> > &prev) {
  int n = g.size();
  Array h(n+1);
  REP(k,n) REP(i,n) FOR(e,g[i]) {
    if (h[e->dst] > h[e->src] + e->weight) {
      h[e->dst] = h[e->src] + e->weight;
      if (k == n-1) return false; // negative cycle
    }
  }
  dist.assign(n, Array(n, INF));
  prev.assign(n, vector<int>(n, -2));
  REP(s, n) {
    priority_queue<Edge> Q;
    Q.push(Edge(s, s, 0));
    while (!Q.empty()) {
      Edge e = Q.top(); Q.pop();
      if (prev[s][e.dst] != -2) continue;
      prev[s][e.dst] = e.src;
      FOR(f,g[e.dst]) {
        if (dist[s][f->dst] > e.weight + f->weight) {
          dist[s][f->dst] = e.weight + f->weight;
          Q.push(Edge(f->src, f->dst, e.weight + f->weight));
        }
      }
    }
    REP(u, n) dist[s][u] += h[u] - h[s];
  }
}
vector<int> buildPath(const vector< vector<int> >& prev, int s, int t) {
  vector<int> path;
  for (int u = t; u >= 0; u = prev[s][u])
    path.push_back(u);
  reverse(ALL(path));
  return path;
}

int main() {
	int n;
	while(cin>>n,n){
		Graph g(10);
		Matrix d;
		vector<vector<int> > p;
		REP(i,n){
			int a,b,c;
			cin>>a>>b>>c;
			g[a].push_back(Edge(a,b,c));
			g[b].push_back(Edge(b,a,c));
		}
		shortestPath(g,d,p);

		int mn=INF,t,mi;
		REP(i,d.size()){
			if(d[i][0]==INF)continue;
			t=0;
			REP(j,d[i].size()){
				if(d[i][j]==INF||i==j)continue;
				t+=d[i][j];
			}
			if(t<mn)mn=t,mi=i;
		}
		cout<<mi<<" "<<mn<<endl;
	}
	return 0;
}

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

int main (void){
    string s;
    cin >> s;
    if (s[0] == s[1] && s[0] == s[2]) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3608
// This file is a "Hello, world!" in D language by DMD for wandbox.
import std.algorithm, std.conv, std.stdio, std.array;

int main()
{
    const I = readln.split.map!(to!long).array;
    ((I[2]/I[0])*I[1]).writeln;
    return 0;
}

// DMD reference:
//   https://dlang.org/dmd-linux.html

// D language references:
//   https://dlang.org
//   http://www.kmonos.net/alang/d/ ( Japanese )


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

int main()
{
    fast;
  
    ll n,k;
    cin>>n>>k;

     ll dp[2009][2009];
    memset(dp,0,sizeof(dp));

    dp[0][0]=1;

    for(ll i=1;i<2009;i++)
    {
      dp[i][0]=dp[i][i]=1;
      for(ll k=1;k<i;k++)
        dp[i][k]=(dp[i-1][k]+dp[i-1][k-1])%mod;
    }

    for(ll i=1;i<=k;i++)
    {
      ll x=((ll)dp[n-k+1][i] *dp[k-1][i-1])%mod;
      cout<<x<<endl;
    }
   }

Measured memory_bytes: 31744
n, m = map(int, input().split())
cakes = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(2**3):
    tmp_arr = []
    for j in range(n):
        tmp = 0
        for k in range(3):
            if (i>>k) & 1:
                tmp += cakes[j][k]
            else:
                tmp -= cakes[j][k]
        tmp_arr.append(tmp)
    tmp_arr.sort(reverse=True)
    ans = max(ans, sum(tmp_arr[:m]))
print(ans)

Measured memory_bytes: 42736
def main(N,Q,C,LR,A):
    data=[0]*(N+1)
    def add(i,x):
        i+=1
        while i<=N:
            data[i]+=x
            i+=i&-i
    def sum(a,b):
        r=0
        i=b
        while i>0:
            r+=data[i]
            i-=i&-i
        i=a
        while i>0:
            r-=data[i]
            i-=i&-i
        return r
    p=[-1]*N
    q=0
    a=[0]*Q
    for i in range(N):
        if p[C[i]-1]>=0:
            add(p[C[i]-1],-1)
        p[C[i]-1]=i
        add(i,1)
        while q<Q and LR[A[q]][1]==i+1:
            a[A[q]]=sum(LR[A[q]][0]-1,LR[A[q]][1])
            q+=1
    return a

import sys
if sys.argv[-1]=='ONLINE_JUDGE':
    from numba import*
    from numba.pycc import CC
    cc=CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return njit(f)

    main=cc_export(main,(i8,i8,i8[:],i8[:,:],i8[:]))
    cc.compile()
    exit()

def input(): return sys.stdin.buffer.readline()
N,Q=map(int,input().split())
import numpy as np
C=np.array(input().split(),dtype=np.int64)
LR=np.array(sys.stdin.buffer.read().split(),dtype=np.int64).reshape(Q,2)
A=np.argsort(LR[:,1])

from my_module import main
print(*main(N,Q,C,LR,A),sep='\n')

Measured memory_bytes: 94144
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.07.13 02:43:15
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

const int dx[] = {0,1,0,-1}, dy[] = {1,0,-1,0};
int w,h;
int dfs(int cnt, int nx, int ny, vector<vector<int>> &g, pair<int,int> &goal) {
    if (cnt == 10) return -1;
    int res = 100;
    for (int i = 0; i < 4; i++) {
        int x = nx + dx[i], y = ny + dy[i];
        if (x >= 0 && x < h && y >= 0 && y < w && g[x][y] == 1) continue;
        while (x >= 0 && x < h && y >= 0 && y < w && g[x][y] != 1) {
            if (goal.first == x && goal.second == y) return cnt + 1;
            x += dx[i], y += dy[i];
        }
        if (x >= 0 && x < h && y >= 0 && y < w) {
            g[x][y] = 0;
            x -= dx[i], y -= dy[i];
            int ret = dfs(cnt + 1, x, y, g, goal);
            if (ret != -1) res = min(res,ret);
            g[x + dx[i]][y + dy[i]] = 1;
        }
    }
    if (res == 100) return -1;
    else return res;
}
int main() {
    while (true) {
        cin >> w >> h;
        if (w == 0) break;
        pair<int,int> start,goal;
        vector<vector<int>> g(h,vector<int>(w));
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cin >> g[i][j];
                if (g[i][j] == 2) start = {i,j};
                if (g[i][j] == 3) goal = {i,j};
            }
        }
        cout << dfs(0,start.first,start.second,g,goal) << endl;
    }
    return 0;
}



Measured memory_bytes: 3032
#include <iostream>
#include <climits>
#include <cmath>


using namespace std;

int main()
{
    long long candles[100000];
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> candles[i];
    }

    long long ans = LONG_LONG_MAX;
    for (int i = 0; i < N - K + 1; i++) {
        long long l, r;
        l = candles[i];
        r = candles[i+K-1];
        if (l * r >= 0) {
            ans = min(max(abs(l), abs(r)), ans);
        } else {
            long long can = min(abs(l) * 2 + abs(r), abs(l) + abs(r) * 2);
            ans = min(can, ans);
        }
    }

    cout << ans << endl;
}


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

int main(){
  int N,K;
  vector<long int> hoge;
  int bash;
  long int sum = 0;
  cin >> N >> K;
  if (N <= K){
    cout << "0" << endl;
    return 0;
  }
  for (int i = 0; i < N; i++){
    cin >> bash;
    hoge.push_back(bash);
  }
  sort(hoge.begin(),hoge.end(),greater<int>());
  for (int i = K; i < N; i++){
    sum += hoge[i];
  }
  cout << sum << endl;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; i<n; i++)
#define REP2(i, a, b) for(int i=a; i<b; i++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int N, T;
    cin >> N >> T;
    vector<pair<int, int>> AB(N);
    REP(i, N)
        cin >> AB[i].first >> AB[i].second;
    sort(AB.begin(), AB.end());

    vector<vector<int>> dp(N+1, vector<int>(T+1));
    REP(i, N){
        dp[i+1] = dp[i];
        REP(j, T){
            int k = min(T, j+AB[i].first);
            dp[i+1][k] = max(dp[i+1][k], dp[i][j]+AB[i].second);
        }
    }
    int ans = *max_element(dp[N].begin(), dp[N].end());
    cout << ans << endl;
    return 0;
}


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

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    int n, m;
    while (cin >> n >> m, n) {
        vi data(n);
        rep(i, n) {
            cin >> data[i];
        }
        sort(all(data));
        int pt = 1;
        vi graph(2, 0);
        rep(i, n) {
            if (pt * m > data[i]) {
                graph[pt]++;
            } else {
                pt++;
                i--;
                graph.pb(0);
            }
        }
        int ma = -1;
        rep(i, graph.size()) {
            ma = max(ma, graph[i]);
        }
        double ans = 0.0, diag = (graph.size() - 2);
        Rep(i, graph.size()-1) {
            ans += (graph.size()-1 - i) / diag *
                (double)graph[i] / (double)ma;
        }
        cout << ans + 0.01 << endl;
    }

    return 0;
}

Measured memory_bytes: 3268
//minamoto
#include<bits/stdc++.h>
#define R register
#define pb push_back
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
#define gg(u) for(int &i=cur[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
inline int min(R int x,R int y){return x<y?x:y;}
const int N=1005,inf=0x3f3f3f3f,M=5e6+5;
struct eg{int v,nx,w;}e[M];int head[N],tot;
inline void add(R int u,R int v,R int w){
	e[++tot]={v,head[u],w},head[u]=tot;
	e[++tot]={u,head[v],0},head[v]=tot;
}
int cur[N],dis[N],q[N],S,T;
bool bfs(){
	int h=1,t=0,u;
	memset(dis,0x3f,(T-S+1)<<2);
	memcpy(cur,head,(T-S+1)<<2);
	q[++t]=S,dis[S]=0;
	while(h<=t){
		u=q[h++];
		go(u)if(e[i].w&&dis[v]==inf){
			dis[v]=dis[u]+1,q[++t]=v;
			if(v==T)return true;
		}
	}
	return false;
}
int dfs(int u,int lim){
	if(u==T||!lim)return lim;
	int fl=0,f;
	gg(u)if(dis[v]==dis[u]+1&&(f=dfs(v,min(lim,e[i].w)))){
		fl+=f,lim-=f,e[i].w-=f,e[i^1].w+=f;
		if(!lim)break;
	}
	if(!fl)dis[u]=inf;return fl;
}
int pp[N],mat[N][N];
int n,m;
void dinic(){
	memset(head,0,(T-S+1)<<2),tot=1;
	fp(i,1,n)add(S,i,1),add(i+n,T,1);
	fp(i,1,n)fp(j,1,n)if(mat[i][j])add(i,j+n,1);
	R int res=0;
	while(bfs())res+=dfs(S,inf);
	fp(u,1,n)go(u)if(v!=S&&!e[i].w)pp[u]=v-n;
}
vector<int>c[N][N];
int mp[N][N],fr[N*N],to[N*N],f[N][N],g[N][N];
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d",&n,&m),S=0,T=(n<<1|1);
	fp(i,1,n)fp(j,1,m)scanf("%d",&mp[i][j]),fr[mp[i][j]]=i;
	fp(i,1,n)fp(j,1,m)to[(i-1)*m+j]=i;
	fp(i,1,n*m)c[fr[i]][to[i]].pb(i);
	fp(k,1,m){
		fp(i,1,n)fp(j,1,n)mat[i][j]=!c[i][j].empty();
		dinic();
		for(R int tmp,i=1;i<=n;++i){
			tmp=c[i][pp[i]].back(),c[i][pp[i]].pop_back();
			f[i][k]=tmp,g[pp[i]][k]=tmp;
		}
	}
	fp(i,1,n)fp(j,1,m)printf("%d%c",f[i][j]," \n"[j==m]);
	fp(i,1,n)fp(j,1,m)printf("%d%c",g[i][j]," \n"[j==m]);
	return 0;
}

Measured memory_bytes: 39936
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
int n, a[N][4], b[N], c[N], k;
int dp[N][4];
void solve(){
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> a[i][0] >> a[i][1] >> a[i][2];

    for(int i = 0; i < 3; ++i)
        dp[1][i] = a[1][i];
    for(int i = 2; i <= n; ++i) 
        for(int j = 0; j < 3; ++j)
            dp[i][j] = a[i][j] + max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]);
        
    cout << max({dp[n][0], dp[n][1], dp[n][2]});
    
}   
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
int main(void){
    IOS;
    int R; cin >> R;
    printf("%.6f", 2*PI*R);
    return 0;
}

Measured memory_bytes: 3788
import scala.io.StdIn.readInt

object Main {
  def sieve(n:Int) = {
    val primes = Array.tabulate(n+1) { _ % 2 }
    primes(1) = 0
    primes(2) = 1

    for( i <- 3 to Math.sqrt(n).toInt by 2 )
      if(primes(i) == 1)
        (i*i to n by i*2).foreach { primes(_) = 0 }
    primes
  }

  def main(args:Array[String]) = {
    val p = sieve(50000)
    var n = 0
    while( { n = readInt; n} != 0 ) {
      var cnt = 0
      if(p(2) == 1 && p(n-2) == 1) cnt += 1
      for(i<- 3 to n/2 by 2)
        if(p(i) ==1 && p(n-i) ==1)
          cnt += 1
      println(cnt)
    }
  }
}

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

struct dict{int index,number;};

bool asc( const dict& left, const dict& right ) {
    return left.number == right.number ? left.index < right.index : left.number < right.number;
}

int main(){
    int N;
    cin >> N;
    vector<dict>student(N);
    for(int i = 0; i < N;i++){
        cin >> student[i].number;
        student[i].index = i;
    }
    sort(student.begin(), student.end(), asc);

    for(int i = 0; i < N-1; i++){
        cout << student[i].index+1 << ' ';
    }
    cout << student[N-1].index+1 << endl;

    return 0;



}

Measured memory_bytes: 1664
w = [input() for i in range(4)]
N = int(w[0])
K = int(w[1])
X = int(w[2])
Y = int(w[3])

paid = 0
for i in range(1,N+1):
    if i < K+1:
        paid += X
    else:
        paid += Y

print(paid)



Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int N,M;
int done[50];
vector< vector<int> > path;

void bfs( int a, int b ) {
    
    fill( done, done+50, 0 );
    
    queue<int> Q;
    for ( int i = 0; i < path[0].size(); i++ ) {
        if ( ( a == 0 && b == path[0][i] ) || ( a == path[0][i] && b == 0 ) ) { continue; }
        Q.push(path[0][i]);
        done[path[0][i]] = 1;        
    }
    
    while ( !Q.empty() ) {
        int c = Q.front();
        Q.pop();
        
        for ( int i = 0; i < path[c].size(); i++ ) {
            int n = path[c][i];
            if ( ( a == c && b == n ) || ( a == n && b == c ) ) { continue; }
            if ( !done[n] ) {
                Q.push(n);
                done[n] = 1;
            }
        }
    }
    
}

bool is_all() {
    for ( int i = 0; i < N; i++ ) {
        if ( !done[i] ) { return false; }
    }
    return true;
}

int main() {
    
    cin >> N >> M;
    path.resize(N);
    vector< pair<int, int> > P;
    for ( int i = 0; i < M; i++ ) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        path[a].push_back(b);
        path[b].push_back(a);
        P.push_back( make_pair(a,b) );
    }
    
    int ans = 0;
    for ( int i = 0; i < M; i++ ) {        
        bfs( P[i].first, P[i].second );
        if ( !is_all() ) { ans++; }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))

import itertools
result = 0
# 6C3の羅列
for l in itertools.combinations(L, 3):
    if len(set(l)) != 3:continue
    l = list(l)
    l = sorted(l)
    if (l[0]+l[1])>l[2] and l[2]>abs(l[0]-l[1]):result+=1
print(result)

Measured memory_bytes: 9128
#include<iostream>
#include<iomanip>
using namespace std;
double o,x;
int n;
int main()
{
	cin >>n;
	if (n%2==0)
	o=n/2; 
	else 
	o=n/2+1;
	
	x=n;
	
	cout <<fixed; 
	cout <<setprecision(9)<<o/x<<endl;
	
	system("pause");
	return 0;
}

Measured memory_bytes: 504
n,k=map(int,input().split())
arr=[]
for _ in range(n):
    arr.append(tuple(map(int,input().split())))
arr.sort(key=lambda x:x[0])
cur=0
for pair in arr:
    cur+=pair[1]
    if cur>=k:
        print(pair[0])
        break


Measured memory_bytes: 18192
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

ll Sum(ll s, ll e) {
	return (s + e) * (e / s) / 2;
}

int main(void) {
	ll num, i, ans = 0;
	cin >> num;
	for (i = 1; i <= num; i++) {
		ans += Sum(i, num / i * i);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3548
using System;

namespace myApp
{
    class Program
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split();

            int a= int.Parse(input[0]);
            
            int b=int.Parse(input[1]);

            int c = a*b;

            if(c%2==0){Console.WriteLine("Even");}

            else if(c%2==1){Console.WriteLine("Odd");}
            
            else{}
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		long b = sc.nextLong();
		long g = gcm (a, b);
		int count = 1;
		boolean[] ispr = new boolean[2000000];
		for(int i = 0; i < ispr.length; i++) {
			ispr[i] = true;
		}
		ispr[0] = false;
		ispr[1] = false;
		long n = (long)Math.sqrt(g);
		n++;
		/*for(int i = 2; i <= n; i++) {
			if(ispr[i]) {
				if(g%i == 0) count++;
				for(int j = 1; j*i <= n; j++) {
					ispr[j] = false;
				}
			}
		}*/
		for(int i = 2; i < n; i++) {
			if(g%i == 0) {
				while(g%i == 0) {
					g = g/i;
				}
				count++;
			}
		}
		if(g > 1) count++;
		System.out.println(count);
		sc.close();

	}
	private static  long gcm(long a, long b) {
		if(a<b) return gcm(b, a);
		if(b ==0) return a;
		return gcm(b, a%b);
	}
}

Measured memory_bytes: 23892
import java.util.Scanner;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();
        String[] str= new String [N];
        sc.nextLine();
        for(int i = 0;i < N;i++){
            str[i] = sc.nextLine();
        }
        Arrays.sort(str);
        for(int i = 0;i < N;i++){
            System.out.print(str[i]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  char s;
  cin>>s;
  int n = (int)s-(int)'A';
  if(n>=0&&n<=25)
    cout<<'A'<<endl;
  else
    cout<<'a'<<endl;
}

Measured memory_bytes: 3596
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, m, n) for (int i = m; i < n; i++)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int selectionSort(vector<int> &v, int N){
    int minj,val,count = 0;

    rep(i, N - 1){
        minj = i;
        rep2(j, i, N){
            if(v.at(j) < v.at(minj)){
                minj = j;
            }
        }

        val = v.at(i);
        v.at(i) = v.at(minj);
        v.at(minj) = val;

        if(i != minj){
            count++;
        }
    }

    return count;
}

int main()
{
    int N,count = 0;
    cin >> N;
    vector<int> v(N);

    rep(i, N){
        cin >> v.at(i);
    }

    count = selectionSort(v, N);

    rep(i, N){
        if(i > 0){
            cout << " ";
        }
        cout << v.at(i);
    }

    cout << endl << count << endl;
}


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

const int N = 1e5;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	int cnt = 0;
	for(int i=0;i<s.length();++i)
	{
		if(s[i] == 'o')
		cnt++;
	}
	if(cnt + (15-s.length()) >= 8)cout << "YES";
	else cout << "NO"; 
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		ArrayList<String> result = new ArrayList<String>();
		Scanner insert = new Scanner(System.in);
		int n = -1;
		while(true) {
			String line = insert.nextLine();
			n = Integer.parseInt(line);
			if(n==0) {
				break;
			}
			int[] jewelX = new int[n];
			int[] jewelY = new int[n];
			int[] kekka = new int[n];
			for(int i =0; i < n; i++) {
				line = insert.nextLine();
				String array[] = line.split(" ");
				jewelX[i] = Integer.parseInt(array[0]);
				jewelY[i] = Integer.parseInt(array[1]);
			}
			line = insert.nextLine();
			int m = Integer.parseInt(line);
			int nowX = 10;
			int nowY = 10;
			for(int i =0;i < m; i++) {
				line = insert.nextLine();
				String array[] = line.split(" ");
				int distance = Integer.parseInt(array[1]);
				for(int j = 0; j < distance; j++) {
					if(array[0].equals("N")) {
						nowY++;
					}
					if(array[0].equals("E")) {
						nowX++;
					}
					if(array[0].equals("W")) {
						nowX--;
					}
					if(array[0].equals("S")) {
						nowY--;
					}
					for(int k = 0; k < n; k++) {
						if((nowX == jewelX[k]) && (nowY == jewelY[k])) {
							kekka[k] = 1;
						}
					}
				}
			}
			int sum = 0;
			for(int i = 0; i < n ; i++) {
				sum+=kekka[i];
			}
			if(sum == n) {
				result.add("Yes");
			}
			else {
				result.add("No");
			}

		}
		for(int i = 0;i < (result.size());i++) {
			System.out.println(result.get(i));
		}
	}
}



Measured memory_bytes: 52784
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
    long long a;
    cin>>a;
    map<string,long long> mp;
    long long ans=0;
    rep(i,a){
        string s;
        cin>>s;
        if(mp[s]==0){
            ans++;
        }
        mp[s]++;
    }
    cout<<ans<<endl;
}



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


int a1();
void a2();
int a3();

int main()
{
	//cout << a1() << endl;
	//a2();
	a3();
	return 0;
}

//***********3
int cnt = 0;
void insertsort(vector<int> &v, int g);

int a3()
{
	//插入排序的特点：当数据相对有序时效率较高。利用对已经排好的数据进行插入排序，只需比较N次，而不需要移动。
	//希尔排序：利用插入排序的特点。
	//首先生成希尔数列(h = 3 * h + 1)

	//输入数据
	int n;//元素数目
	vector<int> v1;
	cin >> n;
	int temp;
	for (int i = 0; i<n; i++)
	{
		cin >> temp;
		v1.push_back(temp);
	}

	//生成数列
	vector<int> G;//希尔数列
	int h = 1;
	while (h <=n)
	{
		G.push_back(h);
		h = 3 * h + 1;
	}
	
	//间隔插入排序
	
	for (int i = G.size() - 1; i >= 0; i--)
	{
		
		insertsort(v1, G[i]);
	}
	
	//输出
	cout << G.size() << endl;;
	for (int i = G.size()-1; i >=0; i--)
	{
		if (i == G.size() - 1) cout << G[i];
		else cout << " " << G[i];
		cout<< endl;
	}
	
	cout << cnt << endl;
	for (int i = 0; i < v1.size(); i++)
		cout << v1[i] << endl;

	return 0;
}
void insertsort(vector<int> &v, int g)//间隔为g的插入排序
{
	int n = v.size();
	
	//cout << n << endl;
	for (int i = g; i < n; i++)
	{
		int t = v[i];
		int j = i - g;
		while (j >= 0 &&v[j]>t )//实际上只需要把v[i]插入到里面即可，v[j]都是已经排好序的...记住应该首先判断j,
			//对与每个 i 循环代码实际只运行一次
		{
			v[j + g] = v[j];
			j -= g;
			cnt++;//计算交换次数
			//cout << cnt << endl;
			
		}
		v[j + g] = t;
		//for (int i = 0; i < v.size(); i++)
		//	cout << v[i];
		//cout << endl;
	}
}


int a1()
{
	int n;
	cin >> n;
	vector<int> v;
	int t;
	for (int i = 0; i<n; i++)
	{
		cin >> t;
		v.push_back(t);
	}
	int tmin = v[0];
	int tmax = -1000000000;

	for (int i = 1; i<n; i++)
	{
		tmax = max(tmax, v[i] - tmin);
		tmin = min(tmin, v[i]);
	}
	return tmax;
}
void a2()
{
	cout << "插入排序，冒泡排序，选择排序空间复杂度O（1）,时间复杂度O（N^2）" << endl;
	cout << "插入排序，冒泡排序属于稳定排序" << endl;
	cout << "选择排序属于不稳定排序" << endl;
	cout << "冒泡排序的交换次数又称为逆序数，反映了数据的混乱程度" << endl;
}




Measured memory_bytes: 6952
n,m,x=map(int,input().split())
As=list(map(int,input().split()))

way=[]
for i in range(n):
  way.append(i)
  
ans1,ans2=0,0
for i in range(x,n,1):
  if i in As:
    ans1+=1
for i in range(x,0,-1):
  if i in As:
    ans2+=1
print(min(ans1,ans2))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int ans = 0;
        for (int i = 1; i < s.length; i++) {
            if(s[i-1] != s[i]) ans++;
        }

        System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 27668
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;

int main(){
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ans = max({
    a * c, a * d, b * c, b * d,
  });
  cout << ans << endl;
}

Measured memory_bytes: 3632
using DataStructures
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n,q = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	ft = FenwickTree(a)
	for query in 1:q
		x,y,z = readline() |> split |> parseMap
		if x == 0
			inc!(ft,y+1,z)
		else
			println(prefixsum(ft,z)-(y>0 ? prefixsum(ft,y) : 0))
		end
	end
end

main()

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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    while(1) {
        int aa = ans * 0.08;
        int bb = ans * 0.10;
        if(aa == a && bb == b) break;
        if(aa > a || bb > b) {
            ans = -1;
            break;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    ll ans = 0;
    cin >> n;
    map<ll,ll> mii;
    rep(i,n){
        int x;
        cin >> x;
        mii[x]++;
        ans += x;
    }
    int q;
    cin >> q;
    rep(i,q){
        ll b,c;
        cin >> b >> c;
       //cout << "start" << endl;
        /*for(auto u : mii){
            cout << u.first << " " << u.second << endl;
        }*/
        ans -= b*mii[b];
        ans += c*mii[b];
        mii[c] += mii[b];
        mii[b] = 0;
        cout << ans << endl;
    }
    return 0;
}

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

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


min_ = 10**9
sum_ = 0
m_count = 0
for a in An:
    if a < 0:
        m_count += 1

    t = abs(a)
    min_ = min(min_, t)
    sum_ += t


#print((min_,sum_,m_count))
ans = sum_ if m_count % 2 == 0 else sum_ - 2*min_

print(ans)


    

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

int n,last[200010];
long long ans=0;

int main(){
	scanf("%d",&n);
	int bound=0;
	memset(last,-1,sizeof(last));
	for(int i=0;i<n;i++){
		int x;
		scanf("%d",&x);
		for(int j=0;j<20;j++){
			if(x&(1<<j)){
				bound=max(bound,last[j]+1);
				last[j]=i;
			}
		}
		ans+=i-bound+1;
	}
	printf("%lld\n",ans);
	return 0;
} 

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

int main(int argc, char const *argv[]) {
	int m;
	string train, s1, s2;
	set<string> ts;

	cin >> m;
	for (int i = 0; i < m; ++i) {
		cin >> train;
		ts.clear();
		for (int j = 1; j < train.size(); ++j) {
			s1 = train.substr(0, j);
			s2 = train.substr(j, train.size());
			ts.insert(s1 + s2);
			ts.insert(s2 + s1);
			reverse(s2.begin(), s2.end());
			ts.insert(s1 + s2);
			ts.insert(s2 + s1);
			reverse(s1.begin(), s1.end());
			ts.insert(s1 + s2);
			ts.insert(s2 + s1);
			reverse(s2.begin(), s2.end());
			ts.insert(s1 + s2);
			ts.insert(s2 + s1);
		}

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

	return 0;
}

Measured memory_bytes: 1288
import java.util.*;

public class Main {
  static int INF = 10000;
  static int N,A,B,C;
  static int[] l;
  
  public static void main(String[] args) {    
    Scanner sc = new Scanner(System.in);
    N = sc.nextInt();A = sc.nextInt();
    B = sc.nextInt();C = sc.nextInt();
    l = new int[N];
    for (int i =0; i<N; i++) l[i] = sc.nextInt();
    System.out.println(dfs(0,0,0,0));
  }

  public static long dfs(int cur, int a, int b, int c) {
    int min = INF;
    if (cur == N) {
      if (Math.min(a,Math.min(b, c)) == 0) return Integer.MAX_VALUE;     
      return Math.abs(a - A) + Math.abs(b - B) + Math.abs(c - C) - 30;
    }
    long ret0 = dfs(cur + 1, a, b, c);
    long ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;
    long ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
    long ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;
    return Math.min(Math.min(ret0,ret1),Math.min(ret2,ret3));
  }
}

Measured memory_bytes: 38152
import sys
sys.setrecursionlimit(10**6)

def f(j):
  nodes[j]=1
  for k in links[j]:
    if nodes[k]==0:
      f(k)

N, M=map(int, input().split())
XYZ=[list(map(int, input().split())) for _ in range(M)]
links=[[] for _ in range(N+1)]
for i in range(M):
  links[XYZ[i][0]].append(XYZ[i][1])
  links[XYZ[i][1]].append(XYZ[i][0])
  
nodes=[0]*(N+1)
ans=0
for i in range(1, N+1):
  if nodes[i]==0:
    ans+=1
    nodes[i]=1
    for j in links[i]:
      f(j)
      
print(ans)

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

int main(){
	int x;
  	cin>>x;
  
  	int h=0;
  
    h+=1000*(x/500);
    x=x%500;
  	
  	h+=5*(x/5);
  	x=x%5;
  
  	cout<<h<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22){
        cout<<"bust"<<endl;
    }
    else{
        cout<<"win"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
using namespace std;
typedef pair<int64_t,int64_t> P;
typedef pair<int64_t,P> T;
const int64_t INF=1e15;

class uft {//union-find tree
public:
    int parent[200010];
    int root(int x);
    bool same(int x,int y);
    void unite(int x,int y);
};
int uft::root(int x){
    if(parent[x]==x){
        return x;
    }
    return parent[x] = root(parent[x]);
}
bool uft::same(int x,int y){
    if(root(x)==root(y)){
        return true;
    }else{
        return false;
    }
}
void uft::unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x == y) return;
    parent[x] = y;
}
int64_t Kruskal(priority_queue<T, vector<T>, greater<T> > q,int N){
    uft u;
    for(int i=0;i<N;i++){
        u.parent[i]=i;
    }
    int64_t ret=0;
    while(!q.empty()){
        T edge = q.top(); q.pop();
        int s=(edge.second).first;
        int t=(edge.second).second;
        if(u.root(s) != u.root(t) ){
            u.unite(s,t);
            ret += edge.first;
        }
    }
    return ret;
}

int main(){
    int N,Q;
    cin>>N>>Q;
    int64_t neigh[200001];
    fill(neigh,neigh+N,INF);
    priority_queue<T, vector<T>, greater<T> > q;
    for(int i=0;i<Q;i++){
        int64_t A,B,C;
        cin>>A>>B>>C;
        q.push(T(C,P(A,B)));
        neigh[A]=min(neigh[A],C+1);
        neigh[B]=min(neigh[B],C+2);
    }
    for(int i=0;i<2*N;i++){
        int k=i%N;
        int l=(i+1)%N;
        neigh[l]=min(neigh[l],neigh[k]+2);
    }
    for(int i=0;i<N;i++){
        q.push(T(neigh[i],P(i,(i+1)%N)));
    }
    int64_t res = Kruskal(q,N);
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 24552