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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

class mint {
  private:
    ll x;

  public:
    constexpr mint(const ll x = 0) noexcept : x((x % mod + mod) % mod) {}
    constexpr ll value() noexcept { return x; }
    constexpr mint operator += (const mint right) noexcept {
      if ((x += right.x) >= mod) x -= mod;
      return *this;
    }
    constexpr mint operator -= (const mint right) noexcept {
      if ((x += mod - right.x) >= mod) x -= mod;
      return *this;
    }
    constexpr mint operator *= (const mint right) noexcept {
      x = x * right.x % mod;
      return *this;
    }
    constexpr mint operator /= (const mint right) noexcept {
      return *this *= right.inv();
    }
    constexpr mint operator + (const mint right) const noexcept {
      return mint(*this) += right;
    }
    constexpr mint operator - (const mint right) const noexcept {
      return mint(*this) -= right;
    }
    constexpr mint operator / (const mint right) const noexcept {
      return mint(*this) /= right;
    }
    constexpr mint operator * (const mint right) const noexcept {
      return mint(*this) *= right;
    }
    constexpr mint inv() const {
      return pow(mod-2);
    }
    constexpr mint pow(ll n) const {
      if (n == 0) return 1;
      mint a = pow(n>>1);
      a *= a;
      if (n & 1) a *= *this;
      return a;
    }
};

signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  
  int n; cin >> n;
  map<int,int> div;

  rep2(i, 1, n) {
    int x = i;
    rep2(j, 2, sqrt(x)) {
      int cnt = 0;

      while (x % j == 0) {
        x /= j;
        ++cnt;
      }

      div[j] += cnt;
    }

    if (x != 1) ++div[x];
  }

  mint ans = 1;
  for (auto e : div) {
    ans *= e.se+1;
  }

  cout << ans.value() << endl;
}

Measured memory_bytes: 3668
#include<cstdio>
#include<algorithm>
using namespace std;
int ans;
int main() {
	int a[4];
	scanf("%d%d%d",&a[1],&a[2],&a[3]);
	while(a[1]!=a[2]||a[2]!=a[3]||a[1]!=a[3]) {
		sort(a+1,a+4);
		ans++;
		if(a[2]-a[1]>=2) {
			a[1]+=2;
		}
		else {
			a[1]++;
			a[2]++;
		}
		
	}
	printf("%d",ans);
}

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

long long N, L[1 << 18], cnt[1 << 18];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) { cin >> L[i]; cnt[L[i]]++; }

	// 同じ長さの棒を一本も使わない (i < j < k)
	long long ans = 0;
	for (int i = 1; i <= 1000; i++) {
		for (int j = i + 1; j <= 1000; j++) {
			int P = min(1000, i + j - 1);
			for (int k = j + 1; k <= P; k++) ans += cnt[i] * cnt[j] * cnt[k];
		}
	}

	// 同じ長さの棒を二本使う
	for (int i = 1; i <= 1000; i++) {
		for (int j = 1; j <= 1000; j++) {
			if (j == i || i * 2 <= j) continue;
			ans += (cnt[i] * (cnt[i] - 1) / 2) * cnt[j];
		}
	}

	// 同じ長さの棒を三本使う
	for (int i = 1; i <= 1000; i++) {
		ans += 1LL * cnt[i] * (cnt[i] - 1) * (cnt[i] - 2) / 6LL;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};




int main(){
	int n;
	cin >> n;
	int keta=1;
	int cp = n;
	int ju = 1;
	while(cp/10){
		keta++;
		cp/=10;
		ju *= 10;
	}

	if(keta == 1){
		// cerr << "a" << endl;
		cout << n << endl;
	}else if(n/ju == 1 && n%ju == 0){
		// cerr << "b" << endl;
		cout << 10 << endl;	
	}else{
		int ans = 0;
		while(n){
			ans += n%10;
			n /= 10;
		}
		// cerr << "c" << endl;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	string S;
	long long K;
	int x;
	cin >> S >> K;
	for (int i = 0; i < S.size(); i++) {
		K -= pow(S[i] - '0',5000*pow(10,12));
		if (K <= 0) {
			x = i; break;
		}
	}
	cout << S[x] << endl;
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main(){
  int p,q;
 
  while(cin >> p >> q){ 
    int Quo[100],Rem[100];    
    bool flg = false;
    int begin,end,t = 0;
 
    for(int i = 0 ; i < 100 ; i++ ,t++){
      p *= 10;
      Quo[i] = p / q;
      Rem[i] = p % q;
      p %= q;
 
      for(int j = 0 ; j < i ; j++){
    if(Quo[i] == Quo[j] && Rem[i] == Rem[j]){
      begin = j;
      end = i;
      goto end;
    }
      }
       
      if(!p){
    flg = true;
    break;
      }
    }
  end:
 
    if(flg){
      for(int i = 0 ; i <= t ; i++){
    cout << Quo[i];
      }
      cout << endl;
    } else {
      for(int i = 0 ; i < t ; i++){
    cout << Quo[i];
      }
      cout << endl;
    
      for(int i = 0 ; i < begin ; i++) cout << " ";
      for(int i = begin ; i < end ; i++) cout << "^"; 
      cout << endl;
    }    
  }
 
  return 0;
}

Measured memory_bytes: 2952
#include <bits/stdc++.h>
#define M 1000000007
using namespace std;

int main() {
	int n,k;
	cin>>n>>k;
	int A[n];
	for(int i=0;i<n;i++)
	{
	    cin>>A[i];
	}
	int dp[n][k+1];
	int presum[k+1];
	for(int i=0;i<n;i++)
	{
	    for(int j=0;j<=k;j++)
	    {
	        if(i==0)
	        {
	            if(j>A[i])
	            dp[i][j]=0;
	            else
	            dp[i][j]=1;
	        }
	        else if(j==0)
	        dp[i][j]=1;
	        else
	        {
	            if(j>A[i])
	            dp[i][j]=(presum[j]+M-presum[j-A[i]-1])%M;
	            else
	            dp[i][j]=presum[j];
	        }
	    }
	    presum[0]=dp[i][0];
	    for(int j=1;j<=k;j++)
	    {
	        presum[j]=(presum[j-1]%M+dp[i][j]%M)%M;
	    }
	}
	cout<<dp[n-1][k]<<endl;
	return 0;
}

Measured memory_bytes: 43040
N=int(input())
s=input()
 
dicX={s[0]:1}
dicY={}
for i in range(1,N):
    if s[i] in dicY: dicY[s[i]]+=1
    else: dicY[s[i]]=1
 
ans=0

for i in range(1,N-1):
    if not s[i] in dicX: dicX[s[i]]=1
    
    if dicY[s[i]]>1: dicY[s[i]]-=1
    else: dicY.pop(s[i])
    
    tmp=0
    for j in dicX:
         if j in dicY: tmp+=1
    ans=max(tmp,ans)
 
print(ans)

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

int main() {
    string s;
    cin >> s;
    int64_t k;
    cin >> k;
    char ans = '1';
    for(int i = 0;i < k;i++){
        if(s[i] != '1'){
            ans = s[i];
            break;
        }
    }
    cout << ans << endl;
}

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

class UnionFind {
private:
  vector<ll> data;
  vector<ll> sum;

public:
  UnionFind(ll n, vector<ll> sum): data(n, -1), sum(sum) {
  }

  ll size(ll i) { return -data[find(i)]; }
  bool root(ll i) { return data[i] < 0; }
  bool same(ll i, ll j) { return find(i) == find(j); }

  ll find(ll i) { return root(i) ? i : (data[i] = find(data[i])); }

  bool unite(ll i, ll j) {
    if(same(i, j)) return false;
    sum[find(i)] += sum[find(j)];
    data[find(i)] += data[find(j)];
    data[find(j)] = find(i);
    return true;
  }

  ll get(ll i) {
    return sum[find(i)];
  }
};

struct edge {
  ll u, v, w;
};

int main(void) {
  ll N, M;
  cin >> N >> M;
  vector<ll> W(N);
  REP(i, 0, N) cin >> W[i];
  vector<edge> edges(M);
  REP(i, 0, M) cin >> edges[i].u >> edges[i].v >> edges[i].w, edges[i].u--, edges[i].v--;

  sort(edges.begin(), edges.end(), [](const edge x, const edge y) { return x.w < y.w; });

  ll ans = 0;
  vector<ll> cnt(N, 0);
  UnionFind uf(N, W);

  REP(i, 0, M) {
    edge e = edges[i];
    ll u = e.u, v = e.v, w = e.w;

    if (!uf.same(u, v)) {
      cnt[uf.find(u)] += cnt[uf.find(v)];
      cnt[uf.find(u)]++;
      uf.unite(u, v);
    } else {
      cnt[uf.find(u)]++;
    }

    if (uf.get(u) >= w) {
      ans += cnt[uf.find(u)];
      cnt[uf.find(u)] = 0;
    }
  }

  cout << M - ans << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>                          
using namespace std;    
int n,m,x,i; 
int main(){	
	cin>>n>>m;
	x=m/n;
	for(i=x;i>=1;i--)
		if(m%i==0) break;
	cout<<i;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
class UnionFind:
    def __init__(self,size):
        self.parent=range(size)
        self.tree_num=size
        self.tree_w=[1]*size
        self.rank=[0]*size

    def findset(self,x):
        if self.parent[x]==x:
            return x
        else:
            self.parent[x]=self.findset(self.parent[x])
            return self.parent[x]

    def unite(self,x,y):
        x=self.findset(x)
        y=self.findset(y)
        if x==y:
            return
        if self.rank[x]<self.rank[y]:
            self.parent[x]=y
            self.tree_num-=1
            self.tree_w[y]+=self.tree_w[x]
        else:
            self.parent[y]=x
            self.tree_num-=1
            self.tree_w[x]+=self.tree_w[y]
            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1

    def same(self,x,y):
        if self.findset(x)==self.findset(y):
            return True
        else:
            return False

    def tree_number(self):
        return self.tree_num

    def tree_weight(self,x):
        return self.tree_w[self.findset(x)]

n,k,l=map(int,raw_input().split())
uf1=UnionFind(n)
uf2=UnionFind(n)
for i in xrange(k):
    p,q=map(int,raw_input().split())
    p-=1;q-=1
    uf1.unite(p,q)
for i in xrange(l):
    p,q=map(int,raw_input().split())
    p-=1;q-=1
    uf2.unite(p,q)
cnt=defaultdict(int)
for i in xrange(n):
    cnt[(uf1.findset(i),uf2.findset(i))]+=1
ans=[0]*n
for i in xrange(n):
    ans[i]+=cnt[(uf1.findset(i),uf2.findset(i))]
print " ".join(map(str,ans))


Measured memory_bytes: 55596
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct _Node{
    int key;
    struct _Node *next, *prev;
} Node;

Node *nil;

void init();
Node* search(int);
void deleteNode(Node*);
void insert(int);
void delete(int);
void deleteFirst();
void deleteLast();
void printList();
int main(void){
    int key, n, i;
    char com[20];
    scanf("%d", &n);
    init();
    for(i = 0; i < n; i++){
        scanf("%s%d", com, &key);
        if(com[0] == 'i') insert(key);
        else if(com[0] == 'd'){
            if(strlen(com) > 6){
                if(com[6] == 'F') deleteFirst();
                else if(com[6] == 'L') deleteLast();
            }
            else delete(key);
        }
    }
    printList();

    return 0;
}

Node* search(int key){
    Node *cur = nil->next;
    while(cur != nil && cur->key != key){
        cur = cur->next;
    }
    return cur;
}

void init(void){
    nil = (Node *)malloc(sizeof(Node));
    nil -> next = nil;
    nil -> prev = nil;
}

void printList(void){
    Node *cur = nil->next;
    int isf = 0;
    while(1){
        if(cur == nil) break;
        if(isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *dst){
    if(dst == nil) return;
    dst->prev->next = dst->next;
    dst->next->prev = dst->prev;
    free(dst);
}

void deleteFirst(void){
    deleteNode(nil->next);
}

void deleteLast(void){
    deleteNode(nil->prev);
}

void delete(int key){
    deleteNode(search(key));
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}


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

int main()
{
    string S;

    cin >> S;

    int len = S.length();

    int count = 0;
    rep(i, len / 2)
    {
        if (S.at(i) != S.at(len - i - 1))
        {
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
function main(input) {
  input = input.trim();
  const a = input.split(" ").map(Number);
  const str_num = a.join('');
  if(Number(str_num)%4==0){
    console.log("YES");
  }else{
    console.log("NO");
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30464
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    
    string s; cin >> s;
    int ans=INT_MAX;
    for(uint b=0; b<=s.size()-3; ++b){ // b: begin
        int tmp = 100*(s[b+0]-'0') + 10*(s[b+1]-'0') + (s[b+2]-'0');
        ans = min(ans, abs(tmp-753));
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

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

    int ans=0;
    for(int i=1;i<N;i++){
        int n=N-i;
        if(n>i) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int main()
{
	string s;
	cin >> s;
	rep(i,s.length()){
		s[i] = 'x';
	}	
	cout << s << endl;
}

Measured memory_bytes: 256
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N, T = NMI()
    A = NLI()

    if N == 1:
        print(1)
        exit()

    A_min = []
    A_min.append(A[0])
    A_min.append(min(A[0], A[1]))
    for i, a in enumerate(A):
        if i < 2:
            continue
        A_min.append(min(A_min[-1], a))

    diff = [0] * N
    for i, am in enumerate(A_min):
        if i == 0:
            diff[0] = 0
            continue
        diff[i] = max(A[i] - A_min[i-1], 0)
    diff_max = max(diff)
    print(diff.count(diff_max))


if __name__ == "__main__":
    main()

Measured memory_bytes: 20528
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


int main(){FIN
    
    ll k;cin>>k;
    ll a,b;cin>>a>>b;
    FOR(i,a,b){
        if (i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}

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

#define REP(i,n,m) for(i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)

int h,w;
int tx[4],ty[4],size;
int area[80010];
char t[1002][82];

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

void updatePoint(int x,int y){
	if(ty[0] > y){
		ty[0] = ty[3] = y;
		tx[0] = tx[3] = x;
	}
	else if(ty[0] == y){
		if(tx[0] > x) tx[0] = x;
		else if(tx[3] < x) tx[3] = x;
	}

	if(ty[1] < y){
		ty[1] = ty[2] = y;
		tx[1] = tx[2] = x;
	}
	else if(ty[1] == y){
		if(tx[1] > x) tx[1] = x;
		else if(tx[2] < x) tx[2] = x;
	}
}

void solve(int x,int y,int d){
	int i,nx,ny;

	t[y][x] = ' ';
	updatePoint(x,y);

	rep(i,8){
		nx = x + dx[i];
		ny = y + dy[i];

		if(nx>=0 && nx<w && ny>=0 && ny<h && t[ny][nx]=='*'){
			solve(nx,ny,i);
		}
	}
}

int main(void){
	int set,i,j;
	char s[12];
	w = 80;

	for(set=0;fgets(s,12,stdin);set++){
		h = atoi(s);
		if(h == 0) break;
		if(set != 0) printf("----------\n");

		memset(t,' ',sizeof(t));
		memset(area,0,sizeof(area));

		rep(i,h) fgets(t[i],w,stdin);

		rep(i,h) rep(j,w) if(t[i][j] == '*') {
			size = 0;
			tx[0] = tx[1] = w;
			tx[2] = tx[3] = 0;
			ty[0] = ty[3] = h;
			ty[1] = ty[2] = 0;

			solve(j,i,-1);

			area[((tx[3]-tx[0]+1)+(tx[2]-tx[1]+1))*(ty[1]-ty[0]+1)/2]++;
		}

		rep(i,80010) if(area[i] > 0) {
			printf("%d %d\n",i,area[i]);
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>

using namespace std;


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


    long long X,Y;scanf("%lld %lld",&X,&Y);

    long long  sum=0;

    for(long long i=X;i<=Y;i*=2){
        sum++;
    }

    printf("%lld\n",sum);

    return 0;
}


Measured memory_bytes: 256
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

A, B, C, D = map(int, input().split())

c = B // C - (A - 1) // C
d = B // D - (A - 1) // D
CD = lcm(C, D)
cd = B // CD - (A - 1) // CD

ans = (B - A + 1) - (c + d - cd)
print(ans)

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

vector<pint> f;
void factorize(ll n){
    for(ll i = 2; i*i <= n; i++){
        if(n % i != 0){
            continue;
        }
        int c = 0;
        while(n % i == 0){
            n /= i;
            c++;
        }
        f.push_back(make_pair(i,c));
    }
    if(n > 1) f.push_back(make_pair(n,1));
}

int main(){
    ll n;
    cin >> n;
    f.resize(0);
    factorize(n);
    // rep(i,f.size()){
    //     cout << f[i].first << " " << f[i].second << endl;
    // }
    int ans = 0;
    for(int i = 0; i < f.size(); i++){
        int m = f[i].second;
        int j = 1;
        while(j*(j+1)/2 <= m) j++;
        ans += j - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

#include <iostream>
#include <string>
#include <algorithm>
#include<vector>
using namespace std;

int main(){
    int n;
    int a[200000];
    int s = 0;
    cin >> n;
    rep(i,n){
        cin >> a[i];
        s^=a[i];
    }
    rep(i,n){
        cout<<(s^a[i]);
        if(i!=n-1){
            cout << " ";
        }else{
            cout << endl;
        }
    }
}

Measured memory_bytes: 3824
// https://beta.atcoder.jp/contests/abc074

#define SUBMIT
//#define DEBUG

#include <bits/stdc++.h>
using namespace std;
using ui64 = uint64_t;

const int MAX_N = 300;
ui64 A[MAX_N][MAX_N];
ui64 d[MAX_N][MAX_N];
int N;

void floyd() {
    for (int k = 0; k < N; ++k) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(3
0 1 3
1 0 2
3 2 0
)");
#endif
    stream >> N;
    for (int y = 0; y < N; ++y) {
        for (int x = 0; x < N; ++x) {
            stream >> A[y][x];
            d[y][x] = A[y][x];
        }
    }

    floyd();
    bool exist = true;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (d[i][j] != A[i][j]) exist = false;
        }
    }

    if (!exist) {
        cout << "-1" << endl;
        exit(0);
    }

    ui64 ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            bool avoid = false;
            for (int k = 0; k < N; ++k) {
                if (i == k || j == k) continue;
                if (d[i][j] == d[i][k] + d[k][j]) avoid = true;
            }
            if (!avoid) {
                ans += d[i][j];
            }
        }
    }
    cout << ans << endl;

 #ifdef DEBUG
    cout << "floyd" << endl;
    for (int y = 0; y < N; ++y) {
        for (int x = 0; x < N; ++x) {
            cout << d[y][x] << " ";
        }
        cout << endl;
    }

    cout << "input" << endl;
    for (int y = 0; y < N; ++y) {
        for (int x = 0; x < N; ++x) {
            cout << A[y][x] << " ";
        }
        cout << endl;
    }
#endif
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int M, K;
	cin >> M >> K;

	if (M == 0) {
		if (K == 0) cout << "0 0" << endl;
		else co(-1);
	}
	else if (M == 1) {
		if (K == 0) cout << "0 0 1 1" << endl;
		else co(-1);
	}
	else {
		if ((1 << M) <= K) {
			co(-1);
		}
		else {
			cosp(K);
			rep(i, 1 << M) {
				if (i != K) cosp(i);
			}
			cosp(K);
			rep(i, 1 << M) {
				if ((1 << M) - 1 - i != K) cosp((1 << M) - 1 - i);
			}
		}
	}

	Would you please return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
int main(){
	int n;
	scanf("%d",&n);
	int d[n]={};
	for(int i=0;i<n;i++){
		scanf("%d",&d[i]);
	}
	std::sort(d,d+n);
	int m;
	scanf("%d",&m);
	int t[m];
	for(int i=0;i<m;i++){
		scanf("%d",&t[i]);
	}
	std::sort(t,t+m);
	int k=0;
	int x=0;
	int y=0;
	for(int i=0;0==0;i++){
		if(d[x]==t[y]){
			x++;
			y++;
		}else if(d[x]<t[y]){
			x++;
		}else{
			k=1;
			break;
		}
		if(y>=m)break;
	}
	if(k==1)printf("NO");
	else printf("YES");
	return 0;
}


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

int main() {
	int x;
	cin >> x;
	if(400 <= x && x < 600) cout << 8;
	else if(600 <= x && x < 800) cout << 7;
	else if(800 <= x && x < 1000) cout << 6;
	else if(1000 <= x && x < 1200) cout << 5;
	else if(1200 <= x && x < 1400) cout << 4;
	else if(1400 <= x && x < 1600) cout << 3;
	else if(1600 <= x && x < 1800) cout << 2;
	else cout << 1;
	return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  string s, s2, s3;
  cin >> s >> s2 >> s3;
  string ans = "";
  cout << s[0] << s2[1] << s3[2] << endl;

}


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

int main(){
    int N;
    cin >> N;
    int d[100]={0};
    for(int i=0; i<N; i++){
        cin >> d[i];
    }
    sort(d, d+N);
    reverse(d,d+N);
    int k=0, count=0;
    for(int i=0; i<N; i++){
        if(d[i]==d[i+1]){
            count--;
        }
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int 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 F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;
int a[200010];
int dp[25][200010];//dp[i][j+1]=(a[0]～a[j]のiケタ目の1の個数)
vector<int> v(100);
signed main(){
  int n;cin>>n;
  int ans=0;
  rep(i,n)cin>>a[i];
  rep(i,20){
    dp[i][0]=0;
    rep(j,n){
      int ima=(a[j]>>i)%2;
      dp[i][j+1]=dp[i][j]+ima;
      //cout<<dp[i][j]<<" ";
    }
    //cout<<endl;
  }
  rep(j,n){
    int res=INF;
    rep(i,20){
      int po;
      if(dp[i][n]<dp[i][j]+2)po=n;
      else {po=lower_bound(dp[i],dp[i]+n,dp[i][j]+2)-dp[i];po--;}
      res=min(res,po);
    }
    ans+=(res-j);
  }
  cout<<ans<<endl;  
       
  return 0;
}

Measured memory_bytes: 36416
N = input()

A = list(map(int, input().split()))

def lcm(x, y):
    return (x * y) // gcd(x, y)
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y)

l = 1
for i in A:
    l = lcm(l, i)

ans = 0
for i in A:
    ans += l // i

print(ans%1000000007)

Measured memory_bytes: 4084
let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc)
  in doit str []

let () =
  let open Hashtbl in
  let n = read_int () in
  let tbl = create ~random:true n in
  let rec doit i =
    if i < n then
      match split (read_line ()) ' ' with
      | ["insert"; x] -> (add tbl x true; doit (i + 1))
      | ["find"; x] -> (print_endline (if mem tbl x then "yes" else "no"); doit (i + 1))
      | _ -> exit 1
  in doit 0

Measured memory_bytes: 43808
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner in = new Scanner(System.in);
    int W = in.nextInt();
    int H = in.nextInt();
    int x = in.nextInt();
    int y = in.nextInt();
    int r = in.nextInt();
    
    if( 0 <= x-r && x+r <= W && 0<=y-r && y+r <= H ){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 26408
#include"bits/stdc++.h"
using namespace std;

int main()
{
	int n, a, sum = 0;
	cin >> n ;
	for (int i = 0;i < n;i++)
	{
		cin >> a;
		while (a % 2 == 0)
		{
			a /= 2;
			sum++;
		}
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main ()
{
  char a;
  while(1){
    scanf("%c",&a);
    if(a=='\n'){
      printf("\n");
      break;
    }
    if('A'<=a&&a<='Z'){
      printf("%c",a+'a'-'A');
    }else{
      if('a'<=a&&a<='z'){
	printf("%c",a-'a'+'A');
      }else{
	printf("%c",a);
      }
    }
  }
}

Measured memory_bytes: 932
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8



int main() {
    ll W,A=1;cin>>W;
    rep(i,W){
        A*=(i+1);
        A%=MOD;
    }
    cout << A << endl;
}

Measured memory_bytes: 256
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/5/10 20:00:32
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
int n,m,x,c[20],a[20][20],ans=1e9;
bool v[20];
bool check(){
	int tmp[20]={0};
	For(i,1,n)
		if(v[i])
			For(j,1,m)
				tmp[j]+=a[i][j];
	For(i,1,m)
		if(tmp[i]<x) return false;
	return true;
}
void dfs(int num,int val){
	if(val>=ans) return ;
	if(num==n+1){
		if(check()) ans=val;
		return ;
	}
	v[num]=0;
	dfs(num+1,val);
	v[num]=1;
	dfs(num+1,val+c[num]);
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	n=read(); m=read(); x=read();
	For(i,1,n){
		c[i]=read();
		For(j,1,m) a[i][j]=read();
	}
	dfs(1,0);
	if(ans==1e9) printf("-1\n");
	else printf("%d\n",ans);	
	return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<" "
#define rep(i, n) for(int i=0; i<(n); i++)

int main(){
    int a, b; cin>> a >> b;
    cout<<(a+b)/2<<endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,q,c[500010],ans[500010];
	cin >> n >> q;
	for(int i = 0;i < n;i++) cin >> c[i];
	struct query{ int l,r,num; };
	vector<query> qs;
	for(int i = 0;i < q;i++){
		int l,r;
		cin >> l >> r; l--; r--;
		qs.push_back({l,r,i});
	}
	int B = 700;
	sort(qs.begin(),qs.end(),[B](const query &q1,const query &q2){
		return ((q1.l / B != q2.l / B) ? (q1.l / B < q2.l / B) : (q1.r < q2.r));
	});
	int l = 0,r = -1,cnt[500010] = {},tmp = 0;
	for(query que : qs){
		while(l < que.l){
			if(cnt[c[l]] == 1) tmp--;
			cnt[c[l]]--;
			l++;
		}
		while(que.l < l){
			l--;
			if(!cnt[c[l]]) tmp++;
			cnt[c[l]]++;
		}
		while(r < que.r){
			r++;
			if(!cnt[c[r]]) tmp++;
			cnt[c[r]]++;
		}
		while(que.r < r){
			if(cnt[c[r]] == 1) tmp--;
			cnt[c[r]]--;
			r--;
		}
		ans[que.num] = tmp;
	}
	for(int i = 0;i < q;i++) printf("%lld\n",ans[i]);
}

Measured memory_bytes: 27248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 100000000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));



const ll MAX_N = 1 << 22;
// セグメント木を持つグローバル配列 
ll n, dat[2 * MAX_N - 1];
// 初期化
void init(ll n_) {
	// 簡単のため、要素数を2のべき乗に 
	n = 1;
	while (n < n_) n *= 2;
	// すべての値をLLONG_MAX/4に
	for (ll i = 0; i < 2 * n - 1; i++) dat[i] = LLONG_MAX/4; 
}

// k番目の値(0-indexed)をaに変更
void update(ll k, ll a) {
	// 葉の節点
	k += n - 1; 
	dat[k] = a; 
	// 登りながら更新 
	while (k > 0) {
		k = (k - 1) / 2;
		dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
	}
}

// [a, b)の最小値を求める
// 後ろのほうの引数は、計算の簡単のための引数。
// kは節点の番号、l, rはその節点が[l, r)に対応づいていることを表す。 
// したがって、外からはquery(a, b, 0, 0, n)として呼ぶ。
ll query(ll a, ll b, ll k, ll l, ll r) {
	// [a, b)と[l, r)が交差しなければ、LLONG_MAX/4 
	if (r <= a || b <= l) return LLONG_MAX/4;
	// [a, b)が[l, r)を完全に含んでいれば、この節点の値 
	if (a <= l && r <= b) return dat[k]; 
	else {
		// そうでなければ、2つの子の最小値
		ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2); 
		ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	} 
}



vector<ll> dp(100001, INF);

int main(){	
	ll M;
	ll N;
	scanf("%lld",&N);
	init(N);
	scanf("%lld",&M);
	vector<ll> C(M-1+1);
	vector<ll> L(M-1+1);
	vector<ll> R(M-1+1);
	vector<vector<ll>> lv(M, vector<ll>(3));
	for(ll i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&L[i]);
		scanf("%lld",&R[i]);
		scanf("%lld",&C[i]);
		L[i]--; R[i]--;
		lv[i][0] = L[i];
		lv[i][1] = R[i];
		lv[i][2] = C[i];
	}
	dp[0] = 0;
	update(0, 0);
	sort(lv.begin(),lv.end());
	// rep(i, M) {
	// 	cout << lv[i][0] << " " << lv[i][1] << " " << lv[i][2] << endl;
	// }
	rep(i, M) {
		ll l = lv[i][0], r = lv[i][1], c = lv[i][2];
		// cout << lv[i][0] << " " << lv[i][1] << " " << lv[i][2] << endl;
		
		dp[r] = min(dp[r], query(l, r+1, 0, 0, n)+c);
		update(r, dp[r]);

		// rep(j, N+1) if (dp[j] >= LLONG_MAX/4/4) cout << "i"; else cout << dp[j];
		// cout << endl;
	}

	if (dp[N-1] >= INF ) printf("-1\n"); else printf("%lld\n",dp[N-1]);
	return 0;
}



Measured memory_bytes: 12800
n,a,b,c,d=map(int,input().split())
s=input()
f=0;F=0
for i in range(a,max(c,d)-1):
  if s[i]=='#' and s[i+1]=='#':f=1
for i in range(b-2,min(c,d)-1):
  if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':F=1
if F==0 and c>d:f=1
print('YNeos'[f::2])

Measured memory_bytes: 3572
using System;
 
class Sample{
	public static void Main(){
      int total;
      total =int.Parse(System.Console.ReadLine());
      int[] price=new int[total];
      int totalprice=0;
      for(int i=0;i<total;i++){
      price[i]=int.Parse(System.Console.ReadLine());
      }
      Array.Sort(price);
      for(int i=0;i<total;i++){
      if(i==total-1){totalprice+=price[i]/2;}
        else{totalprice+=price[i];}
      }
      System.Console.WriteLine(totalprice);
    }
}

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

int main() {
  long long n,k;
  long long sum = 0;
  cin >> n >> k;
  for (long long i = k; i <= n+1; i++) {
    sum += ((i * n - i * (i-1)) + 1) % 1000000007;
  }
  cout << sum % 1000000007 << endl;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

struct E {
    int to;
    LL w;
};

using G = vector<vector<E>>;

template <typename T>
pair<vector<T>, vector<int>> dijkstra(G g, int s, T inf) {
    int n = g.size();
    vector<T> d(n, inf);
    vector<int> r(n, -1);
    d[s] = 0;
    using P = pair<T, int>;
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push({0, s});
    while(!pq.empty()){
        auto c = pq.top();pq.pop();
        if(d[c.second] < c.first) continue;
        for(auto e : g[c.second]){
            if(d[e.to] > d[c.second] + e.w){
                d[e.to] = d[c.second] + e.w;
                r[e.to] = c.second;
                pq.push({d[e.to], e.to});
            }
        }
    }
    return {d, r};
}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--;t--;

    G g(n);

    inc(i, 0, m){
        int a, b, c;
        LL w;
        cin >> a >> b >> c >> w;
        a--;b--;c--;
        g[a].push_back({b, w});
        g[b].push_back({a, w});
        g[b].push_back({c, w});
        g[c].push_back({b, w});
        g[c].push_back({a, w});
        g[a].push_back({c, w});
    }

    auto ans = dijkstra<LL>(g, s, LLONG_MAX/3).first;

    printf("%lld\n", ans[t]);
    return 0;
}



Measured memory_bytes: 36544
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int ft_pow(int a, int num)
{
	int i = 0;
	int x = 1;
	while (i < num)
	{
		x *= a;
		i++;
	}
	return (x);
}
int main(void)
{
	int n,k;
	scanf("%d %d",&n, &k);
	int *a;
	a = (int *)malloc(sizeof(int)*(n+2));
	a[0] = 0;
	int i =1;
	int j =0;
	while (i <= n)
	{
		j = 0;
		a[i] = i;
		while (j < 20 && a[i] < k)
		{
			a[i] = 2*a[i];
			j++;
		}
		a[i] = j;
		i++;
	}
	i = 1;
	j = 0;
	int sum = 0;
	int z = n*2;
	double d = 0;
	while (i <= n)
	{
		//printf("a[%d]:%d\n",i,a[i]);
		sum += ft_pow(2,a[1] - a[i]);
		z *= 2;
		d += 1 / ((double)n * ft_pow(2,a[i]));
		i++;
	}
	
	double ans = (double)sum / (double)z;
	//printf("debug sum:%d, z:%d\n",sum,z);
	//printf("%.14lf\n",ans);
	printf("%.12lf\n",d);

	return(0);
}


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

int main()
{
	constexpr int inf{1 << 30};
	int N, M;
	scanf("%d%d", &N, &M);
	std::vector<std::vector<std::pair<int, int>>> edges(N);
	for (int i{}; i < M; i++)
	{
		int p, q, c;
		scanf("%d%d%d", &p, &q, &c);
		p--; q--;
		edges[p].push_back({q, c});
		edges[q].push_back({p, c});
	}

	std::vector<int> distance(N, inf);
	distance[0] = 0;
	std::queue<int> bfs;
	bfs.push(0);
	std::vector<std::set<int>> usedCompany(N);
	std::vector<bool> inQueue(N);
	inQueue[0] = true;

	while (!bfs.empty())
	{
		int now{bfs.front()};
		bfs.pop();
		inQueue[now] = false;
		for (auto& next: edges[now])
		{
			int dist{distance[now]};
			if (usedCompany[now].find(next.second) == usedCompany[now].end()) dist++;
			if (dist > distance[next.first]) continue;
			if (distance[next.first] != dist)
				usedCompany[next.first].clear();
			distance[next.first] = dist;
			if (!usedCompany[next.first].insert(next.second).second) continue;
			if (inQueue[next.first]) continue;
			inQueue[next.first] = true;
			bfs.push(next.first);
		}
	}

	if (distance.back() == inf)
		puts("-1");
	else
		printf("%d\n", distance.back());

	return 0;
}


Measured memory_bytes: 23284
#include<bits/stdc++.h>
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
using namespace std;
//  =========     /\       /|    |====/|
//      |        /  \       |    |   / |
//      |       /____\      |    |  /  |
//      |      /      \     |    | /   |
//  ========= /        \  =====  |/====|  
//  code

int main(){
    init;
    int n,i,j,k,l;
    cin>>n;
    int a[n+1][3],dp[n+1][3];
    for(i=1;i<=n;i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    dp[1][0] = a[1][0];
    dp[1][1] = a[1][1];
    dp[1][2] = a[1][2];
    for(i=2;i<=n;i++){
        dp[i][0] = max(dp[i-1][1] , dp[i-1][2]) + a[i][0];
        dp[i][1] = max(dp[i-1][0] , dp[i-1][2]) + a[i][1];
        dp[i][2] = max(dp[i-1][1] , dp[i-1][0]) + a[i][2];
    }
    cout<<max(dp[n][0] , max(dp[n][1],dp[n][2]))<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int maxn=200009;

int n;
int a[maxn];
queue<int>q;

long long ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	sort(a+1,a+1+n);
	q.push(a[n]);
	for(int i=n-1;i>=1;--i){
		ans+=q.front();q.pop();
		q.push(a[i]);q.push(a[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

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

signed main() {
	vector<string> dice(7);

	dice[1] = "##3524#";
	dice[2] = "#4#16#3";
	dice[3] = "#26##15";
	dice[4] = "#51##62";
	dice[5] = "#3#61#4";
	dice[6] = "##4253#";

	vector<int> s(7);
	map<int, int> a;
	for (int i = 1; i < 7; ++i) {
		cin >> s[i];
		a[s[i]] = i;
	}

	int N;
	cin >> N;
	
	for (int i = 0; i < N; ++i) {
	    int n, m;
	    cin >> n >> m;
	    cout << s[int(dice[a[n]][a[m]] - '0')] << endl;
	}
}



Measured memory_bytes: 3148
#include<cstdio>
#include<iostream>

using namespace std;

int main(){
  int h, w, n;
  cin >> h >> w >> n;
  
  int l = (h > w) ? h : w; 
  int num = (n-1)/l + 1;

  printf("%d\n",num);
  return 0;
}

Measured memory_bytes: 256
#ダブリング解
n, x, m = map(int, input().split())
tmp = [None]*m
for i in range(m):
    tmp[i] = i*i%m
pos = [tmp]
accu = [tmp]
for i in range(40):
    tmp1 = [None]*m
    tmp2 = [None]*m
    for j in range(m):
        tmp1[j] = pos[-1][pos[-1][j]]
        tmp2[j] = accu[-1][pos[-1][j]] + accu[-1][j]
    pos.append(tmp1)
    accu.append(tmp2)
now = x
ans = x
for i in range(40):
    if (n-1)>>i&1:
        ans += accu[i][now]
        now = pos[i][now]
print(ans)

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

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

//-----------------------------------------------------------------------------

int x,y,z;

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

	cin>>x>>y>>z;
	x-=z;
	int ans=x/(y+z);
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
  let mut line = String::new();
  io::stdin().read_line(&mut line).unwrap();
  let vec: Vec<&str> = line.split_whitespace().collect();
  //println!("{:?}", vec);
  let n: i32 = vec[0].parse().unwrap();
  let m: i32 = vec[1].parse().unwrap();
  //println!("{}, {}", n, m);

  if n * m % 2 == 0 {
    println!("Even");
  } else {
    println!("Odd");
  }
}


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

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n, k; cin >> n >> k;
	if (k <= (n + 1) / 2) {
		int j = n + (n - 1) / 2, sum = k + 2 * n;
		for (int i = 0; i < n; i += 2) cout << k + i << " " << k + j << " " << sum << "\n", sum++, j--;
		j = n + n - 1;
		for (int i = 1; i < n; i += 2) cout << k + i << " " << k + j << " " << sum << "\n", sum++, j--;
		return 0;
	} else cout << "-1\n";
	
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back 
#define mp make_pair
typedef long long ll;



int main(){
	string s; cin>>s;
	set<char> a;
	for(int i=0;i<4;i++){
		a.insert(s[i]);
	}
	if(a.size()==2) cout<<"Yes";
	else cout<<"No";
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;

int main() {
    int N, M;
    cin>>N>>M;
    vector<vector<pair<int, ll> > > edge(N);
    int L, R;
    ll D;
    for(int i=0;i<M;++i){
        cin>>L>>R>>D;
        L--;
        R--;
        edge[L].push_back(make_pair(R, D));
        edge[R].push_back(make_pair(L, -D));
    }
    map<int, int> deta;
    map<int, ll> posmap;
    queue<int> numque;
    queue<int> posque;
    int num;
    ll pos;
    bool ans = true;
    for(int i=0;i<N;++i){
        if(deta[i]==0){
            numque.push(i);
            posque.push(0);
            posmap[i] = 0;
            deta[i]++;
            while(!numque.empty()){
                num = numque.front();numque.pop();
                pos = posque.front();posque.pop();
                for(int i=0;i<edge[num].size();++i){
                    if(deta[edge[num][i].fi]==0){
                        numque.push(edge[num][i].fi);
                        posque.push(pos + edge[num][i].se);
                        posmap[edge[num][i].fi] = pos + edge[num][i].se;
                        deta[edge[num][i].fi]++;
                    }
                    else{
                        if(posmap[edge[num][i].fi] != pos + edge[num][i].se) ans = false;
                    }
                }
            }
        }
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 23408
N, P = gets.split.map(&:to_i)
S = gets.chomp.split('')
result = 0
if P == 2
  S.length.times do |i|
    if S[i].to_i.even?
      result += i + 1
    end
  end
  puts result
  exit
end

if P == 5
  S.length.times do |i|
    if [5,0].include?(S[i].to_i)
      result += i + 1
    end
  end
  puts result
  exit
end

mod_counts = {}
mods = []
s_length = S.length
mod_counts[0] = 1
mod = 0

@fact10 = {}
def fact10 x
  return 1 if x == 0
  unless @fact10[x]
    @fact10[x] = (fact10(x-1) * 10) % P
  end
  @fact10[x]
end
s_length.times do |i|
  target = S[(s_length - 1 -i)].to_i
  mod = (mod + target * fact10(i)) % P
  if mod_counts[mod]
    result += mod_counts[mod]
    mod_counts[mod] += 1
  else
    mod_counts[mod] = 1
  end
end

puts result

Measured memory_bytes: 26364