akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N;cin>>N;
  ll a[N];
  rep(i,N) cin>>a[i];
  ll ans=0;
  vector<bool> judge(N+10,true);
  judge[1]=false;
  ll hv=1;
  for(int i=0;i<N;i++){
    hv=a[hv-1];
    ans++;
    if(!judge[hv]){
      ans=-1;
      break;
    }
    
    else if(hv==2) break;
    
    else{
      judge[hv]=false;
    }
  }
  cout<<ans<<endl;
}

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

int main()
{
    int H, W;
    char c[52][52];
    int dx[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    int dy[8] = {1, 1, 1, 0, -1, -1, -1, 0};

    cin >> H >> W;
    for (int i = 1; i <= H; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            cin >> c[i][j];
        }
    }

    for (int i = 1; i <= H; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            if (c[i][j] == '.')
            {
                char ans = '0';
                for (int k = 0; k < 8; k++)
                {
                    if (c[i + dx[k]][j + dy[k]] == '#')
                    {
                        ans++;
                    }
                }
                c[i][j] = ans;
            }
        }
    }

    for (int i = 1; i <= H; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            cout << c[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int n;
        cin >> n;
        vector<int> a(n);
        rep(i, n) cin >> a[i];
        vector<int> l(n), r(n);
        rep(i, n - 1) l[i + 1] = gcd(l[i], a[i]);
        for (int i = n - 1; i >= 1; i--)
        {
                r[i - 1] = gcd(r[i], a[i]);
        }

        int ans = 1;
        rep(i, n) ans = max(ans, gcd(l[i], r[i]));
        cout << ans << endl;
}


Measured memory_bytes: 1536
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

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

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }


int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    cin >> a;

    vector<ll> cnt(100001);
    ll sum = 0;
    rep(i, n) {
        cnt[a[i]]++;
        sum += a[i];
    }

    int q;
    cin >> q;
    rep(_, q) {
        int b, c;
        cin >> b >> c;
        sum -= cnt[b] * b;
        sum += cnt[b] * c;
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 4776
//Solution by Tima
#include <bits/stdc++.h>
 
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
 
using namespace std;    
const int N = int(3e5) + 12, mod = int(1e9)  + 7; 

ll ans;

int cnt[70], n, a[N];

int main () {
	scanf("%d", &n);

	for(int i = 1; i <= n; i++){
		ll x;
		scanf("%lld", &x);
		for(int j = 0; j < 60; j++){
			if(x & (1ll<<j)){
				ans += (1ll << j) % mod * (i - 1 - cnt[j]);
				ans %= mod;
				cnt[j]++;
			}
			else{
				ans += (1ll << j) % mod * cnt[j];
				ans %= mod;
			}
		}
	}
	printf("%lld", ans);

return 0;
}

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

int a[10], b[10];

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, g;
  cin >> n >> g;
  for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
  int ans = 1e9;
  for(int i = 0; i < (1 << n); i++) {
    int k = g;
    int res = 0;
    for(int j = 0; j < n; j++) if(i & (1 << j)) {
      k -= (j + 1) * 100 * a[j] + b[j];
      res += a[j];
    }
    for(int j = n-1; j >= 0; j--) if(i & (1 << j)); else {
      if(k <= 0) continue;
      int bu = k / ((j + 1) * 100);
      bu = min(bu, a[j]);
      k -= bu * ((j + 1) * 100);
      if(bu == a[j]) k -= b[j];
      res += bu;
    }
    if(k <= 0) ans = min(ans, res);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int A,B,ans=0;
	cin>>A>>B;
	for(int i=A;i<=B;i++)
	{
		int a=i/10000,d=i%10;
		int b=i/1000-a*10,c=(i%100)/10;
		if(a==d&&b==c)ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

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

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

int main() {
    ll a, b;
    cin >> a >> b;
    int ans = 1;
    ll gcd_num = gcd(a, b);
    ll tmp = gcd_num;
    for (ll i = 2; i * i <= gcd_num; ++i) {
        if (tmp % i == 0) {
            ++ans;
            while(1) {
                if (tmp % i != 0) break;
                tmp /= i;
            }
        }
    }
    if (tmp != 1) ++ans;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
    int N;
    string W[100] = {};
    bool isOK = true;
    int head, tail;

    cin >> N;
    cin >> W[0];

    for(int i = 1; i < N; i++){
        cin >> W[i];
        for(int j = 0; j < i; j++){
            if(W[i] == W[j]){
                isOK = false;
                break;
            }
        }
        tail = W[i - 1].size() - 1;
        if(W[i][0] != W[i - 1][tail])
            isOK = false;
    }

    if(isOK)
        cout << "Yes";
    else 
        cout << "No";

    return 0;
}
        

            

Measured memory_bytes: 256
import collections, math, bisect

local = False
if local:
    file = open("input.txt", "r")
    import time

def inp():
    if local:
        return file.readline().rstrip()
    else:
        return input().rstrip()

def ints():
    return [int(_) for _ in inp().split()]


if local:
    start=time.time()

N, L = ints()
S = [""]*N

for i in range(N):
    S[i] = inp()

S.sort()

ans = []

for s in S:
    ans.append(s)

print("".join(ans))


if local:
    fin = (time.time()-start)*1000
    print("{:.2f}".format(fin) + "ms")





Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define REP2(i, n) for (LL i = 1; i <= (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
 LL a,b,c,d,e,n,m,l,k,r,x,y,z,ans=0,ans2=0,cnt=0;
string s,S,t;
int main() {
ios_base::sync_with_stdio(false);
  cin >> a>>b>>k;
 for ( int i = min (a , b ); i >= 1; --i ) {
      if(a%i==0&&b%i==0){
          --k ;
        if(0==k){
            cout <<i<<endl;
            return 0;
        }
      }
  }
}

Measured memory_bytes: 3632
alp = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
s1 = str(input())
s = []
for i in s1:
    s.append(i)
s = list(set(s))
s.sort()
x = 'None'
for h in alp:
    if h not in s:
        x = h
        break
print(x)


Measured memory_bytes: 9676
fun main(args: Array<String>) {
    abc149d()
}

fun abc149d() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val points = readLine()!!.split(' ').map { it.toInt() }
    val t = readLine()!!.map {
        when (it) {
            'r' -> 2
            's' -> 0
            else -> 1
        }
    }.toIntArray()

    val grouped = t.withIndex().groupBy { it.index % k }
        .map { it.value.map { iv -> iv.value } }

    var answer = 0L

    for (g in grouped) {
        val dp = Array(g.size) { IntArray(3) { 0 } }
        dp[0][g[0]] = points[g[0]]

        for (i in 1..g.lastIndex) {
            val win = g[i]

            for (i2 in 0..2) {
                dp[i][i2] = (0..2).filterNot { it == i2 }.map { dp[i - 1][it] }.max()!! +
                        if (i2 == win) points[win] else 0
            }
        }

        answer += dp.last().max()!!
    }

    println(answer)
}


Measured memory_bytes: 80348
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n, m = map(int, input().split())
g = [[] for _ in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

q = int(input())

query = [list(map(int, input().split())) for _ in range(q)]

color = [0] * n
depth = [-1] * n

def dfs(node, dist, col, pre_node):
    if dist <= depth[node]:
        return
    depth[node] = dist
    if color[node] == 0:
        color[node] = col
    if dist == 0:
        return
    for next_node in g[node]:
        if next_node == pre_node:
            continue
        dfs(next_node, dist-1, col, node)

for v, d, c in query[::-1]:
    v -= 1
    dfs(v, d, c, -1)

for co in color:
    print(co)


Measured memory_bytes: 109856
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
#define Di 3.1415926
#include<math.h>
#define INF 0x3f3f3f3f
using namespace std;
ll  gcd(ll a,ll b)
{
    return a%b? gcd(b,a%b):b;
}

int main()
{
  int a,b,c,t1=0,t2=0;
   cin>>a>>b>>c;
   if(a==5)
   {
       t1++;
   }
   if(a==7)
   {
       t2++;
   }

  if(b==5)
   {
       t1++;
   }
   if(b==7)
   {
       t2++;
   }
    if(c==5)
   {
       t1++;
   }
   if(c==7)
   {
       t2++;
   }
   if(t1==2&&t2==1)
    printf("YES\n");
   else
   {
       printf("NO\n");
   }



 return 0;
}


Measured memory_bytes: 256
import sys
a, b, c = map(int, input().split())
k = int(input())
for i in range(k):
  if a < b and b < c:
    print('Yes')
    sys.exit()
  if a >= b:
    b *= 2
  else:
    c *= 2
if a < b and b < c:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9176
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;

//a, a + 1, a + 2, ... , b - 1, bの総和を求める関数(a <= b)。計算量はO(1)
Int Sum(Int a, Int b) {
	if (b < a)return 0;
	if ((b - a + 1) % 2 == 0)return (a + b) * (b - a + 1) / 2;
	else return (a + b) * ((b - a + 1) / 2) + (a + b) / 2;
}

void calc() {

	Int A, B, C, D; std::cin >> A >> B >> C >> D;
	Int takahashi = (C % B == 0) ? C / B : C / B + 1;
	Int aoki = (A % D == 0) ? A / D : A / D + 1;
	if (takahashi <= aoki)std::cout << "Yes";
	else std::cout << "No";

}


int main() {

	calc();

	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll X, Y;
    cin >> X >> Y;

    if (abs(X - Y) <= 1) {
        put("Brown");
    }
    else {
        put("Alice");
    }
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3604
# C - 

import math

A, B, H, M = map(int, input().split())

sub = abs(360 * ((H * 60 + M) / (12 * 60)) - 360 * (M / 60))
deg = min(sub, 360 - sub)
rad = math.radians(deg)

ans = (A ** 2) + (B ** 2) - (2 * A * B * math.cos(rad))

print(ans ** (1 / 2))


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

#define INF 100100100
#define MOD 1000000007

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

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

struct edge{ll to,cost;};

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0);
   string S;
   cin >> S;
   vector<int>s;
   FOR(i,S.size()){
      s.emplace_back(S[i] - '0');
   }
   vector<ll> bit (1 << (S.size()-1));
   ll ans = 0;
   ll stack;
   for(ll i=0;i<(1 << (S.size()-1));i++){
      stack = s[0];
      for(ll j=1;j<S.size();j++){
         if(i & (1 << (j-1))){
            ans += stack;
            stack = s[j];
         }
         else{
            stack = stack*10 + s[j];
         }


      }

      ans += stack;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _I inline
#define _R register
#define mid ((l)+(r))>>1
#define max(a,b) (a)<(b)?(b):(a)
#define min(a,b) (a)>(b)?(b):(a)
#define abs(a) (a)<0?(-a):(a)
#define swap(a,b) int t=a,a=b,b=t
#define lowbit(i) ((i)&(-i))
#define memset(x,y) memset(x,y,sizeof(x))
#define mod 1000000007
#define INF 0x3f3f3f3f
#define ull unsigned long long
#define ll long long
using namespace std;
//char buf[1<<21],*p1=buf,*p2=buf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
_I int read(){
	int x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9')f|=(ch=='-'),ch=getchar();
	while('0'<=ch&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	f&&(x=-x);
	return x;
}
char s[105];
long long ans,n,m,a[105];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	scanf("%s",s+1);
	n=strlen(s+1);
	m=read();
	a[0]=1;a[1]=1;
	for(_R int i=2;i<=n;++i)if(s[i]==s[i-1])++a[a[0]];else a[++a[0]]=1;
	for(_R int i=2;i<a[0];++i)ans+=m*(a[i]/2);
	if(a[0]==1)return printf("%lld",(m*a[1])/2),0;
	ans+=a[1]/2+a[a[0]]/2;
	if(s[1]==s[n])ans+=(m-1)*((a[1]+a[a[0]])/2);
	else ans+=(m-1)*(a[1]/2+a[a[0]]/2);
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int n,k;
    cin >> n >> k;
    double p=0;
    for(int i=n;i>0;i--){
    //for(int i=0;i<=n;i++){
        for(int j=0;j<k;j++){
            if(i*pow(2,j) >= k){
                p += pow(2,-j)/n;
                break;
            }
        }
    }
    printf("%.12f",p);
    return 0;
}


Measured memory_bytes: 512
from itertools import accumulate
def main():
    N,P=map(int, input().split())
    S=input()
    B=[(ord(c)-ord("0"))%P for c in S]
    ans=0
    if P==2 or P==5:
        for i,b in enumerate(B,1):
            if b==0:
                ans+=i
    else:
        D={0:1}
        x=0
        y=1
        for b in B[::-1]:
            x=(x+(b*y))%P
            D.setdefault(x,0)
            ans+=D[x]
            D[x]+=1
            y=(y*10)%P
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 7396
s = input()

if "N" in s:
    if "S" not in s:
        print("No")
        exit()
if "S" in s:
    if "N" not in s:
        print("No")
        exit()
if "E" in s:
    if "W" not in s:
        print("No")
        exit()
if "W" in s:
    if "E" not in s:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 38256
import sys

s = input()

for i, c in enumerate(s):
    if (i + 1) % 2 == 0 and c in {'L', 'U', 'D'}:
        continue
    elif (i + 1) % 2 == 1 and c in {'R', 'U', 'D'}:
        continue
    else:
        print('No')
        sys.exit()

print('Yes')


Measured memory_bytes: 2940
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n; cin >> n;
	vector<int> v(n), c(n);
	for (int i = 0; i <= n - 1; i++) cin >> v[i];
	for (int i = 0; i <= n - 1; i++) cin >> c[i];

	int ans = INT_MIN;
	for (int mask = 0; mask <= ((1 << n) - 1); mask++) {

		int x = 0, y = 0;

		for (int j = 0; j <= n - 1; j++) {
			if ((mask & (1 << j)) != 0) {
				x += v[j];
				y += c[j];
			}
		}

		ans = max(ans, x - y);
	}

	cout << ans;

	return 0;
}

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


int main()
{
	int a[5], len = 0;
	string st;

	for (int i = 1; i <= 3; i++)
	{
		cin >> a[i];
	}
	
	if (a[3] - a[2] == a[2] - a[1])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0; 
}

Measured memory_bytes: 256
using System;
 
class Test{
 public static void Main(){
   var str = Console.ReadLine().Split(' ');
   double tax8  = double.Parse(str[0]);
   double tax10 = double.Parse(str[1]);
   
   double val8 = Math.Ceiling(tax8 / 0.08);
   double val10 = Math.Ceiling(tax10 / 0.1);
   if(val8 >= val10){
     if(Math.Floor(val8*0.1) == tax10){
       Console.WriteLine(val8);
     }else{
       Console.WriteLine(-1);
     }
   }else{
     if(Math.Floor(val10*0.08) == tax8){
       Console.WriteLine(val10);
     }else{
       Console.WriteLine(-1);
     }
   }
 }
}

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

int main() {
  long long a,b;
  cin >> a >> b;
  if(a > 0) cout << "Positive" << endl;
  else if(b < 0){
    if((b-a)%2 == 0) cout << "Negative" << endl;
    else cout << "Positive" << endl;
  }
  else cout << "Zero" << endl;
}


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

using namespace std;
const int mod = 1e9 + 7;
int pw[200005];
int fact[200005];

void pre() {
    pw[0] = 1;
    fact[0] = 1;
    for (int i = 1; i <= 200003; ++i) {
        pw[i] = (2 * pw[i - 1]) % mod;
        fact[i] = (1ll * fact[i - 1] * i) % mod;
    }
}

int fastpower(int b, int p) {
    int res = 1;
    int v = b;
    while (p) {
        if (p & 1) res = (1ll * res * v) % mod;
        v = (1ll * v * v) % mod;
        p >>= 1;
    }
    return res;
}


int ncr(int n, int r) {
    if (r == 0 || r == n) return 1;
    int res = fact[n];
    res = (1ll * res * fastpower(fact[r], mod - 2)) % mod;
    res = (1ll * res * fastpower(fact[n - r], mod - 2)) % mod;
    return res;
}

int main() {
    //  freopen("in.txt", "rt", stdin);
    pre();
    int n, m, a, b;
    scanf("%d %d %d %d", &n, &m, &a, &b);
    int ans = 0;
    int j = b - 1;

    for (int i = 0; i + a < n; ++i) {
        int v = ncr(i + j, j);
        v = (1ll * v * ncr((n - i - 1 + m - j - 2), n - i - 1)) % mod;
        ans = (ans + v) % mod;
    }
    printf("%d", ans);
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, K;
    cin >> A >> B >> K;
    if (A+K-1 >= B-K+1) {
        REP(i, A, B) cout << i << endl;
    } else {
        REP(i, A, A+K-1) cout << i << endl;
        REP(i, B-K+1, B) cout << i << endl;
    }

    return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll n,m;
    cin>>n>>m;
    vector<ll> a(n);
    ll sm=0;
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
        sm+=a[i];
    }
    sort(all(a));
    reverse(all(a));
    if(a[m-1]*4*m>=sm)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <cctype>
#include <cmath>
#include <climits>
#include <set>
#include <deque>

using namespace std;
using ll = long long;

int main(void) {
	
	int n;
	cin >> n;
	
	vector<ll> a(n + 1), b(n);
	for(int i = 0; i < n + 1; ++i) {
		cin >> a[i];
	}
	
	for(int i = 0; i < n; ++i) {
		cin >> b[i];
	}
	
	ll ans = 0;
	ll tmp = 0;
	for(int i = 0; i < n; ++i) {
		
		tmp = min(a[i], b[i]);
		ans += tmp;
		a[i] -= tmp;
		b[i] -= tmp;
		
		tmp = min(a[i + 1], b[i]);
		ans += tmp;
		a[i + 1] -= tmp;
		b[i] -= tmp;
	}
	
	cout << ans << endl;
	
	return 0; 
}


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

int main(){

  int N,M;

  cin >> N >> M;
  
  if(N == M){
    cout << "Yes";
    return 0;
  }

  cout << "No";
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
 
typedef long long ll;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
//const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;

int main(){
    int h,w;
    std::cin>>h>>w ;
    vvector(c,char,h,w,'0');
    reprep(i,j,h,w)std::cin >> c[i][j];
    std::vector<bool> hh(h,1),ww(w,1);
    rep(i,h){
        bool d=0;
        rep(j,w)if(c[i][j]=='#')d=1;
        if(!d)hh[i]=0;
    }
    rep(i,w){
        bool d=0;
        rep(j,h)if(c[j][i]=='#')d=1;
        if(!d)ww[i]=0;
    }
    rep(i,h){
        rep(j,w){
            if(hh[i]&&ww[j])std::cout << c[i][j];
            
        }
        if(hh[i])std::cout  << std::endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;

/* -- template -- */

int main(){
    int N, M;cin >> N >> M;
    int G[N][N];
    rep(i, N)
        rep(j, N)
            if(i == j)
                G[i][j] = 0;
            else
                G[i][j] = INF;
    int a[M], b[M], c[M];
    rep(i, M){
        cin >> a[i] >> b[i] >> c[i];
        --a[i];--b[i];
        G[a[i]][b[i]] = G[b[i]][a[i]] = c[i];
    }
    for(int k = 0;k < N;++k){
        for(int i = 0;i < N;++i){
            for(int j = 0;j < N;++j){
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
    int ans = 0;
    for(int i = 0;i < M; ++i){
        bool flg = false;
        for(int j = 0; j < N; ++j){
            for(int k = 0; k < N; ++k){
                if(G[j][a[i]] + G[b[i]][k] + c[i] == G[j][k])flg = true;
            }
        }
        if(!flg)ans++;
    }
    cout << ans;
    //cout << G[0][3] << endl;
}


Measured memory_bytes: 256
@n = gets.to_i
@a = gets.split.map(&:to_i)
m = @n.odd? ? 1 : -1

@memo = Array.new(@n) {Array.new(@n)}
@n.times {|i| @memo[i][i] = @a[i] * m}

def calc(i, j)
    return @memo[i][j] if @memo[i][j]

    if (@n - j + i - 1).even?
        x = @a[i] + calc(i+1, j)
        y = @a[j] + calc(i, j-1)
        @memo[i][j] = x > y ? x : y
    else
        x = -@a[i] + calc(i+1, j)
        y = -@a[j] + calc(i, j-1)
        @memo[i][j] = x < y ? x : y
    end
end

p calc(0, @n-1)

Measured memory_bytes: 85104
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int main() {
  int A, N;
  cin >> N >> A;
  if ((N % 500) <= A) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

template <class T>
void show(vector<T> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cerr << v[i] << " ";
    }
    cerr << "\n";
}

template <typename T, class F = function<T(const T &, const T &)>>
class SparseTable
{
public:
    int n;
    vector<vector<T>> mat;
    F func;

    SparseTable(const vector<T> &a, const F &f) : func(f)
    {
        n = static_cast<int>(a.size());
        int max_log = 32 - __builtin_clz(n);
        mat.resize(max_log);
        mat[0] = a;
        for (int j = 1; j < max_log; j++)
        {
            mat[j].resize(n - (1 << j) + 1);
            for (int i = 0; i <= n - (1 << j); i++)
            {
                mat[j][i] = func(mat[j - 1][i], mat[j - 1][i + (1 << (j - 1))]);
            }
        }
    }

    T get(int from, int to) const
    {
        assert(0 <= from && from <= to && to <= n - 1);
        int lg = 32 - __builtin_clz(to - from + 1) - 1;
        return func(mat[lg][from], mat[lg][to - (1 << lg) + 1]);
    }
};

int main()
{
    int n,t;
    cin >> n>>t;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin>>p[i];
    }
    
    SparseTable<int> smin(p, [&](int i, int j) { return min(i, j); });
    SparseTable<int> smax(p, [&](int i, int j) { return max(i, j); });
    vector<int>a(n),b(n);
    for (int i = 0; i < n-1; i++)
    {
        a[i]=p[i]-smax.get(i+1,n-1);
       // cerr << smax.get(i + 1, n - 1) << endl;
    }
    for (int i = 1; i < n; i++)
    {
        b[i]=p[i]-smin.get(0,i-1);
    }
    long long minn=1e18,maxn=-1e18;
    for (int i = 0; i < n; i++)
    {
        minn=min(minn,(long long)a[i]);
        maxn=max(maxn,(long long)b[i]);
    }
    int cnt1=0,cnt2=0;
    for (int i = 0; i < n; i++)
    {
        if(a[i]==minn) cnt1++;
        if(b[i]==maxn) cnt2++;
    }
    cout<<min(cnt1,cnt2)<<endl;
  //  show(a);
  //  show(b);
    
}

Measured memory_bytes: 13696
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key



__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x



if __name__ == '__main__':
    A, B = mulinputs()

    for x in range(10000):
        a = floor(0.08*x)
        b = floor(0.1*x)
        if A == a and B == b:
            print(x)
            exit()
    print(-1)



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

using namespace std;

#define fr first
#define sc second
#define mp make_pair

typedef long long int64;
typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

const int INF = 2 << 28;
const double EPS = 1e-10;

#define MAX 1300000

vector< int > p;
vector< bool > isP(MAX, true);

void makePrime() {
    isP[0] = isP[1] = false;
    for(int i = 2; i * i < MAX; i++)
        for(int j = i + i; j < MAX; j += i)
            isP[j] = false;

    for(int i = 2; i < MAX; i++) {
        if(isP[i]) p.push_back(i);
    }
}

int main() {

    makePrime();

    int k;
    while(cin >> k, k) {
        if(isP[k]) cout << 0 << endl;
        else cout << *upper_bound(p.begin(), p.end(), k) - *(lower_bound(p.begin(), p.end(), k) - 1) << endl;
    }
}

Measured memory_bytes: 1880
a, b, c = map(int, input().split())
if (a == b) & (b == c) & (a%2 == 0):
  print(-1)
else :
  cnt = 0
  while True:
    if (a%2 == 1) | (b%2 == 1) | (c%2 == 1) :
      print(cnt)
      exit()
    cnt += 1
    buf_a = (b+c)//2
    buf_b = (a+c)//2
    buf_c = (a+b)//2
    a = buf_a
    b = buf_b
    c = buf_c


Measured memory_bytes: 3060
nums = int(input())
ary = [0,0]
for i in range(2):
    ary[i] = list(map(int,input().split()))

max = 0

for i in range(nums):
    h = 0
    w = 0
    count = ary[h][w]
    for x in range(nums):
        if i == x :
            h = 1
            count += ary[h][w]
            continue
        w += 1
        count += ary[h][w]
    if count > max :
        max = count
print(max)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int maxAB(int A, int B)
{  if(A>=B){ return 0;}else{return 1;} }

int main(void)
{
  int A[2];
  scanf("%d %d",&A[0], &A[1]);
  int i;   
  int count =0;
  int c;
  for(i=0;i<2;i++){
    c = maxAB(A[0], A[1]) ;
    count += A[c];
    A[c] --;
  }

  printf("%d", count); 
  return (0);
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <limits>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

int main(void) {

	ll N,M;
	cin >> N >> M;

	vector<ll> a(M), b(M), c(M);
	REP(i, M) {
		cin >> a[i] >> b[i] >> c[i];
	}

	ll d[1010];
	d[0] = 0;
	FOR(i, 1, 1010) d[i] = -(1e17);

	ll count = 0;
	ll temp;

	while (count < N*2+1) {

		if (count == N) {
			temp = d[N - 1];
		}

		FOR(i, 0, M){
			d[b[i]-1] = max(d[b[i]-1], d[a[i]-1]+c[i]);
		}

		if (count == (N*2)) {
			break;
		}
		count++;
	}

	if (d[N - 1] > temp) {
		cout << "inf" << endl;
	}
	else {
		cout << d[N - 1] << endl;
	}


	return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int n;
  cin >> n;
  deque<int> d;
  for (int i = 1; i <= n; i++) {
    int t; cin >> t;
    if (i % 2) d.push_back(t);
    else d.push_front(t);
  }
  if (n % 2) reverse(all(d));
  for (auto &i : d) cout << i << ' ';
  cout << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 5204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const int maxn = 200005;
int ans[10005];
int main()
{
	int n;
	for(int x=1;x<100;x++)
		for(int y=1;y<100;y++)
			for(int z=1;z<100;z++){
				int k=x*x+y*y+z*z+x*y+x*z+y*z;
				// cout<<x<<' '<<y<<' '<<z<<' '<<k<<endl;
				if(k<=10000)
					ans[k]++;
				else 
					break;
			}
	cin>>n;
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

struct UnionFind {
    vector<int> par;// par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  
    UnionFind(int N): par(N) {
        for (int i = 0; i < N; i++) par[i] = i; // 初期では親は自分自身
    }
  
    void init(int N) {
        par.resize(N);
        for (int i = 0; i < N; i++) par[i] = i; // 初期では親は自分自身
    }
  
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
        //return par[x];
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
  
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならfalseを返す
        int rx = root(x);
        int ry = root(y);
        return rx != ry;
    }
};

int main() {
    float N, M;
    cin >> N >> M;
  
    vector<vector<float>> data(M, vector<float>(3));//input　　
    float ans;
    ans = 1;
  
    for(int i = 0; i < M; i++) {
        float x, y, z;
        cin >> x >> y >> z;
        data[i][0] = x;
        data[i][1] = y;
        data[i][2] = z;
    }
  
    UnionFind tree(N + 1);
      
    for (int i = 0; i < M; i++) {
      //tree.init(N + 1);//毎回ツリーを初期化
      //cout << i << endl;
      tree.unite(data.at(i).at(0), data.at(i).at(1));
    }
    
    for (int i = 2; i <= N; i++) {
      //tree.init(N + 1);//毎回ツリーを初期化
      //cout << i << endl;
      if (tree.same(1, i)) {
        ans += 1;
        tree.unite(1, i);  
      }
      //cout << ans << endl;
    }
    cout << ans << endl;
  
    return 0;
}


Measured memory_bytes: 10164
import bisect
import math
N, A, B = map(int, input().split())
v = sorted(list(map(int, input().split())))
ave = sum(v[-A:]) / A
print(ave)
leftA = bisect.bisect_left(v, v[-A])
rightA = bisect.bisect_right(v, v[-A])

def comb(n, r):
    return math.factorial(n) // math.factorial(r) // math.factorial(n-r)

ans = 0
if v[-A] == v[-1]:
    for i in range(A, min(rightA-leftA, B) + 1):
        ans += comb(rightA-leftA, i)
    print(ans)
else:
    print(comb(rightA-leftA, A+rightA-N))

Measured memory_bytes: 3064
/*
Author: CNYALI_LK
LANG: C++
PROG: a.cpp
Mail: cnyalilk@vip.qq.com
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define all(x) x.begin(),x.end()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const signed inf=0x3f3f3f3f;
const double eps=1e-8;
const double pi=acos(-1.0);
template<class T>int chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>int chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
template<class T>int dcmp(T a,T b){return a>b;}
template<int *a>int cmp_a(int x,int y){return a[x]<a[y];}
#define min mmin
#define max mmax
#define abs aabs
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	inline void read (signed &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}

	inline void read (long long &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}
	inline void read (char &x) {
		x=gc();
	}
	inline void read(char *x){
		while((*x=gc())=='\n' || *x==' '||*x=='\r');
		while(!(*x=='\n'||*x==' '||*x=='\r'))*(++x)=gc();
		*x=0;
	}
	template<typename A,typename ...B>
	inline void read(A &x,B &...y){
		read(x);read(y...);
	}
	// print a signed integer
	inline void write (signed x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}

	inline void write (long long x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	inline void write (char x) {
		putc(x);
	}
	inline void write(const char *x){
		while(*x){putc(*x);++x;}
	}
	inline void write(char *x){
		while(*x){putc(*x);++x;}
	}
	template<typename A,typename ...B>
	inline void write(A x,B ...y){
		write(x);write(y...);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: read;
using io :: putc;
using io :: write;
int c[256];
char s[2333];
int main(){
#ifdef cnyali_lk
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
#endif
	read(s);	
	for(int i=0;s[i];++i)c[s[i]]=1;
	write((c['N']==c['S'] && c['E']==c['W'])?"Yes\n":"No\n");
	return 0;
}



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

using namespace std;

const int MAX_N = 100000;
const int MAX_M = 100000;
int cnt[MAX_N+1];
int A[MAX_N],B[MAX_N],C[MAX_N];

int P[MAX_M];

int N,M;

int main(){
	scanf("%d%d",&N,&M);
	for(int i=0;i<M;i++){
		scanf("%d",P+i);
	}
	for(int i=0;i<N-1;i++){
		scanf("%d%d%d",A+i,B+i,C+i);
	}
	for(int i=0;i<M-1;i++){
		int x=P[i],y=P[i+1];
		if(x>y) swap(x,y);
		x--;
		y--;
		cnt[x]++;
		cnt[y]--;
	}
	for(int i=1;i<N;i++){
		cnt[i]+=cnt[i-1];
	}
	long long ans=0;
	for(int i=0;i<N-1;i++){
		long long paper=(long long)A[i]*cnt[i];
		long long ic=(long long)B[i]*cnt[i]+C[i];
		ans+=min(paper,ic);
	}
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 4640
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		for (int i=1;i<1000;i++) {
			if (360*i%X == 0) {
				System.out.println(360*i/X);
				return;
			}
		}
	}
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    int a ;
    cin >> a ;

    int ans = a + a*a + a*a*a ;
    cout << ans ; line ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


Measured memory_bytes: 3632
using System;
using System.IO;
using System.Text;

class Program{
    static void Main(string[] args){
        var N = Convert.ToString(int.Parse(Console.ReadLine()),2);
        var sb = new StringBuilder();
        sb.Append("1");
        for (int i = 0; i < N.Length - 1; i++) sb.Append("0");
        var answer = Convert.ToInt32(sb.ToString(), 2);
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 27584