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

using namespace std;

typedef unsigned long long ui64;

int n, m; 
long long res = 0;
priority_queue<int> q;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        res += x;
        q.push(x);
    }

    for(int i = 0; i < m; i++){
        int cur = q.top();
        q.pop();
        res -= (cur - (cur >> 1));
        q.push(cur >> 1);
    }

    cout << res << endl;
}

Measured memory_bytes: 892
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int ans=0;
		for(int i=1; i<=n; i++){
			String s=String.valueOf(i);
			if(s.length()%2==1){
				ans++;
			}
		}
		System.out.println(ans);
	}
}


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

using namespace std;

int main(){
    long long A=0,B=0,C=0,D=0,N=0,ans=0;
    string S;



    cin>>N;
    vector<long long> vec(N);
    vector<long long> tt(N);

    for(int i=0;i<N;++i)
    {
            cin>>vec[i];
                }
    
    for(int i=0;i<N;++i)
    {
            cin>>tt[i];

    }

    for(int k=0;k<=(1<<N);++k){
        long cos=0,eki=0;
        for(int i=0;i<N;++i){
            if(k&(1<<i)){
                eki+=vec[i];
                cos+=tt[i];
            }
        }
        if(ans<eki-cos){ 
            ans=eki-cos;
        }
    }





    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n), orderd(n);
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
        orderd[i] = a[i];
    }

    std::sort(orderd.begin(), orderd.end());

    if(orderd[n - 1] == orderd[n - 2]){
        // 最大値が2つあればどれ抜いても最大値
        for(int i = 0; i < n; i++){
            std::cout << orderd[n - 1] << std::endl;
        }
    }else{
        // 最大値が1つであればその最大値の場合を除いて全部最大値
        for(int i = 0; i < n; i++){
            if(a[i] == orderd[n - 1]){
                std::cout << orderd[n - 2] << std::endl;
            }else{
                std::cout << orderd[n - 1] << std::endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int dp1[7],dp2[6];
int dp[100010];
void initialise()
{
    int i;
    dp1[0]=6,dp2[0]=9;
    for(i=1;i<=6;i++)
    {
        dp1[i]=dp1[i-1]*6;
    }
    for(i=1;i<=5;i++)
    {
        dp2[i]=dp2[i-1]*9;
    }
    
    //cout<<dp1[6]<<" "<<dp2[5]<<" ";
    
}

int main()
{
    initialise();
    int n,i,j,ans=0,k;
    cin>>n;
    dp[0]=0;
    dp[1]=1;
    for(i=2;i<=n;i++)
    {
        ans=dp[i-1]+1;
        j=i,k=0;
        while(j-dp1[k]>=0)
        {
            ans=min(ans,dp[j-dp1[k]]+1);
            k++;
        }
        k=0;
        while(j-dp2[k]>=0)
        {
            ans=min(ans,dp[j-dp2[k]]+1);
            k++;
        }
        dp[i]=ans;
        
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to,cap,rev; 
	edge (int from, int to, int cap, int rev){
		this->from=from; this->to=to; this->cap=cap; this->rev=rev;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;



int main(){
	int k, s;
	cin >> k >> s;
	int cnt = 0;
	FORI(0, k + 1) {
		FORJ(0, k + 1) {
			if (i + j <= s && s-(i+j)<=k)
				cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long ll;

int main() {
   int n;
   cin >> n;
   vector<int> a(n);
   for( int i = 0; i < n; i++ ) cin >> a[i];
   sort(a.begin(), a.end());
   int res = 0;
   int mi = 1e9;
   for( int i = 0; i < n-1; i++ ) {
       if( mi >= abs(a[n-1]/2-a[i])) {
           mi = abs(a[n-1]/2-a[i]);
           res = a[i];
       }
   }
   cout << a.back() << " " << res << endl;
   return 0;  
}

Measured memory_bytes: 640
n = int(input())
b = [int(bk) for bk in format(abs(n), "b")[::-1]] + [0] * 3
if n>=0:
    for i, bk in enumerate(b):
        if i % 2 and bk:
            b[i + 1] += 1
else:
    for i, bk in enumerate(b):
        if i % 2==0 and bk:
            b[i + 1] += 1
for i, bk in enumerate(b):
    if bk > 1:
        if b[i + 1] > 0:
            b[i + 1] -= 1
        else:
            b[i + 1] += 1
            b[i + 2] += 1
        b[i] -= 2
print(int("".join(map(str,b[::-1]))))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long LL;
typedef unsigned long long ULL;
const LL LINF = 0x3f3f3f3f3f3f3f3f; 
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int mod = 1e9+7;
const ULL P = 131;
const int N = 2e5+7;

int a[N];

int main()
{
	string s;
	cin>>s;
	if(s[1]=='B') cout<<"ARC\n";
	else cout<<"ABC\n"; 
	
	
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> P;
int mod = 1e9+7;

vector<P> prime_factorize(int N){
	vector<P> ans;
	for(int a = 2; a*a <= N; a++){
		if(N%a == 0){
			int ex = 0;
			while(N%a == 0){
				ex++;
				N /= a;
			}
			ans.push_back(P(a, ex));
		}
	}
	if(N != 1) ans.push_back(P(N, 1));
	return ans;
}

signed main(){
	int N, Q; cin >> N >> Q;
	vector<P> map = prime_factorize(Q);
    int ans = 1;
    for (int i = 0; i < map.size(); i++) {
        for (int j = 0; j < map[i].second/N; ++j) ans *= map[i].first;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const long long M=0xffffffffff;
int main()
{
	long long sum,a,b,gap, n,temp,t;
	while(cin>>n) 
	{
		sum=0;
		t=M;
		for(long long i=0;i<n;i++)
		{
			scanf("%lld%lld",&a,&b);
		    gap=b-a;
		    if(gap<0)
		    {
		    	if(t>b)t=b;
			}
			sum+=a; 
		}
		if(t==M)t=sum;
		cout<<sum-t<<endl;
	}
}

Measured memory_bytes: 256
#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, n) for(int i=0; i<n; i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main(){
    ll n; cin>> n;
    vector<ll> a(n);
    cin>> a[0];
    ll ans=0;
    for(int i=1; i<n; i++){
        cin>> a[i];
        if(a[i] < a[i-1]){
            ans += a[i - 1] - a[i];
            a[i] += a[i - 1] - a[i];
        }
    }
    cout<< ans << endl;
}


Measured memory_bytes: 4744
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
ll in(){ll x; cin >> x; return x;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];

	ll ma = 0, p = 0;
	rep(i, n) if(chmax(ma, abs(a[i]))) p = i;
	co(2*n-2);
	rep(i, n){
		if(i != p){
			a[i] += a[p];
			coVec({p+1, i+1});
		}
	}
	if(a[p] >= 0) rep(i, n-1) coVec({i+1, i+2});
	else rep(i, n-1) coVec({n-i, n-i-1});

	return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <map>
#include <numeric>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

class UnionFind {
    int *par, *rank;
    long long *weight;
    struct Undo_info {
        int x, y, rx, ry;
        long long wx, wy;
    };
    map<pair<int, int>, Undo_info> undo_info;
public:
    UnionFind(int n, int *x) {
        par = new int[n];
        iota(par, par+n, 0);
        rank = new int[n];
        fill(rank, rank+n, 1);
        weight = new long long[n];
        copy(x, x+n, weight);
    };
    int find(int i) {
        while (par[i] != i) i = par[i];
        return i;
    }
    int same(int i, int j) { return find(i) == find(j); }
    void unite(int i, int j) {
        int x = find(i), y = find(j);
        if (x == y) return;
        undo_info[make_pair(i, j)] = {x, y, rank[x], rank[y], weight[x], weight[y]};
        if (rank[x] < rank[y]) {
            par[x] = y;
            weight[y] += weight[x];
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
            weight[x] += weight[y];
        }
    }
    void undo(int i, int j) {
        assert (undo_info.find(make_pair(i, j)) != undo_info.end());
        Undo_info info = undo_info[make_pair(i, j)];
        int x = info.x, y = info.y;
        par[x] = x;
        par[y] = y;
        rank[x] = info.rx;
        rank[y] = info.ry;
        weight[x] = info.wx;
        weight[y] = info.wy;
        undo_info.erase(make_pair(i, j));
    }
    long long get_weight(int i) { return weight[find(i)]; }
};

struct edge { int src, dst, w; };

int main() {
    int n, m; cin >> n >> m;
    int x[n]; for (int i = 0; i < n; i++) cin >> x[i];
    edge es[m];
    for (int i = 0; i < m; i++) {
        int a, b, c; cin >> a >> b >> c;
        es[i] = {a-1, b-1, c};
    }
    sort(es, es+m, [](edge lhs, edge rhs) {
            return lhs.w < rhs.w;
        });
    UnionFind uf(n, x);
    vector<edge> used;
    for (int i = 0; i < m; i++) {
        if (!uf.same(es[i].src, es[i].dst)) {
            uf.unite(es[i].src, es[i].dst);
            used.push_back(es[i]);
        }
    }
    for (int i = used.size()-1; i >= 0; i--) {
        edge e = used[i];
        if (uf.get_weight(e.src) < e.w) {
            uf.undo(e.src, e.dst);
            // cerr << "remove " << i << endl;
        }
        // else cerr << i << " ok, edge weight " << e.w << ", component weight " << uf.get_weight(e.src) << endl;
    }
    int ans = m;
    for (int i = 0; i < m; i++) {
        edge e = es[i];
        // if (uf.same(e.src, e.dst) && uf.get_weight(e.src) >= e.w)
        //     cerr << "edge " << i << " used\n";
        if (uf.same(e.src, e.dst) && uf.get_weight(e.src) >= e.w) ans--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 14388
let list_of_str s =
  let rec f i = if i >= String.length s then [] else s.[i] :: f (i+1) in f 0

let rec solve = function
  | [] -> "YES"
  | 'e'::'r'::'a'::'s'::'e'::'r'::xs | 'e'::'r'::'a'::'s'::'e'::xs
  | 'd'::'r'::'e'::'a'::'m'::'e'::'r'::'a'::'s'::'e'::'r'::xs
  | 'd'::'r'::'e'::'a'::'m'::'e'::'r'::'a'::'s'::'e'::xs
  | 'd'::'r'::'e'::'a'::'m'::'e'::'r'::xs
  | 'd'::'r'::'e'::'a'::'m'::xs
    -> solve xs
  | _ -> "NO"

let () = Scanf.scanf "%s" list_of_str |> solve |> print_endline


Measured memory_bytes: 9472
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	ll N, X, Y; cin >> N >> X >> Y;

	ll dis[N][N];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			dis[i][j] = abs(i - j);
		}
	}

	X--; Y--;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			dis[i][j] = min(dis[i][j], dis[i][X] + dis[Y][j] + 1);
		}
	}

	ll ans[N] = {};
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			ans[dis[i][j]]++;
		}
	}

	for (int i = 1; i < N;i++) {
		cout << ans[i] << endl;
	}
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	cin >> n;
	cout << fixed << setprecision(7);
	cout << ((n + 1) / 2) / (double)n << endl;
	
    return 0;
}



Measured memory_bytes: 3804
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<iostream>
using namespace std;


int main()
{
	int i, j, k, l, A, B, C, D, X, Y;
	long long int sum, flag;
	sum = 0;
	flag = 0;
	int x[3];
	cin >> A >> B;
	x[0] = A + B;
	x[1] = A - B;
	x[2] = A * B;
	sort(x, x + 3);
	cout << x[2] << endl;
    return 0;
}



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

char a[2003][2003];
int s[2003][2003];

void pre(int i,int n)
{
	int head=1,sum=0;
	for (int j=1; j<=n; j++)
	{
		if(a[i][j]=='.') 
		{
			if(a[i][head]=='#') head=j;
			sum++;
			if (j==n)
				for (int u=head; u<=j; u++) s[i][u]+=sum;
		}
		else 
		{
			for (int u=head; u<j; u++) s[i][u]+=sum;
			sum=0;
			head=j;
		}
	}
}

void pre2(int i,int n)
{
	int head=1,sum=0;
	for (int j=1; j<=n; j++)
	{
		if(a[j][i]=='.') 
		{
			if(a[head][i]=='#') head=j;
			sum++;
			if (j==n)
				for (int u=head; u<=j; u++) s[u][i]+=sum-1;
		}
		else 
		{
			for (int u=head; u<j; u++) if (s[u][i]) s[u][i]+=sum-1;
			sum=0;
			head=j;
		}
	}
}

int main()
{
	int n,m;
	cin>>n>>m; 
	for (int i=1; i<=n; i++) 
	    for (int j=1; j<=m; j++) cin>>a[i][j];
	    
	for (int i=1; i<=n; i++) pre(i,m);

	for (int j=1; j<=m; j++) pre2(j,n);
	
	int ans=0;
	
	for (int i=1; i<=n; i++)
		for (int j=1; j<=m; j++)
		    ans=max(ans,s[i][j]);
	        
	cout << ans;
}

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

int main(){
  int N, K, S=0;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++){
    int x;
    cin >> x;
    
    if (x <= K/2){
      S += 2*x;
    }
    else {
      S += 2*(K - x);
    }
  }
  cout << S << endl;
}
      

Measured memory_bytes: 256
import numpy as np
n,d=map(int, input().split())
l=[np.array(list(map(int, input().split()))) for _ in range(n)]
cnt=0
for i in range(n):
    for j in range(i+1,n):
        tmp=0
        for k in range(d):
            tmp+=(l[i][k]-l[j][k])**2
        if np.sqrt(tmp)%1==0.0: cnt+=1
print(cnt)

Measured memory_bytes: 12552
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct Data
{
  int days,money;
  Data(int days, int money): days(days), money(money) {}
  bool operator<(const Data& other) const {
    return days < other.days;
}
};

int main(){
  int n, m;
  cin >> n >> m;
  vector<Data> job;

  for(int i = 0; i < n; i++){
    int a, b;
    cin >> a >> b;
    job.push_back(Data(a, b));
  }

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

  int job_index=0;
  int c=0;

  priority_queue<int> salary;

  for( int i = 1; i <= m; i++){
    while( job_index < n && job[job_index].days <= i){
      salary.push(job[job_index].money);
      job_index++;
    }
    if(!salary.empty()){
      c += salary.top();
      salary.pop();
    }
  }

  cout << c << endl;
  return 0;
}

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

map<int,int> mp;

int main(){
    long long ans=0,w=0,h=0;
    int n; cin>>n;
    while(n--){
        int a; cin>>a;
        ++mp[a];
    }
    for(auto it=mp.rbegin();it!=mp.rend();++it){
        while(it->second>1){
            it->second-=2;
            if(w){
                cout<<w*it->first<<endl;
                exit(0);
            }
            w=it->first;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

const int MAXN = 305;

int n, m, st;
char c[MAXN][MAXN];
int ans[MAXN][MAXN];

int main() {
  //assert(freopen("input.txt","r",stdin));
  //assert(freopen("output.txt","w",stdout));

  scanf("%d %d %d\n", &n, &m, &st);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%c", &c[i][j]);
    }
    scanf("\n");
  }

  int cut = 0;
  for (int j = 0; j < m; j++) {
    int count = 0;
    for (int i = 0; i < n; i++) {
      if (c[i][j] == '#') {
        cut++;
        count++;
        ans[i][j] = cut;
      } else if (count > 0) {
        ans[i][j] = cut;
      }
    }
    if (count > 0) {
      for (int i = 0; i < n; i++) {
        if (ans[i][j] == 0) {
          ans[i][j] = cut - count + 1;
        }
      }
    }
  }

  for (int i = 0; i < n; i++) {
    int num = 0;
    for (int j = 0; j < m; j++) {
      if (ans[i][j] != 0) {
        num = ans[i][j];
        break;
      }
    }
    for (int j = 0; j < m; j++) {
      if (ans[i][j] == 0) {
        ans[i][j] = num;
      } else {
        num = ans[i][j];
      }
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      printf("%d ", ans[i][j]);
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 1152
n, x = map(int, input().split())
llist = [0] + list(map(int, input().split())) + [1e9]
for i in range(1, n+2):
  llist[i] += llist[i-1]

for i in range(n+2):
  if llist[i] > x:
    break
print(i)


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

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


Measured memory_bytes: 3112
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var ab = ReadLine().Split().Select(int.Parse).ToArray();
        var a = ab[0];
        var b = ab[1];

        WriteLine((a *3+ b)/2);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const ll INFL = (1LL<<60);
const double eps = (1e-9);

ll solve(const vector<ll>& s, const vector<ll>& t, const ll x) {
  ll ls = s[lower_bound(ALL(s), x) - s.begin() - 1];
  ll us = s[lower_bound(ALL(s), x) - s.begin()];
  ll lt = t[lower_bound(ALL(t), x) - t.begin() - 1];
  ll ut = t[lower_bound(ALL(t), x) - t.begin()];

  ll ans = INFL;
  chmin(ans, x - min(ls, lt));   // 左左
  chmin(ans, max(us, ut) - x);   // 右右
  chmin(ans, 2 * (x-ls) + ut - x);  // 左の神社，右の寺
  chmin(ans, 2 * (x-lt) + us - x);  // 左の寺，右の神社
  chmin(ans, 2 * (ut-x) + x - ls);  // 右の寺，左の神社
  chmin(ans, 2 * (us - x) + x - lt); // 右の神社，左の寺
  return ans;
}

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

  ll a, b, q;
  cin >> a >> b >> q;
  vector<ll> s(a+2);
  vector<ll> t(b+2);
  s[0] = -INFL;
  s[a+1] = INFL;
  t[0] = -INFL;
  t[b+1] = INFL;

  rep(i, a) {
    cin >> s[i+1];
  }
  rep(i, b) {
    cin >> t[i+1];
  }

  rep(i, q) {
    ll x;
    cin >> x;
    cout << solve(s, t, x) << endl;
  }

  return 0;
}


Measured memory_bytes: 2944
//?????\?????????
#include <iostream>
using namespace std;

void disp(int n,int A[])
{
	for(int i = 0 ; i < n ; i++)
	{
		if(i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
	return;
}

void insertionsort(int n,int A[])
{
	int v,j = 0;
	for(int i = 1 ; i < n ; i++)
	{
		v = A[i];
		j = i-1;
		while(j >= 0 && A[j] > v)
		{
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		disp(n,A);
	}
	return;
}

int main(void)
{
	int n;
	cin >> n;
	int A[n];
	for (int i = 0; i < n ; i++)
	{
		cin >> A[i];
	}
	disp(n,A);
	insertionsort(n,A);
	return 0;
}
	

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

struct Edge{
  int from;
  int to;
  long cost;
};

vl dp(100010,-1);
vector<vector<Edge>> Graph(100010);
vl ans(100010,-1);

long dfs(int v, int pv, long m){
  if(dp[v] != -1) return dp[v];
  dp[v] = 1;
  for(Edge ed : Graph[v]){
    int nv = ed.to;
    if(nv == pv) continue;
    dp[v] = (dp[v] * (dfs(nv, v, m) + 1)) % m;
  }
  return dp[v];
}

void dfs2(int v, int pv, long rec, long m){
  int s = Graph.at(v).size();
  vl acm(s+1,1);
  vl rev(s+1,1);
  rep(i,s){
    if(Graph.at(v).at(i).to != pv){
      acm.at(i+1) = (acm.at(i) * (dp[Graph.at(v).at(i).to]+1) ) % m;
    }else{
      acm.at(i+1) = (acm.at(i) * (rec+1)) % m;
    }
    if(Graph.at(v).at(s-1-i).to != pv){
      rev.at(s-1-i) = (rev.at(s-i) * (dp[Graph.at(v).at(s-1-i).to]+1) ) % m;
    }else{
      rev.at(s-1-i) = (rev.at(s-i) * (rec+1)) % m;
    }
  }
  ans[v] = acm[s];
  rep(i,s){
    int nv = Graph.at(v).at(i).to;
    if(nv == pv) continue;
    long r = acm[i] * rev[i+1] % m;
    dfs2(nv, v, r, m);
  }
}

int main(){
  long n,m;
  cin >> n >> m;
  rep(i,n-1){
    int x,y;
    cin >> x >> y;
    x--;y--;
    Graph.at(x).push_back({x,y,1});
    Graph.at(y).push_back({y,x,1});
  }
  ans[0] = dfs(0,-1,m);
  dfs2(0,-1,1,m);
  rep(i,n){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 26812
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define MAX 200001
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

ll n;
bool a[MAX];
ll dp[MAX][2];
ll f(ll index,bool prev){
	if(index==n){
		return 0;
	}
	if(dp[index][prev]!=-1) return dp[index][prev];
	ll ans=0;
	if(!prev){
		ll t1 = f(index+1,a[index]);
		ll t2 = f(index+1,!a[index])+1;
		ans = min(t1,t2);
	}else{
		if(a[index]){
			ans = f(index+1,1);
		}else{
			ans = f(index+1,1)+1;
		}
	}
	dp[index][prev]=ans;
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	memset(dp,-1,sizeof(dp));
	cin>>n;
	string s;cin>>s;
	For(i,0,n) a[i]=(s[i]!='.');
	cout<<f(0,0)<<endl;









	
}

Measured memory_bytes: 13332
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 4e4;
bool flag[N];

int gcd(int a, int b) {
  while (b) {
    int c = a;
    a = b;
    b = c % b;
  }
  return a;
}

int main() {
  int n;
  scanf("%d", &n);
  // n = 10000;
  vector<int> c(n + 1);
  for (int i = n; i >= 0; --i) {
    scanf("%d", &c[i]);
    // c[i] = 1;
  }
  int g = abs(c[n]);
  for (int i = 0; i < n; ++i) {
    int x = abs(c[i]);
    if (x) g = gcd(g, x);
  }
  // int k;
  // for (k = 0; k <= n && c[k] == 0; ++k);
  // n -= k;
  // for (int i = 0; i <= n; ++i) {
  //   c[i] = c[k + i];
  // }
  vector<int> prime;
  for (int i = 2; i < N; ++i) {
    if (flag[i]) continue;
    for (int j = i * i; j < N; j += i) flag[j] = true;
    prime.push_back(i);
  }
  unordered_map<int, int> A;
  set<int> ret;
  int m = g;
  vector<int> f;
  for (auto& p : prime) {
    if (p * p > m) break;
    if (m % p == 0) {
      while (m % p == 0) {
        m /= p;
      }
      f.push_back(p);
    }
  }
  if (m > 1) f.push_back(m);
  for (auto& p : f) {
    A.clear();
    for (int i = 0; i <= n; ++i) {
      int x = i;
      if (x >= p) x = (x - 1) % (p - 1) + 1;
      int y = (c[i] % p + p) % p;
      A[x] = (A[x] + y) % p;
    }
    // trace(p);
    // for (auto& it : A) {
    //   trace(it.first, it.second);
    // }
    bool found = false;
    for (auto& it : A) {
      if (it.second != 0) found = true;
    }
    if (!found) ret.insert(p);
  }
  // trace("1");
  for (auto& p : prime) {
    if (p > n) break;
    A.clear();
    for (int i = 0; i <= n; ++i) {
      int x = i;
      if (x >= p) x = (x - 1) % (p - 1) + 1;
      int y = (c[i] % p + p) % p;
      A[x] = (A[x] + y) % p;
    }
    // trace(p);
    // for (auto& it : A) {
    //   trace(it.first, it.second);
    // }
    bool found = false;
    for (auto& it : A) {
      if (it.second != 0) found = true;
    }
    if (!found) ret.insert(p);
  }
  for (auto& p : ret) {
    printf("%d\n", p);
  }
  return 0;
}


Measured memory_bytes: 768
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int n,m,i,j,k;cin>>m>>n;
	static int uL[100][100];
	static int dL[100][100];
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			uL[i][j]=mod;
			dL[i][j]=0;
		}
	}
	for(i=0;i<m;i++){
		int K;cin>>K;
		while(K--){
			int s,t;
			string cond;
			cin>>s>>cond>>t;s--;
			if(cond=="<="){mineq(uL[i][s],t);}
			else{maxeq(dL[i][s],t);}
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			if(uL[i][j]<dL[i][j]){cout<<"No"<<endl;return 0;}
		}
	}
	vector<vector<int>>go(m);
	vector<int>zi(m);
	for(i=0;i<m;i++){
		for(j=0;j<m;j++){
			bool aru=false;
			for(k=0;k<n;k++){
				if(uL[i][k]<dL[j][k]){aru=true;break;}
			}
			if(aru){go[i].pub(j);zi[j]++;}
		}
	}
	queue<int>que;
	for(i=0;i<m;i++){if(zi[i]==0){que.push(i);}}
	int toru=0;
	while(que.size()){
		toru++;
		int x=que.front();
		que.pop();
		for(auto it:go[x]){
			zi[it]--;
			if(zi[it]==0){que.push(it);}
		}
	}
	cout<<(toru==m?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 3292
#ABC161-F Division or Substraction
"""
nとn-1の約数の個数が答え
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())

"""約数の個数"""
#参考：青チャp280
#注意：1も約数としてカウントされる
def factrize(n):
    b = 2
    fct = []
    while b*b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b+1
    if n > 1:
        fct.append(n)
    if len(fct) == 1: #素数だった場合
        return 2 #1と、その数の2通り
    
    divisor = dict()
    for i in fct:
        if not i in divisor:
            divisor[i] = 1
        else:
            divisor[i] += 1
    ans = 1
    for i in divisor.values():
        ans *= (i+1)
    return ans
def factrize_all(n):
    b = 2
    fct = []
    while b*b <= n:
        if n%b == 0:
            fct.append(b)
        b += 1
    return fct + [n]

ans = 0
res2 = []
for i in factrize_all(n):
    res = n
    while True:
        if res == 0:
            break
        if res%i != 0:
            res2.append([i,res])
            break
        res = res//i

for i,j in res2:
    if j%i == 1:
        ans += 1

print(ans+factrize(n-1)-1) #1を2回引く

Measured memory_bytes: 39664
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int to[200001],nex[200001],val[200001],col[200001],st[100001];
int fa[100001],son[100001],top[100001],dep[100001],siz[100001],sum[100001];
int ans[100001],colsum[100001],colnum[100001];
int n,m,cnt;
vector<int>c1[100001],c2[100001],id[100001],imp[100001];
void addedge(int x,int y,int v,int color)
{
    to[++cnt]=y;
    val[cnt]=v;
    col[cnt]=color;
    nex[cnt]=st[x];
    st[x]=cnt;
}
void dfs1(int x)
{
    dep[x]=dep[fa[x]]+1;
    siz[x]=1;
    for(int i=st[x];i;i=nex[i])
    {
        if(to[i]==fa[x])continue;
        fa[to[i]]=x;
        sum[to[i]]=sum[x]+val[i];
        dfs1(to[i]);
        siz[x]+=siz[to[i]];
        if(siz[to[i]]>siz[son[x]])son[x]=to[i];
    }
}
void dfs2(int x,int f)
{
    top[x]=f;
    if(son[x])dfs2(son[x],f);
    for(int i=st[x];i;i=nex[i])
    {
        if(to[i]==son[x]||to[i]==fa[x])continue;
        dfs2(to[i],to[i]);
    }
}
int LCA(int x,int y)
{
    while(top[x]!=top[y])
    {
        if(dep[top[x]]<dep[top[y]])swap(x,y);
        x=fa[top[x]];
    }
    if(dep[x]>dep[y])swap(x,y);
    return x;
}
void dfs(int x)
{
    for(int i=0;i<id[x].size();i++)
    {
        ans[id[x][i]]-=colsum[c1[x][i]]*imp[x][i];
        ans[id[x][i]]+=colnum[c1[x][i]]*c2[x][i]*imp[x][i];
    }
    for(int i=st[x];i;i=nex[i])
    {
        if(to[i]==fa[x])continue;
        colsum[col[i]]+=val[i];
        colnum[col[i]]++;
        dfs(to[i]);
        colsum[col[i]]-=val[i];
        colnum[col[i]]--;
    }
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<n;i++)
    {
        int x,y,v,color;
        //cin>>x>>y>>color>>v;
        scanf("%d%d%d%d",&x,&y,&color,&v);
        addedge(x,y,v,color);
        addedge(y,x,v,color);
    }
    dfs1(1);
    dfs2(1,1);
    //cout<<sum[4]-sum[1];
    //cout<<LCA(4,3)<<endl;
    for(int i=1;i<=m;i++)
    {
        int x,y,u,v,z;
        //cin>>u>>v>>x>>y;
        scanf("%d%d%d%d",&u,&v,&x,&y);
        z=LCA(x,y);
        ans[i]=sum[x]+sum[y]-2*sum[z];
        c1[x].push_back(u);
        c2[x].push_back(v);
        id[x].push_back(i);
        imp[x].push_back(1);
        c1[y].push_back(u);
        c2[y].push_back(v);
        id[y].push_back(i);
        imp[y].push_back(1);
        c1[z].push_back(u);
        c2[z].push_back(v);
        id[z].push_back(i);
        imp[z].push_back(-2);
    }
    dfs(1);
    for(int i=1;i<=m;i++)
    {
        //cout<<ans[i]<<endl;
        printf("%d\n",ans[i]);
    }
    return 0;
}

Measured memory_bytes: 32372
#include <iostream>

int main() {
  int first=0, second=0, third=0;
  for (int i=0; i<10; ++i) {
    int a;
    std::cin >> a;
    if (a >= first) {third = second; second = first; first = a;}
    else if (a >= second) {third = second; second = a;}
    else if (a >= third) {third = a;}
  }
  std::cout << first << std::endl;
  std::cout << second << std::endl;
  std::cout << third << std::endl;

  return 0;
}


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

int main(){

    int N;
    cin >> N;
    vector<int> vec(N);
    rep(i, N){
        cin >> vec.at(i);
    }


    vector<int> ans(N);
    rep (i, N){
        ans.at(vec.at(i)-1) = i+1;
    }


    rep (i, N){
        cout << ans.at(i) << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>

int main()
{
    int i;
    int n;
    int s[100];

    int k = 0;

    scanf("%d", &n);

    for(i=0;i<n;i++){
        scanf("%d", &s[i]);
    }

    for(i=1;i<n;i++){
        if(s[i-1] == s[i]){
            k++;
            i++;
        }
    }

    printf("%d\n", k);

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<limits>

#define INFTY 2000000000;
int L[500000/2+2];
int R[500000/2+2];
int cnt = 0;

void merge(int* A, int n, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i=0; i<n1; i++){
        L[i] = A[left + i];
    }
    for(int i=0; i<n2; i++){
        R[i] = A[mid + i];
    }
    L[n1] = R[n2] =  INFTY;
    int i=0;
    int j=0;
    for(int k=left; k<right; k++){
        cnt++;
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
        }
        else{
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(int* A, int n, int left, int right){
    if(left+1 < right){
        int mid = (left + right)/2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main(){

    int n;
    scanf("%d", &n);
    int A[500000];
    for(int i=0; i<n; i++) scanf("%d", &A[i]);

    mergeSort(A, n, 0, n);

    for(int i=0; i<n; i++){
        if(i!=n-1) printf("%d ", A[i]);
        else {
            printf("%d\n", A[i]);
            printf("%d\n", cnt);
        }
    }

    return 0;
}



Measured memory_bytes: 6524
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int r,g,b;
	cin>>r>>g>>b;
	int num=r*100+g*10+b;
	if(num%4)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        int N = NextInt();
        int[] A = LineInt();
        int ans = 0;
        for (int i = 0; i < N; i++)
        {
            if (i == A[A[i]-1] - 1) ans++;
        }
        Console.WriteLine(ans/2);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 18144
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)

	l := len(s)
	sum := 0
	for bits := 0; bits < 1<<uint(l-1); bits++ {
		t := ""
		for j := 0; j < l; j++ {
			t += string(s[j])
			if bits&(1<<uint(j)) > 0 {
				x, _ := strconv.Atoi(t)
				sum += x
				t = ""
			}
		}
		if t != "" {
			x, _ := strconv.Atoi(t)
			sum += x
		}
	}
	fmt.Println(sum)
}


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

int gcm_sub(int c,int d)
	{
		if (c % d == 0)
			return d;
		else
			return gcm_sub(d,c % d);
	}
int gcm(int a,int b)
{
	if (a >= b) 
		return gcm_sub(a,b);
	else if (b > a)
		return gcm_sub(b,a);
}

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

int main()
{
	int a[2];
	int i=0;
	int n1,n2;
	while(cin >> n1 >> n2){
		// cout << sizeof(a) / sizeof(a[0]) << endl;
		cout << gcm(n1,n2) << ' ' << lcm(n1,n2) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
import itertools
import math
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
c=itertools.combinations(range(n),2)
lng=0
for a,b in c:
    x1,y1=l[a][0],l[a][1]
    x2,y2=l[b][0],l[b][1]
    lng+=((x2-x1)**2+(y2-y1)**2)**0.5
p=math.factorial(n-1)
print(lng*(p*2)/(p*n))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
signed main(){
   string s;
   cin >> s;
   string pre = "A" , cur;
   int size = (int)s.size();
   int same[size+5] = {0};
   same[size-1] = 1;
   int ans = 0;
   for(int i = size-2; i >= 0; i--){
       if(s[i] == s[i+1]){
           same[i] = (same[i+1] == 0 ) ? 0 : 1;
           same[i]+=same[i+1];
       }
   }
   int rem = 0;
   for(int i = 0; i < size; i++){
              cur = ""; cur+=s[i];
              rem = same[i];
              if(rem > 0){
                  break;
              }
              if(cur != pre){
                 ans++;
              }
              else if(cur == pre){
                 cur+=s[i+1];
                 ans++; i++;
              }
              pre = cur;
   }
   
   if(rem > 0){
       
       int n = rem;
       int extra1 = 0 , parity = 1 , extra2 = 0;
       
       while(n > 0){
           if(parity%2){
               parity^=1;
               n-=2; extra1++; continue;
           }
           parity^=1;
           n--; extra1++; continue;
       }
       
       if(n < 0){
           extra1 = 0;
       }
       
       n = rem; parity = 1;
       
       while(n > 0){
           if(parity%2){
               parity^=1;
               n-=1; extra2++; continue;
           }
           parity^=1;
           n-=2; extra2++; continue;
       }
       
       if(n < 0){
           extra2 = 0;
       }
       
       ans += (max(extra1 , extra2));
       
   }
   
   cout << ans << '\n';
}

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

int main(){
  string s;
  cin >> s;
  int n = s.length();

  
  int q1 = (n-1)/2,q2 =(n+3)/2;

  for(int i = 0;i < q1;i++){
    if(s[i] != s[q1-1-i]){
      cout << "No" << endl;
      return 0;
    }
  }

  for(int i = q2-1;i<n;i++){
    if(s[i] != s[n-1-i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;

int main() {

    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    long long sum = 0;
    long long startat1 = 0, startat2 = 0;

    for (int i = 0; i < n; i++) {
        
        sum += a[i];

        if (i % 2 == 0 && sum <= 0) {
            startat1 += 1 - sum;
            sum = 1;
        }
        else if (i % 2 != 0 && sum >= 0) {
            startat1 += 1 + sum;
            sum = -1;
        }
    
    }
    sum = 0;
    for (int i = 0; i < n; i++) {
        
        sum += a[i];

        if (i % 2 == 0 && sum >= 0) {
            startat2 += 1 + sum;
            sum = -1;
        }
        else if (i % 2 != 0 && sum <= 0) {
            startat2 += 1 - sum;
            sum = 1;
        }
    
    }

    cout << min(startat1, startat2) << endl;

    return 0;

}

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

int main(){
  int a,b,sum,i;
  cin >> a >> b;
  sum=0;
  for(i=0;i<2;++i){
    if(a>b){
      sum=sum+a;
      --a;
    }else{
      sum=sum+b;
      --b;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cassert>
#include <unordered_map>

#define DEBUG false
#define OJ_DEBUG

#define $(x) {if (DEBUG) {cout << __LINE__ << ": "; {x} cout << endl;}}
#define _(x) {cout << #x << " = " << x << " "; }
const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

typedef long long ll;
typedef std::pair<int, int> pii;
typedef unsigned long ul;

int main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    vector<int> v;
    cin >> n;
    for (int i = 0, a; i < n; ++i) {
        cin >> a;
        v.push_back(a);
    }
    int min_d = 1e9;
    for (int i = 1; i <= 100; ++i) {
        int p = i;
        int dif = 0;
        for (int j = 0; j < n; ++j) {
            int aux = pow(v[j] - p, 2);
            dif += aux;
        }
        min_d = min(min_d, dif);
    }
    cout << min_d << '\n';
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  if(s == "Sunny") 		cout << "Cloudy";
  else if(s == "Cloudy")cout << "Rainy";
  else if(s == "Rainy") cout << "Sunny";
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

ll D, G, p[12], c[12];

int main() {

	scanf("%lld %lld", &D, &G);
	rep(i, D) scanf("%lld %lld", &p[i], &c[i]);
	int Ans = 123456789;
	rep(i, 1 << D) {
		vector<ll> lefts(D);
		rep(j, D) lefts[j] = p[j];
		ll score = 0;
		int count = 0;

		rep(j, D) {
			if (i & 1 << j) {
				score += (j + 1) * 100 * p[j] + c[j];
				lefts[j] = 0;
				count += p[j];
			}
		}

		while (score < G) {
			vector<ll> scores(D);

			rep(j, D) {
				if (lefts[j] <= 0) {
					scores[j] = 0;
				}
				else if (lefts[j] == 1) {
					count = 123456789;
					break;
					//scores[j] = (j + 1) * 100 + c[i];
				}
				else {
					scores[j] = (j + 1) * 100;
				}
			}

			if (count == 123456789) break;

			int m = distance(scores.begin(), max_element(scores.begin(), scores.end()));
			lefts[m]--;
			score += scores[m];
			count++;
		}
		Ans = min(Ans, count);
	}

	printf("%d\n", Ans);

	return 0;
}

Measured memory_bytes: 256
def ok (last4):
    for i in range(4):
        t = list(last4)
        if i >=1:
            t[i-1],t[i] = t[i],t[i-1]
        if ''.join(t).count('AGC')>=1:
            return False
    return True
def dfs (cur,last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur==N:
        return 1
    res =0
    for c in "ACGT":
        if ok(last3+c):
            res += dfs(cur+1,last3[1:]+c)
            res = res%mod
    memo[cur][last3]=res
    return res
mod = 10**9+7
N = int(input())
memo=[{} for _ in range(N+1)]

print(dfs(0,"TTT"))

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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int a,b,c,d;

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

Measured memory_bytes: 256