akhauriyash/Code-Regression huggingface dataset:
N = int(input())

zoro = 0
m = 0
for i in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        zoro += 1
        m = max(zoro, m)
    else:
        zoro = 0

if m >= 3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9164
# 100以下の素数を求める
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
pi_100 = len(primes)

mod = 10**9+7

prime_vector = [0]*pi_100

N = int(input())
for n in range(2,N+1):
    # calc prime
    for i in range(pi_100):
        while n % primes[i] == 0:
            prime_vector[i] += 1
            n = n//primes[i]

ret = 1

# print(prime_vector)
for i in range(pi_100):
    ret = (ret * (prime_vector[i]+1)) % mod

print(ret)

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

int main(){
	int n;
	cin >> n;
	int a;
	int min, max;
	long sum;
	cin >> a;
	min = max = sum = a;
	for(int i = 1; i < n; i++){
		cin >> a;
		if(min > a){
			min = a;
		}else if(max < a){
			max = a;
		}
		sum += a;
	}
	cout << min << " " << max << " " << sum << endl;
}

Measured memory_bytes: 1168
# -*- coding: utf-8 -*-
"""
A - One Card Poker
https://atcoder.jp/contests/abc054/tasks/abc054_a

"""
import sys


def solve(A, B):
    if A == 1:
        A = 14
    if B == 1:
        B = 14
    if A == B:
        return 'Draw'
    if A > B:
        return 'Alice'
    return 'Bob'


def main(args):
    A, B = map(int, input().split())
    ans = solve(A, B)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

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

  string S;
  map<string, int> mp;
  int counter = 0;
  for (int i=0; i<N; i++) {
    cin >> S;
    if(mp.find(S) != mp.end()) {
      mp[S] += 1;
    } else {
      mp[S] = 0;
    }
    if (mp[S] > counter) {
      counter = mp[S];
    }
    if (counter > N / 2) {
      break;
    }
  }

  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    if (itr->second == counter) {
      cout << itr->first << endl;
    }
  }   
}

Measured memory_bytes: 25216
#include <cstdio>
#include <algorithm>

using std :: max;
using std :: min;

typedef long long LL;

LL A,B,C,ans;

int main(){
	scanf("%lld%lld%lld",&A,&B,&C);
	if(A == B && B == C){
		if(~A & 1 && ~B & 1 && ~C & 1) return puts("-1"),0;
		else return puts("0"),0;
	}
	
	while(1){
		if((A % 2 == 1) || (B % 2 == 1) || (C % 2 == 1)) return printf("%lld\n",ans),0;
		int _A = B / 2 + C / 2;
		int _B = A / 2 + C / 2;
		int _C = A / 2 + B / 2;
		A = _A,B = _B,C = _C;
		ans++;
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  vector<bool> have(N,false);
  for (int i=0;i<N;i++){
    int d;
    cin >> d;
    for (int j=0;j<d;j++){
      int a;
      cin >> a;
      have[--a] = true;
    }
  }
  
  int ans = 0;
  for (int i=0;i<N;i++){
    if(!have[i]) ans++ ;
  }
  cout << ans << endl;
}

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

main(){
    int N;
    int d[100];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> d[i];    
    }

    int backet[101] = {0};
    for (int i = 0; i < N; i++){
        backet[d[i]]++; 
    }
    int mochi = 0;
    for (int i = 0; i <= 100; i++){
        if (backet[i] > 0){
            mochi++;
        }
    }

    cout << mochi << endl;
    return 0;
}

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

int main(){
    ll a,v,b,w,t,ab,vw;
    cin >> a >> v >> b >> w >> t;
    bool flag = true;
    if(a > b){
        ab = a-b;
    }else{
        ab = b-a;
    }
    if(v-w <= 0){
        flag = false;   
    }else{
        vw = v-w;
        ll n = ab%vw;
        if(n == 0){
            if(ab/vw > t){
                flag = false;
            }
        }else{
            if(ab/vw >= t){
                flag = false;
            }
        }
    }
    if(flag){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<vector>

using namespace std;

int main()
{
  int n,a;
  cin >> n;
  vector<int> vec(n,0);
  
  for(int i = 0; i < n-1; i++)
  {
    cin >> a;
    vec[--a]++;
  }
  
  for(int i = 0; i < n; i++)
  	cout << vec[i] << ' ';
  cout << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 100000+5;

int n;
string s;

int main(){
	cin >> s;
	n = s.size();
	bool can = (s[0] == '1') & (s[n-1] == '0');
	for(int i=2; i<n-i; i++){
		if(s[i-1] != s[n-1-i]) can = false;
	}
	if(can){
		reverse(all(s));
		int root = 1;
		for(int i=2; i<=n; i++){
			printf("%d %d\n",root,i);
			if(s[i-1] == '1') root = i;
		}
	}
	else puts("-1");
	return 0;
}


Measured memory_bytes: 1664
S=input()
listy=[S[i] for i in range(len(S)) ]
rev=list(reversed(listy))
bef=(len(S)-1)/2
aft=(len(S)+3)/2
jouken1=listy[0:int(bef)]
rev2=list(reversed(jouken1))
jouken2=listy[int(aft-1):len(S)]
rev3=list(reversed(jouken2))
if rev==listy and rev2==jouken1 and rev3==jouken2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
int u[1100000];
vector<int> y;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=INF,e=0,f=0,g=0;
  cin >>a>>b;
  for(int n=0;n<a;n++){
    cin >>c>>e;
    if(b>=e&&d>c) d=c;
  }
  if(d==INF) cout <<"TLE\n";
  else
    cout <<d<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 300005 ;
const long long mod = 1e9+7;
int n,w;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int i,j,x=0,y;
    cin>>n>>w;
    int v[n+1],wt[n+1];
    for(i=0;i<n;i++)
    {
        cin>>wt[i]>>v[i];
        x+=v[i];
    }
    int dp[x+1];
    for(i=1;i<=x;i++)
    {
        dp[i]=INT_MAX;
    }
    dp[0]=0;
    for(i=1;i<=n;i++)
    {
        for(j=x;j>=0;j--)
        {
            if(j>=v[i-1])
            {
                dp[j]=min(dp[j],wt[i-1]+dp[j-v[i-1]]);
            }
        }
    }
    int ans=0;
    for(i=0;i<=x;i++)
    {
        if(dp[i]<=w)
        {
            ans=max(ans,i);
        }
    }
    /*for(i=1;i<=n;i++)
    {
        for(j=1;j<=x;j++)
        {
            cout<<dp[j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<ans<<endl;
}

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

int main(){
    int N,X; cin >> N >> X;
    int ama=X;
    int minA=1e9;
    int ans=N;
    rep(i,N){
        int A; cin >> A;
        ama-=A;
        minA=min(A,minA);
    }
    ans+=ama/minA;
    cout << ans;
}

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

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n =sc.nextInt();
        int m = sc.nextInt();

        int[] a = new int[m];
        for(int i = 0; i < m; i++){
            a[i] = sc.nextInt();
        }

        int sum = Arrays.stream(a).sum();
        System.out.println(n>=sum?n-sum:"-1");
    }
}

Measured memory_bytes: 46676
/*
    Author - Param Kothari
    Ah shit, here we go again
*/
 
/* Ordered Set Implementaton:

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;

typedef tree<
    int,
    null_type,
    less<int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
ordered_set;
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair 
 
typedef long long ll;
typedef long double ld;

void solve(){
    string s;
    cin >> s;
    deque<char> q;
    int c = 0;
    for(int i = 0; i < (int)s.size(); i++){
        q.push_back(s[i]);
    }
    int n = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(x == 1){
            c++;
        }
        else if(x == 2){
            int fi;
            char ci;
            cin >> fi >> ci;
            if(fi == 1){
                if(c % 2 == 0){
                    q.push_front(ci);
                }
                else{
                    q.push_back(ci);
                }
            }
            else if(fi == 2){
                if(c % 2 == 0){
                    q.push_back(ci);
                }
                else{
                    q.push_front(ci);
                }
            }
        }
    }
    string res = "";
    for(int i = 0; i < (int)q.size(); i++){
        res += q[i];
    }
    if(c % 2 == 1){
        reverse(res.begin(), res.end());
    }
    cout << res << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 1368
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {

    const lines = input.split('\n')
    const N = lines[0] - 0
    const S = lines

    const c = {AC: 0, WA: 0, TLE: 0, RE: 0}

    for (let i = 1; i <= N; i++) {
        c[S[i]]++
    }

    console.log('AC x ' + c.AC)
    console.log('WA x ' + c.WA)
    console.log('TLE x ' + c.TLE)
    console.log('RE x ' + c.RE)

})(input)


Measured memory_bytes: 37268
#入力
N = int(input())
lst = input().split()

#整数値化
for i in range(len(lst)):
   lst[i] = int(lst[i])

#ソート
lst.sort()

#コスト計算関数
def get_cost(x, y):
   return (x - y) ** 2

costs = []

#コスト計算
for i in range(lst[0], lst[-1]): #入力値の最小値から最大値まで
   cost = 0
   for j in lst:
      cost = cost + get_cost(j, i)
   costs.append(cost)

#ソート
costs.sort()

#最小コストを出力
#入力値が全て同じとき最小も最大も同じなのでfor文の中のやつは1回も実行されない
#つまりcostsリストが空なのでcosts[0]が存在しない
if costs != []:
   print(costs[0])
else:
   print(0)

Measured memory_bytes: 9172
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<62;
const double pi=acos(-1);
const long double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int N=100,M=2000,MAX=20005,AL=26;
int n,m,ID=1,S[N],a[N][2*N];
string s[N];
ll k,b[AL],dp1[M+1],dp2[M+1];

void f(ll& x,ll y){
	x=min(x+min(y,k+1),k+1);
}

int main(){
	cin>>n>>m>>k;
	dp1[0]=dp2[0]=1;
	string res;
	for(int i=0;i<n;i++){
		cin>>s[i];
		S[i]=s[i].size();
		a[i][0]++;
	}
	for(int i=1;i<=m;i++) for(int j=0;j<n;j++) if(i>=S[j]) f(dp1[i],dp1[i-S[j]]);
	for(int i=0;i<m;i++){
		ll sum=0;
		fill(b,b+AL,0);
		for(int j=0;j<n;j++) for(int l=max(S[j]+i-m,0);l<min(i+1,S[j]);l++) if(a[j][l]){
			ll A=dp1[m+l-S[j]-i],B=dp2[i-l];
			f(b[s[j][l]-'a'],(!A||INF/A>=B?A*B:k+1));
		}
		for(int j=0;j<AL;j++){
			if(sum+b[j]>=k){
				res+=(char)('a'+j);
				k-=sum;
				break;
			}
			f(sum,b[j]);
		}
		if(res.size()!=i+1){
			cout<<'-'<<endl;
			return 0;
		}
		for(int j=0;j<n;j++){
			if(i-S[j]>=-1&&s[j]==res.substr(i-S[j]+1,S[j])) f(dp2[i+1],dp2[i-S[j]+1]);
			for(int l=S[j]-1;l>0;l--){
				a[j][l]=0;
				if(a[j][l-1]&&s[j][l-1]==res[i]) a[j][l]=1;
			}
			a[j][0]=1;
		}
	}
	cout<<res<<endl;
}

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

void fnInput(vector<int>& rvnBSort, int& rnMaxElm)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  rnMaxElm = 0;
  rvnBSort.resize(nMaxSiz);
  for (int i = 0; i < nMaxSiz; i++)
  {
    cin >> rvnBSort[i];
    rnMaxElm = max(rnMaxElm, rvnBSort[i]);
  }
}

void fnCntSort(const vector<int>& cnrvnBSort,vector<int>& rvnASort, int nMaxElm)
{
  vector<int> vnCnt;
  vnCnt.resize(nMaxElm);

  for (int i = 0; i < cnrvnBSort.size(); i++)
    vnCnt[cnrvnBSort[i]]++;

  for (int i = 1; i <= nMaxElm; i++)
    vnCnt[i] += vnCnt[i - 1];

  for (int i = cnrvnBSort.size() - 1; i >= 0; i--)
  {
    rvnASort[vnCnt[cnrvnBSort[i]] - 1] = cnrvnBSort[i];
    vnCnt[cnrvnBSort[i]]--;
  }
}

void fnResult(const vector<int>& cnrvnASort)
{
  for (int i = 0; i < cnrvnASort.size(); i++)
  {
    if (i)  cout << " ";
    cout << cnrvnASort[i];
  }
  cout << endl;
}

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

  int nMaxElm;
  vector<int> vnBSort, vnASort;

  fnInput(vnBSort, nMaxElm);
  vnASort.resize(vnBSort.size());

  fnCntSort(vnBSort, vnASort, nMaxElm);
  fnResult(vnASort);

  return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;

int C(int ,int);
int quick_pow(int ,int);

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	int ans = quick_pow(2, n) - 1;
	ans = (1ll * ans - C(n, a) - C(n, b) + mod + mod) % mod;
	cout << ans << endl;
	return 0;
}

int C(int x, int y){
	int sum1 = 1, sum2 = 1;
	for(int i = x; i >= x - y + 1; --i)
		sum1 = 1ll * sum1 * i % mod;
	for(int i = 1; i <= y; ++i)
		sum2 = 1ll * sum2 * i % mod;
	return 1ll * sum1 * quick_pow(sum2, mod - 2) % mod;
}

int quick_pow(int x, int y){
	int sum = 1;
	for(; y; y >>= 1, x = 1ll * x * x % mod)
		if(y & 1) sum = 1ll * sum * x % mod;
	return sum;
}

Measured memory_bytes: 256
let pn = 1000000007

let pow x n =
  let rec doit x n acc =
    if n = 0 then acc
    else if n mod 2 = 0 then doit (x * x) (n / 2) acc
    else doit (x * x) (n / 2) (acc * x) in
  doit x n 1

let fold_left f init s n =
  let rec doit i acc =
    if i = n then acc
    else doit (i + 1) (f acc s.[i]) in
  doit 0 init

let () =
  let p = read_line () in
  let t = read_line () in
  let n = String.length p in
  let m = String.length t in
  let h = Array.make (n + 1) 0 in
  String.iteri (fun i c -> h.(i+1) <- h.(i)*pn + Char.code c) p;
  let ht = fold_left (fun acc c -> acc*pn + Char.code c) 0 t m in
  let x = pow pn m in
  for i = m to n do
    if h.(i) - h.(i-m)*x = ht then Printf.printf "%d\n" (i - m);
  done

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

bool binarySearch(int n, int S[], int T){
  int left = 0, right = n, mid;
  while ( left < right ){
  	mid = (left + right) / 2;
  	if ( S[mid] == T ) return true;
  	else if ( T < S[mid] ) right = mid;
  	else left = mid + 1;
  }
  return false;
}

int main(){
  int n, S[100000+1], q, T, sum = 0;
  
  cin >> n;
  for ( int i = 0; i < n; i++ ) cin >> S[i];
  
  cin >> q;
  for ( int i = 0; i < q; i++ ){
  	cin >> T;
  	if ( binarySearch(n, S, T) ) sum++;
  }
  
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 3484
import java.util.Scanner;

public class Main{
  static long x, y;

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

    x = sc.nextLong();
    y = sc.nextLong();

    if((x == 0 && y == 0) ||
        (x == 0 && y == 1) || (x == 1 && y == 0)
        || (x == 1 && y == 1)){
      System.out.println("Brown");
      return;
    }

    if(x == 0 || y == 0){
      System.out.println("Alice");
      return;
    }

    if(Math.abs(x - y) <= 1){
      System.out.println("Brown");
      assert(!f(x, y));
    }
    else{
      System.out.println("Alice");
      assert(f(x, y));
    }
  }

  private static boolean f(long a, long b){
    if((a == 0 && b == 0) ||
        (a == 0 && b == 1) || (a == 1 && b == 0)
        || (a == 1 && b == 1)){
      return false;
    }

    for(long i = a / 2; i >= 1; i--){
      if(!f(a - 2 * i, b + i)){
        return true;
      }
    }
    for(long i = b / 2; i >= 1; i--){
      if(!f(a + i, b - 2 * i)){
        return true;
      }
    }
    return false;
  }
}


Measured memory_bytes: 23380
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    A, B = (int(_) for _ in input().split())
    if A > 8 or B > 8:        
        print(':(')
    else:
        print('Yay!')
        
if __name__ == '__main__':
    main()


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

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

const int MAX = 1e6;
int lp[MAX+1];
vector<int> pr;

int factors_count_upto(int n) {
  if (n == 1) return 1; 
  int ans = 1; 
  int sf = lp[n]; 
  int c = 1; 
  int j = n / lp[n]; 
  
  while (j != 1) { 
    if (lp[j] == sf) c += 1; 
    else { 
      sf = lp[j]; 
      ans = ans * (c + 1); 
      c = 1; 
    }
  
    j = j / lp[j]; 
  }
  
  ans = ans * (c + 1); 
  return ans; 
}

int main() {
  fast_io();

  int n;
  cin >> n;

  for (int i = 2; i <= MAX; ++i) {
    if (lp[i] == 0) {
      lp[i] = i;
      pr.push_back(i);
    }
    for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=MAX; ++j)
      lp[i * pr[j]] = pr[j];
  }

  ll ans = 0;
  while (--n) ans += factors_count_upto(n);
  cout << ans << '\n';
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t a, p;
  std::cin >> a >> p;
  p += a * 3;
  std::cout << p / 2 << std::endl;
  return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();

            var flag1 = false;
            var flag9 = false;
            var flag7 = false;
            var flag4 = false;
            foreach (var item in N)
            {
                switch (item)
                {
                    case 1:
                        flag1 = true;
                        break;
                    case 4:
                        flag4 = true;
                        break;
                    case 7:
                        flag7 = true;
                        break;
                    case 9:
                        flag9 = true;
                        break;
                    default:
                        break;
                }
            }

            if (flag1 && flag4 && flag7 && flag9)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <queue>
#include <cstring>
#include <set>
#include <list>
#include <map>
#include <random>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vvi> vvvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;

#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define forn(i, a, b) for(int i = a; i < b; i++)

#define pb push_back
#define mp make_pair

int main()
{

    int n;
    scanf("%d", &n);
    vi x(n);
    forn(i,0,n) scanf("%d", &x[i]);
    int l;
    scanf("%d", &l);
    int q;
    scanf("%d", &q);
    vvi d(20, vi(n));
    forn(i,0,n) {
        d[0][i] = (upper_bound(all(x), x[i] + l) - x.begin()) - 1;
    }
    forn(k,1,20) {
        forn(i,0,n) {
            d[k][i] = d[k-1][d[k-1][i]];
        }
    }
    vi d2(1,1);
    forn(i,0,20) d2.pb(d2.back()*2);
    forn(i,0,q) {
        int a,b;
        scanf("%d %d", &a, &b);
        if(a>b) swap(a,b);
        a--;
        b--;
        int ans = 0;
        int cur = 19;
        while(cur>=0) {
            if(d[cur][a] < b) {
                a = d[cur][a];
                ans += d2[cur];
            }
            cur--;
        }
        if(a<b) ans++;
        printf("%d\n", ans);
    }
    
    
}



Measured memory_bytes: 9080
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
good_course = []
for i in range(n - 1):
    if a[i] + 1 == a[i + 1]:
        good_course.append(a[i] - 1)

ans = sum(b)
for i in good_course:
    ans += c[i]

print(ans)

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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<int>> lcp(n, vector<int>(n));
    int res = 0;
    for (int i = n - 1; i >= 0; i--) {
        for (int j = i + 1; j < n; j++) {
            if (s[i] == s[j]) {
                if (j == n - 1) {
                    lcp[i][j] = 1;
                } else {
                    lcp[i][j] = lcp[i + 1][j + 1] + 1;
                }
            }
            res = max(res, min(lcp[i][j], j - i));
        }
    }
    cout << res;

    return 0;
}

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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    char c; cin>>c;
    cout<<(char)(c+1);
    return 0;
}

Measured memory_bytes: 256
/*input
16
0 5 -4 -5 -8 -4 7 2 -4 0 7 0 2 -3 7 7
5 0 8 -9 3 5 2 -7 2 -7 0 -1 -4 1 -1 9
-4 8 0 -9 8 9 3 1 4 9 6 6 -6 1 8 9
-5 -9 -9 0 -7 6 4 -1 9 -3 -5 0 1 2 -4 1
-8 3 8 -7 0 -5 -9 9 1 -9 -6 -3 -8 3 4 3
-4 5 9 6 -5 0 -6 1 -2 2 0 -5 -2 3 1 2
7 2 3 4 -9 -6 0 -2 -2 -9 -3 9 -2 9 2 -5
2 -7 1 -1 9 1 -2 0 -6 0 -6 6 4 -1 -7 8
-4 2 4 9 1 -2 -2 -6 0 8 -6 -2 -4 8 7 7
0 -7 9 -3 -9 2 -9 0 8 0 0 1 -3 3 -6 -6
7 0 6 -5 -6 0 -3 -6 -6 0 0 5 7 -1 -5 3
0 -1 6 0 -3 -5 9 6 -2 1 5 0 -2 7 -8 0
2 -4 -6 1 -8 -2 -2 4 -4 -3 7 -2 0 -9 7 1
-3 1 1 2 3 3 9 -1 8 3 -1 7 -9 0 -6 -8
7 -1 8 -4 4 1 2 -7 7 -6 -5 -8 7 -6 0 -9
7 9 9 1 3 2 -5 8 7 -6 3 0 1 -8 -9 0
*/

//sometimes it's the people who no one imagines anything of 
//who do the things that no one can imagine.

//code author: iamxlr8

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

#define ll long long
#define endl "\n"
#define all(c) c.begin(),c.end()
#define mod 1000000007
#define inf 1e18L + 5
#define F first
#define S second
#define dbg(x) cout << #x << " = " << x << '\n'
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

vector<ll> pre;
vector<ll> dp;

void fun(ll i,const vector<ll>& not_taken,ll score_so_far,ll mask,ll group)
{
    if(i==not_taken.size())
    {
        dp[mask]=max(dp[mask],score_so_far+pre[group]);
        return;
    }
    fun(i+1,not_taken,score_so_far,mask,group);
    fun(i+1,not_taken,score_so_far,mask|(1<<not_taken[i]),group|(1<<not_taken[i]));
}

void solve()
{
    ll n;
    cin>>n;
    ll v[n][n];
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++)
            cin>>v[i][j];
    }
    dp.resize(1<<n,-inf);
    pre.resize(1<<n,0);
    dp[0]=0;

    // preprocessing
    for(ll mask=0;mask<(1<<n);mask++)
    {
        for(ll i=0;i<n;i++)
        {
            if((1<<i)&mask)
            {
                for(ll j=i+1;j<n;j++)
                {
                    if((1<<j)&mask)
                        pre[mask]+=v[i][j];
                }
            }
        }
    }
    for(ll mask=0;mask<(1<<n);mask++)
    {
        vector<ll> not_taken;
        for(ll i=0;i<n;i++)
        {
            if(!((1<<i)&mask))
                not_taken.push_back(i);
        }
        fun(0,not_taken,dp[mask],mask,0);
    }
    cout<<dp[(1<<n)-1];
}

int main() 
{
    off;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ll tests=1;
    // cin>>tests;
    while(tests--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
const long long MOD=1e9+7;
vector<long long> fact, fact_inv, inv;
void init_nCk(int n){
  fact.resize(n+5);
  fact_inv.resize(n+5);
  inv.resize(n+5);
  fact[0]=fact[1]=1;
  fact_inv[0]=fact_inv[1]=1;
  inv[1]=1;
  for(int i=2;i<n+5;i++){
    fact[i]=fact[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    fact_inv[i]=fact_inv[i-1]*inv[i]%MOD;
  }
}
int nCk(int n,int k){
  assert(!(n<k));
  assert(!(n<0 || k<0));
  return fact[n]*(fact_inv[k]*fact_inv[n-k]%MOD)%MOD;
}
int main(){
  long long ans1=1,ans2=0;
  int N,M;
  cin>>N>>M;
  for(int i=M;i>M-N;i--){
    ans1*=i;
    ans1%=MOD;
  }
  init_nCk(N);
  long long a=1;
  for(int i=N;i>=1;i--){
    if(i%2==1){
      ans2+=nCk(N,i)*a;
      ans2%=MOD;
    }
    else{
      ans2-=nCk(N,i)*a-MOD*MOD;
      ans2%=MOD;
    }
    a*=(M-i+1);
    a%=MOD;
  }
  cout<<ans1*(ans1-ans2+MOD)%MOD<<endl;
}

Measured memory_bytes: 14672
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }

void _main() {
  int N;
  cin >> N;
  int a[N];
  rep(i, 0, N) cin >> a[i];

  int next = 1;
  rep(i, 0, N) {
    next = a[next-1];
    if (2 == next) {
      cout << (i+1) << "\n";
      return;
    }
  }
  cout << -1 << "\n";
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char ch;
    cin>>ch;
    if(ch >= 'A' && ch <= 'Z')
    {
        printf("A");
    }
    else if(ch >= 'a' && ch <= 'z')
    {
        printf("a");
    }
 
}


Measured memory_bytes: 3616
import sys
from collections import defaultdict

def solve():
    input = sys.stdin.readline
    N = int(input())
    sDict = defaultdict(int)
    maxCount = 0
    for i in range(N):
        s = input().strip("\n")
        sDict[s] += 1
        maxCount = max(maxCount, sDict[s])
    maxS = []
    for key in sDict:
        if sDict[key] == maxCount:
            maxS.append(key)
    maxS.sort()
    print(*maxS, sep="\n")

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 36836
import java.util.Scanner;
class Main{
	
    public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int x=sc.nextInt();
int a=sc.nextInt();
int b=sc.nextInt();
System.out.println(ze(x-a)>ze(x-b)?"B":"A");
 }
    public static int ze(int x) {
    	int x_ = x<0 ?-x :x ;
    	return x_;
    }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define V(i) vector<i>
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define crep(i,N,n) for (__typeof(n) i = N; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define P(i,j) pair<i,j>
#define MP make_pair
#define MOD 1000000007
typedef long long ll;
typedef long l;
#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ll n,m;
    cin>>n>>m;
    V(ll) cn(n+1,0),og(n+1,0),vis(n+1,0),piss;
    V(V(ll)) graph(n+1);
    rep(i,m)
    {
        ll a,b;
        cin>>a>>b;
        graph[b].push_back(a);
        cn[a]++;
    }
    crep(i,1,n+1)
    {
        if(cn[i] == 0)
        {
            piss.push_back(i);
        }
    }
    while(piss.size()>0)
    {
        ll node = piss[0];
        if(vis[node] !=0)
        {
            piss.erase(piss.begin());
            continue;
        }
        vis[node] = 1;
        for(ll i=0;i<graph[node].size();i++)
        {
            og[graph[node][i]] = max(og[graph[node][i]],og[node]+1);
            cn[graph[node][i]]--;
            if(cn[graph[node][i]] == 0 && vis[graph[node][i]] == 0)
            {
                piss.push_back(graph[node][i]);
            }
        }
        piss.erase(piss.begin());
    }
    cout<<*max_element(all(og));

    return 0;
}

Measured memory_bytes: 10952
#include <cstdio>
#include <string.h>
using namespace std;

int n, m, s, ans;
int dp[2][2001][3001];

int main(){
    while(scanf("%d%d%d", &n, &m, &s) && n && m && s){
        for(int i = 1; i <= m; i++)
            dp[0][i][i] = 1;

        for(int i = 2; i <= n * n; i++){
            for(int j = 1; j < m; j++){
                for(int k = j; k < s; k++){
                    dp[1][j + 1][k + 1] += dp[1][j][k];
                    dp[1][j + 1][k + 1] += dp[0][j][k - j];
                    dp[1][j + 1][k + 1] %= 100000;
                }
            }
            for(int j = 1; j <= m; j++){
                for(int k = 1; k <= s; k++){
                    dp[0][j][k] = dp[1][j][k];
                    dp[1][j][k] = 0;
                }
            }
        }

        for(int i = 1; i <= m; i++){
            ans += dp[0][i][s];
            ans %= 100000;
        }

        printf("%d\n", ans);
        memset(dp, 0, sizeof dp);
        ans = 0;
    }

    return 0;
}

Measured memory_bytes: 47944
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define c(a) cout<<a<<"\n";
using namespace std;


int main() {
	speed;
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int>xx;
	vector<int>yy;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		xx.push_back(a);
	}
	rep(i, m) {
		int a;
		cin >> a;
		yy.push_back(a);
	}
	sort(All(xx));
	sort(All(yy));
	int xlst = xx.back();
	int yfrt = yy.front();
	if (x >= y || xlst+1 > yfrt||x>=yfrt||y<=xlst) {
		c("War");
	}
	else{
		c("No War");
	}

	ed;
	return 0; 
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <numeric>

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

using namespace std;

int main(void){
  int ab,bc,ca;
  cin >> ab >> bc >> ca;
  cout << ab*bc/2;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 1e9 + 7;
const int N = 1e6 + 5;
const int M = 1e3 + 5;
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
ll n;

int main(){
    ios;
    cin>>n;
    int ans = 0;
    for(ll i=2;i*i<=n;++i){
        if(n%i==0){
            int tmp=0, pos=1;
            while(n%i==0){
                n/=i;
                ++tmp;
                if(tmp==pos){
                    pos++;
                    tmp=0;
                    ++ans;
                }
            }
        }
    }
    if(n!=1) ++ans;
    cout<<ans;
    return 0;
}

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

public static class P {
    public static void Main() {
        int[]a=new int[5];
        for(int i=0;i<5;i++){
            a[i]=int.Parse(Console.ReadLine());
        }
        int k=int.Parse(Console.ReadLine());
        Console.WriteLine(a.Max()-a.Min()<=k?"Yay!":":(");
    }
}


Measured memory_bytes: 13268
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <ctime>
#include <memory.h>
#include <bitset>
#include <climits>
#include <iomanip>

#define F first
#define S second
#define endl "\n"
#define pb push_back
#define mp make_pair
#define bs 1000000007
#define pi 3.141592653589793
#define y1 kjdfshnvoavaofobiopj
#define ends yryrqayrehojoborolo
using namespace std;

int k, s, cnt;

int main(){
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);

cin>>k>>s;
for(int i = 0; i <= k; i++)
    for(int j = 0; j <= k; j++)
    {
        if(s-(i+j) <= k && s-(i+j) >= 0)
            ++cnt;
    }
cout<<cnt<<endl;

return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <limits>
#include <numeric>
#include <type_traits>

#define roop(i, n) for(int i=0;i<n;i++)

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int myGCD(int a, int b) {
	while(1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

ull myABS(ull a) {
	if (a > 0) {
		return a;
	} else {
		return -a;
	}
}

int main() {
	ull n, k;
	cin >> n >> k;
	cout << min(n%k, k-n%k) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val A = nextIntList()
    println(A.max()!! * 9 + A.sum())
}

Measured memory_bytes: 37780
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N;
ll A[SIZE];
ll K;

int main()
{
	cin >> N;
	rep(i,0,N)cin >> A[i];
	sort(A,A+N);
	deque<ll> S,T;
	rep(i,0,N)S.push_back(A[i]);

	T.push_back(S.front());
	S.pop_front();
	while(!S.empty()){
		ll sl = S.front();
		ll sr = S.back();
		ll tl = T.front();
		ll tr = T.back();
		ll sltl = abs(sl-tl);
		ll sltr = abs(sl-tr);
		ll srtl = abs(sr-tl);
		ll srtr = abs(sr-tr);
		ll mx = max({sltl,sltr,srtl,srtr});
		if(mx==sltl){
			T.push_front(sl);
			S.pop_front();
		}else if(mx==sltr){
			T.push_back(sl);
			S.pop_front();
		}else if(mx==srtl){
			T.push_front(sr);
			S.pop_back();
		}else{
			T.push_back(sr);
			S.pop_back();
		}
	}
	ll ans = 0;
	ll u = T.front();
	T.pop_front();
	while(!T.empty()){
		ll t = T.front();
		ans += abs(u-t);
		u = t;
		T.pop_front();
	}
	cout << ans << endl;

	return 0;
}


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

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  rd(string, s);
  sort(all(s));
  wt(s == "abc" ? "Yes" : "No");
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

ll mod = 1000000007;

signed main()
{
    int n;
    cin >> n;
    vi l;
    rep(i, n)
    {
        int a;
        cin >> a;
        l.push_back(a);
    }
    sort(all(l));
    ll ans = 0;
    rep(i, n)
    {
        for (int j = i + 1; j < n; j++)
        {
            //二辺が決まると条件が決まる
            //a-b<c,b-a<c,c<a+b
            int left = max(l[i] - l[j], l[j] - l[i]);
            int right = l[i] + l[j];
            //            auto it1=upper_bound(all(l),left);
            auto it = lower_bound(all(l), right);
            //            cout << i << " " << j << " " << it - l.begin() << endl;
            if (it - l.begin() - j - 1 > 0)
            {
                ans += it - l.begin() - j - 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<int> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];

    vector<int> G[N];
    for (int i = 0; i < M; i++) {
        int A, B; cin >> A >> B;
        G[A-1].push_back(B-1);
        G[B-1].push_back(A-1);
    }

    int ans = 0;
    for (int u = 0; u < N; u++) {
        bool flag = true;
        for (int v : G[u]) {
            if (H[u] <= H[v]) flag = false;
        }
        if (flag) ans++;
    }
    cout << ans << endl;
}

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

int main()
{
    int N, T;
    cin >> N >> T;
    int c[N];
    int t[N];
    for (int i=0; i<N; i++) {
        cin >> c[i];
        cin >> t[i];
    }

    int result = INT32_MAX;
    for (int i=0; i<N; i++) {
        if (t[i] <= T && c[i] < result) {
            result = c[i];
        }
    }
    if (result == INT32_MAX) {
        cout << "TLE";
    } else {
        cout << result;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mk make_pair
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define vl vector<long long int>
#define vvl vector<vector<ll> > 
#define fo(i,a,b) for(int i=a;i<b;i++)
#define rof(i,a,b)  for(int i=b;i>=a;i--)
using namespace std;
ll mod=1000000007;

int main()
{
    ll n,k;cin>>n>>k;
    ll h[n];
    fo(i,0,n)   cin>>h[i];
    ll dp[n+1];
    memset(dp,0,sizeof(dp));
    dp[0]=0;
    for(ll i=1;i<n;i++)
    {
        dp[i]=1e9+7;
        for(ll j=i-1;j>=i-k&&j>=0;j--)
        {
            dp[i] = min(dp[i],abs(h[i]-h[j])+dp[j]);
        }
        
    }
    cout << dp[n-1];
}



Measured memory_bytes: 5180
# -*- coding: utf-8 -*-
"""
B - Problem Set
https://atcoder.jp/contests/code-festival-2017-qualb/tasks/code_festival_2017_qualb_b

"""
import sys

from collections import Counter

def solve(N, D, M, T):
    have = Counter(D)
    required = Counter(T)
    return 'NO' if required - have else 'YES'


def main(args):
    N = int(input())
    D = [int(d) for d in input().split()]
    M = int(input())
    T = [int(t) for t in input().split()]
    ans = solve(N, D, M, T)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 56928
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string s, t;
  cin >> s >> t;
  vector<int> from(26, -1);
  vector<int> to(26, -1);
  rep(i, (int)s.size()) {
    int start = s[i] - 'a';
    int end = t[i] - 'a';
    
    if (to[end] != -1 || from[start] != -1) {
      if (to[end] != start || from[start] != end) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      from[s[i] - 'a'] = t[i] - 'a';
      to[t[i] - 'a'] = s[i] - 'a';
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3904
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,sum=0;

    cin>>n;
    vector<int>v;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        v.push_back(a);
        sum +=a;
    }
    sort(v.begin(),v.end());
    a = v[n-1]/2.0;
    sum -=a;
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define cpy(a,b) memcpy(a,b,sizeof(a))
#define prq priority_queue
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n,b=0,r=0;
	string s;
	cin>>n>>s;
	fo(i,0,n){
		if(s[i]=='B')b++;
		else r++;
	}
	if(r>b)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<int> a(n);
	multiset<int> mst;
	for (int i=0; i<n; i++)
		cin>>a[i], mst.insert(a[i]);
	for (int i=0; i<n; i++) {
		mst.erase(mst.find(a[i]));
		cout<<*mst.rbegin()<<"\n";
		mst.insert(a[i]);
	}
	return 0;
}

Measured memory_bytes: 11776