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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
const ul mod = 1000000007;

template <typename Tp, size_t Nb>
auto make_vector(std::vector<size_t> &sizes, Tp const &x) {
    if constexpr (Nb == 1) {
        return std::vector<Tp>(sizes[0], x);
    } else {
        size_t size = sizes[Nb - 1];
        sizes.pop_back();
        return std::vector(size, make_vector<Tp, Nb - 1>(sizes, x));
    }
}

template <typename Tp, size_t Nb>
auto make_vector(size_t const (&sizes)[Nb], Tp const &x = Tp()) {
    std::vector<size_t> s(Nb);
    for (size_t i = 0; i < Nb; ++i)
        s[i] = sizes[Nb - i - 1];
    return make_vector<Tp, Nb>(s, x);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) { cin >> a[i]; }

    vector<ll> b(n);
    iota(b.begin(), b.end(), 0);

    sort(b.begin(), b.end(),
         [&](const ll &x, const ll &y) { return a[x] > a[y]; });

    auto dp = make_vector({(size_t)n, (size_t)n + 1}, 0LL);
    rep(i, n) {
        ll active = a[b[i]], base = b[i];
        if (i == 0) {
            // move to right
            dp[0][0] = active * abs(base - (n - 1));
            // move to left
            dp[0][1] = active * abs(base - 0);
        } else {
            rep(j, i + 2) {
                if (j == 0) {
                    dp[i][j] =
                        dp[i - 1][j] + active * abs(base - (n - 1 - (i - j)));
                    continue;
                }
                ll left, right;
                left = dp[i - 1][j - 1] + active * abs(base - (j - 1));
                right = dp[i - 1][j] + active * abs(base - (n - 1 - (i - j)));
                dp[i][j] = max(left, right);
            }
        }
    }
    ll ans = 0;
    rep(i, n) { ans = max(ans, dp[n - 1][i]); }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 34616
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

// modulo integer
// M: modulo number
// * M < 2^31
// * M must be prime if you use division
template <int64_t M> class mint {
public:
  mint() : v(-1) {}
  mint(int n) : v(n % M) {}

  int64_t get() const { return v; }

  mint &operator+=(const mint &r) {
    v = (v + r.v) % M;
    return *this;
  }
  mint &operator-=(const mint &r) {
    v = (v - r.v + M) % M;
    return *this;
  }
  mint &operator*=(const mint &r) {
    v = (v * r.v) % M;
    return *this;
  }
  mint &operator/=(const mint &r) { return (*this) *= r.inv(); }

  mint pow(int r) const {
    mint k = *this, ret = 1;
    while (r > 0) {
      if (r % 2 != 0)
        ret *= k;
      r /= 2;
      k *= k;
    }
    return ret;
  }

  mint inv() const { return pow(M - 2); }

private:
  int64_t v;
};

template <int64_t M> inline mint<M> operator+(mint<M> l, const mint<M> &r) {
  return l += r;
}

template <int64_t M> inline mint<M> operator-(mint<M> l, const mint<M> &r) {
  return l -= r;
}

template <int64_t M> inline mint<M> operator*(mint<M> l, const mint<M> &r) {
  return l *= r;
}

template <int64_t M> inline mint<M> operator/(mint<M> l, const mint<M> &r) {
  return l /= r;
}

template <int64_t M> inline ostream &operator<<(ostream &os, const mint<M> &r) {
  return os << r.get();
}

typedef mint<1000000007> MINT;

bool erase(vector<int> &xs, int pos) {
  if (pos < 2)
    return true;

  for (int i = pos - 1; i - 1 >= 0; i--) {
    if (xs[i] - xs[i - 1] == 1) {
      xs[i - 1]--;
      if (xs[i - 1] <= 0)
        return false;

      int j = i - 1;
      while (j - 1 >= 0 && xs[j] - xs[j - 1] <= 0) {
        xs[j - 1]--;
        if (xs[j - 1] <= 0)
          return false;
        j--;
      }
    }
  }
  return true;
}

int main() {
  cin.tie(0);
  int n;
  cin >> n;

  vector<int> as(n);
  for (auto &a : as)
    cin >> a;

  MINT ans = 1;
  int cur = 0;
  for (int i = 0; i < n; i++) {
    while (cur < n - 1) {
      int t = cur - i + 1;
      if (as[cur] < t * 2 - 1) {
        break;
      }
      cur++;
    }

    // cout << i << ", " << cur << ": " << cur - i + 1 << endl;
    ans *= (cur - i + 1);
  }

  cout << ans << endl;

  return 0;

  /*
    vector<int> perm(n);
    for (int i = 0; i < n; i++)
      perm[i] = i;

    int ans = 0;
    do {
      auto tmp = as;
      bool ok = true;
      auto pm = perm;
      for (int i = 0; i < n; i++) {
        auto p = pm[i];
        if (!erase(tmp, p)) {
          ok = false;
          break;
        }
        //   tmp[perm[i]] = 0x7fffffff;
        for (int j = p; j + 1 < n; j++) {
          tmp[j] = tmp[j + 1];
        }
        for (int j = i + 1; j < n; j++) {
          if (pm[j] > p) {
            pm[j]--;
          }
        }
      }
      if (ok) {
        cout << "* ";
        for (auto &p : perm)
          cout << p + 1 << " ";
        cout << endl;
        ans++;
      }
    } while (next_permutation(perm.begin(), perm.end()));

    cout << ans << endl;

    return 0;
    */
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = pi * r * r;
        double length = 2 * pi * r;
        System.out.printf("%f %f", area, length);
    }
}


Measured memory_bytes: 28352
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10;
ll sum[maxn],ans,wdc;
int num[maxn],a[maxn];
int i,j,k,l,t,n,m,x,y;
void change(int l,int r,int v){
	sum[l]+=(ll)v;
	sum[r+1]-=(ll)v;
}
void modify(int l,int r,int v){
	num[l]+=v;
	num[r+1]-=v;
}
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,n) scanf("%d",&a[i]);
	fo(i,1,n-1){
		x=a[i];y=a[i+1];
		if (x==y) continue;
		if (x<y){
			change(1,x,y-x);
			change(y+1,m,y-x);
			change(x+1,y,y+1);
			modify(x+1,y,-1);
		}
		else{
			change(y+1,x,y+m-x);
			change(x+1,m,y+m+1);
			modify(x+1,m,-1);
			change(1,y,y+1);
			modify(1,y,-1);
		}
	}
	ans=100000000000000;
	fo(i,1,m){
		sum[i]+=sum[i-1];
		num[i]+=num[i-1];
		wdc=sum[i]+(ll)num[i]*i;
		ans=min(ans,wdc);
	}
	printf("%lld\n",ans);
}

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

using namespace std;
using int64 = long long;
//const int mod = 1e9 + 7;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  vector< int64 > A(N + 1);
  cin >> A;

  vector< int64 > nowLow(N + 1), nowHigh(N + 1);
  nowLow[N] = A[N];
  nowHigh[N] = A[N];
  for(int i = N - 1; i >= 0; i--) {
    nowLow[i] = (nowLow[i + 1] + 1) / 2;
    nowHigh[i] = nowHigh[i + 1];
    nowLow[i] += A[i];
    nowHigh[i] += A[i];
  }

  int64 ret = 0, now = 1;
  for(int i = 0; i <= N; i++) {
    chmin(now, nowHigh[i]);
    if(nowLow[i] <= now) {
      ret += now;
      now -= A[i];
      now *= 2;
    } else {
      cout << -1 << "\n";
      return 0;
    }
  }
  if(now == 0) {
    cout << ret << "\n";
  } else {
    cout << -1 << "\n";
  }
}

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

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		int x = sc.nextInt();
		int[] vals = new int[N];
		for (int i = 0; i < vals.length; i++) {
			vals[i] = sc.nextInt();
		}
		Arrays.sort(vals);
		int ans = 0;
		for (int i = 0; i < N; i++) {
			if (x >= vals[i] && ( i + 1 < N || x == vals[i])) {
				ans++;
				x -= vals[i];
			}
		}
		out.println(ans);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class DPairs {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N, K;
        cin >> N >> K;
        vector<int> A(N);
        REP(i, N) {
            cin >> A[i];
        }
        sort(A.begin(), A.end());

        int ng = -INF;
        int ok = INF;
        while (ok - ng > 1) {
            int x = (ok + ng) / 2;
            int num = 0;
            int xnum = 0;
            REP(i, N) {
                if (A[i] * A[i] <= x) {
                    xnum++;
                }
                if (A[i] > 0) {
                    int b = x / A[i];
                    if (x < 0 && x % A[i] != 0) b--;
                    num += upper_bound(A.begin(), A.end(), b) - A.begin();
                } else if (A[i] == 0) {
                    if (x >= 0) {
                        num += N;
                    }
                } else {
                    int b = x / A[i];
                    if (x < 0 && x % A[i] != 0) b++;
                    num += N - (lower_bound(A.begin(), A.end(), b) - A.begin());
                }
            }
            num -= xnum;
            num /= 2;
            if (num < K) {
                ng = x;
            } else {
                ok = x;
            }
        }
        cout << ok << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DPairs solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll a[5];
  for(int i=0;i<5;++i) a[i] = 0;
  string tmp;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    if(tmp[0]=='M') a[0]++;
    if(tmp[0]=='A') a[1]++;
    if(tmp[0]=='R') a[2]++;
    if(tmp[0]=='C') a[3]++;
    if(tmp[0]=='H') a[4]++;
  }
  ll ans = 0;
  for(int i=0;i<5;++i) {
    for(int j=i+1;j<5;++j) {
      for(int k=j+1;k<5;++k) {
        ans += a[i]*a[j]*a[k];
      }
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3596
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,a[100111];
int main()
{
	geti(n);
	for(int i=1;i<=n;i++)geti(a[i]);
	ll ans=0,sum=0;
	for(int i=1;i<=n+1;i++)
	{
		sum+=a[i];
		if(a[i]==0)
		{
			ans+=sum/2;
			sum=0;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 768
#[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 main() {
    input! {
        n: usize,
        s: chars,
    }
    let mut result = 0;
    for i in 2..n {
        if s[i - 2] == 'A' && s[i - 1] == 'B' && s[i] == 'C' {
            result += 1;
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = 1000000007;

LL N,M,S;
int a,b,c,d;
string s;
int main(){
    cin>>s;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]==s[i+1]){
            cout<<"Bad";
            return 0;
        }
    }
    cout<<"Good";
    return 0;
}


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

import static java.lang.Integer.parseInt;

/**
 * Modular Query
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int N = parseInt(line.substring(0, line.indexOf(' ')));
			int Q = parseInt(line.substring(line.indexOf(' ') + 1));
			boolean[] cs = new boolean[300001];
			int max = 0;

			StringTokenizer st = new StringTokenizer(br.readLine());
			while (st.hasMoreTokens()) {
				int c = parseInt(st.nextToken());
				cs[c] = true;
				max = Math.max(max, c);
			}

			for (int i = 0; i < Q; i++) {
				int q = parseInt(br.readLine());
				int j = q - 1;
				found:
				for (; j >= 1; j--) {
					for (int k = j; k <= max; k += q) {
						if (cs[k]) break found;
					}
				}
				System.out.println(j);
			}
		}
	}
}

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

int main()
{
    string s;
    long long n, z=0, r = 0, g = 0, b = 0;
    cin >> n;
    cin >> s;
    for (long long i = 0; i < n; i++)
    {
        if (s[i] == 'R')
        {
            z+=g*b;
            r++;
        }
        if (s[i] == 'G')
        {
            z+=r*b;
            g++;
        }
        if (s[i] == 'B')
        {
            z+=r*g;
            b++;
        }
    }
        for (long long o = 3; o-1 < n; o += 2) {
      for (long long i = o-1; i < n; i++){
        if (s[i] != s[i-o+1] && s[i-o+1] != s[i-o/2] && s[i-o/2] !=s[i])
          z--;
        }
    }
    cout<<z<<endl;
    return 0;
}

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

using namespace std;
int main () {
  string s;
  cin >> s;
  if (s == "Sunny") {
    cout << "Cloudy" << "\n";
  }else if (s == "Cloudy") {
    cout << "Rainy" << "\n";
  }else {
    cout << "Sunny" << "\n";
  }
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define PI (acos(-1))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define MAXN 1123456
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

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

  int k, n;
  cin >> k >> n;

  vi a(n);
  rep(i,0,n) cin >> a[i];
  sort(all(a));

  int mx = 0;
  rep(i,1,n) {
    mx=max(mx,a[i]-a[i-1]);
  }
  mx=max(mx,a[0]+k-a[n-1]);
  cout << k-mx << endl;
}

Measured memory_bytes: 1792
import sys
import math
import numpy as np
bl = np.searchsorted

N=int(input())
a=np.int32(input().split())
b=np.int32(input().split())
b.sort()
q=max(a+[b[-1]])
if q==0: print(0),sys.exit()

p=math.ceil( math.log(q,2) )+1


ans=0
for i in range(p,-1,-1):
    low=2**i
    ai=a % (2*low)
    bi=b % (2*low)
    bi.sort()
    bi = np.hstack((bi - 2*low, bi))
    tmp=0
    left1 = bl(bi, low - ai)
    right1 = bl(bi, 2*low - ai)   
    if np.sum(-left1 + right1) % 2: ans+=low

print(ans)

Measured memory_bytes: 35884
n = int(input())
words = []
won = True
for i in range(n):
    new_word = input()
    if i > 0 and won:
        if new_word in words or new_word[0] != words[i-1][len(words[i-1])-1]:
            won = False
    words.append(new_word)

if won:
    print("Yes")
else:
    print("No")


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

int main() {
  int N;
  cin >> N;
  uint64_t l0,l1,ans;
  l0=2;
  l1=1;
  ans=1;
  for (int i=0;i<N-1;i++){
      ans=l0+l1;
      l0=l1;
      l1=ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
using namespace std;
int main()
{
    int n,m,sum=0;
    cin>>n>>m;
    int arr[m];
    for (int i = 0; i < m; i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    if(sum>n)
    cout<<"-1";
    else
    cout<<n-sum;
    return 0;
}

Measured memory_bytes: 3636
n=int(input())
a,b=0,0
for i in range(1,n+1):
    if n%i==0:
        a=i
        b=n//i
    if i>n//i:
        break

alog,blog=1,1
i=0
while 1:
    a=a//10
    if a==0:
        break
    alog+=1

while 1:
    b=b//10
    if b==0:
        break
    blog+=1

print(max(alog,blog))

Measured memory_bytes: 39152
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	int i;
	vector<LL> A(N),B(N);
	for (i=0;i<N;i++){
		cin>>A[i];
		B[i]=A[i];
	}
	int l=N/2-1;
	sort(B.begin(),B.end(),greater<LL>());
	int j=0;
	for (i=0;i<N;i++){
		if (B[l]>A[i]){
			cout<<B[l]<<endl;
		}else{
			cout<<B[l+1]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

int main(){

  string t;
  cin >> t;


  for(int i=0;i<t.size();i++){
    if(t[i]=='?'){
      t[i]='D';
    }
  }

  int c=0;

  if(t[0]=='D')c++;
  for(int i=1;i<t.size();i++){
    if(t[i]=='D')c++;
    if(t[i-1]=='P' && t[i]=='D')c++;
  }
  for(int i=0;i<t.size();i++){
    cout << t[i];
  }
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

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

	sort(s.begin(),s.end());
	rep(i,1,s.size()){
		if(s[i-1] == s[i]){
			printf("no\n");
			return 0;
		}
	}
	printf("yes\n");
	
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int main(){
	int H,W;
	while(cin>>H>>W,H||W){
		char board[120][120];
		for(int i =0; i < H;i++){
			for(int j = 0;j < W;j++){
				cin>>board[i][j];
			}
		}
		std::vector<pii> v;
		int y = 0;
		int x = 0;
		int cnt = 0;
		bool flag =true;
		while(1){
			if(cnt>=1000000){
				flag =false;
				break;
			}
			cnt++;
			if(board[y][x]=='>'){
				x++;
			}else if(board[y][x]=='<'){
				x--;
			}else if(board[y][x]=='^'){
				y--;
			}else if(board[y][x]=='v'){
				y++;
			}else{
				break;
			}
		}
		if(!flag)cout <<"LOOP"<<endl;
		else cout <<x<<" "<<y<<endl;
	}
	return 0;
}

Measured memory_bytes: 1172
import sys
input = sys.stdin.readline

'''

'''

s = input().rstrip()

if s == "MON": print(6)
elif s == "SAT": print(1)
elif s == "FRI": print(2)
elif s == "THU": print(3)
elif s == "WED": print(4)
elif s == "TUE": print(5)
else:
    print(7)

Measured memory_bytes: 38256
n = int(input())
l = list(int(x) for x in input().split())
a = []
for i in l:
    if i % 2 == 0:
        a.append(i)
x = [i % 3 == 0 or i % 5 == 0 for i in a]

if len(a) == sum(x):
    print('APPROVED')
elif len(a) == 0:
    print('DENIED')
else:
    print('DENIED')

Measured memory_bytes: 3064
import numpy as np
S=input();T=S[::-1];a=[];c=0
for t in T:
    if t==">":
        c+=1
    else:
        c=0
    a.append(c)
A=np.array(a[::-1]+[0])
b=[];c=0
for s in S:
    if s=="<":
        c+=1
    else:
        c=0
    b.append(c)
B=np.array([0]+b)
print(np.maximum(A,B).sum())

Measured memory_bytes: 48404
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Console.WriteLine(ri() <= 999 ? "ABC" : "ABD");
	}

	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,k,minim;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>k;
    minim=n%k;
    n=n%k;
    minim=min(minim,k-n);
    cout<<minim;
    return 0;
}


Measured memory_bytes: 256
#include "stdio.h"

int main(){
	
	int n,m,a[100][100],b[100],i,j,x;
	scanf("%d%d", &n, &m);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d", &a[i][j]);
		}
	}
	for(j=0;j<m;j++){
		scanf("%d", &b[j]);
	}
	for(i=0;i<n;i++){
		x=0;
		for (j=0; j<m; j++){
			x += a[i][j] * b[j];			
		}
		printf("%d\n", x);
	}
	return 0;
}

Measured memory_bytes: 636
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353




def get_divisors(n):
    """
    n の約数をリストで返す
    :param int n:
    :rtype: list of int
    """
    ret = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret


n = int(sys.stdin.buffer.readline())
ans = 0
for i in range(1, n +1):
    ans +=i& 1 and len(get_divisors(i)) == 8
print(ans)


Measured memory_bytes: 14036
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int max=0;
    for(int i=0;i<s.size();i++){
        int lo=0;
        int so=i;
        while(1){
            if(s[so]=='A'||s[so]=='C'||s[so]=='G'||s[so]=='T'){
                lo++;
                so++;
            }
            else if(so<=s.size())break;
            else{
                break;
            }
        }
        if(max<lo)max=lo;
    }
    cout << max << endl;
 }


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int main()
{
  char n[16], m[16];
  scanf("%s", n);
  scanf("%s", m);

  for(int i = 0; i < strlen(n); i++){
    if(n[i] != m[i]){
      printf("No\n");
      return 0;
    }
  }
  if(strlen(n) + 1 == strlen(m)){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,j,b,e; 
	string a;
	cin>>a;
	for(i=0;i<a.size();i++){
		if(a[i]=='A'){
			b=i;
			break;
		}
	}
	for(i=a.size()-1;i>=0;i--){
		if(a[i]=='Z'){
			e=i;
			break;
		}
	}
	cout<<e-b+1<<endl;
}

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

int main() {
	int a = 0, b = 0;
	cin >> a;
	cin >> b;
	if (a > b) {
		cout <<"a > b"<< endl;
	}

	else if (a < b) {
		cout << "a < b" << endl;
	}

	else if (a == b) {
		cout << "a == b" << endl;
	}

	

	return 0;
}

Measured memory_bytes: 3100
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let x = read::<i64>();
    let ans = 360 / gcd(x, 360);
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}


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

int main(){
    int a, b;
    scanf("%d%d", &a, &b);
    int sum, sub, mul;
    sum = a+b;
    sub = a-b;
    mul = a*b;
    
//     printf("%d %d %d\n", sum, sub, mul);
    
    int max=sum;
    if(sub>max)
        max=sub;
    
    if(mul>max)
        max=mul;
    
    printf("%d\n", max);
    
    exit(EXIT_SUCCESS);
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i,k,n) for(int i = k; i < n; i++)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define argmax max_element
#define argmin min_element
#define ALL(x) (x).begin(), (x).end()

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

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int dx8[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

template<class T = ll> T in() {
    T _in;
    cin >> _in;
    return _in;
}

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

    int N;
    cin >> N;
    ll a[10000];
    rep(i, N) {
      cin >> a[i];
    }

    ll ans = 0;
    rep(i, N) {
      while(a[i]%2 == 0) {
        a[i] = a[i] / 2;
        ans++;
      }
    }

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


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

int main(int argc, char *argv[]){
  string S;
  cin>>S;
  for(int i=S.size()-1; i>=0; ){
    string T="";
    for(int j=i,k=0; k<7; k++,j--){
      T+=S[j];
      
      if(T=="esare"||T=="maerd"){
       
	i-=5;
	break;
      }
      else if(T=="resare"){
    
	i-=6;
	break;
      }
      else if(T=="remaerd"){
	i-=7;
	break;
      }
      else if(k==6||j==0){
	cout<<"NO"<<endl;
	return 0;
      }
    }
  }
  cout<<"YES"<<endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int d[210][210];

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, R;
    cin >> N >> M >> R;
    int r[10];
    rep(i, R) cin >> r[i];
    rep(i, R) r[i]--;
    sort(r, r + R);
    rep(i, N) rep(j, N) d[i][j] = INF;
    rep(i, M) {
        int A, B, C;
        cin >> A >> B >> C;
        A--; B--;
        d[A][B] = C;
        d[B][A] = C;
    }
    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    int ans = INF2;
    do {
        int tmp = 0;
        rep(i, R - 1) tmp += d[r[i]][r[i + 1]];
        ans = min(ans, tmp);
    }while(next_permutation(r, r + R));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列
using namespace std;
typedef long long ll;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素
signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N, K;
    cin >> N >> K;

    vector<int> A(N);
    REP(i, N)
    {
        cin >> A[i];
    }

    ll Q = (N - 1) / (K - 1);
    ll R = (N - 1) % (K - 1);

    ll ans = (R == 0 ? Q : Q + 1);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3716
import itertools
N,M,Q = map(int, input().split())
a = itertools.combinations_with_replacement([i for i in range(1,M+1)], N)
abcdQ = [list(map(int, input().split())) for i in range(Q)]
maxSumD = 0
for A in a:
  sumD = 0
  for abcd in abcdQ:
    if A[abcd[1]-1]-A[abcd[0]-1] == abcd[2]:
      sumD += abcd[3]
  maxSumD = max(maxSumD, sumD)
  
print(maxSumD)

Measured memory_bytes: 9216
#include <iostream>
//#include <iomanip>

using namespace std;
//#define

int main() {
	int h, w;

	while(1){
		cin >> h >> w;
		if(h==0 && w==0) break;

		for(int i=0;i<h;i++){
			for(int k=0;k<w;k++){
				cout << '#';
			}
			cout << "\n";
		}
		cout << "\n";
	}
	return 0;
}

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

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

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

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

    int n, k;
    cin >> n >> k;
    int bound = (n - 1) * (n - 2) / 2;
    if(k > bound){
        cout << -1 << endl;
        return 0;
    }
    int rest = bound - k;
    int ans = (n - 1) + rest;
    cout << ans << '\n';
    for(int i = 0; i < n - 1; ++i){
        cout << 1 << ' ' << i + 2 << '\n';
    }
    int cur = 2;
    int add = 0;
    while(rest > 0){
        if(cur + ++add > n){
            ++cur;
            add = 1;
        }
        cout << cur << ' ' << cur + add << '\n';
        --rest;
    }
}

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr ll mo2 = 998244353;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll a,b,n;
    cin>>a>>b>>n;
    if(n < b){
        cout << floor(a*n/b) - a*floor(n/b) << endl;
    }
    else {
        cout << floor(a*(b-1)/b) - a * floor((b-1)/b) << endl;
    }
    return 0;
}

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

#define rep(i,n) for(int (i) = 0;i < (int)(n);(i)++)
int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[n-i-1];
    rep(i,n){ 
        cout << a[i];
        if(i != n-1) cout << " ";
    }
    cout << endl;
}



Measured memory_bytes: 3096
program main
	implicit none
    character(3)::s
    integer::a(7)=(/7,6,5,4,3,2,1/)
    read(*,*)s
    if(s=='SUN')then
    	write(*,*)7
    else if(s=='MON')then
    	write(*,*)6
    else if(s=='TUE')then
    	write(*,*) 5
    else if(s=='WED')then
    	write(*,*) 4
    else if(s=='THU')then
    	write(*,*) 3
    else if(s=='FRI')then
    	write(*,*) 2
    else 
    	write(*,*) 1
    end if
    stop
end program main

Measured memory_bytes: 2856
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define print(x) cerr <<"\033[1;33m" << x << "\033[0m" << '\n'
#define int long long
#define LL __int128_t
const int xx = 2e5;
const int MOD = 1e9 + 7;
map<int,int>dp;
int cal(int x){
    if(x == 0) return 0;
    if(x == 1) return 1;
    if(dp[x]) return dp[x];

    return dp[x] = 1 + cal(x/2) + cal(x/2);
}
signed main(){
    int H;
    dp[0] = 0;
    dp[1] = 1;
    cin >> H;

    int ans = cal(H);
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#define N 1300000
using namespace std;
int start(int);
int goal(int);
int sosu[N];
int main(){
  int i,j,n,s,g;
  for(i=0;i<N;i++) sosu[i]=1;
  sosu[0]=0;
  sosu[1]=0;
  for(i=0;i<N/2;i++){
    if(sosu[i]==1){
      for(j=i*2;j<N;j+=i){
	sosu[j]=0;
      }
    }
  }
  while(1){
    cin >> n;
    if(n==0) break;
    if(sosu[n]!=1){
      s=start(n);
      g=goal(n);
      cout << g-s << endl;
    }
    else cout << 0 << endl;
  }
  return 0;
}
int start(int n){
  int i,result;
  if(n%2==0) n--;
  else n-=2;
  for(i=n;i>=2;i-=2){
    if(sosu[i]==1){
      result=i;
      break;
    }
  }
  return result;
}
int goal(int n){
  int i,result;
  if(n%2==0) n++;
  else n+=2;
  for(i=n;i<N;i+=2){
    if(sosu[i]==1){
      result=i;
      break;
    }
  }
  return result;
}

Measured memory_bytes: 6232
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;
using System.Text;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var a = consoleReader.Int;
            var b = consoleReader.Int;
            var c = b - a;
            return c * (c - 1) / 2 - a;
        }
        struct Cake
        {
            public long x; public long y; public long z;
            public static Cake operator +(Cake a, Cake b) => new Cake { x = a.x + b.x, y = a.y + b.y, z = a.z + b.z };
            public long Abs => Math.Abs(x) + Math.Abs(y) + Math.Abs(z);
        }

        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader
    {
        private string[] line = Array.Empty<string>();
        private int linePosition;
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                if (linePosition >= line.Length)
                {
                    linePosition = 0;
                    line = textReader.ReadLine().Split();
                }
                return line[linePosition++];
            }
        }
        public class SplitLine
        {
            private string[] splited;
            public SplitLine(ConsoleReader cr) { splited = cr.textReader.ReadLine().Split(); }
            public int[] Int => String.Select(x => int.Parse(x)).ToArray();
            public long[] Long => String.Select(x => long.Parse(x)).ToArray();
            public double[] Double => String.Select(x => double.Parse(x)).ToArray();
            public string[] String => splited;
        }
        public SplitLine Split => new SplitLine(this);
        public class RepeatReader
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerable<T> Select<T>(Func<ConsoleReader, T> func) { for (int i = 0; i < count; i++) yield return func(cr); }
            public IEnumerable<string> String { get { for (int i = 0; i < count; i++) yield return cr.String; } }
            public IEnumerable<int> Int { get { for (int i = 0; i < count; i++) yield return cr.Int; } }
            public IEnumerable<double> Double { get { for (int i = 0; i < count; i++) yield return cr.Double; } }
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	int N;
	cin >> N;
	vector<vector<pair<int, int>>> As;

	rep(i, N) {
		int a;
		cin >> a;
		vector<pair<int, int>> xys(a);
		rep(j, a) {
			cin >> xys[j].first >> xys[j].second;
		}

		As.push_back(xys);
	}

	int ans = 0;

	for(int i = 0; i<pow(2, N); i++) {
		// i が成立するか調べる
		bool OK = true;
		for(int j=0; j<N; j++) {

			if((i>>j)%2 == 1) { // As[j]の証言を確認
				for(int k=0; k<As[j].size(); k++){
					if( (i>>(As[j][k].first - 1)) % 2 != As[j][k].second) {
						OK = false;
						j = N;
						break;
					}
				}
			}

		}

		if(OK) {
			int cnt = 0;
			int tmp = i;
			while(tmp>0) {
				cnt += (tmp%2);
				tmp = tmp >> 1;
			}
			//cout << i << ' ' << cnt << endl;
			ans = max(ans, cnt);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
A,B,C,x,y = map(int,input().split())
ans = 0
if A+B > 2*C:
    ans += min(x,y)*C*2
else:
    ans += x*A + y*B
    print(ans)
    exit()    

if x >= y:
    x -= y
    y = 0
    if A <2*C:
        ans += x*A
    else:
        ans += x*2*C    
else:
    y -= x
    x = 0
    if B < 2*C:
        ans += y*B
    else:
        ans += y*2*C
print(ans) 

Measured memory_bytes: 9160
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, p; cin >> n >> p;
  string s; cin >> s;
  
  if (p == 2 || p == 5) {
    ll ans = 0;
    for (int i = 0; i < n; i++) {
      int d = s[i] - '0';
      if (d % p == 0) {
        ans += i + 1;
      }
    }
    cout << ans << endl;
    return 0;
  }
  
  auto power = [&](ll a, ll b) -> ll {
    ll x = 1, y = a;
    while (b > 0) {
      if (b % 2) x = (x * y) % p;
      y = (y * y) % p;
      b /= 2;
    }
    return x % p;
  };
  
  vector<ll> count(p, 0);
  count[0] = 1;
  int res = 0;
  for (int i = 0; i < n; i++) {
    res = (10 * res + s[i] - '0') % p;
    int idx = (res * power(10, n - 1 - i)) % p;
    count[idx]++;
  }
  
  ll ans = 0;
  for (int i = 0; i < p; i++) {
    ans += (count[i] * (count[i] - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}
    
    

Measured memory_bytes: 720