akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int count = 0;
		double d = scan.nextDouble();
		for(int i = 0; i < n; i++) {
			double x = scan.nextDouble();
			double y = scan.nextDouble();
			double res = solve(x,y);
			if(res <= d) {
				count++;
			}
		}
		System.out.println(count);
		
		
	}
	public static double solve(double x,double y) {
		double a = Math.pow(x, 2);
		double b = Math.pow(y, 2);
		double c = a + b;
		double res = Math.sqrt(c);
		return res;
	}

}


Measured memory_bytes: 63828
import re
 
S = input()
 
R = [
    "^.*keyence$",
    "^k.*eyence$",
    "^ke.*yence$",
    "^key.*ence$",
    "^keye.*nce$",
    "^keyen.*ce$",
    "^keyenc.*e$",
    "^keyence.*$",
]
 
for ri in R:
    if re.match(ri, S):
        print("YES")
        exit(0)
print("NO")

Measured memory_bytes: 3188
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    int N, K;
    cin >> N >> K;
    int ma = (N - 1) * (N - 2) / 2;
    if (K > ma) {
        cout << -1 << endl;
        return 0;
    } else {
        vector<pair<int, int>> v;
        for (int i = 2; i <= N; i++) {
            v.push_back({1, i});
        }

        ma -= K;
        bool judge = 0;
        for (int i = 2; i <= N; i++) {
            for (int j = i + 1; j <= N; j++) {
                if (ma == 0) {
                    judge = 1;
                    break;
                }
                v.push_back({i, j});
                ma--;
            }
            if (judge)
                break;
        }

        cout << v.size() << endl;
        for (auto p : v) {
            cout << p.first << " " << p.second << endl;
            ;
        }
    }
}

Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>
#include <utility>

#define repd(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue();
void inputArray(int*,int);
void inputVector(vector<int>*,int);
template <typename T>
void output(T,int);
int gcd(int a,int b);

int main(){
	//source
	int n;
	cin >> n;
	int a[n];
	rep(i,n){
		cin >> a[i];
	}
	sort(a,a+n);
	ll ans=0;
	int  num_minus=lower_bound(a,a+n,1)-a;
	if(num_minus%2==0){
		rep(i,n){
			ans+=abs(a[i]);
		}
	}else if(num_minus!=n){
		ll ans1=0,ans2=0;
		rep(i,n){
			if(i<num_minus-1){
				ans1+=a[i]*(-1);
			}else{
				ans1+=a[i];
			}

			if(i<num_minus+1){
				ans2+=a[i]*(-1);
			}else{
				ans2+=a[i];
			}
		}

		ans=max(ans1,ans2);
	}else{
		rep(i,n){
			if(i!=n-1){
				ans+=abs(a[i]);
			}else{
				ans+=a[i];
			}
		}
	}

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

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template<typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

int gcd(int a,int b){
	if(b>a){
		int temp=a;
		a=b;
		b=temp;
	}
	if(b==0){
		return a;
	}
	return (b,b%a);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    std::ios_base::sync_with_stdio(false);
    int t,n,c;
   cin>>t;
   n=t%10;
   if(n==3)cout<<"bon\n";
   else if(n==0 || n==1 || n==6 || n==8)cout<<"pon\n";
   else cout<<"hon\n";
}


Measured memory_bytes: 3612
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

const int NOT_ASIGNED = -1;
const int FREE = -2;
int n = 1;
int m;
int pos;
int sum = 0;
char str[1000];
int variable[200];
int pointer[10000];

int Expr();
int Malloc(int s) {
  if (sum + s > m) { return 0; }
  pointer[n++] = s;
  sum += s;
  return -(n - 1);
}

int Clone(int p) {
  if (p == 0) { return 0; }
  if (p > 0 || pointer[-p] == NOT_ASIGNED || pointer[-p] == FREE) { throw 1; }
  return Malloc(pointer[-p]);
}

void Free(int p) {
  if (p == 0) { return; }
  if (p > 0 || pointer[-p] == NOT_ASIGNED || pointer[-p] == FREE) { throw 1; }
  sum -= pointer[-p];
  pointer[-p] = FREE;
}

int Number() {
  int ret = 0;
  while (isdigit(str[pos])) {
    ret = ret * 10 + (str[pos] - '0');
    pos++;
  }
  return ret;
}

int Expr() {
  int lhs;
  if (str[pos] == '(') {
    pos++;
    lhs = Expr();
    assert(str[pos] == ')');
    pos++;
  } else if (str[pos] == 'N' && str[pos + 1] == 'U') {
    lhs = 0;
    pos += 4;
  } else if (str[pos] == 'm') {
    pos += 7;
    int s = Number();
    lhs = Malloc(s);
    assert(str[pos] == ')');
    pos++;
  } else if (str[pos] == 'c') {
    pos += 6;
    int p = Expr();
    lhs = Clone(p);
    assert(str[pos] == ')');
    pos++;
  } else {
    assert(isupper(str[pos]));
    int p = str[pos] - 'A';
    pos++;
    if (str[pos] == '=') {
      pos++;
      int rhs = Expr();
      variable[p] = rhs;
    }
    lhs = variable[p];
  }
  return lhs;
}

void Line() {
  if (str[pos] == 'f') {
    pos += 5;
    int p = Expr();
    Free(p);
    assert(str[pos] == ')');
    pos++;
  } else {
    Expr();
  }
}

int main() {
  MEMSET(variable, 0x0f);
  MEMSET(pointer, -1);
  pointer[0] = 0;
  scanf("%d", &m);
  try {
    fgets(str, 999, stdin);
    while (fgets(str, 999, stdin)) {
      pos = 0;
      Line();
    }
    REP(i, 200) {
      if (variable[i] <= 0) { pointer[-variable[i]] = 0; }
    }
    int ans = 0;
    REP(i, n) {
      if (pointer[i] == FREE) { continue; }
      ans += pointer[i];
    }
    printf("%d\n", ans);
  } catch (int x) {
    puts("Error");
  }
}

Measured memory_bytes: 0
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc166
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc166A();
			Console.Out.Flush();

        }

        public static void solve_abc166B()
        {
        }

        public static void solve_abc166A()
        {
            string s = Console.ReadLine();
            if (s == "ABC")
            {
                Console.WriteLine("ARC");
            }
            else
            {
                Console.WriteLine("ABC");
            }
        }
    }
}


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

int main()
{
  int n, x;
  cin>>n>>x;
  vector<int> l(n);
  for(auto& i : l)cin>>i;
  
  int ans = 0;
  for(int i = 0, sum = 0; i < n; ++i)
  {
    if(sum + l[i] <= x)
    {
      sum += l[i];
      ++ans;
    }
    else break;
  }
  
  cout <<ans + 1 <<endl;
}

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

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

int main(){
    ll n, a, b; cin >> n >> a >> b;
    vector<ll> x(n);
    rep(i,n) cin >> x[i];
    ll ans = 0;
    rep(i,n-1){
        ans += min((x[i+1]-x[i]) * a, b);
    }
    cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n); 
  
  rep(i,n){
  cin >> a.at(i);
  }
  
  sort(a.begin(),a.end());
  
  string ans = "YES";
  
  rep(i,n-1){
  if(a.at(i) == a.at(i+1)) ans = "NO";
  }
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
const ll mod =   1e9+7;
int n;string s;
int x=0;int y=0;
int main()
{  fast
cin>>n>>s;
y=n-1;int ans=0;
while(x<y){
	while(x<y&&s[x]=='R')x++;
	while(y>x&&s[y]=='W')y--;
	if(x<y)
	ans++;
	x++;y--;
}

cout<<ans;
}

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

int main(){
    int x;
    cin >> x;
    int check = 0;
    for(int i = -200;i<=200;i++){
        if(check == 1){
            break;
        }
        for(int j = -200;j <= 200;j++){
            if(pow(i,5)-pow(j,5) == x){
                cout << i << " " << j<<endl;
                check =1;
                break;
            }
        }
    }
}

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

static const int INF = 1e9+7;
int dx[] = {1,0};
int dy[] = {0,1};


int main(){
    int H,W;
    cin>>H>>W;
    char s[100+10][100+10];

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin>>s[i][j];
        }
    }

    vector<vector<int>> dp(H+50,vector<int>(W+50,INF));

    dp[0][0] = 0;
    if(s[0][0] == '#') dp[0][0]++;

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            for(int k=0; k<2; k++){

                int nx = j + dx[k];
                int ny = i + dy[k];
                if(ny >= H || nx >= W) continue;
                if(s[i][j] == '.' && s[ny][nx] == '#') dp[ny][nx] = min(dp[ny][nx],dp[i][j]+1);
                else dp[ny][nx] = min(dp[ny][nx],dp[i][j]);
            }
        }
    }

    cout<<dp[H-1][W-1]<<endl;

    return 0;
}


Measured memory_bytes: 3688
def cookie_exchanges():
	a, b, c = map(int, raw_input().split(" "))
	if a%2==1 or b%2==1 or c%2==1:
		print 0
		return
	ans = 0
	while True:
		if a==b and b==c:
			print -1
			return
		_a = a
		_b = b
		_c = c
		a = (_b+_c)/2
		b = (_a+_c)/2
		c = (_a+_b)/2
		# print a,b,c
		ans+=1
		if a%2==1 or b%2==1 or c%2==1:
			print ans
			return

if __name__ == "__main__":
	cookie_exchanges()

Measured memory_bytes: 2568
import java.util.*;

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

    ArrayList<Long> arr = new ArrayList<Long>();

    for (int i = 0; i < n; i++) {
      long num = sc.nextLong();
      arr.add(num);
    }

    Collections.sort(arr);
    long max = arr.get(arr.size() - 1);
    long pair = max / 2;
    long max2 = pair;
    long diff = Long.MAX_VALUE;
    for (int i = 0; i < arr.size() - 1; i++) {
      long temp = arr.get(i);
      long min = Math.min(Math.abs(pair - temp), Math.abs(pair - max + temp));
      if (diff > min) {
        max2 = temp;
        diff = min;
      }
    }
    System.out.println(max + " " + max2);
  }
}


Measured memory_bytes: 62552
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll N;
    cin >> N;
    VL A(N);
    rep(i, 0, N) cin >> A[i];

    for(ll n : A){
        if(~n & 1 && ((n % 3) && (n % 5))){
            cout << "DENIED" << endl;
            return 0;
        }
    }

    cout << "APPROVED" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pt;
const int N=2e5+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const double eps=1e-8;
const double pi=acos(-1);
LL n,m;
char s[N];
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    scanf("%s",s+1);
    int len=strlen(s+1);
    r(m);
    LL ans=0;
    FOR(i,1,len-1){
        if(m==1){
            ans+=9;
        }
        else if(m==2){
            if(i>=2)
            ans+=81*(i-1);
        }
        else if(m==3){
            if(i>=3)
            ans+=81ll*9*(i-1)*(i-2)/2;
        }
    }

    if(m==1) ans+=s[1]-'0';
    else if(m==2){
        int get=s[1]-'0'-1;
        if(get>0) ans+=get*9*(len-1);
        FOR(i,2,len){
            bool flag=1;
            FOR(j,2,i-1) if(s[j]!='0') flag=0;
            if(flag){
                ans+=s[i]-'0';
            }
            else ans+=9;
        }
    }
    else if(m==3){
        int get=s[1]-'0'-1;//这一位不满
        if(get>0) ans+=get*9*9*(len-1)*(len-2)/2;
        FOR(i,2,len){// two
            bool flag=1;
            FOR(j,2,i-1) if(s[j]!='0') flag=0;
            if(flag){
                int gg=s[i]-'0'-1;//这一位不满
                if(gg>0) ans+=gg*9*(len-i);
                if(gg>=0){
                    FOR(j,i+1,len){
                        bool ff=1;
                        FOR(k,i+1,j-1) if(s[k]!='0') ff=0;
                        if(ff){
                            ans+=s[j]-'0';
                        }
                        else ans+=9;
                    }
                }
            }
            else{
                ans+=9*9*(len-i);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//		String W	 = in.readLine();
		//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		final long X = sc.nextInt();
		Map<Integer, Long> fivePow = new HashMap<Integer, Long>();
		long tmp = 0;

		long max = (long) (Math.pow(10, 11));

		for (int i = 0; i == 0 || tmp < max; i++) {
			tmp = (long) Math.pow(i, 5);
			fivePow.put(i, tmp);
		}

		for (int i = 0; i == 0 || tmp > -max; i--) {
			tmp = (long) Math.pow(i, 5);
			fivePow.put(i, tmp);
		}

		long A = 0;
		long B = 0;

		for (Integer a : fivePow.keySet()) {
			tmp = fivePow.get(a)-X;
			if (fivePow.containsValue(tmp)) {
				A = a;
				break;
			}
		}
		for(Integer b:fivePow.keySet()) {
			if(fivePow.get(b)==tmp) {
				B = b;
				break;
			}
		}


		System.out.println(A + " " + B);
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray) {
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedArray[mid] <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList) {
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedList.get(mid) <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}

}


Measured memory_bytes: 38812
e=input
a=[]
for _ in[0]*int(e()):
 X,z=e(),[]
 for y in e():
  s=i=0
  for k in z:
   t=X.find(y,s)+1
   if t<1:break
   if t<k:z[i]=t
   s=k;i+=1
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 a+=[z]
print('\n'.join(map(str,map(len,a))))


Measured memory_bytes: 5656
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  ll n;
  cin>>n;
  vector<ll> a(n);
  REP(i,n) cin>>a[i];
  ll cnt = 0;
  REP(i,n) {
    if (a[i] < 0) ++cnt;
  }
  ll sum = 0;
  REP(i,n) sum += abs(a[i]);
  if ((cnt % 2) == 0) {
    cout << sum << endl;
  } else {
    ll mn = 1000000000;
    REP(i,n) mn = min(mn, abs(a[i]));
    cout << sum - 2*mn << endl;
  }
  return 0;
}


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


int main(){
  int x, y;
  cin >> x >> y;
  int res = 0;
  if (x == 1) res += 300000;
  else if (x == 2) res += 200000;
  else if (x == 3) res += 100000;

  if (y == 1) res += 300000;
  else if (y == 2) res += 200000;
  else if (y == 3) res += 100000;

  if (x == 1 && y == 1) res += 400000;

  cout << res << endl;
  
  return 0;
} 

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

typedef long long ll;

ll mod = 1e9 + 7;
ll dp[200005];
int pos[200005];

int main() {
	int n; cin >> n;
	vector<int> c(n), d;
	for (int i = 0; i < n; i++) cin >> c[i];
	d.push_back(c[0]);
	for (int i = 1; i < n; i++) {
		if (c[i] == c[i - 1]) continue;
		d.push_back(c[i]);
	}
	dp[d.size()] = 1;
	for (int i = (int)d.size() - 1; i >= 0; i--) {
		dp[i] = dp[i + 1];
		if (pos[d[i]] != 0) {
			dp[i] += dp[pos[d[i]]];
			dp[i] %= mod;
		}
		pos[d[i]] = i;
	}
	cout << dp[0] << endl;
	return 0;
}

Measured memory_bytes: 4340
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] input = In.ReadToEnd().Split(new[] { " ", "\n", "\r" },
        StringSplitOptions.RemoveEmptyEntries);

    T Get<T>(Func<string, T> parser) => parser(input[idx++]);

    public string S => Get(s => s);
    public char C => Get(char.Parse);
    public int I => Get(int.Parse);
    public long L => Get(long.Parse);
    public double F => Get(double.Parse);
    public decimal D => Get(decimal.Parse);
    public BigInteger B => Get(BigInteger.Parse);

    T[] Gets<T>(int n, Func<string, T> parser)
        => input.Skip((idx += n) - n).Take(n).Select(parser).ToArray();

    public string[] Ss(int n) => Gets(n, s => s);
    public char[] Cs(int n) => Gets(n, char.Parse);
    public int[] Is(int n) => Gets(n, int.Parse);
    public long[] Ls(int n) => Gets(n, long.Parse);
    public double[] Fs(int n) => Gets(n, double.Parse);
    public decimal[] Ds(int n) => Gets(n, decimal.Parse);
    public BigInteger[] Bs(int n) => Gets(n, BigInteger.Parse);

    public void Write<T>(params T[] xs) => WriteLine(string.Join(" ", xs));
    public void Write(params object[] xs) => WriteLine(string.Join(" ", xs));
}

#region Library

static class Extentions
{
}

#endregion

static class Program
{
    public static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { NewLine = "\n" };
#if DEBUG
        sw.AutoFlush = true;
#else
        sw.AutoFlush = false;
#endif
        SetOut(sw);
        Solve(new IO());
        Out.Flush();
    }

    static void Solve(IO io)
    {
        var x = io.I;
        var a = io.I;
        var b = io.I;

        io.Write(Abs(a - x) < Abs(b - x) ? "A" : "B");
    }
}

Measured memory_bytes: 13268
#include<stdio.h>
#include<math.h>
int main(){
int a[50000],b=0,i=3,c=0,d=2,e,num=0,sum,k,l,cir=0,low,high;
while(d<50030){
if(d==2){
a[b]=d;
b++,d++;
}
else{
while(i<=sqrt(d)){
if(d%i==0){
c++;
break;
}
i=i+2;
}
if(c!=1){
a[b]=d;
b++;
}
c=0,i=3;
d=d+2;
}
}
while(1){
scanf("%d\n",&e);
if(e==0){
break;
}
for(i=0;;i++){
if(e<a[i]){
break;
}
}
sum=i;
for(i=0;i<sum;i++){
if(e<a[i]*2){
break;
}
k=e-a[i];
low=0,high=sum-1;
while(1){
l=(high+low)/2;
if(a[l]==k){
cir=1;
break;
}
if(low>high){
break;
}
if(a[l]<k){
low=l+1;
}
else if(a[l]>k){
high=l-1;
}
}
if(cir==1){
num++;
cir=0;
}
}
printf("%d\n",num);
num=0;
}
return 0;
}


Measured memory_bytes: 2052
#include <stdio.h>
#include <stdlib.h>

/* https://ncode.syosetu.com/n2267be/ */
#define RIZERO return 0

int main(void) {
	int a, b, c, d;
	if (scanf("%d%d%d%d", &a, &b, &c, &d) != 4) return 1;
	puts(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d) ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>
 
using namespace std;
 
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))
 
typedef long long ll;
 
int main(){
    int n, c; cin >> n >> c;
    vector<int> v(n); rep(i,n) cin >> v[i];
    int ans = 0;
  	sort(all(v));
    rep(i,n-1){
        if(v[i]>c) break;
        ans++; c -= v[i];
    }
    if(v[n-1] == c) ans++;
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int n, k, b;

    cin >> n;
    cin >> k;

    int u[n];
    double p = pow( 2, (double)n );

    for( int i = 0; i < n; i++ )
        u[i] = i;

    for( int i = 0; i < (int)p; i++ )
    {
        bitset<28> t(i);

        bool judge = true;                  //kの数字分だけ1が立っていれば、それが組み合わせとなる。
        if( t.count() != k )                //count()は1が立っている数を出力する
            judge = false;

        if( judge == true )
        {
            cout << i << ":";
            for( int j = 0; j < 28; j++ )
            {
                if( t[j] == 1 )
                    cout << " " << u[j];
            }
            cout << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3268
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int n;
	cin >> n;
	VI operations;
	operations.push_back(1);
	operations.push_back(6);
	int tmp;
	for(int i = 1; (tmp = *(operations.end() - 1) * 6) < 100001; i++) {
		operations.push_back(tmp);
	}
	operations.push_back(9);
	for(int i = 1; (tmp = *(operations.end() - 1) * 9) < 100001; i++) {
		operations.push_back(tmp);
	}
	sort(ALL(operations));
	int m = operations.size();

	VI2D dp(n + 1, VI(m + 1, INF)); // dp[合計][使える引き出し操作]
	REP(i, m + 1) { dp[0][i] = 0; }
	REP(i, n) {
		REP(j, m) {
			if(i + 1 < operations[j]) {
				dp[i + 1][j + 1] = dp[i + 1][j];
			} else {
				dp[i + 1][j + 1] =
					min(dp[i + 1 - operations[j]][j + 1] + 1, dp[i + 1][j]);
			}
		}
	}

	cout << dp[n][m] << endl;
	return 0;
}


Measured memory_bytes: 11856
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#define INF 1000000009
#define LINF 1000000000000000009
#define EPS 1e-10
#define PI 3.1415926535897932384626
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmax(T &a, const T&b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T&b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

int main() {
	int n; double l;
	cin >> n >> l;
	vector<double> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	double ansx = 0, ansy = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			double arg1 = (double)(a[i] + a[j]) / l;
			double arg2 = (double)(a[i] + a[j]) / l + 1;
			ansx += cos(PI*arg1)*(n - 1 + i - j);
			ansy += sin(PI*arg1)*(n - 1 + i - j);
			ansx += cos(PI*arg2)*(j - i - 1);
			ansy += sin(PI*arg2)*(j - i - 1);
		}
	}
	ansx *= 6; ansx /= n; ansx /= n - 1; ansx /= n - 2;
	ansy *= 6; ansy /= n; ansy /= n - 1; ansy /= n - 2;
	cout << fixed << setprecision(20) << ansx << ' ' << ansy << endl;
}

Measured memory_bytes: 256
D = [[-1, 0], [1, 0], [0, -1], [0, 1]]

def puyo_rensa(cnt)
  check = 14.times.map{ [false] * 8 }
  res = 0
  (1..12).each do |i|
    (1..6).each do |j|
      if !check[i][j] && $fld[i][j] =~ /[^O.]/
        puyo_connector(i, j){ |arr|
          if arr.size >= 4
            arr.each do |s, t|
              D.each do |x, y|
                p, q = s + x, t + y
                check[p][q] = true if $fld[p][q] == 'O'
              end
              check[s][t] = true
            end
            res = 1
          end
        }
      end
    end
  end
  fld = $fld.transpose
  check = check.transpose
  (1..6).each do |i|
    fld[i].map!.with_index{ |c, j| c unless check[i][j] }.compact!
    (14 - fld[i].size).times{ fld[i].unshift('.') }
  end
  $fld = fld.transpose
  if res == 1 then puyo_rensa(cnt + 1)
  else cnt
  end
end

def puyo_connector(i, j)
  check = 14.times.map{ [false] * 8 }
  arr = [[i, j]]
  ret = [[i, j]]
  check[i][j] = true
  until arr.empty?
    i, j = arr.shift
    D.each do |x, y|
      p, q = i + x,  j + y
      if !check[p][q] && $fld[i][j] == $fld[p][q]
        check[p][q] = true
        arr << [p, q]
        ret << [p, q]
      end
    end
  end
  yield(ret)
end

gets.to_i.times do
  $fld = 14.times.map{ ['.'] * 8 }
  12.times do |i|
    gets.chomp.split('').each_with_index do |c, j|
      $fld[i+1][j+1] = c
    end
  end
  p puyo_rensa(0)
end

Measured memory_bytes: 9428
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_L (200000L)
#define INF (1000000000000000000L)

using namespace std;

long accl_as[MAX_L + 2], accr_as[MAX_L + 2];
long accl_nes[MAX_L + 2];
long dp1s[MAX_L + 1], dp2s[MAX_L + 1];
long dp2ds[MAX_L + 1];
long minr_dp2ds[MAX_L + 1];

int main(int argc, char *argv[]) {
  // read inputs
  long L, as[MAX_L + 2] = {};
  scanf("%ld", &L);
  for (long i = 1; i <= L; i++) {
    scanf("%ld", &as[i]);
  }

  // calculate accumulated sums
  accl_as[0] = 0;
  for (long i = 1; i <= L; i++) {
    accl_as[i] = accl_as[i - 1] + as[i];
    // printf("i = %ld, accl_as[i] = %ld\n", i, accl_as[i]);
  }
  accr_as[L + 1] = 0;
  for (long i = L; i > 0; i--) {
    accr_as[i] = accr_as[i + 1] + as[i];
    // printf("i = %ld, accr_as[i] = %ld\n", i, accr_as[i]);
  }

  // calculate accumulated number of even elements in as
  accl_nes[0] = 0;
  for (long i = 1; i <= L; i++) {
    accl_nes[i] = accl_nes[i - 1] + 1 - as[i] % 2;
    // printf("i = %ld, accl_nes[i] = %ld\n", i, accl_nes[i]);
  }

  // calculate dp
  dp1s[0] = 0;
  for (long i = 1; i <= L; i++) {
    const long a = as[i];
    dp1s[i] = accl_as[i] - accl_as[0];
    if (a == 0) {
      dp1s[i] = min(dp1s[i], dp1s[i - 1] + 2);
    } else {
      dp1s[i] = min(dp1s[i], dp1s[i - 1] + a % 2);
    }
    // printf("i = %ld, dp1s[i] = %ld\n", i, dp1s[i]);
  }
  dp2s[L] = 0;
  for (long i = L - 1; i >= 0; i--) {
    const long a = as[i + 1];
    dp2s[i] = accr_as[i + 1] - accr_as[L + 1];
    if (a == 0) {
      dp2s[i] = min(dp2s[i], dp2s[i + 1] + 2);
    } else {
      dp2s[i] = min(dp2s[i], dp2s[i + 1] + a % 2);
    }
    // printf("i = %ld, dp2s[i] = %ld\n", i, dp2s[i]);
  }

  // modify dp2s
  for (long i = 0; i <= L; i++) {
    dp2ds[i] = dp2s[i] - (accl_nes[L] - accl_nes[i]);
  }

  // calculate minimum of dp2ds
  minr_dp2ds[L] = dp2ds[L];
  for (long i = L - 1; i >= 0; i--) {
    minr_dp2ds[i] = min(dp2ds[i], minr_dp2ds[i + 1]);
  }

  // solve
  long ans = INF;
  for (long i = 0; i <= L; i++) {
    long ans_i = dp1s[i] + accl_nes[L] - accl_nes[i];
    ans_i += minr_dp2ds[i];  // TODO : check
    ans = min(ans, ans_i);
  }
  printf("%ld\n", ans);

  return 0;
}


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

int main()
{
	int n;
	cin>>n;
	int dp[n];
	int h[n];
	for(int i=0; i<n; i++)
	{
		int temp;
		cin>>temp;
		h[i] = temp;
	}
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(int i=2; i<n; i++)
	{
		dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i]));
	}

	cout<<dp[n-1];

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
int main(){
	ll l,r;
	scl(l);scl(r);
	if(l==1||r==1)pf("1\n");
	else if(l%2==0)pf("%lld\n",(l/2)*r);
	else pf("%lld\n",(l/2)*r+r/2+r%2);
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, = map(int, input().split())
L = [int(v) for v in input().split()]
c = max(L) + 1

ans = 0
for i in range(N - 1):
    if L[i] == L[i + 1]:
        L[i + 1] = c
        c += 1
        ans += 1
        
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
typedef pair<int,int> P;
int t, in, lim;
P ans;
string ans_s;

string change(string s, int n){
  int a = 0;
  string out = "";

  for(int i = 0; i < s.length(); i++){
    out += s[i];
    if(s[i] >= '0' && s[i] <= '9') a++;
    if(a == n) out += " ";
  }
  return out;
}


int make(string s){
  s += " ";
  int out = 0;
  int now = 0;
  string tmp = "";

  for(int i = 0; i < s.length(); i++){
    if(s[i] < '0' || s[i] > '9'){
      //if(tmp.length() > 1 && tmp[0] == '0') return -1;
      out += now;
      now = 0;
      tmp = "";
    }else{
      now *= 10;
      tmp += s[i];
      now += s[i]-'0';
    }
  }
  return out;
}

void solve(string s, int num){
 
  int dig = make(s);
  //cout << s << "  " << dig << endl;
  if(dig != -1){
    if(dig <= t && dig >= ans.first){ 
      if(dig == ans.first && ans_s != s) ans.second++;
      else{
	ans.first = dig;
	ans.second = 1;
	ans_s = s;
      }
    }
  }
  if(num < lim){
    //do not cut 
    solve(s,num+1);
    //cut
    s = change(s,num);
    solve(s,num+1);
  }
}

bool isError(string s){
  int n = 0;
  for(int i = 0; i < s.length(); i++)
    n+=s[i]-'0';

  return t<n;
}

string tos(int num){
  string out = "";
  while(num){
    out += num%10+'0';
    num/=10;
  }
  reverse(out.begin(),out.end());
  return out;
}


int main(){
  while(cin >> t >> in && in){
    ans = P(-1,0);
    string s = tos(in);
    if(isError(s)) cout << "error" << endl;
    else{
      lim = s.length();
      solve(s,1);
      if(ans.second > 1) cout << "rejected" << endl;
      else cout << ans.first << " " << ans_s << endl;
    }
  }

  return 0;
}

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

using namespace std;

const int inf = 0x3f3f3f3f;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  vector<int> a(n);
  vector<bool> b(n);
  int prefix = -1, q = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    --a[i];
    if (a[i] > prefix) {
      prefix = a[i];
      b[i] = true;
      ++q;
    }
  }
  
  vector<int> fenw_even(n, 0), fenw_odd(n, -inf);
  stack<pair<int*, int>> memory;

  auto modify = [&](vector<int> &fenw, int x, int value) {
    while (x < n) {
      if (fenw[x] < value) {
        memory.emplace(&fenw[x], fenw[x]);
        fenw[x] = value;
      }
      x |= x + 1;
    }
  };

  auto query = [&](vector<int> &fenw, int x) {
    int result = -inf;
    while (x >= 0) {
      result = max(result, fenw[x]);
      x = (x & x + 1) - 1;
    }
    return result;
  };

  vector<int> size(n);
  for (int i = n - 1; ~i; --i) {
    int even = -inf, odd = -inf;
    size[i] = memory.size();
    if (b[i]) {
      even = query(fenw_even, n - a[i] - 1) + 2;
      odd = query(fenw_odd, n - a[i] - 1) + 2;
    } else {
      even = query(fenw_odd, n - a[i] - 1) + 1;
      odd = query(fenw_even, n - a[i] - 1) + 1;
    }
    if (even >= 0) {
      modify(fenw_even, n - a[i] - 1, even);
    }
    if (odd >= 0) {
      modify(fenw_odd, n - a[i] - 1, odd);
    }
  }

  auto check = [&](int x, int need) {
    if (need < 0) {
      return false;
    }
    if (need & 1) {
      return query(fenw_odd, n - x - 1) >= need;
    } else {
      return query(fenw_even, n - x - 1) >= need;
    }
  };

  auto valid = [&](int max0, int max1, int diff, int q) {
    return check(max0, q - diff) || check(max1, q + diff);
  };

  int max0 = 0, max1 = 0;
  if (!check(0, q)) {
    puts("-1");
    return 0;
  }
  int diff = 0;
  for (int i = 0; i < n; ++i) {
    if (b[i]) {
      --q;
    }
    while (memory.size() > size[i]) {
      *memory.top().first = memory.top().second;
      memory.pop();
    }
    if (max0 <= a[i]) {
      if (valid(a[i], max1, diff + 1, q)) {
        cout << 0;
        max0 = a[i];
        ++diff;
      } else {
        cout << 1;
        if (max1 <= a[i]) {
          max1 = a[i];
          --diff;
        }
      }
    } else {
      if (valid(max0, max1, diff, q)) {
        cout << 0;
      } else {
        cout << 1;
        if (max1 <= a[i]) {
          max1 = a[i];
          --diff;
        }
      }
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 33796
N = int(input())
a = [int(s) for s in input().split()]
b = sum(a)
c = int(0)
i = int(0)
sabun = int(0)
sabun2 = int(0)
count = int(0)

for i in range(N):
  if sabun >= 0:
    b = b - a[i]
    c = c + a[i]
    sabun = b - c
    i = i + 1
  else:
    sabun2 = sabun + a[i-1] * 2
    break

print(int( min([abs(sabun),abs(sabun2)]) ))
    

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;string S;cin>>N>>S;
  int W=0;
  int U=0;
  for(int X=0;X<N;X++){
    if(S[X]=='R'){
      W++;
    }
  }
  for(int X=0;X<W;X++){
    if(S[X]!='R'){
      U++;
    }
  }
  cout<<U<<endl;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    ll con = 0, num = 0;
    REP(i, n) {
        if(s[i]=='R') con++;
        else con = 0;
        if(con >= 2) num++;
    }
    con = 0;
    for(ll i=n-1; i>=0; --i) {
        if(s[i]=='L') con++;
        else con = 0;
        if(con >= 2) num++;
    }


    cout << min(n-1, num+k*2) << endl;

    return 0;
}


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

using namespace std;

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

    long ans = 0;
    int n = s.size();
    for (int x = 0; x < 1<<(n-1); ++x) {
        long acc = 0;
        for (int i = 0; i < n; ++i ) {
            acc *= 10;
            acc += s[i] - '0';
            if((x&(1<<i)) == 0) {
                ans += acc;
                acc = 0;
            }
        }
        ans += acc;
    }
    cout << ans << endl;
    return 0;
}


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

const int MAXN = 1e5+10;
int n, m;
int main(){
  cin.tie(0); ios_base::sync_with_stdio(0);
  cin>> n >> m;
  set<int> days;
  for(int i=1;i<=m;i++) days.insert(i);
  int ans = 0;
  vector<pair<int,int>> vp;
  for(int i=0;i<n;i++) {
    int a, b;
    cin >> a >> b;
    vp.emplace_back(b, a);
  }
  sort(vp.rbegin(), vp.rend());
  for(auto p:vp) {
    int a = p.second;
    int b = p.first;
    //cerr << a << " " << b <<endl;
    auto it = days.lower_bound(a);
    if (it==days.end()) continue;
    days.erase(it);
    ans+=b;
  }
  cout << ans <<endl;
}


Measured memory_bytes: 6140
from collections import deque
n, m = map(int, input().split())
edge = [[] for i in range(n)]
kkp = [0] * n
for i in range(m):
    u, v = map(int, input().split())
    edge[u - 1].append(v - 1)
s, t = map(int, input().split())
que = deque([(s - 1, 0)])
while que:
    now, dis = que.popleft()
    for next in edge[now]:
        if next == t - 1 and (dis + 1) % 3 == 0:
            exit(print((dis + 1) // 3))
        if not kkp[next] & (2 ** ((dis + 1) % 3)):
            kkp[next] = kkp[next] | (2 ** ((dis + 1) % 3))
            que.append((next, dis + 1))
print(-1)

Measured memory_bytes: 23400
use std::io::{ stdin, stdout, Read, Write };

const N: usize = 4;

fn main() {
  let mut buf = [0; N];

  let mut stdin = stdin();
  stdin.read(&mut buf).unwrap();

  let mut i = 0;
  while i < N - 1 {
    buf[i] = if buf[i] == b'1' { b'9' } else { b'1' };
    i += 1;
  }

  let stdout = stdout();
  let mut writer = stdout.lock();
  writer.write(&buf).unwrap();
  writer.flush().unwrap();
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int K, X; cin >> K >> X;
  if(500*K >= X) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

#include <algorithm>
struct Product {long w, v;};

int main(){
  int N, K;
  
  cin >> N >> K;
  vector<int> H(N);
  int dp[N];
  for (int i=0;i<N;i++) dp[i] = 1000000000;
  for (int i=0;i<N;i++){
    int h;
    cin >> h;
    H[i] = h;
  }

  dp[0] = 0;
  for (int i=1; i<N; i++){
    for(int j=1; j<=K; j++){
      if (i-j>=0) {
	dp[i] = min(dp[i], dp[i-j]+ abs(H[i]-H[i-j]));
      }
    }
  }
  
  cout << dp[N-1] << endl;
  return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int, int> pii;
const int mod = (int)1e9 + 7;

vector<vector<bool>> maj;

double cvv(double a, double b){return a*a + b*b; };
vector<vector<pair<int, double>>> r;

const double INF = 1e22;
vector<double> dijkstra(int s){
	typedef pair<double, int> pdi;
	priority_queue< pdi, vector<pdi>, greater<pdi> > que;
	vector<double> d(sz(r), INF); 
	d[s] = 0;
	que.push(pii(0, s));
	while(!que.empty()){
		int v; double cost;
		tie(cost, v) = que.top();
		que.pop();
		if(d[v] < cost) continue;
		for(const auto& rp : r[v]){ 
			double rct; int rto;
			tie(rto, rct) = rp;
			if(d[rto] > d[v] + rct){
				d[rto] = d[v] + rct;
				que.push(pdi(d[rto], rto));
			}
		}
	}
	return d;
}

int main()
{

	int xs,ys,xt,yt, n;
	cin >>xs >>ys >>xt >>yt >>n;
	VI xx(n+2), yy(n+2), rr(n+2);
	rep(i,n) cin >> xx[i] >> yy[i] >> rr[i];
	xx[n]=xs; yy[n]=ys; rr[n]=0;
	xx[n+1]=xt; yy[n+1]=yt; rr[n+1]=0;
	
	r.resize(n+2);
	rep(i,n+1) rep2(j,i+1,n+2){
		double ky = sqrt(cvv(xx[i]-xx[j], yy[i]-yy[j]));
		r[i].emplace_back(j, max(0.0, ky - (rr[i]+rr[j])));
		r[j].emplace_back(i, max(0.0, ky - (rr[i]+rr[j])));
	}
	
	auto rc = dijkstra(n);

	printf("%.15f\n", rc[n+1]);
	return 0;
}


Measured memory_bytes: 20720
//include
//-------------------------
#include<vector>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<stack>
#include<bitset>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<string>
#include<cstring>
#include<ctime>

using namespace std;

//conversion
//-----------------------
inline int toInt(string s) { int v;istringstream sin(s);sin >> v;return v; }
template<class T>inline string toString(T x) { ostringstream sout;sout << x;return sout.str(); }

//math
//-----------------------
template<class T>inline T sqr(T x) { return x * x; }

//using
//-----------------------
using VI = vector<int>;
using VVI = vector<VI>;
using VS = vector<string>;
using PII = pair<int, int>;
using LL = long long;

//container util
//-----------------------
#define WHOLE(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define RWHOLE(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); })(x)
#define CWHOLE(f,x,...) ([&](decltype((x)) whole) { return (f)(cbegin(whole), cend(whole), ##__VA_ARGS__); })(x)
#define CRWHOLE(f,x,...) ([&](decltype((x)) whole) { return (f)(crbegin(whole, crend(whole), ##__VA_ARGS__); })(x)
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())


// repetition
//----------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REPEAT(i,n) FOR(i,0,n)

//constant
//----------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a).0,sizeof(a))

//debug
//#define DEBUG
#ifdef DEBUG
#define dump(x) cerr<<#x<<"="<<(x)<<endl;
#define debug(x) cerr<<#x<<"="<<(x)<<"(L"<<__LINE__<<")"<<""<<__FILE__<<endl;
#define stay cout<<"Push any key and Enter..."; scanf_s("%*s");
#else
#define dump(x)
#define debug(x)
#define stay
#endif

int main() {
	int n;cin >> n;
	VI num(n);
	REPEAT(i, n) { cin >> num[i]; --num[i]; }
	cout<<WHOLE(accumulate, num,0)<<endl;
	stay;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a, b, c, x, count;
        count = 0;

	scanf("%d %d %d", &a, &b, &c);

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

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

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

using namespace std;

int main()
{
    long long N, K, i;
    cin >> N >> K;
    long long arreglo[N];
    for (i=0; i<N; i++) cin >> arreglo[i];
    sort(arreglo, arreglo+N);
    long long suma=0;
    for(i=0; i<K; i++) suma=suma+arreglo[N-1-i];
    cout << suma << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000000
#define mod 1000000007
using namespace std;
using LL = long long;

int main(){
    int n,m;cin>>n>>m;
    int buf;
    int l=0,r=100000;
    for(int i=0;i<m;i++){
        cin>>buf;l=max(l,buf);
        cin>>buf;r=min(r,buf);
    }
    
    if(r<l)cout<<0<<endl;
    else cout<<r-l+1<<endl;
}


Measured memory_bytes: 256
import Data.List (sort)

main = do
  n <- readLn
  xn <- map read . words <$> getLine::IO[Int]
  let sn = sort xn
  let upMedian = sn !! (div n 2)
  let downMedian = sn !! ((div n 2) - 1)
  mapM_ print $ map (\x -> if x < upMedian then upMedian else downMedian) xn

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

int main(){
    vector<int> vec(3);
    rep(i, 3){
        cin>>vec.at(i);
    }
    sort(vec.begin(), vec.end());
    cout<<vec.at(0)<<" "<<vec.at(1)<<" "<<vec.at(2)<<endl;
}


Measured memory_bytes: 3116