akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define INF (1<<29)
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=1e5;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
string s;
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    
    cin>>s;
    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
    
    return 0;
}


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

using namespace std;

typedef long long ll;
#define _ ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

#define sll(x) scanf("%I64d",&x)
#define sd(x)  scanf("%d",&x)
#define pll(x) printf("%I64d",x)
#define pd(x)  printf("%d",x)

#define clr(x) memset(x,0,sizeof x)

#define mid    ((l+r)>>1)
#define Pi acos(-1)
#define EPS 1e-12
#define MOD  1000000007
#define MOD1 1000000009
#define INFL 10000000000000LL
#define INF  2000000000

#define N 100005

ll ar[N],dp[N],n;

ll solve(int i){
if(i == n-1) return 0;
if(i>=n) return INFL;
if(dp[i] != -1 ) return dp[i];

ll ret = min(solve(i+1)+abs(ar[i] -ar[i+1]),solve(i+2)+abs(ar[i] -ar[i+2]));

return dp[i] = ret;

}

int main()
{_
    memset(dp,-1,sizeof dp);
    cin >> n;
    for(int i=0;i<n;i++) cin >> ar[i];
    cout << solve(0) ;

    return 0;
}


Measured memory_bytes: 3328
#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: 2060
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var X = items[0];
            var N = items[1];
            var p = (N > 0) ? Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToList() : new List<int>();

            // 低い値からチェックして差の最小を初めて更新した値が答え
            var minDiff = int.MaxValue;
            var answer = -1;
            foreach (var i in Enumerable.Range(0, 102))
            {
                if (minDiff > Math.Abs(i - X))
                {
                    if (p.All(elem => elem != i))
                    {
                        minDiff = Math.Abs(i - X);
                        answer = i;
                    }
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 28416
#include <bits/stdc++.h>
using namespace std;
#define intx long long
multiset<string> a;
set<string> b;
string s;
intx n;
intx i;
intx N,K;
intx res=0;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>s;
        sort(s.begin(),s.end());
        a.insert(s);
        b.insert(s);
    }
    for(set<string>::iterator it=b.begin();it!=b.end();it++)
    {
        N=a.count(*it);
        res+=(N*(N-1))/2;
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
#define LL long long
#define maxn 200005
#define modn 998244353

using namespace std;
int main(){
	double s;
	while(~scanf("%lf", &s)){
		s/=3;
		double ans = s*s*s;
		printf("%lf\n",  ans);
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

int h,w;
vector<vector<int>> cs(10, vector<int>(10));
vector<int> cnts(10);
int res;

int main()
{
    // 入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(10); // 浮動小数の表示の精度

    cin>>h>>w;
    rep(i,10) {
        rep(j,10) {
            int c; cin>>c;
            cs[i][j] = c;
        }
    }
    rep(i,h) {
        rep(j,w) {
            int a; cin>>a;
            if (a != -1) { cnts[a]++; }
        }
    }
    rep(k,10) {
        rep(i,10) {
            rep(j,10) {
                cs[i][j] = min(cs[i][j], cs[i][k] + cs[k][j]);
            }
        }
    }
    rep(i,10) {
        res += cs[i][1] * cnts[i];
    }
    cout<<res<<'\n';

    return 0;
}


Measured memory_bytes: 3556
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
  a = input()
  if a == 'AC':
    ac=ac+1
  elif a == 'WA':
    wa=wa+1
  elif a == 'TLE':
    tle=tle+1
  elif a == 'RE':
    re = re + 1
print('AC x %d'%ac)
print('WA x %d'%wa)
print('TLE x %d'%tle)
print('RE x %d'%re)


Measured memory_bytes: 9172
#include <iostream>
#include <string>
#include <set>
#include <list>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	while(n--)
	{
		set<char> marked;
		list<char> train;
		string str;
		cin >> str;
		train.push_back(str[0]);
		marked.insert(str[0]);
		for(int i = 1; i < str.size(); i += 3)
		{
			if(str[i] == '-' && str[i + 1] == '>')
			{
				if(marked.find(str[i + 2]) == marked.end())
				{
					marked.insert(str[i + 2]);
					train.push_back(str[i + 2]);
				}
			}
			else if(str[i] == '<' && str[i + 1] == '-')
			{
				if(marked.find(str[i + 2]) == marked.end())
				{
					marked.insert(str[i + 2]);
					train.push_front(str[i + 2]);
				}
			}
		}
		list<char>::iterator it = train.begin();
		while(it != train.end())
		{
			cout << *it;
			++it;
		}
		cout << endl;
	}
}

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

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

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

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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const double PI = acos(-1);
const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

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

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

    ll R = 0, G = 0, B = 0;
    REP(i, N) {
        if (S[i] == 'R') ++R;
        if (S[i] == 'G') ++G;
        if (S[i] == 'B') ++B;
    }

    ll ans = R*G*B;
    REP (i, N) {
        FOR (j, i, N) {
            int k = 2 * j - i;
            if (k < N) {
                if (S[i] == S[j]) continue;
                if (S[j] == S[k]) continue;
                if (S[i] == S[k]) continue;
                ans--;
            }
        }
    }

    cout << ans << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_V = int(1e2) + 5;
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
string dir = "RDLU";
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

const string INF = "NO";

struct edge {
    int from, to;
    string s;
};

int n, a, s, g;
vector<edge> es;

string bellman_ford() {
    vector<string> d(n, INF);
    d[g] = "";
    for (int i = 0; i < 7 * n; i++) {
        for (auto e : es) {
            if (d[e.to] != INF && (d[e.from] == INF || d[e.from] > e.s + d[e.to])) {
                d[e.from] = e.s + d[e.to];
                if (i > n && e.from == s) return INF;
            }
        }
    }
    return d[s];
}

int main() {
    while (1) {
        cin >> n >> a >> s >> g;
        if (n == 0) break;
        es.clear();
        REP(i, a) {
            int x, y;
            string lab;
            cin >> x >> y >> lab;
            es.push_back({x, y, lab});
        }
        cout << bellman_ford() << endl;
    }
    return 0;
}



Measured memory_bytes: 3532
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 0;
    rep(i, N){
        int l, r; cin >> l >> r; l--;
        ans += (r - l);
    }
    cout << ans;
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(void) 
{
    int N, M;
    cin >> N >> M;

    vector<int> X(M);
    for(int i=0; i<M; i++)
    {
        cin >> X[i];
    }
  
    if(N>=M)
    {
      cout << 0 << endl;
      return 0;
    }

    sort(X.begin(), X.end());

    vector<int> L(M-1);
    for(int i=0; i<M-1; i++)
    {
        L[i] = X[i+1] - X[i];
    }

    sort(L.begin(), L.end(), greater<int>());

    int sum=0;
    for(int i=0; i<N-1; i++)
    {
        if (i>=M-1) break;
        sum += L[i];
    }

    cout << (X[M-1]-X[0]) - sum << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if (b - a == c - b){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
  double L;
  cin >> L;
  double x = L / 3.0;
  cout << fixed << setprecision(10) << (x*L*L - 2*L*x*x + x*x*x) / 4.0 << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

n = int(input())
p = list(map(int, input().split()))


counter = 0

for i in range(1,n-1):
    p_partial = [p[i-1],p[i],p[i+1]]
    p_partial.sort()
    if p_partial[1] == p[i]:
        counter += 1

print(counter)


Measured memory_bytes: 2940
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;

  int strLen = s.length();
  vector<int> counts(strLen);
  counts[0] = 0;
  for(int i=1;i<=strLen;i++) {
    if(s[i-1] == 'A' && s[i] == 'C') {
      counts[i] = counts[i-1] + 1;
    } else {
      counts[i] = counts[i-1];
    }
  }

  int l, r;
  REP(i, q) {
    cin >> l >> r;
    cout << counts[r-1] - counts[l-1] << endl;
  }

  return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using P   = pair<int, int>;
using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    LL n, k;cin >> n;cin >> k;
    vector<LL> a(n), b(n);
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    LL sum = 0;
    for(int i=0;i<n;i++){
        if((a[i] | k) == k){
            sum += b[i];
        }
    }
    for(LL i=1;i<=k;i<<=1){
        if((k & i) == 0) continue;
        LL ssum = 0;
        LL kk = (k & (~i)) | (i-1);
        for(int j=0;j<n;j++){
            if(a[j] > k) continue;
            if((a[j] | kk) != kk) continue;
            ssum += b[j];
        }
        sum = max(sum, ssum);
    }
    printf("%lld\n", sum);

    return 0;
}


Measured memory_bytes: 1792
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N;
    cin >> N;

    if(N==1){
        p(1);
        return 0;
    }

    ll left = 1; // 不可能
    ll right = N; // 可能

    while(left+1!=right){
        ll center = (left + right) / 2;
        ll sum = center * (center+1) / 2;
        if(sum >= N){
            right = center;
        }else{
            left = center;
        }
    }

    while(N!=0){
        for(int i=right; i>=1; i--){
            if(N>=i){
                N -= i;
                p(i);
            }
        }
    }

    return 0;
}

Measured memory_bytes: 764
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

lin = [0 for i in range(10**5+1)]
n = int(input())
a = list(map(int, input().split()))
ans = 0
for x in a:
    ans += x
    lin[x] += 1
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    ans += (c - b)*lin[b]
    lin[c] += lin[b]
    lin[b] = 0
    print(ans)

Measured memory_bytes: 23200
#include <bits/stdc++.h>
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;
 
int main(){
  string s;
  cin >> s;
  switch(s[s.size()-1]){
    case '0':
      cout << "pon" << endl;
      return 0;
    case '1':
      cout << "pon" << endl;
      return 0;
    case '2':
      cout << "hon" << endl;
      return 0;
    case '3':
      cout << "bon" << endl;
      return 0;
    case '4':
      cout << "hon" << endl;
      return 0;
    case '5':
      cout << "hon" << endl;
      return 0;
    case '6':
      cout << "pon" << endl;
      return 0;
    case '7':
      cout << "hon" << endl;
      return 0;
    case '8':
      cout << "pon" << endl;
      return 0;
    case '9':
      cout << "hon" << endl;
      return 0;
  }
}

Measured memory_bytes: 3624
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
    int F => int.Parse(Str);
    long FL => long.Parse(Str);
    int[] G => Strs.Select(int.Parse).ToArray();
    long[] GL => Strs.Select(long.Parse).ToArray();
    string Str => ReadLine();
    string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    const int MOD = 998244353;
    public K()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        WriteLine(Solve());
        Out.Flush();
    }
    Random rand = new Random();
    long Solve()
    {
        var I = G;
        int Y = I[0], X = I[1];
        var mat = new bool[Y][];
        for (var y = 0; y < Y; y++)
        {
            mat[y] = new bool[X];
            I = G;
            for (var x = 0; x < X; x++) mat[y][x] = I[x] != 0;
        }
        var r = 0;
        for (var c = 0; c < X; c++)
        {
            int y = r;
            while (y < Y && !mat[y][c]) y++;
            if (y == Y) continue;
            if (y != r) AddTo(mat[r], mat[y]);
            for (y = r + 1; y < Y; y++) if (mat[y][c]) AddTo(mat[y], mat[r]);
            r++;
        }
        return (Pow(2, X + Y - 1, MOD) - Pow(2, X + Y - r - 1, MOD) + MOD) % MOD;
    }
    void Print(bool[] a) => WriteLine(string.Join("", a.Select(b => b ? 1 : 0)));
    public static long Pow(long a, long b, long mod)
    {
        var p = 1L;
        var x = a;
        while (b > 0)
        {
            if ((b & 1) == 1) p = (p * x) % mod;
            b >>= 1;
            x = (x * x) % mod;
        }
        return p;
    }
    // a += b
    void AddTo(bool[] a, bool[] b)
    {
        var n = a.Length;
        for (var i = 0; i < n; i++) a[i] = a[i] ^ b[i];
    }
}


Measured memory_bytes: 17612
#include "bits/stdc++.h"
using namespace std;
 
int main() {
	
	int n;
	cin >> n;
	vector<pair<int, pair<int, int> > > t;
	
	for (int i=0; i<n; i++) {
		int x;
		cin >> x;
		for (int j=0; j<x; j++) {
			int w, wh;
			cin >> w >> wh;
			t.push_back(make_pair(i, make_pair(w-1, wh)));
		}
	}
	
	int mx = 0;
	
	for (int st=0; st<(1<<n); st++) {
		bool honest[n];
		for (int i=0; i<n; i++) {
			if (st & (1 << i)) {
				honest[i] = true;
			}
			else {
				honest[i] = false;
			}
		}
		bool ok = true;
		for (int co=0; co<t.size(); co++) {
			if (!honest[t[co].first]) continue;
			bool ch = honest[t[co].second.first];
			bool sa = (honest[t[co].first] ? t[co].second.second : !t[co].second.second);
			if (ch != sa) ok = false;
		}
		if (ok) {
			mx = max(mx, __builtin_popcount(st));
		}
	}
	
	cout << mx << endl;
	
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

const double EPS = 1e-7;

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

	unsigned long long A;
	double B;
	cin >> A >> B;

	unsigned long long nB = B * 100 + EPS;

	cout << (A * nB) / 100;

	return 0;
}


Measured memory_bytes: 3728
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;

  auto nodes = new BiNode[](n);
  foreach (_; n.iota) {
    auto rd = readln.split.to!(int[]), id = rd[0], l = rd[1], r = rd[2];
    nodes[id] = new BiNode(id, l, r);
  }

  foreach (node; nodes) {
    if (node.l != -1) nodes[node.l].parent = node.id;
    if (node.r != -1) nodes[node.r].parent = node.id;
  }

  foreach (node; nodes)
    writefln("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s",
             node.id, node.parent, node.sibling(nodes), node.degree,
             node.depth(nodes), node.height(nodes), node.type);
}

class BiNode
{
  int id;
  int parent;
  int l, r;

  this(int id, int l, int r)
  {
    this.id = id;
    this.parent = -1;
    this.l = l;
    this.r = r;
  }

  int sibling(BiNode[] nodes)
  {
    if (parent == -1) return -1;
    auto pn = nodes[parent];
    return pn.l == id ? pn.r : pn.l;
  }

  int degree()
  {
    return (l != -1 ? 1 : 0) + (r != -1 ? 1 : 0);
  }

  int depth(BiNode[] nodes)
  {
    if (parent == -1) return 0;
    else return nodes[parent].depth(nodes) + 1;
  }

  int height(BiNode[] nodes)
  {
    auto lh = l != -1 ? nodes[l].height(nodes) + 1 : 0;
    auto rh = r != -1 ? nodes[r].height(nodes) + 1 : 0;
    return max(lh, rh);
  }

  string type()
  {
    if (parent == -1) return "root";
    else if (degree != 0) return "internal node";
    else return "leaf";
  }
}

Measured memory_bytes: 2544
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int POW(int a,int n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return (int)ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL N,M,V,P,i,a,ans=0;
  scanf("%lld%lld%lld%lld",&N,&M,&V,&P);
  P--;
  LL A[N],min=-1,max=N-P,mid=max/2;
  FOR(i,0,N)scanf("%lld",&A[i]);
  qsort(A,N,sizeof(LL),lcmp);
  while(max-min!=1){
    mid=(max+min)/2;
    a=0;
    if(M<A[N-P-1]-A[mid]){
      min=mid;
      continue;
    }
    FOR(i,mid+1,N-P)a+=A[i]-A[mid];
    if((N-V)*M<a)min=mid;
    else max=mid;
  }


  printf("%lld\n",N-max);
	return 0;
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
typedef long long l1;
#define mod 1000000007
#define f first
#define se second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(),x.end()
#define set(a,b) memset(a,b,sizeof(a))
#define mn *min_element
#define mx *max_element
#define input l1 t; cin>>t; while(t--)
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  l1 k,n;
  cin>>k>>n;
  l1 a[n],res=0,mins=INT_MAX;
  for(l1 i=0;i<n;++i)
    cin>>a[i];
  mins=min(a[n-1]-a[0],mins);
  for(l1 i=1;i<n;++i)
    	mins=min(k-(a[i]-a[i-1]),mins);
  cout<<mins;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<queue>
#include<map>
#include<cstring>
using namespace std;

typedef pair<int,int> P;
int bfs(int s,int d,int v);

int k[111];
int t[111][111];
bool flag[111];

int main(){
  int r,n,p;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> r;
    cin >> k[r];
    for(int j=0;j<k[r];j++){
      cin >> t[r][j];
    }
  }
  cin >> p;
  for(int i=0;i<p;i++){
    int s,d,v;
    memset(flag,0,sizeof(flag));
    cin >> s >> d >> v;
    int ans = bfs(s,d,v);
    if(ans == -1) cout << "NA" << endl;
    else cout << ans << endl;
  }
}

int bfs(int s,int d,int v){
  queue<P> que;
  que.push(P(s,0));
  while(!que.empty()){
    P p = que.front();
    que.pop();
    int now = p.first;
    int cou = p.second;
    cou++;
    if(now == d) return cou;
    if(flag[now] == false && v-cou > 0){
      flag[now] = true;
      for(int i=0;i<k[now];i++){
	que.push(P(t[now][i],cou));
      }
    }
  }
  return -1;
}

Measured memory_bytes: 1248
class Cmber:
    def __init__(self,gensize,mod=10**9+7):
        self.mod = mod
        self.g1=[1,1]
        self.g2 = [1, 1] #逆元テーブル
        self.inverse = [0, 1] #逆元テーブル計算用テーブル
        self.getgen(gensize)
    def getgen(self,N):
        for i in range( 2, N + 1 ):
            self.g1.append( ( self.g1[-1] * i ) % self.mod )
            self.inverse.append( ( -self.inverse[self.mod % i] * (self.mod//i) ) % self.mod )
            self.g2.append( (self.g2[-1] * self.inverse[-1]) % self.mod )

    def cmb(self,n, r):
        if ( r<0 or r>n ):
            return 0
        r = min(r, n-r)
        return self.g1[n] * self.g2[r] * self.g2[n-r] % self.mod

    def cmb_very_high_n(self,n, r):
        if ( r<0 or r>n ):
            return 0
        g1=1
        r = min(r, n-r)
        for i in range(n-r+1,n+1):
            g1*=i
            g1%=self.mod
        return g1 * self.g2[r] % self.mod


def resolve():
    H,W,A,B= map(int,input().split())
    cmb= Cmber(H+W+1)
    sm =0
    for i in range(H-A):
        bef = cmb.cmb(B+i-1,i)
        r=W-B-1
        u=H-i-1
        aft = cmb.cmb(r+u,u)
        sm += (aft*bef) % 1000000007
        sm %= 1000000007
#        print(i,r,u,bef,aft)
    print(sm)

if __name__ == "__main__":
    resolve()

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

int top = 0;
int test[101];

void push(int n)
{
  top++;
  test[top] = n;
}

int pop()
{
  top--;
  return test[top+1];
}

int main()
{
  char arr[100];
  int a, b;
  
  while(scanf("%s", arr) != EOF)
    {
      if(arr[0] == '+')
	{
	  push(pop()+pop());
	}
      else if(arr[0] == '-')
	{
	  a = pop();
	  b = pop();
	  push(b-a);
	}
      else if(arr[0] == '*')
	{
	  push(pop()*pop());
	}
      else
	{
	  push(atoi(arr));
	}
    }
  printf("%d\n", pop());
}



Measured memory_bytes: 1992
def compare(q,p):
    if q>p:
        return p
    else:
        return q
a,b,c,x,y= map(int, input().split())
re=0
if a+b>2*c:
    if x>y:
        re=compare(c*x*2,c*y*2+a*(x-y))
    else:
        re=compare(c*y*2,c*x*2+b*(y-x))
else:
    re=a*x+b*y
print(re)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b==c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 888
N, Q = map(int, input().split())
S = ' ' + input() + ' '

ps = [0, N+1]
dirs = { 'L': -1, 'R': 1 }
QS = [input().split() for _ in range(Q)]
def drop(p):
  for t, d in QS:
    if S[p] == t:
      p = p + dirs[d]
      if p == 0 or p == N+1:
        return 1 if p == N+1 else -1
  return 0

# 二分探索
f = 0
t = N+1
while f + 1 < t:
  mid = f + (t-f)//2
  ret = drop(mid)
  if ret != -1:
    t = mid
  else:
    f = mid
p1 = f

f = 0
t = N+1
while f + 1 < t:
  mid = f + (t-f)//2
  ret = drop(mid)
  if ret == 1:
    t = mid
  else:
    f = mid
p2 = f
print(max(0, p2-p1))

Measured memory_bytes: 41392
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  ll N, X;
  cin >> N >> X;
  vector<ll> x(N);
  set<ll> res;
  for (int i = 0; i < N; i++) {
    cin >> x[i];
    res.insert(abs(X - x[i]));
  }
  int cnt = 0;
  ll ans;
  for (auto e : res) {
    if (cnt == 0) {
      cnt++;
      ans = e;
      continue;
    }
    ans = gcd(ans, e);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8520
N = int(input())
prv = [0,0,0]
for _ in range(N):
  t, x, y = map(int,input().split())
  n = 0
  dif = (t- prv[2]) - (abs(prv[0]-x) + abs(prv[1]-y))
  if dif >= 0 and dif%2 == 0:
    prv = [x,y,t]
  else:
    print('No')
    exit()
print('Yes')

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

vector<long long>adj[100099];
map<long long,long long>vis; long long cnt=0;

void bfs(long long src)
{

    vis[src]=1; long long sz,x,y,i,z;
    queue<long long>qu;

    qu.push(src);

    while(!qu.empty())
    {
        x=qu.front();  qu.pop();  sz=adj[x].size();

        for(i=0;i<sz;i++)
        {
            y=adj[x][i];
            if(vis[y]==0)
            {
                vis[y]=x; qu.push(y);  cnt++;
            }
        }


    }



}

int main()
{

        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,sz1,sz2,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX; string str,ttr,ntr;
        long long res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct,tct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr,mp1,mp2;

        scanf("%lld %lld",&n,&m);

        for(i=1;i<=m;i++)
        {
            scanf("%lld %lld",&a,&b);
            adj[a].push_back(b);  adj[b].push_back(a);

        }

        bfs(1);

        if(cnt<n-1)printf("No\n");
        else
        {
            printf("Yes\n");

            for(i=2;i<=n;i++)printf("%lld\n",vis[i]);
        }






    return 0;
}





Measured memory_bytes: 18440
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

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

void set_pos(int* x,int* y,int n,int** table){

	bool isok = true;
	while(1){
		if(*x >= n){
			*x = 0;
			isok=false;
		}

		if(*x < 0){
			*x = n-1;
			isok=false;
		}

		if(*y >= n){
			*y = 0;
			isok=false;
		}

		if(*y>=0 && *y<n && *x>=0 && *x<n && table[*y][*x]!=0){
			*y += 1;
			*x -= 1;
			isok=false;
		}

		if(isok) break;

		isok=true;
	}
}

int main(){
	int n;
	while(scanf("%d",&n)){
		if(n==0) break;
		int** table = new int*[n];
		for(int i=0;i<n;i++) table[i] = new int[n]();

		int cx = n/2;
		int cy = n/2;

		int dx = cx;
		int dy = cy + 1;

		table[dy][dx] = 1;

		for(int i=2;i<=n*n;i++){
			dx++;
			dy++;
			set_pos(&dx,&dy,n,table);
			table[dy][dx] = i;
		}

		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				printf("%4d%s",table[i][j],j==n-1 ? "\n" : "");
			}
		}


		for(int i=0;i<n;i++) delete[] table[i];
		delete[] table;
	}
}

Measured memory_bytes: 0
def main():
    N = int(input())
    B = list(map(int, input().split()))
    
    if N == 2:
        print(B[0] * 2)
        return

    ans = B[0]
    for i in range(1, N-1):
        ans += min(B[i-1], B[i])
    ans += B[-1]
    print(ans)
    
main()

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

int lcs(string s1, string s2) {
    int i, j, ret = 0;
    int n = s1.size();
    int m = s2.size();
    int c[n+1][m+1];
    s1 = ' ' + s1;
    s2 = ' ' + s2;

    for (i = 0; i <= n; i++) c[i][0] = 0;
    for (j = 1; j <= m; j++) c[0][j] = 0;

    for (i = 1; i <= n; i++) {
        for (j = 1; j <= m; j++) {
            if (s1[i] == s2[j]) {
                c[i][j] = c[i - 1][j - 1] + 1;
            }
            else {
                c[i][j] = max(c[i - 1][j], c[i][j - 1]);
            }
            ret = max(ret, c[i][j]);
        }
    }
    
    return ret;
}

int main(void) {
    int q, i;
    string s1, s2;
    
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        cin >> s1 >> s2;
        printf("%d\n", lcs(s1, s2));
    }

    return 0;
}

Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(vs) sort(vs.begin(), vs.end())
#define RSORT(vs) sort((vs).rbegin(), (vs).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

LLI dt[100000][26];
int main() {
    cout << fixed << setprecision(10);
    string s, t;
    cin >> s >> t;
    LLI l = s.size();

    LLI sp[26];
    REP(i, 100000) REP(j, 26) dt[i][j] = INF;
    REP(i, 26) sp[i] = -1;
    s = s + s;
    for(int i = s.size() - 1; 0 <= i; i--) {
        char c = s[i] - 'a';

        REP(j, 26) {
            if(sp[j] != -1)
                dt[i % l][j] = sp[j] - i;
        }
        sp[c] = i;
    }

    LLI len = dt[0][t[0] - 'a'];
    if(s[0] == t[0])
        len = 0;
    // 存在しない
    if(INF == len) {
        cout << "-1";
        return 0;
    }

    LLI index = len;
    FOR(i, 1, t.size()) {
        if(INF == dt[index][t[i] - 'a']) {
            cout << "-1";
            return 0;
        }
        len += dt[index][t[i] - 'a'];
        (index += dt[index][t[i] - 'a']) %= l;
    }
    cout << len + 1;
    return 0;
}

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

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

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse
#define size(collection) ((ll) (collection).size())						// collection size

#endif



int main(void)
{
	ll n; cin >> n;
	vector<double> v(n);

	rep(i, 0, n)
		cin >> v[i];


	double ans = 0;
	for (auto& e : v)
	{
		ans += (1 / e);
	}



	cout << (double)1.0 / ans;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 30;


const ll eight=40320;

ll solve(int n){
	ll dp[3][10][110][3]={0};  // first princess seats prev
	if(n&1){
			dp[0][0][1][0]=dp[1][1][1][1]=1;
			rep(i,8+1){
				for(int j=1;j<=100;j++){
					rep(k,2){ 
						dp[k][i][j+1][0]+= dp[k][i][j][0]+dp[k][i][j][1];
						dp[k][i+1][j+1][1]+=dp[k][i][j][0];
					}
				}
			}
			return dp[0][8][n][0]+dp[0][8][n][1]+dp[1][8][n][0];
		}else{
			int half=n/2;	
			dp[0][0][1][0]=dp[1][1][1][1]=dp[2][1][1][2]=1;
			rep(i,8+1){
				for(int j=1;j<=100;j++){
					rep(k,3){ 
						dp[k][i][j+1][0]+= dp[k][i][j][0]+dp[k][i][j][1]+dp[k][i][j][2];
						dp[k][i+1][j+1][1]+=dp[k][i][j][0]+dp[k][i][j][2];
						dp[k][i+1][j+1][2]+=dp[k][i][j][0]+dp[k][i][j][1];
					}
				}
			}
			ll ans=0;
			rep(i,3)rep(j,3){
				if( (i==1&&j==2)||(i==2&&j==1) ) 
					continue;
				else 
					ans+=dp[i][8][half][j];
			}
			return ans;
		}
}

int main(void){
	int n;
	while(cin >> n,n){
		ll ans=solve(n);
		cout << ans*eight << endl; 
	}
	return 0;
}

Measured memory_bytes: 1236
using System;
using System.Linq;

namespace ABC086_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var T = new int[N][];
            for (int i = 0; i < N; i++)
                T[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var canGo = true;
            var x = 0;
            var y = 0;

            for (int i = 0; i < N; i++)
            {
                var nx = T[i][1];
                var ny = T[i][2];
                canGo = Math.Abs(nx - x) + Math.Abs(ny - y) <= T[i][0];
                if (!canGo) break;
                canGo = (Math.Abs(nx - x) + Math.Abs(ny - y)) % 2 == T[i][0] % 2;
                if (!canGo) break;
            }

            Console.WriteLine(canGo ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 24508
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    int n, a, b; cin >> n >> a >> b;

    int vmax = min(a, b);
    int vmin = max(0, a + b - n);

    cout << vmax << " " << vmin << endl;

    return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]
V = 0
for i in range(N):
  V += L[i][1]

dp = [10**9+1] * (V + 1)
dp[0] = 0
for i in range(N):
    for j in range(V, -1, -1):
        dp[j] = min(dp[j], dp[j-L[i][1]] + L[i][0])
ans = 0
for j in range(V+1):
    if  W >= dp[j]:
        ans = max(ans, j)
print(ans)

Measured memory_bytes: 41964
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }
}  // namespace my
////////////////////////

int main() {
  ll a;
  ld b;
  cin >> a >> b;
  cout << to_string((ll)floor((ld)a * b)) << endl;
}

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

using namespace std;

const int N = 3e6 + 6, mod = 1e9 + 7;

long long powmod(long long b, long long p){
  long long r = 1;
  for (; p; p >>= 1, b = b * b % mod)
    if (p & 1)
      r = r * b % mod;
  return r;
}

long long fac[N], inv[N];

long long C(int n, int k) {
  if (k < 0 || n < k) return 0;
  return (fac[n] * inv[k] % mod) * inv[n-k] % mod;
}

int main() {
  fac[0] = inv[0] = 1;
  for (int i = 1; i < N; ++i)
    fac[i] = fac[i-1] * i % mod;
  inv[N-1] = powmod(fac[N-1], mod-2);
  for (int i = N-2; i > 0; --i) {
    inv[i] = inv[i+1] * (i+1) % mod;
    assert((inv[i] * fac[i] % mod) == 1);
  }
  int n;
  scanf("%d", &n);
  --n;
  long long ans = fac[n] * n % mod;
  for (int i = 1; i <= n; ++i) {
    int sela = i+1;
    int ada = n - sela;
    long long cur = C(ada, i) * fac[n-i] % mod;
    cur = (cur * fac[i]) % mod;
    ans = (ans + mod - cur) % mod;
  } 
  if (ans < 0) ans += mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 47104
#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>;

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

//begin
template <class T>
class SqrtDecompositionRangeAddRangeSum
{
  private:
    int N, K;
    int sqrtN;
    vector<T> data;
    vector<T> bucket_sum;
    vector<T> bucket_add;
  public:
    SqrtDecompositionRangeAddRangeSum(int n) : N(n)
    {
        sqrtN = 512;
        K = (N + sqrtN - 1) / sqrtN;
        data.assign(K * sqrtN, 0);
        bucket_sum.assign(K, 0);
        bucket_add.assign(K, 0);
    }
    // [s, t)
    void add(int s, int t, T x)
    {
        int p = s / sqrtN;
        int q = t / sqrtN;
        for (int k = p; k <= q; ++k)
        {
            int l = k * sqrtN, r = (k + 1) * sqrtN;
            if (r <= s || t <= l)
                continue;
            if (s <= l && r <= t)
            {
                bucket_add[k] += x;
            }
            else
            {
                for (int i = max(s, l); i < min(t, r); ++i)
                {
                    data[i] += x;
                    bucket_sum[k] += x;
                }
            }
        }
    }
    // [s, t)
    T get_sum(int s, int t)
    {
        int p = s / sqrtN;
        int q = t / sqrtN;
        T sum = 0;
        for (int k = p; k <= q; ++k)
        {
            int l = k * sqrtN, r = (k + 1) * sqrtN;
            if (r <= s || t <= l)
                continue;
            if (s <= l && r <= t)
            {
                sum += bucket_sum[k] + bucket_add[k] * sqrtN;
            }
            else
            {
                for (int i = max(s, l); i < min(t, r); ++i)
                {
                    sum += data[i] + bucket_add[k];
                }
            }
        }
        return sum;
    }
    T get_value(int i)
    {
        int k = i / sqrtN;
        return data[i] + bucket_add[k];
    }
};
//end
signed main()
{
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    SqrtDecompositionRangeAddRangeSum<ll> decomp(N);
    while (Q--)
    {
        int c;
        cin >> c;
        if (c == 0)
        {
            int s, t, x;
            cin >> s >> t >> x;
            decomp.add(s, t + 1, (long long)x);
        }
        else
        {
            int s, t;
            cin >> s >> t;
            cout << decomp.get_sum(s, t + 1) << endl;
        }
    }
}

Measured memory_bytes: 3632