akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(){
    int W, H, N; cin >> W >> H >> N;
    int x[N], y[N], a[N]; for(int i=0; i<N; i++) cin >> x[i] >> y[i] >> a[i];
    vector<vector<int>> S(W,vector<int>(H,1));

    for(int i=0; i<N; i++){
        switch(a[i]){
            case 1:
                for(int j=0; j<x[i]; j++){
                    for(int k=0; k<H; k++){
                        S[j][k] = 0;
                    }
                }
            	break;
            case 2:
                for(int j=x[i]; j<W; j++){
                    for(int k=0; k<H; k++){
                        S[j][k] = 0;
                    }
                }
            	break;
            case 3:
                for(int j=0; j<W; j++){
                    for(int k=0; k<y[i]; k++){
                        S[j][k] = 0;
                    }
                }
            	break;
            default:
                for(int j=0; j<W; j++){
                    for(int k=y[i]; k<H; k++){
                        S[j][k] = 0;
                    }
                }
            	break;
        }
    }

    int sum = 0;
    for(int j=0; j<W; j++){
        for(int k=0; k<H; k++){
            sum += S[j][k];
        }
    }
    cout << sum;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
    int a,b,c,temp;
    cin >> a >> b >> c;
    temp = a;
    a = b;
    b = temp;
    temp = a;
    a = c;
    c = temp;
    cout << a << " "<< b << " "<< c ;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int asc(const void* a, const void* b)
{
	if (*(long long int*)a > * (long long int*)b)return 1;
	if (*(long long int*)a < *(long long int*)b)return -1;
	return 0;
}
int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	int i;
	long long int h[200005];
	for (i = 0; i < n; i++)
		scanf("%lld", &h[i]);
	qsort(h, n, sizeof(long long int), asc);
	long long int ans = 0;
	for (i = 0; i < n - k; i++)
		ans += h[i];
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3324
#include <iostream>
using namespace std;
int main(){
	unsigned long long a,b,c;
	while(cin>>a>>b){
		c=a*b;
		if(a==b){
			cout<<a<<" "<<b<<endl;
		}else{
			while(!(a==0 || b==0)){
				if(a>b){
					a-=b;
				}else{
					b-=a;
				}
			}
			cout<<((a==0)?b:a)<<" "<<c/((a==0)?b:a)<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

ll gcd(ll a,ll b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd(b, a%b);
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  ll ans = 1;
  for (ll i = 2;i*i <= g;i++) {
    if (g % i == 0) {
      ans++;
      while (g % i == 0) {
        g /= i;
      }
    }
  }
  if (g != 1) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        n:usize,
        k:usize,
        s:chars,
    }
    let mut ans = 0;
    for i in 0..n {
        let count_up_flg = match s[i] {
            'L' if i >= 1 => s[i-1] == 'L',
            'R' if i + 1 < n => s[i+1] == 'R',
            _ => false,
        };
        if count_up_flg {
            ans += 1;
        }
    }
    println!("{}",min(ans + k * 2, n-1));
}


fn is_prime(x:i64) -> bool {
    if x == 2 {return true;}
    if x < 2 || x % 2 == 0 {return false;}
    let mut j = 3;
    while j <= (x as f64).sqrt() as i64 {
        if x % j == 0 {
            return false;
        }
        j += 2;
    }
    true
}

Measured memory_bytes: 4352
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn f(n: usize) -> usize {
    let mut n = n;
    while n / 10 > 0 {
        n /= 10;
    }
    return n;
}

fn main() {
    input! {
        n: usize,
    }
    let mut m = 0;
    let mut tmp = n;
    while tmp != 0 {
        m += 1;
        tmp /= 10;
    }
    let mut result = 0;
    for i in 1..n + 1 {
        // println!("{} {}", i, result);
        let f = f(i);
        let l = i % 10;
        if l == 0 {
            continue;
        }
        if f == l {
            result += 1;
        }
        let mut base = 10;
        for _ in 1..m {
            if l * base + f > n {
                break;
            }
            if (l + 1) * base + f - 10 > n {
                result += (n - (l * base + f)) / 10 + 1;
                break;
            }
            result += base / 10;
            base *= 10;
        }
    }

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


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

int main()
{
    vector<vector<int>> A(3, vector<int>(3, 0));
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;
    for (int k = 0; k < N; k++)
    {
        int b;
        cin >> b;
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (A[i][j] == b)
                    A[i][j] = -1;
            }
        }
    }

    for (int i = 0; i < 3; i++)
    {
        if (A[i][0] == -1 && A[i][1] == -1 && A[i][2] == -1)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    for (int i = 0; i < 3; i++)
    {
        if (A[0][i] == -1 && A[1][i] == -1 && A[2][i] == -1)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if (A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1)
    {
        cout << "Yes" << endl;
        return 0;
    }

    if (A[0][2] == -1 && A[1][1] == -1 && A[2][0] == -1)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>

using namespace std;

typedef vector<int> vi;

inline bool ok(const vi & v){
    for (int i = 1; i < v.size(); i++){
        if (v[i] != v[0]) return false;
    }
    return true;
};

struct state {
    vi v;
    int n;
};

int main(){
    string s;
    while (cin >> s, s != "0"){
        vi init(s.size());
        for (int i = 0; i < s.size(); i++){
            if (s[i] == 'r') init[i] = 0;
            else if (s[i] == 'g') init[i] = 1;
            else init[i] = 2;
        }
        queue<state> q;
        set<vi> dp;
        q.push({ init, 0 });

        int ans = -1;
        while (q.size()){
            state sta = q.front();
            q.pop();
            vi & sv = sta.v;
            auto pr = dp.insert(sv);
            if (!pr.second){
                continue;
            }
            if (ok(sv)){
                ans = sta.n;
                break;
            }
            for (int i = 1; i < sv.size(); i++){
                if (sv[i] != sv[i - 1]){
                    int a = sv[i];
                    int b = sv[i - 1];
                    sv[i] = sv[i - 1] = 3 - (a + b);
                    q.push({ sv, sta.n + 1 });
                    sv[i] = a;
                    sv[i - 1] = b;
                }
            }
        }
        if (ans == -1){
            cout << "NA" << endl;
        }
        else{
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 3456
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	int ans = 0;

	for (int i = 0; i < N;i++) {
		int x;
		cin >> x;
		int min_dist = min(K - x, x);
		ans += min_dist;
	}
	cout << 2 * ans << endl;

		


	

	return 0;
}



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

int main() {
    int N;
    cin >> N;
    int ans = 0;
    rep(i, N) {
        int a;
        cin >> a;
        while (a%2 == 0) {
            a /= 2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int ans = MOD;
    rep(i, max(x*2,y*2)+1){
        int a_num = (i/2 >= x) ? 0 : x-(i/2);
        int b_num = (i/2 >= y) ? 0 : y-(i/2);

        int total = (a_num*a)+(b_num*b)+(i*c);
        ans = min(total, ans);
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <queue>
#include <cstring>
#include <iostream>
using namespace std;

struct Process
{
    string name;
    int time;
};

int main()
{
    queue<Process> q;
    int processNum, roundTime;
    cin >> processNum >> roundTime;

    int elapsedTime = 0;
    for (int i = 0; i < processNum; i++)
    {
        Process process;
        cin >> process.name >> process.time;
        q.push(process);
    }
    while (!q.empty())
    {
        Process process = q.front();
        q.pop();
        if (process.time - roundTime <= 0)
        {
            elapsedTime += process.time;
            cout << process.name << " " << elapsedTime << endl;
        }
        else
        {
            process.time -= roundTime;
            elapsedTime += roundTime;
            q.push(process);
        }
    }
}



Measured memory_bytes: 6336
N = int(input())
s = input()
ans = s

def solve(n,s):
    cnt0 = [0]*n
    cnt1 = [0]*n
    cnt0[0] = 1 if s[0] == '(' else 0
    cnt1[-1] = 1 if cnt1[-1] == ')' else 0
    for i in range(1,n):
        cnt0[i] = cnt0[i - 1]
        if s[i] == '(' :
            cnt0[i] += 1
        elif cnt0[i] > 0:
            cnt0[i] -= 1
    return cnt0[-1]
        

right = solve(N,s)
r_s =''
for i in s:
    if i =='(':
        r_s = ')' + r_s
    else:
        r_s = '(' + r_s
left = solve(N,r_s)
print('('*left + ans + ')'*right)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  int N = s.size();

  map<char, int> m;
  REP(i, N){
    m[s[i]]++;
  }

  bool flag = true;
  for(auto p : m) if(p.second%2 == 1) flag = false;

  flag? Yes: No;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = []
B = []

for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A = A[::-1]
B = B[::-1]

count = 0
for i in range(N):
    if (A[i] + count) % B[i] != 0:
        count += (B[i] - (A[i] + count) % B[i])

print(count)


Measured memory_bytes: 17692
#include <iostream>

using namespace std;

const int MAX_N = 100;

int main() {
    int n, x;
    int l[MAX_N];

    cin >> n >> x;
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }

    int p = 0;
    int ans = 1;

    for (int i = 0; i < n; i++) {
        p += l[i];
        if (p > x) {
            break;
        }
        ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  string S;
  cin >> S;
  int ans = 0;
  for(int i = 0;i<3;i++){
    if(S.at(i) == '1'){
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
#define MOD 1000000007
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	string S;
	cin >> S;

	LL K;
	cin >> K;

	LL elapsed_days = 5000000000000000;
	LL total_length = 0;
	for (LL i = 0; i < S.size(); i++) {
		LL num = LL(S[i] - '0');
		if (num == 1) {
			total_length += 1;
			if (K <= total_length) {
				cout << num << endl;
				return 0;
			}
		}
		else {
			LL tmp = 1;
			for (LL j = 0; j < elapsed_days; j++) {
				tmp *= num;
				LL next_total_length = total_length + tmp / num;
				if (next_total_length < total_length) {
					total_length = 1LL << 60;
				}
				else {
					total_length = next_total_length;
				}

				if (K <= total_length) {
					cout << num << endl;
					return 0;
				}
			}
		}
	}
	return 1;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

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

    vector<int> a(n), b(n);
    ll as = 0, bs = 0;
    for(int i = 0; i < n; i++)  cin >> a[i], as += a[i];
    for(int i = 0; i < n; i++)  cin >> b[i], bs += b[i];

    if(as < bs){
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;
    ll need = 0;
    vector<int> excess;

    for(int i = 0; i < n; i++){
        if(a[i] > b[i]){
            excess.push_back(a[i]-b[i]);
        }else if(a[i] < b[i]){
            ans++;
            need += b[i]-a[i];
        }
    }

    sort(excess.rbegin(), excess.rend());

    int cur = 0;
    while(need > 0){
        need -= excess[cur++];
    }

    cout << ans+cur << endl;

    return 0;
}

Measured memory_bytes: 1408
ai, ao, at, aj, al, a_s, a_z = map(int, input().split())

b = min(ai, aj, al)
ans1 = ao + min(1, b)*3 + ((ai - min(1, b)) // 2) * 2 + ((aj - min(1, b)) // 2) * 2 + ((al - min(1, b)) // 2) * 2
ans2 = ao + (ai // 2) * 2 + (aj // 2) * 2 + (al // 2) * 2

ans = max(ans1, ans2)

print(ans)


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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main(){
  long long x, y; cin >> x >> y;
  if((2 * x - y) % 3 != 0 | (2 * y - x) % 3 != 0){
    cout << 0;
    return 0;
  }
  if(2 * x - y < 0 | 2 * y - x < 0){
    cout << 0;
    return 0;
  }
  long long a, b;
  a = (2 * x - y) / 3;
  b = (2 * y - x) / 3;
  long long abx = 1, ax = 1, bx = 1;
  for(int i = 1; i < a + 1; i++){
    ax *= i;
    ax = ax % 1000000007;
  }
  for(int i = 1; i < b + 1; i++){
    bx *= i;
    bx = bx % 1000000007;
  }
  for(int i = 1; i < a + b + 1; i++){
    abx *= i;
    abx = abx % 1000000007;
  }
  long long axbx = modinv(ax * bx, 1000000007);
  cout << axbx * abx % 1000000007;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int N;
  cin >> N;

  double x[N];
  string u[N];

  double price = 0;

  for(int i=0; i < N; i++){
    cin >> x[i] >> u[i];
    if(u[i] == "JPY"){
      price += x[i];
    }else{
      price += x[i] * 380000;
    }
  }

  cout << price << endl;

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <stdlib.h>
int N,K;
static int  h[100001][3];
static int  dp[100001][3];
int  INF = INT_MAX;

int 
chmin(int  *a, int b) 
{
	 if (*a > b){
		 *a = b; //	printf("%ld\n",*a);
		 return 1; 
	 }
	 return 0;
}

int 
chmax(int  *a, int b) 
{
	 if (*a < b){
		 *a = b; //	printf("%ld\n",*a);
		 return 1; 
	 }
	 return 0;
}

int 
main(){
	int i,j,k;
	scanf("%d",&N);
	for(i=0;i<N;i++)
	for(j=0;j<3;j++)
	{
		scanf("%d",&h[i][j]);
		//dp[i][j]=0;
	}
	//for(j=0;j<3;j++)
	//	dp[0][j]=0;
	
	#if 1
	for(i=0;i<N;++i){
		for( j=0;j<3;j++)
			for( k=0;k<3;k++){
				if(j==k)continue;
        		chmax(&dp[i + 1][k], dp[i][j] + h[i][k]);
			}
    }
    #endif
	
	int res = 0;
	for(j=0;j<3;j++) chmax(&res,dp[N][j]);
	printf("%d\n",res);
	

	
 return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>

#define N 64

int n;
int S[N][26];

int input(){
	char str[N];
	for( int i = 0; i < N; i++ ){
		for( int j = 0; j < 26; j++ ){
			S[i][j] = 0;
		}
	}
	std::cin >> n;
	for( int i = 0; i < n; i++ ){
		std::cin >> str;
		for( int j = 0; str[j] != '\0'; j++ ){
			S[i][str[j]-'a']++;
		}
	}
	return 0;
}

int run(){
	int m;
	for( int i = 0; i < 26; i++ ){
		m = S[0][i];
		for( int j = 1; j < n; j++ ){
			if( S[j][i] < m ){
				m = S[j][i];
			}
		}
		for( int k = 0; k < m; k++ ){
			std::cout << (char)('a'+i);
		}
	}
	std::cout << std::endl;
	return 0;
}

int main(){
	input();
	run();
	return 0;
}


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

ll gcd(ll x, ll y){
    if (y == 0) return x;
    return gcd(y, x % y);
}

struct Eratos{
    vector<int> first_prime; //その数を割り切る最小の素数,その数自身のとき素数とわかる
    vector<int> P;

    Eratos(int N){
        first_prime.resize(N + 1);
        rep (i, N + 1)
            first_prime[i] = i;
        for(int i = 2; i <= N; i++){
            if(first_prime[i] == i){
                for(int j = 2 * i; j <= N; j += i){
                    first_prime[j] = min(first_prime[j], i);
                }
                P.pb(i);
            }
        }
    }
    vector<int> factorization(int n, vector<int> &f){
        if (n == 1)
            return f;
        else {
            f.pb(first_prime[n]);
            return factorization(n / first_prime[n], f);
        }
    }
};

int main(){
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    Eratos er(1e6);
    ll ans = 1;
    rep(i, er.P.size()){
        if (g % er.P[i] == 0){
            while (g % er.P[i] == 0)
                g /= er.P[i];
            ans ++;
        }
    }
    if (g != 1) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 7824
/* written by : vipin kumar */
#include<iostream>
using namespace std;
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#define int long long int
#define mod 1000000007
int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     string str1,str2;
     cin>>str1>>str2;
     int n=str1.size(),answer=0;
     for(int j=0;j<n;j++)
     {
		 if(str1[j]!=str2[j])
		 {
			 answer++;
		 }
	 }
	 cout<<answer<<endl;
}


Measured memory_bytes: 3884
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int,char> P;
typedef pair<int,P> PP;

bool compare(PP a,PP b){
  return a.first > b.first;
}

int main(){
  int n,res[10];
  char ch;

  while(cin >> n ,n){
    vector<PP> v;
    for(int i = 0 ; i < n ; i++){
      int sum = 0 , f = 0;
      cin >> ch;
      for(int j = 0 ; j < n-1 ; j++){
	cin >> res[j];
	if(res[j]==0) sum += 5;
	else if(res[j]==2) sum++;
	else f++;
      }  
      v.push_back(PP(sum,P(f,ch))); 
    }
    sort(v.begin(),v.end(),compare);
    for(int i = 0 ; i < n ; i++) cout << v[i].second.second << endl;
  }

  return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

    void Solve() {
        LL X; cin >> X;
        for (LL A = 1; A < 1000; A++) {
            LL Bp4 = A * A * A * A * A - X;
            LL l = -A, r = A;
            while (l + 1 < r) {
                LL m = (l + r) >> 1;
                if (m * m * m * m * m <= Bp4) l = m;
                else r = m;
            }
            if (l * l * l * l * l == Bp4) { cout << A << " " << l << endl; return; }
        }
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main()
{
  int r, g, b;
  
  cin >> r >> g >> b;
  
  if((r * 100 + g * 10 + b) % 4 == 0){
    cout << "YES" << endl;
  }
  else{
	cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

ll cnt[N];
int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    ll n, x, y;
    cin >> n >> x >> y;
    for (int i = 1; i <= n; i ++) {
    	for (int j = i + 1; j <= n; j ++) {
    		ll d = j - i;
    		d = min(d, abs(i - x) + abs(y - j) + 1);
    		d = min(d, abs(i - y) + abs(x - j) + 1);
    		cnt[d] ++;
		}
	}
	for (int i = 1; i < n; i ++)
		cout << cnt[i] << '\n';
	return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e-a<=k) {
    cout << "Yay!" << endl;
  }
  else {
    cout << " :( " << endl;
  }
}

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

int main(){
    int n;
    cin >> n;
    map<string,int> mp;
    rep(i,n){
        string s;
        cin >> s;

        auto result=mp.find(s);
        if(result!=mp.end()) mp[s]++;
        else mp.insert(make_pair(s,1));

    }
    vector<string> ans;
    int u=0;
    for(auto iter=begin(mp);iter!=mp.end();iter++){
        u=max(u,iter->second);
    }

    for(auto iter=mp.begin();iter!=mp.end();iter++){
        if(iter->second==u) ans.push_back(iter->first);
    }

    sort(ans.begin(),ans.end());
    for(auto x: ans){
        cout << x << "\n";
    }

}

Measured memory_bytes: 26868
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const int MAX_N = 101;
int N;
int x[MAX_N];
int y[MAX_N];
int h[MAX_N];

bool check(int cx, int cy, int currH){
	if (currH <= 0) return false;
	rep (i, N){
		if (h[i] != max(currH - abs(x[i] - cx) - abs(y[i] - cy), 0)){	
			return false;
		} // end if
	} // end rep
	return true;
}
					
int main()
{
	memset(x, 0, sizeof(x));
	memset(y, 0, sizeof(y));
	memset(h, 0, sizeof(h));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> N;
	rep (i, N){
		cin >> x[i] >> y[i] >> h[i];
	} // end rep

	vector<int> res(3, -1);
	rep (cx, 101){
		rep (cy, 101){
			set<int> cand; cand.clear();
			rep (i, N){
				if (h[i] != 0){
					int curr = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
					cand.insert(curr);
				} // end if
			} // end rep
			if ((int)cand.size() == 1){
				set<int>::iterator it = cand.begin();
				if (check(cx,cy,*it)){
					res[0] = cx;
					res[1] = cy;
					res[2] = *it;
					break;
				} // end if
			} // end if
		} // end rep
	} // end rep

	rep (i, 3){
		cout << res[i] << (i != 2 ? ' ' : '\n');
	} // end rep
			
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pb push_back
#define ii pair<int,int>
#define ppb pop_back
#define orta ((bas+son)>>1)
#define st first
#define nd second
#define ll long long
#define N 5005
#define inf 1000000000
#define MOD 1000000007
#define LOG 29
#define EPS 0.000000001
#define M 305
using namespace std;

int dp[105][105];
int n,m;
int w[2][2]={-1,0,0,-1};
string s[105];

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);	

	cin>>n>>m;
	for(int i=1;i<=n;i++) {
		cin>>s[i];
		s[i]=" "+s[i]; 
	}
	dp[1][1]=(s[1][1]=='#');
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++) {
			if(i==1 && j==1) continue ;
			dp[i][j]=inf;
			for(int k=0;k<2;k++) {
				int tx=i+w[k][0];
				int ty=j+w[k][1];
				if(tx<1 || ty<1) continue ;
				dp[i][j]=min(dp[i][j],dp[tx][ty]+(s[i][j]!=s[tx][ty] && s[i][j]=='#'));
			}
		}
	}
	cout<<dp[n][m];

}

Measured memory_bytes: 384
import sys

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

nM=0
As=sorted(A, reverse=True)
threshold=float(sum(A)/(4*M))
#print(As, sum(A), threshold)

last=A[0]

for i in range(N):
    if not(float(As[i]) < threshold):
        nM+=1
    else:
        break
    
    if nM>=M:
        break

#print(nM,M)
if nM>=M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import sys
readline = sys.stdin.buffer.readline

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

ans = 0
height = A[0]
for i in range(1, N):
    h = A[i]
    if h < height:
        ans += height - h

    height = max(height, h)


print(ans)


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll n, a[222222], b[222222], r;
set<ll> s;

int main() {
	cin >> n;
	rep(i,n) {
		cin >> a[i];
		b[a[i]-1] = i;
	}
	s.insert(-1);
	s.insert(n);
	rep(i,n) {
		auto it = s.lower_bound(b[i]);
		ll ri = *it - b[i];
		it--;
		ll le = b[i] - *it;
		r += a[b[i]] * le * ri;
		s.insert(b[i]);
	}
	cout << r << ln;
}

Measured memory_bytes: 12800
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int x1 = sc.nextInt();
	int x2 = sc.nextInt();
	int x3 = sc.nextInt();
	int x4 = sc.nextInt();
	int x5 = sc.nextInt();
	if (x1 == 0) {
	    System.out.print(1);
	} else if (x2 == 0) {
	    System.out.print(2);
	} else if (x3 == 0) {
	    System.out.print(3);
	} else if (x4 == 0) {
	    System.out.print(4);
	} else {
	    System.out.print(5);
	}
    }
}


Measured memory_bytes: 35672
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  vll a(n);
  rep(i,n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  
  ll ans = 1;
  int cnt = 0;
  int pos = 0;
  int now = 0;
  while (pos < n) {
    int cnt2 = 0;
    now = a[pos];
    while (pos < n && now == a[pos]) {
      cnt2++;
      pos++;
      if (cnt2 == 2) {
        ans *= now;
        cnt++;
        if (cnt == 2) {
          break;
        }
        break;
      }
    }
    if (cnt == 2) break;
  }

  cout << (cnt==2?ans:0) << endl;
  return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N, M; cin >> N >> M;
	if (M == 0) {
		cout << 0 << endl;
		return 0;
	}
	vector<double> L(N), a(N), b(N);
	for (int i = 0; i < N; i++)
		cin >> L[i] >> a[i] >> b[i];
	vector< vector<double> > d(N, vector<double>(N));
	for (int i = 0; i < N; i++)
		for (int j = i + 1; j < N; j++) {
			double dL = L[i] - L[j], da = a[i] - a[j], db = b[i] - b[j];
			d[i][j] = dL * dL + da * da + db * db;
		}
	double maxi = 0;
	for (int S = (1 << M) - 1; S < (1 << N);) {
		double sum = 0;
		vector<int> v;
		for (int i = 0; i < N; i++)
			if (S & (1 << i)) v.push_back(i);
		for (int k = 0; k < v.size(); k++)
			for (int l = k + 1; l < v.size(); l++)
				sum += d[v[k]][v[l]];
		maxi = max(maxi, sum);
		int x = S & -S, y = S + x;
		S = ((S & ~y) / x >> 1) | y;
	}
	printf("%.10f\n", maxi);
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll k,s;
  cin >> k >> s;
  ll ans = 0;
  REP(i,k+1){
    ll J = s-i;
    if(J>2*k || J<0) continue;
    REP(j,k+1){
      ll K = J - j;
      if(0<=K && K<=k) ans++;
    }
  }
  cout << ans<< endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n; cin >> n;
    vector<ll> a(n); cin >> a;
    vector<ll> b(n, 0);
    ll m = 0;
    for(ll i = n-1; i >= 0; --i){
        if((i+1)*2 > n){
            b[i] = a[i];
        }else{
            ll sum = 0;
            for(ll j = i; j < n; j += (i+1)){
                sum += b[j];
            }
            if(sum%2 == 0 && a[i] == 1) b[i] = 1;
            if(sum%2 == 1 && a[i] == 0) b[i] = 1;
        }
        m += b[i];
    }
    cout << m << endl;
    rep(i, n){
        if(m == 0) continue;
        if(i > 0 && b[i-1]) cout << " ";
        if(b[i]) cout << i+1;
    }
    return 0;
}

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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
#define DRT() int t; si(t); while(t--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//# define M_PI           3.14159265358979323846264338327950288
// DSU
void IO(){
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
}
const int maxn = 1e5+1;
VII arr;
LL n,m;
LL parent[maxn];
LL quantity[maxn];
LL findSet(LL v){
	if(v == parent[v])
		return v;
	return parent[v] = findSet(parent[v]);
}
void unionSet(LL a, LL b){
	LL r1 = findSet(a);
	LL r2 = findSet(b);
	if(r1 != r2){
		if(quantity[r1] < quantity[r2]){
			parent[r1] = r2;
			quantity[r2] += quantity[r1];
		}
		else{
			parent[r2] = r1;
			quantity[r1] += quantity[r2];
		}
	}
}
int main(){
	IO();
	cin>>n>>m;
	arr.resize(m);
	for(LL i=0;i<m;i++){
		cin>>arr[i].F;
		cin>>arr[i].S;
	}
	rep(i,1,n+1){
		parent[i] = i;
		quantity[i] = 1;
	}
	VL ans;
	rep(i,m,0){
		LL r1 = findSet(arr[i].F);
		LL r2 = findSet(arr[i].S);
		if(r1 == r2)
			ans.PB(0);
		else{
			LL t =(LL) quantity[r1] * quantity[r2];
			ans.PB(t);
			unionSet(r1, r2);
		}
	}
	reverse(ALL(ans));
	rep(i,1,m){
		ans[i] += ans[i-1];
	}
	for(auto it : ans){
		cout<<it<<"\n";
	}
	return 0;
}

Measured memory_bytes: 6652
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define ll long long
using namespace std;
ll a[1000005],book[1000005];
int main()
{
    int n,flag=0;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    int t=0;
    for(int j=n-1; j>=0; j--)
    {
        if(a[j]==a[j-1])
        {
            book[t]=a[j];
            a[j]=a[j-1]=0;
            t++;
            if(t==2)
            {
                flag=1;
                break;
            }
        }
    }
    if(flag==0)
        printf("0\n");
    else
        printf("%lld\n",book[0]*book[1]);
    return 0;


}

Measured memory_bytes: 4352
s = input()#n-1

n = len(s)+1
a1 =[0]*n#n
a2 =[0]*n#n
a =[0]*n#n


for i in range(n-1):
	if s[i] =='<':
		a1[i+1] =a1[i]+1
for i in reversed(range(n-1)):
	if s[i] == '>':
		a2[i] = a2[i+1] + 1

for i in range(n):
	a[i] = max(a1[i],a2[i])

print(sum(a))


Measured memory_bytes: 31144
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		if(a==100000){
			System.out.println(90909);
	  }else if(a>=10000){
			System.out.println(909+a-9999);
		}else if(a>=1000){
			System.out.println(909);
		}else if(a>=100){
			System.out.println(9+a-99);
		}else if(a>=10){
			System.out.println(9);
		}else{
			System.out.println(a);
		}
	}
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
clock_t startTime;
long double getTime(){
	return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
}

int main(){
	startTime=clock();
	ll n,m;
	cin >> n >> m;
	std::vector<ll> div;
	for(ll i=1; i <  sqrt(m)+1;i++){
		if(m%i==0) div.eb(i);
	}
	for(ll k=div.size()-1;k>=0;k--){
		div.eb(m/div[k]);
	}
	ll j=div.size()-1;
	while(j >= 0 && div[j]*n > m) j--;
	cout << div[j];

	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
 
void change(int,int);
int muki = 0,flag = 0;
 
int main(){
    int i,j,x = 0,y = 0,wall_x[4][5],wall_y[5][4];
    for(i = 0;i < 9;i++){
        if(i % 2 == 0) for(j = 0;j < 4;j++) scanf("%1d",&wall_x[j][i / 2]);
        else for(j = 0;j < 5;j++) scanf("%1d",&wall_y[j][(i - 1)/ 2]);
    }
    do{
        if(muki == 0){
            if(x != 4 && wall_x[x][y] == 1){
                flag = 0;
                change(x,y);
                putchar('R');
                x++;
            }else change(x,y);
        }else if(muki == 1){
            if(y != 4 && wall_y[x][y] == 1){
                flag = 0;
                change(x,y);
                putchar('D');
                y++;
            }else change(x,y);
        }else if(muki == 2){
            if(x != 0 && wall_x[x - 1][y] == 1){
                flag = 0;
                change(x,y);
                putchar('L');
                x--;
            }else change(x,y);
        }else if(muki == 3){
            if(y != 0 && wall_y[x][y - 1] == 1){
                flag = 0;
                change(x,y);
                putchar('U');
                y--;
            }else change(x,y);
        }
    }while(x != 0 || y != 0);
    puts("");
    return 0;
}
 
void change(int x,int y){
    int i;
    if(!flag){
        flag = 1;
        muki = (muki + 3) % 4;
    }
    else muki = (muki + 1) % 4;
}


Measured memory_bytes: 2052
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String S = in.next();
		String s="";
		for(int i=0;i<3;i++) {
			if (S.charAt(i) == '1') {
				s=s+'9';
			}else if(S.charAt(i) == '9'){
					s=s+'1';
			}else {
				s=s+S.charAt(i);
			}
		}
		

		
		System.out.print(s);

	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,K;
  cin>>N>>K;
  vector <int> H(N);
  for(int i=0;i<N;i++)
    cin>>H.at(i);
  int ans=0;
  for(int i=0;i<N;i++){
  if(K<=H.at(i)) ans++;
  } cout<<ans<<endl;
  return 0;
}

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

typedef long long ll;

int N, M, sx, sy;
ll K;
vector<int> A, B;
vector<ll> X, Y;

void input_init(void) {
	cin >> N >> M >> K;
	A.resize(N + 1, 0);
	for (int i = 1; i <= N; ++i)
		cin >> A[i];
	B.resize(M + 1, 0);
	for (int i = 01; i <= M; ++i)
		cin >> B[i];
	if (N < M) {
		sx = N;	sy = M;
		X.resize(sx + 1, (ll)0);
		for (int i = 1; i <= sx; ++i)
			X[i] = X[i - 1] + (ll)A[i];
		Y.resize(sy + 1, (ll)0);
		for (int i = 1; i <= sy; ++i)
			Y[i] = Y[i - 1] + (ll)B[i];
	}
	else {
		sx = M;	sy = N;
		X.resize(sx + 1, (ll)0);
		for (int i = 1; i <= sx; ++i)
			X[i] = X[i - 1] + (ll)B[i];
		Y.resize(sy + 1, (ll)0);
		for (int i = 1; i <= sy; ++i)
			Y[i] = Y[i - 1] + (ll)A[i];
	}
}

int solve(void) {
	int max_cnt = 0;
	for (int i = 0; i <= sx; ++i) {
		if (X[i] > K)
			break;
		int p = (upper_bound(Y.begin(), Y.end(), K - X[i]) - Y.begin());
		if (p > 0)
			--p;
		max_cnt = max(i + p, max_cnt);
	}
	return max_cnt;
}

int main(void) {
	input_init();
	int ans = solve();
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 7988
#-------------------------------------------------------------------------------
# Name:        module6
# Purpose:
#
# Author:      user
#
# Created:     12/04/2020
# Copyright:   (c) user 2020
# Licence:     <your licence>
#-------------------------------------------------------------------------------
from math import gcd



def main():
    k = int(input())
    total = 0

    for a in range(1,k+1):
        for b in range(1,k+1):
            for c in range(1,k+1):
              temp = gcd(a,b)
              total += gcd(temp,c)
    print(total)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxd = 1e5+10;
int a[maxd];
int main()
{
    // freopen("a.in","r",stdin);
    // freopen("k.out","w",stdout);
    int n;
    scanf("%d",&n);
    for(int i=1;i<n;i++) scanf("%d",&a[i]);
    int ans = a[1]+a[n-1];
    for(int i=1;i<n-1;i++)
        ans+= min(a[i],a[i+1]);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()

void solve(){
  int n; cin >> n;
  vector<ld> v(n);
  FOR(i,0,n) cin >> v[i];
  sort(ALL(v));
  ld ans = v[0];
  FOR(i,1,n) ans = (ans+v[i])/2;
  std::cout << std::fixed << std::setprecision(20);
  cout << ans << endl;
}

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

Measured memory_bytes: 256
lst = list(map(int, input().split()))
ans = 0
tot = 0
cnt = 0
 
for i in range(1,lst[0]+1):
    flg = True
    val = i
    while flg:
        cnt += 1
        tot = tot + val%10
        val = val//10
 
        if val==0:
            if ( lst[1] <= tot and
                 tot <= lst[2] ):
                ans = ans + i
 
            tot = 0
            flg = False
 

print(ans)

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

class Main{
	private void compute(){
		Scanner scanner = new Scanner(System.in);
		for( int i = 0; i < 7; i++){
			int nHigh = scanner.nextInt();
			int nLow = scanner.nextInt();
			System.out.println(nHigh - nLow);
		}
	}
	public static void main(String args[]){
		new Main().compute();
	}
	
}

Measured memory_bytes: 17172
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  auto n = readln.chomp.to!int;
  int[string] cnt;
  int m;
  foreach (_; 0..n) {
    auto s = readln.chomp;
    cnt[s]++;
    m = max(cnt[s], m);
  }
  auto keys = cnt.keys;
  sort(keys);
  foreach (k; keys) {
    if (cnt[k] == m) {
      writeln(k);
    }
  }
}


Measured memory_bytes: 28796
N, M = map(int, input().split())
A = list(map(int,input().split()))
count = 0
total = 0
for i in range(N):
  total += A[i]
for j in range(N):
  if A[j] >= total / ( 4 * M ):
    count += 1
  else:
    pass
if count >= M:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	int n,m;
	int a,b,c;
	int i,j,k;
	int s=0;
	while(cin>>n){
		if(!n)break;
		b=0,c=1e5,s=0;
		for(i=0;i<n;i++){
			cin>>a;
			if(b<a)b=a;
			if(a<c)c=a;
			s+=a;
		}
		s-=b+c,n-=2;
		s/=n;
		cout<<s<<endl;
	}
}



Measured memory_bytes: 3100
import java.io.*;
import java.util.*;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		stdin.readLine();
		int[] elems = Arrays.stream(stdin.readLine().split(" "))
				.mapToInt(Integer::parseInt)
				.boxed()
				.sorted(Comparator.reverseOrder())
				.mapToInt(Integer::new)
				.toArray();
		int alice = IntStream.range(0, elems.length)
				.filter(i -> i % 2 == 0)
				.map(i -> elems[i])
				.sum();
		int bob = IntStream.range(0, elems.length)
				.filter(i -> i % 2 == 1)
				.map(i -> elems[i])
				.sum();
		System.out.println(alice - bob);
	}

}

Measured memory_bytes: 27604