akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  long long A,B;
  cin>>A>>B;
  long long Ans;
  Ans=lcm(A,B);
  cout<<Ans<<endl;
}


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

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

    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (i + k - 1 < n)
        {
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func calc(prices []int) int {

	var m, s int

	for _, p := range prices {
		s += p
		if m < p {
			m = p
		}
	}

	return s - (m / 2)
}

func parse() []int {

	stdin := bufio.NewScanner(os.Stdin)
	stdin.Split(bufio.ScanLines)

	stdin.Scan()
	n, _ := strconv.Atoi(stdin.Text())

	ret := make([]int, n)

	for i := 0; i < n; i++ {
		stdin.Scan()
		p, _ := strconv.Atoi(stdin.Text())
		ret[i] = p
	}

	return ret
}

func main() {
	prices := parse()
	fmt.Println(calc(prices))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main() {
    int w, a, b;
    cin >> w >> a >> b;
    int len = abs(a - b);
    int ans = max(0, len - w);
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ff(i,n) for(i=0;i<n;i++)
ll bg=1000000007;
ll gcd(ll a,ll b)
{
if(b==0)
   return a;
else
   return gcd(b,a%b);   
}
ll power(ll x,ll y)
{
	if(y==0)
		return 1;
	ll h=power(x,y/2);	
	h=(h*h)%bg;
	if(y%2==1)
	  return (x*h)%bg;
	else
	  return h%bg;  
}
ll isp(string str) 
{ 
    // Start from leftmost and rightmost corners of str 
    int l = 0; 
    int h = str.length() - 1;
    // Keep comparing characters while they are same 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        {  
            return -1; 
        } 
    } 
    return 1; 
} 
vector<vector<ll> >adj(300000);
void bfs(ll s,ll n,ll d[])
{
	queue<ll> q;
    ll used[n+1]={0};
    vector<ll> p(n+1);
    q.push(s);
    used[s] = 1;
    p[s] = -1;
    d[s]=0;
    while (!q.empty()) {
    ll v = q.front();
    q.pop();
    ll j;
    for (j=0;j<adj[v].size();j++) {
    	ll u=adj[v][j];
        if (used[u]==0) {
            used[u] = 1;
            q.push(u);
            d[u] = d[v] + 1;
            p[u] = v;
        }
    }
   }
}
int main()
{
	ll t;
	t=1;
	while(t--)
	{	
	   ll i,j,n,m,x,k;
	   cin>>n;
	   ll arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	   cout<<arr[n-1];
	}
return 0;
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
// ll mod_pow(ll x, ll n, ll mod){//x^n % mod
//     if (n == 0)
//         return 1;
//     ll res = mod_pow(x * x % mod, n / 2, mod);
//     if (n & 1)
//         res = res * x % mod;
//     return res;
// }
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N,K; cin >> N >> K;
    double res = 0.0;
    for (int i = 1; i <= N; i++) {
        int j = i;
        double tmp_res = 1.0;
        while (j < K) {
            tmp_res /= 2;
            j = j<<1;
        }
        res += tmp_res;
    }


    cout << setprecision(12) << res / N << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
<url:https://agc001.contest.atcoder.jp/tasks/agc001_c>
問題文============================================================
 N 頂点の木があり、頂点には 1~N の番号がついています。
 N−1 本の辺について、i(1≦i≦N−1) 本目の辺は頂点 Ai と頂点 Bi を繋いでいます。
 
 この木の直径を K 以下にするために削除する必要のある頂点数の最小値を求めてください。
 ただし、頂点を削除した後のグラフは連結になっていなければなりません。
 
 木の直径とは、2 つの頂点間の距離の最大値のことを指します。
 2 つの頂点間の距離とは、2 つの頂点を結ぶパスに含まれる辺の本数を指します。
 
 制約
 2≦N≦2000
 1≦K≦N−1
 1≦Ai≦N,1≦Bi≦N
 与えられるグラフは木である。

=================================================================

解説=============================================================

================================================================
*/
ll solve(){
    ll res = INF;
    ll N,K; cin >> N >> K;
    vector<vector<ll>> G(N);
    vector<pll> edge(N);
    for(int i = 0; i < N-1;i++){
        ll A,B; cin >> A >> B; A--; B--;
        G[A].push_back(B); G[B].push_back(A);
        edge[i] = {A,B};
    }
    queue<ll> q;
    vector<ll> dist(N,INF);
    dist[0] = 0; q.push(0);
    while(q.size()){
        ll n = q.front(); q.pop();
        for(ll next : G[n]){
            if(dist[next] > dist[n] + 1){
                dist[next] = dist[n] + 1;
                q.push(next);
            }
        }
    }
    ll _n = max_element(dist.begin(), dist.end()) - dist.begin();
    fill(dist.begin(),dist.end(),INF);
    dist[_n] = 0; q.push(_n);
    while(q.size()){
        ll n = q.front(); q.pop();
        for(ll next : G[n]){
            if(dist[next] > dist[n] + 1){
                dist[next] = dist[n] + 1;
                q.push(next);
            }
        }
    }
    
    queue<pll> q2;
    if(K&1){
        ll D = (K-1)/2;
        for(auto& e:edge){
            vector<int> f(N,false);
            ll l = e.first,r = e.second;
            q2.push({l,0}); q2.push({r,0});
            while(q2.size()){
                auto p = q2.front(); q2.pop();
                ll n,d; tie(n,d) = p;
                f[n] = true;
                if(d == D) continue;
                for(auto next:G[n]){
                    if(f[next])continue;
                    q2.push({next,d+1});
                }
            }
            res = min(res,N - accumulate(f.begin(), f.end(), 0));
        }
    }else{
        ll D = K/2;
        for(int i = 0; i < N;i++){
            vector<int> f(N,false);
            q2.push({i,0});
            while(q2.size()){
                auto p = q2.front(); q2.pop();
                ll n,d; tie(n,d) = p;
                f[n] = true;
                if(d == D) continue;
                for(auto next:G[n]){
                    if(f[next])continue;
                    q2.push({next,d+1});
                }
            }
            res = min(res,N - accumulate(f.begin(), f.end(), 0));
        }
    }
    return res;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 512
from fractions import gcd
def lcm(x,y):
    return (x*y) // gcd(x,y)

a,b,c,d = map(int,input().split())
a = a-1
c_can = b//c - a//c
d_can = b//d - a//d
e = lcm(c,d)
e_can = b//e - a//e
print(b-a-c_can-d_can+e_can)

Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  ll L, R;
  cin >> L >> R;
  if(L % 2019 == 0 || R % 2019 == 0)
    cout << 0 << endl;
  else if(L / 2019 < R / 2019)
    cout << 0 << endl;
  else {
    int l = L % 2019;
    int r = R % 2019;
    int ans = 2020;
    REP(i, l, r+1) {
      REP(j, i+1, r+1) {
        ans = min(ans, (i * j) % 2019);
      }
    }
    cout << ans << endl;
  }
  return 0;
}


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

int main(){
	int x,y;
	cin >> x >> y;
	if((y-2*x)%2==0 && y - 2*x >= 0 && (4*x - y) % 2 == 0 && 4*x - y >= 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
    return 0;
}



Measured memory_bytes: 3640
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1

const int maxn = 2e5 + 7;
const int INF = 0x3f3f3f3f;

struct node {
    int pos,val;
}a[maxn];

bool cmp(node aa,node bb) {
    return aa.pos < bb.pos;
}

LL q[maxn];

int main() {
    int n,d,x;
    scanf("%d%d%d",&n,&d,&x);
    for(int i = 1 ; i <= n ; i++) {
        scanf("%d%d",&a[i].pos,&a[i].val);
    }
    d <<= 1;
    sort(a+1,a+n+1,cmp);
    LL ans = 0;
    for(int i = 1 ; i <= n ; i++) {
        q[i] += q[i-1];
        a[i].val -= q[i] * x;
        if(a[i].val <= 0) continue;
        LL temp = (a[i].val + x - 1) / x;
        ans += temp;
//        cout << "i = " << i << " ans = " << ans << endl;
        q[i] += temp;
        int l = i , r = n;
        int res = 0;
        while(l <= r) {
            int mid = (l + r) >> 1;
//            cout << "l = " << l << " r = " << r << " " << a[mid].pos << " " << a[i].pos + d << endl;
            if(a[mid].pos <= a[i].pos + d) {
                res = mid;
                l = mid + 1;
            } else {
                r = mid - 1;
            }
        }
//        cout << "res = " << res << endl;
        q[res+1] -= temp;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 6868
#include <iostream>
#include <string>
#include <vector>
#include <memory>
#include <cstdint>

using namespace std;

int main()
{
	int N;
	cin >> N;
	const int MAX_N = 1000000000;
	int bytes = (MAX_N >> 3) + 1;
	vector<uint8_t> bits(bytes);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		int x = A >> 3;
		int y = A & 0x7;
		int bit = 1 << y;
		if (bits[x] & bit) {
			ans--;
			bits[x] &= (uint8_t)~bit;
		} else {
			ans++;
			bits[x] |= bit;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 122368
#include<bits/stdc++.h>
#define maxn 200005
#define ll long long
using namespace std;
int n;
ll k;
ll arr[maxn];
bool check(ll m) {
	ll sum = 0;
	for(int i=1;i<=n;i++) {
		if(arr[i] == 0) {
			if(m >= 0)	sum += n;
		}
		else {
			int l = 1 , r = n , mid;
			while(true) {
				if(r - l < 3) {
					if(arr[i] > 0) {
						for(mid=l;mid<=r && arr[i]*arr[mid] <= m;mid++);
						mid--;
						if(1 <= mid && mid <= n)
							sum += mid;
					}
					else {
						for(mid=r;mid>=l && arr[i]*arr[mid] <= m;mid--);
						mid++;
						if(1 <= mid && mid <= n)
							sum += (n - mid + 1);
					}
					break;
				}
				mid = (l+r)>>1;
				if(arr[i] * arr[mid] <= m) {
					if(arr[i] > 0)
						l = mid;
					else
						r = mid;
				}
				else {
					if(arr[i] > 0)
						r = mid - 1;
					else
						l = mid + 1;
				}
			}
		}
		if(arr[i] * arr[i] <= m)	sum--;
	}
	return sum / 2 >= k;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	for(int i=1;i<=n;i++)
		cin >> arr[i];
	sort(arr+1,arr+1+n);
	ll l = -1e18 , r = 1e18 , m;
	while(true) {
		if(r - l < 3) {
			for(m=r;m>=l && check(m);m--);
			m++;
			break;
		}
		m = (l+r)>>1;
		if(check(m))
			r = m;
		else
			l = m + 1;
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=sum(a)
for i in range(n):
    if a[i]>=b[i]:
        a[i]-=b[i]
    else:
        if a[i+1]-b[i]+a[i]<0:
            a[i+1]=0
        else:
            a[i+1]-=b[i]-a[i]

        a[i]=0

print(s-sum(a))

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

ll dp[100100];
ll N,K;
ll ans;
long long mod_pow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
  rep(i,100100){dp[i]=0;}
  cin>>N>>K;
  for(ll i=K;i>0;i--){
    ll num = K/i;
    ll tmpCount = mod_pow(num, N, (ll)MOD);
    dp[i] = tmpCount;
    ll r=i*2;
    while(r<=K){
      dp[i]=dp[i]+(MOD-dp[r]);
      dp[i]%=MOD;
      r+=i;
    }
  }
  ll ans=0;
  for(ll i=1;i<=K;i++){
  	ans+=i*dp[i];
    ans%=MOD;
  }
  cout<<ans;
}

Measured memory_bytes: 4404
#include"cstdio"
int main(){
	int a,b,c;
	while(~scanf("%d%d%d",&a,&b,&c)){
		if(a==b&&b==c){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	return 0;
} 


Measured memory_bytes: 128
#include<stdio.h>
main(){
  float max,min,h[10000];
  int i=0,j;
  while(scanf("%f",&h[i])!=EOF){
    i++;
  }
  max=min=h[0];
  for(j=1;j<i;j++){
    if(max<h[j]){
      max=h[j];
    }
    else if(min>h[j]){
      min=h[j];
    }
  }
  printf("%g\n",max-min);
  return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    stack<int> slope;
    stack<pair<int,int>> lake;
    string hoge;
    cin>>hoge;
    
    long long sum=0;
    
    for(int i=0;i<hoge.size();i++){
        if(hoge.at(i)=='\\') slope.push(i);
        if(hoge.at(i)=='/' && slope.size()>0){
            int t=slope.top();
            slope.pop();
            int pre=i-t;
            sum+=pre;
            
            while(lake.size()>0 && lake.top().first>t){
                pre+=lake.top().second;
                lake.pop();
            }
            
            lake.push(make_pair(t,pre));
        }
    }
    
    vector<int> lakes;
    
    while(lake.size()>0){
        lakes.push_back(lake.top().second);
        lake.pop();
    }
    
    cout<<sum<<endl<<lakes.size();
    
    for(int i=lakes.size()-1;i>=0;i--) cout<<" "<<lakes.at(i);
    
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 3308
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define range_for(i, b, e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define pb push_back
# define len(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
# define LINT_MAX (LONG_LONG_MAX)
# define cauto const auto
using namespace std;
using lint = long long;
template <class Type> inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) { return (i <= x) && (x <= a); }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a<b) { a=b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }

// 整数の桁数を返す ( log(N) )
template <class Integer> Integer GetDigit(Integer n) {
    if (n == 0) return 1;
    Integer d = 0;
    while (n) {
        n /= 10;
        d++;
    }
    return d;
}

// 素数かどうかを返す ( O(sqrt(N)) )
template <class Integer>
constexpr bool IsPrime(const Integer n) noexcept {
    if (n < 4) return n == 2 || n == 3;
    if (n % 2 == 0 || n % 3 == 0 || (n % 6 != 1 && n % 6 != 5)) return false;
    for (Integer i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;
}


int main()
{
    int a, b; cin >> a >> b;
    if (a == b)
    {
        cout << 2*a << endl;
    }
    else
    {
        cout << 2*max(a, b) - 1 << endl;
    }

    return 0;
}



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

using namespace std;

int main(void) {
    int N, M;
    cin >> N >> M;

    int odd = (N/2 + 1) / 2;
    int even = N/2 / 2;
    // cerr << odd << ' ' << even << endl;
    for(int i=1; i<=N/2; i++) {
        if(M == 0) break;
        if(i%2 == 0) {
            cout << N-even-i/2 << ' ' << N-even+i/2 << endl;
        } else {
            cout << odd-i/2 << ' ' << odd+(i+1)/2 << endl;
        }
        --M;
    }
    return 0;
}


Measured memory_bytes: 3580
import sys
def input():
    return sys.stdin.readline()[:-1]

n = int(input())

if n > 81:
    print('No')
    sys.exit()


for i in range(1, 10):
    for j in range(1, 10):
        if n == i * j:
            print('Yes')
            sys.exit()

print('No')

Measured memory_bytes: 38392
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if(s == "abc") cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll a,ll b)
{ll result=1;
while(b>0)
{if(b%2==1)
 result*=a;
 a*=a;
 b/=2;
}
return result;
}
int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll n,d;
cin>>n>>d;
vector<pair<ll,ll> > v;
ll count=0;
while(n--)
{ll x,y;
 cin>>x>>y;
 v.push_back(make_pair(x,y));
 double temp=sqrt(pow(x,2)+pow(y,2));
 if(temp<=d)
 count++;
}
cout<<count;
}

Measured memory_bytes: 7432
S = input()
T = input()

S_list = []
pre_c = S[0]
c_num = {}
for i, c in enumerate(S[1:]):
    if c != pre_c:
        if c not in c_num:
            c_num[c] = i
        S_list.append((i, c_num[c]))
        pre_c = c

T_list = []
pre_c = T[0]
c_num = {}
for i, c in enumerate(T[1:]):
    if c != pre_c:
        if c not in c_num:
            c_num[c] = i
        T_list.append((i, c_num[c]))
        pre_c = c

if S_list == T_list:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 42544
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)

h = {}
n.times do |i|
  h[a[i]] = h[a[i]] ? h[a[i]] + 1 : 1
end

answer = 0
h.each do |k, v|
  if k > v
    answer += v
  elsif k < v
    answer += (v - k)
  end
end

puts answer


Measured memory_bytes: 15492
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    rep(i, n) cin >> x[i];
    rep(i, n) y[i] = x[i];
    sort(y.begin(), y.end());
    int sm = y[n / 2];
    int la = y[n / 2 - 1];
    rep(i, n) {
        if(x[i] < sm) cout << sm << endl;
        else cout << la << endl;
    }
    return 0;
}


Measured memory_bytes: 4804
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int ans = 0;
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=n; j++) {
			for (int k=1; k<=n; k++) {
				ans += gcd(gcd(i, j), k);
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 3660
N, K = list(map(int, input().split()))
S = input()

# 終端を追加
S = S + 'E'
ans = -1

# standは利用した命令の数であるのでS[0] == '0'のときstand = 1になる
if (S[0] == '0'):
    stand = 1
else:
    stand = 0

L = 0
R = 0

# 尺取り法　(two pointers というみたい)
while(R < N):
    if (stand <= K):
        # 0からはじまる連続列が見つかったらstandを増やす
        if (S[R] == '1' and S[R+1] == '0'):
            stand+=1
        ans = max(ans, R - L + 1)
        R += 1
    elif L == R:
        L += 1
        R += 1
    else:
        if (S[L] == '0' and S[L+1] == '1'):
            stand -= 1
        L += 1

print(ans)

Measured memory_bytes: 42480
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset> 
using namespace std;
typedef long long ll;
ll a[1000006]={0};
int main(void)
{
	ll n;
	scanf("%lld",&n);
	ll n1=n;
	for(ll i=2;i*i<=n;i++)
	{
		if(n1%i==0)
		{
			ll cnt=0;
			while(n1%i==0) n1/=i,cnt++;
			a[i]=cnt;
		}
	}
	
	ll ans=0;
	if(n1>1) ans++;
	for(ll i=2;i*i<=n;i++)
	{
		if(a[i]!=0)
		{
			for(ll j=1;j<=n;j++)
			{
				if(j*(j+1)/2>a[i]) break;
				ans++;
			}
		}
	}
	printf("%lld",ans);
}

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

int min(int,int);

int main(void){
  char dp[1001][1001];
  int n,i,j,max,M[1001][1001];
  
  
  while(cin >> n,n){
      max=0;

      for(i=0;i<n;i++){
	  for(j=0;j<n;j++){
	      M[i][j]=1;
	    }
	} 

      for(i=0;i<n;i++){
	  for(j=0;j<n;j++){
	      cin >> dp[i][j];
	      if(i==0){
		  if(dp[i][j]!='*')M[i][j]=1;
		  else M[i][j]=-1;
		}
	      else{
		  if(dp[i][j]!='*'){
		  if(j==0)M[i][j]=1;
		  else{
		      if(M[i-1][j]==-1 || M[i-1][j-1]==-1 || M[i][j-1]==-1)
			M[i][j]=1;
		      else M[i][j]=min(M[i-1][j],min(M[i-1][j-1],M[i][j-1]))+1;
		  }
		  }
	      }
	      if(dp[i][j]=='*')M[i][j]=-1;
	  }
      }
      
      for(i=0;i<n;i++){
	  for(j=0;j<n;j++){
	      if(M[i][j]>=0 && max<M[i][j])max=M[i][j];
	    }
	}
      cout << max <<"\n";
    }
  return 0;
}

int min(int x,int y){
  return x<y?x:y;
}

Measured memory_bytes: 4656
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;


int main(){
    ll N, a, b;
    cin >> N >> a >> b;

    ll ans = (1LL << 60);
    if((b - a) % 2 == 0){
        ans = (b - a) / 2;
    } else {
        //1までいって合流
        ll tmp = a + (b - a - 1) / 2;
        ans = min(ans, tmp);
        //Nまでいって合流
        tmp = (N - b + 1) + (-a + b - 1) / 2;
        ans = min(ans, tmp);

    }

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
#include <map>
#include <set>
using namespace std;
using P = pair<int,int>;
using ll = long long;
int main(){
    int n,x;
    cin>>n>>x;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    vector<vector<int>> m(n,vector<int>(n));
    for(int i=0;i<n;i++){
        m[i][0]=a[i];
        for(int j=1;j<n;j++){
            m[i][j]=min(m[i][j-1],a[(i-j+n)%n]);
        }
    }
    ll ret=LLONG_MAX;
    for(int i=0;i<n;i++){
        ll cnt=0;
        for(int j=0;j<n;j++){
            cnt+=m[j][i];
        }
        cnt+=(ll)x*i;
        ret=min(ret,cnt);
    }
    cout<<ret<<endl;
}


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

int x,y,z,n,m,mx;
int ar[2005];

int main() {
	scanf("%d%d%d",&x,&y,&z);
	for (int a = 1; a < x; a++) {
		for (int b = a+1; b <= x; b++) {
			ar[min(b-a,(abs(a-y)+abs(z-b)+1))]++;
		}
	}
	for (int a = 1; a < x; a++) printf("%d\n",ar[a]);
	return 0;
}

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

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N, M;
    cin >> N >> M;
    vector<int> A(N), mod(N + 1);
    readvec(A);

    mod[0] = 0;
    REP(i, N){
        mod[i + 1] = (mod[i] + A[i]) % M;
    }

    sort(mod.begin(), mod.end());

    int ans = 0;
    int tmp = 1;

    REP(i, N + 1){
        if(i == N || mod[i] != mod[i + 1]){
            ans += tmp * (tmp - 1) / 2;
            tmp = 1;
        }else{
            tmp++;
        }
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 1792
def read_int():
    return int(input())

def read_int_map():
    return map(int,input().split(' '))

def read_int_list():
    return list(map(int,input().split(' ')))

def read_s_list_loop(n):
    return [input() for _ in range(n)]

S = input()

if S == 'ABC':
    print('ARC')
else:
    print('ABC')

Measured memory_bytes: 61648
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BrokenCipherGenerator solver = new BrokenCipherGenerator();
        solver.solve(1, in, out);
        out.close();
    }

    static class BrokenCipherGenerator {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String token = in.next();
            while (!".".equals(token)) {
                out.println(decrypt(token).toString());
                token = in.next();
            }
        }

        private static StringBuilder decrypt(String str) {
            StringBuilder plain = new StringBuilder();
            int n = str.length();
            int offset = 0, depth = 0, open = -1;
            for (int i = 0; i < n; i++) {
                switch (str.charAt(i)) {
                    case '+': {
                        if (depth == 0) offset++;
                        break;
                    }
                    case '-': {
                        if (depth == 0) offset--;
                        break;
                    }
                    case '[': {
                        if (depth == 0) open = i;
                        depth++;
                        break;
                    }
                    case ']': {
                        depth--;
                        if (depth == 0) plain.append(decrypt(str.substring(open + 1, i)).reverse());
                        break;
                    }
                    case '?': {
                        if (depth == 0) {
                            plain.append('A');
                            offset = 0;
                        }
                        break;
                    }
                    default: {
                        if (depth == 0) {
                            char c = (char) ((str.charAt(i) - 'A' + offset + 78) % 26 + 'A');
                            // System.out.println("APPENDING " + c + " WITH OFFSET " + offset);
                            plain.append(c);
                            offset = 0;
                        }
                        break;
                    }
                }
            }
            return plain;
        }

    }
}




Measured memory_bytes: 27732
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;

int main() {
    string A, B, C;
    cin >> A >> B >> C;

    bool isOk = true;
    if (A.at(A.size() - 1) != B.at(0)) {
        isOk = false;
    }
    if (B.at(B.size() - 1) != C.at(0)) {
        isOk = false;
    }
    if (isOk) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
class Program
{
    static void Main(string[] args)
    {
        string[] input = ReadLine().Split(' ');
        int K = int.Parse(input[0]);
        int X = int.Parse(input[1]);
        for(int i = X - K + 1;i < X + K; i++)
        {
            Write(i);
            if(i < X + K - 1)
            {
                Write(" ");
            }
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int h, m, s, sum;

    while(cin >> h >> m >> s, s != -1){
        sum = (h * 60 + m) * 60 + s;
        sum -= 2 * 60 * 60;
        sum *= -1;
        rep(i,2){
            h = sum / 60 / 60;
            m = (sum - h * 60 * 60) / 60;
            s = sum - (h * 60 + m) * 60;
            sum *= 3;
            cout << setfill('0');
            cout << setw(2) << h << ':' << setw(2) << m << ':' << setw(2) <<  s << endl;
        }
    }
}

Measured memory_bytes: 1168
N = int(input())
restaurant = []
for i in range(N):
    Sn, Pn = input().split()
    Pn = int(Pn)
    restaurant.append([i, Sn, -1 * Pn])

for r in sorted(restaurant, key=lambda x: (x[1], x[2])):
    print(r[0] + 1)

Measured memory_bytes: 38512
<?php
$ans = array(
    "AC" => 0
    , "WA" => 0
    , "TLE" => 0
    , "RE" => 0
);

$n = trim(fgets(STDIN));
for ($i = 0;$i < $n;++$i) {
    ++$ans[trim(fgets(STDIN))];
}
foreach ($ans as $key => $value) {
    echo $key." x ".$value.PHP_EOL;
}

Measured memory_bytes: 16168
#include<bits/stdc++.h>
using namespace std;
long xoror(long n){
    long ans = 0;
    for(long i=1;i<=n;i*=2){
        if(i==1){
            if(n%4 == 1 || n%4==2)ans += 1;
        }else{
            if(n % (i*2) >= i && n%2==0)ans += i;
        }
    }
    return ans;
}





int main(){
    long a,b;
    cin >> a >> b;
    long aa = 0;
    if(a>0)aa = xoror(a-1);
    long bb = xoror(b);
    cout << (aa^bb) << endl;
    
}


Measured memory_bytes: 256
S=list(reversed(input()))
N=len(S)
i=0
while i<N:
  if N-i<=4:
    print("NO")
    exit()
    
  elif N-i<=5:
    if S[i]=="m" and S[i+1]=="a" and S[i+2]=="e" and S[i+3]=="r" and S[i+4]=="d":
      i+=5
    elif S[i]=="e" and S[i+1]=="s" and S[i+2]=="a" and S[i+3]=="r" and S[i+4]=="e":
      i+=5
    else:
      print("NO")
      exit()
  
  elif N-i<=6:
    if S[i]=="m" and S[i+1]=="a" and S[i+2]=="e" and S[i+3]=="r" and S[i+4]=="d":
      i+=5
    elif S[i]=="e" and S[i+1]=="s" and S[i+2]=="a" and S[i+3]=="r" and S[i+4]=="e":
      i+=5
    elif S[i]=="r" and S[i+1]=="e" and S[i+2]=="s" and S[i+3]=="a" and S[i+4]=="r" and S[i+5]=="e":
      i+=6
    else:
      print("NO")
      exit()
      
  else:
    if S[i]=="m" and S[i+1]=="a" and S[i+2]=="e" and S[i+3]=="r" and S[i+4]=="d":
      i+=5
    elif S[i]=="e" and S[i+1]=="s" and S[i+2]=="a" and S[i+3]=="r" and S[i+4]=="e":
      i+=5
    elif S[i]=="r" and S[i+1]=="e" and S[i+2]=="s" and S[i+3]=="a" and S[i+4]=="r" and S[i+5]=="e":
      i+=6
    elif S[i]=="r" and S[i+1]=="e" and S[i+2]=="m" and S[i+3]=="a" and S[i+4]=="e" and S[i+5]=="r" and S[i+6]=="d":
      i+=7
    else:
      print("NO")
      exit()
  
    
print("YES")

Measured memory_bytes: 4212
def submit():
    n = int(input())
    alist = list(map(int, input().split()))

    curr = 0
    for a in alist:
        if a == curr + 1:
            curr += 1
    
    if curr == 0:
        print(-1)
    else:
        print(n - curr)


if __name__ == "__main__":
    submit()

Measured memory_bytes: 24744
import scala.io.{StdIn => in}

object Main extends App {
  val out = new java.io.PrintWriter(System.out)
  val n = in.readLine.toInt
  val Array(s, t) = in.readLine.split(" ")

  for(i <- 0 until n)
  {
    out.print(s(i))
    out.print(t(i))
  }

  out.println
  out.flush
}

Measured memory_bytes: 27184
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	while(1){
		cin>>a>>b>>c;
		char res;
		if(a==-1&&b==-1&&c==-1)break;
		if(a+b>=80)res='A';
		if(a+b<80&&a+b>=65)res='B';
		if(a+b<65&&a+b>=50)res='C';
		if(a+b<50&&a+b>=30)res=(c>=50?'C':'D');
		if(a+b<30)res='F';
		if(a==-1||b==-1)res='F';
		cout<<res<<endl;
	}
	return 0;
}


Measured memory_bytes: 3124
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(sx,sy,tx,ty);
  int x = tx-sx;
  int y = ty-sy;

  REP(i,x)cout<<"R";
  REP(i,y)cout<<"U";
  REP(i,x)cout<<"L";
  REP(i,y+1)cout<<"D";
  REP(i,x+1)cout<<"R";
  REP(i,y+1)cout<<"U";
  cout<<"L";
  cout<<"U";
  REP(i,x+1)cout<<"L";
  REP(i,y+1)cout<<"D";
  COUT("R");



  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//Calorie Counting
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			int[] id = new int[n], p = new int[n], q = new int[n], r = new int[n];
			for(int i=0;i<n;i++){
				id[i] = sc.nextInt();
				p[i] = sc.nextInt();
				q[i] = sc.nextInt();
				r[i] = sc.nextInt();
			}
			List<Integer> l = new ArrayList<Integer>();
			int P = sc.nextInt(), Q = sc.nextInt(), R = sc.nextInt(), C = sc.nextInt();
			for(int i=0;i<n;i++){
				if(p[i]<=P && q[i]<=Q && r[i]<=R && p[i]*4+q[i]*9+r[i]*4<=C)l.add(id[i]);
			}
			if(l.isEmpty())System.out.println("NA");
			else for(int x:l)System.out.println(x);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n,x;
  cin>>n>>x;
   vector<int> m(n);
   for (int i = 0; i < n; i++) {
    cin >> m.at(i);
  }
sort(m.begin(), m.end());
  int sum=0;
  for (int i = 0; i < n; i++) {
 sum +=m[i];
}
  x-=sum;
  int ans=n;
  for (int i = 0; i < 100000; i++) {
 if(x>=m[0]){
   x-=m[0];
   ans++;
 }
    else{
      break;
    }
}
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-Ofast"
#endif
#include <bits/stdc++.h>
 
#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)
 
#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif
 
typedef long long ll;
typedef double ld;
typedef unsigned long long ull;
 
using namespace std;
 
const int MX = 307;
 
ld f[MX + 5][MX + 5][MX + 5];
 
int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n;
    cin >> n;
    int c1 = 0, c2 = 0, c3 = 0;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (x == 1) {
            c1++;
        } else if (x == 2) {
            c2++;
        } else {
            c3++;
        }
    }
 
    for (int k = 0; k < MX; k++) {
        for (int j = 0; j + k < MX; j++) {
            for (int i = 0; i + j + k < MX; i++) {
                if (i == 0 && j == 0 && k == 0) {
                    continue;
                }
                if (i + j + k > MX) {
                    continue;
                }
                ld wait = 1.0 * n / (i + j + k);
                ld pi = 1.0 * i / (i + j + k);
                ld pj = 1.0 * j / (i + j + k);
                ld pk = 1.0 * k / (i + j + k);
 
                if (i) {
                    f[i][j][k] += pi * f[i - 1][j][k];
                }
                if (j) {
                    f[i][j][k] += pj * f[i + 1][j - 1][k];
                }
                if (k) {
                    f[i][j][k] += pk * f[i][j + 1][k - 1];
                }
                f[i][j][k] += wait;
            }
        }
    }
 
    cout.precision(10);
    cout << fixed << f[c1][c2][c3] << "\n";
    return 0;
}
 

Measured memory_bytes: 233728
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		
		if (a > b) {
		    System.out.println("a > b");
		} else if (a < b) {
		    System.out.println("a < b");
		} else {
		    System.out.println("a == b");
		}
		
	}
}


Measured memory_bytes: 26348
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>

#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(n);V a(n+2,0);REP(i,n)cin>>a[i+1];
  V diff1(n+1,0);
  REP(i,n+1)
    diff1[i]=abs(a[i]-a[i+1]);

  V diff2(n,0);
  REP(i,n)
    diff2[i]=abs(a[i]-a[i+2]);
  /*
  VECCOUT(diff1);
  VECCOUT(diff2);
  */

  ll ans = accumulate(ALL(diff1),0LL);

  REP(i,n){
    COUT(ans - diff1[i] - diff1[i+1] + diff2[i]);
  }


  

  return 0;
}


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int H, W; cin >> H >> W;
    string board[H];
    REP(i, H) {
        cin >> board[i];
    }
    REP(i, H) {
        REP(j, W) {
            int cnt = 0;
            if (board[i][j] == '#') {
                continue;
            }
            REP(k, 8) {
                int ni = i + dy[k], nj = j + dx[k];
                if(ni < 0 || ni >= H || nj < 0 || nj >= W) {
                    continue;
                }
                if(board[ni][nj] == '#') {
                    cnt++;
                }
            }
            board[i][j] = cnt + '0';
        }
    }
    REP(i, H) {
        cout << board[i] << endl;
    }
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <complex>
#include <cmath>
#include <algorithm>
#include <valarray>

using namespace std;
typedef long long ll;
typedef __int128 cent;
typedef long double R;

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

ll dp[1<<20];
int main() {
    int n;
    ll m;
    cin >> n >> m;
    cent a[20];
    for (int i = 0; i < n; i++) {
        ll aa;
        cin >> aa;
        a[i] = aa;
    }
    for (int i = 0; i < (1<<n); i++) {
        cent re = 1;
        for (int j = 0; j < n; j++) {
            if ((i & (1<<j)) == 0) continue;
            re = re/gcd(re, a[j])*a[j];
            if (m < re) break;
        }
        dp[i] = m / re;
    }


    for (int i = 0; i < n; i++) {
        for (int j = 0; j < (1<<n); j++) {
            if (j & (1<<i)) continue;
            dp[j] -= dp[j ^ (1<<i)];
        }
    }


    for (int i = 0; i < n; i++) {
        for (int j = 0; j < (1<<n); j++) {
            if (!(j & (1<<i))) continue;
            dp[j] += dp[j ^ (1<<i)];
        }
    }



    R p[20];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i] /= 100;
    }
    R sm = 0;
    for (int i = 0; i < (1<<n); i++) {
        R pp = 1;
        for (int j = 0; j < n; j++) {
            if (i & (1<<j)) {
                pp *= 1-p[j];
            } else {
                pp *= p[j];
            }
        }
        sm += pp * (m-dp[i]);
    }
    printf("%.20Lf\n", sm);
    return 0;
}

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

using namespace std;

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

    int n = s.length();
    vector<long long> l(n + 1, 0);
    vector<long long> r(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        if (s[i] == '<') l[i + 1] = l[i] + 1;
    }

    for (int i = n - 1; i >= 0; --i) {
        if (s[i] == '>') r[i] = r[i + 1] + 1;
    }

    long long ans = 0;
    for (int i = 0; i <= n; ++i) {
        ans += max(l[i], r[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8708
a = raw_input().replace("egg","0").replace("chicken","1")
for i in range(len(a)-2,-1,-1):
	if a[i] == a[i+1]: a = a[:i+1] + " " + a[i+1:]
a = sorted(a.split(), key = lambda x:len(x), reverse = True)
print "egg" if a[0][-1] == "0" else "chicken"

Measured memory_bytes: 4240
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	if(a.size()>b.size())cout<<"GREATER";
	else
	   if(a.size()<b.size())cout<<"LESS";
	   else
	      if(a>b)cout<<"GREATER";
	      else if(a==b)cout<<"EQUAL";
	            else cout<<"LESS";
	return 0;
}

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

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;
int N;


int main(void) {
    scanf("%d", &N);
    bool ok = true;
    rep(i, 0, N) {
        int a;
        cin >> a;
        if (a%2==0) {
            if (a%3!=0&&a%5!=0) ok = false;
        }
    }

    if (ok) puts("APPROVED");
    else puts("DENIED");

	return 0;
}


Measured memory_bytes: 256
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

import math

dist = [[0] * N for _ in range(N)]
for i in range(N):
    xi, yi = xy[i]
    for j in range(i, N):
        xj, yj = xy[j]
        dist_tmp = math.sqrt((xi - xj) ** 2 + (yi - yj) ** 2)
        dist[i][j] = dist[j][i] = dist_tmp

ans = sum([sum([dist[i][j] for j in range(N)]) for i in range(N)]) / N
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
vector<long long> a, f;
long long n, k;
long long z = 0;
bool check(long long x) {
    long long co = 0;
    for (int i = 0; i < n; i++) {
        long long m = x / f[i];
        co += max(z, a[i] - m);
    }
    if (co <= k) {
        return true;
    }
    else {
        return false;
    }
}
int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        long long a1;
        cin >> a1;
        a.emplace_back(a1);
    }
    for (int i = 0; i < n; i++) {
        long long f1;
        cin >> f1;
        f.emplace_back(f1);
    }
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());
    long long ok = 1844674407300000000, ng = -1;
    while (ok - ng > 1) {
        long long mid = (ok + ng) / 2;
        if (check(mid)) {
            ok = mid;
        }
        else {
            ng = mid;
        }
    }
    cout << ok << endl;
}


Measured memory_bytes: 7912
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();

        int result = 0;

        for (int i = 1; i < n; i++) {
            result += (n - 1) / i;
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 35784