akhauriyash/Code-Regression huggingface dataset:
a = int(input())
ar = [a]
i = 2
while True:
    if a % 2 == 0:
        a /= 2
    else:
        a *= 3
        a += 1
    if a in ar:
        print(i)
        exit()
    else:
        ar.append(a)
        i += 1

Measured memory_bytes: 2940
import java.io.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    InputReader cin = new InputReader(System.in);
    PrintWriter cout = new PrintWriter(System.out);

    Task task = new Task();
    task.run(cin, cout);

    cout.close();
  }
}

class Task {
  void run(InputReader cin, PrintWriter cout) {
    int n = cin.nextInt();
    int l = cin.nextInt();
    int[] a = new int[n];

    for (int i = 0; i < n; ++i) {
      a[i] = cin.nextInt();
    }

    int p = 0;
    for (int i = 1; i < n; ++i) {
      if (a[i-1] + a[i] >= l) {
        p = i;
        break;
      }
    }

    if (p == 0) {
      cout.printf("Impossible\n");
    } else {
      cout.printf("Possible\n");
      for (int i = 1; i < p; ++i) {
        cout.println(i);
      }
      for (int i = n-1; i >= p+1; --i) {
        cout.println(i);
      }
      cout.println(p);
    }
  }
}

class InputReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  private int BUFFER_SIZE = 32768;

  public InputReader(InputStream stream) {
    reader = new BufferedReader(new InputStreamReader(stream), BUFFER_SIZE);
    tokenizer = null;
  }

  public boolean hasNext() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      String line;
      try {
        line = reader.readLine();
        if (line == null) {
          return false;
        }
        tokenizer = new StringTokenizer(line);
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
    return true;
  }

  public String next() {
    if (!hasNext()) {
      return null;
    }
    return tokenizer.nextToken();
  }

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


Measured memory_bytes: 43984
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,m,ans,sum,a[N],b[N];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	n=read();m=read();
	if((n%m)==0){cout<<0;return 0;}
	cout<<min(n%m,abs(n%m-m));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef pair<P,double> C;
typedef pair<P,P> L;

const double eps=1e-8;

bool eq(double a,double b){
  return -eps<a-b&&a-b<eps;
}

double cross(P a,P b){
  return imag(b*conj(a));
}

bool isCrossCC(C a,C b){
  double ar=a.second, br=b.second;
  double dist=abs(a.first-b.first);
  if( dist > ar+br+eps)return false;
  if( dist > ar+br-eps )return true;
  if( dist > abs(ar-br)+eps)return true;
  if( dist > abs(ar-br)-eps)return true;
  return false;
}

double Sqrt(double x){
  if(x<0)return 0;
  return sqrt(x);
}

P reflect(P a,P b,P c){
  b-=a;
  c-=a;
  return a+ conj(c/b)*b;
}

P getCrossCC(C a,C b){
  P p1=a.first,p2=b.first;
  double r1=a.second, r2=b.second;
  double cA = (r1*r1+norm(p1-p2)-r2*r2) / (2.0*r1*abs(p1-p2));
  return p1+(p2-p1)/abs(p1-p2)*r1*P(cA, Sqrt(1.0-cA*cA) );
}

int n;
int t[15];
int u[6];
bool used[15];
double ans=-1;

double calcArea(double a,double b,double c){
  P p1=P(0,0);
  P p2=P(b,0);
  P p3=getCrossCC( C(p1,a) , C(p2,c) );
  return abs( cross( p1-p3 , p2-p3 )*0.5 );
}

P getCrossLL(L line0,L line1){
  P a=line0.first, b=line0.second;
  P c=line1.first, d=line1.second;
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

bool check(int a,int b,int c){
  if(a<b)swap(a,b);
  if(b<c)swap(b,c);
  if(a<b)swap(a,b);
  return ( a < b + c );
}


void check(){

  
  double S=calcArea(u[0],u[1],u[2]);

  double h=1e9;
  
  C ca = C( P(0,0) , u[4] );
  C cb = C( P(u[1],0) , u[5] );
  C cc = C( getCrossCC( C(ca.first,u[0]) , C(cb.first,u[2]) ) , u[3] );

  if( isCrossCC(ca,cb) == false )return;
  if( isCrossCC(cc,cb) == false )return;
  if( isCrossCC(ca,cc) == false )return;
  
  L fi  = L( getCrossCC(ca,cb) , getCrossCC(cb,ca) );
  if( abs(fi.second-fi.first ) < eps )return;
  
  L se  = L( getCrossCC(cc,ca) , getCrossCC(ca,cc) );
  if( abs(se.second-se.first ) < eps )return;
  

  L th = L( getCrossCC(cc,cb) , getCrossCC(cb,cc) );
  
  P target=getCrossLL(fi,se);

  P target2 = getCrossLL( th,se);
  if( abs(target-target2) > eps )return;
  
  double di;
  
  di=abs(P(0,0)-target);
  double Ah=min(h, Sqrt(u[4]*u[4]-di*di) );

  di=abs(P(u[1],0)-target);
  double Bh=min(h, Sqrt(u[5]*u[5]-di*di) );

  di=abs(cc.first-target);
  double Ch=min(h, Sqrt(cc.second*cc.second-di*di) );
  if( !eq(Ah,Ch) )return;
  if( !eq(Ah,Bh) )return;
  if( !eq(Bh,Ch) )return;
  h=min( Ah, Bh);
  h=min( h, Ah);

  ans=max(ans, h*S/3.0);
}

void dfs(int cnt){
  if(cnt>=3 && !check(u[0],u[1],u[2]))return;
  if(cnt>=5 && !check(u[0],u[3],u[4]))return;
  if(cnt>=6 && !check(u[1],u[4],u[5]))return;
  if(cnt>=6 && !check(u[2],u[3],u[5]))return;
  
  if(cnt==6){
    check();
  }else{
    for(int i=0;i<n;i++){
      if(used[i])continue;
      used[i]=true;
      u[cnt]=t[i];
      dfs(cnt+1);
      used[i]=false;
    }
  }
}

int main(){
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    
    for(int i=0;i<n;i++){
      scanf("%d",&t[i]);
    }

    sort(t,t+n);
    
    memset(used,false,sizeof(used));
    ans=-1;
    dfs(0);
    printf("%.10f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 3324
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n,m;
    cin >> n >> m;
    pair<int,bool> box[n];
    for(int i = 0;i < n;i++)
    {
        box[i].first = 1;
        box[i].second = false;
    }
    box[0].second = true;
    for(int i = 0;i < m;i++)
    {
        int x,y;
        cin >> x >> y;
        box[x - 1].first--;
        box[y - 1].first++;
        if(box[x - 1].second)
        {
            box[y - 1].second = true;
            if(box[x - 1].first == 0)
            {
                box[x - 1].second = false;
            }
        }
    }
    int ans = 0;
    for(int i = 0;i < n;i++)
    {
        if(box[i].second)
        {
            ans++;
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 1024
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	cin >> N >> M;
	vector<long long int>by(N * 3 + M * 3 + 1, 1);
	vector<long long int>rev(N * 3 + M * 3 + 1, 1);
	for (int i = 1; i <= (N + M) * 3; i++) {
		by[i] = by[i - 1] * i;
		by[i] %= MOD;
		rev[i] = power(by[i], MOD - 2, MOD);
	}
	long long int ans = by[M * 3 + N - 1];
	ans *= rev[N - 1];
	ans %= MOD;
	ans *= rev[M * 3];
	ans %= MOD;
	//cout << ans << endl;
	for (int i = M * 3; i > M * 2; i--) {
		long long int minus = N;
		minus *= by[M * 3 - i + N - 2];
		minus %= MOD;
		minus *= rev[N - 2];
		minus %= MOD;
		minus *= rev[M * 3 - i];
		minus %= MOD;
		ans += MOD - minus;
		ans %= MOD;
	}
	//cout << ans << endl;
	for (int i =  M + 1; i <= min(3 * M, N); i ++) {
		long long int minus = by[N];
		minus *= rev[i];
		minus %= MOD;
		minus *= rev[N - i];
		minus %= MOD;
		long long int num = M * 3 - i;
		if (num & 1)continue;
		num /= 2;
		minus *= by[num + N - 1];
		minus %= MOD;
		minus *= rev[num];
		minus %= MOD;
		minus *= rev[N - 1];
		minus %= MOD;
		ans += MOD - minus;
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 70528
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N;
	cin >> N;
	if (N == 1000000000000000000) cout << 0 << " " << 0 << " " << 1000000000 << " " << 0 << " " << 0 << " " << 1000000000 << endl;
	else cout << 0 << " " << 0 << " " << 1000000000 << " " << 1 << " " << 1000000000 - N % 1000000000 << " " << N / 1000000000 + 1 << endl;
}

Measured memory_bytes: 256
N,Y = map(int,input().split())

Y //= 1000

# 10a+5b+c = y
# a+b+c = n

answer = [-1,-1,-1]
for c in range(Y%5, N+1, 5):
  x = (Y - c) // 5
  # a+b=N-c, 2a+b=x
  a = x - (N-c)
  b = 2*(N-c)-x
  if a < 0:
    continue
  if b < 0:
    continue
  answer = [a,b,c]
  break

print(*answer)

Measured memory_bytes: 3064
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint hani(vector<int>&in,int L,int R){return UBI(in,R)-LBI(in,L);}
bool solve(string S,string T,int W,int sta){
	//LRときます
	sta--;
	//0未満かW以上になるならfalseを返します
	int hi=0,mg=W-1,n=S.size();
	for(int i=n-1;i>=0;i--){
		if(T[i]=='L'){mg++;}
		if(T[i]=='R'){hi--;}
		if(mg>=W){mg=W-1;}
		if(hi<0){hi=0;}
		if(S[i]=='L'){hi++;}
		if(S[i]=='R'){mg--;}
		if(hi>mg){return false;}
		//cerr<<hi<<" "<<mg<<endl;
	}
	if(sta<hi||mg<sta){return false;}
	return true;
}
int main(void){
	//LR,UDで独立です。
	int i,n,sr,sc,H,W;cin>>H>>W>>n>>sr>>sc;
	string S,T;cin>>S>>T;
	if(!solve(S,T,W,sc)){cout<<"NO"<<endl;return 0;}
	for(i=0;i<n;i++){
			 if(S[i]=='L'){S[i]='U';}
		else if(S[i]=='U'){S[i]='L';}
		else if(S[i]=='R'){S[i]='D';}
		else if(S[i]=='D'){S[i]='R';}
		
			 if(T[i]=='L'){T[i]='U';}
		else if(T[i]=='U'){T[i]='L';}
		else if(T[i]=='R'){T[i]='D';}
		else if(T[i]=='D'){T[i]='R';}
	}
	if(!solve(S,T,H,sr)){cout<<"NO"<<endl;return 0;}
	cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
#define rank __RANK
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
const int maxn = 4005;
const int mod = 1e9+7;
int fac[maxn],inv[maxn],n,k;
inline int qpow(int a,int b){
	int ans=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1) ans=1ll*ans*a%mod;
	return ans;
}
inline int C(int x,int y){
	return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}
inline int calc(int x,int y){
	if(y<0) return 0;
	return C(x+y,x);
}
int main(){
	n = rd(),k = rd();
	if(n==1&&k==1) return puts("1"),0;
	fac[0] = 1;
	Rep(i,1,n+k) fac[i] = 1ll * fac[i-1] * i % mod;
	inv[n+k] = qpow(fac[n+k],mod-2);
	Dep(i,n+k-1,0) inv[i] = 1ll * inv[i+1] * (i+1) % mod;
	ll ans = calc(n,k-1)-2*calc(n,k-2);
	Rep(i,1,n-k-1)ans=ans*2%mod;
	ans %= mod;
	ans = (ans + mod) % mod;
	writeln(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
 
#define mod 1000000007
long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    for(int i = 0;;i++){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
        if(temp == 0) break;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (((a*b)%mod)*(exp(ebob(a,b), (ll)mod-2))) % mod;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int a, b; cin>>a>>b;
	vector<ll> vec(a);
	for(int i = 0; i < a; i++){
		cin>>vec[i];
	}
	sort(vec.begin(), vec.end());
	ll res = 0;
	for(int i = 0; i < a-b; i++){
		res += vec[i];
	}
	cout<<res;
	return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int  s, w;
    cin >> s >> w;
    if(w>=s)
        cout << "unsafe";
    else
        cout << "safe";
    return 0;
}



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

int main(){
  int h, w; cin >> h >> w;
  string s;
  for(int i=0; i<h*w; i++){
    cin >> s;
    if(s == "snuke"){
      cout << char('A' + i%w) << i/w + 1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define int ll
    #define M 1000000007
    #define hell 998244353
    #define inf 1e18
    #define pb push_back
    #define pi 3.1415926536
    #define mp make_pair
    #define ub upper_bound
    #define lb lower_bound
    #define all(a) a.begin(),a.end()
    #define ll long long
    #define vec vector <int>
    #define pii pair<int,int>
    #define endl "\n"
    #define gcd __gcd
    using namespace std;
    int power(int x, unsigned int y, unsigned int m) 
    { 
        if (y == 0) 
            return 1; 
        int p = power(x, y/2, m) % m; 
        p = (p * p) % m; 
  
        return (y%2 == 0)? p : (x * p) % m; 
    } 
    int modInverse(int a, int m) 
    {   
        return power(a, m-2, m);
    }
    int nCrModPFermat(int n, int r, int p) 
    { 
           if (r==0) 
              return 1; 
  
        int fac[n+1]; 
        fac[0] = 1; 
        for (int i=1 ; i<=n; i++) 
            fac[i] = fac[i-1]*i%p; 
  
        return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
    } 
    signed main()
    {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        ll t=1;
        // cin >> t;
        /*SAARE INPUTS LENA*/
        /*VARIABLES KI RANGE DEKHLENA*/
        /*EXPONENT RANGE OF OUTPUT KA DHYAN RAKHNA*/
        while(t-->0)
        {
            ll n=0,W=0,v=0;
            cin>>n>>W;
            int val[n],weight[n];
            for (int i = 0; i < n; ++i)
            {
                cin>>weight[i]>>val[i];
                v+=val[i];
            }
            // vector <int> dp(v+1,inf);
            int dp[n+1][v+1];
            // dp[0]=0;
            for (int i = 0; i <=n; ++i)
                for(int j=0;j<=v;j++)
                    if(j==0)
                        dp[i][j]=0;
                    else
                        dp[i][j]=inf;
            for (int i = 1; i <=n; ++i)
                for(int j=1;j<=v;j++)
                    if(val[i-1]<=j)
                        dp[i][j]=min(weight[i-1]+dp[i-1][j-val[i-1]],dp[i-1][j]);
                    else
                        dp[i][j]=dp[i-1][j];
                
            int ans=0;
            for (int i = v; i >=0 ; --i)
            {
                if(dp[n][i]<=W)
                {
                    ans=i;
                    break;
                }
            }
            cout<<ans;
        }
        return 0;
    }

Measured memory_bytes: 82504
#include <cmath>
#include <iomanip>
#include <iostream>

using namespace std;
using ld = long double;

constexpr ld rad2pi = 180.l / 3.14159265359l;
int main() {
  ld a, b, x, ans;
  cin >> a >> b >> x;
  if (x < a * a * b / 2) {
    ans = atan(a * b * b / 2 / x) * rad2pi;
  } else {
    ans = atan(2 * b / a - 2 * x / a / a / a) * rad2pi;
  }
  cout << fixed << setprecision(10) << ans << endl;
}


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

typedef long long ll;

int main() {
    ll pos = -1;
    string s;
    cin >> s;
    ll ans = 0;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'W') {
            pos++;
            ans += i-pos;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let cond = buf
        .trim()
        .split(' ')
        .map(|x| x.parse::<i32>().unwrap())
        .fold(1, |res, x| res * x)
        % 2
        == 0;
    if cond {
        println!("Even");
    } else {
        println!("Odd");
    }
}


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

#define ll long long
#define MOD 1000000007

string s;
ll n, d;
ll dp[10010][110][2];

ll add(ll a, ll b)
{
    return (a + b) % MOD;
}

int main()
{
    cin >> s >> d;
    n = s.size();
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < d; j++) {
            for (int k = 0; k < 10; k++) {
                for (int l = 0; l < 2; l++) {
                    if (l == 0 && k > s[i - 1] - '0') continue;
                    if (l == 0 && k < s[i - 1] - '0') dp[i][(j + k) % d][1] = add(dp[i][(j + k) % d][1], dp[i - 1][j][0]);
                    else dp[i][(j + k) % d][l] = add(dp[i][(j + k) % d][l], dp[i - 1][j][l]);
                }
            }
        }
    }

    ll sol = 0;
    sol = add(sol, dp[n][0][0]);
    sol = add(sol, dp[n][0][1]);
    if (sol == 0) cout << MOD - 1;
    else cout << sol - 1;



//    cout << "\n";
//    for (int i = 1; i <= n; i++) {
//        for (int j = 0; j < d; j++) {
//            for (int l = 0; l < 2; l++) {
//                cout << dp[i][j][l] << " ";
//            }
//            cout << " | ";
//        }
//        cout << "\n";
//    }
}


Measured memory_bytes: 20796
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

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

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

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

// generated by online-judge-template-generator v4.4.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
  int M;
  int H, W;
  std::cin >> H >> W >> M;
  vector<int> ch(H, 0);
  vector<pair<int, int>> cw(W, {0, 0});
  set<pair<int, int>> s;
  REP(i, W) { cw[i].second = i; }
  for (int i = 0; i < M; ++i) {
    int h, w;
    std::cin >> h >> w;

    h--;
    w--;
    ch[h]++;
    cw[w].first++;
    s.insert({h, w});
  }

  int ans = 0;
  for (const auto [i, j] : s) {
    chmax(ans, ch[i] + cw[j].first - 1);
  }

  sort(cw.rbegin(), cw.rend());

  REP(i, H) {
    REP(j, W) {
      if (!s.count({i, cw[j].second})) {
        chmax(ans, ch[i] + cw[j].first);
        break;
      }
    }
  }

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


Measured memory_bytes: 20924
#include <stdio.h>

int main () {
  int N;
  scanf("%d",&N);
  char *str[] = {"hon","pon","bon"};
  
  switch(N%10){
    case 0:
    case 1:
    case 6:
    case 8:
      printf("%s",str[1]);
      break;
    case 3:
      printf("%s",str[2]);
      break;
    default:
      printf("%s",str[0]);
      break;
  }
  return 0;
}


Measured memory_bytes: 1728
//abc091.cpp
//Sun Mar 25 15:16:05 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;

int main(){
	int x;
	int y;
	int z;
	cin >> x;
	cin >> y;
	cin >> z;

	if (x+y>=z){
	cout << "Yes" << endl;
	}else{
	cout << "No" << endl;
	}

}

Measured memory_bytes: 256
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		a[i]=s.nextInt();
		int max=a[0];
		int min=a[0];
		int count=1;
		for(int i=1;i<n;i++)
		{if(a[i]<=max && a[i]<min)
		{count++;min=a[i];}
		else
		{max=a[i];}}
		System.out.println(count);}}

Measured memory_bytes: 64756
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
int n,k,ans,x;
int main () {
    scanf ("%d%d",&n,&k);
    for (int i=1;i<=n;i++) {
		scanf ("%d",&x);
		if (x<=k/2)
			ans+=x*2;
		else
			ans+=(k-x)*2;
	}
	printf ("%d\n",ans);
	return 0;
} 

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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");
#define FOR(i, l, r) for (int i = int(l); i < int(r); ++i)

int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}

vi vis(100001,0);
vi adj[100001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //srand(time(0));
    //cin.tie(NULL);
    //cout.tie(NULL);
    ll n,l;
    cin>>n>>l;
    vl flav;
    ll sum=0;
    for(int i=1; i<=n; ++i)
    {
    	int x = (l+i-1);
    	flav.pb(x);
    	sum+=x;
    }
    //for(auto x : flav)
    //	cout<<x<<" ";
    //cout<<"\n";
   // cout<<sum<<"\n";
    ll mini=INT_MAX;
    for(auto x : flav)
    {
    	ll tempx = sum;
    	tempx-=x;
    	tempx=abs(sum-tempx);
    	//cout<<tempx<<"\n";
    	if(tempx<mini)
    		mini=tempx;
    	//cout<<mini<<"\n";
    }
    if(sum>0)
    	cout<<sum-mini<<"\n";
    else
    	cout<<sum+mini<<"\n";


}

Measured memory_bytes: 2944
#include <cstdio>

using namespace std;

typedef long long LL;

LL n, a, b, dist, ans;

int main() {
    scanf("%lld%lld%lld", &n, &a, &b);
    dist = b - a;
    ans = 0;
    if (dist & 1) {
        dist--;
        if (a - 1 < n - b) {
            ans = a;
        } else {
            ans = n - b + 1;
        }
    }
    printf("%lld\n", ans + dist / 2);
    return 0;
}

Measured memory_bytes: 128
a,b  = map(int,input().split())

# k = (b+a)/2
# if isinstance(k, int) != True:
#     print("IMPOSSIBLE") 
# else:
#     print(k)
if (b+a)%2 != 0:
    print("IMPOSSIBLE")
else :
    print(int((b+a)/2))

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



int main() {
    int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    
    ll sum = 0;
    vector<char> te(n);
    rep(i,n) {
        if(t[i] == 'r') {
            if(i >= k && te[i-k] == 'p') {
                if(i+k < n)
                    te[i] = t[i+k];
                else
                    te[i] = 'r';
            }
            else {
                te[i] = 'p';
                sum += p;
            }
        }
        else if(t[i] == 's') {
            if(i >= k && te[i-k] == 'r') {
                if(i+k < n)
                    te[i] = t[i+k];
                else
                    te[i] = 's';
            }
            else {
                te[i] = 'r';
                sum += r;
            }
        }
        else {
            if(i >= k && te[i-k] == 's') {
                if(i+k < n)
                    te[i] = t[i+k];
                else
                    te[i] = 'p';
            }
            else {
                te[i] = 's';
                sum += s;
            }
        }
    }
    
    cout << sum << endl;
    
    
    return 0;
}




Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define met(s) memset(s, 0, sizeof(s))
const int MOD = 100000007;
const int MAXN = 1000000;
const int inf = 0x3f3f3f3f;
int gcd(int a, int b)
{
	while (b)
	{
		int t = a;
		a = b;
		b = t % b;
	}
	return a;
}
int pre[100005], Next[100005], book[100005], n;
int main()
{
	//freopen("data.txt","r",stdin);
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &book[i]);
	}
	pre[0] = book[0];
	for (int i = 1; i < n; i++)
	{
		pre[i] = gcd(pre[i - 1], book[i]);
	}
	Next[n - 1] = book[n - 1];
	for (int i = n - 2; i >= 0; i--)
	{
		Next[i] = gcd(Next[i + 1], book[i]);
	}
	int ans = Next[1];
	//printf("%d\n", ans );
	for (int i = 1; i < n - 1; i++)
	{
		int now = gcd(pre[i - 1], Next[i + 1]);
		if (now > ans) ans = now;
	}
	if (pre[n - 2] > ans) ans = pre[n - 2];
	printf("%d\n", ans );
	return 0;
}

Measured memory_bytes: 1408
from typing import List


class Node:
    __slots__ = ['prev', 'next', 'data']

    def __init__(self, prev, next, data) -> None:
        self.prev = prev
        self.next = next
        self.data = data


def insert(x: int, cur: Node) -> Node:
    cur.prev.next = cur.prev = cur = Node(cur.prev, cur, x)
    return cur


def move(x: int, cur: Node) -> Node:
    if x > 0:
        for _ in range(x):
            cur = cur.next
    else:
        for _ in range(-x):
            cur = cur.prev
    return cur


def erase(cur: Node) -> Node:
    cur.next.prev = cur.prev
    cur.prev.next = cur = cur.next
    return cur


if __name__ == "__main__":
    num_query = int(input())
    root = Node(None, None, None)
    cur = root.next = Node(root, None, None)

    for _ in range(num_query):
        op, *value = map(lambda x: int(x), input().split())
        if (0 == op):
            cur = insert(value[0], cur)
        elif (1 == op):
            cur = move(value[0], cur)
        elif (2 == op):
            cur = erase(cur)
        else:
            pass

    ans: List[int] = []
    it = root.next
    while it.next:
        ans.append(it.data)
        it = it.next

    for elem in ans:
        print(elem)



Measured memory_bytes: 47328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1e9+7;
using P = pair<int, int>;
int main()
{
    int n, q;
    cin >> n >> q;
    multimap<int, P> m;
    for(int i = 0; i < n; i++)
    {
        int s, t, x;
        cin >> s >> t >> x;
        m.insert(make_pair(x, P(s, t)));
    }
    map<int, int> ans; // <time, distance>
    set<int> tm;
    for(int i = 0; i < q; i++)
    {
        int d;
        cin >> d;
        ans[d] = -1;
        tm.insert(d);
    }

    for(auto ite = m.begin(); ite != m.end(); ite++)
    {
        int x = ite->first;
        P p = ite->second;
        int s = p.first;
        int t = p.second;
        auto sit = tm.lower_bound(s-x);
        while(sit != tm.end() && *sit < t-x)
        {
            ans[*sit] = x;
            sit = tm.erase(sit);
        }
    }
    for(auto ite = ans.begin(); ite != ans.end(); ite++)
    {
        cout << ite->second << endl;
    }
}


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

int main()
{
    while (true)
    {

        int a, b;
        string op;
        cin >> a >> op >> b;

        if (op == "+")
        {
            cout << (a + b) << endl;
        }
        else if (op == "-")
        {
            cout << (a - b) << endl;
        }
        else if (op == "*")
        {
            cout << (a * b) << endl;
        }
        else if (op == "/")
        {
            cout << (a / b) << endl;
        }
        else if (op == "?")
        {
            break;
        }
    }
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,a,b,c;
  int d[1000];
  cin>>n>>a>>b>>c;
  for(int i=0;i<n;i++){
    cin>>d[i];
  }
  sort(d,d+n,greater<int>() );
  int maxs=c/a;
  for(int i=0;i<n;i++){
    a+=b;
    c+=d[i];
    maxs=max(maxs,c/a);
  }
  cout<<maxs<<endl;
}
    

Measured memory_bytes: 1176
#include <iostream>
using namespace std;
string S;
int main(){
  cin >> S;
  int N = S.size();
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      if(S[i]=='C' && S[j]=='F'){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100

int main( ){
  int i,j,k,v,m,n,u;
   int G[MAX][MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j] = 0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      G[u][v] = 1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j) printf(" ");
      printf("%d",G[i][j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2112
def examA():
    def calc_L(x1,y1,x2,y2):
        return ((x2-x1)**2 + (y2-y1)**2)**0.5
    N = I()
    X = [LI()for _ in range(N)]
    ans = 0
    for x in itertools.permutations(X):
        cur = 0
        for i in range(1,N):
            cur += calc_L(x[i-1][0],x[i-1][1],x[i][0],x[i][1])
        #print(x,cur)
        ans += cur
    for i in range(1,N+1):
        ans /= i
    print(ans)
    return

def examB():
    def judge(n):
        sn = 0
        for i in n:
            sn += int(i)
        if int(n)%sn==0:
            return "Yes"
        return "No"
    N = SI()
    ans = judge(N)
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examB()

"""

"""

Measured memory_bytes: 5360
n = int(input())
li = [list(map(int, input().split())) for i in range(n)] + [[0]*3]

dp = [[0 for i in range(3)] for j in range(n+1)]
for i in range(3):
    dp[0][i] = li[0][i]

for i in range(n):
    dp[i+1][0] = max(dp[i][1], dp[i][2]) + li[i+1][0]
    dp[i+1][1] = max(dp[i][0], dp[i][2]) + li[i+1][1]
    dp[i+1][2] = max(dp[i][0], dp[i][1]) + li[i+1][2]

print(max(dp[n-1]))

Measured memory_bytes: 47188
while True:
    h,w = map(int, input().split())
    
    if h == 0 and w == 0:
        break
   
    for i in range(h):
        if i == 0 or i == h-1:
            print('#' * w)
        else:
            print('#'+'.'*(w-2)+'#')
    print()


Measured memory_bytes: 5612
/*

  _|_|                              _|  _|    _|
_|    _|  _|  _|_|  _|_|_|_|        _|  _|  _|
_|    _|  _|_|          _|          _|  _|_|
_|    _|  _|          _|      _|    _|  _|  _|
  _|_|    _|        _|_|_|_|    _|_|    _|    _|

*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
//#define ls (rt<<1)
//#define rs (rt<<1|1)
#define vi vector<int>
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define fi first
#define se second
typedef long long ll;
using namespace std;
const int maxn=1e5+1000;
vi side[maxn];
int d[maxn];
int vis[maxn];
int st,ed;
void dfs(int u){
    vis[u]=1;
    for(int i=0;i<side[u].size();i++){
        int v=side[u][i];
        if(vis[v]==1)continue;
        if(vis[v]==-1){if(st)ed=v;else st=v;continue;}
        dfs(v);
    }
    return;
}
int main(){
    ios::sync_with_stdio(0);
    int n,m;cin>>n>>m;
    rep(i,1,m){
        int u,v;cin>>u>>v;side[u].pb(v);side[v].pb(u);d[u]++,d[v]++;
    }
    int mxd=0,mxcnt=0;
    rep(i,1,n){
        if(d[i]&1){
            cout<<"No";return 0;
        }
        if(d[i]>mxd){
            mxd=d[i];mxcnt=1;
        }
        else if(mxd==d[i])mxcnt++;
    }
    if(mxd>=6){cout<<"Yes";return 0;}
    else if(mxd==2){cout<<"No";return 0;}
    else if(mxcnt==1){cout<<"No";return 0;}
    else if(mxcnt>2){cout<<"Yes";return 0;}
    else{
        int te=0;
        rep(i,1,n)if(d[i]==4)vis[i]=-1;
        rep(i,1,n)if(vis[i]==0)st=ed=0,dfs(i),te+=(st==ed);
        if(te){
            cout<<"Yes";return 0;
        }else {cout<<"No";return 0;}
    }
    return 0;
}

Measured memory_bytes: 10644
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int a[1000];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	int ans=0;
	int t=0;
	while(1){
		if(t==n){
			ans++;t=0;
		}
		if(a[t]%2!=0)
			break;
		 a[t]/=2;
		 t++;
		 
	}
	cout<<ans<<endl;
	return  0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
//typedef long long int;
const ll M = 1000000007;
ll A, B, C, D, G, H, N, L, K, P, Q, R, W, X, Y, Z;
string S, T;

signed main(){
	std::cin >>N ;
	ll a[N+1];
	ll b[N];
	ll ans=0;
	REP(i,N+1){std::cin >> a[i];}
	REP(i,N){std::cin >> b[i];}
	REP(i,N){
	    if(a[i]>=b[i])ans+=b[i];
	    else{
	        if(a[i+1]+a[i]>=b[i]){ans+=b[i];a[i+1]-=(b[i]-a[i]);}
	        else {ans+=a[i]+a[i+1];a[i+1]=0;}
	    }
	}
	std::cout << ans << std::endl;
    
}

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

using lint = long long;

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

#define EPS 1e-6;

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; }

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

    int N;
    lint x;

    cin >> N >> x;
    vector<lint> a(N);

    REP(i, N) { cin >> a[i]; }

    sort(a.begin(), a.end());
    lint ans = 0;

    for (int i = 0; i < N; ++i) {
        if (x >= a[i]) {
            x -= a[i];
            if (i < N - 1 || x == 0) ++ans;
        } else break;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// Atcoder Beginner Contest 178
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(ll i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cerr.tie(0);
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll o = a*c;
	ll t = a*d;
	ll th = b*c;
	ll f = b*d;
	cout<<max(max(o,t),max(th,f))<<Endl;
	return 0;
}

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

int main() {
    int32_t n, k;
    cin >> n >> k;
    int32_t a[n + 1];
    a[0] = 0;
    for (int32_t i = 1; i <= n; i++) {
        cin >> a[i];
    }

    int64_t answer = -(1L << 63);
    int64_t sumb = 0;
    int64_t sumw = 0;

    for (int32_t i = 0; i <= n; i++) {
        sumb += (i < k || a[i] > 0) ? a[i] : 0;
        sumw += (i >= k && a[i] > 0) ? a[i] : 0;
    }

    for (int32_t i = 0; i <= n - k; i++) {
        if (a[i] >= 0) {
            sumw += a[i];
        } else {
            sumb -= a[i];
        }
        if (a[i + k] >= 0) {
            sumw -= a[i + k];
        } else {
            sumb += a[i + k];
        }
    
        if (sumw > answer) {
            answer = sumw;
        }
        if (sumb > answer) {
            answer = sumb;
        }
    }

    cout << answer << endl;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

ll A[3], K;

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

    for(int i=0;i<3;++i){
        std::cin >> A[i];
    }

    std::cin >> K;

    std::sort(A, A + 3);

    ll mx = A[0] + A[1] + (A[2] << K);
    std::cout << mx << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   
  int a,b,c,x,y,z;
   
  scanf("%d%d%d",&a,&b,&c);
   
  if(a > b){ 
    x = a;
    a = b;
    b = x;
  }
   
  if(b > c){
    y = b;
    b = c;
    c = y;
  }
   
  if(a > b){
    z = a;
    a = b;
    b = z;
  }
   
  printf("%d %d %d\n",a,b,c);
   
  return 0;
}

Measured memory_bytes: 596
import math


def count(N, X):
    cnt = sum(map(int, str(X))) + sum(map(int, str(X - N)))
    return cnt


def solve_naive_first(N):
    keta = math.floor(math.log(N, 10))
    p = pow(10, keta)
    return min(solve_naive(N), 1+solve_naive(p*10-N))


def solve_naive(N):
    if N < 10:
        return min(N, 10-N+1)
    keta = math.floor(math.log(N, 10))
    p = pow(10, keta)
    return min(solve_naive((N // p + 1) * p - N) + (N // p + 1), solve_naive(N % p) + N // p)


def solve(N):
    n_0, n_1 = 0, 1  # 0: その桁で処理, 1: 次の桁に1タス
    for i in N[::-1]:
        i = int(i)
        if i == 9:
            n_0, n_1 = n_0 + i, min(n_0 + 10 - i, n_1 + 10 - i - 1)
        else:
            n_0, n_1 = min(n_0 + i, n_1 + i + 1), min(n_0 +
                                                      10 - i, n_1 + 10 - i - 1)
    return min(n_0, n_1+1)


if __name__ == '__main__':
    N = input()
    ans = solve(N)
    print(ans)


Measured memory_bytes: 78144
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdio>

const double EPSILON = 1e-10;

inline bool equals(double a, double b) {
    return std::fabs(a - b) < EPSILON;
}

struct Point {
    double x;
    double y;

    bool operator < (const Point& p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point& p) const {
        return equals(x, p.x) && equals(y, p.y);
    }
};

Point operator + (const Point& p1, const Point& p2) {
    return Point{p1.x + p2.x, p1.y + p2.y};
}

Point operator - (const Point& p1, const Point& p2) {
    return Point{p1.x - p2.x, p1.y - p2.y};
}

Point operator * (const Point& p1, double k) {
    return Point{p1.x * k, p1.y * k};
}

struct Segment {
    Point p1, p2;
};

struct Circle {
    Point center;
    double radius;
};

using Vector = Point;
using Line = Segment;
using Polygon = std::vector<Point>;


double norm(const Vector& p) {
    return p.x * p.x + p.y * p.y;
}

double abs(const Vector& p) {
    return std::sqrt(norm(p));
}

double dot(const Vector& a, const Vector& b) {
    return a.x * b.x + a.y * b.y;
}

double cross(const Vector& a, const Vector& b) {
    return a.x * b.y - a.y * b.x;
}

Vector projection(const Segment& s, const Point p) {
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / norm(base);
    using namespace std;
    // cerr << "p: " << p.x << ", " << p.y;
    // cerr << " dot: " << dot(p - s.p1, base);
    // cerr << " norm: " << norm(base) << endl;
    return s.p1 + base * r;
}

int main() {
    using namespace std;

    Point p1, p2;
    cin >> p1.x >> p1.y >> p2.x >> p2.y;
    Segment s{p1, p2};

    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        long long x, y;
        cin >> x >> y;
        // cerr << x << " " << y << endl;
        auto p = projection(s, Point{static_cast<double>(x), static_cast<double>(y)});
        cout << setprecision(20) << p.x << " " << p.y << endl;
    }

    return 0;
}


Measured memory_bytes: 3292
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
  int x,y,size,cnt = 0,ma = -1;
  int mas[10][10] = {0};
  int dx1[4] = {0,1,0,-1},dy1[4] = {1,0,-1,0};
  int dx2[8] = {0,1,0,-1,1,1,-1,-1},dy2[8] = {1,0,-1,0,1,-1,1,-1};
  int dx3[12]={1,0,-1,0,1,1,-1,-1,0,0,2,-2},dy3[12]={0,1,0,-1,-1,1,1,-1,2,-2,0,0};
  while(scanf("%d,%d,%d",&x,&y,&size) != EOF){
    if(size == 1){
      mas[y][x] += 1;
      for(int i=0;i<4;i++){
	int nx = x+dx1[i];
	int ny = y+dy1[i];
	if(nx >= 0 && nx < 10 && ny >= 0 && ny < 10) mas[ny][nx] += 1;
      }
    }
    if(size == 2){
      mas[y][x] += 1;
      for(int i=0;i<8;i++){
	int nx = x+dx2[i];
	int ny = y+dy2[i];
	if(nx >= 0 && nx < 10 && ny >= 0 && ny < 10) mas[ny][nx] += 1;
      }
    }
    if(size == 3){
      mas[y][x] += 1;
      for(int i=0;i<12;i++){
	int nx = x+dx3[i];
	int ny = y+dy3[i];
	if(nx >= 0 && nx < 10 && ny >= 0 && ny < 10) mas[ny][nx] += 1;
      }
    }
  }
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      if(mas[i][j] == 0) cnt++;
      ma = max(ma,mas[i][j]);
    }
  }
  cout << cnt << endl << ma << endl;
}

Measured memory_bytes: 1208
#include <iostream>
#include <map>

using namespace std;

int main() {
	map<int, int> cntMap;
	map<int, int>::iterator it;
	int in, buf;
	while(cin>>in){
		if(cntMap.count(in) == 0){ cntMap.insert(make_pair(in, 0)); }
		else{ cntMap.find(in)->second++; }
	}

	int maxCnt = 0;
	for(it=cntMap.begin(); it!=cntMap.end(); it++){
		maxCnt = max(maxCnt, it->second);
	}
	for(it=cntMap.begin(); it!=cntMap.end(); it++){
		if(maxCnt == it->second){
			cout<<it->first<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

void solve()
{
    int n,p;
    while(cin>>n>>p,n|p){
        int now=0,tmp=p;
        vector<int>s(n,0);
        while(1){
            if(tmp==0&&s[now]==p){
               cout<<now<<endl;break;
            }
            else if(tmp>0)tmp--,s[now]++;
            else if(tmp==0)tmp=s[now],s[now]=0;
            now++;
            now%=n;
        }
    }
}

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


Measured memory_bytes: 3040
import sys

sys.setrecursionlimit(10**7)

inf = float('inf')

def solve():
    n = int(sys.stdin.readline())

    r = [0] * n
    c = [0] * n

    for i in range(n):
        ri, ci = map(int, sys.stdin.readline().split())
        r[i] = ri
        c[i] = ci

    dp = [[0]*(n + 1) for i in range(n + 1)]

    for ls in range(2, n + 1):
        for i in range(n - ls + 1):
            dp[i][i + ls] = inf
            for j in range(i + 1, i + ls):
                dp[i][i + ls] = min(dp[i][i + ls], dp[i][j] + dp[j][i + ls] + r[i]*r[j]*c[i + ls - 1])

    ans = dp[0][n]

    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 7768
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int answer = n * n;
            Console.WriteLine(answer);
        }
    }
}

Measured memory_bytes: 13140
N = int(input())
A = [int(input()) for _ in range(N)]

max1 = 0
max2 = 0
for i in range(N):
    if max2 < A[i]:
        if A[i] > max1:
            max2 = max1
            max1 = A[i]
        else:
            max2 = A[i]

for i in range(N):
    if A[i] == max1:
        print(max2)
    else:
        print(max1)


Measured memory_bytes: 12520
#include <stdio.h>
int C[1000000000];
int A[1000000000];
int count=0;
void merge(int a[],int left,int right);
int main(){
  int i,n;
 
  scanf("%d",&n);
  for(i=0; i < n ; i++){
    scanf("%d",&A[i]);
  }
  merge(A,0,n-1);
  for(i=0; i < n ; i++){
    if(i < n-1){
    printf("%d ",A[i]);
    }
    else{
      printf("%d",A[i]);
    }
  }
  printf("\n%d\n",count);
  return 0;
}

void merge(int A[],int left,int right){
  int mid,i,j,p;
  if(right <=left)return;
  mid=(left+right)/2;
  merge(A,left,mid);
  merge(A,mid+1,right);

  for(i=left; i <= mid;i++){
    C[i]=A[i];
  }
  j=right;
  for(i=mid+1;i <=right;i++,j--){
    C[i]=A[j];
  }
  j=right;
  i=left;
  for(p=left;p<=right;p++){
    if(C[i]<=C[j]){
      A[p]=C[i++];
      count++;
    }
    else{
      A[p]=C[j--];
      count++;
    }
  }
}



Measured memory_bytes: 5588