akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;


int dx8[8] = { -1,-1,-1, 0, 1, 1, 1, 0 };
int dy8[8] = { -1, 0, 1, 1, 1, 0,-1,-1 };
void dfs(int nowx,int nowy,vector<pair<int, int>>&sames, vector<vector<int>>&field, vector<vector<int>>&memo) {
	
	for (int way = 0; way < 8; ++way) {
		int nextx = nowx + dx8[way];
		int nexty = nowy + dy8[way];
		if (field[nexty][nextx] && !memo[nexty][nextx]) {
			memo[nexty][nextx] = true;
			sames.push_back(make_pair(nexty, nextx));
			dfs(nextx, nexty, sames, field, memo);
		}
	}
}

int main() {
	vector<map<int, int>>mps;
	while (1) {
		string a;
		int N; getline(cin, a);
		N = stoi(a);
		if (!N)break;
		vector<vector<int>>field(N+2, vector<int>(100));
		vector<vector<int>>memo(N+2, vector<int>(100, 0));
		for (int i = 0; i < N; ++i) {
			string st; getline(cin, st);
			for (int j = 0; j < st.size(); ++j) {
				if (st[j] == '*')field[i+1][j + 1] = true;
			}
		}

		map<int, int>ans;
		for (int i = 1; i < N+2; ++i) {
			for (int j = 1; j < 99; ++j) {
				if (field[i][j] && !memo[i][j]) {
					memo[i][j] = true;
					vector<pair<int, int>>sames(1,make_pair(i,j));
					dfs(j, i, sames, field, memo);
					sort(sames.begin(), sames.end());
					int h = sames.back().first - sames.front().first + 1;
					int w = (sames.size() -2* h+4);
					ans[h*w/2]++;
				}
			}
		}
		mps.emplace_back(ans);
	}
	for (int i = 0; i < mps.size(); ++i) {
		map<int, int>mp(mps[i]);
		for (auto&&m : mp) {
			cout << m.first << " " << m.second << endl;
		}
		if (i == mps.size() - 1) {

		}
		else {
			for (int j = 0; j < 10; ++j) {
				cout << '-';
			}
			cout << endl;
		}
	}
	return 0;
}

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

#define ld			long double
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD         1000000007
#define sd(t) 		scanf("%d",&(t))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define hii 		cout << "hii" << endl
#define okay 		cout << "okay" << endl
#define hey 		cout << "hey" << endl
# define M_PI           3.14159265358979323846 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);	
    
}

clock_t time_p=clock();
void starboy1299()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

const int N = 2e5+5;
int arr[N];

void solve()
{
	int n;
	cin >> n;

	map<int, int> mp;
	rep(i, 0, n){
		cin >> arr[i];
		mp[arr[i]]++;
	}

	for(int i=1; i<=n; i++){
		cout << mp[i] << endl;
	}

}			 	

int32_t main(){
	fast();
    int t = 1;
    // cin>> t;
    while(t--){
    	solve();
    }
	starboy1299();
}




Measured memory_bytes: 17824
#include <iostream>

using namespace std;
int main(){
    int N, A, B, cnt, counter;
    cin >> N>>A>>B;
    for(int i=1;i<=N;i++){
        int j = i;
        counter = 0;
        while(j>0){
            counter+=j%10;
            j = j/10;
        }
        if(counter>=A && counter<=B) cnt+=i;
    }
    cout << cnt <<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

ll fac[444444], inv[444444], finv[444444];

void COMinit()
{
	fac[0] = 1;
	fac[1] = 1;
	finv[0] = 1;
	finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<444444; i++){
		fac[i] = fac[i-1]*i%MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
}

ll COM(int n, int k){
	if(n < k) return 0;
	if(n < 0 or k < 0) return 0;
	return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

signed main()
{
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	ll ans=0;
	COMinit();
	for(int i=0; i<W-B; i++){
		ans += (COM(H-A+B-1+i, H-A-1) % MOD)*(COM(W+A-B-2-i, A-1) % MOD) % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 10624
A, B = [int(i) for i in input().split()]

def calc(i):
  rem = i % 4
  if rem == 0:
    return i
  elif rem == 1:
    return 1
  elif rem == 2:
    return i + 1
  elif rem == 3:
    return 0

print(calc(A - 1) ^ calc(B))


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

int main() {
int N,s;
cin >> N;
s=N %10;
  if(s == 2||s ==4||s==5||s==7||s==9){
  cout  <<  "hon"  <<  endl;
  }
  else if(s==3){
  cout << "bon" << endl;
  }
  else cout << "pon" << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define INF 1234567890

int manju[123456];
int before_manju[123456];

int manju_num;
int box_num;

// ??±?????\????\????
int can_box[12345];

// ??±?????????
int box_exp[500];

int memo[12345][1000];
int answer;

// x = manju
// y = box

int dp(int x, int y){
	if (x <= 0) return 0;
	if (memo[x][y] >= 0) return memo[x][y];
	if (y == 0) return INF;
	else{
		return memo[x][y] = min(dp(x, y - 1), dp(x - can_box[y - 1], y - 1) + box_exp[y - 1]);
	}
}

int main(){
	int buf = 0;
	memset(memo, 255, sizeof(memo));
	scanf("%d%d", &manju_num, &box_num);
	for (int a = 0; a < manju_num; a++){
		scanf("%d", &before_manju[a]);
	}
	for (int a = 0; a < box_num; a++){
		scanf("%d%d", &can_box[a], &box_exp[a]);
	}
	sort(before_manju, before_manju + manju_num);
	reverse_copy(before_manju, before_manju + manju_num, manju);
	for (int a = 1; a <= manju_num; a++){
		buf += manju[a - 1];
		answer = max(answer, buf - dp(a, box_num));
	}
	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 51156
N, M = list(map(int,input().split()))
base = N
if N%2==1:
  for i in range(1,M+1):
    print(i,base-i)
else:
  if N%4==0:
    candidate = []
    for i in range(1,N//4+1):
      candidate.append((i,N+1-i))
    for i in range(N//4+1,N//2):
      candidate.append((i,N-i))
  else:
    candidate = []
    for i in range(1,N//4+1):
      candidate.append((i,N+1-i))
    for i in range(N//4+1,N//2):
      candidate.append((i,N-i))
  for i in range(M):
    a,b = candidate[i]
    print(a,b)

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

long long dp[51][51][2501];

int main(){
    int n, a;
    int x[51];

    scanf("%d %d", &n, &a);
    for(int i = 1; i <= n; ++i) cin >> x[i];


    dp[0][0][0] = 1;
    for(int i = 1; i <= n; ++i){
        for(int j = 0; j <= i; ++j){
            for(int k = 0; k <= 50 * j; ++k){
                if(k < x[i]){
                    dp[i][j][k] = dp[i - 1][j][k];
                }
                else{
                    dp[i][j][k] = dp[i - 1][j - 1][k - x[i]] + dp[i - 1][j][k];
                }
            }
        }
    }

    long long ans = 0;
    for(int i = 1; i <= n; ++i){
        ans += dp[n][i][i * a];
    }

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


Measured memory_bytes: 48640
#include <iostream>
#include <cmath>

bool isPrime(int n)
{
	int ub = (int)std::sqrt((float)n);
	for (int i=2; i<=ub; i++) {
		if (n%i == 0) return false;
	}
	return true;
}

int main()
{
	int n;
	while (std::cin >> n) {
		for (int p=n; p>=2; p--) {
			if (isPrime(p) && isPrime(p-2)) { std::cout << p-2 << " " << p << std::endl; break; }
		}
	}
	return 0;
}



Measured memory_bytes: 2992
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	double ans;
	if (!d) {
		double p = (double)n / (n * n);
		ans = (double)p * (m - 1);
	}
	else {
		double p = (double)2 * (n - d) / (n * n);
		ans = (double)p * (m - 1);
	}

	cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define long long long // for codeforces

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

  long sq = 1;
  while(sq*sq<n) sq++;

  while(n%sq!=0) sq--;

  long l = n/sq;
  int ans=0;
  while(l>0) ans++,l/=10;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, M;
  cin >> N >> M;
  ll ans = 0;
  if(N == 1 && M == 1) {
    ans = 1;
  } else if(N == 1) {
    ans = M - 2;
  } else if(M == 1) {
    ans = N - 2;
  } else {
    ans = N*M - (N+M-2)*2;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<algorithm>
#include<iostream>

using namespace std;
int main ()
{
    int n,m;
    char tmp[21];
    while (scanf ("%d%d",&n,&m)!=EOF)
    {
        scanf ("%s",tmp);
        if (tmp[n]!='-') printf ("No\n");
        else
        {
            int falg=1;
            for (int i=0;i<n;i++)
                if (tmp[i]<'0'||tmp[i]>'9')
            {
                falg=0;
                break;
            }
            for (int i=n+1;i<n+m+1;i++)
            if (tmp[i]<'0'||tmp[i]>'9')
            {
                falg=0;
                break;
            }
            printf ("%s\n",falg?"Yes":"No");
        }
    }
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
k = int(readline())
x = list(map(int, readline().split()))
cnt = 0
for i in range(n):
    cnt += min((k - x[i]) * 2, x[i] * 2)
print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define be(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

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

ll h[100010];
	ll dp[100010];
int main() {
	ll n,k; cin >> n >> k;
	rep(i,n) {
		cin >> h[i];
		dp[i] = INF;
	}
	dp[0]=0;
	rep(i,n) {
		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: 1792
from sys import stdin
N = int(stdin.readline().rstrip())
V = [int(_) for _ in stdin.readline().rstrip().split()]
C = [int(_) for _ in stdin.readline().rstrip().split()]
ans=0
for i in range(N):
    if V[i]-C[i] > 0:
        ans+=V[i]-C[i]
print(ans)

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


struct DeliciousnessWithIndices {
    ll deliciousness;
    int i, j, k;
    DeliciousnessWithIndices(ll _deli, int _i, int _j, int _k) {
        deliciousness = _deli;
        i = _i, j = _j, k = _k;
    }
};


bool operator <(const DeliciousnessWithIndices& x, const DeliciousnessWithIndices& y) {
    return tie(x.deliciousness, x.i, x.j, x.k) < tie(y.deliciousness, y.i, y.j, y.k);
}

bool operator >(const DeliciousnessWithIndices& x, const DeliciousnessWithIndices& y) {
    return tie(x.deliciousness, x.i, x.j, x.k) > tie(y.deliciousness, y.i, y.j, y.k);
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    int X, Y, Z, K;
    vector<ll> A_list, B_list, C_list;
    cin >> X >> Y >> Z >> K;

    for (int i = 0; i < X; i++) {
        ll tmp;
        cin >> tmp;
        A_list.emplace_back(tmp);
    }
    for (int i = 0; i < Y; i++) {
        ll tmp;
        cin >> tmp;
        B_list.emplace_back(tmp);
    }
    for (int i = 0; i < Z; i++) {
        ll tmp;
        cin >> tmp;
        C_list.emplace_back(tmp);
    }

    sort(A_list.begin(), A_list.end(), greater<ll>());
    sort(B_list.begin(), B_list.end(), greater<ll>());
    sort(C_list.begin(), C_list.end(), greater<ll>());
    priority_queue<DeliciousnessWithIndices> current_in_comparison;
    current_in_comparison.emplace(A_list.at(0) + B_list.at(0) + C_list.at(0), 0, 0, 0);
    vector<ll> result;
    set<tuple<int, int, int>> visited;
    visited.emplace(0, 0, 0);

    while (result.size() < K) {
        DeliciousnessWithIndices cur_top = current_in_comparison.top();
        current_in_comparison.pop();
        result.emplace_back(cur_top.deliciousness);
        int i = cur_top.i, j = cur_top.j, k = cur_top.k;
        if (i + 1 < X && visited.find(tuple<int, int, int>(i + 1, j, k)) == visited.end()) {
            ll deli = A_list.at(i + 1) + B_list.at(j) + C_list.at(k);
            current_in_comparison.emplace(deli, i + 1, j, k);
            visited.emplace(i + 1, j, k);
        }
        if (j + 1 < Y && visited.find(tuple<int, int, int>(i, j + 1, k)) == visited.end()) {
            ll deli = A_list.at(i) + B_list.at(j + 1) + C_list.at(k);
            current_in_comparison.emplace(deli, i, j + 1, k);
            visited.emplace(i, j + 1, k);
        }
        if (k + 1 < Z && visited.find(tuple<int, int, int>(i, j, k + 1)) == visited.end()) {
            ll deli = A_list.at(i) + B_list.at(j) + C_list.at(k + 1);
            current_in_comparison.emplace(deli, i, j, k + 1);
            visited.emplace(i, j, k + 1);
        }
    }

    for (auto deli : result) {
        cout << deli << "\n";
    }
}

Measured memory_bytes: 1024
from sys import exit
from math import gcd

def eratosthenes(n):
    '''
    n以下の整数の素数判定/列挙 (n > 1)
    O(NloglogN)
    '''
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    min_factor = [-1] * (n+1)
    min_factor[0] = 0
    min_factor[1] = 1
    
    for i in range(2, n+1):
        if is_prime[i]:
            min_factor[i] = i
            for j in range(i*2, n+1, i):
                is_prime[j] = False
                if min_factor[j] == -1:
                    min_factor[j] = i

    return min_factor


n = int(input())
a = list(map(int, input().split()))

l = eratosthenes(10**6+1)

flag = True
used = [False] * (10**6+1)
for v in a:
    s = set()
    while v > 1:
        if l[v] not in s:
            if used[l[v]]:
                flag = False
                break
            else:
                s.add(l[v])
                used[l[v]] = True
        
        v //= l[v]

if flag:
    print('pairwise coprime')
    exit()

g = 0
for v in a:
    g = gcd(g, v)

print('setwise coprime' if g == 1 else 'not coprime')

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

#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

vector<ll> L, R;

ll merge(vector<ll> &a, ll left, ll mid, ll right) {
  ll n = a.size();
  ll n1 = mid - left;
  ll n2 = right - mid;
  rep(i, n1) L[i] = a[left + i];
  rep(i, n2) R[i] = a[mid + i];
  L[n1] = R[n2] = INF;

  ll li = 0, ri = 0, ret = 0;
  for (ll i = left; i < right; i++) {
    if (L[li] <= R[ri]) {
      a[i] = L[li++];
    } else {
      a[i] = R[ri++];
      ret += n1 - li;
    }
  }
  return ret;
}

ll merge_sort(vector<ll> &a, ll left, ll right) {
  if (right - left > 1) {
    ll mid = (left + right) / 2;
    ll v1 = merge_sort(a, left, mid);
    ll v2 = merge_sort(a, mid, right);
    ll v3 = merge(a, left, mid, right);
    return v1 + v2 + v3;
  } else {
    return 0;
  }
}

ll inversion_number(vector<ll> &a) {
  ll n = a.size();
  L.resize(n / 2 + 2);
  R.resize(n / 2 + 2);

  return merge_sort(a, 0, n);
}

void solve() {
  ll n; cin >> n;
  vector<ll> a(n); rep(i, n) cin >> a[i];

  outl(inversion_number(a));
}

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

  solve();
}



Measured memory_bytes: 5924
#include<bits/stdc++.h>
using namespace std;
string s;
char c[200001]={'T'};
int lens,m=0;
int main(){
	cin>>s;
	lens=s.size();
	for(int i=0;i<lens;i++){
		if(s[i]=='S'){
			m++;c[m]='S';			
		}
		else{
			if(c[m]=='S')m--;
			else {m++;c[m]='T';}	
		}
	}
	cout<<m<<endl;
	
}

Measured memory_bytes: 772
#include<iostream>

using namespace std ;
int main()
{
    char b;
    cin>>b;

    if(b=='T'){
        cout<<"A"<<endl;
    }

    else if(b=='A'){
        cout<<"T"<<endl;
    }

    else if(b=='G'){
        cout<<"C"<<endl;
    }
    else if(b=='C'){
        cout<<"G"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import Data.List
main = do
    s <- group <$> getLine
    k <- readLn
    let h = head s
        l = last s
        inner = sum $ map (\g -> (length g) `div` 2) s
        inter | head h /= head l = 0
              | otherwise = lh `div` 2 + ll `div` 2 - (lh+ll) `div` 2
              where lh = length h
                    ll = length l
    print $ if length s == 1 then (head (map length s) * k) ` div` 2 else inner * k - inter * (k-1)

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define inf 100000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(void) {
    int h, n; cin >> h >> n;
    int a[n+5], b[n+5];
    rep(i, n) cin >> a[i] >> b[i];
    int dp[n+5][h+5];
    rep(i,n+2) rep(j, h+2) dp[i][j] = inf;
    dp[0][h] = 0;
    rep(i, n) {
        rep(mode,2) {
            if(mode)
            for(int j=h;j>=0;j--) {
                if(j>=a[i]){
                    dp[i+1][j-a[i]] = min(dp[i+1][j-a[i]],dp[i][j]+b[i]);
                    dp[i+1][j-a[i]] = min(dp[i+1][j-a[i]],dp[i+1][j]+b[i]);
                }
                else
                    dp[i+1][0] = min(dp[i+1][0],dp[i][j]+b[i]);
                
                dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
            }
            else
                for(int j=h;j>=0;j--) {
                    if(j>=a[i]){
                        dp[i][j-a[i]] = min(dp[i][j-a[i]],dp[i][j]+b[i]);
                    }
                    else
                        dp[i][0] = min(dp[i][0],dp[i][j]+b[i]);
                }
        }
    }
    /*rep(i, n+1) {
        rep(j, h+1) {
            if(dp[i][j]==inf)
                printf("%2d ",-1);
            else
                printf("%2d ",dp[i][j]);
        }puts("");
    }*/
    cout << dp[n][0] << endl;
}



Measured memory_bytes: 39424
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const long long INF = 1LL << 60;

int a,b,c,d;

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

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	int s;
	int a;
	int i = 1;
	int ans;
	map<int,int> as;

	cin >> s;

	a = s;
	as[a] = i;

	i++;
	while(1){
		if (a % 2 == 0){
			a = a / 2; 
		}else{
			a = 3 * a + 1;
		}

		if (as.count(a) == 0){
			as[a] = i;
			i++;
		}else{
			ans = i;
			break;
		}
	}

	printf("%d", ans);

	return 0;
}



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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<vector<int> > ivve;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define up         upper_bound
#define setp       setprecision
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define spc(x)     cout<<fixed<<setp(x)

const   long long  inf = 1e18;
const   long long  cs =  200005;
const   long long  mod = 1000000007;
const   double     PI =  2 * acos(0.0);
void solve()
{
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;
    
    cin>>n;
    m=n;
    while(n>0)
    {
        cnt+=n%10;
        n/=10;
    }
    if(m%cnt) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n; cin>>n;
    //string s; cin>>s;
    //if() cout<<""<<endl;
    //else cout<<""<<endl;
    cout<<n+n*n+n*n*n<<endl;
    return 0;
}

Measured memory_bytes: 3632
/*
   AOJ 2141 Girls' Party
   2019.3.26 bal4u
   Josephus問題。1から数えてN番目のひとを外す。
   ただし、途中最大１回は、Nではなく、N+1にすることができる。
   輪の人数が最大200人なので、シュミュレーションして解く。
   人数が10万なら、他の方法を考えるしかない。
   計算量は最大 O(N^3) 
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//// 入力処理
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()  // 非負整数の入力
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int ins(char *s)  // 文字列の入力　スペース以下の文字で入力終了
{
	char *p = s;
	do *s = gc();
	while (*s++ > ' ');
	*--s = 0;
	return s - p;
}

int N;                 // N番目のひとを外す
char S[205]; int W;    // 人の輪、長さ
int ans;

int check(int k, int ng, int nb)
{
	int i, n, start;
	char s[205], *p; int w;

	memcpy(s, S, W+1);
	w = W, start = 0;
	for (i = 0; i < W; i++) {
		if (i == k) n = N+1; else n = N;     // 外す人の間隔

		start = (start + n-1) % w;
		if (s[start] == 'G') ng--; else nb--;  // どのチームのひとが外れたか
		if (ng == 0 || nb == 0) break;      // 相手チームのひとが残っていなければ
		if (nb < ans) return 0;             // 残りの無駄な調べを省く

		p = s + start;                      // 外した人を外す
		while (*p) *p = *(p + 1), p++;
		w--;

		if (start >= w) start -= w;
	}
	return nb;
}

int main()
{
	int cs, i, a;
	int ng, nb;   // 'G'の人数、'B'の人数
	char *p;

	cs = in();
	while (cs--) {
		N = in(), W = ins(S);

		// 人数を数える
		p = S, ng = nb = 0; while (*p) if (*p++ == 'G') ng++; else nb++;

		ans = 0;
		// i回目でNをN+1にする。(-1)はそうしないケース。
		for (i = -1; i < W; i++) {
			a = check(i, ng, nb);
			if (a > ans) ans = a;
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>

int main()
{
    char s[201];
    scanf("%s", s);
    int lens = strlen(s), i;
    for (i=lens - 2; i>=2; i-=2)
    {
        if (strncmp(s, s+i/2, i/2) == 0) {
            printf("%d\n", i);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,t,m,sum=0;
    cin>>n>>t;
    vector<long long int>v;
    for(long long int i=0;i<n;i++)
    {
        cin>>m;
        v.push_back(m);
    }
    sum=t;
    m=t;
    for(long long int i=0;i+1<n;i++)
    {
        if(v[i+1]<=m)
        {
            sum+=(t+v[i+1])-m;
            m=v[i+1]+t;
        }
        else if(v[i+1]>m)
        {
            sum+=t;
            m=v[i+1]+t;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <math.h>
using namespace std;

typedef long long signed int ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(obj) (obj).begin(),(obj).end()

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
  int K,S,count=0;
  cin>>K>>S;
  for(int i=0;i<=K;++i){
    for(int j=0;j<=K;++j){
      if((S-i-j)<=K&&(S-i-j)>=0){
        count++;
      }
    }
  }
  cout<<count<<endl;
	return 0;
}


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

using namespace std;

int smaller(int a,int b){
  if(a > b) return b;
  else return a;
}

int main(void){
  int n;
  cin >> n;

  vector<int> b(n - 1);
  for(int i = 0;i < n - 1;i++){
    cin >> b[i];
  }

  long ans = b[n - 2];

  if(n == 2) cout << 2 * b[0];
  else {
    for(int i = n - 2;i > 0;i--){
      ans += smaller(b[i],b[i - 1]);
     
    }
  cout << ans + b[0];
  }


  return 0;    
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (1001)
#define MOD (1000000007)

//グラフ
#define MAXV (MAXN)
int Gv;
typedef struct edge
{
    int to;
    struct edge* next;
}edge;

edge* Ge[MAXV]; //vから出てる有向辺
int Gd[MAXV]; //vの次数

// vは頂点数、指定するときは0～(v-1)
void Ginit(int v)
{
    Gv = v;
}

void Gadd(int v, int to)
{
    edge* e = malloc(sizeof(edge));
    e->to = to;
    e->next = Ge[v];
    Ge[v] = e;
    Gd[v]++;
}

int ns;
int check[MAXN];
int routei[MAXN];

int slen;
int ss;

void dfs(int i, int len)
{
    if(check[i]!=ns && check[i]!=0) return;
    if(len > slen) return;
    check[i] = ns;
    if(routei[i]!=0)
    {
        //ループ
        if(slen > len-routei[i])
        {
            slen = len-routei[i];
            ss = i;
        }
        return;
    }
    routei[i] = len;
    edge* e= Ge[i];
    while(e!=NULL)
    {
        dfs(e->to,len+1);
        e = e->next;
    }
    routei[i] = 0;
}

int sr[MAXN];
bool ok;
void dfs2(int i,int len)
{
    if(len > slen) return;
    if(i==ss && len == slen)
    {
        ok = true;
        return;
    }
    sr[len] = i;
    edge* e= Ge[i];
    while(e!=NULL)
    {
        dfs2(e->to,len+1);
        e = e->next;
        if(ok) return;
    }
}

int main(void)
{
    ll n,m;
    scanf("%ld %ld",&n,&m);

    for(ll i=0;i<m;i++)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        Gadd(a,b);
    }

    slen = INT_MAX;
    for(int i=1;i<=n;i++)
    {
        if(check[i]) continue;
        ns = i;
        dfs(i,1);
        if(slen!=INT_MAX) break;
    }
    if(slen==INT_MAX)
    {
        printf("-1\n");
        return 0;
    }
    dfs2(ss,0);
    printf("%d\n",slen);
    for(int i=0;i<slen;i++)
    {
        printf("%d\n",sr[i]);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <bits/stdc++.h>
using namespace std;
long long MOD=998244353;
long long base[200001];

long long mpow(long long a, long long b){
	long long cur=a;
	long long ans=1;
	for(;;){
		if(b==0)return ans;
		if(b&1){
			ans=(ans*cur)%MOD;

		}
		b=b>>1;
		cur=(cur*cur)%MOD;
	}
}
long long lstmul(long long a, long long b){
	long long l=1;
	for(long long i=a;i<=b;i++)l=(l*i)%MOD;
	return l;
}
long long choose(long long a, long long b){
	long long l=base[a];
	l=(l*mpow((base[b]*base[a-b])%MOD,MOD-2))%MOD;
	return l;
}
int main(){
	base[0]=1;
  for(int i=1;i<200001;i++){
  	base[i]=(base[i-1]*i)%MOD;
  }
  long long n,m,k;
  cin>>n>>m>>k;	
  if(m==1&&k<n-1){cout<<0<<endl;return 0;}
  if(m==1){cout<<1<<endl;return 0;}
  long long ans=0;
  for(int i=0;i<=k;i++){
  	long long cur=choose(n-1,n-i-1);
  	cur=(cur*m)%MOD;
  	cur=(cur*mpow(m-1,n-i-1))%MOD;
  	ans=ans+cur;
  	ans=ans%MOD;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5196
def main():
    n = int(input())
    a = list(map(int,input().split()))
    m = int(input())
    q = list(map(int,input().split()))
    mem = [False]*40001
    def dfs(i,s):
        mem[s] = True
        if n<=i:return
        dfs(i+1,s)
        dfs(i+1,s+a[i])
    dfs(0,0)
    for i in q:
        if mem[i]:print ('yes')
        else     :print ('no')

if __name__ == '__main__':
    main()




Measured memory_bytes: 5928
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N, K;
  cin >> N >> K;
  double value = log(N) / log(K);
  cout << floor(value) + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
console.log((args=>{
  const [N,...S] = args.trim().split('\n');
  let AC = 0, WA = 0, TLE = 0, RE = 0;
  for ( let i = 0; i < N; i++ ) {
    switch(S[i]){
      case 'AC': AC++; break;
      case 'WA': WA++; break;
      case 'TLE': TLE++; break;
      case 'RE': RE++; break;
    }
  }
  return `AC x ${AC}\nWA x ${WA}\nTLE x ${TLE}\nRE x ${RE}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 43532
#include <cstring>
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

#define str to_string
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()

#define MAX_N 101
int N;
char name[30]; // .{3,25}
int len_name;

// buf??§`name`????????????????????????
bool solve(char *buf) {
  int len_buf = strlen(buf);
  if (len_buf < len_name) return false;

  int t = len_buf;
  for (int offset=0; offset<len_buf; offset++) {
    if (buf[offset] != name[0]) continue;

    for (int size=1; size<t; size++) {

      rep(i, len_name) {
        // if ((offset + i*size) < len_buf) goto PASS;
        if (buf[offset+i*size] != name[i]) goto PASS;
      }
      return true;
      PASS:
      ;
    }
  }

  return false;
}

int main() {
  cin >> N;
  cin >> name;
  len_name = strlen(name);

  char buf[110];

  int answer = 0;
  rep(i, N) {
    memset(buf, 0, 110);
    cin >> buf;
    if (solve(buf)) answer++;
  }

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

Measured memory_bytes: 1164
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  const int mod = 1e9 + 7;
  int s;
  cin >> s;
  const int N = 2010;
  vi dp(N, 0);
  dp[0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 3; j < N; j++) {
      if (i + j >= N) break;
      dp[i + j] += dp[i];
      if (dp[i + j] >= mod) dp[i + j] -= mod;
    }
  }
  cout << dp[s] << '\n';
  return (0);
}


Measured memory_bytes: 3640
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,T = LI()
    A = [LI() for _ in range(N)]
    A.sort()
    dp = [[0] * (T+1) for _ in range(N+1)]

    for i in range(1,N+1):
        for j in range(1,T+1):
            a,b = A[i-1]
            if j == T:
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-1]+b)
                continue
            if j < a:
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-a]+b)
    print(dp[-1][T])


if __name__ == '__main__':
    main()

Measured memory_bytes: 113624
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
dd = inpl()
ans = 0
for i in range(N):
    for j in range(i+1,N):
        ans += dd[i]*dd[j]
print(ans)


Measured memory_bytes: 4452
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
inline void modAdd(int& _a, int _b, int _m) { _a = (_a + _b) % _m; }
inline void modAdd(lint& _a, lint _b, lint _m) { _a = (_a + _b) % _m; }
inline void minUpdate(int& _a, int _b) { _a = min(_a, _b); }
inline void minUpdate(lint& _a, lint _b) { _a = min(_a, _b); }
inline void maxUpdate(int& _a, int _b) { _a = max(_a, _b); }
inline void maxUpdate(lint& _a, lint _b) { _a = max(_a, _b); }

int n, m;
int poyo[1010][110];

void solve() {
	int cnt[110] = { 0 };
	for_(i,0,m) for_(j,0,n) cnt[i] += poyo[j][i];
	
	PArray vp;
	for_(i,0,m) vp.push_back(pii(cnt[i], -(i + 1)));
	sort(allof(vp));
	
	for_rev(i,m-1,0) {
		if (i > 0) cout << -vp[i].second << " ";
		else cout << -vp[i].second << endl;
	}
}

int main() {
	while (cin >> n >> m, n) {
		for_(i,0,n) for_(j,0,m) cin >> poyo[i][j];
		solve();
	}
	return 0;
}

Measured memory_bytes: 1632
import java.io.*;
	import java.util.*;
    class Main
    {
      public static void main(String args[])throws IOException
      {
        double l,x,a;
        BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
        Scanner sc =new Scanner(System.in);
        l=Double.parseDouble(input.readLine());
        x=l/3;
        a=x*x*x;
        System.out.println(a);
      }
    }

Measured memory_bytes: 20948
#include <stdio.h>
#include <math.h>

#define N 1000000
#define INFTY 2000000000

int A[N], count=0;

void merge(int, int, int);
void mergeSort(int, int);
int main()
{
  int n,i;

  scanf("%d",&n);

  for(i=0; i<n; i++)
    scanf("%d",&A[i]);

  mergeSort(0,n);

  for(i=0;i<n;i++){
    printf("%d", A[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n%d\n", count);

  return 0;
}

void merge(int left, int mid, int right)
{
  int n1, n2, i, j, k, L[N], R[N];

  n1 = mid - left;
  n2 = right - mid;

  for(i=0; i<=n1-1; i++)
    L[i] = A[left + i];

  for(i=0; i<=n2-1; i++)
    R[i] = A[mid + i];

  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;

  for(k=left; k<=right-1; k++)
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
      count++;
    }
    else {
      A[k] = R[j];
      j = j + 1;
      count++;
    }
}

void mergeSort(int left, int right)
{
  int mid;

  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    merge(left, mid, right);
  }
}


Measured memory_bytes: 5612
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
typedef long long ll;

using namespace std;

int main(){
  string S;
  cin >> S;

  int prev_idx = 0;
  int ans = 0;

  for (int i = 1; i < S.size(); i++) {
    if (S[prev_idx] != S[i]) {
      ans += 2;
      S[prev_idx] = '2';
      S[i] = '2';
      do {
	prev_idx--;
      } while (S[prev_idx] == '2');
      if (prev_idx == -1) {
	//cout << "**" << endl;
	prev_idx = i + 1;
	i++;
      }
    }
    else {
      prev_idx = i;
    }

    cout << endl;
  }

  cout << ans << endl;

}


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

#define int long long

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


signed main(void) {
  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  // int N;
  // int M;
  // int K;
  array<int, 100000> A;
  // string S;
  // string T;

  cin >> A[0] >> A[1] >> A[2];

  sort(A.begin(), A.begin() + 3, greater<int>());

  cout << 10 * A[0] + A[1] + A[2] << endl; 
  // cin >> N;
  // for (auto it = A.begin(); it < A.begin() + N; ++it) cin >> *it;

  // for (auto it = A.begin(); it < A.begin() + N; ++it) if (*it % 2 == 0) ++num;

  // cout << num << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

/////////////         modの計算

#define MOD_IS_PRIME
constexpr ll mod = 1000000007LL;

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

	constexpr int K = 16;

	constexpr ll v_e[] = { 0, 765144583, 346175634, 347662323, 5655049, 184117322, 927321758, 444014759, 542573865, 237315285, 417297686, 471090892, 183023413, 660103155, 727008098, 869418286 };
	constexpr ll v_o[] = { 539588932, 729548371, 700407153, 404391958, 962779130, 184117322, 927321758, 444014759, 542573865, 237315285, 417297686, 471090892, 183023413, 660103155, 727008098, 869418286 };

	int T; cin >> T;
	for (int _t = 0; _t < T; _t++) {
		ll N; cin >> N;
		if (N % 2 == 0) {// even
			ll ans = 0;
			ll x = 1;
			for (int i = 0; i < K; i++) {
				ans += (x * v_e[i]) % mod;
				x = (x * N) % mod;
			}
			cout << ans % mod << endl;
		}
		else {// odd
			ll ans = 0;
			ll x = 1;
			for (int i = 0; i < K; i++) {
				ans += (x * v_o[i]) % mod;
				x = (x * N) % mod;
			}
			cout << ans % mod << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3180
import java.util.Scanner;

public class Main {
	// inputs
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int[] R = new int[n];
		
		for(int i=0; i<n;i++) {
			R[i] = s.nextInt();
		}
		
		
	
		
		int max_profit = R[1]-R[0];
		int min = minimum(R[0],R[1]);
		
		for (int j=2;j<n;j++) {
			max_profit  = maximum(max_profit,R[j]-min);
			min = minimum(min,R[j]);
		}
		System.out.println(max_profit);
	}
	static int minimum(int a, int b) {
		if (a < b) return a;
		else return b;
	}
	static int maximum(int a, int b) {
		if(a > b) return a;
		else return b;
	}
	
	
}


Measured memory_bytes: 100792
N = gets.to_i
as = gets.split.map(&:to_i)

rs = Array.new(8, false)
f = 0
as.each do |a|
  if a >= 3200
    f += 1
  else
    rs[a / 400] = true
  end
end
c = rs.count(&:itself)
ci = c
ci += 1 if c.zero? && f.positive?
cx = c + f

puts "#{ci} #{cx}"


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

int main(){
	// input
	int A, B; cin >> A >> B;
	// compute
	int ans = 0;
	if(A >= 13){
		ans = B;
	}
	else if(A >= 6 && A <= 12){
		ans = B / 2;
	}
	else{
		ans = 0;
	}
	// output
	cout << ans << endl;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll q, h, s, d;
    cin >> q >> h >> s >> d;
    ll n;
    cin >> n;
    ll l = min(s, min(2 * h, 4 * q));
    if (l * 2 <= d) {
        cout << n * l << endl;
    } else {
        cout << n / 2 * d + n % 2 * l << endl;
    }
    return 0;
}

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

ans = 0

def f(i, j):
    tmp = p[i]
    p[i] = p[j]
    p[j] = tmp

for i in range(N - 1):
    if p[i] == i + 1:
        f(i, i + 1)
        ans += 1

if p[-1] == N:
    ans += 1

print(ans)


Measured memory_bytes: 14008
N = int(input())
X = list(map(int, input().strip().split(" ")))
S = sum(X)

p = -1
if S % N == 0:
    p = S // N
    print(sum([(p-i)**2 for i in X]))
else:
    cand1 = (S+N) // N
    cand2 = S // N
    p1 = sum([(cand1-i)**2 for i in X])
    p2 = sum([(cand2-i)**2 for i in X])

    if p1 < p2:
        print(p1)
    else:
        print(p2)

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

int main() {
    int sx, sy, tx, ty;
    string ans;

    cin >> sx >> sy >> tx >> ty;

    // 一回目の移動
    int move_y = abs(ty - sy);
    int move_x = abs(tx - sx);

    for(int i = 0; i < move_y; i++) ans += "U";
    for (int i = 0; i < move_x; i++) ans += "R";
    for(int i = 0; i < move_y; i++) ans += "D";
    for (int i = 0; i < move_x; i++) ans += "L";

    // 二回目の移動
    ans += "L";
    for(int i = 0; i < move_y+1; i++) ans += "U";
    for (int i = 0; i < move_x+1; i++) ans += "R";
    ans += "DR";
    for(int i = 0; i < move_y+1; i++) ans += "D";
    for (int i = 0; i < move_x+1; i++) ans += "L";
    ans += "U";

    cout << ans << endl;
}

Measured memory_bytes: 256
s = list(input())
ans = 0

for i in range(1,len(s)):
    if s[i] == "0" and s[i-1] == "0":
        s[i] = "1"
        ans += 1
    if s[i] == "1" and s[i-1] == "1":
        s[i] = "0"
        ans += 1

print(ans)

Measured memory_bytes: 49620
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
  ll n, ans=0;
  cin>>n;
  vector<pair<string,ll>>v;
  rep(i,n){
    ll t;
    string s;
    cin>>s>>t;
    v.push_back(make_pair(s,t));
  }
  string x;
  cin>>x;
  bool ok=false;
  for(pair<string,ll> l: v){
    if(ok) ans += l.second;
    if(l.first == x) ok = true;
  }
  cout<<ans<<endl;
}

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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> A >> B;
	if ((A + B) < 3) {
		cout << "Impossible";
	}
	else {
		if (A >= 3 && A % 3 == 0) {
			cout << "Possible";
		}
		else if (B >= 3 && B % 3 == 0) {
			cout << "Possible";
		}
		else if ((A + B) % 3 == 0) {
			cout << "Possible";
		}
		else {
			cout << "Impossible";
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
const double PI=acos(-1.0);
//----------------------------------------------------------------------------------------------------------------------------------//

int main(){
        string s;
        cin>>s;
        int n,m;
        for(int i=0; i<s.length(); i++) {
                if(s[i]=='A') {
                        n=i;
                        break;
                }
        }
        for(int j=s.length()-1; j>=0; j--) {
                if(s[j]=='Z') {
                        m=j;
                        break;
                }
        }
        cout<<m-n+1<<endl;
}


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

int main() {
	char x[19];
	for (int i=0; i<19; i++) {
		cin >> x[i];
	}
	for (int i = 0; i<5; i++) {
		cout << x[i];
	}
	cout << " ";
	for (int i=6; i<13; i++) {
		cout << x[i];
	}
	cout << " ";
	for (int i=14; i<19; i++) {
		cout << x[i];
	}
	cout << endl;
}

Measured memory_bytes: 256