akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector A(N, 0), B(N, 0);
  for (auto &a : A) cin >> a;
  for (auto &a : B) cin >> a;
  long X = 0, Y = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(i) < B.at(i)) X += (B.at(i) - A.at(i)) / 2;
    else Y += A.at(i) - B.at(i);
  }
  cout << ((Y > X) ? "No" : "Yes") << "\n";
}

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

int main()
{
    long long int n;
    cin>>n;
    long long a=26;
    string s;
    while(n>0)
    {
        n--;
        s+=(char)((n%26)+'a');
        n/=26;
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			System.out.println((a - b == b - c) ? "YES" : "NO");
		}
	}
}


Measured memory_bytes: 21844
using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		String s="";
		while(!String.IsNullOrEmpty(s=Console.ReadLine())){
			if(int.Parse(s)==0)break;
			Sol mySol =new Sol(int.Parse(s));
			mySol.Solve();
		}
	}
}

class Sol{
	public void Solve(){
		int cnt=0;
		for(int i=0;i<N;i++)cnt+=ri();
		Console.WriteLine("{0}",cnt);
		
		
		
	}
	int N;
	public Sol(int T){
		N=T/4;
	}




	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

Measured memory_bytes: 5628
#include<iostream>
#include <math.h>
#include <string>
#include <iomanip>
using namespace std;
string s;
long long ans = 0;
void f(int k, long long c, long long sum){
	if (k == s.length()){
		ans += c + sum;
	}
	else{
		f(k + 1, s[k] - '0', c + sum);
		f(k + 1, c*10+s[k] - '0', sum);
	}
}

int main(){
	cin >> s;
	f(1, s[0] - '0', 0);
	cout << ans << endl;
	//cout << keta << endl;
	return 0;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

int Top(int X){
    int res = X;
    while(X / 10 != 0){
        X /= 10;
        res = X;
    }
    return res;
}


int main(){
    int N; cin >> N;
    map<pair<int, int>, int> M;
    for(int i = 1; i <= N; i++){
        int top = Top(i);
        int btm = i%10;
        if(top == 0 || btm == 0) continue;
        M[{top, btm}]++;
    }
    ll ans = 0;
    for(auto m : M) {
        if(m.first.first == m.first.second) ans += pow(m.second, 2);
        else ans += m.second * M[{m.first.second, m.first.first}];
        
    }
    cout << ans << endl;

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main() {
	while (true) {
		string s;
		cin >> s;
		if (s == "0") break;
		int ans = 0;
		for (int i = 0; i < s.length(); i++) {
			int x = s.at(i) - '0';
			ans += x;
		}
		cout << ans << endl;
	}
}


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

using namespace std;
vector < vector <int> > graf;
vector <int> bio;
vector <int> pomoc;
vector <int> BrojPredaka;

void ubaci(int i)
{
	bio[i]=1;
	for (int j=0;j<graf[i].size();j++)
		if (!bio[graf[i][j]])
			ubaci(graf[i][j]);
			
	for (int j=0;j<graf[i].size();j++)
		BrojPredaka[i]=max(BrojPredaka[i],BrojPredaka[graf[i][j]]+1);
		
}

int main(){
	int N , M , x , y , maxi=0;
	cin>>N>>M;
	graf.insert(graf.begin(),N+1,pomoc);
	BrojPredaka.insert(BrojPredaka.begin(),N+1,0);
	bio.insert(bio.begin(),N+1,0);
	for (int i=0;i<M;i++){
		cin>>x>>y;
		graf[y-1].push_back(x-1);
	}
	for (int i=0;i<N;i++) if (!bio[i]) ubaci(i);
	for (int i=0;i<N;i++)
		if (BrojPredaka[i]>maxi)
			maxi=BrojPredaka[i];
	
	cout<<maxi;
	
	return 0;
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using mp = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmx(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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int H,W,M;
set<P> st;

void input() {
  cin >> H >> W >> M;
  REP(i,M) {
    int a,b; cin >> a >> b;
    a--; b--;
    st.insert({a, b});
  }
}

void solver() {
  mp mh, mw;
  int hmxv = 0, wmxv = 0;
  vector<int> hmx, wmx;

  for (auto tmp: st) {
    mh[tmp.first]++; mw[tmp.second]++;
    chmx(hmxv, mh[tmp.first]);
    chmx(wmxv, mw[tmp.second]);
  }

  // 最大値のみ抽出する
  for (auto tmp: mh) {
    if (hmxv == tmp.second) hmx.push_back(tmp.first);
  }
  for (auto tmp: mw) {
    if (wmxv == tmp.second) wmx.push_back(tmp.first);
  }

  int ans = hmxv + wmxv - 1;
  for (auto h : hmx) {
    for (auto w: wmx) {
      // findで見つからなかった場合は st.end() を返す
      if (st.find({h, w}) == st.end()) {
        ans++;
        COUT(ans);
        return;
      }
    }
  }

  COUT(ans);
  return;
}

int main() {
  IOS;
  input();
  solver();

  return 0;
}

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

int main(){
  for (int i = 0;true;i++){
    int x,y;
    cin >> x >> y;

    if(x == 0 && y == 0) break;

    if(x<y){
      cout << x << " " <<  y << endl;
    }
    else {
      cout << y << " " <<  x << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3004
/*********************************
 *                  _
 *  _|_ o._ o._  __|_| _. _|_
 * _>| ||| ||| |(_|| |(_|_>| |
 *               _|
 * @author Amirul islam Al Mamun
 * Knapsack (DP sol) TC - O(n*W)
 *********************************/

#include <cstdio>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stack>
#include <list>
#include <iostream>
#include <assert.h>

/**Define memory set function**/
#define mem(x,y) memset(x,y,sizeof(x))
#define CLEAR(x) memset(x,0,sizeof(x))

/**Define function and object**/
#define pb push_back
#define Sort(v) sort(v.begin(),v.end())
#define _sort(s, n) sort(s, s+n)
#define sqr(x) ((x)*(x))

/**Define constant value**/
#define le 5001
#define ERR 1e-9
#define pi (2*acos(0))
#define PI 3.141592653589793

/**Define input**/
#define scanint(a) scanf("%d",&a)
#define scanLLD(a) scanf("%lld",&a)

typedef long long ll;
using namespace std;

/**********************End*******************/

const int N = 1000002;

ll val[N], w[N], dp[N];

ll max(ll a, ll b) { return (a > b) ? a : b; }

ll knapsack(int n, int W) {
    CLEAR(dp);
    for (int i = 0; i < n; i++)
        for (int j = W; j >= w[i]; j--)
            dp[j] = max(val[i] + dp[j-w[i]], dp[j]);
    return dp[W];
}

int main() {
    int n, W; cin >> n >> W;
    for (int i = 0; i < n; i++) cin >> w[i] >> val[i];
    cout << knapsack(n, W) << endl;
}


Measured memory_bytes: 10496
#include<iostream>
using namespace std;
int main(){
    int s,m,h;
    cin >> s;
    h = s/60/60;
    s = s-h*60*60;
    m = s/60;
    s = s-m*60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
    
}


Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
using P = pair<i64, i64>;
vector<P> ss;
int main() {
  cin >> n;
  ss.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> ss[i].first >> ss[i].second;
  }

  sort(begin(ss), end(ss), [](auto a, auto b) {
    if (a.second == b.second) return a.first < b.first;
    return a.second < b.second;
  });

  vector<i64> ls(n + 1), rs(n + 1);
  {
    i64 x = 0, y = 1e9;
    for (int i = 0; i < n; ++i) {
      x = max(x, ss[i].first);
      y = min(y, ss[i].second);
      ls[i] = max(i64(0), y - x + 1);
    }
  }
  {
    i64 x = 0, y = 1e9;
    for (int i = n - 1; i >= 0; --i) {
      x = max(x, ss[i].first);
      y = min(y, ss[i].second);
      rs[i] = max(i64(0), y - x + 1);
    }
  }

  i64 ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    ans = max(ans, ls[i] + rs[i + 1]);
  }

  for (int i = 0; i < n; ++i) {
    ans = max(ans, ss[i].second - ss[i].first + 1 + ls[n - 1]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
import java.util.Arrays;
import java.util.Scanner;

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

    int X = scanner.nextInt();
    int Y = scanner.nextInt();
    int Z = scanner.nextInt();
    int K = scanner.nextInt();
    long[] A = new long[X];
    long[] B = new long[Y];
    long[] C = new long[Z];
    for (int i = 0; i < X; i++) A[i] = scanner.nextLong();
    for (int i = 0; i < Y; i++) B[i] = scanner.nextLong();
    for (int i = 0; i < Z; i++) C[i] = scanner.nextLong();

    Arrays.sort(A);
    reverse(A);
    Arrays.sort(B);
    reverse(B);
    Arrays.sort(C);
    reverse(C);

    long[] AB = new long[K * K];
    for (int i = 0; i < K && i < X; i++) {
      for (int j = 0; j < K && j < Y; j++) {
        AB[i * K + j] = A[i] + B[j];
      }
    }
    Arrays.sort(AB);
    reverse(AB);

    long[] ABC = new long[K * K];
    for (int i = 0; i < K; i++) {
      for (int j = 0; j < K && j < Z; j++) {
        ABC[i * K + j] = AB[i] + C[j];
      }
    }
    Arrays.sort(ABC);
    reverse(ABC);

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < K; i++) sb.append(ABC[i]).append('\n');
    System.out.println(sb.toString());
  }

  private static void reverse(long[] arr) {
    int i = 0;
    int j = arr.length - 1;
    while (i < j) {
      long tmp = arr[i];
      arr[i] = arr[j];
      arr[j] = tmp;
      i++;
      j--;
    }
  }
}


Measured memory_bytes: 171972
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n, a, d, m;
    cin >> n >> a >> d >> m;

    map<int, int> seq;
    while(--m >= 0){
        int x, y, z;
        cin >> x >> y >> z;

        if(seq.find(y) == seq.end())
            seq[y] = a + d * (y - 1);
        if(seq.find(z) == seq.end())
            seq[z] = a + d * (z - 1);

        if(x == 0)
            swap(seq[y], seq[z]);
        else
            seq[y] = seq[z];
    }

    int k;
    cin >> k;
    int ans;
    if(seq.find(k) == seq.end())
        ans = a + d * (k - 1);
    else
        ans = seq[k];
    cout << ans << endl;

    return 0;
}

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

int n;
char s[20];
int main(){
	cin >> s;

	for(int i = 0;s[i] != '\0';i++)n++;

	for(int i = 0;i < n;i++)
		s[i] -= '0';

	n--;

	long ans = 0;
	for(int S = 0;S < (1 << n);S++) {
		long a = s[0];
		for(int i = 0;i < n;i++) {
			if(S & (1 << i)) {
				ans += a;
				a = s[i + 1];
			}else {
				a *= 10;
				a += s[i + 1];
			}
		}
		ans += a;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
	auto s = readln.chomp.map!(to!char).array;
  auto k = readln.chomp.to!int;
  foreach (i; 0..s.length-1) {
    if (s[i] == 'a') continue;
    if (26 - (s[i] - 'a') > k) continue;
    k -= 26 - (s[i] - 'a');
    s[i] = 'a';
  }
  s[$-1] = ('a' + (s[$-1] - 'a' + k) % 26).to!char;
  s.writeln;
}


Measured memory_bytes: 672
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	string s;

	cin >> s;

	ll ans1 = -1;
	ll ans2 = -1;

	if (s.size() == 2) {
		if (s[0] == s[1]) {
			ans1 = 1;
			ans2 = 2;
		}
	}
	else if (s.size() > 1) {
		REP(i, s.size() - 2) {
			if (s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2]) {
				ans1 = i + 1;
				ans2 = i + 3;
				break;
			}
		}
	}

	cout << ans1 << " " << ans2 << endl;
}

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

#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

const double PI = 3.14;


int main()
{
	uint64_t a;
	cin >> a;

	vector< int > vec( a );

	for( auto &it : vec )
	{
		cin >> it;
	}

	uint64_t total = 0;


	for( int i=0 ; i<a ; i++ )
	{
		for( int i2=i+1 ; i2<a ; i2++ )
		{
			total += vec[ i ] * vec[ i2 ];
		}
	}

	cout << total << endl;

	return 0;
}

Measured memory_bytes: 256
//C
//Author : Sidiq Tri Pratikto
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
//order_of_key(x) = number of elements stricly smaller than x
//find_by_order(x) = return x-th largest element
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);
int arr[11], a[51], b[51], c[51], d[51], ans, N, M, Q;

void generate(int idx, int bef) {
	if (idx == N + 1) {
		int cnt = 0;
		for (int i = 0; i < Q; i++) {
			if (arr[b[i]] - arr[a[i]] == c[i]) cnt += d[i];
		}
		ans = max(ans, cnt);
	} else {
		for (int i = bef; i <= M; i++) {
			arr[idx] = i;
			generate(idx + 1, i);
		}
	}
}

int main() {
	scanf("%d%d%d", &N, &M, &Q);
	for (int i = 0; i < Q; i++) {
		scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
	}
	generate(1, 1);
	printf("%d\n", ans);
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n , m ; 
	cin >> n >> m ; 
	int r , c ; 
	cin >> r >> c ; 
	int ans = n * m - r * m - (n - r)*c; 
	cout << ans << endl;
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <cmath>         // sqrt
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll, string> Tlls;

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b)
{
  // Eucledean algorithm
  while (a)
  {
    if (a < b)
    {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

// Least Common Multiple 最小公倍数
ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

// key: value of prime factor素因数分解
// value: number of prime factor
map<ll, ll> prime_factorization(ll n)
{
  map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

// 約数リスト約数の列挙
vector<ll> get_divisors(const ll n)
{
  vector<ll> divs;
  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++)
  {
    if (n % i == 0)
    {
      divs.push_back(i);
      if (i != n / i)
      {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

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

int main()
{
  const long long INF = 1LL << 60;

  // 入力
  long long h[110000];

  // DP テーブル
  long long dp[110000];
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < N; ++i)
    cin >> h[i];

  // 初期化 (最小化問題なので INF に初期化)
  for (int i = 0; i < 110000; ++i)
    dp[i] = INF;

  // 初期条件
  dp[0] = 0;

  // ループ
  for (int i = 0; i < N; ++i)
  {
    for (int j = 1; j <= K; ++j)
    {
      chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
  }

  // 答え
  cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define y1 shinkle
#define fi first
#define se second
#define bg begin
cs int RLEN=1<<20|1;
inline char gc(){
    static char ibuf[RLEN],*ib,*ob;
    (ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob)?EOF:*ib++;
}
#define gc getchar
inline int read(){
    char ch=gc();
    int res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
    return f?res:-res;
}
inline ll readll(){
    char ch=gc();
    ll res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
    return f?res:-res;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	s[top+1]='\0';return top;
}
template<typename tp>inline void chemx(tp &a,tp b){a=max(a,b);}
template<typename tp>inline void chemn(tp &a,tp b){a=min(a,b);}
cs int N=100;
int main(){
	int a=read(),b=read(),c=read(),d=read();
	int vl=min(a,d);d-=vl;
	if(d>b)vl-=(d-b);
	cout<<vl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n;
vector<int> adjlist[N];
int p[N];
int ct[N][20];
int ANS = 0;
void dfs(int u){
    for (auto v: adjlist[u]){
        if (p[u] == v) continue;
        p[v] = u;
        dfs(v);
        for (int i = 0; i < 20; i++){
            ct[u][i] += ct[v][i];
        }
    }
    int ans[20]; memset(ans,0,sizeof(ans));
    int id = 19;
    for (; id >= 0; id--){
        if (ct[u][id] >= 2) break;
    }
    if (id == -1) id = 0;
    for (; id < 20; id++){
        if (ct[u][id] == 0){
            ANS = max(ANS,id);
            ans[id] = 1;
            break;
        }
    }
    for (; id < 20; id++){
        ans[id] += ct[u][id];
    }
    for (int i = 0; i < 20; i++){
        ct[u][i] = ans[i];
    }
    /*printf("%d ",u);
    for (int i = 0; i < 20; i++){
        printf("%d",ct[u][i]);
    }
    printf("\n");*/
}
int main(){
    scanf("%d",&n);
    for (int i = 1,a,b;i < n; i++){
        scanf("%d%d",&a,&b);
        adjlist[a].push_back(b);
        adjlist[b].push_back(a);
    }
    p[1] = 1;
    dfs(1);
    printf("%d ",ANS);
}


Measured memory_bytes: 25344
s = input()
t = input()

flag = False
idx = 0

for i in range(len(s)-len(t)+1):
    if flag == True:
        break
    for j in range(len(t)):
        if s[len(s)-1-i-j] == '?' or s[len(s)-1-i-j] == t[len(t)-1-j] :
            if j == len(t)-1:
                flag = True
                idx = i
                break
        else:
            break
        
if flag == False:
    print('UNRESTORABLE')
    exit()
    
ans = []
num = 0

idx = len(s)-1-idx-len(t)+1
S1 = s[:idx] + t + s[idx+len(t):]
S1 = S1.replace('?', 'a')
print(S1)

Measured memory_bytes: 3064
n,*h=map(int,open(0).read().split())
a=[0]+[abs(h[1]-h[0])]+[10**8]*(n-2)
for i in range(2,n):
    a[i]=min(a[i-1]+abs(h[i]-h[i-1]),a[i-2]+abs(h[i]-h[i-2]))
print(a[-1])

Measured memory_bytes: 13876
import sys

n = int(input())
ans = 0
if n == 1:
    print(0)
    sys.exit()
ma = int(n**(0.5))+1
for i in range(2,ma):
    j = 1
    k = 0
    while n%i == 0:
        k += 1
        n //= i
    else:
        while j <=k:
            ans += 1
            k -= j
            j += 1
if n != 1:
    ans += 1
print(ans)

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

int main() {
int x,a,b;
cin >> x >> a >> b;
bool flag=true;
if(abs(x-a)>abs(x-b) ) flag=false;
if(flag) cout << "A" << endl;
else cout << "B" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,K;
    cin>>N>>K;
    int A[N];
    string ans="IMPOSSIBLE";
    rep(i,N) {
        cin>>A[i];
        if(A[i]==K) ans="POSSIBLE";
    }
    sort(A,A+N);
    int def=INF;
    rep(i,N-1){
        if(A[i]!=A[i+1]) def=min(def,A[i+1]-A[i]);
    }
    rep(i,N){
        if(abs(A[i]-K)%def==0) ans="POSSIBLE";
    }
    if(K>A[N-1]) ans="IMPOSSIBLE";
    cout << ans << endl;




}


Measured memory_bytes: 1024
from heapq import heapify,heappush, heappop

N=input()
A=map(int, raw_input().split()) 

hq1=A[:N]
heapify(hq1)
sum1=sum(hq1)


T1=[]
T1.append(sum1)

for i in range(N, 2*N):
	x=A[i]
	if hq1[0]<x:
		u=heappop(hq1)
		heappush(hq1,x)
		sum1+=(x-u)
	T1.append(sum1)


hq2=map(lambda x: x*-1, A[2*N:])
sum2=-1*sum(hq2)
heapify(hq2)



T2=[]
T2.append(sum2)

for i in range(2*N-1,N-1,-1):
	x=A[i]
	if x*-1 > hq2[0]<x:
			u=heappop(hq2)
			heappush(hq2,x*-1)
			sum2+=u+x

	T2.append(sum2)


T2.reverse()


ans=float("-inf")
for x, y in zip(T1, T2):
	ans=max(ans , x-y)
print ans


Measured memory_bytes: 72400
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	ll n, a, b;
	cin >> n >> a >> b;
	ll s, t, ans = 0;
	rep(i, n) {
		cin >> t;
		if (i > 0)ans += min(a * (t - s), b);
		s = t;
	}

	cout << ans << endl;

}

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

int dp[105][4][2];

void Main() {
  string s;
  cin >> s;
  int n = s.size();
  int k;
  cin >> k;

  dp[0][0][0] = 1;
  for (int a = 0; a < n; a++) {
    for (int b = 0; b < 4; b++) {
      for (int c = 0; c < 2; c++) {
        int nd = s[a] - '0';
        for (int d = 0; d < 10; d++) {
          int na = a + 1, nb = b, nc = c;
          if (d != 0) nb++;
          if (nb > k) continue;
          if (c == 0) {
            if (d > nd) continue;
            if (d < nd) nc = 1;
          }
          dp[na][nb][nc] += dp[a][b][c];
        }
      }
    }
  }

  int ans = dp[n][k][0] + dp[n][k][1];
  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back;
#define mod 1000000007
#define test cout<<"#"


int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   ll n;
   cin>>n;
   while(n!=0)
   {
      if(n%10==7)
      {
         cout<<"Yes\n";
         return 0;
      }
      n=n/10;
   }
   cout<<"No\n";
}

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

int c[3][3];
bool flag = true;

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

	for (int i = 0; i < 3; i++) {
		int n1 = c[0][i] - c[0][(i + 1)%3];
		int n2 = c[1][i] - c[1][(i + 1)%3];
		int n3 = c[2][i] - c[2][(i + 1)%3];

		if (!(n1 == n2 && n2 == n3))flag = false;
	}

	for (int i = 0; i < 3; i++) {
		int n1 = c[i][0] - c[(i + 1)%3][0];
		int n2 = c[i][1] - c[(i + 1)%3][1];
		int n3 = c[i][2] - c[(i + 1)%3][2];

		if (!(n1 == n2 && n2 == n3))flag = false;
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
N, M = map(int,input().split())
ball = [1 for i in range(N)]
boolball = [False for i in range(N)]
boolball[0] = True
for _ in range(M):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    if boolball[x]:
        boolball[y] = True
    if ball[x] == 1:
        boolball[x] = False
    ball[x] -= 1
    ball[y] += 1

ans = 0
for t in boolball:
    if t:
        ans += 1

print(ans)

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

using namespace std;

int main()
{
    int n = 0,a = 100000, e = 0;
    cin >> n;
    for(int i = 0;i < n;i++){
        a = a + a * 0.05;
        e = a % 1000;
        if(e > 0)a = a + 1000 - e;
    }
    cout << a << endl;

    return 0;
}

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

using namespace std;

#define ll long long
#define pii pair<int,int>

int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans = LLONG_MIN;
	ans = max(ans,a*c);
	ans = max(ans,a*d);
	ans = max(ans,b*c);
	ans = max(ans,b*d);
	cout<<ans<<endl;
}

Measured memory_bytes: 3604
N = int(input())
l = list(map(int,input().split(' ')))

i = 0
count = 0
flag =1
while flag :
    flag = 0
    for j in range(N-1,i,-1):
        if l[j-1] > l[j]:
            l[j-1],l[j] = l[j],l[j-1]
            count +=1
            flag =1
    i+=1

print(' '.join(list(map(str,l))))
print(count)



Measured memory_bytes: 5604
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,d,a;
    cin>>n>>d>>a;
    vp v(n);
    rep(i,n)cin>>v[i].fi>>v[i].se;
    SORT(v);
    vi x(n),h(n);
    rep(i,n)x[i]=v[i].fi,h[i]=v[i].se;
    int ans=0;
    vi t(n+1);
    int ac=0;
    rep(i,n){
        ac-=t[i];
        int dm=h[i]-ac*a;
        if(dm>0){
            int c=(dm+a-1)/a;
            ans+=c;
            ac+=c;
            int j=upper_bound(all(x),x[i]+2*d)-x.begin();
            t[j]+=c;
        }
    }
    cout<<ans<<endl;
}

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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
 
using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

signed main(){
    io();
    int r; cin >> r;
    cout << r*r << '\n';
    return 0;
}

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

const int N = 200;
const int Q = 1000000007;

char s[2][100];

int main() {
    int n;
    scanf("%d" , &n);
    scanf("%s%s" ,  s[0] , s[1]);
    long long res = 1;
    int pre = -1;
    for (int i = 0 ; i < n ; ) {
        if (s[0][i] == s[1][i]) {
            if (pre == -1) {
                res = res * 3 % Q;
            } else if (pre == 1) {
                res = res * 2 % Q;
            } else {
                res = res * 1 % Q;
            }
            pre = 1;
            i += 1;
        } else {
            if (pre == -1) {
                res = res * 6 % Q;
            } else if (pre == 1) {
                res = res * 2 % Q;
            } else {
                res = res * 3 % Q;
            }
            pre = 2;
            i += 2;
        }
    }
    cout << res << endl;

}


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

int n;
ll a[100001];
ll dp[100001];
const ll inf=9999999999;

int main(){
 ios::sync_with_stdio(false);
 cin.tie(0);
 cin>>n;
 for(int i=0;i<n;i++){
  cin>>a[i];
 }
 for(int i=0;i<100001;i++){
  dp[i]=inf;
 }
 for(int i=0;i<n;i++){
  *lower_bound(dp,dp+n,a[i])=a[i];
 }
 for(int i=0;i<100001;i++){
  if(dp[i]==inf){
   cout<<i<<endl;
   return 0;
  }
 }
 return 0;
}

Measured memory_bytes: 4692
#include<bits/stdc++.h>
#define debug(x) cout<<#x<<"::"<<x<<endl;
using namespace std;
typedef long long ll;

bool ispalindrome(string s,int l,int r)
{
	//debug(l);
	//debug(r);
	int j=r;
	for(int i=l;i<=(r+l)/2;i++)
	{
		if(s[i]!=s[j])
		{
			// debug(s[i]);
			// debug(s[j]);
			return 0;
		}
		j--;
	}
	return 1;
}

void solve()
{
	string s;
	cin>>s;
	int n=s.length();
	int flag=1;
	// debug(ispalindrome(s,0,n-1));
	// debug(n-1);
	// debug(ispalindrome(s,0,((n-1)/2-1)));
	// debug((n-1)/2-1);
	// debug(ispalindrome(s,(n+3)/2-1,n-1));
	if(n%2)
	{
		if(ispalindrome(s,0,n-1) && ispalindrome(s,0,((n-1)/2-1)) && ispalindrome(s,(n+3)/2-1,n-1))
		{
			cout<<"Yes\n";
			flag=0;
		}
		
	}
	if(flag)
	{
		cout<<"No\n";
	}
}

int main()
{
	
	int t;
	t=1;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

        String S = scanner.next();

        StringBuilder sb = new StringBuilder(S);

        S = sb.reverse().toString();

        // dream, dreamer, erase, eraser

        String[] keywords = {
                "dream", "dreamer", "erase", "eraser"
        };

        List<String> reversedKeywords = new ArrayList();

        for (String s : keywords) {
            reversedKeywords.add((new StringBuilder(s)).reverse().toString());
        }

        for (int i = 0; i < S.length();) {
            boolean found = false;
            for (String reversed : reversedKeywords) {
                if (S.startsWith(reversed, i)) {
                    i += reversed.length();
                    found = true;
                    break;
                }
            }
            if (!found) {
                System.out.println("NO");
                return;
            }
        }

        System.out.println("YES");
    }
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n;
  cin >> n;
  vll h(n);
  REP(i, n)
  cin >> h[i];

  vll num(n, 0);
  ll now = 0;
  REP(i, n){
    num[n-1-i]=now;
    now++;
    if(n-2-i < 0)
      break;
    if(h[n-2-i] < h[n-1-i])
      now = 0;
  }
  
  ll ans = 0;
  REP(i, n)
    ans = max(ans, num[i]);
  
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int h,w;
    cin >> h >> w;
    string s[h];
    rep(i,h)cin >> s[i];

    int a[h][w];
    int b[h][w];
    rep(i,h){
        rep(j,w){
            a[i][j] = 0;
            b[i][j] = 0;
        }
    }

    int f[w] = {};
    rep(i,h){
        rep(j,w){
            if(s[i][j] == '#'){
                f[j] = 1;
            }
        }
    }

    rep(j,w){
        a[0][j] = 1;
        b[h-1][j] = 1;
    }

    int c = 0;
    srep(i,1,h-1){
        b[i][0] = 1;
    }
    c = 1;
    int before = 0;
    rep(j,w){
        if(f[j] == 1){
            rep(i,h){
                if(s[i][j]=='#'){
                    srep(k,before,j+1){
                        if(c%2==1){
                            b[i][k] = 1;
                        }else{
                            a[i][k] = 1;
                        }
                    }
                }
            }
            srep(i,1,h-1){
                if(c%2==1){
                    a[i][j] = 1;
                }else{
                    b[i][j] = 1;
                }
            }
            c++;
            before = j;
        }
    }

    rep(i,h){
        rep(j,w){
            if(a[i][j] == 0){
                cout << '.';
            }else{
                cout << '#';
            }
        }
        cout << endl;
    }
    cout << endl;
    rep(i,h){
        rep(j,w){
            if(b[i][j] == 0){
                cout << '.';
            }else{
                cout << '#';
            }
        }
        cout << endl;
    }
    
    return 0;
}
 
 


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

A, B, C = map(int, input().split())

K = int(input())

cnt = 0

while A >= B:
    B *= 2
    cnt += 1

while B >= C:
    C *= 2
    cnt += 1

if cnt > K:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 61644
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.Unboxed
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

maximumOrDefault d xs = if null xs then d else maximum xs
pairs [] = []
pairs (x:xs) = [(x,y) | y <- xs] ++ pairs xs

pillars :: [(Int, Int)] -> UArray (Int, Int) Bool
pillars xs = runSTUArray $ do
    arr <- newArray ((0,0), (5000, 5000)) False :: ST s (STUArray s (Int,Int) Bool)
    forM_ xs $ flip (writeArray arr) True
    return arr

main = do
    n <- getInt
    when (n/=0) $ do
        ds <- map (apply2 (,)) <$> replicateM n getInts
        let arr = pillars ds
        print $ maximumOrDefault 0 [dx ^ 2 + dy ^ 2| ((x1,y1),(x2,y2)) <- pairs ds, let dx = x2 - x1, let dy = y2 - y1, let (x3,y3) = (x1-dy,y1+dx), let (x4,y4) = (x2-dy,y2+dx), 0<=x3, x3<=5000, 0<=y3, y3<=5000, 0<=x4, x4<=5000, 0<=y4, y4<=5000, arr!(x3,y3), arr!(x4,y4)]
        main

Measured memory_bytes: 46176
import java.util.*;

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

		for (int i = 0; i < 3; i++) {
			N[i] = sc.nextInt();
		}
		sc.close();

		Arrays.sort(N);

		System.out.println(10 * N[2] + N[1] + N[0]);
	}
}


Measured memory_bytes: 22740
#include <iostream>
#include <cstdio>
#define N 65
using namespace std;

typedef long long ll;
ll M = 1e9 + 7;
ll n, s, c[2][N];
int main()
{
	ll i, t;
	cin >> n;
	while (n--) {
		scanf("%lld", &t);
		for (i = 0; i < N; i++, t /= 2) {
			c[t % 2][i]++;
		}
	}
	for (i = 0; i < N; i++) {
		s = ((1LL << i) % M * c[0][i] % M * c[1][i] % M + s) % M;
	}
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
     
    using namespace std;
     
    int main(){
    	int h,w,a,b;
    	cin>>h>>w>>a>>b;
    	for(int i=0;i<h;i++){
    		for(int j=0;j<w;j++){
    			if((i<b)^(j<a))
    				cout<<1;
    			else
    				cout<<0;
    		}
    		cout<<"\n";
    	}
    }

Measured memory_bytes: 1280
n, k = map(int, input().split())
d = set(map(int, input().split()))
d ^= {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}

while True:
    if d >= set(map(int, list(str(n)))):
        print(n)
        break
    n += 1


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

struct P {
    int i, j;
    char c;
};

void solve() {
    string s, t;
    cin >> s >> t;
    int N = s.size(), M = t.size();
    vector<vector<int>> dp(N + 1, vector<int>(M + 1, -1));
    vector<vector<P>> dp2(N + 1, vector<P>(M + 1, {-1, -1, 0}));
    dp[0][0] = 0;
    dp2[0][0] = {-1, -1, 0};
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (s[i] == t[j]) {
                if (dp[i + 1][j + 1] < dp[i][j] + 1) {
                    dp[i + 1][j + 1] = dp[i][j] + 1;
                    dp2[i + 1][j + 1] = {i, j, s[i]};
                }
            }
            if (dp[i + 1][j] < dp[i][j]) {
                dp[i + 1][j] = dp[i][j];
                dp2[i + 1][j] = {i, j, 0};
            }
            if (dp[i][j + 1] < dp[i][j]) {
                dp[i][j + 1] = dp[i][j];
                dp2[i][j + 1] = {i, j, 0};
            }
        }
        
        if (dp[i + 1][M] < dp[i][M]) {
            dp[i + 1][M] = dp[i][M];
            dp2[i + 1][M] = {i, M, 0};
        }
    }
    for (int j = 0; j < M; j++) {
        if (dp[N][j + 1] < dp[N][j]) {
            dp[N][j + 1] = dp[N][j];
            dp2[N][j + 1] = {N, j, 0};
        }
    }
    
    int nowi = N, nowj = M;
    string ans;
    while(!(nowi == -1 || nowj == -1)) {
        if (dp2[nowi][nowj].c != 0) {
            ans += dp2[nowi][nowj].c;
        }
        int newi = dp2[nowi][nowj].i;
        int newj = dp2[nowi][nowj].j;
        nowi = newi;
        nowj = newj;
    }
    reverse(all(ans));
    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 141312
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> result(4, vector<int>(13,0));

    for (int a = 0; a < n; ++a) {
        string s;
        int tmp;
        cin >> s >> tmp;

        if(s == "S") result.at(0).at(tmp - 1) = 1;
        if(s == "H") result.at(1).at(tmp - 1) = 1;
        if(s == "C") result.at(2).at(tmp - 1) = 1;
        if(s == "D") result.at(3).at(tmp - 1) = 1;
    }

    for (int h = 0; h < 4; ++h) {
        for (int k = 0; k < 13; ++k) {
            if(result.at(h).at(k) != 1){
                if(h == 0) cout << "S" << " " << k+1 << endl;
                if(h == 1) cout << "H" << " " << k+1 << endl;
                if(h == 2) cout << "C" << " " << k+1 << endl;
                if(h == 3) cout << "D" << " " << k+1 << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3184
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 998244353

N, M = list(map(int, sys.stdin.readline().split()))


def get_factorials(max, mod=None):
    """
    階乗 0!, 1!, 2!, ..., max!
    :param int max:
    :param int mod:
    :return:
    """
    ret = [1]
    n = 1
    if mod:
        for i in range(1, max + 1):
            n *= i
            n %= mod
            ret.append(n)
    else:
        for i in range(1, max + 1):
            n *= i
            ret.append(n)
    return ret


def mod_invs(max, mod):
    """
    逆元のリスト 0 から max まで
    :param max:
    :param mod:
    :return:
    """
    invs = [1] * (max + 1)
    for x in range(2, max + 1):
        invs[x] = (-(mod // x) * invs[mod % x]) % mod
    return invs


factorials = get_factorials(M * 3 // 2 + N, MOD)
finvs = []
inv = 1
for i in mod_invs(M * 3 // 2 + N, MOD):
    inv = inv * i % MOD
    finvs.append(inv)


def ncr(n, r, mod=None):
    """
    scipy.misc.comb または scipy.special.comb と同じ
    組み合わせの数 nCr
    :param int n:
    :param int r:
    :param int mod: 3 以上の素数であること
    :rtype: int
    """
    if n < r:
        return 0

    # return factorials[n] * mod_inv(factorials[r], mod) * mod_inv(factorials[n - r], mod) % mod
    return factorials[n] * finvs[r] * finvs[n - r] % mod


# 合計が M*3 となる数列の数
# c1 = ncr(M * 3 + N - 1, N - 1, MOD)
# (1) 合計が M*3 で、奇数の数が M 以下である数列の数
c1 = 0
for odds in range(M * 3 % 2, M + 1, 2):
    half = (M * 3 - odds) // 2
    # 合計が half の数列を 2 倍して、odds 個選んで 1 を足す
    c1 += ncr(half + N - 1, N - 1, MOD) * ncr(N, odds, MOD)
    c1 %= MOD

# (2) max が M*2 より大きく、奇数の数が M 以下である数列の数
# c2 = 0
# for mx in range(M * 2 + 1, M * 3 + 1):
#     rem = M * 3 - mx
#     oddmax = M if mx % 2 == 0 else M - 1
#     for odds in range(rem % 2, min(oddmax, rem) + 1, 2):
#         half = (rem - odds) // 2
#         c2 += ncr(half + N - 2, N - 2, MOD) * ncr(N - 1, odds, MOD) * N
#         c2 %= MOD
# print((c1 - c2) % MOD)


# (2) max が M*2 より大きく、奇数の数が M 以下である数列の数
# => 合計が M で、1 要素目が 0 より大きい、奇数が M 以下である数列の数 * N
# 1 要素目に M*2 を足せば (2) になる
# a. 合計が M で奇数が M 以下
c2a = 0
# b. 1 要素目が 0 である数列の数
c2b = 0
for odds in range(M % 2, M + 1, 2):
    half = (M - odds) // 2
    c2a += ncr(half + N - 1, N - 1, MOD) * ncr(N, odds, MOD)
    c2a %= MOD
    c2b += ncr(half + N - 2, N - 2, MOD) * ncr(N - 1, odds, MOD)
    c2b %= MOD

c2 = (c2a - c2b) * N
print((c1 - c2) % MOD)


Measured memory_bytes: 143892
program fennec_vs_monster
  implicit none
  integer :: n, k, h(200000) = 0
  read(*,*) n, k
  if (k >= n) then
    write(*,'(i0)') 0
    stop
  end if
  read(*,*) h(1:n)
  call quick_sort(h(1:n))
  write(*,'(i0)') sum(int(h(1:n-k),8))
contains
  recursive subroutine quick_sort(a)
    integer, intent(inout) :: a(:)
    integer :: n, l, r, m
    integer :: p
    n = size(a,1)
    l = 1
    r = n
    m = (n+1)/2
    p = a(l)+a(m)+a(r)-max(a(l),a(m),a(r))-min(a(l),a(m),a(r))
    do
      do while (a(l) < p)
        l = l+1
      end do
      do while (a(r) > p)
        r = r-1
      end do
      if (l >= r) exit
      a(l) = xor(a(l),a(r))
      a(r) = xor(a(l),a(r))
      a(l) = xor(a(l),a(r))
      l = l+1
      r = r-1
    end do
    if (l-1 > 1) call quick_sort(a(1:l-1))
    if (n > r+1) call quick_sort(a(r+1:n))
  end
end program fennec_vs_monster

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
/*

*/
int main(){
  ll N; cin>>N;
  ll ans=0;
  rep(i,N){
    ll a; cin>>a;
    if(i%2==1) continue;
    if(a%2==1) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628