akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

int main() {
  cout << setprecision(10);
  int N, K;
  cin >> N >> K;

  int cnt = 0;
  while (N != 0) {
    cnt++;
    N /= K;
  }
  cout << cnt << endl;
  return 0;
}


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll a, b;
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


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


public class Main{


	
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner();
		PrintWriter out=new PrintWriter(System.out);
		long K = sc.nextLong();
		int rest = (int)(K % 50);
		long num = K / 50;
		System.out.println(50);
		long[] ans = new long[50];
		for (int i = 0; i < rest; i++) {
			ans[i] = num + 50  + 50 - rest;
		}
		for (int i = rest; i < 50; i++) {
			ans[i] = num + 50 - 1 - rest;
		}
		for (int i = 0; i < 49; i++) {
			System.out.print(ans[i] + " ");
		}
		System.out.println(ans[49]);
		out.close();

	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		Scanner(String fileName) throws FileNotFoundException{
			br=new BufferedReader(new FileReader(fileName));
		}
		String next() throws IOException {
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		String nextLine() throws IOException {
			return br.readLine();
		}
		int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		long nextLong()  throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 21332
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let a = List.sort compare @@ Array.to_list @@ Array.init n @@ fun _ -> Scanf.sscanf (read_line ()) "%d" @@ fun a -> a

let rec take res n acc = match (n, acc) with
  | (_, []) | (0, _) -> List.rev res
  | (i, x :: xs) -> take (x :: res) (n - 1) xs
let take = take []

let rec drop n acc = match (n, acc) with
  | (0, acc) -> acc
  | (_, []) -> []
  | (n, x :: xs) -> drop (n - 1) xs

let sum = List.fold_left (+) 0

let solve_1 () = 
  let left, right = take (n / 2) a, drop (n / 2) a in
  let head_r, tail_l = List.hd right, List.hd (List.rev left) in
  (sum right - sum left) * 2 - head_r + tail_l

let solve_2 () = 
  let left, right = take (n / 2) a, drop (n / 2 + 1) a in
  let acc = take 3 (drop (n / 2 - 1) a) in
  match acc with 
  | mid_l :: mid :: mid_r :: [] -> max 
                                     ((sum right - sum left) * 2 - mid + mid_l)
                                     ((sum right - sum left) * 2 - mid_r + mid)
  | _ -> failwith "program error"

let () = Printf.printf "%d\n" @@ (if n mod 2 = 0 then solve_1 else solve_2) ()

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

using namespace std;
typedef long long ll;
const int INF = 1e9;

int main(){
	ll T = 1;
	cin >> T;
	ll AC = 0;
    ll WA = 0;
    ll TLE = 0;
    ll RE = 0;
	while (T--){
	 string x;
     cin >> x;
     if (x == "AC") {
      AC = AC + 1;
     } else if (x == "WA") {
      WA = WA + 1;
     } else if (x == "TLE") {
      TLE = TLE + 1;
     } else if (x == "RE") {
      RE = RE + 1;
      }
	}
	cout << "AC x " << AC << endl;
	cout << "WA x " << WA << endl;
	cout << "TLE x " << TLE << endl;
	cout << "RE x " << RE << endl;
}
	

Measured memory_bytes: 3648
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int n;
    cin >> n;
    ll ans = 1LL;
    rep(i, n) {
        int a;
        cin >> a;
        if(a&1) ans *= 1;
        else ans *= 2;
    }
    cout << pow(3, n) - ans << endl;
    return 0;
}

Measured memory_bytes: 512
#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 FASTIO cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define ll long long int
#define F first
#define S second
#define pll pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vpii vector<pair<int,int> >
#define vvpii vector<vpii >
#define vpll vector<pair<ll,ll> >
#define vvpll vector<vpll >
#define pb push_back
#define MOD 1000000007

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;

struct compare {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		if ((a.S - a.F) != (b.S - b.F)) return ((a.S - a.F) > (b.S - b.F));
		else return (a.F < b.F);
	}
};

vvl paths; vvi grid;
int h, w;
ll npaths(int i, int j) {
	if (paths[i][j] != -1) return  paths[i][j];
	if (i == (h - 1) && j == (w - 1)) {
		paths[i][j] = 1; return paths[i][j];
	}
	else {
		ll np = 0;
		if ((i + 1) < h && grid[i + 1][j] == 0) np += npaths(i + 1, j);
		np %= MOD;
		if ((j + 1) < w && grid[i][j + 1] == 0) np += npaths(i, j + 1);
		np %= MOD;
		paths[i][j] = np;
		return paths[i][j];
	}
}


int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	FASTIO;
	cin >> h >> w;
	grid.resize(h, vi(w));
	paths.resize(h, vl(w, -1));
	for (int i = 0; i < h; i++) {
		string s; cin >> s;
		for (int j = 0; j < w; j++) {
			if (s[j] == '.')grid[i][j] = 0;
			else grid[i][j] = 1;
		}
	}
	ll ans = npaths(0, 0);
	if (ans == -1) cout << "0" << endl;
	else cout << ans << endl;

}

Measured memory_bytes: 12160
#include <stdio.h>
#include <stdlib.h>
int main(void){
    char a[1001],c[101],f[1001],m[1001];
    int b,d,e,i,j;
    scanf("%s",&a);
    scanf("%d",&b);
    for(i=0;i<b;i++){
        scanf("%s %d %d",&c,&d,&e);
         
        if(strcmp(&c,"print")==0){
            for(j=d;j<=e;j++) printf("%c",a[j]);
            printf("\n");
        }
         
        if(strcmp(&c,"reverse")==0){
            for(j=d;j<=e;j++) m[j] = a[j];
            for(j=d;j<=e;j++) a[j] = m[d+e-j];
        }
         
        if(strcmp(&c,"replace")==0){
            scanf("%s",&f);
            for(j=d;j<=e;j++) a[j] = f[j-d];
        }
    }
    return 0;
}


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

bool is_feasible(int N, int K, const vector<int> &A_vec, int len)
{
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        int num = (A_vec.at(i) + len - 1) / len - 1;
        if (num > K)
            return false;
        cnt += num;
        if (cnt > K)
            return false;
    }
    return true;
}

int main()
{
    int N;
    int K;
    cin >> N >> K;
    vector<int> A_vec(N);
    for (int i = 0; i < N; ++i)
        cin >> A_vec.at(i);
    int max_len = *max_element(A_vec.begin(), A_vec.end());
    int left = 0, right = max_len;
    while (right - left > 1) {
        int mid = (right + left) / 2;
        if (is_feasible(N, K, A_vec, mid))
            right = mid;
        else
            left = mid;
    }
    cout << right << endl;
}


Measured memory_bytes: 4000
n,q=map(int,input().split())
s=input()+"P"
A=[list(map(int,input().split())) for i in range(q)]
B=[0]*(n+1)
cnt=0
for i in range(1,n):
    if s[i-1]+s[i]=="AC":cnt +=1
    B[i+1]=cnt

for l,r in A:print(B[r]-B[l])

Measured memory_bytes: 30664
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(int)(0.5*b*a);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <set>
#include <string>
#include <algorithm>
#include <iterator>
#include <utility>

int main() {
  std::int_fast64_t n;
  std::cin >> n;
  std::string s;
  std::cin >> s;
  std::multiset<char> multiset(s.begin(), s.end());
  for (std::int_fast64_t i = 1; i < n; ++i) {
    std::cin >> s;
    std::multiset<char> prev_multiset = std::move(multiset);
    std::multiset<char> curr_multiset(s.begin(), s.end());
    std::set_intersection(prev_multiset.begin(), prev_multiset.end(), curr_multiset.begin(), curr_multiset.end(), std::inserter(multiset, multiset.end()));
  }
  std::cout << std::string(multiset.begin(), multiset.end()) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<set>
#include<map>
using namespace std;

int main(){
  while(1){
    int m, n ;
    int seiza[200][2], stars[1000][2];
    set< pair<int, int> > starset;
    scanf("%d", &m);
    if(m == 0){
      return 0;
    }
    for(int i = 0;i < m;i++){
      int xi, yi;
      scanf("%d%d", &xi, &yi);
      seiza[i][0] = xi;
      seiza[i][1] = yi;
    }
    scanf("%d", &n);
    for(int i = 0;i < n;i++){
      int xi, yi;
      scanf("%d%d", &xi, &yi);
      stars[i][0] = xi;
      stars[i][1] = yi;
      starset.insert(make_pair(xi, yi));
    }
    for(int i = 0;i < n;i++){
      int xdis = stars[i][0] - seiza[0][0];
      int ydis = stars[i][1] - seiza[0][1];
      int j;
      for(j = 1;j < m;j++){
	if(starset.find(make_pair(seiza[j][0] + xdis, seiza[j][1] + ydis)) == starset.end()){
	  break;
	}
      }
      if(j == m){
	printf("%d %d\n", xdis, ydis);
	break;
      }
    }
  }
}

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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<int>> masu(h, vector<int>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char c;
      cin >> c;
      if (c == '#') masu[i][j] = 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < (1<<h); i++) {
    for (int j = 0; j < (1<<w); j++) {
      int cnt = 0;
      //cout << "i:" << i << ",j:" << j << ",cnt:" << cnt << " ";
      for (int l = 0; l < h; l++) {
        if ((i>>l)&1 == 1) continue;
        for (int m = 0; m < w; m++) {
          if ((j>>m)&1 == 1) continue;
          if (masu[l][m] == 1) cnt++;
        }
      }
      if (cnt == k) ans++;
      //cout << cnt << " " << ans << endl;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
/*
2020-05-03
atcoder ABC
*/

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;
int main() {
    int N;
    ll ans = 0;
    cin >> N;
    map<ll, int> L_map;

    rep(i, N){
        ll A;
        cin >> A;
        L_map[i + A]++;
        ans += L_map[i - A];
    }

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


Measured memory_bytes: 26340
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt=0;
  if (s[0]=='1') ++cnt;
  if (s[1]=='1') ++cnt;
  if (s[2]=='1') ++cnt;
  cout << cnt << endl;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
int cmpint(const void *x, const void *y) { return *(int *)x - *(int *)y; }
int main() {
	int a[3];
	for (int i = 0; i < 3; i++) {
		scanf("%d", &a[i]);
	}
	qsort(a, 3, sizeof(int), cmpint);
	printf("%d\n", a[0] + a[1]);
	return 0;
}

Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
count=0
for i in range(0,n):
  attack=b[i]
  if attack>=a[i]:
    count+=a[i]
    attack-=a[i]
    a[i]=0
  else:
    count+=attack
    a[i]-=attack
    attack=0
  if attack>=0:
    if attack>=a[i+1]:
      count+=a[i+1]
      attack-=a[i+1]
      a[i+1]=0
    else:
      count+=attack
      a[i+1]-=attack
      attack=0
print(count)
    
    

Measured memory_bytes: 18476
#include<bits/stdc++.h>
using namespace std;
int util(string S){
	int n=S.size();
	vector<int>dp(n,0);
	for(int i=1;i<n;i++){
		if(i==2){
			if(S[i]!=S[i-1] || (S[i]==S[i-1] && dp[i-1]==1)){
				dp[i]=dp[i-1];
			}else{
				dp[i]=1+dp[i-1];
				S[i]=(1-(S[i]-'0'))+'0';
			}
		}else{
			if(S[i]!=S[i-1]){
				dp[i]=dp[i-1];
			}else{
				dp[i]=1+dp[i-1];
				S[i]=(1-(S[i]-'0'))+'0';
			}
		}
	}
	return dp[n-1];
}
int main(){
	string S;
	cin>>S;
	// int res=INT_MAX;
	int res=util(S);
	reverse(S.begin(),S.end());
	res=min(res,util(S));
	cout<<res;
	return 0;
}

Measured memory_bytes: 896
import sys
from fractions import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# A が2で何回割れるか
N, M = lr()
A = lr()
A = [x // 2 for x in A]
cnt = 0
while all(x%2 == 0 for x in A):
    cnt += 1
    A = [x // 2 for x in A]

if any(x%2 == 0 for x in A):
    print(0); exit()

lcm = 1
for a in A:
    lcm *= a // gcd(lcm, a)

answer = M // (2 ** cnt * lcm) - M // (2 ** (cnt+1) * lcm)
print(answer)
# 21


Measured memory_bytes: 16292
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from itertools import permutations

def main():
    T = int(input())
    for _ in range(T):
        number = list(map(int,input().split()))
        color = input().split()
        ans = 0
        for ptr in permutations(range(9)):
            flag = True
            for i in range(3):
                c = color[ptr[3*i]]
                card = []
                for j in range(3):
                    if c != color[ptr[3*i + j]]:
                        flag = False
                        break
                    card.append(number[ptr[3*i + j]])
                if not flag:
                    break
                card.sort()
                if card[0] == card[2] or (card[2] - card[1] == 1 and card[1] - card[0] == 1):
                    continue
                else:
                    flag = False
                    break
            if flag:
                ans = 1
                break
        print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 5656
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt()*1000;
		int A = sc.nextInt()*1000;
		int[] H = new int[N];
		int[] t = new int[N];
		int ans = 0;
		for(int i=0; i<N; i++){
			H[i] = sc.nextInt();
			t[i] = T - H[i]*6;
			if(Math.abs(t[i]-A)<Math.abs(t[ans]-A)){
				ans = i;
			}
		}
		System.out.println(ans+1);
		return;
	}
}


Measured memory_bytes: 24268
//
// Created on 2019-02-09.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define PB push_back
#define INF 1e9
#define MOD 1e9+7
#define EPS 1e-9

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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


    int a, b;
    cin >> a >> b;

    int ans = 0;

    ans += max(a, b);
    if (a < b) b--;
    else a--;
    ans += max(a, b);

    cout << ans << endl;

    return 0;

}

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

#define in_fre freopen("redir.txt", "r", stdin);
#define out_fre freopen("out5.txt", "w", stdout);
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug(i) printf("\nDebug %d\n",i);
#define mod 1000000007
#define ll long long int

int main()
{	
clock_t begin, end;
double time_spent;
begin = clock();

//	fast();
#ifndef ONLINE_JUDGE
	//in_fre
//	out_fre
#endif

ll n,d;
cin>>n>>d;
ll x[n]={0},y[n]={0},cnt=0;
for (int i = 0; i < n; ++i)
{cin>>x[i]>>y[i];
double dis=sqrt(x[i]*x[i]+y[i]*y[i]);
//cout<<dis<<"\n";
if(dis<=(double)d)
cnt++;
}
cout<<cnt<<"\n";

end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
cerr<<"Time spent = "<<time_spent<<endl;

return 0;
}

Measured memory_bytes: 6964
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int[] a = new int[n];
      float sum = 0;
      int count = 0;
      for(int i = 0;i<n;i++){
         a[i] = sc.nextInt();
         sum += a[i];
      }
      for(int i = 0;i<n;i++){
         if(a[i]>=sum/(4*m)){
            count++;
            if(count>=m){
               System.out.println("Yes");
               return;
               }
            
         }
      }
     
       System.out.println("No");
   }
}


Measured memory_bytes: 36064
#!/usr/bin/env python3
q = int(input())
for _ in range(q):
    n = input()
    for k in range(len(n)**2):
        if len(n) == 1:
            print(k)
            break
        n = str(max(int(n[:i]) * int(n[i:]) for i in range(1, len(n))))




Measured memory_bytes: 5608
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>

int main()
{
  char a[100],b[100];
  int n;
  
  scanf("%s", a);
  scanf("%s", b);
  
  n = strlen(a);
  
  if(strncmp(a,b,n)==0 && strlen(b)==n+1)
  {
    printf("Yes");
  }else
  {
   printf("No"); 
  }
  return 0; 
}


Measured memory_bytes: 1772
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n  = scanner.nextInt();

        Node[] nodes = new Node[n];

        for (int i = 0; i < n; i++) {
            Node node = new Node(scanner);
            nodes[node.id] = node;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < nodes[i].degree; j++) {
                nodes[nodes[i].children[j]].parent = i;
            }
        }
        for (int i = 0; i < n; i++) {
            int parent = nodes[i].parent;
            while (parent != -1) {
                nodes[i].depth++;
                parent = nodes[parent].parent;
            }
        }
        for (int i = 0; i < n; i++) {
            print(nodes[i]);
        }
    }

    public static void print(Node node) {
        System.out.println(
               "node " + node.id + ": " +
               "parent = " + node.parent + ", " +
               "depth = " + node.depth + ", " +
               getTypeString(node) + ", " +
               getChildrenString(node.children)
               );
    }

    private static String getTypeString(Node node) {
        if (node.parent == -1) {
            return "root";
        }
        if (node.children.length == 0) {
            return "leaf";
        }
        return "internal node";
    }

    private static String getChildrenString(int[] children) {
        if (children.length == 0) return "[]";
        StringBuilder sb = new StringBuilder();
        sb.append("[" + children[0]);
        for (int i = 1; i < children.length; i++) sb.append(", " + children[i]);
        sb.append("]");
        return sb.toString();
    }
}

class Node {
    int id;
    int parent = -1;
    int degree;
    int depth = 0;
    int[] children;

    Node(Scanner scanner) {
        id       = scanner.nextInt();
        degree   = scanner.nextInt();
        children = new int[degree];
        for (int i = 0; i < degree; i++) {
            children[i] = scanner.nextInt();
        }
    }

}



Measured memory_bytes: 144584
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;

template<class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


const int INF = 1e9;


void solve() {
    int N, M; cin >> N >> M;

    vector<pair<int, int>> key(M);

    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b;

        int s = 0;
        for (int j = 0; j < b; j++) {
            int c; cin >> c; c--;
            s |= 1<<c; 
        }

        key[i] = make_pair(a, s);
    }

    vector<vector<int>> dp(M+1, vector<int>(1<<N, INF));

    dp[0][0] = 0;

    for (int i = 0; i < M; i++) {
        for (int s = 0; s < 1<<N; s++) {
            // not use
            chmin(dp[i+1][s], dp[i][s]);

            // use
            int cost = dp[i][s] + key[i].first;
            chmin(dp[i+1][s|key[i].second], cost);
        }
    }

    int ans;
    if (dp[M-1][(1<<N) - 1] == INF) ans = -1;
    else ans = dp[M-1][(1<<N) - 1];

    cout << ans << endl;
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 19340
package main

import(
    "fmt"
)



func main() {
    var n int
    fmt.Scan(&n)
    fmt.Println(n*800 - n/15*200)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}


Measured memory_bytes: 512
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let v = if n % 2 == 0 { n + 1 } else { n };
    let mut edges = vec![];
    for i in 1..n+1 {
        for j in i+1..n+1 {
            if i + j != v {
                edges.push((i, j));
            }
        }}
    put!(edges.len());
    for &(i, j) in edges.iter() {
        put!(i, j);
    }

}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


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

int main() {
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    for(int i=0;i<101;i++){
        C-=B;
        if(C<=0){cout<<"Yes"<<endl;break;}
        A-=D;
        if(A<=0){cout<<"No"<<endl;break;}

        
    }

    
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int MOD = 1e8 + 7;
const int INF = 1001001001;
// const ll INF = 1000000000000000000LL;

int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ac = a*c;
    ll ad = a*d;
    ll bc = b*c;
    ll bd = b*d;
    cout << max(max(ac,ad),max(bc,bd)) << endl;
    return 0;
}

Measured memory_bytes: 3624
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    int a, b;
    char op;
    scan(a, op, b);
    if (op == '+') {
        writeln(a+b);
    }
    else {
        writeln(a-b);
    }
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
const int loose = 0;
const int tight = 1;


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;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n, d, a;
	cin >> n >> d >> a;

	vector<P> xh(n);
	REP(i, n) cin >> xh[i].F >> xh[i].S;
	sort(all(xh));

	priority_queue<P, vector<P>, greater<P>> que;
	ll ans = 0;
	ll num = 0;
	REP(i, n) {
		ll x = xh[i].first;
		ll h = xh[i].second;

		while (que.size() != 0 && que.top().F<x-2*d) {
			num-=que.top().second;
			que.pop();
		}

		h -= num * a;

		if (h <= 0) continue;
		
		ll con = 0;
		if (h % a == 0) con += h / a;
		else con += h / a + 1;
		num += con;
		ans += con;
		que.push({ x, con });
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5620
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        List<int> gs = new List<int>() { 1 };
        while (gs.Last() * 3 + 1 < n)
        {
            gs.Add(gs.Last() * 3 + 1);
        }
        gs.Reverse();

        Console.WriteLine(gs.Count);
        Console.WriteLine(string.Join(" ", gs));

        var a = Enumerable.Repeat(0, n).Select(_ => int.Parse(Console.ReadLine())).ToArray();

        int cnt = 0;
        foreach (var g in gs)
        {
            for (int i = g; i < n; i++)
            {
                var v = a[i];
                int j;
                for (j = i - g; j >= 0 && a[j] > v; j -= g)
                {
                    a[j + g] = a[j];
                    cnt++;
                }
                a[j + g] = v;
            }
        }
        Console.WriteLine(cnt);

        Console.WriteLine(string.Join("\n", a));
    }
}


Measured memory_bytes: 60972
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define yes(a) printf(a ? "yes\n" : "no\n")
#define Yes(a) printf(a ? "Yes\n" : "No\n")
#define YES(a) printf(a ? "YES\n" : "NO\n") 
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

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

  ll cnt = 0;
  ll ans = 0;
  for(ll i = 0; i < n-1; i++){
    if(a[i] == i+1){
      swap(a[i], a[i+1]);
      ans++;
    }
  }
  if(a[n-1] == n) ans++;
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
function Main(input) {
	input = input.trim().split(" ").map((a)=>Number(a));
  var X = input[0];
  var A = input[1];
  var B = input[2];
  
  if(A + X < B){
     console.log("dangerous");
     }else if(A - B >= 0){
    console.log("delicious");
  }else{
    console.log("safe");
  }
  
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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


typedef pair<int, int> QQ;
const int NL = 'z' - 'a' + 1;

int cnt[50000][NL];


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

	vector<int> qt(Q);
	vector<QQ> qq(Q);
	for (int i = 0; i < Q; ++i) {
		cin >> qt[i];
		if (qt[i] == 1) {
			char c;
			cin >> qq[i].first >> c;
			qq[i].second = c - 'a';
		}
		else
			cin >> qq[i].first >> qq[i].second;
	}

	set<int> pos_s;
	for (int i = 0; i < Q; ++i) {
		if (qt[i] == 2) {
			pos_s.insert(qq[i].first - 1);
			pos_s.insert(qq[i].second);
		}
	}

	int pos_cnt = 0;
	map<int, int> pos_to_ind;
	for (int pos : pos_s)
		pos_to_ind[pos] = pos_cnt++;
	assert(pos_cnt == pos_s.size());
		

	vector<int> tmp(NL);
	for (int i = 0; i < N; ++i) {
		int c = S[i] - 'a'; tmp[c]++;
		int pos = i + 1;

		if (pos_s.find(pos) != pos_s.end()) {
			int ind = pos_to_ind[pos];
			for (int j = 0; j < NL; ++j)
				cnt[ind][j] = tmp[j];
		}
	}

	for (int i = 0; i < Q; ++i) {
		if (qt[i] == 1) {
			int pos = qq[i].first;
			int c0 = S[pos - 1] - 'a';
			int c1 = qq[i].second;
			if (c0 == c1) continue;
			for (auto keyval : pos_to_ind) {
				int pos2 = keyval.first;
				int ind2 = keyval.second;
				if (pos2 < pos) continue;
				cnt[ind2][c0]--;
				cnt[ind2][c1]++;
			}
			S[pos - 1] = 'a' + c1;
		} else {
			int ind1 = pos_to_ind[qq[i].first - 1], ind2 = pos_to_ind[qq[i].second];
			int kind = 0;
			for (int j = 0; j < NL; ++j) kind += (cnt[ind2][j] - cnt[ind1][j] > 0);
			cout << kind << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 11028
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()	
	{
		string S = GetString();
		int first = int.Parse(S.Substring(0, 2));
		int last = int.Parse(S.Substring(2, 2));

		if(canMM(first) && canMM(last))
		{
			Console.WriteLine("AMBIGUOUS");
		}
		else if(!canMM(first) && canMM(last))
		{
			Console.WriteLine("YYMM");
		}
		else if(canMM(first) && !canMM(last))
		{
			Console.WriteLine("MMYY");
		}
		else
		{			
			Console.WriteLine("NA");
		}
	}

	private static bool canMM(int x)
	{
		return ((x >= 1) && (x <= 12));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <iostream>
#include <sstream>
#include <complex>
#include <cassert>
#include <bitset>

#define enp     puts("**chkchkchkchkchk**")
#define A       first
#define B       second
#define MP      make_pair

using namespace std;

typedef long long ll;
typedef unsigned int uint;

const int INF = 0x60000000;
const int MINF = -1000000000;
const int mod = 1000000007;
const int cons = 100001;
const double pi = 3.141592653589793;
const int sqrtMax = 317;
const int blocks = cons / 3;

char M[15][15];
int h, w;
int maxcnt = 0;

void go(int y, int x, int cnt)
{
	int newcnt = cnt;
	if (M[y][x] == '#')newcnt++;

	if (y == h - 1 && x == w - 1)
	{
		maxcnt = max(maxcnt, newcnt);
		return;
	}


	if (y < h - 1)go(y + 1, x, newcnt);
	if (x < w - 1)go(y, x + 1, newcnt);
}

int main() 
{
	scanf("%d%d", &h, &w);

	int need = 0;
	for (int i = 0; i < h; i++)
	{
		scanf("%s", &M[i]);

		for (int j = 0; j < w; j++)
		{
			if (M[i][j] == '#')need++;
		}
	}

	go(0, 0, 0);

	if(maxcnt == need)puts("Possible");
	else puts("Impossible");

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;
class Unionfind
{
public:
  vector<int>parent;
  Unionfind(int n)
  {
    parent=vector<int>(n,-1);
  }
  int root(int a)
  {
    if(parent[a]<0)return a;
    parent[a]=root(parent[a]);
    return parent[a];
  }
  int size(int a)
  {
    return -parent[root(a)];
  }
  bool connect(int a,int b)
  {
    int pa=root(a),pb=root(b);
    if(pa==pb)return false;
    if(size(pa)>size(pb))swap(pa,pb);
    parent[pb]+=parent[pa];
    parent[pa]=pb;
    return true;
  }
};




int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  int n,m;
  cin>>n>>m;
  vector<int>p(n+1);
  Unionfind uni(n+1);
  rep(i,n)cin>>p[i+1];
  rep(i,m)
  {
    int x,y;
    cin>>x>>y;
    uni.connect(x,y);
  }
  int res=0;
  repi(i,1,n+1)
  {
    if(uni.root(i)==uni.root(p[i]))res++;
  }
  cout<<res<<endl;
  return 0;

}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N, M;

struct city {
    city(int m, int y, int p, int r) : m(m), y(y), p(p), r(r) {}
    int m;
    int y;
    int p;
    int r;
};

vector<city> cities;

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

    rep(i, M) {
        int p, y;
        cin >> p >> y;
        cities.push_back(city(i, y, p, 0));
    }

    sort (ALLOF(cities), [](const city& l, const city& r){ 
        if (l.p == r.p) return r.y > l.y;
        return r.p > l.p;
     });
    
    int rank = 1;
    REP(i, 0, M) {
        if (i >= 1 && cities[i].p != cities[i - 1].p) rank = 1;
        cities[i].r = rank++;
    }

    sort(ALLOF(cities), [](const city& l, const city& r){ return l.m < r.m; });

    rep(i, M) {
        printf("%06d%06d\n", cities[i].p, cities[i].r);
    }

    return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(ll i=p;i<n;i++)
#define fr1(i,p,n) for(ll i=p;i>=n;i--)
#define FAST ios::sync_with_stdio(0);
#define sz(v) (ll)v.size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define mod 1000000007
#define mod1 998244353
#define precise cout << std::setprecision(12) << std::fixed;
#define endl "\n"
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FAST
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        priority_queue<ll> pq;
        ll a[n];
        fr(i,0,n) cin>>a[i];
        sort(a,a+n);
        pq.push(a[n-1]);
        ll ans=0;
        fr1(i,n-2,0)
        {
            ans+=pq.top();
            pq.pop();
            pq.push(a[i]);
            pq.push(a[i]);
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

int main() {
    int X;
    cin >> X;
    int ans = 1;
    for (int i = 2; i < X; i++) {
        int e = 1;
        while (pow(i, e) <= X) e++;
        e--;
        if (e >= 2 && pow(i, e) > ans) ans = pow(i, e);
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/*
 * Assuming i goes to lft, the 1st mid point can be at i=N-1; the last
 * mid point can be at i=2N-1.
 */

const LL inf = 1e15;

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    int N;
    while (cin >> N) {
        LL A[3*N];
        FOR(i,0,3*N)
            cin >> A[i];
        priority_queue<LL, vector<LL>, greater<LL>> L; /* asc */
        priority_queue<LL, vector<LL>, less<LL>>    R; /* desc */
        LL lft,rht; lft = rht = 0;
        FOR(i,0,N) {
            lft += A[i]; L.push(A[i]);
        }
        FOR(i,2*N,3*N) {
            rht += A[i]; R.push(A[i]);
        }
        LL bestL[3*N],bestR[3*N],ans = -inf;
        bestL[N-1] = lft; bestR[2*N-1] = rht;
        FOR(i,N,2*N) {
            /* A[i] can go to lft */
            L.push(A[i]); lft += A[i]-L.top(); L.pop();
            bestL[i] = lft;
        }
        FORR(i,2*N-2,N-2) {
            /* A[i] can go to lft, so A[i+1] can be assigned to rht */
            R.push(A[i+1]); rht += A[i+1]-R.top(); R.pop();
            bestR[i] = rht;
        }
        FOR(i,N-1,2*N)
            ans = max(ans,bestL[i]-bestR[i]);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 5876
#include <stdio.h>

int main(void)
{
	int i,j;
	int h,w;

	while(1){
		scanf("%d %d", &h,&w);
		if(w==0 && h==0)
			break;
		for(i=0; i<h; i++){
			for(j=0; j<w; j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
    }

    ll cnt = 0;
    rep(i, N) {
        if (A[i] < 0) {
            cnt++;
            A[i] *= -1;
        }
    }

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

    ll ans = 0;
    rep(i, N) {
        ans += A[i];
    }
    if (cnt % 2 == 1) {
        ans -= A[0] * 2;
    }

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

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
  
  long int x;
  long int y = 100;
  long int z;
  
  scanf("%ld", &x);
  
  for(long int i = 1; ; i++){
    y = y * 1.01;
    if(y >= x){
      z = i;
      break;
    }
  }
  printf("%ld", z);
}


Measured memory_bytes: 1732
N, M, Q = [int(_) for _ in input().split()]
Query = []
for _ in range(M):
    Query += [[int(_) for _ in input().split()] + [0, _]]
for _ in range(Q):
    p, q = [int(_) for _ in input().split()]
    Query += [[p, q + 1, 1, _]]
Query.sort(key=lambda xs: 2 * xs[1] - xs[2])
ans = [0] * Q


class SegmentTree():
    """
        Parameters
        ----------
        array : list
            to construct segment tree from
        m : func
            binary operation of the monoid
        e : 
            identity element of the monoid
        size : int
            limit for array size
    """

    def __init__(self, array, m, e, size):
        self.m = m
        self.e = e
        self.size = size
        self.n = n = len(array)
        self.dat = dat = [e] * n + array + [e] * (2 * size - 2 * n)
        self.build()

    def build(self):
        dat, n, m = self.dat, self.n, self.m
        for i in range(n - 1, 0, -1):
            dat[i] = m(dat[i << 1], dat[i << 1 | 1])

    def modify(self, p, v):
        """
        set value at position p (0-indexed)
        """
        m, n, dat = self.m, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            dat[p >> 1] = m(dat[p], dat[p ^ 1])
            p >>= 1

    def query(self, l, r):
        """
        result on interval [l, r) (0-indexed)
        """
        m, e, n, dat = self.m, self.e, self.n, self.dat
        res = e
        l += n
        r += n
        while l < r:
            if l & 1:
                res = m(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = m(res, dat[r])
            l >>= 1
            r >>= 1
        return res


e = 0
size = N + 2
ST = SegmentTree([0] * (N + 2), m=lambda x, y: x + y, e=e, size=size)
for l, r, t, i in Query:
    if t:
        ans[i] = ST.query(l, r)
    else:
        ST.modify(l, ST.query(l, l + 1) + 1)
print(*ans, sep='\n')


Measured memory_bytes: 120408