akhauriyash/Code-Regression huggingface dataset:
use proconio::{input, fastout};

const MOD: usize = 1_000_000_007;

#[fastout]
fn main() {
    input! {
        n: usize,
    }

    if n == 1 {
        println!("0");
        return;
    }

    let mut ans = 1;

    for _ in 0..n {
        ans *= 10;
        ans %= MOD;
    }

    let mut eight = 1;
    for _ in 0..n {
        eight *= 8;
        eight %= MOD;
    }
    ans += eight;
    ans %= MOD;

    let mut nine = 1;
    for _ in 0..n {
        nine *= 9;
        nine %= MOD;
    }
    nine *= 2;
    nine %= MOD;

    ans += MOD;
    ans -= nine;
    ans %= MOD;

    println!("{}", ans);
}


Measured memory_bytes: 2176
N,T=map(int,input().split())
A=list(map(int,input().split())) # 0-indexed
B=[0 for i in range(N)] # B[i]~B[N-1]のmax
Bl=[set() for i in range(N)] # B[i]~B[N-1]のmaxとなるB[j]の添字jのリスト
B[N-1]=A[N-1]
Bl[N-1].add(N-1)
for i in range(N-2,-1,-1):
    if A[i]>B[i+1]:
        B[i]=A[i]
        Bl[i].add(i)
    elif A[i]==B[i+1]:
        B[i]=B[i+1]
        Bl[i]=Bl[i+1]+{i}
    elif A[i]<B[i+1]:
        B[i]=B[i+1]
        Bl[i]=Bl[i+1]

C=[B[i]-A[i] for i in range(N)]
'''
print(A)
print(B)
print(Bl)
print(C)
'''
Cm=max(C)
Cml=set()
for i in range(N):
    if C[i]==Cm:
        Cml.update(Bl[i])
'''
print(Cm)
print(Cml)
'''
ans=len(Cml)

print(ans)

Measured memory_bytes: 78700
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n,k;
    cin >> n >> k;
    ll a[n];
    ll b[n];
    rep(i,n)cin >> a[i] >> b[i];

    int count = 0;
    ll k_ = k;
    rep(i,30){
        if(k_ % 2 == 1)count++;
        k_ /= 2;
    }
    ll f[count + 1][30];
    rep(i,count+1){
        k_ = k;
        if(i == 0){
            rep(j,30){
                f[i][j] = k_ % 2;
                k_ /= 2;
            }
        }else{
            rep(j,30){
                f[i][j] = k_ % 2;
                k_ /= 2;
            }
            int count_ = 0;
            drep(j,30){
                if(count_ == i){
                    f[i][j] = 1;
                }else{
                    if(f[i][j] == 1){
                        count_++;
                        if(count_ == i){
                            f[i][j] = 0;
                        }
                    }
                }
            }
        }
    }
    ll ans[count + 1] = {};


    rep(i,n){
        rep(j,count+1){
            int flag = 0;
            ll a_ = a[i];
            rep(l,30){
                if(f[j][l] < (a_%2)){
                    flag = 1;
                    break;
                }
                a_ /= 2;
            }
            if(flag == 0){
                ans[j] += b[i];
            }
        }
    }

    ll ans2 = 0;
    rep(i,count + 1){
        ans2 = max(ans2, ans[i]);
    }
    cout << ans2 << endl;
    return 0;
}
 
 


Measured memory_bytes: 1792
N, M = map(int, input().split())
student = [list(map(int, input().split())) for i in range(N)]
checkpoint = [list(map(int, input().split())) for i in range(M)]

for i in range(N):
    count = float("inf")
    for j in range(M):
        calc = abs(student[i][0]-checkpoint[j][0]) + \
            abs(student[i][1]-checkpoint[j][1])
        if count > calc:
            count = calc
            num = j+1

    print(num)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);

int main() {
  long n,k;
  cin >> n >> k;
  if(n >= k) {
    long t = n % k;
    cout << min(t,k-t) << endl;
  }
  else {
    cout << min(n, k-n) << endl;
  }
}

Measured memory_bytes: 3640
import java.math.BigDecimal

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xu = (1..n).map { readLine()!!.split(" ") }

    val u = BigDecimal.valueOf(380000.0)

    var ans: BigDecimal = BigDecimal.ZERO
    for (l in xu) {
        if (l[1] == "JPY") {
            ans  = ans.add(BigDecimal.valueOf(l[0].toDouble()))
        } else {
            ans = ans.add(BigDecimal.valueOf(l[0].toDouble()).multiply(u))
        }
    }
    println(ans.toPlainString())
}

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

int main() {
	int n,d;
	cin>>n>>d;
	int a[n][d];
	for(int i=0;i<n;i++)
	{
	    for(int j=0;j<d;j++)
	    cin>>a[i][j];
	}
	int count=0;
	for(int j=0;j<n-1;j++)
    {
    	for(int i=j+1;i<n;i++)
    	{
    	    long double dis=0;
    	    for(int k=0;k<d;k++)
    	    {
    	        dis=dis+((a[j][k]-a[i][k])*(a[j][k]-a[i][k]));
    	    }
    	    long double t=sqrt(dis);
    	    if((t-floor(t))==0)
    	    count=count+1;
    	}
    }
	cout<<count<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline LL read(){
    LL x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-10;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 1e6+10;
const int MAXM = (int) 1e6+10;
const int sigma_size = (int) 26;

///--------------------START-------------------------
int n;
string s;
set<string> st;

void work(){
    scanf("%d",&n);
    cin>>s;
    char c;
    int ok=1;
    int len=s.length();
    c=s[len-1];
    st.insert(s);
    for(int i=1;i<n;i++){
        cin>>s;
        len=s.length();
        if(s[0]!=c) ok=0;
        if(st.count(s)) ok=0;
        st.insert(s);
        c=s[len-1];
    }
    printf("%s\n",ok ? "Yes" : "No");
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}



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

#define ll long long
#define pb push_back
#define eb emplace_back
//#define st first
#define sc second

using namespace std;

const ll mod = 1e9 + 7;
const int e = 55;
const int base = 311;

// dung inverse module de tinh nCk
// beginer 81
// mbeginer
// cach tao hoan vi tu n so : n*(n+1)/2;

//vector<pair<ll,ll>>adj[e];
//vector<ll>adj[e];

/*ll Pow(ll n, ll dem)
{
    if(dem == 0) return 1;
    if(dem == 1) return n ;
    ll t = Pow(n, dem/2);
    if(dem % 2 == 0) return (t*t);
    else return ((t * t) * n);
}*/

/*ll C(ll k, ll n)
{
    if(k == 0) return 1;
    if(n < k) return 0;
    return (gt[n]%mod * (igt[k]%mod * igt[n-k]%mod)%mod)%mod;
}*/

ll n, m, k;
ll a[e];

int main()
{
   cin >> n;
   ll maxx ;
   ll minn = 1e18;
   ll posmn, posmx;
   for(int i=1; i<=n; i++)
   {
       cin >> a[i];
       if(i == 1)
       {
           maxx = a[i];
           posmx = 1;
           continue;
       }
       if(abs(a[i]) > abs(maxx))
       {
           maxx = a[i];
           posmx = i;
       }
   }
   cout << 2*n - 1 <<"\n";
   for(int i=1; i<=n; i++)
   {
       cout << posmx <<" "<<i<<"\n";
   }
   if(maxx > 0)
   {
       for(int i=2; i<=n; i++)
       {
           cout << i-1 <<" "<<i<<"\n";
       }
   }
   else
   {
       for(int i=n; i>=2; i--)
       {
           cout << i<<" "<<i-1<<"\n";
       }
   }
}
/*

*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt" , "r" , stdin);
	// freopen("output.txt" , "w" , stdout);
	// #endif

	ll a,b,c;
	cin>>a>>b>>c;
	if(c-a-b>=0)
	{
		if(4*a*b<(c-a-b)*(c-a-b))
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	else
		cout<<"No"<<endl;

	
	
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){

	long long int N;
	while(1){
	char G[1001];
	for(int i=0;i<1000;i++)
	{
		G[i]=-1;
	}

	cin>>N;if(N==0)break;
	for(int i=0;i<N;i++){
		char x,y;
		cin>>x>>y;
		G[x]=y;

	}
	int NN;
	cin>>NN;
	for(int i=0;i<NN;i++){
		char h;
		cin>>h;
		if(G[h]==-1)cout<<h;
		else if(G[h]!=-1)cout<<G[h];
	

	}
	cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
N = int(input())
X = []
Y = []
H = []
ansx = 0
ansy = 0
ansh = 0
for _ in range(N):
    x,y,h = map(int,input().split())
    X.append(x)
    Y.append(y)
    H.append(h)

for cx in range(101):
    for cy in range(101):
        center_height = 0
        for i in range(N):
            if H[i] != 0:
                center_height = H[i] + abs(X[i]-cx) + abs(Y[i]-cy)
                break
        
        ok = True
        for i in range(N):
            if H[i] == 0 and center_height - abs(X[i]-cx) - abs(Y[i]-cy)>0:
                ok = False
            if H[i] > 0 and center_height != H[i] + abs(X[i]-cx) + abs(Y[i]-cy):
                ok = False

        if ok is True:
            ansx = str(cx)
            ansy = str(cy)
            ansh = str(center_height)


print(ansx + ' ' + ansy + ' ' + ansh)


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

vector<int> a, dp;

int rec(int M) {
    if (M < 0) return 1;
    if (dp[M] != -1) return dp[M];
    int res = 0;
    rep(i, a.size()) {
        if (!rec(M - a[i])) res = 1;
    }
    return dp[M] = res;
}

int main() {
    int N, K;
    cin >> N >> K;
    a = vector<int>(N);
    rep(i, N) cin >> a[i];
    dp = vector<int>(K + 1, -1);
    cout << (rec(K) ? "First\n" : "Second\n");
    return 0;
}


Measured memory_bytes: 6912
s = gets.chomp
t = gets.chomp
count = 0
0.upto(s.length-1) do |i|
  str = s[i,2]
  if !(t.include?(str)) then
    count += 1
  end
end
if count <= 1 then
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
import Data.List
main = do
    (n:as) <- map read . words <$> getContents :: IO [Int]
    print $ if n == 2 then maximum as - minimum as else max (solve1 as) (solve2 as)

solve1 as | odd n =  sum (map (*2) asl) + sum (map (*(-2)) ass) + m2 + m1
          | even n = sum (map (*2) asl) + sum (map (*(-2)) ass) + m2 - m1
    where n = length as
          as' = sort as
          ns = n `div` 2
          ass = take ns as'
          (m1:m2:_) = take 2 $ drop ns as'
          asl = drop (ns + 2) as'

solve2 as | odd n =  sum (map (*2) asl) + sum (map (*(-2)) ass) - m2 - m1
          | even n = sum (map (*2) asl) + sum (map (*(-2)) ass) + m2 - m1
    where n = length as
          as' = sort as
          ns = n `div` 2 - 1
          ass = take ns as'
          (m1:m2:_) = take 2 $ drop ns as'
          asl = drop (ns + 2) as'

Measured memory_bytes: 104092
#include <bits/stdc++.h>
using namespace std;
int f[101][100001],sum[100001];
int a[101];
int main()
{
	int n,k,i,j,K;
	scanf("%d %d",&n,&K);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	f[0][0]=1;
	for(i=1;i<=n;i++)
	{
		sum[0]=f[i-1][0];
		for(j=1;j<=K;j++)
			sum[j]=((long long)sum[j-1]+f[i-1][j])%1000000007;
		for(j=0;j<=K;j++)
		{
			if(j>a[i])
				f[i][j]=(sum[j]-sum[j-a[i]-1]+1000000007)%1000000007;
			else
				f[i][j]=sum[j]%1000000007;
			//printf("---%d %d %d\n",i,j,f[i][j]);
		}
	}
	//for(i=1;i<=n;i++)
	//	for(j=0;j<=K;j++)
		//	printf("%d %d %d\n",i,j,f[i][j]);
	printf("%d",f[n][K]);
	return 0;
}

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

int main(){
	int d;
	int n;
	while(cin >> d){
		int s = 0;
		n = 600 / d;
		for(int i = 0; i < n; i++){
			s += (i * d) * (i * d) * d;
		}
		cout << s << endl;
	}
	return 0;
}

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

int main(){
  ll N , D;
  cin >> N >> D;
  
  vector<ll> vecx(N), vecy(N);
  
  for (int i=0; i < N; i++){
    cin >> vecx.at(i) >> vecy.at(i);
  }
  
  int ans = 0;
  
  for (int i=0; i < N; i++){
    ll a = vecx.at(i), b = vecy.at(i);
    if (a*a + b*b <= D * D){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 6324
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int n; 
	cin >> n;

	vector<int> a(n);
	for (int &x : a) cin >> x;

	for (int i = 0; i < n / 2; i++) {
		swap(a[i], a[n -1- i]);
	}
	
	for (int i = 0; i < n; i++) {
		
		if (i == n - 1) {
			cout << a[i] << endl;
		}
		else {
			cout << a[i] << " ";
		}
	}


	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<int> w(n);
  REP(i, n) cin >> w[i];
  int sum = 0;
  REP(i, n) sum += w[i];
  int ans = 10000;
  FOR(i, 1, n) {
    int x = 0;
    FOR(j, 1, n - 1) {
      if (j > i) break;
      else x += w[j - 1];
    }
    ans = min(ans, abs(x - (sum - x)));
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main(){
 let a:i32=read();
 let b:i32=read();
 println!("{}",a-(if a>b{1}else{0}));
}

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

#define int long long 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define N 1005

const int mod =1e9+7;
int dp[N][N];
char grid[N][N];
int n,m;

int solve(){

    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++) dp[i][j]=0;
    }
    dp[1][1]=1;
    for(int i=2;i<=n;i++) {
        if(grid[i][1]=='#') break;
        dp[i][1]=dp[i-1][1];
    }
    for(int i=2;i<=m;i++){
        if(grid[1][i]=='#') break;
        dp[1][i]=dp[1][i-1];
    }
    
    for(int i=2;i<=n;i++){
        for(int j=2;j<=m;j++){
            if(grid[i][j]=='#') dp[i][j]=0;
            else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
        }
    }
    return dp[n][m];

}
int32_t main(){
    cin>>n>>m; 
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++) cin>>grid[i][j];
    }
    cout<<solve();
    

}


Measured memory_bytes: 9088
def main():
  n, m = map(int, input().split())
  shops = sorted([list(map(int, input().split())) for i in range(n)])
  
  cost = 0
  got = 0
  for shop in shops:
    if got + shop[1] <= m:
      got += shop[1]
      cost += shop[0] * shop[1]
    else:
      cost += (m - got) * shop[0]
      break
  print(cost)
  

if __name__ == '__main__':
  main()


Measured memory_bytes: 28652
# include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b ;
    cin >> a >> b;
    if(a>b){
        cout << "a > b" << endl;
    } else if(a==b){
        cout << "a == b" << endl;
    } else {
        cout << "a < b" << endl;
    }
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        string S;
        cin>>S;
        if(S=="0") break;
        int sum=0;
        int n;
        n=S.size();
        for(int i=0;i<n;i++){
            int num;
            num=S[i]-'0';
            sum+=num;
        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 3220
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		 int N = scan.nextInt();
		String S ;
		int AC=0;
		int WA=0;
		int TLE=0;
		int RE=0;

		for(int i=0; i<N; i++) {
			S= scan.next();
			if(S.equals("AC")) {
				AC++;
			}else if(S.equals("WA")) {
				WA++;
			}else if(S.equals("TLE")) {
				TLE++;
			}else {
				RE++;
			}
 
		}
		System.out.println("AC x "+AC);
		System.out.println("WA x "+WA);
		System.out.println("TLE x "+TLE);
		System.out.println("RE x "+RE);
	}

}


Measured memory_bytes: 58528
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double PI = 3.14159265358979323846;

int main(void) {
  ll n;
  cin >> n;
  vector<ll> f(n + 1, 0);
  for (ll x = 1; x * x <= 2 * n; x++) {
    for (ll y = 1; y * y <= 2 * n; y++) {
      for (ll z = 1; z * z <= 2 * n; z++) {
        ll val = (x + y + z) * (x + y + z) + x * x + y * y + z * z;
        // if (val == 2 * n) f[n]++;
        if (val % 2 == 0 && val / 2 <= n) {
          f[val / 2]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << f[i] << endl;
  return 0;
}

Measured memory_bytes: 3500
#include<stdio.h>
#define YOSHI 100
#define WHITE 1
#define GRAY 2
#define BLACK 3
#define NIL -1

int M[YOSHI][YOSHI],a[YOSHI],b[YOSHI],n;
int queue[YOSHI],head = 0,tail = 0;

int deq(){
    head++;
    if(head == YOSHI){
        head = 0;
        return queue[YOSHI - 1];
    }
    return queue[head - 1];
}
void enq(int u){
    queue[tail++] = u;
    if(tail == YOSHI) tail = 0;
}

void bfs(){
    int i,u = 0;
    for(i = 0;i < n;i++){
        a[i] = WHITE;
        b[i] = NIL;
    }
    b[u] = 0;
    a[u] = GRAY;
    enq(u);
    
    while(head != tail){
        u = deq();
        for(i = 0;i < n;i++){
            if(M[u][i] == 1 && a[i] == WHITE){
                enq(i);
                a[i] = GRAY;
                b[i] = b[u] + 1;
            }
        }
        a[u] = BLACK;
    }
}

int main(){
    int i,j,u,k,l;
    scanf("%d",&n);
    
    for(i = 0;i < n;i++){
        for(j = 0;j < n;j++){
            M[i][j] = 0;
        }
    }
    for(i = 0;i < n;i++){
        scanf("%d",&u);
        scanf("%d",&k);
        for(j = 0;j < k;j++){
            scanf("%d",&l);
            M[u - 1][l - 1] = 1;
        }
    }
    bfs();
    
    for(i = 0;i < n;i++) printf("%d %d\n",i + 1,b[i]);
    return 0;
}


Measured memory_bytes: 2112
a,b=map(int,input().split())
s=str(input())
for i in range(a+b+1):
    if i!=a:
        if s[i] not in '1234567890':
            print('No')
            break
    else:
        if s[i]!='-':
            print('No')
            break
else:
    print('Yes')
            

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, l;
    cin >> n >> l;
    string*a=new string[n];
    for (int i=0; i<n; i++)
        cin>>a[i];
    sort(a,a+n);
    for (int i=0; i<n; i++)
        cout<<a[i];
    return 0;
}

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

#define ll long long

int main(){

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false); 

	string s, t;
	cin >> s;
	cin >> t;
	bool ok = true;
	for (int i = 0; i < s.size(); i++){
		if (s[i] != t[i]){
			ok = false;
		}
	}

	if (ok){
		cout << "Yes";
	} else {
		cout << "No";
	}




}

Measured memory_bytes: 3620
#include<stdio.h>

#define NIL -1

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j, e, sum,min,length;
  int key[MAX],pass[MAX],pi[MAX],M[MAX][MAX];

  scanf("%d", &n);

  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }

  for(i=0;i<n;i++){
    key[i]=INFTY;
    pi[i]=NIL; 
    pass[i] = 0;
  }
  key[0]=0;

  while(length!=NIL){
    min=INFTY;
    length=NIL;
    for(i=0;i<n;i++){
      if(key[i]<min && pass[i]!=1){
      length=i;
      min=key[i];
      }
    }
    pass[length]=1;
    for(i=0;i<n;i++){
      if(key[i] >= M[length][i] && pass[i]!=1){
	key[i] = M[length][i];
	pi[i] = length; 
      }
    }
  }
  
  sum = 0;

  for ( i = 0; i < n; i++ ){
    if ( pi[i] != -1 ) sum += M[i][pi[i]];
  }

  printf("%d\n", sum);

  return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


int P;
int ans[3030];//Σans[i]*x^i

__inline int power(int a, int b, int p) {
    int res = 1;
    while (b) {
        if (b & 1) {
            res *= a;
            res %= p;
        }
        b >>= 1;
        a *= a;
        a %= p;
    }
    return res;
}

int fac[3030];
int fac_inv[3030];

void calc(int p) {
    fac[0] = 1;
    fac_inv[0] = 1;
    for (int i = 1; i < 3030; ++i) {
        fac[i] = fac[i - 1] * i;
        fac[i] %= p;
        fac_inv[i] = power(fac[i], p - 2, p);
    }
}

__inline int Comb(int n, int r, int p) {
    return fac[n] * fac_inv[r] * fac_inv[n - r];
}

signed main() {
    cin >> P;
    calc(P);
    rep(i, P) {
        int a;
        cin >> a;
        if (a == 0)continue;
        ans[0] += 1;
        for (int j = 0; j < P; ++j) {
            ans[j] -= Comb(P - 1, j, P) * power(P - i, P - 1 - j, P);
            ans[j] %= P;
        }
    }
    rep(i, P) {
        ans[i] = ans[i] < 0 ? ans[i] + P : ans[i];
        if (i)cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()

//Union-Find木(ランク有り)
struct UnionFind{
private:
	vector<int> parent;
	vector<int> rank;
public:
	void init(int N){ //初期化する O(N)
		parent.clear();
		rank.clear();
		for(int i=0; i<N; i++) parent.push_back(i);
		for(int i=0; i<N; i++) rank.push_back(0);
	}
	int root(int a){ //親を返す O(log N)
		if(parent[a] == a) return a;
		return parent[a] = root(parent[a]);
	}
	void unite(int a, int b){ //木を併合する O(log N)
		int rootA = root(a);
		int rootB = root(b);
		if(rootA == rootB) return;
		if(rank[rootA] < rank[rootB]) parent[rootA] = rootB;
		else{
			parent[rootB] = rootA;
			if(rank[rootA] == rank[rootB]) rank[rootA]++;
		}
	}
	bool same(int a, int b){ //属する木が同じかを返す O(log N)
		return root(a) == root(b);
	}
};

int main(){
	
	int N,Q;
	cin >> N >> Q;
	UnionFind uf;
	uf.init(N);
	for(int i=0; i<Q; i++){
		int c,x,y;
		cin >> c >> x >> y;
		if(c == 0) uf.unite(x,y);
		else cout << (int)uf.same(x,y) << endl;
	}

	return 0;
}




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

int main() {
	int N;
	cin >> N;
  vector<string> W(N);
  rep(i,N) cin >> W[i];

  char before = W[0][0];
  rep(i,N){
    if(before == W[i][0]){
      before = W[i][W[i].size()-1];
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  sort(all(W));
  rep(i,N-1){
    if(W[i] == W[i+1]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

int main()
{
    int counter = 0;
    string str;
    cin >> str;
    for(int i = 0;i < str.size();++i){
        if(str.at(i) == 'o'){
        ++counter;
        }
    }
    int a;
    a = 15 - str.size();
    if(counter >= 8 || counter + a >= 8){
        cout << "YES" << endl;
    }
    else{
    cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cstring>
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
long long k,ans,a[111111],b[111111],ff[44],k1,qq,ta,ta1;
int n,u;
int main()
{
    scanf("%d%lld",&n,&k);
    ans=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld%lld",&a[i],&b[i]);
        if((a[i]|k)==k) ans+=b[i];
    }
    k1=k;
    u=0;
    while(k1!=0)
    {
        u++;
        ff[u]=k1%2;
        k1/=2;
    }
    for(int i=u;i>0;i--)
    {
        if(ff[i]==1)
        {
            qq=0;
            ta1=ta*2;
            for(int j=1;j<i;j++)
                ta1=ta1*2+1;
            for(int j=1;j<=n;j++)
            {
                if((a[j]|ta1)==ta1) qq+=b[j];
            }
            if(qq>ans) ans=qq;
            ta=ta*2+1;
        }
        else ta*=2;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;


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

    int a,b,t;

    cin >> a >> b >> t;

    cout << (t/a)*b << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void ppp(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(int n,int k){
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
int main(void){
  int n,m;
  scanf("%d %d",&n,&m);
  char s[2][4]={"No","Yes"};
  PRS(s[n==m]);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    int i, n, k, *h_n, cnt;
    cin >> n >> k;
    cnt = 0;
    h_n = new int[n];

    for(i = 0; i < n; i++){
        cin >> h_n[i];
        if(h_n[i] >= k){
            cnt++;
        }
    }
    cout << cnt << endl;

}

Measured memory_bytes: 640
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        int N = cin.ni();
        int K = cin.ni();
        int X = cin.ni();
        int Y = cin.ni();

        Console.WriteLine(Math.Min(K, N) * X + Math.Max((N - K), 0) * Y);
    }
}


public class cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }

    public static int ni() {
        return int.Parse(next());
    }

    public static long nextLong() {
        return long.Parse(next());
    }

    public static double nextDouble() {
        return double.Parse(next());
    }

}


Measured memory_bytes: 2648
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)

using namespace std;

const ll sz=1e5+5;
const ll szz=1e6+6;
const ll mod=1e9+7;

int main()
{
	Ryuga;

	
	clock_t startTime=clock();

	ll a,b;
	cin>>a>>b;
	cout<<a*b;

	cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

Measured memory_bytes: 3760
import sys
input = sys.stdin.readline
H, W, K = map(int, input().split())
mod = 10 ** 9 + 7
dp = [[0] * W for _ in range(H + 1)]
dp[0][0] = 1
for i in range(H):
  for j in range(W):
    for b in range(pow(2, W - 1)):
      f = 0
      t = 0
      bb = []
      for k in range(W - 2, -1, -1):
        bb.append(int(b >= pow(2, k)))
        if b >= pow(2, k): b -= pow(2, k)
      for k in range(len(bb) - 1):
        if bb[k] and (bb[k + 1]):
          f = 1
          break
      if f: continue
      #print(bb, i)
      if j > 0:
        if bb[j - 1]:
          dp[i + 1][j - 1] += dp[i][j]
          dp[i + 1][j - 1] %= mod
          f = 1
      if j < W - 1:
        if bb[j]:
          dp[i + 1][j + 1] += dp[i][j]
          dp[i + 1][j + 1] %= mod
          f = 1
      if f == 0:
        dp[i + 1][j] += dp[i][j]
        dp[i + 1][j] %= mod
print(dp[-1][K - 1])

Measured memory_bytes: 49132
/*
 *
 * Author: r3gz3n
 * 
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define rep(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)


#define endl '\n'


class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
		int n, k, x, y;
        double p, ans = 0;
        in >> n >> k;
        int m = min(n+1, k);
        rep(i, 1, m, 1) {
            x = i;
            y = 0;
            p = 1;
            while (x < k) x <<= 1, y++;
            while (y--) p /= 2;
            ans += p;
        }
        if (n >= k) ans += n-k+1;
        ans /= n;
        out << ans << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define MAX 100000
int A[MAX];
signed main(){
    int n; cin >> n;
    int even_cnt = 0;
    for(int i=0; i<n; ++i){
        cin >> A[i];
        while(A[i] % 2 == 0){
            even_cnt++;
            A[i] /= 2;
        }
    }
    cout << even_cnt << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let mut c = vec![0i64; n];
    let mut s = vec![0i64; n];
    let mut f = vec![0i64; n];
    for i in 1..n {
        c[i] = input();
        s[i] = input();
        f[i] = input();
    }

    let mut dp = vec![vec![0i64; n + 1]; n + 1];
    for i in 1..n {
        for j in i..n {
            dp[i][j + 1] += dp[i][j] + c[j];
            if dp[i][j] < s[j] {
                dp[i][j + 1] += s[j] - dp[i][j];
            } else if dp[i][j] % f[j] > 0 {
                dp[i][j + 1] += f[j] - dp[i][j] % f[j];
            }
        }
    }

    for i in 1..n + 1 {
        println!("{}", dp[i][n]);
    }
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if (a<b) swap (a,b);
	if (a<c) swap (a,c);
	if (b<c) swap (b,c);
	cout<<(a-b)+(b-c);
	return 0; 
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - ATCoder
            string s = Console.ReadLine();
            var acgts = new List<string>();

            for(int i = 0; i < s.Length; i++)
            {
                int j = 1;
                
                while(i + j <= s.Length)
                {
                    var substring = s.Substring(i, j);
                    
                    if(IsAcgt(substring))
                    {
                        acgts.Add(substring);
                    }
                    
                    j++;
                }
            }

            int max = GetMaxLength(acgts);
            Console.WriteLine(max);
        }
        
        static int GetMaxLength(List<string> acgts)
        {
            int max = 0;
            
            foreach(var s in acgts)
            {
                if(s.Length > max)
                {
                    max = s.Length;    
                }
            }
            
            return max;
        }
        
        static bool IsAcgt(string substring)
        {
            var acgt = new char[] { 'A', 'C', 'G', 'T' };
            
            foreach(var c in substring)
            {
                if(!acgt.Contains(c))
                {
                    return false;    
                }    
            }
            
            return true;
        }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
using I = long long;
int main() {
  int N;
  cin >> N;
  vector<I> A(N);
  for(auto& i: A) cin >> i, i*=2;
  sort(begin(A), end(A));
  auto m = A.back()/2;
  auto d = A.back();
  I r = 0;
  for(auto a: A) {
    if(abs(a-m)<d) {
      d = abs(a-m);
      r = a;
    }
  }
  cout << A.back()/2 << " " << r/2 << endl;
}


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

public class Main {
	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = null;

		try {
			input = br.readLine();
		} catch (IOException e) {
		}
		String[] inputs = input.split(" ");
		int a = Integer.parseInt(inputs[0]);
		int b = Integer.parseInt(inputs[1]);
		
		int d = a / b;
		int r = a % b;
		double f = (double) a / b;

		System.out.printf("%d %d %f\n",d,r,f);
	}
}


Measured memory_bytes: 24804
//not answered
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#include <algorithm>
#include <cmath>

int main(){
  string s, t;
  cin >> s >> t;
  
  vector<int> s_to_t_table(30, 100);
  vector<int> t_to_s_table(30, 100);
  for(int i = 0; i < s.size(); i++){
    int t_index = t[i] - 'a';
    int s_index = s[i] - 'a';
    if(t_to_s_table[t_index] == 100)
      t_to_s_table[t_index] = s[i] - 'a';
    else{
      if(t_to_s_table[t_index] != s[i] - 'a'){
        cout << "No" << endl;
        return 0;
      }
    }
    
    if(s_to_t_table[s_index] == 100)
      s_to_t_table[s_index] = t[i] - 'a';
    else{
      if(s_to_t_table[s_index] != t[i] - 'a'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;

}

Measured memory_bytes: 776
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(50, vector<ll>(50, INF));

int main() {
	cin >> n;
	counter = 1;
	while (counter < 10000) {
		sum += counter;
		if (sum >= n) break;
		counter++;
	}
	while (n) {
		if (counter < n) {
			cout << counter << endl;
			n -= counter;
			counter--;
		}
		else {
			cout << n << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
#include<stdio.h>

typedef struct{
  char name[10];
  int time;
} Process;

#define QSIZE 100000

void enque(Process);

int head=0;
int tail=0;
Process que[QSIZE];

int main()
{
  int n, q, timer = 0, flag = 0;

  scanf("%d%d", &n, &q);

  for( tail = 0; tail < n; tail++)
    {
      scanf("%s%d", que[tail].name, &que[tail].time);
    }
  tail--;
  
  for( head = 0; flag < n; head++)
    {
      head = head % QSIZE;
      if(que[head].time - q > 0)
	{
	  que[head].time -= q;
	  enque(que[head]); 
	  timer += q;
	}
      else 
	{
	  timer += que[head].time;
	  printf("%s %d\n", que[head].name, timer);
	  flag++;
	}
    }
  
  return 0;

}

void enque(Process inque)
{
  int next = (tail+1) % QSIZE;
  
  que[next] = inque;
  tail = next;

  return;
}



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

int main()
{
    string s;
    cin >> s;
    bool ans = true;
    if(s[0] != 'A') ans = false;
    int count_c = 0;
    int index = 100;
    for(int i = 0; i < s.length(); i++){
        if(2 <= i && i <= s.length()-1-1){
            if(s[i] == 'C'){
                count_c++;
                index = i;
            }
        }
        if(i != index && i != 0){
            if('A' <= s[i] && s[i] <= 'Z'){
                ans = false;
            }
        }
    }
    if(count_c != 1) ans = false;
    if(ans) cout << "AC" << endl;
    else cout << "WA" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace C_ABC145
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            var nl = new List<int[]>();
            for(int i=0;i<s[0];i++){
                int[] n = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
                nl.Add(n);
            }

            double dist = 0;

            int ptn = 0;

            for(int i=0;i<s[0]-1;i++){
                for(int j=i+1;j<s[0];j++){
                    //WriteLine("i : {0}  j : {1} ",i,j);
                    dist+= Sqrt(Pow(Abs(nl[i][0]-nl[j][0]),2) + Pow(Abs(nl[i][1]-nl[j][1]),2));
                    ptn++;
                }
            }

            //WriteLine(ptn);

            int fac = 1;
            for(int i=1;i<=s[0];i++){
                fac = fac *i;
            }
            int tmp = fac * (s[0]-1);
            tmp = tmp/ptn;

            dist = dist * tmp;
            dist = dist/fac;
            

            WriteLine(dist);



        }
    }
}


Measured memory_bytes: 13396
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if X == 500*i + 100*j + 50*k:
        count+=1

print(count)

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


int main()
{
  uint64_t N, M;

  cin >> N >> M;
  multiset<pair<uint64_t, uint64_t> > ba;
  for (uint64_t i = 0; i < N; ++i) {
    uint64_t a, b;
    cin >> a >> b;
    ba.insert(make_pair(b, a));
  }

  uint64_t sum = 0;
  set<uint64_t> notused;
  for (uint64_t i = 0; i < M; ++i) {
    notused.insert(i+1);
  }
  for (auto itr = ba.rbegin(); itr != ba.rend(); ++itr) {
    auto g = notused.lower_bound((*itr).second);
    if (g != notused.end()) {
      sum += (*itr).first;
      notused.erase(g);
    }
  }

  cout << sum;

  return 0;
}




Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
typedef long long ll;
using namespace std;
int main()
{
	string s;
	cin >> s;
	fore(i, 0, s.size()) {
		cout << "x";
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll N,M;
	cin>>N>>M;
	ll ans = min(N,M/2LL);
	M -= 2*N;
	if(M>=4LL){ans += M/4LL;}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;int64_t N,a,b,i,V[1<<20],f[1<<20],R[1<<20];main(){for(cin>>N;i<N;cin>>a>>b,a+=1e9,R[i++]=(a<<32)+a+b);for(sort(R,R+N),b=V[N]=1;a=i--;b=V[i]=(b+V[f[i]=a])%998244353)for(;a<N&R[a]<R[i]<<32;a=f[a]);cout<<*V;}

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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define ABS(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x)))
#define MOD(x, y) ((x) % (y))
#define DIVCEIL(x, y) (((x) + ((y) - 1)) / (y))
#define DIVFLOOR(x, y) ((x) / (y))
#define DIVROUND(x, y) (MOD(x, y) * 2 >= (y) ? DIVCEIL(x, y) : DIVFLOOR(x, y))

using ll = long long;

struct Q {
  ll p;
  ll c;
};

int main() {
  ll D, G;
  cin >> D >> G;
  vector<Q> q(D);
  for (ll i{}; i < D; ++i) {
    cin >> q[i].p >> q[i].c;
  }

  ll ans{numeric_limits<ll>::max()};

  ll len{D};
  for (ll i{}; i < (1 << len); ++i) {
    ll score{G};
    ll solved{};
    set<ll> comp;
    for (ll j{}; j < len; ++j) {
      if (i & (1 << j)) {
        comp.insert(j);
      }
    }

    for (const auto& j : comp) {
      score -= q[j].p * (j + 1) * 100 + q[j].c;
      solved += q[j].p;
    }
    for (ll j{D - 1}; j >= 0 && score > 0; --j) {
      if (comp.find(j) != comp.end())
        continue;
      ll needed = min(DIVCEIL(score, (j + 1) * 100), q[j].p);
      score -= needed * (j + 1) * 100;
      solved += needed;
    }

    ans = min(ans, solved);
  }

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


Measured memory_bytes: 256
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

n = sys.stdin.buffer.readline().decode().rstrip()
for a in n:
    if a == '9':
        print(1, end='')

    if a == '1':
        print(9, end='')
print()


Measured memory_bytes: 2940
program reconciled;
uses math;
const
  md: int64 = 1000000007;
  x50000: int64 = 765302181;
  x75000: int64 = 393193551;
var
  n, m, x, i: int64;
begin
  read(n, m);
  if abs(n-m) > 1 then
  begin
    writeln(0);
    halt(0);
  end;
  if min(n, m) < 50000 then
  begin
    x := ifthen(n = m, 2, 1);
    for i := 1 to min(n, m) do
      x := ((i*i mod md)*x mod md);
    for i := min(n, m)+1 to max(n, m) do
      x := (i*x mod md);
    writeln(x);
    halt(0);
  end;
  if min(n, m) < 75000 then
  begin
    x := x50000*ifthen(n = m, 2, 1);
    for i := 50001 to min(n, m) do
      x := ((i*i mod md)*x mod md);
    for i := min(n, m)+1 to max(n, m) do
      x := (i*x mod md);
    writeln(x);
    halt(0);
  end;
  x := x75000*ifthen(n = m, 2, 1) mod md;
  for i := 75001 to min(n, m) do
    x := ((i*i mod md)*x mod md);
  for i := min(n, m)+1 to max(n, m) do
    x := (i*x mod md);
  writeln(x);
end.

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

vector<int> ansx, ansy;
vector<int> px, py;

bool search(int t, vector<int> nx, vector<int> ny){
    if(nx.size() == 8){
        ansx = nx;
        ansy = ny;
        return true;
    }
    if(t >= px.size()) return false;
    bool check = true;
    for(int i = 0; i < nx.size(); i++){
        if(ny[i] == py[t] || nx[i] == px[t] || abs(ny[i]-py[t]) == abs(nx[i]-px[t])){
            check = false;
            break;
        }
    }
    if(search(t+1, nx, ny)) return true;
    if(check){
        nx.push_back(px[t]);
        ny.push_back(py[t]);
        if(search(t+1,nx,ny)) return true;
    }
    return false;
}

int main(){
    int k;
    cin >> k;
    vector<int> qr(k), qc(k);
    for(int i = 0; i < k; i++){
        cin >> qr[i] >> qc[i];

    }

    for(int i = 0; i < 8; i++){
        for(int j = 0; j < 8; j++){
            for(int l = 0; l < k; l++){
                if(qr[l] == j || qc[l] == i || abs(qr[l]-j) == abs(qc[l]-i)) continue;    
                px.push_back(i);
                py.push_back(j);
            }
        }
    }

    if(search(0,qc,qr) == false) return 0;

    char board[8][8];
    
    for(int i = 0; i < 8; i++){
        for(int j = 0; j < 8; j++){
            board[i][j] = '.';
        }
    }
    for(int i = 0; i < ansx.size(); i++){
        board[ansx[i]][ansy[i]] = 'Q';
    }
    
    for(int i = 0; i < 8; i++){
        for(int j = 0; j < 8; j++){
            cout << board[j][i];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3204