akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int,input().split()))

flg = 0
cnt = 0

while (flg == 0):
    for i in a:
        if i%2 == 1:
            flg = 1
    if flg == 1:
        break
    cnt += 1
    a = [i/2 for i in a]

print(cnt)

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fr(i,k) for(i=0;i<k;i++)
#define deb(x) cerr<<#x<<"  = "<<x<<endl;
#define deb2(x,y) cerr<<#x<<" ="<<x<<endl<<#y<<" ="<<y<<endl;
#define SZ(x) (x).size();
#define ll long long
#define mod 1000000007
#define ff first
#define ss second
#define pb push_back
#define em emplace_back
#define ulli unsigned long long int
#define inf 1e18
#define endl "\n"
typedef vector<vector<ll>> vvll;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
void solve();

int main() {
	fastio;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t;
	t = 1;

	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

ll dp[10001][101][2];

ll calc(string &k, ll pos, ll D, ll d, ll tight)
{
	if (dp[pos][d][tight] != -1)
		return dp[pos][d][tight];

	ll ub = tight ? (k[pos] - '0') : 9;

	if (pos == k.length() - 1)
	{
		ll ans = 0;
		for (ll x = 0; x <= ub; x++)
		{
			if (x % D == d)
				ans++;
		}

		return ans;
	}

	ll ans = 0;
	for (ll x = 0; x <= ub; x++)
	{
		ans = (ans + calc(k, pos + 1, D, (D + d - x % D) % D, tight && (x == ub))) % mod;
	}


	return dp[pos][d][tight] = ans;



}

inline void solve()
{
	ll D, i;
	string k;
	cin >> k >> D;

	memset(dp, -1, sizeof dp);

	cout << (mod + calc(k, 0, D, 0, 1) - 1) % mod << endl;
}


Measured memory_bytes: 20552
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

ll gcd(ll u, ll v) {
    ll r;
    while (v) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

ll lcm(ll u,ll v){
    ll r;
    r = u/gcd(u,v)*v;
    return r;
}

int n;

int main() {
    cin >> n;
    vector<ll> t(n);
    REP(i,n){
        cin >> t[i];
    }
    ll res = 1;
    REP(i,n){
        res = lcm(res,t[i]);
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
/*
AizuOnline A2024
Title blackjack
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int N;
char d1,d2;
char pile[8];
int acef;
int softf;//including A that counts as 11
//
int   eval_card(char c)
 {
   if(c=='T' || c=='J' || c=='Q' || c=='K')
     return(10);
   if(c=='A')
     return(1);
   return(c - '0');
 }
int point(int c)
{
  int i,ret;

  ret=0;

  for(i=0;i<c+2;i++)
    {
      ret += eval_card(pile[i]);
      if(pile[i]=='A')
	acef=-1;
    }
  softf=0;
  if(ret < 12 && acef)
    { softf=-1;
      ret += 10;
    }
  return(ret);
}

main()
{
  int i,j,count,sum;
  char s[20],s2[20];

  while(EOF != scanf("%d\n",&N) && N)
    {
      for(i=0;i<N;i++)
	{
	  fgets(s,20,stdin);
	  pile[0]=s[0];pile[1]=s[2];
	  fgets(s,20,stdin);
	  pile[2]=s[0];pile[3]=s[2];pile[4]=s[4];pile[5]=s[6];
	  pile[6]=s[8];pile[7]=s[10];pile[8]=s[12];pile[9]=s[14];
	  count=0;acef=0;
	    while(point(count) < 17 ||point(count) == 17 && softf && count < 8)
	      {  //printf("%d %d\n",count,point(count));
	      count++;
	      }
	    sum=point(count);
	    if(count==0 && sum == 21)
	      printf("blackjack\n");
	    else if(sum < 22)
	      printf("%d\n",sum);
	    else
	      printf("bust\n");
	}

    }

return(0);
}

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

namespace AtCoderProg {
    class C_Traveling {
        static void Main(string[] args) {
            int count = int.Parse(Console.ReadLine());
            int reslutCount = count;
            int reslut = 0;

            while(count > 0) {
                string[] input = Console.ReadLine().Split(' ');
                int time = int.Parse(input[0]);
                int num = int.Parse(input[1]) + int.Parse(input[2]);

                if ((time%2 == num%2) && (time >= num)) {
                    reslut++;
                }
                count--;
            }
            if (reslutCount == reslut) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 15160
#include<bits/stdc++.h>
using namespace std;
int ans[100003],n,m,q,do1[100003],do2[100003],do3[100003];
vector<int>v[100005];
bool vis[13][100003];
void dfs(int a,int b,int c){
	if(b==-1)return;
	if(vis[b][a])return;
	for(int i=0;i<=b;i++)
		vis[i][a]=1;
	if(!ans[a])ans[a]=c;
	for(int i=0;i<v[a].size();i++)
		dfs(v[a][i],b-1,c);
}
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	cin>>q;
	for(int i=1;i<=q;i++)
		cin>>do1[i]>>do2[i]>>do3[i];
	for(int i=q;i>0;i--){
		dfs(do1[i],do2[i],do3[i]);
	}
	for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
}

Measured memory_bytes: 9080
n,k = gets.split.map &:to_i
MOD = 10 ** 9 + 7

min = 0

n2 = n + 1

if n2 / 2 > k then
	min = n2 / 2
else
	min = k
end

sum = 0

diff = n2 - 1
current = 1

(n2 - k + 1).times{ |x|
	sum = (sum + current) % MOD
	current = (current + diff) % MOD
	diff -= 2
}

puts sum

Measured memory_bytes: 14256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
#include <complex>
using namespace std;
int main()
{
    int n,i,chge,cnt=0;
    cin>>n;
    vector <int> p(n,0);
    for(i=0;i<n;i++) cin>>p[i];
    for(i=0;i<n-1;i++)
    {
        if((p[i]==(i+1))and(p[i+1]==(i+2)))
        {
            chge=p[i];
            p[i]=p[i+1];
            p[i+1]=chge;
            cnt++;
        }
    }
    for(i=0;i<n;i++)
    {
        if(p[i]==(i+1))
        {
            chge=p[i];
            if(i==(n-1))
            {
                p[i]=p[i-1];
                p[i-1]=chge;
            }
            else
            {
                p[i]=p[i+1];
                p[i+1]=chge;
            }
            cnt++;
        }
    }
    cout<<cnt;
    system ("pause"); 
    return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc=new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int N = sc.nextInt();
		//int map[][]=new int[H+1][W+1];//添字が座標
		int nowx,nowy,direx,direy,count=0;
		
		nowx=sc.nextInt();
		nowy=sc.nextInt();
		for(int z=1;z<N;z++){
			direx=sc.nextInt();
			direy=sc.nextInt();
			while(true){
				if(nowx==direx && nowy==direy) break; //保険　?
				else if(direx>nowx){//???
					if(direy>nowy){//?
						nowx++;	
						nowy++;
						count++;
					}
					else if(direy<nowy){//?
						nowx++;
						nowy--;
						count+=2;
					}
					else if(direy==nowy){//?
						nowx++;
						count++;
					}
				}
				else if(direx<nowx){//４３８
					if(direy<nowy){//?
						nowx--;
						nowy--;
						count++;
					}
					else if(direy>nowy){//3
						nowx--;
						nowy++;
						count+=2;
					}
					else if(direy==nowy){
						nowx--;
						count++;	
					}
				}
				else if(direx==nowx){//５６
					if(direy<nowy){
						nowy--;
						count++;
					}
					else if(direy>nowy){
						nowy++;
						count++;
					}
				}
			}
		}
		System.out.println(count);
		
	}

}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

const int a[] = {6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049};

// 個数制限なしナップサック
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    vi dp(n + 1);
    REP(i, n + 1) dp[i] = i;
    REP(j, 11) REP(i, n + 1) dp[i] = i >= a[j] ? min(dp[i - a[j]] + 1, dp[i]) : dp[i];

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 640
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 2e5;
pair<pair<LL,LL>,LL> arr[N + 5];

LL BIT[N + 5];

int n;

void update(int idx,LL x) {
	for( ; idx <= n; idx += (idx & -idx)) BIT[idx] = max(BIT[idx],x);
}

LL query(int idx) {
	LL res = 0;
	for( ; idx > 0; idx -= (idx & -idx)) res = max(res, BIT[idx]);
	return res;
}

void hora(int tc) {
	cin>>n;
	for(int i = 0;i < n;i++) {
		cin>>arr[i].FI.FI;
		arr[i].FI.SE = i + 1;
	}
	for(int i = 0;i < n;i++) cin>>arr[i].SE;
	sort(arr,arr + n);
	LL ans = 0;
	for(int i = 0;i < n;i++) {
		int pos = arr[i].FI.SE;
		LL tot = query(pos) + arr[i].SE;
		ans = max(ans, tot);
		update(pos, tot);
	}
	cout<<ans<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}



Measured memory_bytes: 6528
#include<iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	
	int ans = 0;
	for(int i = 0;i < n;i++){
		int l,r;
		cin >> l >> r;
		ans += r - l + 1;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if((max(a,b)-min(a,b))%2==0)cout<<max(a,b)-(max(a,b)-min(a,b))/2<<endl;
  else cout<<"IMPOSSIBLE\n";
}

Measured memory_bytes: 256
uses crt;
var n,a,j:qword;
i:longword;
begin
        clrscr;
        readln(n);
        for i:=1 to round(sqrt(n))  do
        begin
        if n mod i=0 then begin j:=n div i;a:=j+i-2;end;
        end;
        write(a);
        readln
end.




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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD ((int)(1e9) + 7)
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define filename "lynext"
#define freop freopen(filename ".cik","w",stdout);freopen(filename ".gir","r",stdin)
const long long int N = ((long long int)1e5) + 5;
const long long int M = ((long long int)1e3) + 5;
const long long int llinf = (long long int)1e18;
const int inf = INT_MAX;
typedef long long int lli;

lli dp[N];
lli n;
lli k;
lli h[N];

lli f (lli i)
{
	if (dp[i] != -1)
		return dp[i];
	if (i == n)
		return 0;
	if (i == n - 1)
		return abs(h[n] - h[i]);
	lli t = llinf;
	for (int j = i + 1; j <= min(i + k,n); j++)
		t = min(t,f(j) + abs(h[i] - h[j]));
	return dp[i] = t;
}

int main ()
{
	fast;
	//freop;
	cin >> n >> k;
	memset(dp, -1, sizeof dp);
	for (int i = 1; i <= n; i++)
	{
		cin >> h[i];
	}
	cout << f(1) << "\n";
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

ll n,a[6],d;

map<ll,ll> mp;

ll solve(ll x){
	if(mp.count(x)){
		return mp[x];
	}
	if(x==0){
		mp[0]=0;
	}
	mp[x]=1e18;
	if(x<=mp[x]/d){
		mp[x]=min(mp[x],d*x);
	}
	fore(t,2,6){
		if(t==4)continue;
		mp[x]=min(mp[x],(x-(x/t)*t)*d+a[t]+solve(x/t));
		if((x+1)/2<x)mp[x]=min(mp[x],abs(x-((x+t-1)/t)*t)*d+a[t]+solve((x+t-1)/t));
	}
	return mp[x];
}

int main(){FIN;
	ll t; cin>>t;
	while(t--){
		mp.clear();
		cin>>n>>a[2]>>a[3]>>a[5]>>d;
		cout<<solve(n)<<"\n";
	}
	
	return 0;
}

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

int main()
{
    int N, K, S;
    cin >> N >> K >> S;
    for(int i=0;i<K;i++){
        cout << S << " ";
    }
    if(S==1e+9) S=0;
    for(int i=K;i<N;i++){
        cout << (S+1) << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1280
import sys
import numpy as np
n=int(input())
mod=10**9+7
if n==1:print(1);sys.exit()
def searchPrimeNum(N):
    max = int(np.sqrt(N))
    searchList = [i for i in range(2,N+1)]
    primeNum = []
    while searchList[0] <= max:
        primeNum.append(searchList[0])
        tmp = searchList[0]
        searchList = [i for i in searchList if i % tmp != 0]
    primeNum.extend(searchList)
    return primeNum
l=len(searchPrimeNum(n))
plist=searchPrimeNum(n)
cnt=[0]*l
for i in range(l):
  k=1 
  while plist[i]**k<=n:
    cnt[i]+=n//(plist[i]**k)
    k+=1
ans=1
for i in cnt:
  ans=(ans*(i+1))%mod
print(ans)


Measured memory_bytes: 12432
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;


int main(int argc, char const *argv[]) {
  ll n, l, t;std::cin >> n >> l >> t;
  vvl dat = VV(n, 2, 0, ll);
  vll af(n);
  for(int i=0;i<n;i++) scanf("%lld %lld", &dat[i][0], &dat[i][1]);

  ll y;
  //最初にi番目にいたアリの位置
  for(int i=0;i<n;i++){
    ll x = t%l;
    if(dat[i][1]==1) af[i] = dat[i][0]+x;
    else af[i] = dat[i][0]-x+l;
    if(af[i]>=l) af[i]-=l;
    if(i==0) y = af[i];
  }
  sort(all(af));
  for(int i=0;i<n;i++){
    if(af[i]==y) {
      y = i;
      break;
    }
  }
  ll z = 0;
  //アリ0が終了後にアリ何番目になっているか
  ll num = 0;
  for(int i=1;i<n;i++){
    if(dat[i][1]==dat[0][1]) continue;
    //t秒間で2t進める
    ll fst = (dat[0][1]==1?(dat[i][0]-dat[0][0]):(l-(dat[i][0]-dat[0][0])));
    if(fst>2*t) continue;
    num++;
    num += (2*t-fst)/l;
    if((2*t-fst)%l==0) z++;
  }
  if(dat[0][1]==1) num -= z;
  num = (num%n==0?(num==0?0:n):num%n);
  ll after = (dat[0][1]==1?num:(n-num)%n);
  vll ans(n);
  for(int i=0;i<n;i++) ans[(after+i)%n] = af[(i+y)%n];
  for(int i=0;i<n;i++) std::cout << ans[i] << "\n";
  return 0;
}


Measured memory_bytes: 8192
A,B,C,D,E,F=map(int,input().split())

cand_water=set()
for i in range(31):
  for j in range(31):
    vol=i*100*A+j*100*B
    if 0<vol<=F:
      cand_water.add(vol)
#print(cand_water)

cand_sugar=set()
for i in range(3001):
  for j in range(3001):
    vol=i*C+j*D
    if 0<=vol<=F:
      cand_sugar.add(vol)
#print(cand_sugar)

max_concent=-1
answer=[0,0]
for water in cand_water:
  for sugar in cand_sugar:
    if water+sugar>F:
      continue
    if sugar/(water+sugar)>E/(100+E):
      continue
      
    if sugar/(water+sugar)>max_concent:
      answer=(water+sugar,sugar)
      max_concent=sugar/(water+sugar)
      
print(*answer)

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

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

	ll N=in<ll>(),K=in<ll>();
	
	if(N>K){
		out(0);
		return 0;
	}
	ll ans = 1;
	REP(i,N){
		ans *= (K-i);
		ans %= atcoder_mod;
	}
	out(ans);
	return 0;
}



Measured memory_bytes: 3148
N = int(input())
brick = list(map(int, input().split()))
n = 0
br = 0
flg = False
for b in brick:
    if b == n + 1:
        n += 1
        flg = True
    else:
        br += 1
if flg:
    print(br)
else:
    print(-1)

Measured memory_bytes: 24744
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	cout << N - 1 - M << endl;
	return 0;
}

Measured memory_bytes: 3212
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;




void main() {
    int n;
    scan(n);
    auto a = iota(n).map!(i => readln.chomp.to!int).array;

    auto left = new int[](n + 1);
    foreach (i ; 1 .. n + 1) {
        left[i] = max(left[i - 1], a[i - 1]);
    }

    auto right = new int[](n + 1);
    foreach_reverse (i ; 0 .. n) {
        right[i] = max(right[i + 1], a[i]);
    }

    foreach (i ; 0 .. n) {
        auto ans = max(left[i], right[i + 1]);
        writeln(ans);
    }
}




















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 6396
#include<iostream>

int main(){
    int m,f,r;
    std::string c;
    while(1){
        std::cin >> m >> f >> r;
        if(m==-1 && f==-1 && r==-1) break;
        if(m==-1 || f==-1){
            c= "F";
        }else if(m+f>=80) {
            c="A";
        }else if(m+f>=65) {
            c="B";
        }else if(m+f>=50) {
            c="C";
        }else if(m+f>=30) {
            if(r>=50) c="C";
            else c="D";
        }else {
            c="F";
        }
        std::cout << c << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1188
#include <cstdio>
#include <set>
#include <cassert>
using namespace std;

const int N = 100500;
int wait[N];

int P[N];
int Q[N];
int A[N];

bool was[N];

int main() {
    int n, m, q;
    scanf("%d %d %d", &n, &m, &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &A[i]);
        --A[i];
    }
    int pt = 0;
    for (int i = q - 1; i >= 0; i--) {
        if (!was[A[i]])
            was[A[i]] = true, P[pt] = A[i], Q[A[i]] = pt, pt++;
    }
    set<int> unused;
    for (int i = 0; i <= m; i++)
        unused.insert(i);
    for (int i = 0; i < pt; i++)
        unused.erase(P[i]);
    while (pt > 0 && P[pt - 1] < *unused.begin()) {
        --pt;
        unused.insert(P[pt]);
    }

    wait[0] = n;
    for (int i = q - 1; i >= 0; i--) {
        int a = A[i];
        assert(was[a]);
        if (Q[a] >= pt)
            continue;
        if (wait[Q[a]])
            wait[Q[a]]--, wait[Q[a] + 1]++;
    }
    if (wait[pt] != n) {
        puts("No");
    } else {
        puts("Yes");
    }
}


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

typedef long long int ll;
ll powk(ll a, ll n = 2){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}


int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll a = 1; a <= n;a++){
        ll b = n / a;
        ll c = n - a * b;
        if(b != 0){
            if(c == 0){
                b -= 1;
            }
            ans += b;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <memory>
#include <numeric>
#include <type_traits>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
typedef long long ll;
bool color[10];
int cost[10];
int c[10][10];
const int costMax = 1e4;
stack<int> s;



void dfs(int u){
    s.pop();
    rep(i,10){
        //if(color[i]) continue;
        if (cost[i] > cost[u]+c[i][u]){
            cost[i] = cost[u]+c[i][u];
            s.push(i);
            //color[i] = true;
        }
    }
    
    if (!s.empty()) dfs(s.top());
}

 
int main() {
    int h,w;
    cin >> h >> w;
    rep(i,10){
        rep(j,10){
            cin >> c[i][j];
        }
    }
    int a[h][w];
    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
        }
    }
    s.push(1);
    color[1] = true;
    rep(i,10) cost[i] = costMax;
    cost[1] = 0;
    dfs(s.top());
    int res = 0;
    rep(i,h){
        rep(j,w){
            if (a[i][j] == -1) continue;
            else {
                res += cost[a[i][j]];
            }
        }
    }
    cout << res << endl;
    return 0;
}

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

int isPrime(int n){
	int root = sqrt(n);
	for(int i=2;i<=root;i++){
		if(n%i==0)
			return 0;
	}

	return 1;
}


int main(){

int n;
scanf("%d",&n);
int count = 0;
int num;
for(int i=0;i<n;i++){
	scanf("%d",&num);

	int primeChecker = isPrime(num);
	if(primeChecker==1)
		count++;
}


printf("%d\n",count);

	return 0;

} 


Measured memory_bytes: 2108
n, a, b = map(int,input().split())
total = 0

def digit_calc(n):
    sum = 0
    while(n > 0):
        sum += n%10
        n /= 10
        n = int(n)
    return sum

for i in range(n+1):
    ans = digit_calc(i)
    if ans >= a and ans <= b:
        total += i

print(total)


Measured memory_bytes: 3060
//2020年3月21日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

namespace {
    // printElems(&a[0], &a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari rep1(i,n-1)rep(j,i)
#define souatari1 for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 10000000000000000;


ll p[100005];
ll q[100005];
ll r[100005];
int cnt[5];


int main(){
	ll x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	rep(i,a) cin >> p[i];
	rep(i,b) cin >> q[i];
	rep(i,c) cin >> r[i];

	sort(p, p+a,greater<>());
	sort(q, q+b,greater<>());

	priority_queue<pll> que;
	rep(i,x) que.push(mp(p[i],3));
	rep(i,y) que.push(mp(q[i],2));
	rep(i,c) que.push(mp(r[i],1));

	ll ans = 0;

	while(true){
		pll tmp = que.top();
		que.pop();
		if(tmp.S == 3 && cnt[3] < x){
			cnt[3]++;
			ans+=tmp.F;
		}
		if(tmp.S == 2 && cnt[2] < y){
			cnt[2]++;
			ans+=tmp.F;
		}
		if(tmp.S == 1){
			cnt[1]++;
			ans+=tmp.F;
		}
		if(cnt[1]+cnt[2]+cnt[3]>=x+y){
			break;
		}
	}

	prints(ans);

	return 0;
}



Measured memory_bytes: 12780
a, b, c = gets.chomp.split().map(&:to_f)
rad = ( c * Math::PI/ 180.0 )
h = b * Math::sin( rad )
puts a * h / 2.0
puts a + b + Math::sqrt( a**2 + b**2 - 2 * a * b * Math::cos( rad ) )
puts h

Measured memory_bytes: 9000
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
  	cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    V<ll> a(n);
    set<ll> st;
    map<ll,ll> mp;
    rep(i,n){
        cin>>a[i];
        st.insert(i+1);
        mp[a[i]]=i+1;
    }
    st.insert(-1);
    st.insert(0);
    st.insert(n+1);
    st.insert(n+2);
    ll ans=0;
    for(ll i=1;i<n;i++){
        ll s,t,u,v;
        auto it1=st.find(mp[i]);
        auto it2=st.find(mp[i]);
        auto it3=st.find(mp[i]);
        auto it4=st.find(mp[i]);
        auto it=st.find(mp[i]);
        it1--;
        it1--;
        it2--;
        it3++;
        it4++;
        it4++;
        if(*it1==-1) s=0;
        else s=*it1;
        t=*it2;
        u=*it3;
        if(*it4==n+2) v=n+1;
        else v=*it4;
        ans+=((t-s)*(u-*it)+(*it-t)*(v-u))*i;
        it=st.erase(it);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 12032
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: u32,
        arr: [String; n],
    }
    let mut map = HashMap::new();
    
    for a in arr {
        let m = map.entry(a).or_insert(0);
        *m += 1;
    }
    
    for k in ["AC", "WA", "TLE", "RE"].iter() {
        println!("{} x {}", k, map.get(*k).unwrap_or(&0));
    }
}


Measured memory_bytes: 7852
n,k,*l=map(int,open(0).read().split())
for _ in range(k):
  s=[0]*(n+1)
  for i in range(n):
    s[max(i-l[i],0)]+=1
    s[min(i+l[i]+1,n)]-=1
  s[0]=min(s[0],n)
  for i in range(1,n):
    s[i]=min(s[i-1]+s[i],n)
  s.pop()
  if s==l: break
  l=s
print(*l)

Measured memory_bytes: 161000
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<pll> v(n);
	rep(i,n){
		cin>>v[i].fs;
		v[i].sc=i+1;
	}
	sort(all(v));
	rep(i,n){
		cout<<v[i].sc<<(i!=n-1?" ":"\n");
	}
}


Measured memory_bytes: 2432
// 

// g++ -std=c++11 abc145_c.cc && ./a.out 
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    ll N, A, B, result;
    cin >> N >> A >> B;

    result = 0;
    result += N / (A + B) * A;

    ll mod = N % (A + B);
    if (mod <= A) {
        result += mod;
    } else {
        result += A;
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
h, w, k = map(int, input().split())
ma = [ list(input()) for _ in range(h) ]
ans = 0

for i in range(2 ** h):
    l = []
    for j in range(h):
        if ((i >> j) & 1):
            l.append(ma[j])

    for p in range(2 ** w):
        cnt = 0
        for q in range(w):
            if ((p >> q) & 1):
                for g in l:
                    if g[q] == "#":
                        cnt += 1
        if cnt == k:
            ans += 1

print(ans)


Measured memory_bytes: 9136
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            ans = i*500 + j*100 + k*50
            if ans == x:
                cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    string s;
    cin >> s;
    set<char> cs;
    rep(i,s.size()) cs.insert(s[i]);
    if(cs.size() == s.size()) cout << "yes" << endl;
    else cout << "no" << endl;
}

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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    vector<int> ResultArray = {105, 135, 165, 189, 195};
    int result;
    for (auto& n : ResultArray){
        if (n <= N) ++result;
    }
    cout << result << endl;
}

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

int main() {
    int n;
    cin >> n;
    int a[110000][3];
    rep(i,n)rep(j,3) cin >> a[i][j];
    int dp[110000][3];
    rep(i,n) rep(j,3) rep(k,3) {
        if(j==k) continue;
        chmax(dp[i+1][j],dp[i][k]+a[i][j]);
    }
    int ans = 0;
    rep(i,3) {
        ans = max(ans,dp[n][i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<queue>
#include<set>
using namespace std;

queue<pair<int,int> >Q;
set<int> S;
vector<pair<int,int> >V;

int c[2][4];
void PULL(int q){
	for(int i=0;i<8;i++){
		c[i/4][i%4]=q%8;
		q/=8;
	}
}
int PUSH(){
	int ret=0,w=1;
	for(int i=0;i<8;i++){
		ret+=c[i/4][i%4]*w;
		w*=8;
	}
	return ret;
}

void BFS(int q,int len){
	V.push_back(make_pair(q,len));
	PULL(q);
	int x,y;
	for(int i=0;i<8;i++)if(c[i/4][i%4]==0)x=i/4,y=i%4;
	int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
	for(int i=0;i<4;i++){
		int xx=dx[i]+x,yy=dy[i]+y;
		if(xx>=0&&xx<2&&yy>=0&&yy<4){
			swap(c[xx][yy],c[x][y]);
			int k=PUSH();
			if(S.find(k)==S.end()){
				S.insert(k);
				Q.push(make_pair(k,len+1));
			}
			swap(c[xx][yy],c[x][y]);
		}
	}
}

int main(){
	for(int i=0;i<8;i++)c[i/4][i%4]=i;
	Q.push(make_pair(PUSH(),0));S.insert(PUSH());
	while(!Q.empty()){
		BFS(Q.front().first,Q.front().second);
		Q.pop();
	}
	while(cin>>c[0][0]){
		for(int i=1;i<8;i++)cin>>c[i/4][i%4];
		int k=PUSH();
		for(int i=0;i<V.size();i++){
			if(V[i].first==k)cout<<V[i].second<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int n, k;
    cin >> n >> k;
    ll ans = 10000000005;
    for(int a = 0; a <= n; a++){
        ll tmp = 1;
        for(int i = 0; i < a; i++)
            tmp *= 2;
        int b = n - a;
        while(b--){
            tmp += k;
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


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

// C - Poll
// 途中
int main() {
    int N;
    cin >> N;
    map<string, int> betMap;
    string S;
    int maxCount = 0;
    for (int i = 0; i < N; i++) {
        cin >> S;
        betMap[S]++;
        maxCount = max(betMap[S], maxCount);
    }

    vector<string> maxBetList;
    for (auto bet : betMap){
        if (bet.second == maxCount) {
            maxBetList.push_back(bet.first);
        }
    }
    sort(maxBetList.begin(), maxBetList.end());

    for (auto bet : maxBetList) {
        cout << bet << endl;
    }

}


Measured memory_bytes: 27144
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  if(abs(a-c)<=d)
      printf("Yes");
  
  else if(abs(a-b)<=d && abs(b-c)<=d)
       printf("Yes");
  
  else
     printf("No");
}

Measured memory_bytes: 256
//
// Created by Hideaki Imamura on 2019-07-17.
//

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

const ll MOD = 1e9+7;
ll N, M, stairs[100010], a;
ll dp[100010];

int main() {
    cin >> N >> M;
    for(int i = 0; i < M; ++i) {
        cin >> a;
        stairs[a] = 1;
    }

    dp[0] = 1;
    for (ll i = 0; i < N; ++i) {
        for (ll j = i+1; j <= min(N, i+2); ++j) {
            if (stairs[j] == 0) {
                dp[j] += dp[i];
                dp[j] %= MOD;
            }
        }
    }

    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;
void init();
#ifdef DEBUG_BUILD
#define DBG(expr) cout << #expr << " = " << expr << endl;
#endif
#define ECHO(expr) cout << expr << endl;
#define REP(var, num) for(ll var = 0; var < num; var++)
#define REP_FROM(var, from, num) for(ll var = from; var < num; var++)
#define MAX_OF(type) numeric_limits<type>::max()
#define MIN_OF(type) numeric_limits<type>::min()
#define SORT(vec) sort(vec.begin(), vec.end())
#define REVERSE(vec) reverse(vec.begin(), vec.end())
#define ALL(vec) vec.begin(), vec.end()
typedef signed long long ll;
typedef unsigned long long ull;

void solve() {
    vector<int> xs(3);
    cin >> xs[0] >> xs[1] >> xs[2];
    sort(begin(xs), end(xs));
    ECHO(10 * xs[2] + xs[1] + xs[0])
}

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

#ifdef INPUT_FILE
    if (!freopen(INPUT_FILE, "r", stdin)) {
        perror("freopen");
        exit(1);
    }
#endif

    solve();
    return 0;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n, m, k;
    cin >> n >> m >> k;
    vec<ll> a(n), b(m);
    vec<ll> suma(n + 1, 0), sumb(m + 1, 0);
    REP(i, n) {
        cin >> a[i];
        suma[i + 1] = suma[i] + a[i];
    }
    REP(i, m) {
        cin >> b[i];
        sumb[i + 1] = sumb[i] + b[i];
    }

    ll ans = 0;
    REP(i, n + 1) {
        if(suma[i] > k)
            break;
        ll t = k - suma[i];
        auto it = upper_bound(all(sumb), t);
        it--;
        ll bb = it - sumb.begin();
        chmax(ans, i + bb);
    }
    cout << ans << en;
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 9532
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define MAX 100010
#define aout(a) REP(i,sizeof(a)) cout << a[i] << " "; cout << endl;
#define vout(v) REP(i,v,size()) cout << v[i] << " "; cout << endl;
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main() {
  ll N; cin>>N;
  if(N == 1){
    cout << 0;
    return 0;
  }
  else if(N == 2){
    cout << 2;
    return 0;
  }
  ll a = 1;
  ll b = 1;
  ll c = 1;
  FOR(i,1,N+1) a = (a*10) %MOD;
  FOR(i,1,N+1) b = (b*9) %MOD;
  FOR(i,1,N+1) c = (c*8) %MOD;
  ll b2 = (b*2) %MOD;
  ll ans = (a-b2+c) %MOD;
  if(ans < 0) ans = ans + MOD;
  cout<<ans;
}

Measured memory_bytes: 3628
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    vvi dp(10011,vi(100,0));
    vi v;
    rep(i,n){
        int hoge; cin>>hoge;
        v.push_back(hoge);
        if(!i)dp[v[0]][0]=1;
    }
    for(int i=0; i<v.size()-1;i++){
        for(int j=0; j<10010;j++){
            if(!dp[j][i])continue;
            dp[j+v[i+1]][i+1]=1;
            dp[j][i+1]=1;
            dp[v[i+1]][i+1]=1;
        }
    }
    ll ans=0;
    for(int i=0; i<10010;i++){
        if(dp[i][n-1]&&i%10)cmax(ans,i);}
    cout<<ans<<endl;
}

Measured memory_bytes: 4608
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int D;
	scanf("%d", &D);
	int c[26], s[D][26], last[26], ans[D];
	for (int i = 0; i < 26; ++i) scanf("%d", &c[i]);
	for (int i = 0; i < D; ++i) {
		for (int j = 0; j < 26; ++j) scanf("%d", &s[i][j]);
	}
	int bst = 0, ok = 0;
	for (int h = 0; h < 13; ++h) {
		fill_n(last, 26, -1);
		int sav = 0;
		for (int i = 0; i < D; ++i) {
			int x = 0, opt = 0;
			for (int j = 0; j < 26; ++j) {
				if (c[j] * (i - last[j] + h) + s[i][j] > x) x = c[j] * (i - last[j] + h) + s[i][j], opt = j;
			}
			sav += c[opt] * (i - last[opt]) + s[i][opt];
			last[opt] = i;
		}
		if (sav > bst) bst = sav, ok = h;
	}
	for (int i = 0; i < D; ++i) {
		int x = 0, opt = 0;
		for (int j = 0; j < 26; ++j) {
			if (c[j] * (i - last[j] + ok) + s[i][j] > x) x = c[j] * (i - last[j] + ok) + s[i][j], opt = j;
		}
		last[opt] = i;
		ans[i] = opt;
	}
	for (int i = 0; i < D; ++i) printf("%d\n", ans[i] + 1);
	return 0;
}

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

using namespace std;

int main() {
	int m,n; cin >> m >> n;
	vector<int> a(n);
	for(auto&e:a) cin >> e;
	int ans=0;
	if(m>2) {
		for(int i=1;i<n;++i) {
			if(a[i-1]==a[i]) {
				a[i]=-1;
				++ans;
			}
		}
	} else {
		int t1=0,t2=1;
		for(int i=1;i<n;++i) {
		    if(a[i]==a[0]) {
				if(i&1) ++t1;
				else ++t2;
			} else {
				if(i&1) ++t2;
				else ++t1;
			}
		}
		ans=min(t1,t2);
	}
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 3132
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N; cin >> N;
    vector<int> h(N+1);
    rep(i,N) cin >> h[i];
    h[N] = 0;
    int ans = 0;
    rep(i,N){
        if(h[i] != 0){
            while(h[i] > 0){
                repr(j,i+1,N+1){
                    if(h[j] == 0){
                        repr(k,i,j){
                            h[k]--;
                        }
                        ans++;
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

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

int main()
{
    int n,m,l,r,i;
    int l0=-1,r0=1000000000;
    cin>>n>>m;
    for(i=1;i<=m;i++){
        scanf("%d%d",&l,&r);
        l0=max(l0,l);
        r0=min(r0,r);
    }
    if(l0>r0) cout<<0;
    else{
        if(l0>n) cout<<0;
        else if(l0==n) cout<<1;
        else if(n>=r0) printf("%d",r0-l0+1);
        else printf("%d",n-l0+1);
    }
    return 0;
}


Measured memory_bytes: 256