akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B;
    cin >> A >> B;
    if (A==B)
        cout << "Draw" << endl;
    else if (A==1)
        cout << "Alice" << endl;
    else if (B==1)
        cout << "Bob" << endl;
    else if (A>B)
        cout << "Alice" << endl;
    else 
        cout << "Bob" << endl;
        
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int n;
  cin>>n;

  ll ct=0;
  ll now =0;

  bool rev=false;
  bool allzero=true;

  ll a[n];
  rep(i,n){
    cin>>a[i];
    if(allzero==true){
      if(a[i]>0){
        rev=false;
        allzero=false;
      }
      else if(a[i]<0){
        rev=true;
        allzero=false;
      }
    }
  }
  /*
  rep(i,n){
    now+=a[i];
    if((i%2) xor rev ==0){
      if(now<=0){
        ct+=1-now;
        now=1;
      }
    }
    else{
      if(now>=0){
        ct+=now+1;
        now=(-1);
      }
    }
  }
  */
  ll ct1=0;
  ll ct2=0;
  rep(i,n){
    now+=a[i];
    if((i%2) ==0){
      if(now<=0){
        ct1+=1-now;
        now=1;
      }
    }
    else{
      if(now>=0){
        ct1+=now+1;
        now=(-1);
      }
    }
  }
  now=0;
  rep(i,n){
    now+=a[i];
    if((i%2) !=0){
      if(now<=0){
        ct2+=1-now;
        now=1;
      }
    }
    else{
      if(now>=0){
        ct2+=now+1;
        now=(-1);
      }
    }
  }

  cout<<min(ct1,ct2) <<"\n";
}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
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; }

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    string s,t; cin >> s >> t;

    string r_t = t;
    reverse(r_t.begin(), r_t.end());

    int ans = 0;
    for(int i = 0; i <= N; i++){
        string tmp = "";
        rep(j,i){
            tmp += s[j];
        }
        tmp += t;
        
        bool isOK = true;
        rep(j,N){
            if (s[j] != tmp[j]){
                isOK = false;
            }
        }
        reverse(tmp.begin(), tmp.end());

        rep(j,N){
            if (r_t[j] != tmp[j]){
                isOK = false;
            }
        }

        if(isOK){
            ans = tmp.size();
            break;
        }
    }

    cout << ans << endl;
}

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

int main(void){
    // Your code here!
    long long X, Y;
    cin >> X >> Y;
    
    long long num_len = 0;
    long long count = X;
    while(count <= Y){
        num_len += 1;
        count *= 2;
    }
    
    cout << num_len;
    
}


Measured memory_bytes: 256
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

h,w = mi()
c = [[float('inf') for j in range(10)]for i in range(10)]

for i in range(10):
    cc = li()
    for j in range(10):
        c[i][j] = cc[j]

# cost of i to j

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j] , c[i][k] + c[k][j])

ans = 0
for i in range(h):
    w = li()
    for j in w:
        if j == -1:
            continue
        ans += c[j][1]

print(ans) 




Measured memory_bytes: 73804
#pragma region template

#include <bits/stdc++.h>
using namespace std;

// -type-
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vpii = vector<pii>;
using vpll = vector<pll>;


// -const-
const ll MOD = 1000000007;

const ll INF = (ll)0x3f0000003f000000;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
          dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


// -define-
#define reps(i, k, n) for (int i = (k), i##_len = (n); i < i##_len; ++i)
#define rep(i, n) reps(i, 0, n)
#define repsr(i, k, n) \
    for (int i = int(n) - 1, i##_len = (k); i >= i##_len; --i)
#define repr(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(o) begin(o), end(o)
#define sz(a) ((int)(a).size())
#define debug(...) debug_args(__LINE__, __VA_ARGS__)


// clang-format off
// -functions-
inline bool in(string s, string c) {return (s.find(c) != string::npos);}
inline bool in(string s,   char c) {return (s.find(c) != string::npos);}

template <class T> T udiv(T a, T b) {return (a + b - 1) / b;}
template <class T> T rdiv(T a, T b) {return (a + b / 2) / b;}

void print_args(ostream&) {}
template <class S, class... T>
void print_args(ostream& out,const S& a,const T&... args) {
    out << ' ' << a;
    print_args(out, args...);
}
template <class S, class... T>
void print(const S& a, const T&... args) {
    std::cout << a;
    print_args(std::cout, args...);
    std::cout << '\n';
}
template <class S, class... T>
void debug_args(const S& a, const T&... args) {
    std::cout << "(L:" << std::setw(3) << a << ")";
    print_args(std::cout, args...);
    std::cout << '\n';
}
// clang-format on

struct setup_main {
    setup_main() {
        std::cin.tie(0);
        std::ios::sync_with_stdio(0);
        std::cout << fixed << setprecision(15);
    }
} setup_main_;

ll ans = 0;
#pragma endregion

void solve(long long N, std::vector<long long> h) {
    vi dp(N, INF);

    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);

    reps(i, 2, N) {
        int n1 = dp[i - 1] + abs(h[i] - h[i - 1]);
        int n2 = dp[i - 2] + abs(h[i] - h[i - 2]);
        dp[i] = min(n1, n2);
    }
    print(dp[N - 1]);
}
signed main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> h(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &h[i]);
    }
    solve(N, std::move(h));

    return 0;
}


Measured memory_bytes: 1408
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#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++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 998244353;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1}};



int main() {

	ll A, B, T;

	cin >> A >> B >> T;


	cout << B * (T / A) << endl;


	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
int n, a[maxn + 10], f[maxn + 10][maxn + 10], ans = 1e9;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for (int i = 1; i <= n; ++i) f[1][i] = (i != a[1]);
	for (int i = 2; i <= n; ++i)
		for (int j = 1; j <= n; ++j) {
			f[i][j] = 1e9;
			for (int k = 1; k <= n; ++k)
				if (j != k)
					f[i][j] = min(f[i][j], f[i - 1][k]);
			f[i][j] += (j != a[i]);
			if (i == n) ans = min(ans, f[i][j]);
		}
	printf("%d", ans);
}

Measured memory_bytes: 256
N = int(input())
min = 1000000000

for i in range(1,N):
    A = str(N - i)
    B = str(i)
    temp = 0
    for j in range(len(A)):
        temp += int(A[j])
    for j in range(len(B)):
        temp += int(B[j])
    if min > temp:
        min = temp
print(min)







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

const int MAX_N = 100000;

vector<vector<int>> graph(MAX_N+1);
vector<int> path(MAX_N+1, -1);
vector<bool> visited(MAX_N+1, false);

int dp(int obj) {
    if (path[obj] == -1) {
        int k = 0;
        for (auto x : graph[obj]) {
            k = max(k, dp(x)+1);
        }
        path[obj] = k;
    }
    return path[obj];
}

int main() {
    int N, M; cin >> N >> M;

    for (int i = 0; i < M; i++) {
        int x, y; cin >> x >> y;
        graph[x].push_back(y);
    }
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        ans = max(dp(i), ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 8192
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST         ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll           long long
#define ld           long double
#define pb           push_back
#define mp           make_pair
#define pii          pair<int,int>
#define mii          map<int,int>
#define vi           vector<int>
#define vll          vector<long long>
#define all(a)       (a).begin(),(a).end()
#define clz(a)       __builtin_clz(a) // count leading zeroes
#define ctz(a)       __builtin_ctz(a) // count trailing zeroes
#define popc(a)      __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul          1000000007
#define rep(i,a,b)   for(int i=a;i<b;i++)
#define rfor(i,a,b)  for(int i=a; i>=b; i--)
#define SIZE         1000005
#define F            first
#define S            second
#define mod          998244353
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define pll          pair<ll,ll>
#define endl         '\n'
#define ordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{
    unordered_map<ll,ll> ma1,ma2;
    vll fact;
    ll a,b; cin>>a>>b;
    for(ll i=1; i*i<=a; i++)
    {
        if(a%i==0)
        {
            ma1[i]=1;
            if(i!=a/i)
            {
                ma1[a/i]=1;
            }
        }
    }
    for(ll i=1; i*i<=b; i++)
    {
        if(b%i==0)
        {
            if(ma1.count(i)) fact.pb(i);
            if(i!=b/i)
            {
                if(ma1.count(b/i)) fact.pb(b/i);
            }
        }
    }
    sort(all(fact));
    int ans = 1;
    for(auto num:fact)
    {
        int flag=1;
        for(ll i=2; i*i<=num; i++)
        {
            if(num%i==0)
            {
                if(ma2.count(i) or ma2.count(num/i))
                {
                    flag=0;
                    break;
                }
            }
        }
        if(flag and num!=1)
        {
            ans++;
            ma2[num]=1;
        }
    }
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1; //cin>>t;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,1)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a){return parent[a]!=a?parent[a]=find(parent[a]):a;}
	bool same(int a,int b){return find(a)==find(b);}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
			rank[b]+=rank[a];
		}
		else
		{
			parent[b]=a;
			rank[a]+=rank[b];
		}
		return true;
	}
	int size(int a){return rank[find(a)];}
};
string S,O;
int N;
long mod=1e9+7;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
main()
{
	cin>>S>>O>>N;
	if(N<O.size())
	{
		vector<int>X(N*2+S.size()+O.size());
		for(int i=0;i<N;i++)X[i]=X[S.size()+N+i]=i+26;
		for(int i=0;i<S.size();i++)X[N+i]=S[i]-'a';
		for(int i=0;i<O.size();i++)X[N*2+S.size()+i]=O[i]-'a';
		UF uf(N+26);
		vector<bool>fixed(N+26);
		for(int i=0;i<X.size();i++)uf.unite(X[i],X[X.size()-i-1]);
		for(int i=0;i<26;i++)fixed[uf.find(i)]=true;
		for(int i=0;i<26;i++)for(int j=i+1;j<26;j++)
		{
			if(uf.same(i,j))
			{
				cout<<0<<endl;
				return 0;
			}
		}
		long ans=1;
		for(int i=0;i<N;i++)
		{
			if(!fixed[uf.find(i+26)])
			{
				fixed[uf.find(i+26)]=true;
				(ans*=26)%=mod;
			}
		}
		cout<<ans<<endl;
		return 0;
	}
	reverse(O.begin(),O.end());
	S+=O;
	for(int i=0;i<S.size();i++)
	{
		if(S[i]!=S[S.size()-i-1])
		{
			cout<<0<<endl;
			return 0;
		}
	}
	cout<<power(26,(N-O.size()+1)/2)<<endl;
}


Measured memory_bytes: 3896
#include<iostream>
#include<vector>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';

const int MOD = 998244353;
const ll MAX_VAL = 1000000;

ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}


ll inv[1000010];//逆元
vector<ll>divisors[1000010];//約数の集合
ll sum1[1000010];//sum1[d]=dの倍数の和
ll sum2[1000010];//sum2[d]=dの倍数の2乗の和
ll A[200020];
ll f[1000010];
ll g[1000010];
//逆元の前計算
void inverse_init() {
	inv[1] = 1;
	for (int i = 2; i <= MAX_VAL; i++) {
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
	}
}
//約数列挙
void divisors_init() {
	for (int d = 1; d <= MAX_VAL; d++) {
		for (int x = d; x <= MAX_VAL; x += d) {
			divisors[x].pb(d);
			//divs[x].insert(d);
		}
	}
}
//g(d)の計算
void calc_g() {
	for (int d = 1; d <= MAX_VAL; d++) {
		ll tmp = 0;
		tmp = add(tmp, mult(sum1[d], sum1[d]));
		tmp = sub(tmp, sum2[d]);
		tmp = mult(tmp, inv[2]);
		g[d] = tmp;
	}
}

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

	divisors_init();//約数列挙
	inverse_init();//逆元の前計算
	int N; cin >> N;
	REP(i, N) {
		cin >> A[i];
		for (auto x : divisors[A[i]]) {
			sum1[x] = add(sum1[x], A[i]);
			sum2[x] = add(sum2[x], mult(A[i], A[i]));
		}
	}
	calc_g();//g(d)の計算
	ll ans = 0;
	for (int d = MAX_VAL; d >= 1; d--) {
		ll tmp = g[d];
		for (int k = 2; k*d <= MAX_VAL; k++) {
			tmp = sub(tmp, f[k*d]);
		}
		f[d] = tmp;
		ans = add(ans, mult(f[d],inv[d]));
	}
	cout << ans << endl;
}


Measured memory_bytes: 221440
def f(m):
    if z[m]==-1:
        z[m]=q[m]
        s=(m-1)&m
        while s:
            z[m]=max(z[m],f(s)+q[s^m])
            s=(s-1)&m
    return z[m]
n=input()
a=[map(int,raw_input().split()) for _ in xrange(n)]
t=1<<n
q=[0]*t
for m in xrange(t):
    s=0
    for i in xrange(n):
        if (m>>i)&1:
            for j in xrange(i):
                if (m>>j)&1:
                    q[m]+=a[i][j]
z=[-1]*t
print f(t-1)

Measured memory_bytes: 85172
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44


/*const int MOD = (int) 1e9 + 7;

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}*/

using namespace std;

const int MAXN = (int) 1e5;

vector < pair <int, bool> > g[MAXN + 1];
int deg[MAXN + 1];
bool vis[MAXN + 1];

void dfs(int nod, int par) {
    vis[nod] = 1;
    for(auto it : g[nod]) {
        if(vis[it.first] == 0) {
            dfs(it.first, nod);
            deg[nod]++;
        }
        else if(it.second == 0 && it.first != par) {
            deg[nod]++;
            cout << nod << " " << it.first << "\n";
        }
    }

    if(nod != 1) {
        if(deg[nod] & 1) {
            cout << nod << " " << par << "\n";
            deg[nod]++;
            deg[par]--;
        }
        else {
            cout << par << " " << nod << "\n";
        }
    }
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n, m;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n >> m;

    if(m & 1) {
        cout << -1;
        return 0;
    }

    for(i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        g[x].push_back({y, 0});
        g[y].push_back({x, 1});
    }

    dfs(1, 0);

    return 0;
}


Measured memory_bytes: 15232
#include <iostream>
using namespace std;
int main()
{
    int x;
    cin >> x;
    int res = 0;
    int index = 0;
    for(int i=1; i<=x;i++)
    {
        int icount = 0;
        int calc = i;
        while((calc%2) == 0)
        {
            calc = calc/2;
            icount++;
        }
        if(icount >= res)
        {
            res = icount;
            index =i;
        }
    }
    cout << index << endl;
    return 0;
}



Measured memory_bytes: 256
import numpy as np
X, Y, A, B, C=map(int, input().split())
P=sorted(list(map(int, input().split())), )[-X:]
Q=sorted(list(map(int, input().split())), )[-Y:]
R=sorted(list(map(int, input().split())), reverse=True)

PQ=sorted(P+Q)

ans=0
for i in range(len(PQ)):
  if len(R)>0:
    
    now=max(PQ[i], R.pop(0))
  else:
    now=PQ[i]
  ans+=now
  
print(ans)

Measured memory_bytes: 30448
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18

priority_queue<int,vector<int>,greater<int>> que;


llint b;
bool f=0;
void dfs(string s,int i){
	if(s=="AKIHABARA"){
		f=1;
		return;
	}
	if(i>s.size()) return;
	dfs(s,i+1);
  s.insert(s.begin()+i,'A');
  dfs(s,i+2);
}
void solve(){
	string s;
	cin >> s;
	if(s.size()>9){
    cout<<"NO"<<endl;
  }
	else{
  	dfs(s,0);
  	if(!f) cout<<"NO"<<endl;
  	else cout<<"YES"<<endl;
	}
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int A[100005],i,j,N,x;
void sw(int *a,int *b)
{
	int c=*a;
	*a=*b;
	*b=c;
}
int main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)
		scanf("%d",A+i);
	x=A[N-1];
	for(i=j=0;j<N-1;j++)
	{
		if(A[j]<=x)
		{
			
			sw(&A[i++],&A[j]);
		}
	}
	sw(&A[i],&A[N-1]);
	x=i;
	for(i=0;i<N;i++)
		printf("%s%d%s%c",i==x?"[":"",A[i],i==x?"]":"",i==N-1?'\n':' ');
	return 0;
}

Measured memory_bytes: 988
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int p = 1;
    for(int i = 0; i < n; i++) {
      int a = sc.nextInt();
      if(a == p) {
        p++;
      }
    }
    if(p > 1) System.out.println(n - p + 1);
    if(p == 1) System.out.println(-1);
  }
}

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

int main() {
  int N, K, sum;
  cin >> N >> K;
  sum = 1;

  // ここにプログラムを追記
  for (int i = 0; i < N; i++){
    if (sum <= K) {
      sum += sum;
    }
    
    else {
      sum += K;
    }

  }  

  cout << sum << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 505

int main(){

    ll a,b,c,d,n;
    cin >> a >> b >> c >> d >> n;
    cout << (n/2)* min(min(8*a,4*b),min(2*c,d)) + (n%2)*min(4*a,min(2*b,c)) << endl;
    





    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> data(N);
  rep(i,N){
    cin >> data.at(i);
  }
  bool judge = true;
  int count = 0;
  while(judge == true){
    rep(i,N){
      if(data.at(i)%2==1){
        judge = false;
      }
      data.at(i) /= 2;
      }
    count++;
  }
  cout << count -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>
 
#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;
 
int main(){
    string s;
    cin >> s;
    int n = s.length();
    vl a(n+1);
    rep(i,n + 1){
        if(s[i] == '<'){
            a[i+1] = max(a[i+1],a[i] + 1);
        }
    }
 
    for(int i = n;i >= 0; i--){
        if(s[i] == '>'){
            a[i] = max(a[i],a[i+1]+1);
        }
    }
    ll ans = 0;
    rep(i,n+1){
        //cout << a[i]  << " ";
        ans+= a[i];
    }
    //cout << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7640
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<ctime>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<tuple>
#include<cassert>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<iomanip>
#include<climits>
#include<typeinfo>
#include<utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
double pi = 3.141592653589793238;
using ll = long long;
using namespace std;

ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpcombination[10000][10000];

ll modi = 1000000007;
ll combination(ll n, ll r) {
	if (n == r) { return dpcombination[n][n] = 1; }
	else if (r == 0) { return dpcombination[n][0] = 1; }
	else if (r == 1) { return dpcombination[n][1] = n; }
	else if (dpcombination[n][r]) { return dpcombination[n][r]; }
	else { return dpcombination[n][r] = combination(n - 1, r - 1) % modi + combination(n - 1, r) % modi; }
}

void clockman(int time1) {

	cout << 1.0*(clock() - time1) / CLOCKS_PER_SEC << endl;
	return;
}
//cout << fixed << setprecision(10)



int main() {
	
	string t;
	cin >> t;
	for (int i = 0;i < t.size();i++) {
		if (t[i] == '?') {
			t[i] = 'D';
		}


	}

	cout << t << endl;

	




	return 0;
}


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

int main() {
  int N, K, x, sum;
  cin >> N >> K;
  sum = 0;
  
  for (int i = 0; i < N; i++){
    cin >> x;
    
    if (x < (K - x)){
      sum += 2 * x;
    }else{
      sum += 2 * (K - x);
    }
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#if 0
#define DEBUG(x) do{cerr << #x << "=" << x << endl;}while(0);
#else
#define DEBUG
#endif

int main(){
	int k,x;
	cin >> k >> x;
	int min_x = x-k+1;
	int max_x = x+k-1;
	if( min_x < -1000000){
		min_x = -1000000;
	}
	if( 1000000 < max_x){
		max_x = 1000000;
	}
	for(int i=min_x; i<=max_x; ++i){
		cout << i << ((i==k+x-1)?"\n":" ");
	}


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
void solve(){
    ll n;
    cin>>n;
    ll a[n];
    fo(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    ll ans = a[n-1];
    deb(ans);
    ll cm = n-2;
    for(ll i = n-2;i>=0;i--){
        if(cm<=0)break;
        if(cm>=2){
            cm-=2;
            ans += 2*(a[i]);
        }
        else if(cm == 1){
            ans += a[i];
            cm--;
        }
    }
    cout<<ans<<nl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";


}


Measured memory_bytes: 5372
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
#define repi(i,a,b) for (int i=a;i<(b);i++)
using namespace std;
typedef long long ll;
int main(){
  int a,b;
  cin >> a >> b;
  if((1<=a) && (a<=9)&&(b<=9)&&(1<=b)){
    cout << a*b << endl;
  }else{
    cout << -1 << endl;
  }
}
    

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let vec: Vec<u16> = line.split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();
    let (a, b, c) = (vec[0], vec[1], vec[2]);
    println!("{}", (a..b+1).filter(|i| c%i == 0).count());
}


Measured memory_bytes: 5028
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
max_color_num = 8
ans_min = 0
colors = Array.new(max_color_num+1, 0)
a.each do |i|
    if i < 400 then
        colors[0] += 1
    elsif i < 800 then
        colors[1] += 1
    elsif i < 1200 then
        colors[2] += 1
    elsif i < 1600 then
        colors[3] += 1
    elsif i < 2000 then
        colors[4] += 1
    elsif i < 2400 then
        colors[5] += 1
    elsif i < 2800 then
        colors[6] += 1
    elsif i < 3200 then
        colors[7] += 1
    else
        colors[8] += 1
    end
end
 
8.times do |i|
    ans_min += 1 if colors[i] != 0
end
 
ans_max = colors[8] + ans_min
ans_min = 1 if ans_min == 0
 
puts [ans_min, ans_max].join(" ")

Measured memory_bytes: 1788
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << a + b + c - (max(a, max(b, c))) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
int pal(int n){
	char s[9],t[9];
	sprintf(s,"%d",n);
	strcpy(t,s);
	std::reverse(t,t+strlen(t));
	return strcmp(t,s);
}
main(){
	int n,i;
	scanf("%d",&n);
	for(i=0;;i++){
		if(!pal(n-i)){printf("%d\n",n-i);return 0;}
		if(!pal(n+i)){printf("%d\n",n+i);return 0;}
	}
}

Measured memory_bytes: 1056
import numpy as np
N = int(input())
H = np.array(input().split(), dtype=np.int32)

def F(L,R):
  if R < L:
    return 0
  idx = L + H[L:R+1].argmin()
  x = H[idx]
  H[L:R+1] -= x
  return x + F(L,idx-1) + F(idx+1,R)

answer = F(0,N-1)
print(answer)

Measured memory_bytes: 12488
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
using namespace std;
 
#define li long long int
#define ld long double
const int MX1=1e5+5;
const int MX2=1e6+5;
const li inf=4e18;
const li mod=1e9+7;

li power(li a,li b){li res=1;while(b){if(b%2)res=(res*a)%mod;
a=(a*a)%mod;b/=2;}return res;}
 
li mmi(li a){return power(a,mod-2);}
 
li cntbit(li n){li cnt=0;while(n){n&=(n-1);cnt++;}return cnt;}

int n;
int a[105];
multiset<int> ms;

void solve(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		ms.insert(-a[i]);
	}
	int ans=0;
	int cnt=0;
	for(auto it:ms){
		if(cnt%2==0) ans+=-it;
		else ans-=-it;
		cnt++;
	}
	cout<<ans;
}

int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1e5+10
#define mod 1e9 + 7
#define pii pair<int,int>
using namespace std;
const int N = 1e5 + 1;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
vector<int> dp,v;
int brute(int indx){
	if(indx >= (n)){
		return 1e9;
	}
	if(indx == (n-1))
		return 0;
	if(dp[indx] != -1){
		return dp[indx];
	}
	int ans = 1e9;
	for(int i=1;i<=k;i++)
		ans = min(ans,brute(indx+i) + abs(v[indx] - v[indx+i]));
	return dp[indx] = ans;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>k;
	v.assign(n,0);
	for(auto &x : v){
		cin>>x;
	}
	dp.assign((int)1e5+10,-1);
	cout<<brute(0);
    return 0;
}
//.........

Measured memory_bytes: 6528
# include<iostream>
# include<string.h>
using namespace std;
int vis[101];
int a[101], b[101];
int c[101], d[101];
int cx[101], cy[101];

int path[101][101], n;

int match(int u)
{
    for(int i = 0; i < n; ++i)
    {
        if(vis[i] == 0 && path[u][i] == 1)
        {
            vis[i] = 1;
            if(cy[i] == -1 || match(cy[i]))
            {
                cx[u] = i;
                cy[i] = u;
                return 1;
            }
        }
    }
    return 0;
}

int main(void)
{
    while(cin >> n && n!=0)
    {
        int i, j;
        for(i = 0; i < n; ++i)
            cin >> a[i] >> b[i];

        memset(path, 0, sizeof(path));
        for(i = 0; i < n; ++i)
        {
            cin >> c[i] >> d[i];
            for(j = 0; j < n; ++j)
            {
                if(c[i] > a[j] && d[i] > b[j])
                    path[j][i] = 1;
            }
        }
        memset(cx, -1, sizeof(cx));
        memset(cy, -1, sizeof(cy));

        int ans = 0;
        for(i = 0; i < n; ++i)
        {
            if(cx[i] == -1)
            {
                memset(vis, 0, sizeof(vis));
                ans+=match(i);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
N = int(input())
A = sys.stdin.readlines()
A = [b.strip() for b in A]
print('AC x ' + str(A.count('AC')))
print('WA x ' + str(A.count('WA')))
print('TLE x ' + str(A.count('TLE')))
print('RE x ' + str(A.count('RE')))

Measured memory_bytes: 23428
s = list(input())
t = list(input())
subset = True
ans = ""
for i in range(min(len(s),len(t))):
    s_n = s.pop(s.index(min(s)))
    t_n = t.pop(t.index(max(t)))
    if s_n != t_n:
        subset = False
        if s_n < t_n:
            ans = "Yes"
        else:
            ans = "No"
        break
if subset == True:
    if len(s) < len(t):
        ans = "Yes"
    else:
        ans = "No"
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
#define vs vector<string>
#define mn -
#define mod %
#define E =
#define EE ==
int mx=9999999;
/**  '' "\n" - ^ **/

void yes()
{
    cout<<"Yes\n";
}

void no()
{
    cout<<"No\n";
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
void bin(int n)
{
    cout<<n<<endl;
    while(n>0)
    {
        cout<<n%2;
        n/=2;
    }
}
int main() {
    string str;
    cin>>str;
    if(str.length()==1)
    {
        cout<<"No\n";
    }

    else if(str.length()==2)
    {
        if(str[0]!=str[1])
            cout<<"Yes\n";
        else
        cout<<"No\n";
    }

    else
    {
        if(str[0]!=str[1]||str[1]!=str[2])
            cout<<"Yes\n";
        else
        cout<<"No\n";
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, h, w;
    cin >> n >> h >> w;
    int ans = 0;
    rep(i,n){
        int a, b;
        cin >> a >> b;
        if(a >= h && b >= w) ++ans;
    }
    cout << ans << endl;
	return 0;
}


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

int x[100];

int main(){
	int n;
	scanf("%d", &n);
	f(i, 0, n)scanf("%d", x + i);
	sort(x, x + n);
	printf("%d\n", x[n - 1] - x[0]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(void)
{
	int N, l, r, i, sum;
  	
    sum = 0;
	cin >> N;
	for (i = 0; i < N; ++i)
    {
      cin >> l >> r;
      sum  += r - l + 1;
    }
	cout << sum << endl;
    return (0);
}

Measured memory_bytes: 3544
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input {(source=$s:expr,$($r:tt)*) => {let mut iter=$s.split_whitespace(); let mut next=||{iter.next().unwrap()}; input_inner! {next,$($r)*}};($($r:tt)*) => {let stdin=std::io::stdin();let mut bytes=std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next=move||->String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()}; input_inner! {next,$($r)*}};}
#[allow(unused_macros)]
macro_rules! input_inner {($next:expr) => {}; ($next:expr,) => {}; ($next:expr,$var:ident:$t:tt$($r:tt)*) => {let $var=read_value!($next,$t); input_inner! {$next$($r)*}};}
#[allow(unused_macros)]
macro_rules! read_value {($next:expr,($($t:tt),*)) => {($(read_value! ($next,$t)),*)}; ($next:expr, [$t:tt; $len:expr]) => {(0..$len).map(|_|read_value! ($next,$t)).collect::<Vec<_>>()}; ($next:expr,chars) => {read_value! ($next,String).chars().collect::<Vec<char>>()}; ($next:expr,usize1) => {read_value! ($next,usize)-1}; ($next:expr,$t:ty) => {$next().parse::<$t>().expect("Parse error")};}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX: usize = 100006;
#[allow(dead_code)]
const INF_U32: u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32: i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64: u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64: i64 = 1 << 62;
#[allow(dead_code)]
const MOD: i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{n:usize, a:[i64;n]};
    let mut crt = 1i64;
    let mut ans = 0i64;
    for i in 0..n {
        if crt == a[i] {
            crt += 1;
        } else {
            ans += 1;
        }
    }
    println!("{}", if ans==n as i64 {-1} else {ans});

}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;

ll N, K;
ll A[201000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> A[i];
    ll ok = 1e9;
    ll ng = 0;
    while(abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        ll timer = 0;
        for(int i = 0; i < N; i++) {
            timer += (A[i] - 1)/ mid;
        }
        if(timer <= K) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}


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

#define REP(i,a,b) for(int i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)

char input[70][70];
string dp[70][70];

int comp(string s,string t) { // comp s and t if s < t return negative
  if(s.length() != t.length()) return (s.length() - t.length());
  rep(i,s.length()) if(s[i] != t[i]) return (s[i] - t[i]);
  return 0;
}

int main() {
  int w,h,n;
  while(cin>>w>>h, w|h) {
    string s;
    rep(i,h) {
      cin>>s;
      rep(j,w) {
	dp[i][j] = "";
	input[i][j] = s[j];
      }
    }

    rep(i,h) {
      rep(j,w) {
	char c = input[i][j];
	if(i == 0 && j == 0) {
	  if(c <= '9' && c >= '0') dp[i][j] = string(1,c);
	}else{
	  if(!(c <= '9' && c >= '0')) continue;
	  string ab = "",left = "";
	  if(i > 0) ab = dp[i-1][j] + string(1,c);
	  if(j > 0) left = dp[i][j-1] + string(1,c);
	  /*
	  if(comp(ab,left) <= 0) {
	    dp[i][j] = left;
	  }else{
	    dp[i][j] = ab;
	  }
	  */

	  dp[i][j] = (comp(ab,left) <= 0) ? left : ab;
	  if(dp[i][j][0] == '0') dp[i][j] = dp[i][j].substr(1);
	}
      }
    }

    string ans = "";
    rep(i,h) rep(j,w) { if(comp(ans,dp[i][j]) < 0) ans = dp[i][j]; }
    cout<<ans<<endl;
  }
}

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

#define N (91)

int w, h;
char map[N][N];
int max;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

void getWay(int x, int y, int cost)
{
	int i;
	
	if (cost > max){
		max = cost;
	}
	
	for (i = 0; i < 4; i++){
		int nx = x + dx[i];
		int ny = y + dy[i];
		
		if (nx >= 0 && nx < w && ny >= 0 && ny < h){
			if (map[nx][ny] == 1){
				map[nx][ny] = 0;
				getWay(nx, ny, cost + 1);
				map[nx][ny] = 1;
			}
		}
	}
	
}

int main(void)
{
	int i, j;
	
	while (1){
		max = 0;
		scanf("%d", &w);
		scanf("%d", &h);
		
		if (w == 0 || h == 0){
			break;
		}
		for (j = 0; j < h; j++){
			for (i = 0; i < w; i++){
				scanf("%d", &map[i][j]);
			}
		}
		for (j = 0; j < h; j++){
			for (i = 0; i < w; i++){
				
				if (map[i][j] == 1){
					map[i][j] = 0;
					getWay(i, j, 1);
					map[i][j] = 1;
				}
			}
		}
		printf("%d\n", max);
	}
	
	return (0);
}

Measured memory_bytes: 608
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var nmx = Console.ReadLine().Split();
            var n = int.Parse(nmx[0]);
            var m = int.Parse(nmx[1]);
            var x = int.Parse(nmx[2]);

            var cost = new int[n];
            var a = new int[n, m];

            for(int i = 0; i < n; i++)
            {
                var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
                cost[i] = inputs[0];
                for(int j = 0; j < m; j++)
                {
                    a[i, j] = inputs[j + 1];
                }
            }

            const int INF = 10000000;
            var ans = INF;

            for(int i = 0;i < Math.Pow(2,n); i++)
            {
                var understand = new int[m];
                var costSum = 0;

                for(int j = 0; j < n; j++)
                {
                    if((i >> j & 1) == 1)
                    {
                        for(int k = 0; k < m; k++)
                        {
                            understand[k] += a[j, k];
                        }
                        costSum += cost[j];
                    }
                }

                var can = 1;
                for(int l = 0; l < m; l++)
                {
                    if(understand[l] < x)
                    {
                        can = 0;
                        break;
                    }
                }
                if(can == 1 && costSum < ans)
                {
                    ans = costSum;
                }
            }

            if(ans == INF)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 28912
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)



int main(){
	int n,k;
	string s;
	cin >> n >> k >> s;
	
	s[k-1]+=32;
	cout << s << endl;
	
	
	return 0;
}

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

int main() {
    string ans = "Yes";
    int c[3][3];

    int i, j;
    for(i = 0; i < 3; i++) {
        for(j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }

    if (c[1][0] - c[0][0] != c[1][1] - c[0][1]) {
        ans = "No";
    }
    else if (c[1][1] - c[0][1] != c[1][2] - c[0][2]) {
        ans = "No";
    }

    if (c[2][0] - c[1][0] != c[2][1] - c[1][1]) {
        ans = "No";
    }
    else if (c[2][1] - c[1][1] != c[2][2] - c[1][2]) {
        ans = "No";
    }

    if (c[0][1] - c[0][0] != c[1][1] - c[1][0]) {
        ans = "No";
    }
    else if (c[1][1] - c[1][0] != c[2][1] - c[2][0]) {
        ans = "No";
    }

    if (c[0][2] - c[0][1] != c[1][2] - c[1][1]) {
        ans = "No";
    }
    else if (c[1][2] - c[1][1] != c[2][2] - c[2][1]) {
        ans = "No";
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

ans = "U"*dy + "R"*dx + "D"*dy + "L"*(dx+1) + "U"*(dy+1) \
        + "R"*(dx+1) + "D" + "R" + "D"*(dy+1) + "L"*(dx+1) + "U"
        
print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    int N,M,Q;
    cin >> N >> M >> Q;
    int left[N]={};
    int right[N]={};
    int left2[N][N]={};
    rep(i,M){
        int l,r;
        cin >> l >> r;
        l--,r--;
        left[l]++,right[r]++;
        left2[l][r]++;
    }
    int lefts[N+1]={};
    int rights[N+1]={};
    rep(i,N) lefts[i+1]=lefts[i]+left[i];
    rep(i,N) rights[i+1]=rights[i]+right[i];
    int leftsum[N+1][N]={};
    rep(i,N) rep(j,N) leftsum[j+1][i]=leftsum[j][i]+left2[j][i];
    int leftsumsum[N+1][N+1]={};
    rep(i,N+1) rep(j,N) leftsumsum[i][j+1]=leftsumsum[i][j]+leftsum[i][j];
    rep(i,Q){
        int ans=M;
        int l,r;
        cin >> l >> r;
        l--,r--;
        ans-=lefts[l];
        ans+=leftsumsum[l][N]-leftsumsum[l][r+1];
        ans-=rights[N]-rights[r+1];
        cout << ans << endl;
    }
}

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

int main(){
    int n,m;
    cin >> m >> n;
    vector<int> s(n),t(n);
    for(int i=0; i<n; i++){
        cin >> s.at(i) >> t.at(i);
    }
    vector<pair<int,int>> itv(n);
    for(int i=0; i<n; i++){
        itv.at(i).first=t.at(i);
        itv.at(i).second=s.at(i);
    }
    sort(itv.begin(),itv.end());
    
    int ans=0;
    int a=0;
    for(int i=0; i<n; i++){
        if(a<=itv.at(i).second){
            ans += 1;
            a = itv.at(i).first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
    // Your code here!
    // https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/all/ITP1_3_B
    
    int i=0,x=0;
    while(1){
      scanf("%d",&x);
      i++;
      if(x==0)break;
      printf("Case %d: %d\n",i,x);
      
    }
}



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

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "YES"
#define FALSE__ "NO"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

ll N;
ll A, B;

int culc()
{
	ll a = A;
	ll b = B;
	int res  = 0;
	int res2 = 0;
	while (a) {
		res++;
		a /= 10;
	}
	while (b) {
		res2++;
		b /= 10;
	}
	return max(res, res2);
}

signed main()
{
	int mi = 1000;
	cin >> N;
	for (A = 1; A * A <= N; A++) {
		if (N % A != 0) continue;
		B = N / A;
		mi = min(mi, culc());
	}
	cout << mi << endl;
}


Measured memory_bytes: 256