akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        long n=0;
        long sum=0;
        while (n<s.length()){
            int num=Integer.parseInt(String.valueOf(s.charAt((int) n)));
            sum=sum+num;
            n++;
        }
        if (sum%9==0){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 49632
n,a,b = map(int,input().split())

check = abs(a-b)

if check%2 == 0:
    print(check//2)
    exit()

temp1 = min(max(a,b) - 1, n - min(a,b))
temp2 = min(min(a,b) - 1, n - max(a,b))
ans = min(temp1, temp2 + 1 + (check)//2)

print(ans)

Measured memory_bytes: 3064
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] d = new int[N];
		for(int i = 0; i < N; i++) d[i] = sc.nextInt();
		Arrays.sort(d);
		
		int ans = 1;
		int bef = d[0];
		for(int i = 0; i < N; i++){
			if(d[i] != bef){
				bef = d[i];
				ans++;
			}
		}
		
		System.out.println(ans);
	}
}

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

using ll = long long int;
const int MAX_N = (int)1e5 + 5;

ll n, a[MAX_N];

ll ans;

int main(void){
  scanf("%lld", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
  }

  ll zans = 0, zcur = 0; // +, -, +, -, ...
  for (int i = 0; i < n; ++i) {
    zcur += a[i];
    if (i % 2 == 0) {
      if (zcur <= 0) {
        zans += (1 - zcur);
        zcur = 1;
      }
    }
    else {
      if (zcur >= 0) {
        zans += (zcur - (-1));
        zcur = -1;
      }
    }
  }

  ll oans = 0, ocur = 0; // -, +, -, +, ...
  for (int i = 0; i < n; ++i) {
    ocur += a[i];
    if (i % 2 == 0) {
      if (ocur >= 0) {
        oans += (ocur - (-1));
        ocur = -1;
      }
    }
    else {
      if (ocur <= 0) {
        oans += (1 - ocur);
        ocur = 1;
      }
    }
  }

  ans = min(zans, oans);

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

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

int main(){
	int A,B;
	cin >> A >> B;
	
	int x1=round(A/0.08);
	int x2=round(B/0.1);
	
  //cout << x1 << " " << x2 << endl;
  
  
	if(x1==x2){  //等しければそれが解
		cout << x1 << endl;
	} else if(x1>x2){   //大きいほうで別のほうを再計算
		int xB = x1*0.1;   //切り捨て計算
		if(xB==B) cout << x1 << endl;  //一致するならそれが解
		else cout << -1 << endl;  //一致しないなら解なし
	} else {
		int xA = x2*0.08;
		if(xA==A) cout << x2 << endl;
		else cout << -1 << endl;
	}
}

Measured memory_bytes: 256
#include<functional>
#include <algorithm>
#include  <iostream>
#include   <ctype.h>
#include   <cstring>
#include   <fstream>
#include    <cstdio>
#include    <vector>
#include    <string>
#include     <cmath>
#include     <deque>
#include     <stack>
#include     <queue>
#include      <list>
#include       <set>
#include       <map>
#define INF 0X7FFFFFFF
#define PI acos(-1.0)
typedef long long ll;
using namespace std;
const int N = 1e6;
inline int getint()
{
	int w = 0, q = 0;
	char c = getchar();
	while ((c<'0' || c>'9') && c != '-') c = getchar();
	if (c == '-') q = 1, c = getchar();
	while (c >= '0'&&c <= '9') w = w * 10 + c - '0', c = getchar();
	return q ? -w : w;
}
string s;
int main() {
	cin >> s;
	int a = -1, b = -1;
	for (int i = 0; i < s.size() && a == -1; i++) {
		if (i + 1 < s.size() && s[i] == s[i + 1]) {
			a = i + 1;
			b = i + 2;
			break;
		}
		if (i + 2 < s.size() && s[i] == s[i + 2]) {
			a = i + 1;
			b = i + 3;
			break;
		}
	}
	cout << a << " " << b << endl;
	return 0;
}

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

template<typename T>
class UnionFind {
  public:
    vector<T> parent;

    UnionFind(T n) {
      parent = vector<T>(n, -1);
    }

    T root(T a) {
      if (parent[a] < 0) return a;
      else return parent[a] = root(parent[a]);
    }

    T size(T a) {
      return -parent[root(a)];
    }

    bool connect(T a, T b) {
      a = root(a);
      b = root(b);
      if (a == b) {
        return false;
      }

      if (size(a) < size(b)) swap(a, b);

      parent[a] += parent[b];
      parent[b] = a;
      return true;
    }
};

void Main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }

  vector<long long> ans(m);
  ans[m - 1] = (long long)n * (n - 1) / 2;

  UnionFind<int> u(n);
  for (int i = m - 1; i >= 1; i--) {
    if (u.root(a[i]) != u.root(b[i])) {
      ans[i - 1] = ans[i] - (long long)u.size(a[i]) * u.size(b[i]);
      u.connect(a[i], b[i]);
    } else {
      ans[i - 1] = ans[i];
    }
  }

  for (int i = 0; i < m; i++) {
    cout << ans[i] << endl;
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, n, k);
	int ans = 0;
	while(n) { n /= k; ans++; }
	OUT(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define f first
#define s second
#define int long long
#define pb push_back
#define pencho ios_base::sync_with_stdio(false);cin.tie(NULL);
#define N 3005
#define MOD 1000000007

inline int add(int a, int b) {
       a += b;
       if (a >= MOD)a -= MOD;
       return a;
}

inline int sub(int a, int b) {
       a -= b;
       if (a < 0)a += MOD;
       return a;
}

void solve() {
       pencho
       int n, k; cin >> n >> k;
       int a[n + 1];
       for (int i = 1; i <= n; i++)       cin >> a[i];
       int prefix[n + 1][k + 1] = {0}, dp[n + 1][k + 1] = {0};

       for (int i = 0; i <= n; i++)       dp[i][0] = prefix[i][0] = 1;
       for (int j = 0; j <= k; j++)       prefix[0][j] = 1;

       for (int i = 1; i <= n; ++i)
              for (int j = 1; j <= k; ++j) {
                     int first = (j - a[i] - 1 >= 0) ? prefix[i - 1][j - a[i] - 1] : 0;
                     int last = prefix[i - 1][j];
                     dp[i][j] = add(dp[i][j], sub(last, first));
                     prefix[i][j] = add(prefix[i][j - 1], dp[i][j]);
              }

       cout << dp[n][k];

}


signed main()
{
#ifndef ONLINE_JUDGE
       freopen("input.txt", "r", stdin);
       freopen("o.txt", "w", stdout);
#endif

       solve();
}

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

using namespace std;

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

	vector<string> S(N);
	vector<int> C(4, 0);

	for(int i = 0; i < N; i++) {
		cin >> S.at(i);
	}

	for(int i = 0; i < N; i++) {
		if(S.at(i) == "AC") {
			C[0] += 1;
		} else if(S.at(i) == "WA") {
			C[1] += 1;
		} else if(S.at(i) == "TLE") {
			C[2] += 1;					
		} else if(S.at(i) == "RE") {
			C[3] += 1;			
		}

	}

	cout << "AC x " << C[0] << endl;
	cout << "WA x " << C[1] << endl;
	cout << "TLE x " << C[2] << endl;
	cout << "RE x " << C[3] << endl;
	return 0;
}

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

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1) 
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__)
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__) 
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__)
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__)
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__)
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__)
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__)

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__)

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32") == 0) return "%d";
  if(strcmp(fmt, "u32") == 0) return "%u";
  if(strcmp(fmt, "f32") == 0) return "%f";
  if(strcmp(fmt, "f64") == 0) return "%lf";
  if(strcmp(fmt, "i64") == 0) return "%lld";
  if(strcmp(fmt, "u64") == 0) return "%llu";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { const type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__)
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__)
#define RF(...)   _FCN(_R, f32, __VA_ARGS__)
#define RD(...)   _FCN(_R, f64, __VA_ARGS__)
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__)
#define RULL(...) _FCN(_R, u64, __VA_ARGS__)

#define PI(...)   _FCN(_P, i32, __VA_ARGS__)
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__)
#define PF(...)   _FCN(_P, f32, __VA_ARGS__)
#define PD(...)   _FCN(_P, f64, __VA_ARGS__)
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__)
#define PULL(...) _FCN(_P, u64, __VA_ARGS__)

#define REP(n) for (int _i = 0; _i < n; _i++)

const u64 mod = 1000000007;

int main() {
  vector<u64> v;
  REP(3) { RULL(t); v.push_back(t); }

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

  v[2] *= 10;

  PULL(accumulate(v.begin(), v.end(), 0));
}


Measured memory_bytes: 384
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int main(){
    ll n,d;
    ll x[30][30];
    std::cin >> n>>d;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            std::cin >> x[i][j];
            // std::cout << x[i][j] << std::endl;
        }
    }
    ll result = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            ll dis = 0;
            for (int k = 0; k < d; k++) {
                dis += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            
            float ans = sqrt(1.0*dis);
            if(float(ans) == ceil(ans)){
                result++;
            }
            
        }
    }
    std::cout << result << std::endl;
}

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

int main() {
  int A , B , C , D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D)  {
    cout << "Left" << endl;
  }
  else if (A + B == C + D)  {
    cout << "Balanced" << endl;
  }
  else
    cout << "Right" << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc=new Scanner(System.in);
      	int x=sc.nextInt();
      	int y=sc.nextInt();
      	boolean flag=false;
      	for(int i=0;i<=x;i++){
        	if(y==(i*2+(x-i)*4)){
				flag=true;
              	break;
            }
        }
      	System.out.println(flag? "Yes":"No");
    }
}

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

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

  bool ans= true;
  for(int i=0; i<N; i++){
    cin >> buf;
    if(buf%2==0 && buf%3!=0 && buf%5!=0){
      ans= false;
      break;
    }
    else continue;
  }

  if(ans){
    cout << "APPROVED" << endl;
  }
  else{
    cout << "DENIED" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T& t,const V& v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T& t,const V& v){for(auto &e:t)fill_v(e,v);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int a,b,c;cin>>a>>b>>c;
    cout<<min(c,b/a)<<endl;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  int n,k; cin>>n>>k;
  std::vector<int> v(n);
  int ans = 0;
  rep(i,n) {
    cin>>v[i];
    ans += v[i];
  }
  sort(v.rbegin(), v.rend());
  debug(v);
  rep(i,n-k) {
    ans -= v[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3192
#!/usr/bin/env python3
import sys


def solve(N: int):
    # zの条件
    # - Nの約数
    # - 素数pのn乗
    # - 過去に選択したzと被らない

    def f(x):
        cnt = 0
        for i in range(1, x + 1):
            x -= i
            if x < 0:
                break
            cnt += 1
        return cnt

    print(sum([f(p[1]) for p in factorize(N)]))
    return


def factorize(n: int):
    """nの素因数分解を求める"""
    res = []
    for i in range(2, int(n ** 0.5//1 + 2)):
        if n % i:
            continue
        s = 0
        while n % i == 0:
            n /= i
            s += 1
        res.append([i, s])
    if n != 1:
        res.append([n, 1])
    return res


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

int main() {
    cin.tie(0);ios::sync_with_stdio(0);
    cin >> k;
  
    ll pasi = 0, n = 100;
  
    while (n < k) {
        pasi++;
        n += n / 100;
    }
  
    cout << pasi;
    return 0;
}


Measured memory_bytes: 3640
def show(nums):
    for i in range(len(nums)):
        if i != len(nums) - 1:
            print(nums[i],end=' ')
        else:
            print(nums[i])

def bubbleSort(A,N):
    flag = 1
    count = 0
    while flag:
        flag = 0
        for j in range(N-1,0,-1):
            if A[j] < A[j-1]:
                tmp = A[j]
                A[j] = A[j-1]
                A[j-1] = tmp
                flag = 1
                count += 1
    show(A)
    print(count)

N = int(input())
A = list(map(int,input().split()))


bubbleSort(A,N)



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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long int ll;
typedef vector< pair<int, int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int, int> pii;

const ll INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;

int n, arr[nax];
vi graph[nax];
int dist[nax], visited[nax];

int main()
{
    ios::sync_with_stdio(0);
    int m;
    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        int u, v;
        cin >> u >> v;
        graph[u].pb(v);
        graph[v].pb(u);
    }
    queue<int> q;
    q.push(1);
    while(!q.empty())
    {
        int topi = q.front();
        q.pop();
        for(auto x: graph[topi])
        {
            if(visited[x] == 0)
            {
                visited[x] = 1;
                q.push(x);
                dist[x] = 1 + dist[topi];
            }
        }
    }
    if(dist[n] == 2)
        cout << "POSSIBLE";
    else
        cout << "IMPOSSIBLE";
    return 0;
}


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

int main()
{
	int i;
	i = 0;
	while(1)
	{
		int a;
		i++;
		cin >> a ;
		if (a == 0) break;
		cout << "Case " << i << ": " << a << endl;

	}
    return 0;
}


Measured memory_bytes: 3088
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    auto calc = [&](ll num){ 
        ll den = 0, n2 = num;
        while(n2){
            den += n2 % 10;
            n2 /= 10;
        }
        return 1. * num / den;
        // return pair<int, int>
    };
    int idx = 0;
    vector<pair<double, ll>> anss;
    anss.emplace_back(-1, -1);
    // double maxi = 1;
    // for(int i = 2; i < 100000000; i++){
    for(int i = 0; i < 18; i++){
    for(int j = 2; j <= 1000; j++){
        ll num = j;
        for(int k = 0; k < i; k++){
            num *= 10;
        }
        num--;
        if(anss.back().second >= num){ continue; }
        // ll num = i;
        double s = calc(num);
        // double s = calc(i);
        while(anss.back().first > s || anss.back().second == num){
            anss.pop_back();
        }
        anss.emplace_back(s, num);
        // prints(num, s, anss.size());
        // anss.emplace_back(s, i);
        // prints(i, s);
        // if(maxi <= s){
        //     maxi = s;
        //     cout << i << '\n';
        // }
    }
    }
    // prints(anss);
    int k; cin >> k;
    for(int i = 0; i < k; i++){
        cout << anss[i + 1].second << '\n';
    }
    // string ans = "0";
    // for(int i = 0; i < k; i++){
    //     if(ans[0] == '9'){
    //         ans = '1' + ans;
    //     }else{
    //         ans[0]++;
    //     }
    //     cout << ans << '\n';
    // }
}


Measured memory_bytes: 384
//TDteam01
#include <cstdio>  
#include <cstring>  
#include <algorithm>  
#include <iostream>  
#include <string>  
#include <vector>  
#include <stack>    
#include <cstdlib>  
#include <cmath>  
#include <set>  
#include <list>  
#include <deque>  
#include <map>  
#include <queue> 
using namespace std;

int H,W;
char t[200][200];
int si,sj,ti,tj;
int d[200][200];
int di[]={-1,0,1,0};
int dj[]={0,1,0,-1};
 
int main(){
	while(cin>>H>>W)
	{
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin>>t[i][j];
			if(t[i][j]=='@'){
				si=i;
				sj=j;
			}
			if(t[i][j]=='%'){
				ti=i;
				tj=j;
			}
		}
	}
	memset(d,1,sizeof(d));
	d[ti][tj]=0;
	queue<int> qi,qj;
	qi.push(ti);
	qj.push(tj);
	while(!qi.empty()){
		int pi=qi.front();qi.pop();
		int pj=qj.front();qj.pop();
		for(int dir=0;dir<4;dir++){
			int ni=pi+di[dir];
			int nj=pj+dj[dir];
			if(ni<0||nj<0||ni>=H||nj>=W)
				continue;
			if(t[ni][nj]=='#')
				continue;
			if(d[ni][nj]>d[pi][pj]+1){
				d[ni][nj]=d[pi][pj]+1;
				qi.push(ni);
				qj.push(nj);
			}
		}
	}
	int dist=d[si][sj];
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			if(t[i][j]=='$')
				if(d[i][j]<=dist)
					dist=0;
	if(dist)
		cout<<"Yes"<<endl;
	else 
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3356
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans;
  ans = min(b, d) - max(a, c);
  if(ans<0)
    ans = 0;
  cout << ans << endl;
  return 0;
}

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

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

    bool ok = true;
    for (int i = 0; i < 3; i++) {
        if (s[i] == s[i+1]) ok = false;
    }

    if (ok) cout << "Good" << endl;
    else cout << "Bad" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);	
		
		String str = scan.next();
		String s = "";
		for(int i = 0 ; i < str.length() ; i++){
			
			s += str.charAt(i) + "";
			
			if(i == 3){
				s += " ";
			}
		}
		
		System.out.println(s);
		
	}
}


Measured memory_bytes: 9556
#include<stdio.h>
int main()
{
int n,sum=0,i,j,t;
scanf("%d",&n);
int l[2*n];
for(i=0;i<2*n;i++)
{
scanf("%d",&l[i]);
}
for(i=0;i<2*n;i++)
{
for(j=i+1;j<2*n;j++)
{
if(l[i]>l[j])
{
t=l[i];
l[i]=l[j];
l[j]=t;
}
}
}
for(i=2*n-2;i>=0;i-=2)
{
sum+=l[i];
}
printf("%d",sum);
return 0;
}


Measured memory_bytes: 128
a=[2];b=[2]
for i in range(3,100000):
    t=0
    while t<len(a):
        if i%a[t]==0:
            break
        else:t+=1
    else:
        a.append(i)
        if i%5==2:
            b.append(i)

    if len(b)==55:
        break

b.sort()
print(*b[:int(input())])

Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int A, B, M;
	cin >> A >> B >> M;
	vector<int>a(A), b(B), x(M), y(M), c(M);
	int mna = INF, mnb = INF;
	rep(i, A) {
		cin >> a[i];
		mna = min(mna, a[i]);
	}
	rep(i, B) {
		cin >> b[i];
		mnb = min(mnb, b[i]);
	}
	rep(i, M) {
		cin >> x[i] >> y[i] >> c[i];
		x[i]--; y[i]--;
	}
	int nouse = mna + mnb;
	int mn = INF;
	rep(i, M) {
		int num = a[x[i]] + b[y[i]] - c[i];
		mn = min(mn, num);
	}
	int ans = min(mn, nouse);
	cout << ans;
}

Measured memory_bytes: 4096
#include <iostream>
#include <cstdio>
using namespace std;
char a[100][101];
int h,w;
 
int main() {
        while(1){
     cin>>h>>w;
     bool flag=true;
     if(!h&&!w)break;
     for(int i=0;i<h;i++){
         scanf("%s",a[i]);
     }
     int x=0,y=0;
     for(int i=0;i<h*w+1;i++){
         if(a[y][x]=='>')x++;
         if(a[y][x]=='<')x--;
         if(a[y][x]=='^')y--;
         if(a[y][x]=='v')y++;
         if(i==h*w&&a[y][x]!='.')flag=false;
     }
     if(flag)cout<<x<<" "<<y<<endl;
     else cout<<"LOOP"<<endl;
        }
        return 0;
}

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

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

  int c[n],s[n],f[n];
  for(i=0;i<n-1;i++) scanf("%d %d %d",&c[i],&s[i],&f[i]);

  for(i=0;i<n;i++){
    int t=0;
    for(int j=i;j<n-1;j++){
      if(t<s[j]) t=s[j];
      else if(t%f[j]==0);
      else t=t+f[j]-t%f[j];
      t+=c[j];
    }
    printf("%d\n",t);
  }
  return 0;
}


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

AB_list = list()

for _ in range(M):
    A,B = map(int, input().split())
    AB_list.append( (A, B) )

#print(AB_list)
bad_towers = dict()
can_good_towers = dict()

for (A,B) in AB_list:
    win = A
    lose = B
    if H_list[A-1] < H_list[B-1]:
        win = B
        lose = A
    
    # try:
    #     if can_good_towers[lose] == 1:
    #         del(can_good_towers[lose])
    # except KeyError:
    #     pass
        
    can_good_towers[str(win)] = 1
    bad_towers[str(lose)] = 1

    if H_list[A-1] == H_list[B-1]:
        bad_towers[str(win)] = 1

#print(can_good_towers)
#print(bad_towers)
# 一度もルートの組み合わせに入らず、またbadに入らないものの個数が良いやつ
good_tower_num = N - len(bad_towers)
print(good_tower_num)


Measured memory_bytes: 40500
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int a[19][19];

int main()
{
	int n,d; cin>>n>>d;
	for (int i=1; i<=n; i++)
	    for( int j=1; j<=d; j++)
	        cin>>a[i][j];
	
	int ans=0;        
    for (int i=1; i<=n-1; i++)
        for (int j=i+1; j<=n; j++)
        {
        	int res=0;
        	for (int u=1; u<=d; u++)
        	    res+=(a[i][u]-a[j][u])*(a[i][u]-a[j][u]);
        	        
        	int sq=sqrt(res);
        	if (sq*sq==res) ans++;   
		}
		
	cout << ans;
 } 

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int R, G, B, N;
    scanf("%d %d %d %d", &R, &G, &B, &N);
    int cnt = 0;
    int r, g, b;
    r = N/R ;
    g = N/G ;
    b = N/B ;
    for(int i=0;i<r+1;i++){
        for(int j=0;j<g+1;j++){
            if((N-R*i-G*j)%B==0&&(N-R*i-G*j)>-1){
                cnt += 1;
            }
        }
    }
    printf("%d\n", cnt);
    return 0;
}

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

using namespace std;

int main(){
	int a, b;
	cin>>a>>b;
	if((a<=9 && a>=1) & (b<=9 && b>=1)){
		cout<<a*b<<endl;
	}else{
		cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n){
        int k;
        cin >>k;
        a[i] = k%2;
    }
    bool c=0,d=0;
    int cnt = 0;
    rep(i,n){
        if(a[i]==0){
            c = 1;
        }else{
            d = 1;
            cnt++;
        }
    }
    if(c&&d){
        if(cnt%2==0){
            cout << n-2 << endl;
        }else{
            cout << n-1 << endl;
        }
    }else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <tuple>
#include <set>
#include <functional>

using namespace std;


int main() {
    long long n, m;
    cin >> n >> m;
    vector<pair<long long , long long>> nums(n);

    for (int i = 0; i < n; i++) {
        long long a, b;
        cin >> a >> b;
        nums[i] = make_pair(a, b);
    }
    sort(nums.begin(), nums.end());

    long long cnt = 0;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        int a, b;
        long long tmp = cnt;
        a = nums[i].first, b = nums[i].second;
        tmp= min(tmp + b, m);
        ans += (tmp - cnt) * a;

        cnt = tmp;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1792
import sys
import numpy as np


def test(a, K):
    from itertools import combinations
    answer = []
    for i, j in combinations(a, 2):
        answer.append(i * j)
    answer.sort()
    print(answer[K - 1])


def main():
    read = sys.stdin.read

    N, K, *A = map(int, read().split())

    if N <= 10:
        test(A, K)
        exit()
    A.sort()
    A = np.array(A, np.int64)
    negative = A[A < 0]
    positive = A[A > 0]
    m = len(negative)
    p = len(positive)
    z = N - m - p

    M = m * p
    Z = z * (N - z) + z * (z - 1) // 2
    negative = -negative[::-1]
    # 負の数の操作(pythonの挙動)は頭がこんがらがるので正の数にして考える

    if K <= M:
        left = 1
        right = -A[0] * A[-1] + 1
        while left + 1 < right:
            mid = (left + right) // 2
            cnt = (p - np.searchsorted(positive, (mid + negative - 1) // negative, side='left')).sum()
            if cnt < K:
                right = mid
            else:
                left = mid
        print(-left)
    elif K <= M + Z:
        print(0)
    else:
        K -= M + Z
        left = 0
        right = max(A[0] * A[1], A[-1] * A[-2])
        positive2 = positive ** 2
        negative2 = negative ** 2
        while left + 1 < right:
            mid = (left + right) // 2
            a = np.searchsorted(negative, mid // negative, side='right').sum() - (mid >= negative2).sum()
            b = np.searchsorted(positive, mid // positive, side='right').sum() - (mid >= positive2).sum()

            if (a + b) // 2 < K:
                left = mid
            else:
                right = mid

        print(right)


if __name__ == '__main__':
    main()


Measured memory_bytes: 32324
#include<bits/stdc++.h>
#include <bitset>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dcm(a) setprecision(a)<<fixed
#define MOD 1000000007
#define clr(memo, a) memset(memo,a,sizeof(memo))
#define PI acos(-1)

void solve()
{
int n;
cin>>n;
vector<double> dp(n+5);
dp[0]=1;
for(int i=0;i<n;i++){
    double p;
    cin>>p;
    for(int j=i+1;j>=0;--j)
    {
      dp[j]=(j==0? 0:dp[j-1]*p)+dp[j]*(1-p);
    }

}
  double ans=0;
    for(int i=0;i<=n;i++)
        if(i>(n-i))
        ans+=dp[i];
    cout<<setprecision(11)<<ans<<endl;
}
int main()
{
    fast;
    solve();

    return 0;
}


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

int main() {
    int n;
    string s;
    cin>>n>>s;

    int ans = 0;
    for(int i=0; i<n-2; i++) {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import fractions
a,b= list(map(int, input().split()))
i= list(map(int, input().split()))

ans=0
l=[]
for j in range(a):
    l.append(abs(b-i[j]))
for k in range(0,a):
    if k==0:
        ans=l[0]
    else:
        ans=fractions.gcd(ans,l[k])
print(ans)
    

Measured memory_bytes: 16240
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

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

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define rep(i,n) for(int i=0; i <(n); i++)

int compint(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

int main(){
  int a[3];
  rep(i,3){
    scanf("%d",&a[i]);
  }
  qsort(a,3,sizeof(int),compint);
  printf("%d\n",a[0]+a[1]);
  return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <vector>

typedef long long ll;

int main(int argc, char* argv[])
{
  ll N;
  std::cin >> N; 
  std::vector< ll > va(N, 0);

  ll max_color = 1;
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
    max_color = std::max(max_color, va[i]);
  }

  ll ans = 0;
  for (ll i = 1; i < N; i++) {
    if (va[i] == va[i-1]) {
      ans++;
      va[i] = max_color + 1;
      max_color++;
    }
  }

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


Measured memory_bytes: 256
#ifdef __GNUC__ 
#include <bits/stdc++.h>
auto & in = std::cin;
#else
std::istringstream in;
#endif
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/dynamic_bitset.hpp>
#include <boost/preprocessor.hpp>

using namespace std;
#define ALL(v) std::begin(v),std::end(v)
#define RALL(v) v.rbegin(),v.rend()
using u6 = std::uint64_t;
using u3 = std::uint32_t;
constexpr u6 moduloNo = 1'000'000'000 + 7; //' 1e9 + 7
constexpr u3 maxA = 0x10'0000;//'

#define APPLY_PP(pp, ...) pp( __VA_ARGS__ )
#define DEFVALUE1(r,type,name) type name;
#define DEFINIT1(r,type,name) in >> calc.name;
#define DEFVALUEIMPL(r,fn,tpl) BOOST_PP_LIST_FOR_EACH(fn,BOOST_PP_TUPLE_ELEM(0, tpl), BOOST_PP_TUPLE_TO_LIST(BOOST_PP_TUPLE_POP_FRONT(tpl)))
#define DEFVALUES(expr) APPLY_PP(DEFVALUESIMPL,expr)
#define DEFVALUESIMPL(expr) \
	BOOST_PP_SEQ_FOR_EACH(DEFVALUEIMPL,DEFVALUE1,BOOST_PP_VARIADIC_SEQ_TO_SEQ(expr))\
	template <typename U> struct Initer<0,U>{template <typename T>static void init(T & calc){BOOST_PP_SEQ_FOR_EACH(DEFVALUEIMPL,DEFINIT1,BOOST_PP_VARIADIC_SEQ_TO_SEQ(expr)) }};

template <typename T>
struct invecT {
	decltype(auto) begin()const {
		return std::istream_iterator<T>(in);
	}
	decltype(auto) end()const {
		return std::istream_iterator<T>();
	}
};
template <typename T>
invecT<T> invec;
struct State {
	array<u3, 3> buf;
	//State() :buf{ 1,0,1 } {}
	constexpr State() :buf{1,0,0}{}
	State(u3 zerocount) :buf{ 1,0,zerocount } { addX(zerocount); }
	void addX(u3 zero) {
		if (zero != buf[2]) {
			u6 zerodiff = zero - buf[2];
			buf[0] = (u3)(((u6)buf[0] + zerodiff * buf[1]) % moduloNo);
			buf[2] = zero;

		}

		buf[1] = buf[0] + buf[1];
		buf[1] = (buf[1] >= moduloNo) ? buf[1] - moduloNo : buf[1];
	}
};
/*
u6 pow2(u6 n) {
	if (n < 64)return (u6(1) << n) % moduloNo;
	else if (n == 64)return (u6(0) - moduloNo) % moduloNo;
	u6 tmp = pow2(n / 2);
	tmp = tmp * tmp;
	if (n & 1)tmp *= 2;
	return tmp % moduloNo;
}
 //*/
u6 pow2(u6 n) {
	if(n<64)return (u6(1) << n) % moduloNo;
	vector<bool> mod2;
	while (n >= 64) {
		mod2.push_back(n&1);
		n >>= 1;
	}
	u6 result = (u6(1) << n) % moduloNo;
	result = std::accumulate(mod2.rbegin(), mod2.rend(), result, [](u6 st, bool i) {return ((st*st)<<u6(i))%moduloNo; });
	return result;
}
//*/

struct Calc {
	template <int i,typename U=void> struct Initer {
		template <typename T>static void init(T & calc) {}
	};
	DEFVALUES((u6,N));
	State stmap[maxA];
	u6 calc() {
		u3 st = 0;
		u3 zerocount = 0;
		for (auto tmp:invec<u3>) {
			// in >> tmp;
			st ^= tmp;
			if (!st) {
				++zerocount;
			}
			else {
				stmap[st].addX(zerocount);
			}
		}
		if (st != 0) {
			return stmap[st].buf[0];
		}
		else {
			u6 result = pow2(zerocount - 1);
			for (auto & stv : stmap) {
				result = (result + stv.buf[1]) % moduloNo;
			}
			return result;
		}
	}
};
Calc calc;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);//
#ifndef __GNUC__ 
	//in.str("24\n1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2");
	in.str("32\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0");
#endif
	Calc::Initer<0>::init(calc);
	cout << calc.calc() << endl;
}


Measured memory_bytes: 12668
import java.util.*;

public class Main{
    public static void main (String[] args){
        int a;
        int b;
        Scanner reader = new Scanner(System.in);

        a = reader.nextInt();
        b = reader.nextInt();

        if(a < b){
            System.out.println("a < b");
        }
        else if(a > b){
            System.out.println("a > b");
        }
        else{
            System.out.println("a == b");
        }
        reader.close();
    }
}


Measured memory_bytes: 26176
using System;
using System.Collections.Generic;
using System.Linq;

namespace ATCoderPuzzles
{
    class DKnapsack1
    {
        static void Main()
        {
            // N, W
            var backpack = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();

            // WeightRemaining, value
            Dictionary<int, long> dict = new Dictionary<int, long>()
            {
                { backpack[1], 0 }
            };
            SortedSet<int> keys = new SortedSet<int>() { backpack[1] };
            HashSet<int> newKeys = new HashSet<int>();

            // Build set
            long maxVal = 0;
            while (backpack[0]-- > 0)
            {
                // Weight, Value
                int[] lineSegments = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();

                foreach(var key in keys.GetViewBetween(lineSegments[0],backpack[1]))
                {
                    int newKey = key - lineSegments[0];
                    long newVal = dict[key] + lineSegments[1];
                    maxVal = Math.Max(maxVal, newVal);

                    if (dict.ContainsKey(newKey))
                    {
                        dict[newKey] = Math.Max(newVal, dict[newKey]);
                    }
                    else
                    {
                        dict[newKey] = newVal;
                        newKeys.Add(newKey);
                    }
                }
                keys.UnionWith(newKeys);
            }

            Console.WriteLine(maxVal);
        }
    }
}


Measured memory_bytes: 41732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<int, ll> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
// const ll MAXN = 

int n;
priority_queue<double, vector<double>, greater<double>> d;
/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();

    cin >> n;
    REP (i, n) {
        double x;
        cin >> x;
        d.emplace(x);
    }

    REP (i, n-1) {
        double a, b;
        a = d.top();
        d.pop();
        b = d.top();
        d.pop();

        d.emplace((a+b)/2);
    }

    cout << fixed << setprecision(10) << d.top() << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
int main() {
	int n, a[100010], ans = 0;
	pair<int, int>f;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	f.first = a[0];
	f.second = 1;
	for (int i = 1; i < n; i++) {
		if (f.first == a[i])f.second++;
		else {
			if (f.second % 2)ans++;
			f.first = a[i];
			f.second = 1;
		}
	}
	if (f.second % 2)ans++;
	cout << ans << endl;
	return 0;
}

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

int main()
{
	int n, m,vote=0; long int count=0;
	cin >> n >> m;
	int a[n];
	for(int i=0; i<n; i++)
	{
		cin >> a[i];
		count = count + a[i];
	}
	if(m==0)
	{cout << "Yes"; return 0;}
	for(int i=0; i<n; i++)
	{
		if(a[i]>=((float)count/(4*m)))
		vote++;
	}
	//cout << (float)count/(4*m);
	if(vote>=m)
	cout << "Yes";
	else
	cout << "No";
	
	return 0;
}


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

int main(){
    int n,a,min=1000001,max=-1000001;
    long long sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        sum+=a;
        if(a>max)max=a;
        if(a<min)min=a;
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3112
n=int(input())
c=[]
s=[]
f=[]
for i in range(n-1):
    ci,si,fi=map(int,input().split())
    c.append(ci)
    s.append(si)
    f.append(fi)
for h in range(n):
    now=0
    for i in range(h,n-1):
        if(now <= s[i]):
            now = s[i]+c[i]
        else:
            now =  s[i] + (-(-(now-s[i])//f[i]))*f[i] + c[i]
#        print("i:"+str(i)+" now:"+str(now))
    print(now)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <stdint.h>

using namespace std;

int main(){
    int N;
    uint64_t m_san = 0;
    uint64_t a_san = 0;
    uint64_t r_san = 0;
    uint64_t c_san = 0;
    uint64_t h_san = 0;
    cin >> N;
    string s;
    for(int i=0;i<N;i++){
        cin >> s;
        if(s[0] == 'M') m_san++;
        if(s[0] == 'A') a_san++;
        if(s[0] == 'R') r_san++;
        if(s[0] == 'C') c_san++;
        if(s[0] == 'H') h_san++;
    }

    uint64_t total = 0;
    total += m_san * a_san * r_san;
    total += m_san * a_san * c_san;
    total += m_san * a_san * h_san;
    total += m_san * c_san * r_san;
    total += m_san * h_san * r_san;
    total += m_san * c_san * h_san;
    total += c_san * a_san * r_san;
    total += h_san * a_san * r_san;
    total += c_san * a_san * h_san;
    total += c_san * r_san * h_san;

    printf("%llu\n", total);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        int K = Integer.parseInt(st.nextToken());

        st = new StringTokenizer(br.readLine());
        int[] price_array = new int[N];

        int result = 0;

        for(int i = 0; i < N; i++) {
            price_array[i] = Integer.parseInt(st.nextToken());
        }

        Arrays.sort(price_array);

        for(int j = 0; j < K; j++) {
            result += price_array[j];
        }
        
        pw.println(result);
        br.close();
        pw.close();
    }
}

Measured memory_bytes: 33104
/**
 *    author:  math2do
 *    created: 28.03.2020 17:31:19
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  bool yes = (s[2] == s[3] && s[4] == s[5]);
  cout << (yes ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
using namespace std;

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

using ll=long long;

using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;
using vs=vector<string>;

const ll INF=LLONG_MAX;

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

  int N,K; cin >>N >>K;
  vll h(N);
  rep(i,0,N) {cin >>h[i];}
  vll dp(N,INF);
  dp[0]=0;
  rep(i,1,N) {
    rep_eq(j,1,K) {
      if (0<=i-j) {
        chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
      }
    }
  }
  cout <<dp.back() <<'\n';
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll unsigned long long 

 
int main()
{
	ios::sync_with_stdio(false); 
	std::cin.tie(NULL); std::cout.tie(NULL);
	int n,m; cin>>n>>m;
	string ar[n];
	for(int i=0;i<n;i++) cin>>ar[i];
	ll dp[n+1][m+1];
	for(int i=0;i<n+1;i++){
		for(int j=0;j<m+1;j++) dp[i][j]=0;
	}
	dp[1][1]=1;
	for(int i=2;i<n+1;i++){
		if(ar[i-1][0]!='#')
			dp[i][1]=dp[i-1][1];
	}
	for(int i=2;i<m+1;i++){
		if(ar[0][i-1]!='#')
			dp[1][i]=dp[1][i-1];
	}
	for(int i=2;i<n+1;i++){
		for(int j=2;j<m+1;j++){
			if(ar[i-1][j-1]=='.'){
				dp[i][j]=dp[i-1][j]%mod+dp[i][j-1]%mod;
				dp[i][j]%=mod;
			}
		}
	}
	cout<<dp[n][m]<<endl;
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int E[N+1]={};
    int W[N+1]={};
    for(int i=0;i<S.size();i++){
        if(S[i]=='W') W[i]++;
        else E[i]++;
    }
    for(int i=1;i<S.size();i++){
        W[i]+=W[i-1];
    }
    for(int i=S.size()-2;i>=0;i--){
        E[i]+=E[i+1];
    }
    int ans=1e7;
    for(int i=0;i<S.size();i++){
        int res;
        res=W[i-1]+E[i+1];
        ans=min(res,ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
#include <iostream>
#include <string>
using namespace std;
int main(){
	int i,n,c=0;
	string s;
	cin >> s;
	n = s.size();
	for(i=0;i<n-1;i++){
		if(s[i]!=s[i+1]){
			c +=1;
		}
	}
	cout << c << endl;
}
	

Measured memory_bytes: 512