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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par,sz,vis,dis;
vector<vi> graph;
vector<vector<pair<li,li>>> wgraph;

void init(li n)
{
    par.resize(n);
    sz.resize(n);
    wgraph.resize(n);
    dis.resize(n);
    vis.resize(n);
    graph.resize(n);

    f(i,0,n-1)
    {
        par[i]=i;
        sz[i]=1;
        dis[i]=1e18;
    }
}

li root(li a)
{
    while(a!=par[a])
    {
        par[a]=par[par[a]];
        a=par[a];
    }

    return a;
}

void unio(li a,li b)
{
    li r_a=root(a);
    li r_b=root(b);

    if(par[r_a]!=r_b)
    { 
        if(sz[r_a]<sz[r_b])
        {
            par[r_a]=par[r_b];
            sz[r_b]+=sz[r_a];
            sz[r_a]=0;
        }
        else
        {
            par[r_b]=par[r_a];
            sz[r_a]+=sz[r_b];
            sz[r_b]=0;
        }
    }
}

int main()
{    
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li n,a,b;

    cin>>n>>a>>b;

    li tp1,tp2;

    tp1=n/(a+b);

    tp2=min(n%(a+b),a);

    cout<<tp1*a+tp2;
    
    return 0;
}

Measured memory_bytes: 256
def resolve():
    A, B, C = list(map(int, input().split()))
    K = int(input())
    cnt = 0
    while cnt < K:
        if A >= B:
            B *= 2
            cnt += 1
            continue
        if B >= C:
            C *= 2
            cnt += 1
            continue
        cnt += 1
    if A < B < C:
        print('Yes')
    else:
        print('No')
    return

resolve()

Measured memory_bytes: 9192
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
	int x, i, j, t;
	x = A[r];
	i = p - 1;
	for( j = p; j < r; j++) {
		if(A[j] <= x) {
			i++;
			t = A[i]; A[i] = A[j]; A[j] = t;
		}
	}
	t = A[i+1]; A[i+1] = A[r]; A[r] = t;
	return i+1;
}

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

Measured memory_bytes: 2936
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define COUT(x) cout << (x) << endl
using namespace std;
typedef pair<int,int> P;
typedef long long int ll;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main() {
    int n; cin >> n;
    vector<int> v(n), sum(n);
    rep(i, n) {
        cin >> v[i];
        if(i == 0) sum[i] = v[i];
        else sum[i] = sum[i - 1] + v[i];
    }
    int minv = INF; 
    for(int t = 1; t < n; t++) {
        minv = min(minv, abs(sum[n -1] - 2*sum[t - 1]));
    }
    COUT(minv);

    return 0;
}

Measured memory_bytes: 256
n,m = [int(x) for x in input().split()]
cnt = [0]*(n+1)
for i in range(m):
    a,b = [int(x) for x in input().split()]
    cnt[a]+=1
    cnt[b]+=1
for i in range(n):
  if cnt[i]%2==1:
    print("NO")
    exit()
print("YES")

Measured memory_bytes: 45400
#include <stdio.h>

int main(void)
{
    int n, m;

    while(scanf("%d %d", &n, &m), n || m){
        int tarou[128] = {0}, hanako[128] = {0};
        int sumt, sumh;
        int changet, changeh;
        int diff;
        int i, j;

        sumt = 0;
        for (i = 0; i < n; i++){
            int t;
            scanf("%d", &t);
            sumt += t;
            tarou[t] = 1;
        }
        sumh = 0;
        for (i = 0; i < m; i++){
            int t;
            scanf("%d", &t);
            sumh += t;
            hanako[t] = 1;
        }

        changet = changeh = 128;
        for (i = 0; i <= 100; i++){
            for (j = 0; j <= 100; j++){
                if (!tarou[i] || !hanako[j]) continue;
                if (sumt - i + j == sumh + i - j && i + j < changet + changeh){
                    changet = i;
                    changeh = j;
                }
            }
        }
        if (changet != 128 && changeh != 128) printf("%d %d\n", changet, changeh);
        else puts("-1");
    }

    return 0;
}

Measured memory_bytes: 612
N = int(input())
S = input()
ans = 0
for i in range(1, N):
    tmp = "?" * i + S
    c = 0
    m = 0
    for j in range(i, N):
        if S[j] != tmp[j]:
            c = 0
        else:
            c += 1
        m = max(m, c)
    m = min(m, i)
    ans = max(ans, m)

print(ans)


Measured memory_bytes: 44636
s = input()
num = 0
num2 = 0
for i in range (3) :
#  print(s[i])

  yesterday = 'R'
  if s[i] == 'R':
    if yesterday == 'R':
      num2 += 1
    else :
      yesterday = 'R'
  else :
    yesterday = 'S'
    if num2 > num:
      num = num2
      num2 = 0


if num2 > num:
  num = num2


print(num)

Measured memory_bytes: 9116
gets
as = gets.split.map(&:to_i)
rates = Array.new 8
free = 0

as.each do |a|
  i = a / 400
  if i < 8
    rates[i] = 1
  else
    free += 1
  end
end

rates.compact!
if rates.size.zero?
  puts [1, free].join(' ')
else
  puts [rates.size, rates.size + free].join(' ')
end

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

using namespace std;

#define int long long
#define double long double
#define mod 1000000007ll
#define INF 1000000000000000000ll

void zlacz(vector<int> & a, vector<int> b) {
    for (int i : b) a.push_back(i);
}

vector<int> zamien0(int dl) {
    if (dl == 0) return {};
    vector<int> res = zamien0(dl - 1);
    res.push_back(dl - 1);
    zlacz(res, zamien0(dl - 1));
    for (int & i : res) i = dl - 1 - i;
    return res;
}

int tab[1000010];

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    /*
    {
        vector<int> x = zamien0(3);
        int gdzie = 0;
        cout << gdzie << " ";
        for (int i : x) {
            gdzie = gdzie^(1<<i);
            cout << gdzie << " ";
        }
        return 0;
    }*/
    int n;
    cin >> n;
    int a, b;
    cin >> a >> b;
    b = a^b;

    int li = 0;
    for (int cos=0, cos2=1, i=0; i<n; i++) {
        if (b & (1<<i)) {
            li++;
            tab[n-cos2] = i;
            cos2++;
        } else {
            tab[cos] = i;
            cos++;
        }
    }
    //for (int i=0; i<n; i++) {
    //    cout << tab[i] << endl;
    //}

    vector<int> res;
    for (int i=1; i<=li; i++) {
        zlacz(res, zamien0(n-i));
        res.push_back(n-i);
    }
    zlacz(res, zamien0(n-li));

    //cout << li << endl;

    if (li % 2 == 0) {
        cout << "NO";
        return 0;
    }
    cout << "YES\n";

    int gdzie = 0;
    cout << (gdzie^a) << " ";
    int s=1;
    for (int i : res) {
        gdzie = gdzie^(1<<tab[i]);
        cout << (gdzie^a) << " ";
        s++;
    }
    //cout << endl << s;
    return 0;
}/*

*/


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


int main() {

    int64_t a,b;
    cin>>a>>b;

    //1/2*n*(n+1) 1/2*n*(n+1)+(n+1)
    //b-a=n+1
    //n=b-a-1
    //1/2*n*(n+1)-a

    int64_t n=b-a-1;
    cout<<n*(n+1)/2-a<<endl;

	return 0;
}

Measured memory_bytes: 3568
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        boolean flag = false;
        char[][] res = new char[8][5];

        while ((line = br.readLine()) != null) {
            if (flag) {
                System.out.println();
            }

            line = String.format("%5s", line).replaceAll(" ", "0");
            for (int i = 0; i < 5; i++) {
                int n = (int) (line.charAt(i) - '0');
                char[] x = dec(n).toCharArray();
                for (int j = 0; j < 8; j++) {
                    res[j][i] = x[j];
                }
            }

            // display
            for (char[] a : res) {
                for (char c : a) {
                    System.out.print(c);
                }
                System.out.println();
            }

            flag = true;
        }
    }

    static String dec(int n) {
        switch (n) {
        case 0:
            return "* = ****";
        case 1:
            return "* =* ***";
        case 2:
            return "* =** **";
        case 3:
            return "* =*** *";
        case 4:
            return "* =**** ";
        case 5:
            return " *= ****";
        case 6:
            return " *=* ***";
        case 7:
            return " *=** **";
        case 8:
            return " *=*** *";
        case 9:
            return " *=**** ";
        }

        return null; // unreachable
    }
}


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

int main() {
	long long A, V, B, W, T;
	cin >> A >> V >> B >> W >> T;
	if (A < B) {
		if (A + V * T >= B + W * T) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	else {
		if (A - V * T <= B - W * T) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        string s=to_string(i);
        if(s.size()%2==1) ++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    //freopen("vacation.inp","r",stdin);
    //freopen("vacation.out","w",stdout);
    int n;
    cin>>n;
    vector <int> a(n);
    vector <int> b(n);
    vector <int> c(n);
    for (int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    vector <int> a1(n);
    vector <int> b1(n);
    vector <int> c1(n);
    a1[0]=0;
    b1[0]=0;
    c1[0]=0;
    for (int i=1;i<=n;i++)
    {
        a1[i]=max(b1[i-1],c1[i-1])+a[i];
        b1[i]=max(a1[i-1],c1[i-1])+b[i];
        c1[i]=max(b1[i-1],a1[i-1])+c[i];
    }
    cout<<max(max(a1[n],b1[n]),c1[n]);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#define eol '\n';
using namespace std;

class Node {
public:
  Node* p;
  Node* l;
  Node* r;
  int k;
  Node(): p(nullptr),l(nullptr),r(nullptr),k(-1){};
};

Node* root = nullptr;

void insert(Node* z) {
  Node* y = nullptr;
  Node* x = root;
  while (x != nullptr) {
    y = x;
    if (z->k < x->k) {
      x = x->l;
    } else {
      x = x->r;
    }
  }
  z->p = y;
  
  if (y == nullptr) {
    root = z;
  } else if (z->k < y->k) {
    y->l = z;
  } else {
    y->r = z;
  }
}

void inorder(Node* node) {
  if (node->l != nullptr) {
    inorder(node->l);
  }
  cout << " " << node->k;
  if (node->r != nullptr) {
    inorder(node->r);
  }
  if (node->p == nullptr) {
    cout << eol;
  }
}

void preorder(Node* node) {
  cout << " " << node->k;
  if (node->l != nullptr) {
    preorder(node->l);
  }
  if (node->r != nullptr) {
    preorder(node->r);
  }
  if (node->p == nullptr) {
    cout << eol;
  }
}

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

  int m,k;
  string cmd;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> cmd;
    if (cmd == "insert") {
      cin >> k;
      Node* node = new Node();
      node->k = k;
      insert(node);
    } else if (cmd == "print") {
      inorder(root);
      preorder(root);
    }
  }
  
  return 0;
}

Measured memory_bytes: 24664
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    for (auto &&i : v) scanf("%lld", &i);
    for (int i = 0; i < n; ++i) {
        if(v[i] % 2) {
            cout << "first" << "\n";
            return 0;
        }
    }
    cout << "second" << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
int n, cnt1 = 0, cnt0 = 0, ans0,ans1;
char c;
bool flag = 0;
//bool A[200002];
int main()
{
	cin >> n;
	vector<bool>A(n);
	loop(i, 0, n)
	{
		cin >> c;
		if (c == 'W')A[i] = 1;
		if (A[i])cnt1++;
		else cnt0++;
	}
	loop(i, 0, cnt0)if (A[i])ans0++;
	loop(i, cnt0, n)if (A[i] == 0)ans1++;
	int i = 0;
	while (i < n and A[i] == 0)cnt0--,i++;
	i = n - 1;
	while (i and A[i])cnt1--, i--;
	cout << min(max(ans0,ans1), max(cnt1, cnt0));
}

Measured memory_bytes: 3608
(* O(√n) *)
let lowest_prime_factor n =
  let m = int_of_float (floor (sqrt (float_of_int n))) in
  let rec loop i =
    if i > m then
      n
    else
      if n mod i = 0 then i else loop (i + 1)
  in
    loop 2

(* O(√n * log(n)) *)
let factorize_primes n =
  if n <= 1 then
    []
  else
    let rec loop sofar (p, count) m =
      if m = 1 then
        List.tl (List.rev ((p, count) :: sofar))
      else
        let prime = lowest_prime_factor m in
        if p = prime then
          loop sofar (p, count + 1) (m / p)
        else
          loop ((p, count) :: sofar) (prime, 1) (m / prime)
    in
      loop [] (1, 0) n

let solve n p =
  if p = 1 then
    1
  else
    List.fold_left
      (fun sofar (p, count) ->
        let factor = int_of_float (float_of_int p ** float_of_int (count / n)) in
        sofar * factor)
      1
      (factorize_primes p)

let _ = Scanf.scanf "%d %d" (fun n p -> solve n p |> string_of_int |> print_endline)

Measured memory_bytes: 384
s = int(input())
ans = 1

while True:
    if s == 1 or s == 2 or s == 4:
        ans = ans + 3
        break
    else:
        if s % 2 == 0:
            s = s // 2
        else:
            s = s * 3 + 1
        ans = ans + 1

print(ans)

Measured memory_bytes: 2940
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int x = scanner.nextInt();
		for(int i = a; i <a + x; i++) {
			if(i > b) continue;
			System.out.println(i);
		}
		for(int r = b - x + 1; r < b + 1; r++) {
			// 範囲がかぶってたらbreak
			if(r < a + x || r < a) continue;
			
			System.out.println(r);
		}
	}

}


Measured memory_bytes: 23252
char_num = int(input())
char_length = 10
chars = []
for i in range(char_num):
    chars.append(input())


class CharArrange:
    def __init__(self, char):
        self.char = char

    def char_run(self):
        list_char = self.str2ord_list(self.char)
        for pos in range(1, len(list_char)):
            self.insert_sort(list_char, pos, list_char[pos])
        self.char = self.ordList2Str(list_char)

    def order_run(self, chars):
        for i, char in enumerate(chars):
            chars[i] = self.ord_list2ord_concat(self.str2ord_list(char))
        for pos in range(len(chars)):
            self.insert_sort(chars, pos, chars[pos])
        self.ord_chars = chars

    def str2ord_list(self, char):
        return list(map(ord, char))

    def ordList2Str(self, ordList):
        return ''.join(list(map(chr, ordList)))

    def ord_list2ord_concat(self, ord_list):
        self.ord_concat = ''
        for ord_num in ord_list:
            self.ord_concat += str(ord_num)
        return int(self.ord_concat)

    def insert_sort(self, A, pos, value):
        i = pos - 1
        while (i >= 0 and A[i] > value):
            A[i+1] = A[i]
            i = i - 1
        A[i+1] = value
        return A


counter = 0
hash_table = {}
for i, char in enumerate(chars):
    CA = CharArrange(char)
    CA.char_run()
    if CA.char in hash_table:
        hash_table[CA.char] += 1
    else:
        hash_table[CA.char] = 0
    counter += hash_table[CA.char]


print(counter)


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

struct cww{cww(){
    ios::sync_with_stdio(false);cin.tie(0);
    cout<<fixed;
    cout<<setprecision(10);
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
double p;
double f(LL x){
    x/=2;
    return x/p;
}
int main(){
    LL x;
    cin>>x>>p;
    p/=100;
    if(x%2)cout<<1+p*f(x-1)+(1-p)*f(x+1)<<endl;
    else cout<<f(x)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.nextLine());

		String[] C = scan.nextLine().split(" ");

		String[] arrayBubble = C.clone();
		String[] arraySelection = C.clone();

		BubbleSort(arrayBubble, N);
		SelectionSort(arraySelection, N);

		for(int i= 0; i < arrayBubble.length; i++){
	        System.out.print(arrayBubble[i]);
	        if(i < arrayBubble.length-1){
	            System.out.print(" ");
	        } else {
	            System.out.println();
	            }
	        }
		System.out.println("Stable");

		for(int i= 0; i < arraySelection.length; i++){
	        System.out.print(arraySelection[i]);
	        if(i < arraySelection.length-1){
	            System.out.print(" ");
	        } else {
	            System.out.println();
	            }
	        }
		/*if(arrayBubble == arraySelection) {
		System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}*/
		
		if(stable(arrayBubble, arraySelection) == true) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}
	}


	public static void BubbleSort(String[] C, int n) {
		for(int i= 0; i <= n-1; i++) {
			for(int j = n-1; j >= i+1; j--) {
				if((int)(C[j].charAt(1)) < (int)(C[j-1].charAt(1))) {
					String temp = C[j];
					C[j] = C[j-1];
					C[j-1] = temp;
				}
			}
		}
	}

	public static void SelectionSort(String[] C, int n) {
		for(int i = 0; i <= n-1; i++){
            int minj = i;
            for(int j = i; j <= n-1; j++){
                if((int)(C[j].charAt(1)) < (int)(C[minj].charAt(1))){
                    minj = j;
                }
            }
            if(i != minj){
            	String tmp = C[i];
                C[i] = C[minj];
                C[minj] = tmp;
                }
            }
	}

	public static boolean stable(String[] a, String[] b) {
		if(!(a.length == b.length)) {
			return false;
		}
		for(int i = 0; i < a.length; i++) {
			if(!(a[i].equals(b[i]))) {
				return false;
			}
		}
		return true;
	}
}


Measured memory_bytes: 26328
#include <iostream>
#include <queue>
#include <stdio.h>
#include<cstring>
#include<algorithm>
#include<cmath> 
using namespace std;


int main() {
    long  long a,b,c;
	cin>>a>>b>>c; 
//	cout<<a*a+b*b+c*c-2*a*b-2*a*c-2*b*c<<endl;
//	cout<<sqrt(a)<<endl;
    if(c<a+b)
    cout<<"No"<<endl;
    else {
	if(a*a+b*b+c*c-2*a*b-2*a*c-2*b*c<=0)
	cout<<"No"<<endl;
	else
	cout<<"Yes"<<endl;}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi w(n), s(n);
    for(int i=0; i<n; i++){
        cin >> w.at(i);
    }
    int64_t sum = 0;
    for(int i=0; i<n; i++){
        sum += w.at(i);
        s.at(i) = sum;
    }
    int64_t res = 1000000000;
    for(int i=0; i<n; i++){
        if(res > abs(s.at(n-1) - s.at(i) * 2)){
            res = abs(s.at(n-1) - s.at(i) * 2);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<cctype>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
#define init(x) memset(x,0,sizeof(x))
ll n,a[100005],ans;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for (int i=1;i<=n;++i) cin>>a[i];
    sort(a+1,a+n+1);
    ans=a[1];
    for (int i=2;i<n;++i){
    	if (abs(a[n]-ans-ans)>abs(a[n]-a[i]-a[i])) ans=a[i];
	}
	cout<<a[n]<<" "<<ans;
    return 0; 
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);

int main()
{
  fast;
  int n, sum=0;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
  sort(v.begin(), v.end());
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)
      sum+=lower_bound(v.begin(), v.end(), v[i]+v[j])-v.begin()-j-1;
  cout<<sum<<"\n";
  return 0;
}
  

Measured memory_bytes: 384
MAX_N = 55555

p = [True] * (MAX_N + 1)
p[0] = False
p[1] = False

for i in range(2,MAX_N + 1):
	if p[i] == True:
		for j in range(2 * i, MAX_N + 1, i):
			p[j] = False

prime = []
for i in range(2,MAX_N + 1):
	if p[i] == True and len(prime) < MAX_N:
		prime.append(i)

#print(len(prime))

N = int(input())

res = []
for i in range(len(prime)):
	if prime[i] % 5 == 1 and len(res) < N:
		res.append(prime[i])

print(" ".join(map(str,res)))

Measured memory_bytes: 3572
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;
using Int = long long;

constexpr double EPS = 1e-10;
constexpr long long MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    long long N, K; cin >> N >> K;
    long long ans = min(N%K, K - N%K);
    cout << ans << endl;
}


Measured memory_bytes: 888
n = int(input())
list = [[0 for i in range(10)] for j in range(10)]
for i in range(1, n+1):
    s = str(i)
    list[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(1,10):
    ans+=list[i][i]*list[i][i]
for i in range(1,10):
    for j in range(i+1, 10):
        ans+=list[i][j]*list[j][i]*2
print(ans)


Measured memory_bytes: 3064
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = Array(n){ mutableListOf<Pair<Int, Int>>() }

    repeat(n) { aIdx ->
        val a = readLine()!!.toInt()
        repeat(a) {
            val (x, y) = readLine()!!.split(" ").map { it.toInt() }
            aa[aIdx].add(Pair(x, y))
        }
    }

    var max = 0
    for (i in 0 until 1.shl(n)) {
        var failed = false

        inner@for (j in aa.indices) {
            val shouldSkip = ((i.shr(j) and 1) == 0)
            if (shouldSkip) continue@inner

            for (k in aa[j]) {
                val target = (i.shr(k.first-1) and 1)
                if (target != k.second) {
                    failed = true
                    break@inner
                }
            }
        }

        if (!failed) {
            max = Math.max(max, Integer.bitCount(i))
        }
    }

    println(max)
}

Measured memory_bytes: 40756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
ll a[N],x=1e18;
long long ans=1;
int main(){
     int n,f=0;
  	 scanf("%d",&n);
  	 for(int i=1;i<=n;i++){
	    scanf("%lld",&a[i]);
	    if(!a[i]) f=1;
	}
	if(f) puts("0"),exit(0);
  	 for(int i=1;i<=n;i++){
         if((__int128)ans*a[i]>x){
            puts("-1");
            exit(0);
         }
         else ans*=a[i];
     }
    printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 4596
//Keep Working Hard
  // I__Like__Food  

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define tracel5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)

const int N = 2005;

const int MOD = 1000000007;
int arr[N];

int32_t main()
{


    IOS

   	int n;
	string s;
	cin >> n >> s;
 
	int ans = 0;
	for (int i = 1; i < n - 1; i++) {
		auto t = s.substr(0, i);
		auto u = s.substr(i);
 
		set<char> ss;
		for (char c: t) {
			if (u.find(c) != string::npos) {
				ss.insert(c);
			}
		}
 
		ans = max<int>(ans, ss.size());
	}
	
	cout << ans << endl;






    return 0;
}




Measured memory_bytes: 256
// AOJ 1015: Dominating Set
// 2018.1.18 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int n, ans;
int to[31][31], hi[31];
char black[31];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int check()
{
	int i, j;

	for (i = 0; i < n; i++) {
		if (black[i]) continue;
		for (j = 0; ; j++) {
			if (j == hi[i]) return 0;
			if (black[to[i][j]]) break; 
		}
	}
	return 1;
}

void calc(int k, int cost)
{
	if (cost >= ans) return;

	if (k == n) {
		if (check()) ans = cost;
		return;
	}

	black[k] = 0; calc(k+1, cost);
	black[k] = 1; calc(k+1, cost+1);
}

int main()
{
	int m, a, b;

	while (n = in()) {
		memset(hi, 0, sizeof(hi));
		m = in(); while (m--) {
			a = in(), b = in();
			to[a][hi[a]++] = b, to[b][hi[b]++] = a;
		}

		ans = n;
		calc(0, 0);
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2028
import sys
import math

sys.setrecursionlimit(10**7)

n, s = map(int, input().split())
a = list(map(int, input().split()))
dp = [0 for _ in range(s+1)]
dp[0] = 1
for i in range(n):
    _dp = [0 for _ in range(s+1)]
    for j in range(s+1):
        if j+a[i] <= s:
            _dp[j+a[i]] += dp[j]
            _dp[j+a[i]] %= 998244353
        _dp[j] += 2*dp[j]
        _dp[j] %= 998244353
    dp = _dp
print(dp[s])

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

using namespace std;

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

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

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

char C[114][514];

struct P {
    int r, c;
    int cost;
};

int dd[5] = {0, -1, 0, 1, 0};

int bfs(int r, int c) {

    queue<P> Q;
    int vis[33][33] = {};
    Q.push({r, c, 0});

    int ans = 0;
    while (Q.size()) {
        auto q = Q.front();
        Q.pop();
        if (vis[q.r][q.c]++) continue;
        ans = max(ans, q.cost);
        for (int i = 0; i < 4; i++) {
            int ty = q.r + dd[i];
            int tx = q.c + dd[i + 1];
            if (C[ty][tx] != '.') continue;
            Q.push({ty, tx, q.cost + 1});
        }
    }
    return ans;


}

int main() {
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> C[i + 1][j + 1];
        }
    }


    int ans = 0;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (C[i][j] == '.')
                ans = max(bfs(i, j), ans);
        }
    }

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


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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> children(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> children[i];
  }
  
  sort(children.begin(), children.end());
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      if (x == children[i]) {
      	  ans++;
      }
    } else {
      if (x >= children[i]) {
        ans++;
        x -= children[i];
      }
    }
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    cin >> n;
    map <string,int> v;
    for(i = 0; i < n; i++){
        string s, t;
        cin >> s;
        map <string,int> :: iterator itr;
        itr = v.find(s);
        if(v.find(s) == v.end()){
           v.insert({s,1});
        }
        else{
            itr -> second ++;
        }
    }
    map <string,int> :: iterator it;
    for(it = v.begin(); it != v.end(); it ++){
       x = it->second;
       m = max(x,m);
    }
    for(it = v.begin(); it != v.end(); it ++){
       x = it->second;
       if(x < m){
        continue;
       }
       else{
        cout << it -> first << endl;
       }
    }


    return 0;
}


Measured memory_bytes: 23808
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;cin>>s;
    int cnt[26];
    fill(cnt,cnt+26,0);
    rep(i,0,4)cnt[s[i]-'A']++;
    int t=0;
    rep(i,0,26)if(cnt[i]==2)t++;
    if(t==2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	lld n;
	cin >> n;
	vector<string> s(n);
	for(int i = 0; i < n; i++)
	{
		cin >> s[i];
	}

	lld al[26] = {0};
	for(int i = 0; i < n; i++)
	{
		al[s[i][0]-'A']++;
	}
	int cnt = 0;
	for(int i = 0; i < 26; i++)
	{
		if(al[i]!=0)cnt++;
	}
	// for(int i = 0; i < 26; i++)
	// {
	// 	cout << char(i + 'A') << "  " <<  al[i] << endl;
	// }


	vector<lld> march;;
	if(al['M'-'A']!=0) march.push_back(al['M'-'A']);
	if(al['A'-'A']!=0) march.push_back(al['A'-'A']);
	if(al['R'-'A']!=0) march.push_back(al['R'-'A']);
	if(al['C'-'A']!=0) march.push_back(al['C'-'A']);
	if(al['H'-'A']!=0) march.push_back(al['H'-'A']);

	//cout << march.size()<<endl;


	if (march.size() < 3)
	{
		cout << 0 << endl;
	}else
	{
		lld ans = 0;
		lld m = march.size();
		for(int i = 0; i < m; i++)
		{
			lld y = 0;
			for(int j = i+1; j < m; j++)
			{
				if (j!=i)
				{
					lld x=0;
					for(int k = j+1; k < m; k++)
					{
						if(k!=i && k!=j) x += march[k];
					}
					y += march[j] * x;
				}
			}
			ans += y*march[i];
		}
		cout << ans << endl;
	}


	return 0;
}

Measured memory_bytes: 6144
#include <cstdio>

int main()
{
    int N, tmp;
    int num[150];

    scanf (" %d", &N);

    for (int i = 0; i < N; i++){
        scanf (" %d", &num[i]);
    }

    for (int i = 1; i < N; i++){

        for (int j = 0; j < N; j++){
            if (j != N-1){
                printf("%d ", num[j]);
            }
            else {
                printf("%d\n", num[j]);
            }
        }

        tmp = num[i];

        int j = i - 1;
        while (j >= 0 && num[j] > tmp){
            num[j+1] = num[j];
            j--;
        }
        num[j+1] = tmp;
    }
    

    for (int i = 0; i < N; i++){
        if (i != N-1){
            printf("%d ", num[i]);
        }
        else {
            printf("%d\n", num[i]);
        }
    }

  
    return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>

int main(){
	int c=0,flag,i=0,j,tmp,data[100],n;
	scanf("%d",&n);
	while(i != n){
		scanf("%d",&data[i]);
		i++;
	}
	flag = 1;
    while(flag){
   		flag = 0;
		for(j=n-1; j>=1; j--){
			if(data[j] < data[j-1]){
				tmp = data[j];
				data[j] = data[j-1];
				data[j-1] = tmp;
				flag = 1;
				c++;
			}
		}
	}
	for(i=0;i<n;i++){
		i != n-1 ? printf("%d ",data[i]):printf("%d\n",data[i]);
	}
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int ans=0,task=0;
		int n=sc.nextInt();
		int k=sc.nextInt();
		int[] l=new int[51];
		for(int i=0;i<n;i++) {
			l[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				if(l[i]>l[j]) {
					task=l[i];
					l[i]=l[j];
					l[j]=task;
				}
			}
		}
		for(int i=0;i<k;i++) {
			ans+=l[i];
		}
		System.out.println(ans);

	}

}

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

namespace ConsoleApp2
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int[] NK = Read(Console.ReadLine());

            int N = NK[0];
            int K = NK[1];

            double prob = 0;

            for (int i = 1; i < N + 1; i++)
            {
                double times = 0;
                if (i < K)
                {
                    times = Math.Ceiling(Math.Log(K / (double)i) / Math.Log(2));
                }
                prob += Math.Pow(0.5, times);

            }

            Console.WriteLine(prob/N);
            

        }


        private static string ReplaceOneChar(string S ,int index,string newS)
        {
            string s1 = S.Substring(0, index-1);
            string s2 = S.Substring(index);
            return s1 + newS + s2;
        }

        private static int[] Read(string input)
        {
            string[] inputs = input.Split(' ');
            int num = inputs.Length;
            int[] ints = new int[num];
            for (int i = 0; i < num; i++)
            {
                ints[i] = int.Parse(inputs[i]);
            }
            
            return ints;
        }


    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int a, b, c;
  int k;
  cin >> a >> b >> c;
  cin >> k;
  while (a >= b) {
    k--;
    b *= 2;
  }
  while (b >= c) {
    k--;
    c *= 2;
  }

  cout << (k >= 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,a,b;
	char s[3];
	cin>>s;
	a=b=0;
   for(i=0;i<3;i++){
   	if(s[i]=='A')a++;
   	else b++;
   }
   if(a==2&&b==1||(a==1&&b==2)){
   	cout<<"Yes";
   }else {
   	cout<<"No";
   }
} 

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

int main() {
  int N, X;
  vector<int> vec(N);
  cin >> N >> X;
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  int x = 0;	/*座標 */
  int ans = 0;
    	for (int i = 0; i < N + 1; i++) {
           if (x <= X) {
             ans++;
           }
          x += vec.at(i);
        }
  cout << ans << endl;
}

Measured memory_bytes: 16640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
typedef long long lint;
const int N=1e5+5;
int n,val[N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x>y?x=y:0;}
	template <class T> inline void apx(T &x,const T y){x<y?x=y:0;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

bool vld(const int x){
	int sz=val[x];
	for(int i=1; sz<=(int)1e9&&i<x; ++i){
		sz+=val[i];
	}
	for(int i=x+1; sz<=(int)1e9&&i<=n; ++i){
		if(sz*2<val[i]) return 0;
		sz+=val[i];
	}
	return 1;
}

int main(){
	n=nxi();
	for(int i=1; i<=n; ++i){
		val[i]=nxi();
	}
	std::sort(val+1,val+n+1);
	{
		int l=1,r=n,mid;
		while(l!=r){
			mid=(l+r)>>1;
			if(vld(mid)) r=mid;
			else l=mid+1;
		}
		printf("%d\n",n-l+1);
	}
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

constexpr int m = 2019;

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

    string s;
    cin >> s;
    int n = s.length();
    
    vector<ll> dp(m, 0);
    dp[0] = 1;
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        int num = s[i] - '0';
        vector<ll> nextdp(m, 0);
        for(int j = 0; j < m; ++j){
            if(!dp[j])  continue;
            int nj = (j * 10 + num) % m;
            nextdp[nj] += dp[j];
        }
        dp = nextdp;
        ans += dp[0]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3684
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let (l, r) = get!(u64, u64);

    let mut ans = 2020;

    for x in l..min(r + 1, l + 2020) {
        for y in x + 1..min(r + 1, l + 2020) {
            ans = min(ans, ((x % 2019) * (y % 2019)) % 2019);
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 8572
package main

import (
	"fmt"
	"math"
)

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

	var a, b int
	min := 10000000000000

	for i := 1; i <= int(math.Sqrt(float64(n))); i++ {
		if n%i == 0 {
			a = n / i
			b = i
			if a+b < min {
				min = a + b
			}
		}
	}

	fmt.Println(min - 2)
}


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


int main() {
	char c[500];
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	if (c[k - 1] == 'A')c[k - 1] = 'a';
	if (c[k - 1] == 'B')c[k - 1] = 'b';
	if (c[k - 1] == 'C')c[k - 1] = 'c';
	for (int i = 0; i < n; i++) {
		cout << c[i];

	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#define P pair<long long, long long>


using namespace std;
const long long int MOD=1e9+7;

int main(){
  int h, a;
  cin >> h >> a;
  cout << (h-1)/a + 1 << endl;
}

Measured memory_bytes: 256
while True:
    str=''
    try:
        str=input()
    except:
        break
       
    lens=list(map(int,str.split(',')))
    v1=lens[10]
    v2=lens[11];
    lens=lens[0:10]
    rsum=sum(lens)
    lsum=0
    ans=0
    for i in range(10):
        lsum+=lens[i]
        rsum-=lens[i]
        if(lsum*v2>=rsum*v1):
            ans=i+1
            break
    print(ans)

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, m;
	cin>>n>>m;
	deque<int> d1;
	for(int i = 1; i <= m; i += 2){
		d1.push_back(i);
		d1.push_front(i);
	}
	deque<int> d2; d2.push_back(0);
	for(int i = 2; i <= m; i += 2){
		d2.push_back(i);
		d2.push_front(i);
	}
	vector<int> a;
	for(auto x : d1){
		a.push_back(x);
	}
	for(auto x : d2){
		a.push_back(x);
	}
	vector<int> ans[m + 1];
	for(int i = 0; i < a.size(); i++){
		ans[a[i]].push_back(i + 1);
	}
	for(int i = 1; i <= m; i++){
		int x = ans[i][0];
		int y = ans[i][1];
		if(x > y)swap(x, y);
		cout<<x<<" "<<y<<'\n';
	}

	return 0;
}

Measured memory_bytes: 9392
#include <iostream>
#include <math.h>
#include <algorithm>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using namespace std;

ll chmin(ll a,ll b){
  if(a>b){a = b;}
  return a;
}

int main(){
  ll n,ans=100;
  cin >> n;
  
  for(ll i=1; (i*i)<=n; i++){
    ll count=1;
    if(n%i == 0){
      ll m = n/i;
      while(m>=10){
        m /= 10;
        count++;
      }
      ans = chmin(ans,count);
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cassert>
using namespace std;

#define INF (1<<29)
#define MAX 55

typedef pair<int, int> P;

int N, D;
int cost[MAX][MAX];
P dp[MAX][MAX]; // dp[何泊目][泊まってるホテル] := (宿泊代の合計, 移動回数)

bool isValid(int p, int m, vector<int> path){
  int sum = 0;
  int move = 0;
  for(int i = 0 ; i < (int)path.size() ; i++) sum += cost[i][path[i]];
  for(int i = 1 ; i < (int)path.size() ; i++){
    if(path[i] != path[i-1]) move++;
  }
  if(p == sum && move == m) return true;
  else return false;
}

int main(){
  cin >> N >> D;
  for(int i = 0 ; i < N ; i++)
    for(int j = 0 ; j < D ; j++) cin >> cost[j][i];
  
  for(int i = 0 ; i < MAX ; i++)
    for(int j = 0 ; j < MAX ; j++) dp[i][j].first = dp[i][j].second = INF;
  
  vector<int>  paths[MAX][MAX];
  for(int j = 0 ; j < N ; j++){
    dp[0][j] = P(cost[0][j], 0);
    vector<int> p;
    paths[0][j].push_back(j);
  }
  
  for(int i = 1 ; i < D ; i++){
    for(int k = 0 ; k < N ; k++){
      for(int j = 0 ; j < N ; j++){
	
	P next = dp[i-1][k];	  
	next.first += cost[i][j];
	if(j != k) next.second += 1;	  
	
	vector<int> path;
	path = paths[i-1][k];
	path.push_back(j);
	
	if(dp[i][j] >= next){
	  dp[i][j] = min(dp[i][j], next);
	  paths[i][j] = path;
	}
      }
    }
  }

 for(int i = 1 ; i < D ; i++){
    for(int k = N-1 ; k >= 0 ; k--){
      for(int j = N-1 ; j >= 0 ; j--){
	
	P next = dp[i-1][k];	  
	next.first += cost[i][j];
	if(j != k) next.second += 1;	  
	
	vector<int> path;
	path = paths[i-1][k];
	path.push_back(j);
	
	if(dp[i][j] >= next){
	  dp[i][j] = min(dp[i][j], next);
	  if(paths[i][j].size() == 0) paths[i][j] = path;
	  else paths[i][j] = min(paths[i][j], path);
	}
      }
    }
  }

  P ans;
  ans.first = ans.second = INF;
  for(int j = 0 ; j < N ; j++) ans = min(ans, dp[D-1][j]);
  
  cout << ans.first << ' ' << ans.second << endl;
    
  vector<int> ans_path;
  
  for(int j = 0 ; j < N ; j++){
    if(dp[D-1][j] == ans){
      //if(!isValid(ans.first, ans.second, paths[D-1][j])) continue;	
      if(ans_path.size() == 0) ans_path = paths[D-1][j];
      else ans_path = min(ans_path, paths[D-1][j]);
    }
  }
  
  if(ans_path.size() == 0) assert(false);
  for(int i = 0 ; i < ans_path.size() ; i++){
    cout << ans_path[i]+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1604