akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000],nos[10000],nos1[10000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    long long i,j,k,a,b,c,x,y,z,n;
	nos[0]=1;
	nos1[0]=1;
	for (i=0;i<=100000;i++)
	{
		arr[i]=10000000000000;
	}
	for (i=1;i<=100;i++)
	{
		if (6*nos[i-1]>100000)
		{
			break;
		}
		nos[i]=6*nos[i-1];
	} 
	x=i;
	for (i=1;i<=100;i++)
	{
		if (9*nos1[i-1]>100000)
		{
			break;
		}
		nos1[i]=9*nos1[i-1];
	} 
	y=i;
	for (i=1;i<y;i++)
	{
		nos[x]=nos1[i];
		x++;
	}	
	for (i=0;i<12;i++)
	{
		arr[nos[i]]=1;
	}
	for (i=1;i<=100000;i++)
	{
		for (j=0;j<12;j++)
		{
			if (i-nos[j]<=0)
			{
				continue;
			}
			arr[i]=min(arr[i],arr[i-nos[j]]+1);
		}
	}
	cin>>n;
	cout<<arr[n]<<endl;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n, m; read(n, m);
	int ans = 0;

	vector<int> v;
	for (int i = 1; i * i <= m; i++) 
		if (m % i == 0) v.push_back(i), v.push_back(m / i);
	for (int f : v) if (m / f >= n) chmax(ans, f);
	die(ans);
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int N = sc.nextInt();
        int A[] = new int[N];
        for(int i = 0; i < N; i++) A[i] = sc.nextInt();

        int sum = 0;
        for(int i = 0; i < N; i++){
            int minj = i;
            for(int j = i; j < N; j++){
                if(A[j] < A[minj]){
                    minj = j;
                }
            }
            if(A[i] > A[minj]){
                int m = A[i];
                A[i] = A[minj];
                A[minj] = m;
                sum++;
            }
        }
        
        for(int i = 0; i < N; i++){
            System.out.print(A[i]);
            if(i != N - 1) System.out.print(" ");
        }
        System.out.println();
        System.out.println(sum);

        sc.close();
    }
}


Measured memory_bytes: 26428
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H,W;
  cin >> H >> W;
  vector<string> lines(H);
  for (int i=0; i<H; i++) cin >> lines.at(i);
  for (int i=0; i<W+2; i++) cout << '#';
  cout << endl;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W+2; j++) {
      if (j == 0 || j == W+1) cout << '#';
      else cout << lines.at(i).at(j-1);
    }
    cout << endl;
  }
  for (int i=0; i<W+2; i++) cout << '#';
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] cnt = new int[4];
		while(sc.hasNext()) {
			String[] s = sc.next().split(",");
			if(s[1].length() == 2) {
				cnt[2]++;
			}else {
				char c = s[1].charAt(0);
				if(c == 'A') {
					cnt[0]++;
				}else if(c == 'B') {
					cnt[1]++;
				}else {
					cnt[3]++;
				}
			}
		}
		sc.close();
		for(int i : cnt) {
			System.out.println(i);
		}
	}
}


Measured memory_bytes: 26088
<?php
$n = int();
while(true){
    if(isPrime($n)){
        echo $n;
        exit;
    }
    $n++;
}
function isPrime($n){
    $sqrtn = sqrt($n)+0.01;
    for($i = 2; $i < $sqrtn; $i++){
        if($n % $i == 0)return false;
    }
    return true;
}

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (LLONG_MAX)
#define MOD (1000000007)
#define MAX (100000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
T1 mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  T1 tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

/////////////////////////////////////////////////////////

ll fact[MAX], fact_inv[MAX];

// 繰り返し二乗法
ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

ll comb(ll n, ll r){
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
void Main() {
  int N, M; cin >> N >> M;
  vector<pair<int, int>> xy(M);
  rep(i, 0, M){
    cin >> xy[i].first >> xy[i].second;
    xy[i].first--; xy[i].second--;
  }
  vector<pair<int, int>> C(N, make_pair(0, 1));
  C[0] = make_pair(1, 1);
  rep(i, 0, M){
    if(C[xy[i].first].first == 1){
      if(C[xy[i].first].second == 1) C[xy[i].first].first = 0;
      C[xy[i].first].second--;
      C[xy[i].second].first = 1;
      C[xy[i].second].second++;
    }else{
      C[xy[i].first].second--;
      C[xy[i].second].second++;
    }
  }
  int res = 0;
  rep(i, 0, N){
    if(C[i].first) res++;
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 1792
h,w,k = map(int,input().split())

cells = []
rowBlack = []
columnBlack = [0] * w
for _ in range(h):
    ipt = input()
    rowBlack.append(ipt.count("#"))
    cells.append(ipt)

for cell in cells:
    for i in range(w):
        if cell[i] == "#":
            columnBlack[i] += 1

total = sum(columnBlack)
cnt = 0
for hbit in range(2**h):
    for wbit in range(2**w):
        decBlack = 0

        hlis = []
        for he in range(h):
            if not hbit >> he & 1: continue
            decBlack += rowBlack[he]
            hlis.append(he)

        for we in range(w):
            if not wbit >> we & 1: continue
            decBlack += columnBlack[we]
            for he in hlis:
                if cells[he][we] == "#":
                    decBlack -= 1

        if total - decBlack == k:
            cnt += 1
print(cnt)



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


void solve(long long A, long long B, long long N){
    if(N >= B - 1){
        cout<<floor(1.0 * A * (B-1) / B) - A * floor((B - 1) / B)<<endl;
    }else{
        cout<<floor(1.0 * A * (N) / B) - A * floor((N) / B)<<endl;
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    solve(A, B, N);
    return 0;
}


Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)



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

    LL a = 1;
    LL b = 1;
    LL c = 1;
    LL d = 1;

    rep(i,N){
        a *= 10;
        b *= 9;
        c *= 9;
        d *= 8;
        a %= MOD;
        b %= MOD;
        c %= MOD;
        d %= MOD;
    }
    a -= b;
    a += MOD;
    a %= MOD;
    a -= c;
    a += MOD;
    a %= MOD;
    a += d;
    a += MOD;
    a %= MOD;

    cout << a << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define vvi vector<vi>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define tc(i) int test_casesq; cin >> test_casesq; f(i, test_casesq)
#define ync(x, a, b) cout << (x?a:b) << '\n';
#define yn(x) ync(x, "YES", "NO");
#ifndef ONLINE_JUDGE
#define DBG(v) cerr << #v << " = " << (v) << endl;
#else
#define DBG(v) ;
#endif
template <typename T> std::ostream& operator<<(std::ostream &os, std::vector<T> v){os << "["; f(i, sz(v)) os << v[i] << " "; return os << "]";}

using namespace std;

ll INF = (1ll<<61);



int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n; cin >> n;
    vi v(n);
    f(i, n) cin >> v[i];
    int ans = 0;
    f(i, n) ans += (i % 2  == 0) && (v[i]%2==1);
    cout << ans << endl;
    return 0;
}







// END


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

int main() {
    int n;
    int p[30];
    int ans = 0;
    
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    
    for (int i = 1; i < (n - 1); i++) {
        if (
            ((p[i] > p[i - 1]) && (p[i] < p[i + 1])) ||
            ((p[i] > p[i + 1]) && (p[i] < p[i - 1]))
        ) {
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long N;
    cin >> N;
    long m = 0, current = 0, eve = 0;
    for (long i = 0; i < N; ++i) {
        long h;
        cin >> h;
        if (eve < h) {
            current = 0;
            eve = h;
        } else {
            ++current;
            m = max(m, current);
            eve = h;
        }
    }
    cout << m << endl;
}


Measured memory_bytes: 504
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int s;
	vector<int> a;
	scanf("%d", &s);
	a.push_back(s);
	for (int i = 1;true; i++) {
		if (a[i - 1] % 2 == 0) {
			a.push_back(a[i - 1] / 2);
		}
		else {
			a.push_back(3 * a[i - 1] + 1);
		}
		for (int j = 0; j < i; j++) {
			if (a[i] == a[j]) {
				printf("%d", i + 1);
				return 0;
			}
		}
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

string n;
int K;

ll dp[110][2][5];

int main() {
    cin >> n >> K;
    int nlen = n.length();
    // memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;

    for(int i = 0; i < nlen; ++i) {
        int limit = n.at(i) - '0';
        for(int j = 0; j < 2; ++j) {
            for(int k = 0; k <= K; ++k) {
                for(int d = 0; d <= (j ? 9 : limit); ++d) {
                    if(d == 0) {
                        // kは増えない
                        dp[i+1][j || (d<limit)][k] += dp[i][j][k];
                    }else {
                        dp[i+1][j || (d<limit)][k+1] += dp[i][j][k];
                    }
                }
            }
        }
    }
    
    cout << dp[nlen][0][K] + dp[nlen][1][K] << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n,m;
 cin>>n>>m;
 ll b,c;
 vector<ll>a;
 vector<pair<ll,ll>>vec(m);
 rep(i,0,n){
  sc(b);
  push(a,b);
 }
 rep(i,0,m){
  cin>>b>>c;
  vec[i].first=c;
  vec[i].second=b;
 }
 sort(all(a));
 sort(all(vec));
 reverse(all(vec));
 ll t,ans=0;
 rep(i,0,n){
  if(!vec.empty()){
   t=vec[0].first;
   if(t>a[i]){
    a[i]=t;
    vec[0].second--;
    if(vec[0].second==0)vec.erase(vec.begin());
   }
  }
  ans+=a[i];
 }
 pr(ans);
return 0;}

Measured memory_bytes: 5812
#include <stdio.h>

int main(){
   int h,w,i,j,k,l;
   char a[100][100];

   scanf("%d %d",&h,&w);
   for (i=0;i<h;) {
      for (j=k=0;j<w;j++) {
          scanf(" %c",&a[i][j]);
          if (a[i][j]=='#') k=1;
      }
      if (k==0) h--;
      else      i++;
   }
   for (j=k=0;j<w;j++) {
      for (i=l=0;i<h;i++) {
          a[i][k]=a[i][j];
          if (a[i][k]=='#') l=1;
      }
      if (l==1) k++;
   }
   for (i=0;i<h;i++) {
       for (j=0;j<k;j++) printf("%c",a[i][j]);
       puts("");
   }
   return 0;
}


Measured memory_bytes: 128
a = list(input().split(" "))
b = list(input().split(" "))
t = 0
for k, i in enumerate(b):
    if k < len(b)-1:
        if int(i)+int(a[1]) > int(b[k+1]):
            t += int(b[k+1]) - int(b[k])
        else:
            t += int(a[1])
    else:
        t += int(a[1])
print(t)

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

int n,m;
vector<int> dp;
vector<vector<int>> adj;
vector<int> vis;

void dfs(int node){
	vis[node]=1;
	for(int cld : adj[node]){

		if(!vis[cld])dfs(cld);

		dp[node]=max(dp[node],1+dp[cld]);
	}
}
int main() {
	int n,m;
	cin>>n>>m;

	adj.resize(n);
	dp.resize(n);
	vis.resize(n);

	int x,y;

	for(int i=0;i<m;i++){

		cin>>x>>y,x--,y--;
		adj[x].push_back(y);

	}

	for(int i=0;i<n;i++){
		if(!vis[i])	dfs(i);
	}

	int ans=0;

	for(int i=0;i<n;i++){
		ans=max(ans,dp[i]);
	}

	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 8576
#include <iostream>
#include <algorithm>
#include <cstring>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define inf (1<<29)
using namespace std;

    int N, D;
    int p[100][100];
    int minp[100];
    int dp[100][100];
    int path[100][100];
int main() {
    cin >> N >> D;
    int i,j;
    for (i = 0; i < N; i++) {
      for(j = 0; j < D; j++) {
        cin >> p[i][j];
      }
    }
    int sum = 0;
    for(j = 0; j < D; j++) {
      minp[j] = 1000000;
      for(i = 0; i < N; i++) {
        if(minp[j] > p[i][j]) {
          minp[j] = p[i][j];
        }
        path[i][j] = 100;
      }
      sum += minp[j];
    }

    int count_min[100];
    memset(count_min, 100, sizeof(count_min));
    for(i = 0; i < N; i++) {
      if(minp[D-1] == p[i][D-1]){
        dp[i][D-1] = 0;
      } else {
        dp[i][D-1] = 100;
      }
      for(j = 0; j < D-1; j++) {
        dp[i][j] = 100;
      }
    }
    count_min[D-1] = 0;

    int k;
    for(j = D-2; j >= 0; j--) {
      for(i = 0; i < N; i++) {
        if(minp[j] != p[i][j]) continue;

        if(dp[i][j+1] == count_min[j+1]) {
          dp[i][j] = count_min[j+1];
          path[i][j] = min(i, path[i][j]);
        } else {
          dp[i][j] = count_min[j+1] + 1;
          if(dp[i][j] == dp[i][j+1]) {
            path[i][j] = min(i, path[i][j]);
          }
          for(k=0; k < N; k++){
            if(dp[k][j+1] == count_min[j+1]) {
              path[i][j] = min(k, path[i][j]);
              break;
            }
          }
        }
        count_min[j] = min(count_min[j], dp[i][j]);
      }
    }
    int ans[50];
    int prev = -1;

    int temp;
    for(i = N - 1; i >= 0; i--) {
      if(count_min[0] == dp[i][0]) {
        ans[0] = i;
      }
    }
    for(j = 0; j < D; j++) {
      ans[j+1] = path[ans[j]][j];
    }
    cout << sum << " " << count_min[0] << endl;

    for(j = 0; j < D; j++) {
      cout << ans[j] + 1 << endl;
    }

}

Measured memory_bytes: 1232
import re
 
n, q = map(int, input().split())
s = input()
 
l = []
r = []
 
for i in range(q):
    _l, _r = map(int, input().split())
    l.append(_l)
    r.append(_r)
 
memo = [0 for i in range(len(s))]
cnt = 0
 
for i in range(1, len(s)):
    if s[i - 1] == "A" and s[i] == "C":
        cnt += 1
    memo[i] = cnt
 
for i in range(q):
    print(memo[r[i] - 1] - memo[l[i] - 1])

Measured memory_bytes: 14360
#include <bits/stdc++.h> 
#define pb push_back
#define F first
#define S second
#define M (ll)(1e9+7)
#define mp make_pair
  
using namespace std; 
typedef long long ll;
 
void solve()
{
    string s,t;
    cin>>s>>t;
    cout<<t+s<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

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

#define mx 100005
#define ll long long

int ar[mx];
char ch[mx];

int n,m,ii;

int func(int i,int j,int k)
{
    return (i*i+j*j+k*k+i*j+j*k+k*i);
}

void solve()
{
    scanf("%d",&n);
    for(int k=1; k<=n; k++)
    {
        int re=0;
        for(int i=1; i*i<=k; i++)
        {
            for(int j=1; j*j<=k; j++)
            {
                for(int l=1; l*l<=k; l++)
                {
                    int val=func(i,j,l);
                    if(val==k)
                    {
                        re++;
                        break;
                    }
                    else if(val>k)break;
                }
            }
        }
        printf("%d\n",re);
    }
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int t=1;
//  scanf("%d",&t);
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
char s[205];
int k, n;
void init(){
    scanf("%s%d", s, &k);
    n = strlen(s);
}
void solve(){
    if (s[0] == s[n - 1] && k > 1){
        bool flag = true;
        for (int i = 1; i < n; ++i)
            if (s[i] != s[0]){
                flag = false;
                break;
            }
        if (flag) {
            printf("%lld\n", (1ll * n * k) / 2ll);
            return ;
        }

        int cnt = 0, hd = 0, tl = n - 1;
        while (s[tl] == s[0]) --tl;
        ++tl;
        while (s[hd] == s[0]) ++hd;
        
        for (int i = hd; i < tl; ){
            int j = i;
            while (j < tl && s[i] == s[j])
                ++j;
            cnt += ((j - i) >> 1);
            i = j;
        }
        ll ans = 0;
        ans += 1ll * k * cnt;
        ans += 1ll * (k - 1) * ((n - tl + hd) >> 1);
        ans += ((n - tl) >> 1) + (hd >> 1);
        printf("%lld\n", ans);
    }else {
        int cnt = 0;
        for (int i = 0; i < n; ){
            int j = i;
            while (j < n && s[i] == s[j])
                ++j;
            cnt += ((j - i) >> 1);
            i = j;
        }
        printf("%lld\n", 1ll * cnt * k);
    }
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 256
ABCD = input()

for bit in range(1<<3):
    f = ABCD[0]
    ans = int(ABCD[0])
    for i in range(3):
        if bit & (1<<i):
            f += '+'
            ans += int(ABCD[i+1])
        else :
            f += '-'
            ans -= int(ABCD[i+1])
        f += ABCD[i+1]
    if ans == 7:
        break
print(f+'=7')

Measured memory_bytes: 61880
from queue import PriorityQueue
 
 
def main():
    N, M = map(int, input().split(' '))
    jobs = [[] for _ in range(M + 1)]
    for i in [input() for i in range(N)]:
        A, B = map(int, i.split(' '))
        if A > M:
            continue
        jobs[A].append(B)
 
    pq = PriorityQueue()
    reward = 0
 
    for sameJobs in jobs:
        for job in sameJobs:
            pq.put(-job)
        if not pq.empty():
            reward += -(pq.get())
 
    print(reward)
 
if __name__ == "__main__":
    main()

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

using namespace std;
using i64 = long long;

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

    i64 A, B;
    cin >> A >> B;
    int res = 1;
    for (int i = 2; 1LL * i * i <= A; ++i) {
        if (A % i == 0) {
            if (B % i == 0) {
                ++res;
            }
            while (A % i == 0) {
                A /= i;
            }
        }
    }
    if (A > 1 && B % A == 0) {
        ++res;
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

hon 0 = "pon"
hon 1 = "pon"
hon 2 = "hon"
hon 3 = "bon"
hon 4 = "hon"
hon 5 = "hon"
hon 6 = "pon"
hon 7 = "hon"
hon 8 = "pon"
hon 9 = "hon"

main :: IO ()
main = do
	n <- readLn
	putStrLn $ hon (n `mod` 10)


Measured memory_bytes: 3928
package main

import "fmt"

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

	l := len(n)

	dp0 := make([]int32, l)
	dp1 := make([]int32, l)

	for i := 0; i < l; i++ {
		m := int32(n[i] - '0')

		if i == 0 {
			dp0[i] = min(m, 11-m)
			dp1[i] = min(m+1, 10-m)
		} else {
			dp0[i] = min(dp1[i-1]+10-m, dp0[i-1]+m)
			dp1[i] = min(dp1[i-1]+9-m, dp0[i-1]+m+1)
		}
	}

	fmt.Println(dp0[l-1])
}

func min(n int32, m int32) int32 {
	if n <= m {
		return n
	}
	return m
}


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<string,int>Psi;

int main(){
  int n,k;
  string s;
  cin>>n>>k>>s;
  if(s[k-1]=='A'){
    s[k-1]='a';
  }else if(s[k-1]=='B'){
    s[k-1]='b';
  }else{
    s[k-1]='c';
  }
  cout<<s<<endl;
}

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

void _swap(int *x, int *y) {
	int tmp;
	tmp = *x;
	*x = *y;
	*y = tmp;
	return;
}

int main(int argc, char const *argv[]) {
	int x, y;

	while (true) {
		cin >> x >> y;
		if (x == 0 && y == 0) {
			break;
		}
		else if (x > y) {
			_swap(&x, &y);
		}
		cout << x << " " << y << endl;
	}
	

	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
int main(void){

    char s[1001]=" ";
    char *const word = s;
    
    scanf("%s",s);

    char *tail = word + strlen(word) - 1;
    if(strchr("s", *tail) != NULL){
        strcpy(tail+1,"es");
    }else {
        strcpy(tail+1,"s");
    }

    printf("%s\n",s);

    return 0;
}

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

int main(){
    double a, b, c;
    cin >> a >> b >> c;
    double c_rad = c / 180.0 * M_PI;
    const double h = sin(c_rad) * b;
    const double S = h * a / 2;
    const double d = sqrt(a * a + b * b - 2 * a * b * cos(c_rad));
    printf("%.10f\n%.10f\n%.10f\n", S, a + b + d, h);
    return 0;
}



Measured memory_bytes: 3432
/*

                                                ====||====      --      --         /\
                                                    ||         |       |          /  \
                                                    ||                 |         /    \
                                                    ||         |--     |-       /------\
                                                    ||         |       |       /        \
                                                    ||          --     |      /          \
*/
#include <bits/stdc++.h>
#define ll long long
#define E endl
#define ull unsigned long long
#define TeFa
#define in cin
using namespace std;
//-----------------------------------


  ll N,M,C1=0,C2=0;
bool fn(ll w,ll N)
{
     if(w==N){return true;}
     else if(w>N){return false;}

    bool x=fn(w*2,N);
    bool y=fn(w*3,N);

    if(x||y){C1++;return true;}
    return false;
}
int main()
{
   //solve();
  ll T,K,N,S=0;
  in>>T>>K;
  vector<ll>v;
  for(int i=0;i<T;i++)
  {
      in>>N;
      S+=N;
      v.push_back(N);
  }
  sort(v.begin(),v.end());
  if(K>T)cout<<0<<E;
  else if(K==0)cout<<S<<E;
  else{
    for(int i=v.size()-1;i>=0;i--)
    {
        if(K==0)break;
        K--;
        S-=v[i];
    }
    cout<<S<<E;
  }



      return 0;
}


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

int main(){
	
	ll a,b,c,d; cin>>a>>b>>c>>d;
	ll sum{};
	sum += (b - (b/c+b/d) + b/(c*d/__gcd(c,d)));
	a--;
	sum -= (a - (a/c+a/d) + a/(c*d/__gcd(c,d)));
	cout << sum << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=7000005;
typedef long long ll;
typedef double dbl;
typedef long double ld;
const ld EPS=1e-9;
const ld PI=3.141592653589793;
const ll MOD = 1e9+7;
const int SQRT = 300;
const int LG=21;
const int FOURIER = (1<<LG);
////////////////
int a[maxn];
int pref[maxn];
int suff[maxn];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=1; i<=n; ++i)
        cin>>a[i];
    for(int i=1; i<=n; ++i)
        pref[i]=pref[i-1]+abs(a[i]-a[i-1]);
    for(int i=n; i>=1; --i){
        suff[i]=suff[i+1]+abs(a[i+1]-a[i]);
    }
    for(int i=1; i<=n; ++i){
        int fi=pref[i-1];
        int se=suff[i+1];
        cout<<fi+se+abs(a[i-1]-a[i+1])<<"\n";
    }
}




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

#define limit (int)(2e5 + 5)
#define mod (int)(1e9 + 7)

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;



int main() {

	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int x[5];
	int ans = -1;
	for (int i = 0; i < 5; ++i)
	{
		cin >> x[i];

		if (x[i] == 0)
		{
			ans = i+1;
		}
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    int A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    long long count = 0;
    
    for(int i=0;i<N;i++){
        count += (long long)A[i]/2;
        A[i] = A[i] %2;
        if(A[i]==1 && i+1<N && A[i+1]>0){
            count++;
            A[i]--;
            A[i+1]--;
        }
    }
    
    cout << count;
    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int N;
string S;

int check(int from) {
	int right = -1;
	for (int i = from+2; i < N; i++) {
		if (S[i] == '#' && S[i-1] == '#') {
			right = i-2;
			break;
		}
	}
	if (right == -1) right = N-1 - (int)(S[N-1] == '#');
	return (right);
}

void Main() {
	int A, B, C, D;
	cin >> N >> A >> B >> C >> D; --A, --B, --C, --D;
	cin >> S;
	int ad = check(A);
	int bd = check(B);
	if (C <= ad && D <= bd) {
		if (C > D) {
			for (int i = B; i <= D; i++) {
				if (S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') {
					cout << "Yes" << endl;
					return;
				}
			}
			cout << "No" << endl;
		} else {
			cout << "Yes" << endl;
		}
	} else {
		cout << "No" << endl;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int result[100][100];
int win[100];
int sum[100];
int ans=0;
int n;
void dfs(int);
void comb(int w,int s,int d,int num,int bbit,int wnum,int lnum){
  //cout<<num<<endl;
  if(num==n-s-1){
    int cnt=0;
    vector<pair<int,int> >po;
    for(int i=d+1;i<n;i++){
      if(result[d][i]==0){
	if(bbit&(1<<cnt)){
	  result[d][i]=1;
	  result[i][d]=2;
	  sum[i]++;
	  win[d]++;
	  po.pb(mp(i,0));
	}else{
	  result[d][i]=2;
	  result[i][d]=1;
	  sum[i]++;
	  win[i]++;
	  po.pb(mp(i,1));
	}
	cnt++;
      }
    }
    dfs(d+1);
    for(int i=0;i<po.size();i++){
      if(po[i].S){
	win[po[i].F]--;
      }else
	win[d]--;
      sum[po[i].F]--;
      result[d][po[i].F]=0;
      result[po[i].F][d]=0;
    }
    return;
  }
  if(wnum+w<(n-1)/2)
    comb(w,s,d,num+1,bbit+(1<<num),wnum+1,lnum);
  if(lnum+(s-w)<(n-1)/2)
    comb(w,s,d,num+1,bbit,wnum,lnum+1);
}
void dfs(int depth){
  if(depth==n-1){
     for(int i=0;i<n;i++){
    // for(int j=0;j<n;j++){
    //	cout<<result[i][j]<<" ";
    // }
    // cout<<endl;
      if(win[i]!=n/2)return;
      }
    ans++;
    return;
  }
  comb(win[depth],sum[depth],depth,0,0,0,0);
}
int main(){
  while(cin>>n,n){
    ans=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++)
	result[i][j]=0;
      win[i]=0;
      sum[i]=0;
    }
    int m;cin>>m;
    for(int i=0;i<m;i++){
      int x,y;cin>>x>>y;
      result[--x][--y]=1;
      result[y][x]=2;
      win[x]++;
      sum[x]++;
      sum[y]++;
    }
    dfs(0);
    cout<<ans<<endl;
  }
  return 0;
}



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

int main()
{
	int a, b; cin >> a >> b;
	
	int ans = 0;

	for (int j = a; j <= b; j++) {

		string s = to_string(j);
		bool same = true;

		for (int i = 0; i <= s.size() / 2 - 1; i++) {

			if (s.at(i) != s.at(s.size() - i - 1)) same = false;

		}

		if (same) ans++;

	}
		
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<stdio.h>
#include<stack>
#include<math.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,n) for(int i=1;i<=(n);i++)
#define LL long long int
 
 
using namespace std;
 
LL lcm(LL n, LL m)
{
	LL u;
	LL ansl = 0;
	for(u=m; u>=m; u++){
		if(u%n == 0){
			if(u%m == 0){
				ansl = u;
				break;
			}
		}
	}
	return ansl;
}
 
int main(void){
    LL n;
    int w;
    cin >>n;
    vector<int> a(n+1,0);
    Rep(i,n-1){
        cin >>w;
        a[w]++;
    }
    Rep(i,n){
        cout <<a[i]<<endl;
    }
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
//using
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;

//関数マクロ
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl

//定数マクロ
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>

//定数
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);

//テンプレート関数
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; }
//intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); } //c++17からある
//intl lcm(intl a,intl b){ return a / gcd(a, b) * b; } //c++17からある

//自作テンプレート関数
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}//Yes,Noの出力を楽にするよう
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}//上の関数のYes,Noを任意の文字列でできるようにしたもの
intl fact(intl k){ intl a = 1; for(int i = 2; i <= k; i++){ a *= i; } return a; }//k!を求める関数,O(N)
intl digit10(intl a){ intl b = 0; do{ a /= 10; b++; }while(a); return b; }//aを10進数で表したときの桁数を求める関数,O(logN)




signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    repi(i,1,n + 1){
        intl cnt = 0;
        for(intl x = 1;x * x <= i;x++){
            for(intl y = 1;y * y <= i;y++){
                if(x * x + y * y + x * y >= i)break;
                intl n0 = i;
                intl a = x + y;
                intl b = n0 -(x * x + y * y + x * y);
                intl z = (-a + sqrtl(a * a + 4 * b)) / 2;
                //cout << i << ":" << z << endl;
                if(z <= 0)continue;
                if(x * x + y * y + z * z + x * y + x * z + y * z == i)cnt++;
                else {
                    z = (-a - sqrtl(a * a + 4 * b)) / 2;
                    if(z <= 0)continue;
                    if(x * x + y * y + z * z + x * y + x * z + y * z == i)cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
# coding: utf-8
# Your code here!

# coding: utf-8
# Your code here!
a,b,c = list(map(int,input().split()))
K=int(input())

if b <= c:
    b,c=c,b
if a <= b:
    a,b = b,a
print(a*(2**K)+b+c)
    


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

int main() {
	cin >> n;
	for (int i = n;i <= 999;i++) {
		if (i % 111 == 0) {
			cout << i << endl;
			return 0;
		}
	}
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
int main(){
    ll n,ans=0;
    string a;cin>>a;
    n=a.size();
    For(i,0,n){
        if(i%2==0){
            if(a.at(i)=='L'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        else {
            if(a.at(i)=='R'){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


int main() {
	string s;
	cin >> s;
	int a=0, b=0;
	rep(i, s.size()) {
		if (s[i] == '0')a++;
		else b++;
	}
	cout << 2 * min(a, b);
	return 0;
}










Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  if (k <= a + b) {
    cout << min(k, a) << endl;
  } else {
    cout << a + (k - (a + b)) * (-1) << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
char in[310][310];
int s[940][940];
const int S=310;
inline int calc(int a,int b,int c,int d){
	if(a<1||a>=930)return 0;
	if(b<1||b>=930)return 0;
	
	return s[a-1][b-1]+s[c][d]-s[a-1][d]-s[c][b-1];
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%s",in[i]);
	}
	long long ret=0;
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			if(in[i][j]=='.')continue;
			for(int k=j+1;k<b;k++){
				if(in[i][k]=='.')continue;
				if(k%2!=j%2)continue;
				int di=(k-j)/2;
				if(i-di>=0&&in[i-di][j+di]=='#')ret++;
				if(i+di<a&&in[i+di][j+di]=='#')ret++;
			}
		}
	}
	for(int i=0;i<b;i++){
		for(int j=0;j<a;j++){
			if(in[j][i]=='.')continue;
			for(int k=j+1;k<a;k++){
				if(in[k][i]=='.')continue;
				if(k%2!=j%2)continue;
				int di=(k-j)/2;
				if(i-di>=0&&in[j+di][i-di]=='#')ret++;
				if(i+di<b&&in[j+di][i+di]=='#')ret++;
			}
		}
	}
	//printf("%lld\n",ret);
	ret=-ret;
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		if(in[i][j]=='#')s[S+i+j][S+i-j]=1;
	}
	for(int i=0;i<S*3;i++){
		for(int j=0;j<S*3-1;j++){
			s[i][j+1]+=s[i][j];
		}
	}
	for(int i=0;i<S*3;i++){
		for(int j=0;j<S*3-1;j++){
			s[j+1][i]+=s[j][i];
		}
	}
	for(int i=0;i<S*3;i++){
		for(int j=0;j<S*3;j++){
			if(calc(i,j,i,j)==0)continue;
			for(int k=j+1;k<S*3;k++){
				if(calc(i,k,i,k)==0)continue;
				int D=k-j;
				ret+=calc(i+D,j,i+D,k);
				ret+=calc(i-D,j,i-D,k);
			}
		}
	}
	for(int i=0;i<S*3;i++){
		for(int j=0;j<S*3;j++){
			if(calc(j,i,j,i)==0)continue;
			for(int k=j+1;k<S*3;k++){
				if(calc(k,i,k,i)==0)continue;
				int D=k-j;
				ret+=calc(j,i+D,k,i+D);
				ret+=calc(j,i-D,k,i-D);
			}
		}
	}
	
	printf("%lld\n",ret);
}

/*
.......
..B....
.......
A...C..
...C...
..C....
.......
.......
*/

Measured memory_bytes: 3712