akhauriyash/Code-Regression huggingface dataset:
import sys
from operator import itemgetter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
ab = []
for i in range(n):
    ab.append(na())

ab.sort(key=itemgetter(0))

pq = []
import  heapq

ans = 0
p = 0
for i in range(m+1):
    while p < n and ab[p][0] <= i:
        heapq.heappush(pq, -ab[p][1])
        p += 1

    if len(pq) == 0:
        continue

    ans -= heapq.heappop(pq)

print(ans)


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001000;

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    rep(i, N) {
        cin >> C[i];
        rep(j, M) cin >> A[i][j];
    }

    int ans = INF;
    rep(bit, 1 << N) {
        vector<int> sum(M, 0);
        int cost = 0;
        rep(i, N) {
            if (bit & (1 << i)) {
                rep(j, M) sum[j] += A[i][j];
                cost += C[i];
            }
        }
        bool ok = true;
        rep(j, M) if (sum[j] < X) ok = false;
        if (ok) chmin(ans, cost);
    }

    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  if (A <= C && B <= C) 
    cout << C * 10 + A + B;
  
  if (A <= B && C < B)
    cout << B * 10 + A + C;
  
  if (B < A && C < A)
    cout << A * 10 + B + C;
  }

Measured memory_bytes: 256
// Problem : B - Resistors in Parallel
// Contest : AtCoder Beginner Contest 138
// URL : https://atcoder.jp/contests/abc138/tasks/abc138_b
// Memory Limit : 1024,000000 MB 
// Time Limit : 2000,000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  cout.precision(16);
  cout << fixed;
  
  int n;
  cin >> n;
  
  vector<int> a(n);
  for (auto&& i : a)
    cin >> i;
    
  double ans = 0.0;
  
  sort(a.rbegin(), a.rend());
  
  for (int i = 0; i < n; ++i) {
    ans += 1.0 / a[i];
  }
  
  cout << 1 / ans;
}


Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define LLIandI pair<long long int , int>
#define ll long long
 int main(){
     long long int n,m;
     scanf("%lld %lld",&n,&m);
     long long int x[100002],y[100002];
     long long int bx[100002],by[100002];
     rep(i,n){scanf("%lld",&x[i]);if(i>0)bx[i-1]=x[i]-x[i-1];}
     rep(i,m){scanf("%lld",&y[i]);if(i>0)by[i-1]=y[i]-y[i-1];}
     long long int mod=1000000007;
     long long int xans=0,yans=0;
     rep(i,n-1){
         long long int use=(n-1-i)*(i+1);
         xans+=(bx[i]*use)%mod;xans%=mod;
     }
     rep(i,m-1){
         long long int use=(m-1-i)*(i+1);
         yans+=(by[i]*use)%mod;yans%=mod;
     }
     printf("%lld\n",(xans*yans)%mod );
     
 }

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    map<ll, ll> p, n;
    REP(i, N){
        p[i + A[i]]++;
        if (i - A[i] >= 0) n[i - A[i]]++;
    }
    ll ans = 0;
    for(auto iter = p.begin(); iter != p.end(); iter++){
        ll i = iter->first;
        ans += p[i] * n[i];
    
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 30132
N, M = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))
P = 300005
d1 = [0] * P
d2 = [0] * P
s = 0
for i in range(N - 1):
    x = a[i]
    y = a[i + 1]
    if y < x:
        y += M
    s += y - x
    if x + 1 < y:
        d1[x + 2] += 1
        d1[y + 1] -= 1
        d2[y + 1] += y - x - 1
        d1[M + x + 2] += 1
        d1[M + y + 1] -= 1
        d2[M + y + 1] += y - x - 1

ans = float('inf')
for i in range(3 * M):
    if i > 0:
        d1[i] += d1[i - 1]
        d2[i] += d2[i - 1]
    d2[i] -= d1[i]
    ans = min(ans, s + d2[i])

print(ans)



Measured memory_bytes: 56940
# ABC098 D - Xor Sum 2
n=int(input())
a=list(map(int,input().split()))

l=0
r=1
tmp=a[0]
ans=0

while l<n:
    if r==n:
        ans+=(r-l)
        l+=1
        continue
    if tmp+a[r]==tmp^a[r]:
        tmp=tmp+a[r]
        r+=1
    else:
        ans+=(r-l)
        tmp=tmp-a[l]
        l+=1      

print(ans)


Measured memory_bytes: 23560
#include <iostream>
using namespace std;
int main(void) {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      int rest = s - i - j;
      if (rest >= 0 && rest <= k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

std::vector<std::vector<int>> G;

void warshall_floyd(int n) {
  for (int k=0; k<n; k++) for (int i=0; i<n; i++) for (int j=0; j<n; j++) G[i][j] = std::min(G[i][j], G[i][k]+G[k][j]);
  return;
}


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N, M, R; 
  std::cin >> N >> M >> R;
  std::vector<int> r(R);
  rep(i,R) { std::cin >> r[i]; r[i]--; }
  G.resize(N); rep(i,N) G[i].resize(N, (1LL<<29));
  rep(i,M) {
    int a, b, c; std::cin >> a >> b >> c;
    a--,b--;
    G[a][b] = c;
    G[b][a] = c;
  }

  warshall_floyd(N);
  std::sort( all(r) );

  int ans = (1LL<<29);
  do{
    int tmp = 0;
    for(int i=1; i<R; i++) tmp += G[r[i-1]][r[i]];
    ans = std::min(ans,tmp);
  } while(std::next_permutation( r.begin(), r.end() ));

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define mx 100002
vector<int> adj[mx];
int dp[mx];

int depth(int a)
{
  if(dp[a]!=-1) return dp[a];
  int ans = 0;
  for(int x : adj[a])
  {
    ans = max(ans,1+depth(x)); 
  }
  dp[a] = ans;
  return ans;
}


int main() {
  int n,m;
  cin>>n>>m;
  int a,b;
  for(int i=0;i<m;i++)
  {
    cin>>a>>b;
    adj[a].push_back(b);
  }
  for(int i=0;i<mx;i++)
    dp[i] = -1;
  int ans = 0;
  for(int i=1;i<=n;i++)
  {
    ans = max(ans,depth(i));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int n,m,x;
    cin >> n >> m >> x;
    int a[n][m];
    int c[n];
    for(int i = 0; i < n; i++)
    {
        cin >> c[i];
        for(int j = 0; j < m; j++)
            cin >> a[i][j];
    }
    int sum = INT32_MAX;
    for(int i = 0; i < (1 << n); i++)
    {
        // cout << "i: " << i << " ";
        vector<int> temp(m);
        int cost = 0;
        for(int j = 0; j < n; j++)
        {
            // cout << (i & (1 << j)) << " ";
            if(i & (1 << j))
            {
                for(int k = 0; k < m; k++)
                    temp[k] += a[j][k];
                cost += c[j];
            }
        }
        // cout << '\n';
        // for(int v = 0; v < m; v++)
        //     cout << temp[v] << " ";
        int f = 1;
        for(int v = 0; v < m; v++)
            if(temp[v] < x)
            {
                f = 0;
                break;
            }
        if(f)
            sum = min(sum,cost);
        // cout << '\n';
    }   
    if(sum == INT32_MAX)
        cout << "-1\n";
    else
        cout << sum << '\n';
}

Measured memory_bytes: 3640
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
N = int(input())
a = [0]
reva = [[] for _ in range(N + 1)]
for _ in range(N - 1): a.append(int(input()))
for i in range(N):
  if a[i] == 0: continue
  reva[a[i]].append(i + 1)
dp = [-1] * (N + 1)
def dfs(x):
  global dp
  if len(reva[x]) == 0:
    dp[x] = 1
    return 1
  t = []
  for y in reva[x]:
    t.append(dfs(y))
  t.sort(reverse = True)
  for i in range(len(t)):
    t[i] += i + 1
  dp[x] = max(t)
  return dp[x]
print(dfs(1) - 1)

Measured memory_bytes: 123824
import java.util.Scanner;
//import java.io.*;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		//InputStreamReader is = new InputStreamReader(System.in);
		//BufferedReader br = new BufferedReader(is);
		//String text = scan.next();
		
		while(scan.hasNext()){
			String text = scan.next();
			int count = 0;
			for(int i = 0 ; i < Integer.parseInt(text) ; i++){
				++count;
				if(count == 40){
					count = 1;
				}
			}
			if(Integer.toString(count).length() == 1){
				System.out.println("3C0" + count);
			}else{
				System.out.println("3C" + count);
			}
			
		}
	}
}

Measured memory_bytes: 27420
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<int> A, B;
int main()
{
    cin >> N;
    A.resize(N);
    B.resize(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i] >> B[i];
    }
    if (A == B)
    {
        cout << 0 << endl;
        return 0;
    }
    ll sum_a = accumulate(A.begin(), A.end(), 0LL);
    ll res = LL_INF;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i] >> B[i];

        if (A[i] > B[i])
        {
            res = min(res, (ll)B[i]);
        }
    }
    cout << sum_a - res << endl;
    return 0;
}


Measured memory_bytes: 384
from itertools import*
n=int(input())
a=[[s for s in input().split()]for _ in range(n)]
for k in range(n):
 b=a[k];b[3],b[4]=b[4],b[3]
def f():
 for d,e in list(combinations(a,2)):
  for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
   f=[d[k]for k in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:return'No'
 return'Yes'
print(f())


Measured memory_bytes: 5988
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <unordered_map>

using namespace std;

using ll = long long;
using ld = long double;

#define REP(i, s, e) for (ll i = s; i < e; ++i)

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

    int N, Q;
    ll K;
    cin >> N >> K >> Q;
    vector<int> As(N, 0);
    REP(i, 0, Q)
    {
        int A; cin >> A;
        As[A - 1]++;
    }

    REP(i, 0, N)
    {
        if (K - Q + As[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
n = int(input())
height = list(map(int, input().split()))

top = [0] + [i+1 for i in range(n-1) if height[i] < height[i+1] ]

result = [top[i+1]-top[i]-1 for i in range(len(top)-1)] + [(n-1)-top[len(top)-1]]

print(max(result))

Measured memory_bytes: 14252
#include <stdio.h>
int main(void)
{
  int n,m,c,i;
  int a[100000];
  while(1){
    scanf("%d",&n);
    if(n==-1) break;
    if(n==0)
      printf("0\n");
    else{   
      c=0;
      while(n/4){
	a[c++]=n%4;
	n/=4;
      }
      a[c]=n%4;
      for(i=c;i>=0;i--)
	printf("%d",a[i]);
      putchar('\n');
    }
  }
  return 0;
}

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

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

    int n;
    cin >> n;
    vector<int> A(n + 1);

    // 1-indexed
    for(int i = 1; i <= n; i++){
        cin >> A[i];
    }

    vector<int> B(n + 1, false);
    int m = 0;
    for(int i = n; i >= 1; i--){
        int c = 0;
        for(int j = i; j <= n; j += i){
            c ^= B[j];
        }
        if(A[i]){
            if(c);
            else{
                B[i] = 1;
                m++;
            }
        }else{
            if(c){
                B[i] = 1;
                m++;
            }
        }
    }

    cout << m << endl;
    if(m > 0){
        for(int i = 1; i <= n; i++){
            if(B[i]) cout << i << ' ';
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

LL get_median(vector<LL> input)
{
  int N = input.size();
  sort(input.begin(), input.end());

  if (N % 2 == 1)
  {
    return input[N / 2];
  }

  return input[N / 2 - 1] + input[N / 2];
}

void solve(long long N, std::vector<long long> A, std::vector<long long> B)
{
  cout << get_median(B) - get_median(A) + 1 << endl;
}

int main()
{
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  std::vector<long long> B(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
  }
  solve(N, std::move(A), std::move(B));
  return 0;
}


Measured memory_bytes: 9588
N, M = map(int, input().split())

e = []
for _ in range(M):
    e.append(tuple(map(int, input().split())))

e.sort(key=lambda x:x[1])


ans = 1
s, g = e[0]

for i in range(1, M):

    # 直近で最も小さい終点と、現在の始点を比較する
    if e[i][0] < g:
        continue
    else:
        g = e[i][1]
        ans += 1

print(ans)

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

int main() {
  string s;
  cin >> s;
  int size = s.size();
  vector<string> vec(15);
  for (int i = 0; i < size; i++) {
    if (s.at(i) == '0') {
      vec.push_back("0");
    }
    else if (s.at(i) == '1') {
      vec.push_back("1");
    }
    else {
      if (i == 0) continue;
      else {
        vec.pop_back();
      }
    }
  }
  for (int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
  }
}



Measured memory_bytes: 256
from bisect import bisect_right
n,m,k=map(int,input().split())
a=[int(i) for i in input().split()][:n]
b=[int(i) for i in input().split()][:m]
x=[0]*(n+1)
y=[0]*(m+1)
for i in range(1,n+1):
    x[i]=x[i-1]+a[i-1]
for j in range(1,m+1):
    y[j]=y[j-1]+b[j-1]
ans,j=0,m
for i in range(n+1):
    if x[i]>k:
        break
    j=bisect_right(y,k-x[i])-1
    ans=max(ans,i+j)
print(ans)            

Measured memory_bytes: 47084
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
ll a,b,c;
cin>>a>>b>>c;
cout<<max({a,b,c})*10+a+b+c-max({a,b,c})<<endl;
}









Measured memory_bytes: 256
n = int(input())
s = input()

frag = 0
count = 0
for i in range(n) :
    if s[i] == 'A':
        frag = 1
    elif s[i] == 'B' and frag == 1 :
        frag = 2
    elif s[i] == 'C' and frag == 2 :
        count += 1
        frag = 0
    else :
        frag = 0
print(count)


Measured memory_bytes: 3060
#include <iostream>
#include <unordered_set>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>


using namespace std;
typedef long long ll;



int main() {

    int n;
    string s;
    int res = 0;
    cin>>s;

    n = s.size();
    for(int i=0;i<n/2;i++){
        if ( s[i] != s[n-i-1] ) res++;
    }

    cout<<res;

     return 0;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vd vector<double>
#define f(i,l,r) for(ll i=l;i<r;i++)
#define d(i,n,m) for(ll i=n;i>=m;i--)
#define P (ll)1e9+7
#define pb push_back
#define F first
#define S second
#define IP ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int offset[]={1,0,-1,0,1};
int main()
{
    IP
    ll n,k;
    cin>>n>>k;
    vector<ll> snuke[n];
    f(i,1,k+1)
    {
      ll d;
      cin>>d;
      f(j,0,d)
      {
          ll temp;
          cin>>temp;
          snuke[temp-1].pb(i);
      }
    }
    ll ans=0;
    f(i,0,n)
    {
        if(snuke[i].empty())
        ans++;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3736
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int x,y;
	while(1){
		cin>>x>>y;
		if(!(x||y))break;
		int status[y][x],dp[y][x];
		rep(i,y){
			rep(j,x){
				cin>>status[i][j];
			}
		}
		int sum=0;
		rep(i,y){
			rep(j,x){
				if(i==0 && status[i][j]!=1)dp[i][j]=1;
				else dp[i][j]=0;
			}
		}
		rep(i,y){
			rep(j,x){
				if(status[i][j]==1)continue;
				if(status[i][j]==2){
					if(i>=y-2)sum+=dp[i][j];
					else dp[i+2][j]+=dp[i][j];
					continue;
				}
				if(i==y-1)sum+=dp[i][j];
				else{
					if(j==0){
						if(status[i+1][j]!=1)dp[i+1][j]+=dp[i][j];
						if(status[i+1][j+1]==0)dp[i+1][j+1]+=dp[i][j];
					}else if(j==x-1){
						if(status[i+1][j]!=1)dp[i+1][j]+=dp[i][j];
						if(status[i+1][j-1]==0)dp[i+1][j-1]+=dp[i][j];
					}else{
						if(status[i+1][j]!=1)dp[i+1][j]+=dp[i][j];
						if(status[i+1][j+1]==0)dp[i+1][j+1]+=dp[i][j];
						if(status[i+1][j-1]==0)dp[i+1][j-1]+=dp[i][j];
					}
				}
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AStationAndBus solver = new AStationAndBus();
        solver.solve(1, in, out);
        out.close();
    }

    static class AStationAndBus {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();

            if (S.contains("A") && S.contains("B")) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }

    static class Scanner {
        private final InputStream in;
        private final byte[] buffer;
        private int ptr;
        private int buflen;

        public Scanner(InputStream in) {
            this.in = in;
            this.buffer = new byte[1024];
            this.ptr = 0;
            this.buflen = 0;
        }

        private boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }

        private byte readByte() {
            if (hasNextByte()) return buffer[ptr++];
            return -1;
        }

        private boolean isPrintableChar(byte c) {
            return '!' <= c && c <= '~';
        }

        private void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
        }

        public boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            byte b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

    }
}



Measured memory_bytes: 21460
n = int(input())
a = list(map(int, input().split()))

def gcd(x, y):
    x, y = min(x, y), max(x, y)
    while True:
        mod = y % x
        if mod == 0:
            break
        y = x
        x = mod

    return x

lcm = a[0]
for i in range(1, n):
    lcm = lcm * a[i] // gcd(lcm, a[i])

res = 0
for i in range(n):
    res += (lcm - 1) % a[i]
print(res)

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

int fact(int n)
{
  // int ret = 1;
  // while (n > 1)
  // {
  //   ret *= n;
  //   n--;
  // }
  // return ret;
  return n <= 1 ? 1 : n * fact(n - 1);
}

int main()
{
  int n, a = 0, b = 0, count = 0;
  bool flag;
  cin >> n;
  vector<int> P(n), Q(n), T(n);
  vector<vector<int>> vec;
  for (int i = 0; i < n; i++)
    cin >> P.at(i);
  for (int i = 0; i < n; i++)
    cin >> Q.at(i);
  for (int i = 0; i < n; i++)
    T.at(i) = i + 1;

  do
  {
    count++;
    flag = true;
    for (int i = 0; i < n; i++)
    {
      if (T.at(i) != P.at(i))
      {
        flag = false;
        break;
      }
    }
    if (flag)
      a = count;

    flag = true;
    for (int i = 0; i < n; i++)
    {
      if (T.at(i) != Q.at(i))
      {
        flag = false;
        break;
      }
    }
    if (flag)
      b = count;
  } while (next_permutation(T.begin(), T.end()));

  cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		int[] stones = new int[n];
		int[] sol = new int[n];
		for (int i = 0; i < n; i++) {
			stones[i]=s.nextInt();
		}
		sol[0]=0;
		sol[1]=Math.abs(stones[0]-stones[1]);
		for (int i = 2; i < sol.length; i++) {
			int solid = Math.abs(stones[i-1]-stones[i])+sol[i-1];
			for (int j = 2; j <= k&&i-j>=0; j++) {
				solid=Math.min(solid,(Math.abs(stones[i-j]-stones[i])+sol[i-j]));
			}
			sol[i]=solid;
			
		}
		System.out.println(sol[n-1]);
	}

}


Measured memory_bytes: 59392
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.HashSet;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String s = in.readLine();
    HashSet<String> hs = new HashSet<String>();
    int max = 0;
    
    for(int i=1; i<n; i++) {
      String s_bf = s.substring(0,i);
      String s_af = s.substring(i,n);
      hs.clear();
      for(int j=0; j<s_bf.length(); j++) {
        String x = s_bf.substring(j,j+1);
        if(s_af.contains(x))
          hs.add(x);
      }
      if(hs.size()>max)
        max = hs.size();
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 33096
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define pconent(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int FFTMOD = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

const int maxn = 1e5 + 5;
int n;
int a[maxn];

void chemthan() {
    cin >> n;
    a[0] = 1;
    FOR(i, 1, n + 1) cin >> a[i];
    long long lo = 2, hi = 2;
    FORd(i, n + 1, 1) {
        if (lo % a[i] || hi % a[i]) {
            cout << - 1 << "\n";
            return;
        }
        lo = (lo + a[i - 1] - 1) / a[i - 1] * a[i - 1];
        hi = (hi + a[i] - 1) / a[i - 1] * a[i - 1];
    }
    if (lo > hi) {
        cout << - 1 << "\n";
        return;
    }
    cout << lo << " " << hi << "\n";
}

int main(int argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

#define io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
#define ld long double
#define EPS (1e-15)
#define mod 1000000007
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define SIZE(x) (int) x.size()
#define to_string(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
#define lp(i, a, n) for (int(i) = (a); (i) <= (int)(n); ++(i))
#define lpd(i, n, a) for (int(i) = (n); (i) >= (a); --(i))
#define bitcount(n) __builtin_popcountll(n)
#define readi(x) scanf("%d", &x);
#define readl(x) scanf("%lld", &x);
#define reads(x) scanf("%s", &x);
#define readc(x) scanf("%c", &x);
#define readd(x) scanf("%lf", &x);

using namespace std;
const int N = 200005;
const int K = (int)log2(N) + 2;
const ll infi = 1ll << 60;

int main() {
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);
    io;
    ll a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
module Main where

import Data.Functor
import Control.Monad

main :: IO ()
main=do
  n <- read <$> getLine::IO Int
  when (n/=0) $
    do
      let out=map (unwords . map show) (allPat n n)
      mapM_ putStrLn out
      main

allPat::Int->Int->[[Int]]
allPat n l
  |n==0 = [[]]
  |n<0 =[]
  |otherwise =(\m->(m:) <$> allPat (n-m) m) =<< [l,(l-1)..1]

Measured memory_bytes: 4080
import sys
import copy
from collections import deque


def main():
    N, M, Q = map(int, input().split())
    ABCD = [[int(_) for _ in input().split()] for i in range(Q)]

    seq_list = make_sequence(N, M)
    
    max_score = 0
    for i_seq in seq_list:
        score = 0
        for a, b, c, d in ABCD:
            if (i_seq[b-1] - i_seq[a-1]) == c:
                score += d
        
        max_score = max(max_score, score)

    print(max_score)
    return


def make_sequence(N, M):
    seq_list = []
    sequence = [-1] * N

    seq_deque = deque()
    now_ele = 0
    for i in range(M):
        sequence[0] = i
        now_seq = copy.copy(sequence)
        seq_deque.append([now_ele, now_seq])

    while len(seq_deque) > 0:
        pre_ele ,pre_seq = seq_deque.popleft()
        if pre_seq[-1] != -1:
            seq_list.append(pre_seq)
            continue

        end_ele = M - sum(pre_seq[0:pre_ele+1])
        for i in range(end_ele):
            pre_seq[pre_ele+1] = i
            now_seq = copy.copy(pre_seq)
            seq_deque.append([pre_ele+1 ,now_seq])

    for i_seq in seq_list:
        now_value = 1
        for i, i_value in enumerate(i_seq):
            now_value += i_value
            i_seq[i] = now_value

    return seq_list


if __name__ == '__main__':
    main()
    sys.exit(0)

Measured memory_bytes: 119560
import sys
import os
import copy
N = int(input())
X = list(map(int,input().split()))
XX = copy.deepcopy(X)
X.sort()
mid = X[N//2-1]
midr = X[N//2]
ans = 0
for x in XX:
    if x <= mid:
        ans = midr
    elif midr <= x:
        ans = mid
    print(ans)
    ans = 0


Measured memory_bytes: 27156
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct node {
  vector <node*> children;
};

int calcDepth(node *n) {
  if (n->children.empty()) return 0;
  priority_queue <int> childDepth;
  for (int i = 0; i < n->children.size(); i++) {
    childDepth.push(calcDepth(n->children[i]));
  }
  int max = 0;
  int rank = 1;
  while (!childDepth.empty()) {
    int depth = childDepth.top() + rank;
    childDepth.pop();
    rank++;
    max = (max < depth) ? depth : max;
  }
  return max;
}

int main() {
  int N;
  cin >> N;
  node *nodes = new node[N + 1];
  for (int i = 2; i <= N; i++) {
    int input;
    cin >> input;
    nodes[input].children.push_back(nodes + i);
  }
  cout << calcDepth(nodes + 1);
  return 0;
}


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

using namespace std;

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

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

    int max_dist = a[0] + (k - a[n-1]);
    int sum = max_dist;
    for (int i = 0;i < n-1;i++) {
        int temp = a[i+1] - a[i];
        if (temp > max_dist) {
            max_dist = temp;
        }
        sum += temp;
    }

    cout << sum - max_dist << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,a,ba[100010],m,r;


int main(){
    cin>>n;
    m=200;
    a=0;
    for(int i=0;i<n;i++){
        cin>>ba[i];
        if(ba[i]%10==0)a++;
        else m=min(m,ba[i]);
        
        r+=ba[i];
    }
    
    if(r%10)C r E;
    else if(n==a)C 0 E;
    else C r-m E;
    
    
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define N         100005
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
    
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
} 
ll n;
vector<vector<ll> > mat_mul(vector<vector<ll> > &a,vector<vector<ll> > &b)
{
	vector<vector<ll> > c(n,vector<ll>(n,0)); ll m=0;
	rep(i,0,n)
	{
		rep(j,0,n)
		{
			rep(k,0,n)
			{
				c[i][j]+=a[i][k]*b[k][j];
				c[i][j]=c[i][j]%mod;
			}
		}
	}
	return c;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
//	cout<<setprecision(12)<<fixed;
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,l,m,first,last,x,k;
    	cin>>n>>k;
		j=0;
    	vector<vector<ll> > a(n,vector<ll>(n)),ans(n,vector<ll>(n));
    	rep(i,0,n)
    	{
    		rep(j,0,n)
    		{
    			cin>>a[i][j];
    			ans[i][j]=i==j?1:0;
			}
		}
		while(k)
		{
			if(k%2)
			ans=mat_mul(ans,a);
			a=mat_mul(a,a);
			k
			=k/2;
		}
		ll jj=0;
		rep(i,0,n)
		{
			rep(j,0,n)
			{
				jj+=ans[i][j];
				jj=jj%mod;
			}
		}
		cout<<jj;
	}
	return 0;
}

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

using namespace std;

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  auto m = max(a * b, c * d);
  cout << m << endl;

  return 0;
}


Measured memory_bytes: 384
// D - Xor Sum 4
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define MOD 1000000007

int main(){
	int N; cin>>N;
	vector<ll> Z(60), O(60);
	rp(i, 0, N){
		ll a; cin>>a;
		rp(j, 0, 60) if((a>>j)&1) O[j]++; else Z[j]++;
	}
	ll ans = 0;
	rp(i, 0, 60) ans = (ans + (Z[i]*O[i] % MOD) * ((1LL<<i) % MOD)) % MOD;
	cout<< ans <<endl;
}

Measured memory_bytes: 256
// AOJ CGL_4_A Convex Hull
// 2018.5.3 bal4u

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

typedef struct { int x, y; } PP;

PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
int cross(PP a, PP b) { return a.x * b.y - a.y * b.x; }

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n)
{
	int i;
	char ob[20];

	if (!n) { pc('0'); return; }
	if (n < 0) pc('-'), n = -n;
	i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
	while (i--) pc(ob[i]); 
}

int cmp(PP *a, PP *b)
{
	int t = a->y - b->y;
	if (t) return t;
	return a->x - b->x;
}

int convex_hull(int n, PP *ps, PP *po)
{
	int i, k, j = 0;

	qsort(ps, n, sizeof(PP), cmp);
	for (i = 0; i < n; i++) {
		while (j > 1 && cross(vsub(po[j-1], po[j-2]), vsub(ps[i], po[j-1])) < 0) j--;
		po[j++] = ps[i];
	}
	k = j;
	for (i = n - 2; i >= 0; i--) {
		while (j > k && cross(vsub(po[j-1], po[j-2]), vsub(ps[i], po[j-1])) < 0) j--;
		po[j++] = ps[i];
	}
	return j-1;
}

PP p[100005], poly[100005];

int main()
{
	int n, k, i;

	n = in();
	for (i = 0; i < n; i++) p[i].x = in(), p[i].y = in();
	k = convex_hull(n, p, poly);
	out(k), pc('\n');
	for (i = 0; i < k; i++) {
		out(poly[i].x), pc(' '), out(poly[i].y), pc('\n');
	}
	return 0;
}


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

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

	vector<string> a;
	string input;
	for (int i = 0; i < H; i++) {
		cin >> input;
		a.push_back(input);
	}
	for (int i = 0; i<W + 2; i++)
		cout << "#";
	cout << endl;
	for (int i = 0; i < H; i++)
		cout << "#" << a.at(i) << "#" << endl;
	for (int i = 0; i<W + 2; i++)
		cout << "#";

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    string s;
    cin >> s;
    set<char> cnt;
    for (int i = 0; i < s.size(); ++i) {
        if (cnt.count(s[i]) == 1) {
            cout << "no" << "\n";
            return 0;
        }
        cnt.insert(s[i]);
    }
    cout << "yes" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

// nの約数を降順に列挙したvectorを返す。計算量はO(√n)
vector<ll> yakusu(ll n) {
    vl res;
    for(ll i = 1; i*i <= n; i++) {
        if(n%i == 0) {
            res.pb(i);
            if(i != n/i) {
                res.pb(n/i);
            }
        }
    }
    sort(rall(res));
    return res;  
}
 
int main() {
    ll n, k;
    cin >> n >> k;

    vl a(n);
    ll sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }

    vl AAA = yakusu(sum);

    for(auto d : AAA) {
        vl v(n);
        rep(i, n) {
            v[i] = a[i]%d;
        }
        sort(all(v));
        rep(x, n) {
            ll cnt = 0;
            exrep(i, 0, x) {
                cnt += v[i];
            } 
            if(cnt > k) {
                continue;
            }
            cnt = 0;
            exrep(i, x+1, n-1) {
                cnt += d - v[i];
            }
            if(cnt <= k) {
                out(d);
                re0;
            }
        }
    }
    
    re0;
}

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

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
	int n;
	ll t;
	cin >> n >> t;
	int a[n];
	for(int i=0; i<n; i++) cin >> a[i];
 	ll ans = 0;
	int start;
	ll now;
	start = now = 0;
	for(int i=0; i<n; i++){
		if(now == 0){
			start = a[i];
			now = t;
		}else if(a[i] - start < now){
			now = t + a[i] - start;
		}else{
			start = a[i];
			ans += now;
			now = t;
		}
	}
	cout << ans + now << endl;
  return 0;
}


Measured memory_bytes: 1024
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  str <- getLine
  putStrLn $ foldl imput [] str
  
imput result x
  |x=='0' = result ++ "0"
  |x=='1' = result ++ "1"
  |x=='B' = safeinit result

safeinit [] = []
safeinit str = init str

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 100005;
const ll MOD = 1e9+7;
ll ans = 1;
vector<int> G[MAX_N];
bool visit1[MAX_N],visit2[MAX_N];
int pa[MAX_N];
ll ch[MAX_N]; //子の数

void dfs_pa(int x)
{
	visit1[x] = true;
	rep(i,G[x].size())
	{
		if (!visit1[G[x][i]])
		{
			pa[G[x][i]] = x;
			dfs_pa(G[x][i]);
		}
	}
	return;
}

void dfs(int x, int c, int fcnt, int d)
{
	visit2[x] = true;
	ans = (ans * c) % MOD;
	//cout << x << " " << c << endl;
	int cnt = 0;
	rep(i,G[x].size())
	{
		if (!visit2[G[x][i]])
		{
			dfs(G[x][i],c-1-cnt+fcnt+(d>=2),cnt,d+1);
			cnt++;
		}
	}
	return;
}


int main()
{
	ll N,K;
	cin >> N >> K;
	rep(i,N-1)
	{
		int a,b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	ch[0] = G[0].size();
	rep(i,N-1)
	{
		ch[i+1] = G[i+1].size() - 1;
	}
	//pa[0] = 0;
	//dfs_pa(0);
	dfs(0,K,0,0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12416
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int nres=1,mres=1;
    for(int i=n;i>(n-2);i--) nres*=i;
    for(int i=m;i>(m-2);i--) mres*=i;
    nres/=2;
    mres/=2;
    System.out.println(nres+mres);                             
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < n; ++1)
using namespace std;
int main(){
int W,H,x,y,r;
cin >> W >> H >> x >> y >> r;
if (((x-r)>=0 && (x+r)<=W)&&((y-r)>=0 &&(y+r)<=H)){
cout << "Yes" << endl;
}
else {
cout << "No" <<endl;
}
return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
void solve(int T, int D, int L){
    vector<int> V(T);
    rep(i,0,T)cin >> V[i];
    int cnt = 0, last = -INF;
    rep(i,0,T){
        if(i <= last + D)cnt++;
        if(V[i] >= L)last = i;
    }
    cout << cnt << endl;
}
main(){
    int T,D,L;
    cin >> T >> D >> L;
    while(T){
        solve(T,D,L);
        cin >> T >> D >> L;
    }
}


Measured memory_bytes: 3388