akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type& a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	int n,k;
	string s;
	cin>>n>>k>>s;
	
	int cnt=1;
	for(int i=1;i<n;++i){
		if(s[i-1]!=s[i]) cnt++;
	}
	//cout<<cnt<<endl;//!!!!!!!!!
	
	while(cnt>1&&k>0){
		if(cnt==2){
			cnt=1;
			k--;
		}else{
			cnt-=2;
			k--;
		}
	}
	
	cout<<n-cnt<<endl;
	return 0;
}//refering others code.

Measured memory_bytes: 512
program prob3
    implicit none
    character(len=100005)::S
    integer::n, i, j, cnt
    read(*,*) S
    cnt = 0
    n = len_trim(S)
    do i = 1, N
        if(S(i:i) .eq. "0") cnt = cnt + 1
    end do
    write(*,*) 2*min(n-cnt,cnt)
    stop
end program

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int,int> P;

struct UnionFind {
    vector<int> par;
    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    int p[n];
    UnionFind tree(n);
    rep(i, n) cin >> p[i];
    rep(j, m){
        int x, y;
        cin >> x >> y;
        tree.unite(x - 1, y - 1);
    }
    int cnt = 0;
    rep(i, n){
        if (tree.same(p[i] - 1, i)) cnt ++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.awt.geom.*;
import static java.util.Arrays.*;

class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = 0;
		int m = 0;
		int count = 0;
		int[] h = new int[1500];
		int[] w = new int[1500];
		int[] hh = new int[1500001];
		int[] ww = new int[1500001];
		while(true){
			n = Integer.parseInt(stdIn.next());
			m = Integer.parseInt(stdIn.next());
			if(n==0 && m==0){
				break;
			}
			Arrays.fill(h,0);
			Arrays.fill(w,0);
			Arrays.fill(hh,0);
			Arrays.fill(ww,0);
			count = 0;
			for(int i=0;i<n;i++){
				h[i] = Integer.parseInt(stdIn.next());
			}
			for(int i=0;i<m;i++){
				w[i] = Integer.parseInt(stdIn.next());
			}
			for(int i=0;i<n;i++){
				int c = 0;
				for(int j=i;j<n;j++){
					c += h[j];
					hh[c]++;
				}
			}
			for(int i=0;i<m;i++){
				int c = 0;
				for(int j=i;j<m;j++){
					c += w[j];
					ww[c]++;
				}
			}

			for(int i=0;i<1500001;i++){
				count += hh[i]*ww[i];
			}

			out.println(count);
			out.flush();
		}
	}
}

Measured memory_bytes: 61776
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9) + 7;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
      	int n = sc.nextInt();
      	int res = 0;
      	
      	for (int i = 0; i < n; i++) {
      		int num = sc.nextInt();
      		
      		while (num % 2 == 0) {
      			res++;
      			num/= 2;
      		}
      		
      	}
      	
 		System.out.println(res);
	}
	
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 24532
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


int main(){
    ll n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<ll> dp(n+1,0);
    vector<ll> dp2(n+1,0);
    for(int i=1;i<n;i++){
        if(s[i-1]=='A' && s[i]=='C'){dp[i]++;}
        dp2[i]=dp2[i-1]+dp[i];
    }
    while(q--){
        ll l,r;
        cin>>l>>r;
        l--;
        r--;
        ll ans=dp2[r];
        ans-=dp2[l];
        cout<<ans<<endl;
    }
    
    
    return 0;
}


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

int main(){
   int n,d;
   cin >> n >> d;
   int ans = n / (2*d+1);
   int pass = n %(2*d+1);
   if(pass != 0){
       cout << ans + 1 << endl;
   }
   else{
       cout << ans << endl;
   }
   
}

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

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

  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];
  sort(h.begin(), h.end());
  cout << n - (lower_bound(h.begin(), h.end(), k) - h.begin()) << '\n';
  return 0;
}

Measured memory_bytes: 640
def alpha2alpha(alpha,n):
    if ord(alpha)+n-ord("A")<26:
        return chr(ord(alpha)+n)
    else:
        return chr(ord(alpha)+n-26)
N=int(input())
S=input()
T=""
for t in S:
    T=T+alpha2alpha(t,N)
print(T)

Measured memory_bytes: 3060
#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int main(){
	char buf[10];
	bool FLG;

	while(scanf("%s",buf)!=EOF){
		FLG = true;
		for(int i=0;i<=6;i+=3){
			if((buf[i] == 'o' || buf[i] == 'x') && buf[i] == buf[i+1] && buf[i+1] == buf[i+2]){
				printf("%c\n",buf[i]);
				FLG = false;
				break;
			}
		}

		if(FLG){
			for(int i = 0; i <=2; i++){
				if((buf[i] == 'o' || buf[i] == 'x') && buf[i] == buf[i+3] && buf[i] == buf[i+6]){
					printf("%c\n",buf[i]);
					FLG = false;
					break;
				}
			}
		}

		if(FLG){
			if((buf[0] == 'o' || buf[0] == 'x') && buf[0] == buf[4] && buf[4] == buf[8]){
				printf("%c\n",buf[0]);
				FLG = false;
			}
		}

		if(FLG){
			if((buf[2] == 'o' || buf[2] == 'x')  && buf[2] == buf[4] && buf[4] == buf[6]){
				printf("%c\n",buf[2]);
				FLG = false;
			}
		}

		if(FLG)printf("d\n");

	}

    return 0;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

template<int SZ>
struct DSU {
    int par[SZ], sz[SZ];

    void init(int n) {
        for (int i=0; i<n; i++) {
            par[i] = i;
            sz[i] = 1;
        }
    }

    int findRoot(int u) {
        if (u != par[u])
            par[u] = findRoot(par[u]);
        return par[u];
    }

    bool unite(int u, int v) {
        u = findRoot(u);
        v = findRoot(v);
        if (u == v)
            return false;
        if (sz[u] < sz[v])
            swap(u, v);
        par[v] = u;
        sz[u] += sz[v];
        return true;
    }
};
DSU<200000> ds;

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

    int n, q;
    cin >> n >> q;
    ds.init(n);
    for (int i=0; i<q; i++) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0)
            ds.unite(u, v);
        else
            cout << (ds.findRoot(u) == ds.findRoot(v)) << "\n";
    }

    return 0;
}


Measured memory_bytes: 5068
#include<iostream>
#include<algorithm>
using namespace std;
int num[200];
bool flg[200];
int n,m,ans;
int t[20][20];
bool used[10];
void solve(int y,int x,int sum){
  if(y==0&&x==m){
    if(sum==0)ans++;
    return;
  }
  int a=num[t[y][x]];

  if(y==n-1){
    if(a==-1){
      if((!flg[t[y][x]]||sum%10!=0) && !used[sum%10]){
	used[sum%10]=true;
	num[t[y][x]]=sum%10;
	solve(0,x+1,sum/10);
	used[sum%10]=false;num[t[y][x]]=-1;
      }
    }else if(a==sum%10)solve(0,x+1,sum/10);

  }else{
    if(a==-1){
      for(int i=0;i<10;i++){
	if(i==0&&flg[t[y][x]])continue;
	if(used[i])continue;
	num[t[y][x]]=i;
	used[i]=true;
	solve(y+1,x,sum+i);
	num[t[y][x]]=-1;used[i]=false;
      }
    }else solve(y+1,x,sum+a);
  }
}

void init(){
  m=ans=0;
  for(int i=0;i<200;i++)num[i]=-1,flg[i]=false;
  for(int i=0;i<20;i++)for(int j=0;j<20;j++)t[i][j]=0;
  for(int i=0;i<10;i++)used[i]=false;
  num[0]=0;
}

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    init();
    string str;
    for(int i=0;i<n;i++){
      cin>>str;
      int size=str.size();
      m=max(m,size);
      for(int j=0;j<size;j++)t[i][j]=str[size-j-1];
      if(size>1)flg[(int)str[0]]=true;
    }
    solve(0,0,0);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	int i;
	int alice = 0;
	int bob = 0;
	int num = 0;

	cin >> n;

	vector<int> a(n);
	
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	while (1) {
		sort(a.begin(), a.end());
		reverse(a.begin(), a.end());

		alice += a[0];
		a[0] = 0;
		num++;
		if (num == n) break;
		bob += a[1];
		a[1] = 0;
		num++;
		if (num == n) break;
	}

	cout << alice - bob << "\n";

    return 0;
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vli;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define I cin
#define O cout
#define EN endl
#define ln cout<<endl
#define pb(a) push_back(a)
#define x first
#define y second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
  return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
  return a / gcd(a, b) * b;
}

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
vi v;
llint cnt[100001] = {};

int main()
{
  llint n, k;
  I >> n >> k;

  int a, b;
  for(int i= 0; i < n; i++) {
    I >> a >> b;
    if(cnt[a] == 0) v.pb(a);
    cnt[a] += b;
  }
  
  sort(v.begin(), v.end());
  
  for(int i = 0; i < v.size(); i++) {
    k -= cnt[v[i]];
    if(k <= 0) {
      O << v[i] << EN;
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 1408
# AOJ 0025 Hit and Blow

while line = gets
  a = line.split.map {|v| v.to_i}
  b = gets.split.map {|v| v.to_i}

  n_hits = n_blows = 0
  b.each_with_index do |x, i|
    i_x_a = a.index(x)

    if i_x_a
      if i_x_a == i
        n_hits += 1
      else
        n_blows += 1
      end
    end
  end

  puts [n_hits, n_blows].join(" ")
end

Measured memory_bytes: 6108
#include <stdio.h>

int main(int argc, char **argv)
{
    int w, a, b;
    scanf("%d %d %d", &w, &a, &b);

    int d = 0;
    if (a + w < b) {
        d = b - a - w;
    } else if (b + w < a) {
        d = a - b - w;
    }
    printf("%d\n", d);
    return 0;
}

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

int n;
const int maxn = 1e5 + 500;
long long dp[maxn][2];
int a[maxn];

long long solve (int p, bool flip) {
  if (p >= n) return 0;
  if (dp[p][flip] != -1) return dp[p][flip];
  long long tot = - 1e12; 
  if (flip == false) {    
    tot = max(tot, a[p] + solve(p + 1, false));
    if (p <= n - 2) tot = max(tot, -a[p] + solve(p + 1, true));
  } 
  if (flip == true){
    if (p <= n - 2) tot = max(tot, a[p] + solve(p + 1, true));
    tot = max(tot, -a[p] + solve(p + 1, false));
  } 
  return dp[p][flip] = tot;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  memset (dp, -1, sizeof(dp));
  cout << solve (0, 0) << '\n';
  return 0;
}

Measured memory_bytes: 6912
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Queue;

/**
 * 解説通りに実装したソースコード
 * 
 * https://atcoder.jp/contests/abc174/submissions/15644133 と https://atcoder.jp/contests/abc174/submissions/15644479
 * にも参考<br/>
 * TLE回避するため以下のことを実施
 * <ol>
 * <li>java.util.Scanner のかわりに、java.io.BufferedReaderを使用</li>
 * <li>Stream APIのかわりに、普通のfor文使用</li>
 * <li>結果出力する際に、いったんStringBuilderに入れてからいっきに出力</li>
 * </ol>
 */
public class Main {

	public static void main(String[] args) {
		try (InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr)) {
			String[] strings = br.readLine().split(" ", 2);
			int n = Integer.parseInt(strings[0]), q = Integer.parseInt(strings[1]);
			String[] cs = br.readLine().split(" ", n);
			Queue<Query> queue = new PriorityQueue<>();
			for (int i = 0; i < q; i++) {
				String[] s = br.readLine().split(" ", 2);
				int l = Integer.parseInt(s[0]), r = Integer.parseInt(s[1]);
				queue.add(new Query(i, l, r));
			}
			BinaryIndexedTree bit = new BinaryIndexedTree(n + 1);
			int[] answers = new int[q], indexes = new int[n + 1];
			Arrays.fill(indexes, 0);
			for (int i = 0; i < n; i++) {
				int c = Integer.parseInt(cs[i]);
				if (indexes[c] > 0) {
					bit.add(indexes[c], -1);
				}
				bit.add(i + 1, 1);
				indexes[c] = i + 1;
				while (!queue.isEmpty() && (i + 1 == queue.peek().right)) {
					Query query = queue.poll();
					answers[query.index] = bit.sum(query.left, query.right);
				}
				if (queue.isEmpty()) {
					break;
				}
			}
			StringBuilder sb = new StringBuilder();
			for (int x : answers) {
				sb.append(x).append("\n");
			}
			System.out.print(sb);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	private static class Query implements Comparable<Query> {
		int index;
		int left;
		int right;

		Query(int index, int left, int right) {
			super();
			this.index = index;
			this.left = left;
			this.right = right;
		}

		@Override
		public int compareTo(Query o) {
			return this.right - o.right;
		}
	}

	private static class BinaryIndexedTree {
		int size;
		int[] data;

		BinaryIndexedTree(int size) {
			super();
			this.size = size;
			data = new int[size];
			Arrays.fill(data, 0);
		}

		void add(int index, int value) {
			for (int i = index; i < size; i += (i & -i)) {
				data[i] += value;
			}
		}

		int sum(int index) {
			int sum = 0;
			for (int i = index; i > 0; i -= (i & -i)) {
				sum += data[i];
			}
			return sum;
		}

		int sum(int from, int to) {
			return sum(to) - sum(from - 1);
		}
	}
}


Measured memory_bytes: 108648
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

// 累積和
struct cumulative_sum {
    using lint = long long int;
    int sz;
    // data[i]:元の数列
    vector<lint> data;
    // cum[i]:[0,i)の和
    vector<lint> sum;
    // 要素数を指定して初期化
    cumulative_sum(const int _sz) : sz(_sz) {
        data.assign(sz, 0);
        sum.assign(sz + 1, 0);
    }
    lint& operator[](const int k) {
        return data[k];
    }
    // dataに基づいてsumを構築
    void build() {
        for (int i = 0; i < sz; i++) sum[i + 1] = sum[i] + data[i];
    }
    // [a,b)の和を求める
    lint query(const int a, const int b) {
        return sum[b] - sum[a];
    }
};

lint n, m;
vector<lint> a;

//幸福度k以上の握手が何個あるか
lint count(lint k) {
    lint res = 0;
    for (int i = 0; i < n; i++) {
        res += a.end() - lower_bound(a.begin(), a.end(), k - a[i]);
    }
    return res;
}

bool check(lint k) {
    return count(k) < m;
}

// めぐる式二分探索
long long meguru_BinarySearch(long long ok, long long no,
                              function<bool(long long)> isValid) {
    while (abs(ok - no) > 1) {
        long long mid = ok / 2 + no / 2 + (1 & ok & no);
        (isValid(mid) ? ok : no) = mid;
    }
    return ok;
}

int main() {
    cin >> n >> m;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    lint ok = meguru_BinarySearch(1e+6, 0, check);
    lint ans = 0;
    ans += (ok - 1) * (m - count(ok));
    cumulative_sum cum(n);
    for (int i = 0; i < n; i++) {
        cum[i] = a[i];
    }
    cum.build();
    for (int i = 0; i < n; i++) {
        int b = lower_bound(a.begin(), a.end(), ok - a[i]) - a.begin();
        ans += a[i] * (n - b) + cum.query(b, n);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
def solve():
    N = int(input())
    cnt = [[0]*10 for i in range(10)]
    for i in range(1, N+1):
        target_str = str(i)
        cnt[int(target_str[0])][int(target_str[-1])] += 1

    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans += cnt[i][j] * cnt[j][i]
    print(ans)

if __name__ == "__main__":
    solve()

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

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

  int now = 100000;
  while(n--){
    now *= 1.05;
    if(now % 1000) now +=  -now % 1000 + 1000;
  }
  cout << now << endl;

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main(void) {
  int n;
  cin >> n;

  int x[n],y[n];
  for(int i=1;i<=n;i++){
    cin >> x[i] >> y[i];
  }
  
  vector<int> p(n);
  rep(i,n){p[i] = i+1;}
  
  double sum=0.0,cnt=0;
  do{
    for(int i=0;i<n-1;i++){
      double dx = x[p[i]] - x[p[i+1]];
      double dy = y[p[i]] - y[p[i+1]];
      sum += pow(dx*dx + dy*dy,0.5);      
    }
    cnt++;
  }while(next_permutation(p.begin(),p.end()));

  cout << fixed << setprecision(10) << sum/cnt << endl;
  
  return 0;
}

Measured memory_bytes: 512
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();

    let a = iter.next().unwrap().parse::<usize>().unwrap();
    let b = iter.next().unwrap().parse::<usize>().unwrap();
    let c = iter.next().unwrap().parse::<usize>().unwrap();
    let d = iter.next().unwrap().parse::<usize>().unwrap();
    let e = iter.next().unwrap().parse::<usize>().unwrap();
    let k = iter.next().unwrap().parse::<usize>().unwrap();

    let mut antennas = vec![a, b, c, d, e];
    antennas.sort();

    for i in 0..4 {
        for j in i+1..5 {
            if antennas[j] - antennas[i] > k {
                println!(":(");
                return
            }
        }
    }
    println!("Yay!");
}


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

int main(){
    int n;
    cin >> n;
    double s = sqrt(n);
    int k = (int) s;
    ll count = 0;
    ll ans = 0;
    for (int i = 1; i < k + 1; i ++){
        for (ll j = i; j < 10000000; j++){
            if (i * j < n){
                if (i == j){
                    count += 1;
                }
                else{
                    count += 2;
                }
                
            }
            else {
                break;
            }
        }
        
    }
    cout << count << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;

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

#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)

#ifdef LOCAL
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#else
#define dump(c) ;
#endif

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

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

inline vi uni(vi &vec) {
    sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

struct ____ {
    ____() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} ________;

ll solve() {
    string S;
    cin >> S;
    int n = S.length();

    ll sum = 0;
    rep(M, 1 << (n - 1)) {
        stringstream ss;

        ss << S[0];
        rep(i, n - 1) {
            if ((M >> i & 1) == 1) {
                ll num;
                ss >> num;
                sum += num;
                ss = stringstream();
            }

            ss << S[i + 1];
        }

        ll num;
        ss >> num;
        sum += num;
    }

    return sum;
}

int main() {
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000001

int A[MAX],B[MAX],n;

void CountingSort(){
  int i,k=10000;
  int C[10000]={};
  for(i=1;i<n+1;i++)C[A[i]]++;
  for(i=1;i<k+1;i++)C[i]=C[i]+C[i-1];
  for(i=n;i>=1;i--){
    B[C[A[i]]]=A[i];
    C[A[i]]--;
  }
  return;
}


int main(){
  scanf("%d",&n);
  int i;
  for(i=1;i<n+1;i++)scanf("%d",&A[i]);
  CountingSort();
  for(i=1;i<n+1;i++){
    if(i!=n)printf("%d ",B[i]);
    else printf("%d\n",B[i]);
  }
  return 0;
}



Measured memory_bytes: 17516
defmodule Main do
    def main do
        n = IO.read(:line)
        |> String.trim
        |> String.to_integer

        ans = 1..n
        |> Enum.map(fn x ->
            cond do
                rem(x, 3) == 0 -> 0
                rem(x, 5) == 0 -> 0
                true -> x
            end
        end)
        |> Enum.sum

        IO.puts ans
    end
end


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int main() {
	string str[10] = {"* = ****", "* =* ***", "* =** **", "* =*** *", "* =**** ",
					 " *= ****", " *=* ***", " *=** **", " *=*** *", " *=**** "
	};
	bool flag = false;
	int x;

	while (cin >> x) {
		if (flag) puts("");
		
		int ans[5];
		for (int i = 4; i >= 0; i--) {
			ans[i] = x % 10;
			x /= 10;
		}
		
		REP(i, 8) {
			REP(j, 5) {
			printf("%c", str[ans[j]][i]);
			}
			puts("");
		}
		
		flag = true;
	}
	return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,A,B;
ll sum[55];
ll v[55];
ll a[55],b[55];
ll C[55][55];
ll nCr(int n,int r){
	if(C[n][r]!=-1ll)return C[n][r];
	if(r==0||n==r)return C[n][r]=1ll;
	return C[n][r]=nCr(n-1,r-1)+nCr(n-1,r);
}
int main(){
	scanf("%d %d %d",&N,&A,&B);
	for(int i=0;i<N;i++)scanf("%lld",&v[i]);
	sort(v,v+N);
	a[N-1]=1;
	for(int i=N-2;i>=0;i--){
		if(v[i]==v[i+1])a[i]=a[i+1]+1;
		else a[i]=1;
	}
	b[0]=a[0];
	for(int i=1;i<N;i++){
		if(v[i]==v[i-1])b[i]=b[i-1];
		else b[i]=a[i];
	}
	/*for(int i=0;i<N;i++)cout << a[i] << ' ';
	cout << endl;
	for(int i=0;i<N;i++)cout << b[i] << ' ';
	cout << endl;*/
	sum[0]=0;
	for(int i=1;i<=N;i++){
		sum[i]=sum[i-1]+v[N-i];
	}
	for(int i=0;i<=50;i++){
		for(int j=0;j<=50;j++){
			C[i][j]=-1ll;
		}
	}
	printf("%.12f\n",(double)sum[A]/(double)A);
	if(a[N-A]==A){
		ll ans = 0ll;
		for(int i=A;i<=B;i++){
			if(b[N-A]<i)break;
			ans+=nCr(b[N-A],i);
		}
		cout << ans << endl;
	}else{
		cout << nCr(b[N-A],a[N-A]) << endl;
	}
	return 0;
}

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

int main() {
string s;
cin >> s;
string ans = "";
for(int i = 0; i < s.size(); i+=2){
  ans += s.at(i);
}
cout << ans << endl;
 }


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

int main() {
	double n;
	while (cin >> n) {
		double sum = 0, a[10] = { 0 };
		sum = a[0] = n;
		for (int i = 1; i < 10; i++) {
			if ((i + 1) % 2 == 0) {
				a[i] = a[i - 1] * 2.0;
				sum += a[i];
			} else {
				a[i] = a[i - 1] / 3.0;
				sum += a[i];
			}
		}
		printf("%.8f\n", sum);
	}
	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ll N;
	cin >> N;
	vector<pair<ll, ll>> d;
	vector<ll> A(N);
	vector<ll> B(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> A[i] >> B[i];
		auto sum = A[i] + B[i];
		d.push_back({ abs(sum), i });
	}

	auto sum = 0ll;
	sort(d.begin(), d.end(), greater<pair<ll, ll>>());
	for (auto i = 0; i < N; ++i)
	{
		auto& p = d[i];
		if (i % 2 == 0)
		{
			sum += A[p.second];
		}
		else
		{
			sum -= B[p.second];
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3956
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

int main(){

	int N,W,H,x,y,w;

	scanf("%d %d %d",&N,&W,&H);

	int* TATE = new int[H+1];
	int* YOKO = new int[W+1];

	for(int i = 0; i <= H; i++)TATE[i] = 0;
	for(int i = 0; i <= W; i++)YOKO[i] = 0;

	for(int loop = 0; loop < N; loop++){
		scanf("%d %d %d",&x,&y,&w);
		TATE[max(0,y-w)] += 1;
		TATE[min(W,y+w)] -= 1;
		YOKO[max(0,x-w)] += 1;
		YOKO[min(H,x+w)] -= 1;
	}

	for(int i = 1; i <= H; i++)TATE[i] += TATE[i-1];
	for(int i = 1; i <= W; i++)YOKO[i] += YOKO[i-1];

	bool FLG1 = true,FLG2 = true;

	for(int i = 0; i <= H-1; i++){
		if(TATE[i] == 0){
			FLG1 = false;
			break;
		}
	}

	for(int i = 0; i <= W-1; i++){
		if(YOKO[i] == 0){
			FLG2 = false;
			break;
		}
	}

	if(FLG1 == true || FLG2 == true){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

   return 0;
}

Measured memory_bytes: 3448
package main

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

func main() {
	io, flush := NewIO()
	defer flush()

	n := io.ScanInt()
	nums := io.ScanInts(n)

	if n <= 2 {
		fmt.Println(0)
		return
	}

	var count int
	for i := 0; i < n-2; i++ {
		for j := i+1; j < n-1; j++ {
			if nums[i] == nums[j] {
				continue
			}
			for k := j+1; k < n; k++ {
				if nums[i] == nums[k] || nums[j] == nums[k] {
					continue
				}
				max := nums[i]
				if nums[j] > max {
					max = nums[j]
				}
				if nums[k] > max {
					max = nums[k]
				}
				if max < nums[i]+nums[j]+nums[k]-max {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInt2() (int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt3() (int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt4() (int, int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 2176
#include<iostream>
#include<stdio.h>
using namespace std;

int main(void) {
	int H, W, h, w;
	scanf("%d %d %d %d", &H, &W, &h, &w);
	printf("%d\n", H * W - (h * W + w * H - h * w));
	return 0;
}


Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e8)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

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

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}

int N,M;
int H, W;



int ans = 0;

int main()
{
	cin >> H >> W;
	int chang[H][W];
	int A[H][W];
	queue<pair<int, int> > q;
	queue<pair<int, int> > nexq;
	REP(i, H)
	{
		string s;
		cin >> s;
		REP(j, W)
		{
			if(s[j]=='#'){
				A[i][j] = 0;
				q.push(make_pair(i, j));

			}else{
				A[i][j] = 1;

			}
			chang[i][j] = 0;
		}
	}

	int ans= 0;
	while (1)
	{
		if(q.size()==0){
				break;
		}
		ans++;
		while (q.size()!=0)
		{
			
			pair<int, int> now = q.front();
			q.pop();
			if(now.first>0&&A[now.first - 1][now.second] ==1){
			nexq.push(make_pair(now.first - 1, now.second));
			A[now.first - 1][now.second] = 0;
			}
			if(now.first<H-1&&A[now.first + 1][now.second] ==1){
			nexq.push(make_pair(now.first + 1, now.second));
			A[now.first +1][now.second] = 0;
			}
			if(now.second>0&&A[now.first ][now.second-1] ==1){
			nexq.push(make_pair(now.first , now.second-1));
			A[now.first][now.second-1] = 0;
			}
			if(now.second<W-1&&A[now.first ][now.second+1] ==1){
			nexq.push(make_pair(now.first , now.second+1));
			A[now.first][now.second+1] = 0;
			}
		}

		q = nexq;

		clear(nexq);
	}
	ans--;

	cout << ans << endl;








	return 0;
}

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

int main() {
    int L, R;
    cin >> L >> R;
    int L1 = L % 2019;
    int R1 = R % 2019;

    int answer = 2019;

    if (L1 >= R1)
    {
        answer = 0;
    }
    else
    {
        for (int i = L1; i < R1; i++)
        {
            for (int j = i + 1; j < R1 + 1; j++)
            {  
                answer = min((i * j) % 2019, answer);
            }
        }
    }
    
    
    for (int i = L; i <R + 1 ; i++)
    {
        if (i % 2019 == 0)
        {
            answer = 0;
            break;
        }
        
    }
    

    cout << answer << endl;

}

Measured memory_bytes: 256
def search(mat, i, j, iter, res = [])
  res << j
  if i == 0
    puts res.join
    exit
  end
  iter2 = iter
  jj = [j - 1, j, j + 1].select { |n| (0..9).include?(n) }
  jj.each do |j|
    return search(mat, i - 1, j, iter2, res) if iter2 - mat[i - 1][j] <= 0
    iter2 -= mat[i - 1][j]
  end
end

k = gets.strip!.to_i

if k < 10
  puts k
  exit
end

mat = Hash.new(0)
mat[0] = Hash.new(0)
(0..9).each { |n| mat[0][n] = 1 }

iter = 9
(1..10).each do |i|
  mat[i] = Hash.new(0)
  (0..9).each do |j|
    mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j] + mat[i - 1][j + 1]
    if j != 0
      search(mat, i, j, k - iter) if k <= iter + mat[i][j]
      iter += mat[i][j]
    end
  end
end


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

int main() {
  long long a, b, c;
  long long d;
  std::cin >> a >> b >> c;
  d = c - a - b;
  if (d > 0 && 4*a*b < d*d) std::cout << "Yes";
  else std::cout << "No";
  
  return 0;
}

Measured memory_bytes: 3640
N, K = map(int, input().split())
d = []
A = []
sunuke = []

for i in range(K):
    d = input()
    A.append(list(map(int, input().split())))

for i in range(K):
    for item in A[i]:
        if item in sunuke:
            continue
        sunuke.append(item)

result = N - len(sunuke)
print(result)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e12;

struct edge{
    int to, cost;
};

int V,E;
vector<vector<edge>> graph;
vector<long long int> d;

void Dijkstra(int s){// s = starting point
    priority_queue<
        pair<int, int>// temporarily keeping (shortest distance, vertex)
        , vector<pair<int, int>>, greater<pair<int, int>>// shorter ones first
    > pq;

    // initialize (INF)
    for(int i=0; i<V; i++){
        d[i] = INF;
    }
    d[s] = 0;
    pq.push({0,s});

    // search
    pair<int, int> current;// (shortest-distance confirmed, vertex)
    while(!pq.empty()){
        current = pq.top(); pq.pop();

        int v = current.second;
        if(d[v] < current.first){
            continue;// ignore (not the shortest path)
        }
        // else (need to check)
        for(edge e : graph[v]){// adjacent nodes
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;// update minimum cost
                pq.push({d[e.to], e.to});
            }
        }
    }
}


int main(){
    cin >> V >> E;
    V *= 3;
    graph.resize(V);
    d.resize(V);

    for(int i=0; i<E; i++){
        int u, v;
        cin >> u >> v;
        u -= 1;
        v -= 1;
        graph[3*u].push_back({3*v+1, 1});
        graph[3*u+1].push_back({3*v+2, 1});
        graph[3*u+2].push_back({3*v, 1});
    }

    int s, t;
    cin >> s >> t;
    s -= 1;
    t -= 1;

    Dijkstra(3*s);
    if(d[3*t] == INF) cout << -1         << endl;
    if(d[3*t] != INF) cout << d[3*t] / 3 << endl;
    return 0;
}

Measured memory_bytes: 18944
import scala.io.Source.stdin

object Main {
  def getMax(max:Int, min:Int, list:Iterator[Int]):Int = {
    if(list.hasNext) {
      val m = list.next()
      val (x:Int,y:Int) =
        if(max < m-min) {
          if(min > m) (m-min,m) else (m-min,min)
        }
        else {
          if(min>m) (max,m) else (max,min)
        }
      getMax(x, y, list)
    }
    else { max }
  }

  def main(args: Array[String]) = {
    val list = stdin.getLines().map { _.toInt }
    val n = list.next()
    val r0 = list.next()
    val r1 = list.next()
    val max = getMax(r1 - r0, if(r0 > r1) r1 else r0, list)

    println(max)
  }
}

Measured memory_bytes: 77528
#include<bits/stdc++.h>
using namespace std;
struct node
{
    string s;
    int t;
}ans[111];
int main()
{
	ios::sync_with_stdio(false);
	string x;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
    {
        cin>>ans[i].s>>ans[i].t;
    }
    cin>>x;
    int flag=0,sum=0;
    for(int i=1;i<=n;i++)
    {
        if(ans[i].s==x)
            {
                flag=i;
                break;
            }
    }
    for(int i=flag+1;i<=n;i++)
    {
        sum+=ans[i].t;
    }
    cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#define N 12
#define P 100001
using namespace std;

int main(){
  int n,d,x,p[N][N],dp[N][P],ans;
  cin>>n>>d>>x;
  for(int i=0;i<d;i++)
    for(int j=0;j<n;j++) cin>>p[i][j];
  for(int i=0;i<N;i++)
    for(int j=0;j<P;j++) dp[i][j]=-1;
  for(int i=0;i<d;i++) dp[i][x]=ans=x;
  for(int i=0;i<d;i++)
    for(int l=i+1;l<d;l++)
      for(int j=P-1;j>=0;j--){
	if(dp[i][j]<0) continue;
	for(int k=0;k<n;k++){
	  if(j<p[i][k]) continue;
	  if(p[i][k]>p[l][k]) continue;
	  int idx=dp[i][j]+(p[l][k]-p[i][k]);
	  dp[i][j-p[i][k]]=max(dp[i][j-p[i][k]],idx);
	  dp[l][idx]=idx;
	}	
      }
  for(int i=0;i<d;i++)
    for(int j=0;j<P;j++) ans=max(ans,dp[i][j]);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5848
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main() {
	int32_t t=0;
	set<int32_t> stat;
	int32_t n;
	cin>>n;
	for(int i=0;i<n;i++){
		int32_t temp;
		cin>>temp;
		if(stat.find(temp)!=stat.end()){
			stat.erase(temp);
		}else{
			stat.insert(temp);
		}
	}
	cout<<stat.size()<<endl;
	return 0;

}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n";
using namespace std;
using ll=long long;
using ld=long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class DBinomialCoefficients {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n;
	    in >> n;
	    vector<ll> a(n);
	    for(int i=0; i<n; i++){
	        in >> a[i];
	    }

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

	    ll res = 0;
        for(int i=n-1; i>=0; i--){
            if(abs(res - a[n-1]/2) > abs(a[i] - a[n-1]/2)) res = a[i];
        }

        out << a[n-1] sp res << endl;
	}
};


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


Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	
    	int a=sc.nextInt();
    	int b=sc.nextInt();

    	System.out.print(a/b+" "+a%b+" ");
        System.out.println(String.format("%.8f", (double)a/b));
    	
    }
}


Measured memory_bytes: 26400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll A[500000];
ll tree[9000000];
ll max(ll a, ll b)
{
    if(a>b) return a;
    else return b;
}
ll min(ll a, ll b)
{
    if(a<b) return a;
    else return b;
}
ll query(ll node, ll b, ll e, ll i, ll j)
{
    if(b>j || i>e) return 0;
    if(i<=b && j>=e) return tree[node];
    ll left=node*2;
    ll right=node*2+1;
    ll mid=(b+e)/2;
    ll p1=query(left,b,mid,i,j);
    ll p2=query(right,mid+1,e,i,j);
    return max(p1,p2);
}
void update(ll node, ll b, ll e, ll i, ll x)
{
   if(b>i || i>e) return;
  if(i<=b && i>=e) {tree[node]=x;return;}
    ll left=node*2;
    ll right=node*2+1;
    ll mid=(b+e)/2;
    update(left,b,mid,i,x);
    update(right,mid+1,e,i,x);
    tree[node]=max(tree[left],tree[right]);
}
ll dp[300000+4];
int main()
{
    ll N,k,i,j;
    cin>>N>>k;

    ll ans=0;
    for(i=1;i<=N;i++)
    {
        cin>>A[i];
        ll l=max(0,A[i]-k);
        ll r=min(300000,A[i]+k);
        ll x=query(1,0,300000,l,A[i]);
        ll y=query(1,0,300000,A[i],r);
        dp[A[i]]=max(x,y)+1;
        ans=max(ans,dp[A[i]]);
        update(1,0,300000,A[i],dp[A[i]]);

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



}



Measured memory_bytes: 16508
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define range(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) range(i, 0, n)
#define pb push_back
const double eps = 1e-10;

int main()
{
    int n;
    cin >> n;
    rep(i, n)
    {
        vector<double> x(4), y(4);
        rep(j, 4) cin >> x[j] >> y[j];
        double a = (x[3] - x[2]) * (y[1] - y[0]) - (x[1] - x[0]) * (y[3] - y[2]);
        if (abs(a) > eps) {
            cout << "NO" << endl;
        } else {
            cout << "YES" << endl;
        }
    }
}


Measured memory_bytes: 3200
// problem: "https://atcoder.jp/contests/abc143/tasks/abc143_c"

#include<bits/stdc++.h>

using namespace std;

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

    stack<char>Q;
    int i;
    char c;

    for(i=0;i!=n;i++)
    {
        cin>>c;

        if(Q.empty())
            Q.push(c);

        else if(Q.top() != c)
            Q.push(c);
    }

    cout<<Q.size();

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N;
  
  for (int i = 0; i < N; i++){
    int x;
    cin >> x;
    
    int j = 0;
    while (x % 2 == 0){
      j++;
      x /= 2;
    }
    if (i == 0) M = j;
    if (M > j) M = j;    
  }
  
  cout << M << endl;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Deque<Integer> stack = new ArrayDeque<Integer>();
		while(sc.hasNext()) {
			int q = sc.nextInt();
			if (q == 0) {
				System.out.println(stack.pop());
			}else{
				stack.push(q);
			}
		}
	}

}

Measured memory_bytes: 17208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll C(int p)
{
    if(p<=1) return 0;
    return p*(p-1)/2;
}
main()
{
    int n,k;
    cin>>n>>k;
    int most=((n-1)*(n-2))/2;
    if(k>most)
    {
        cout<<-1;
        return 0;
    }
    int baki=most-k;
    cout<<n-1+baki<<endl;
    for(int i=2;i<=n;i++)
    {
        cout<<1<<' '<<i<<endl;
    }


    for(int i=2;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            if(baki==0) return 0;
            cout<<i<<' '<<j<<endl;
            baki--;
        }
    }
}

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

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

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

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	a := readString()
	b := readString()

	if a == "H" && b == "H" || a == "D" && b == "D" {
		println("H")
	} else {
		println("D")
	}

}


Measured memory_bytes: 640