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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define MOD 1000000007

uint add(uint a, uint b) { return a+b < MOD ? a+b : a+b-MOD; }
uint sub(uint a, uint b) { return a < b ? a+MOD-b : a-b; }
uint mul(uint a, uint b) { return (ull)a*b%MOD; }
uint sqr(uint a) { return mul(a, a); }

uint modpow(uint b, uint e)
{
    uint r = 1;
    for (; e; e >>= 1) {
        if (e&1) r = mul(r, b);
        b = mul(b, b);
    }
    return r;
}

uint modinv(uint n) { return modpow(n, MOD-2); }
uint moddiv(uint n, uint d) { return mul(n, modinv(d)); }

#define N 100016

uint ans = 1;
vi adj[N];

void dfs(int u, int k, int c = 0, int p = 0)
{
    ans = mul(ans, max(k-c, 0));
    c = p > 0;
    for (int v : adj[u]) {
        ctif(v == p);
        dfs(v, k, ++c, u);
    }
}

int main()
{
    canhazfast();

    int n, k;

    cin >> n >> k;
    for (int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    dfs(1, k);
    cout << ans << '\n';

    return 0;
}


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

const int MAX = 100;
const int INF = 1 << 29;

int n;
int grid[MAX][MAX];

int prim()
{
	int ans[MAX];
	int visited[MAX];

	for (int i = 0; i < n; i++) {
		ans[i] = INF;
		visited[i] = false;
	}

	ans[0] = 0;

	while (true) {
		int min = INF;
		int min_index;

		for (int i = 0; i < n; i++) {
			if (min > ans[i] && visited[i] == false) {
				min = ans[i];
				min_index = i;
			}
		}

		if (min == INF) {
			break;
		}

		visited[min_index] = true;

		for (int i = 0; i < n; i++) {
			if (ans[i] > grid[min_index][i] && visited[i] == false) {
				ans[i] = grid[min_index][i];
			}
		}
	}

	int sum = 0;

	for (int i = 0; i < n; i++) {
		sum += ans[i];
	}

	return sum;
}

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int temp;
			cin >> temp;

			if (temp == -1) {
				grid[i][j] = INF;
			}
			else {
				grid[i][j] = temp;
			}
		}
	}

	cout << prim() << endl;

	return 0;
}

Measured memory_bytes: 3132
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>
#include <cmath>
#include <iomanip>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    int N;

    cin >> N;

    vector<pair<int, int>> segments;

    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;

        int min_val(0);
        int balance(0);
        for (auto x : S) {
            if (x == '(') {
                balance++;
            } else {
                balance--;
                min_val = min(balance, min_val);
            }
        }

        segments.emplace_back(balance, min_val);
    }

    vector<pair<int, int>> positive, negative;

    for (auto s : segments) {
        if (s.first >= 0) {
            positive.push_back(s);
        } else {
            negative.push_back(s);
        }
    }

    sort(positive.begin(), positive.end(), [&](const pair<int,int>& A, const pair<int, int>& B) {
        if (A.second != B.second)
            return A.second > B.second;
        else
            return A.first > B.first;
    });

    sort(negative.begin(), negative.end(), [&](const pair<int,int>& A, const pair<int, int>& B) {
        return A.first - A.second > B.first - B.second;
    });

    int X = 0;

    for (auto s : positive) {
        if (X + s.second < 0) {
            cout << "No\n";
            return 0;
        }
        X += s.first;
    }

    for (auto s : negative) {
        if (X + s.second < 0) {
            cout << "No\n";
            return 0;
        }
        X += s.first;
    }

    cout << (!X ? "Yes\n" : "No\n");

    return 0;
}


Measured memory_bytes: 24368
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	sum := 0
	for i := 0; i < n; i++ {
		sum += getNextInt(scanner) % 2
	}

	if sum%2 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
	writer.Flush()
}


Measured memory_bytes: 2688
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

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

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    vec<ll> v(3);
    for (auto& e : v)
    {
        cin >> e;
    }

    int k;
    cin >> k;

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

    cout << v[0] + v[1] + v[2] * (1 << k) << endl;
    
    
    

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define VMAX 10000

void C(unsigned short *, unsigned short *, int);

int main(){
    unsigned short *A, *B;
    int n, i;

    scanf("%d", &n);

    A = malloc(sizeof(short)*n+1);
    B = malloc(sizeof(short)*n+1);

    /* your code */
    for(i = 0; i < n; i++){
        scanf("%hu",&A[i]);
    }

    C(A, B, n);

    for(i = 1; i < n; i++)
        printf("%u ",B[i]);
    printf("%u\n",B[i]);

  return 0;
}

void C(unsigned short *A, unsigned short *B, int n){
    int i, j;
    int C[VMAX+1]; 

    for(i = 0; i <= VMAX; i++)
        C[i] = 0;
    
    for(j = 0; j < n; j++)
        C[A[j]] = C[A[j]] + 1;

    for(i = 1; i <= VMAX; i++)
        C[i] = C[i] + C[i-1];
    
    for(j = n-1; j >= 0; j--){
        B[C[A[j]]] = A[j];
        C[A[j]] = C[A[j]] - 1;
    }
}


Measured memory_bytes: 9588
#include <stdio.h>

int n,ans,tmp,i,j,k,y,tmp1,tmp2 ;
char s[120] ;
char p[30]="abcdefghijklmnopqrstuvwxyz" ;

int main(void){
    
    scanf ("%d%s",&n,s) ;


    for (y=1; y<n; y++){
        for (i=0; i<26; i++){
            for (k=0; k<y; k++){
                if ( s[k]==p[i] ){
                tmp1 = 1 ;
                break ;
                }
            }    
            for (j=y; j<n; j++){
                if ( s[j]==p[i] ) {
                tmp2 = 1 ;
                break ;
                }
            }
            
            if ( tmp1==1 && tmp2==1 ){
                tmp++ ;
            }
            
            tmp1 = 0 ;
            tmp2 = 0 ;
    }
        if ( ans<tmp ){
            ans=tmp ; 
        }
        
        tmp = 0 ;
    }
    
    printf("%d\n",ans) ;
    
    return 0 ;
}

Measured memory_bytes: 128
mi = lambda : map(int, input().split())

import math

a, b, x = mi()

if x <= (a*b/2)*a:
    c = x*2/(a*b)
    ans = math.degrees(math.atan(b/c))
else:
    d = ((a*a*b-x)*2/(a*a))
    ans = math.degrees(math.atan(d/a))

print(ans)

Measured memory_bytes: 3060
import numpy as np
import math
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

p = np.arange(N) + 1

def dict_num(arr, N):
    n = 1
    num_used = []
    for i in range(N):
        k = 0
        for a in range(1, arr[i]):
            if a in num_used:
                k += 1
        n += (arr[i] - 1 - k) * math.factorial(N - i - 1)
        num_used.append(arr[i])
    return n

p_n = dict_num(P, N)
q_n = dict_num(Q, N)
print(abs(p_n - q_n))

Measured memory_bytes: 13036
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		char[][] A = new char[N][N];
		char[][] B = new char[M][M];
		for (int i = 0; i < N; i++) {
			A[i] = sc.next().toCharArray();
		}
		for (int i = 0; i < M; i++) {
			B[i] = sc.next().toCharArray();
		}

		for (int i = 0; i <= N-M; i++) {
			for (int j = 0; j <= N-M; j++) {
					a: for (int k = 0; k < M ; k++) {
						for (int l = 0; l < M; l++) {
							if (A[i+k][j+l] != B[k][l]) {
								break a;
							} else if (k == M - 1 && l == M  - 1) {
								System.out.println("Yes");
								return;
							}
					    }
					  }
				
				
			}

		}

		System.out.println("No");
	}

}


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

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


Measured memory_bytes: 3556
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>

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

using namespace std;

template<class T, class U>
istream& operator>>(istream& is, pair<T, U>& pair)
{
    is >> pair.first >> pair.second;
    return is;
}

template<class T>
istream& operator>>(istream& is, vector<T>& collection)
{
    for(auto& item : collection) is >> item;
    return is;
}

template <class T>
T peak_and_pop(std::queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.front());
    q.pop();
    return t;
}

template <class T>
T peak_and_pop(std::priority_queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

template <class T>
T peak_and_pop(std::stack<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

constexpr double rad2deg(double x)
{
    return 180 * x / 3.14159265358979323846;
}

void solution()
{
    double a,b,x;
    cin >> a >> b >> x;
    cout << fixed << setprecision(10);
    if(x > a*a*b/2){
        cout << rad2deg(atan(2*b/a - 2*x/(a*a*a))) << '\n';
    }else{
        cout << rad2deg(atan(a*b*b/(2*x))) << '\n';
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solution();
    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    A = list(map(int,input().split()))
    B = [0] * n
    x = 0
    for a in A:
        x ^= a
    for i in range(n):
        B[i] = x^A[i]
    print(" ".join(map(str,B)))


if __name__=='__main__':
    main()

Measured memory_bytes: 41616
from collections import defaultdict


def combination(n, r):
    ret = 1
    a = 1
    b = 1
    for i in range(1,r+1):
        a *= (n+i-1)
        b *= (r-i+1)
    return a // b


def compute_divisors(n):
    ret = defaultdict(int)
    m = n
    while m%2 == 0:
        ret[2] += 1
        m = m//2
    r = 3
    while m > 1:
        if r**2 > m:
            ret[m] = 1
            break
        while m%r==0:
            ret[r] += 1
            m = m//r
        r += 2
    return ret


def main():
    N, M = list(map(int, input().split(' ')))
    divisors = compute_divisors(M)
    exp = 0
    ret = 1
    for d in divisors:
        c = divisors[d]
        ret *= combination(N,c)
        ret %= 1000000007
    print(ret)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
//cout << fixed << setprecision(10);

int main () {
  string L[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string s;
  cin >> s;
  int ans;
  rep(i,7) {
    if (s == L[i]) {
      ans = 7-i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  long long N;

  std::cin >> N;

  std::string s = "0";

  if (N > 0) {
    long long x = 0x55555555LL, b = 0x80000000LL;

    for (int i = 0; b; i ++, b >>= 1) {
      bool f = i % 2 == 0 ? false : true;

      if (x > N)
        if (x - b >= N) {
          x -= b;
          
          f = ! f;
        }

      s += f ? "1" : "0";
    }
  }
  else if (N < 0) {
    N = -N;
    
    long long x = 0xaaaaaaaaLL, b = 0x80000000LL;

    for (int i = 0; b; i ++, b >>= 1) {
      bool f = i % 2 == 0 ? true : false;

      if (x > N)
        if (x - b >= N) {
          x -= b;
          
          f = ! f;
        }

      s += f ? "1" : "0";
    }
  }

  while (s[0] == '0')
    s.erase(std::begin(s));

  if (s.empty())
    s.push_back('0');

  std::cout << s << std::endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int already_n = Integer.parseInt(sc.next());
        boolean[][] board = new boolean[8][8];
    	for(int i=0; i<8; i++){
    		for(int j=0; j<8; j++){
    		    board[i][j] = false;
    		}
    	}
        
        int row =0, column=0;
        for(int i=0; i<already_n; i++){
            row = Integer.parseInt(sc.next());
            column = Integer.parseInt(sc.next());
            board[row][column] = true;
        }
        
        ArrayList<boolean[][]> ans = boardAll(board, 0);
        boolean[][] new_board = new boolean[8][8];
        
        for(int i=0; i<ans.size(); i++){
                new_board = ans.get(i);
        		for(int j=0; j<8; j++){
        			for(int k=0; k<8; k++){
        			    if(new_board[j][k]) System.out.print("Q");
        			    else System.out.print(".");
        			}
        			System.out.println();
            }
        }
        
    }
    private static boolean ckConflict(boolean[][] board, int y, int x){       //true・・・ぶつかる
        int over = 0;
        for(int i=0; i<8; i++){
            if(board[i][x]) over++;
            if(over>0) return true;
        }
        over = 0;
        for(int i=0; i<8; i++){
            if(board[y][i]) over++;
            if(over>0) return true;
        }
        over = 0;
        for(int i=-8; i<8; i++){
            if(((x+i)>=0) && ((y+i)>=0) && ((x+i)<8) && ((y+i)<8)){
                if(board[y+i][x+i]) over++;
            }
            if(over>0) return true;
        }
        over = 0;
        for(int i=-8; i<8; i++){
            if(((x-i)>=0) && ((y+i)>=0) && ((x-i)<8) && ((y+i)<8)){
                if(board[y+i][x-i]) over++;
            }
            if(over>0) return true;
        }
        return false;
    }
    
    private static ArrayList<boolean[][]> boardAll(boolean[][] board, int r_now){
        ArrayList<boolean[][]> ans = new ArrayList<boolean[][]>(1);
        boolean there = false;
        boolean[][] new_board = new boolean[8][8];
        
        if(r_now==8){
            ans.add(board.clone());
            return ans;
        }
        
        for(int i=0; i<8; i++){
            if(board[r_now][i]) there=true;
        }
        if(there){
            return boardAll(board, r_now+1);
        }else{
            for(int i=0; i<8; i++){
                if(!ckConflict(board, r_now, i)){
                    for(int j=0; j<8; j++){ new_board[j] = board[j].clone(); }
                    new_board[r_now][i] = true;
                    ans.addAll(boardAll(new_board, r_now+1));
                }
            }
            return ans;
        }
    }
}


Measured memory_bytes: 26320
#include<iostream>
#include<algorithm>
#define INF 1145141919
using namespace std;
int n,m;
int dp[2][256],c[16];
int main(){
	while(cin>>n>>m&&n+m){
	for(int i=0;i<m;i++)cin>>c[i];
	for(int i=0;i<256;i++)dp[0][i]=INF,dp[1][i]=INF;
	dp[0][128]=0;
	for(int i=0;i<n;i++){
		int x;cin>>x;bool t=i%2;
		for(int j=0;j<256;j++){
			for(int k=0;k<m;k++){
				int y=j+c[k];if(y<0)y=0;if(y>255)y=255;
				int z=(x-y)*(x-y)+dp[t][j];
				dp[1-t][y]=min(dp[1-t][y],z);
			}
		}
		for(int j=0;j<256;j++)dp[t][j]=INF;
	}
	int ans=INF;
	for(int i=0;i<256;i++){
		ans=min(ans,dp[n%2][i]);
	}
	cout<<ans<<endl;
	}
	return 0;
}

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

int main() {
	
	int n, m;
	cin >> n >> m;
	
	vector< vector<int> > jobs(m);
	priority_queue<int> pq;
	ll ans = 0;
	rep(i, n){
		int a, b;
		cin >> a >> b;
		if(a > m)	continue;
		jobs[a-1].push_back(b);
	}
	
	rep(i, m){
		for(int b: jobs[i]){
			pq.push(b);
		}
		if(!pq.empty()){
			ans += pq.top();
			pq.pop();
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef double db;

#define rep_it(it,x) for (__typeof((x).begin()) it=(x).begin(); it!=(x).end(); it++)
#define ____ puts("\n_______________\n\n") 
#define debug(x) ____; cout<< #x << " => " << (x) << endl
#define debug_pair(x) cout<<"\n{ "<<(x).fir<<" , "<<(x).sec<<" }\n"
#define debug_arr(x,n) ____; cout<<#x<<":\n"; rep(i,0,n+1) cout<<#x<<"["<<(i)<<"] => "<<x[i]<<endl
#define debug_arr2(x,n,m) ____; cout<<#x<<":\n"; rep(i,0,n) rep(j,0,m) cout<<#x<<"["<<(i)<<"]["<<(j)<<"]= "<<x[i][j]<<((j==m)?"\n\n":"    ")
#define debug_set(x) ____; cout<<#x<<": \n"; rep_it(it,x) cout<<(*it)<<" "; cout<<endl
#define debug_map(x) ____; cout<<#x<<": \n"; rep_it(it,x) debug_pair(*it)

void file_put() {
    freopen("filename.in", "r", stdin);
    freopen("filename.out", "w", stdout);
}

const int N=1e5+5; 
int n,ans=0,a[N],k; bool v[N]; int f[N][20],id[N],p[N],dep[N]; vi V[N];

int G(int x,int k) {
	per(i,0,20) if (k>>i&1) x=f[x][i];
	return x;
}

void dfs(int x,int d) {
	v[x]=1; if (dep[x]==-1) dep[x]=d;
	for (auto y:V[x]) if (!v[y]) dfs(y,d+1);
}

bool cmp(int x,int y) {
	return dep[x]>dep[y];
}

int main() {
//	file_put();
	
	scanf("%d%d",&n,&k);
	rep(i,1,n+1) scanf("%d",&a[i]);
	ans=(a[1]!=1),a[1]=1;
	rep(i,2,n+1) V[a[i]].pb(i);
	memset(dep,-1,sizeof(dep)); 
	dfs(1,0); memset(v,0,sizeof(v)); 
	if (k>=n-1) return 0*printf("%d\n",ans);
	rep(i,1,n+1) f[i][0]=a[i];
	rep(i,1,20) rep(j,1,n+1) f[j][i]=f[f[j][i-1]][i-1];
	rep(i,1,n+1) p[i]=G(i,k-1),id[i]=i;
	sort(id+1,id+n+1,cmp);
	rep(i,1,n+1) {
		if (dep[id[i]]<=k) break;
		if (v[id[i]]) continue;
		if (a[p[id[i]]]==1) continue;
		ans++;
		dfs(p[id[i]],0);
//		debug_arr(dep,n);
	}
	printf("%d\n",ans);
	
	return 0;
}



Measured memory_bytes: 18304
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
typedef long long LL;

string s;
int n,cnt = 0;

int main(){
	cin >> s;
	n = s.length();
	for(int i = 0;i < n;i ++){
		if(s[i] != s[n - i - 1]) cnt ++;
	}
	cout << (cnt >> 1) << endl;
	return 0;
}

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

typedef long long ll;
using namespace std;

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

	bool f[31] = {false};

	for (int i = 0;i < 28;i++){
		int tmp; cin >> tmp;
		f[tmp] = true;
	}

	for (int i = 1;i < 31;i++){
		if(!f[i]) cout << i << endl;
	}

	return 0;

}



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

int main()
{
    ll n,a[100000+9],b[100000+9]= {0},i,j,f=0,c=0;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    for(i=0; i<n; i++)
    {
        if(a[i]!=b[i])
        {
            f=1;
            c++;
        }
    }

    if(f==0)
    {
        cout<<"YES"<<endl;
    }
    else if(f==1)
    {
        if(c==2)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    ll n,k;cin>>n>>k;
    int a[n];
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
    bool seen[n];
    rep(i,n)seen[i]=false;
    ll now=0;
    ll st;
    rep(i,n+5){
        if(seen[now]){
            st=i;
            break;
        }
        seen[now]=true;
        now = a[now];
    }
    rep(i,n)seen[i]=false;
    vi res;
    while(!seen[now]){
        seen[now]=true;
        res.push_back(now);
        now=a[now];
    }
    ll x= k;
    if(st>=k){
        now =0;
        rep(i,k){
            now=a[now];
        }
        cout<<now+1<<endl;
        return 0;
    }
    x-=st-res.size();
    x%=res.size();
    cout<<res[min(k,x)]+1<<endl;
    

}


Measured memory_bytes: 5120
N, W = map(int, input().split())
w = [list(map(int, input().split())) for _ in range(N)]
dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]

for i in range(N):
    for j in range(W + 1):
        if j - w[i][0] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i][0]] + w[i][1])

        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])

print(dp[N][W])

Measured memory_bytes: 171784
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int[] a = new int[N];
   for(int i =0;i<N;i++) a[i] =sc.nextInt();
   boolean br = true;
   int tmp = 1;
   int ans = -1;
   
   for(int i=1;i<=100000;i++)
   {
     tmp=a[tmp-1];
     if(tmp==2)
     {
       ans = i;
       break;
     }
   }
   System.out.println(ans);
 }
}

Measured memory_bytes: 50864
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
typedef long long int ll;
#define iceil(x,y) (x+y-1)/y
#define min(x,y)(x<y?x:y)
 
using namespace std;
typedef pair<int, int> P;

int main() {
	FAST;

	ll n;
	cin >> n;

	string ans="";

	while(n!=0) {
		if (n%2!=0) {
			n--;
			ans = "1"+ans;
		}
		else {
			ans = "0"+ans;
		}
		n /= -2;
	}

	if (ans=="") ans = "0";

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int hp = sc.nextInt();
		int n = sc.nextInt();
		for(int i = 0; i < n; i++){
			hp -= sc.nextInt();
		}
		if(hp <= 0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}

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

int main() {
  int n;
  scanf("%d", &n);
  vector<int> l(n);
  for (int i = 0; i < n; i++)
    scanf("%d", &l[i]);

  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (l[i] != l[j])
        for (int k = j + 1; k < n; k++)
          if (l[k] != l[i] && l[k] != l[j] && l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[j] + l[k] > l[i])
            ans++;
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 3788
N = int(input())

scores = [int(i) for i in input().split()]

under_3200_cnt = {}
over_3200_cnt = 0
for score in scores:
    key = score // 400
    if key >= 8:
        over_3200_cnt += 1
    else :
        under_3200_cnt.setdefault(key, 0)
        under_3200_cnt[key] += 1
        
colors = len(under_3200_cnt.keys())

if over_3200_cnt == 0:
    min_color = colors
    max_color = colors
else :
    if colors >= 1:
        min_color = colors
    else :
        min_color = 1
    max_color = colors + over_3200_cnt
    
print(min_color, max_color)

Measured memory_bytes: 3064
h, w = map(int, input().split())

a = [list(map(int, input().split())) for i in range(h)]
b = [list(map(int, input().split())) for i in range(h)]

c = [[abs(a[i][j] - b[i][j]) for j in range(w)] for i in range(h)]
mask = (1 << (h+w) * 80) - 1
sets = [[0 for j in range(w)] for i in range(h)]
sets[0][0] = (1 << 80+c[0][0]) | (1 << 80-c[0][0])
for i in range(1, h):
    sets[i][0] |= (sets[i - 1][0] << 80 + c[i][0]
                   ) | (sets[i - 1][0] << 80 - c[i][0])
for i in range(1, w):
    sets[0][i] |= (sets[0][i-1] << 80 + c[0][i]
                   ) | (sets[0][i-1] << 80 - c[0][i])
for i in range(1, h):
    for j in range(1, w):
        sets[i][j] |= (sets[i - 1][j] << 80 + c[i][j]
                       ) | (sets[i - 1][j] << 80 - c[i][j])
        sets[i][j] |= (sets[i][j-1] << 80 + c[i][j]
                       ) | (sets[i][j - 1] << 80 - c[i][j])
    sets[i][j] &= mask

s = bin(sets[h - 1][w - 1] + (1 << (h + w) * 80))
min_v = 1 << 80
for i in range(len(s)):
    if s[-1-i] == '1':
        min_v = min(min_v, abs(i - (h + w) * 80 + 80))
print(min_v)


Measured memory_bytes: 52700
from math import atan2, degrees
A, B, X = map(int, input().split())
S = X / A


if S >= A * B / 2:
    h = (2 * (A * B - S)) / A
    print(degrees(atan2(h, A)))

else:
    w = (2 * S) / B
    print(degrees(atan2(B, w)))


Measured memory_bytes: 3188
#include <iostream>
#define MAXN 10000
using namespace std;

string s[50];
int w,h,count,minsum=MAXN;
char color;

int change(int i,int j){
	int sum=0;
	for(int k=0;k<h;k++){
		if(k<i){
			color='W';
		}else if(k<j){
			color='B';
		}else{
			color='R';
		}
		for(int l=0;l<w;l++){
			if(s[k][l]!=color)sum++;
		}
	}
	return sum;
}


int main(){
	cin >>h >>w;
	for(int i=0;i<h;i++){
		cin >> s[i];
	}
	for(int i=1;i<h-1;i++){
		for(int j=i+1;j<h;j++){
			count=change(i,j);
			if(count<minsum)minsum=count;
		}

	}
	cout << minsum<<endl;
	return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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


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

    int sum = 0;

    for (int i = 1; i <= k ; i++)
    {
        for (int j = 1; j <=k; j++)
        {
            for (int l = 1; l <=k; l++)
            {
                sum += gcd(gcd(i,j),l);
            }
            
        }
        
    }
    
    cout << sum << endl;

    return 0;
}

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

// 互除法で2正数x,yのgcdを返す関数
int gcd (int x, int y) {
    int p = x % y;
    while(p){
        x = y;
        y = p;
        p = x % y;
    }
    return y;
}

int main() {
    int N, M;
    string S, T;
    cin >> N >> M >> S >> T;
    int k = gcd(N, M);
    ll lcm = N;
    lcm *= M / k;
    ll id = 0;
    for (int i = 0; i < k; ++i) {
        if(S[id/M] != T[id/N]){
            cout << -1 << "\n";
            return 0;
        }
        id += lcm;
    }
    cout << lcm;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
map<int,double>mp;
main()
{
     int n,i,j;
     cin>>n;
     double p[n+1],ans=0;
     for(i=1;i<=n;i++)
     {
         scanf("%lf",&p[i]);
     }
     mp[1]=p[1];mp[0]=1-p[1];mp[-1]=0;
     for(i=2;i<=n;i++)
     {
        for(j=i;j>=0;j--)
        {
            mp[j]=mp[j]*(1-p[i])+mp[j-1]*p[i];
        }
        //cout<<mp[0]<<" "<<mp[1]<<" "<<mp[2]<<" "<<mp[3]<<endl;
     }
     for(i=n/2+1;i<=n;i++)
     {
         ans+=mp[i];
         //cout<<i<<" "<<mp[i]<<endl;
     }
     printf("%.10lf\n",ans);
     //cout<<ans<<endl;
}


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

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

const int dx[9] = { 1,1,1,0,0,0,-1,-1,-1 }, dy[9] = { 1,0,-1,1,0,-1,1,0,-1 };
const int inf = 1e16;

int h, w, n, a, b, cnt, x, y, nx, ny, nnx, nny, sum;
unordered_map<int, bool>mp;
int ans[10], v[100001];
signed main() {
	scanf("%lld %lld %lld", &h, &w, &n);
    v[n] = inf;
	rep(i, n) {
		scanf("%lld %lld", &a, &b);
		--a; --b;
		v[i]= w * a + b;
	}
	sort(v, v + n);
	for (int i : v) {
        if(i == inf) break;
		y = i / w, x = i % w;
		rep(j, 9) {
			nx = x + dx[j], ny = y + dy[j];
			if (1 <= nx && nx < w - 1 && 1 <= ny && ny < h - 1) {
				if (!mp[w * ny + nx]) {
					mp[w * ny + nx] = true;
					rep(k, 9) {
						nnx = nx + dx[k], nny = ny + dy[k];
						if (binary_search(v, v + n, w * nny + nnx)) {
							++cnt;
						}
					}
					++ans[cnt];
					++sum;
					cnt = 0;
				}
			}
		}
	}
	ans[0] += (h - 2) * (w - 2) - sum;
	for (int i : ans) {
		printf("%lld\n", i);
	}
}

Measured memory_bytes: 37392
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int A[2000010];
int C[100010];
 
int main (){
	int n;
	cin>>n;
	for(int i=0;i<100000;i++) C[i]=0;
	for(int i=0;i<n;i++) {
		cin>>A[i];
		C[A[i]]++;
	}
	int flag=0;
	for(int i=0;i<100000;i++){
		for(int j=C[i];j>0;j--) if(flag) {
			cout<<" "<<i;
			flag++;
		}
		else {cout<<i;flag++;}
	}
	cout<<endl;
	return 0;
}


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

// TLEった解法
void solve1(long long N, long long Q, std::string S, std::vector<long long> l, std::vector<long long> r){
    long long left, right, cnt;
    string ss;
    for(long long i = 0; i < Q; i++){
        cnt = 0;
        left = l[i]-1;
        right = r[i]-1;
        ss = S.substr(left, right - left + 1);
        //cout << "ss: " << ss << endl;
        for(long long j = 0; j < ss.size() - 1; j++){
            //cout << "ss.substr: " << ss.substr(j, 2) << endl;
            if(ss.substr(j, 2) == "AC"){
                cnt++;
            }
        }
        cout << cnt << endl;
    }
}

void solve2(long long N, long long Q, std::string S, std::vector<long long> l, std::vector<long long> r){
    vector<long long> cumsum(N+1, 0);
    for(long long i = 0; i < N; i++){
        if(S.substr(i, 2) == "AC") cumsum[i+1] = cumsum[i] + 1;
        else cumsum[i+1] = cumsum[i];
    }
    long long left, right, cnt;
    for(long long i = 0; i < Q; i++){
        cnt = 0;
        left = l[i]-1;
        right = r[i]-1;
        cnt = cumsum[right] - cumsum[left];
        cout << cnt << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long Q;
    scanf("%lld",&Q);
    std::string S;
    std::cin >> S;
    std::vector<long long> l(Q);
    std::vector<long long> r(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&l[i]);
        scanf("%lld",&r[i]);
    }
    //solve1(N, Q, S, std::move(l), std::move(r));
    solve2(N, Q, S, std::move(l), std::move(r));
    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=1e7;
const ll INF=(1ll<<60);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
    int N;
    vi bit;
    Binary_indexed_tree(int n):N(n){
        bit.resize(N+1,0);
    }
    void add(int x,int a){
        for(x;x<=N;x+=(x&-x)) bit[x]+=a;
    }
    ll sum(int x){
        ll ret=0;
        for(x;x>0;x-=(x&-x)) ret+=bit[x];
        return ret;
    }
};
struct Union_Find{
    ll N;
    vi par;
    vi siz;
    Union_Find(int n):N(n){
        par.resize(N);
        siz.resize(N,1);
        rep(i,0,N) par[i]=i;
    }
    ll root(ll X){
        if(par[X]==X) return X;
        return par[X]=root(par[X]);
    }
    bool same(ll X,ll Y){
        return root(X)==root(Y);
    }
    void unite(ll X,ll Y){
        X=root(X);
        Y=root(Y);
        if(X==Y) return;
        par[X]=Y;
        siz[Y]+=siz[X];
        siz[X]=0;
    }
    ll size(ll X){
        return siz[root(X)];
    }
};
ll modpow(ll X,ll Y){
    ll sum=X,cnt=1;
    vi A;
    while(cnt<=Y){
        A.pb(sum);
        sum*=sum;
        sum%=MOD;
        cnt*=2;
    }
    int M=A.size();
    ll ret=1;
    REP(i,1,M){
        if(Y>=(1ll<<M-i)){
            Y-=(1ll<<M-i);
            ret*=A[M-i];
            ret%=MOD;
        }
    }
    return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n,ll r){
    if(n<r||n<0||r<0) return 0;
    return fac[n]*finv[r]%MOD*finv[n-r];
}
signed main(){
    ll L; cin>>L;
    vi A(L);
    rep(i,0,L) cin>>A[i];
    vector<vii> dp(2,vii(L+1,vi(3)));
    rep(i,0,2){
        rep(j,0,L){
            dp[i][j+1][0]=dp[i][j][0]+A[j];
            dp[i][j+1][1]=std::min({dp[i][j][1],dp[i][j][0],dp[i][j][2]})+1-A[j]%2;
            ll X=A[j]%2;
            if(A[j]==0) X+=2;
            dp[i][j+1][2]=std::min(dp[i][j][2],dp[i][j][0])+X;
        }
        reverse(ALL(A));
    }
    vii min(2,vi(L+1));
    rep(i,0,2){
        REP(j,0,L) min[i][j]=std::min({dp[i][j][0],dp[i][j][1],dp[i][j][2]});
    }
    ll ans=INF;
    REP(i,0,L) ans=std::min(ans,min[0][i]+min[1][L-i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 34688
import sys

get = sys.stdin.readline()
a, b = get.split(" ")
a2 = int(a)
b2 = int(b)
ans = 0
if(b2 == 100):
    ans = (b2+1) * (10 ** (a2*2))
else:
    ans = b2 * (10 ** (a2*2))
print(ans)

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

#define HAS_TEST_CASE 0  // Do you forget to complete this?

namespace rG
{
typedef long long ll;

const int N=5e5;

int n,m,a[N+10];
char str[N+10];

inline void main()
{
	scanf("%s",str);
	if(str[0]=='R'&&str[1]=='R'&&str[2]=='R')puts("3");
	else if(str[0]=='R'&&str[1]=='R'||str[1]=='R'&&str[2]=='R')puts("2");
	else if(str[0]=='S'&&str[1]=='S'&&str[2]=='S')puts("0");
	else puts("1");
}
}

int main()
{
#if !defined(ONLINE_JUDGE)&&HAS_TEST_CASE
	freopen("tmp.out","w",stdout);
#endif
	int T=1;
#if HAS_TEST_CASE
	scanf("%d",&T);
#endif
	while(T--)rG::main();
	return 0;
}


Measured memory_bytes: 3756
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = scan.nextInt();
		}
		bubbleSort(A, N);
		scan.close();
	}

	public static void bubbleSort(int[] A, int N) {
		// ???????????°
		int count = 0;
		boolean flag = true;
		int i = 0;
		while(flag){
			flag = false;
			for (int j = N - 1; j > i; j--) {
				if (A[j] < A[j - 1]) {
					int temp = A[j];
					A[j] = A[j - 1];
					A[j - 1] = temp;
					flag = true;
					count++;
				}
			}
			i++;
		}
		String output = Arrays.toString(A).replaceAll(",", "");
		System.out.println(output.substring(1, output.length() - 1));
		System.out.println(count);
	}
}

Measured memory_bytes: 26272
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class A500YenCoins {
public:
    void solve(std::istream& in, std::ostream& out) {
        int K, X;
        in >> K >> X;
        out << ((500 * K >= X) ? "Yes" : "No") << "\n";
    }
};


signed main() {
    A500YenCoins solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll H,W; cin>>H>>W;
    ll N; cin>>N;
    vector<ll> A(N);
    vector<vector<ll> > field(H+1,vector<ll>(W+1,0));
    rep(i,N) cin>>A[i];
    
    ll rem=0,sub=0;
    rep1(i,H)rep1(j,W){
        if(rem==0){
            sub++;
            rem=A[sub-1];
        }
        
        field[i][j]=sub;
        rem--;
    }

    rep1(i,H){
        rep1(j,W){
            if(i%2==1) cout<<field[i][j]<<" ";
            else cout<<field[i][W-j+1]<<" ";
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3716
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <climits>

//find out the use of the below
#include <list>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
vector<vector<LL> > dp(2, vector<LL>((int)1e5+1,0));
int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    int n, w;
    scanf("%d%d", &n, &w);
    int w0, v0;
    for (int i = 1; i <=n; ++i){
        scanf("%d%d", &w0, &v0);
        for (int j = 1; j <= w; ++j){
            dp[i%2][j] = max(dp[(i-1)%2][j], dp[i%2][j-1]);
            if (j >= w0)
                dp[i%2][j] = max(dp[i%2][j], dp[(i-1)%2][j-w0]+v0);
        }
    }
    cout << dp[n%2][w];
    return 0;
}
/* BEFORE submitting, check for:
 *  1. Integer overflow
 *  2. Float/Double precision errors
 *  3. Array index out of bounds
 *  4. Edge cases.(n=1, n=max, etc.)
 *  5. Time complexity. No TLEs
 */



Measured memory_bytes: 2560
#![allow(non_snake_case, unused_imports)]

// Input macros
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,VecDeque,BinaryHeap};

// Functions

// Main
fn main(){
    input!{
        A: u64,
        B: u64,
    }
    let x:u64 = format!("{}{}", A, B).parse().unwrap();
    let y:u64 = (x as f64).sqrt() as u64;
    println!("{}",
        if x==y*y{
            "Yes"
        }else{
            "No"
        }
    );
}


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

int main() {
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if (m1 != m2) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}

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

public class Main{	
public static void main (String[] args){
	Scanner sc = new Scanner(System.in);
	String s = sc.next();
	boolean flag = true;
	for(int i = 0; i < 3; i++){
	 	if(s.substring(i,i+1).equals(s.substring(i+1,i+2))){
	 		flag = false;
	 	}
	}
	if(flag){
		System.out.println("Good");
	}else{
		System.out.println("Bad");
	}
}
}


Measured memory_bytes: 23892
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	ans := 0.0
	for i := 1; i <= n; i++ {
		score := i
		suc := 1.0 / float64(n)
		for score < k {
			score *= 2
			suc *= 0.5
		}
		ans += suc
	}
	fmt.Print(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  vector<int> a(3);
  for (int i = 0; i < 3; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  cout << a[0] + a[1] << endl;
  return 0;
}


Measured memory_bytes: 256