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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

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

void Main() {
    int n; cin >> n;
    
    vll a(n); 
    ll tot = 0;
    rep(i, n) {
        cin >> a[i];
        tot ^= a[i];
        // cout << tot << endl;
    }
    
    rep(i, n) {
        cout << ll(tot^a[i]) << " ";
    }
    cout << endl;
    return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 4732
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var S = lines[0];
    var K = Number(lines[1]);

    S = S.split("");

    for (var i = 0; i < K; i++) {
        if (S[i] !== '1') { console.log(S[i]); return(0); }
    }
    console.log('1');
});

Measured memory_bytes: 21320
// Math = ♥
// Sometimes it is people that no one imagines anything of who do things that no one can imagine
// After all this time? Always

#include <bits/stdc++.h>                        // uncomment before submission
//#include <ext/pb_ds/assoc_container.hpp>		// uncomment before submission
//#include <ext/pb_ds/tree_policy.hpp>			// uncomment before submission
//using namespace __gnu_pbds;					// uncomment before submission
using namespace std;
//<---------------------------------------------------Template----------------------------------------------------------->
#define int long long
#define ll long long
#define ld long double
const int INF = 1e5 + 7;
const int MAX = 1e15 + 7;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;                  // Vector of long long
typedef vector<vi> vvi;                 // Vector of vi
typedef vector<ii> vii;                 // Vector of pairs
typedef vector<vii> vvii;               // Vector of Vector of pairs
typedef vector<bool> vb;                // Vector of bool
#define pq priority_queue               // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                        // For pairs
#define ss second                       // For pairs
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//<----------------------------------------------------------------------------------------------------------------------->

vi f, h;
int n, k;

int solve(int x)
{
    if (x <= 1)
        return 0;
    if (f[x] != -1)
        return f[x];

    f[x] = MAX;
    for (int i = k; i > 0; i--)
    {
        if (x - i >= 1)
            f[x] = min(f[x], solve(x - i) + labs(h[x] - h[x - i]));
    }

    return f[x];
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;

    f.resize(INF, -1), h.resize(INF, 0);
    for (int i = 1; i <= n; i++)
        cin >> h[i];
    f[0] = f[1] = 0;

    f[n] = solve(n);
    cout << f[n] << endl;
    return 0;
}


Measured memory_bytes: 6528
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
		long[] numsb = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
		long sumBefore = 0;
		long sumAfter = 0;
		List<long> plusList = new List<long>();
		long mustPlus = 0;
		long answer = 0;

		for(int i = 0; i < n; i++)
		{
			sumBefore += nums[i];
			sumAfter += numsb[i];
			if(nums[i] < numsb[i])
			{
				mustPlus += numsb[i] - nums[i];
				answer++;
			}
			else if(nums[i] > numsb[i]) plusList.Add(nums[i] - numsb[i]);
		}
		plusList.Sort((a, b) => a.CompareTo(b));

		if(sumBefore < sumAfter) Console.WriteLine(-1);
		else
		{
			while(mustPlus > 0)
			{
				mustPlus -= plusList[plusList.Count()-1];
				plusList.RemoveAt(plusList.Count()-1);
				answer++;
			}
			Console.WriteLine(answer);
		}
	}
}

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

using namespace std;

int main(void){
    int N,K;
    cin>>N>>K;
    vector<int> d(K);
    vector<vector<int>> A(K,vector<int>(N));
    for(int i=0;i<K;i++){
        cin>>d[i];
        for(int j=0;j<d[i];j++){
            cin>>A[i][j];
            A[i][j]--;
        }
    }
    map<int,int> result;
    for(int i=0;i<K;i++){
        for(int j=0;j<d[i];j++){
            result[A[i][j]]++;
        }
    }
    cout<<N-result.size()<<endl;
    return 0;
}



Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;


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

Measured memory_bytes: 256
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()

//グローバル変数宣言
 ll p=0,q=0,r=0;

int main(){
  string s;
  cin>>s;
  r=753;
  rep(i,s.size()-2){
    p=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0')*1;
    q=abs(p-753);
    r=min(q,r);
  }
  print(r);
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] / (fac[k] * fac[n - k]);
}


//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[10101][110];
bool flag[30][30];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	string s, t;
	cin >> s >> t;
	ll n = s.length();
	vector<pair<ll, ll>>p;
	rep(i, n) {
		ll x = s[i] - 'a';
		ll y = t[i] - 'a';
		flag[x][y] = true;
	}
	bool ans = true;
	for (ll i = 0;i <= 'z'-'a';++i) {
		ll res = 0;
		ll res2 = 0;
		for (ll j = 0;j <= 'z'-'a';++j) {
			if (flag[i][j])res++;
			if (flag[j][i])res2++;
			if (res >= 2) {
				puts("No");
				return 0;
			}
			if (res2 >= 2) {
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}


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

int main()
{

    int k;
    cin>>k;

    string s;
    cin>>s;


    if(s.size()<=k)
        cout<<s<<endl;
    else{
        cout<<s.substr(0,k)+"..."<<endl;
    }

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>

  int main(void) {
  int data[2] = {0,0};
  int input;
  for(int i=0;i<3;i++){
     std::cin >> input;
     if(input == 5) data[0]++;
     else if( input == 7) data[1]++;
  }
   if(data[0] == 2 && data[1]  == 1)
      std::cout << "YES";
   else
    std::cout << "NO";
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<stdlib.h>
#include<algorithm>
using namespace std;
typedef long long int lli;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli t, n, i, ans, x, m, y, j, cnt;
    cin >> n >> t;
    cout << n-t+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int score[55][55];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h, w; cin >> h >> w;
    vector<int> mx = {-1,1,0,0};
    vector<int> my = {0,0,1,-1};
    vector<string> f(h);
    rep(i,h) cin >> f[i];
    queue<pair<int,int>> q;
    q.push({0,0});
    while(q.size()!=0) {
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        rep(i,4) {
            int nx = x+mx[i];
            int ny = y+my[i];
            if(nx>=0 && nx<w && ny>=0 && ny<h && score[ny][nx]==0 && f[ny][nx]!='#') {
                score[ny][nx] = score[y][x] + 1;
                q.push({nx,ny});
            }
        }
    }
    int cnt = -1;
    rep(i,h) {
        rep(j,w) {
            if(f[i][j]=='.') cnt++;
        }
    }
    if(score[h-1][w-1]==0) {
        cout << -1 << endl;
        return 0;
    }
    cout << cnt - score[h-1][w-1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a < b)
	{
		printf("a < b\n");
	}
	else if(a > b)
	{
		printf("a > b\n");
	}
	else if(a == b)
	{
		printf("a == b\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
#include "iostream"
#include "random"
#include "string"
#include "bitset"
#include "algorithm"
#include "map"
#include "queue"
#include "list"
#include "set"
#include "climits"
#include "iomanip"

using namespace std;
using ll = long long int;


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

	int N, M;

	cin >> N;
	vector<long long int>v(1000001);
	for (int i = 0; i < N; i++) {
		cin >> M;
		v[M] += M;
	}
	cin >> M;
	vector<long long int>w(M);
	vector<long long int>x(M);
	for (int i = 0; i < M; i++)cin >> w[i];
	for (int i = 0; i < M; i++)cin >> x[i];
	for (int i = 1; i <= 1000000; i++) {
		v[i] += v[i - 1];
	}
	for (int i = 0; i < M; i++) {
		if (v[w[i]] >= x[i])cout << "Yes\n";
		else cout << "No\n";
	}
}


Measured memory_bytes: 15256
#define debug_switch
#ifdef debug_switch
#define debug if(1) puts("debug");
#define dout if(1) cout
#else
#define debug if(0) puts("debug");
#define dout if(0) cout
#endif
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

const int N = 1e5 + 7;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-7;
using namespace std;
struct node{
	int a,b;
	bool operator < (const node&p)const{
		return b != p.b ? b < p.b : a < p.a;
	}
}a[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i].a);
	for(int i=0;i<n;i++)scanf("%d",&a[i].b);
	sort(a, a+n);
	int cnt = 0;
	for(int i=0;i<n;i++){
		if(a[i].a > a[i].b){
			cnt++;
			if(cnt > n-2){
				puts("No");
				return 0;
			}
			for(int j=n-1,k=0;j>i;j--,k++){
				if(a[j].a <= a[i].b){
					swap(a[i].a, a[j].a);break;
				}
				if(k > 3000)break;
			}
			if(a[i].a > a[i].b){
				for(int j=i+1;j<n;j++){
					if(a[j].a <= a[i].b){
						swap(a[i].a, a[j].a);break;
					}
				}
				if(a[i].a > a[i].b){
					puts("No");
					return 0;
				}
				
			}
			
		}
	}
	puts("Yes");
	return 0;
}






Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
  int n;
  string s[50];
  int t[50];
  string x;
  
  cin >> n;
  for(int i = 0; i < n; i++)
  {
    cin >> s[i] >> t[i];
  }
  cin >> x;
  
  int time = 0;
  bool sleeped = false;
  for(int i = 0; i < n; i++)
  {
    if(s[i] == x)
    {
      sleeped = true;
      continue;
    }
    if(sleeped)
    {
      time += t[i];
    }
  }
  
  cout << time << endl;
  
  return 0;
}

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

int main()
{
	int n,W;
	cin>>n>>W;
	vector<int>wt(n,0),val(n,0);
	for(int i=0;i<n;i++)
		{
			int x,y;
			cin>>x>>y;
			wt[i]=x;val[i]=y;
		}

	long long int K[n+1][W+1];
	memset(K,0,sizeof(K));
	for (int i = 0; i <= n; i++) { 
        for (int w = 0; w <= W; w++) { 
            if (i == 0 || w == 0) 
                K[i][w] = 0; 
            else if (wt[i - 1] <= w) 
                K[i][w] = max( 
                    val[i - 1] + K[i - 1][w - wt[i - 1]], 
                    K[i - 1][w]); 
            else
                K[i][w] = K[i - 1][w]; 
        } 
    } 
	cout<<K[n][W];
}

Measured memory_bytes: 82544
#include<stdio.h>

void counting_sort(int);
int C[2000001], A[2000001],B[2000001];
int n;

main(){
 
  int max=0;
  int i,j;
  
  scanf("%d",&n);
  for(i=1; i <= n; i++){
    scanf("%d",&A[i]);
    if(max < A[i])
      max = A[i];
  }
  
  counting_sort(max);
  
  for(i=1; i<=n; i++){
    printf("%d",B[i]);
    if((i>0) && (i<n))
      printf(" ");
  }
  printf("\n");
  
  return 0;
}


void counting_sort(int k){
  int i,j;
  
  for(i=0; i <= k; i++){
    C[i] = 0;
  }
  for(j=1; j <= n; j++){
    C[A[j]] = C[A[j]] + 1;
  }
  for(i=1; i <= k; i++){
    C[i] = C[i] + C[i-1];
  }
  for(j=n; j >= 1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]]-1;
  }
}

Measured memory_bytes: 17896
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define mp(i,j) make_pair(i,j)
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

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

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

void Main()
{
	int N; cin >> N;
	int _n = N;
	int cnt = 0;
	while (_n > 0) {
		_n = _n / 10;
		++cnt;
	}
	int res = 0;
	if (cnt % 2 != 0) {
		res += N - pow(10, cnt - 1) + 1;
		cnt -= 2;
	} else {
		cnt -= 1;
	}
	while (cnt > 0) {
		res += pow(10, cnt) - pow(10, cnt - 1);
		cnt -= 2;
	}
	cout << res << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 512
S = input()
 
MOD = 10**9+7
 
dp = [[0]*13 for _ in range(len(S) + 1)]
 
 
dp[0][0] = 1
 
mul = 1
for index in range(len(S)):
    s = S[len(S) - index - 1]
    if s == '?':
        for pre_index in range(13):
            for i in range(10):
                next_i = (i * mul +  pre_index ) % 13
                dp[index+1][next_i] += dp[index][pre_index] 
                dp[index+1][next_i] %= MOD

    else:
        for pre_index in range(13):
            i = int(s)
            next_i = (i * mul  +  pre_index ) % 13
            dp[index+1][next_i] += dp[index][pre_index] 
            dp[index+1][next_i] %= MOD
    mul *= 10
    mul %= 13
 
 
 
print(dp[len(S)][5])


Measured memory_bytes: 62300
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;

#ifndef LOCAL
#pragma GCC optimize ("O2")
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

ll pwr(ll a,ll b, ll mod){
    a %= mod;
    int ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 2005;
vector<int> g[N];
int U[N], V[N];
void dfs(int u,int p,int d,int dd,int &c){
	if(d <= dd) c++;
	for(int v : g[u]){
		if(v != p){
			dfs(v, u, d + 1, dd, c);
		}
	}
}
void solve(){
	int n, k;
	cin >> n >> k;
	fr(i, 1, n - 1){
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
		U[i] = u, V[i] = v;
	}
	int ans = n;
	fr(i, 1, n)
	{
		int c = 0;
		dfs(i, -1, 0, k / 2, c);
		ans = min(ans, n - c);
		c = 0;
		if(i < n){
			dfs(U[i], V[i], 0, (k - 1) / 2, c);
			dfs(V[i], U[i], 0, (k - 1) / 2, c);
			ans = min(ans, n - c);
		}
	}
	cout << ans;
}
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    cout << setprecision(10) << fixed;
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    return 0;
}

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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

constexpr uint mod = 1000000007;

// modをとった和を返す
inline
uint modPlus(uint a, uint b){return (a + b) % mod;}

// modをとった差を返す
inline
uint modMinus(uint a, uint b){return (mod + a - b) % mod;}

// modをとった積を返す
inline
uint modMultiple(uint a, uint b){return (static_cast<long long>(a) * b) % mod;}



int main()
{
    string S;
    cin >> S;
    // cout << S << endl;
    vector<vector<int>> dp(4, vector<int>(S.size() + 1, 0));
    dp[3][0] = 1;
    REP(i, S.size()){
        char& c = S[i];
        REP(j, 4) dp[j][i + 1] = dp[j][i];
        if (c == 'A'){
            dp[0][i + 1] = modPlus(dp[0][i], dp[3][i]);
        }else if (c == 'B'){
            dp[1][i + 1] = modPlus(dp[1][i], dp[0][i]);
        }else if (c == 'C'){
            dp[2][i + 1] = modPlus(dp[2][i], dp[1][i]);
        }else if (c == '?'){
            dp[0][i + 1] = modPlus(modMultiple(dp[0][i], 3), dp[3][i]);
            dp[1][i + 1] = modPlus(modMultiple(dp[1][i], 3), dp[0][i]);
            dp[2][i + 1] = modPlus(modMultiple(dp[2][i], 3), dp[1][i]);
            dp[3][i + 1] = modMultiple(dp[3][i], 3);
        }
        // cout << c << ": ";
        // REP(j, 4) cout << dp[j][i + 1] << " ";
        // cout << endl;
    }
    cout << dp[2].back() << endl;
}


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

#define N 2*123456

int isPrime[1+N];

void sieve()
{
  int i, j;
  
  for(i = 2; i < N; ++i){
    isPrime[i] = 1;
  }
  
  for(i = 2; i < N; ++i){
    if( isPrime[i] ){
      for(j = 2; i * j < N; ++j){
        isPrime[i * j] = 0;
      }
    }
  }
}

int main(int argc, char *argv[])
{
  sieve();

  while(1){
    int x, n;
    int res = 0;

    scanf("%d", &n);
    if( n == 0 ) break;
    
    for(x = n+1; x <= 2*n; ++x){
      if( isPrime[ x ] ) ++res;
    }
    
    printf("%d\n", res);
  }
  return (EXIT_SUCCESS);
}

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

#define cLL(c) static_cast<long long>(c - '0')

string str;

long long divsum(long long prevsum, int n, long long base)
{
  if(n > 0)
  {
    prevsum += cLL(str[n]) * base;
    return divsum(prevsum, n-1, 1) + divsum(prevsum, n-1, base * 10);
  }
  return prevsum + cLL(str[n]) * base;
}

int main(void)
{
  cin >> str;
  cout << divsum(0, str.length() - 1, 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    set<int> st;
    rep(i, 0, n) {
        int a;
        cin >> a;
        st.insert(a);
    }
    if ((int)st.size() == n) cout << "YES" << endl;
    else cout << "NO" << endl; 
    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define p pair<ll,ll>
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

class BIT{
private:
    int N;
    vector<int> bit;

public:
    BIT(int n){
        N = n;
        bit.resize(n + 1);
    }

    int sum(int i){
        int s = 0;
        while(i > 0){
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, int x){
        while(i <= N){
            bit[i] += x;
            i += i & -i; 
        }
    }
};

const ll mod = 998244353;

ll exp(ll x, int y){
    if(y == 0) return 1LL;
    ll e = exp(x, y / 2);
    return (e * e * (y % 2 ? x : 1LL)) % mod;
}


int N;
vector<p> crd;
void compress(vector<p>& ps){
    sort(ps.begin(), ps.end());
    for(int i = 0; i < N; i++){
        ps[i].first = i + 1;
        swap(ps[i].first, ps[i].second);
    }
}

ll multi(ll A = 1, ll B = 1, ll C = 1, ll D = 1){
    ll re = A * B % mod;
    re = re * C % mod;
    re = re * D % mod;
    return re;
}

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        int x, y;
        cin >> x >> y;
        crd.push_back({x, y});
    }
    compress(crd);
    compress(crd);
    BIT b1(N), b2(N);
    for(int i = 1; i <= N; i++){
        b2.add(i, 1);
    }

    ll ans = exp(2, N - 1) * N % mod;

    for(int i = 0; i < N; i++){
        int x = crd[i].first, y = crd[i].second;
        b2.add(x, -1);
        
        ll A = b2.sum(x), C = b2.sum(N) - A;
        ll B = b1.sum(x), D = b1.sum(N) - B;
        A = exp(2, A) - 1;
        B = exp(2, B) - 1;
        C = exp(2, C) - 1;
        D = exp(2, D) - 1;
        ans = (ans + multi(A, D)) % mod;
        ans = (ans + multi(B, C)) % mod;
        ans = (ans + multi(A, B, C)) % mod;
        ans = (ans + multi(A, B, D)) % mod;
        ans = (ans + multi(A, C, D)) % mod;
        ans = (ans + multi(B, C, D)) % mod;
        ans = (ans + multi(A , B, C, D)) % mod;

        b1.add(x, 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6000
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9) 


int main() {
  int n, m;
  long long ans = 0;

  cin >> n >> m;
  vector<vector<long long> > x(8,vector<long long >(n));
  vector<vector<long long> > y(8,vector<long long >(n));
  vector<vector<long long> > z(8,vector<long long >(n));

  for(int i = 0; i < n; i++){
    long long px,py,pz,mx,my,mz;
    cin >> px >> py >> pz;
    mx = -1 * px;
    my = -1 * py;
    mz = -1 * pz;

    x[0][i] = x[1][i] = x[2][i] = x[3][i] = px;
    x[4][i] = x[5][i] = x[6][i] = x[7][i] = mx;
    
    y[0][i] = y[1][i] = y[4][i] = y[5][i] = py;
    y[2][i] = y[3][i] = y[6][i] = y[7][i] = my;
    
    z[0][i] = z[2][i] = z[4][i] = z[6][i] = pz;
    z[1][i] = z[3][i] = z[5][i] = z[7][i] = mz; 
    
  }

  for(int i = 0; i < 8; i++){
    vector<long long> sum(n);
    for(int j = 0; j < n; j++){
      sum[j] = x[i][j] + y[i][j] + z[i][j];
      //cerr << sum[j] << ",";
    }
    //cerr << endl;

    sort(sum.begin(), sum.end());
    long long ans_tmp = 0;
    for(int k = 0; k < m; k++){
      //cerr << sum[n-1-k] << ",";
      ans_tmp += sum[n-1-k];
    }
    //cerr << endl;


   if(ans_tmp > ans){
     ans = ans_tmp;
   }

  }

  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
long long ni(long long ta, vector<long long> & v) {

}
long long rui(long long n, long long k, long long p) {
	if (k == 0) {
		return 1;
	}
	else {
		long long a = rui(n, k / 2, p);
		if (k % 2 == 0) {
			return (a*a) % p;
		}
		return (((a*a) % p)*n) % p;
	}
}
int main(){
	int n;
	cin >> n;
	int max = 0;
	int mino = 101;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		max += a;
		if (a % 2 == 1) {
			mino = min(mino, a);
		}
	}
	cout << (max - (max % 2)*mino)/2 << endl;
}


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

using namespace std;

int main(){
    int N,ans=0;
    cin >> N;
    vector<int> s(N);
    for(int i=0;i<N;i++){
        cin >> s[i];
        ans += s[i];
    }

    sort(s.begin(),s.end());
    
    if(ans%10 == 0){
        for(int i=0;i<N;i++){
            if(s[i]%10 != 0){
                ans -= s[i];
                break;
            }
            if(i==N-1){
                ans = 0;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include<iomanip>
using namespace std;

int main()
{
    long long N,K,Q;
    cin>>N>>K>>Q;
    int A[Q] = {0};
    for(int i = 0;i<Q;i++)
    {
        cin>>A[i];
    }
    int B[N]= {0};
    for(int i = 0;i<Q;i++)
    {
        B[A[i]-1]++;
    }
    for(int i = 0;i<N;i++)
    {
        if(K <= (Q-B[i]))
        {
            cout<<"No"<<endl;
        }
        else
        {
            cout<<"Yes"<<endl;
        }
        
    }
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>

int N;
double length(std::vector<std::pair<int, int>>& p) {
  double res{0.0};
  for (int i = 0; i < N - 1; i++) {
    res += std::sqrt(
        (p[i].first - p[i + 1].first) * (p[i].first - p[i + 1].first) +
        (p[i].second - p[i + 1].second) * (p[i].second - p[i + 1].second));
  }
  return res;
}

int main() {
  std::cin >> N;
  std::vector<std::pair<int, int>> p;
  for (int i = 0; i < N; i++) {
    int x, y;
    std::cin >> x >> y;
    p.emplace_back(x, y);
  }
  std::sort(p.begin(), p.end());
  double res{0.0};
  do {
    res += length(p);
  } while (std::next_permutation(p.begin(), p.end()));
  double f{1.0};
  for (int i = N; i > 0; i--) f *= (i * 1.0);
  res /= f;
  std::cout << std::fixed << std::setprecision(10) << res << std::endl;
}

Measured memory_bytes: 256
using System;

namespace Watch
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            //??\??????
            int S = int.Parse(Console.ReadLine());
            //??????????±???????
            int h = S / 3600;
            //?????¨?§????????????????????±???????
            int criteria = S % 3600;
            //???????±???????
            int m = criteria / 60;
            //?§?????±???????
            int s = criteria % 60;
            Console.WriteLine (h + ":" + m + ":" + s);
        }
    }
}

Measured memory_bytes: 5612
N, K = map(int,input().split())
p = list(map(int,input().split()))
ans = 0
hoge = 0
for i in range(K):
    hoge += (p[i]+1)/2
ans = hoge
for i in range(N-K):
    hoge -= (p[i]+1)/2
    hoge += (p[i+K]+1)/2
    ans = max(hoge,ans)
print(ans)


Measured memory_bytes: 25060
antena = [0, 0, 0, 0, 0, 0]
ng_count = 0

for i in range(0, 6):
    antena[i] = int(input()) #antena[5]は距離"k"として扱う

if ((antena[4] - antena[0]) > antena[5]):
    print(":(")
else:
    print("Yay!")


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

long long int M = 1e+9 + 7;
long long int power(long long int x, long long int n)
{
    if (n == 0)
        return (long long)1;
    else if (n % 2 == 0) //n is even
        return power((x * x) % M, n / 2);
    else //n is odd
        return (x * power((x * x) % M, (n - 1) / 2)) % M;
}
long long int cans(long long int p, long long int q)
{
    return ((p * power(q, M - 2)) % M + M) % M;
}
const int N = 2e+5 + 5;
vector<int> adj[N];
long long int ans[N], alp[N], fact[N], facti[N], alpi[N], fans[N], nc[N], st[N];
int n;

void dfs(int v, int p)
{
    ans[v] = st[v] = alp[v] = 1;
    for (auto it : adj[v])
        if (it != p)
        {
            dfs(it, v);
            nc[v]++;
            alp[v] = (alp[v] * facti[st[it]]) % M;
            st[v] += st[it];
            ans[v] = (ans[v] * ans[it]) % M;
        }
    alp[v] = (fact[st[v] - 1] * alp[v]) % M;
    // alp[v] = (fact[nc[v]] * alp[v]) % M;
    alpi[v] = cans(1, alp[v]);
    fans[v] = ans[v];
    ans[v] = (ans[v] * alp[v]) % M;
    // cout << v << " " << st[v] - nc[v] << " " << alp[v] << "\n";
}

void calans(int v, int p)
{
    // cout << ans[v] << " ";
    if (v != 1)
    {
        ans[v]=(ans[p]*cans(st[v],st[p]-st[v]))%M;
        st[v]=st[p];
    }
    // cout << v << " " << ans[v] << "\n";
    for (auto it : adj[v])
        if (it != p)
            calans(it, v);
    return;
}
int main()
{
    fact[0] = facti[0] = 1;
    for (long long int i = 1; i < N; i++)
    {
        fact[i] = (fact[i - 1] * i) % M;
        facti[i] = cans(1, fact[i]);
    }
    cin >> n;
    for (int i = 1; i < n; i++)
    {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(1, 0);
    calans(1, 0);
    for(int i=1;i<=n;i++)
        cout<<ans[i]<<"\n";
    // cout << ans[1];
}

Measured memory_bytes: 25972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int numN = in.nextInt();
		int numM = in.nextInt();
		
		long[] arrayA = new long[numN];
		long[] arrayB = new long[numN];
		
		for(int i = 0; i< numN; i++){
			arrayA[i] = in.nextInt();
			arrayB[i] = in.nextInt();
		}
		
		quick_sort(arrayA, arrayB, 0, numN -1);
		
		long result = 0;
		int drnkCnt = 0;
		for(int i = 0; i< numN; i++){
			if(drnkCnt + arrayB[i] >= numM){
				long tmpL = 0;
				long tmpR = arrayB[i];
				while(tmpL <= tmpR){
					long M  = (tmpL+tmpR)/2;
					if((drnkCnt + M) == numM ){
						result +=arrayA[i]* (M);
						drnkCnt += (M);
						break;
					}else if ((drnkCnt + M) > numM) {
						tmpR = M;
					}else{
					    tmpL = 	M+1;
					}
				}
			}else{
				result +=arrayA[i]*arrayB[i];
				drnkCnt += arrayB[i];
			}
			if(drnkCnt == numM)break;
		}
		System.out.println(result);
		
		in.close();
	}
	static void quick_sort(long[] d,long[] s, int left, int right) {
		if (left >= right) {
			return;
		}
		long p = d[(left + right) / 2];
		int l = left;
		int r = right;
		long tmp;
		long tmp2;
		while (l <= r) {
			while (d[l] < p) {
				l++;
			}
			while (d[r] > p) {
				r--;
			}
			if (l <= r) {
				tmp = d[l];
				d[l] = d[r];
				d[r] = tmp;
				
				tmp2 = s[l];
				s[l] = s[r];
				s[r] = tmp2;
				l++;
				r--;
			}
		}
		quick_sort(d,s, left, r); 
		quick_sort(d,s, l, right);
	}
}


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

struct Card {char suit, value;};

void bubble(struct Card A[], int N){
    for(int i = 0; i <= N - 1; i++){
        for(int j = N-1; j >= i + 1; j--){
            if(A[j-1].value > A[j].value){
                Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
            }  
        }
    }
}

void selection(struct Card A[], int N){
    for(int i = 0; i <= N - 1; i++){
        int minj = i;
        for(int j = i; j <= N-1; j++){
            if(A[j].value < A[minj].value) minj = j;
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(struct Card A[], int N){
    for(int i = 0; i <= N - 1; i++){
        if(i > 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N){
    for(int i = 0; i <= N - 1; i++){
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int N;
    
    cin >> N;
    for(int i = 0; i <= N - 1; i++){
        cin >> C1[i].suit >> C1[i].value;
    }
    for(int i = 0; i <= N - 1; i++) C2[i] = C1[i];
    
    bubble(C1, N);
    selection(C2, N);
    
    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if(isStable(C1, C2, N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
typedef pair<db,ll> Pdl;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

int main(){
  ll X,Y,n,x[1010],y[1010],r[1010];
  db ka;
  cin>>x[0]>>y[0]>>X>>Y>>n;
  Fr(i,n) cin>>x[i]>>y[i]>>r[i];
  x[n+1]=X;y[n+1]=Y;
  r[0]=r[n+1]=0;
  vector<Pdl> v[1010];
  Fr(i,n+1){
    fr(j,i){
      ka=max(0.0,sqrt((db)(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j]);
      v[i].pb(mp(ka,j));
      v[j].pb(mp(ka,i));
    }
  }
  db d[1010];
  fr(i,n+2) d[i]=1e10;
  bool vis[1010]={};
  priority_queue<Pdl,vector<Pdl>,greater<Pdl>> pq;
  pq.push(mp(0.0,0));
  while(!pq.empty()){
    Pdl dl=pq.top();
    pq.pop();
    ka=dl.ft;
    ll i=dl.sd;
    if(vis[i]) continue;
    vis[i]=1;d[i]=ka;
    fr(j,v[i].size()){
      if(ka+v[i][j].ft>=d[v[i][j].sd]) continue;
      d[v[i][j].sd]=ka+v[i][j].ft;
      pq.push(mp(d[v[i][j].sd],v[i][j].sd));
    }
  }
  printf("%.12f\n",d[n+1]);
}

Measured memory_bytes: 21744
import java.util.Scanner;
class Main{
  public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    int a=scan.nextInt();
    int e=scan.nextInt();
    e=scan.nextInt();
    e=scan.nextInt();
    e=scan.nextInt();
    int k=scan.nextInt();
    if(e-a<=k){
      System.out.println("Yay!");
    }else{
      System.out.println(":(");
    }
  }
}


Measured memory_bytes: 21844
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define dump(x)  cout << #x << " = " << (x) << endl;

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
//             0123456789 - digits. check the limits, int vs long
const int MX = 100001;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;
    // freopen("ex.in","r",stdin);
    // freopen("ex.out","w",stdout);
    int a;
    string s;
    cin >> a >> s;
    if (a < 3200) cout << "red\n";
    else cout << s << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define F               first
#define S               second
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18 + 1
#define endl            '\n'
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define forI(i,a,n)     for(int i=a;i<=n;i++)
#define forD(i,a,n)     for(int i=n;i>=a;i--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void init(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

int dp[100005][2];
vi Tree[100005];

void compute(int n, int p){
    dp[n][0] = dp[n][1] = 1;

    for(auto child : Tree[n]){
        if(child == p)  continue;
        compute(child, n);
        dp[n][0] = dp[n][0] * ((dp[child][0] + dp[child][1])%mod)%mod;
        dp[n][1] = dp[n][1] * dp[child][0]%mod;
    }
}

void solve(){
    int n, x, y;  cin>>n;
    forI(i, 1, n-1){
        cin>>x>>y;
        Tree[x].pb(y);
        Tree[y].pb(x);
    }
    compute(1, -1);
    cout<<(dp[1][0]+dp[1][1])%mod<<endl;
}   

int32_t main(){
    init();
    // w(t) 
    solve();
    return 0;
}

Measured memory_bytes: 17488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N;
    cin >> N;
    double A,B;
    cin >> A >> B;
    vector<double> val(N);
    REP(i,N)cin >> val[i];
    sort(ALL(val),greater<>());
    double maximum = val[0];
    double sum = 0;
    REP(i,A){
        sum += val[i];
    }
    double number = 0;
    double numberbefore = 0;
    REP(i,N){
        if(val[i] == val[A-1]){
            number++;
            if(i <= A-1)numberbefore++;
        }
    }
    double answer = 0;
    ll much = 0;
    answer = sum/A;
    if(maximum == val[A-1]){
        double nck = 1;
        REP(i,A){
            nck*=(number-i);
            nck /= i+1;
        }
        // REPS(i,A){
        //     nck/=i;
        // }
        much += nck;
        for(int i = A+1;i<=min(number,B);i++){
            nck*=number-i+1;
            nck/=i;
            much+=nck;
        }
    }else{
        double nck = 1;
        REP(i,numberbefore){
            nck *= number-i;
            nck /= i+1;
        }
        // REPS(i,numberbefore){
        //     nck /= i;
        // }
        much = nck;
    }
    cout << answer << "\n";
    cout << much << "\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int i = 0; i < 1000; ++i) {
    static char t[4];
    sprintf(t, "%03d", i);
    int p = 0;
    for (int j = 0; j < n; ++j)
      if (t[p] == s[j])
        ++p;
    ans += p == 3;
  }
  cout << ans;

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
//=======================
const int MOD = 1000000007;
const int N = 2e6+13, M = N;
//=======================
vi g[N];
int a[N];
int n, m, k;
//=======================

void solve() {
    string n;
    int sum=0;
    cin >> n;
    for(auto x : n)
        sum += (x - '0');
    cout << (sum%9==0 ? "Yes" : "No") << '\n';

}

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

    int t = 1;
    while(t--) {
      solve();
    }

    return 0;
}

Measured memory_bytes: 50604
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>
#include <cmath>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep01(i, n) for(int i = 0; i < (n) + 1; i++)
#define rep10(i, n) for(int i = 1; i < (n); i++)
#define rep11(i, n) for(int i = 1; i < (n) + 1; i++)
#define all(a) (a).begin(), (a).end()
typedef long long int ll;
typedef struct { int x; int y; } Pos;
using namespace std;

//*********************
//n!
//*********************

//ABC054C
int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> A(N, vector<int>());
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        A[a-1].push_back(b-1);
        A[b-1].push_back(a-1);
    }
    vector<int> pattern;
    int cnt = 0;
    rep(i, N) pattern.push_back(i);
    do {
        if (pattern[0] != 0) continue;
        bool success = true;
        rep(i, N-1) {
            if (A[pattern[i]].end() == find(all(A[pattern[i]]), pattern[i + 1])) {
                success = false;
                break;
            }
        }
        if(success) cnt++;
    } while (next_permutation(all(pattern)));
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define INF 1000000007
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int x=tx-sx;
    int y=ty-sy;
    for(int i=0;i<x;i++)cout<<'R';
    for(int i=0;i<y;i++)cout<<'U';
    for(int i=0;i<x;i++)cout<<'L';
    for(int i=0;i<y+1;i++)cout<<'D';
    for(int i=0;i<x+1;i++)cout<<'R';
    for(int i=0;i<y+1;i++)cout<<'U';
    cout<<'L';
    cout<<'U';
    for(int i=0;i<x+1;i++)cout<<'L';
    for(int i=0;i<y+1;i++)cout<<'D';
    cout<<'R';
    cout<<endl;
    return 0;
}



Measured memory_bytes: 256
a=int(input())
def div(n):
    div=set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.add(i)
            div.add(n//i)
            if i != n // i:
                div.add(i)
    return div
s=list((div(a)|div(a-1))|div(a+1))
def x(n,k):
  if k==1:
    return False
  else:
    while n>1 and n>k-1:
      if n%k==0:
        n=n//k
      else:
        n=n%k
    if n==1:
      return True
    else:
      return False
ans=0
for i in s:
  if x(a,i):
    ans+=1
    #print(i)
  else:pass
print(ans)


Measured memory_bytes: 41572
#include<cstdio>
#include<stdio.h>
#include<cstring>
#include<iostream>

using namespace std;

int main()
{
    int i,j,t,n,a,b;
    cin>>a>>b;

    if(a>8 || b>8)
        printf(":(\n");
    else
        printf("Yay!\n");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main() {
    int n,f=0;
    scanf("%d",&n);
    while(n!=0){
        if(n%10==7){f=1;break;}
        n=n/10;
    }
    if(f==1) printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 1732
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>
#include<map>

using namespace std;

int i,j,N;

string S;

map<string,int> mp;

int main()
{
  cin >> N;
  
  for(i=0;i<N;i++)
  {
    cin >>S;
    mp[S]+=1;
    
  }
  
  i=0;
  for(auto u:mp)
  {
    i++;
  }
  cout<<i;

  
}

Measured memory_bytes: 19200
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main(){
  int n;
  map<string,long long>mp;
  cin>>n;
  for(int i=0;i<n;i++){
    string str;
    vector<int>vec;
    cin>>str;
    for(int i=0;i<str.size();i++){
      vec.push_back(str[i]);
    }
    sort(vec.begin(),vec.end());
    for(int i=0;i<str.size();i++){
      str[i]=vec[i];
    }
    
    if(mp.find(str)==mp.end()){
      mp.insert(make_pair(str,1));
    }else{
      mp[str]+=1;
    }
  }
  
  long long sum=0;
  for(map<string,long long>::iterator itr=mp.begin();itr!=mp.end();itr++){
    long long value=itr->second;
    if(value>=2){
      sum+=value*(value-1)/2;
    }
  }
  cout<<sum<<endl;
  return(0);
}

Measured memory_bytes: 11136