akhauriyash/Code-Regression huggingface dataset:
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto dud(C *x)->decltype(os << *x, 0);
template<class C> static char dud(...);
template<class C> typename enable_if<sizeof dud<C>(0)!=1,Dbg&>::type operator<<(const C &x) {os<<x; return *this;}
template<class C> Dbg &dump(C b, C e) {
    for (struct{C i;int j;} i={(*this<<"\n[",b),0}; i.i!=e and i.j<26; i.i++, i.j++) *this<<", "+2*(i.i==b)<<*i.i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof dud<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator<<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator<<(const pair<B, C> &x) {return *this<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = -1;

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    int h1, m1, h2, m2, K;
    cin >> h1 >> m1 >> h2 >> m2 >> K;
    if (tie(h1, m1) > tie(h2, m2)) h2 += 24;
    cout << (h2*60+m2-(h1*60+m1))-K << '\n';
}

Measured memory_bytes: 3636
n, k, *a = map(int, open(0).read().split())
b = [0]*49
for i in a:
    c = bin(i)[::-1][:-2]
    for j in range(len(c)):
        b[j] += int(c[j])
d = [int(i < n-i) for i in b]
*e, = bin(k)[2:]
*e, = map(int, e)
d = d[:len(e)][::-1]
for i in range(len(e)):
    d[i] = d[i]&e[i]
    if d[i] < e[i]: break
*d, = map(str, d)
f = int(''.join(d), 2)
print(sum(f^i for i in a))

Measured memory_bytes: 14492
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define el(a) (a).end()-(a).begin()
int main(){
	int n,k;
	cin>>n>>k;
	vector<ll> p,m;
	ll a[n];
	rep(i,n){
		cin>>a[i];
		if(a[i]>0)p.push_back(a[i]);
		else m.push_back(a[i]);
	}
	ll max=1;
	//すべて
	if(n==k){
		rep(i,k)max=(max*a[n-1-i])%1000000007;
		if(max<0)max=max+1000000007;
		cout << max;
		return 0;
	}
	
	
	p.push_back(0);
	m.push_back(0);
	sort(all(p));
	sort(all(m));
	
	
	ll b,c;
	int i,j;
	i=el(p)-1;
	j=0;
	
	//負となるとき(すべてが負の数)
	if(i==0&&k%2==1){
		rep(i,k)max=(max*m[el(m)-2-i])%1000000007;
		if(max<0)max=max+1000000007;
		cout<<max;
		return 0;
	}
	//絶対値が大きい順に取っていく
	rep(o,k){
		if(p[i]>-1*m[j])i--;
		else j++;
	}
	//負になるとき
	if(j%2==1){
		if(i!=el(p)-1)b=p[i+1]*p[i];
		else b=1000000000000000001;
		c=m[j-1]*m[j];
		if(b>c){
			i--;
			j--;
		}
		else{
			i++;
			j++;
		}
	}
	rep(n,j)max=(max*m[n])%1000000007;
	for(int n=el(p)-1;n>i;n--)max=(max*p[n])%1000000007;
	if(max<0)max=max+1000000007;
	cout <<max;
	return 0;
}

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

#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

const int INF = 1e9+100;
const int MAXN = 2e5+100;
const double EPS = 1e-6;


int n;
ll dp[MAXN];
ll h[MAXN];

void solve() {
	cin >> n;
	for(int i = 1; i <= n; ++i)
		cin >> h[i];
	dp[1] = 0;
	dp[2] = abs(h[2]-h[1]);
	dp[3] = min(dp[2]+abs(h[3]-h[2]), 
				abs(h[3]-h[1]));
	for(int i = 4; i <= n; ++i)
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),
					dp[i-2]+abs(h[i]-h[i-2]));
	cout << dp[n];
}

int main() {

//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int t = 1;
//	cin >> t;
	while(t--) {
		solve();
	}
}

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

int main(){
    double n, k;
    cin >> n >> k;

    double ans = 0;
    int lim = n;
    if(k <= n) lim = k-1;
    for(int i=1; i<=lim; i++){
        double base = 1;
        double x = 0;
        while(k > base * i){
            base *= 2;
            x++;
        }
        ans += 1/n * pow(0.5, x);
    }

    if(k <= n){
        ans += (n-k+1)/n;
    }

    cout << setprecision(12) << ans << endl;
}

Measured memory_bytes: 256
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

dec(x) = x%10==0?x:(div(x,10)+1)*10
function main()
	a = readline() |> parseInt
	b = readline() |> parseInt
	c = readline() |> parseInt
	d = readline() |> parseInt
	e = readline() |> parseInt
	aa = a%10==0?10:a%10
	ab = b%10==0?10:b%10
	ac = c%10==0?10:c%10
	ad = d%10==0?10:d%10
	ae = e%10==0?10:e%10
	k = min(aa,ab,ac,ad,ae)
	println(dec(a)+dec(b)+dec(c)+dec(d)+dec(e)-(10-k))
end
main()

Measured memory_bytes: 163020
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		double[] p = new double[n];
		for(int i = 0; i < n; i++){
		    p[i] = sc.nextDouble();
		}
		
		// 計算
		double result = 0;
		double[][] dp  = new double[n+1][n+1];
		dp[0][0] = 1;
		for(int i = 0; i < n; i++){
		    for(int j = 0; j < n; j++){
		        dp[i+1][j+1] += dp[i][j]*p[i];
		        dp[i+1][j] += dp[i][j]*(1-p[i]);
		    }
		}
		for(int i = (n+1)/2; i <= n; i++){
		    result += dp[n][i];
		}
		
		// 出力
		System.out.println(result);
	}

	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 132560
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int cards[4][13];  //[mark][number]
    int n,Number;
    char Mark;
    cin >> n;
    for (int i=0; i<4; i++) {
        for (int j=0; j<13; j++) {
            cards[i][j]=0;
        }
    }
    
    for (int i=0; i<n; i++) {
        cin >> Mark >> Number;
        //番号とマークが入力された時'1'で記録
        if (Mark == 'S') {
            cards[0][Number-1]=1;
        }else if(Mark == 'H'){
            cards[1][Number-1]=1;
        }else if(Mark == 'C'){
            cards[2][Number-1]=1;
        }else if(Mark == 'D'){
            cards[3][Number-1]=1;
        }
    }
    for (int i=0; i<4; i++) {
        for (int j=0; j<13; j++) {
            //'1'が記録されていないときマークと番号を印字
            if(i == 0 && cards[i][j] == 0){
                cout << 'S' <<" "<< j+1 << endl;
            }else if(i == 1 && cards[i][j] == 0){
                cout << 'H' <<" "<< j+1 << endl;
            }else if(i == 2 && cards[i][j] == 0){
                cout << 'C' <<" "<< j+1 << endl;
            }else if(i == 3 && cards[i][j] == 0){
                cout << 'D' <<" "<< j+1 << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3076
#include "bits/stdc++.h"
using namespace std;

int main() {
	int k, a, b,i;

	cin >> k >> a >> b;

	for (i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3640
class UnionFind:
    def __init__(self, N):
        self.parent = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def find(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
            self.size[y] += self.size[x]
        else:
            self.parent[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        return self.size[self.find(x)]

def kruskal(edges, size):
    uf = UnionFind(size)
    edges = sorted(edges, key=lambda e: e[2])
    ret = 0
    for u, v, weight in edges:
        if not uf.same(u, v):
            uf.unite(u, v)
            ret += weight
    return ret

N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    a, b = map(int, input().split())
    x[i] = (a, i)
    y[i] = (b, i)
x.sort()
y.sort()
edges = []
for i in range(N-1):
    x1, u = x[i]
    x2, v = x[i+1]
    edges.append((u, v, x2 - x1))
    y1, u = y[i]
    y2, v = y[i+1]
    edges.append((u, v, y2 - y1))
ans = kruskal(edges, N)
print(ans)

Measured memory_bytes: 131888
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long l = sc.nextLong();
    long r = sc.nextLong();
    r = Math.min(r,(l+2019));
    long mod = 2019L;
    long ans = (long)Math.pow(10,9)+7;
    for(long i = l; i < r; i++){
        for(long j = i+1; j <= r; j++){
            //System.out.println(i + " "+ j + " " + ((i*j)%mod));
            long tmp = ((i%mod)*(j%mod))%mod;
            ans = Math.min(ans,tmp);
        }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (empty($l)) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->N = $a[0];
    $key->K = $a[1];
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->D=$a;
  }
}
$N = array();
for($i=0;$i<9;$i++) {
  $N[$i]=0;
}
foreach($key->D as $a) {
  $N[$a]=1;
}
$val = $key->N + 0;
$cnt = 0;
while(1) {
  if (isvalid($N,$val)==true) {
    break;
  }
  $val++;
  $cnt++;
}
printf("%d\n",$val);

function isvalid($key,$vi) {
  $val = $vi . "";
  $wk = "";
  for($i=0;$i<strlen($val);$i++) {
    $v = $val[$i];
    $wk = $wk . $v;
    if ($key[$v]==1) return false;
  }
  return true;
}


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

int lenght(char *str)
{
    int i = 0;
    while (str[i])
    {
        i++;
    }
    return i;
}

int main()
{

    // 整数の入力
    char str[10];
    char rst[10];

    cin >> str;
    int ln = lenght(str);
    if(ln == 2)
        cout << str;
    if(ln == 3){
        rst[0] = str[2];
        rst[1] = str[1];
        rst[2] = str[0];
        cout << rst;
    }


    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <chrono>
#include <numeric>

using namespace std;
using namespace std::chrono;

typedef long long int lo;
#define fast ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0);
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e9
#define N (lo)1e5 * 5
#define all(x) (x).begin(), (x).end()
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
#define si pair<string,lo>
#define vi vector <lo> 
#define vii vector <ii> 

int main() {
	fast
	lo n;
	cin >> n;
	vi a(n);
	for(lo i = 0 ; i < n ; i++){
		cin >> a[i];
	}

	lo ans = inf;

	for(lo i = 1 ; i <= 100 ; i++){
		lo k = 0;
		for(lo j = 0 ; j < n ; j++){
			k += (i - a[j]) * (i - a[j]);
		}

		ans = min(k, ans);
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1000
using namespace std;
 
string itos(int x){
  string res;
  int X=x;
  while(x)res+=x%10+'0',x/=10;
  reverse(res.begin(),res.end());
  if(X==0)res="0";
  return res;
}
 
int main(){
  set<string> s;
  int n,k,ans=-1;
  string str;
  char c;
  cin>>n;
  for(int i=0;i<n;i++)cin>>c,str+=c;
  for(int i=1;i<N;i++){
    for(int j=0;j+i-1<n;j++)
      s.insert(str.substr(j,i));
    k=1;
    for(int j=0;j<i;j++)k*=10;
    for(int j=0;j<k;j++)
      if(s.find(itos(j))==s.end()){
    ans=j;
    break;
      }
    if(ans>=0)break;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1296
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

ll ans = 0;
int n, m, q;
vector<int> a, b, c, d;

void dfs(string &s, int moji){

    if(moji == n){
        ll anstmp = 0;

        rep(i,q){
            if((s[b[i]] - '0') - (s[a[i]] - '0') == c[i]){
                anstmp += d[i];
            }
        }

        ans = max(ans, anstmp);
        //cout << s << endl;

        return;
    }


    int simo = s[moji -1] - '0';
    for(int i = simo; i<= m-1; i++){
        string tmp = to_string(i);
        string ns = s + tmp;

        dfs(ns, moji + 1);
    }

    return;

}

int main(){
    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);

    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }

    rep(i,m){
        string s = to_string(i); 
        dfs(s, 1);
    }

    cout << ans << endl;

}



Measured memory_bytes: 3700
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	int N, M, X; cin >> N >> M >> X;
	int a = 0, b = 0;;
	rep(i, 0, M) {
		int m;
		cin >> m;
		(m < X) ? a++ : b++;
	}
	cout << ((a > b) ? b : a) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()
 
using ll = long long;
constexpr ll mod = 1000000007;
 
ll n, k;
 
ll powMod( ll x, ll y )
{
  ll ret = 1ll;
 
  while( y > 0 )
  {
    if( y & 1 )
      ret = (ret * x) % mod;
 
    x = (x*x) % mod;
 
    y >>= 1;
  }
 
  return ret;
}
 
ll fact[200010], inv[200010];
 
ll comb( ll n, ll r )
{
  if( n < r || n <= 0 || r < 0 )
    return 0;
 
  return fact[n]*inv[r]%mod*inv[n-r]%mod;
}
 
int main()
{
  scanf( "%lld%lld", &n, &k );
 
  k = std::min(n-1,k);
 
  fact[0] = 1;
  rep( i, 200010 )
    fact[i+1] = (i+1)*fact[i]%mod;
 
  rep( i, 200010 )
    inv[i] = powMod( fact[i], mod-2 );
 
  ll ans = 0;
 
  rep( r, k+1 )
    ans = (ans+comb(n,r)*comb(n-1,r)%mod)%mod;
 
  printf( "%lld\n", ans );
 
  return 0;
}


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

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

int main()
{
    while (1)
    {
	int n,m,p[1000]={0},tmp=0;
	cin >> n >> m;
	if (n==0)break;
	rep (i,n)
	{
	    rep(j,m)
	    {
		tmp++;
		if (p[tmp%n] != 0)j--;
	    }
	    p[tmp%n]=1;
	}
	(tmp%n == 0)?cout << n:cout << tmp%n;
	cout << endl;
    }
    return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String strn = input.readLine( );
		int n = Integer.parseInt(strn);
		int[] list = new int[n+1];
		Arrays.fill(list, 0);
		long answer = 1;
		int x = 0;

		for(int i=1; i<n+1; i++){
			x = i;
			for(int j=1; j<i+1; j++){
				while((x)%(j) == 0){
					list[j] = list[j]+1;
					x = x / (j);
					if(j==1){
						break;
					}
				}
//				System.out.println("i="+i+",j="+j+",list["+j+"]="+list[j]);
			}
		}

		for(int i=2; i<n+1; i++){
//			System.out.println(list[i]);
			answer = answer * (list[i]+1);
			answer = answer % (int)(Math.pow(10, 9)+7);
		}

		System.out.println(answer);
	}

}



Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int i;
  double x;
  string u;
  string F = "JPY";
  double sum = 0;
  for(i=0; i<N; i++){
    cin >> x;
    cin >> u;
    if(u == F) sum += x;
    else sum = sum + x * 380000.0;
  }
  
  cout << sum << endl;

  return 0;
}

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

int main() {
  int N,M,i=0,j=0;
  cin >> N;
  vector<string> s(N);
  vector<int> point(100,1);
  
  for(i=0;i<N;i++){
    cin >> s[i];
  }
  cin >> M;
  vector<string> t(M);
  for(i=0;i<M;i++){
    cin >> t[i];
  }
  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      if(s[i]==s[j]){
        point[i] += 1;
      }
    }
    for(j=0;j<M;j++){
      if (s[i]==t[j]){
        point[i] -= 1;
      }
    }
  }
  int max;
  
  for(i=0;i<N;i++){
    if(max<=point[i]){
      max = point[i];
    }
  }
  cout << max << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
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 (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

struct edge{
    ll to, w;
};

const ll INF= (1ll<<60);
vector<ll> visited(101010, INF);

void dfs(ll now, ll pos, vector<vector<edge>> &G){
    if(visited[now] != INF) return;
    visited[now] = pos;
    
    for(auto e: G[now]){
        if(visited[e.to] == INF){
            dfs(e.to, pos + e.w, G);
        }else{
            if(visited[e.to] != pos + e.w){
                cout << "No" << endl;
                exit(0);
            }
        }
    }
    return;
}

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

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

    vector<vector<edge>> G(N);

    REP(i, M){
        ll L, R, D;
        cin >> L >> R >> D;
        L--, R--;
        G[L].push_back((edge){R, D});
        G[R].push_back((edge){L, -D});
    }

    REP(i, N) dfs(i, 0, G);

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 16512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define Rep(i, s, n) for (ll i = (ll)s; i < (ll)n; i++)
#define len(array) (sizeof(array)/sizeof(array[0]))
typedef long long ll;

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

    ll n, k, q;
    cin >> n >> k >> q;
    ll point[n]= {0};
    rep (i, q) {
        int a;
        cin >> a;
        point[a-1]++;
    }
    rep (i, len(point)) {
        if ((k+point[i]-q) > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 4384
#include<bits/stdc++.h>
using namespace std;
 
int a[15]={0};
 
int main(){
    int n;
    cin >> n;
    int ans = pow(3,n);
    int odd = 1;
    for(int i=0;i<n;++i){
        cin >> a[i];
        if(a[i] % 2 == 0)odd *= 2;
    }
 
    cout << ans - odd << endl;
 
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

char input[1001];

int main(void)
{
    int i, j, len;
    scanf("%s",input);
    len = strlen(input);
    for (i = 0; i < len; i++) {
        if ('A' == input[i] ) {
            input[i] = 'X';
        } else if ('B' == input[i]) {
            input[i] = 'Y';
        } else if ('C' == input[i]) {
            input[i] = 'Z';
        } else {
        input[i] -= 3;
        }
    }
    printf("%s\n",input);
    return 0;
}

Measured memory_bytes: 524
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    val resultMap : MutableMap<String, Long> = mutableMapOf(
            "AC" to 0L,
            "WA" to 0L,
            "TLE" to 0L,
            "RE" to 0L
    )

    for (i in 1..n) {
        val si = readLine()!!
        val value = resultMap[si]!!
        resultMap[si] = value + 1L
    }

    println("AC x ${resultMap["AC"]}")
    println("WA x ${resultMap["WA"]}")
    println("TLE x ${resultMap["TLE"]}")
    println("RE x ${resultMap["RE"]}")
}

Measured memory_bytes: 58260
import java.util.Scanner;

public class Main {

	/**
	 * ?????°??????????????????????????????????????????????????????????????????????????????????????????????????? ???????????????????????????????????´??° a ??¨ b
	 * ??????????????????????????§??????????????????????????????????????\????????????????????§????????????????????????a ??¨ b ??????????????´??°??¨????????????
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner sc = new Scanner(System.in);
		while (sc.hasNextInt()) {
			int a = sc.nextInt();
			int b = sc.nextInt();

			int divisorNum = 0;
			for (int i = 0; i <= 2; i++) {
				int sum = a + b;
				int keta = 1;
				divisorNum = 0; // ??¨????????????????????°
				while (true) {
					if (sum / keta > 0) {
						keta *= 10;
						divisorNum++;
					} else {
						break;
					}
				}

			}

			System.out.println(divisorNum);
		}
	}

}

Measured memory_bytes: 20372
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ALL(a)  (a).begin(),(a).end()
const int MOD = 1000000007;
ll l,x,y,s = 0,d,n;
int main() {
    cin >> n;
    vector<pair<int, int>> v(n);
    rep(i, n) {
        cin >> x >> y;
        v[i] = make_pair(y, x);
    }
    sort(ALL(v));
    rep(i, n) {
        s += v[i].second;
        if (s > v[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int h,n; cin>>h>>n;
  int sum=0,l;
  for(int i=0; i<n; ++i){ cin>>l; sum+=l;}
  if(h>sum) cout<<"No"; else cout<<"Yes";
  return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 300001

int H,W,M;
pi A[maxn];
vi B[maxn]; //all on in each column
int num[maxn]; //number per row
int num2[maxn]; //number per col
int main(){
	fast;
	
	cin>>H>>W>>M;
	
	FOR(i,1,M){
		cin>>A[i].f>>A[i].s;
		B[A[i].s].pb(A[i].f);
		num[A[i].f]++; num2[A[i].s]++;
	}
	
	multiset <int> st;
	FOR(i,1,H) st.insert(num[i]);
	int ans = 0;
	FOR(i,1,W){
		aFOR(j,B[i]){
			st.erase(st.find(num[j]));
			num[j]--;
			st.insert(num[j]);
		}
		
		ans = max(ans, *st.rbegin() + num2[i]);
		
		aFOR(j,B[i]){
			st.erase(st.find(num[j]));
			num[j]++;
			st.insert(num[j]);
		}
	}
	cout<<ans;
}



Measured memory_bytes: 41108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N,A,B;
  cin >> N;
  if(N==1) cout << "Hello World" << endl;
  else{
    cin >> A >> B;
    cout << A+B << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	double EPS = 1e-5;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			double q = sc.nextDouble();
			if( q == 0 ) { System.out.println(0.00000); continue; }
			if( q == -1 ) break;
			double x = q / 2;
			while( abs( x*x*x - q) >= EPS * q ) {
				x = f(x, q);
			}
//			debug(EPS*q);
			System.out.printf("%.6f\n", x);
		}
	}
	
	double f(double x, double q) {
		return x - (x*x*x - q) / ( 3 * x*x);
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 1000000000


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


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

typedef long long ll;

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

    // int t;
    // cin >> t;
    // while (t--)
    // {
        
    // }


    string a, b;
    cin >> a >> b;
    if (b.size() != a.size() + 1)
    {
        cout << "No\n";
        return 0;
    }
    int ans = 1;
    for (int i = 0; i < a.size(); i++)
        if (a[i] != b[i])
            ans = 0;
    if (ans)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
int main() {
	long long int n;
	long long int tes = 0;
	scanf("%lld", &n);
	
	for (int i = 1; i<= n; i++){
		if (i % 3 != 0 && i % 5 != 0){
			tes = tes + i;
			;
		}
	}
	printf("%lld\n", tes);
	return 0;
}

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

int main()
{
	int N, K;
	cin >> N >> K;
	if (N % K == 0) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}
}

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

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> Food(M,0);
    rep(i,N){
        int K;cin >> K;
        rep(j,K){
            int A;cin>>A;
            A--;
            Food[A]++;
        }
    }

    int ans = 0;
    rep(i,M){
        if(Food[i] == N)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int n, m;

int main()
{
    int p[100005] = {}, y[100005] = {};
    vector<int> v[100005];
    cin>>n>>m;
    rep(i,m){
        cin>>p[i]>>y[i];
        v[p[i]].push_back(y[i]);
    }
    rep(i,n){
        sort(v[i+1].begin(), v[i+1].end());
    }
    
    rep(i,m){
        printf("%06lld",p[i]);
        auto index = lower_bound(v[p[i]].begin(), v[p[i]].end(), y[i]);
        printf("%06ld\n", index - v[p[i]].begin() + 1);
    }
}

Measured memory_bytes: 7808
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 
ll A[10000000];
ll B[10000000];
ll cnt=0;

int main(){

    int N;
    
    cin >> N;

    for( int ni = 0 ; ni <N+1 ; ni++ ){
        cin >> A[ni];
    }
    for( int ni = 0 ; ni <N ; ni++ ){
        cin >> B[ni];
    }

    int beated;
    int index;
    index=0;

    beated = min(B[index],A[index]);
    cnt+=beated;
    B[index] -= beated;
    A[index] -= beated;
    
    for( index = 1 ; index <N ; index++ ){

        beated = min(B[index-1],A[index]);
        cnt+=beated;
        B[index-1] -= beated;
        A[index] -= beated;

        beated = min(B[index],A[index]);
        cnt+=beated;
        B[index] -= beated;
        A[index] -= beated;
        
    }
    index = N;
    beated = min(B[index-1],A[index]);
    cnt+=beated;
    B[index-1] -= beated;
    A[index] -= beated;

    cout << cnt << endl;

}

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

using namespace std;

#define ll long long
const int M=1e9+7;
const int mxN=2e5;
ll mod(ll x){
	return ((x%M+M)%M);
}
ll add(ll a,ll b){
	return mod(mod(a)+mod(b));
}
ll mul(ll a,ll b){
	return mod(mod(a)*mod(b));
}

vector<int> adj[mxN];
bool vis[mxN];
int dfs(int u){
	int ans=0;
	if(!vis[u]){
		vis[u]=true;
		ans++;
		for(auto v:adj[u])
			ans+=dfs(v);
	}
	return ans;
}

int main(){
//#ifndef ONLINE_JUGDE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif

	ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n,m;
    cin>>n>>m;
    memset(vis,false,sizeof(vis));
    for(int i=0;i<m;i++){
    	int a,b;
    	cin>>a>>b;
    	a--,b--;
    	adj[a].push_back(b);
    	adj[b].push_back(a);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		if(!vis[i]){
			ans=max(ans,dfs(i));
		}
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 20952
#include <iostream>
#include <algorithm>

#define rep(var, start, end)  for(int var = start; var <= end; ++var)
#define drep(var, start, end) for(int var = start; var >= end; --var)

using namespace std;

int main() {

    int input;
    cin >> input;

    int ar[100] = {0};

    rep(i, 0, input) cin >> ar[i];

    sort(ar, ar+input, greater<int>());

    int alice = 0;
    int bob = 0;

    rep(i, 0, input) {
        if (i % 2) {
            bob += ar[i];
        } else {
            alice += ar[i];
        }
    }

    cout << abs(alice - bob) << endl;

    return 0;
}

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

int main(){
	long long mod =1000000007;

	int n;
	int slen;
	std::string s;
	std::vector<std::vector<std::vector<long long>>> dpList;

	std::cin>>s;
	std::cin>>n;

	slen= s.size();
	dpList.resize(slen);

	for(int i=0; i<slen; i++){
		dpList[i].resize(n);

		for(int j=0; j<n; j++)
			dpList[i][j].resize(2, 0);
	}

	for(int i=1; i<=9; i++){
		dpList[0][i%n][0]++;

		if(s[slen-1]-'0'>=i)
			dpList[0][i%n][1]++;
	}

	for(int i=1; i<slen; i++){
		for(int k=0; k<n;k++){
			dpList[i][k][0]=dpList[i-1][k][0];
			if(s[slen-i-1]=='0')
				dpList[i][k][1]=dpList[i-1][k][1];
			else
				dpList[i][k][1]=dpList[i-1][k][0];
		}

		for(int j=1; j<=9; j++){
			for(int k=0; k<n; k++)
				dpList[i][(k+j)%n][0]= (dpList[i][(k+j)%n][0]+dpList[i-1][k][0])%mod;
			
			dpList[i][j%n][0]++;
		}

		for(int j=1; j<=9; j++){
			for(int k=0; k<n; k++){
				if(s[slen-i-1]-'0'>j)
					dpList[i][(k+j)%n][1]= (dpList[i][(k+j)%n][1]+dpList[i-1][k][0])%mod;

				if(s[slen-i-1]-'0'==j)
					dpList[i][(k+j)%n][1]= (dpList[i][(k+j)%n][1]+dpList[i-1][k][1])%mod;
			}

			if(s[slen-i-1]-'0'>=j)
				dpList[i][j%n][1]++;
		}
	}

	std::cout<<dpList[slen-1][0][1]<<std::endl;

	return 0;
}

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

int main() {    
    /* Input */
    int H, W, K;
    cin >> H >> W >> K;
    
    vector<vector<char>> masu(H, vector<char>(W));
    rep (i, H) {
        rep (j, W) {
            cin >> masu.at(i).at(j);
        }
    }
    
    /* Main Logic */
    int ans = 0;
    rep (ib, 1 << H) {
        rep (jb, 1 << W) {
            /* ex. ib == 001001, jb == 000101 */
            int cnt = 0;
            rep (i, H) {
                rep (j, W) {
                    if (ib >> i & 1) continue;
                    if (jb >> j & 1) continue;
                    if (masu.at(i).at(j) == '#') cnt++;
                }
            }
            if (cnt == K) ans++;
        }
    }

    /* Output */
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int K;
int A[100005];
ll B[100005][2]; // MIN, MAX 

int main() {
  INCANT;
  cin >> K;
  rep(i, K) cin >> A[i];
  B[K][0] = 2ll;
  B[K][1] = 2ll;
  for (int i=K-1; i>=0; i--) {
    B[i][0] = (B[i+1][0]+A[i]-1)/A[i]*A[i];
    B[i][1] = B[i+1][1]/A[i]*A[i]+A[i]-1;
    if (B[i][0]>B[i][1]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << B[0][0] << ' ' << B[0][1]  << endl;
  return 0;
}

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

signed main() {
  ios::sync_with_stdio(false);

  string S;
  cin >> S;

  if (S[0] == '0' || S[S.size() - 1] == '1') {
    cout << -1 << endl;
    return 0;
  }

  for (int i = 0; i + 1 < S.size(); ++i) {
    if (S[i] != S[S.size() - 2 - i]) {
      cout << -1 << endl;
      return 0;
    }
  }

  S[S.size() - 1] = '1';
  vector<int> nxt(S.size());
  for (int i = S.size() - 1, p; ~i; --i) {
    nxt[i] = p;
    if (S[i] == '1') p = i;
  }

  for (int i = 0; i + 1 < S.size(); ++i) {
    cout << i + 1 << " " << nxt[i] + 1 << endl;
  }

  return 0;
}


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

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> L(N);
    for (int i = 0; i < N; i++){
        cin >> L.at(i);
    }
    sort(L.begin(), L.end());
    reverse(L.begin(), L.end());
    int ans = 0;
    for (int i = 0; i < K; i++){
        ans += L.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import Data.List (group, sort)

main :: IO ()
main = do
    (_:as) <- getParams
    print $ solve as

getParams :: IO [Int]
getParams = map read . words <$> getContents

solve :: [Int] -> Int
solve = sum . map numDrop . group . sort

numDrop :: [Int] -> Int
numDrop xxs@(x:xs)
  | len < x   = len
  | otherwise = len - x
  where
    len = length xxs


Measured memory_bytes: 17660
#include <queue>
#include <tuple>
#include <string>
#include <cstring>
#include <iostream>

#pragma warning(disable : 4996)

using namespace std;

const int dx1[4] = { 0, 1, 0, -1 };
const int dy1[4] = { -1, 0, 1, 0 };
const int dx2[4] = { 0, -1, 0, 1 };
const int dy2[4] = { -1, 0, 1, 0 };

int H, W; string L[50], R[50];

bool used[50][50][50][50];

bool over(int x, int y)
{
	return 0 <= x && x < W && 0 <= y && y < H;
}

bool solve(int x1, int y1, int x2, int y2)
{
	queue<tuple<int, int, int, int> > que;

	que.push(make_tuple(y1, x1, y2, x2));

	used[y1][x1][y2][x2] = true;

	while (!que.empty())
	{
		int ly = get<0>(que.front());
		int lx = get<1>(que.front());
		int ry = get<2>(que.front());
		int rx = get<3>(que.front());

		que.pop();

		if (L[ly][lx] == '%' && R[ry][rx] == '%') return true;

		if (L[ly][lx] == '%') continue;
		if (R[ry][rx] == '%') continue;

		bool ok = false;

		for (int i = 0; i < 4; i++)
		{
			int ltx = lx + dx1[i];
			int lty = ly + dy1[i];
			int rtx = rx + dx2[i];
			int rty = ry + dy2[i];

			if (!over(ltx, lty))
			{
				ltx -= dx1[i];
				lty -= dy1[i];
			}

			if (!over(rtx, rty))
			{
				rtx -= dx2[i];
				rty -= dy2[i];
			}

			if (L[lty][ltx] == '#')
			{
				ltx -= dx1[i];
				lty -= dy1[i];
			}

			if (R[rty][rtx] == '#')
			{
				rtx -= dx2[i];
				rty -= dy2[i];
			}

			if (!used[lty][ltx][rty][rtx])
			{
				used[lty][ltx][rty][rtx] = true;

				que.push(make_tuple(lty, ltx, rty, rtx));
			}
		}
	}

	return false;
}

int main()
{
	while (true)
	{
		scanf("%d", &W);
		scanf("%d", &H);

		if (W == 0 && H == 0) break;

		for (int i = 0; i < 50; i++) L[i] = "";
		for (int i = 0; i < 50; i++) R[i] = "";

		for (int i = 0; i < H; i++) cin >> L[i] >> R[i];

		int lx, ly, rx, ry;

		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (L[i][j] == 'L')
				{
					lx = j;
					ly = i;
				}

				if (R[i][j] == 'R')
				{
					rx = j;
					ry = i;
				}
			}
		}

		memset(used, false, sizeof(used));

		printf("%s\n", solve(lx, ly, rx, ry) ? "Yes" : "No");
	}

	return 0;
}

Measured memory_bytes: 10052
// I/O
#include <iostream>
#include <iomanip>

// data structures
#include <set>
#include <queue>
#include <vector>

// manipulations
#include <algorithm>

#define rep(i,n) for(int i=0;i< (n);++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define for_lowercase(c) for(int c='a';c<='z';++c)
#define for_uppercase(c) for(int c='A';c<='Z';++c)
#define ALL(a) (a).begin(),(a).end()
using LLI = long long int;
LLI GCD(LLI a,LLI b){ if(a<b) return GCD(b,a); else if(a%b==0) return b; else return GCD(b,a%b); }
LLI LCM(LLI a,LLI b){ return (a/GCD(a,b))*b; }
using VI  = std::vector<LLI>;
using PI  = std::pair<LLI,LLI>;
using VVI = std::vector<VI>;
using VPI = std::vector<PI>;
template<class T> bool is_odd (T x){ return   x%2 ; }
template<class T> bool is_even(T x){ return !(x%2); }
LLI combination(LLI n,LLI k,bool reset=false){
    static VVI C; static LLI n_hashed = -1;
    if(n<0){ std::cerr << "[ERROR] n must be non-negative in combination()" << std::endl; exit(1); }
    if(!(0<=k&&k<=n)){ std::cerr << "[WARNING] k should be in range [0,n] in combination()" << std::endl; return 0; }
    if(n_hashed<n || reset){
        C.resize(n+1);
        for(int i=0;i<=n;++i) C[i].resize(i+1,1); // filled with 1
        for(int i=1;i<=n;++i)for(int j=1;j<i;++j) C[i][j] = C[i-1][j-1] + C[i-1][j]; // calc
        n_hashed = n;
    }
    return C[n][k];
}

int main() {
    std::ios::sync_with_stdio(false);

    LLI N,A,B;
    std::cin >> N >> A >> B;
    VI v(N);
    rep(i,N)
        std::cin >> v[i];

    std::sort(ALL(v),std::greater<LLI>()); // descending order

    double max_average = 0.;
    rep(i,A){
        max_average += v[i];
    }
    max_average /= A;

    std::cout << std::fixed << std::setprecision(6) << max_average << std::endl;

    LLI min = v[A-1];
    LLI num_min = 0;
    rep(i,N)
        if(v[i]==min)
            ++num_min;

    LLI num_fixed;
    for(num_fixed=0;v[num_fixed]>min;++num_fixed);

    A -= num_fixed;
    B -= num_fixed;

    // sum of (num_min choose i) for i in [A,B]
    LLI result = 0;
    for(int i=A;i<=std::min(B,num_min);++i){
        result += combination(num_min,i);
        if(min!=v[0]) break;
    }

    std::cout << result << std::endl;

    return 0;
}

Measured memory_bytes: 384
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


import sys
input = sys.stdin.readline
import copy
ss=list(input())
ans=0
for i in range(2**(len(ss)-2)):
    s=copy.copy(ss)
    li=[]
    i=bin(i)[2:]
    for j in range(len(i)):
        if i[j]=="1":
            li.append(len(i)-j)
    #print(i,li)
    for i in range(len(li)):
        s.insert(li[i],"+")
    #print(s)
    ans+=eval("".join(s))
print(ans)
        


Measured memory_bytes: 3444
# coding: utf-8
import functools

def M(s):
    s=s.split('+')
    for i in range(len(s)):
        if '*' in s[i]:
            s[i]=functools.reduce(lambda x,y:str(int(x)*int(y)),s[i].split('*'))
    return int(functools.reduce(lambda x,y:str(int(x)+int(y)),s))

def L(s):
    ret=0
    i=0
    ope=1
    while i<len(s):
        if i%2==0:
            if ope==1:
                ret+=int(s[i])
            else:
                ret*=int(s[i])
        else:
            if s[i]=='+':
                ope=1
            else:
                ope=2
        i+=1
    return ret

original=input()
ans=int(input())
f=0
if ans==M(original):
    f+=1
if ans==L(original):
    f+=2

if f==0:
    print('I')
elif f==1:
    print('M')
elif f==2:
    print('L')
else:
    print('U')




Measured memory_bytes: 6292
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,m,ans=0; cin>>n>>m;
    vector<pair<ll,ll>> e(n);
    rep(i,n){
        ll a,b; cin>>a>>b;
        e[i]=mk(a,b);
    }
    sort(al(e));
    rep(i,n){
        if(m>e[i].second){
            ans+=e[i].first*e[i].second;
            m-=e[i].second;
        }
        else{
            ans+=e[i].first*m;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  vector<int> P(10), Q(10), A(10);

  cin >> N;
  for(int i=0; i<N; i++) cin >> P[i];
  for(int i=0; i<N; i++) cin >> Q[i];
  for(int i=0; i<N; i++) A[i] = i+1;
  
  int cnt = 0;
  int
   p, q;
  do{
      bool is_P = true, is_Q = true;
      for(int i=0; i<N; i++){
        if(P[i] != A[i]) is_P = false;
      }
      for(int i=0; i<N; i++){
        if(Q[i] != A[i]) is_Q = false;
      }

      
      if(is_P) p = cnt;
      if(is_Q) q = cnt;
      cnt++;
  }while(next_permutation(A.begin(), A.begin()+N));

  cout << abs(q-p) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    long long N, x, i;
    scanf("%lld", &N);
    x=0;
    for (i=1; i<=N; i++) {
        if (i%3!=0 && i%5!=0) x+=i;
    }
    printf("%lld", x);
    return 0;
}

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

int main(){
    ll n;
    cin >> n;
    if(n == 0){
        cout << 0 << endl;
        return 0;
    }
    string ans;
    while(n != 1){
        //cerr << n << endl;
        if(n < 0){
            if(n % 2 == 0){
                n = - n / 2;
                ans.push_back('0'); 
            }else{
                n = - (n-1) / 2;
                ans.push_back('1');
            }
        }else{
            if(n % 2 == 0){
                n = - n / 2;
                ans.push_back('0');
            }else{
                n = - (n-1) / 2;
                ans.push_back('1');
            }
        }
    }
    ans.push_back('1');
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// abc136_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    int ans = 0;
    for (int i = 1; i < 7; i+=2){
        if (N < pow(10, i)){
            ans += max(0, N - (int)pow(10, i-1) + 1);
            break;
        } else {
            ans += (int)pow(10, i) - (int)pow(10, i-1);
        }
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 384
N = int(input())
a = []
flag = 1
for i in range(N):
    a.append(str(input()))
    if i != 0:
        for j in range(i):
            if a[i] == a[j]:
                flag =0


back = a[0][-1]
for i in range(1,N):
    front = a[i][0]
    if front != back:
        flag = 0
        break
    back = a[i][-1]

if flag == 0:
    print("No") 
else:
    print("Yes")

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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 100

int N;
int a[MAX];

int main() {
	cin >> N;
	for( int i = 0; i < N; i++ ) {
		cin >> a[i];
	}

	int ave = 0;
	for( int i = 0; i < N; i++ ) {
		ave += a[i];
	}
	ave = round((double)ave / N);
	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		int d = a[i] - ave;
		ans += d * d;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

signed main() {
  int D, T, S; cin >> D >> T >> S;
  if (S * T >= D) cout << "Yes" << endl;
  else            cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3632
N=int(input())
px,py,ct=0,0,0
for i in range(N):
  t,x,y=map(int,input().split())
  dis=abs(px-x)+abs(py-y)
  mt=t-ct
  if dis>mt or (mt-dis)%2==1:
    print("No")
    exit(0)
  px,py,ct=x,y,t
print("Yes")

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
vector<string> s;
double n=1,a,b,c,ans,d,e,left,right,count;
string s1,s2,s3;
cin >>a>>b;
left=b*10;
count=left;
right=left+10;
for(double i=left;i<right;i++){
if(i/12.5>=a&&i/12.5<a+1){
cout<<i<<endl;
  break;
}
  if(i==right-1)cout<<"-1"<<endl;
}
return 0;
} 

Measured memory_bytes: 256
#!python3

# input
N = int(input())
X = list(map(int, input().split()))


def main():
    W = sorted(X)
    a = N // 2
    for i in range(N):
        if X[i] < W[a]:
            print(W[a])
        else:
            print(W[a - 1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 25624
#include <stdio.h>
int x,h,m,s;
int main(){
    scanf("%d", &x);
    h=x/3600;
    m=x/60-h*60;
    s=x-h*3600-m*60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2092