akhauriyash/Code-Regression huggingface dataset:
n = int(input())

dic = dict()
mode_words = list()

for _ in range(n):
  word = input()
  if word not in dic:
    dic[word] = 1
  else:
    dic[word] += 1

mode = max(dic.values())

for word, times in dic.items():
  if times == mode:
    mode_words.append(word)

mode_words.sort()

for word in mode_words:
  print(word)

Measured memory_bytes: 32092
# スペース区切りの整数の入力
N = int(input())
C = []
S = []
F = []

for i in range(N-1):
    c, s, f= map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(N-1):
    time = 0
    for j in range(i, N-1):
        if time < S[j]:
            time = S[j]
        else:
            if time % F[j] != 0:
                time += F[j] - (time % F[j])
        time += C[j]
    print(time)
    
print(0)

Measured memory_bytes: 3064
#include<stdio.h>
/*long long int xbys(long long int a[],int n)
{
	int i;
	long long int m,zxgbs,x,y;
	m=a[0];
	for(i=0;i<n-1;i++)
	{
		x=m;
		y=a[i+1];
		zxgbs=zzxc(x,y);
		m=x/zxgbs*y/zxgbs*zxgbs;
	}
	return m;
}*/

long long int ntm(long long int a,long long int b)
{
	long long int num;
	if(a<b)
	{
		num=a;
		a=b;
		b=num;
	 }
	if(a%b==0)
	  return b;
	else
	  return ntm(b,a%b);
}

int main(void)
{
    int n,i;
    long long int t[105],out,mid,zxgbs,x,y;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%lld",&t[i]);
    }
    out=t[0];
        mid=t[0];
        for(i=1;i<n;i++){
            x=mid;
            y=t[i];
            zxgbs=ntm(mid,t[i]);
            mid=out=x/zxgbs*y/zxgbs*zxgbs;
        }
        printf("%lld",out);
    return 0;
}


Measured memory_bytes: 128
import java.io.PrintStream
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`);
    try {
        solve(sc, System.out);
    } finally {
        sc.close();
    }
}

fun solve(sc: Scanner, print: PrintStream) {
    val a = sc.nextLong()
    val b = sc.nextLong()
    val c = sc.nextLong()
    val d = sc.nextLong()

    val cand = arrayOf(a * c, a * d, b * c, b * d)
    print.println(cand.max())
}


Measured memory_bytes: 40308
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;

int N,u,v;
vector<int> G[100002];
int par[100002]={};
int rnk[100002]={};
int trnk[100002]={};

void decide_par(int x,int r)
{
	for(int i=0;i<G[x].size();i++)
	{
		if(par[G[x][i]]==0){par[G[x][i]]=x; rnk[G[x][i]]=r+1; decide_par(G[x][i],r+1);}
	}
	return;
}
//rnkが高い方が子
int decide_trnk(int x)
{
	int maxm=0;
	for(int i=0;i<G[x].size();i++)
	{
		if(rnk[x]<=rnk[G[x][i]]){
			if(trnk[G[x][i]]==0){maxm=max(maxm,decide_trnk(G[x][i]));}
			else{maxm=max(maxm,trnk[G[x][i]]);}
		}
	}
	trnk[x]=maxm+1;
	return trnk[x];
}

int main()
{
 scanf("%d %d %d",&N,&u,&v);
 for(int i=0;i<(N-1);i++)
 {
	int s,t;
	scanf("%d %d",&s,&t);
	G[s].push_back(t);
	G[t].push_back(s);
 }
 par[v]=-1;
 rnk[v]=1;
 decide_par(v,1);
 int vrk=decide_trnk(v);
 int urk=trnk[u];
 int sa=0,zzz=u;
 for(;;)
 {
	zzz=par[zzz];
	sa++;
	if(zzz==v){break;}
 }
 int ans=sa/2;
 int mv=(sa-1)/2; //移動可能回数
 int uu=u;
 for(int i=0;i<mv;i++)
 {
	uu=par[uu];
 }
 ans+=trnk[uu]-1;
 printf("%d",ans);
}



Measured memory_bytes: 15452
N = int(input())

lis=list(map(int,input().split()))

ans = 0

for ind in range(len(lis)):
  flag = True
  if ind == 0:
    ans += 1
    continue
  for j in range(ind):
      if lis[j] > lis[ind]: 
        flag = False
  if flag:
    ans +=1  
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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 (b < a) { a = b; return 1; } return 0; }

using Graph=vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;


int main(void)

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

	ll n;
	cin >> n;
	ll a, b;
	cin >> a >> b;

	ll ans = 0;
	ans = a * (n / (a + b));
	ll tmp = n % (a + b);

	ans += min(a, tmp);
	cout << ans << endl;

	return 0;
}

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

int a[100005];

int main(){
    int n,i;cin>>n;
    for(i=1;i<=n;++i) cin>>a[i];
    sort(a+1,a+n+1,greater<int>());
    for(i=1;i<=n;++i){
        if(a[i+1]<i+1 && a[i]>=i){
            int j=0;
            while(a[j+i+1]==i) j++;
            if((a[i]-i)%2==0 && j%2==0) puts("Second");
            else puts("First");
        }
    }
}

Measured memory_bytes: 640
def check(cor, cc):
    
    for i in range(cc):
        flg = True
        for j in range(cc):
            if cor[i][j] != 1:
                flg = False
                break
        if flg:
            return True

    
    for i in range(cc):
        flg = True
        for j in range(cc):
            if cor[j][i] != 1:
                flg = False
                break
        if flg:
            return True

    flg = True
    for i in range(cc):
        if cor[i][i] != 1:
            flg = False
            break
    if flg:
        return True

    flg = True
    for i in range(cc):
        if cor[i][cc-1-i] != 1:
            flg = False
            break
    if flg:
        return True
    
    return False
    
    

tmp = list(map(int, input().split(' ')))
cc = len(tmp)
box = [[]for _ in range(cc)]
cor = [[0 for _ in range(cc)] for _ in range(cc)]
box[0] = tmp

for i in range(cc-1):
    box[i+1] = list(map(int, input().split(' ')))


N = int(input())
for _ in range(N):
    num = int(input())
    for i in range(cc):
        for j in range(cc):
            if num == box[i][j]:
                cor[i][j] = 1

if check(cor, cc):
    print('Yes')
else:
    print('No')




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
#define mp(a, b) make_pair(a, b)
/*
map<pair<int, int>, int> M;
int sg(int x, int y)
{
	if(x > y) swap(x, y);
	if(x <= 1 && y <= 1) return 0;
	if(M.count(mp(x, y))) return M[mp(x, y)];
	unordered_set<int> s;
	for(int i = 2; i <= x; i += 2) s.insert(sg(x - i, y + i / 2));
	for(int i = 2; i <= y; i += 2) s.insert(sg(x + i / 2, y - i));
	for(int i = 0; ; ++i)
		if(!s.count(i))
			return M[mp(x, y)] = i;
}
*/
int main()
{
	ll x, y;
	cin >> x >> y;
	if(abs(x - y) <= 1) puts("Brown");
	else puts("Alice");
	return 0;
}

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

int n;

int main()
{
    cin >> n;
    vector<int> ans(n + 1);
    for (int x = 1; x * x <= n; x++)
    {
        for (int y = 1; y * y <= n; y++)
        {
            for (int z = 1; z * z <= n; z++)
            {
                int idx = x * x + y * y + z * z + x * y + y * z + z * x;
                if (idx <= n) ans[idx]++;
            }
        }
    }
    for (int i = 1; i <= n; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 3604
from itertools import accumulate as ac
n=int(input())
s=input()
a=[0 if i=="#" else 1 for i in s]
p=[0]+list(ac(a))
b=p[-1]
d=float("inf")
for i in range(n+1):
    d=min(i-p[i]+(b-p[i]),d)
print(d)


Measured memory_bytes: 14568
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 60;
const double EPS = 1e-10;

int N;
int h[100010];
int dp[100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  REP(i, N) cin >> h[i];
  fill(dp, dp+N, INF);
  dp[0] = 0;
  REP(i, N) {
    if (i+1<N) chmin(dp[i+1], dp[i]+abs(h[i]-h[i+1]));
    if (i+2<N) chmin(dp[i+2], dp[i]+abs(h[i]-h[i+2]));
  }
  cout << dp[N-1] << endl;

  return 0;
}

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

using namespace std;

int main()
{

    int x,a,b ;
    cin >>x>> a>>b;
    int t,r;
    t=abs(x-a);
    r=abs(x-b);
    if (t<r)
        cout <<'A';
    else
        cout <<'B';



    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;
int n,m,a,b;
char s[1010][1010];

void oku(int i,int j,int tile){
  if(tile==1)s[i][j]='<',s[i][j+1]='>';
  else s[i][j]='^',s[i+1][j]='v';
}

void no(){
  cout<<"NO"<<endl;
}

void yes(){
  cout<<"YES"<<endl;
  rep(i,n){
    rep(j,m){
      cout<<s[i][j];
    }
    cout<<endl;
  }
}
  
signed main(){
  cin>>n>>m>>a>>b;
  rep(i,n)
    rep(j,m)s[i][j]='.';
  
  int A=n*(m/2),B=(n/2)*m,S=n*m/2;
  if(a>A || b>B || a+b>S){no();return 0;}
  
  if((n*m)%2==0 || a+b<S || (a-m/2)%2==0){
    if(n%2==1){
      for(int j=0;j<m-1 && a>0;j+=2){
        oku(n-1,j,1);
        a--;
      }
    }
    if(m%2==1){
      for(int i=0;i<n-1 && b>0;i+=2){
        oku(i,m-1,2);
        b--;
      }
    }
    for(int i=0;i<n-1;i+=2){
      for(int j=0;j<m-1;j+=2){
        if(a+b==0){yes();return 0;}
        else if(a==0){
          oku(i,j,2);b--;
          if(b>0){
            oku(i,j+1,2);b--;
          }
        }
        else{
          oku(i,j,1);a--;
          if(a>0){
            oku(i+1,j,1);a--;
          }
        }
      }
    }
    if(a+b==0)yes();
    else no();
    return 0;
  }
  
  //if(m<3 || n<3){no();return 0;}
  if(a>0){oku(n-3,m-3,1);a--;}
  if(a>0){oku(n-1,m-2,1);a--;}
  if(b>0){oku(n-2,m-3,2);b--;}
  if(b>0){oku(n-3,m-1,2);b--;}
  
  for(int j=0;j<m-3 && a>0;j+=2){
    oku(n-1,j,1);
    a--;
  }
  
  for(int i=0;i<n-3 && b>0;i+=2){
    oku(i,m-1,2);
    b--;
  }
  for(int i=0;i<n-1;i+=2){
      for(int j=0;j<m-1;j+=2){
        if(a+b==0){yes();return 0;}
        else if(a==0){
          oku(i,j,2);b--;
          if(b>0){
            oku(i,j+1,2);b--;
          }
        }
        else{
          oku(i,j,1);a--;
          if(a>0){
            oku(i+1,j,1);a--;
          }
        }
      }
  }
  if(a+b==0)yes();
  else no();
    
  return 0;
}

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

int main(int argc, char const *argv[])
{
  for (int n, m; cin>>n>>m, !(n==0&&m==0); ) {
    vector<int> xs(n), ys(m);
    for (int i=0; i<n; i++) cin>>xs[i];
    for (int i=0; i<m; i++) cin>>ys[i];

    map<int, int> ws, hs;
    for (int i=0; i<n; i++) {
      int t = 0;
      for (int j=i; j<n; j++) {
        t += xs[j];
        ++ws[t];
      }
    }
    for (int i=0; i<m; i++) {
      int t = 0;
      for (int j=i; j<m; j++) {
        t += ys[j];
        ++hs[t];
      }
    }

    long long ans = 0;

    map<int, int>::iterator p = ws.begin();
    map<int, int>::iterator q = hs.begin();
    while (p != ws.end() && q != hs.end()) {
      if (p->first < q->first) {
        ++p;
        continue;
      }
      if (p->first > q->first) {
        ++q;
        continue;
      }
      ans += p->second * q -> second;
      ++p;
      ++q;
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 27980
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int X;
int Y;
int A[80][80];
char vis[80][80][6400];
int main(){
  int i;
  int v;
  int res;
  rd(X);
  rd(Y);
  for(i=(0);i<(X);i++){
    int j;
    for(j=(0);j<(Y);j++){
      A[i][j] = rd_int();
    }
  }
  for(i=(0);i<(X);i++){
    int j;
    for(j=(0);j<(Y);j++){
      A[i][j] = abs(A[i][j] - rd_int());
    }
  }
  vis[0][0][A[0][0]] = 1;
  for(i=(0);i<(X);i++){
    int j;
    for(j=(0);j<(Y);j++){
      int k;
      for(k=(0);k<(6400);k++){
        if(vis[i][j][k]){
          if(i+1 < X){
            v = abs(k-A[i+1][j]);
            if(v < 6400){
              vis[i+1][j][v] = 1;
            }
            v = k+A[i+1][j];
            if(v < 6400){
              vis[i+1][j][v] = 1;
            }
          }
          if(j+1 < Y){
            v = abs(k-A[i][j+1]);
            if(v < 6400){
              vis[i][j+1][v] = 1;
            }
            v = k+A[i][j+1];
            if(v < 6400){
              vis[i][j+1][v] = 1;
            }
          }
        }
      }
    }
  }
  for(res=(0);res<(6400);res++){
    if(vis[X-1][Y-1][res]){
      break;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200119-1

// --- original code ---
// int X, Y, A[80][80];
// char vis[80][80][6400];
// 
// {
//   int v, res;
//   rd(X,Y);
//   rep(i,X) rep(j,Y) A[i][j] = rd_int();
//   rep(i,X) rep(j,Y) A[i][j] = abs(A[i][j] - rd_int());
// 
//   vis[0][0][A[0][0]] = 1;
//   rep(i,X) rep(j,Y) rep(k,6400) if(vis[i][j][k]){
//     if(i+1 < X){
//       v = abs(k-A[i+1][j]);
//       if(v < 6400) vis[i+1][j][v] = 1;
//       v = k+A[i+1][j];
//       if(v < 6400) vis[i+1][j][v] = 1;
//     }
//     if(j+1 < Y){
//       v = abs(k-A[i][j+1]);
//       if(v < 6400) vis[i][j+1][v] = 1;
//       v = k+A[i][j+1];
//       if(v < 6400) vis[i][j+1][v] = 1;
//     }
//   }
// 
//   rep(res,6400) if(vis[X-1][Y-1][res]) break;
//   wt(res);
// }


Measured memory_bytes: 40192
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), true);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.flush();
		out.close();
	}
}

class Pair {
	long first;
	long second;
	long third;

	Pair(long first, long second, long third) {
		this.first = first;
		this.second = second;
		this.third = third;
	}
}

class TaskB {

	public void solve(int testNumber, InputReader in, PrintWriter pw) {
		int N = in.nextInt();
		long x[] = new long[N];
		long y[] = new long[N];
		long h[] = new long[N];
		Pair arr[] = new Pair[N];
		Pair temp = null;
		for (int i = 0; i < N; i++) {
			x[i] = in.nextLong();
			y[i] = in.nextLong();
			h[i] = in.nextLong();
			if (h[i] >= 1) {
				temp = new Pair(x[i], y[i], h[i]);
			}
		}
		ArrayList<Pair> ans = new ArrayList<Pair>();
		for (int i = 0; i < 101; i++) {
			for (int j = 0; j < 101; j++) {
				long V = temp.third + Math.abs(i - temp.first) + Math.abs(j - temp.second);
				V = Math.max(0, V);
				boolean flag = true;
				for (int k = 0; k < N; k++) {
					long height = V - Math.abs(i - x[k]) - Math.abs(j - y[k]);
					height = Math.max(0, height);
					if (height != h[k]) {
						flag = false;
						break;
					}
				}
				if (flag) {
					ans.add(new Pair(i, j, V));
				}
			}
		}
		if (ans.size() == 1) {
			pw.println(ans.get(0).first + " " + ans.get(0).second + " " + ans.get(0).third);
		}
	}

	int __gcd(int a, int b) {
		if (b == 0)
			return a;
		return __gcd(b, a % b);

	}

	public int getInt(int num) {
		int ret = -1;
		switch (num) {
		case 0:
			ret = 6;
			break;
		case 1:
			ret = 2;
			break;
		case 2:
			ret = 5;
			break;
		case 3:
			ret = 5;
			break;
		case 4:
			ret = 4;
			break;
		case 5:
			ret = 5;
			break;
		case 6:
			ret = 6;
			break;
		case 7:
			ret = 3;
			break;
		case 8:
			ret = 7;
			break;
		case 9:
			ret = 6;
			break;
		}
		return ret;
	}

	public int isPow(long num) {
		int count = 0;
		while (num > 0) {
			num /= 2;
			count++;
		}
		return count;
	}
}

class InputReader {
	BufferedReader br;
	StringTokenizer st;

	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));
		st = null;
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 26032
#include <iostream>
using namespace std;
int main(int argc, const char *argv[])
{
    int n;
    cin >> n;
    if (n % 10 == 0)
    {
        cout << 10 << endl;
    }
    else
    {
        string s = to_string(n);
        int sum = 0;
        for (int i = 0; i < s.length(); i++)
        {
            sum += s[i] - '0';
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

int main()
{
    int a,b,c;
   while(~scanf("%d %d %d",&a,&b,&c))
   {
       if(a==b)
       printf("%d\n",c);
       else
        if(a==c)
        printf("%d\n",b);
       else
       printf("%d\n",a);


   }
}




Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int a,b,c,d,i;
	scanf("%d %d %d",&a,&b,&c);
	d=min(a,b);
	for(i=d;i>=1;i--){
		if(a%i==0&&b%i==0){
			printf("%d\n",(a*b)/(i*i)*c);
			break;
		}
	}
	return 0;
}


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

int main() {
  int N, X;
  cin >> N >> X;
  int count = 0;
  int D = 0; //D1
  if ( D <= X ) {
    count++;
  }
  int L;
  rep(i,N) {
    cin >> L;
    D += L;
    if ( D <= X ) {
      count++;
      continue;
    }
    break;
  }
  cout << count << endl;
}

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

int main()
{
    int A, B, C, X;
    cin >> A >> B >> C >> X;


    int ans = 0;
    for( int i = 0; i <= A; ++i ){
        if( X < 500*i ) break;

        for( int j = 0; j <= B; ++j ){
            if( X < 500*i + 100*j ) break;

            int zan = X - (500*i + 100*j);
            if( zan/50 <= C && zan%50 == 0 ){
                ++ans;
                // cout << "500*(" << i << ") + 100*(" << j << ") + 50*(" << zan/50 << ")" << endl;
            }
        }
    }


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;

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

	vector<int> primeList;
	primeList.push_back(2);
	primeList.push_back(3);
	for(long long i = 5; i <= 1000001; i += 2) {
		bool isPrime = true;
		for(const auto &x : primeList) {
			if(i * i > x) {
				break;
			}
			if(i % x == 0) {
				isPrime = false;
				break;
			}
		}
		if(isPrime) {
			primeList.push_back(i);
		}
	}

	unordered_map<int, int> factor;
	long long n = N;
	for(const auto &x : primeList) {
		factor[x] = 0;
		while(n % x == 0) {
			n /= x;
			factor[x]++;
		}
		if(n == 1) {
			break;
		}
	}

	int result = 0;
	if(n != 1) {
		result++;
	}
	for(const auto &x : factor) {
		int work = x.second;
		int need = 1;
		while(work >= need) {
			work -= need;
			need++;
			result++;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 24800
#include<stdio.h>
int main() {
 char s[3];
 int counta=0,countb=0;
  for(int i=0;i<3;i++){
    scanf("%c",&s[i]);
    if(s[i]=='A'){
      counta++;
    }else if(s[i]=='B'){
      countb++;
    }
  }
  
  if((counta==3)||(countb==3)){
  	printf("No");
  }else{
  	printf("Yes");
  }
  
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

signed main(){
    int N, M;
    cin >> N >> M;
    priority_queue<int> price;
    rep(i,N){
        int p; cin >> p;
        price.push(p);
    }
    rep(i,M){
        int p = price.top();
        price.pop();
        price.push(p/2);
    }
    int res = 0;
    while(!price.empty()){
        res += price.top();
        price.pop();
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int w;
	cin >> w;
	cout << w * 32 << endl;

	return 0;
}

Measured memory_bytes: 3088
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = B*1
B.append(0)
B.append(0)

ans = 0
tamari = 0
for i in range(N+1):
  if A[i] <= tamari:
    ans += A[i]
    tamari = B[i]
  elif A[i] <= tamari + B[i]:
    ans += A[i]
    tamari = tamari+B[i]-A[i]
  else: #倒しきれない
    ans += tamari + B[i]
    tamari = 0
    
    
print(ans)

Measured memory_bytes: 18476
#define _CRT_SECURE_NO_WARNINGS
#define MOD 1000000007
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <functional>
#include <algorithm>
#include <iterator>
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <cmath>
#include <chrono>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef pair<ll, ll> P;
struct edge { ll to, cost; };

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

inline ll madd(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a + b) % MOD;
}
inline ll msub(ll a, ll b) {
	a %= MOD;b %= MOD;
	a += MOD;
	return (a - b) % MOD;
}
inline ll mmul(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a*b) % MOD;
}
inline ll mpow(ll a, ll r) {
	long long res = 1;
	while (r > 0) {
		if (r & 1) res = res * a % MOD;
		a = a * a % MOD;
		r >>= 1;
	}
	return res;
}
inline ll minv(ll a) {
	a %= MOD;
	ll b = MOD, u = 0, v = 1;
	while (a) {
		ll t = b / a;
		b -= t * a; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if (u < 0) u += MOD;
	return u;
}
inline ll mdiv(ll a, ll b) {
	a %= MOD;
	a *= minv(b);
	return a%MOD;
}

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

/*int V;
vector<edge> G[MAX_V];
int d[MAX_V]:
void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P>> q;
	fill(d, d + V, INF);


}*/


ll combi[2001][2001];

int main(void) {
	ll n, k;
	cin >> n >> k;
	REP(i, 2001) combi[0][i] = 1;
	FOR(i, 1, 2001) {
		REP(j, i + 1) {
			if (j == 0 || j == i) combi[i][j] = 1;
			else combi[i][j] = madd(combi[i - 1][j - 1], combi[i - 1][j]);
		}
	}
	REP(i, k) {
		cout << mmul(combi[n - k + 1][i + 1], combi[k-1][i]) << endl;
	}
}


Measured memory_bytes: 30080
from sys import stdin

n,q = map(int,input().split(" "))

list2 = [[] for _ in range(n)]

for i in range(q):
	cmd = stdin.readline().strip().split()

	t = int(cmd[1])
	if cmd[0] == "0":
		list2[t].append(cmd[2])
	elif cmd[0] == "1":
		if len(list2[t]) != 0:
			print(list2[t][-1])
	else:
		if len(list2[t]) != 0:
			list2[t].pop()



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

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

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

        if x == y:
            return

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

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

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

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

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

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

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

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

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

N, Q = map(int,input().split())
uf = UnionFind(N)

for i in range(Q):
    tuv = list(input().split())
    if tuv[0] == "0":
        uf.union(int(tuv[1]), int(tuv[2]))
    else:
        if uf.same(int(tuv[1]), int(tuv[2])):
            print(1)
        else:
            print(0)

Measured memory_bytes: 83048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG
int main(){
  ll K; cin>>K;
  ll A,B; cin>>A>>B;
  bool judge=false;
  rep(i,B-A+1){
    if((A+i)%K==0) judge =true;
    else continue;
  }
  if(judge) cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

signed main() {
    ll n, m, k;
    cin >> n >> m >> k;
    ll a[n], b[m];
    ll sa[n + 1] = {}, sb[m + 1] = {};
    rep (i, 0, n) {
        cin >> a[i];
        sa[i + 1] = sa[i] + a[i];
    }
    rep (i, 0, m) {
        cin >> b[i];
        sb[i + 1] = sb[i] + b[i];
    }
    ll ans = 0;
    rep (i, 0, n + 1) {
        if (sa[i] > k) break;
        ll now = k - sa[i];
        auto itr = lower_bound (sb, sb + m + 1, now);
        ll sum = itr - sb;
        if (itr == sb + m + 1) sum--;
        else if (now < *itr)
            sum--;
        // cout << sum + i << "\n";
        ans = max (ans, sum + i);
    }
    cout << ans << "\n";
}


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

#define se second
#define fi first
#define mk(a,b) make_pair(a,b)

typedef long long ll;
typedef pair<int,int> pii;

ll K;
int D[100010] = {0};
vector<pii> G[100010];
priority_queue<pii, vector<pii>, greater<pii> > Q;

int main()
{
    scanf("%lld",&K);

    for(int i = 0; i < K; i++)
    {
        G[i].push_back(mk((int)((i + 1) % K),1));
        G[i].push_back(mk((int)(i * 10 % K),0));
    }

    Q.push(mk(1,1));
    while(Q.size())
    {
        pii now = Q.top();
        Q.pop();
        if(D[now.se] != 0)continue;
        D[now.se] = now.fi;

        for(int i = 0; i < G[now.se].size(); i++)Q.push(mk(now.fi + G[now.se][i].se,G[now.se][i].fi));
    }
    printf("%d\n",D[0]);
    return 0;
}


Measured memory_bytes: 7284
#include<stdio.h>
#include<string.h>

int main(void){
    int n,i,j,a[101],p[101],pos,apos;
    scanf("%d",&n);
    char s[101][101];
    char temps[11];
    for(i=0;i<n;i++){
        scanf("%s %d",s[i],&p[i]);
        a[i]=i;
    }
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            if(strcmp(s[j],s[i])<0){
                strcpy(temps,s[i]);
                strcpy(s[i],s[j]);
                strcpy(s[j],temps);
                
                pos = p[i];
                p[i]=p[j];
                p[j]=pos;
                
                apos = a[i];
                a[i] =a[j];
                a[j]=apos;
            }else if(strcmp(s[j],s[i])==0){
                if(p[j]>p[i]){
                    strcpy(temps,s[i]);
                    strcpy(s[i],s[j]);
                    strcpy(s[j],temps);
                    
                    pos = p[i];
                    p[i]=p[j];
                    p[j]=pos;
                    
                    apos = a[i];
                    a[i] =a[j];
                    a[j]=apos;
                }
            }
        }
    }
    for(i=0;i<n;i++){
        printf("%d\n",a[i]+1);
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,k,h[101010],dp[101010];
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>h[i];
	}
	for(int i=0;i<n;i++)
	{
		dp[i]=1e9;
	}
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++)
	{
		for(int j=1;j<=min(i,k);j++)
		{
			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
N = int(input())

l = len(str(10**9))
def dfs(A):#配列Aからできる753数
    global N
    if len(A)>0 and(int("".join(map(str, A)))>N):
        return 0
    
    ans = 0
    if(all(A.count(i)==0 for i in [0, 1, 2, 4, 6, 8, 9]) and (A.count(3) >0 and A.count(5) >0 and A.count(7) >0)):
        ans = ans + 1
    
    for i in [3, 5, 7]:
        A.append(i)
        ans = ans + dfs(A)
        A.pop()
    
    return ans
print(dfs([]))


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
int n,W;
signed main(){
  cin>>n>>W;
  int hoge=500;
  vector<int> w(n);
  vector<int> v(n);
  rep(i,n)cin>>w[i]>>v[i];
  int b=w[0]-1;
  rep(i,n)w[i]-=b;
  vector<vector<vector<int>>> dp(n,vector<vector<int>>(hoge+10,vector<int>(n+1,0)));
  dp[0][w[0]][1]=v[0];
  rep1(i,hoge-1){
    dp[0][i][1]=v[0];
  }
  for(int i=1;i<n;++i){
    for(int j=0;j<hoge;++j){
      for(int k=1;k<=n;++k){
        if(j-w[i]>=0)dp[i][j][k]=max(dp[i-1][j][k],dp[i-1][j-w[i]][k-1]+v[i]);
        else dp[i][j][k]=dp[i-1][j][k];
      }
    }
  }
  int res=0;
  rep1(i,n){
    int buf=min(W-b*i,hoge-1);
    if(buf<0)continue;
    res=max(res,dp[n-1][buf][i]);
  }
  cout<<res<<"\n";
  return 0;
}


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

using namespace std;
using LL = long long;

const int MOD = 1e9+7;

class Edge{
public:
    LL from,to, value;
    Edge(int f,int t, int c){
        from = f;
        to = t;
        value = c;
    }
};

int main(){
    int N;cin >> N;
    for(int i = 1;i <= 9;i++){
        for(int j = 1;j <= 9;j++){
            if(i * j == N){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
N,Q = map(int,input().split())
S = input()
s = [0]

for i in range(N):
  s.append(s[-1]+(1 if S[i:i+2]=='AC' else 0))

for i in range(Q):
  l,r=map(int,input().split())
  print(s[r-1]-s[l-1])

Measured memory_bytes: 7688
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Integer n = sc.nextInt();
		int k = sc.nextInt();
		List<Integer> d = new ArrayList<>();
		for (int i=0;i < k;i++) d.add(sc.nextInt());

        while (true) {
			boolean flag = true;
			String nStr = n.toString();
			int[] amt = new int[nStr.length()];
			for (int i=0;i < nStr.length();i++) {
				amt[i] = Integer.parseInt(nStr.substring(i,i+1));
			}
			for (int c : amt) {
				if (d.contains(c)) {
					flag = false;
					break;
				}
			}
			if(flag) {
				System.out.println(n);
				break;
			}
			n++;
		}
	}
}

Measured memory_bytes: 38608
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>

using namespace std;

#define dirmax 8
int l[2];
int dir[8][2] = { {0,1}, {1,0}, {-1,0}, {0,-1}, {1,1}, {-1,1}, {1,-1}, {-1,-1} };
string ans;

void search( set<string> *v, int pos[2] , char ch[10][20]){

	for(int i = 0; i < dirmax; i++) {
		string str;
		int cpos[] = { pos[0], pos[1] };

		str += ch[pos[0]][pos[1]];

		while( 1 ) {
			for(int j = 0; j < 2; j++) {
				cpos[j] += dir[i][j];
				if( cpos[j] < 0 ) cpos[j] = l[j] - 1;
				if( cpos[j] >= l[j] ) cpos[j] = 0;
			}
			if( cpos[0] == pos[0] && cpos[1] == pos[1] ) break;
			str += ch[cpos[0]][cpos[1]];
			
			if( v->find(str) != v->end() )
				if( ( str.length() > ans.length() ) || ( str.length() == ans.length() && str < ans ) )
					ans = str;
			v->insert(str);
		}
	}
}

int main(void){
	while(1){
		cin >> l[0] >> l[1];
		if( l[0] == 0 && l[1] == 0 ) break;
		char donut[10][20];
		ans = "";

		set< string > strs;

		//入力を取得する
		for(int i = 0; i < l[0]; i++) {
			string str;
			cin >> str;
			for(int j = 0; j < l[1]; j++){
				donut[i][j] = str[j];
			}
		}

		for(int i = 0; i < l[0]; i++) {
			for(int j = 0; j < l[1]; j++) {
				int pos[2];
				pos[0] = i;
				pos[1] = j;
				search( &strs, pos, donut );
			}
		}

		if(ans == "") 
			cout << 0 << endl;
		else 
			cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 33764
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#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;

#define _int64 long long

vector<int> a[110000];
int used[110000];
int ch[110000];
int p[110000];

int main()
{
  int i,j,n,x,y;
  vector<int> q;
  vector<int> qq;
  scanf("%d",&n);
  if (n==1)
  {
    printf("First\n");
    return 0;
  }
  for (i=0;i<n;i++)
    a[i].clear();
  for (i=0;i+1<n;i++)
  {
    scanf("%d%d",&x,&y);
    x--;y--;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  memset(used,0,sizeof(used));
  memset(ch,0,sizeof(ch));
  q.clear();
  q.push_back(0);
  used[0]=1;
  p[0]=-1;
  for (i=0;i<q.size();i++)
  {
    x=q[i];
    for (j=0;j<a[x].size();j++)
    {
      if (used[a[x][j]]==0)
      {
        p[a[x][j]]=x;
        q.push_back(a[x][j]);
        used[a[x][j]]=1;
        ch[x]++;
      }
    }
  }
  memset(used,0,sizeof(used));
  qq.clear();
  for (i=0;i<n;i++)
    if (ch[i]==0) qq.push_back(i);
  for (i=0;i<qq.size();i++)
  {
    x=qq[i];
    y=p[x];
    //cout<<x<<" "<<y<<endl;
    if ((y==-1)||(used[y]==1))
    {
      printf("First\n");
      return 0;
    }
    used[x]=1;
    used[y]=1;
    if (p[y]!=-1)
    {
      ch[p[y]]--;
      if (ch[p[y]]==0)
      {
        qq.push_back(p[y]);
      }
    }
  }
  printf("Second\n");
  return 0;
}

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

using namespace std;

map<char, bool>cbMap;

int main() {
	int n;
	scanf("%d", &n);
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		char buff[5];
		scanf("%s", buff);
		if (!cbMap[buff[0]]) ans++;
		cbMap[buff[0]] = true;
	}
	printf("%s\n", ans == 3 ? "Three" : "Four");
	return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const ll  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1000000007;

/*vll adj[MAXN];ll visit[MAXN]={};
ll dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m,k,d,w;
string s,t;
//vll a,b;
// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN(ll _) {
	vll a(3);
	cin>>a[0]>>a[1]>>a[2];
	sort(all(a));
	cin>>k;
	cout<<(a[0]+a[1]+((ll)pow(2,k))*a[2]);
}

int main() {
	fastio;randomINT;
	//cin>>T;
	for(ll i=1;i<=T;i++) {
		MAIN(i);
	}
	return 0;
}



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

int main() {
  int a,b,c,d;
  string ans;
  cin >> a >> b >> c >> d;
  if(a+b == c+d){
    ans = "Balanced";
  }
  else if(a+b > c+d){
    ans = "Left";
  }else{
    ans = "Right";
  }
  cout << ans << endl;
}

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

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N,K;
vector <int > H;
string s;




int main()
{
	cin >> s;

	REP(i,s.length()){
		if(!(i%2))
			cout << s[i];
	}





}

Measured memory_bytes: 512
x1,y1,x2,y2 = map(int, input().split())
dx = x2-x1
dy = y2-y1
res = [x1-dy+dx, y1+dx+dy, x1-dy, y1+dx]
res_s = [str(r) for r in res]
ans = " ".join(res_s)
print(ans)

Measured memory_bytes: 9076
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int x; cin>>x;
    if (x < 600) {
        cout << 8 << '\n';
    }
    else if (x < 800) {
        cout << 7 << '\n';
    }
    else if (x < 1000) {
        cout << 6 << '\n';
    }
    else if (x < 1200) {
        cout << 5 << '\n';
    }
    else if (x < 1400) {
        cout << 4 << '\n';
    }
    else if (x < 1600) {
        cout << 3 << '\n';
    }
    else if (x < 1800) {
        cout << 2 << '\n';
    }
    else if (x < 2000) {
        cout << 1 << '\n';
    }
    return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;

const int MOD = 1e9 + 7;


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

    int n;
    cin >> n;

    string s, t, ans;
    cin >> s >> t;


    rep(i, n){
        ans += s[i];
        ans += t[i];
    }

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



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

int main () 
{
    int High, Width;
    
    while (1)
    {
        std::cin >> High >> Width;
        
        if (High == 0 && Width == 0) break;
        
        for (int i = 0; i < High; i++) 
        {
            for (int j = 0; j < Width; j++) 
            {
                if ( (i + j) % 2 == 0)
                {
                    std::cout << "#";
                }
                else
                {
                    std::cout << ".";
                }
            }
            
            std::cout << std::endl;
        }
        
        std::cout << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 3068
using System;
namespace kozaiyApp
{
    public class A
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            int S = int.Parse(input[0]);
            int W = int.Parse(input[1]);

            if (S <= W)
            {
                Console.WriteLine("unsafe");
            }
            else
            {
                Console.WriteLine("safe");
            }
        }
    }
}


Measured memory_bytes: 27512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

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

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define LEN 100005

typedef struct pp {
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue(){
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b) {return a < b ? a : b ;}

int main() {
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d%d",&n,&q);
    for (i = 1; i <= n; i++) {
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head = 1;
    tail = n + 1;
    while(head != tail){
        u = dequeue();
        c = min(q,u.t);
        u.t -= c;
        elaps += c;
        if (u.t > 0) enqueue(u);
        else {
            printf("%s %d\n",u.name, elaps);
        }
    }
    return 0;
}



Measured memory_bytes: 11920
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
  int n, a, b ;
  cin >> n >> a >> b ;
  int ans = 0 ;
  FOR(i,1,n+1){
    int c = 0 ;
    c = i/10000+i%10000/1000+i%1000/100+i%100/10+i%10 ;
    if(a<=c && c<=b){
      ans += i ;
    }
  }
  
  cout << ans <<endl ;
    
    

  return 0 ;
}




Measured memory_bytes: 256