akhauriyash/Code-Regression huggingface dataset:
# 二つ入れて、次のところで小さい方を入れる。
n = gets.to_i
b = gets.split(' ').map(&:to_i)
array = Array.new
(n-1).times do |a|
    if a == 0
        array[a..a+1] = b[a],b[a]
    else
        if array[a] >= b[a]
            array[a..a+1]=b[a],b[a]
        else
            array[a+1]= b[a]
        end
    end
end
puts array.inject(:+)



Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
//loopはあたいの更新に注意！！
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    char s[4];
    rep(i, 4) cin >> s[i];
    int cnt = s[0] - '0';
    rep(i, 2) {
    int cnt1 = (i == 0 ? cnt + s[1] - '0' : cnt - s[1] + '0');
        rep(j, 2) {
            int cnt2 = (j == 0 ? cnt1 + s[2] - '0' : cnt1 - s[2] + '0');
            rep(k, 3) {
                int cnt3 = (k == 0 ? cnt2 + s[3] - '0' : cnt2 - s[3] + '0');
                if(cnt3 == 7) {
                    cout << s[0] << (i == 0 ? '+' : '-') << s[1] << (j == 0 ? '+' : '-') << s[2] << (k == 0 ? '+' : '-') << s[3] << "=7" << endl;
                    return 0;
                }
            }
        }
    }
	return 0;
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n;
    cin >> n;
    vector<lint> a(n);
    rep(i, n){
        cin >> a[i];
    }
    int l = pow(3, n), ans = 0;
    rep(i, l){
        int tmp = i;
        lint m = 1;
        rep(j, n){
            if(tmp % 3 == 0){
                m *= (a[j] - 1LL);
            }else if(tmp % 3 == 1){
                m *= a[j];
            }else{
                m *= (a[j] + 1LL);
            }
            tmp /= 3;
        }
        if(m % 2LL == 0){
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>

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

  std::vector<int> vec(N);
  for (int i=0; i < N ; i++ ) {
    std::cin >> vec.at(i);
  }

  int maxv = -1 * (1000000000);
  int minv = vec.at(0) ;
  for (int i = 1; i < N ; i ++ ) {
    if ( maxv < vec.at(i) - minv ){
      maxv =  vec.at(i) - minv;
    }

    if (minv > vec.at(i)){
      minv =vec.at(i);
    }
  }

  std::cout << maxv << std::endl;

}


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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, k, r, s, p;
    string t;

    cin >> n >> k >> r >> s >> p >> t;

    REP(i, n)
    {
        if (t[i] == 'r')
            t[i] = 'p';
        else if (t[i] == 's')
            t[i] = 'r';
        else
            t[i] = 's';
    }

    bool used[112345];
    fill(used, used + n + 1, false);

    ll res = 0;

    REP(i, n)
    {
        if (used[i])
            continue;

        int cnt = 0;
        int j = i;

        while (j < n && t[j] == t[i])
            used[j] = true, j += k, cnt++;

        int a;
        if (t[i] == 'r')
            a = r;
        else if (t[i] == 's')
            a = s;
        else
            a = p;

        res += (cnt - (cnt / 2)) * a;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
 
//DEFINE and TYPEDEF--------------------------------------------------------------
// For actual content check from line 94

#define FORG(i,a,n) for(lld i=(lld)a;a<n?i<(lld)n:(lld)n<i;a<n?++i:--i) //for - general
#define FORZ(i,n) for(lld i=0;i<(lld)n;++i) //for - zero
#define FORGI(i,a,n,inc) for(lld i=(lld)a;a<n?i<(lld)n:(lld)n<i;a<n?i+=inc:i-=inc) //for - general incremental
#define FORZI(i,n,inc) for(lld i=0;i<(lld)n;i+=inc) //for - zero incremental
#define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define MEM(a,val) memset(a,val,sizeof(a));
 
#define all(m) m.begin(),m.end()
#define sz(m) (lld)m.size()
 
#define st first
#define nd second
#define pb push_back
#define DEC(x) fixed<<setprecision(x)
 
typedef long long int lld;
typedef unsigned long long int ulld;
 
//DEBUGGER------------------------------------------------------------------------
// #define DEBUG(x) cerr<<(#x)<<" is "<<(x)<<"\n" //to debug values of variables
#define DEBUGON
#define ZINDA cerr<<"\nIdhar-ich hai apun!!\n"; //to debug if code reached that point

#ifdef DEBUGON
	vector<string> vec_splitter(string s) 
	{
		for(char& c: s) c = c == ',' ?  ' ': c;
		stringstream ss; ss << s;
		vector<string> res;
		for(string z; ss >> z; res.push_back(z));
		return res;
	}

	void debug_out(
	vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx, __attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
	template <typename Head, typename... Tail>
		void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) 
		{
			if(idx > 0) cerr << ", "; 
			else cerr << "Line(" << LINE_NUM << "): ";
			stringstream ss; ss << H;
			cerr << args[idx] << " = " << ss.str();
			debug_out(args, idx + 1, LINE_NUM, T...);
		}

	#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__);
	#define DEBUG(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__);
#else
	#define debug(...) 320;
	#define DEBUG(...) 320;
#endif

lld power(lld b, lld e)
{
	assert(e>=0);
    if(e==0) return 1;
    if(e%2==1) return b*power(b*b,(e-1)/2);
    else return power(b*b,e/2);
}
 
lld power(lld b, lld e, lld m)
{
	assert(e>=0);
	if(e==0) return 1;
	if(e%2==1) return b*power(((b%m)*(b%m))%m,(e-1)/2,m)%m;
	else return power(((b%m)*(b%m))%m,e/2,m)%m;
}
 
int nDig(lld n)
{
	if(n<0) n*=-1;
	if(n==0) return 1;
    else return int(log10(n) + 1);
}

int lognk(lld n, lld k) // logk(n)
{
	assert(n>=0 and k>=0 and k!=1);
	if(n==0) return -1;
	else return lognk(n/k,k)+1;
}

const long double pi = acos(-1);
#define endl '\n'
#define mod 1000000007

//endl : changed to '\n', to flush comment that definition
//--------------------------------------------------------------------------------

void swagWaalaFunction()
{
	lld n,ans=0;
	cin>>n;

	if(n%1000!=0)
		ans=1000-n%1000;

	cout<<ans;
	return;
}

int main()
{
    SPEEDUP;
 	lld t=1;
 	//cin>>t;

 	#ifdef PRIMES
 		sieve();
 	#endif

 	#ifdef CHOOSE
 		nCrModInit();
 	#endif

 	while(t--)
 		swagWaalaFunction();
	
	// cerr<<"\n"<<timeKyaHorhaH; 	
 	return 0;
}

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

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

    int black=0;
    int white=0;
    
    string S_c = S;
    for(int i=0;i<S_c.length(); i++){ // 黒開始にしてみる   
        if(i==0){
            if( S_c.at(i)=='0'){
                S_c.at(i) = '1'; black++;
            }
        }else if(S_c.at(i-1)=='0' && S_c.at(i)=='0'){
            S_c.at(i) = '1'; black++;
        }else if(S_c.at(i-1)=='1' && S_c.at(i)=='1'){
            S_c.at(i) = '0'; black++;
        }
    }
    S_c = S;
     for(int i=0;i<S_c.length(); i++){ // 白開始にしてみる   
        if(i==0){
            if(S_c.at(i)=='1'){
                S_c.at(i) = '0'; white++;
            }
        }else if(S_c.at(i-1)=='0' && S_c.at(i)=='0'){
            S_c.at(i) = '1'; white++;
        }else if(S_c.at(i-1)=='1' && S_c.at(i)=='1'){
            S_c.at(i) = '0'; white++;
        }
    }
    int res = min(black, white);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3788
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;

const int maxn=50005;
struct edge{
	int u,v;
	double cost;
}es[maxn];
int n,m;
int x[maxn],y[maxn],f[maxn];
bool cmp(edge a,edge b){
	return a.cost>b.cost;
}
int find(int x){
	if(f[x]==x) return x;
	return f[x]=find(f[x]);
}
bool unite(int a,int b){
	int x=find(a),y=find(b);
	if(x==y) return 0;
	else f[x]=y;
	return 1;
}
double K(){
	sort(es,es+m,cmp);
	double ans=0;
	for(int i=0;i<m;i++){
		if(unite(es[i].u,es[i].v)) ans+=es[i].cost;
	}
	return ans;

}
int main(){
	while(cin>>n>>m){
		for(int i=1;i<=n;i++) f[i]=i,cin>>x[i]>>y[i];
		int p,q;
		double sum=0;
		for(int i=0;i<m;i++){
			cin>>p>>q;
			es[i].u=p,es[i].v=q;
			es[i].cost=sqrt((x[p]-x[q])*(x[p]-x[q])+(y[p]-y[q])*(y[p]-y[q]));
			sum+=es[i].cost;
		}
		double ans=sum-K();
		printf("%.3lf",ans);
	}
	return 0;
}


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

int const maxN = 1e5 + 10;

int N, ut, va;
vector<int> E[maxN];

int main()
{
  scanf("%d%d%d", &N, &ut, &va);
  for(int i = 0; i < N-1; i++) {
    int A, B;
    scanf("%d%d", &A, &B);
    E[A].push_back(B);
    E[B].push_back(A);
  }

  if(ut == va) { puts("0"); return 0; }


  int aoki[maxN];
  vector<bool> vis(N+1, false);
  queue<pair<int, int>> q;
  vis[va] = true;
  q.push({va, 0});

  while(q.size()) {
    //auto [u, t] = q.front(); q.pop();
    int u, t;
    tie(u, t) = q.front(); q.pop();
    aoki[u] = t;
    for(int v: E[u])
      if(!vis[v]) q.push({v, t+1}), vis[v] = true;
  }

  int taka[maxN];
  queue<tuple<int, int, int>> q2;
  memset(taka, -1, sizeof taka);
  //vis.assign(N+1, false);
  //vis[ut] = true;
  q2.push(make_tuple(ut, ut, 0));

  while(q2.size()) {
    //auto [u, t] = q2.front(); q2.pop();
    int p, u, t;
    tie(p, u, t) = q2.front(); q2.pop();
    taka[u] = t;
    for(int v: E[u])
      if(v != p && t+1 <= aoki[v]) q2.push(make_tuple(u, v, t+1)), vis[v] = true;
  }


  int ans = 0;
  for(int i = 1; i <= N; i++)
    if(taka[i] != -1) ans = max(ans, aoki[i]-1);

  //for(int i = 1; i <= N; i++) printf("%d ", taka[i]);

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 7032
use std::cmp;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let mut left = vec![];
    let mut right = vec![];
    for _ in 0..n {
        let l: i64 = sc.read();
        let r: i64 = sc.read();
        left.push(2 * l);
        right.push(-2 * r);
    }
    left.sort();
    right.sort();
    left.reverse();
    right.reverse();

    let mut sum = 0;
    let mut ans = 0;
    ans = cmp::max(ans, left[0]);
    ans = cmp::max(ans, right[0]);
    for i in 0..(n / 2) {
        sum += left[i];
        sum += right[i];
        let used = (i + 1) * 2;
        ans = cmp::max(ans, sum);
        if used < n {
            ans = cmp::max(ans, sum + left[i + 1]);
            ans = cmp::max(ans, sum + right[i + 1]);
        }
    }

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

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8444
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N, K; std::cin >> N >> K;
  int R, S, P; std::cin >> R >> S >> P;
  std::map<char, LL> score = {
    {'r', P},  {'s', R}, {'p', S}
  };

  std::vector<std::string> T(K, "");
  for (int i = 0; i < N; ++i) {
    char c; std::cin >> c;
    T[i%K] += c;
  }

  LL total_score = 0;
  for (std::string& s : T) {
    total_score += score[s[0]];
    for (int i = 1; i < s.size(); ++i) {
      if (s[i] == s[i-1]) s[i] = 'x';
      else                total_score += score[s[i]];
    }
  }

  std::cout << total_score << std::endl;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int64_t a, b; cin >> a >> b;
    bitset<32> A(a);
    bitset<32> B(b);
    cout << (A & B) << endl;
    cout << (A | B) << endl;
    cout << (A ^ B) << endl;
}


Measured memory_bytes: 3152
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
	bool operator<(const P &b) const{ return cost < b.cost; }
	bool operator>(const P &b) const{ return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const{ return cost < b.cost; }
	bool operator>(const E &b) const{ return cost > b.cost; }
};
struct H {
	ll x, y;
	bool operator<(const H &b) const{
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const{
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const{ return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const{ return (*this) != b; }
};
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ld mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[200000];
signed main() {
	cin >> n;
	int m = 1;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0) m = a[i];
		else m = gcd(m, a[i]);
	}
	cout << m << endl;
}

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

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

    int n,d;
    cin >> n >> d;
    
    int wid = d * 2 + 1;
    int mod = n % wid ? 1 : 0;
    
    cout << n / wid + mod << endl;
    
    return 0;
}

Measured memory_bytes: 256
def main():
  x,y,z,k=map(int,input().split())
  al=[int(i) for i in input().split()]
  bl=[int(i) for i in input().split()]
  cl=[int(i) for i in input().split()]
  lst=[i+j for i in al for j in bl]
  lst.sort(reverse=True)
  num=min(x*y,k)
  lst=lst[:num]
  L=[i+j for i in cl for j in lst]
  L.sort(reverse=True)
  for i in range(k):
    print(L[i])
if __name__=='__main__':
  main()

Measured memory_bytes: 168392
#include <iostream>

using namespace std;

inline int S(int a0, int d, int n){
    return n * (2 * a0 + (n-1) * d) / 2;
}

int solve(int n){
    int res = 0;
    for(int i=1; i<=n/2; ++i){
        int lo = 2, hi = 45;
        while(lo + 1 < hi){
            int mid = (lo + hi) >> 1;
            (S(i, 1, mid) <= n? lo: hi) = mid;
        }
        res += S(i, 1, lo) == n;
    }
    return res;
}

int main(){
    for(int n; cin >> n, n;)cout << solve(n) << '\n';
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstring>

using namespace std;

int main(int argc, char* argv[])
{
    bool cards[4][14];
    int n, rank;
    char suit;

    for (int s = 0; s < 4; s++) {
        for ( int r = 1; r <= 13; r++) {
            cards[s][r] = 0;
        }
    }

    cin >> n;

    for ( int i = 0; i < n; i++) {
        cin >> suit >> rank;
        if (suit == 'S') cards[0][rank] = 1;
        if (suit == 'H') cards[1][rank] = 1;
        if (suit == 'C') cards[2][rank] = 1;
        if (suit == 'D') cards[3][rank] = 1;
    }

    for (int s = 0; s< 4; s++) {
        for (int r = 1; r <= 13; r++) {
            if (cards[s][r]) continue;
            if (s == 0) suit = 'S';
            if (s == 1) suit = 'H';
            if (s == 2) suit = 'C';
            if (s == 3) suit = 'D';
            cout << suit << " " << r << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3108
n, k, c = gets.split.map(&:to_i)
s       = gets.chomp

limit_l = Array.new(200123,0)
limit_r = Array.new(200123,0)

bef = -2 * c - 1
cnt =  0
n.times do |i|
  break if cnt >= k
  if s[i] == 'o' && i - bef > c
    limit_l[cnt] = i + 1
    cnt += 1
    bef = i
  end
end

bef =  n + 2 * c + 1
cnt =  0
(n-1).downto(0) do |i|
  break if cnt >= k
  if s[i] == 'o' && bef - i > c
    limit_r[cnt] = i + 1
    cnt += 1
    bef = i
  end
end

k.times do |i|
  if limit_l[i] == limit_r[k-1-i] && limit_l[i] != 0
    puts limit_l[i]
  end
end

Measured memory_bytes: 6524
import math
Q = int(input())
lst = []
for i in range(Q):
    lst.append(list(map(int, input().split())))
for i in lst:
    if i[0] == i[1]:
        print(2*i[0] - 2)
    else:
        ans = math.floor((i[0]*i[1])**0.5)
        if ans**2 == i[0]*i[1]:
          print((ans-1)*2 - 1)
        elif ans * (ans+1) >= i[0]*i[1]:
          print(ans*2 - 2)
        else:
          print(ans*2 - 1)

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  string s; cin >> s;
  int maxcnt = 0;
  int cnt;
  for(int i = 0; i < s.size(); ++i) {
    cnt = 0;
    if(s[i] == 'A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T') {
      cnt++;
      for(int j = i + 1; j < s.size(); ++j) {
        if(s[j] == 'A' || s[j] == 'G' || s[j] == 'C' || s[j] == 'T') {
          cnt++;
        } else {
          break;
        }
      }
      maxcnt = max(maxcnt, cnt);
    }
  }
  cout << maxcnt << endl;

  return 0;
}


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

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

  int a = 0, num = 0;
  vector<char> c{'0', '1'};
  for (int i = 0; i < S.length(); i++) {
    if (S.at(i) == c.at(a)) {
      num++;
    }
    a = (a + 1) % 2;
  }

  if (num < S.length() - num) {
    cout << num << endl;
  }
  else {
    cout << S.length() - num << endl;
  }
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>

int main(void)
{
	long long int n;
	long long int *a;
	scanf("%lld", &n);
	a = (long long int *)malloc(sizeof(long long int)*(n+1));
	long long int i = 0;
	while (i < n)
	{
		scanf("%lld", &(a[i]));
		i++;
	}

	long long int money = 1000;
	long long int stock = 0;
	long long int tmp_m = 0;
	long long int tmp_s = 0;
	i = 0;
	while (i < n - 1)
	{
		//if (a[i] == a[i+1])
		if (a[i] > a[i+1])
		{
			money = money + stock * a[i];
			stock = 0;
		}
		if (a[i] < a[i+1])
		{
			stock = stock + (money / a[i]);
			money = money % a[i];
		}
		i++;
	}
	money = money + stock * a[i];
	printf("%lld\n",money);
}


Measured memory_bytes: 1728
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    bool pw[1001]={};
    for(int i=1;i<=34;i++){
        for(int j=2;j<=9;j++){
            if(pow(i,j)<=1000) pw[(int)pow(i,j)]=true;
        }
    }
    int X;
    cin >> X;
    while(true){
        if(pw[X]==true){
            cout << X << endl;
            break;
        }
        X--;
    }
}

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

const long long mod = 1000000007;
const int maxn = 3000006;

int k, n;
string s;
long long ans;
long long fact[maxn];

long long add_mod (long long a, long long b) {
	return (a + b) % mod;
}

long long sub_mod (long long a, long long b) {
	return (a + mod - b) % mod;
}

long long mul_mod (long long a, long long b) {
	return (a * b) % mod;
}

long long pow_mod (long long a, long long b) {
	long long res = 1, t = a;
	while (b) {
		if (b & 1)
			res = mul_mod(res, t);
		t = mul_mod(t, t);
		b >>= 1;
	}
	return res;
}

long long div_mod (long long a, long long b) {
	return mul_mod(a, pow_mod(b, mod - 2));
}

long long ncr_mod (long long a, long long b) {
	return div_mod(fact[a], mul_mod(fact[b], fact[a - b]));
}

long long ncr_rep_mod (long long a, long long b) {
	return ncr_mod(a + b - 1, b);
}

void precalc () {
	fact[1] = fact[0] = 1LL;
	for (long long i = 2; i < maxn; ++i)
		fact[i] = mul_mod(i, fact[i - 1]);
}

signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	precalc();
	
	cin >> k >> s;
	n = s.size();
	for (long long pos = n; pos <= n + k; ++pos) 
		ans = add_mod(ans, mul_mod(mul_mod(ncr_mod(pos - 1, n - 1), pow_mod(25, pos - n)), pow_mod(26, n + k - pos)));
	cout << ans << '\n';
}


Measured memory_bytes: 27676
#define _USE_MATH_DEFINES
#define INF 100000000

#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

static const double EPS = 1e-8;

const int tx[] = {0,1,0,-1};
const int ty[] = {1,0,-1,0};

char stage[20][20];

int main(){
	int m,n;
	while(~scanf("%d %d",&m,&n)){
		if(m==n && n==0) break;
		vector<int> t;
		vector<int> h;
		int sumt=0,sumh=0;
		for(int i=0;i<m;i++){
			int num;
			scanf("%d",&num);
			t.push_back(num);
			sumt+=num;
		}

		for(int i=0;i<n;i++){
			int num;
			scanf("%d",&num);
			h.push_back(num);
			sumh+=num;
		}

		P res = P(-1,-1);
		int minv = numeric_limits<int>::max();
		for(int i=0;i<t.size();i++){
			for(int j=0;j<h.size();j++){
				if(sumt - t[i] + h[j] == sumh - h[j] + t[i]){
					if(minv > h[j] + t[i]){
						res = P(t[i],h[j]);
						minv = t[i]+h[j];
					}
				}
			}
		}
		if(res.first==-1) printf("%d\n",-1);
		else printf("%d %d\n",res.first,res.second);
	}
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#include <complex>
#include <queue>
#include <stack>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
  int a,b;
  cin>>a>>b;
  if(a<13)b/=2;
  if(a<6)b=0;
  cout<<b<<endl;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
//#include <string>
//#include <set>
#define ll long long
using namespace std;

int main() 
{
    ll n, ans;
    cin >> n;
    vector<vector<ll>>  happy(n, vector<ll>(3));
    for(ll i = 0; i < n; i++)
        cin >> happy.at(i).at(0) >> happy.at(i).at(1) >> happy.at(i).at(2);
    
    vector<vector<ll>>  max_happy(n, vector<ll>(3, 0));
    for(ll i = 0; i < 3; i++) {
        max_happy.at(0).at(i) = happy.at(0).at(i);
    }

    for(ll i = 1; i < n; i++) {
        max_happy.at(i).at(0) = max(max_happy.at(i - 1).at(1) + happy.at(i).at(0), max_happy.at(i - 1).at(2) + happy.at(i).at(0));      
        max_happy.at(i).at(1) = max(max_happy.at(i - 1).at(0) + happy.at(i).at(1), max_happy.at(i - 1).at(2) + happy.at(i).at(1));     
        max_happy.at(i).at(2) = max(max_happy.at(i - 1).at(0) + happy.at(i).at(2), max_happy.at(i - 1).at(1) + happy.at(i).at(2));    
    }

    ans = max(max(max_happy.at(n - 1).at(0), max_happy.at(n - 1).at(1)), max_happy.at(n - 1).at(2));
    cout << ans << endl;
}

Measured memory_bytes: 11136
#include <iostream>
#include <stdlib.h>
#include <string>
#define rep(i, n) for(int i = 1; i < n; i++)

using namespace std;

int main(){
	int n;
	cin >> n;
	
	int ans = 0;
	
	rep(i, n+1){
		string num = to_string(i);
		if(num.size() % 2 != 0) ans++;
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 3752
#include <stdio.h>
int main(void){
	int n,m;
	int a[1000],b[1000];
	int i,j,k;
	int count1=0,count2=0;
	int temp;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d %d",&a[i],&b[i]);
		if(a[i]>=n){
			a[i]=b[i]=0;
			count1++;
		}
	}
	if(m-1>count1){
		for(i=1;i<=m;i++)b[i]=n-a[i];
		for(i=1;i<m;i++){
			for(j=i+1;j<=m;j++){
				if(b[i]>b[j]){
					temp=b[i];
					b[i]=b[j];
					b[j]=temp;
				}
			}
		}
		for(i=1;i<=m-count1-1;i++)count2+=b[i];
	}
	printf("%d\n",count2);
	return 0;
}


Measured memory_bytes: 1996
#include<bits/stdc++.h>
using namespace std;
#define li long long
#define gc getchar()
#define pc putchar
li read(){
	li x = 0;
	int y = 0,c = gc;
	while(!isdigit(c)){
		y = c;
		c = gc;
	}
	while(isdigit(c)){
		x = (x << 1) + (x << 3) + (c ^ '0');
		c = gc;
	}
	return y == '-' ? -x : x;
}
void print(li q){
	if(q < 0){
		pc('-');
		q = -q;
	}
	if(q >= 10) print(q / 10);
	pc(q % 10 + '0');
}
li n,a,b,k;
const int mo = 998244353;
li jc[300010],ny[300010];
li ksm(li q,li w){
	li as = 1;
	while(w){
		if(w & 1) as = as * q % mo;
		q = q * q % mo;
		w >>= 1;
	}
	return as;
}
li zh(li q,li w){
	if(q < w) return 0;
	if(q < 0 || w < 0) return 0;
	return jc[q] * ny[w] % mo * ny[q - w] % mo;
}
int main(){
	int i;
	li j;
	n = read();a = read();b = read();k = read();
	if((a + b) * n < k){
		pc('0');
		return 0;
	}
	if(!k){
		pc('1');
		return 0;
	}
	jc[0] = 1;
	for(i = 1;i <= n;++i) jc[i] = jc[i - 1] * i % mo;
	ny[n] = ksm(jc[n],mo - 2);
	for(i = n - 1;i >= 0;--i) ny[i] = ny[i + 1] * (i + 1) % mo;
	li as = 0;
	for(i = 0;i <= n;++i){
		j = k - a * i;
		if(j % b) continue;
		(as += zh(n,i) * zh(n,j / b)) %= mo;
	}
	print(as);
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <algorithm>
#define MN 200000
typedef long long LL;
int n,a[MN+5];
LL check(int b){
	LL ret=0;
	for(int i=1;i<=n;i++)
		ret+=std::abs(a[i]-b);
	return ret;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		a[i]-=i;
	}
	std::sort(a+1,a+1+n);
	int mid=(1+n)>>1;
	printf("%lld",std::min(check(a[mid]),check(a[mid+1])));
}

Measured memory_bytes: 896
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
    string s;
    cin >> s;
    string check[4] = {"dream", "dreamer", "erase", "eraser"};

    reverse(s.begin(), s.end());
    REP(i, 4) reverse(check[i].begin(), check[i].end());

    bool ans = true;
    for(int i = 0; i < s.size();){
        bool div = false;
        for(int j = 0; j < 4; ++j){
            string tmp = check[j];
            if(tmp == s.substr(i, tmp.size())){
                div = true;
                i += tmp.size();
            }
        }
        if(!div){
            ans = false;
            break;
        }
    }
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		StringBuilder cardset;
		int shufflecount;
		int h;
		final char END = '-';

		Scanner stdIn = new Scanner(System.in);

		while(true) {
			cardset = new StringBuilder(stdIn.next());
			if(cardset.charAt(0) == END) {
				break;
			}
			shufflecount = stdIn.nextInt();

			for(int i = 0; i < shufflecount; i++) {
				h = stdIn.nextInt();
				String s = cardset.substring(0, h);
				cardset.delete(0, h);
				cardset.append(s);
			}
			System.out.println(cardset);
		}
		stdIn.close();
	}
}

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

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

int main() {
	int n, k;
	int x[105];
	int ans = 0;
	cin >> n >> k;
	rep(i, n){
		cin >> x[i];
		ans += min(x[i], k-x[i]);
	}
	cout << ans * 2 << endl;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

   int N;
   cin>>N;
   vector<int>a(N);
   for(int i=0;i<N;i++)cin>>a[i];

   ll Max = 0;
   ll base;
   for(int i=0;i<N;i++){
      if(abs(Max) <= abs(a[i])){
         Max = a[i];
         base = i;
      }
   }

   for(int i=0;i<N;i++){
      a[i]+=Max;
   }

   //for(auto it:a)cout<<it<<endl;

   cout<<N-1+N-1<<endl;
   for(int i=0;i<N;i++){
      if(i==base)continue;
      cout<<base+1<<" "<<i+1<<endl;
   }

   if(Max>=0){
      for(int i=1;i<N;i++){
         cout<<i-1+1<<" "<<i+1<<endl;
         a[i]+=a[i-1];
      }
   }
   else{
      for(int i=N-1;i>=1;i--){
         cout<<i+1<<" "<<i-1+1<<endl;
         a[i-1]+=a[i];
      }
   }

   //cout<<endl;
   //for(auto it:a)cout<<it<<endl;

   return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main (){
	var takahashi, aoki, k int
	fmt.Scan(&takahashi, &aoki, &k)
	if k >= takahashi {
		aoki -= k-takahashi
		if aoki < 0 {
			aoki = 0
		}
		takahashi = 0
	} else if k < takahashi {
		takahashi = takahashi - k
	}
	fmt.Println(takahashi , aoki)
}





Measured memory_bytes: 512
from sys import stdin
readline = stdin.buffer.readline
read = stdin.buffer.read
def s_input(): return input().rstrip()
def i_input(): return int(input().rstrip())
def i_map(): return map(int, input().rstrip().split())
def i_list(): return list(i_map())

def main():
    ans = 0
    for s in s_input():
        if s == '1':
            ans += 1 
    print(ans)

if __name__ == "__main__":
    main()


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

int main(void){
    string s,ss;
    cin>>s>>ss;

    ll len1=s.size();
    ll len2=ss.size();
    int cnt=0;

    if(len1==len2){

        for(ll i=0; i<len1; i++){
            if(s[i]!=ss[i])
                cnt++;
                s[i]='0';
                ss[i]='0';
        }
        cout<<cnt<<'\n';
    }
}


Measured memory_bytes: 3856
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        
        vector<vector<LL>> dp;
        dp.assign(55, vector<LL>(35, 0));

        vector<vector<bool>> sche;
        sche.assign(55, vector<bool>(35, false));

        REP(i, n){
            int x; cin >> x;
            REP(j, x){
                int s; cin >> s;
                sche[i][s] = true;
            }
        }
        REP(i, n) dp[i][0] |= (1LL << i);
        FOR(i, 1, 31){
            REP(j, n){
                dp[j][i] |= dp[j][i-1];
                if(sche[j][i]) REP(k, n){
                    if(sche[k][i]) dp[k][i] |= dp[j][i-1];
                }
            }
        }
        int ans = INF;
        REP(i, 31) REP(j, n) if(dp[j][i] == ((1LL << n) - 1)) ans = min(ans, i);
        if(ans != INF) cout << ans << endl;
        else cout << -1 << endl;
        
    }
}



Measured memory_bytes: 3032
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

vector<lint> Divisor(lint n){
  vector<lint> result;
  for(lint i=1;i*i<=n;i++){
    if(n % i == 0) {
      result.push_back(i);
      if(i * i != n) result.push_back(n / i);
    }
  }
  return result;
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  lint n;
  cin>>n;
  lint result=Divisor(n-1).size()-1;
  vector<lint> divisor=Divisor(n);
  for(auto div:divisor){
    if(div==1) continue;
    lint val=n;

    while(val%div==0){
      val/=div;
    }
    if(val%div==1) result++;
  }
  cout<<result<<endl;

  return 0;
}




Measured memory_bytes: 384
//file_name:ABC79_C.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


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

    if(s[0]==s[1]&&s[1]==s[2]||s[1]==s[2]&&s[2]==s[3])yn;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
const int limit = 1e7;
vi lp,prime;
void linear_sieve()
{
	lp.assign(limit+1,0);
	for(int i=2;i<=limit;++i)
	{
		if(lp[i]==0)
		{
			lp[i] = i;
			prime.push_back(i);
		}
		for(int j=0;j<prime.size()&&prime[j]<=lp[i]&&i*prime[j]<=limit;++j)
		{
			lp[i*prime[j]] = prime[j];
		}
	}
}
int main()
{
	linear_sieve();
	int n,i,j;
	scanf("%d",&n);
	int d[n+1];
	for(i=0;i<=n;i++)	d[i]=1;
	for(i=1;i<=n;i++)
	{
		map<int,int> cnt;
		j = i;
		while(j!=1)
		{
			cnt[lp[j]]++;
			j/=lp[j];
		}
		for(auto j:cnt)		d[i]=d[i]*(j.second+1);
		cnt.clear();
	}
	ll ans = 0ll;
	for(i=1;i<=n;i++)
	{
		ans = ans + 1ll * i * d[i];
	}
	cout<<ans;
}


Measured memory_bytes: 84232
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
using namespace std;

const int INT__MAX = 2147483647;
const int MOD = 1000000007;
int main(){

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

	if (x < a&&a < b) {

		cout << "A" << endl;

	}
	else if (x < b&&b < a) {

		cout << "B" << endl;

	}
	else if (a < x&&x < b) {

		if (x - a > b - x)cout << "B" << endl;
		else cout << "A" << endl;

	}
	else if (a < b&&b < x) {

		cout << "B" << endl;

	}
	else if (b < x&&x < a) {

		if (x - b > a - x)cout << "A" << endl;
		else cout << "B" << endl;

	}
	else {

		cout << "A" << endl;

	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
ll n,a[205];
ll dp[205][205];
ll rec(ll i,ll j)
{
	if(i<=0)
		return j==0?0:-INF;
	if(dp[i][j]!=-1)
		return dp[i][j];
	ll an=rec(i-1,j+1);
	if(j)
		an=max(an,rec(i-1,j-1)+a[i]);
	return dp[i][j]=an;
}
int main()
{
	memset(dp,-1,sizeof dp);
	SPEED;
	cin>>n;
	n*=2;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	cout<<rec(n,0)<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>

typedef struct endPoint{
  double x;
  double y;
}endpoint;

void kock(int, endpoint, endpoint);

int main(){

  int n;
  endpoint p1, p2;

  p1.x = 0.0;
  p1.y = 0.0;
  p2.x = 100.0;
  p2.y = 0.0;

  scanf("%d",&n);

  printf("%.8f %.8f\n",p1.x,p1.y);

  kock(n,p1,p2);

  printf("%.8f %.8f\n",p2.x,p2.y);

  return 0;

}

void kock(int n, endpoint p1, endpoint p2){

  endpoint s,t,u;

  if( n==0 ) 
    return ;
  
  s.x = (2 * p1.x + 1 * p2.x) / 3.0;
  s.y = (2 * p1.y + 1 * p2.y) / 3.0;
  t.x = (1 * p1.x + 2 * p2.x) / 3.0;
  t.y = (1 * p1.y + 2 * p2.y) / 3.0;
  u.x = (t.x - s.x) * cos(M_PI/3) - (t.y - s.y) * sin(M_PI/3) + s.x;
  u.y = (t.x - s.x) * sin(M_PI/3) + (t.y - s.y) * cos(M_PI/3) + s.y;
 
  kock(n-1, p1, s);

  printf("%.8f %.8f\n", s.x, s.y);

  kock(n-1, s, u);

  printf("%.8f %.8f\n", u.x, u.y);

  kock(n-1, u, t);

  printf("%.8f %.8f\n", t.x, t.y);

  kock(n-1, t, p2);

}

Measured memory_bytes: 640
def resolve():
    M,D=map(int,input().split())
    count=0
    for j in range(1,M+1):
        for i in range(1,D+1):
            if i<10: continue
            s1=int(str(i)[0])
            s2=int(str(i)[1])
            if s1>1 and s2>1:
                if s1*s2==j:
                    count+=1
    print(count)
resolve()

Measured memory_bytes: 3064
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
		int c = int.Parse(input[2]);
		int ans = b / a;
		if (b / a > c) { ans = c; }
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int h,w;
  cin>>h>>w;
  vector<vector<char> >a(h);
  for(int i=0;i<h;i++)
  {
    a[i].resize(w);
    for(int j=0;j<w;j++)
    {
		cin>>a[i][j];
    }
  }
  vector<vector<int> >ans(h);
  for(int i=0;i<h;i++)
  {
    ans[i].resize(w);
    for(int j=0;j<w;j++)
    {
      if(i!=0 && j!=0)ans[i][j]=min(ans[i-1][j],ans[i][j-1]);
      else if(i==0 && j!=0)ans[i][j]=ans[i][j-1];
      else if(i!=0 && j==0)ans[i][j]=ans[i-1][j];
      
      if(a[i][j]=='#')
      {      
        if(i!=0 && j!=0)
        {
          //if(ans[i][j]==ans[i-1][j] && ans[i][j]==ans[i][j-1])
          if(ans[i][j]==ans[i-1][j] && a[i-1][j]=='#')continue;
          else if(ans[i][j]==ans[i][j-1] && a[i][j-1]=='#')continue;
          else 
          {
            ans[i][j]++;
          }
            
        }
        else if(i==0 && j!=0 && a[i][j-1]=='.')ans[i][j]++;
        else if(i!=0 && j==0 && a[i-1][j]=='.')ans[i][j]++;
        if(i==0 && j==0)ans[i][j]++;
      }
    }
  }
  cout<<ans[h-1][w-1]<<endl;
 /* for(int i=0;i<h;i++)
  {
    //a[i].resize(w);
    for(int j=0;j<w;j++)
    {
		cout<<ans[i][j]<<" ";
    }
    cout<<endl;
  }*/
  
  return 0;
}
   

Measured memory_bytes: 3692
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
  // read inputs
  int R, G, B, N;
  scanf("%d %d %d %d", &R, &G, &B, &N);

  // solve
  int ans = 0;
  for (int r = 0; r * R <= N; r++) {
    for (int g = 0; r * R + g * G <= N; g++) {
      const int remaining = N - r * R - g * G;
      if (remaining % B == 0) {
        ans++;
      }
    }
  }
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		Long N = scan.nextLong();
		Long K = scan.nextLong();

		Long  m = new Long(N % K);
		Long x = new Long(K - m);

		if(m.compareTo(x) == 1) {
			System.out.println(x);
		}else {
			System.out.println(m);
		}


	}
}

Measured memory_bytes: 35808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll x,n,ans,minDif=LLONG_MAX;
	cin>>x>>n;
	map<ll,bool>m;
	for (int i=0;i<n;i++)
	{
		ll tmp;
		cin>>tmp;
		m[tmp]=1;
	}
	for (int i=0;i<=101;i++)
	{
		if (!m[i])
		{
			ll tmpDif=abs(x-i);
			if (tmpDif<minDif)
			{
				ans=i;
				minDif=tmpDif;
			}
		}
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,x,c,d;
	cin>>x>>a>>b;
	if(a>=x){
		c=a-x;
	}
	if(a<x){
		c=x-a;
	}
	if(b>=x){
		d=b-x;
	}
	if(b<x){
		d=x-b;
	}
	if(c>d){
		cout<<'B';
	}
	if(d>c){
		cout<<'A';
	}
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let (n, m) = (sc.read(), sc.read());
    let a: Vec<Vec<i64>> = (0..n).map(|_| (0..m).map(|_| sc.read()).collect()).collect();
    let b: Vec<i64> = (0..m).map(|_| sc.read()).collect();
    for row in &a {
        println!("{}", row.iter().zip(b.iter()).map(|(a, b)| a * b).sum::<i64>());
    }
}



Measured memory_bytes: 5052