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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){

int N, T;
cin >> N >> T;

vector<int> t(N);
REP(i, N) cin >> t[i];
int ans = T;
for(int i = 1; i < N; i++){
	int d = abs(t.at(i - 1) - t.at(i));
	if(T > d) ans += d;
	else ans += T;
}

print(ans);


}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>P;
map<P,int>mp;
int main(){
    int n;
    cin>>n;
    while(n--){
        int cnt2=0,cnt5=0;
        ld x;
        cin>>x;
        ll t=llround(x*1000000000);
        while(t%2==0)t/=2,cnt2++;
        while(t%5==0)t/=5,cnt5++;
        mp[make_pair(cnt2,cnt5)]++;
    }
    ll ans=1;
    for(auto&v:mp){
        for(auto&u:mp){
            if(v.first.first+u.first.first>=18&&v.first.second+u.first.second>=18){
                if(v==u){
                    ans+=1ll*v.second*(v.second-1);
                }
                else ans+=1ll*v.second*u.second;
            }
        }
    }
    cout<<ans/2<<endl;
    return 0;
}

Measured memory_bytes: 3760
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        boolean flg = false;
        double price;
        price = N/1.08;
        for(int i = 0; i < 50000; i++){
            if(Math.floor(i*1.08) == N){
                System.out.println(i);
                flg = false;
                break;
            }else{
                flg = true;
                continue;
            }
        }
        if(flg){
            System.out.println(":(");
        }
        }
    }

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

long long gcd(long long a,long long b){
    //if(b == 0) return a;
    //return gcd(b,a%b);
    return b ? gcd(b,a%b) : a;
}

vector<pair<long long,int>> factorize(long long n){
    vector<pair<long long,int>> res;
    for (long long i = 2; i*i <= n;++i){
        //if(n%i != 0)continue;
        if(n%i)continue;
        res.emplace_back(i,0);
        while(n%i == 0){
            n/=i;
            res.back().second++;
        }
    }
    if(n!= 1)res.emplace_back(n,1);
    return res;
}


int main() {
    //input
    long long a, b;
    cin >> a;
    cin >> b;
    //
    long long g = gcd(a,b);
    auto f = factorize(g);
    int ans = f.size()+1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
long long mod = 1e9+7;
long long dp[1000+3][24];
int main(){
#ifdef LOCAL
	freopen("input.txt","r",stdin);
#endif
   int n, m;
  cin >> n >> m;
  if(m<n)
    cout << "No";
    else
    {
        cout << "Yes";
    }
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#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;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    string S; cin >> S;

    ll c = 0;
    rep(i,N) if (S[i]=='1') c++;

    vector<int> A(N);
    rep(i,N) {
        int K = i;
        while (K) {
            A[i]++;
            int k = popcount(K);
            K = K%k;
        }
    }

    vector<ll> bekip(N+1,1),bekim(N+1,1);
    ll p = 0, q = 0;
    rep(i,N) {
        bekip[i+1] = bekip[i]*2;
        bekip[i+1] %= (c+1);
    }
    if (c != 1) {
        rep(i,N) {
            bekim[i+1] = bekim[i]*2;
            bekim[i+1] %= (c-1);
        }
    }
    reverse(all(S));
    rep(i,N) {
        if (S[i]=='1') {
            p += bekip[i];
            p %= (c+1);
            if (c != 1) {
                q += bekim[i];
                q %= (c-1);
            }
        }
    }

    vector<int> ans(N);
    rep(i,N) {
        if (S[i]=='1') {
            if (c==1) continue;
            ll val = q - bekim[i];
            if (val < 0) val += c-1;
            val %= (c-1);
            ans[i] = A[val]+1;
        } else {
            ll val = p + bekip[i];
            val %= (c+1);
            ans[i] = A[val]+1;
        }
    }

    reverse(all(ans));
    rep(i,N) cout << ans[i] << ln;
}

Measured memory_bytes: 8356
#include <iostream>
#include <vector>
using namespace std;
 
int main(){
  int A, B;
  cin >> A >> B;

  if( A + B ==5 ){
    cout << 1 << endl;
  }
  if( A + B ==4 ){
    cout << 2 << endl;
  }
  if( A + B== 3 ){
    cout << 3 << endl;
  }
}

Measured memory_bytes: 256
#include <vector>
#include <string>
#include <iostream>
//#include <algorithm>
using namespace std;

int main(void)
{
	int row, column;
	int fillRow, fillColumn;

	cin >> row >> column >> fillRow >> fillColumn;

	int resultValue = 0;
	for (int i = 1; i <= row; ++i)
	{
		for (int j = 1; j <= column; ++j)
		{
			if (i > fillRow && j > fillColumn)
			{
				++resultValue;
			}
		}
	}

	cout << resultValue << endl;
	return 0;
}

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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

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

ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}

int main()
{
  ll A[3];
  cin >> A[0] >> A[1] >> A[2];
  rep(i,0,3){
    if (A[i] == A[(i+1)%3])
    {
      cout << A[(i+2)%3] << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		long ans = Integer.MAX_VALUE;
		for (int i = a[0]; i <= a[n - 1]; i++) {
			long sum = 0;
			for (int j = 0; j < a.length; j++) {
				sum += Math.pow((i - a[j]), 2);
			}
			ans = Math.min(ans, sum);
		}
		System.out.println(ans);
	}
}




Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


vector<vector<int>> C;

void comb_init(int N){
  C = vector<vector<int>>(N+1, vector<int>(N+1));
  REP(i, N+1) REP(j, i+1){
    if(j == 0 || j == i) C[i][j] = 1;
    else C[i][j] = C[i-1][j-1]+C[i-1][j];
  }
}

int comb(int n, int r){
  return C[n][r];
}

signed main() {
  int N, A, B; 
  cin >> N >> A >> B;

  vector<int> v(N);
  REP(i, N) cin >> v[i];

  map<int, int> m;
  REP(i, N) m[v[i]]++;

  sort(ALL(v));
  v.resize(unique(ALL(v))-v.begin());
  reverse(ALL(v));

  comb_init(51);

  int cnt = 0;
  int sum = 0;
  int ans = 1;
  bool first = true;
  REP(i, v.size()){
    if(cnt+m[v[i]] < A){
      cnt += m[v[i]];
      sum += v[i]*m[v[i]];
      first = false;
    }else{
      int req = A-cnt;
      sum += v[i]*req;

      if(first){
        ans = 0;
        FOR(j, A-cnt, min(m[v[i]], B-cnt)+1){
          ans += comb(m[v[i]], j);
        }
      }else ans = comb(m[v[i]], A-cnt);
      break;
    }
  }

  cout << 1.0*sum/A << "\n";
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <queue>
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(){
    ll n; cin>>n;
    if(n%2==0){
        cout<<(n-2)/2<<endl;
    }else{
        cout<<(n-1)/2<<endl;
    }
}

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

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<P> doll;
		for(int i = 0; i < n; ++i)
		{
			int h, r;
			cin >> h >> r;
			doll.push_back(P(h, r));
		}
		int m;
		cin >> m;
		for(int i = 0; i < m; ++i)
		{
			int h, r;
			cin >> h >> r;
			doll.push_back(P(h, r));
		}
		sort(doll.begin(), doll.end());
		int N = doll.size();
		vector<int> dp(N, 1);
		int ans = 1;
		for(int i = 0; i < N; ++i)
		{
			for(int j = 0; j < i; ++j)
			{
				if(doll[j].first < doll[i].first && doll[j].second < doll[i].second)
				{
					dp[i] = max(dp[i], dp[j] + 1);
				}
			}
			ans = max(ans, dp[i]);
		}
		cout << ans << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

int N,C,K;
priority_queue<int, vector<int> , greater<int> > Q;
int main(){
  cin>>N>>C>>K;
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    Q.push(x);
  }
  int ans=0;
  int last=-1;
  while(!Q.empty()){
    ans++;
    last=Q.top()+K;
    //    cout<<last<<endl;
    
    int cnt=0;
    while(!Q.empty()){
      int x=Q.top();
      if(x<=last){
        Q.pop();
        cnt++;
        if(cnt==C)break;
      }else break;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;



void solve(){
	ll a,b;
	cin>>a>>b;
	for(int i=1;;i++)
		if(i*2/25==a && i/10==b)
		{cout<<i<<"\n";break;}
		else if(i*2/25>a) {cout<<-1;break;}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	//ll t;cin>>t;while(t--)
	solve();

}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int A[20];
    int B[20];
    int C[19];
    int N;
    int i;
    int sum = 0;
    int index;
    
    scanf( "%d", &N );
    
    if( N<=20 )
    {
        for(i=0; i<N; i++)
        {
            scanf( "%d", &A[i]);
        }
        for(i=0; i<N; i++)
        {
            scanf( "%d", &B[i]);
        }
        for(i=0; i<N-1; i++)
        {
            scanf( "%d", &C[i]);
        }
    }
    
    
    for(i=0; i<N; i++)
    {
        index = A[i]-1;
        sum = sum + B[index];
        
        if( A[i] == (A[i+1]-1) )
        {
            sum = sum + C[index];
        }
    }
    
    printf( "%d",sum );
    return(0);
}


Measured memory_bytes: 128
<?php
fscanf(STDIN, '%d', $count);
$nums = explode(' ', trim(fgets(STDIN)));
$ans = 0;
for ($i=1; $i < $count-1; $i++) { 
    $tmp = [$nums[$i-1], $nums[$i], $nums[$i+1]];
    sort($tmp);
    if ($tmp[1] === $nums[$i]) {
        $ans++;
    }
}
echo $ans."\n";

Measured memory_bytes: 4728
#include<stdio.h>
int main ()
{
int a[200010];
 int ans[200010];
 int n;
 scanf("%d",&n);
 for(int i=2;i<=n;i++)
 {
 scanf("%d",&a[i]);}
 for(int i=2;i<=n;i++)
 {
 ans[a[i]]++;}
 for(int i=1;i<=n;i++)
 {
 printf("%d\n",ans[i]);}
 return 0;
 }

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  
  for (int i=0; i<N; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  
  int S=0;
  for (int i=0; i<N; i++) {
    S += pow(-1, i) * a.at(i);
  }
  cout << abs(S) << endl;
}

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

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

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

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m;
int msk[55];

vector < int > pth;
vector < pair<int,int> > g[55];
bool found = 0;

bool path (int a, int b, int pr = -1) {
	if (a == b) return 1;

	for (auto e : g[a]) {
		int c, d;
		tie(c, d) = e;

		if (c != pr && path(c, b, a)) {
			pth.pb(d);
			return 1;
		}
	}

	return 0;
}

void add (int &a, int b) {
	a += b;
	if (a >= mod) a -= mod;
}


ll dp[(1 << 20)];

int main () {
	SpeedForce;
	cin >> n;
	for (int i = 1; i < n; ++i) {
		int l, r;
		cin >> l >> r;
		g[l].pb({r, i});
		g[r].pb({l, i});
	}
	cin >> m; 
	for (int i = 0; i < m; ++i) {
		int u, v;
		cin >> u >> v;
		
		found = 0;
		path(u, v);

		for (auto it : pth) {
			msk[it] |= (1 << i);
		}
		pth.clear();
	}

	dp[0] = 1;

	for (int i = 1; i < n; i ++) {
		for (int j = (1 << m) - 1; j >= 0; --j) {
			dp[j | msk[i]] += dp[j];
		}
	}

	cout << dp[(1 << m) - 1] << '\n';
	
	return Accepted;
}

// B...a

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, int b, int _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

// 0 indexed
int n;
int bit[1000010];
void add(int a, int w) {
  for (int x = a; x < n; x |= x + 1) bit[x] += w;
}
int sum(int a) { // [0, a)
  int ret = 0;
  for (int x = a - 1; x >= 0; x = (x & (x + 1)) - 1) {
    ret += bit[x];
  }
  return ret;
}

int invnum(vector<pii> v) {
  // 自分より手前の大きい数の数
  // 大きい数から埋めていく
  sort(all(v), greater<pii>());

  int cnt = 0;
  rep(i, n) {
    add(v[i].S, 1);
    // cout << "s " << sum(v[i].S + 1) << endl;
    if (sum(v[i].S + 1) == v[i].S + 1) {
      cnt++;
      // cout << i << endl;
    }
  }
  return cnt;
}

void solve() {
  cin >> n;
  vector<int> a(n);
  cin >> a;

  vector<pii> b(n);
  rep(i, n) b[i] = pii(a[i], i);
  cout << invnum(b) << endl;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  in6 n;
  cin >> n;
  in6 order = 0;
  in6 copy = n;
  while(copy > 0) {
    order++;
    copy -= pow(26,order);
  }
  repa(i,1,order) {
    n -= pow(26,i-1);
  }
  vi ans(order,1);
  ans[0] = 0;
  rep(i,ans.size()) {
    ans[i] += n / pow(26,order-1);
    in6 poww = pow(26,order-1);
    n %= poww;
    order--;
  }
  rep(i,ans.size()) {
    char c = ans[i] + 96;
    cout << c;
  }
  hinata;
}

Measured memory_bytes: 4052
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    int n, m, x, a[max];
    int asum=0, bsum=0;
    
    scanf("%d%d%d", &n, &m, &x);
    rep(i, m){
        scanf("%d", &a[i]);
    }
    
    rep(i, m){
        if (a[i]<x) {
            asum++;
        } else {
            bsum++;
        }
    }
    
    printf("%d", (int)fmin(asum, bsum));
    
    return 0;
}


Measured memory_bytes: 2120
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int h = sc.nextInt();
    int w = sc.nextInt();
    String a[] = new String[h+2];
    String b = "";

    for (int j = 0; j < w+2; j++) {
      b += "#";
    }

    for (int i = 0; i < h+2; i++) {
      if (i == 0 || i == h+1) {
        a[i] = b;
      } else {
        a[i] = "#" + sc.next() + "#";
      }
    }

    for (int i = 0; i < (h+2); i++) {
      System.out.println(a[i]);
    }
  }  
}


Measured memory_bytes: 21844
#ANS-2
input_all = input()
input_N = input_all.split()[0] #str型で読み込む
A,B = int(input_all.split()[1]),int(input_all.split()[2]) #int型で読み込む

count = 0
for i in range(int(input_N)+1):
    sum_all = 0
    i_str = str(i)
    for j in range(len(i_str)):
        sum_all += int(i_str[j])
    if A<=sum_all:
        if sum_all<=B:
            count += i
print(count)

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main() {
	int n;
	int cnt_1 = 0, cnt_2 = 0, cnt_4 = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a % 4 == 0)cnt_4++;
		else if (a % 2 == 0)cnt_2++;
		else cnt_1++;
	}

	if (cnt_2 > 0)cnt_2 = 1;
	if (cnt_1 == n) {
		cout << "No" << endl;
	}
	else if (cnt_1 == 0 && cnt_4 == 0) {
		cout << "Yes" << endl;
	}
	else if (cnt_4 == n) {
		cout << "Yes" << endl;
	}
	else if (cnt_1 == 0) {
		cout << "Yes" << endl;
	}
	else if (cnt_2 == 0) {
		if (cnt_1 <= cnt_4 + 1)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else if (cnt_4 == 0) {
		cout << "No" << endl;
	}
	else {
		if (cnt_1 <= cnt_4)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		long[] arr = new long[n+5];
		long ans = 0;
		for(int i=1;i<=n;i++) {
			arr[i]=sc.nextInt();
		}
		int r=0;
		long minAns=1000000000l;
		for(int i=1;i+k-1<=n;i++) {
			r=i+k-1;
			ans =  arr[r]-arr[i]+Math.min(Math.abs(arr[i]), Math.abs(arr[r]));
			if(ans<minAns) {
				minAns=ans;
			}
		}
		System.out.println(minAns);
	}
}


Measured memory_bytes: 62012
#include  <iostream>
#include  <string>
#include  <cstdlib>

bool solve(void);


int main(void)
{
	bool ans;
	ans = solve();

	std::cout << (ans == true ? "Yes" : "No") << std::endl;

	
	return EXIT_SUCCESS;
}

bool solve(void)
{
	std::string N;
	std::cin >> N;

	unsigned long long sum = 0;
	for(char n : N)
		sum += (n - '0');

	bool ans;
	ans = (sum % 9 == 0);

	return ans;
}
	


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

#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

#define vc vector<char>
#define vvc vector<vc>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvvll vector<vvll>
#define vs vector<str>
#define vvs vector<vs>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vpll vector<pll>
#define vvpll vector<vpll>
#define vb vector<bool>
#define vvb vector<vb>
#define rep(i, a, b) for (int i = (a); i < int(b); i++)
#define repi(i, a, b) for (int i = (a); i <= int(b); i++)


using namespace std;
ll INF = LONG_LONG_MAX;
ll mod = 1000000000 + 7;

template <typename T, typename L>
void read(vector<T> & _data, L & _size, bool _shift) {
    _data.resize(_size + (ll)_shift);
    for (ll i = (ll)_shift; i < _size + (ll)_shift; i++)
        cin >> _data[i];
}

template <typename T, typename L>
void read(vector<vector<T>> & _data, L & _rows, L & _cols, bool _shiftRows, bool _shiftCols) {
    _data.resize(_rows + (ll)_shiftRows);
    for (ll i = 0; i < _rows + (ll)_shiftRows; i++)
        _data[i].resize(_cols + (ll)_shiftCols);
    for (ll i = (ll)_shiftRows; i < _rows + (ll)_shiftRows; i++)
        for (ll j = (ll)_shiftCols; j < _cols + (ll)_shiftCols; j++)
            cin >> _data[i][j];
}

template <typename T>
void write(vector<T> & _data, bool _shift) {
    for (ll i = (ll)_shift; i < _data.size(); i++)
        cout << _data[i] << " ";
    cout << endl;
}


//TODO: SOLUTION


void solve() {
    ll r, c, k; cin >> r >> c >> k;
    vector<vvll> dp(r, vvll(c, vll(4, 0)));

    vvll shop(r, vll(c, 0));
    rep(i, 0, k) {
        int u, v, w;
        cin >> u >> v >> w;
        shop[u-1][v-1] = w;
    }

    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {

            for (int s = 0; s < 4; s++) {
                dp[i][j][s] = shop[i][j] * (s > 0);
                if (j > 0)
                    dp[i][j][s] = max(dp[i][j-1][s], dp[i][j-1][(s-1) * (s > 0)] + shop[i][j] * (s > 0));
                if (i > 0)
                    dp[i][j][s] = max(dp[i][j][s], dp[i-1][j][3] + shop[i][j] * (s > 0));
            }
        }
    }

    cout << dp[r-1][c-1][3] << endl;
}


int main() {

    // TODO: Set value of this variable manually
    bool _multipleTestCases = false;

    if (_multipleTestCases) {
        ll t; cin >> t;
        while (t--)
            solve();
    }
    else {
        solve();
    }

    return 0;
}

Measured memory_bytes: 706444
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(int i=0; i<9; ++i){
        string s;
        int a, b;
        cin >> s >> a >> b;
        cout << s << ' ' << (a+b) << ' ' << (200*a+300*b) << endl;
    }
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  
  for(int i = 0; i<n; i++)
    cin >> a.at(i);
  
  sort(a.begin(), a.end());
  
  cout << a.back() - a.at(0) << endl;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int heights[n];
    for (int i = 0; i < n; i++) {
        cin >> heights[i];
    }
    if (n == 1) {
        cout << "Yes";
        return 0;
    }
    for (int i = n - 2; i >= 0; i--) {
        if (heights[i] - 1 > heights[i + 1]) {
            cout << "No";
            return 0;
        } else if (heights[i] - 1 == heights[i + 1]) {
            heights[i]--;
        }
    }
    //Check if valid
    for (int i = 0; i < n - 1; i++) {
        if (heights[i] > heights[i + 1]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


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

#define ll long long
#define mp make_pair
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)

using namespace std;

typedef pair<int, int> pii;
typedef double db;
const int N = 1e6 + 50;
int a, b, ans;
inline int read(){
	int x = 0, f = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar();}
	while(ch >='0' && ch <='9') { x = (x<<3)+(x<<1)+(ch^48); ch = getchar();}
	return x*f;
}
void init(){
	a = read(); b = read();
	ans = a-2*b;
	printf("%d\n", ans < 0 ? 0 : ans);
}
int main(){
//	freopen("input.in","r",stdin);
//	freopen("output.out","w",stdout);
	init(); 
	return 0;
}


Measured memory_bytes: 256
import java.util.*

/**
 * 行列.
 */
data class Matrix(val elements: List<List<Int>>) {
    /**
     * 行数.
     */
    val row = this.elements.size
    /**
     * 列数.
     */
    val col = if (this.row > 0) this.elements[0].size else 0

    /**
     * 指定された行列の要素を返します.
     * @param row 行
     * @param col 列
     * @return 要素
     */
    fun get(row: Int, col: Int) = this.elements.get(row).get(col)

    /**
     * 行列の掛け算の結果を返します.
     * @param other 乗数の行列
     */
    fun times(other: Matrix): Matrix = Matrix(
        elements.map { e ->
            (0..other.col - 1).map { col ->
                e.foldIndexed(0, {row, acc, a -> acc + a * other.get(row, col)})
            }
        }
    )

    override fun toString(): String =
        this.elements.map { it.joinToString(" ") }.joinToString("\n")
}

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val m = scanner.nextInt()
    val A = Matrix((1..n).map {
        (1..m).map { scanner.nextInt() }
    })
    val b = Matrix((1..m).map {
        listOf(scanner.nextInt())
    })
    println(A.times(b))
}


Measured memory_bytes: 46072
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>

using namespace std;
using ll = long long;
const int INF = 999999999;

int main() {
    string S;
    cin >> S;
    ll ans = 0;
    for (int s = 0; s < (1 << (S.size() - 1)); ++s) {
        string now;
        now = "";
        now += S[0];
        for (int i = 0; i < S.size() - 1; ++i) {
            if (s & (1 << i)) now += "+";
            now += S[i + 1];
        }
        ll sum = 0;
        int pos = 0;
        while (now.find('+', pos) != string::npos) {
            int nextpos = now.find('+', pos);
            sum += stoll(now.substr(pos, nextpos - pos));
            pos = nextpos + 1;
        }
        sum += stoll(now.substr(pos));
        ans += sum;
    }
    cout << ans << endl;
}

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

#define F first
#define S second
#define pb push_back
#define endl '\n'

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int N = 1e3 + 10;

int n, m, k;

string e(int x, int sz) {
	//cout << "HELLO\n";
	string s = "";
	while(x >= 1) {
		if ( x % 2 )
			s += '1';
		else
			s += '0';
		x /= 2;
	}
	string ad(sz - s.size(), '0');
	reverse(s.begin(), s.end());
	ad += s;
	return ad;
}

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

	cin >> n >> m >> k;
	char ch[n][m];
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> ch[i][j];
		}
	}

	for (int i = 0; i < (1 << n); ++i) {
		for (int j = 0; j < (1 << m); ++j) {
			//cout << "HELLO\n";
			int cnt = 0;
			string a = e(i, n);
			string b = e(j, m);
			// cout << a << " " << b << endl;
			//cout << "HELLO\n";
			for (int x = 0; x < n; ++x) {
				for (int y = 0; y < m; ++y) {
					if ( a[x] == '0' and b[y] == '0' and ch[x][y] == '#' )
						++cnt;
				}
			}

			if ( cnt == k )
				++ans;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

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

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

int N;
int P[11];
int ans = 0;

int main(){
	
	cin>>N;
	REP( i, N ) cin>>P[i];
	
	sort( P, P+N );
	
	REP( i, N ){
		if( i == N-1 ) ans += P[i]/2;
		else{		ans += P[i];}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define K 1000
#define M 1000000
using namespace std;

int main(){
	int i, j, n, pnum[M]={0}, cnt=0;
	bool notp[M]={true, true, 0};
	i=2;
	j=0;
	while(j<K){
		for(j=i*i;j<M;j+=i){
			notp[j] = true;
		}
		for(j=i+1;j<=K;j++){
			if(notp[j] == false){
				i=j;
				break;
			}
		}
	}
	for(i=0;i<M;i++){
		if(!notp[i]) cnt++;
		pnum[i]=cnt;
	}
	while(cin>>n){
		cout << pnum[n] <<endl;
	}
	return 0;
}

Measured memory_bytes: 6048
#ifndef TEMPLATE
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif
#define mp make_pair
#define sz(a) ((int)(a).size())
#define mem(x,v) memset((x),(v),sizeof((x)));
#define A(x) (x).begin(),(x).end()
#define re(i,n) for(int i=0;i<(int)n;i++)
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define erp(i,k,n) for(int i=n;i>=k;i--)
#define input(v,n) re(i,n)cin>>v[i]
using vi = vector<int>;
using vpi = vector<pair<int,int>>;
using vvi = vector<vi>;
using tp = tuple<int,int,int>;
using pi = pair<int,int>;

const int nax = 1e5+7;
const int mod = 1e9+7; //1e9+2667 :: 0xcf : inf, 0xc0 -inf
const int inf = numeric_limits<int> :: max() - (int)9e6;
#endif
// ===================== MANASH =================== //

int n;

void test() {

      int k; cin >> n >> k; 
      vi vec(n); input(vec,n);
      bool dp[k+1]; mem(dp,0);
      sort(A(vec));
      for( int stones = 1; stones <= k; stones++) {
            for( int i = 0; i < n and vec[i] <= stones; i++) {
                  dp[stones] |= !dp[stones-vec[i]];
            }
      }
      cout << (dp[k] ? "First" : "Second");
}

signed main() {

      ios_base :: sync_with_stdio(false);
      cin.tie(NULL);
      #ifdef LOCAL
      freopen("input.txt","r",stdin);
      #endif
      int T = 1;
      //cin >> T;
      for( int tt = 1; tt <= T; tt++) {
            //cout << "Case #" << tt << " ";
            test();
            cout << "\n";
      }
      return 0;

}

Measured memory_bytes: 3728
#include "stdio.h"
#define NUMBER 100
int main(void){
int n,i,tmp;
int a[NUMBER];
scanf("%d",&n);
for(i=0;i<n;i++){
if(i==n-1){
scanf("%d",&a[i]);
}else{
scanf("%d ",&a[i]);
}
}
for(i=0;i<n/2;i++){
tmp=a[i];                                                                      
a[i]=a[n-i-1];
a[n-i-1]=tmp;
}
for(i=0;i<n;i++){
if(i==n-1){
printf("%d",a[i]);
}else{
printf("%d ",a[i]);
}
}
puts("");
return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  if (2 * k > n + 1) {
    return cout << -1 << '\n', 0;
  }
  int n0 = (n + 1) / 2;
  for (int i = 0; i < n0; ++i) {
    cout << k + i << ' ' << k + 2 * n - n0 + i << ' ' << k + 2 * n + 2 * i << '\n';
  }
  for (int i = n0; i < n; ++i) {
    cout << k + i << ' ' << k + n + i - n0 << ' ' << k + 2 * n + 2 * (i - n0) + 1 << '\n';
  }
}

Measured memory_bytes: 2304
<?php

fscanf(STDIN, '%d', $count);
$numbers = explode(" ", trim(fgets(STDIN)));
$exchangeCount = 0;

for($i = 0; $i < $count; $i++){
  $min = $i;
  for($j = $i + 1; $j < $count; $j++){
    if($numbers[$min] > $numbers[$j]){
      $min = $j;
    }
  }
  if($i != $min){
    $tmp = $numbers[$min];
    $numbers[$min] = $numbers[$i];
    $numbers[$i] = $tmp;
    $exchangeCount++;
  }
}

echo implode(" ", $numbers) . PHP_EOL;
echo $exchangeCount . PHP_EOL;


Measured memory_bytes: 9256
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = myconv(next(),4);
  var N = one[0];
  var M = one[1];
  var list = new Array(N);
  for(var i = 0; i < N; i++){
    list[i] = new Array();
  }
  for(var i = 0; i < M; i++){
    var tmp = myconv(next(),4);
    list[tmp[0] - 1].push(tmp[1] - 1);
    list[tmp[1] - 1].push(tmp[0] - 1);
  }
  var output = 0;
  dfs(0, new Set([0]));
  myout(output);
  function dfs(parent, set){
    if(set.size == N){
       output++;
      myerr("末端についたよ");
      return;
    }
    for(var i = 0; i < list[parent].length; i++){
      myerr("次にみる子要素:" + list[parent][i] + ",通過済み:" + set.size);
      //if(list[parent][i] == parent){continue;}
      if(!set.has(list[parent][i])){
         var tmpSet = new Set(Array.from(set));
         tmpSet.add(list[parent][i]);
        myerr("通過" + tmpSet.size);
         dfs(list[parent][i],tmpSet);
      }
    }
  }
}

Measured memory_bytes: 12068
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const ll INF = 1000000000;
//const ll MOD = 1000000007;
const ld PI = (acos(-1));
using Graph = vector<vector<int>>;
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;}
typedef pair<int, int> P;
double rad(double a) {return a * 180 / PI;}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//dpTable
int dp[100050];

int main(){
    int N,M = 0;
    cin >> N;
    vector<int> a(200050,0);
    for (int i = 1; i <= N; i++) cin >> a.at(i);
    vector<int> acnt(200050,0);
    for (int i = N; i > 0; i--) {
        int cnt = 0;
        for (int j = i; j <= N; j += i) {
            cnt += acnt.at(j);
        }
        if (!(cnt % 2 == a.at(i))) {
            acnt.at(i) = 1;
            M++;
        }
    }
    cout << M << endl;
    for (int i = 1; i <= N; i++) {
        if (acnt.at(i) == 1) {
            cout << i << ' ';
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4848
N,M,Q=map(int,input().split())
Train=[[int(i) for i in input().split()] for i in range(M)]
Map=[[0]*(N+1) for i in range(N+1)]
for i in Train:
  x,y=i[0],i[1]
  Map[y][x]+=1
for a in range(1,N+1):
  for b in range(1,N+1):
    if b<=N-1:
      Map[a][b+1]=Map[a][b]+Map[a][b+1]
    if a>=2:
      Map[a][b]=Map[a-1][b]+Map[a][b]
for i in range(Q):
  p,q=map(int,input().split())
  print(Map[q][q]-Map[q][p-1]-Map[p-1][q]+Map[p-1][p-1])

  


    

Measured memory_bytes: 43264
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;


// calc nCk mod p, O(n + log p)
// 1. init(n, p)
// 2. use mod_nck(n, k, p) 
const int MAX_N = 200000;
ll fact[MAX_N + 1], fact_inv[MAX_N + 1];

ll mod_pow(ll x, ll n, ll p) {
  if(n == 0) return 1;
  ll res = mod_pow(x * x % p, n / 2, p);
  if(n & 1) res = res * x % p;
  return res;
}

void init(ll n, ll p) {
  fact[0] = 1;
  for(int i = 0; i < n; i++) {
    fact[i + 1] = fact[i] * (i + 1) % p;
  }
  fact_inv[n] = mod_pow(fact[n], p - 2, p);
  for(int i = n - 1; i >= 0; i--) {
    fact_inv[i] = fact_inv[i + 1] * (i + 1) % p;
  }
}

ll mod_nck(ll n, ll k, ll p) {
  if(n < k) return 0;
  return (fact[n] * fact_inv[k]) % p * fact_inv[n-k] % p;
}

ll N, A, B, C;

int main(){
  cin >> N >> A >> B >> C;
  init(2 * N, MOD);
  ll ans = 0;
  for(ll n = N; n < 2 * N; n++) {
    ans += n * mod_nck(n - 1, N - 1, MOD) % MOD 
    * mod_pow(A * mod_pow(A + B, MOD - 2, MOD) % MOD, N, MOD) % MOD 
    * mod_pow(B * mod_pow(A + B, MOD - 2, MOD) % MOD, n - N, MOD) % MOD;
    ans %= MOD;
    ans += 
      n * mod_nck(n - 1, N - 1, MOD) % MOD 
        * mod_pow(B * mod_pow(A + B, MOD - 2, MOD) % MOD, N, MOD) % MOD 
        * mod_pow(A * mod_pow(A + B, MOD - 2, MOD) % MOD, n - N, MOD) % MOD;
    ans %= MOD;
  }

  if(C != 0) {
    ans = ans * 100 % MOD * mod_pow((100 - C), MOD - 2, MOD) % MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 100;

int n,m,q;
int a[maxn],b[maxn],c[maxn],d[maxn];

int ans = 0;

void solve(int x, vector <int> v) {
	//cout << x << "\n";
	if (x == n+1) {
		//cout << x << "\n";
		//for (auto i: v) cout << i << " ";
		//cout << "\n";
		int res = 0;
		for (int i =0;i<q;i++) {
			if (v[b[i]] - v[a[i]] == c[i]) res += d[i];
		}
		ans = max(ans,res);
		return;
	}
	
	for (int i = (v.empty() ? 1 : v.back()); i <= m; i++) {
		vector <int> vv = v;
		vv.push_back(i);
		solve(x+1,vv);
	}
	
}


int32_t main() {
	FAST	
	cin >> n >> m >> q;
	for (int i =0;i<q;i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--; b[i]--;
	}
	
	vector <int> vv;
	solve(1,vv);
	cout << ans;
}



Measured memory_bytes: 3676
// #pragma GCC optimize("03")
#include <bits/stdc++.h>
#define ll long long 
#define fi first
#define se second
#define mod 1000000007

using namespace std;

int n;
ll memo[3010][3010]; 
ll dp[3010];     
ll a[3010];
ll s;

ll getsum(int l, int r) {
    return dp[r] - dp[l - 1];
}

int main() {    
    // ifstream cin("tst.in");
    // ofstream cout("tst.out");
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    cin >> n;  
    for (int i = 1; i <= n; i++)
        cin >> a[i], dp[i] = a[i] + dp[i - 1]; 

    for (int i = 1; i <= n; i++)
        memo[i][i] = a[i];

    for (int len = 2; len <= n; len++)
        for (int i = 1; i + len - 1 <= n; i++) {
            int st = i;
            int dr = i + len - 1;
            memo[st][dr] = max(a[st] + getsum(st + 1, dr) - memo[st + 1][dr], a[dr] + getsum(st, dr - 1) - memo[st][dr - 1]);
        }

    cout << 2 * memo[1][n] - getsum(1, n);

    return 0;
}

Measured memory_bytes: 70016
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(){
    int N,W,i,j;
    scanf("%d%d",&N,&W);
    long int w[N+1],v[N+1],dp[N+1][W+1];
    
    for(i=1;i<=N;i++){
        scanf("%ld%ld",w+i,v+i);
    }
    for(i=0;i<=W;i++){
        dp[0][i]=0;
    }
    for(i=0;i<=N;i++){
        dp[i][0]=0;
    }
    for(i=1;i<=N;i++){
        for(j=1;j<=W;j++){
            dp[i][j]=(j-w[i]<0)? dp[i-1][j] : max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
        }
    }
    printf("%ld\n",dp[N][W]);
    return 0;
}


Measured memory_bytes: 79104
#include <iostream>
using namespace std;
int main(){
  string s;cin>>s;
  for(int i = 0; s.size() > i; i++){
    if(s.substr(i,5) == "dream"){
      if(i+5 == s.size()){
        break;
      }
      if(s[i+5] == 'd'){
        i+=4;
      }else if(s.substr(i,7) == "dreamer"){
        if(i+7 == s.size()){
          break;
        }
        if(s[i+7] == 'a'){
          i+=4;
        }else if(s[i+7] == 'e' || s[i+7] == 'd'){
          i+=6;
        }else{
          cout << "NO" << endl;
          return 0;
        }
      }else{
        cout << "NO" << endl;
        return 0;
      }
    }else if(s.substr(i,5) == "erase"){
      if(i+5 == s.size()){
        break;
      }
      if(s[i+5] == 'r'){
        i+=5;
      }else if(s[i+5] == 'd' ||s[i+5] == 'e' ){
        i+=4;
      }else{
        cout << "NO" << endl;
        return 0;
      }
    }else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vote(N);
  int count = 0, sum = 0;
  
  for(int i = 0; i < N; i++) {
    cin >> vote.at(i);
    sum += vote.at(i);
  }
  
  for(int i = 0; i < N; i++) {
    if(vote.at(i) * 4 * M >= sum) {
      count++;
    }
  }
  
  if(count >= M) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
  
  int age;
  
  cin >> age;
  
  if (age == 1) {
    cout << "Hello World" << endl;
  } else {
    int a,b;
    cin >> a;
    cin >> b;
    cout << a+b << endl;
  }
        return 0;


  
}

Measured memory_bytes: 256
time = [int(input()) for i in range(5)]
total = 0
min = 10
index = 0

for i in range(5):
    if (min > time[i] % 10 and time[i] % 10 != 0):
        min = time[i] % 10
        index = i
if min < 10:
    max = time[index]
    time.pop(index)

for i in range(len(time)):
    while total % 10 != 0:
        total += 1
    total += time[i]

if min < 10:
    while total % 10 != 0:
        total += 1
    total += max

print(total)


Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
  int n;
  int b,f,r,v;
  int kousya[4][4][10];


  for(int i=0; i<4; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<10; k++){
          kousya[i][j][k] = 0;
        }
      }
    }

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

  for(int i=0; i<n; i++){
    scanf("%d %d %d %d\n",&b,&f,&r,&v);

    if(kousya[b-1][f-1][r-1] + v <= 9 && kousya[b-1][f-1][r-1] + v >= 0){
      kousya[b-1][f-1][r-1] += v;
    }
  }

  for(int i=0; i<4; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<10; k++){
        printf(" %d",kousya[i][j][k]);
      }
      printf("\n");
    }
    if(i != 3){
      printf("####################\n");
    }
  }

  return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
using ll = long long int;
const ll maxs = 1e5+5;
const ll mod = 1e9+7;

ll grid[1002][1002];
char inp[1002][1002];

ll add(ll & a,ll & b) {
	return (a + b)%mod;
}

int main()
{
	int H,W;
	cin >> H >> W;
	
	for(int i=0;i<H;i++) {
		for(int j=0;j<W;j++) {
			cin >> inp[i][j];
		}
	}
	
	if(inp[H-1][W-1] != '#')
		grid[H-1][W-1] = 1;
	
	for(int i=H-1;i>=0;i--) {
		for(int j=W-1;j>=0;j--) {
			if(inp[i][j] != '#') {
				grid[i][j] = (grid[i][j] + add(grid[i+1][j], grid[i][j+1]))%mod;
			}
		}
	}
	
	cout << grid[0][0];
}


Measured memory_bytes: 9088