akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 3e5 + 5;
int a[N];
int n;

int main() {
    scanf("%d", &n);
    int m = 3 * n;
    for (int i=1; i<=m; ++i) {
        scanf("%d", &a[i]);
    }
    sort(a+1, a+m+1);
    ll ans = 0;
    int i = m - 1;
    while (n--) {
        ans += a[i];
        i -= 2;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<string, string> sP;
typedef pair<ll, pair<ll, ll>> PP;

const ll mod = 1e4;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second



int main() {
	ll n, z, w, a[2010];
	cin >> n >> z >> w;
	for (int i = 0;i < n;i++)cin >> a[i];
	cout << max(abs(a[n - 2] - a[n - 1]), abs(a[n - 1] - w)) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		String[] str = new String[3];
		for(int i = 0; i < str.length; i++) {
			str[i] = scan.next();
		}
		for(int i = 0; i < str.length; i++) {
			System.out.print(str[i].charAt(i));
		}
	}
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef vector<int64_t> vi;
typedef pair< int64_t,int64_t> ii;
typedef vector<pair<int64_t, int64_t> > vp;
typedef vector<pair<int64_t, ii> > vpp;
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define INF 1e9
#define SIZE 200001
#define mod 1000000007
#define int int64_t
void solve();
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    solve();
    return 0;
}
void solve()
{
    int n;
    cin>>n;
    vi ar(n+1);
    vi br(n+1);
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        br[i]=1e10;
    }
    br[0]=0;
    for(int i=0;i<n-1;i++)
    {
        for(int j=1;j<=2;j++)
        {
            if(i<n-2)
            {
                br[i+j]=min(br[i+j],br[i]+abs(ar[i+j]-ar[i]));
            }
            else
            {
                br[i+j]=min(br[i+j],br[i]+abs(ar[i+j]-ar[i]));
                break;
            }
        }
    }
    cout<<br[n-1]<<"\n";
}




Measured memory_bytes: 1792
/*
Author : N_o_o_B
Created : April 22 2020 22:51:03 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n,m;
    cin >> n >> m;
    fori(i,n){
        string s;
        cin >> s;
        cout << s << endl;
        cout <<  s << endl;
    }



    time_taken();
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    char a, b;
    cin >> a >> b;

    if((a == 'H') ^ (b == 'H'))
        cout << 'D' << endl;
    else
        cout << 'H' << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100010
#define INF 10000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    int l,r;
    cin>>l>>r;
    int ans=0;
    if(r-l<2019){
        ans=1000000;
        for(int i=l;i<r;i++){
            for(int j=i+1;j<=r;j++){
                ans=min(ans,((j%2019)*(i%2019))%2019);
            }
        }
    }
    OUT(ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int res = 0;
		if (a == b) {
			res = c;
		} else if (a == c) {
			res = b;
		} else if (b == c) {
			res = a;
		}
		System.out.println(res);
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 21332
#include <cstdio>
int ans[505][505];
int main()
{
 int k;
 scanf("%d",&k);
 if(k==1)
 {
  puts("1");
  puts("1");
  return 0;
 }
 int n=(k+1)/2;
 if(n%2)n++;
 printf("%d\n",n);
 for(int i=0;i<n;i++)
  for(int j=0;j<n;j++)
   ans[i][j]=n*(i%2)+(i+j)%n+1;
 for(int c=2*n;c>k;c--)
  for(int i=1;i<n;i+=2)
   for(int j=0;j<n;j++)
    if(ans[i][j]==c)ans[i][j]-=n;
 for(int i=0;i<n;i++)
 {
  for(int j=0;j<n;j++)
   printf("%d ",ans[i][j]);
  puts("");
 }
 return 0;
}


Measured memory_bytes: 2048
mod = 998244353

n, s = gets.to_s.split.map{|e| e.to_i }
a = gets.to_s.split.map{|e| e.to_i }.sort

dp = [0] * (s+1)
dp[0] = 1

s_max = 0
a.each do |t|
  s_max = s < s_max + t ? s : s_max + t
  s_max.downto(0) do |j|
    dp[j] *= 2
    dp[j] += dp[j-t] if j - t >= 0
    dp[j] %= mod if dp[j] >= mod
  end
end

puts dp[s]


Measured memory_bytes: 14440
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = LIST()

A.sort(reverse = True)

p = [A[0]]

for i in range(1, N):
	p += [A[i]]*2

print(sum(p[:N-1]))


Measured memory_bytes: 34488
import java.io.PrintWriter
import java.util.*

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

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

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

fun main() {
    val N = nextLong()
    val primes = primefact(N)
    var ans = 0
    for (e in primes) {
        var (p, n) = e
        var i = 1
        while (i <= n) {
            ans++
            n -= i
            i++
        }
        primes[p] = n
    }
    println(ans)
}

fun primefact(n: Long): HashMap<Long, Int> {
    val map = HashMap<Long, Int>()
    var tmp = n
    for (i in 2L..(Math.sqrt(n.toDouble()).toLong() + 1)) {
        if (tmp % i == 0L) {
            var cnt = 0
            while (tmp % i == 0L) {
                tmp /= i
                cnt++
            }
            map[i] = cnt
        }
    }
    if (tmp != 1L) {
        map[tmp] = 1
    }
    return map
}

Measured memory_bytes: 34924
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

template<int N, typename T, T M>
struct ModFact {
    T fact[N+1];
    T ifact[N+1];
    constexpr ModFact() : fact(), ifact() {
        fact[0] = 1;
        for (int i=0; i<N; ++i)
            fact[i+1] = (fact[i]*(i+1))%M;
        ifact[N] = power(fact[N], M-2);
        for (int i=N-1; i >= 0; --i)
            ifact[i] = (ifact[i+1]*(i+1))%M;
    }
    constexpr T power(T a, T b) {
        T r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%M;
            a = (a*a)%M;
            b >>= 1;
        }
        return r;
    }
    constexpr T comb(T n, T r) {
        return (((fact[n]*ifact[r])%M)*ifact[n-r])%M;
    }
};
 
ModFact<100000, ll, MOD> fact;

ll N, ans = 1;
ll cnt = 1;
char S[200000];

int main() {
    scanf("%lld\n", &N);
    fread_unlocked(S, 1, (N<<1), stdin);
    if(S[0] == 'B' && S[(N<<1)-1] == 'B') {
        size_t i;
        bool f = false;
        for(i = 1; i < (N<<1); i++) {
            if(S[i] == S[i-1]) f ^= true;
            if(f) {
                ans *= (cnt << 1) - i;
                if(ans > 1LL<<45) ans %= MOD;
            }
            else cnt++;
            if(cnt > N) break;
        }
        if(cnt != N) ans = 0;
        else ans = ((ans % MOD) * fact.fact[N]) % MOD;
    } else ans = 0;
    printf("%lld\n", ans);
	return 0;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    string s;
    cin >> s;
    if( s.back() == 's' ) s += "e";
    s += "s";
    cout << s << endl;

    return 0;
}



Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y) {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for ( int i = 0; i <= m; i++ ) c[i][0] = 0;
  for ( int j = 1; j <= n; j++ ) c[0][j] = 0;

  for ( int i = 1; i <= m; i++ )
    for ( int j = 1; j <= n; j++ ) {
      if ( X[i] == Y[j] )
        c[i][j] = c[i - 1][j - 1] + 1;
      else
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      maxl = max(maxl, c[i][j]);
    }

  return maxl;
}

int main() {
  string s1, s2;
  int n; cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}


Measured memory_bytes: 7108
def prime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if not n % 2:
        return False
    for i in range(3, int(n ** 0.5) + 1,2):
        if n % i == 0:
            return False
    return True
def main(a, d, n):
    i = 0
    a -= d
    while i < n:
        a += d 
        if prime(a):
            i += 1
    print(a)
while 1:
    a, d, n = map(int, input().split())
    if a == d == n == 0:
        break
    main(a, d, n)


Measured memory_bytes: 5660
#include <iostream>

using namespace std;

int main(){
  int s;
  while(cin >> s){
    int c = 0;
    for (int i = 0; i <= 9; i++){
      for (int j = 0; j <= 9; j++){
        for (int k = 0; k <= 9; k++){
          for (int l = 0; l <= 9; l++){
            if ((i+j+k+l) == s){
              c++;
            }
          }
	}
      }
    }
    cout << c << endl;
  }
}

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

int main(void)
{
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h.at(i);
  }

  vector<int> onezero(n-1);
  for(int i=0;i<n-1;i++){
    if(h.at(i) < h.at(i+1)){
      onezero.at(i) = 0;
    }else{
      onezero.at(i) = 1;
    }
  }


  int tmp=0,ans=0;
  for(int i=0;i<n-1;i++){
    if(onezero.at(i)==1){
      tmp+=1;
    }else{
      if(ans < tmp){
	ans=tmp;
      }
      tmp=0;
    }
  }
  
  if(ans < tmp){
    ans = tmp;
  }

  cout << ans << endl;
  
}


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

signed main(){
  
  int a, b, c, x, y;
  cin>>a>>b>>c>>x>>y;
  
  int mina = min( x, y );
  int ans = 0;
  
  if( a + b > c * 2 ) ans += mina * c * 2;
  else ans += mina * ( a + b );

  x-=mina, y-=mina;
  
  if( x && a > c * 2 ) ans += x * c * 2;
  else ans += x * a;

  if( y && b > c * 2 ) ans += y * c * 2;
  else ans += y * b;

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N; cin >> N ;
  vector<tuple<int, int>> A(N);
  for(int i=0; i<N; i++) {
    int a; cin >> a;
    A[i] = make_tuple(a, i+1);
  }
  
  sort(A.begin(), A.end());
  for(auto a: A)
    cout << get<1>(a) << " ";
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<math.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    cout<<n<<":";
    int m=n;
    for(int i=2;i<sqrt(n);i++){
       for(;;){
          if(m%i!=0){break;}
          else if(m%i==0){
          	     cout<<" "<<i;
          	     m/=i;
          }
       }
       if(m==1)break;
    }
    if(n==m){
      cout<<" "<<n<<endl;
    }
    else if(m!=1){
           cout<<" "<<m<<endl;	
    }
    else{cout<<endl;}
    return 0;
}


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

using namespace std;

#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)

const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S;
    cin >> S;

    cout << S.substr(0, 4) << " " << S.substr(4, 8) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<complex>
using namespace std;

typedef complex<double> P;

#define X real()
#define Y imag()
typedef int kz;

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

int main(){
    int mod=1000000007;
    int m=70099;
    int a,b,n;
    while (scanf("%d %d %d",&a,&b,&n)!=EOF) {
        int ans=0;
        while (n>0) {
            a=a%b*10;
            ans+=a/b;
            n-=1;
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3192
/*
https://atcoder.jp/contests/dp/tasks/dp_i
Space n*(n+1) Time n*n
#probability #dp #topDown #Recursion
*/

#include <bits/stdc++.h>
using namespace std;
int n;
double dp[3000][3000],p[3000];
double solve(int nheads,int coin) {
  double &res = dp[nheads][coin];
  if (res >= 0) return res;
  if (coin==n-1) {
    if (nheads>1) res = 0;
    else if (nheads == 1) res = p[coin];
    else res = 1-p[coin];
  } 
  else {
    if (nheads==0) 
      res = (1-p[coin])*solve(nheads,coin+1);
    else 
      res = p[coin]*solve(nheads-1,coin+1)+(1-p[coin])*solve(nheads,coin+1);
  }
  // cerr <<"res for : " << nheads << ' ' << coin << ' ' << res << '\n';
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  for(int i=0;i<3000;i++) {
    for(int j=0;j<3000;j++) {
      dp[i][j] = -1;
    }
  }
  cin >> n;
  for(int i=0;i<n;i++)
    cin >> p[i];
  double res = 0;
  for(int heads = n/2+1;heads<=n;heads++) {
    res += solve(heads,0);
  }
  cout << setprecision(10) << res;
  return 0;
}

Measured memory_bytes: 70784
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, S: "List[str]"):
    ans = {}
    for s in S:
        if s in ans:
            ans[s]+=1
        else:
            ans[s]=1
    print(len(ans))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 56304
#include <stdio.h>
int main(void){
    int i, j, x;
    int min, max;
    long sum;
    min = max = sum = 0;
    scanf("%d", &i);
    for(j = 0; j < i; j++){
        scanf("%d", &x);
        if(j == 0){
            min = max = x;
        }
        if(x < min)
            min = x;
        if(x > max)
            max = x;
        sum += x;
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}


Measured memory_bytes: 600
#include <iostream>
#include <string>

using namespace std;

int main() {
	int n;
	string s;

	cin >> n >> s;
	
	const int len = s.length();
	string t(len,' ');

	for (int i = 0; i < len; i++) {
		t[i] = ((s[i] - 'A') + n) % 26 + 'A';

	}
	cout << t << endl;

	return 0;
};


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<((abs(a-b)<=d && abs(b-c)<=d)||abs(a-c)<=d ? "Yes" : "No")<<endl;
    return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

void solve() {
    int ans = 700;
    for (int i = 0; i < 3; ++i) {
        char c; c = getchar();
        if (c == 'o') ans += 100;
    }
    printf("%d", ans);
}

int main() {
    init();
    int t = 1; //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

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

const int maxn = 3e5 + 10;
int cL[maxn], cR[maxn], n;
string s;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif // CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    cin >> n >> s;
    for (int i = 0; i < n; ++i)
    {
        cR[i + 1] = cR[i] + (s[i] == 'E');
        cL[i + 1] = cL[i] + (s[i] == 'W');
    }
    int ans = n;
    for (int i = 1; i <= n; ++i)
        ans = min(ans, cL[i - 1] + cR[n] - cR[i]);
    cout << ans;
}


Measured memory_bytes: 3092
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
char s[N];
char word[4][100] = {"dreamer", "eraser", "dream", "erase"};
bool dp[N];

int main() {
  scanf("%s", s);
  vector<int> len(4);
  for (int k = 0; k < 4; ++k) {
    len[k] = strlen(word[k]);
  }
  int n = strlen(s);
  dp[n] = true;
  for (int i = n - 1; i >= 0; --i) {
    for (int k = 0; k < 4; ++k) {
      if (i + len[k] <= n && strncmp(s + i, word[k], len[k]) == 0) {
        dp[i] |= dp[i + len[k]];
      }
    }
  }
  puts(dp[0] ? "YES" : "NO");
  return 0;
}


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

int main() {
  string s;
  getline(cin ,s);

  for(int i = 0; i < s.size(); i++){
    if(islower(s[i])){
      s[i] = toupper(s[i]);

    }else if(isupper(s[i])){
      s[i] = tolower(s[i]);
    }
  }
  cout << s << endl;
}



Measured memory_bytes: 3228
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int k,n;

void solve(){
    cin >> k >> n;
    if (k%2==0){
        cout << k/2 << " ";
        rep(i,n-1) cout << k << " ";
        return;
    }
    deque<P> sta;
    int num=n;
    sta.push_back(P((k+1)/2,n));
    rep(i,n/2){
        int a=sta.back().first,m=sta.back().second;
        sta.pop_back();
        if (m>1) sta.push_back(P(a,m-1));
        if (a>1) {
            sta.push_back(P(a-1,1));
            if (num!=n) sta.push_back(P(k,n-num));
            num=n;
        }
        else num-=1;

        // rep(i,sta.size()){
        //     rep(j,sta[i].second){
        //         cout << sta[i].first << " ";
        //     }
        // }
        // cout << "" << endl;
    }

    rep(i,sta.size()){
            rep(j,sta[i].second){
                cout << sta[i].first << " ";
            }
        }
}



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

Measured memory_bytes: 2304
require 'prime'

MAX_n = 1120

primes = Prime.each.take_while { |n| n <= MAX_n }

t = nil
prev = nil

0.upto(primes.size) do |i|
  t = Array.new(MAX_n + 1) { Array.new(15) }
  0.upto(MAX_n) do |j|
    0.upto(primes.size) do |k|

      t[j][k] = if i == 0 || j <= 1 || k == 0
                     0
                   elsif primes[i-1] == j && k == 1
                     1
                   else
                     prev[j][k] + (primes[i-1] < j ? prev[j-primes[i-1]][k-1] : 0)
                   end
      
      # puts '%p = %p' % [ [i,j,k], t[i][j][k] ]

    end
  end
  prev = t
end

f = lambda { |n, k| t[n][k] }

loop do
  n, k = gets.split.map(&:to_i)
  break if [n,k] == [0,0]
  puts f.(n, k)
end

Measured memory_bytes: 14400
N,M=map(int,input().split())
if N%2:
    for i in range(1,M+1):
        print(i,N-i)
else:
    if N==4:
        print(2,3)
    else:
        t=1
        l=[]
        a,b=1,N
        while a<b:
            l.append((a,b))
            a+=1
            b-=1
            if N//2>=b-a and t:
                b-=1
                t=0
        for i in range(M):
            print(*l[i])

Measured memory_bytes: 18008
#include <cstdio>
#include <utility>
#include <vector>

using namespace std;

int main ()
{
  int m, f, r;
  int count = 0;
  vector<char> data(100);

  while (1) {
    scanf("%d %d %d", &m, &f, &r);
    if (m == -1 && f == -1 && r == -1) {
      for (int i = 0; i < count; i++) {
        printf("%c\n", data[i]);
      }
      return 0;
    }
    if (m == -1 || f == -1 || m + f < 30) {
      data[count] = 'F';
      count++;
      continue;
    }
    if (m + f >= 80) {
      data[count] = 'A';
    } else if (m + f >= 65 && m + f < 80) {
      data[count] = 'B';
    } else if (m + f >= 50 && m + f < 65) {
      data[count] = 'C';
    } else if (m + f >= 30 && m + f < 50) {
      if (r >= 50) {
        data[count] = 'C';
      } else {
        data[count] = 'D';
      }
    }
    count++;
  }
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N, K;
    cin >> N >> K;

    vector<int> h(N);
    for(int i = 0; i < N; i++) cin >> h[i];
    int ans = 0;
    for(int i = 0; i < N; i++){if(h[i]>=K) ans++;}
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;

	int ans = 0;

	for (int i = '0'; i <= '9'; i++)
	{
		for (int j = '0'; j <= '9'; j++)
		{
			for (int k = '0'; k <= '9'; k++)
			{

				int pointer_b = 0;
				bool flaga = false;
				bool flagb = false;
				bool flagc = false;

				for (char &val : s)
				{
					if (pointer_b == 0 && val == i)
					{
						flaga = true;
						pointer_b++;
					}
					else if (pointer_b == 1 && val == j)
					{
						flagb = true;
						pointer_b++;
					}
					else if (pointer_b == 2 && val == k)
					{
						flagc = true;
						pointer_b++;
					}

					if (flaga && flagb && flagc)
					{
						ans++;
						break;
					}
				}
			}
		}
	}

	cout << ans << endl;
}
//g++ -std=c++17 -g main.cpp -o mai	n

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

int main(){
    int W,H,x,y,r;

    cin >> W >> H >> x >> y >> r;

    if(x-r >= 0 && x+r <= W &&
       y-r >= 0 && y+r <= H){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define FAST()                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define fill(a, i) memset(a, i, sizeof(a))
#define all(vec) vec.begin(),vec.end()
#define revall(vec) vec.rbegin(),vec.rend()
#define v vector
#define tlll tuple<ll, ll, ll>
#define pb push_back
#define fr(i, a, b) for (int i = a; i < b; ++i) 
const ll maxn=3e3+5;
ll dp[maxn][maxn];
void solve()
{
   ll n;
   cin>>n;
   ll arr[n+1];
   fr(i,0,n)cin>>arr[i+1];
   fr(i,1,n+1)
   dp[i][i]=arr[i];
   ll pref[n+1];
   pref[0]=0;
   fr(i,1,n+1)
   pref[i]=pref[i-1]+arr[i];
   for(int l=2;l<=n;++l)
   {
       for(int i=1;i+l-1<=n;++i)
       {
           ll a,b;
           a=arr[i]+pref[i+l-1]-pref[i]-dp[i+1][i+l-1];
           b=arr[i+l-1]+pref[i+l-2]-pref[i-1]-dp[i][i+l-2];
           dp[i][i+l-1]=max(a,b);
       }
   }
   cout<<dp[1][n]*2-pref[n];

}
int main()
{
    ll t=1;
    // cin>>t;
    while(t--)
    solve();
}

Measured memory_bytes: 49772
#include <bits/stdc++.h>
using namespace std;
double f[3030][3030],a[3030],ans;
int n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	f[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<(n+1)/2 && j<=i;j++)
			f[i][j]=f[i-1][j-1]*(1-a[i])+f[i-1][j]*a[i];
	for(int i=0;i<(n+1)/2;i++)
		ans+=f[n][i];
	cout<<fixed<<setprecision(10)<<ans<<endl; 
	return 0;
}


Measured memory_bytes: 70272
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int K;
cin >> K;
int ans;
if (K % 2 == 0) {
    ans = (K/2) * (K/2);
} else {
    ans = (K/2) * (K/2+1);
}
cout << ans << endl;


return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
//#define DEBUG

int main (void){

	int n = 0 ;			//???????????°????????????????????°
	int pt_taro = 0 ;	//?????????????????????????¨???????????????°
	int pt_hanako = 0 ; //??±??????????????????????¨???????????????°

	int i = 0 ;			//???????????°
	int j = 0 ;

	scanf("%d",&n);
#ifdef DEBUG
	printf("???????????°n???%d\n" ,n);
#endif

	/*?????????n??? ??¨??????????????????????????°j*/
	for( j = 1 ; j <= n ; j++){

		/*???????????¨??????????????????????????????*/
		char card_taro[101] = {} ;		//??????????????????????????????
		char card_hanako[101] = {} ;	//??±???????????????????????????

		scanf("%s", card_taro);
		scanf("%s", card_hanako);

#ifdef DEBUG
	printf("?????????%s?????±??????%s\n" ,card_taro,card_hanako);
#endif

		/*??????????????????????????? ???????????°i*/
		for( i = 0 ; i < 101 ; i++){
			if(card_taro[i] > card_hanako[i]){
				pt_taro += 3 ;			//?????????????????§??????
#ifdef DEBUG
	printf("???????????????\n");
#endif
				break;
			}
			else if(card_taro[i] < card_hanako[i]){
				pt_hanako += 3 ;			//??±??????????????§??????
#ifdef DEBUG
	printf("??±????????????\n");
#endif
				break;
			}
			else if(card_taro[i] == '\0'){	//??????????????§\0?????´????????????????????§??????
				pt_hanako++;
				pt_taro++;
#ifdef DEBUG
	printf("????????????\n");
#endif
				break;
			}
											//?±????????????????\0??§??????????????°??????????¶????
		}//???????????°i?????????????????????????????§

#ifdef DEBUG
	printf("%d????????????????????????????????????%d\n",j,pt_taro);
	printf("??±???????????????%d\n",pt_hanako);
#endif

	}//???????????°j?????????????????????????????§

#ifdef DEBUG
	printf("????????????????????????%d\n",pt_taro);
	printf("??±?????????????????????%d\n",pt_hanako);
#endif

	/*????????¨???*/
	printf("%d %d\n" , pt_taro , pt_hanako);



	return 0;
}

Measured memory_bytes: 596
import java.util.*;

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

    boolean tmp = true;

    while(tmp){
      int h = sc.nextInt();
      int w = sc.nextInt();

      if(h == 0 && w == 0){
        tmp = false;
        break;
      }

      for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
          System.out.print("#");
        }
        System.out.println();
      }

      System.out.println();
    }
  }
}



Measured memory_bytes: 36784
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }


int dp[4001][4001];
signed main(){

    string S; cin >> S;
    int N = S.size();
    int r = 0, b = 0;
    int mod = 998244353;

    REP(i, 4001) REP(j, 4001) dp[i][j] = 0;
    dp[0][0] = 1;
    REP(i, 2 * N){
        if(i < N){
            if(S[i] == '0') r += 2;
            else if(S[i] == '1'){
                r += 1; b += 1;
            }else b += 2;
        }
        REP(j, i + 1){
            if(j + 1 <= b){
                dp[i + 1][j + 1] += dp[i][j];
                dp[i + 1][j + 1] %= mod;
            }
            if(i + 1 - j <= r){
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][j] %= mod;
            }
        }
    }
    cout << dp[2 * N][b] << endl;

    return 0;
}


Measured memory_bytes: 125312
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g $PROGRAM -o $OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

vector<string> split(char d,string s)
{
	stringstream ss(s);
	string t;
	vector<string> words;
	while(getline(ss,t,d))
	{
		words.pb(t);
	}

	return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
	auto start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	VII arr(n + 1);
	for (int i = 1; i <= n;++i)
	{
		int x;
		cin >> x;
		arr[x] = i;
	}

	for (int i = 1; i <= n;++i)
		cout << arr[i] << ' ';

#ifdef LOCAL
	auto end = chrono::high_resolution_clock::now();
	double time_taken =
		chrono::duration_cast<chrono::nanoseconds>(end - start).count();

	time_taken *= 1e-9;

	cerr << "\nTime taken by program is : " << fixed
		 << time_taken << setprecision(9);
	cerr << " sec" << endl;
#endif
	return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<string>
using namespace std;
int main() {
	int N, l[1000], r[1000];
	int ans[1000];
	int sum = 0;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> l[i] >> r[i];
		ans[i] = r[i] - l[i] + 1;
		sum += ans[i];
	}
	cout << sum << endl;
	return 0;
}

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

using namespace std;

int main(){
  int N;
  vector< string > s;
  string str;
  long long int ans=0;
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> str;
    sort(begin(str),end(str));
    s.push_back(str);
  }
  sort(begin(s), end(s));

  str = "";
  long long int tmp=0;
  for (auto itr=begin(s);itr != end(s); itr++) {
    if (str != *itr) {
      str = *itr;
      tmp=0;
    } else {
      tmp++;
      ans+=tmp;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int a[N], b[N];
int main() {
	int n, x;
	scanf("%d%d", &n, &x);
	for (int i = 0; i < n; ++ i) {
		scanf("%d", &a[i]);
		b[i] = a[i];
	}
	long long ans = 0;
	for (int i = 0; i < n; ++ i) ans += a[i];
	for (int cnt = 1; cnt <= n; ++ cnt) {
		long long res = 0;
		for (int j = 0; j < n; ++ j) b[j] = min(b[j], a[(j - cnt + n) % n]);
		for (int j = 0; j < n; ++ j) res += b[j];
		ans = min(ans, 1LL * cnt * x + res);
	}
	cout << ans << endl;
}



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

signed main(){
  int n;cin>>n;
  string s;cin>>s;
  s+="###############";
  int ans=0;
  for(int i=0;i<n+5;i++)ans+=(s.substr(i,3)=="ABC");
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
	#include<vector>
	#include<algorithm>
	#include<string>
	#include<cmath>
	#include<map>
	#include<cstdio>
	#include<stack>
	#include<queue>
	#include<fstream>
	#include<cstdio>
	#include<deque>
	#include<iomanip>
	#include <numeric>
	//#include<bits/stdc++.h>

	using namespace std;
	#define ok1 printf("ok1\n");
	#define ok2 printf("ok2\n");
	#define M 1000000000000000000LL
	#define rep(i,n) for(int i=0;i<n;i++)
	#define REP(i,s,n) for(int i=(s);i<(n);i++)
	#define repr(i,n) for(int i=n-1;i>=0;i--)
	#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
	#define all(a) (a).begin(),(a).end()
	#define reall(a) (a).rbegin(),(a).rend()
	#define pb push_back
	#define pf push_front
	#define MIN(a,b) a=min((a),(b))
	#define MAX(a,b) a=max((a),(b))
	#define SIZE(v) (int)v.size()
	const double pi = acos(-1.0);

	typedef vector<int> vi;
	typedef vector<string> vs;
	typedef long long ll;
	typedef vector<ll> vll;
	typedef vector<vi> vvi;
	typedef vector<vll> vvll;
	typedef deque<ll> dll;
	typedef pair<ll, ll> P;
	const ll mod = 1e9 + 7;
	ll dx[4] = {1,0,-1,0};
	ll dy[4] = {0,1,0,-1};


	int main() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		/*ll n, ans = 0;
		cin >> n;
		vs s(3);
		rep(i, 3) cin >> s[i];
		rep(i, n) {
			//cout << s[0][i] << s[1][i] << s[2][i] << endl;
			if (s[0][i] != s[1][i]) {
				if (s[1][i] != s[2][i]) {
					if (s[0][i] == s[2][i]) ans++;
					else ans += 2;
				}
				else ans++;
			}
			else {
				if (s[1][i] != s[2][i]) ans += 1;
			}
			//cout << ans << endl;
		}
		cout << ans << endl;*/

		
		ll n,a,b;
		cin >> n >> a >> b;
		ll x=0;
		if (min(a, b) - (n - max(a, b)) > 0) x = min(a, b) - (n - max(a, b));
		cout << min(a, b) << " " << x << endl;
		/*ll n, ans = 0;
		cin >> n;
		vll a(n), b(n);
		vector<P> v(n), w(n);
		rep(i, n) {
			cin >> a[i] >> b[i];
			v[i] = P(a[i], i);
			w[i] = P(b[i], i);
		}
		sort(reall(v));
		sort(reall(w));
		//rep(i, n) cout << w[i].first << " " << w[i].second << endl;
		ll x = 0, y = 0;
		map<ll, bool> m;
		rep(i, n) {
			if (i % 2 == 1) {
				while (m[v[x].second]) x++;
				ans -= b[v[x].second];
				m[v[x].second] = true;
				x++;
			}
			else {
				//cout << m[w[y].second] << endl;
				while (m[w[y].second]) y++;
				ans += a[w[y].second];
				m[w[y].second] = true;
				y++;
			}
			//cout << ans << endl;
		}
		cout << ans << endl;*/
		return 0;
	}	

Measured memory_bytes: 256
k = int(input())
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
howmany = [0]*(k+1)
for i in range(1,k+1):
    for j in range(1,k+1):
        howmany[gcd(i,j)] += 1
sumlist = [0]*(k+1)
for i in range(1,k+1):
    cur = 0
    for j in range(1,k+1):
        cur += gcd(i,j)
    sumlist[i] += cur*howmany[i]
print(sum(sumlist))


Measured memory_bytes: 9208
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;


int main(){

	int coin[6] ={ 500,100,50,10,5,1 },sum,price;

	while(true){
		scanf("%d",&price);
		if(price == 0)break;

		sum = 0;

		price = 1000 - price;

		for(int i = 0; i <= 5; i++){
			while(price >= coin[i]){
				price -= coin[i];
				sum++;
			}
		}

		printf("%d\n",sum);
	}

    return 0;
}

Measured memory_bytes: 2580
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 998244353;

struct mint {
    lint v;
    lint _mod;
    mint() : v(0) {}
    mint(signed v, lint _mod = mod) : v(v), _mod(_mod) {}
    mint(lint t, lint _mod = mod) : _mod(_mod) {
        v = t % _mod;
        if (v < 0)
            v += _mod;
    }

    mint pow(lint k) {
        mint res(1), tmp(v);
        while (k) {
            if (k & 1)
                res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    static mint add_identity() { return mint(0); }
    static mint mul_identity() { return mint(1); }
    mint inv() { return pow(_mod - 2); }

    mint &operator+=(mint a) {
        v += a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    mint &operator-=(mint a) {
        v += _mod - a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    mint &operator*=(mint a) {
        v = v * a.v % _mod;
        return *this;
    }
    mint &operator/=(mint a) { return (*this) *= a.inv(); }

    mint operator+(mint a) const { return mint(v) += a; };
    mint operator-(mint a) const { return mint(v) -= a; };
    mint operator*(mint a) const { return mint(v) *= a; };
    mint operator/(mint a) const { return mint(v) /= a; };

    mint operator-() const { return v ? mint(_mod - v) : mint(v); }

    bool operator==(const mint a) const { return v == a.v; }
    bool operator!=(const mint a) const { return v != a.v; }
    bool operator<(const mint a) const { return v < a.v; }
};
ostream &operator<<(ostream &os, mint m) { return os << m.v; }

struct Combination {
    vector<lint> fac, finv, inv;
    Combination(lint maxN) : fac(maxN + 100), finv(maxN + 100), inv(maxN + 100) {
        maxN += 100; // for safety
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1]            = 1;
        for (lint i = 2; i <= maxN; ++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;
        }
    }
    lint operator()(lint n, lint k) {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    Combination nCk(n);
    mint ng = 0;
    for (int i = n / 2 + 1; i <= n; ++i) {
        ng += mint(2).pow(n - i) * nCk(n, i);
    }
    cout << mint(3).pow(n) - ng * 2 << "\n";
    return 0;
}

Measured memory_bytes: 234624
import java.util.Scanner;

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

		int x = 0,y = 0;
		int l = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		while(a > 0){
			a -= c;
			x++;
		}
		while(b > 0){
			b -= d;
			y++;
		}
		System.out.println(l - Math.max(x, y));
		
		sc.close();
	}
}

Measured memory_bytes: 17164