akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define int long long
#define ll long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i>=b;i--)
#define fill(a,i) memset(a,i,sizeof a);


void solve()
{ 
    int n,d,x,y;
    vi v;cin>>n>>d;
    rep(i,1,n)
    {
        cin>>x>>y;
        long double ff=sqrt((x*x) + (y*y));
        int a=ceil(ff);
        v.pb(a);
    }
    sort(all(v));
    int b=upper_bound(all(v),d) - v.begin();
   
    cout<<b;
}

signed main()
{ 
    boost
    int test=0,t;
    //cin >> t ;
    t=1;
    while(test++ <t){
    //cout<<"Case #"<<test<<": ";
    solve();}
  
}

Measured memory_bytes: 5352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

typedef long long ll;

struct starryskytree{
	int N;
	using D = ll;
	D id_ = 1e17;		//initialize	!!このあとaddクエリがきてもidを超えないようにする!!
	D id  = 1e18;		//id
	vector<D> mn,ad;
	starryskytree(){}
	starryskytree(int n){
		N=1;
		while(N<n) N*=2;
		mn.assign(N*2,id_);
		ad.assign(N*2,0);
	}
	starryskytree(vector<D>& vc){
		int n = vc.size();
		N=1;
		while(N<n) N*=2;
		mn.assign(N*2,id_);
		ad.assign(N*2,0);
		rep(i,n) mn[i+N]=vc[i];
		for(int i=N-1;i>0;i--) mn[i]=min(mn[i*2],mn[i*2+1]);
	}
	void add(int a,int b,D v){
		add(a,b,0,N,1,v);
	}
	void add(int a,int b,int l,int r,int k,D v){
		if(b<=l||r<=a) return;
		if(a<=l&&r<=b){
			ad[k]+=v;
			return;
		}
		add(a,b,l,(l+r)/2,k*2,v);
		add(a,b,(l+r)/2,r,k*2+1,v);
		mn[k]=min(mn[k*2]+ad[k*2],mn[k*2+1]+ad[k*2+1]);
	}
	D getmin(int a,int b){
		return getmin(a,b,0,N,1);
	}
	D getmin(int a,int b,int l,int r,int k){
		if(b<=l||r<=a) return id;
		if(a<=l&&r<=b) return mn[k]+ad[k];
		return ad[k]+min(getmin(a,b,l,(l+r)/2,k*2),getmin(a,b,(l+r)/2,r,k*2+1));
	}
	void assign(int x,ll v){
		add(x,x+1,v-getmin(x,x+1));
	}
	void changemin(int x,ll v){
		D dif = v - getmin(x,x+1);
		if(dif<0) add(x,x+1,dif);
	}

	bool hasnegative(int k,D acm){return acm+mn[k]+ad[k]<0;}
	int leftmostnegativeid(){
		D acm = 0;
		if(!hasnegative(1,acm)) return N;
		int k = 1;
		while(k<N){
			acm += ad[k];
			if(hasnegative(k*2,acm)) k=k*2;
			else k=k*2+1;
		}
		return k-N;
	}

}Ap,Am,Bp,Bm;

const int MQ = 200000;
ll xs[MQ];

void assignA(int x,ll v){
	Ap.changemin(x,v+x);
	Am.changemin(x,v-x);
}
void assignB(int x,ll v){
	Bp.changemin(x,v+x);
	Bm.changemin(x,v-x);
}
int main(){
	int N,Q,A,B;
	cin>>N>>Q>>A>>B;
	A--,B--;
	Ap = starryskytree(N);
	Am = starryskytree(N);
	Bp = starryskytree(N);
	Bm = starryskytree(N);
	assignA(B,0);
	assignB(A,0);

	rep(t,Q) cin>>xs[t],xs[t]--;

	rep(qt,Q){
		ll x = xs[qt];

		//change fix
		ll Af = min(Bm.getmin(0,x+1) + x , Bp.getmin(x,N) - x);
		ll Bf = min(Am.getmin(0,x+1) + x , Ap.getmin(x,N) - x);

		{	//prev A fix
			ll px = (qt==0 ? A : xs[qt-1]);
			Ap.add(0,N,abs(x-px));
			Am.add(0,N,abs(x-px));
		}
		{	//prev B fix
			ll px = (qt==0 ? B : xs[qt-1]);
			Bp.add(0,N,abs(x-px));
			Bm.add(0,N,abs(x-px));
		}
		{	//prev A fix
			ll px = (qt==0 ? A : xs[qt-1]);
			assignB(px,Bf);
		}
		{	//prev B fix
			ll px = (qt==0 ? B : xs[qt-1]);
			assignA(px,Af);
		}
	}
	ll ans = 1e18;
	rep(i,N) chmin(ans,Ap.getmin(i,i+1)-i);
	rep(i,N) chmin(ans,Bp.getmin(i,i+1)-i);
	cout<<ans<<endl;
}


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

using namespace std;
#define ll long long
#define ld long double

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int l, r;
    cin >> l >> r;
    // there exists a multiple of 2019 in interval [l, r]
    if(l / 2019 != r / 2019) {
        cout << 0 << '\n';
    }
    // no multiple of 2019 exists
    else {
        int ans = 2019;
        l %= 2019;
        r %= 2019;
        for(int i=l;i<=r;i++) {
            for(int j=i+1;j<=r;j++) {
                ans = min(ans, i * j % 2019);
            }
        }
        cout << ans << '\n';
    }
    return 0;
}



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

using namespace std;

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m;
    cin>>n>>m;
    cout<<(n*(n-1))/2+(m*(m-1))/2<<'\n';
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e6+3)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int gcd(int A,int B) {if(!B)return A;return gcd(B,A%B);}
ll ans = 0;
ll pf(ll n)
{
	vector<ll>p;
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i == 0){
			ll cnt = 0;
			while(n%i == 0){n/=i;cnt++;}
			ll j = 1;
			while(cnt-j>=0){cnt-=j;j++;}
			ans+=j-1;
		}
	}
	if(n > 1)ans++;
	return ans;
}
int main()
{
   ll n;
   cin>>n;
   cout<<pf(n);
}


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

using namespace std;

int main()
{
    int A[200000];
    vector<int> a;
    int n;
    cin >> n;
    int i,j;
    for(i = 0;i < n;i++)
    {
        cin >> A[i];
        a.emplace_back(A[i]);
    }
    int counter = 0;
    vector<int>::iterator tmp;
    vector<int>::iterator now = a.begin();
    int ans = 0;
    while(1)
    {
        counter++;
        tmp = find(now,a.end(),counter);
        if(tmp == a.end())
        {
            if(counter == 1 && a[0] != 1)
            {
                ans = -1;
                goto end;
            }
            else if(counter == 1 && a[0] == 1)
            {
                goto end;
            }
            else if (*(a.end()) == counter || *(a.end()) != counter)
            {
                ans += tmp - now - 1;
                goto end;
            }
            else
            {
                goto end;
            }
            
        }
        else
        {
        //cout << tmp - now << endl;
            if(counter == 1)
            {
                ans += tmp - now;
            }
            else
            {
                ans += tmp - now - 1;
            }
            
            now = tmp;
        }
    }
    end:
    cout << ans;
    return 0;
}

Measured memory_bytes: 1912
S = int(input())
if S == 10**18:
    print(0, 0, 10**9, 0, 0, 10**9)
    exit()
Y3 = (S // 10**9) + 1
X3 = ((10**9)) - S % 10**9
print(0, 0, 10**9, 1, X3, Y3)


Measured memory_bytes: 2940
#include<stdio.h>
int d[2][100010],w=0;
int ta[100010],to[200010],nt[200010];
void f(int s){
  int i,j,t,r,q[100010];
  d[w][q[t=0]=s]=1;
  for(r=1;r-t;t++){
    for(i=ta[q[t]];i+1;i=nt[i]){
      if(d[w][to[i]])continue;
      d[w][to[i]]=d[w][q[t]]+1;
      q[r++]=to[i];
    }
  }
}
int main(){
  int n,a,b,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)ta[i+1]=-1;
  for(i=0;i<n-1;i++){
    scanf("%d %d",&a,&b);
    nt[i    ]=ta[to[i+n]=a];
    nt[i+n  ]=ta[to[i  ]=b];
    ta[a]=i;
    ta[b]=i+n;
  }
  f(1);
  w++;//for(i=1;i<=n;i++)printf("%d %d\n",d[0][i],d[1][i]);
  f(n);
  for(i=a=b=0;i<n;i++){
    if(d[0][i+1]>d[1][i+1])b++;
    else a++;
  }
  //for(i=1;i<=n;i++)printf("%d %d\n",d[0][i],d[1][i]);
  printf("%s\n",b<a?"Fennec":"Snuke");
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int z;
  cin>>z;
  if(z%4==0) cout<<"Yes"<<endl;
  else if(z%4==1&&z>=21) cout<<"Yes"<<endl;
  else if(z%4==2&&z>=14) cout<<"Yes"<<endl;
  else if(z%4==3&&z>=7) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

#define FOR(i,S,E) for(int i=S; i<E; i++)

string s[2];
int main() {
    FOR(i,0,2) cin >> s[i];
    FOR(i,0,3) {
        if (s[0][i] != s[1][2-i]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K , N , x;
  cin >> N >> K;
  
  x = 1;
  
  for(int i = 0; i < N; i++){
    if(K+x > x*2){
      x = x * 2;
    }else{
      x = x + K;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 3616
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		int n = Integer.parseInt(bf.readLine());
	 		ArrayList<Integer> array = new ArrayList<Integer>();
	 		StringTokenizer st2 = new StringTokenizer(bf.readLine());
	 		for(int j=0;j<n;j++){
	 			array.add(Integer.parseInt(st2.nextToken()));
	 		}
	 		Collections.sort(array);
	 	long sum =0;
	 	for(int i =0;i<n-1;i++){
	 		sum+=array.get(array.size()-1-(i+1)/2);
	 	}

 		
 		
 		out.println(sum);
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 54148
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = I()
    d = [None for i in range(n+1)]
    d[0] = 2
    d[1] = 1
    for i in range(2,n+1):
        d[i] = d[i-1]+d[i-2]
    print(d[n])
    return

#D
def D():
    x,y,z = LI()
    for i in range(1000000)[::-1]:
        if i*y+(i+1)*z <= x:
            print(i)
            quit()
    return

#E
def E():
    d = [(1,0),(-1,0),(0,1),(0,-1)]
    h,w = LI()
    s = SR(h)
    for i in range(h):
        for j in range(w):
            if s[i][j] == "#":
                su = 0
                for dy,dx in d:
                    y = i+dy
                    x = j+dx
                    if 0 <= y < h and 0 <= x < w:
                        if s[y][x] == "#":
                            su += 1
                if su == 0:
                    print("No")
                    quit()
    print("Yes")
    return

#F
def F():
    a,b,c,X,Y = LI()
    ans = float("inf")
    for z in range(300001):
        if z%2 == 0:
            m = c*z
            x = z//2
            y = z//2
            m += a*max(0,X-x)
            m += b*max(0,Y-y)
            if m < ans:
                ans = m
    print(ans)
    return

#G
def G():
    n = I()
    x = LI()
    f = [(i,x[i]) for i in range(n)]
    f.sort(key = lambda x:x[1])
    g = [(f[i][0],i) for i in range(n)]
    g.sort(key = lambda x:x[0])
    for i in range(n):
        if g[i][1] < n//2:
            print(f[n//2][1])
        else:
            print(f[n//2-1][1])
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 40560
a = int(input())
if a < 10:
  print(a)
elif a >= 10 and a < 100:
  print(9)
elif a >= 100 and a < 1000:
  print(9 + a - 100 + 1)
elif a >= 1000 and a < 10000:
  print(909)
elif a >= 10000 and a < 100000:
  print(909 + a - 10000 + 1)
else:
  print(90909)


Measured memory_bytes: 3064
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def culc(x):
    return x*(x-1)//2

n,m=map(int,input().split())
edge=[]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    edge.append((a,b))


ans=[culc(n)]

uf=UnionFind(n)
for i in range(m):
    a,b=edge[m-i-1]
    if uf.same(a,b):
        ans.append(ans[-1])
    else:
        member_a=uf.size(a)
        member_b=uf.size(b)
        uf.union(a,b)
        add=culc(member_a)+culc(member_b)-culc(uf.size(a))
        ans.append(ans[-1]+add)


for i in range(m):
    print(ans[m-i-1])





Measured memory_bytes: 27320
from collections import defaultdict
S = input()
T = input()
DS = defaultdict(int)
for s in S:
  DS[s] += 1
CS = sorted(DS.values())
DT = defaultdict(int)
for t in T:
  DT[t] += 1
CT = sorted(DT.values())
if len(CS) == len(CT):
  for i in range(len(CS)):
    if CS[i] != CT[i]:
      print('No')
      break
  else:
    print('Yes')
else:
  print('No')

Measured memory_bytes: 4144
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  ll N,M;
  cin >> N >> M;
  vector<ll> H(N);
  for(int i=0;i<N;i++)
  {
    cin >> H[i];
  }
  vector<ll> A(M);
  vector<ll> B(M);
  for(int i=0;i<M;i++)
  {
    cin >> A[i] >> B[i];
  }
  rep(i,M)
  {
    A[i] --;
    B[i] --;
  }
  set<ll> S;
  for(int i=0;i<N;i++)
  {
    S.insert(i);
  }
  for(int i=0;i<M;i++)
  {
    if(H[A[i]]<=H[B[i]]){
    S.erase(A[i]);
    }
    if(H[B[i]]<H[A[i]]){
      S.erase(B[i]);
    }
    if(H[A[i]]==H[B[i]])
    {
      S.erase(A[i]);
      S.erase(B[i]);
    }
  }
  cout << S.size() << endl;
  return 0;
}


Measured memory_bytes: 10388
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> td(n);
  rep(i, n) cin >> td[i].second >> td[i].first;
  sort(all(td));
  reverse(all(td));
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
  int ans = 0, sum = 0, x = 0;
  vector<int> used(100005, 0);
  rep(i, k) {
    sum += td[i].first;
    if (used[td[i].second] == 0)
      x++;
    else
      pq.push(td[i]);
    used[td[i].second]++;
  }
  cmax(ans, sum + x * x);
  for (int i = k; i < n; i++) {
    if (used[td[i].second]) continue;
    if (pq.empty()) break;
    auto tmp = pq.top();
    pq.pop();
    sum -= tmp.first;
    used[tmp.second]--;
    sum += td[i].first;
    used[td[i].second]++;
    x++;
    cmax(ans, sum + x * x);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3704
h,w=map(int,input().split())
a=[list(map(int,input().split()))for _ in range(h)]
ans=[]
for i in range(1,h,2):a[i]=a[i][::-1]
for i in range(h):
  for j in range(w):
    if a[i][j]%2==0:continue
    if j==w-1:
      if i==h-1:continue
      a[i+1][0]+=1
      a[i][w-1]-=1
      ans.append([i,w-1,i+1,0])
    else:
      a[i][j+1]+=1
      a[i][j]-=1
      ans.append([i,j,i,j+1])
for i in range(len(ans)):
  if ans[i][0]%2==1:ans[i][1]=(w-1)-ans[i][1]
  if ans[i][2]%2==1:ans[i][3]=(w-1)-ans[i][3]
print(len(ans))
for i in ans:
  a,b,c,d=i
  print(a+1,b+1,c+1,d+1)

Measured memory_bytes: 26192
#include <bits/stdc++.h>          
using namespace std;
typedef long long ll;

int main() {
    string S, T, ans="Yes";
    cin >> S >> T;
    int Ns = S.size(), Nt = T.size();
    for (int i=0; i<Ns; i++) {
        if (S[i]!=T[i]) {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
import bisect

N = int(input())
A = [int(zz) for zz in input().split()]
B = set(A)
A.sort()
ans = 0
for i in B:
    p = bisect.bisect_right(A, i) - bisect.bisect_left(A, i)
    if i > p:
        ans += p
    elif i < p:
        ans += p - i

print(ans)


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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000


typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

const int N = 1e3+5;
const int MOD = 1e9+7;

int n, m;
int dp[N][N];
string arr[N];

int solve(int i, int j){
	if(i >= n || j >= m || arr[i][j] == '#')
		return 0;
	if(i == n-1 && j == m-1)
	    return 1;
	int & cur = dp[i][j];
	if(~cur)
		return cur;
	return cur  = (solve(i+1, j)%MOD + solve(i, j+1)%MOD)%MOD;
}

int main()
{
    cin >> n >> m;
	clr(dp, -1);
    lp(i, n)
    	cin >> arr[i];
    cout << solve(0, 0);
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
using namespace std;
typedef long long ll;
 
int64_t gcd(int64_t x,int64_t y){
    if(y==0)return x;
    else return gcd(y,x%y);
}
 
int main(){
    int64_t a,b,mini=0,small;
    cin>>a>>b;
    vector<int> yakusua,yakusub,ans(100000000);
    small=min(a,b);
    //int s=sqrt(a);
   
    int64_t yaku = gcd(a,b);
   
    
    //int64_t s=sqrt(yaku);
    
    for(int64_t i=2;i*i<=yaku;i++){
        //cout<<i<<endl;
      if(yaku%i==0){
         mini++;
          //ans.at(i)=1;
      }
      while(yaku%i==0){
          yaku/=i;
      }
     
   }
    
 if(yaku!=1)mini++;
 
  
  cout<<mini+1<<endl;

}

Measured memory_bytes: 390912
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	for (;;) {
		string s; cin >> s;
		int n = s.length();
		if (s == "-") break;
		int m; cin >> m;
		int sum = 0;
		while (m--) {
			int h; cin >> h;
			sum += h;
		}
		for (int i = 0; i < n; i++)
			cout << s[(i + sum) % n];
		cout << endl;
	}
}

Measured memory_bytes: 1204
from sys import stdin
import bisect
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    s=list(map(int,readline().split()))
    q=int(readline())
    t=list(map(int,readline().split()))

    cnt=0
    for x in t:
        if bisect.bisect_left(s,x)!=bisect.bisect_right(s,x):
            cnt+=1

    print(cnt)
if __name__=="__main__":
    main()


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

int main() {
  int a, b;  /* 整数１、２　１００以内 */
  int c = 0;  /* a,b の平均値の余り */
  
  cin >> a >> b;

  if (a*b > 10000) { 
    cout << "Error!" << endl;
  } else {
    c = (a + b) % 2;
    if (c > 0 ) {
      cout << (a + b) / 2 + 1 << endl;
    }else{
      cout << (a + b) / 2 << endl;
    }
  }
}

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

// strをdelで区切る.いずれdelがstringでも大丈夫なように作り変える.
vector<string> split(string str, char del){
    vector<string> ret;
    string cutoff = "";
    for(int i = 0; i < str.length(); i++){
        if(str[i] == del){
            if(cutoff != "")    ret.push_back(cutoff);
            cutoff = "";
        }else{
            cutoff += str[i];
        }
    }
    if(cutoff != "")    ret.push_back(cutoff);
    return ret;
}

int main(){
    string s;
    vector<int> v;
    v.push_back(0);
    v.push_back(0);

    while(getline(cin, s)){
        vector<int> u;
        u.push_back(0);
        vector<string> line = split(s, ',');
        if(v.size() - 2 > line.size()){
            // ひし形は減衰
            for(int i = 0; i < line.size(); i++){
                u.push_back(max(v[i+1], v[i+2]) + stoi(line[i]));
            }
        }else{
            // ひし形は成長
            for(int i = 0; i < line.size(); i++){
                u.push_back(max(v[i], v[i+1]) + stoi(line[i]));
            }
        }
        u.push_back(0);
        v = u;
    }

    cout << v[1] << endl;

    return 0;
}


Measured memory_bytes: 3032
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


int main(void){
    ll n; cin >> n;
    vector <ll> as;
    REP(i, n){
        string a; cin >> a;
        string new_a;
        ll cnt = 1;
        bool period = false;
        REP(i, a.size()){
            if (a[i]=='.'){
                cnt = i;
                period = true;
                continue;
            }
            if (a[i] == '-'){
                continue;
            }
            new_a.push_back(a[i]);
        }
        if (!period){
            as.push_back(stoll(a)*1e9);
            continue;
        }
        ll aa = stoll(new_a);
        aa *= pow(10, 10 - a.size() +cnt);
        as.push_back(aa);
    }
    ll ans = 0;
    ll thre = 50;
    vector <vector <ll>> twofives(thre, vector<ll>(thre, 0));
    for(auto a: as){
        ll twos = 0;
        if (a == 0){
            twofives[thre-1][thre-1]++;
            continue;
        }
        while(a % 2 == 0){
            a /= 2;
            twos++;
        }
        ll fives = 0;
        while(a % 5 == 0){
            a /= 5;
            fives++;
        }
        twofives[twos][fives]++;
    }
    REP(i1, thre){
        REP(j1, thre){
            REP(i2, thre){
                REP(j2, thre){
                    if ((i1 == i2) && (j1 == j2)){
                        if (i1 + i2 < 18){
                            continue;
                        }
                        if (j1 + j2 < 18){
                            continue;
                        }
                        ans += twofives[i1][j1] * (twofives[i2][j2] - 1) ;
                        continue;
                    }
                    if (i1 + i2 < 18){
                        continue;
                    }
                    if (j1 + j2 < 18){
                        continue;
                    }
                    if (twofives[i1][j1] == 0){
                        continue;
                    }
                    if (twofives[i2][j2] == 0){
                        continue;
                    }
                    ans += twofives[i1][j1] * twofives[i2][j2];
                }
            }
        }
    }
    cout << ans/2 << endl;
    return 0;
}

Measured memory_bytes: 5812
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;

    immutable long MOD = 10^^9 + 7;
    long ans = 1;
    long pos = 1;
    long cnt = 0;

    foreach (i; 0..N) {
        if (A[i] >= pos) {
            cnt += 1;
            pos += 2;
        } else {
            ans = ans * (cnt + 1) % MOD;
        }
    }

    while (cnt) {
        ans = ans * cnt % MOD;
        cnt -= 1;
    }

    ans.writeln;
}

Measured memory_bytes: 4356
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXN=120;
int a[MAXN];
int cnt[MAXN];

bool check(int N) {
	if(a[N-1]!=a[N-2]) return 0;
	int len=a[N-2];
	for(int i=0;i<N;i++) cnt[a[i]]++;
	debug("! (len%d)\n",len);
	for(int i=len;i>len/2;i--)
		if(cnt[i]<2) {
			debug("i==%d\n",i);
			return 0;
		}
	int mid=len/2;
	if(len%2==1) mid++;
	if(len%2==1 && cnt[mid]!=2) return 0;
	if(len%2==0 && cnt[mid]!=1) return 0;
	for(int i=mid-1 ; i>=0 ; i--)
		if(cnt[i]>0) return 0;
	return 1;
}

int main() {
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;i++) scanf("%d",a+i);
	sort(a,a+N);
	puts(check(N)?"Possible":"Impossible");
	return 0;
}


Measured memory_bytes: 384
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var A = Number(lines[0].split(" ")[0])
    var B = Number(lines[0].split(" ")[1])
    var K = Number(lines[0].split(" ")[2])

    var ans = {};
    for (var i = A; i < Math.min(A + K, B + 1); i++) { ans[i] === undefined ? ans[i] = 1 : ans[i]++; }
    for (var i = B; Math.max(B - K, A - 1) < i; i--) { ans[i] === undefined ? ans[i] = 1 : ans[i]++; }

    Object.keys(ans).forEach(value => {
        console.log(value)
    })
});

Measured memory_bytes: 9088
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl a(n);
    vl rui(n+1);  // rui[i+1] : a[0]からa[i]までの和
    rep(i, n) {
        cin >> a[i];
        rui[i+1] = rui[i] + a[i];
    }

    vvl dp(n, vl(n+1));  // dp[L][R] : a[L],…,a[R-1]の状態からはじめて1匹にするためのコストの総和の最小値
    exrep(len, 2, n) {  // 区間の長さ(len = 1 のときdpの値は0)
        for(ll L = 0; L + len <= n; L++) {  // 区間[L,R)の左
            ll R = L + len;  // 区間[L,R)の右
            // まずa[L],…,a[x-1]を合成してcost1でスライム1を作る
            // 次にa[x],…,a[R-1]を合成してcost2でスライム2を作る
            ll u = INF;  // cost1 + cost2 の最小値
            exrep(x, L+1, R-1) {
                ll cost1 = dp[L][x];
                ll cost2 = dp[x][R];
                chmin(u, cost1 + cost2);
            }
            // 最後にスライム1とスライム2を合成してcost3でスライム3を作る
            ll cost3 = rui[R] - rui[L];  // スライム1の大きさ(rui[x] - rui[L]) + スライム2の大きさ(rui[R] - rui[x])
            dp[L][R] = u + cost3;
        }
    }
    
    out(dp[0][n]);
    re0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <math.h>
#include <iomanip>
#include <bits/stdc++.h>
#include <string.h>
#include <string>
#include <algorithm>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << (#x) << " = " << x << endl;
#define debug2(i,j) cout << (#i) << "=" << i << " , " << (#j) << "=" << j << endl;

using namespace std;

ll modInverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

ll binomialCoeff(ll n,ll k)
{
    ll res = 1;
    if(k >n - k)
        k = n - k;
    for(int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

ll power(ll x,ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}

/* nCr % mod
ll fact[6*N];
ll inv[6*N],invfac[6*N];
ll mod = 998244353;

void factorial()
{
    fact[0] = invfac[0] = fact[1] = invfac[1] = 1;
    inv[1] = 1;
    for(int i=2;i<=5*N + 10;i++)
    {
        fact[i] = (fact[i-1]*i)%mod;
        inv[i] = (inv[mod%i]*(mod - mod/i))%mod;
        invfac[i] = (invfac[i-1]*inv[i])%mod;
    }
}*/

bool prime[100005];

void Sieve(int n)
{
    //bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    /*for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";*/
}

//******************************************************    CHECK CONSTRAINTS   ***************************************************************//

const int Nmax = 1e6 + 5;
ll mod = 1e9 + 7;

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int x,y;
    cin >> x >> y;
    bool ans = false;
    for(int i=0;i<=x;i++)
    {
        int p = i*4 + (x-i)*2;
        if( p == y)
            ans = true;
    }
    if(ans)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>

using namespace std;

int main(){

 int n;
  cin >> n;
  
  int m=n;
  
  int res=0;
  
  while(n>0){
   res+=n%10;
    n/=10;
  }
  if(m%res==0)
  cout << "Yes" << endl;
  else
  cout << "No" << endl;  
}

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

int main() {
  string Ans;
  int A; cin >>A;
  if (A>=30) {
    Ans="Yes";
  }else{
    Ans="No";
  }
  cout << Ans << '\n';
  return 0;
}


Measured memory_bytes: 3624
N=int(input())
S=input()
S=list(map(int,S))
ans=0
for s in range(1000):
      A=s//100
      B=(s-A*100)//10
      C=s-A*100-B*10
      isOne=0
      isTen=0
      isHundred=0
      for i in range(N) :
        if isOne==0:
          if S[i]==A: 
            isOne=1
        elif isTen==0:
          if S[i]==B: 
            isTen=1
        elif isHundred==0:
          if S[i]==C:
            isHundred=1
            ans+=1
        else:
          break

print(ans)

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

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

int main() {
  int a, b;
  cin >> a >> b;
  int x, y;
  ExtGcd(a, b, x, y);
  cout << x << ' ' << y << endl;
}


Measured memory_bytes: 3092
N = gets.chomp.to_i
A = gets.chomp.split(' ').map(&:to_i)

ans = 1000
A.each do |aaa|
  count = 0
  while aaa % 2 == 0
    aaa = aaa / 2
    count += 1
  end
  ans = [ans, count].min
end

p ans

Measured memory_bytes: 1788
N,A,B=map(int,input().split())
l=[]
count=0
num=0
for i in range(N):
    num=i+1
    l=list(str(num))
    for j in range(len(l)):
        l[j]=int(l[j])
    #print(l)
    if (A<=sum(l))and(sum(l)<=B):
        count=count+num
print(count)

Measured memory_bytes: 42588
import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> v = new ArrayList<>();
        for(int i=0; i<N; i++){
            v.add(scanner.nextInt());
        }
        Collections.sort(v);
        double val = v.get(0);
        for(int i=1; i<N; i++){
            val = (val + v.get(i))/2.0;
        }

        System.out.println(val);
    }
}

Measured memory_bytes: 21588
//Be Name Khoda
/*
ID: aminra81
PROG: :)))
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const ll inf = (ll)1e18;
const int infint = (int)2e9;
const int MAXN = 1e6 + 7;
ll part[MAXN], part2[MAXN];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int a; 
		cin >> a;
		part[i] = a;
		part2[i] = a;
		if(i != 0)
			part[i] += part[i - 1], part2[i] += part2[i - 1];
	}
	ll sum = 0, ans = 0;
	//first +
	for (int i = 0; i < n; i++)
	{
		part[i] += sum;
		if(i % 2 == 0 and part[i] <= 0)
		{
			ans += 1 - part[i];
			sum += 1 - part[i];
		}
		if(i % 2 and part[i] >= 0)
		{
			ans += part[i] + 1;
			sum -= part[i] + 1;
		}
	}
	
	//first -
	ll sum2 = 0, ans2 = 0;
	for (int i = 0; i < n; i++)
	{
		part2[i] += sum2;
		if(i % 2 == 0 and part2[i] >= 0)
		{
			ans2 += part2[i] + 1;
			sum2 -= part2[i] + 1;
		}
		if(i % 2 and part2[i] <= 0)
		{
			ans2 += 1 - part2[i];
			sum2 += 1 - part2[i];
		}
	}
	cout << min(ans, ans2);
}

Measured memory_bytes: 5120
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int N, P;

int main()
{
  while (scanf("%d %d ", &N, &P) == 2) {
    if (N == 0 && P == 0) {
      return 0;
    }
    vector<int> v(N);
    int p = P;
    for (int i = 0;; i = (i + 1) % N) {
      if (p == 0) {
	p += v[i];
	v[i] = 0;
      } else {
	v[i]++;
	p--;
      }
      if (v[i] == P) {
	printf("%d\n", i);
	break;
      }
    }
  }
}

Measured memory_bytes: 912
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define push_back pb
#define int long long int
int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	while (t--)
	{
		string s;
		int n = 0;
		cin >> s;
		for (auto i : s)
		{
			n += i - '0';
		}
		(n % 9 == 0) ? cout << "Yes" : cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = max(a*c, a*d);
  ans = max(ans, b*c);
  ans = max(ans, b*d);
  cout << ans << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

//container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQUE(a)  (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,n,0)

//debug
#define dump(x)  cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";

int a1,a2,a4;
int main() {
	int n;
	cin >> n;
	REP(i,n){
		int a;
		cin>>a;
		if(a%4==0)a4++;
		else if(a%2==0)a2++;
		else a1++;
	}
	bool yes = false;
	if(a2){
		if(a4>=a1)yes = true;
	}else{
		if(a4>=a1-1)yes = true;
	}
	cout << (yes ? "Yes" : "No") << endl;
}


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

int main() {
    int N; cin >> N;
    int ret = N;
    for (int i = 0; i <= N; i++) {
        int cc = 0;
        int t = i;
        while (0 < t) {
            cc += t%6;
            t /= 6;
        }
        t = N-i;
        while (0 < t) {
            cc += t%9;
            t /= 9;
        }
        if (cc < ret) {
            ret = cc;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <map>
#define ll long long

using namespace std;

int main(void){
    ll n, q;
    cin >> n >> q;
    vector<vector<ll>> g(n+1);
    for(ll i = 1; i <= n-1; i++){
        ll a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<ll> dist(n+1,-1);
    queue<ll> que;
    dist[1] = 0;
    que.push(1);
    vector<pair<ll, ll>> pairs(n+1);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(ll nv : g[v]){
            if(dist[nv]!=-1) continue;
            dist[nv] = dist[v]+1;
            que.push(nv);
        }
    }

    vector<ll> ans(n+1, 0);
    for(ll i = 0; i < q; i++){
        ll a, b; cin >> a >> b;
        ans[a] += b;
    }
    for(ll i = 1; i <= n; i++)
        pairs[i] = make_pair(dist[i], i);

    sort(pairs.begin()+1, pairs.end());

    for(ll i = 1; i <= n; i++){
        ll c = pairs[i].second;
        for(ll j = 0; j < g[c].size(); j++){
            ll d = g[c][j];
            if(dist[c] < dist[d]){
                ans[d] += ans[c];
            }
        }
    }
    for(ll i = 1; i <= n; i++)
        cout << ans[i] << " ";
    cout << endl;
    return 0;
}


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

long long burg(long long  N,long long X){
  long long length,point;
  if(X<=0) return 0;
  else if(N==0) return 1;
  length = 4*pow(2,N)-3;
  point = length/2 + 1;
  if(point > X) return burg(N-1,X-1);
  else if(point == X) return (point-1)/2+1;
  else return (point-1)/2+1+burg(N-1,X-point);
}

int main(int argc,char* argv[]){
  long long N,X;
  cin >> N >> X;
  cout << burg(N,X) << endl;

  return 0;
}


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

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

#define MAXN 1123456
#define MOD 1000000007

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

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

  char c;
  cin >> c;

  cout << (char)(c+1) << endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args : Array<String>) {
    val sc = Scanner(System.`in`)
    val n = Integer.parseInt(sc.next())
    val dList = (0 until n).map { Integer.parseInt(sc.next()) }.sorted()
    val (median1,median2) = dList[n / 2 - 1] to dList[n / 2]
    if (dList.count { it < (median1 + median2) / 2F } == dList.count { it >= (median1 + median2) / 2F }) {
        println(median2 - median1)
    } else {
        println(0)
    }
}

Measured memory_bytes: 56332
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;


vector<string> split(string v,char del){
	vector<string> strs;
	int head=0;
	for(int j = 0; j < v.size(); j++){
		if(v[j]==del){
			strs.push_back(v.substr(head,j-head));
			head=j+1;
		}
		else if(j==v.size()-1){
			strs.push_back(v.substr(head,j-head+1));
		}
	}
	return strs;
}


int main(){
    map<string,int> dict;
    dict["yotta"]=24;
    dict["zetta"]=21;
    dict["exa"]=18;
    dict["peta"]=15;
    dict["tera"]=12;
    dict["giga"]=9;
    dict["mega"]=6;
    dict["kilo"]=3;
    dict["hecto"]=2;
    dict["deca"]=1;
    dict["deci"]=-1;
    dict["centi"]=-2;
    dict["milli"]=-3;
    dict["micro"]=-6;
    dict["nano"]=-9;
    dict["pico"]=-12;
    dict["femto"]=-15;
    dict["ato"]=-18;
    dict["zepto"]=-21;
    dict["yocto"]=-24;
    int n;
    cin>>n;
    string str;
    getline(cin,str);
    while(n--){
        string num;
        string pref;
        string tani;

        getline(cin,str);
        vector<string> strs=split(str,' ');
        num=strs[0];
        int sum=0;

        int initNotZero=-1;
        int commma=-1;
        for(int i = 0; i < num.size(); i++){
            if(num[i]=='.')
                commma=i;
            else if(num[i]!='0'&&initNotZero==-1)
                initNotZero=i;
        }
        if(initNotZero==0){
            int diff;
            if(commma!=-1){
                diff=commma-1;
                num=num.substr(0,commma)+num.substr(commma+1);
            }
            else
                diff=num.size()-1;
            sum+=diff;
        }
        else{
            int diff=initNotZero-commma;
            num=num.substr(initNotZero);
            sum-=diff;
        }
        num=num.substr(0,1)+'.'+num.substr(1);
        if(num[num.size()-1]=='.')
            num=num.substr(0,num.size()-1);
        if(strs.size()==2)
            tani=strs[1];
        else{
            pref=strs[1];tani=strs[2];
            int t=dict[pref];
            sum+=t;
        }
        cout<<num<<" * "<<"10^"<<sum<<" "<<tani<<endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll a,b,k;
  cin>>a>>b>>k;
  if(a>k) cout<<a-k<<" "<<b<<endl;
  else{
    ll j=k-a;

    if(b-j<0) b=j;
    cout<<0<<" "<<b-j<<endl;
  }
}


Measured memory_bytes: 256
n,a,b = map(int ,input().split())
d=0
sum_list=[]
for i in range(1,n+1):
    l=(list(str(i)))
    for j in range(len(l)):
        d+=int(l[j])
    if a<=d<=b:
        sum_list.append(i)
        d=0
    else:
        d=0
print(sum(sum_list))

Measured memory_bytes: 3420
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys
from collections import deque

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    s = input()
    l = len(s)
    n = [0] * l
    rite = 0
    lite = 0

    cnt = 0
    for i in range(l):
        if s[i] == 'L':
            if cnt > 0:
                n[i] += cnt//2
                n[i-1] += cnt- cnt//2
                cnt = 0
        else:
             cnt += 1

    cnt = 0
    for i in range(l-1, -1, -1):
        if s[i] == 'R':
            n[i] += cnt//2
            n[i+1] += cnt - cnt//2
            cnt = 0
        else:
            cnt += 1

    print(*n)


if __name__ == '__main__':
    main()


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

int main() {
    string S;
    cin >> S;
    int n = 0 , t = 0;
    for (int i = 0; i < S.size(); ++i) {
        if(S.at(i) == '1'){
            n++;
        }
        else{
            t++;
        }
    }
    cout << 2 * min(n , t) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main()
{
	string S, T;
	cin >> S>>T;

	int slen = S.size();
	int tlen = T.size();

	int l = slen-tlen+1;
	vector<string> cand;
	for (int i = 0; i < l; i++){
		//cout << i<<" " << l <<" "<<S[i] << endl;
		bool flg = true;
		bool flg2=false;
		REP(j, tlen){
			if(S[i+j]==T[j]||S[i+j]=='?'){
				flg2=true;
				continue;
			}
			else {
				flg=false;
				break;
			}
			//cout << S[i+j]<<" "<<T[j] <<" "<<flg<< endl;
		}
		//cout << flg <<" "<<flg2 << endl;
		
		if(flg&flg2){
			string tmps = S;
			REP(j, tlen) tmps[i+j]=T[j];
			REP(j, slen) {
				if(tmps[j]=='?') tmps[j]='a';
			}
			cand.push_back(tmps);
		}
		
	}
	sort(cand.begin(), cand.end());
	//for(auto x:cand) cout << x << endl;
	cout << (cand.size()==0?"UNRESTORABLE":cand[0]) << endl;

	return 0;
}

Measured memory_bytes: 256