akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;

int main(){
    int n, m, h, k;
    while(scanf("%d %d %d %d", &n, &m, &h, &k), n){
        vector<int> p(n);
        for(int i = 0; i < n; i++)  scanf("%d", p.begin()+i);

        vector<int> bar[1000];
        for(int i = 0; i < m; i++){
            int a, b;
            scanf("%d %d", &a, &b);
            bar[b].push_back(a);
        }

        for(int i = h-1; i >= 1; i--){
            for(int j : bar[i]) swap(p[j-1], p[j]);
        }

        vector<int> pos(n, -1);
        for(int i = 0; i < k; i++)  pos[i] = i;

        int ans = 0;
        for(int i = 0; i < n; i++) if(pos[i] != -1) ans += p[i];
        
        for(int i = 1; i <= h-1; i++){
            for(int j : bar[i]){
                swap(p[j-1], p[j]);
                int tmp = 0;
                for(int x = 0; x < n; x++){
                    if(pos[x] != -1)    tmp += p[x];
                }
                ans = min(ans, tmp);
                swap(p[j-1], p[j]);
            }
            for(int j : bar[i]){
                swap(p[j-1], p[j]);
                swap(pos[j-1], pos[j]);
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main  ()
{
    int N,R,res=0;


         cin>>N>>R;


         if(N>=10)
         {cout<<R<<endl;}
         else if(N<10)
            {
             res=R+(100*(10-N));
             cout<<res<<endl;
             }




}


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

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


long long MOD = 1000000007;

int main() {

    long long N;
    cin >> N;

    vector<long long> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    map<long long, long long> M;
    for (auto x : A) M[x]++;

    bool good = true;
    if (N % 2 == 0) {
        for (int i = 1; i <= N; i += 2) if (M[i] != 2) good = false;
    }
    if (N % 2 == 1) {
        if (M[0] != 1) good = false;
        for (int i = 2; i <= N; i += 2) if (M[i] != 2) good = false;
    }
    if (!good) {
        cout << 0;
        return 0;
    }

    long long ans =1 ;
    for(int i = 0;i<N/2;i++) ans *= 2, ans %= MOD;
    cout << ans;

    return 0;
}





























































Measured memory_bytes: 6144
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root=NIL;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

 
Node treeSearch(Node u, int k){
  if (u == NIL ||  k == u->key){
    return u;
  }
  else if (k < u->key){
    return treeSearch(u->left,k);
  }
  else return treeSearch(u->right,k);
}
  
Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL){
    return treeMinimum(x->right);
  }
  y = x->parent;
  while( y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}
  

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  Node r = root;

  if(z->left == NIL || z->right == NIL) y =z;

  else y = treeSuccessor(z);

  if(y->left != NIL )x = y->left;

  else x = y->right;

  if (x != NIL)x->parent = y->parent;

  if (y->parent == NIL)r=x;

  else if (y == y->parent->left)y->parent->left = x;

  else y->parent->right = x;

  if ( y != z)z->key =y->key;

}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
     
    while(x/*->key*/ != NIL){
        y=x;
        if(z->key < x->key)x=x->left;
        else x=x->right;
    }
        z->parent=y;
        if (y==NIL)root=z;
        else if(z->key < y->key)y->left=z;
        else y->right = z;
}
 
void inorder(Node u){
    if(u->left != NIL){
        inorder(u->left);
    }
        printf(" %d",u->key);
    if(u->right != NIL){
        inorder(u->right);
    }
 
}
void preorder(Node u){
    printf(" %d",u->key);
    if(u->left != NIL){
        preorder(u->left);
    }
    if(u->right != NIL){
        preorder(u->right);
    }
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      //return 0;
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }  else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
 
  return 0;
}

Measured memory_bytes: 19364
N = int(input())
A = list(map(int,input().split()))

for i in range(1,N+1):
    A[i-1] -= i
sA = sorted(A)

def sadness(b):
    global A
    s = 0
    for i, a in enumerate(A):
        s += abs(a-b)
    return s

print(sadness(sA[len(A)//2]))

Measured memory_bytes: 88148
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	char ca, cb;
	cin >> ca >> cb;
	bool a = (ca == 'H'), b = (cb == 'H');
	if((a && b)|| (!a && !b)) cout << 'H' << endl;
	else cout << 'D' << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define ll long long
using namespace std;
#define MOD 1000000007

int main() {
    int N,W;
    int sum = 0;
    ll ans;
    cin >> N >> W;
    vector<int> vect(N);
    vector<ll> dp_old(W+1,0),dp(W+1,0);
    for(int i=0 ; i<N ; i++){
        cin >> vect[i];
        sum += vect[i];
    }
    sort(vect.begin(),vect.end(),greater<int>());
    dp_old[0] = 1; 
    for(int i=0; i< N; i++){
        sum -= vect[i];
        for(int j=max(W-sum-vect[i]+1,0); j <= W-sum ; j++){
            ans = (ans + dp_old[j])%MOD;
            //dp[j] = 0;
        }
        for(int j=0; j<=W ;j++){
            if ( j-vect[i] >= 0){
                dp[j] = (dp_old[j]%MOD) + (dp_old[j-vect[i]]%MOD);
            } else {
                dp[j] = dp_old[j];
            }
        }
        swap(dp,dp_old);
    }

    if(ans==0) ans = 1;
    cout << ans << endl;

    return 0;
}



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

int main() {
  int64_t N, h, n, w;
  int a = n = h = w =1;
  cin >> N;
  for(h=1; h<=3500; h++){
    for(n = h; n<=3500; n++){
      if(4*h*n-N*(h+n)>0){
      if(N*h*n%(4*h*n-N*(h+n))==0){
        w = N*h*n/(4*h*n-N*(h+n));
        if(w!=0){
        int a =0;
        goto SKIP;
        }
      }
      }
    }
  }
  
  SKIP:
  
  cout << h << " " << n << " " << w <<endl;
        
}

Measured memory_bytes: 3600
//INOI 2013 - Calvin's Game
//https://www.codechef.com/INOIPRAC/problems/INOI1301

//Submission Link : https://www.codechef.com/viewsolution/28715845

#include <iostream>
#include <cmath>
#include <vector>
#include <climits>
using namespace std;

#define rep(i,a,b) for(auto (i)=a;i<b;i++)
#define list(i,N) for(auto (i)=0;i<N;i++)
#define int long long
typedef long long ll;
int n, m;
vector<int> adj[100005];
int dp[1000005];
int f(int i){
    if(dp[i]>=0) return dp[i];
    dp[i] = 0;
    for(int j: adj[i]) dp[i] = max(dp[i], f(j));
    dp[i]++;
    return dp[i];
}
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n>>m;
    for(int i = 0;i<m;i++){
        int x, y;
        cin>>x>>y;
        adj[x].push_back(y);
    }
    for(int i = 0;i<=n;i++) dp[i] = -1;
    int maxi = 0;
    for(int i = 1;i<=n;i++) maxi = max(maxi, f(i));
    cout<<(maxi-1)<<endl;
    return 0;
}



Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  map<int,int> mp;
  for(int i=0;i<n;++i){
    int curr;cin>>curr;
    mp[curr]++;
  }
  // case
  if(mp.size()==1 && mp[0]>0){
    cout<<"Yes"<<endl;
  }else if(mp.size()==3 && n%3==0){
    vector<int> arr;
    bool f = true;
    for(auto i:mp){
      if(i.second != n/3){
        f = false;
      }
      arr.push_back(i.first);
    }
    if((arr[0]^arr[2]^arr[1]) != 0 ){
      f = false;
    }
    if(f){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }else if (mp.size()==2 && n%3==0 && mp[0]==n/3){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3840
/*  In the name of ALLAH */

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define int long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define w(x) int x;cin>>x;while(t--)
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int POSITIVE_INFINITY = 9223372036854775807;
const int NEGATIVE_INFINITY = -9223372036854775807;
const int MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __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...);
}
#else
#endif



int32_t main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
  
    int n,m;
    cin>>n>>m;
    vector<string> g(n);
    rep(i,0,n)cin>>g[i];
    vector<vector<int>>dp(n,vector<int>(m,numeric_limits<int>::max()));
    dp[0][0] = (g[0][0]=='#');
    for(int i = 0 ; i < n;i++){
        for(int j =  0 ; j < m;j++){
         if(i+j==0)continue;
          if(i-1>=0)  dp[i][j] = min(dp[i][j], dp[i-1][j] + (g[i - 1][j] == '.' && g[i][j] == '#'));
          if(j-1>=0)  dp[i][j] = min(dp[i][j], dp[i][j-1] + (g[i][j - 1] == '.' && g[i][j] == '#'));
        }
    }

    cout<<dp[n-1][m-1]<<endl;
 

 
    
 
    return 0;
}


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

// n ??\????????´??°???k????????£????????????s??????????????????????????????????????????

int main() {
    int N, K, S;
    while (cin >> N >> K >> S and (N or K or S)) {
        int dp[30][30][300];
        fill(dp[0][0], dp[30][0], 0);
        dp[0][0][0] = 1;
        for (int i=1; i<=N; ++i) {
            for (int j=0; j<=K; ++j) {
                for (int k=0; k<=S; ++k) {
                    if ( k - i >= 0 and j != 0 ) dp[i][j][k] += dp[i-1][j-1][k-i];
                    dp[i][j][k] += dp[i-1][j][k];
                }
            }
        }
        cout << dp[N][K][S] << endl;
    }
}

Measured memory_bytes: 4012
#include <stdio.h>

int main(){
    int H,W;
    scanf("%d %d",&H,&W);
    char can[H][W+1];
    for(int i=0;i<H;i++){
        for(int j=0;j<=W;j++){
            scanf("%c",&can[i][j]);
        }
    }
    for(int i=0;i<H;i++){
        for(int j=1;j<=W;j++){
            if(can[i][j]==35){
                if(j==1||i==0)continue;
                if(can[i-1][j]==35||can[i][j-1]==35)continue;
                if(j==W||i==H-1)continue;
                if(can[i][j+1]==35||can[i+1][j]==35)continue;
                printf("No");
                return 0;
            }
        }
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 128
a = list(map(int,input().split()))
n = a[0]
k = a[1]
q = a[2]
n_list = [0]*n
for i in range(q):
  seikaisha = int(input())
  n_list[seikaisha-1] += 1
  #print(n_list)
for j in range(n):
  if n_list[j]+k-q > 0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 4680
#include <iostream>

using namespace std;

int main(){
    int N,M,X,Y;

    cin >> N >> M >> X >> Y;

    int x[N],y[M];

    for(int i = 0; i < N; i++)
        cin >> x[i];
    
    
    for(int i = 0 ; i < M; i++)
        cin >> y[i];
    
    for(int z = X+1; z <= Y; z++){
        bool flag = true;
        for(int i = 0; i < N; i++){
            if(x[i] >= z){
                flag = false;
                break;
            }
        }
        if(!flag)
            continue;
        
        for(int i = 0 ; i < M; i++){
            if(y[i] < z){
                flag = false;
                break;
            }    
        }

        if(flag){
            cout << "No War" <<  endl;
            return 0;
        }
    }

    cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    n=int(input())
    A=list(map(int,input().split()))
    X,Y=[0]*n,[0]*n
    for i in range(n):
        X[i]=i+A[i]
        Y[i]=i-A[i]
    set_x=set(X)
    yc=Counter(Y)
    xc=Counter(X)
    ans=0
    for x in set_x:
        ans+=xc[x]*yc[x]
    print(ans)

if __name__=='__main__':
    main()

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

int n;
vector<int> g[100005];

map<pair<int,int>,int> mp;

void dfs(int node,int par,int skip)
{
	int c=1;
	for(auto i:g[node])
	{
		if(i==par)
			continue;
		if(c==skip)
			c++;
		mp[{node,i}]=c;
		dfs(i,node,c);
		c++;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n;	
	int maxi=0;
	pair<int,int> pi[n-1];
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		pi[i]={a,b};
		g[a].push_back(b);
		g[b].push_back(a);
		int ma = max(g[a].size(),g[b].size());
		maxi = max(maxi,ma);
	}
	cout<<maxi<<"\n";
	
	dfs(1,0,0);
	
	for(int i=0;i<n-1;i++)
		cout<<mp[pi[i]]<<"\n";
	
	
}

Measured memory_bytes: 14080
N = gets.to_i
ary = N.times.map{gets.split.map(&:to_i)}
min_list = ary.map{|a| a.min}.sort
max_list = ary.map{|a| a.max}.sort
if N.odd?
    ret = max_list[(N+1)/2 - 1] - min_list[(N+1)/2 - 1] + 1
else
    ret = max_list[N/2-1] + max_list[N/2] - (min_list[N/2-1] + min_list[N/2]) + 1
end
puts ret

Measured memory_bytes: 36060
//Volume0-0080
import java.util.*;

public class Main {

	public static void main(String[] args) {

		//declare
		final int END = -1;
		double    q,x;

		//input
		Scanner sc = new Scanner(System.in);
		while((q = sc.nextDouble()) != END){
			
			//calculate
			x = q / 2;
			while(true){
				x = x - ((Math.pow(x,3) - q) / (3 * Math.pow(x,2)));
				if(Math.abs(Math.pow(x,3) - q) < 0.00001 * q){
					break;
				}
			}
			
			//output
			System.out.printf("%.6f\n", x);
		}
	}
}

Measured memory_bytes: 18920
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int  n, k, ans=0;
  cin >> n >> k;
  vector<bool> check(n);
  for(int i=0;i<n;i++){
    check[i]=0;
  }
  for(int i=0;i<k;i++){
    int d;
    cin >> d;
    vector<int> a(d);
    for(int j=0;j<d;j++){
      cin >> a[j];
      if(check[a[j]-1] == 0){
        check[a[j]-1] =1;
      }
    }
  }
  for(int i=0;i<n;i++){
    if(check[i]==0){
      ans++;
    }
  }
  
  
  cout << ans <<endl;
}


Measured memory_bytes: 3632
#ABC159B
import sys
s = sys.stdin.readline().rstrip()
n = len(s)
#print(s)
#print(n)
a = s[:int((n-1)/2)]
b = s[int((n+3)/2-1):]

if s == s[::-1]:
    if a == a[::-1] and b == b[::-1]:
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 3060
#include <cstdio>
using namespace std;
int n,m;
int arr[100005];
int main(){
    scanf("%d%d",&n,&m);
    int a,b;
    for (int x=0;x<m;x++){
        scanf("%d%d",&a,&b);
        arr[a]++;
        arr[b]++;
    }
    
    for (int x=0;x<n;x++){
        if (arr[x]&1) {
            printf("NO\n");
            return 0;
        }
    }
    
    printf("YES\n");
}

Measured memory_bytes: 512
/*
  AOJ #3129
  title:Contest T-shirts
  @kankichi57301
  2020/02/28 
 */
#include <stdio.h>
#define min(x,y) (((x)<(y))?(x):(y))

int n,m;
int main()
{
  int i,c,c0,r,ret;
  scanf("%d %d",&m,&n);
  ret=r=0;

  if(m==2)
  {
      for(i=0;i<n;i++)
      {
	scanf("%d",&c);
	if((c-1)== (i & 1))
	   r++;
      }
      //printf("n=%d:r=%d\n",n,r);
      ret = min(r,n-r);
  }
  else
  {
    scanf("%d ",&c0);
    for(i=1;i<n;i++)
    {
      scanf("%d",&c);
      if(c == c0)
	ret++,c0=0;
      else
	c0=c;
    }
  }
  printf("%d\n",ret);
 
  return(0);
}



Measured memory_bytes: 2120
/** By @ZhakudaMagzhan **/

/*
# pragma comment(linker, "/stack:20000000")
# pragma GCC optimize("Ofast,no-stack-protector")	
# pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") // */

# include <bits/stdc++.h>

# define fi first
# define se second

# define y1   WENAO
# define endl "\n"
# define ioi  exit(0)  /* 2019 */

# define mp make_pair
# define pp pop_back	
# define pb push_back

# define ub upper_bound
# define lb lower_bound

# define sz(x)   (int)x.size()
# define all(x)  x.begin(), x.end()
# define bit(x)  __builtin_popcountll(x)
# define CLOCK   clock()/(double)CLOCKS_PER_SEC
# define uniq(x) x.resize(unique(all(x))-x.begin())

/*
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
# include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;

typedef tree < int, null_type, less < int >, rb_tree_tag,
tree_order_statistics_node_update > ordered_set; // find_by_order(), order_of_key(). */

using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

typedef pair <ll, ll> pll;
typedef pair <int,int> pii;

typedef vector <ll>  vll;
typedef vector <int> vi;
typedef vector <pii> vpii;


const int inf = (int) 2e9, mod = (int) 1e9 + 7;
const ll linf = (ll) 2e18;

/*
int mult (int x, int y) { return ((ll)x * y) % mod; } 
int sub  (int x, int y) { x -= y; if (x < 0) return x + mod; return x; } 
int add  (int x, int y) { x += y; if (x >= mod) return x - mod; return x; } //*/

const int maxn = (int) 1e5 + 666, maxn2 = (int) 1e6 + 666;

int n, m;
int was[maxn], x[maxn];
vector <pii> g[maxn];

void dfs (int v, int add = 0) {
	if (was[v]) {
		if (x[v] != add) {
			cout << "No";
			ioi;
		}
		return;
	}
	x[v] = add;
	was[v] = true;
	for (auto go: g[v]) {
		int to = go.fi;
		int cost = go.se;
		dfs (to, add + cost);
	}
}
                         
int main () {
	#define FN "" // zverskii raper		
	#ifdef GOLD
		freopen (FN".in", "r", stdin);
		freopen (FN".out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
	/*unsigned int FOR; asm("rdtsc" : "=A"(FOR)); srand(FOR); // */	
	cin >> n >> m;
	for (int i = 1; i <= m; ++ i) {
		int u, v, d;
		cin >> u >> v >> d;
		g[u].pb (mp (v, d));
		g[v].pb (mp (u, -d));
	}

	for (int i = 1; i <= n; ++ i) {
		if (!was[i]) {
			dfs (i);
		}
	}

	cout << "Yes";
	return 0;
}


/* Jocelyn Flores */
	

Measured memory_bytes: 11520
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

vector<P> A;
_int used[1<<18][51];
Int mem[1<<18][51];
Int dfs(Int bitA, Int num){
  if(bitA == (1<<A.size())-1)return 0;
  if(used[bitA][num]++) return mem[bitA][num];

  Int res = INF;
  Int c = 0;
  Int x = __builtin_popcount(bitA)&1;
  Int rev = x;
  for(Int i=0;i<(Int)A.size();i++){
    if(bitA>>i&1) {rev = !rev; continue;}
    Int nnum = (rev + c)%2== 0? A[i].first:A[i].second;
    c++;
    //pr(c, bitA, num, nnum, A[i]);
    if(nnum < num) continue;
    Int nbitA = bitA | (1<<i);
    Int cost = dfs(nbitA, nnum) + c - 1;
    Min(res, cost);

  }

  return mem[bitA][num]= res;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  Int N;
  cin>>N;
  vector<Int> tmpA(N), tmpB(N);
  cin>>tmpA;
  cin>>tmpB;
  for(Int i=0;i<N;i++){
    Int a = tmpA[i], b = tmpB[i];
    A.push_back(P(a, b));
  }

  Int ans = dfs(0, 0);
  if(ans == INF) ans = -1;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 156928
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a%m+b%m);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a%m-b%m);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}
//	x<<1 => x*2		x>>1 => x/2;	cout<<flush;
//	cout<<fixed<<setprecision(10)<<ans<<endl;

void solve()
{
	int a,b,x,n=0;
	cin >> a >> b >> x ;
	for(int i=a;i<=b;i++){
	    if(i%x==0)n++;
	}
	cout << n<< endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}

Measured memory_bytes: 3644
import java.util.*;

public class Main {

  static Scanner scan = new Scanner(System.in);

  public static void main(String[] args) {
    int h1 = scan.nextInt();
    int a1 = scan.nextInt();
    int h2 = scan.nextInt();
    int a2 = scan.nextInt();

    int i = 0;

    while (h1 > 0 && h2 > 0) {
      if (i == 0) {
        h2 -= a1;
        i = 1;
      }
      else {
        h1 -= a2;
        i = 0;
      }
    }

    System.out.println(h1 > 0 ? "Yes" : "No");
  }
}


Measured memory_bytes: 27084
#include <iostream>

using namespace std;

struct set_type{
	int rank;
	int parent;
};

int find(set_type subsets[], int i){
	if(subsets[i].parent != i){
		subsets[i].parent = find(subsets, subsets[i].parent);
	}
	return subsets[i].parent;
}

void unite(set_type subsets[], int i, int j){
	int i_root = find(subsets, i);
	int j_root = find(subsets, j);
	if(subsets[i_root].rank > subsets[j_root].rank){
		subsets[j_root].parent = i_root;
	}else if(subsets[i_root].rank < subsets[j_root].rank){
		subsets[i_root].parent = j_root;
	}else{
		subsets[i_root].parent = j_root;
		subsets[j_root].rank++;
	}
}

int main(){
	int n;
	cin >> n;
	set_type subsets[n];
	for(auto i = 0; i < n; ++i){
		subsets[i] = {0, i};
	}

	int q;
	cin >> q;
	for(auto i = 0; i < q; ++i){
		int cmd_type;
		int x, y;
		cin >> cmd_type >> x >> y;
		if(cmd_type == 0){
			unite(subsets, x, y);
		}else if(cmd_type == 1){
			int is_same = find(subsets, x) == find(subsets, y);
			cout << is_same << endl;
		}
	}
}


Measured memory_bytes: 3188
import sys
import numpy as np
import itertools
input = sys.stdin.readline

n, d = map(int, input().split())
a = [[int(i) for i in input().split()] for n in range(n)]
count = 0

for i in list(itertools.combinations(a, 2)):
  length = 0
  i = np.array(list(i))
  for j in np.array(i[0]-i[1]):
    length += j**2
  if np.sqrt(length).is_integer():
    count+=1
print(count)

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

int left, right, ans;
int cnt[2019], min[2];

int main() {
    scanf("%d%d", &left, &right);
    right = std::min(right, left + 2019);
    ans = 2019;
    for (int i = left; i <= right ; ++i) {
        for (int j = i + 1; j <= right; ++j) {
            ans = std::min(ans, (i % 2019) * (j % 2019) % 2019);
        }
    }
    printf("%d", ans);
    return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acos(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

#define DEBUG

ll p(ll n)
{
	if(n == 1) return 0;
	return (n - 1) + p(n - 1);
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n; cin >> n;
	vector<string> s(n);
	rep(i, n) cin >> s[i];

	unordered_map<string, ll> um;
	rep(i, n)
	{
		sort(all(s[i]));
		um[s[i]]++;
	}


	ll ans = 0;
	for(auto a : um)
	{
		if(a.second == 1) continue;
		ans += p(a.second);
	}

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

Measured memory_bytes: 16036
#include<bits/stdc++.h>
using namespace std;
double a[200005];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		double t;
		cin>>t;
		a[i]=(1.0+t)/2.0;
	}
	double sum=0,maxn=0;
	for(int i=1;i<=n;i++){
		if(i<=k){
			sum+=a[i];
		}
		else{
			sum=sum-a[i-k]+a[i];
		}
		maxn=max(maxn,sum);
	}
	printf("%.7lf",maxn);
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
 
using namespace std ;
 
typedef double D ;
typedef long long ll ;
typedef long double ld ;
typedef unsigned int ui ;
typedef unsigned long long ull ;
 
# define F first
# define S second
# define R return
# define C continue 
# define pb push_back 
# define pf push_front
# define mp make_pair
 
# 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 vi vector <int>
# define vb vector <bool>
# define vll vector <ll>
# define vs vector <string>
 
# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >
 
# 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 Fi(i,L,R) for (int i = L ; i <= R ; i++)
# define Fd(i,R,L) for (int i = R ; i >= L ; i--)
# define fast ios_base :: sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0)
 
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))
 
const ld PI = 3.1415926535897932384626 ;
const ll MOD = 1e9 + 7 ;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve ()
{
  ll n ;
  cin >> n ;
  ll h1 = n / 500 ;
  ll ans = 0 ; 
  ans += h1*1000 ;
  ll h1r = n % 500 ;
  ll h2r = h1r / 5 ;
  ans += h2r*5 ;
  cout << ans ;
}
 
int main()
{
	//freopen ("input.txt","r",stdin) ;
	//freopen ("output.txt","w",stdout) ;
	fast ;
	int t = 1 ;
//	cin>>t ;
	while (t--) 
	  solve () ;
	return 0 ;
}


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

const int MAXN = 200005;

char s[MAXN];
int n;

int main(){
	scanf("%s", s);
	n = strlen(s);
	
	int cnt = 0;
	long long sum = 0;
	
	for(int i = 0; i < n; i++){
		if(s[i] == 'B'){
			cnt++;
			sum -= i;
		}
	}
	
	for(int i = n - cnt; i < n; i++){
		sum += i;
	}
	
	printf("%lld\n", sum);
	
	return 0;
}


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

typedef long long ll;
#pragma GCC optimize ("Ofast")
#define rep(i,a,b) for(ll i = (a); i < (b); ++i)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define pb push_back
#define fs first
#define sc second
#define MOD 1000000007
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

int main()
{
    ll n;
    cin >> n;
    vi A(n);
    ll mx1 = -10000000;
    ll mx2 = -10000000;
    ll mx1ind = 0;
    ll mx2ind = 0;
    rep(i,0,n){
        cin >> A[i];
    }
    rep(i,0,n){
        if(A[i] > mx2){
            if(A[i] > mx1){
                mx2 = mx1;
                mx1 = A[i];
                mx1ind = i;
            }else{
                mx2 = A[i];
                mx2ind = i;
            }
        }
    }
    rep(i,0,n){
        if(i == mx1ind) cout << mx2 << endl;
        else cout << mx1 << endl;
    }
}


Measured memory_bytes: 3200
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <set>
#include <cassert> //assart
using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
const int  MOD=1000000007;
const int  INF=2000000000;
const int INF2=  10000000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INF2){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
#define br printf("\n");
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}

int printintN(int array[],const int num){
    for(int i=0;i<num;i++){printf("%d ",array[i]);}
    br;
    return 0;
}


//#define int long long int

/*
 1.困った時こそ冷静に問題文を見直す！制約条件を見ろ！乱択アルゴリズムとかO(N^3)とか！
 2.一度に大量のことをやろうとしない。デバッグしやすいように細かく！
 3.プログラミングは半分数学だし、もう半分は数学ではない！
 4.できない問題はできない！！！！！
 */

int experiment(){
    int A,B;
    scanf("%d %d",&A,&B);
    int ans;
    if(A>12){ans=B;}
    else if(6<=A and A<=12){ans=B/2;}
    else /* A<=5 */ {ans=0;}
    printf("%d\n",ans);
    return 0;
}
signed main(){
    assert(1);
    experiment();
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int n;
  std::cin >> n;
  int a[3][110];
  int sum1=0;
  for(int i=0; i<n; i++){
    std::cin >> a[1][i];
    sum1+=a[1][i];
  }
  for(int i=0; i<n; i++){
    std::cin >> a[2][i];
  }
  int max=0;
  for(int i=0; i<n; i++){
    int p=0;
    for(int j=i+1; j<n; j++) p+=a[1][j];
    int gyou1=sum1-p;
    int gyou2=0;
    for(int k=i; k<n; k++) gyou2+=a[2][k];
    if(max<gyou1+gyou2) max=gyou1+gyou2;
  }
  std::cout << max << '\n';
  return 0;
}


Measured memory_bytes: 256
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
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

ans = ""
for i in range(3):
    s = input()
    ans += s[i]
print(ans)


Measured memory_bytes: 27044
import Data.List
main = interact $ unlines . map (show . maximum_sum_seq) . groupProb . map read . lines

groupProb [] = []
groupProb (0:_) = []
groupProb (n:ns) = (take n ns) : groupProb (drop n ns)

maximum_sum_seq ns = if all (<0) (tail ns') then maximum ns else maxgain
 where
  maxgain= maximum $ map (\xs -> maximum xs - head xs) $ init $ tails ns'
  ns' = scanl (+) 0 ns

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

typedef long long ll;
typedef vector<long long> vl;
typedef pair<long , long> pll;
typedef vector< pll > vll;
typedef set<ll> sl;
typedef map<string, int> msi;

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define inf 0x3f3f3f3f
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))

const ll md = 1000000007;
//void mod(ll &x){if (x >= md) x -= md; if (x < 0) x += md;}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,k,i,j;
	cin>>n>>k;
	bool dp[100005];
	memset(dp,false,sizeof(dp));
	ll arr[n+1];
	for(i=1;i<=n;i++){
		cin>>arr[i];
	}
	dp[0] = false;
	for(i=1;i<=k;i++){
		for(j=1;j<=n;j++){
			if(i-arr[j]>=0){
				dp[i] = dp[i] | !dp[i-arr[j]];
			}
		}
	}
	if(dp[k])
		cout<<"First";
	else 
		cout<<"Second";
    return 0;
}




Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int num[10];
int n,l,k,temp;
int maxn,minn;
int a[21];
int ans1,ans2,ans3;
int main(){
	while(1){
		cin >> n>>l;
		if(!(n||l))break;
		a[0]=n;
		k=0;
		temp=0;
		while(1){
			temp=a[k];
			for(int i=0;i<l;i++){
				num[i]=temp%10;
				temp=temp/10;
			}
			sort(num,num+(l));
			maxn=minn=0;
			for(int i=0;i<l;i++){
				maxn=maxn*10+num[l-1-i];
				minn=minn*10+num[i];
			}
			k++;
			a[k]=maxn-minn;
			for(int i=0;i<k;i++){
				//cout <<a[i] <<endl;
				if(a[k]-a[i]==0){
					ans1=i;
					ans2=a[k];
					ans3=k-i;
					goto END;
				}
			}

		}
		END:;
		cout <<ans1 <<" " <<ans2 <<" " <<ans3 <<endl;
	}
}

Measured memory_bytes: 3024
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)

using namespace std;

vector<int> vec;

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int main(void) {
	long long a;
	long long b;

	std::map<std::string, long long> map;

	vector<long long> vec;

	long long ans;


	cin >> a;


	string temp;

	for (int i = 0; i < a - 1; i++) {
		cin >> temp;

		map[temp]++;
	}


	for (int i = 1; i <= a; i++) {

		cout << map[to_string(i)] << endl;

	}




}




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

int main(void)
{
    int n, x;
    cin >> n >> x;
    vector<int> L(n);
    rep(i, n) cin >> L[i];

    int sum = 0;
    int cnt = 1;
    
    for(int i = 0; i < n; i++)
    {
        sum += L[i];
        if(sum <= x) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int A, B;
    cin >> A >> B;
    print(6 - A - B);
}

signed main() {
    solve();
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import os
import pprint

#fd = os.open('ITP1_1_C.txt', os.O_RDONLY)
#os.dup2(fd, sys.stdin.fileno())

a, b = list(map(int, input().split()))
s = a * b
l = 2 * a + 2 * b
print(s, l)

Measured memory_bytes: 8244
n,k = map(int,raw_input().split())

arr = [0,1,2,3,4,5,6,7,8,9]
r = map(int,raw_input().split())

for i in r:
	arr.remove(i)


def count_digit(num):
	count = 0
	t = num 
	while t > 0 :
		count += 1
		t /= 10
	return count

dc = count_digit(n) + 1


ans = float("inf")

def dfs(s,i):
	global ans,n,dc
	
	ret = int(s) if i > 0 else 0
	if ret >= n :
		ans = min(ans,ret)

	if i != dc :
		for j in arr :
			dfs(s + str(j),i + 1)

dfs('',0)
print ans

Measured memory_bytes: 2696
n=int(input())
l=list(map(int, input().split()))
l.sort()
l.reverse()
ans=0

for i in range(n):
  for j in range(i+1, n):
    for k in  range(j+1, n):
      if l[i]<l[j]+l[k] and l[i]!=l[j] and l[i]!=l[k] and l[j]!=l[k]:

        ans=ans+1
        
print(ans)

Measured memory_bytes: 9192
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
    int N, ans = 0, c = 0;
    string S;
    cin >> N >> S;
    rep(i, N) {
        if (S[i] == 'I') c++;
        else c--;
        ans = max(ans, c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e9;

ll c(int x,int k){
    ll res  = 1;
    for(int i=0;i<k;i++){
        res *= x-i;
        res /= i+1;
    }
    return res;
}
//input
ll n,a,b;
vector<ll>v;



int main(){
    cin >> n >> a >> b;
    v.resize(n);
    rep(i,n)cin>>v[i];
    sort(v.rbegin(),v.rend());
    if(v[0]!=v[a-1]){
        double ave = 0;
        rep(i,a){
            ave += v[i];
        }
        ave /= double(a);
        printf("%.10lf\n",ave);
        ll k=0;
        for(ll i=1;i<a;i++){
            if(v[i]==v[a-1])k++;
        }
        ll m = 0;
        for(ll i=1;i<n;i++){
            if(v[i]==v[a-1])m++;
        }
        cout << c(m,k) << endl;
    }
    else{
        double ave = v[0];
        printf("%.10lf\n",ave);
        ll m = 0;
        rep(i,n){
            if(v[i]==v[0])m++;
        }
        ll ans = 0;
        ans += pow(2,m);
        for(int i=0;i<a;i++){
            ans -= c(m,i);
        }
        for(int i=b+1;i<=m;i++){
            ans -= c(m,i);
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main() {
  
  int h,w;
  cin >> h >> w;
  
  vector<vector<char>> c(h,vector<char>(w));
  for ( int i = 0; i < h; i++){
    for ( int j = 0; j < w; j++){
      cin >> c[i][j];
    }
  }
  
  for ( int i = 0; i < h; i++){
    int k = 0;
    while(k < 2){
      for ( int j = 0; j < w; j++){
        cout << c[i][j];
      }
      cout << endl;
      k++;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	cin>>n;
	rep(i,n){
		cout<<"Case "<<i+1<<":"<<endl;
		int a;
		cin>>a;
		rep(j,10){
			a*=a;
			a=a%1000000/100;
			cout<<a<<endl;
		}
	}		
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<algorithm>
using namespace std;

#define MIN(a,b) ((a)<(b)?(a):(b))


int main() {
	int a;
	cin >> a;
	string s;
	cin >> s;
	for (auto &i : s) {
		i += a;
		i -= 'A';
		i %= 'Z'-'A'+1;
		i += 'A';
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(register int i=(a);i<(b);++i)
#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
#define pi pair<int,int>
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 200005;
const int maxm = 100;
const int inf = 2147483647;
typedef long long ll;
const double eps = 1e-9;
const long long INF = 9223372036854775807ll;
ll qpow(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c;b>>=1;}return ans;}
struct Node{
	int l,r,d;
}s[maxn];
vector<int>a,b;
bool cmp(int a,int b){
	return s[a].d<s[b].d;
}
priority_queue<int,vector<int>,greater<int> >aa,bb;
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n;
		scanf("%d",&n);
		ll ans=0;
		FOR(i,0,n){
			scanf("%d%d%d",&s[i].d,&s[i].l,&s[i].r);
			if(s[i].l>s[i].r)a.push_back(i);else {
				b.push_back(i);
				s[i].d=n-s[i].d;
			}
			ans+=min(s[i].l,s[i].r);
		}
		sort(a.begin(),a.end(),cmp);
		sort(b.begin(),b.end(),cmp);
		FOR(i,0,a.size()){
			if(s[a[i]].d==0)continue;
			if(aa.size()==s[a[i]].d && aa.top()<abs(s[a[i]].r-s[a[i]].l)){
				aa.pop();
				aa.push(s[a[i]].l-s[a[i]].r);
			}else if(s[a[i]].d>aa.size())aa.push(s[a[i]].l-s[a[i]].r);
		}
		FOR(i,0,b.size()){
			if(!s[b[i]].d)continue;
			if(bb.size()==s[b[i]].d && bb.top()<abs(s[b[i]].r-s[b[i]].l)){
				bb.pop();
				bb.push(s[b[i]].r-s[b[i]].l);
			}else if(s[b[i]].d>bb.size())bb.push(s[b[i]].r-s[b[i]].l);
		}
		while(!aa.empty())ans+=aa.top(),aa.pop();
		while(!bb.empty())ans+=bb.top(),bb.pop();
		a.clear(),b.clear();
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 7376
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
    unsigned long long x,y;
    cin >> x >> y;
    int ans = 1;
    while(true){
        x *= 2;
        if(x <= y){
            ++ans;
        }else{
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
int main(){
long long N,X;
cin>>N>>X;
long long a[1000];
int counter=0;
int counter1=0;
for(int j=0; j<N;j++){
cin>>a[j];}
while (counter<=X){
counter+=a[counter1];
counter1++;}
if(counter1<=N+1){
cout<<counter1<<endl;}
else
cout<<N+1<<endl;}


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    vector<ll> x;
    x.pb(0);
    rep(i, n) {
        ll pos; cin >> pos;
        x.pb(pos);
    }
    x.pb(0);
    n = x.size();
    ll sum = 0;
    rep(i, n-1) {
        sum += abs(x[i] - x[i+1]);
    }
    // cout << sum - abs(x[1] - x[0]) << endl;
    rep(i, 1, n-1) {
        cout << sum + abs(x[i+1] - x[i-1]) - (abs(x[i] - x[i-1]) + abs(x[i] - x[i+1])) << endl;
    }
    // cout << sum - abs(x[n-1] - x[n-2]) << endl;
}


Measured memory_bytes: 2164
#include <iostream>

using namespace std;

int main(){
char s;
cin >>s;
    if(s=='A'){
        s='T';
    }else if(s=='C'){
        s='G';
    }else if(s=='T'){
        s='A';
    }else{
        s='C';
    }
  cout <<s;
return 0;
}

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

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
      
      long n = Integer.parseInt(in.readLine());

      long p,q;
      for(long x=1; x<3501; x++) {
        for(long y=1; y<3501; y++) {

          if((p = ((x*y)<<2) - n*x - n*y) < 1)
            continue;

          if((q = n*x*y) % p == 0) {
            System.out.println(x + " " + y + " " + q/p);
            return;
          }
        }
      }
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 22996
macro_rules! get_one {
    ($t:ty) => {{
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse::<$t>().unwrap()
    }};

    ($t:ty; $n:expr) => {
        (0..$n).map(|_| get_one!($t)).collect::<Vec<_>>()
    };
}

fn main() {
    let s = get_one!(String);
    let t = get_one!(String);

    let diff: usize = s.chars().zip(t.chars()).map(|(c1, c2)| if c1 == c2 {0} else {1}).sum();

    println!("{}", diff);


}


Measured memory_bytes: 2572