akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
	int n,s=0;
	cin>>n;
//	cout<<s<<endl;
	int b[n-1];
	for(int i=0;i<n-1;i++){
		cin>>b[i];
	}
	//int a[n];
	for(int i=0;i<n;i++){
		if(i==0)s+=b[i];
		if(i==n-1)s+=b[n-2];
		else{
			s+=min(b[i],b[i-1]);
		}
	}
	cout<<s;
	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	
	static final int MAX = 200002;
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		long K = sc.nextLong() * N;
		int[] A = new int[2 * N];
		for (int i = 0; i < N; i++) {
			A[N + i] = A[i] = sc.nextInt();
		}
		int[] last = new int[MAX];
		Arrays.fill(last, -1);
		int[] next = new int[N];
		for (int i = 0; i < 2 * N; i++) {
			if (last[A[i]] != -1) {
				next[last[A[i]]] = i % N;
			}
			last[A[i]] = i % N;
		}
		int[] sum = new int[N];
		for (int i = 0; i < N; i++) {
			sum[i] = next[i] - i;
			if (sum[i] <= 0) sum[i] += N;
			sum[i]++;
		}
		boolean[] visited = new boolean[N];
		long[] position = new long[N];
		long cicle = 0;
		int current = 0;
		while (!visited[current]) {
			visited[current] = true;
			position[current] = cicle;
			cicle += sum[current];
			current += sum[current];
			current %= N;
		}
		long realCicle = cicle - position[current];
		long begin = position[current];
		int from = 0;
		if (K > begin) {
			K -= begin;
			from = current;
			K %= realCicle;
		}
		
		int[] values = new int[N + 2];
		boolean[] got = new boolean[MAX];
		int size = 0;
		while (K > 0) {
			if (sum[from] <= K) {
				K -= sum[from];
				from += sum[from];
				from %= N;
			} else {
				while (K > 0) {
					int val = A[from];
					if (got[val]) {
						while (values[size - 1] != val) {
							got[values[size - 1]] = false;
							size--;
						}
						got[values[size - 1]] = false;
						size--;
					} else {
						got[val] = true;
						values[size++] = val;
					}
					K--;
					from++;
					from %= N;
				}
			}
		}
		for (int i = 0; i < size; i++) {
			if (i > 0) out.print(" ");
			out.print(values[i]);
		}
		out.println();
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


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

from fractions import gcd

T = int(input())
ABCD = [[int(x) for x in input().split()] for _ in range(T)]

def F(A,B,C,D):
    if D<B:
        return False
    if A<B:
        return False
    g = gcd(D,B)
    # 個数 mod gは不変量。平行移動して、g=1に帰着する。
    diff = A%g
    A -= diff
    C -= diff
    C -= C%g
    A //= g; B //= g; C //= g; D //= g
    # 以下、(B,D) = 1. mod Dで任意の状態になる
    # C+1,...,C+Bの全部をとる。
    # C+1 >= Bが必要十分
    return C+1>=B

print('\n'.join('Yes' if F(a,b,c,d) else 'No' for a,b,c,d in ABCD))

Measured memory_bytes: 5116
#include <iostream>

int main(void)
{
    int a, b, c;
    std::cin >> a >> b >> c;
    int count = 0;
    for(int i = a; i <= b; i++) {
	if(c % i == 0) { count++; }
    }
    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int dp[1100000][3];

int main(){
    string str;
    cin >> str;
    int ans = 0;
    int n = str.size();
    dp[0][0] = 0;
    dp[0][1] = INF;
    dp[0][2] = 1;
    for(int i = 0;i < str.size();i++){
        char c = str[i];
        int d = c - '0';
        dp[i+1][0] = dp[i+1][1] = dp[i+1][2] = INF;
        dp[i+1][0] = dp[i][0] + d;
        for(int j = 0;j < 10;j++){
            if(j > d){
                dp[i+1][1] = min(dp[i+1][1], dp[i][0] + j + j - d);
                dp[i+1][2] = min(dp[i+1][2], dp[i][0] + j + j - d - 1);
                dp[i+1][2] = min(dp[i+1][2], dp[i][1] + j + j - d - 1);
            }
            if(j >= d){
                dp[i+1][1] = min(dp[i+1][1], dp[i][1] + j + j - d);
            }            
            dp[i+1][1] = min(dp[i+1][1], dp[i][2] + j + 10 + j - d);
            dp[i+1][2] = min(dp[i+1][2], dp[i][2] + j + 10 + j - d-1);
        }
    }
    cout << min(dp[n][0], dp[n][1]) << endl;
    return 0;
}

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int h,w,c;
int data[100][100];
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int ans;

int check(int grid[100][100]){
	int issearched[100][100] = {0};
	issearched[0][0] = 1;
	int cnt = 1;
	queue<int> qx,qy;
	qx.push(0); qy.push(0);
	while(!qx.empty()){
		int x = qx.front(); int y = qy.front();
		qx.pop(); qy.pop();
		REP(i,4){
			int nx = x + dx[i]; int ny = y + dy[i];
			if(nx > -1 && ny > -1 && nx < h && ny < w && issearched[nx][ny] == 0){
				issearched[nx][ny] = 1;
				if(grid[nx][ny] == c){
					cnt++;
					qx.push(nx); qy.push(ny);
				}
			}
		}
	}
	return cnt;
}

void change(int col,int grid[100][100]){
	int issearched[100][100] = {0};
	queue<int> qx,qy;
	qx.push(0); qy.push(0);
	int stcol = grid[0][0];
	grid[0][0] = col;
	while(!qx.empty()){
		int x = qx.front(); int y = qy.front();
		qx.pop(); qy.pop();
		REP(i,4){
			int nx = x + dx[i]; int ny = y + dy[i];
			if(nx > -1 && ny > -1 && nx < h && ny < w && issearched[nx][ny] == 0){
				issearched[nx][ny] = 1;
				if(grid[nx][ny] == stcol){
					grid[nx][ny] = col;
					qx.push(nx); qy.push(ny);
				}
			}
		}
	}
}

int solve(int n,int grid[100][100]){
	// cout << n << endl;
	int bgrid[100][100];
	REP(i,h) REP(j,w) bgrid[i][j] = grid[i][j];

	if(n == 4){
		change(c,grid);
		ans = max(check(grid),ans);
	}else{
		REP(i,6){
			change(i,grid);
			solve(n+1,grid);
			REP(i,h) REP(j,w) grid[i][j] = bgrid[i][j];	
		}
	}
	return ans;
}

int main(){
	while(1){
		cin >> h >> w >> c;
		if(h==0) break;
		c--;
		ans = 0;
		REP(i,h) REP(j,w) cin >> data[i][j];
		REP(i,h) REP(j,w) data[i][j]--;
		cout << solve(0,data) << endl;
	}
}

Measured memory_bytes: 1420
def main():
    height, width, w_min, h_min = map(int, input().split())
    answer = [["1" for _ in range(width)] for _ in range(height)]
    for i in range(height):
        for j in range(width):
            if (i < h_min and j < w_min) or (h_min <= i and w_min <= j):
                answer[i][j] = "0"
    for i in range(height):
        print("".join(answer[i]))


if __name__ == '__main__':
    main()



Measured memory_bytes: 12788
// Vicfred
// https://atcoder.jp/contests/abc157/tasks/abc157_c
import std.stdio;
import std.algorithm;

int[] digits(int n) {
    int[] ans;
    while(n > 0) {
        ans ~= n%10;
        n /= 10;
    }
    reverse(ans);
    return ans;
}

void main() {
    int n, m;
    readf("%s %s", &n, &m);
    readln;

    int[int] value;
    bool impossible = false;
    foreach(_; 0..m) {
        int s, c;
        readf("%s %s\n", &s, &c);
        if(s in value && value[s] != c)
            impossible = true;
        else
            value[s] = c;
    }

    if(1 in value && value[1] == 0 && n > 1)
        impossible = true;

    if(impossible) {
        "-1".writeln;
        return;
    }

    if(n == 1 && m == 0) {
        0.writeln;
        return;
    }

    if(n == 1 && m == 0) {
        0.writeln;
        return;
    }

    if(n == 1 && m == 1 && 1 in value && value[1] == 0) {
        0.writeln;
        return;
    }

    for(int num = 10^^(n-1); num < 10^^n; ++num) {
        int[] digit = 0~digits(num);
        bool valid = true;
        for(int i = 1; i <= n; ++i) {
            if(i in value && value[i] != digit[i])
                valid = false;
        }
        if(valid) {
            num.writeln;
            return;
        }
    }
    "-1".writeln;
}



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

int main(){
  int H,W,h,w;
  cin >> H >> W >> h >> w;

  int all,black;
  all = H * W;
  black = (h * w) + (h * (W-w)) + (w * (H-h));

  int white = all - black;

  cout << white << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
        string s;
        cin >> s;
        int ans = 0;
        for (int i = 1; i < s.length(); i++)
                if (s[i-1] != s[i])
                        ans++;
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 512
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n,m = readline() |> split |> parseMap
	h = readline() |> split |> parseMap
	e = [Int[] for i in 1:n]
	for i in 1:m
		a,b = readline() |> split |> parseMap
		push!(e[a],b)
		push!(e[b],a)
	end
	ans = 0
	f = 0
	for i in 1:n
		f = 0
		for j in e[i]
			if h[j]>=h[i]
				f = 1
			end
		end
		if f == 0
			ans += 1
		end
	end
	println(ans)
end

main()

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

int main(){
    int N; cin >> N;
    vector<int> P, Q;
    for (int i = 0; i < N; i++)
    {
        int p; cin >> p;
        P.push_back(p);
    }
    for (int i = 0; i < N; i++)
    {
        int q; cin >> q;
        Q.push_back(q);
    }

    for (int i = 0; i < P.size(); i++)
    {
        if(P[i] < Q[i]) break;
        else if(P[i] > Q[i]){
            P.swap(Q);
            break;
        } 
    }
    
    int count = -1;
    do{
        count++;
        bool flag = true;
        for (int i = 0; i < P.size(); i++)
        {   
            if(P[i] != Q[i]){
                flag = false;
                break;
            } 
        }
        if(flag==false) continue;
        cout << count << endl;
        break;
    } while (next_permutation(P.begin(), P.end()));
}

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


// 素数 p で割ったあまりに関する構造体 (特に p = 1000000007 とすることが多い)
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


// スターリング数 (n 個を k グループにわける、n >= k)
template<class T> struct Stirling {
    vector<vector<T> > S;
    constexpr Stirling(int MAX) noexcept : S(MAX, vector<T>(MAX, 0)) {
        S[0][0] = 1;
        for (int n = 1; n < MAX; ++n) {
            for (int k = 1; k <= n; ++k) {
                S[n][k] = S[n-1][k-1] + S[n-1][k] * k;
            }
        }
    }
    constexpr T get(int n, int k) {
        if (n < 0 || k < 0 || n < k) return 0;
        return S[n][k];
    }
};


int main() {
    // 1000000007 で割ったあまりのクラス
    using mint = Fp<1000000007>;
    
    // スターリング数
    Stirling<mint> sl(3100); // S(n, k) を n, k < 3100 の範囲で求める

    // スターリング数
    int n, k;
    cin >> n >> k;
    cout << sl.get(n, k) << endl;
}



Measured memory_bytes: 77904
#include <stdio.h>
#include <ctype.h>
int main(void){
	int i,len;
	char str[1200];

	fgets(str,sizeof(str),stdin);
	len = strlen(str)-1;
	for(i=0;i<len;i++){
		if(isupper(str[i])){
			str[i]=tolower(str[i]);
		}
		else{
			str[i]=toupper(str[i]);
		}
	}
	printf(str);
	return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<string>
#include<vector>

using namespace std;

typedef long long ll;


int main(){

ll R,G,B,N;

cin>>R>>G>>B>>N;

ll cnt;

for(int r=0;r<N+1;r++){
    if(N-r*R>0){
        for(int g=0;g<N+1;g++){
            if(N-r*R-g*G>0){
                
                    if((N-r*R-g*G)%B==0){
                        cnt++;
                    }             
            }
            else if(N-r*R-g*G==0){
                cnt++;
            }else if(N-r*R-g*G<0){
                break;
            }
        }
    }else if(N-r*R==0){
        cnt++;
    }else{
        break;
    }
}

cout<<cnt<<endl;

    return 0;

}



Measured memory_bytes: 256
#include <iostream>
#include<string>
#include <math.h>
#include<algorithm>
#include<vector>
#include<bitset>
using namespace std ;
typedef long long int ll ;
int main(){
	//ll a; 
	//int t  ;
	//cin >> t ;
	//int  a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51} ;
	ll i , j ;
	cin >> i>> j ;
if((i == 1  ||  j == 1 )){
cout << 1 << endl ;
return  0 ;
}
	i = i*j ;
	cout << i - i/2 << endl ;
	

return 0 ;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int total = a + b + c;
  if (total % 2 == 0 && (a == total / 2 || b == total / 2 || c == total / 2))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 10000000000

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	int A,B,C;
	cin>>A>>B>>C;
	int x,y,z,co=0;
	if(A>=B && A>=C){
		x=A;
		y=max(B,C);
		z=min(B,C);
	}
	else if(B>=A && B>=C){
		x=B;
		y=max(A,C);
		z=min(A,C);
	}
	else{
		x=C;
		y=max(A,B);
		z=min(A,B);
	}
	while(x>y){
		z++;
		y++;
		co++;
	}
	while(x>z){
		//cout<<"A"<<endl;
		z+=2;
		co++;
	}
	if(x!=z)co++;
	cout<<co<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<algorithm>
#include<numeric>
#include<cstdlib>
using namespace std;
typedef string S;
typedef pair<int,S>P;
typedef list<P>L;
typedef map<char,L>B;
typedef map<char,vector<int> >C;
typedef map<S,pair<int,int> >D;
int main()
{
	int n,i,j,k,p,v;
	char y;
	S s,t,x;
	P _;
	while(cin>>n,n)
	{
		B a,b;
		C c;
		D d;

		getline(cin,s);
		while(n--)
		{
			getline(cin,s);
			i=s.find(' ');
			j=s.find(' ',i+1);
			k=s.find(' ',j+1);
			x=s.substr(0,i);
			t=s.substr(i+1,j-i-1);
			y=s[j+1];
			p=atoi(s.substr(k+1).c_str());

			if(t=="SELL")
			{
				L::iterator h=b[y].end(), f;
				_=P(0,"");
				for(f=b[y].begin();f!=b[y].end();++f)
					if(f->first>=p && x!=f->second && _.first<f->first)
						_=*f,h=f;
				if(h!=b[y].end())
				{
					v=(p+h->first)/2;
					c[y].push_back(v);
					d[h->second].first+=v;
					d[x].second+=v;
					b[y].erase(h);
				}
				else a[y].push_back(P(p,x));
			}
			else
			{
				L::iterator h=a[y].end(),f;
				_=P(9999,"");
				for(f=a[y].begin();f!=a[y].end();++f)
					if(f->first<=p && x!=f->second && _.first>f->first)
						_=*f, h=f;
				if(h!=a[y].end())
				{
					v=(p+h->first)/2;
					c[y].push_back(v);
					d[h->second].second+=v;
					d[x].first+=v;
					a[y].erase(h);
				}
				else b[y].push_back(P(p,x));
			}	d.insert(make_pair(x,make_pair(0,0)));
		}

		for(C::iterator f=c.begin();f!=c.end();++f)
		{
			vector<int>::iterator g=f->second.begin(),
				h=f->second.end();
			cout<<f->first<<' '<<*min_element(g,h)
				<<' '<<accumulate(g,h,0)/f->second.size()
				<<' '<<*max_element(g,h)<<endl;
		}
		cout<<"--\n";
		for(D::iterator f=d.begin();f!=d.end();++f)
			cout<<f->first<<' '<<f->second.first<<' '<<f->second.second<<endl;
		cout<<"----------\n";
	}
	return 0;
}

Measured memory_bytes: 0
from copy import deepcopy
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
mod = 10 ** 9 + 7
ans = 1
i, j = 0, n - 1
k2 = deepcopy(k)
while k2 > 1:
    if a[i] * a[i + 1] > a[j] * a[j - 1]:
        ans *= a[i] * a[i + 1]
        ans %= mod
        i += 2
        k2 -= 2
    else:
        ans *= a[j]
        j -= 1
        ans %= mod
        k2 -= 1
if k2 == 1:
    ans *= a[j]
    ans %= mod
if a[-1] < 0 and k % 2:
    ans = 1
    for i in range(n - k, n):
        ans *= a[i]
        ans %= mod
print(ans)

Measured memory_bytes: 32160
# Takahashi's Information
c = tuple(tuple(map(int, input().split())) for _ in range(3))
a1 = 0
b1 = c[0][0]
b2 = c[0][1]
b3 = c[0][2]
a2 = c[1][0]-b1
a3 = c[2][0]-b1
if c[1][1]==a2+b2 and c[1][2]==a2+b3 and c[2][1]==a3+b2 and c[2][2]==a3+b3:
    print('Yes')
else:
    print('No')


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

int main() {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  vector<int> ans;
  int last = 0, biggest = 0;
  for (int i = 1; i <= n; i++) {
    if (i - last > m) {
      if (biggest == 0) {
        cout << -1 << endl;
        return 0;
      } else {
        last += biggest;
        ans.push_back(biggest);
        biggest = 0;
      }
    }
    if (s.at(i) == '0') {
      biggest = i - last;
    }
  }
  if (biggest) ans.push_back(biggest);
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); i++) {
    cout << ans.at(i);
    if (i == ans.size() - 1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
}


Measured memory_bytes: 1144
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> X(n), Y(n), H(n);
    for (int i = 0; i < n; ++i) {
        cin >> X[i] >> Y[i] >> H[i];
    }

    const int MX = 100;


    auto ok = [&](int cx, int cy) {
        long long R = 1LL << 50;
        long long L = 0;
        for (int i = 0; i < X.size(); ++i) {
            long long h = abs(X[i] - cx) + abs(Y[i] - cy) + H[i];
            R = min(R, h);
            if (H[i] > 0) {
               if (L != 0 && L != h) {
                   return -1LL;
               }
               L = h;
           }
        }
        if (L == 0 && R == 1) {
            return 1LL;
        }
        
        if (L == 0 || L > R) {
            return -1LL;
        }
        return L;
    };
    for (int x = 0; x <= MX; ++x) {
        for (int y = 0; y <= MX; ++y) {
            int h = -1;
            if ((h = ok(x, y)) > 0) {
                cout << x << ' ' << y << ' ' << h << '\n';
                return 0;
            }
        }
    }

    assert(0);

    return 0;
}

Measured memory_bytes: 256
#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long
using namespace std;

vector<set<pair<int,int> > > g;
vector<int> gv[100001];
set<pair<int,int> > s,s2;
bool vis[100001];
int a[100001];

inline void dfs(int x){
	for(int i=0;i<gv[x].size();i++){
		if(!vis[gv[x][i]]){
			vis[gv[x][i]]=1;
			s.insert(make_pair(a[gv[x][i]],gv[x][i]));
			dfs(gv[x][i]);
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	if(n-1==m){
		cout<<0;
		return 0;
	}
	if((n-1-m)*2>n){
		cout<<"Impossible";
		return 0;
	}
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=m;i++){
		int u,v;
		cin>>u>>v;
		++u,++v;
		gv[u].push_back(v);
		gv[v].push_back(u);
	}
	for(int i=1;i<=n;i++)
		if(!vis[i]){
			vis[i]=1;
			s.insert(make_pair(a[i],i));
			dfs(i);
			g.push_back(s);
			s.clear();
		}
	for(int i=1;i<=n;i++) s2.insert(make_pair(a[i],i));
	ll ans=0;
	for(int i=0;i<n-m;i++){
		s=g[i];
		ans+=(ll)(*s.begin()).first;
		s2.erase(*s.begin());
	}
	for(int i=1;i<=2*(n-m-1)-(n-m);i++){
		ans+=(ll)(*s2.begin()).first;
		s2.erase(s2.begin());
	}
	cout<<ans;
}

Measured memory_bytes: 20352
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int N;
	cin >> N;

	vector<P>student(N);

	for (int i = 0; i < N; i++) {
		cin >> student[i].first;
		student[i].second = i + 1;
	}

	SORT(student);

	REP(i, N) {
		if (i < N - 1) cout << student[i].second << " ";
		else cout << student[i].second << endl;
	}

	return 0;

}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    ll n = s.size(), m = t.size();
    vector<vector<int>> index(30);
    for (ll i = 0; i < n; i++)
    {
        index[s[i] - 'a'].push_back(i + 1);
    }
    ll ans = 0;
    ll last = 0;

    for (ll i = 0; i < m; i++)
    {
        ll nch = t[i] - 'a';
        if ((ll)index[nch].size() <= 0)
        {
            cout << -1 << endl;
            return 0;
        }
        else
        {
            auto itr = upper_bound(ALL(index[nch]), last);
            if (itr == index[nch].end())
            {
                ans += n;
                itr = index[nch].begin();
            }
            last = *itr;
        }
    }
    ans += last;
    cout << ans << endl;
}


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

typedef long long ll;
const int N=2e5+5;
map<string,int>vis;
int n;
string s[N];
int main()
{
    scanf("%d",&n);
    int mx=0;
    for(int i=1;i<=n;i++)
    {
        cin>>s[i];vis[s[i]]++;
        mx=max(mx,vis[s[i]]);
    }
    sort(s+1,s+1+n);
    for(int i=1;i<=n;i++)
        if(vis[s[i]]==mx)
    {
        cout<<s[i]<<endl;
        vis[s[i]]=0;
    }
}

Measured memory_bytes: 26752
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
char s[N];
int main()
{
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    int flag = 0;
    for (int i = 1; i <= len; i++)
    {
        if (i % 2 == 0 && s[i] != 'i')
            flag = 1;
        if (i % 2 == 1 && s[i] != 'h')
            flag = 1;
    }
    if (len & 1)
        flag = 1;
    if (flag)
        cout << "No" << endl;
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	int N;
	cin>>N;
	int A,B;
	cin>>A>>B;
	int c[3] = {};
	rep(i,N){
		int x;
		cin>>x;
		if(x<=A) c[0]++;
		else if(x<=B) c[1]++;
		else c[2]++;
	}
	cout<<min(c[0],min(c[1],c[2]))<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

int main() {
  int x[3000], y[3000];
  int end;
  for (int i = 0; i < 3000; i++) {
    cin >> x[i] >> y[i];
    if (x[i] == 0 && y[i] == 0) {
      end = i;
      break;
    }
  }

  for (int i = 0; i < 3000; i++) {
    if (i == end) break;

    if (x[i] < y[i])
      cout << x[i] << " " << y[i] << endl;
    else
      cout << y[i] << " " << x[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3128
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#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 hell        1000000007
#define N	    100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
long long A[1001][1001];
int main() {
	int n, m;
	cin>>n>>m;
	vector<string> v;
	for(int i = 0; i < n; i++) {
		string tem;
		cin>>tem;
		v.pb(tem);
	}
	A[n][m] = 1;
	for(int i = n; i >= 1; i--) {
		for(int j = m; j >= 1; j--) {
			if(v[i - 1][j - 1] == '#' || (i == n & j == m)) continue;
			long long a = 0, b = 0;
			if(i != n)
				a = A[i + 1][j];
			if(j != m)
				b = A[i][j + 1];
			A[i][j] = (a + b) % hell;
		}
	}
	cout<<A[1][1]<<endl;	
}


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

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 51, B = 18, M = (1 << B);
int a[N], b[N];
ll dp[N];
int ct = B;

int removeBit(int x, int p) {
	int res = 0, y = 0;
	for (int i = 0; i < ct; i++) {
		if (i != p) {
			res |= (((x >> i) & 1) << y);
			y++;
		}
	}
	return res;
}

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

	int n, k, s, t;
	cin >> n >> k >> s >> t;

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

	for (int i = B - 1; i >= 0; i--) {
		int x = (s >> i) & 1,
			y = (t >> i) & 1;

		if (x > y) {
			cout << "0\n";
			return 0;
		}

		if (x == 1) {
			int new_n = 0;
			for (int j = 0; j < n; j++) {
				if ((a[j] >> i) & 1)
					a[new_n++] = removeBit(a[j], i);
			}
			n = new_n;
			ct--;
		}
		
		if (y == 0) {
			int new_n = 0;
			for (int j = 0; j < n; j++) {
				if (((a[j] >> i) & 1) == 0)
					a[new_n++] = removeBit(a[j], i);
			}
			n = new_n;
			ct--;
		}
	}

	ll ans = 0;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			b[j] = (a[i] ^ a[j]);
		}

		for (int j = 0; j < (1 << ct); j++) {
			memset(dp, 0, sizeof(dp));
			dp[1] = 1;

			for (int h = i + 1; h < n; h++) {
				if ((b[h] & j) == 0) {
					for (int z = k - 1; z > 0; z--) {
						dp[z + 1] += dp[z];
					}
				}
			}
			int p = 0;
			for (int h = 0; h < ct; h++)
				p ^= (j >> h);

			ll cur = 0;
			for (int h = 1; h <= k; h++)
				cur += dp[h];

			if (p & 1)
				ans -= cur;
			else
				ans += cur;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	int MOD = 1000000007;
	public void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		long dp[][] = new long[n+1][4];
		dp[0][0]=1;
		for(int i=0; i<n; i++) {
			char c = s.charAt(i);

			if(c=='A'||c=='?') {
				dp[i+1][0] = (dp[i+1][0] + dp[i][0]) % MOD;
				dp[i+1][1] = (dp[i+1][1] + dp[i][1]) % MOD;
				dp[i+1][2] = (dp[i+1][2] + dp[i][2]) % MOD;
				dp[i+1][3] = (dp[i+1][3] + dp[i][3]) % MOD;

				dp[i+1][1] = (dp[i+1][1] + dp[i][0]) % MOD;

			}
			if(c=='B'||c=='?') {
				dp[i+1][0] = (dp[i+1][0] + dp[i][0]) % MOD;
				dp[i+1][1] = (dp[i+1][1] + dp[i][1]) % MOD;
				dp[i+1][2] = (dp[i+1][2] + dp[i][2]) % MOD;
				dp[i+1][3] = (dp[i+1][3] + dp[i][3]) % MOD;

				dp[i+1][2] = (dp[i+1][2] + dp[i][1]) % MOD;
			}
			if(c=='C'||c=='?') {
				dp[i+1][0] = (dp[i+1][0] + dp[i][0]) % MOD;
				dp[i+1][1] = (dp[i+1][1] + dp[i][1]) % MOD;
				dp[i+1][2] = (dp[i+1][2] + dp[i][2]) % MOD;
				dp[i+1][3] = (dp[i+1][3] + dp[i][3]) % MOD;

				dp[i+1][3] = (dp[i+1][3] + dp[i][2]) % MOD;
			}
		}
		System.out.println(dp[n][3]);
		sc.close();
	}


}


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

int sumOfDig(int a) {
  int sum = 0;
  while(a > 0) {
    sum += a % 10;
    a /= 10;
  }

  return sum;
}

int main() {
  int n;
  cin >> n;
  int minSumDig = 100000000;

  for(int i = 1; i < n; i++) {
    int m = n - i;
    minSumDig = min(sumOfDig(m) + sumOfDig(i), minSumDig);
  }

  cout << minSumDig;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main() {
  int x;
  cin >> x;
  cout << x*x*x << endl;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

vii G(100010);

bool dfs(int now, int par, int u, int v) {
  rep (i, G[now].size()) {
    if (G[now][i] == par) continue;
    if (G[now][i] == u) return false;
    if (G[now][i] == v) return true;
    return dfs(G[now][i], now, u, v);
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  rep (i, m) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  vi yobun;
  int sum = 0;
  vi temp;
  rep (i, n) {
    if (G[i].size() % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
    if (G[i].size() > 2) {
      temp.push_back(i);
      yobun.push_back((int)G[i].size() - 2);
      sum += (int)G[i].size() - 2;
    }
  }
  if (sum >= 6) {
    cout << "Yes" << endl;
    return 0;
  }
  else if (sum <= 2) {
    cout << "No" << endl;
    return 0;
  }
  else {
    if (yobun.size() == 1) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  int u = temp[0], v = temp[1];
  rep (i, G[u].size()) {
    if (!dfs(G[u][i], u, u, v)) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	int k=(a+b)/2;
	if (abs(a-k)==abs(b-k)) cout<<k;
	else cout<<"IMPOSSIBLE"<<endl;
	return 0;
}


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

int main(){
    string s;
    cin >> s;
    string ans = "No";
    if(s[0]==s[1] && s[1]==s[2]) ans="Yes";
    if(s[1]==s[2] && s[2]==s[3]) ans="Yes";

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll bit[800010];
ll u;
void bitinit(ll n){
    ll y=1;
    rep(i,0,69){
        
        if(y>=n){
            u=y;
            break;
        }
        y*=2;
    }
    fill(bit,bit+u+10,0);
}
void add(ll n,ll x){
    ll i=n;
    bit[i]+=x;
    bit[i]%=mod;
    while(i<u){
        i+=i&(-i);
        bit[i]+=x;
        bit[i]%=mod;
    }
}
ll sum(ll n){
    ll i=n;
    ll ret=0;
    while(i>0){
        ret+=bit[i];
        i-=i&(-i);
        ret%=mod;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,m;cin>>n>>m;
    bitinit(m+1);
    vector<int> v[m+1];
    int l[n],r[n];
    rep(i,0,n){
        cin>>l[i]>>r[i];
        v[r[i]-l[i]+1].push_back(i);
    }
    ll cnt=0;
    rep(i,1,m+1){
        ll ans=n-cnt;
        for(int j=i;j<=m;j+=i){
            ans+=sum(j);
        }
        cout<<ans<<endl;
        rep(j,0,v[i].size()){
            int num=v[i][j];
            add(l[num],1);
            add(r[num]+1,-1);
        }
        cnt+=v[i].size();
    }
    
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  int a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  cout<<a[2]*10+a[1]+a[0]<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3624
s = input()
n = 0
for i in range(len(s)+1):
  for j in range(i,len(s)+1):
    if s[i:j].replace("A","").replace("T","").replace("G","").replace("C","")=="":
      if len(s[i:j]) > n:
        n = len(s[i:j])
print(n)

Measured memory_bytes: 3060
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2020-01-03 17:38:55
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    LL n, ans;
    cin >> n;

    ans = 0;
    if (n % 2 == 0) {

        for (int i = 0; n/(10*pow(5, i)) != 0; i++) {
            LL a = 10*pow(5, i);
            ans += n/a;
        }

    }

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


Measured memory_bytes: 640
import math
from functools import reduce
from collections import deque, Counter
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

n = int(input())

if n == 1:
    print(0)
    exit()

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(n**0.5)+2):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

    if len(arr) == 0:
        arr.append((n, 1))
    return arr

fac_ = prime_factorize(n)
fac = Counter(fac_)
# log(fac)

ans = 0
for p,e in fac.items():
    # log(p,e)
    x = e
    for i in range(1, 99999999):
        if x >= i:
            x -= i
            ans += 1
        else:
            break

print(ans)


Measured memory_bytes: 68016
#include<stdio.h>
main(void){
	int x,y,i=0;
	while(1){
		scanf("%d %d",&x,&y);
		if(x>=y){
			i=x;
			x=y;
			y=i;
			if(x==0&&y==0){
			break;
			}
		}
		printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 600
from collections import deque
n = int(input())
ls = [list(map(lambda x:int(x)-1, input().split())) for i in range(n-1)]
m = int(input())
cond = [list(map(lambda x:int(x)-1, input().split())) for i in range(m)]
ans=0
graph = [[0]*(n) for _ in range(n)]



for i in range(n-1):
    graph[ls[i][0]][ls[i][1]]+=1<<i
    graph[ls[i][1]][ls[i][0]]+=1<<i

eset = []

for cns in cond:
    d=deque()
    d.append([cns[0], 0])
    while d:
        s, es = d.pop()
        for i in range(n):
            if graph[s][i] and not es&graph[s][i]:
                es2 = es|graph[s][i]
                if i == cns[1]:
                    eset.append(es2)
                    break
                d.append([i, es2])

for i in range(1<<m):
    mask=0
    for j in range(m):
        if i&1<<j:
            mask|=eset[j]
    white=bin(mask).count('1')
    if bin(i).count('1')%2:
        ans-=1<<(n-1-white)
    else:
        ans+=1<<(n-1-white)

print(ans)








Measured memory_bytes: 44960
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<set>
using namespace std;
typedef long long ll;
#define in_ inline
#define re_ return
#define st_ static
#define op_ operator
#define gC() getchar()
#define fst first
#define snd second
#define mP(a, b) make_pair(a, b)
#define inc(l, i, r) for(i=l;   i<r;  ++i)
#define dec(l, i, r) for(i=r-1; i>=l; --i)
in_ ll mne(ll& a, ll b) {a<b?a=b:0;}
in_ ll upd(ll& a, ll b) {a=(a+b)%1000000007;}

struct io
{
	ll r, c, s;
	in_ ll op_!(void)
	{
		for(r=s=0;(c=gC())<48||57<c;)
			if(c=='-') s=1;
		for(;c>47&&58>c; c=gC())
			r=10*r+c-48;
		re_ s?-r:r;
	}
	in_ io& op_&(char* a)
		{re_ scanf("%s", a), *this;}
	in_ io& op_&(ll& a)
		{re_ a=!*this, *this;}
	in_ io& op_^(ll a)
		{re_ printf("%lld", a), *this;}
	in_ io& op_^(const char* a)
		{re_ printf("%s", a), *this;}
} io;

const ll mxn=56;
const bool b1[6][6]=
{
	{0, 0, 1, 1, 1, 0},
	{0, 0, 1, 0, 1, 1},
	{1, 1, 0, 0, 0, 1},
	{1, 0, 0, 0, 1, 1},
	{1, 1, 0, 1, 0, 0},
	{0, 1, 1, 1, 0, 0}
}, b2[3][6]=
{
	{0, 0, 0, 1, 0, 1},
	{0, 1, 0, 0, 1, 0},
	{1, 0, 1, 0, 0, 0}
};
const ll mod=1000000007;
ll n, m, f[mxn]; char s1[mxn], s2[mxn]; bool s[mxn];

int main()
{
	ll i, j, k;
	io &n &s1 &s2;
	for(i=m=0; i<n; ++m)
	{
		if(s1[i]==s2[i]) s[m]=1, ++i;
		else i+=2;
	}
	s[0]?f[0]=3:f[0]=6;
	inc(1, i, m)
	{
		if(s[i-1]&&s[i]) f[i]=(f[i-1]<<1)%mod;
		if(!s[i-1]&&!s[i]) f[i]=(3ll*f[i-1])%mod;
		if(!s[i-1]&&s[i]) f[i]=f[i-1];
		if(s[i-1]&&!s[i]) f[i]=(f[i-1]<<1)%mod;
	}
	io^f[m-1]^"\n";
//	if(s[0]) inc(0, i, 3)
//		f[0][i]=1;
//	else inc(0, i, 6)
//		f[0][i]=1;
//	inc(1, i, m)
//		inc(0, j, 6)
//			inc(0, k, 6)
//			{
//				if(s[i-1] && s[i])
//					if(j!=k && j<3 && k<3)
//						upd(f[i][j], f[i-1][k]);
//				if(!s[i-1] && !s[i] && b1[j][k])
//					upd(f[i][j], f[i-1][k]);
//				if(s[i-1] && !s[i] && k<3 && b2[k][j])
//					upd(f[i][j], f[i-1][k]);
//				if(!s[i-1] && s[i] && j<3 && b2[j][k])
//					upd(f[i][j], f[i-1][k]);
//			}
//	inc(j=0, i, 6)
//		j+=f[m-1][i];//, io^f[m-1][i]^"\n";
//	io ^j ^"\n";
	re_ 0;
}

Measured memory_bytes: 128
K = int(input())
import queue
L = 0
q = queue.Queue()
for i in range(1,10):
  q.put(i)
while L < K:
  x = q.get()
  if x % 10 != 0:
    q.put(10*x + (x%10) -1)
  q.put(10*x +(x%10))
  if x % 10 != 9:
    q.put(10*x + (x%10) +1)
  L += 1
print(x)


Measured memory_bytes: 12452
#include<iostream>
using namespace std;
int main(void) {
  int c[3][3];
  int aa[3];
  int ab[3];
  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++) {
    for(int j=i+1; j<3; j++) {
      for(int k=0; k<3; k++) {
	aa[k]=c[k][i]-c[k][j];
	ab[k]=c[i][k]-c[j][k];
      }
      if(aa[0]!=aa[1] or aa[0]!=aa[2] or aa[1]!=aa[2] or ab[0]!=ab[1] or ab[0]!=ab[2] or ab[1]!=ab[2]) {
	cout<<"No"<<endl;
	return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


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


int main(){
	string S;
	cin >> S;
	
	int ans = 0;
	for(int i = 0; i < S.size() / 2; i++){
		if(S[i] != S[S.size()-1-i]) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// "header" {{{
#pragma GCC optimize("Ofast")

#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int int64_t
#define double long double
#define Fixed fixed << setprecision(10)
#define moke_pair make_pair

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int64_t mod1 = 1000000007;
constexpr int64_t mod2 = 998244353;

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class T,class U> using umap = unordered_map<T,U>;

inline int64_t updiv(int64_t n,int64_t d){ return ((n + d -1) / d); }
inline int square(int a){ return a * a; }
// }}}

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

    int n,m,q;
    cin >> n >> m >> q;

    vector<vector<int> > cum(n+1,vector<int>(n+1));

    rep(i,m){
        int l,r;
        cin >> l >> r;
        cum[l][r]++;
    }

    reps(i,n){
        reps(j,n){
            cum[i][j] += cum[i-1][j] + cum[i][j-1] - cum[i-1][j-1];
        }
    }

    rep(i,q){
        int l,r;
        cin >> l >> r;

        cout << cum[r][r] - cum[l-1][r] - cum[r][l-1] + cum[l-1][l-1] << '\n';

    }

    return 0;
}


Measured memory_bytes: 2944