akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n-1; i++) cin >> c[i];
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (i && a[i-1] + 1 == a[i]) ans += c[a[i-1]-1];
        ans += b[a[i]-1]; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main() {
    int a,b,c,x;
    cin >> a >> b >> c;
    x = (a-c)%b;
    FOR(i,1,10000){
        x = (x+a)%b;
        if (x==0) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 3604
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+:---test
RUDLUDR
---+/
/+---test
DULL
---+/

void main(string[] args) {
  const S = readln.chomp;

  foreach (i, c; S) {
    ++i;
    if ((i%2 == 1 && c == 'L') || (i%2 == 0 && c == 'R')) {
      "No".writeln;
      return;
    }
  }
  "Yes".writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n;
 
    scanf("%d", &n);
 
    for (int i = 0; i < n; i++){
        int k, p;
        scanf("%d %d", &k, &p);
        printf("%d\n", (k - 1) % p + 1);
    }
 
    return (0);
}

Measured memory_bytes: 1188
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

const int INF=5e8;
int h,w,K;
char buf[805][805];
int cost[805][805];
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int main(){
  cin>>h>>w>>K;
  REP(i,h) scanf("%s",buf[i]);
  int sx,sy;
  REP(i,h) REP(j,w) if(buf[i][j]=='S'){
    sy=i;sx=j;
  }
  memset(cost,-1,sizeof(cost));
  queue<pi> q;q.push({sy,sx});
  cost[sy][sx]=0;
  int res=INF;
  while(!q.empty()){
    pi cur=q.front();q.pop();
    if(cost[cur.fr][cur.sc]>K) continue;
    chmin(res,(cur.fr+K-1)/K+1);
    chmin(res,(cur.sc+K-1)/K+1);
    chmin(res,((h-1-cur.fr)+K-1)/K+1);
    chmin(res,((w-1-cur.sc)+K-1)/K+1);
    REP(d,4){
      int px=cur.sc+dx[d],py=cur.fr+dy[d];
      if(px<0 || py>=h || py<0 || px>=w || buf[py][px]=='#') continue;
      if(cost[py][px]!=-1) continue;
      cost[py][px]=cost[cur.fr][cur.sc]+1;
      q.push({py,px});
    }
  }
  cout<<res<<endl;
  return 0;
}





Measured memory_bytes: 3456
using System;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int[] a=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] s=new int[n];
		int b=n%2,c=n/2;
		s[c]=a[0];
		for(int i=1;i<n;i++){
			if(i%2==b){s[c+(i+1)/2]=a[i];}
			else {s[c-(i+1-b)/2]=a[i];}
		}
		for(int i=0;i<n-1;i++){Console.Write("{0} ",s[i]);}
		Console.WriteLine("{0}",s[n-1]);
	}
}

Measured memory_bytes: 36264
/***



***/

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>

#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <queue>

using namespace std;

void solve(){

    long long n, m, input;
    cin >> n >> m;

//    long long <vector> arr;
    for(int i=1; i<=m; i++){
        cin >> input;
        n-=input;
    }

    if(n>=0)
        cout << n << endl;
    else
        cout << -1 << endl;

}


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

//
//    long long t;
//
//    cin >> t;
//
//   while(t--){
        solve();


//  }
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;
// import java.io.*;

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

        int num = sc.nextInt();

        ArrayList<Integer> array = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            int tmp = sc.nextInt();
            array.add(tmp);
        }

        int num_query = sc.nextInt();

        for (int i = 0; i < num_query; i++) {
            int l = sc.nextInt();
            int m = sc.nextInt();
            int r = sc.nextInt();

            Collections.rotate(array.subList(l, r), l - m);
        }

        for (int i = 0; i < array.size(); i++) {
            sb.append(array.get(i));
            if (i != array.size() - 1) sb.append(' ');
        }

        System.out.println(sb);
        
        sc.close();
    }
}



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

int main() {
  string S;
  int flg = 0;
  cin >> S;
  if(S.at(0)==S.at(1)&&S.at(1)==S.at(2)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    long long int n, ans = 0;
    cin >> n;
    vector<int> a(n + 1), b(n);
    for(int i = 0;i < n + 1;i++) cin >> a[i];
    for(int i = 0;i < n;i++) cin >> b[i];

    for(int i = 0;i < n;i++){
        if(a[i] + a[i + 1] >= b[i]){
            ans += b[i];
            if(b[i] - a[i] >= 0){
                a[i + 1] = a[i + 1] - (b[i] - a[i]);
                a[i] = 0;
            }
            else{
                a[i] = a[i] - b[i];
            }
            b[i] = 0;
        }
        else{
            ans += a[i] + a[i + 1];
            b[i] -= a[i] + a[i + 1];
            a[i] = 0;
            a[i + 1] = 0;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)998244353
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll N=1000005, inf=1e18;
vector<vector<ll> > v;
vector<ll> a(25);
ll n, ans=0, m;
void go(ll idx,ll val){
	ll cur=0;
	if(idx==n+1){
		for(auto i : v)
			if(a[i[1]]-a[i[0]]==i[2])cur+=i[3];
		ans=max(ans,cur);
		return;
	}
	rep(i,val,m+1){
		a[idx]=i;
		go(idx+1,i);
	}
}
void solve(){
	ll q, x;
	cin>>n>>m>>q;
	vector<ll> tmp;
	rep(i,0,q){
		tmp.clear();
		rep(j,0,4){
			cin>>x;
			tmp.pb(x);
		}
		v.pb(tmp);
	}
	go(1,1);
	cout<<ans;
}	
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(time(NULL));
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


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

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


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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert

void solve(){
    ll n;
    cin>>n;
    ll a[n];
    map<ll,ll> MAP;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        MAP[a[i]]++;
    }
    ll tot = 0;
    for(auto it : MAP){
        tot += (it.ss*(it.ss-1))/2;
    }
    for(ll i=0;i<n;i++){
        ll f = MAP[a[i]];
        ll val = tot - (f*(f-1))/2;
        f--;
        val += (f*(f-1))/2;
        cout << val << endl;
    }

}

int main(){
    
    IOS;
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 11904
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll dp[310][310];
ll map[310][310];
ll check[310][310];
int main()
{
	ll n;
	scanf("%lld", &n);
	ll dap = 0;
	for (int i = 0; i < n; i++)
	{
		for (int y = 0; y < n; y++)
		{
			scanf("%lld", &map[i][y]);
			dp[i][y] = map[i][y];
		}
	}

	for (int z = 0; z < n; z++) 
	{
		for (int i = 0; i < n; i++)
		{
			for (int y = 0; y < n; y++)
			{
				dp[i][y] = min(dp[i][y], dp[i][z] + dp[z][y]);
				if (i!=z&&y!=z&&dp[i][y] == dp[i][z] + dp[z][y])
					check[i][y] = 1;
			}
		}
	}
	for (int i = 0; i < n; i++)
		for (int y = 0; y < n; y++)
			if (!check[i][y])
				dap += dp[i][y];
	for (int i = 0; i < n; i++)
	{
		for (int y = 0; y < n; y++)
		{
			if (dp[i][y] != map[i][y])
			{
				puts("-1");
				return 0;
			}
		}
	}
	printf("%lld", dap/2);
}

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

using namespace std;

#define MAX_S 1000001
#define MAX_T 10001
typedef unsigned long long ull;
const ull B = 1000000007ULL;

vector<ull> p;

vector<ull> rollingHash(char *s,int N){
    vector<ull> hash(N+1);
    hash[0] = 0;
    for(int i = 0 ; i < N ; i++){
        hash[i+1] = hash[i]*B + s[i];
    }
    return hash;
}

int main(){
    char S[MAX_S],T[MAX_T];
    scanf("%s %s",S, T);
    int N = strlen(S);
    int M = strlen(T);
    if(N < M) return 0;
    p.resize(N+1);
    p[0] = 1;
    for(int i = 0 ; i < N ; i++){
        p[i+1] = p[i]*B;
    }
    vector<ull> h = rollingHash(S,N);
    vector<ull> h2 = rollingHash(T,M);
    for(int i = 0 ; i < N ; i++){
        if(i+M > N) continue;
        int L = i, R = i+M-1;
        if(h[R+1]-h[L]*p[R-L+1] == h2[M]){
            printf("%d\n",i);
        }
    }
    return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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



void solve() {
	int r, D, x; cin >> r >> D >> x;
    vector<ll> nv(11, 0);
    nv[0] = x;
    rep1(i, 10){
        nv[i] = r * nv[i-1] - D;
    }

    rep1(i, 10){
        cout << nv[i] << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) cin<<(x);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x, v) lower_bound((x).begin(), (x).end(), (v))
#define uboundv(x, v) upper_bound((x).begin(), (x).end(), (v))
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1

typedef long long ll;

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	ll q, h, s, d, n, m1, ans;
	cin>>q>>h>>s>>d>>n;
	m1 = q*4;
	m1 = min(h*2, m1);
	m1 = min(s, m1);
	if(m1*2<=d) {
		ans = m1*n;
	}
	else {
		ans = d*(n>>1);
		if(n&1) ans += m1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(int argc, const char * argv[]) {
    double x1,x2,y1,y2;
    double d;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    d=sqrt( (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2) );
    printf("%f",d);
    return 0;
}

Measured memory_bytes: 1756
n, k = map(int, input().split())
MOD = 10 ** 9 + 7
d = [0] * (k + 1)

for i in range(1, k + 1):
    d[i] = pow(k // i, n, MOD)

for i in range(k, 0, -1):
    for j in range(i * 2, k + 1, i):
        d[i] -= d[j]
        d[i] %= MOD

ans = 0
for i in range(1, k + 1):
    ans += d[i] * i
    ans %= MOD
print(ans)

Measured memory_bytes: 11304
n = int(input())
num_list = list(map(int, input().split()))
count = 0
sum_ = num_list[0]
if sum_ > 0:
    for i in range(1, n):
        sum_ += num_list[i]
        if i%2 == 0:
            if sum_ <= 0:
                count += abs(sum_) + 1
                sum_ = 1
        else:
            if sum_ >= 0:
                count += abs(sum_) + 1
                sum_ = -1
    count1 = count
    
    count = 0
    sum_ = -1
    for i in range(1, n):
        sum_ += num_list[i]
        if i%2 == 1:
            if sum_ <= 0:
                count += abs(sum_) + 1
                sum_ = 1
        else:
            if sum_ >= 0:
                count += abs(sum_) + 1
                sum_ = -1
    count2 = count + num_list[0] + 1
    
    print(min(count1, count2))
elif sum_ < 0:
    for i in range(1, n):
        sum_ += num_list[i]
        if i%2 == 1:
            if sum_ <= 0:
                count += abs(sum_) + 1
                sum_ = 1
        else:
            if sum_ >= 0:
                count += abs(sum_) + 1
                sum_ = -1
    count1 = count
    
    count = 0
    sum_ = 1
    for i in range(1, n):
        sum_ += num_list[i]
        if i%2 == 0:
            if sum_ <= 0:
                count += abs(sum_) + 1
                sum_ = 1
        else:
            if sum_ >= 0:
                count += abs(sum_) + 1
                sum_ = -1
    count2 = count + abs(num_list[0]) + 1
    
    print(min(count1, count2))
    
else:
    sum_ = -1
    for i in range(1, n):
        sum_ += num_list[i]
        if i%2 == 1:
            if sum_ <= 0:
                count += abs(sum_) + 1
                sum_ = 1
        else:
            if sum_ >= 0:
                count += abs(sum_) + 1
                sum_ = -1
    count1 = count + 1
    
    count = 0
    sum_ = 1
    for i in range(1, n):
        sum_ += num_list[i]
        if i%2 == 0:
            if sum_ <= 0:
                count += abs(sum_) + 1
                sum_ = 1
        else:
            if sum_ >= 0:
                count += abs(sum_) + 1
                sum_ = -1
    count2 = count + 1    

    print(min(count1, count2))

Measured memory_bytes: 14332
#include <iostream>
using namespace std;
int main() {
    int l=0;
    int n,h,w;
    cin>>n>>h>>w;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(a>=h && b>=w ) l++;
    }
    cout<<l;
}


Measured memory_bytes: 256
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}

int main()
{
    ios;
    int n;
    cin>>n;
    vector<int>l(n);
    for(int i=0;i<n;i++)
        cin>>l[i];
    sort(l.begin(),l.end());
    ll cnt=0;
    for(int i=n-1;i>=0;i--)
    {
        for(int j=i-1;j>=0;j--)
        {
            auto it=lower_bound(l.begin(),l.end(),l[i]+l[j]);
           ll ng=distance(it,l.end());
           cnt+=(n-1-i)-ng;
        }
    }
    cout<<cnt<<endl;



}











Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#define int long long
#define REP(i,n) for(int i=0; i<n; i++)
using namespace std;

int count(int i, int j, int n);

signed main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            int num_a = count(i,j,n);
            int num_b = count(j,i,n);
            ans += num_a * num_b;
        }
    }
    cout << ans << "\n";
    return 0;
}

int count(int i, int j, int n) {
    //cout << "i: " << i << " j: " << j << " n: " << n ;
    int ret = 0;
    int max_digit = log10(n) + 1;
    int digit = 1;
    while (digit <= max_digit) {
        if (digit == 1) {
            if (i == j && i <= n) ret++;
        } else if (digit == 2) {
            if (i * 10 + j <= n) ret++;
        } else if (digit == max_digit) {
            int p = n / pow(10,max_digit-1);
            if (p == i) {
                int tmp = (n - i * pow(10, max_digit - 1) - j) / 10 + 1;
                if (tmp >= 0) ret += tmp;
            } else if (p > i) {
                ret += pow(10, max_digit - 2);
            }
        } else {
            ret += pow(10, digit - 2);
        }
        digit++;
    }
    //cout << " count: " << ret << "\n";
    return ret;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

signed main(){
    int n,m,k;
    cin>>n>>m>>k;
    bool ok=0;
    for(int i=0;i<=n;i++){
        int cnt=i;
        int sum=m*i;
        if(sum==k){
            ok=1;
            break;
        }
        for(int j=0;j<=m;j++){
            sum+=n-cnt;
            sum-=cnt;
            if(sum==k){
                ok=1;
                break;
            }
        }
    }
    cout<<(ok?"Yes":"No")<<endl;
}

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

using namespace std;

int main() {
    string s, t;
    string u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (s == u) {
        a--;
    }
    else {
        b--;
    }
    cout << a << " " << b;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define vv(type)		vector<vector<type>>
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define db(x) 			cout<<x<<" "
#define db1(x) 			cout<<x<<'\n'
#define db2(x,y) 		cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) 		cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) 		for(int i=0;i<(n);++i)
#define repA(i,a,n) 	for(int i=a;i<=(n);++i)
#define repD(i,a,n) 	for(int i=a;i>=(n);--i)
#define so(a) 			sort(a.begin(),a.end())
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
// to find all local maximaa and minima in O(n)
//	 for (int i=1;i<=n;i++)
//        {
//            if (i==1 || i==n || (p[i-1]<p[i])!=(p[i]<p[i+1]))
//           ans.push_back(p[i]);
//        }
int dx[] = { -1, 1, -1, 0, 0, -1, 1, 1 };
int dy[] = { -1, -1, 1, -1, 1, 0, 0, 1 };
int gcd(int a, int b)
{
	if (!b)
		return a;
	return gcd(b, a % b);
}
int modular_expo(int x, int y, int m)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans % m * x % m) % m;
		x = (x % m * x % m) % m;
		y /= 2;
	}
	return ans % m ;
}
int power(int x, int y)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans * x);
		x *= x;
		y /= 2;
	}
	return ans;
}
int dp[22][(1 << 22)];
int ways(vector<vi>&compat, int i, int womenSubset, int N)
{
	if (i == N + 1)
	{
		if (womenSubset == 0)	return 1;
		return 0;
	}
	if (dp[i][womenSubset] != -1)
		return dp[i][womenSubset];
	int ans = 0;
	rep(women, N)
	{
		bool available = ((1 << women) & (womenSubset)) == 0 ? 0 : 1;
		if (available && compat[i][women + 1])
			ans = (ans + ways(compat, i + 1, womenSubset ^ (1 << women), N)) % mod;
	}
	return dp[i][womenSubset] = ans;
}

void solve()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n;
	vector<vector<int>>compat(n + 1, vector<int>(n + 1));
	memset(dp, -1, sizeof(dp));
	vi a(n);
	repA(i, 1, n)
	{
		repA(j, 1, n)
		cin >> compat[i][j];
	}
	db1(ways(compat, 1, ( (1 << n) - 1), n));
}
int32_t main()
{
	solve();
	return 0;
}


Measured memory_bytes: 724560
local function meld(a,b)
    if not a then
        return b
    elseif not b then
        return a
    elseif a[1]<b[1] then
        b[4]=a[3]
        a[3]=b
        return a
    else
        a[4]=b[3]
        b[3]=a
        return b
    end
end

local function pair(a)
    local b=a and a[4]
    local c,d,e
    while b do
        c=b[4]
        a[4]=false
        b[4]=false
        a=meld(a,b)
        a[4]=d
        d=a
        a=c
        b=a and a[4]
    end
    while d do
        e=d
        d=d[4]
        a=meld(a,e)
    end
    return a
end

local PairingHeap={}

PairingHeap.empty=function(self)
    return not self[1]
end

PairingHeap.push=function(self,key,value)
    self[1]=meld(self[1],{key,value,false,false})
end

PairingHeap.top=function(self)
    return self[1][2]
end

PairingHeap.pop=function(self)
    self[1]=pair(self[1][3])
end

PairingHeap.join=function(self,other)
    self[1]=meld(self[1],other[1])
    return self
end

PairingHeap.new=function(self)
    local obj={false}
    setmetatable(obj,{__index=PairingHeap})
    return obj
end

----------

local n,m=io.read("n","n")
local t={}
for i=1,m do
    t[i]={}
end
for i=1,n do
    local a,b=io.read("n","n")
    if a<m+1 then
        table.insert(t[a],b)
    end
end

local pq=PairingHeap:new()
local total=0
for i=1,m do
    for j=1,#t[i] do
        local b=t[i][j]
        pq:push(-b,b)
    end
    if not pq:empty() then
        total=total+pq:top()
        pq:pop()
    end
end
print(total)

Measured memory_bytes: 27596
def resolve():
    A, B = map(int, input().split())
    S = input()
    C = "1234567890"
    for i in range(A):
        if S[i] in C:
            continue
        else:
            print("No")
            exit()
    if S[A] != "-":
        print("No")
        exit()
    for i in range(A+1, len(S)):
        if S[i] in C:
            continue
        else:
            print("No")
            exit()
    print("Yes")
resolve()

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

#define int long long
#define fi first
#define se second
#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 rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define yn(f) cout << (f ? "Yes" : "No") << endl;

int h,w;
string s[100];
vector<pair<int,pair<int,int>>> v[100][100];

#define P pair<int,pair<int,int>>

priority_queue<P, vector<P>, greater<P>> pq;
bool visited[100][100];

signed main() {
    cin >> h >> w;
    rep(i,h) cin >> s[i];
    if (s[0][0] == '.') pq.push(mp(0,mp(0,0)));
    else pq.push(mp(1,mp(0,0)));
    while(pq.size()) {
        int c = pq.top().fi;
        pair<int,int> hoge = pq.top().se;
        pq.pop();
        int y = hoge.fi, x = hoge.se;

        if (y == h-1 && x == w-1) {
            cout << c << endl;
            return 0;
        }
        if (visited[y][x]) continue;
        visited[y][x] = true;
        if (y + 1 < h) {
            int d = 0;
            if (s[y][x] != s[y+1][x] && s[y+1][x] == '#') d = 1;
            pq.push(mp(c+d, mp(y+1, x)));
        }
        if (x + 1 < w) {
            int d = 0;
            if (s[y][x] != s[y][x+1] && s[y][x+1] == '#') d = 1;
            pq.push(mp(c+d, mp(y, x+1)));
        }
    }
}


Measured memory_bytes: 512
#include<stdio.h>
#define N 1000
#define Z 500000
int a, b, c, d;
int pushBack(void);
int dump(void);
int clear(void);
int A[N][Z];
int size[N];
////////////////////////////////////////////////////////////
int main(void){
    scanf("%d%d", &b, &a);
    while (a-- != 0){
        scanf("%d", &b);
        if (b == 0) pushBack();
        if (b == 1) dump();
        if (b == 2) clear();
    }
    return 0;
}
int pushBack(void){
    scanf("%d%d", &c, &d);
    A[c][size[c]] = d;
    size[c]++;
}
int dump(void){
    scanf("%d", &c);
    if (size[c] == 0){ printf("\n"); return 0;}
    for (int i = 0; i < size[c]; i++){
        printf("%d", A[c][i]);
        if(i != size[c] - 1) printf(" ");
    }
    printf("\n");
    return 0;
}
int clear(void){
    scanf("%d", &c);
    size[c] = 0;
    return 0;
}


Measured memory_bytes: 7712
#include <stdio.h>

int main(){
char moji[1001]={'\0'};
int i,b=0;

while(scanf("%s",moji) != EOF){
if(b!=0){
printf(" ");
}
b++;
for(i=0;i<996;i++){
if(moji[i]=='a'&&moji[i+1]=='p'&&moji[i+2]=='p'&&moji[i+3]=='l'&&moji[i+4]=='e'){
moji[i]='p';
moji[i+1]='e';
moji[i+2]='a';
moji[i+3]='c';
moji[i+4]='h';
continue;
}
else if(moji[i]=='p'&&moji[i+1]=='e'&&moji[i+2]=='a'&&moji[i+3]=='c'&&moji[i+4]=='h'){
moji[i]='a';
moji[i+1]='p';
moji[i+2]='p';
moji[i+3]='l';
moji[i+4]='e';
continue;
}
}
printf("%s",moji);
}
printf("\n");
return 0;
}

Measured memory_bytes: 540
while True:
    nums = list(map(int, input().split()))
    if(nums[0]==0 and nums[1]==0):
        break
    num = nums[0]**nums[1]
    unit = ["", "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan", "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts"]
    ans = ""
    for i in range(17, -1, -1):
        tmp = num//(10**(i*4))
        if tmp == 0:
            continue
        ans += str(tmp) + unit[i]
        num -= tmp*(10**(i*4))
    print(ans)



Measured memory_bytes: 5600
fn main() {
    let v: Vec<u32> = read_vec();
    let (a, b) = (v[0], v[1]);

    println!("{}", (a * 3 + b) / 2);
}





//**********************************************************************************************************************************************//

// 標準入力から一行を読み取り、指定の型に変換する関数
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec2<T: std::str::FromStr>(n: u64) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

// 10進数での各桁の和
pub fn sum_dights(x: isize) -> isize {
    if x % 10 == 0 {
        return 0
    }
    let m = x % 10;
    m + sum_dights((x - m) / 10)
}


Measured memory_bytes: 4352
import sys
n = int(input())
a = [list(map(int,input().split())) for i in range(n)]

if a[0][0] < (a[0][1] + a[0][2]):
    print("No")
    sys.exit()
if a[0][0]%2 != (a[0][1]+a[0][2])%2:
    print("No")
    sys.exit()
if n==1 and a[0][0]%2 == (a[0][1]+a[0][2])%2:
    print("Yes")
    sys.exit()

# n>=2
for i in range(1, n):
    if (a[i][0] - a[i-1][0]) < (abs(a[i][1]-a[i-1][1]) + abs(a[i][2]-a[i-1][2])):
        print("No")
        sys.exit()
    if (a[i][0] - a[i-1][0])%2 != (abs(a[i][1]-a[i-1][1]) + abs(a[i][2]-a[i-1][2]))%2:
        print("No")
        sys.exit()
print("Yes")

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<char> color(1);
    int count = 0;
    rep(i, n) {
        if(color[0] != s[i]) {
            count++;
            color.clear();
            color.push_back(s[i]);
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 512
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

total = 0
for i in range(0, N-1):
    idx = a[i]
    total += b[idx-1]
    if a[i+1] == idx+1:
      total += c[idx-1]
      
total += b[a[-1]-1]
print(total)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    string t ;
    cin >> t ;
    size_t n = t.length() ;
    

    bool flag = true ;
    if(t[0] != 'A'){
        flag = false ;
    }
    
    int count = 0 ;
    int cplace = 0;
    for(int i = 2 ; i < n-1 ; i++){
       if(t[i] == 'C'){
           count++ ;
           cplace =  i  ;
       }
    } 
    if(count == 0){
        flag = false;
    }

    for(int j = 1 ; j < n ; j++ ){
        if(j != cplace){
            if(t[j] < 'a'){
                flag =false ;
            }
        }
    }
    
    if(flag == true){
        cout << "AC " << endl;
    }else{
        cout <<"WA" << endl;
    }

    
    return 0;
}

Measured memory_bytes: 256
#pragma region template 1.0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a) \
    REP(i, (a).size()) { cout << (a[i]) << (i == (a).size() - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    ll N, K;
    cin >> N >> K;
    vi a(N);
    REP(i, N)
    {
        cin >> a[i];
    }

    vector<bool> dp(K + 1);
    REP(i, K + 1)
    {
        REP(j, N)
        {
            dp[i] = dp[i] or a[j] <= i and not dp[i - a[j]];
        }
    }
    if (dp[K])
    {
        OUT("First");
    }
    else
    {
        OUT("Second");
    }
}
#pragma endregion template

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ll n, s;
  cin >> n >> s;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll dp[n + 1][s + 1][3];
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  rep(i, n) {
    rep(j, s + 1) {
      dp[i + 1][j][0] = (dp[i + 1][j][0] + dp[i][j][0]) % mod2;
      dp[i + 1][j][1] = (dp[i + 1][j][1] + dp[i][j][0] + dp[i][j][1]) % mod2;
      dp[i + 1][j][2] = (dp[i + 1][j][2] + dp[i][j][0] + dp[i][j][1] + dp[i][j][2]) % mod2;
      if (j + a[i] <= s) {
        dp[i + 1][j + a[i]][1] = (dp[i + 1][j + a[i]][1] + dp[i][j][0] + dp[i][j][1]) % mod2;
        dp[i + 1][j + a[i]][2] = (dp[i + 1][j + a[i]][2] + dp[i][j][0] + dp[i][j][1]) % mod2;
      }
    }
  }
  cout << dp[n][s][2] << endl;




  
  return 0;
}

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

int main (void){
  int n, k;
  cin >> n >> k;
  
  vector<int> s(n, 0);
 
  rep(i, n){
    cin >> s[i];
  }
  
  sort(s.begin(), s.end());
  
  int sum = 0;
  rep(i, k){
    sum += s[i];
  }
  
  cout << sum << endl;
                
  return 0;
}

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

unordered_map<ll, ll> pfact(ll m) {
  unordered_map<ll, ll> ps;
  ll tmp = m;
  for (ll i = 2; i * i <= m; ++i) {
    while (tmp % i == 0) {
      if (ps.count(i) == 0) ps[i] = 0;
      ps[i]++;
      tmp /= i;
    }

    if (tmp == 1) break;
  }

  if (tmp > 1) {
    if (ps.count(tmp) == 0) ps[tmp] = 0;
    ps[tmp]++;
  }

  return move(ps);
}

int main() {
  ll n;
  cin >> n;
  auto mp = pfact(n);

  ll ans = 0;
  for (auto& mpi : mp) {
    int cnt = mpi.second;
    int x = 1;
    while (cnt - x >= 0) {
      cnt -= x;
      x++;
      ans++;
    }
  }

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

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

using namespace std;


int main() {
	int num;
	cin >> num;

	int first = num / 500;

	long long res = 0;

	res += (first * 1000);

	num -= (first * 500);

	int second = num / 5;

	res += (second * 5);

	cout << res;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int comp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}
int main() {
  int n,a[100000],i,d=1,ans=0;
  scanf("%d",&n);
  for (i=0;i<n;i++) {
    scanf("%d",&a[i]);
  }
  qsort(a, n, sizeof(int), comp);
  for (i=0;i<n;i++) {
    while (a[i]==a[i+1]) {
      d++;
      i++;
    }
    if (d<a[i]) {
      ans+=d;
    } else {
      ans+=d-a[i];
    }
    d=1;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
int N, M, x;
int main() {
	scanf("%d%d\n", &N, &M);
	int ret = N;
	for(int i = 0; i < M; i++) {
		reader(&x);
		ret = __gcd(ret, __gcd(x, N));
	}
	puts(ret == 1 ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.length()-2; i++){
        if(s[i]=='A'){
            if(s[i+1]=='B'){
                if(s[i+2]=='C'){
                    ans++;    
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
ll ssum;

void dfs(string S, int i, int start, ll sum){
    if(i==S.size()-1){
        sum += stoll(S.substr(start, i-start+1));
        ssum += sum;
        return;
    }
    dfs(S, i+1, start, sum);
    dfs(S, i+1, i+1, sum+stoll(S.substr(start, i-start+1)));
}

int main(void)
{
    string S;
    cin >> S;
    ssum = 0;
    dfs(S, 0, 0, 0);
    cout << ssum << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

	int ans = 0;

	for (int i = 0; i < 4; i++) {
		if (S[i] == '+') {
			ans++;
		}
		else ans--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
#define vecfirst (*vec.begin())
#define veclast (*vec.rbegin())
#define vecall(v) (v).begin(), (v).end()
#define vecupsort(v) (sort((v).begin(), (v).end()))
#define vecdownsort(v, type) (sort(vecall(v), greater<type>()))
#define veccmpsort(v, cmp) (sort(vecall(v), cmp))
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 998244353LL;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
int n, Q;
int c[N];
int vis[N], ans[N];
int nowans;
struct query
{
    int l, r, id;
} q[N];
int belong[N];
inline bool cmp(const query &a, const query &b)
{
    return (belong[a.l] ^ belong[b.l]) ? belong[a.l] < belong[b.l] : ((belong[a.l] & 1) ? a.r < b.r : a.r > b.r);
}
inline void addcolor(int x)
{
    if (vis[c[x]] == 0)
        nowans++;
    vis[c[x]]++;
}
inline void delcolor(int x)
{
    vis[c[x]]--;
    if (vis[c[x]] == 0)
        nowans--;
}

void solve()
{
    scanf("%d%d", &n, &Q);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &c[i]);
    int size = sqrt(n);
    int bnum = ceil((double)n / size);
    for (int i = 1; i <= bnum; ++i)
        for (int j = (i - 1) * size + 1; j <= i * size; ++j)
            belong[j] = i;
    for (int i = 1; i <= Q; ++i)
    {
        int l, r;
        scanf("%d%d", &l, &r);
        q[i].l = l, q[i].r = r, q[i].id = i;
    }
    sort(q + 1, q + Q + 1, cmp);
    int L = 1, R = 0;
    for (int i = 1; i <= Q; ++i)
    {
        while (R < q[i].r)
            addcolor(++R);
        while (R > q[i].r)
            delcolor(R--);
        while (L < q[i].l)
            delcolor(L++);
        while (L > q[i].l)
            addcolor(--L);
        ans[q[i].id] = nowans;
    }
    for (int i = 1; i <= Q; ++i)
        printf("%d\n", ans[i]);
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
        solve();
    TIME__END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 17408
#include<stdio.h>
#include<iostream>
using namespace std;

int N,M;
int main (){
    cin >> N >> M;
    int x[N+1] = {0};
    for(int i=1; i<M+1; i++){
        int a,b;
        cin >> a >> b;
        x[a]++;
        x[b]++;
    }
    for(int i=1; i<N+1; i++){
        cout << x[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
li = [ [int(it) for it in input().split()] for i in range(N) ]
li.sort( key=lambda x:x[1] )
#print (li)
s = 0
flag = True
for a,b in li:
    s += a
    flag = flag and s<=b
    #print (s,b,s<=b)
print ( "Yes" if flag else "No" )

Measured memory_bytes: 90072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll x,y,ans=1,inv[2000005],invk[2000005],ka[2000005];
int main(void){
	cin>>x>>y;
	inv[0]=1,inv[1]=1,ka[0]=1,invk[0]=1;
	for(ll i=2;i<=x+y;i++)inv[i]=M-(M/i)*inv[M%i]%M;
	for(ll i=1;i<=x+y;i++)ka[i]=ka[i-1]*i%M,invk[i]=invk[i-1]*inv[i]%M;
	if((x+y)%3!=0)ans=0;
	ll n=(x+y)/3;
	x-=n,y-=n;
	ans=ans*ka[x+y]%M*invk[y]%M*invk[x]%M;
	cout<<ans<<endl;
}


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

int a[200002],b[200002];
ll atot[200002], btot[200002];
int main() {
	int n,m,k;
	cin >> n >> m >> k;
	rep(i,n) cin >> a[i];
	rep(i,m) cin >> b[i];
	rep(i,n) atot[i+1] = atot[i] + a[i];
	rep(i,m) btot[i+1] = btot[i] + b[i];

	int ans = 0;
	int j = m;
	rep(i,n+1) {
		if (atot[i] > k) break;
		while (atot[i]+btot[j]>k)
		{
			j--;
			if (j < 0) break;
		}
		if (j < 0) break;
		ans = max(ans, i+j);
	} 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8212
#include <iostream>
#include <cstdio>
#include <algorithm>
typedef long long ll;
using namespace std;
ll n,k,ans;
inline ll myabs(ll a){return a > 0 ? a : -a;}
int main(){
    scanf("%lld%lld",&n,&k);
    ans = n % k;
    ans = min(ans, myabs(k-ans));
    printf("%lld\n",ans);
    return 0;
}

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

int main(){
  ll n,m,k;
  cin >>n >>m >>k;
  vector<int> a(n), b(m);
  rep(i,n) cin >>a[i];
  ll total = 0;
  rep(i,m) {
    cin >>b[i];
    total += b[i];
  }
  int ans = 0;
  int j = m;
  rep(i,n+1){
    while(j>0 && total > k){
      j--;
      total -= b[j];
    }
    if(total > k) break;
    ans = max(ans, i+j);
    if(i==n) break;
    total += a[i];
  }
  cout << ans << endl;
  return 0; 
}

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

#define ll long long
#define pb push_back
#define eb emplace_back
//#define st first
#define sc second

using namespace std;

const ll mod = 1e9 + 7;
const int e = 1e6 + 69;
const int base = 311;

// dung inverse module de tinh nCk
// beginer 87
// mbeginer 161
// cach tao hoan vi tu n so : n*(n+1)/2;

//vector<pair<ll,ll>>adj[e];
//vector<ll>adj[e];

/*ll Pow(ll n, ll dem)
{
    if(dem == 0) return 1;
    if(dem == 1) return n ;
    ll t = Pow(n, dem/2);
    if(dem % 2 == 0) return (t*t);
    else return ((t * t) * n);
}*/

/*ll C(ll k, ll n)
{
    if(k == 0) return 1;
    if(n < k) return 0;
    return (gt[n]%mod * (igt[k]%mod * igt[n-k]%mod)%mod)%mod;
}*/

ll a[e];

int main()
{
   ll n, m;
   cin >> n >> m;
   //if(n < m) cout << n;
   //else
   {
       n -= n/m*m;
       ll minn = 1e18;
       while(n >= m)
       {
           minn = min(minn, abs(n - m));
           n -= m;
       }
       minn = min(minn, abs(n - m));
       minn = min(minn, n);
       cout << minn;
   }
}
/*

*/


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

int caculateNumberSum(string num){
    int res = 0;
    for(int i = 0;i < num.size();i++){
       res = res + (num[i] - '0');
    }
    return res;
}

int main(){
    string x;
    getline(cin,x);
    while(x[0] != '0'){
        int sum = caculateNumberSum(x);  
        cout<<sum<<endl;
        cin>>x;
    }
    return 0;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define input(x) cin>>x;


void inputArr(ll *arr, ll &n){
	for(ll i=0;i<n;++i){
		cin>>arr[i];
	}
}



int main()
{
	
	ll x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	
	ll A[a],B[b],C[c];
	// a red apples , b green and we have to eat x, y
	inputArr(A,a);
	inputArr(B,b);
	inputArr(C,c);

    sort(A,A+a,greater<ll>());sort(B,B+b,greater<ll>());sort(C,C+c,greater<ll>());
    vector<ll> farr(x+y+c);
    ll i=0;
    
    while(i< x){
    	farr[i] = A[i];
    	++i;
	}
	while(i<x+y){
		farr[i] = B[i-x];
		++i;
	}
	while(i< x+y+c){
		farr[i] = C[i-x-y];
		++i;
	}
	sort(farr.begin(),farr.end(),greater<ll>());
	i=0;
	ll ans=0;
	for(i=0;i<x+y;++i){
		ans += farr[i];
	}
    cout<<ans<<endl;
return 0;
}



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

int main() {
  string str1, str2, str3;
  cin >> str1 >> str2 >> str3;
  if (str1[str1.length()-1] == str2[0] && str2[str2.length()-1] == str3[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)

{
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a < b){
		printf("a < b\n");
	}
	else{
		if(a > b){
			printf("a > b\n");
		}
		else{
			printf("a == b\n");
		}
	}
		return 0;
}

Measured memory_bytes: 580
'use strict'

function main(inp) {
  inp = inp.trim().split(' ').sort((a, b) => (Number(a) - Number(b)))
  if ((inp[0] == inp[1]) || (inp[1] == inp[2])) {
    if (!(inp[0] == inp[1] && (inp[1] == inp[2]))) {
      return console.log('Yes')
    }
  }
  console.log('No')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 23112
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int a,b;
		int x,y;
		a=sc.nextInt();
		b=sc.nextInt();
		x=a-1;
		y=b-1;
		System.out.println(x*y);
	}
}


Measured memory_bytes: 20816