akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
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...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;

vector<ll> a;
vector<ll> f;

ll n,k;
bool solve(ll mid){
    ll sum = 0;
    rep(i, n){
        if(a[i] > mid / f[i]) sum += a[i] - mid / f[i];
    }
    return sum <= k;
}

ll binary_search(){
  ll ok = LLINF;
  ll ng = -1;
  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(solve(mid)){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  return ok;
}

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cin >> n >> k;
    a.resize(n);
    f.resize(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(all(a));
    sort(rall(f));
    ll ans = binary_search();
    print(ans);
    

}



Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

// n回の行動で相手を倒しきれるか
bool canDelete(ll n, vector<ll> &h, ll A, ll B){

    ll cnt = 0; // 必要なA攻撃の回数
    for(int i = 0; i < h.size(); i++){
        ll rem = h[i] - B * n;
        if(rem > 0){
            cnt += (rem + A - B - 1) / (A - B)  ;
        }
    }
    if(cnt <= n) return true;
    else return false;
}

int main(){

    ll N, A, B;
    cin >> N >> A >> B;

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

    ll left  = 0;
    ll right = 1000000000;
    while(right - left != 1){
        ll mid = (left + right) / 2;
        bool flag = canDelete(mid, h , A, B);
        if(flag){
            right = mid;
        }
        else{
            left = mid;
        }
    }
    cout << right << endl;


}

Measured memory_bytes: 1024
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            // Console.WriteLine("Hello World!");
            var pqr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(pqr.Sum() - pqr.Max());
        }
    }
}


Measured memory_bytes: 13396
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N,a,x,y; cin >> N;
  ll mat[N][N];
  for (ll i = 0; i < N; ++i) for (ll j = 0; j < N; ++j) mat[i][j] = -1;
  for (ll i = 0; i < N; ++i) {
    cin >> a;
    for (ll j = 0; j < a; ++j) {
      cin >> x >> y;
      mat[i][x-1] = y;
    }
  }
  int honest_num = 0;
  for (ll i = (1<<N)-1; i >= 0; --i) {
    bool is_consistent = true;
    for (ll j = 0; j < N; ++j) {
      if (i>>j&1) {
        for (ll k = 0; k < N; ++k) 
          if (mat[j][k] != -1 && mat[j][k] != (i>>k&1)) is_consistent = false;
      }
      if (!is_consistent) break;
    }
    if (is_consistent) honest_num = max(honest_num,__builtin_popcount(i));
  }
  cout << honest_num << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define vll vector<long long>
#define mll map<long long,long long>
#define pb push_back
typedef  long long ll;
typedef long double ld;
long double pi=3.14159265358979323846;

vll al[500005];
ll vis[500005],color[500005],I[101][101];

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

bool isPrime(int n)
{
    if (n<=1) return false; 
    if (n<=3) return true; 
    if (n%2==0||n%3==0) return false; 
    for (int i=5;i*i<=n;i=i+6) if (n%i==0||n%(i+2)==0) return false; 
    return true; 
}

ll bpow(ll n, ll po)
{
	ll res=1;
	while(po>0)
	{
		if(po%2)
		{
			res*=n;
			po--;
		}
		else
		{
			n*=n;
			po/=2;
		}
	}
	return res;
}

ll binpow(ll n, ll po, ll mod)
{
	ll res=1;
	while(po>0)
	{
		if(po%2)
		{
			res=(res*n)%mod;
			po--;
		}
		else
		{
			n=(n*n)%mod;
			po/=2;
		}
	}
	return res;
}

ll swap(ll a, ll b)
{
	a=a+b;
	b=a-b;
	a=a-b;
}

ll fact(ll n) { 
   if ((n==0)||(n==1))
      return 1;
   else
      return n*fact(n-1);
}

ll C(ll n, ll r) {
    if(r > n - r) r = n - r; 
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
        ans=ans%1000000007;
    }

    return ans;
}

//bool bipartite_dfs(ll node, ll flag)
//{
//	vis[node]=1;
//	ll cflag=flag;
//	color[node]=cflag;
//	for(ll child : al[node])
//	{
//		if(!vis[child])
//		{
//			bool n=bipartite_dfs(child,1-cflag);
//			if(n==false) return false;
//		}
//		else if(color[child]==color[node]) return false;
//	}
//	return true;
//}

void mmul(ll A[][101], ll B[][101], ll dim)
{
	ll res[dim][dim];
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++)
	{
		res[i][j]=0;
		for(ll k=0;k<dim;k++) res[i][j]=(res[i][j]+A[i][k]*B[k][j])%1000000007;
	}
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++) A[i][j]=res[i][j];
}

void mpow(ll A[][101],ll dim, ll po)
{
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++)
	{
		if(i==j) I[i][j]=1;
		else I[i][j]=0;
	}
	while(po>0)
	{
		if(po%2==1)
		{
			mmul(I,A,dim);
			po--;
		}
		else
		{
			mmul(A,A,dim);
			po/=2;
		}
	}
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++) A[i][j]=I[i][j];
}


int main(){
   ios_base::sync_with_stdio(false); 
   cin.tie(NULL);
   cout.tie(NULL);
   ll a;
   ld b;
   cin>>a;
   cin>>b;
   b*=100;
   ll ans=a*round(b);
   ans/=100;
   cout<<ans;
   return 0;
}

Measured memory_bytes: 15468
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;

int n;
int a[3];
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    int tmp;cin>>tmp;
    if(tmp % 4 == 0){
      a[2]++;
    } else if(tmp % 2 == 0){
      a[1]++;
    } else {
      a[0]++;
    }
  }

  if(a[0] > a[2]){
    if(abs(a[0]-a[2]) == 1){
      if(a[1] == 0) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    } else {
      cout<<"No"<<endl;
    }
  } else {
    cout<<"Yes"<<endl;
  }
  return 0;
}

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

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<i64> a(n), b(n);
  i64 asum = 0, bsum = 0;
  REP(i, n) {
    cin >> a[i];
    asum += a[i];
  }
  REP(i, n) {
    cin >> b[i];
    bsum += b[i];
  }
  auto check = [&]() -> bool {
    if (asum > bsum) return false;
    i64 count = bsum - asum;
    DEBUG(count, bsum, asum);
    i64 ca = 0, cb = 0;
    REP(i, n) {
      if (a[i] < b[i]) {
        ca += (b[i] - a[i] + 1) / 2;
        if (a[i] % 2 != b[i] % 2) ++cb;
      }
      if (a[i] > b[i]) {
        cb += a[i] - b[i];
      }
    }
    return ca <= count && cb <= count;
    /*
    int ai = 0, bi = 0;
    for (; ai < n;) {
      if (a[ai] >= b[ai]) {
        ++ai;
        continue;
      }
      DEBUG(ai, a[ai], b[ai]);
      if (a[ai] % 2 != b[ai] % 2) {
        a[ai] += 2;
        b[ai]++;
        --count;
        DEBUG(count, a[ai], b[ai]);
        if (count < 0) return false;
      }
      i64 da = b[ai] - a[ai];
      assert(da % 2 == 0);
      da /= 2;
      if (da == 0) {
        ++ai;
        continue;
      }
      for (; bi < n; ++bi) {
        if (a[bi] > b[bi]) break;
      }
      if (bi == n) return false;
      i64 db = a[bi] - b[bi];
      i64 dm = min(da, db);
      count -= dm;
      DEBUG(count, ai, bi, dm);
      if (count < 0) return false;
      a[ai] += 2 * dm;
      b[bi] += dm;
      if (a[ai] == b[ai]) ++ai;
      if (a[bi] == b[bi]) ++bi;
    }
    */
    return true;
  };

  cout << (check() ? "Yes\n" : "No\n");
}

Measured memory_bytes: 3736
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;
int main() {
	int dp[3][105] = { 0 };
	int n;
	cin >> n;
	for (int i = 1; i <= 2; i++) {
		for (int j = 1; j <= n; j++) {
			scanf("%d", &dp[i][j]);
			dp[i][j] += max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	cout << dp[2][n] << endl;

	return 0;
}

Measured memory_bytes: 256
n, m = map(int,input().split())
v_li = list()
for _ in range(n):
    ele = list(map(int,input().split()))
    v_li.append(ele)
b = [int(input()) for _ in range(m)]

#print(v_li)
#print(b)
#mul = 0
for row in v_li:
    mul = 0
    for col in range(m):
        mul+=row[col]*b[col]
    print(mul)


Measured memory_bytes: 6024
import math
import itertools

from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def nextLine(): return next(stdin)
def nextStrList(): return nextLine().split()
def nextIntList(): return [int(_) for _ in nextStrList()]

# def main0():
# # 	k=int(nextLine())
# 	k=200
# 	s=0
# 	for a,b,c in itertools.product(range(1,k+1), repeat=3):
# 		g=math.gcd(math.gcd(a,b),c)
# 		s+=g
# 	print(s)
	
	
def main():
	k=int(nextLine())
# 	k=200
	s=0
	for a,b,c in itertools.combinations(range(1,k+1), 3):
		g=math.gcd(math.gcd(a,b),c)
		g*=6
		s+=g
	for a,b in itertools.combinations(range(1,k+1), 2):
		g=math.gcd(a,b)
		g*=6
		s+=g
	for a in range(1,k+1):
		g=a
		s+=g
	print(s)
	
	
if __name__=="__main__":
# 	main0()
	main()


Measured memory_bytes: 9216
#include <bits/stdc++.h> 
using namespace std;
#define int long long int
#define float double
#define pb push_back
#define FF first
#define SS second
#define N 201000
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i++)
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define pii pair<int,int>
#define INF 1000000000000000000
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

signed main() 
{
    speed;
    
    
    int n;
    cin>>n;
    int A[n],B[n],C[n];
    int dpa[n],dpb[n],dpc[n];
    for(int i=0;i<n;i++)
    {
    	cin>>A[i]>>B[i]>>C[i];
    	if(i==0) 
    	{
    		dpa[i]=A[i];
    		dpb[i]=B[i];
    		dpc[i]=C[i];
    	}
    	else
    	{
    		dpa[i]=max(dpb[i-1],dpc[i-1])+A[i];
    		dpb[i]=max(dpa[i-1],dpc[i-1])+B[i];
    		dpc[i]=max(dpb[i-1],dpa[i-1])+C[i];
    	}
    }
    cout<<max(max(dpa[n-1],dpb[n-1]),dpc[n-1]);
    return 0;
}


Measured memory_bytes: 4992
s = list(input())
len = 0
max_len = 0
for str in s:
    if str in ["A", "C", "G", "T"]:
        len += 1
    else:
        if len > max_len:
            max_len = len
        len = 0
else:
    if len > max_len:
        max_len = len
print(max_len)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


int solve(){


    int x,y;cin>>x>>y;
    for(int j=0;j<=x;j++){
        int legs=j*2+(x-j)*4;
        if(legs==y) return cout<<"Yes",0;
    }
    cout<<"No";

    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <math.h>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int N,K;






int main()
{

	cin >> N >> K;

	if(N == 1)
		cout << K;
	else


		cout << (int) (pow(K-1,N-1) * K) << endl;



}


Measured memory_bytes: 384
N = int(input())
stocks = [int(i) for i in input().split()]

cash = 1000
hold_stock = 0

for i in range(N):
    stock_price = stocks[i]
    if hold_stock == 0:
        if i == N-1:
            break
        elif stock_price == max(stocks[i:]):
            pass
        else :
            j = 1
            next_stock_price = stocks[i+j]
            while stock_price == next_stock_price:
                j += 1
                next_stock_price = stocks[i+j]
                if i + j == N:
                    break
            if next_stock_price < stock_price:
                pass
            else :
                hold_stock, cash = divmod(cash, stock_price)
    else :
        if i == N-1:
            cash += hold_stock*stock_price
            hold_stock = 0

        elif stock_price == min(stocks[i:]):
            pass
        else :
            j = 1
            next_stock_price = stocks[i+j]
            while stock_price == next_stock_price:
                j += 1 
                next_stock_price = stocks[i+j]
                if i + j == N:
                    break
            if next_stock_price > stock_price:
                pass
            else :
                cash += hold_stock*stock_price
                hold_stock = 0

print(cash)

Measured memory_bytes: 9092
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if((a==7&&b==5&&c==5)
     ||(a==5&&b==7&&c==5)
     ||(a==5&&b==5&&c==7))
    cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());

    ll n,m;
    cin >> n >> m;
    vector <ll> lisx, lisy;
    for (ll i=0;i<n;i++){
        ll p;
        cin >> p;
        lisx.push_back(p);
    }
    for (ll i=0;i<m;i++){
        ll p;
        cin >> p;
        lisy.push_back(p);
    }
    vector <ll> numlisx, numlisy;
    for (ll i=0;i<n-1;i++){
        ll tmp = (n-1-i)*(i+1);
        numlisx.push_back(tmp);
    }
    for (ll i=0;i<m-1;i++){
        ll tmp = (m-1-i)*(i+1);
        numlisy.push_back(tmp);
    }
    ll squarex = 0;
    for (ll i=0;i<n-1;i++){
        squarex += numlisx[i] * (lisx[i+1] - lisx[i]);
        squarex %= mop;
    }
    ll squarey = 0;
    for (ll i=0;i<m-1;i++){
        squarey += numlisy[i] * (lisy[i+1] - lisy[i]);
        squarey %= mop;
    }
    cout << (squarex*squarey)%mop << endl;


}




Measured memory_bytes: 4084
#include<iostream>
using namespace std;
int main()
{
	int  n[1024], x[1024],a,s=0;
	for (int i = 0; i < 1024; i++){
		cin >> n[i] >> x[i];
		if (n[i] == 0&&x[i]==0){
			a = i;
			break;
		}
	}
	for (int i = 0; i < a; i++){
		for (int j=1; j < n[i]-1; j++){
			for (int k = j+1;k<n[i]; k++){
				for (int l = k+1;l<n[i]+1; l++){
					if (j + k + l == x[i]){
						s += 1;
					}
				}
			}
		}
		cout << s << endl;
		s = 0;
	}
	return 0;
}

Measured memory_bytes: 3084
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han Elmuzaffer Daima
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid (start+end)/2
#define ort (bas+son)/2

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

lo n,m,cev,b,a[li],k;
string s;
vector<lo> v;

int main(void){
	scanf("%lld",&n);
	for(lo i=1;i*i<=n;i++){
		if(n%i==0 && i!=n/i && (i*(i+1)!=n)){cev+=n/i-1;}
		//~ if(n%i==0 && i==n/i){cev+=n/i-1;}
	}
	//~ for(lo i=0;i<(lo)v.size();i++){
		//~ if((v[i]-1)*(v[i]-1)+(v[i]-1)>n) cev+=v[i]-1;
	//~ }
	printf("%lld\n",cev);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;

// a^n (mod)を計算
ll modpow(ll a, ll n, ll mod){
  ll res = 1;
  while (n > 0){
    if (n & 1) res = res * a % mod; //nが奇数の時
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main(){
  ll H; cin >> H;

  ll x = H;
  ll res = 0;
  ll depth = 0;
  while (true){
    res += pow(2, depth);
    if (x / 2 > 0) {
      depth++;
      x = x / 2;
    }else{
      break;
    }
  }
  cout << res << endl;
}


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

unordered_set<string> cur,nx;

int main(void){
	string in;
	while(cin >> in){
		cur.clear(),nx.clear();
		if(in=="#") break;
		int n=in.size();

		cur.insert(in);

		for(int i=24;i>=0;--i){
			for(auto &s:cur){
				bool end=false;
				char b=i+1+'a';
				char a=i+'a';
				rep(i,n){
					if(s[i]==b){
						end=true;
						// zy?????¨????????¨???zz  yz??????????£??????????
						// before????????????????????????????????????after????????£??????????????¨???????????????
						break;
					}
					if(s[i]==a){
						string can=s; // bbbb-> cbbb bcbb bbcb bbbc
						can[i]=b;
						nx.insert(can);
					}
				}
				if(!end){
					nx.insert(s);
				}
			}
			cur.swap(nx);
			nx.clear();
		}

		vector<string> answers(cur.begin(),cur.end());
		sort(answers.begin(),answers.end());
		cout <<	answers.size() << endl;
		if(answers.size()<=10){
			rep(i,answers.size()) cout << answers[i] << endl;
		}else{
			rep(i,5) cout << answers[i] << endl;
			rep(i,5) cout << answers[answers.size()-5+i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3908
import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str

isdelim(x::UInt8, xs::Set{UInt8}) = x in xs

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        if !isdelim(c, delims)
            break
        end
    end
    push!(out, c)
    if eof(s)
        return out
    end
    while !eof(s)
        c = read(s, UInt8)
        if isdelim(c, delims)
            break
        end
        push!(out, c)
    end
    return out
end

delimset = Set([0x0a, 0x20])

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

readvec(tys::Tuple , len::Signed)::Vector{Tuple{tys...}} = @inbounds Tuple{tys...}[reads(tys...) for i in 1:len]

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i = 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

function main()
    A,B,H,M = reads(Int,Int,Int,Int)
    rh = H/6+1/6*(M/60)
    rm = M/30
    println(sqrt((A*cospi(rh)-B*cospi(rm))^2+(A*sinpi(rh)-B*sinpi(rm))^2))
end

main()


Measured memory_bytes: 230592
'use strict';
function Main(input) {   
  const temp = input.split("\n");
  
  const n = parseInt(temp.shift(), 10);
  const arr = [];

  for(let i = 0; i < n; i++){
    arr.push(temp[i].split(" "));
    arr[i].push(i + 1);
    arr[i][1] = parseInt(arr[i][1],10)
  }
  
  // arr.sort((a,b) => b[1] - a[1]);
  arr.sort((a,b) => {
    if(a[0] < b[0]) return -1;
    else if(a[0] > b[0]) return 1;
    else return b[1] - a[1];
  });
  
  arr.forEach(e => console.log(e[2]))
  // const ans = arr.map(e => e[2]);
  // console.log(ans.join("\n"));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<string, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

char judge(char a, char b){
    if((a == 'r' && b == 'b') || (a == 'b' && b == 'r')) return 'g';
    if((a == 'b' && b == 'g') || (a == 'g' && b == 'b')) return 'r';
    if((a == 'g' && b == 'r') || (a == 'r' && b == 'g')) return 'b';
}

int main(){
    while(1){
        string s; cin>>s;
        if(s == "0") return 0;

        queue<P> que;
        que.push(P(s, 0));
        map<string, bool> visited;
        visited[s] = true;
        bool isNA = true;
        while(que.size()){
            string t;
            int cnt;
            tie(t, cnt) = que.front();
            que.pop();

            bool valid = true;

            for(int i=0; i<t.size()-1; i++){
                if(t[i] != t[i+1]){
                    valid = false;
                    string nt = t;
                    nt[i] = nt[i+1] = judge(t[i], t[i+1]);

                    if(!visited[nt]){
                        visited[nt] = true;
                        que.push(P(nt, cnt+1));
                    }
                }
            }

            if(valid){
                isNA = false;
                cout << cnt << endl;
                break;
            }
        }

        if(isNA){
            cout << "NA" << endl;
        }
    }
}


Measured memory_bytes: 4888
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define V vector<int>
#define COUT(x) cout<<(x)<<endl
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

bool graph[8][8];

int dfs(int v, int n, bool visited[8]) {
	bool all_visited = true;
	rep(i, n) {
		if (!visited[i])all_visited = false;
	}
	if (all_visited)return 1;
	int ret = 0;
	rep(i, n) {
		if (!graph[v][i])continue;
		if (visited[i])continue;
		visited[i] = true;
		ret += dfs(i, n, visited);
		visited[i] = false;
	}
	return ret;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	rep(i, m) {
		int a, b; cin >> a >> b;
		graph[a - 1][b - 1] = graph[b - 1][a - 1] = true;
	}
	bool visited[8]; rep(i, n)visited[i] = false;
	visited[0] = true;
	cout << dfs(0, n, visited) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define read cin >>
#define echo cout <<
#define fin << endl
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)

// for debug macro
bool global_debug_flag = false;
#define DEBUG(val) \
  if (global_debug_flag) cout << #val << " = " << val << endl

int main() {
  string s;
  cin >> s;
  int len = s.size();
  int ans = 0;
  FOR(i, 0, len) {
    if (s[i] != 'A' && s[i] != 'G' && s[i] != 'C' && s[i] != 'T') {
      continue;
    } else {
      ans = max(ans, 1);
      FOR(j, i + 1, len) {
        DEBUG(i);
        DEBUG(j);
        if (s[j] == 'A' || s[j] == 'G' || s[j] == 'C' || s[j] == 'T') {
          ans = max(ans, j - i + 1);
        } else {
          break;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int dc = 0;
        for (int j = i; j; j /= 10) {
            dc++;
        }

        if (dc % 2 == 1) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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


int main()
{
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n) cin>>a[i];
	sort(a.begin(),a.end());
	int ans1=a[n-1];
	int ans2=INF;
	int dif_v=INF;
	rep(i,n-1)
	{
		if(dif_v>abs(ans1/2-ans1+a[i]))
		{
			ans2=a[i];
			dif_v=abs(ans1/2-ans1+a[i]);
		}
	}
	cout<<ans1<<" "<<ans2<<endl;
	return 0;
}


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

int isprime[500000];

void GetPrime(int n) {
	for(int i = 2; i <= n; i++ ) isprime[i] = 1;
	isprime[0] = 0; isprime[1] = 0;
	for(int i = 2; i <= n; i++ ) {
		if ( isprime[i] ) {
			for( int j = i*2; j <= n; j += i ) {
				isprime[j] = 0;
			}
		}
	}
}

int main() {
	int n, i;
	GetPrime(400000);
	while( cin >> n ) {
		if (!n) break;
		int ans = 0;
		for( int i = n+1; i <= 2*n; i++ ) {
			ans += isprime[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2720
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 


int main()
{
    long A,B,C,D;
    std::cin >> A >> B >> C >> D;
    bool flg=1;
    while(A>0 && B>0){
        C-=B;
        A-=D;

        if(A<=0 && C>0){
            flg=0;
        }
    }
    if(flg){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

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

using namespace std;

// no blocking: O(m) time to calculate.
// blocking one naively: n choices - O(m) to find in total. For each one, O(m) time. So O(mn).

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> adj_list(n);
    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        --s;
        --t;
        adj_list[s].push_back(t);
    }
    auto get_dists = [&](int forbidden_i, int forbidden_j) {
        vector<double> dists(n);
        for (int i = n-2; i >= 0; --i) {
            double sum_dists = 0;
            if (i != forbidden_i) {
                for (int j : adj_list[i]) {
                    sum_dists += dists[j];
                }
                dists[i] = 1 + sum_dists / adj_list[i].size();
            } else {
                for (int j : adj_list[i]) {
                    if (j != forbidden_j) {
                        sum_dists += dists[j];
                    }
                }
                dists[i] = 1 + sum_dists / (adj_list[i].size() - 1);
            }
        }
        return dists;
    };
    vector<double> real_dists = get_dists(-1, -1);
    double best = real_dists[0];
    for (int k = 0; k < n-1; ++k) {
        double largest_dist = -1;
        int largest_index = -1;
        for (int l : adj_list[k]) {
            if (real_dists[l] > largest_dist) {
                largest_index = l;
                largest_dist = real_dists[l];
            }
        }
        if (adj_list[k].size() <= 1) {
            continue;
        }
        best = min(best, get_dists(k, largest_index)[0]);
    }
    cout << setprecision(20) << best << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(void)
{
    static double p[220000][2];
    double min[32], max[32];
    int n;
    int i, j, k;
    double dat;
    double ans;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++){
        for (j = 0; j < 2; j++){
            scanf("%lf", &p[i][j]);
        }
    }
    
    ans = 0;
    for (i = 0; i < 1 << 2; i++){
        for (j = 0; j < n; j++){
            dat = 0;
            for (k = 0; k < 2; k++){
                if ((i >> k) & 1){
                    dat += p[j][k];
                }
                else {
                    dat -= p[j][k];
                }
            }
            if (j == 0){
                min[i] = max[i] = dat;
            }
            else {
                if (dat < min[i]){
                    min[i] = dat;
                }
                if (dat > max[i]){
                    max[i] = dat;
                }
            }
        }
        ans = ans > max[i] - min[i] ? ans : max[i] - min[i];
    }
    
    printf("%.0f\n", ans);
    
    return (0);
}


Measured memory_bytes: 4868
N, X, D = map(int, input().split())
M = [0]*N
M[0] = int(input())
P = [0]*N
for i in range(N-1):
    M[i+1], P[i+1] = map(int, input().split())

C = [1]*N
for i in range(N-1, 0, -1):
    p = P[i]-1
    C[p] += C[i]
    M[p] += M[i]
L = [D]*N
L[0] = X

from collections import deque

def solve(N, W, ws, vs, ms):
    V0 = max(vs)
    V = sum(v * min(V0, m) for v, m in zip(vs, ms))

    dp = [W+1]*(V + 1)
    dp[0] = 0
    for i in range(N):
        v = vs[i]; w = ws[i]; m = ms[i]
        c = min(V0, m)
        ms[i] -= c
        for k in range(v):
            que = deque()
            push = que.append
            popf = que.popleft; popb = que.pop

            for j in range((V-k)//v+1):
                a = dp[k + j*v] - j * w
                while que and a <= que[-1][1]:
                    popb()
                push((j, a))

                p, b = que[0]

                dp[k + j*v] = b + j * w
                if que and p <= j-c:
                    popf()

    *I, = range(N)
    I.sort(key=lambda x: ws[x]/vs[x])
    *S, = [(vs[i], ws[i], ms[i]) for i in I]

    def greedy():
        yield 0
        for i in range(V + 1):
            if dp[i] > W:
                continue
            rest = W - dp[i]
            r = i
            for v, w, m in S:
                m = min(m, rest // w)
                r += m * v
                rest -= m * w
            yield r
    return max(greedy())

print(solve(N, X, M, C, L))

Measured memory_bytes: 48604
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vs = V<string>;
using vd = V<double>; using vvi = V< V<int> >; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////


void solve(){
  
  ini(a , b);
  if(a > b) swap(a , b);
  rep(_ , b) cout << a;
  cout << endl;
  

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main() {

	long n, bnum, brk, tmp;
	cin >> n;


	bnum = 1;
	brk = 0;
	for (int i = 0;i < n;i++) {

		cin >> tmp;

		if (tmp == bnum) {
			bnum++;
		}
		else
		{
			brk++;
		}
	}

	if (brk == n) brk = -1;

	std::cout << brk << endl;

	return 0;
}




Measured memory_bytes: 256
x1,y1,x2,y2 = map(int, input().split())
x3 = x2 - (y2-y1)
y3 = y2 + (x2-x1)
x4 = x1 - (y2-y1)
y4 = y1 + (x2-x1)
print(x3,y3,x4,y4)

Measured memory_bytes: 2940
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>

using namespace std;

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

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://msdn.microsoft.com/library/3bstk3k5.aspx
//   http://www.cplusplus.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   http://www.boost.org/doc/



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

using namespace std;

	long long int gcd(long long int a, long long int b) { 
    	if (a == 0) 
        	return b; 
    	return gcd(b % a, a); 
	} 
  

	long long int lcm(long long int a, long long int b) 
	{ 
    	return (a * b) / gcd(a, b); 
	}

int main(){
	long long int a,b;
	cin>>a>>b;
	cout<<lcm(a,b);
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

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

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, K; cin >> N >> K;
    ll ans = 0;
    FOR(mod, K+1, N+1){
        ll q = N / mod;
        ans += q * (mod - K);
        ans += K == 0 ? (N - q*mod) : max(N - q*mod + 1 - K, 0ll);
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 256
sx,sy,tx,ty = map(int,input().split())

s= ""

xlen = tx - sx
ylen = ty - sy

#iki
for i in range(xlen):
  s += "R"
for i in range(ylen):
  s +="U"

#kaeri
for i in range(xlen):
  s += "L"
for i in range(ylen):
  s +="D"

#iki2
s += "D"
for i in range(xlen + 1):
  s += "R"
for i in range(ylen + 1):
  s += "U"
s += "L"

#kaeri2
s +="U"
for i in range(xlen + 1):
  s += "L"
for i in range(ylen + 1):
  s +="D"
s += "R"

print(s)

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

int main() {
	vector<int>f1 = { 1,3,5,7,8,10,12 };
	vector<int>f2 = {4,6,9,11};
	int x, y; cin >> x >> y;
	bool f = false;
	if (x == 2 || y == 2) {
		cout << "No" << endl; return 0;
	}
	auto search =  [&](auto sf){
		for (auto s1: sf) {
			if (s1 == x) {
				for (auto ss1 : sf) {
					if (ss1 == y) f = true;
				}
			}
		}
	};
	search(f1);  search(f2);
	if (f == true) cout << "Yes" << endl;
	else  cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val x = new Array[Int](n)
    val y = new Array[Int](n)
    for (i <- 0 until n) {
      x(i) = sc.nextInt
      y(i) = sc.nextInt
    }

    val perm: Iterator[IndexedSeq[Int]] = (0 until n).permutations
    var sum = 0d
    var counter = 0
    perm.foreach { list =>
      var tmpSum = 0d
      for (i <- 0 until n - 1) {
        val tmp = math.sqrt(
          math.pow(x(list(i + 1)) - x(list(i)), 2) + math.pow(y(list(i + 1)) - y(list(i)), 2)
        )
        tmpSum += tmp
      }
      sum += tmpSum
      counter += 1
    }

    printf("%.9f\n", sum / counter)
  }
}


Measured memory_bytes: 38472
#include<cstdio>
#include<set>
using namespace std;

int main()
{

    int a[4], b[4];
    set<int> c;
    while(scanf("%d%d%d%d%d%d%d%d",a,a+1,a+2,a+3,b,b+1,b+2,b+3)!=EOF)
    {
        c.clear();
        for(int i=0; i<4; i++)
        {
            c.insert(a[i]);
        }
        int d=0,e=0;
        for(int i=0; i<4; i++)
        {
            if(b[i]==a[i])
            {
                d++;
                e++;
            }
            else if(c.find(b[i])!=c.end())
                e++;
        }
        printf("%d %d\n",d,e-d);
    }
    return 0;
}

Measured memory_bytes: 1028
// D.

#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
	map<int, int> m;
	int n;
	cin >> n;
	for (int i = 2; i <= n; ++i) {
		int x = i;
		for (int k = 2; k <= x; ++k) {
			while ((x % k) == 0) {
				m[k] += 1;
				x /= k;
			}
		}
	}
	vector<int> v;
	for (auto kv : m) {
		v.push_back(kv.second);
	}
	sort(v.rbegin(), v.rend());
	int ans = 0;
	for (int i = 0; i < (int)v.size(); ++i) {
		ans += v[i] >= 74;
		for (int j = i + 1; j < (int)v.size(); ++j) {
			ans += v[i] >= 24 && v[j] >= 2;
			ans += v[i] >= 2 && v[j] >= 24;
			ans += v[i] >= 4 && v[j] >= 14;
			ans += v[i] >= 14 && v[j] >= 4;
			for (int k = j + 1; k < (int)v.size(); ++k) {
				ans += v[i] >= 2 && v[j] >= 4 && v[k] >= 4;
				ans += v[i] >= 4 && v[j] >= 2 && v[k] >= 4;
				ans += v[i] >= 4 && v[j] >= 4 && v[k] >= 2;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int dp[3004][3004];

int main(){
  int N, T;
  scanf("%d", &N);
  scanf("%d", &T);
  std::vector<int > A(N), B(N);
  int max=-1;
  int maxindex=-1;
  std::vector<std::pair<int, int > > pr(N);
  for (int i=0; i<N; i++){
    //scanf("%d", &A[i]);
    //scanf("%d", &B[i]);
    scanf("%d", &pr[i].first);
    scanf("%d", &pr[i].second);
  }
  std::sort(pr.begin(), pr.end());
  for (int i=0; i<N; i++){
    A[i]=pr[i].first;
    B[i]=pr[i].second;
    //printf("(%d, %d)\n", A[i], B[i]);
  }
  for (int i=0; i<3004; i++){
    for (int j=0; j<3004; j++){
      dp[i][j]=-1;
    }
  }
  dp[0][0]=0;
  for (int i=0; i<N; i++){
    /*    if (i==maxindex) {
      for (int j=0; j<=T; j++){
	dp[i+1][j]=dp[i][j];
	//printf("maxindex dp[%d][%d]=%d\n", i+1, j, dp[i+1][j]);
	}*/
    //} else {
    for (int j=0; j<T; j++){
      dp[i+1][j]=std::max(dp[i+1][j], dp[i][j]);
      if (dp[i][j]!=-1 && j+A[i]<T){
	dp[i+1][j+A[i]]=std::max(dp[i+1][j+A[i]], dp[i][j]+B[i]);
	//printf("dp[%d][%d]=%d\n", i+1, j+A[i], dp[i+1][j+A[i]]);
      } else if (dp[i][j]!=-1 && j+A[i]>=T){
	dp[i+1][T]=std::max(dp[i+1][T], dp[i][j]+B[i]);
	//printf("dp[%d][%d]=%d\n", i+1, T, dp[i+1][T]);
      }
    }
    dp[i+1][T]=std::max(dp[i+1][T], dp[i][T]);
  }
  int dpmax=-1;
  for (int j=0; j<=T; j++){
    dpmax = std::max(dpmax, dp[N][j]);
  }
  //printf("dpmax=%d, max=%d\n", dpmax, max);
  //std::cout << dpmax+max << std::endl;
  std::cout << dpmax << std::endl;
  return 0;
}
 

Measured memory_bytes: 38532