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

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
//template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	int n = in(), m = in(), i = 1;
	deque<int> c(n * 2);
	for (int &f: c)
		f = i++;
	while (m--) {
		int k = in();
		if (k)
			for (int i = 0; i < k; i++) {
				c.push_back(c.front());
				c.pop_front();
			}
		else {
			deque<int> t = c;
			for (int i = 0; i < n; i++) {
				c[i * 2] = t[i];
				c[i * 2 + 1] = t[n + i];
			}
		}
	}
	for (int f: c)
		outl(f);
}


Measured memory_bytes: 2560
x,y= map(int,input().split())
crane= 2
turtle= 4
ans="No"
for i in range(x+1):
    b=x-i
    if crane*i + turtle*b == y:
        ans = "Yes"
print(ans)

# the for loop is to check for any combinations of numbers of cranes and turtles in which the statement is correct.

Measured memory_bytes: 9172
#include <iostream>

using namespace std;

int main() {
  string s;
  cin >> s;
  if (s.length() < 6) {
    cout << "No" << endl;
  }
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

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

typedef long long ll;

int n,m;

int par[100005];

int find(int x)
{
	return par[x] = (par[x]==x)?x:find(par[x]);
}

int unite(int x,int y)
{
	if(find(x)<find(y))
		par[find(y)] = find(x);
	else
		par[find(x)]=find(y);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<100005;i++)
		par[i] = i;
	
	for(int i=0;i<m;i++)
	{
		int u,v;
		cin>>u>>v;
		unite(u,v);
	}
	
	int ans=0;
	
	for(int i=0;i<n;i++)
	{
		if(find(i+1)==find(a[i]))
			ans++;
	}
	cout<<ans;
	
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
c = list(map(int, input().split(" ")))

b_sum = sum(b)

c_sum = 0
for i in range(n-1):
    if a[i] != n:
        if a[i] + 1 == a[i+1]:
            c_sum += c[a[i]-1]

print(b_sum + c_sum)

Measured memory_bytes: 3064
n=int(input())
s=input()
ans=""

alfa=list("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ")

for i in s:
  for j in range(26):
    if i==alfa[j]:
      ans+=alfa[j+n]
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define Map map<string,ll>
#define MB	map<string,bool>
#define ft first 
#define sd second

using namespace std;

int main(){
	int n;
	cin>>n;
	MB c;
	Map lis;
	Map rec;
	while(n--){
		string s;
		cin>>s;
		int l = 10;
		sort(s.begin(),s.end());
		if(c[s]!=true)c[s]=true;
		else{
			lis[s]++;
			rec[s]+=lis[s];
		}

		
	}
	//ll no = rec.size();
	//cout<<no<<endl;
	ll pr=0;
	//for(auto it:rec)cout<<it.sd<<' ';

	//cout<<endl;
	
	 //cout<<"no "<<no<<' ';
	for(auto it:rec){
		pr+=it.sd;
	}
	//pr-=no;
	cout<<pr<<endl;
}


Measured memory_bytes: 11264
# -*- coding: utf-8 -*-
from bisect import bisect, bisect_left 
def inpl(): return list(map(int, input().split()))

N = int(input())
A = sorted(inpl())

n = A[-1]

l = A[max(bisect(A, n/2)-1, 0)]
r = A[bisect_left(A, n/2)]

if abs(n/2-l) < abs(r-n/2) or r==n:
    print(n, l)
else:
    print(n, r)

Measured memory_bytes: 14428
#include <stdio.h>
 
int gcd(int x,int y){
  if(x<y){
    int a;
    a = y;y = x; x = a; 
  }
  while(y>0){
    int r=x%y;
    x=y;
    y=r;
  }
  return x;
}
 
int main(){
  int x,y;
  scanf("%d%d",&x,&y);
  printf("%d\n",gcd(x,y));
 
  return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#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>  
// 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) : 
 
#define  rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i>=0; 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); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int n,m; std::cin >> n >> m;
  std::cout << (n-1)*(m-1) << std::endl;
  return 0;
}


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

int main(){
	int n; cin >> n;
  if (n%10 == 3)
     cout << "bon\n";
  else if (n%10 == 0 || n%10 == 1 || n%10==6 || n%10==8)
    cout << "pon\n";
  else cout << "hon\n";
}

Measured memory_bytes: 3656
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    ll x;cin>>x;
    ll c = x / 11;
    dump(2*c);
    x -= c * 11;
    dump(x);
    if (x == 0){
        cout << 2*c << endl;
    }
    else if (x <= 6){
        cout << 2*c + 1 << endl;
    }
    else {
        cout << 2*c + 2 << endl;
    }
    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3660
#include<stdio.h>

#define MAX_VALUE 20000
#define MIN_VALUE 0
#define IS_ERR(n) (n < MIN_VALUE || n > MAX_VALUE)


void print_output(int *data, int count)
{
    int i;
    for(i=0;i<count;i++) printf("%d\n", data[i]);
}

int main(void)
{

    int a, b;
    char op;

    while(1)
   {

        scanf("%d %c %d", &a, &op, &b);

       if(IS_ERR(a) || IS_ERR(b)) return -1;

        switch(op)
        {
            case '+':
                printf("%d\n", a + b);
                break;
            case '-':
                printf("%d\n", a - b);
                break;
            case '*':
                printf("%d\n", a * b);
                break;
            case '/':
                printf("%d\n", a / b);
                break;
            case '?':
            default:
                return 0;
                break;
        }

    }

    return 0;
}


Measured memory_bytes: 2124
a = input().split() 
n = int(a[0])
m = int(a[1])
x = int(a[2])
y = int(a[3])
a = input().split()
a = [int(s) for s in a]
x_max = max(a)
a = input().split()
a = [int(s) for s in a]
y_min = min(a)
if x_max >= y or y_min <= x or x_max >= y_min:
    print("War")
else:
    print("No War")

Measured memory_bytes: 3064
import java.util.*;
public class Main { 
    public static void main(String[] args) {
       Scanner sc=new Scanner(System.in);
       int o=0;
       int n=sc.nextInt();
      int mini=2000000;
      for(int i=0;i<n;i++){
      	int p=sc.nextInt();
        if(p<=mini){
        	o++;
            mini=p;
        }
      }
      System.out.println(o);
    }
}

Measured memory_bytes: 62700
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    int a[n], b[n];
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    
    int ans = 0;

    srep(i,1,30){
        int f[n], g[n];
        rep(j,n){
            f[j] = a[j] % (1<<i);
            g[j] = b[j] % (1<<i);
        }
        sort(g,g+n);
        ll cnt = 0;
        rep(j,n){
            cnt += g+n - lower_bound(g,g+n,3*(1<<(i-1))-f[j]);
            cnt += lower_bound(g,g+n,2*(1<<(i-1))-f[j]) - lower_bound(g,g+n,1*(1<<(i-1))-f[j]);
        }   
        if(cnt % 2 == 1){
            ans += (1<<(i-1));
        }
    }

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




Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define MaxN 200003

int N;
struct Nd {
	int A, B;
}a[MaxN];

inline int Rd() {
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}
inline bool cmp(Nd aa, Nd bb) {
	return aa.B < bb.B;
}

int main() {
//	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	N = Rd();
	for(reg int i = 1; i <= N; ++i)
		a[i].A = Rd(), a[i].B = Rd();
	sort(a + 1, a + 1 + N, cmp);
	long long tim = 0;
	for(reg int i = 1; i <= N; ++i) {
		tim += a[i].A;
		if(tim > a[i].B) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

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

template <typename T>
struct Dijkstra {
  struct Edge {
    int to;
    T cost;
  };
  vector<int> prev;
  vector<vector<Edge>> g;
  Dijkstra(int n) : prev(n, -1), g(n) {}

  void addEdge(int u, int v, T w) {
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  vector<T> build(int s) {
    vector<T> dist(g.size(), -1);
    using Node = pair<T, int>;
    priority_queue<Node, vector<Node>, greater<Node>> pq;
    pq.push({dist[s] = 0, s});

    while (!pq.empty()) {
      auto d = pq.top().first;
      auto u = pq.top().second;
      pq.pop();
      if (dist[u] < d) continue;
      for (auto&& v : g[u]) {
        if (dist[v.to] < 0 || dist[v.to] > dist[u] + v.cost) {
          dist[v.to] = dist[u] + v.cost;
          prev[v.to] = u;
          pq.push({dist[v.to], v.to});
        }
      }
    }
    return dist;
  }
  vector<int> getPath(int t) {
    vector<int> path;
    for (; t != -1; t = prev[t]) path.push_back(t);
    reverse(begin(path), end(path));
    return path;
  }
};

int main() {
  int n, m, s, t;
  cin >> n >> m >> s >> t, s--, t--;
  Dijkstra<int> g(n);
  REP(i, m) {
    int x, y;
    cin >> x >> y, x--, y--;
    g.addEdge(x, y, 1);
  }
  auto ds = g.build(s);
  auto dt = g.build(t);
  map<int, int> ms, mt;
  for (auto x : ds) ms[x]++;
  for (auto x : dt) mt[x]++;
  ll ans = 0LL;
  int c = ds[t] - 1;
  REP(i, c) {
    ans += (ll)ms[i] * mt[c - 1 - i];
  }
  cout << ans << endl;
}



Measured memory_bytes: 11948
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class Main {
    public static void main(String[] args) {
        FastScanner scr = new FastScanner();

//        int t = scr.nextInt();
//        while (t-- > 0)
            solve(scr);
    }


    static void solve(FastScanner scr) {
        String str = scr.nextToken();
        if (str.length()==6&&str.charAt(2)==str.charAt(3)&&str.charAt(4)==str.charAt(5)) System.out.println("Yes");
        else System.out.println("No");
    }


    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            init();
        }

        public FastScanner(String name) {
            init(name);
        }

        public FastScanner(boolean isOnlineJudge) {
            if (!isOnlineJudge || System.getProperty("ONLINE_JUDGE") != null) {
                init();
            } else {
                init("input.txt");
            }
        }

        private void init() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        private void init(String name) {
            try {
                br = new BufferedReader(new FileReader(name));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }

    }
}

Measured memory_bytes: 22612
program guidebook
  implicit none
  integer :: n, p(100,2) = 0, i
  character(10) :: s(100)
  read(*,*) n
  do i = 1, n
    read(*,*) s(i), p(i,1)
    p(i,2) = i
  end do
  call merge_sort(s(1:n),p(1:n,:))
  do i = 1, n
    write(*,'(i0)') p(i,2)
  end do
contains
  subroutine merge_sort(s,a)
    character(10), intent(inout) :: s(:)
    integer, intent(inout) :: a(:,:)
    integer :: n, m, l, i, u
    n = size(a,1)
    m = n
    l = 1
    do while (m > 1)
      do i = 1, m/2
        u = min(2*i*l,n)
        call merger(s(2*(i-1)*l+1:(2*i-1)*l),a(2*(i-1)*l+1:(2*i-1)*l,:),s((2*i-1)*l+1:u),a((2*i-1)*l+1:u,:))
      end do
      l = 2*l
      m = (m+1)/2
    end do
  end
  subroutine merger(s1,a1,s2,a2)
    character(10), intent(inout) :: s1(:), s2(:)
    integer, intent(inout) :: a1(:,:), a2(:,:)
    character(10) :: s(size(s1)+size(s2))
    integer :: a(size(a1,1)+size(a2,1),size(a1,2))
    integer :: i1, i2, n1, n2
    i1 = 1
    i2 = 1
    n1 = size(s1)
    n2 = size(s2)
    do while (i1 <= n1 .and. i2 <= n2)
      if (s1(i1) < s2(i2) .or. (s1(i1) == s2(i2) .and. a1(i1,1) >= a2(i2,1))) then
        s(i1+i2-1) = s1(i1)
        a(i1+i2-1,:) = a1(i1,:)
        i1 = i1+1
      else
        s(i1+i2-1) = s2(i2)
        a(i1+i2-1,:) = a2(i2,:)
        i2 = i2+1
       end if
    end do
    if (i1 <= n1) then
      s(i1+i2-1:n1+n2) = s1(i1:n1)
      a(i1+i2-1:n1+n2,:) = a1(i1:n1,:)
    else
      s(i1+i2-1:n1+n2) = s2(i2:n2)
      a(i1+i2-1:n1+n2,:) = a2(i2:n2,:)
    end if
    s1 = s(1:n1)
    a1 = a(1:n1,:)
    s2 = s(n1+1:n1+n2)
    a2 = a(n1+1:n1+n2,:)
  end
end program guidebook

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 100005
using namespace std;
typedef long long ll;
struct edge{
	int k,next;
}e[N<<2];
int n,m,home[N],cnt=-1,H[N];
void add(int *home,int x,int y){
	cnt++;
	e[cnt].k=y;
	e[cnt].next=home[x];
	home[x]=cnt;
}
int col[N],D,sum[5],P,E;
bool vis[N];
void dfs(int k){
	sum[col[k]]++;
	int w=col[k]%3+1;
	vis[k]=1;P++;
	for(int i=home[k];~i;i=e[i].next){
		E++;
		if(col[e[i].k]&&col[e[i].k]!=w){
			D=0;
		}else{
			col[e[i].k]=w;
		}
	}
	int W=col[k]-1;
	if(W==0) W=3;
	for(int i=H[k];~i;i=e[i].next) if(!vis[e[i].k]){
		if(!col[e[i].k]) col[e[i].k]=W;
		dfs(e[i].k);
	}
}
int main(){
	memset(home,-1,sizeof(home));
	memset(H,-1,sizeof(H));
	scanf("%d%d",&n,&m);
	for(int i=1,x,y;i<=m;i++){
		scanf("%d%d",&x,&y);
		add(home,x,y);
		add(H,x,y);add(H,y,x);
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
		if(!col[i]){
			sum[1]=sum[2]=sum[3]=E=P=0;
			D=1,col[i]=1,dfs(i);
			if(!D) ans+=1LL*P*(P+1)-P;
			else if(!sum[3]||!sum[2]||!sum[1]) ans+=E;
			else ans+=1LL*sum[1]*sum[2]+1LL*sum[2]*sum[3]+1LL*sum[3]*sum[1];
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 7424
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }
  if(a>b){
    printf("a > b\n");
  }
  if(a==b){
    printf("a == b\n");
  }
  return(0);
}

Measured memory_bytes: 580
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

ll sum(ll x) {
  ll s = 0;
  while(x != 0) {
    s += x % 10;
    x /= 10;
  }
  return s;
}

int main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll x = 10;
  ll ans = sum(n);
  while(x <= n) {
    ll a = n / x * x;
    ans = max(ans, sum(a - 1));
    x *= 10;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>){
    val N = readLine()!!.toInt()
    val (D, X) = readLine()!!.split(' ').map(String::toInt)
    val c = (1..N).map { (D - 1) / readLine()!!.toInt() + 1 }
    println(c.sum() + X)
}

Measured memory_bytes: 38292
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

int main() {
    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k;
    cin >> k;
    cout << v[k - 1] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll dp1[1000010];
ll dp2[1000010];
int main(){
	rep(i,0,1000005)dp1[i]=dp2[i]=INF;
	dp1[0]=dp2[0]=0;
	rep(n,1,200){
		ll s=n*(n+1)*(n+2)/6;
		rep(i,0,1000005-s)dp1[i+s]=min(dp1[i+s],dp1[i]+1);
		if(s%2)rep(i,0,1000005-s)dp2[i+s]=min(dp2[i+s],dp2[i]+1);
	}
	ll n;
	while(scanf("%lld",&n),n){
		printf("%lld %lld\n",dp1[n],dp2[n]);
	}
	return 0;
}


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


template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod = 1e9+7;
const int inf= 1<<30;
const int maxn = 200005;
lli a[maxn];
int main(){__
	int n;
	cin >> n;
	lli tot=0ll;
	for(int i=1; i <=n; i++){
		cin >> a[i];
		tot = (tot + a[i]) %mod;
	}
	tot%=mod;

	lli ans = 0ll;
	for(int i=1; i <n; i++){
		tot = (tot+ mod - a[i]) % mod;
		tot%=mod;
		lli res = (1ll * tot * a[i]) % mod;
		res%=mod;
		ans = (ans + res) % mod;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 5176
import itertools
mod = 10**9 + 7
stdin = [int(_) for _ in open(0).read().split()]
N, X = stdin[0], stdin[1:]
A = [pow(i, mod - 2, mod) for i in range(N)]
D = [0] + [a - b for a, b in zip(X[1:], X[:-1])]
f = 1
for i in range(1, N):
    f *= i
    f %= mod
A = [d * f * a % mod for d, a in zip(D, list(itertools.accumulate(A)))]
print(sum(A) % mod)


Measured memory_bytes: 107032
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#include<climits>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
#define MP make_pair
#define all(v) v.begin(),v.end()
const ll mod = 1000000007;
const ll OO = (ll)1e18;
const int dx[] = { 0, 1, -1, 0 };
const int dy[] = { 1, 0, 0, -1 };
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
ll fast_power(ll base, ll power){
	if (power == 1) return base;
	if (power % 2 == 0) return fast_power((base*base), power / 2);
	else return(base*fast_power((base*base), power / 2));
}
//#pragma warning (disable : 4996)
void Qalbaz()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	
}
ll n, m;
int main(){
	//Qalbaz();
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	ll x;
	vector<pair<ll, int>>vec;
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		vec.push_back(MP(x, 1));
		cin >> x;
		vec.push_back(MP(x, 0));
	}
	ll ans = 0;
	sort(all(vec));
	for (int i = vec.size() - 1; i >= 0 && m > 0; i--)
	{
		if (vec[i].second == 1)
		{
			ans += m / vec[i].first;
			if (m % vec[i].first != 0)
				ans++;
			break;
		}
		else
		{
			ans ++;
			m -= vec[i].first;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 6512
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    int n;
    cin>>n;
    vector<int> v(n);
    deque<int> d;
    for(int i=0; i<n; i++) cin>>v[i];
    for(int i=0; i<2; i++) d.push_back(v[i]);
    int answer=0;
    for(int i=2; i<n; i++){
        if(i>=3) d.pop_front();
        d.push_back(v[i]);
        vector<int> v(d.begin(),d.end());
        sort(v.begin(),v.end());
        if(d[1]==v[1]){
            answer+=1;
        }
    }
    cout<<answer;

    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
r = list(reversed(s))
x = 1
t = 0
c = [0] * 2019
ans = 0
for i in range(n):
    c[t] += 1
    t += (int(r[i]))*x
    t %= 2019
    ans += c[t]
    x = x*10%2019
   
print(ans)

Measured memory_bytes: 76244
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_limit=(n); i<i##_limit; ++i)
#define FOR(i, a, b) for (int i=(a), i##_limit=(b); i<i##_limit; ++i)
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long;
using pi = pair<int, int>;

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

    int n = S.length();
    int ret[n];
    REP(i, n) ret[i] = 1;
    REP(i, n-1)
    {
        if (S[i] != 'R') continue;
        if (S[i+1] != 'L') { ret[i+2] += ret[i]; ret[i] = 0; }
    }

    REP(i, n-1)
    {
        int j = n - i - 1;
        if (S[j] != 'L') continue;
        if (S[j-1] != 'R') { ret[j-2] += ret[j]; ret[j] = 0; }
    }

    cout << ret[0];
    FOR(i, 1, n) cout << " " << ret[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
from heapq import heappop, heappush, heapify

def p_d():
    n, m = map(int, input().split())
    *h, = map(int, input().split())
    heapify(h)
    bc = [tuple(map(int, input().split())) for _ in range(m)]
    bc.sort(key=lambda x: x[1], reverse=True)
    for b, c in bc:
        for i in range(b):
            tmp = heappop(h)
            if tmp >= c:
                heappush(h, tmp)
                print(sum(h))
                exit()
            heappush(h, c)
    print(sum(h))
    
p_d()

Measured memory_bytes: 22136
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 998244353;
vector<vector<int>> edge(100010, vector<int>(0));
vector<int> parent(100010, -1);
vector<bool> vis(100010, 0);
vector<int> child[100010];

void makeParent(int N){
    vis.at(N) = 1;
    for(int i = 0; i < edge.at(N).size(); i++){
        if(vis.at(edge.at(N).at(i)) == 0){
            parent.at(edge.at(N).at(i)) = N;
            makeParent(edge.at(N).at(i));
            child[N].push_back(edge.at(N).at(i));
        }
    }
}
vector<int> memo(100010, -1);

int grundy(int x){
    if(memo.at(x) != -1) return memo.at(x);
    if(child[x].size() == 0)return 0;
    int XOR = grundy(child[x][0]) + 1;
    for(int i = 1; i < child[x].size(); i++){
        XOR ^= grundy(child[x][i]) + 1;
    }
    return memo.at(x) = XOR;
}

int main() {
    int N;
    cin >> N;
    for(int i = 0; i < N-1; i++){
        int x,y;
        cin >> x >> y;
        x--,y--;
        edge.at(x).push_back(y);
        edge.at(y).push_back(x);
    }
    
    makeParent(0);
    
    if(grundy(0)){
        cout << "Alice" << endl;
    }else{
        cout << "Bob" << endl;
    }
    
    
}

Measured memory_bytes: 21376
#include<bits/stdc++.h>
#define ll long long int
const ll mod=1e9+7;
const int maxn=2e5+50;
using namespace std;

int main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
{

  
    int n;
    cin>>n;
    map<string,int> mymap;
    string tab[n];
   
    for(int i=0;i<n;i++)
    {
    	string s;
    	cin>>s;
    	tab[i]=s;
    	mymap[s]++;
	}
	vector<pair <int,string> > vect;
	for(int i=0;i<n;i++)
	{
		if(mymap[tab[i]]!=0)
		{
			vect.push_back({mymap[tab[i]],tab[i]});
			mymap[tab[i]]=0;
		}
	}
	sort(vect.begin(),vect.end());
	reverse(vect.begin(),vect.end());
	vector<string> v;
	v.push_back(vect[0].second);
	for(int i=1;i<vect.size();i++)
	{
		if(vect[i].first==vect[0].first)
		{
			v.push_back(vect[i].second);
		}
		else
		{
			break;
		}
	}
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
	{
		cout<<v[i]<<endl;
	}
}



Measured memory_bytes: 33900
from collections import deque
from collections import defaultdict

G = defaultdict(list)
N, M = map(int, input().split())
color = [0] * (N + 1)

for _ in range(M):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
Q = int(input())

data = [list(map(int, input().split())) for _ in range(Q)]
data.reverse()
color_d = [-1] * (N + 1)

for v, d, c in data:
    if color_d[v] >= d:
        pass
    # BFS
    deq = deque([v])
    if color[v] == 0:
        color[v] = c
    color_d[v] = d
    while len(deq) > 0:
        s = deq.popleft()
        for t in G[s]:
            if color_d[t] >= color_d[s] - 1:
                pass
            else:
                color_d[t] = color_d[s] - 1
                if color[t] == 0:
                    color[t] = c
                if color_d[t] > 0:
                    deq.append(t)

for n in range(1, N + 1):
    print(color[n])

Measured memory_bytes: 53520
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
ll n;

void solve() {
  int ans;
  string s; cin >> s;
  fo(i ,s.length()) {
     s[i] -= '0';
     ans += s[i];
     if (ans >= 9)
     ans = ans % 9;
  }
  if (ans == 0)
  cout << "Yes";
  else cout << "No";
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int l = 1;
    //cin >> t;
    while(l--) {
      solve();
    }

    return 0;
}

Measured memory_bytes: 3708
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for _ in range(n)]
def LIR(n):
    return [LI() for _ in range(n)]
def SR(n):
    return [S() for _ in range(n)]
def LSR(n):
    return [LS() for _ in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    k = I()
    print("ACL"*k)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 65336
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int res = 0;
        if (n % 1000 != 0) res = 1000 - n % 1000;
        System.out.println(res);
    }
}

Measured memory_bytes: 35776
#include<bits/stdc++.h>
 using namespace std;
 int main(){
 	int n;
 	cin>>n;
 	map<int,int>ma;
 	for(int i=0;i<n;i++){
 		int x;
 		cin>>x;
       ma[x]++;
 	}
 	int ans=0;
 	for(auto i:ma){
 		if(i.second<i.first)
 			ans+=i.second;
 		if(i.second>i.first)
 			ans+=i.second-i.first;
 	}
 	cout<<ans<<"\n";
 	return 0;
 }

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

struct UnionFind {
    vector<int> data;
    int sz;
    UnionFind(int _sz) : data(_sz, -1), sz(_sz) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y]; data[y] = x; sz--;
        return true;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() { return sz; }
};

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    UnionFind uf(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        A[i]--;
    }
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.unionSet(a, b);
    }
    
    vector<vector<int>> G(N, vector<int>());
    for(int i = 0; i < N; i++)G[uf.root(i)].push_back(i);
    
    int ans = 0;
    for(int i = 0; i < N; i++){
        set<int> se;
        for(int j = 0; j < G[i].size(); j++)se.insert(G[i][j]);
        for(auto v : G[i]){
            if(se.count(A[v]))ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8440
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    int cnt = 0;
    int i = 0;
    for(int i = 1; i <= n; i++){
        string tmps = s.substr(n-i,i);
        string tmpt = t.substr(0,i);
        if(tmps == tmpt) cnt = i;
    } 
    cout << 2*n-cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

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

    cout << (n - 1) * (m - 1) << endl;

    return 0;
}

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

int main()
{
  int N;
  std::cin >> N;
  std::vector<int> an;
  for(int i=0; i<N; i++)
  {
    int a;
    std::cin >> a;
    an.push_back(a);
  }
  std::sort(an.begin(), an.end());
  while( an.size() != 1 )
  {
    auto attacker = an[0];
    for(int i=1; i<an.size(); i++)
    {
      an[i] = an[i] % attacker;
    }
    std::sort(an.rbegin(), an.rend());
    while( an.back()==0 ) { an.pop_back(); }
    std::sort(an.begin(), an.end());
  }

  std::cout << an[0] << std::endl;
}


Measured memory_bytes: 892
#include <stdio.h>
int main(){
    int x,y;
    for(int i = 0; ; i++){
    scanf("%d %d",&x,&y);
    if(x==0 && y==0) break;
    if(x<y){
    printf("%d %d\n",x,y);
    }
    else if(y<x){
    printf("%d %d\n",y,x);
    }
    else{
        printf("%d %d\n",x,y);
    }
    }
}


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


int main() {
 #define int long long
  int A,B,C,N,b,x,s,L;
  
  cin >> L;
  double a,V;
  
  V=(double)L*L*L/27;

  
cout << setprecision(8) << V << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s,t;
vector<int> cnt[26];
int main()
{
	cin>>s>>t;
	for(int i=0;i<s.size();i++)
		cnt[s[i]-'a'].push_back(i);
	int rou=0,pos=-1;
	for(int i=0;i<t.size();i++)
	{
		int tmp=t[i]-'a';
		if(cnt[tmp].empty())
		{
			cout<<-1<<endl;
			return 0;
		}
		if(cnt[tmp].back()<=pos)
		{
			++rou;
			pos=cnt[tmp][0];
		}
		else
			pos=cnt[tmp][upper_bound(cnt[tmp].begin(),cnt[tmp].end(),pos)-cnt[tmp].begin()];
	}
	long long ans=(long long)s.size();
	ans*=(long long)rou;
	ans+=(long long)pos;
	ans+=1LL;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1344
def insertionSort(A, n , g, in_cnt):
    lo_cnt = in_cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j>=0 and A[j]>v:
            A[j+g] = A[j]
            j = j - g
            lo_cnt = lo_cnt + 1
        A[j+g] = v
    return [A,lo_cnt]


A = []
G = []
data_num = int(input())
for i in range(data_num):
     A.append(int(input().rstrip()))

cnt = 0
gap = data_num
while True: 
    if gap > 1:
        gap = gap // 2

    G.append(gap)
    A, cnt = insertionSort(A, data_num, gap, cnt)
    if gap == 1:
        break
    
print(str(len(G)))
print(" ".join(map(str,G)))
print(str(cnt))
print("\n".join(map(str,A)))

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  
  int f,s;
  f = vec.at(N-1)/2;
  s = 0;
  for (int i = 0; i < N-1; i++) {
    s += vec.at(i);
  }
  
  cout << f + s <<endl;
}
  

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};

void Solve() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << " " << max(0, a + b - n) << endl;
}


int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <map>
#include <queue>
typedef long long ll;
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll mod = 1000 * 1000 * 1000 + 7;
    ll s;
    cin >> s;
    vector<vector<ll> > dp(s + 79, vector<ll>(s + 79, 0));
    // dp[dlzka][suma]
    dp[0][0] = 1;
    ll ans = 0;
    for (ll len = 1; len * 3 <= s; len++)
    {
        for (ll sum = 0; sum <= s; sum++)
        {
            if (dp[len - 1][sum])
            {
                for (ll d = 3; sum + d <= s; d++)
                {
                    dp[len][sum + d] += dp[len - 1][sum];
                    if (dp[len][sum + d] >= mod)
                    {
                        dp[len][sum + d] -= mod;
                    }
                }
            }
        }
        ans += dp[len][s];
        if (ans >= mod)
        {
            ans -= mod;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 36888
x,n = map(int,input().split())
if n==0:
    print(x)
else:
    p=list(map(int,input().split()))
    val = 1000
    ans=0
    for i in range(102):
        if abs(x-i)<val and (i not in p):
            ans = i
            val = abs(x-i)
    print(ans)

Measured memory_bytes: 9188
N = int(input())
train = [list(map(int, input().split())) for i in range(N-1)]
anslist = [0]
for i in range(N-1):
    ans = 0
    for j in range(i, N-1):
        ans = max(train[j][1], ans)
        ans = ((ans-1) // train[j][2] + 1) * train[j][2]
        ans += train[j][0]
    print(ans)
print(0)


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

int s2i(string str){
  stringstream ss;
  int res;
  ss<<str;
  ss>>res;
  return res;
}

ll calc(ll y,ll m,ll d){
  ll res=0;

  if(y>800){
    y-=400;
    ll D=y/400;
    y%=400;
    res=D*146097;
    y+=400;
  }
  
  int t[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
  int I=1,J=1,K=1;

  
  while(1){
    res++;
    if(I==y&&J==m&&K==d)break;
    K++;
    if(I%400==0 || (  I%100!=0 && I%4 == 0)){
      t[2]++;
      if(K>t[J]){K=1;J++;}
      if(J==13){I++;J=1;}
      t[2]--;
    }else{
      if(K>t[J]){K=1;J++;}
      if(J==13){I++;J=1;}
    }

  }
  //  cout<<y<<' '<<m<<' '<<d<<' '<<res<<endl;
  return res;
}

void solve(ll y,ll m,ll d){
  ll sum=calc(y,m,d)-calc(2012,12,21);
  cout<<sum/20/18/20/20%13<<'.';
  cout<<sum/20/18/20%20<<'.';
  cout<<sum/20/18%20<<'.';
  cout<<sum/20%18<<'.';
  cout<<sum%20<<endl;
}

void solve2(ll a,ll b,ll c,ll d,ll e){
  ll sum=(((a*20+b)*20+c)*18+d)*20+e;
  ll A=sum/146097;
  sum%=146097;
  ll Y=2012+A*400,M=12,D=21;
  
  while(sum--){
    D++;
    int t[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    if(Y%400==0 || (  Y%100!=0 && Y%4 == 0)){
      t[2]++;
      if(D>t[M]){D=1;M++;}
      if(M==13){Y++;M=1;}
      t[2]--;
    }else{
      if(D>t[M]){D=1;M++;}      
      if(M==13){Y++;M=1;}
    }
  }
  cout<<Y<<'.'<<M<<'.'<<D<<endl;
}

int main(){
  string str;
  while(1){
    cin>>str;
    if(str=="#")break;
    for(int i=0;i<(int)str.size();i++)if(str[i]=='.')str[i]=' ';
    stringstream ss(str);
    string tmp;
    vector<int> vec;
    while(ss>>tmp)vec.push_back(s2i(tmp));
    if(vec.size()==3){      
      solve(vec[0],vec[1],vec[2]);
    }else{
      solve2(vec[0],vec[1],vec[2],vec[3],vec[4]);
    }
  }
}

Measured memory_bytes: 1252
#include <vector>
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int>a1(n);
    vector<int>a2(n);
    vector<int>sum(n);
    for(int i=0;i<n;i++){
        cin >> a1[i];
        sum[i]=0;
    }
    for(int i=0;i<n;i++){
        cin >> a2[i];
    }
    for(int i=0;i<n;i++){
        sum[i]+=accumulate(a1.begin(),a1.begin()+i+1,0)+accumulate(a2.begin()+i,a2.end(),0);
    }
    cout<<*(max_element(sum.begin(),sum.end()))<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
     string S;
     cin >> S;
     int ans = 0;
     if(S[0] == '1') ans++;
     if(S[1] == '1') ans++;
     if(S[2] == '1') ans++;

     cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int n = stdIn.nextInt();
			List<Integer> list = new ArrayList<Integer>();
			for(int i = 0; i < n; ++i)
			{
				int t = stdIn.nextInt();
				list.add(t);
			}
			Collections.sort(list);
			int ans = 0;
			int sum = 0;
			for(int i = 0; i < n; ++i)
			{
				sum += list.get(i);
				ans += sum;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>  
#include <iostream>  
#include <cstdlib>  
#include <cstring>  
#include <string>
#include <cstdio>  
#include <climits>
#include <cmath> 
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <sstream>
#define INF 0x3f3f3f3f
#define LL long long
#define MAXN 100024
const double eps = 1e-8;
using namespace std;
int a[MAXN];
int n;
int main() {
#ifdef DID
	freopen("in.txt", "r", stdin);
	//freopen("out.txt","w",stdout);
#endif
	cin >> n;
	int e=0, o=0;
	for (int i = 0; i <= n; i++) {
		cin >> a[i];
		if (a[i] % 2) o++;
		else e++;
	}
	
	o %= 2;
	if (!o) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int n,m;
  cin >> n>>m;
  vector<int> L(m);
  vector<int> R(m);
  for(int i=0;i<m;i++){
    cin >>L[i] >>R[i];

  }
  sort(L.begin(), L.end());
  sort(R.begin(), R.end());
  if(L[m-1] > R[0])cout << 0 << endl;
  else{cout << R[0] - L[m-1] + 1 << endl;}
}

Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std;
 
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
 
struct edge{ int from, to, cost; };
 
 
int n, m;
bool used[20005];
 
bool comp(const edge& e1, const edge& e2)
{
    return e1.cost < e2.cost;
}
 
int main()
{
    while (cin >> n >> m, n)
    {
        edge es[20005];
        REP(i, m)
        {
            int a, b, c;
            cin >> a >> b >> c;
            c--; b--;
            es[i] = edge{ b, c, a };
        }
        sort(es, es + m, comp);
        memset(used, false, sizeof(used));
        used[0] = true;
        REP(i, m)
        {
            if (used[es[i].from]) used[es[i].to] = true;
        }
        int cnt = 0;
        REP(i, n)
        {
            if (used[i]) cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3368
#solve function
def solve(dates):
    counter = 0;
    start_month = dates[1]
    start_day, end_day = dates[2], 0

    for year in range(dates[0], 1000):
        for month in range(start_month, 11):
            if year%3 == 0 or month%2 == 1:
                end_day = 21
            else:
                end_day = 20

            # count days
            counter += (end_day - start_day)

            start_day = 1
        else:
            start_month = 1

    return counter


#main function
if __name__ == '__main__':
    n = int(input())

    dates = [0 for i in range(3)]
    tmp_dates = []
    for i in range(n):
        tmp_dates = input().split()
        for j, tmp_date in enumerate(tmp_dates):
            dates[j] = int(tmp_date)

        date_count = solve(dates)
        print(date_count)

Measured memory_bytes: 6724
// D - Islands War
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
using II = pair<int,int>;
using VII = vector<II>;

int solve(int N, int M, VII &V){
	sort(all(V));
	int ans = 0;
	int R = 0;
	rp(i, 0, M){
		int l,r; tie(l,r) = V[i];
		if(R <= l){ R = r; ans++; }
		else{ if(R > r) R = r; }
	}
	return ans;
}

int main(){
	int N,M; cin>>N>>M;
	VII V;
	rp(i, 0, M){
		int a,b; cin>>a>>b;
		V.emplace_back(a,b);
	}
	cout<< solve(N,M,V) <<endl;
}

Measured memory_bytes: 1400