akhauriyash/Code-Regression huggingface dataset:
let for_range s e step f =
  let rec loop i =
    if i > e then ()
    else
      begin f i;loop (i + step) end
  in loop s;;

let a =
  let num = 1000000 in
  let p = Array.init (num+1) (fun x -> 1) in
  let rec loop i =
    if i*i < num then
      begin
        for_range (i+i) num i (fun x -> p.(x) <- 0);
        loop (i+2)
      end
  in
  p.(0) <- 0; p.(1)<-(0);
  for_range 4 num 2 (fun x -> p.(x) <- 0);
  loop 3;
  let rec read () =
    try let n = read_int () in
        print_int (Array.fold_left (+) 0 (Array.sub p 0 (n+1)));
        print_newline ();
        read ()
    with End_of_file -> ()
  in read ();;

Measured memory_bytes: 74952
#include <iostream>

using namespace std;

bool isRightTriangle(int a, int b, int c)
{
	return (a*a + b*b == c*c);
}

int main()
{
	int num_of_test;
	cin >> num_of_test;
	
	int a,b,c;
	for (int i=0; i<num_of_test; i++) {
		cin >> a; cin >> b; cin >> c;
		if ( isRightTriangle(a,b,c) || isRightTriangle(c,a,b) || isRightTriangle(b,c,a) ) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 2964
//int a = s - '0'; 文字から数字
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;

//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

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

	ll ans = 0;
	for(ll a = 1; a <= N; a++){
		ans += floor((N-1)/a);
	}

	cout << ans << endl;
}	

Measured memory_bytes: 11004
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int s;
int ta, mu;

signed main(){
	cin >> s;
	ta = (int)sqrt(s);
	if (ta*ta != s)ta++;
	if (s <= ta * (ta - 1))mu = ta - 1;
	else mu = ta;
	cout << 0 << " " << 0 << " " << ta << " " << 1 << " " << ta * mu - s << " " << mu << endl;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    
    vector<int> g1 = {1, 3, 5, 7, 8, 10, 12};
    vector<int> g2 = {4, 6, 9 ,11};
    int g3 = 2;
    
    int ga = 0, gb = 0;
    for (int g : g1) {
        if (g == a) ga = 1;
        if (g == b) gb = 1;
    }
    
    for (int g : g2) {
        if (g == a) ga = 2;
        if (g == b) gb = 2;
    }
    
    if (a == g3) ga = 3;
    if (b == g3) gb = 3;
    
    cout << (ga == gb ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;


int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}


int main()
{
	long long int a, b;

	cin >> a >> b;

	if (a + b >= a - b) {
		if(a + b >= a * b)
			cout << a + b << endl;
		else
			cout << a * b << endl;
	}
	else {
		if (a - b >= a * b)
			cout << a - b << endl;
		else
			cout << a * b << endl;
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int D;
    cin>>D;
    if(D==25){cout<<"Christmas"<<endl;}
    if(D==24){cout<<"Christmas Eve"<<endl;}
    if(D==23){cout<<"Christmas Eve Eve"<<endl;}
    if(D==22){cout<<"Christmas Eve Eve Eve"<<endl;}
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n,k = [int(x) for x in input().split()]

ret = 0
for b in range(1,n+1):
    r = k - b%k
    # print(b,r)
    if r==k:
        # print("|",(n//k)**2)
        ret += (n//k)**2
    elif (2*r)%k==0:
        if r<=n%k:
            # print("*", (n//k+1)**2)
            ret += (n//k+1)**2
        else:
            # print("*", (n//k)**2)
            ret += (n//k)**2
print(ret)
# print("---")
# ret = 0
# for a in range(1,n+1):
#     for b in range(1,n+1):
#         for c in range(1,n+1):
#             if (a+b)%k==0 and (b+c)%k==0 and (a+c)%k==0:
#                 # print(a,b,c)
#                 ret += 1
# print(ret)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
#define pii pair<ll int, ll int>
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define repi(i, n) for(ll i=0; i<n; i++)
#define rep(i, a, b) for(ll i=a; i<=b; i++)
#define M 1000000007
#define INF 1e10

using namespace std;
 
struct Item{
    ll w, v;
};
 
int main() {
    ios
    ll n, W;
    cin>>n>>W;
    vector <Item> a;
    ll V=0;
    repi(i, n){
        ll w, v;
        cin>>w>>v;
        a.pb({w,v});
        V += v;
    }
    vector <vector<ll>> dp(n, vector<ll>(V+1));
    repi(i, n){
        repi(j, V+1){
            if(j==0) dp[i][j] = 0;
            else if(i==0) dp[i][j] = (a[i].v == j ? a[i].w : (ll)INF);
            else dp[i][j] = min(dp[i-1][j], (a[i].v <= j ? a[i].w + dp[i-1][j-a[i].v] : (ll)INF));
        }
    }
    ll ans = 0;
    repi(i, V+1) if(dp[n-1][i] <= W) ans = max(ans , i);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 82284
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void printDivisors(ll n,vector <ll>& v) 
{  
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i==0) 
        { 
            if (n/i == i)
                v.push_back(i); 
            else
            { 
                v.push_back(i); 
                v.push_back(n/i); 
            } 
        } 
    } 
}
int main()
{
  ll n;
  cin>>n;
  vector<ll> v;
  printDivisors(n,v);ll min=n;
  for(auto i=v.begin();i!=v.end();i++){
    //cout<<*i<<" ";
    if(*i-1+n/(*i)-1 < min)
      min=*i-1+n/(*i)-1;
  }
  cout<<min<<endl;
}

Measured memory_bytes: 384
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))

a, b = map(int, input().split())

ans = 0
outlet = 1
while outlet < b:
    outlet -= 1
    outlet += a
    ans += 1
print(ans)



Measured memory_bytes: 9140
if __name__ == "__main__":
    X, K, D = map(lambda x: abs(int(x)), input().split())

    if X - K*D >= 0:
        print(X - K*D)
    else:
        xdd = X // D
        k = xdd + (K - xdd) % 2
        print(abs(X - k*D))


Measured memory_bytes: 9076
import java.util.Scanner;

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

    int N = sc.nextInt();

    int remainder = N % 2;
    int quotient = N / 2;

    if (remainder == 0) {
      System.out.println("0.5000000000");
    } else {
      double probability = (quotient + 1.0) / N;
      System.out.println(probability);
    }
  }
}


Measured memory_bytes: 22868
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
    int x,a,b;
    cin>>x>>a>>b;
    if(b>=x+a+1){
        cout<<"dangerous"<<endl;
    }else if(a>=b){
        cout<<"delicious"<<endl;
    }else{
        cout<<"safe"<<endl;
    }
 
    
    
 
return 0;
}

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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)2
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 9999999999999999
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 100005
#define mxnn 2000005
vector<int>g[mxn],to(mxn),vis(mxn);
int ti = 0;
void dfs(int a){
vis[a] = 1;
for(int i = 0;i<g[a].size();i++){
    int y = g[a][i];
    if(vis[y]) continue;
    dfs(y);
    }
to[ti--] = a;
}
int dp[mxn];
int32_t main(){
sp;
int n,m;
cin >>n >>m;
ti = n;
while(m--){
    int u,v;
    cin >>u >>v;
    g[u].pb(v);
}
for(int i = 1;i<=n;i++) if(!vis[i]) dfs(i);
for(int i = 1;i<=n;i++){
    int x = to[i];
    for(int j = 0;j<g[x].size();j++){
        int y = g[x][j];
        dp[y] = max(dp[y],dp[x]+1);
    }
}
int mx = 0;
for(int i = 1;i<=n;i++) mx = max(mx,dp[i]);
cout<<mx;
return 0;
}


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

using namespace std;

const int N = 1e5+5 , mod = 1e9 +7 , mx = 1e6 +5;


long long n , m , v , p ;
long long sol ;
long long a[N];
long long pre[N];

int main()
{
    cin>>n>>m>>v>>p;
    for(int i = 0 ; i< n  ; i++)
        cin>>a[i];
    sort(a , a + n);
    pre[0] = a[0];
    for(int i = 1;i<n;i++)
    {
        pre[i] = pre[i-1] + a[i];
    }
    v = n - v;
    for(long long i = 0;i<n;i++)
    {
        int l = i + 1 , r  = n-1;
        while(l<=r)
        {
            int mid = (l+r) /2;
            if(a[mid] - a[i] > m || pre[mid] - pre[i] - 1LL * a[i] * (mid - i) > 1LL*v * m)
            {
                r = mid - 1 ;
            }
            else
            {
                l = mid+1;
            }
        }
        if(n - r <= p)
            sol++;
    }
    cout<<sol;
    return 0;
}


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

// region template
#define rep(i, a, b) for (ll i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    for (;;) {
        long long n = -1, d;
        ll v = 0;

        string s;
        cin >> s;

        if (s == "#") break;

        reverse(all(s));

        string s2;
        for (char c : s) if (c == 'n' || c == 'w') s2.push_back(c);

        for (char c : s2) {
            if (n == -1 && (c == 'n' || c == 'w')) {
                if (c == 'n')
                    n = 0, d = 1;
                else if (c == 'w')
                    n = 90, d = 1;
                ++v;
            } else {
                if (c == 'w') {
                    ll n2 = 90, d2 = 1ll << v;
                    tie(n, d) = pair<ll, ll>{n * d2 + n2 * d, d * d2};
                    ++v;
                } else if (c == 'n') {
                    ll n2 = 90, d2 = 1ll << v;
                    tie(n, d) = pair<ll, ll>{n * d2 - n2 * d, d * d2};
                    ++v;
                }

                ll g = __gcd(n, d);
                n /= g, d /= g;

                // cout << n << " " << d << endl;

            }
        }

        // cout << string(s.rbegin(), s.rend()) << ": ";
        cout << n;
        if (d != 1) cout << "/" << d;
        cout << endl;
    }
}



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

using namespace std;

int main(){
    int A[3];
    for(int i=0; i<3; i++) cin >> A[i];
    sort(A, A + 3);
    A[0] = A[2] - A[0];
    A[1] = A[2] - A[1];
    if((A[1] - A[0]) % 2 == 0) cout << (A[0] + A[1]) / 2 << endl;
    else cout << (A[0] + A[1] - 1) / 2 + 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD= 1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  string s;
  cin >> n >> s;
  
  map<pair<string,string>,ll>mp;
  for(int bit=0;bit<(1<<n);bit++){
    string u="", v="";
    rep(i,n){
      if(bit & (1<<i)){
        u+=s[2*n-1-i];
      }
      else v+=s[2*n-1-i];
    }
    auto p=make_pair(u,v);
    mp[p]++;
  }
  
  ll ans=0;
  for(int bit=0;bit<(1<<n);bit++){
    string u="", v="";
    rep(i,n){
      if(bit & (1<<i)){
        u+=s[i];
      }
      else v+=s[i];
    }
    auto p=make_pair(u,v);
    ans+=mp[p];
  }
  cout << ans << endl;
        
  
}


Measured memory_bytes: 91904
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>
#define ll long long
using namespace std;


int main() {
	int a, p, ans;
	cin >> a >> p;
	ans = a * 3 + p;
	ans /= 2;
	cout << ans << endl;
	return 0;
}


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

using namespace std;

using ll = long long;

int N, MOD;
vector<vector<int>> adj;
vector<vector<ll>> dp;

ll Dfs(const int p, const int v) {
    ll res = 1;
    for (size_t i = 0; i < adj[v].size(); ++i) {
        if (adj[v][i] != p) {
            dp[v][i] = Dfs(v, adj[v][i]);
            (res *= (dp[v][i] + 1)) %= MOD;
        }
    }
    return res;
}

void Rev(const int p, const int v, const ll add) {
    for (size_t i = 0; i < adj[v].size(); ++i)
        if (adj[v][i] == p) {
            dp[v][i] = add;
            break;
        }

    const int deg = adj[v].size();
    vector<ll> l(deg), r(deg);
    for (int i = 0; i < deg; ++i) r[i] = ((l[i] = (dp[v][i] + 1)) %= MOD);
    for (int i = 1; i < deg; ++i) (l[i] *= l[i - 1]) %= MOD;
    for (int i = deg - 2; 0 <= i; --i) (r[i] *= r[i + 1]) %= MOD;

    for (int i = 0; i < deg; ++i) {
        if (adj[v][i] == p) continue;

        ll add_c = 1;
        if (i != 0) (add_c *= l[i - 1]) %= MOD;
        if (i != deg - 1) (add_c *= r[i + 1]) %= MOD;
        Rev(v, adj[v][i], add_c);
    }
}

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

    cin >> N >> MOD;

    adj.resize(N);
    for (int i = 0, x, y; i < N - 1; ++i) {
        cin >> x >> y;
        adj[x - 1].push_back(y - 1);
        adj[y - 1].push_back(x - 1);
    }

    dp.resize(N);
    for (int v = 0; v < N; ++v) dp[v].resize(adj[v].size());
    Dfs(-1, 0);
    Rev(-1, 0, 0);

    for (int v = 0; v < N; ++v) {
        ll ans = 1;
        for (ll add : dp[v]) (ans *= (add + 1)) %= MOD;
        cout << ans << '\n';
    }

    return 0;
}


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

int main() {

    int N;

    cin >> N;

    int total = 0;

    for (int i = 1; i <= N; i++) {

        if(i % 2 == 0){
            continue;
        }

        int cnt = 0;
        for (int j = 1; j <= i; j++) {
            if(i % j == 0){
                cnt++;
            }
        }
        if (cnt == 8){
            total++;
        }
    }
    cout << total << endl;

    return 0;

}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;

bool is_prime(int N){
    bool res = true;
    for(int i = 2; i < sqrt(N) + 1; i++){
        if(N % i == 0){
            res = false;
            break;
        }
    }
    if(N == 2)res = true;
    return res;
}

int main(){
    int Q;
    scanf("%d", &Q);
    vector<int> Cumu(100010, 0);
    for(int i = 3; i < 100010; i++){
        Cumu[i] = Cumu[i - 1];
        if(i % 2 == 1){
            if(is_prime(i) && is_prime((i + 1) / 2)){
                Cumu[i]++;
            }
        }
    }
    for(int i = 0; i < Q; i++){
        int L, R;
        scanf("%d%d", &L, &R);
        cout << Cumu[R] - Cumu[L - 1] << '\n';
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

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


Measured memory_bytes: 3084
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    string s;
    cin>>s;
    int n=s.size();
    vec a(n,0);
    int k=0;
    queue<int> quer,quel;
    int cntr=0,cntl=0;
    while(k<n-1){
        if(s[k]==s[k+1]){
            if(s[k]=='R') cntr++;
            else cntl++;
        }else{
            if(s[k]=='R'){
                cntr++;
                quer.push(cntr);
            }else{
                cntl++;
                quel.push(cntl);
                cntl=0;
                cntr=0;
            }
        }
        k++;
    }
    cntl++;
    quel.push(cntl);
    bool ok=true;
    k=0;
    while(!quel.empty()){
        if(ok){
            int r=quer.front();
            quer.pop();
            for(int i=0;i<r;i++){
                if(((k+r)-(i+k))%2==0){
                    a[k+r]++;
                }else{
                    a[k+r-1]++;
                }
            }
            k+=r;
            ok=false;
        }else{
            int l=quel.front();
            quel.pop();
            for(int i=0;i<l;i++){
                if(((i+k)-(k-1))%2==0){
                    a[k-1]++;
                }else{
                    a[k]++;
                }
            }
            k+=l;
            ok=true;
        }
    }
    rep(i,n) cout<<a[i]<<' ';
    cout<<endl;
}

Measured memory_bytes: 1408
using System;

    class Program
    {
        static void Main(string[] args)
        {
            string[] num = Console.ReadLine().Split(' ');

            int a, b, c, d;
            a = int.Parse(num[0]);
            b = int.Parse(num[1]);
            c = int.Parse(num[2]);

            if (a > b)
            {
                d = a;
                a = b;
                b = d;
            }

            if (b > c)
            {
                d = b;
                b = c;
                c = d;
            }

            if (a > b)
            {
                d = a;
                a = b;
                b = d;
            }
            Console.WriteLine(a + " " + b + " " + c);  
        }
    }




Measured memory_bytes: 9160
#include<stdio.h>
#define NIL -1

typedef struct
{
  int parent;
  int r;
  int l;
} Node;
  
Node T[1000000];
int D[1000000];

void depth(int u,int p)
{
  D[u] = p;
  if(T[u].r != NIL) depth(T[u].r,p);
  if(T[u].l != NIL) depth(T[u].l,p + 1);
}
 
int main()
{
  int i = 0,j = 0,n,v,d,c = 0,l,r,x = 0;

  scanf("%d",&n);

  for(i = 0;i < n;i++)
    {
      T[i].parent = NIL;
      T[i].l = NIL;
      T[i].r = NIL;
    }
  
  for(i = 0;i < n; i++)
    {
      scanf("%d%d",&v,&d);
      for(j = 0;j < d;j++)
	{
	  scanf("%d",&c);
	  if(j == 0) T[v].l = c;
	  else T[l].r = c;
	  l = c;
	  T[c].parent = v;
	}
    }
  for(i = 0;i < n;i++){
    if(T[i].parent == NIL) r = i;
  }
  depth(r,0);

  for(i = 0;i < n;i++)
    {
      printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,D[i]);
      if(T[i].parent == NIL) printf("root, ");
      else if(T[i].l == NIL) printf("leaf, ");
      else printf("internal node, ");

      x = T[i].l;
      printf("[");
      for(j = 0;x != NIL;x = T[x].r,j++)
	{
	  if(j) printf(", ");
	  printf("%d",x);
	}
      printf("]\n");
    }

  return 0;
}

  



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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if ((a < c && c < b) || (b < c && c < a))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

printList [a] = print a
printList (a:as) = putStr ( show a ) >> putChar ' ' >> printList as

main = do
	[ n, x, t ] <- readInts
	print $ ( n + x - 1 ) `div` x * t

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

int main()
{	
	int N,K,Q;
	cin >> N >> K >> Q;
	vector<int> v(N);
	rep(i,Q){
		int n;
		cin >> n;
		v[n-1]++;
	}
	rep(i,N){
		if(Q-v[i]>=K)cout <<"No"<<endl;
		else cout << "Yes" <<endl;
	}
}

Measured memory_bytes: 1024
class UnionFind:
    def __init__(self, size):
        self.parent = list(range(size))
        self.rank = [0] * size

    def root(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.root(self.parent[x])
        return self.parent[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return

        if self.rank[x] > self.rank[y]:
            self.parent[y] = x
        else:
            self.parent[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def same(self, x, y):
        return self.root(x) == self.root(y)


def main():
    n, m = map(int, input().split())
    ps = list(map(int, input().split()))

    # 1-origin
    union_find = UnionFind(n + 1)
    for i in range(m):
        x, y = map(int, input().split())
        union_find.unite(x, y)

    ans = 0
    for key, value in enumerate(ps, 1):
        if union_find.same(key, value):
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 13876
#####segfunc#####
def segfunc(x, y):
    return min(x, y)
#################


#####ide_ele#####
ide_ele = pow(2, 31) - 1
#################


class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """

    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res


# a = [14, 5, 9, 13, 7, 12, 11, 1, 7, 8]
# seg = SegTree(a, segfunc, ide_ele)
# # [0, 8)の最小値を表示
# print(seg.query(0, 8))  # 1

# # 5番目を0に変更
# seg.update(5, 0)

# # [0, 8)の最小値を表示
# print(seg.query(0, 8))  # 0
n, q = map(int, input().split())
a = [pow(2, 31) - 1] * n
seg = SegTree(a, segfunc, ide_ele)
for _ in range(q):
    com, *xy = map(int, input().split())
    if com == 0:
        # print(xy[0], xy[1])
        seg.update(xy[0], xy[1])
    else:
        v = seg.query(xy[0], xy[1] + 1)
        print(v)



Measured memory_bytes: 9496
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    cin >> S;
    for(int i=0;i<S.size()/2;i++){
        if(S.at(i)!=S.at(S.size()-i-1)){
            cout << "No"<<endl;
            return 0;
        }
    }
    for(int i=0;i<(S.size()-1)/2;i++){
        if(S.at(i)!=S.at((S.size()-1)/2-i-1)){
            cout << "No"<<endl;
            return 0;
        }
    }
    for(int i=0;i<(S.size()-1)/2;i++){
        if(S.at((S.size()+1)/2+i)!=S.at(S.size()-i-1)){
            cout << "No"<<endl;
            return 0;
        }
    }
    cout << "Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7; 

fn main(){
    let n: usize = read();
    let m: usize = read();
    let mut ab: Vec<Vec<usize>> = vec![vec![]; m];
    for _ in 0..n {
        let a: usize = read();
        let b: usize = read();
        if m >= a{
            ab[m - a].push(b);
        }
    }
    let mut q = BinaryHeap::new();
    let mut ans: usize = 0;
    for i in (0..m).rev(){
        for j in &ab[i]{
            q.push(j);
        }
        if !q.is_empty(){
            ans += *q.pop().unwrap();
        }
    } 
    println!("{}", ans);
}

fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll mod = 1000000007;

using vec = vector<ll>;
using mat = vector<vec>;

mat mul(const mat &a, const mat &b){
    int n = a.size();
    mat c(n,vec(n));
    rep(i,n)rep(j,n)rep(k,n) (c[i][j] += a[i][k]*b[k][j]) %= mod;
    return c;
}

mat pow(mat a, ll n){
    int A = a.size();
    mat r(A,vec(A));
    rep(i,A) r[i][i] = 1;

    while(n){
        if(n&1) r =  mul(r,a);
        a = mul(a,a);
        n >>= 1;
    }
    return r;
}

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

    vector<vector<ll>> a(n,vector<ll>(n));
    rep(i,n)rep(j,n) cin >>a[i][j];

    mat p = pow(a,k);
    ll ans = 0;
    rep(i,n)rep(j,n) (ans += p[i][j]) %= mod;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#include <set>

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 rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n;
	cin >> n;
	vector<int>l(n);
	rep(i, n) {
		cin >> l[i];
	}
	int ans = 0;
	sort(l.begin(),l.end());
	rep(i, n) {
		FOR(j,i+1 ,n) {
			bool end = false;
			RFOR(k, j+1 , n) {
				//cout << i << " " << j << " " << k << endl;
				if (end)break;
				else if (l[i] + l[j] > l[k]) {
					ans += k-j;
					end = true;
				}
			}
		}
	}
	print(ans);
}

Measured memory_bytes: 256
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

/*考えを書くスペース
  AtCoder Grand Contest 019-A


*/
//main.cpp----------------------------
#define max_n 200000

void solve();

ll x, y;

int main() {
  cin >> x >> y;

  solve();

  return 0;
}

void solve() {
  ll size = 0;
  while(x<=y) {
    size += 1;
    x *= 2;
  }

  cout << size << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int w = sc.nextInt();
int n = sc.nextInt();
int[] values = new int[w];
for(int i=0;i<values.length;i++){
values[i]=i+1;
}
for(int i=0;i<n;i++){
String str = sc.next();
String[] ab = str.split(",");
int a = Integer.parseInt(ab[0])-1;
int b = Integer.parseInt(ab[1])-1;
int c = values[a];
values[a] = values[b];
values[b] = c;
}
for(int i=0;i<values.length;i++){
System.out.println(values[i]);
}
}
}


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

int main(){
    double num;
    cin >> num;
    double test1 = (num * num) * 3.14159265359;
    double test2 = (num + num) * 3.14159265359;
    cout << fixed << setprecision(6) << test1 << " " << test2 << endl;
}

Measured memory_bytes: 1288
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if ( ch == 'A' ) return 1;
  else if ( ch == 'C' ) return 2;
  else if ( ch == 'G' ) return 3;
  else if ( ch == 'T' ) return 4;
  else return 0;
}

long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ) {
    sum += p * (getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M - 1)); }

int find(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for ( i = 0; ; i++) {
    h = ( h1(key) + i * h2(key)) % M;
    if ( strcmp(H[h], str) == 0) return 1;
    else if ( strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key, i, h;
  key = getKey(str);
  for(i = 0; ;i++){
    h = (h1(key) + i * h2(key)) % M;
    if ( strcmp(H[h], str) == 0 ) return 1;
    else if (strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main() {
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
  scanf("%d", &n);
  for ( i = 0; i < n; i++) {
    scanf("%s %s", com, str);

    if ( com[0] == 'i' ) {
      insert(str);
    } else {
      if ( find(str) ) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 17052
import sys
#input = sys.stdin.buffer.readline

def main():
    N,A,B,C,D = map(int,input().split())
    s = str(input())
    
    if "##" in s[A:max(C,D)]:
        print("No")
    elif (C > D and "..." not in s[B-2:D+1]):
        print("No")
    else:
        print("Yes")

if __name__ == "__main__":
    main()


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

int main() {

 long long int q,h,s,d;
  cin>>q>>h>>s>>d;


   long long  int x=min(min(min(8*q,4*h),2*s),d);
  long long   int y=min(min(4*q,2*h),1*s);

    int n;
    cin>>n;
    long long int sum=0;
  long long  int c=n/2;
  long long  int b=n%2;

    sum+=c*x+b*y;
    cout<<sum;

return 0;


}


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

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


  int cnt = 0;
  for(int x = a; x <= b; x++){
    if(c % x == 0) cnt++;
  }


  cout<<cnt<<endl;

 return 0;
}


Measured memory_bytes: 3100
N=int(input())
S=[]
for _ in range(N):
    s=input()
    S.append("".join(sorted(s)))
    #S.append(sorted(s))
#print(S)
re=0
dt={}
for i in range(N):
    if S[i] in dt:
        dt[S[i]]+=1
    else:
        dt[S[i]]=1
for v in dt.values():
    if v>=2:
        v-=1
        re+=(v*(v+1)//2)

print(re)


Measured memory_bytes: 19476
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
int ddx[8]={0,0,-1,1,1,1,-1,-1};
int ddy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	int N,K;
	cin>>N>>K;
	vector<int> a;
	for(int i=0;i<N;i++){
		int b;
		cin>>b;
		a.pb(b);
	}
	sort(a.begin(),a.end(),greater<int>());
	int ans=0;
	for(int i=0;i<K;i++){
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}

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


int main(){
    int N;
    cin >> N;
    int T[N];
    int A[N];
    for(int i=0; i<N; i++){
        cin >> T[i] >> A[i];
    }

    long long currentT=T[0], currentA=A[0];
    for(int i=1; i<N; i++){
        long long nextT=T[i], nextA=A[i];
        if(nextT < currentT || nextA < currentA){
            long long scale = max(currentT/nextT,currentA/nextA);

            nextT = T[i]*scale;
            nextA = A[i]*scale;
            if(nextT < currentT || nextA < currentA){
                scale++;
                nextT = T[i]*scale;
                nextA = A[i]*scale;
            }
        }
        currentT = nextT;
        currentA = nextA;
    }
    cout << (currentT + currentA) << '\n';
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
long long x,y,s;
string a[210];
int main(){
	cin>>x>>y;
	for(int i=1;i<=x;i++)
		cin>>a[i];
	for(int i=1;i<=x;i++){
		for(int j=0;j<y;j++){
			if(a[i][j]=='#'){
				cout<<a[i][j];
				continue;
			} 
			if(a[i+1][j]=='#')s++;
			if(a[i-1][j]=='#')s++;
			if(a[i+1][j+1]=='#')s++;
			if(a[i][j+1]=='#')s++;
			if(a[i-1][j+1]=='#')s++;
			if(a[i+1][j-1]=='#')s++;
			if(a[i][j-1]=='#')s++;
			if(a[i-1][j-1]=='#')s++;
			cout<<s;
			s=0;
		}
		cout<<endl;
	}
	return 0;
}
/*

*/

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
typedef long long ll;

int main() {
	int n, m,a,b,c;
	string s;
	cin >> s;
  if (s[0]==s[1]&&s[1]==s[2]) cout<<"No"<<endl;
  else
	cout<< "Yes" <<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,n) for(int i=1;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define Rrep(i,n) for(int i=n-1;i>0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#define P pair<int,int>
#define Pll pair<ll,ll>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main(){
    ll n,k; cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(ALL(a));
    ll dest=n*(n-1LL)/2LL-k+1;
    ll l=-1e18-1,r=1e18+1;
    while(r-l>1){
        ll mid=(r+l)/2;
        ll res=0;
        rep(i,n){
            if(a[i]==0){
                if(mid<=0) res+=n-1;
            }
            else if(a[i]>0){
                if(a[i]*a[n-1]<mid) continue;
                int li=-1,ri=n-1;
                while(ri-li>1){
                    int j=(li+ri)/2;
                    if(a[i]*a[j]>=mid) ri=j; //ok
                    else li=j;
                }
                res+=n-ri;
                if(a[i]*a[i]>=mid) res--;
            }else{
                if(a[i]*a[0]<mid) continue;
                int li=0,ri=n;
                while(ri-li>1){
                    int j=(li+ri)/2;
                    if(a[i]*a[j]>=mid) li=j; //ok
                    else ri=j;
                }
                res+=li+1;
                if(a[i]*a[i]>=mid) res--;
            }
        }
        res/=2;
        if(res>=dest) l=mid;
        else r=mid;
    }
    cout << l << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
	int a;
	double g = 0.5;
	int c=0;

	scanf("%d", &a);

	for (int i = 0; i < a; ++i) {
		if (i % 2 == 0) {
			c++;
		}
	}
	g = (double)c / (double)a;
		printf("%f",g);
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int n, m=-2;
	string ans = "";
	cin >> n;
	if (n == 0) ans = "0";
	while (n != 0)
	{
		if (n%m == 0)
		{
			ans += '0';
			n /= m;
		}
		else
		{
			ans += '1';
			n = (n - 1) / m;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[]
for i in range (n):
    a.append(list(map(int,input().split())))

b=[]
for i in range (m):
    b.append(int(input()))

for i in range(n):
    c=0
    for j in range(m):
        c+=a[i][j]*b[j]
    print(c)


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

#define ll long long
#define mod 1000000007
#define pii pair<ll,ll>

#define debug(a) { cout << #a << " = " << a << endl;}

void sep() {
    cout << "-------------BLOCK-----------------\n";
}

template<typename T>
void debugv(vector<T> arr) {
    for (auto t: arr)
        cout << t << " ";
    cout << "\n";
}

template<typename T>
void debugarr(T arr, int n) {
    for (int i=0;i<n;i++) cout << arr[i] << " ";
    cout << "\n";
}

const int maxn = 1e5+1;
ll arr[maxn], n, m, t, k;
unordered_map<ll,ll> u;

ll __min(ll a, ll b) {
    return a < b ? a : b;
}

ll __max(ll a, ll b) {
    return a > b ? a : b;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin>>n;
    vector<ll> dp(n+1, 0);
    dp[0] = 1;
    for (int i=1;i<=n;i++) {
        for (int j=3;j<=i;j++) {
            dp[i] = (dp[i] + dp[i-j])%mod;
        }
    }
    cout << dp[n] << endl;
}



Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set> 
#include<cmath>
using namespace std;
long long p = 998244353;
//long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)
#define upper(h,val) upper_bound(h.begin(),h.end(),val)
#define mint modint<998244353>
#define end_s(a) cout <<a<<endl;return 0
template <std::uint_fast64_t Modulus> class modint {
	using u64 = std::uint_fast64_t;

public:
	u64 a;

	constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
	constexpr u64 &value() noexcept { return a; }
	constexpr const u64 &value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint &operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint &operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint &operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint &operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) { pa[x] = y; }
}
signed main() {
	int n; cin >> n;
	vel d(n);
	int ans = 0;
	rep(i, n) {
		cin >> d[i];
		rep(j, i) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import math
n,d = map(int,input().split())
c=0
pos={}
for i in range(n):
    pos[i]=list(map(int,input().split()))

for i in range(n):
    for j in range(i+1,n):
        x = 0
        for k in range(d):
            x += (abs(pos[i][k]-pos[j][k]))**2
        if (math.sqrt(x)).is_integer():
            c += 1

print (c)


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

int main(){
  int N,L;
  cin >> N >> L;
  vector<string> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  for(int i=0;i<N;i++){
    cout << A.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256
use std::io;

fn main() {
	let mut buf = String::new();
    let mut a = String::new();

    let _ = io::stdin().read_line(&mut buf);
    let vec: Vec<&str> = buf.split_whitespace().collect();

    let summer_vacation: i32 = vec[0].parse().unwrap();
    let homework = vec[1].parse().unwrap();

    let _ = io::stdin().read_line(&mut a);
    let ai: Vec<&str> = a.split_whitespace().collect();

    let mut result: i32 = summer_vacation;
    let mut a: i32;
    for x in 0..homework {
        a = ai[x].parse().unwrap();
        result = result - a;

        if result < 0 {
            result = -1;
            break;
        }
    }

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

Measured memory_bytes: 2432