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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

ll MOD = 1e9+7;
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll N, K; cin >> N >> K;
	
	ll ans = 1;
	FOR(k, K, N+1) {
		// how many we take
		ll hi = 1LL * N * (N + 1) / 2 - 1LL * (N - k) * (N - k + 1) / 2;
		ll lo = 1LL * k * (k - 1) / 2;
		ans += hi - lo + 1;
		ans %= MOD;
	}
	print(ans);
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
const long long mod = 1e9 + 7 ;
const int N = 3e5+122; 

int n, m, k, t;
int a[N];
long long ans = 0;
vector<int> v[N];

int main ( ) {
	cin >> n;
	string s;
	cin>>s;
	for(int i = 1; i <= n; i++) {
		char c;
		c=s[i-1];
		v[c-'0'].push_back(i);
	}
	for(int i = 0; i <= 9; i++)
	for(int j = 0; j <= 9; j++)
	for(int k = 0; k <= 9; k++) {
		if(v[i].empty() or v[j].empty() or v[k].empty())continue;
		int p1 = v[i][0];
		int p2 = lower_bound(v[j].begin(),v[j].end(), p1+1)-v[j].begin();
		if(p2>=v[j].size())continue;
		p2=v[j][p2];
		if(j==2)
		//cout<<p2<<' '<<p1<<'x';
		if(p2<=p1)continue;
		int p3 = lower_bound(v[k].begin(),v[k].end(),p2+1)-v[k].begin();

		if(v[k].size()<=p3 or v[k][p3]<=p2) continue;
		ans++;
	}
	cout<<ans;
	return 0;

}

Measured memory_bytes: 8704
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 100010), 100010)
	sc.Scan()
	var a [2]int
	for _, v := range sc.Bytes() {
		a[v-48] += 2
	}
	if a[0] < a[1] {
		fmt.Println(a[0])
	} else {
		fmt.Println(a[1])
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<stack>
#include<cstdio>


using namespace std;

int main()
{
	char s;
	int N;
	stack<int> S1;
	stack<pair<int ,int> >S2;
	int sum = 0;
	int ans[20000];
	for (int i = 0; cin >> s; i++)
	{
		if (s =='\\')
		{
			S1.push(i);
		}                                                                                                                                                                                                                                                                                
		else if (s == '/'&&S1.size()>0)
		{
			int j = S1.top();
			S1.pop();
			int a = i-j;
			sum += a;
			while (S2.size() > 0&&j<S2.top().first)
			{
				a += S2.top().second;
				S2.pop();
			}
			S2.push(make_pair(i, a));	
		//	cout << S2.top().first <<"    " << S2.top().second << "    " <<sum<< endl;
		}
		else if (s == '\n')
		{
			break;
		}
	}
	
	N = S2.size();
	
	for (int i = 0; i < N; i++)
	{
		ans[i] = S2.top().second;
		S2.pop();
	}

	cout<<sum<<endl;
	cout << N;
	for (int i = N - 1; i >= 0; i--)
	{
		cout << ' ' << ans[i];
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 3172
#include<stdio.h>

int main(){
  int n,i,max=0,wa=0;
  scanf("%d\n",&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d\n",&a[i]);
    wa=wa+a[i];
    if(max<a[i]){
      max=a[i];
    }
  }
  printf("%d",wa-(max/2));
  return 0;
}
  

Measured memory_bytes: 128
package main

import "fmt"

func maxTwo(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func max(a ...int) int {
	result := a[0]
	for i := 1; i < len(a); i++ {
		result = maxTwo(result, a[i])
	}
	return result
}

const large = 1000000000

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	dp := make([]int, 10e5+5)
	for i := a[0]; i <= k; i++ {
		for j := 0; j < n; j++ {
			if i-a[j] >= 0 {
				dp[i] = max(
					dp[i],
					dp[i-a[j]]^1,
				)
			}
		}
	}

	if dp[k] == 1 {
		fmt.Println("First")
		return
	}

	fmt.Println("Second")
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long long int li;
const ll MAXN=5e3+51,MOD=1e9+7;
struct Edge{
	ll to,prev;
};
Edge ed[MAXN<<1];
ll nc,tot,from,to;
ll last[MAXN],sz[MAXN],f[MAXN],tmp[MAXN],dp[MAXN][MAXN];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
}
inline void addEdge(ll from,ll to)
{
	ed[++tot].prev=last[from];
	ed[tot].to=to;
	last[from]=tot;
}
inline void dfs(ll node,ll fa)
{
	ll p;
	sz[node]=dp[node][1]=1;
	for(register int i=last[node];i;i=ed[i].prev)
	{
		if(ed[i].to!=fa)
		{
			dfs(ed[i].to,node);
			for(register int j=0;j<=sz[node];j++)
			{
				tmp[j]=dp[node][j],dp[node][j]=0;
			}
			for(register int j=0;j<=sz[node];j++)
			{
				for(register int k=0;k<=sz[ed[i].to];k++)
				{
					p=(li)tmp[j]*dp[ed[i].to][k]%MOD;
					dp[node][j+k]=(dp[node][j+k]+p)%MOD;
				}
			}
			sz[node]+=sz[ed[i].to];
		}
	}
	for(register int i=0;i<=sz[node];i+=2)
	{
		dp[node][0]=(dp[node][0]+MOD-(li)dp[node][i]*f[i]%MOD)%MOD;
	}
}
int main()
{
	nc=read(),f[0]=1;
	for(register int i=0;i<nc-1;i++)
	{
		from=read(),to=read();
		addEdge(from,to),addEdge(to,from);
	}
	for(register int i=2;i<=nc;i++)
	{
		f[i]=(li)f[i-2]*(i-1)%MOD;
	}
	dfs(1,0),printf("%d\n",(MOD-dp[1][0])%MOD);
}

Measured memory_bytes: 98304
import numpy as np

n = int(input())

ans = 0
ma = np.zeros((19, 19), dtype=np.int)
for _ in range(n):
    aa = input().split('.')
    a2, a5 = 0, 0
    if len(aa) == 1:
        aaa = int(aa[0])
        a2, a5 = 9, 9
    else:
        aaa = int(aa[0]) * 10 ** 9
        aaa += int(aa[1])*10**(9-len(aa[1]))

    while aaa % 2 == 0:
        a2 += 1
        aaa = aaa // 2
    while aaa % 5 == 0:
        a5 += 1
        aaa = aaa // 5

    a2, a5 = min(a2, 18), min(a5, 18)

    oa2, oa5 = 18-a2, 18-a5
    ans += ma[oa2, oa5]

    ma[:a2+1, :a5+1] += 1

print(ans)


Measured memory_bytes: 27212
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
ll int MOD=1e9+7;
#define N 200000
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    ll int n,l,t,x[N]={},w[N]={};
    cin>>n>>l>>t;
    rep(i,n){
        scanf("%d %d",&x[i],&w[i]);
    }
    ll int y[N]={};
    rep(i,n){
        if(w[i]==1){
            y[i]=(x[i]+t)%l;
        }
        else {
            y[i]=(x[i]+l-t%l)%l;
    }
    }
    sort(y,y+n);

    ll int count=0;
    ll int flag=0;
    rep2(i,1,n-1){
        if(w[i]!=w[0]){
            if(w[0]==1){
                count+=(t*2-x[i]+x[0]+l)/l;
                if((t*2-x[i]+x[0]+l)%l==0){
                    flag=1;
                }
            }
            if(w[0]==2){
                count+=(t*2+x[i]-x[0])/l;
            }
        }
    }
    count=count%n;
    if(w[0]==2) count=(n-count)%n;
    ll int pos;
    if(w[0]==1){
        pos=(x[0]+t)%l;
    }
    else{
        pos=(x[0]+l-(t%l))%l;
    }
    ll int m;
    if(w[0]==2) m=lower_bound(y,y+n,pos)-y;
    else {
        m=lower_bound(y,y+n,pos)-y;
        if(flag) m++;
    }
    m=(m+n-count)%n;
    rep(i,n){
        printf("%d\n",y[m]);
        m++;
        if(m==n) m=0;
    }
    return 0;
    
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N;
  scanf("%d", &N);
  vector<int> dias(105, 0);
  for (int i = 0; i < N; ++i) {
    int d;
    scanf("%d", &d);
    dias[d] = 1;
  }
  int ans = count(dias.begin(), dias.end(), 1);
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    string b;
    cin >> b;
    REP(i,b.size()){
        b[i] = 'x';
    }
    println(b);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
 
// #define N 311111
#define A 1111111
#define BLOCK 555 // ~sqrt(N)
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
 
const ll INF = 1e18 +5;
const int nax = 100005;
const long M = 1000000007;
 
ll dp[1<<22];
// int in_degree[nax];
// vector<int> edges[nax];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	// cout<<fixed;
	// cout<<setprecision(10);
	int t;
	// cin>>t;
	t = 1;
	while(t--){
		int n,m;
		cin>>n;
		int arr[n][n];
		for(int i=0;i<n;i++){
		    for(int j=0;j<n;j++){
		        cin>>arr[i][j];
		    }
		}
		ll x = 1<<n;
		dp[0]=1;
        for (int i=0;i<x;i++){
            int bits = __builtin_popcount (i);
            for (int j=0;j<n;j++){
                if((i & (1<<j)) == 0 && arr[bits][j]==1){
                    dp[i | (1<<j)] +=  dp[i] ;
                    dp[i | (1<<j)] %=M;
                } 
            }                
        }
        // for(int i=0;i<x;i++){
        // 	cout<<dp[i]<<" ";
        // }
        // cout<<endl;
		cout<<dp[(1<<n)-1]<<endl;
	}
}

Measured memory_bytes: 18688
#include<bits/stdc++.h>
using namespace std;
 
 
 
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  vector<pair<int,int>> c;
  c.push_back(make_pair(v[0],1));
  for(int i=1;i<n;i++){
    int d=c.size()-1;
    if(c[d].first==v[i]){
        c[d].second++;
    }else{
      c.push_back(make_pair(v[i],1));
    }
  }


  vector<int> vals(v[n-1]+1,0);
  for(int i=0;i<c.size();i++){
    for(int j=c[i].first;j<=v[n-1];j+=c[i].first){
      vals[j]++;
    }
  }
  int ans=0;
  for(int i=0;i<c.size();i++){
    if(vals[c[i].first]==1 && c[i].second==1){
      ans++;
    }
  }
  cout<<ans<<endl;

  


  }
 
 
 
 


Measured memory_bytes: 9528
using System;

class Program
{
    static void Main()
    {
        string[] abc = Console.ReadLine().Split(' ');
        int a = int.Parse(abc[0]);
        int b = int.Parse(abc[1]);
        int c = int.Parse(abc[2]);
        int cnt = 0;

        for (int i = a; i <= b; i++) 
        {
            if (c % i == 0)
                cnt += 1;
        }
        Console.WriteLine(cnt);

    }
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
signed main(){
    gearup;
    int n; cin >> n;
    vd d(n);
    rep(i,n)cin >> d[i];
    vvd dp(n+1,vd(n+1)); //dp[i][j] i回中j回表が出る
    dp[0][0] = 1.0;
    rep(i,n){
        for(int j=0;j<=i;j++){
            dp[i+1][j+1] += dp[i][j] * d[i];
            dp[i+1][j] += dp[i][j] * (1 - d[i]);
        }
    }
    double res = 0.0;
    for(int i=(n+1)/2;i<=n;i++) res += dp[n][i];
    cout << fixed << setprecision(10);
    out(res);
}


Measured memory_bytes: 70784
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define M 100000
typedef struct node *link;
struct node{long int v; link next; link back;};
link NEW(long int v){
	link x = malloc(sizeof(*x));
	x->v = v;
	return x;
}

void traverse(link head,link end){

	link t;
	t = head->next;

	while(t != end){
		if(t->next==end) printf("%ld",t->v);
		else printf("%ld ",t->v);
		t = t->next;
	}

	printf("\n");

	return;

}

void delete_x(link x){

	x->back->next = x->next;
	x->next->back = x->back;

	return;
}

void insert(link x, link ins){

	ins->next = x->next;
	ins->back = x;
	x->next->back = ins;
	x->next = ins;

	return;
}

link search(link head, link end, long int v){
	link t =head->next;
	while(t != end){
		if(t->v==v){
			return t;
		}
		t = t->next;
	}

	return end;
}

int main(void){

	link head,end,t,a[M];
	head = NEW(-1);
	end = NEW(-1);
	head->next=end;
	end->back=head;

	char com[11];
	int i,j,n;
	long int v;
	scanf("%d",&n);


	for(i=0;i<n;i++){

		scanf("%s",com);
	
	if(strcmp(com,"insert")==0){	
	scanf("%ld",&v);
	a[j] = NEW(v);
	insert(head,a[j]);
	j++;
	}
	
	if(strcmp(com,"delete")==0){
	scanf("%ld",&v);
	t = search(head,end,v);
	if(t!=end) delete_x(t);
	}

	if(strcmp(com,"deleteFirst")==0){
	delete_x(head->next);
	}
	if(strcmp(com,"deleteLast")==0){
	delete_x(end->back);
	}

	}

	traverse(head,end);

	return 0;
}

Measured memory_bytes: 36056
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string s;
	cin >> n >> s;
	vector<int> v;
	for (char c:s)
	v.push_back(c-'0');
	for (int i=0;i<n-1;i++)
	v[i]=abs(v[i]-v[i+1]);
	v.pop_back();
	n--;
	if (count(v.begin(),v.end(),1))
	{
		for (int &i:v)
		i%=2;
	}
	for (int i=0;i<20;i++)
	{
		if ((n-1)&(1<<i))
		{
			vector<int> tmp;
			for (int j=0;j+(1<<i)<v.size();j++)
			tmp.push_back(v[j]^v[j+(1<<i)]);
			v=tmp;
		}
	}
	cout << v[0];
}

Measured memory_bytes: 13624
#include <stdio.h>

int main(void) {
  int n, m, i, j, k, ans[18];
  char t[][10] = {"Mts", "Fks", "Nyt", "Asg", "Ggs", "Gok", "Sai", "Sei", "Kan", "Ko", "Jou", "Jo", "Gai", "Kei", "Cho", "Oku", "Man", ""};
  while( 1 ) {
    for(i = 0; i < 18; ++i) ans[i] = 0;
    scanf("%d%d", &m, &n);
    if(!n) break;
    ans[17] = m;
    for(i = 1; i < n; ++i) {
      for(j = 0; j < 18; ++j) {
        ans[j] *= m;
        if(ans[j] >= 10000) ans[j - 1] += ans[j] / 10000;
        ans[j] %= 10000;
      }
    }
    for(i = 0; i < 18; ++i) if(ans[i])printf("%d%s", ans[i], t[i]);
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2724
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll h(n + 1);
    REP(i, n) cin >> h[i];

    ll res = 0;
    REP(i, n){
        while(h[i]){
            h[i]--;
            ll nxt = i + 1;
            while(h[nxt]){
                h[nxt]--;
                nxt++;
            }
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
# A, B, C = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars

n = N%10
if [2,4,5,7,9].include?(n)
  print "hon\n"
elsif [0,1,6,8].include?(n)
  print "pon\n"
else
  print "bon\n"
end
  

Measured memory_bytes: 14360
#include <bits/stdc++.h>
 
using namespace std;
 
const int INF = 1 << 29;
 
struct UnionFind
{
  vector< int > data;
 
  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }
 
  int find(int k)
  {
    return (data[k] < 0 ? k : data[k] = find(data[k]));
  }
 
  void unite(int x, int y)
  {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
  }
};
 
vector< pair< int, int > > g[100001];
vector< int > leftt[100001], rightt[100001], just[100001];
vector< int > gg[100001], rgg[100001], order;
bool v[100000];
int cmp[100000];
 
 
void dfs(int idx)
{
  if(v[idx]++) return;
  for(auto &to : gg[idx]) dfs(to);
  order.push_back(idx);
}
 
void rdfs(int idx, int k)
{
  cmp[idx] = k;
  for(auto &to : rgg[idx]) if(cmp[to] == -1) rdfs(to, k);
}
 
 
int rec(int idx, int back = -1)
{
  if(back != -1) {
    int tmp = max(leftt[idx][back], rightt[idx][back + 1]);
    if(tmp != INF) return (tmp);
  }
  if(rightt[idx][0] == INF) {
    for(int i = 0; i < g[idx].size(); i++) {
      int to, rev;
      tie(to, rev) = g[idx][i];
      if(i == back) continue;
      just[idx][i] = rec(to, rev) + 1;
    }
    for(int i = 0; i < g[idx].size(); i++) {
      leftt[idx][i + 1] = max(leftt[idx][i], just[idx][i]);
    }
    for(int i = (int) g[idx].size() - 1; i >= 0; i--) {
      rightt[idx][i] = max(rightt[idx][i + 1], just[idx][i]);
    }
  }
  if(back == -1) return (rightt[idx][0]);
  return (max(leftt[idx][back], rightt[idx][back + 1]));
}
 
 
int main()
{
  int N, M;
  vector< pair< int, int > > edges, arcs;
 
  scanf("%d %d", &N, &M);
 
  UnionFind uf(N);
 
  for(int i = 0; i < M; i++) {
    int x, y, t;
    cin >> x >> y >> t;
    --x, --y;
    if(t == 1) {
      arcs.emplace_back(x, y);
      g[x].emplace_back(y, -1);
    } else {
      if(uf.find(x) == uf.find(y)) {
        cout << "Infinite" << endl;
        return (0);
      }
      uf.unite(x, y);
      edges.emplace_back(x, y);
      g[y].emplace_back(x, g[x].size());
      g[x].emplace_back(y, g[y].size() - 1);
    }
  }
 
  {
    for(auto &e : arcs) {
      gg[uf.find(e.first)].push_back(uf.find(e.second));
      rgg[uf.find(e.second)].push_back(uf.find(e.first));
    }
    for(int i = 0; i < N; i++) dfs(i);
    reverse(begin(order), end(order));
    memset(cmp, -1, sizeof(cmp));
    int kk = 0;
    for(auto &i : order) if(cmp[i] == -1) rdfs(i, kk++);
    if(kk != N) {
      cout << "Infinite" << endl;
      return (0);
    }
  }
 
 
  int ret = 0;
  for(int i = 0; i < N; i++) {
    int sz = g[i].size();
    just[i].assign(sz, INF);
    leftt[i].assign(sz + 1, INF);
    rightt[i].assign(sz + 1, INF);
    leftt[i][0] = rightt[i][sz] = 0;
  }
  for(int i = 0; i < N; i++) ret = max(ret, rec(i));
  cout << ret << endl;
}

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

using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	int A[2 * n];
	for (int i = 0; i < 2 * n; i++) {
		scanf("%d", &A[i]);
	}
	sort(A, A + (2 * n));
	int cnt = 0;
	for (int i = 1; i < 2 * n; i += 2) {
		int x = min(A[i - 1], A[i]);
		cnt += x;
	}
	printf("%d\n", cnt);
	return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main()
{
    int N;
    vector<int> a;
    cin >> N;
    REP(i, N)
    {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    // count[0] : レート1 - 399の参加者の数, ..., count[8] : レート3200 以上の参加者の数
    int count[9] = { 0 };
    REP(i, N)
    {
        if (1 <= a[i] && a[i] <= 399) count[0]++;
        else if (400 <= a[i] && a[i] <= 799) count[1]++;
        else if (800 <= a[i] && a[i] <= 1199) count[2]++;
        else if (1200 <= a[i] && a[i] <= 1599) count[3]++;
        else if (1600 <= a[i] && a[i] <= 1999) count[4]++;
        else if (2000 <= a[i] && a[i] <= 2399) count[5]++;
        else if (2400 <= a[i] && a[i] <= 2799) count[6]++;
        else if (2800 <= a[i] && a[i] <= 3199) count[7]++;
        else count[8]++;
    }
    
    int min = 0 , max = 0;
    REP(i, 8)
    {
        if (count[i] != 0)
        {
            min++;
            max++;
        }
    }
    
    if (min == 0) 
    {
        min = 1;
    }
    max += count[8];

    cout << min << " " << max << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/**
    special:n-1相加不互质,n-1分开互质
    数目<=20000,值<=30000
**/
int n;
int main()
{
    scanf("%d",&n);
    int n3=n/3;
    int adjust=0;
    if(n==3||n==6)
    {
        if(n==3)
            printf("2 5 63\n");
        else
            printf("2 4 8 10 3 9\n");
        return 0;
    }
    if(n3>5000)
        n3=5000;
    else
    {
        if(n%3==0)
            n3-=2;
    }
    if((n-3*n3)%2==1)
        adjust=1;
    int X2=n3*3-adjust;
    int X3=n-X2;
    for(int i=1;i<=X2;i++)
        printf("%d ",i*2);
    for(int i=1;i<=X3;i++)
    {
        if(i==X3)
            printf("%d\n",(2*i-1)*3);
        else
            printf("%d ",(2*i-1)*3);
    }
}


Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
int main(void){
  long int N,min;
   scanf("%ld\n",&N);
    min=N;
  for(int a=sqrt(N);1<=a;a--){
      if(N%a==0){
        min=N/a+a-2;
        break;
      }
  }
  printf("%ld\n",min);
  return 0;
}

Measured memory_bytes: 128
import java.util.*; 
public class Main {

  public static void main(String[] args) {
  
  Scanner sc=new Scanner(System.in);
  int a[]=new int[3];
  a[0]=sc.nextInt();
  a[1]=sc.nextInt();



  System.out.println(a[0]*a[1]-(a[1]+a[0]-1));
  }
  
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

using Graph = vector<vector<int>>;
ll k;
vector<ll> ans(100010);

void dfs(const Graph &G, ll v, ll p) { 
    ll now = k-2; if(v == 0)now++;
	for (auto nv : G[v]) {
		if (nv == p)continue;
		ans[nv] = now;
		dfs(G, nv, v);
        chmin(now, max(now-1, 0LL));
	}
}


int main() {
    ll n;
    cin >> n >> k;
    Graph G(n);
    rep(i, n-1){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ll num = 1;
    ans[0] = k;
    dfs(G, 0, -1);
    rep(i, n)num = num * ans[i] % mod;
    cout << num << endl;
}

Measured memory_bytes: 11136
N=int(input())
M=10**9+7
A=[int(x) for x in input().split()]

ans=p=0
for i in range(60):
  one=sum([a>>p&1 for a in A])
  zero=N-one
  p+=1
  ans+=(one*zero)*2**i
  ans%=M
  #print(one,zero)
print(ans)

Measured memory_bytes: 51020
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////



int main() {
	ll N;
	cin >> N;

	vector<ll> A(N + 1);
	repn(i, N) cin >> A[i];

	ll S = 0;
	repn(i, N) S += A[i];

	string ans = "YES";

	if (S % (N*(N + 1) / 2) != 0) { ans= "NO"; }

	else {
		ll M = S / (N*(N + 1) / 2);

		vector<ll> dif(N + 1);
		repn(i, N - 1) { dif[i] = A[i + 1] - A[i]; }
		dif[N] = A[1] - A[N];

		repn(i, N) {
			if (dif[i]>M||(dif[i] - M) % N != 0) { ans= "NO"; }
		}
	}

	cout << ans;

	system("PAUSE");
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

bool valid(const vector<int> b, int m, int w) {
  int sum = 0;
  for (int book : b) {
    if (book > w) return false;
    if (sum + book > w) {
      sum = 0;
      --m;
    }
    sum += book;
  }
  return m > 0;
}

int main() {
  while(1){
    int m,n;
    cin>>m>>n;
    if(!m) break;
    vector<int> b(n);
    REP(i,n) cin>>b[i];
    int i = 1 << 27;
    int j = 0;
    while(i > 0) {
      if(!valid(b,m,i+j)) {
        j += i;
      }
      i/=2;
    }
    cout << (j+1) << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h> 
using namespace std;
//関数
const long INF=1000000000000000;
bool check=false;

int main(void){
    long N;
    cin>>N;
    vector<double> x(N),y(N);
    for(int i=0;i<N;i++) cin>>x.at(i)>>y.at(i);
    
    double ans=0;
    srand(time(NULL));
    for(int i=0;i<10000;i++){
        double theta=rand();
        double X=cos(theta),Y=sin(theta);
        
        double sx=0,sy=0;
        for(int j=0;j<N;j++){
            if(x.at(j)*X+y.at(j)*Y>=0){
                sx+=x.at(j);
                sy+=y.at(j);
            }
        }
        ans=max(ans,sqrt((double) (sx*sx+sy*sy)));
        
    }
    
    cout<<setprecision(20)<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

const int INF = 100000000;

class S{
public:
  int y, x, d, cost;
  S(){}
  S(int y, int x, int d, int cost) : y(y), x(x), d(d), cost(cost) {}
};

int h, w;
int map[30][30];
int cost[4];
int vis[30][30][4];
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1, 0, -1};

bool check(int y, int x){
  if(y<0 || y>=h) return false;
  if(x<0 || x>=w) return false;
  return true;
}

int solve(){
  S u, v;
  queue<S> q;
  q.push(S(0, 0, 1, 0));
  fill(vis[0][0], vis[30][0], INF);
  while(!q.empty()){
    u = q.front(); q.pop();
    if(map[u.y][u.x] != 4){
      v.d = (u.d+map[u.y][u.x])%4;
      v.y = u.y + dy[v.d];
      v.x = u.x + dx[v.d];
      v.cost = u.cost;
      if(check(v.y, v.x) && vis[v.y][v.x][v.d] > v.cost){
        vis[v.y][v.x][v.d] = v.cost;
        q.push(v);
      }
    }
    for(int i=0;i<4;i++){
      v.d = (u.d+i) % 4;
      v.y = u.y + dy[v.d];
      v.x = u.x + dx[v.d];
      v.cost = u.cost + cost[i];
      if(check(v.y, v.x) && vis[v.y][v.x][v.d] > v.cost){
        vis[v.y][v.x][v.d] = v.cost;
        q.push(v);
      }
    }
  }
  int res = INF;
  for(int i=0;i<4;i++) res = min(res, vis[h-1][w-1][i]);
  return res;
}

main(){
  while(cin >> w >> h && (h|w)){
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin >> map[i][j];
    for(int i=0;i<4;i++) cin >> cost[i];
    cout << solve() << endl;
  }
}

Measured memory_bytes: 1072
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  i64 a, b, k;
  cin >> a >> b >> k;

  i64 d = min(a, k);
  a -= d;
  k -= d;
  d = min(b, k);
  b -= d;
  k -= d;
  cout << a << ' ' << b;
}
#endif


Measured memory_bytes: 256
from sys import stdin, stdout
read = stdin.readline
write = stdout.write
flush = stdout.flush
xr = range

def main():
	n,k = map(int,read().split())
	a = sorted(list(map(int,read().split())))
	write('{}\n'.format(sum(a[:k])))

if __name__ == "__main__":
	main()

Measured memory_bytes: 66524
IDENTIFICATION DIVISION.
PROGRAM-ID. 150B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 S    PIC X(51).
01 N    PIC 9(2).
01 I    PIC 9(2).
01 CNT  PIC 9(2).
01 OUT  PIC Z9.
*>
PROCEDURE DIVISION.
  ACCEPT N.
  ACCEPT S.
  MOVE 0 TO CNT  
  MOVE 1 TO I
  PERFORM UNTIL I > N - 2
    IF (S(I:3) = 'ABC') 
      ADD 1 TO CNT
      ADD 3 TO I
    ELSE
      ADD 1 TO I
    END-IF
  END-PERFORM.
*>
  MOVE CNT TO OUT.
  DISPLAY OUT.
*>
  STOP RUN.


Measured memory_bytes: 384
import sys
from collections import defaultdict
from queue import deque
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():

    n = gete(int)
    l = list(geta(int))
    l.sort()

    l_max = 2000
    # p[k]: number of sticks with length >= k
    p = [0] * (l_max + 1)

    cur = 0
    acc = n
    for i in range(l_max + 1):
        p[i] = acc

        if cur < n and i == l[cur]:
            while cur < n and l[cur] == i:
                acc -= 1
                cur += 1

    ans = 0
    for i, a in enumerate(l):
        for b in l[i + 1:]:
            ans += p[abs(a - b) + 1] - p[a + b]

            if abs(a - b) < a:
                ans -= 1

            if abs(a - b) < b:
                ans -= 1
    print(ans // 3)


if __name__ == "__main__":
    main()

Measured memory_bytes: 41576
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
using ldb = long double;
using pa = pair < int, int >;
using vec = vector < int >;
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;
#define pb push_back
#define all(c) c.begin(),c.end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define F  first
#define S  second
#define f(i,x,n) for(int i=x;i<n;i++) 
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 5e5 + 10;
const double PI = acos(-1);
const int LINF = LLONG_MAX;
int n,a,b,c,d,sum;
string s,s1,s2,s3;
int32_t main() {
    fast();
    int n;
     cin >> n;
     vec q(n);
     int f=0;
     f(i,0,n){
     	cin >> q[i];
     	if(q[i]%2==0){
     		if(q[i]%3==0  or q[i]%5==0){

     		}
     	else{
     		f=1;
     	}
     }
     }
     if(f){
     	cout<<"DENIED\n";
     }
     else{
     	cout<<"APPROVED\n";
     }

    return 0;
}



Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    string s;
    cin >> s;

    if (s == "ABC") {
        cout << "ARC\n";
    } else {
        cout << "ABC\n";
    }

    return 0;
}

Measured memory_bytes: 3648
#057_B
n,m=map(int,input().split())
ab=[tuple(map(int,input().split())) for _ in range(n)]
cd=[tuple(map(int,input().split())) for _ in range(m)]
for i in range(n):
    a,b=ab[i]
    ans=10**9
    ans_index=-1
    for j in range(m):
        c,d=cd[j]
        if ans>abs(c-a)+abs(d-b):
            ans=abs(c-a)+abs(d-b)
            ans_index=j+1
    print(ans_index)

Measured memory_bytes: 3064
N=int(input())
A=list(map(int,input().split()))
ans=sum(A)
check=[0]*(10**5+1)
for key in A:
  check[key]+=1
Q=int(input())
for i in range(Q):
  B,C=map(int,input().split())
  if check[B]==0:
    print(ans)
  else:
    x=C-B
    ans+=check[B]*x
    print(ans)
    check[C]+=check[B]
    check[B]=0


Measured memory_bytes: 20884
// g++ -std=c++14

/*

Today might be the chance to grasp the chance to let your talent bloom.
May be tomorrow, the day after, or next year...
May be even when you are 30. I'm not sure if physique has anything to do with it
but if you think that it will never come, it probably never will.

- Tooru Oikawa.

*/


#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define endl "\n"
#define fi first
#define se second
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(c) c.begin(),c.end()
#define pii pair<int, int>

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

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template <typename T>
ostream &operator<<(ostream &out, set<T> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << (*i) << ' ';
    return out;
}
template <typename T>
ostream &operator<<(ostream &out, multiset<T> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << (*i) << ' ';
    return out;
}
template <typename T, typename V>
ostream &operator<<(ostream &out, map<T, V> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << "\n" << (i->first) <<  ":"  << (i->second);
    return out;
}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

#define int ll
int solve() {
    int x;
    cin >> x;
    int lol = x / 500;
    x -= lol * 500;
    int ans = lol * 1000;
    lol = x / 5;
    ans += lol * 5;
    cout << ans << endl;
    return 0;
}

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


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        TreeSet<Long> set = new TreeSet<>();
        for(int i = 0; i < n; i++) {
            set.add(sc.nextLong());
        }
        while(set.size() >= 2) {
            long a = set.pollFirst();
            long b = set.pollFirst();
            if(b % a > 0) {
                set.add(b % a);
            }
            set.add(a);
        }
        System.out.println(set.first());
    }
}


Measured memory_bytes: 65132
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		for(int i=0; i<n; i++) {
			int e = sc.nextInt();
			if(i%2==0) {
				q.addLast(e);
			} else {
				q.addFirst(e);
			}
		}
		Iterator iter;
		if(n%2==1) {
			iter = q.descendingIterator();
		} else {
			iter = q.iterator();
		}
		int i=1;
		while(iter.hasNext()) {
			if(i==n) {
				System.out.print(iter.next());
			} else {
				System.out.print(iter.next());
				System.out.print(" ");
			}
			i++;
		}
	}
	
	// print
	static void print(String s) {
		System.out.println(s);
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 97008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    map<int, int> m;
    ll ans = 0;

    int n;
    cin >> n;
    
    //j-i = x+y
    //-i-x = -j+y
    for (int i=0; i<n; i++) {
        int x;
        cin >> x;
        ans += m[-i+x];
        m[-i-x]++;
    }
    cout << ans << "\n";
}


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

int main(void){
    int n, r;
    while(cin >> n >> r && n && r) {
        vector<int> card(n);
        vector<int> tmp(n);
        rep(i, n) card[i] = n-i;
        rep(i, r) {
            int p, c;
            cin >> p >> c;
            rep(j, n) tmp[j] = card[j];
            rep(j, c) tmp[j] = card[p-1+j];
            rep(j, p-1) tmp[c+j] = card[j];
            rep(j, n) card[j] = tmp[j];
        }
        cout << card[0] << endl;
    }
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main(){
    gearup;
    ll a,b,c;cin>>a>>b>>c;
    rep1(i,b+1){
        if(a*i % b == c){
            out("YES");
            return 0;
        }
    }
    out("NO");
}



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

int main() {
    int L, R, d, ans = 0;
    cin >> L >> R >> d;
    for(int i = L; i <= R; i++){
        if(i % d == 0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

    cin >>n>>m;
    
    int a[m]={};

    for (int i = 0; i < n; i++){
        cin >>k;
        for (int j = 0; j < k; j++){
            cin >>aij;
            a[--aij] += 1;
        }
    }

    for (int i = 0; i < m; i++){
        if(a[i]==n)ans++;
    }
    
    

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


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char a, b;
  cin >> a >> b;
  if(a > b) cout << ">" << endl;
  if(a < b) cout << "<" << endl;
  if(a == b) cout << "=" << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll dx[]={-1,-1,-1,1,1,1,0,0};
ll dy[]={-1,0,1,-1,0,1,-1,1};
string board[60];
int main(){
  ll X,Y;
  cin>>X>>Y;
  rep(i,X) cin>>board[i];
  rep(i,X){
    rep(j,Y){
      if(board[i][j]=='.'){
        int cnt=0;
        rep(k,8){
          int x=i+dx[k];
          int y=j+dy[k];
          if(x>=0 && x<X && y>=0 && y<Y && board[x][y]=='#') cnt++;
        }
        board[i][j]='0'+cnt;
      }
    }
  }
  rep(i,X) cout<<board[i]<<endl;
}

Measured memory_bytes: 256
def main():

    N, K, S = map(int, input().split())

    if S > N-K:
        return [S] * K + [1] * (N-K)
    else:
        return [S] * K + [N+10]*(N-K)

if __name__ == '__main__':
    # print(main())
    ans = main()
    print(" ".join(map(str, ans)))

Measured memory_bytes: 12004
import java.math.BigInteger;
import java.util.*;

// ABC 57-D
// https://beta.atcoder.jp/contests/abc057/tasks/abc057_d

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int A = in.nextInt();
		int B = in.nextInt();
		
		long[] nums = new long[N];
		for (int i = 0; i < N; i++) {
			nums[i] = in.nextLong();
		}
		Arrays.sort(nums);
		
		long sum = 0;
		boolean isAllSame = true;
		
		for (int i = N - 1; i >= N - A; i--) {
			sum += nums[i];
			if (i != N - 1 && nums[i] != nums[i + 1]) {
				isAllSame = false;
			}
		}
		
		double avg = ((double) sum) / A;
		
		long lowest = nums[N - A];
		int numLowestInNums = 0;
		int numLowestInAvg = 0;
		
		for (int i = 0; i < N; i++) {
			if (nums[i] == lowest) {
				numLowestInNums++;
				if (i >= N - A) {
					numLowestInAvg++;
				}
			}
		}
		
		long count = comb(numLowestInNums, numLowestInAvg);
		
		if (isAllSame) {
			for (int i = N - A - 1; i >= N - B; i--) {
				if (nums[i] == lowest) {
					numLowestInAvg += 1;
					count += comb(numLowestInNums, numLowestInAvg);
				} else {
					break;
				}
			}
		}
		
		System.out.printf("%.6f\n", avg);
		System.out.println(count);
	}
	
	public static long comb(int n, int r) {
		long v = 1;
		
		for (int i = 0; i < r; i++) {
			v *= n - i;
			v /= (i + 1);
		}
		
		return v;
	}
}

Measured memory_bytes: 23124